@wandox/sdk 0.1.9 → 0.1.10
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-CEXQhpcc.cjs → arc-DpUsrtzC.cjs} +1 -1
- package/dist/{arc-CrkKpEzV.js → arc-IuyCnzNB.js} +1 -1
- package/dist/{architectureDiagram-3BPJPVTR-DSnygwas.cjs → architectureDiagram-3BPJPVTR-CFhqP0PI.cjs} +1 -1
- package/dist/{architectureDiagram-3BPJPVTR-BSjwdvh_.js → architectureDiagram-3BPJPVTR-CvKNxc0w.js} +3 -3
- package/dist/{blockDiagram-GPEHLZMM-Dg0gcO5u.cjs → blockDiagram-GPEHLZMM-Cc0CarnX.cjs} +1 -1
- package/dist/{blockDiagram-GPEHLZMM-DB-q5TT2.js → blockDiagram-GPEHLZMM-js_GcNo_.js} +3 -3
- package/dist/{c4Diagram-AAUBKEIU-Yeag5-V-.js → c4Diagram-AAUBKEIU-CaPoO4-Y.js} +2 -2
- package/dist/{c4Diagram-AAUBKEIU-CY0zj1qH.cjs → c4Diagram-AAUBKEIU-DEhO1rZd.cjs} +1 -1
- package/dist/{channel-BpESQX0T.js → channel-BwDFsXQa.js} +1 -1
- package/dist/{channel-DBC_GC4s.cjs → channel-CYkjjLHL.cjs} +1 -1
- package/dist/{chunk-2J33WTMH-DdwOYxQl.js → chunk-2J33WTMH-C20XsuMM.js} +1 -1
- package/dist/{chunk-2J33WTMH-CEaAWYsz.cjs → chunk-2J33WTMH-eHwSVkij.cjs} +1 -1
- package/dist/{chunk-4BX2VUAB-BTDWUy0a.cjs → chunk-4BX2VUAB-8xFlqQWy.cjs} +1 -1
- package/dist/{chunk-4BX2VUAB-DMgruKFc.js → chunk-4BX2VUAB-s99LSDZJ.js} +1 -1
- package/dist/{chunk-55IACEB6-DavGDw5n.js → chunk-55IACEB6-CK4l4t2z.js} +1 -1
- package/dist/{chunk-55IACEB6-DFA7qRAD.cjs → chunk-55IACEB6-Ch6BOvVx.cjs} +1 -1
- package/dist/{chunk-727SXJPM-DH6FkJCv.js → chunk-727SXJPM-BsN3_7gn.js} +5 -5
- package/dist/{chunk-727SXJPM-C5USxa4t.cjs → chunk-727SXJPM-DWV9KzGM.cjs} +1 -1
- package/dist/{chunk-AQP2D5EJ-CqYoyzwh.cjs → chunk-AQP2D5EJ-CjTVPQ8m.cjs} +1 -1
- package/dist/{chunk-AQP2D5EJ-CkH7ZasD.js → chunk-AQP2D5EJ-D3bmevZR.js} +3 -3
- package/dist/{chunk-FMBD7UC4-CmNccoIv.cjs → chunk-FMBD7UC4-Bqg5hyAO.cjs} +1 -1
- package/dist/{chunk-FMBD7UC4-DvSIcB9h.js → chunk-FMBD7UC4-CZIxWo0s.js} +1 -1
- package/dist/{chunk-ND2GUHAM--_HUg1RM.cjs → chunk-ND2GUHAM-DQTwQxf8.cjs} +1 -1
- package/dist/{chunk-ND2GUHAM-iZPos4z7.js → chunk-ND2GUHAM-DuoZbgbx.js} +1 -1
- package/dist/{chunk-QZHKN3VN-BDTXw6qa.js → chunk-QZHKN3VN-D5-U1JNX.js} +1 -1
- package/dist/{chunk-QZHKN3VN-BK2vmZ1Y.cjs → chunk-QZHKN3VN-DgaFGE9q.cjs} +1 -1
- package/dist/{classDiagram-4FO5ZUOK-wQxLzoFB.cjs → classDiagram-4FO5ZUOK-B5TE_ApM.cjs} +1 -1
- package/dist/{classDiagram-4FO5ZUOK-CdO4rVsO.js → classDiagram-4FO5ZUOK-CU6IrHYe.js} +2 -2
- package/dist/{classDiagram-v2-Q7XG4LA2-wQxLzoFB.cjs → classDiagram-v2-Q7XG4LA2-B5TE_ApM.cjs} +1 -1
- package/dist/{classDiagram-v2-Q7XG4LA2-cQTi2zHX.js → classDiagram-v2-Q7XG4LA2-DzSdT7w7.js} +2 -2
- package/dist/{cose-bilkent-S5V4N54A-BHiVobxF.cjs → cose-bilkent-S5V4N54A-CqAJ6EIs.cjs} +1 -1
- package/dist/{cose-bilkent-S5V4N54A-BYzpSwhg.js → cose-bilkent-S5V4N54A-D9nYBdw0.js} +2 -2
- package/dist/{dagre-BM42HDAG-CjmTGQmH.cjs → dagre-BM42HDAG-MarPNLQr.cjs} +1 -1
- package/dist/{dagre-BM42HDAG-CmpMrL1y.js → dagre-BM42HDAG-cE50tHcb.js} +1 -1
- package/dist/{diagram-2AECGRRQ-DbLa8xqp.js → diagram-2AECGRRQ-Clg0fT0u.js} +2 -2
- package/dist/{diagram-2AECGRRQ-CNhHONXM.cjs → diagram-2AECGRRQ-CmSIYIlg.cjs} +1 -1
- package/dist/{diagram-5GNKFQAL-BkWDpseb.js → diagram-5GNKFQAL-BJG9q479.js} +3 -3
- package/dist/{diagram-5GNKFQAL-sHLOZaF-.cjs → diagram-5GNKFQAL-BqGcQCrb.cjs} +1 -1
- package/dist/{diagram-KO2AKTUF-Bt7Whudt.js → diagram-KO2AKTUF-BiNgbjTn.js} +2 -2
- package/dist/{diagram-KO2AKTUF-C-2P0kT3.cjs → diagram-KO2AKTUF-DPnHNsIF.cjs} +1 -1
- package/dist/{diagram-LMA3HP47-dlzBngBX.js → diagram-LMA3HP47-Cqi1sLH8.js} +2 -2
- package/dist/{diagram-LMA3HP47-Cl3K9MXJ.cjs → diagram-LMA3HP47-D2UfaqXM.cjs} +1 -1
- package/dist/{diagram-OG6HWLK6-CRmlJVWR.js → diagram-OG6HWLK6-CgXtr_Q_.js} +3 -3
- package/dist/{diagram-OG6HWLK6-Hw-4Cmww.cjs → diagram-OG6HWLK6-motTi6mO.cjs} +1 -1
- package/dist/{erDiagram-TEJ5UH35-rSfVXytx.cjs → erDiagram-TEJ5UH35-B7iU-zDB.cjs} +1 -1
- package/dist/{erDiagram-TEJ5UH35-DzUXbTqw.js → erDiagram-TEJ5UH35-DqiWuCxS.js} +4 -4
- package/dist/{flowDiagram-I6XJVG4X-Q9GQDCcS.cjs → flowDiagram-I6XJVG4X-CKcqDYHM.cjs} +1 -1
- package/dist/{flowDiagram-I6XJVG4X-p-mXkhRd.js → flowDiagram-I6XJVG4X-DlvPVs0R.js} +6 -6
- package/dist/{ganttDiagram-6RSMTGT7-C_cCV-Wx.js → ganttDiagram-6RSMTGT7-1EnnA7m-.js} +3 -3
- package/dist/{ganttDiagram-6RSMTGT7-BCmNRwCE.cjs → ganttDiagram-6RSMTGT7-ClcIuOSo.cjs} +1 -1
- package/dist/{gitGraphDiagram-PVQCEYII-E_HZd6Iq.js → gitGraphDiagram-PVQCEYII-BqJNPbI4.js} +3 -3
- package/dist/{gitGraphDiagram-PVQCEYII-CTALD8Zd.cjs → gitGraphDiagram-PVQCEYII-CjEdQvpQ.cjs} +1 -1
- package/dist/{index-BT0J-f5A.js → index-B5Jz2fDr.js} +1300 -1308
- package/dist/{index-DpG5ixtP.cjs → index-DjjnqT_Q.cjs} +17 -17
- package/dist/{infoDiagram-5YYISTIA-CbTpWHXa.js → infoDiagram-5YYISTIA-BRJSXbpO.js} +1 -1
- package/dist/{infoDiagram-5YYISTIA-DWjTVl8h.cjs → infoDiagram-5YYISTIA-cPtgvX8g.cjs} +1 -1
- package/dist/{ishikawaDiagram-YF4QCWOH-D4v0AyV6.cjs → ishikawaDiagram-YF4QCWOH-BrxShM4n.cjs} +1 -1
- package/dist/{ishikawaDiagram-YF4QCWOH-fhtPBppl.js → ishikawaDiagram-YF4QCWOH-CrrrqDD1.js} +1 -1
- package/dist/{journeyDiagram-JHISSGLW-DKh6e3S_.cjs → journeyDiagram-JHISSGLW-BEN5Dqg6.cjs} +1 -1
- package/dist/{journeyDiagram-JHISSGLW-IiQvD7lP.js → journeyDiagram-JHISSGLW-BVt1g0Jv.js} +4 -4
- package/dist/{kanban-definition-UN3LZRKU-CrtXfBGf.cjs → kanban-definition-UN3LZRKU-Cqxgeg93.cjs} +1 -1
- package/dist/{kanban-definition-UN3LZRKU-DBxEzTLr.js → kanban-definition-UN3LZRKU-DjE4MdLr.js} +2 -2
- package/dist/{linear-5Qb46GpJ.cjs → linear-BDm4Ji_j.cjs} +1 -1
- package/dist/{linear-9cdQlF8N.js → linear-Bky-MqV8.js} +1 -1
- package/dist/{mermaid.core-BEoXBBmj.cjs → mermaid.core-BAGOfCjo.cjs} +3 -3
- package/dist/{mermaid.core-BPdVRFzr.js → mermaid.core-BT_EZRWl.js} +35 -35
- package/dist/{mindmap-definition-RKZ34NQL-5H8_0Oti.js → mindmap-definition-RKZ34NQL-C6F0qfJt.js} +3 -3
- package/dist/{mindmap-definition-RKZ34NQL-DBfXhPhM.cjs → mindmap-definition-RKZ34NQL-skt-AI_H.cjs} +1 -1
- package/dist/{pieDiagram-4H26LBE5-BmdLlvuq.cjs → pieDiagram-4H26LBE5-BKpdGyf0.cjs} +1 -1
- package/dist/{pieDiagram-4H26LBE5-CqubMv5-.js → pieDiagram-4H26LBE5-dhNngauC.js} +3 -3
- package/dist/{quadrantDiagram-W4KKPZXB-BSxdAZtx.js → quadrantDiagram-W4KKPZXB-BDwrp9N6.js} +2 -2
- package/dist/{quadrantDiagram-W4KKPZXB-DNM4IU3c.cjs → quadrantDiagram-W4KKPZXB-BqKIBdAI.cjs} +1 -1
- package/dist/{requirementDiagram-4Y6WPE33-BM388DDn.js → requirementDiagram-4Y6WPE33-B3ZJOM7g.js} +3 -3
- package/dist/{requirementDiagram-4Y6WPE33-iYiLl4-N.cjs → requirementDiagram-4Y6WPE33-BDhzQY_K.cjs} +1 -1
- package/dist/{sankeyDiagram-5OEKKPKP-C0bWTBA6.js → sankeyDiagram-5OEKKPKP-2jpI8GTQ.js} +1 -1
- package/dist/{sankeyDiagram-5OEKKPKP-hMdxXj14.cjs → sankeyDiagram-5OEKKPKP-C_24-RCE.cjs} +1 -1
- package/dist/{sequenceDiagram-3UESZ5HK-bT1G6F5o.js → sequenceDiagram-3UESZ5HK-BlpvmBSX.js} +3 -3
- package/dist/{sequenceDiagram-3UESZ5HK-Ch_rcgwz.cjs → sequenceDiagram-3UESZ5HK-ciRFsKyJ.cjs} +1 -1
- package/dist/{stateDiagram-AJRCARHV-BcGBAdoX.js → stateDiagram-AJRCARHV-B5XvxAxK.js} +2 -2
- package/dist/{stateDiagram-AJRCARHV-5uAyAGoR.cjs → stateDiagram-AJRCARHV-Dbb9Jrjl.cjs} +1 -1
- package/dist/{stateDiagram-v2-BHNVJYJU-Cl1eACDM.cjs → stateDiagram-v2-BHNVJYJU-8P9zZ0vB.cjs} +1 -1
- package/dist/{stateDiagram-v2-BHNVJYJU-C6G7PLrn.js → stateDiagram-v2-BHNVJYJU-BTKHrLIh.js} +2 -2
- package/dist/{timeline-definition-PNZ67QCA-C5OK61sp.js → timeline-definition-PNZ67QCA-BcvkaDtT.js} +2 -2
- package/dist/{timeline-definition-PNZ67QCA-TnZ5KXML.cjs → timeline-definition-PNZ67QCA-nOUTvVEf.cjs} +1 -1
- package/dist/{vennDiagram-CIIHVFJN-DBLwuqjG.js → vennDiagram-CIIHVFJN-B9zRtUwQ.js} +1 -1
- package/dist/{vennDiagram-CIIHVFJN-3N6f0sCH.cjs → vennDiagram-CIIHVFJN-C2_HMATe.cjs} +1 -1
- package/dist/wandox.cjs +1 -1
- package/dist/wandox.js +1 -1
- package/dist/wandox.umd.js +213 -213
- package/dist/{wardleyDiagram-YWT4CUSO-DT3sbZ97.cjs → wardleyDiagram-YWT4CUSO-BKK6Ru--.cjs} +1 -1
- package/dist/{wardleyDiagram-YWT4CUSO-DLppf8Pz.js → wardleyDiagram-YWT4CUSO-yzhrZIwO.js} +2 -2
- package/dist/{xychartDiagram-2RQKCTM6-BRiMIxxT.cjs → xychartDiagram-2RQKCTM6-BwRRptzJ.cjs} +1 -1
- package/dist/{xychartDiagram-2RQKCTM6-i1dGgNQC.js → xychartDiagram-2RQKCTM6-Cak8GEyA.js} +2 -2
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
`);return o===-1?"":i.stack.slice(o+1)})();try{if(!r.stack)r.stack=a;else if(a){const o=a.indexOf(`
|
|
23
23
|
`),s=o===-1?-1:a.indexOf(`
|
|
24
24
|
`,o+1),l=s===-1?"":a.slice(s+1);String(r.stack).endsWith(l)||(r.stack+=`
|
|
25
|
-
`+a)}}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=uv(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:a}=n;r!==void 0&&OP.assertOptions(r,{silentJSONParsing:il.transitional(il.boolean),forcedJSONParsing:il.transitional(il.boolean),clarifyTimeoutError:il.transitional(il.boolean),legacyInterceptorReqResOrdering:il.transitional(il.boolean)},!1),i!=null&&(Ge.isFunction(i)?n.paramsSerializer={serialize:i}:OP.assertOptions(i,{encode:il.function,serialize:il.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),OP.assertOptions(n,{baseUrl:il.spelling("baseURL"),withXsrfToken:il.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=a&&Ge.merge(a.common,a[n.method]);a&&Ge.forEach(["delete","get","head","post","put","patch","query","common"],h=>{delete a[h]}),n.headers=Ho.concat(o,a);const s=[];let l=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(n)===!1)return;l=l&&g.synchronous;const v=n.transitional||mG;v&&v.legacyInterceptorReqResOrdering?s.unshift(g.fulfilled,g.rejected):s.push(g.fulfilled,g.rejected)});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let u,d=0,f;if(!l){const h=[Yee.bind(this),void 0];for(h.unshift(...s),h.push(...c),f=h.length,u=Promise.resolve(n);d<f;)u=u.then(h[d++],h[d++]);return u}f=s.length;let p=n;for(;d<f;){const h=s[d++],g=s[d++];try{p=h(p)}catch(v){g.call(this,v);break}}try{u=Yee.call(this,p)}catch(h){return Promise.reject(h)}for(d=0,f=c.length;d<f;)u=u.then(c[d++],c[d++]);return u}getUri(t){t=uv(this.defaults,t);const n=L0e(t.baseURL,t.url,t.allowAbsoluteUrls);return M0e(n,t.params,t.paramsSerializer)}};Ge.forEach(["delete","get","head","options"],function(t){Wg.prototype[t]=function(n,r){return this.request(uv(r||{},{method:t,url:n,data:(r||{}).data}))}});Ge.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,o,s){return this.request(uv(s||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:o}))}}Wg.prototype[t]=n(),t!=="query"&&(Wg.prototype[t+"Form"]=n(!0))});let eze=class B0e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(i=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](i);r._listeners=null}),this.promise.then=i=>{let a;const o=new Promise(s=>{r.subscribe(s),a=s}).then(i);return o.cancel=function(){r.unsubscribe(a)},o},t(function(a,o,s){r.reason||(r.reason=new lE(a,o,s),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new B0e(function(i){t=i}),cancel:t}}};function tze(e){return function(n){return e.apply(null,n)}}function nze(e){return Ge.isObject(e)&&e.isAxiosError===!0}const mF={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(mF).forEach(([e,t])=>{mF[t]=e});function V0e(e){const t=new Wg(e),n=w0e(Wg.prototype.request,t);return Ge.extend(n,Wg.prototype,t,{allOwnKeys:!0}),Ge.extend(n,t,null,{allOwnKeys:!0}),n.create=function(i){return V0e(uv(e,i))},n}const Oi=V0e(sE);Oi.Axios=Wg;Oi.CanceledError=lE;Oi.CancelToken=eze;Oi.isCancel=D0e;Oi.VERSION=vG;Oi.toFormData=mD;Oi.AxiosError=Gt;Oi.Cancel=Oi.CanceledError;Oi.all=function(t){return Promise.all(t)};Oi.spread=tze;Oi.isAxiosError=nze;Oi.mergeConfig=uv;Oi.AxiosHeaders=Ho;Oi.formToJSON=e=>R0e(Ge.isHTMLForm(e)?new FormData(e):e);Oi.getAdapter=F0e.getAdapter;Oi.HttpStatusCode=mF;Oi.default=Oi;const{Axios:
|
|
25
|
+
`+a)}}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=uv(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:a}=n;r!==void 0&&OP.assertOptions(r,{silentJSONParsing:il.transitional(il.boolean),forcedJSONParsing:il.transitional(il.boolean),clarifyTimeoutError:il.transitional(il.boolean),legacyInterceptorReqResOrdering:il.transitional(il.boolean)},!1),i!=null&&(Ge.isFunction(i)?n.paramsSerializer={serialize:i}:OP.assertOptions(i,{encode:il.function,serialize:il.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),OP.assertOptions(n,{baseUrl:il.spelling("baseURL"),withXsrfToken:il.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=a&&Ge.merge(a.common,a[n.method]);a&&Ge.forEach(["delete","get","head","post","put","patch","query","common"],h=>{delete a[h]}),n.headers=Ho.concat(o,a);const s=[];let l=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(n)===!1)return;l=l&&g.synchronous;const v=n.transitional||mG;v&&v.legacyInterceptorReqResOrdering?s.unshift(g.fulfilled,g.rejected):s.push(g.fulfilled,g.rejected)});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let u,d=0,f;if(!l){const h=[Yee.bind(this),void 0];for(h.unshift(...s),h.push(...c),f=h.length,u=Promise.resolve(n);d<f;)u=u.then(h[d++],h[d++]);return u}f=s.length;let p=n;for(;d<f;){const h=s[d++],g=s[d++];try{p=h(p)}catch(v){g.call(this,v);break}}try{u=Yee.call(this,p)}catch(h){return Promise.reject(h)}for(d=0,f=c.length;d<f;)u=u.then(c[d++],c[d++]);return u}getUri(t){t=uv(this.defaults,t);const n=L0e(t.baseURL,t.url,t.allowAbsoluteUrls);return M0e(n,t.params,t.paramsSerializer)}};Ge.forEach(["delete","get","head","options"],function(t){Wg.prototype[t]=function(n,r){return this.request(uv(r||{},{method:t,url:n,data:(r||{}).data}))}});Ge.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,o,s){return this.request(uv(s||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:o}))}}Wg.prototype[t]=n(),t!=="query"&&(Wg.prototype[t+"Form"]=n(!0))});let eze=class B0e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(i=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](i);r._listeners=null}),this.promise.then=i=>{let a;const o=new Promise(s=>{r.subscribe(s),a=s}).then(i);return o.cancel=function(){r.unsubscribe(a)},o},t(function(a,o,s){r.reason||(r.reason=new lE(a,o,s),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new B0e(function(i){t=i}),cancel:t}}};function tze(e){return function(n){return e.apply(null,n)}}function nze(e){return Ge.isObject(e)&&e.isAxiosError===!0}const mF={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(mF).forEach(([e,t])=>{mF[t]=e});function V0e(e){const t=new Wg(e),n=w0e(Wg.prototype.request,t);return Ge.extend(n,Wg.prototype,t,{allOwnKeys:!0}),Ge.extend(n,t,null,{allOwnKeys:!0}),n.create=function(i){return V0e(uv(e,i))},n}const Oi=V0e(sE);Oi.Axios=Wg;Oi.CanceledError=lE;Oi.CancelToken=eze;Oi.isCancel=D0e;Oi.VERSION=vG;Oi.toFormData=mD;Oi.AxiosError=Gt;Oi.Cancel=Oi.CanceledError;Oi.all=function(t){return Promise.all(t)};Oi.spread=tze;Oi.isAxiosError=nze;Oi.mergeConfig=uv;Oi.AxiosHeaders=Ho;Oi.formToJSON=e=>R0e(Ge.isHTMLForm(e)?new FormData(e):e);Oi.getAdapter=F0e.getAdapter;Oi.HttpStatusCode=mF;Oi.default=Oi;const{Axios:Onn,AxiosError:Lnn,CanceledError:jnn,isCancel:znn,CancelToken:Fnn,VERSION:Bnn,all:Vnn,Cancel:Hnn,isAxiosError:Wnn,spread:Unn,toFormData:Gnn,AxiosHeaders:qnn,HttpStatusCode:Knn,formToJSON:Ynn,getAdapter:Xnn,mergeConfig:Znn,create:Qnn}=Oi,Zee={prod:{baseURL:"https://ai-api.wandox.com",openapiURL:"https://ai-api.wandox.com/openapi.json"},test:{baseURL:"https://test-ai-api.wandox.com",openapiURL:"https://test-ai-api.wandox.com/openapi.json"}},vD={token:"sso_token",tenantId:"sso_company",domain:"sso_domain",username:"sso_username",userId:"sso_user_id"},Qee=["/api/v1/auth/login","/api/v1/auth/dingtalk/callback"],rze={java:41,php:401},ize=e=>{const t=new FileReader;return t.readAsText(e),new Promise((n,r)=>{t.onload=i=>{const a=i.target.result;try{const o=JSON.parse(a);r(o)}catch{n(e)}},t.onerror=()=>{r({success:!1,message:"下载出错",code:0})}})};function aze(){var e;return typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:Nj&&Nj.tagName.toUpperCase()==="SCRIPT"&&Nj.src||new URL("index-DjjnqT_Q.cjs",document.baseURI).href}<"u"?"prod":typeof process<"u"&&((e=process.env)!=null&&e.VITE_WANDOX_ENV)?process.env.VITE_WANDOX_ENV:"test"}function Gi(){var t;const e=aze();return((t=Zee[e])==null?void 0:t.baseURL)||Zee.test.baseURL}function H0e(){return typeof localStorage>"u"?null:localStorage.getItem(vD.token)}function oze(){return typeof localStorage>"u"?null:localStorage.getItem(vD.tenantId)}function sze(){return typeof localStorage>"u"?null:localStorage.getItem(vD.domain)}function lze(e){if(!e)return!1;try{const t=new URL(e,"http://localhost").pathname;return Qee.includes(t)}catch{return Qee.includes(e.split("?")[0])}}function cze(e,t){return t&&!lze(e)}let Jee=!1;function uze(){if(!(typeof localStorage>"u"))for(const e of Object.values(vD))localStorage.removeItem(e)}function dze(e){return Object.values(rze).some(t=>String(e)===String(t))}function ete(e){if(typeof window>"u")return!1;const t=!!H0e();return!cze(e,t)||Jee?!1:(Jee=!0,uze(),window.location.replace("/"),!0)}const QN=Oi.create({baseURL:Gi(),timeout:3e5,responseType:"json"});QN.interceptors.request.use(e=>{const t=H0e(),n=oze(),r=sze();return t&&(e.headers.Authorization=`Bearer ${t}`),n&&(e.headers["X-Tenant-ID"]=n),r&&(e.headers["X-Domain"]=r),e});QN.interceptors.response.use(e=>{var n,r;const t=(n=e==null?void 0:e.data)==null?void 0:n.code;return dze(t)?(ete((r=e==null?void 0:e.config)==null?void 0:r.url),Promise.reject(e)):e},async e=>{var i,a;const t=e.response;if((t==null?void 0:t.status)===401)return ete(((i=t==null?void 0:t.config)==null?void 0:i.url)||((a=e==null?void 0:e.config)==null?void 0:a.url)),Promise.reject(t);if((t==null?void 0:t.status)===403||(t==null?void 0:t.status)===500||(t==null?void 0:t.status)===503)return Promise.reject(t);const n=e.config,r=e.code==="ECONNABORTED"||e.code==="ETIMEDOUT"||(t==null?void 0:t.status)===504||(t==null?void 0:t.status)===408;return n&&r&&(n.__retryCount=n.__retryCount||0,n.__retryCount<1)?(n.__retryCount++,await new Promise(o=>setTimeout(o,2e3)),QN(n)):Promise.reject(t||{message:e.message})});async function Lj(e){var p;const{method:t,url:n,params:r,data:i,headers:a,timeout:o,requestType:s,responseType:l}=e;let c=i;if(s==="form"&&i&&!(i instanceof FormData)){const h=new FormData;for(const g of Object.keys(i))h.append(g,i[g]);c=h}const d=await QN({method:t,url:n,params:r,data:c,headers:a,timeout:o,responseType:l==="blob"?"blob":"json"});if(l==="blob"&&typeof((p=d.data)==null?void 0:p.size)=="number")try{return await ize(d.data),d.data}catch(h){d.data=h}if(l==="blob")return d.data;const f=d.data;if(`${f.code}`=="200"||f.code===0||f.success)return f;throw f}const Ht=Object.assign(function(t){return Lj(t)},{download(e){return Lj({...e,responseType:"blob"})},upload(e){return Lj({...e,requestType:"form"})}});var W0e={exports:{}},Js={},U0e={exports:{}},G0e={};/**
|
|
26
26
|
* @license React
|
|
27
27
|
* scheduler.production.min.js
|
|
28
28
|
*
|
|
@@ -75,7 +75,7 @@ ${p}
|
|
|
75
75
|
onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough
|
|
76
76
|
onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata
|
|
77
77
|
onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`,KFe=`${GFe} ${qFe}`.split(/[\s\n]+/),YFe="aria-",XFe="data-";function gne(e,t){return e.indexOf(t)===0}function Sr(e,t=!1){let n;t===!1?n={aria:!0,data:!0,attr:!0}:t===!0?n={aria:!0}:n={...t};const r={};return Object.keys(e).forEach(i=>{(n.aria&&(i==="role"||gne(i,YFe))||n.data&&gne(i,XFe)||n.attr&&KFe.includes(i))&&(r[i]=e[i])}),r}function ZFe(e,t){return typeof Proxy<"u"&&e?new Proxy(e,{get(n,r){if(t[r])return t[r];const i=n[r];return typeof i=="function"?i.bind(n):i}}):e}let n1e=e=>+setTimeout(e,16),r1e=e=>clearTimeout(e);typeof window<"u"&&"requestAnimationFrame"in window&&(n1e=e=>window.requestAnimationFrame(e),r1e=e=>window.cancelAnimationFrame(e));let vne=0;const yq=new Map;function i1e(e){yq.delete(e)}const on=(e,t=1)=>{vne+=1;const n=vne;function r(i){if(i===0)i1e(n),e();else{const a=n1e(()=>{r(i-1)});yq.set(n,a)}}return r(t),n};on.cancel=e=>{const t=yq.get(e);return i1e(e),r1e(t)};function Li(e,t={}){let n=[];return ve.Children.forEach(e,r=>{r==null&&!t.keepEmpty||(Array.isArray(r)?n=n.concat(Li(r)):Kxe(r)&&r.props?n=n.concat(Li(r.props.children,t)):n.push(r))}),n}function uo(e,t){let n=e;for(let r=0;r<t.length;r+=1){if(n==null)return;n=n[t[r]]}return n}function a1e(e,t,n,r){if(!t.length)return n;const[i,...a]=t;let o;return!e&&typeof i=="number"?o=[]:Array.isArray(e)?o=[...e]:o={...e},r&&n===void 0&&a.length===1?delete o[i][a[0]]:o[i]=a1e(o[i],a,n,r),o}function Ds(e,t,n,r=!1){return t.length&&r&&n===void 0&&!uo(e,t.slice(0,-1))?e:a1e(e,t,n,r)}function QFe(e){return typeof e=="object"&&e!==null&&Object.getPrototypeOf(e)===Object.prototype}function yne(e){return Array.isArray(e)?[]:{}}const JFe=typeof Reflect>"u"?Object.keys:Reflect.ownKeys;function o1e(e,t={}){const{prepareArray:n}=t,r=n||(()=>[]);let i=yne(e[0]);return e.forEach(a=>{function o(s,l){const c=new Set(l),u=uo(a,s),d=Array.isArray(u);if(d||QFe(u)){if(!c.has(u)){c.add(u);const f=uo(i,s);d?i=Ds(i,s,r(f,u)):(!f||typeof f!="object")&&(i=Ds(i,s,yne(u))),JFe(u).forEach(p=>{Object.getOwnPropertyDescriptor(u,p).enumerable&&o([...s,p],c)})}}else i=Ds(i,s,u)}o([])}),i}function Fp(...e){return o1e(e)}const CA="__rc_react_root__";function UD(e,t){const n=t[CA]||qg(t);n.render(e),t[CA]=n}async function s1e(e){return Promise.resolve().then(()=>{var t;(t=e[CA])==null||t.unmount(),delete e[CA]})}function eBe(){}const tBe=m.createContext({}),Rf=()=>{const e=()=>{};return e.deprecated=eBe,e},hB=m.createContext(null);function nBe({children:e,onBatchResize:t}){const n=m.useRef(0),r=m.useRef([]),i=m.useContext(hB),a=m.useCallback((o,s,l)=>{n.current+=1;const c=n.current;r.current.push({size:o,element:s,data:l}),Promise.resolve().then(()=>{c===n.current&&(t==null||t(r.current),r.current=[])}),i==null||i(o,s,l)},[t,i]);return m.createElement(hB.Provider,{value:a},e)}const Bp=new Map;function rBe(e){e.forEach(t=>{var r;const{target:n}=t;(r=Bp.get(n))==null||r.forEach(i=>i(n))})}let p4;function l1e(){return p4||(p4=new ResizeObserver(rBe)),p4}function iBe(e,t){Bp.has(e)||(Bp.set(e,new Set),l1e().observe(e)),Bp.get(e).add(t)}function aBe(e,t){Bp.has(e)&&(Bp.get(e).delete(t),Bp.get(e).size||(l1e().unobserve(e),Bp.delete(e)))}function c1e(e,t,n,r){const i=m.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),a=Dt(l=>{const{width:c,height:u}=l.getBoundingClientRect(),{offsetWidth:d,offsetHeight:f}=l,p=Math.floor(c),h=Math.floor(u);if(i.current.width!==p||i.current.height!==h||i.current.offsetWidth!==d||i.current.offsetHeight!==f){const g={width:p,height:h,offsetWidth:d,offsetHeight:f};i.current=g;const v=d===Math.round(c)?c:d,y=f===Math.round(u)?u:f,x={...g,offsetWidth:v,offsetHeight:y};r==null||r(x,l),Promise.resolve().then(()=>{n==null||n(x,l)})}}),o=typeof t=="function",s=m.useRef(0);m.useEffect(()=>{const l=o?t():t;return l&&e?iBe(l,a):e&&o&&(s.current+=1),()=>{l&&aBe(l,a)}},[e,o?s.current:t])}function oBe(e,t){const{children:n,disabled:r,onResize:i,data:a}=e,o=m.useRef(null),s=m.useContext(hB),l=typeof n=="function",c=l?n(o):n,u=!l&&m.isValidElement(c)&&Bu(c),d=u?Mf(c):null,f=Af(d,o),p=()=>Vu(o.current);return m.useImperativeHandle(t,()=>p()),c1e(!r,p,i,(h,g)=>{s==null||s(h,g,a)}),u?m.cloneElement(c,{ref:f}):c}const sBe=m.forwardRef(oBe);function mB(){return mB=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mB.apply(this,arguments)}const lBe="rc-observer-key";function cBe(e,t){const{children:n}=e;return(typeof n=="function"?[n]:Li(n)).map((i,a)=>{const o=(i==null?void 0:i.key)||`${lBe}-${a}`;return m.createElement(sBe,mB({},e,{key:o,ref:a===0?t:void 0}),i)})}const ho=m.forwardRef(cBe);ho.Collection=nBe;function u1e(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=u1e(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ae(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=u1e(e))&&(r&&(r+=" "),r+=t);return r}function gB(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function uBe(e){if(Array.isArray(e))return gB(e)}function dBe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function d1e(e,t){if(e){if(typeof e=="string")return gB(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?gB(e,t):void 0}}function fBe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
78
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qt(e){return uBe(e)||dBe(e)||d1e(e)||fBe()}const r$="ant",GD="anticon",pBe=["outlined","borderless","filled","underlined"],hBe=(e,t)=>t||(e?`${r$}-${e}`:r$),Vt=m.createContext({getPrefixCls:hBe,iconPrefixCls:GD}),{Consumer:ern}=Vt,bne={};function sn(e){const t=m.useContext(Vt),{getPrefixCls:n,direction:r,getPopupContainer:i,renderEmpty:a}=t,o=t[e];return{classNames:bne,styles:bne,...o,getPrefixCls:n,direction:r,getPopupContainer:i,renderEmpty:a}}function i$(e){for(var t=0,n,r=0,i=e.length;i>=4;++r,i-=4)n=e.charCodeAt(r)&255|(e.charCodeAt(++r)&255)<<8|(e.charCodeAt(++r)&255)<<16|(e.charCodeAt(++r)&255)<<24,n=(n&65535)*1540483477+((n>>>16)*59797<<16),n^=n>>>24,t=(n&65535)*1540483477+((n>>>16)*59797<<16)^(t&65535)*1540483477+((t>>>16)*59797<<16);switch(i){case 3:t^=(e.charCodeAt(r+2)&255)<<16;case 2:t^=(e.charCodeAt(r+1)&255)<<8;case 1:t^=e.charCodeAt(r)&255,t=(t&65535)*1540483477+((t>>>16)*59797<<16)}return t^=t>>>13,t=(t&65535)*1540483477+((t>>>16)*59797<<16),((t^t>>>15)>>>0).toString(36)}const mBe="%";function vB(e){return e.join(mBe)}let xne=0;class gBe{constructor(t){Be(this,"instanceId");Be(this,"cache",new Map);Be(this,"updateTimes",new Map);Be(this,"extracted",new Set);this.instanceId=t}get(t){return this.opGet(vB(t))}opGet(t){return this.cache.get(t)||null}update(t,n){return this.opUpdate(vB(t),n)}opUpdate(t,n){const r=this.cache.get(t),i=n(r);i===null?(this.cache.delete(t),this.updateTimes.delete(t)):(this.cache.set(t,i),this.updateTimes.set(t,xne),xne+=1)}}const bq="data-token-hash",Kd="data-css-hash",Rd="__cssinjs_instance__";function vBe(){const e=Math.random().toString(12).slice(2);if(typeof document<"u"&&document.head&&document.body){const t=document.body.querySelectorAll(`style[${Kd}]`)||[],{firstChild:n}=document.head;Array.from(t).forEach(i=>{i[Rd]||(i[Rd]=e),i[Rd]===e&&document.head.insertBefore(i,n)});const r={};Array.from(document.querySelectorAll(`style[${Kd}]`)).forEach(i=>{var o;const a=i.getAttribute(Kd);r[a]?i[Rd]===e&&((o=i.parentNode)==null||o.removeChild(i)):r[a]=!0})}return new gBe(e)}const pE=m.createContext({hashPriority:"low",cache:vBe(),defaultCache:!0,autoPrefix:!1});function yBe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}const Mb=class Mb{constructor(){Be(this,"cache");Be(this,"keys");Be(this,"cacheCallTimes");this.cache=new Map,this.keys=[],this.cacheCallTimes=0}size(){return this.keys.length}internalGet(t,n=!1){let r={map:this.cache};return t.forEach(i=>{var a;r?r=(a=r==null?void 0:r.map)==null?void 0:a.get(i):r=void 0}),r!=null&&r.value&&n&&(r.value[1]=this.cacheCallTimes++),r==null?void 0:r.value}get(t){var n;return(n=this.internalGet(t,!0))==null?void 0:n[0]}has(t){return!!this.internalGet(t)}set(t,n){if(!this.has(t)){if(this.size()+1>Mb.MAX_CACHE_SIZE+Mb.MAX_CACHE_OFFSET){const[i]=this.keys.reduce((a,o)=>{const[,s]=a;return this.internalGet(o)[1]<s?[o,this.internalGet(o)[1]]:a},[this.keys[0],this.cacheCallTimes]);this.delete(i)}this.keys.push(t)}let r=this.cache;t.forEach((i,a)=>{if(a===t.length-1)r.set(i,{value:[n,this.cacheCallTimes++]});else{const o=r.get(i);o?o.map||(o.map=new Map):r.set(i,{map:new Map}),r=r.get(i).map}})}deleteByPath(t,n){var a;const r=t.get(n[0]);if(n.length===1)return r.map?t.set(n[0],{map:r.map}):t.delete(n[0]),(a=r.value)==null?void 0:a[0];const i=this.deleteByPath(r.map,n.slice(1));return(!r.map||r.map.size===0)&&!r.value&&t.delete(n[0]),i}delete(t){if(this.has(t))return this.keys=this.keys.filter(n=>!yBe(n,t)),this.deleteByPath(this.cache,t)}};Be(Mb,"MAX_CACHE_SIZE",20),Be(Mb,"MAX_CACHE_OFFSET",5);let yB=Mb,wne=0,f1e=class{constructor(t){Be(this,"derivatives");Be(this,"id");this.derivatives=Array.isArray(t)?t:[t],this.id=wne,t.length===0&&(t.length>0,void 0),wne+=1}getDerivativeToken(t){return this.derivatives.reduce((n,r)=>r(t,n),void 0)}};const h4=new yB;function bB(e){const t=Array.isArray(e)?e:[e];return h4.has(t)||h4.set(t,new f1e(t)),h4.get(t)}const bBe=new WeakMap,m4={};function xBe(e,t){let n=bBe;for(let r=0;r<t.length;r+=1){const i=t[r];n.has(i)||n.set(i,new WeakMap),n=n.get(i)}return n.has(m4)||n.set(m4,e()),n.get(m4)}const Sne=new WeakMap;function z_(e){let t=Sne.get(e)||"";return t||(Object.keys(e).forEach(n=>{const r=e[n];t+=n,r instanceof f1e?t+=r.id:r&&typeof r=="object"?t+=z_(r):t+=r}),t=i$(t),Sne.set(e,t)),t}function wBe(e,t){return i$(`${t}_${z_(e)}`)}const xB=Yo();function ue(e){return typeof e=="number"?`${e}px`:e}function p1e(e){const{hashCls:t,hashPriority:n="low"}=e||{};if(!t)return"";const r=`.${t}`;return n==="low"?`:where(${r})`:r}const SBe=e=>e!=null;function xq(e,t){const n=typeof t=="function"?t():t;return n?{...e,csp:{...e.csp,nonce:n}}:e}const qP=(e,t="")=>`--${t?`${t}-`:""}${e}`.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z0-9]+)/g,"$1-$2").replace(/([a-z])([A-Z0-9])/g,"$1-$2").toLowerCase(),_Be=(e,t,n)=>{const{hashCls:r,hashPriority:i="low",scope:a}=n||{};if(!Object.keys(e).length)return"";const o=`${p1e({hashCls:r,hashPriority:i})}.${t}`,s=[a].flat().filter(Boolean);return`${s.length?s.map(c=>`${o}.${c}`).join(", "):o}{${Object.entries(e).map(([c,u])=>`${c}:${u};`).join("")}}`},h1e=(e,t,n)=>{const{hashCls:r,hashPriority:i="low",prefix:a,unitless:o,ignore:s,preserve:l}=n||{},c={},u={};return Object.entries(e).forEach(([d,f])=>{if(l!=null&&l[d])u[d]=f;else if((typeof f=="string"||typeof f=="number")&&!(s!=null&&s[d])){const p=qP(d,a);c[p]=typeof f=="number"&&!(o!=null&&o[d])?`${f}px`:String(f),u[d]=`var(${p})`}}),[u,_Be(c,t,{scope:n==null?void 0:n.scope,hashCls:r,hashPriority:i})]},YT=new Map;function wq(e,t,n,r,i){const{cache:a}=m.useContext(pE),o=[e,...t],s=vB(o),l=d=>{a.opUpdate(s,f=>{const[p=0,h]=f||[void 0,void 0],v=h||n(),y=[p,v];return d?d(y):y})};m.useMemo(()=>{l()},[s]);const u=a.opGet(s)[1];return m.useInsertionEffect(()=>(l(([d,f])=>[d+1,f]),YT.has(s)||(i==null||i(u),YT.set(s,!0),Promise.resolve().then(()=>{YT.delete(s)})),()=>{a.opUpdate(s,d=>{const[f=0,p]=d||[];return f-1===0?(r==null||r(p,!1),YT.delete(s),null):[f-1,p]})}),[s]),u}const CBe={},$Be="css",Xm=new Map;function EBe(e){Xm.set(e,(Xm.get(e)||0)+1)}function TBe(e,t){typeof document<"u"&&document.querySelectorAll(`style[${bq}="${e}"]`).forEach(r=>{var i;r[Rd]===t&&((i=r.parentNode)==null||i.removeChild(r))})}const IBe=-1;function kBe(e,t){Xm.set(e,(Xm.get(e)||0)-1);const n=new Set;Xm.forEach((r,i)=>{r<=0&&n.add(i)}),Xm.size-n.size>IBe&&n.forEach(r=>{TBe(r,t),Xm.delete(r)})}const PBe=(e,t,n,r)=>{let a={...n.getDerivativeToken(e),...t};return r&&(a=r(a)),a},NBe="token";function ABe(e,t,n){const{cache:{instanceId:r},container:i,hashPriority:a}=m.useContext(pE),{salt:o="",override:s=CBe,formatToken:l,getComputedToken:c,cssVar:u,nonce:d}=n,f=xBe(()=>Object.assign({},...t),t),p=z_(f),h=z_(s),g=z_(u);return wq(NBe,[o,e.id,p,h,g],()=>{const y=c?c(f,s,e):PBe(f,s,e,l),x={...y},w=`${o}_${u.prefix}`,S=i$(w),_=`${$Be}-${S}`;x._tokenKey=wBe(x,w);const[C,$]=h1e(y,u.key,{prefix:u.prefix,ignore:u.ignore,unitless:u.unitless,preserve:u.preserve,hashPriority:a,hashCls:u.hashed?_:void 0});return C._hashId=S,EBe(u.key),[C,_,x,$,u.key]},([,,,,y])=>{kBe(y,r)},([,,,y,x])=>{if(!y)return;let w={mark:Kd,prepend:"queue",attachTo:i,priority:-999};w=xq(w,d);const S=ch(y,i$(`css-var-${x}`),w);S[Rd]=r,S.setAttribute(bq,x)})}var MBe={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},qr="-ms-",F_="-moz-",fr="-webkit-",Sq="comm",_q="rule",Cq="decl",RBe="@media",DBe="@import",OBe="@supports",LBe="@namespace",$q="@keyframes",m1e="@layer",jBe="@scope",zBe=Math.abs,B_=String.fromCharCode,wB=Object.assign;function FBe(e,t){return oa(e,0)^45?(((t<<2^oa(e,0))<<2^oa(e,1))<<2^oa(e,2))<<2^oa(e,3):0}function g1e(e){return e.trim()}function Sd(e,t){return(e=t.exec(e))?e[0]:e}function Gn(e,t,n){return e.replace(t,n)}function g4(e,t){return e.indexOf(t)}function oa(e,t){return e.charCodeAt(t)|0}function gv(e,t,n){return e.slice(t,n)}function vc(e){return e.length}function v1e(e){return e.length}function QS(e,t){return t.push(e),e}function BBe(e,t){return e.map(t).join("")}function _ne(e,t){return e.filter(function(n){return!Sd(n,t)})}var qD=1,Rx=1,y1e=0,Ul=0,qi=0,L1="";function KD(e,t,n,r,i,a,o,s){return{value:e,root:t,parent:n,type:r,props:i,children:a,line:qD,column:Rx,length:o,return:"",siblings:s}}function op(e,t){return wB(KD("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function Wy(e){for(;e.root;)e=op(e.root,{children:[e]});QS(e,e.siblings)}function VBe(){return qi}function HBe(){return qi=Ul>0?oa(L1,--Ul):0,Rx--,qi===10&&(Rx=1,qD--),qi}function Ec(){return qi=Ul<y1e?oa(L1,Ul++):0,Rx++,qi===10&&(Rx=1,qD++),qi}function Vp(){return oa(L1,Ul)}function KP(){return Ul}function YD(e,t){return gv(L1,e,t)}function a$(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function WBe(e){return qD=Rx=1,y1e=vc(L1=e),Ul=0,[]}function UBe(e){return L1="",e}function v4(e){return g1e(YD(Ul-1,SB(e===91?e+2:e===40?e+1:e)))}function GBe(e){for(;(qi=Vp())&&qi<33;)Ec();return a$(e)>2||a$(qi)>3?"":" "}function qBe(e,t){for(;--t&&Ec()&&!(qi<48||qi>102||qi>57&&qi<65||qi>70&&qi<97););return YD(e,KP()+(t<6&&Vp()==32&&Ec()==32))}function SB(e){for(;Ec();)switch(qi){case e:return Ul;case 34:case 39:e!==34&&e!==39&&SB(qi);break;case 40:e===41&&SB(e);break;case 92:Ec();break}return Ul}function KBe(e,t){for(;Ec()&&e+qi!==57;)if(e+qi===84&&Vp()===47)break;return"/*"+YD(t,Ul-1)+"*"+B_(e===47?e:Ec())}function YBe(e){for(;!a$(Vp());)Ec();return YD(e,Ul)}function _B(e){return UBe(YP("",null,null,null,[""],e=WBe(e),0,[0],e))}function YP(e,t,n,r,i,a,o,s,l){for(var c=0,u=0,d=o,f=0,p=0,h=0,g=1,v=1,y=1,x=0,w=0,S="",_=i,C=a,$=r,E=S;v;)switch(h=w,w=Ec()){case 40:h!=108&&oa(E,d-1)==58?(x++,E+="("):E+=v4(w);break;case 41:x--,E+=")";break;case 34:case 39:case 91:E+=v4(w);break;case 9:case 10:case 13:case 32:if(x>0){E+=B_(w);break}E+=GBe(h);break;case 92:E+=qBe(KP()-1,7);continue;case 47:switch(Vp()){case 42:case 47:QS(XBe(KBe(Ec(),KP()),t,n,l),l),(a$(h||1)==5||a$(Vp()||1)==5)&&vc(E)&&gv(E,-1,void 0)!==" "&&(E+=" ");break;default:E+="/"}break;case 123*g:s[c++]=vc(E)*y;case 125*g:case 59:case 0:if(x>0&&w){E+=B_(w);break}switch(w){case 0:case 125:v=0;case 59+u:y==-1&&(E=Gn(E,/\f/g,"")),p>0&&(vc(E)-d||g===0)&&QS(p>32?$ne(E+";",r,n,d-1,l):$ne(Gn(E," ","")+";",r,n,d-2,l),l);break;case 59:E+=";";default:if(QS($=Cne(E,t,n,c,u,i,s,S,_=[],C=[],d,a),a),w===123)if(u===0)YP(E,t,$,$,_,a,d,s,C);else{switch(f){case 99:if(oa(E,3)===110)break;case 108:if(oa(E,2)===97)break;default:u=0;case 100:case 109:case 115:}u?YP(e,$,$,r&&QS(Cne(e,$,$,0,0,i,s,S,i,_=[],d,C),C),i,C,d,s,r?_:C):YP(E,$,$,$,[""],C,0,s,C)}}c=u=p=0,g=y=1,S=E="",d=o;break;case 58:d=1+vc(E),p=h;default:if(g<1){if(w==123)--g;else if(w==125&&g++==0&&HBe()==125)continue}switch(E+=B_(w),w*g){case 38:y=u>0?1:(E+="\f",-1);break;case 44:if(x>0)break;s[c++]=(vc(E)-1)*y,y=1;break;case 64:Vp()===45&&(E+=v4(Ec())),f=Vp(),u=d=vc(S=E+=YBe(KP())),w++;break;case 45:h===45&&vc(E)==2&&(g=0)}}return a}function Cne(e,t,n,r,i,a,o,s,l,c,u,d){for(var f=i-1,p=i===0?a:[""],h=v1e(p),g=0,v=0,y=0;g<r;++g)for(var x=0,w=gv(e,f+1,f=zBe(v=o[g])),S=e;x<h;++x)(S=g1e(v>0?p[x]+" "+w:Gn(w,/&\f/g,p[x])))&&(l[y++]=S);return KD(e,t,n,i===0?_q:s,l,c,u,d)}function XBe(e,t,n,r){return KD(e,t,n,Sq,B_(VBe()),gv(e,2,-2),0,r)}function $ne(e,t,n,r,i){return KD(e,t,n,Cq,gv(e,0,r),gv(e,r+1,-1),r,i)}function b1e(e,t,n){switch(FBe(e,t)){case 5103:return fr+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return fr+e+e;case 4855:return fr+e.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+e;case 4789:return F_+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return fr+e+F_+e+qr+e+e;case 5936:switch(oa(e,t+11)){case 114:return fr+e+qr+Gn(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return fr+e+qr+Gn(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return fr+e+qr+Gn(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return fr+e+qr+e+e;case 6165:return fr+e+qr+"flex-"+e+e;case 5187:return fr+e+Gn(e,/(\w+).+(:[^]+)/,fr+"box-$1$2"+qr+"flex-$1$2")+e;case 5443:return fr+e+qr+"flex-item-"+Gn(e,/flex-|-self/g,"")+(Sd(e,/flex-|baseline/)?"":qr+"grid-row-"+Gn(e,/flex-|-self/g,""))+e;case 4675:return fr+e+qr+"flex-line-pack"+Gn(e,/align-content|flex-|-self/g,"")+e;case 5548:return fr+e+qr+Gn(e,"shrink","negative")+e;case 5292:return fr+e+qr+Gn(e,"basis","preferred-size")+e;case 6060:return fr+"box-"+Gn(e,"-grow","")+fr+e+qr+Gn(e,"grow","positive")+e;case 4554:return fr+Gn(e,/([^-])(transform)/g,"$1"+fr+"$2")+e;case 6187:return Gn(Gn(Gn(e,/(zoom-|grab)/,fr+"$1"),/(image-set)/,fr+"$1"),e,"")+e;case 5495:case 3959:return Gn(e,/(image-set\([^]*)/,fr+"$1$`$1");case 4968:return Gn(Gn(e,/(.+:)(flex-)?(.*)/,fr+"box-pack:$3"+qr+"flex-pack:$3"),/space-between/,"justify")+fr+e+e;case 4200:if(!Sd(e,/flex-|baseline/))return qr+"grid-column-align"+gv(e,t)+e;break;case 2592:case 3360:return qr+Gn(e,"template-","")+e;case 4384:case 3616:return n&&n.some(function(r,i){return t=i,Sd(r.props,/grid-\w+-end/)})?~g4(e+(n=n[t].value),"span")?e:qr+Gn(e,"-start","")+e+qr+"grid-row-span:"+(~g4(n,"span")?Sd(n,/\d+/):+Sd(n,/\d+/)-+Sd(e,/\d+/))+";":qr+Gn(e,"-start","")+e;case 4896:case 4128:return n&&n.some(function(r){return Sd(r.props,/grid-\w+-start/)})?e:qr+Gn(Gn(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return Gn(e,/(.+)-inline(.+)/,fr+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(vc(e)-1-t>6)switch(oa(e,t+1)){case 109:if(oa(e,t+4)!==45)break;case 102:return Gn(e,/(.+:)(.+)-([^]+)/,"$1"+fr+"$2-$3$1"+F_+(oa(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~g4(e,"stretch")?b1e(Gn(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return Gn(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(r,i,a,o,s,l,c){return qr+i+":"+a+c+(o?qr+i+"-span:"+(s?l:+l-+a)+c:"")+e});case 4949:if(oa(e,t+6)===121)return Gn(e,":",":"+fr)+e;break;case 6444:switch(oa(e,oa(e,14)===45?18:11)){case 120:return Gn(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+fr+(oa(e,14)===45?"inline-":"")+"box$3$1"+fr+"$2$3$1"+qr+"$2box$3")+e;case 100:return Gn(e,":",":"+qr)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Gn(e,"scroll-","scroll-snap-")+e}return e}function Dx(e,t){for(var n="",r=0;r<e.length;r++)n+=t(e[r],r,e,t)||"";return n}function CB(e,t,n,r){switch(e.type){case m1e:if(e.children.length)break;case DBe:case LBe:case Cq:return e.return=e.return||e.value;case Sq:return"";case $q:return e.return=e.value+"{"+Dx(e.children,r)+"}";case _q:if(!vc(e.value=e.props.join(",")))return""}return vc(n=Dx(e.children,r))?e.return=e.value+"{"+n+"}":""}function x1e(e){var t=v1e(e);return function(n,r,i,a){for(var o="",s=0;s<t;s++)o+=e[s](n,r,i,a)||"";return o}}function ZBe(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case Cq:e.return=b1e(e.value,e.length,n);return;case $q:return Dx([op(e,{value:Gn(e.value,"@","@"+fr)})],r);case _q:if(e.length)return BBe(n=e.props,function(i){switch(Sd(i,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Wy(op(e,{props:[Gn(i,/:(read-\w+)/,":"+F_+"$1")]})),Wy(op(e,{props:[i]})),wB(e,{props:_ne(n,r)});break;case"::placeholder":Wy(op(e,{props:[Gn(i,/:(plac\w+)/,":"+fr+"input-$1")]})),Wy(op(e,{props:[Gn(i,/:(plac\w+)/,":"+F_+"$1")]})),Wy(op(e,{props:[Gn(i,/:(plac\w+)/,qr+"input-$1")]})),Wy(op(e,{props:[i]})),wB(e,{props:_ne(n,r)});break}return""})}}const Ene="data-ant-cssinjs-cache-path",w1e="_FILE_STYLE__";let Kg,S1e=!0;function QBe(){var e;if(!Kg&&(Kg={},Yo())){const t=document.createElement("div");t.className=Ene,t.style.position="fixed",t.style.visibility="hidden",t.style.top="-9999px",document.body.appendChild(t);let n=getComputedStyle(t).content||"";n=n.replace(/^"/,"").replace(/"$/,""),n.split(";").forEach(i=>{const[a,o]=i.split(":");Kg[a]=o});const r=document.querySelector(`style[${Ene}]`);r&&(S1e=!1,(e=r.parentNode)==null||e.removeChild(r)),document.body.removeChild(t)}}function JBe(e){return QBe(),!!Kg[e]}function e8e(e){const t=Kg[e];let n=null;if(t&&Yo())if(S1e)n=w1e;else{const r=document.querySelector(`style[${Kd}="${Kg[e]}"]`);r?n=r.innerHTML:delete Kg[e]}return[n,t]}const t8e="_skip_check_",_1e="_multi_value_";function y4(e,t){return(t?Dx(_B(e),x1e([ZBe,CB])):Dx(_B(e),CB)).replace(/\{%%%\:[^;];}/g,";")}function n8e(e){return typeof e=="object"&&e&&(t8e in e||_1e in e)}function Tne(e,t,n="high"){if(!t)return e;const r=p1e({hashCls:t,hashPriority:n});return e.split(",").map(a=>{var c;const o=a.trim().split(/\s+/);let s=o[0]||"";const l=((c=s.match(/^\w+/))==null?void 0:c[0])||"";return s=`${l}${r}${s.slice(l.length)}`,[s,...o.slice(1)].join(" ")}).join(",")}const $B=(e,t={},{root:n,injectHash:r,parentSelectors:i}={root:!0,parentSelectors:[]})=>{const{hashId:a,layer:o,path:s,hashPriority:l,transformers:c=[],linters:u=[]}=t;let d="",f={};function p(v){const y=v.getName(a);if(!f[y]){const[x]=$B(v.style,t,{root:!1,parentSelectors:i});f[y]=`@keyframes ${v.getName(a)}${x}`}}function h(v,y=[]){return v.forEach(x=>{Array.isArray(x)?h(x,y):x&&y.push(x)}),y}return h(Array.isArray(e)?e:[e]).forEach(v=>{const y=typeof v=="string"&&!n?{}:v;if(typeof y=="string")d+=`${y}
|
|
78
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qt(e){return uBe(e)||dBe(e)||d1e(e)||fBe()}const r$="ant",GD="anticon",pBe=["outlined","borderless","filled","underlined"],hBe=(e,t)=>t||(e?`${r$}-${e}`:r$),Vt=m.createContext({getPrefixCls:hBe,iconPrefixCls:GD}),{Consumer:Jnn}=Vt,bne={};function sn(e){const t=m.useContext(Vt),{getPrefixCls:n,direction:r,getPopupContainer:i,renderEmpty:a}=t,o=t[e];return{classNames:bne,styles:bne,...o,getPrefixCls:n,direction:r,getPopupContainer:i,renderEmpty:a}}function i$(e){for(var t=0,n,r=0,i=e.length;i>=4;++r,i-=4)n=e.charCodeAt(r)&255|(e.charCodeAt(++r)&255)<<8|(e.charCodeAt(++r)&255)<<16|(e.charCodeAt(++r)&255)<<24,n=(n&65535)*1540483477+((n>>>16)*59797<<16),n^=n>>>24,t=(n&65535)*1540483477+((n>>>16)*59797<<16)^(t&65535)*1540483477+((t>>>16)*59797<<16);switch(i){case 3:t^=(e.charCodeAt(r+2)&255)<<16;case 2:t^=(e.charCodeAt(r+1)&255)<<8;case 1:t^=e.charCodeAt(r)&255,t=(t&65535)*1540483477+((t>>>16)*59797<<16)}return t^=t>>>13,t=(t&65535)*1540483477+((t>>>16)*59797<<16),((t^t>>>15)>>>0).toString(36)}const mBe="%";function vB(e){return e.join(mBe)}let xne=0;class gBe{constructor(t){Be(this,"instanceId");Be(this,"cache",new Map);Be(this,"updateTimes",new Map);Be(this,"extracted",new Set);this.instanceId=t}get(t){return this.opGet(vB(t))}opGet(t){return this.cache.get(t)||null}update(t,n){return this.opUpdate(vB(t),n)}opUpdate(t,n){const r=this.cache.get(t),i=n(r);i===null?(this.cache.delete(t),this.updateTimes.delete(t)):(this.cache.set(t,i),this.updateTimes.set(t,xne),xne+=1)}}const bq="data-token-hash",Kd="data-css-hash",Rd="__cssinjs_instance__";function vBe(){const e=Math.random().toString(12).slice(2);if(typeof document<"u"&&document.head&&document.body){const t=document.body.querySelectorAll(`style[${Kd}]`)||[],{firstChild:n}=document.head;Array.from(t).forEach(i=>{i[Rd]||(i[Rd]=e),i[Rd]===e&&document.head.insertBefore(i,n)});const r={};Array.from(document.querySelectorAll(`style[${Kd}]`)).forEach(i=>{var o;const a=i.getAttribute(Kd);r[a]?i[Rd]===e&&((o=i.parentNode)==null||o.removeChild(i)):r[a]=!0})}return new gBe(e)}const pE=m.createContext({hashPriority:"low",cache:vBe(),defaultCache:!0,autoPrefix:!1});function yBe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}const Mb=class Mb{constructor(){Be(this,"cache");Be(this,"keys");Be(this,"cacheCallTimes");this.cache=new Map,this.keys=[],this.cacheCallTimes=0}size(){return this.keys.length}internalGet(t,n=!1){let r={map:this.cache};return t.forEach(i=>{var a;r?r=(a=r==null?void 0:r.map)==null?void 0:a.get(i):r=void 0}),r!=null&&r.value&&n&&(r.value[1]=this.cacheCallTimes++),r==null?void 0:r.value}get(t){var n;return(n=this.internalGet(t,!0))==null?void 0:n[0]}has(t){return!!this.internalGet(t)}set(t,n){if(!this.has(t)){if(this.size()+1>Mb.MAX_CACHE_SIZE+Mb.MAX_CACHE_OFFSET){const[i]=this.keys.reduce((a,o)=>{const[,s]=a;return this.internalGet(o)[1]<s?[o,this.internalGet(o)[1]]:a},[this.keys[0],this.cacheCallTimes]);this.delete(i)}this.keys.push(t)}let r=this.cache;t.forEach((i,a)=>{if(a===t.length-1)r.set(i,{value:[n,this.cacheCallTimes++]});else{const o=r.get(i);o?o.map||(o.map=new Map):r.set(i,{map:new Map}),r=r.get(i).map}})}deleteByPath(t,n){var a;const r=t.get(n[0]);if(n.length===1)return r.map?t.set(n[0],{map:r.map}):t.delete(n[0]),(a=r.value)==null?void 0:a[0];const i=this.deleteByPath(r.map,n.slice(1));return(!r.map||r.map.size===0)&&!r.value&&t.delete(n[0]),i}delete(t){if(this.has(t))return this.keys=this.keys.filter(n=>!yBe(n,t)),this.deleteByPath(this.cache,t)}};Be(Mb,"MAX_CACHE_SIZE",20),Be(Mb,"MAX_CACHE_OFFSET",5);let yB=Mb,wne=0,f1e=class{constructor(t){Be(this,"derivatives");Be(this,"id");this.derivatives=Array.isArray(t)?t:[t],this.id=wne,t.length===0&&(t.length>0,void 0),wne+=1}getDerivativeToken(t){return this.derivatives.reduce((n,r)=>r(t,n),void 0)}};const h4=new yB;function bB(e){const t=Array.isArray(e)?e:[e];return h4.has(t)||h4.set(t,new f1e(t)),h4.get(t)}const bBe=new WeakMap,m4={};function xBe(e,t){let n=bBe;for(let r=0;r<t.length;r+=1){const i=t[r];n.has(i)||n.set(i,new WeakMap),n=n.get(i)}return n.has(m4)||n.set(m4,e()),n.get(m4)}const Sne=new WeakMap;function z_(e){let t=Sne.get(e)||"";return t||(Object.keys(e).forEach(n=>{const r=e[n];t+=n,r instanceof f1e?t+=r.id:r&&typeof r=="object"?t+=z_(r):t+=r}),t=i$(t),Sne.set(e,t)),t}function wBe(e,t){return i$(`${t}_${z_(e)}`)}const xB=Yo();function ue(e){return typeof e=="number"?`${e}px`:e}function p1e(e){const{hashCls:t,hashPriority:n="low"}=e||{};if(!t)return"";const r=`.${t}`;return n==="low"?`:where(${r})`:r}const SBe=e=>e!=null;function xq(e,t){const n=typeof t=="function"?t():t;return n?{...e,csp:{...e.csp,nonce:n}}:e}const qP=(e,t="")=>`--${t?`${t}-`:""}${e}`.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z0-9]+)/g,"$1-$2").replace(/([a-z])([A-Z0-9])/g,"$1-$2").toLowerCase(),_Be=(e,t,n)=>{const{hashCls:r,hashPriority:i="low",scope:a}=n||{};if(!Object.keys(e).length)return"";const o=`${p1e({hashCls:r,hashPriority:i})}.${t}`,s=[a].flat().filter(Boolean);return`${s.length?s.map(c=>`${o}.${c}`).join(", "):o}{${Object.entries(e).map(([c,u])=>`${c}:${u};`).join("")}}`},h1e=(e,t,n)=>{const{hashCls:r,hashPriority:i="low",prefix:a,unitless:o,ignore:s,preserve:l}=n||{},c={},u={};return Object.entries(e).forEach(([d,f])=>{if(l!=null&&l[d])u[d]=f;else if((typeof f=="string"||typeof f=="number")&&!(s!=null&&s[d])){const p=qP(d,a);c[p]=typeof f=="number"&&!(o!=null&&o[d])?`${f}px`:String(f),u[d]=`var(${p})`}}),[u,_Be(c,t,{scope:n==null?void 0:n.scope,hashCls:r,hashPriority:i})]},YT=new Map;function wq(e,t,n,r,i){const{cache:a}=m.useContext(pE),o=[e,...t],s=vB(o),l=d=>{a.opUpdate(s,f=>{const[p=0,h]=f||[void 0,void 0],v=h||n(),y=[p,v];return d?d(y):y})};m.useMemo(()=>{l()},[s]);const u=a.opGet(s)[1];return m.useInsertionEffect(()=>(l(([d,f])=>[d+1,f]),YT.has(s)||(i==null||i(u),YT.set(s,!0),Promise.resolve().then(()=>{YT.delete(s)})),()=>{a.opUpdate(s,d=>{const[f=0,p]=d||[];return f-1===0?(r==null||r(p,!1),YT.delete(s),null):[f-1,p]})}),[s]),u}const CBe={},$Be="css",Xm=new Map;function EBe(e){Xm.set(e,(Xm.get(e)||0)+1)}function TBe(e,t){typeof document<"u"&&document.querySelectorAll(`style[${bq}="${e}"]`).forEach(r=>{var i;r[Rd]===t&&((i=r.parentNode)==null||i.removeChild(r))})}const IBe=-1;function kBe(e,t){Xm.set(e,(Xm.get(e)||0)-1);const n=new Set;Xm.forEach((r,i)=>{r<=0&&n.add(i)}),Xm.size-n.size>IBe&&n.forEach(r=>{TBe(r,t),Xm.delete(r)})}const PBe=(e,t,n,r)=>{let a={...n.getDerivativeToken(e),...t};return r&&(a=r(a)),a},NBe="token";function ABe(e,t,n){const{cache:{instanceId:r},container:i,hashPriority:a}=m.useContext(pE),{salt:o="",override:s=CBe,formatToken:l,getComputedToken:c,cssVar:u,nonce:d}=n,f=xBe(()=>Object.assign({},...t),t),p=z_(f),h=z_(s),g=z_(u);return wq(NBe,[o,e.id,p,h,g],()=>{const y=c?c(f,s,e):PBe(f,s,e,l),x={...y},w=`${o}_${u.prefix}`,S=i$(w),_=`${$Be}-${S}`;x._tokenKey=wBe(x,w);const[C,$]=h1e(y,u.key,{prefix:u.prefix,ignore:u.ignore,unitless:u.unitless,preserve:u.preserve,hashPriority:a,hashCls:u.hashed?_:void 0});return C._hashId=S,EBe(u.key),[C,_,x,$,u.key]},([,,,,y])=>{kBe(y,r)},([,,,y,x])=>{if(!y)return;let w={mark:Kd,prepend:"queue",attachTo:i,priority:-999};w=xq(w,d);const S=ch(y,i$(`css-var-${x}`),w);S[Rd]=r,S.setAttribute(bq,x)})}var MBe={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},qr="-ms-",F_="-moz-",fr="-webkit-",Sq="comm",_q="rule",Cq="decl",RBe="@media",DBe="@import",OBe="@supports",LBe="@namespace",$q="@keyframes",m1e="@layer",jBe="@scope",zBe=Math.abs,B_=String.fromCharCode,wB=Object.assign;function FBe(e,t){return oa(e,0)^45?(((t<<2^oa(e,0))<<2^oa(e,1))<<2^oa(e,2))<<2^oa(e,3):0}function g1e(e){return e.trim()}function Sd(e,t){return(e=t.exec(e))?e[0]:e}function Gn(e,t,n){return e.replace(t,n)}function g4(e,t){return e.indexOf(t)}function oa(e,t){return e.charCodeAt(t)|0}function gv(e,t,n){return e.slice(t,n)}function vc(e){return e.length}function v1e(e){return e.length}function QS(e,t){return t.push(e),e}function BBe(e,t){return e.map(t).join("")}function _ne(e,t){return e.filter(function(n){return!Sd(n,t)})}var qD=1,Rx=1,y1e=0,Ul=0,qi=0,L1="";function KD(e,t,n,r,i,a,o,s){return{value:e,root:t,parent:n,type:r,props:i,children:a,line:qD,column:Rx,length:o,return:"",siblings:s}}function op(e,t){return wB(KD("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function Wy(e){for(;e.root;)e=op(e.root,{children:[e]});QS(e,e.siblings)}function VBe(){return qi}function HBe(){return qi=Ul>0?oa(L1,--Ul):0,Rx--,qi===10&&(Rx=1,qD--),qi}function Ec(){return qi=Ul<y1e?oa(L1,Ul++):0,Rx++,qi===10&&(Rx=1,qD++),qi}function Vp(){return oa(L1,Ul)}function KP(){return Ul}function YD(e,t){return gv(L1,e,t)}function a$(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function WBe(e){return qD=Rx=1,y1e=vc(L1=e),Ul=0,[]}function UBe(e){return L1="",e}function v4(e){return g1e(YD(Ul-1,SB(e===91?e+2:e===40?e+1:e)))}function GBe(e){for(;(qi=Vp())&&qi<33;)Ec();return a$(e)>2||a$(qi)>3?"":" "}function qBe(e,t){for(;--t&&Ec()&&!(qi<48||qi>102||qi>57&&qi<65||qi>70&&qi<97););return YD(e,KP()+(t<6&&Vp()==32&&Ec()==32))}function SB(e){for(;Ec();)switch(qi){case e:return Ul;case 34:case 39:e!==34&&e!==39&&SB(qi);break;case 40:e===41&&SB(e);break;case 92:Ec();break}return Ul}function KBe(e,t){for(;Ec()&&e+qi!==57;)if(e+qi===84&&Vp()===47)break;return"/*"+YD(t,Ul-1)+"*"+B_(e===47?e:Ec())}function YBe(e){for(;!a$(Vp());)Ec();return YD(e,Ul)}function _B(e){return UBe(YP("",null,null,null,[""],e=WBe(e),0,[0],e))}function YP(e,t,n,r,i,a,o,s,l){for(var c=0,u=0,d=o,f=0,p=0,h=0,g=1,v=1,y=1,x=0,w=0,S="",_=i,C=a,$=r,E=S;v;)switch(h=w,w=Ec()){case 40:h!=108&&oa(E,d-1)==58?(x++,E+="("):E+=v4(w);break;case 41:x--,E+=")";break;case 34:case 39:case 91:E+=v4(w);break;case 9:case 10:case 13:case 32:if(x>0){E+=B_(w);break}E+=GBe(h);break;case 92:E+=qBe(KP()-1,7);continue;case 47:switch(Vp()){case 42:case 47:QS(XBe(KBe(Ec(),KP()),t,n,l),l),(a$(h||1)==5||a$(Vp()||1)==5)&&vc(E)&&gv(E,-1,void 0)!==" "&&(E+=" ");break;default:E+="/"}break;case 123*g:s[c++]=vc(E)*y;case 125*g:case 59:case 0:if(x>0&&w){E+=B_(w);break}switch(w){case 0:case 125:v=0;case 59+u:y==-1&&(E=Gn(E,/\f/g,"")),p>0&&(vc(E)-d||g===0)&&QS(p>32?$ne(E+";",r,n,d-1,l):$ne(Gn(E," ","")+";",r,n,d-2,l),l);break;case 59:E+=";";default:if(QS($=Cne(E,t,n,c,u,i,s,S,_=[],C=[],d,a),a),w===123)if(u===0)YP(E,t,$,$,_,a,d,s,C);else{switch(f){case 99:if(oa(E,3)===110)break;case 108:if(oa(E,2)===97)break;default:u=0;case 100:case 109:case 115:}u?YP(e,$,$,r&&QS(Cne(e,$,$,0,0,i,s,S,i,_=[],d,C),C),i,C,d,s,r?_:C):YP(E,$,$,$,[""],C,0,s,C)}}c=u=p=0,g=y=1,S=E="",d=o;break;case 58:d=1+vc(E),p=h;default:if(g<1){if(w==123)--g;else if(w==125&&g++==0&&HBe()==125)continue}switch(E+=B_(w),w*g){case 38:y=u>0?1:(E+="\f",-1);break;case 44:if(x>0)break;s[c++]=(vc(E)-1)*y,y=1;break;case 64:Vp()===45&&(E+=v4(Ec())),f=Vp(),u=d=vc(S=E+=YBe(KP())),w++;break;case 45:h===45&&vc(E)==2&&(g=0)}}return a}function Cne(e,t,n,r,i,a,o,s,l,c,u,d){for(var f=i-1,p=i===0?a:[""],h=v1e(p),g=0,v=0,y=0;g<r;++g)for(var x=0,w=gv(e,f+1,f=zBe(v=o[g])),S=e;x<h;++x)(S=g1e(v>0?p[x]+" "+w:Gn(w,/&\f/g,p[x])))&&(l[y++]=S);return KD(e,t,n,i===0?_q:s,l,c,u,d)}function XBe(e,t,n,r){return KD(e,t,n,Sq,B_(VBe()),gv(e,2,-2),0,r)}function $ne(e,t,n,r,i){return KD(e,t,n,Cq,gv(e,0,r),gv(e,r+1,-1),r,i)}function b1e(e,t,n){switch(FBe(e,t)){case 5103:return fr+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return fr+e+e;case 4855:return fr+e.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+e;case 4789:return F_+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return fr+e+F_+e+qr+e+e;case 5936:switch(oa(e,t+11)){case 114:return fr+e+qr+Gn(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return fr+e+qr+Gn(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return fr+e+qr+Gn(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return fr+e+qr+e+e;case 6165:return fr+e+qr+"flex-"+e+e;case 5187:return fr+e+Gn(e,/(\w+).+(:[^]+)/,fr+"box-$1$2"+qr+"flex-$1$2")+e;case 5443:return fr+e+qr+"flex-item-"+Gn(e,/flex-|-self/g,"")+(Sd(e,/flex-|baseline/)?"":qr+"grid-row-"+Gn(e,/flex-|-self/g,""))+e;case 4675:return fr+e+qr+"flex-line-pack"+Gn(e,/align-content|flex-|-self/g,"")+e;case 5548:return fr+e+qr+Gn(e,"shrink","negative")+e;case 5292:return fr+e+qr+Gn(e,"basis","preferred-size")+e;case 6060:return fr+"box-"+Gn(e,"-grow","")+fr+e+qr+Gn(e,"grow","positive")+e;case 4554:return fr+Gn(e,/([^-])(transform)/g,"$1"+fr+"$2")+e;case 6187:return Gn(Gn(Gn(e,/(zoom-|grab)/,fr+"$1"),/(image-set)/,fr+"$1"),e,"")+e;case 5495:case 3959:return Gn(e,/(image-set\([^]*)/,fr+"$1$`$1");case 4968:return Gn(Gn(e,/(.+:)(flex-)?(.*)/,fr+"box-pack:$3"+qr+"flex-pack:$3"),/space-between/,"justify")+fr+e+e;case 4200:if(!Sd(e,/flex-|baseline/))return qr+"grid-column-align"+gv(e,t)+e;break;case 2592:case 3360:return qr+Gn(e,"template-","")+e;case 4384:case 3616:return n&&n.some(function(r,i){return t=i,Sd(r.props,/grid-\w+-end/)})?~g4(e+(n=n[t].value),"span")?e:qr+Gn(e,"-start","")+e+qr+"grid-row-span:"+(~g4(n,"span")?Sd(n,/\d+/):+Sd(n,/\d+/)-+Sd(e,/\d+/))+";":qr+Gn(e,"-start","")+e;case 4896:case 4128:return n&&n.some(function(r){return Sd(r.props,/grid-\w+-start/)})?e:qr+Gn(Gn(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return Gn(e,/(.+)-inline(.+)/,fr+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(vc(e)-1-t>6)switch(oa(e,t+1)){case 109:if(oa(e,t+4)!==45)break;case 102:return Gn(e,/(.+:)(.+)-([^]+)/,"$1"+fr+"$2-$3$1"+F_+(oa(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~g4(e,"stretch")?b1e(Gn(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return Gn(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(r,i,a,o,s,l,c){return qr+i+":"+a+c+(o?qr+i+"-span:"+(s?l:+l-+a)+c:"")+e});case 4949:if(oa(e,t+6)===121)return Gn(e,":",":"+fr)+e;break;case 6444:switch(oa(e,oa(e,14)===45?18:11)){case 120:return Gn(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+fr+(oa(e,14)===45?"inline-":"")+"box$3$1"+fr+"$2$3$1"+qr+"$2box$3")+e;case 100:return Gn(e,":",":"+qr)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Gn(e,"scroll-","scroll-snap-")+e}return e}function Dx(e,t){for(var n="",r=0;r<e.length;r++)n+=t(e[r],r,e,t)||"";return n}function CB(e,t,n,r){switch(e.type){case m1e:if(e.children.length)break;case DBe:case LBe:case Cq:return e.return=e.return||e.value;case Sq:return"";case $q:return e.return=e.value+"{"+Dx(e.children,r)+"}";case _q:if(!vc(e.value=e.props.join(",")))return""}return vc(n=Dx(e.children,r))?e.return=e.value+"{"+n+"}":""}function x1e(e){var t=v1e(e);return function(n,r,i,a){for(var o="",s=0;s<t;s++)o+=e[s](n,r,i,a)||"";return o}}function ZBe(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case Cq:e.return=b1e(e.value,e.length,n);return;case $q:return Dx([op(e,{value:Gn(e.value,"@","@"+fr)})],r);case _q:if(e.length)return BBe(n=e.props,function(i){switch(Sd(i,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Wy(op(e,{props:[Gn(i,/:(read-\w+)/,":"+F_+"$1")]})),Wy(op(e,{props:[i]})),wB(e,{props:_ne(n,r)});break;case"::placeholder":Wy(op(e,{props:[Gn(i,/:(plac\w+)/,":"+fr+"input-$1")]})),Wy(op(e,{props:[Gn(i,/:(plac\w+)/,":"+F_+"$1")]})),Wy(op(e,{props:[Gn(i,/:(plac\w+)/,qr+"input-$1")]})),Wy(op(e,{props:[i]})),wB(e,{props:_ne(n,r)});break}return""})}}const Ene="data-ant-cssinjs-cache-path",w1e="_FILE_STYLE__";let Kg,S1e=!0;function QBe(){var e;if(!Kg&&(Kg={},Yo())){const t=document.createElement("div");t.className=Ene,t.style.position="fixed",t.style.visibility="hidden",t.style.top="-9999px",document.body.appendChild(t);let n=getComputedStyle(t).content||"";n=n.replace(/^"/,"").replace(/"$/,""),n.split(";").forEach(i=>{const[a,o]=i.split(":");Kg[a]=o});const r=document.querySelector(`style[${Ene}]`);r&&(S1e=!1,(e=r.parentNode)==null||e.removeChild(r)),document.body.removeChild(t)}}function JBe(e){return QBe(),!!Kg[e]}function e8e(e){const t=Kg[e];let n=null;if(t&&Yo())if(S1e)n=w1e;else{const r=document.querySelector(`style[${Kd}="${Kg[e]}"]`);r?n=r.innerHTML:delete Kg[e]}return[n,t]}const t8e="_skip_check_",_1e="_multi_value_";function y4(e,t){return(t?Dx(_B(e),x1e([ZBe,CB])):Dx(_B(e),CB)).replace(/\{%%%\:[^;];}/g,";")}function n8e(e){return typeof e=="object"&&e&&(t8e in e||_1e in e)}function Tne(e,t,n="high"){if(!t)return e;const r=p1e({hashCls:t,hashPriority:n});return e.split(",").map(a=>{var c;const o=a.trim().split(/\s+/);let s=o[0]||"";const l=((c=s.match(/^\w+/))==null?void 0:c[0])||"";return s=`${l}${r}${s.slice(l.length)}`,[s,...o.slice(1)].join(" ")}).join(",")}const $B=(e,t={},{root:n,injectHash:r,parentSelectors:i}={root:!0,parentSelectors:[]})=>{const{hashId:a,layer:o,path:s,hashPriority:l,transformers:c=[],linters:u=[]}=t;let d="",f={};function p(v){const y=v.getName(a);if(!f[y]){const[x]=$B(v.style,t,{root:!1,parentSelectors:i});f[y]=`@keyframes ${v.getName(a)}${x}`}}function h(v,y=[]){return v.forEach(x=>{Array.isArray(x)?h(x,y):x&&y.push(x)}),y}return h(Array.isArray(e)?e:[e]).forEach(v=>{const y=typeof v=="string"&&!n?{}:v;if(typeof y=="string")d+=`${y}
|
|
79
79
|
`;else if(y._keyframe)p(y);else{const x=c.reduce((w,S)=>{var _;return((_=S==null?void 0:S.visit)==null?void 0:_.call(S,w))||w},y);Object.keys(x).forEach(w=>{const S=x[w];if(typeof S=="object"&&S&&(w!=="animationName"||!S._keyframe)&&!n8e(S)){let _=!1,C=w.trim(),$=!1;(n||r)&&a?C.startsWith("@")?_=!0:C==="&"?C=Tne("",a,l):C=Tne(w,a,l):n&&!a&&(C==="&"||C==="")&&(C="",$=!0);const[E,k]=$B(S,t,{root:$,injectHash:_,parentSelectors:[...i,C]});f={...f,...k},d+=`${C}${E}`}else{let _=function($,E){const k=$.replace(/[A-Z]/g,I=>`-${I.toLowerCase()}`);let T=E;!MBe[$]&&typeof T=="number"&&T!==0&&(T=`${T}px`),$==="animationName"&&(E!=null&&E._keyframe)&&(p(E),T=E.getName(a)),d+=`${k}:${T};`};const C=(S==null?void 0:S.value)??S;typeof S=="object"&&(S!=null&&S[_1e])&&Array.isArray(C)?C.forEach($=>{_(w,$)}):SBe(C)&&_(w,C)}})}}),n?o&&(d&&(d=`@layer ${o.name} {${d}}`),o.dependencies&&(f[`@layer ${o.name}`]=o.dependencies.map(v=>`@layer ${v}, ${o.name};`).join(`
|
|
80
80
|
`))):d=`{${d}}`,[d,f]};function C1e(e,t){return i$(`${e.join("%")}${t}`)}const r8e="style";function EB(e,t){const{path:n,hashId:r,layer:i,nonce:a,clientOnly:o,order:s=0}=e,{mock:l,hashPriority:c,container:u,transformers:d,linters:f,cache:p,layer:h,autoPrefix:g}=m.useContext(pE),v=[r||""];h&&v.push("layer"),v.push(...n);let y=xB;wq(r8e,v,()=>{const x=v.join("|");if(JBe(x)){const[E,k]=e8e(x);if(E)return[E,k,{},o,s]}const w=t(),[S,_]=$B(w,{hashId:r,hashPriority:c,layer:h?i:void 0,path:n.join("-"),transformers:d,linters:f}),C=y4(S,g||!1),$=C1e(v,C);return[C,$,_,o,s]},(x,w)=>{const[,S]=x;w&&xB&&n$(S,{mark:Kd,attachTo:u})},x=>{const[w,S,_,,C]=x;if(y&&w!==w1e){let $={mark:Kd,prepend:h?!1:"queue",attachTo:u,priority:C};$=xq($,a);const E=[],k=[];Object.keys(_).forEach(I=>{I.startsWith("@layer")?E.push(I):k.push(I)}),E.forEach(I=>{ch(y4(_[I],g||!1),`_layer-${I}`,{...$,prepend:!0})});const T=ch(w,S,$);T[Rd]=p.instanceId,k.forEach(I=>{ch(y4(_[I],g||!1),`_effect-${I}`,$)})}})}const i8e="cssVar",a8e=(e,t)=>{const{key:n,prefix:r,unitless:i,ignore:a,token:o,hashId:s,scope:l,nonce:c}=e,{cache:{instanceId:u},container:d,hashPriority:f}=m.useContext(pE),{_tokenKey:p}=o,h=Array.isArray(l)?l.join("@@"):l,g=[...e.path,n,h,p];return wq(i8e,g,()=>{const y=t(),[x,w]=h1e(y,n,{prefix:r,unitless:i,ignore:a,scope:l,hashPriority:f,hashCls:s}),S=C1e(g,w);return[x,w,S,n]},([,,y])=>{xB&&n$(y,{mark:Kd,attachTo:d})},([,y,x])=>{if(!y)return;let w={mark:Kd,prepend:"queue",attachTo:d,priority:-999};w=xq(w,c);const S=ch(y,x,w);S[Rd]=u,S.setAttribute(bq,n)})};class gn{constructor(t,n){Be(this,"name");Be(this,"style");Be(this,"_keyframe",!0);this.name=t,this.style=n}getName(t=""){return t?`${t}-${this.name}`:this.name}}function Uy(e){return e.notSplit=!0,e}Uy(["borderTop","borderBottom"]),Uy(["borderTop"]),Uy(["borderBottom"]),Uy(["borderLeft","borderRight"]),Uy(["borderLeft"]),Uy(["borderRight"]);function Xi(e){"@babel/helpers - typeof";return Xi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xi(e)}function o8e(e){if(Array.isArray(e))return e}function s8e(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,o,s=[],l=!0,c=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}function l8e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
81
81
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $A(e,t){return o8e(e)||s8e(e,t)||d1e(e,t)||l8e()}function c8e(e,t){if(Xi(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Xi(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function $1e(e){var t=c8e(e,"string");return Xi(t)=="symbol"?t:t+""}function $r(e,t,n){return(t=$1e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ine(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Si(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ine(Object(n),!0).forEach(function(r){$r(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ine(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Df(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u8e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,$1e(r.key),r)}}function Of(e,t,n){return t&&u8e(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Bb(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function o$(e,t){return o$=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},o$(e,t)}function Eq(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o$(e,t)}function vv(e){return vv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},vv(e)}function XD(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(XD=function(){return!!e})()}function E1e(e,t){if(t&&(Xi(t)=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Bb(e)}function T1e(e){var t=XD();return function(){var n,r=vv(e);if(t){var i=vv(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return E1e(this,n)}}var d8e=Of(function e(){Df(this,e)}),I1e="CALC_UNIT",f8e=new RegExp(I1e,"g");function b4(e){return typeof e=="number"?"".concat(e).concat(I1e):e}var p8e=function(e){Eq(n,e);var t=T1e(n);function n(r,i){var a;Df(this,n),a=t.call(this),$r(Bb(a),"result",""),$r(Bb(a),"unitlessCssVar",void 0),$r(Bb(a),"lowPriority",void 0);var o=Xi(r);return a.unitlessCssVar=i,r instanceof n?a.result="(".concat(r.result,")"):o==="number"?a.result=b4(r):o==="string"&&(a.result=r),a}return Of(n,[{key:"add",value:function(i){return i instanceof n?this.result="".concat(this.result," + ").concat(i.getResult()):(typeof i=="number"||typeof i=="string")&&(this.result="".concat(this.result," + ").concat(b4(i))),this.lowPriority=!0,this}},{key:"sub",value:function(i){return i instanceof n?this.result="".concat(this.result," - ").concat(i.getResult()):(typeof i=="number"||typeof i=="string")&&(this.result="".concat(this.result," - ").concat(b4(i))),this.lowPriority=!0,this}},{key:"mul",value:function(i){return this.lowPriority&&(this.result="(".concat(this.result,")")),i instanceof n?this.result="".concat(this.result," * ").concat(i.getResult(!0)):(typeof i=="number"||typeof i=="string")&&(this.result="".concat(this.result," * ").concat(i)),this.lowPriority=!1,this}},{key:"div",value:function(i){return this.lowPriority&&(this.result="(".concat(this.result,")")),i instanceof n?this.result="".concat(this.result," / ").concat(i.getResult(!0)):(typeof i=="number"||typeof i=="string")&&(this.result="".concat(this.result," / ").concat(i)),this.lowPriority=!1,this}},{key:"getResult",value:function(i){return this.lowPriority||i?"(".concat(this.result,")"):this.result}},{key:"equal",value:function(i){var a=this,o=i||{},s=o.unit,l=!0;return typeof s=="boolean"?l=s:Array.from(this.unitlessCssVar).some(function(c){return a.result.includes(c)})&&(l=!1),this.result=this.result.replace(f8e,l?"px":""),typeof this.lowPriority<"u"?"calc(".concat(this.result,")"):this.result}}]),n}(d8e),h8e=function(t,n){var r=p8e;return function(i){return new r(i,n)}},kne=function(t,n){return"".concat([n,t.replace(/([A-Z]+)([A-Z][a-z]+)/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2")].filter(Boolean).join("-"))};function Pne(e,t,n,r){var i=Si({},t[e]);if(r!=null&&r.deprecatedTokens){var a=r.deprecatedTokens;a.forEach(function(s){var l=$A(s,2),c=l[0],u=l[1];if(i!=null&&i[c]||i!=null&&i[u]){var d;(d=i[u])!==null&&d!==void 0||(i[u]=i==null?void 0:i[c])}})}var o=Si(Si({},n),i);return Object.keys(o).forEach(function(s){o[s]===t[s]&&delete o[s]}),o}var k1e=typeof CSSINJS_STATISTIC<"u",TB=!0;function fn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];if(!k1e)return Object.assign.apply(Object,[{}].concat(t));TB=!1;var r={};return t.forEach(function(i){if(Xi(i)==="object"){var a=Object.keys(i);a.forEach(function(o){Object.defineProperty(r,o,{configurable:!0,enumerable:!0,get:function(){return i[o]}})})}}),TB=!0,r}var Nne={};function m8e(){}var g8e=function(t){var n,r=t,i=m8e;return k1e&&typeof Proxy<"u"&&(n=new Set,r=new Proxy(t,{get:function(o,s){if(TB){var l;(l=n)===null||l===void 0||l.add(s)}return o[s]}}),i=function(o,s){var l;Nne[o]={global:Array.from(n),component:Si(Si({},(l=Nne[o])===null||l===void 0?void 0:l.component),s)}}),{token:r,keys:n,flush:i}};function Ane(e,t,n){if(typeof n=="function"){var r;return n(fn(t,(r=t[e])!==null&&r!==void 0?r:{}))}return n??{}}function v8e(e){return{max:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return"max(".concat(r.map(function(a){return ue(a)}).join(","),")")},min:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return"min(".concat(r.map(function(a){return ue(a)}).join(","),")")}}}var y8e=1e3*60*10,b8e=function(){function e(){Df(this,e),$r(this,"map",new Map),$r(this,"objectIDMap",new WeakMap),$r(this,"nextID",0),$r(this,"lastAccessBeat",new Map),$r(this,"accessBeat",0)}return Of(e,[{key:"set",value:function(n,r){this.clear();var i=this.getCompositeKey(n);this.map.set(i,r),this.lastAccessBeat.set(i,Date.now())}},{key:"get",value:function(n){var r=this.getCompositeKey(n),i=this.map.get(r);return this.lastAccessBeat.set(r,Date.now()),this.accessBeat+=1,i}},{key:"getCompositeKey",value:function(n){var r=this,i=n.map(function(a){return a&&Xi(a)==="object"?"obj_".concat(r.getObjectID(a)):"".concat(Xi(a),"_").concat(a)});return i.join("|")}},{key:"getObjectID",value:function(n){if(this.objectIDMap.has(n))return this.objectIDMap.get(n);var r=this.nextID;return this.objectIDMap.set(n,r),this.nextID+=1,r}},{key:"clear",value:function(){var n=this;if(this.accessBeat>1e4){var r=Date.now();this.lastAccessBeat.forEach(function(i,a){r-i>y8e&&(n.map.delete(a),n.lastAccessBeat.delete(a))}),this.accessBeat=0}}}]),e}(),Mne=new b8e;function x8e(e,t){return ve.useMemo(function(){var n=Mne.get(t);if(n)return n;var r=e();return Mne.set(t,r),r},t)}var w8e=function(){return{}};function S8e(e){var t=e.useCSP,n=t===void 0?w8e:t,r=e.useToken,i=e.usePrefix,a=e.getResetStyles,o=e.getCommonStyle,s=e.getCompUnitless;function l(f,p,h,g){var v=Array.isArray(f)?f[0]:f;function y(E){return"".concat(String(v)).concat(E.slice(0,1).toUpperCase()).concat(E.slice(1))}var x=(g==null?void 0:g.unitless)||{},w=typeof s=="function"?s(f):{},S=Si(Si({},w),{},$r({},y("zIndexPopup"),!0));Object.keys(x).forEach(function(E){S[y(E)]=x[E]});var _=Si(Si({},g),{},{unitless:S,prefixToken:y}),C=u(f,p,h,_),$=c(v,h,_);return function(E){var k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:E,T=C(E,k),I=g==null?void 0:g.extraCssVarPrefixCls,P=typeof I=="function"?I({prefixCls:E,rootCls:k}):I,N=$(P!=null&&P.length?[k].concat(Qt(P)):k);return[T,N]}}function c(f,p,h){var g=h.unitless,v=h.prefixToken,y=h.ignore;return function(x){var w=r(),S=w.cssVar,_=w.realToken,C=n();return a8e({path:[f],prefix:S.prefix,key:S.key,unitless:g,ignore:y,token:_,scope:x,nonce:function(){return C.nonce}},function(){var $=Ane(f,_,p),E=Pne(f,_,$,{deprecatedTokens:h==null?void 0:h.deprecatedTokens});return $&&Object.keys($).forEach(function(k){E[v(k)]=E[k],delete E[k]}),E}),S==null?void 0:S.key}}function u(f,p,h){var g=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},v=Array.isArray(f)?f:[f,f],y=$A(v,1),x=y[0],w=v.join("-"),S=e.layer||{name:"antd"};return function(_){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:_,$=r(),E=$.theme,k=$.realToken,T=$.hashId,I=$.token,P=$.cssVar,N=$.zeroRuntime,A=m.useMemo(function(){return N},[]);if(A)return T;var M=i(),R=M.rootPrefixCls,L=M.iconPrefixCls,z=n(),j="css",O=x8e(function(){var H=new Set;return Object.keys(g.unitless||{}).forEach(function(W){H.add(qP(W,P.prefix)),H.add(qP(W,kne(x,P.prefix)))}),h8e(j,H)},[j,x,P==null?void 0:P.prefix]),V=v8e(),B=V.max,D=V.min,F={theme:E,token:I,hashId:T,nonce:function(){return z.nonce},clientOnly:g.clientOnly,layer:S,order:g.order||-999};return typeof a=="function"&&EB(Si(Si({},F),{},{clientOnly:!1,path:["Shared",R]}),function(){return a(I,{prefix:{rootPrefixCls:R,iconPrefixCls:L},csp:z})}),EB(Si(Si({},F),{},{path:[w,_,L]}),function(){if(g.injectStyle===!1)return[];var H=g8e(I),W=H.token,K=H.flush,U=Ane(x,k,h),q=".".concat(_),Q=Pne(x,k,U,{deprecatedTokens:g.deprecatedTokens});U&&Xi(U)==="object"&&Object.keys(U).forEach(function(Y){U[Y]="var(".concat(qP(Y,kne(x,P.prefix)),")")});var G=fn(W,{componentCls:q,prefixCls:_,iconCls:".".concat(L),antCls:".".concat(R),calc:O,max:B,min:D},U),X=p(G,{hashId:T,prefixCls:_,rootPrefixCls:R,iconPrefixCls:L});K(x,Q);var J=typeof o=="function"?o(G,_,C,g.resetFont):null;return[g.resetStyle===!1?null:J,X]}),T}}function d(f,p,h){var g=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},v=u(f,p,h,Si({resetStyle:!1,order:-998},g)),y=function(w){var S=w.prefixCls,_=w.rootCls,C=_===void 0?S:_;return v(S,C),null};return y}return{genStyleHooks:l,genSubStyleComponent:d,genComponentStyleHook:u}}const Th=["blue","purple","cyan","green","magenta","pink","red","orange","yellow","volcano","geekblue","lime","gold"];function XP(e){return(e+8)/e}function _8e(e){const t=Array.from({length:10}).map((n,r)=>{const i=r-1,a=e*Math.E**(i/5),o=r>1?Math.floor(a):Math.ceil(a);return Math.floor(o/2)*2});return t[1]=e,t.map(n=>({size:n,lineHeight:XP(n)}))}const P1e="6.2.1",N1e={blue:"#1677FF",purple:"#722ED1",cyan:"#13C2C2",green:"#52C41A",magenta:"#EB2F96",pink:"#EB2F96",red:"#F5222D",orange:"#FA8C16",yellow:"#FADB14",volcano:"#FA541C",geekblue:"#2F54EB",gold:"#FAAD14",lime:"#A0D911"},s$={...N1e,colorPrimary:"#1677ff",colorSuccess:"#52c41a",colorWarning:"#faad14",colorError:"#ff4d4f",colorInfo:"#1677ff",colorLink:"",colorTextBase:"",colorBgBase:"",fontFamily:`-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
|
|
@@ -181,7 +181,7 @@ html body {
|
|
|
181
181
|
`]:{animationName:w,animationDuration:d,animationPlayState:"paused",animationTimingFunction:u},[`
|
|
182
182
|
${t}-move-up-appear${t}-move-up-appear-active,
|
|
183
183
|
${t}-move-up-enter${t}-move-up-enter-active
|
|
184
|
-
`]:{animationPlayState:"running"},[`${t}-move-up-leave`]:{animationName:S,animationDuration:d,animationPlayState:"paused",animationTimingFunction:u},[`${t}-move-up-leave${t}-move-up-leave-active`]:{animationPlayState:"running"},"&-rtl":{direction:"rtl",span:{direction:"rtl"}}}},{[t]:{[`${x}-wrapper`]:{..._}}},{[`${t}-notice-pure-panel`]:{..._,padding:0,textAlign:"start"}}]},G9e=e=>({zIndexPopup:e.zIndexPopupBase+Oq+10,contentBg:e.colorBgElevated,contentPadding:`${(e.controlHeightLG-e.fontSize*e.lineHeight)/2}px ${e.paddingSM}px`}),Cwe=bn("Message",e=>{const t=fn(e,{height:150});return U9e(t)},G9e),q9e={info:m.createElement(QD,null),success:m.createElement(Gh,null),error:m.createElement(Lf,null),warning:m.createElement(ly,null),loading:m.createElement(ql,null)},$we=e=>{const{prefixCls:t,type:n,icon:r,children:i,classNames:a,styles:o}=e,s=r||n&&q9e[n],l=oi(s,c=>{const u={...c==null?void 0:c.style,...o==null?void 0:o.icon};return{className:ae(c.className,a==null?void 0:a.icon),style:u}});return m.createElement("div",{className:ae(`${t}-custom-content`,`${t}-${n}`)},l,m.createElement("span",{className:a==null?void 0:a.content,style:o==null?void 0:o.content},i))},K9e=e=>{const{prefixCls:t,className:n,style:r,type:i,icon:a,content:o,classNames:s,styles:l,...c}=e,{getPrefixCls:u,className:d,style:f,classNames:p,styles:h}=sn("message"),g=t||u("message"),v=Pr(g),[y,x]=Cwe(g,v),[w,S]=cn([p,s],[h,l],{props:e});return m.createElement(zq,{...c,prefixCls:g,className:ae(d,w.root,n,y,`${g}-notice-pure-panel`,x,v),style:{...S.root,...f,...r},eventKey:"pure",duration:null,content:m.createElement($we,{prefixCls:g,type:i,icon:a,classNames:w,styles:S},o)})};function Y9e(e,t){return{motionName:t??`${e}-move-up`}}function Fq(e){let t;const n=new Promise(i=>{t=e(()=>{i(!0)})}),r=()=>{t==null||t()};return r.then=(i,a)=>n.then(i,a),r.promise=n,r}const X9e=8,Z9e=3,Q9e=({children:e,prefixCls:t})=>{const n=Pr(t),[r,i]=Cwe(t,n);return m.createElement(Swe,{classNames:{list:ae(r,i,n)}},e)},J9e=(e,{prefixCls:t,key:n})=>m.createElement(Q9e,{prefixCls:t,key:n},e),eHe=m.forwardRef((e,t)=>{const{top:n,prefixCls:r,getContainer:i,maxCount:a,duration:o=Z9e,rtl:s,transitionName:l,onAllRemoved:c,pauseOnHover:u=!0}=e,{getPrefixCls:d,direction:f,getPopupContainer:p}=sn("message"),{message:h}=m.useContext(Vt),g=r||d("message"),v=()=>({left:"50%",transform:"translateX(-50%)",top:n??X9e}),y=()=>ae({[`${g}-rtl`]:s??f==="rtl"}),x=()=>Y9e(g,l),[w,S]=cn([e==null?void 0:e.classNames,h==null?void 0:h.classNames],[e==null?void 0:e.styles,h==null?void 0:h.styles],{props:e}),[_,C]=_we({prefixCls:g,style:v,className:y,motion:x,closable:!1,duration:o,getContainer:()=>(i==null?void 0:i())||(p==null?void 0:p())||document.body,maxCount:a,onAllRemoved:c,renderNotifications:J9e,pauseOnHover:u});return m.useImperativeHandle(t,()=>({..._,prefixCls:g,message:h,classNames:w,styles:S})),C});let mre=0;function Ewe(e){const t=m.useRef(null);return Rf(),[m.useMemo(()=>{const r=l=>{var c;(c=t.current)==null||c.close(l)},i=l=>{if(!t.current){const V=()=>{};return V.then=()=>{},V}const{open:c,prefixCls:u,message:d,classNames:f,styles:p}=t.current,h=(d==null?void 0:d.className)||{},g=(d==null?void 0:d.style)||{},v=(d==null?void 0:d.classNames)||{},y=(d==null?void 0:d.styles)||{},x=`${u}-notice`,{content:w,icon:S,type:_,key:C,className:$,style:E,onClose:k,classNames:T={},styles:I={},...P}=l;let N=C;Hr(N)||(mre+=1,N=`antd-message-${mre}`);const A={...e,...l},M=Hp(v,{props:A}),R=Hp(T,{props:A}),L=Hp(y,{props:A}),z=Hp(I,{props:A}),j=eO(void 0,M,R,f),O=Dq(L,z,p);return Fq(V=>(c({...P,key:N,content:m.createElement($we,{prefixCls:u,type:_,icon:S,classNames:j,styles:O},w),placement:"top",className:ae({[`${x}-${_}`]:_},$,h,j.root),style:{...O.root,...g,...E},onClose:()=>{k==null||k(),V()}}),()=>{r(N)}))},o={open:i,destroy:l=>{var c;l!==void 0?r(l):(c=t.current)==null||c.destroy()}};return["info","success","warning","error","loading"].forEach(l=>{const c=(u,d,f)=>{let p;u&&typeof u=="object"&&"content"in u?p=u:p={content:u};let h,g;typeof d=="function"?g=d:(h=d,g=f);const v={onClose:g,duration:h,...p,type:l};return i(v)};o[l]=c}),o},[]),m.createElement(eHe,{key:"message-holder",...e,ref:t})]}function tHe(e){return Ewe(e)}const $4=()=>({height:0,opacity:0}),gre=e=>{const{scrollHeight:t}=e;return{height:t,opacity:1}},nHe=e=>({height:e?e.offsetHeight:0}),E4=(e,t)=>(t==null?void 0:t.deadline)===!0||t.propertyName==="height",Lx=(e=r$)=>({motionName:`${e}-motion-collapse`,onAppearStart:$4,onEnterStart:$4,onAppearActive:gre,onEnterActive:gre,onLeaveStart:nHe,onLeaveActive:$4,onAppearEnd:E4,onEnterEnd:E4,onLeaveEnd:E4,motionDeadline:500}),Lc=(e,t,n)=>n!==void 0?n:`${e}-${t}`,rHe=e=>{const{componentCls:t,colorPrimary:n,antCls:r}=e,[,i]=Jn(r,"wave");return{[t]:{position:"absolute",background:"transparent",pointerEvents:"none",boxSizing:"border-box",color:i("color",n),boxShadow:"0 0 0 0 currentcolor",opacity:.2,"&.wave-motion-appear":{transition:[`box-shadow 0.4s ${e.motionEaseOutCirc}`,`opacity 2s ${e.motionEaseOutCirc}`].join(","),"&-active":{boxShadow:"0 0 0 6px currentcolor",opacity:0},"&.wave-quick":{transition:[`box-shadow ${e.motionDurationSlow} ${e.motionEaseInOut}`,`opacity ${e.motionDurationSlow} ${e.motionEaseInOut}`].join(",")}}}}},iHe=H8e("Wave",rHe),yE=`${r$}-wave-target`;function vre(e){return e&&typeof e=="string"&&e!=="#fff"&&e!=="#ffffff"&&e!=="rgb(255, 255, 255)"&&e!=="rgba(255, 255, 255, 1)"&&!/rgba\((?:\d*, ){3}0\)/.test(e)&&e!=="transparent"&&e!=="canvastext"}function aHe(e,t=null){const n=getComputedStyle(e),{borderTopColor:r,borderColor:i,backgroundColor:a}=n;return t&&vre(n[t])?n[t]:[r,i,a].find(vre)??null}function T4(e){return Number.isNaN(e)?0:e}const oHe=e=>{const{className:t,target:n,component:r,colorSource:i}=e,a=m.useRef(null),{getPrefixCls:o}=m.useContext(Vt),s=o(),[l]=Jn(s,"wave"),[c,u]=m.useState(null),[d,f]=m.useState([]),[p,h]=m.useState(0),[g,v]=m.useState(0),[y,x]=m.useState(0),[w,S]=m.useState(0),[_,C]=m.useState(!1),$={left:p,top:g,width:y,height:w,borderRadius:d.map(T=>`${T}px`).join(" ")};c&&($[l("color")]=c);function E(){const T=getComputedStyle(n);u(aHe(n,i));const I=T.position==="static",{borderLeftWidth:P,borderTopWidth:N}=T;h(I?n.offsetLeft:T4(-Number.parseFloat(P))),v(I?n.offsetTop:T4(-Number.parseFloat(N))),x(n.offsetWidth),S(n.offsetHeight);const{borderTopLeftRadius:A,borderTopRightRadius:M,borderBottomLeftRadius:R,borderBottomRightRadius:L}=T;f([A,M,L,R].map(z=>T4(Number.parseFloat(z))))}if(m.useEffect(()=>{if(n){const T=on(()=>{E(),C(!0)});let I;return typeof ResizeObserver<"u"&&(I=new ResizeObserver(E),I.observe(n)),()=>{on.cancel(T),I==null||I.disconnect()}}},[n]),!_)return null;const k=(r==="Checkbox"||r==="Radio")&&(n==null?void 0:n.classList.contains(yE));return m.createElement(Ti,{visible:!0,motionAppear:!0,motionName:"wave-motion",motionDeadline:5e3,onAppearEnd:(T,I)=>{var P;if(I.deadline||I.propertyName==="opacity"){const N=(P=a.current)==null?void 0:P.parentElement;s1e(N).then(()=>{N==null||N.remove()})}return!1}},({className:T},I)=>m.createElement("div",{ref:ta(a,I),className:ae(t,T,{"wave-quick":k}),style:$}))},sHe=(e,t)=>{var i;const{component:n}=t;if(n==="Checkbox"&&!((i=e.querySelector("input"))!=null&&i.checked))return;const r=document.createElement("div");r.style.position="absolute",r.style.left="0px",r.style.top="0px",e==null||e.insertBefore(r,e==null?void 0:e.firstChild),UD(m.createElement(oHe,{...t,target:e}),r)},lHe=(e,t,n,r)=>{const{wave:i}=m.useContext(Vt),[,a,o]=Za(),s=Dt(u=>{const d=e.current;if(i!=null&&i.disabled||!d)return;const f=d.querySelector(`.${yE}`)||d,{showEffect:p}=i||{};(p||sHe)(f,{className:t,token:a,component:n,event:u,hashId:o,colorSource:r})}),l=m.useRef(null);return m.useEffect(()=>()=>{on.cancel(l.current)},[]),u=>{on.cancel(l.current),l.current=on(()=>{s(u)})}},F1=e=>{const{children:t,disabled:n,component:r,colorSource:i}=e,{getPrefixCls:a}=m.useContext(Vt),o=m.useRef(null),s=a("wave"),l=iHe(s),c=lHe(o,ae(s,l),r,i);if(ve.useEffect(()=>{const d=o.current;if(!d||d.nodeType!==window.Node.ELEMENT_NODE||n)return;const f=p=>{!O1(p.target)||!d.getAttribute||d.getAttribute("disabled")||d.disabled||d.className.includes("disabled")&&!d.className.includes("disabled:")||d.getAttribute("aria-disabled")==="true"||d.className.includes("-leave")||c(p)};return d.addEventListener("click",f,!0),()=>{d.removeEventListener("click",f,!0)}},[n]),!ve.isValidElement(t))return t??null;const u=Bu(t)?ta(Mf(t),o):o;return oi(t,{ref:u})},Ii=e=>{const t=ve.useContext(yv);return ve.useMemo(()=>e?typeof e=="string"?e??t:typeof e=="function"?e(t):t:t,[e,t])},cHe=e=>{const{componentCls:t}=e;return{[t]:{display:"inline-flex","&-block":{display:"flex",width:"100%"},"&-vertical":{flexDirection:"column"},"&-rtl":{direction:"rtl"}}}},uHe=bn(["Space","Compact"],e=>[cHe(e)],()=>({}),{resetStyle:!1}),tO=m.createContext(null),id=(e,t)=>{const n=m.useContext(tO),r=m.useMemo(()=>{if(!n)return"";const{compactDirection:i,isFirstItem:a,isLastItem:o}=n,s=i==="vertical"?"-vertical-":"-";return ae(`${e}-compact${s}item`,{[`${e}-compact${s}first-item`]:a,[`${e}-compact${s}last-item`]:o,[`${e}-compact${s}item-rtl`]:t==="rtl"})},[e,t,n]);return{compactSize:n==null?void 0:n.compactSize,compactDirection:n==null?void 0:n.compactDirection,compactItemClassnames:r}},dHe=e=>{const{children:t}=e;return m.createElement(tO.Provider,{value:null},t)},fHe=e=>{const{children:t,...n}=e;return m.createElement(tO.Provider,{value:m.useMemo(()=>n,[n])},t)},Bq=e=>{const{getPrefixCls:t,direction:n}=m.useContext(Vt),{size:r,direction:i,orientation:a,block:o,prefixCls:s,className:l,rootClassName:c,children:u,vertical:d,...f}=e,[p,h]=hE(a,d,i),g=Ii(C=>r??C),v=t("space-compact",s),[y]=uHe(v),x=ae(v,y,{[`${v}-rtl`]:n==="rtl",[`${v}-block`]:o,[`${v}-vertical`]:h},l,c),w=m.useContext(tO),S=Li(u),_=m.useMemo(()=>S.map((C,$)=>{const E=(C==null?void 0:C.key)||`${v}-item-${$}`;return m.createElement(fHe,{key:E,compactSize:g,compactDirection:p,isFirstItem:$===0&&(!w||(w==null?void 0:w.isFirstItem)),isLastItem:$===S.length-1&&(!w||(w==null?void 0:w.isLastItem))},C)}),[S,w,p,g,v]);return S.length===0?null:m.createElement("div",{className:x,...f},_)},Twe=m.createContext(void 0),pHe=e=>{const{getPrefixCls:t,direction:n}=m.useContext(Vt),{prefixCls:r,size:i,className:a,...o}=e,s=t("btn-group",r),[,,l]=Za(),c=m.useMemo(()=>{switch(i){case"large":return"lg";case"small":return"sm";default:return""}},[i]),u=ae(s,{[`${s}-${c}`]:c,[`${s}-rtl`]:n==="rtl"},a,l);return m.createElement(Twe.Provider,{value:i},m.createElement("div",{...o,className:u}))},yre=/^[\u4E00-\u9FA5]{2}$/,a8=yre.test.bind(yre);function Vq(e){return e==="danger"?{danger:!0}:{type:e}}function bre(e){return typeof e=="string"}function I4(e){return e==="text"||e==="link"}function hHe(e,t,n,r){if(!Hr(e)||e==="")return;const i=t?" ":"";return typeof e!="string"&&typeof e!="number"&&bre(e.type)&&a8(e.props.children)?oi(e,a=>{const o=ae(a.className,r)||void 0,s={...n,...a.style};return{...a,children:a.children.split("").join(i),className:o,style:s}}):bre(e)?ve.createElement("span",{className:r,style:n},a8(e)?e.split("").join(i):e):mwe(e)?ve.createElement("span",{className:r,style:n},e):oi(e,a=>({...a,className:ae(a.className,r)||void 0,style:{...a.style,...n}}))}function mHe(e,t,n,r){let i=!1;const a=[];return ve.Children.forEach(e,o=>{const s=typeof o,l=s==="string"||s==="number";if(i&&l){const c=a.length-1,u=a[c];a[c]=`${u}${o}`}else a.push(o);i=l}),ve.Children.map(a,o=>hHe(o,t,n,r))}["default","primary","danger"].concat(Qt(Th));const Iwe=m.forwardRef((e,t)=>{const{className:n,style:r,children:i,prefixCls:a}=e,o=ae(`${a}-icon`,n);return ve.createElement("span",{ref:t,className:o,style:r},i)}),xre=m.forwardRef((e,t)=>{const{prefixCls:n,className:r,style:i,iconClassName:a}=e,o=ae(`${n}-loading-icon`,r);return ve.createElement(Iwe,{prefixCls:n,className:o,style:i,ref:t},ve.createElement(ql,{className:a}))}),k4=()=>({width:0,opacity:0,transform:"scale(0)"}),P4=e=>({width:e.scrollWidth,opacity:1,transform:"scale(1)"}),gHe=e=>{const{prefixCls:t,loading:n,existIcon:r,className:i,style:a,mount:o}=e,s=!!n;return r?ve.createElement(xre,{prefixCls:t,className:i,style:a}):ve.createElement(Ti,{visible:s,motionName:`${t}-loading-icon-motion`,motionAppear:!o,motionEnter:!o,motionLeave:!o,removeOnLeave:!0,onAppearStart:k4,onAppearActive:P4,onEnterStart:k4,onEnterActive:P4,onLeaveStart:P4,onLeaveActive:k4},({className:l,style:c},u)=>{const d={...a,...c};return ve.createElement(xre,{prefixCls:t,className:ae(i,l),style:d,ref:u})})},wre=(e,t)=>({[`> span, > ${e}`]:{"&:not(:last-child)":{[`&, & > ${e}`]:{"&:not(:disabled)":{borderInlineEndColor:t}}},"&:not(:first-child)":{[`&, & > ${e}`]:{"&:not(:disabled)":{borderInlineStartColor:t}}}}}),vHe=e=>{const{componentCls:t,fontSize:n,lineWidth:r,groupBorderColor:i,colorErrorHover:a}=e;return{[`${t}-group`]:[{position:"relative",display:"inline-flex",[`> span, > ${t}`]:{"&:not(:last-child)":{[`&, & > ${t}`]:{borderStartEndRadius:0,borderEndEndRadius:0}},"&:not(:first-child)":{marginInlineStart:e.calc(r).mul(-1).equal(),[`&, & > ${t}`]:{borderStartStartRadius:0,borderEndStartRadius:0}}},[t]:{position:"relative",zIndex:1,"&:hover, &:focus, &:active":{zIndex:2},"&[disabled]":{zIndex:0}},[`${t}-icon-only`]:{fontSize:n}},wre(`${t}-primary`,i),wre(`${t}-danger`,a)]}},N4=e=>Math.round(Number(e||0)),yHe=e=>{if(e instanceof _n)return e;if(e&&typeof e=="object"&&"h"in e&&"b"in e){const{b:t,...n}=e;return{...n,v:t}}return typeof e=="string"&&/hsb/.test(e)?e.replace(/hsb/,"hsv"):e};let d$=class extends _n{constructor(t){super(yHe(t))}toHsbString(){const t=this.toHsb(),n=N4(t.s*100),r=N4(t.b*100),i=N4(t.h),a=t.a,o=`hsb(${i}, ${n}%, ${r}%)`,s=`hsba(${i}, ${n}%, ${r}%, ${a.toFixed(a===0?0:2)})`;return a===1?o:s}toHsb(){const{v:t,...n}=this.toHsv();return{...n,b:t,a:this.a}}};const bHe=e=>e instanceof d$?e:new d$(e);bHe("#1677ff");const xHe=(e,t)=>(e==null?void 0:e.replace(/[^\w/]/g,"").slice(0,t?8:6))||"",wHe=(e,t)=>e?xHe(e,t):"";let MA=function(){function e(t){var r;if(Df(this,e),this.cleared=!1,t instanceof e){this.metaColor=t.metaColor.clone(),this.colors=(r=t.colors)==null?void 0:r.map(i=>({color:new e(i.color),percent:i.percent})),this.cleared=t.cleared;return}const n=Array.isArray(t);n&&t.length?(this.colors=t.map(({color:i,percent:a})=>({color:new e(i),percent:a})),this.metaColor=new d$(this.colors[0].color.metaColor)):this.metaColor=new d$(n?"":t),(!t||n&&!this.colors)&&(this.metaColor=this.metaColor.setA(0),this.cleared=!0)}return Of(e,[{key:"toHsb",value:function(){return this.metaColor.toHsb()}},{key:"toHsbString",value:function(){return this.metaColor.toHsbString()}},{key:"toHex",value:function(){return wHe(this.toHexString(),this.metaColor.a<1)}},{key:"toHexString",value:function(){return this.metaColor.toHexString()}},{key:"toRgb",value:function(){return this.metaColor.toRgb()}},{key:"toRgbString",value:function(){return this.metaColor.toRgbString()}},{key:"isGradient",value:function(){return!!this.colors&&!this.cleared}},{key:"getColors",value:function(){return this.colors||[{color:this,percent:0}]}},{key:"toCssString",value:function(){const{colors:n}=this;return n?`linear-gradient(90deg, ${n.map(i=>`${i.color.toRgbString()} ${i.percent}%`).join(", ")})`:this.metaColor.toRgbString()}},{key:"equals",value:function(n){return!n||this.isGradient()!==n.isGradient()?!1:this.isGradient()?this.colors.length===n.colors.length&&this.colors.every((r,i)=>{const a=n.colors[i];return r.percent===a.percent&&r.color.equals(a.color)}):this.toHexString()===n.toHexString()}}])}();var SHe={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"}}]},name:"right",theme:"outlined"};function o8(){return o8=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o8.apply(this,arguments)}const _He=(e,t)=>m.createElement($t,o8({},e,{ref:t,icon:SHe})),Ih=m.forwardRef(_He);function Yi(){return Yi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Yi.apply(null,arguments)}const CHe=ve.forwardRef((e,t)=>{const{prefixCls:n,forceRender:r,className:i,style:a,children:o,isActive:s,role:l,classNames:c,styles:u}=e,[d,f]=ve.useState(s||r);return ve.useEffect(()=>{(r||s)&&f(!0)},[r,s]),d?ve.createElement("div",{ref:t,className:ae(`${n}-panel`,{[`${n}-panel-active`]:s,[`${n}-panel-inactive`]:!s},i),style:a,role:l},ve.createElement("div",{className:ae(`${n}-body`,c==null?void 0:c.body),style:u==null?void 0:u.body},o)):null}),kwe=ve.forwardRef((e,t)=>{const{showArrow:n=!0,headerClass:r,isActive:i,onItemClick:a,forceRender:o,className:s,classNames:l={},styles:c={},prefixCls:u,collapsible:d,accordion:f,panelKey:p,extra:h,header:g,expandIcon:v,openMotion:y,destroyOnHidden:x,children:w,...S}=e,_=d==="disabled",C=h!=null&&typeof h!="boolean",$={onClick:()=>{a==null||a(p)},onKeyDown:N=>{(N.key==="Enter"||N.keyCode===Ct.ENTER||N.which===Ct.ENTER)&&(a==null||a(p))},role:f?"tab":"button","aria-expanded":i,"aria-disabled":_,tabIndex:_?-1:0},E=typeof v=="function"?v(e):ve.createElement("i",{className:"arrow"}),k=E&&ve.createElement("div",Yi({className:ae(`${u}-expand-icon`,l==null?void 0:l.icon),style:c==null?void 0:c.icon},["header","icon"].includes(d)?$:{}),E),T=ae(`${u}-item`,{[`${u}-item-active`]:i,[`${u}-item-disabled`]:_},s),P={className:ae(r,`${u}-header`,{[`${u}-collapsible-${d}`]:!!d},l==null?void 0:l.header),style:c==null?void 0:c.header,...["header","icon"].includes(d)?{}:$};return ve.createElement("div",Yi({},S,{ref:t,className:T}),ve.createElement("div",P,n&&k,ve.createElement("span",Yi({className:ae(`${u}-title`,l==null?void 0:l.title),style:c==null?void 0:c.title},d==="header"?$:{}),g),C&&ve.createElement("div",{className:`${u}-extra`},h)),ve.createElement(Ti,Yi({visible:i,leavedClassName:`${u}-panel-hidden`},y,{forceRender:o,removeOnLeave:x}),({className:N,style:A},M)=>ve.createElement(CHe,{ref:M,prefixCls:u,className:N,classNames:l,style:A,styles:c,isActive:i,forceRender:o,role:f?"tabpanel":void 0},w)))});function Pwe(e,t,n){if(!e||!t)return e||t;const r=Array.from(new Set([...Object.keys(e),...Object.keys(t)])),i={};return r.forEach(a=>{i[a]=n(e[a],t[a])}),i}function $He(e,t){return Pwe(e,t,(n,r)=>ae(n,r))}function EHe(e,t){return Pwe(e,t,(n,r)=>({...n,...r}))}const THe=(e,t)=>{const{prefixCls:n,accordion:r,collapsible:i,destroyOnHidden:a,onItemClick:o,activeKey:s,openMotion:l,expandIcon:c,classNames:u,styles:d}=t;return e.map((f,p)=>{const{children:h,label:g,key:v,collapsible:y,onItemClick:x,destroyOnHidden:w,classNames:S,styles:_,...C}=f,$=String(v??p),E=y??i,k=w??a,T=P=>{E!=="disabled"&&(o(P),x==null||x(P))};let I=!1;return r?I=s[0]===$:I=s.indexOf($)>-1,ve.createElement(kwe,Yi({},C,{classNames:$He(u,S),styles:EHe(d,_),prefixCls:n,key:$,panelKey:$,isActive:I,accordion:r,openMotion:l,expandIcon:c,header:g,collapsible:E,onItemClick:T,destroyOnHidden:k}),h)})},IHe=(e,t,n)=>{if(!e)return null;const{prefixCls:r,accordion:i,collapsible:a,destroyOnHidden:o,onItemClick:s,activeKey:l,openMotion:c,expandIcon:u,classNames:d,styles:f}=n,p=e.key||String(t),{header:h,headerClass:g,destroyOnHidden:v,collapsible:y,onItemClick:x}=e.props;let w=!1;i?w=l[0]===p:w=l.indexOf(p)>-1;const S=y??a,_=$=>{S!=="disabled"&&(s($),x==null||x($))},C={key:p,panelKey:p,header:h,headerClass:g,classNames:d,styles:f,isActive:w,prefixCls:r,destroyOnHidden:v??o,openMotion:c,accordion:i,children:e.props.children,onItemClick:_,expandIcon:u,collapsible:S};return typeof e.type=="string"?e:(Object.keys(C).forEach($=>{typeof C[$]>"u"&&delete C[$]}),ve.cloneElement(e,C))};function kHe(e,t,n){return Array.isArray(e)?THe(e,n):Li(t).map((r,i)=>IHe(r,i,n))}function Sre(e){let t=e;if(!Array.isArray(t)){const n=typeof t;t=n==="number"||n==="string"?[t]:[]}return t.map(n=>String(n))}const PHe=ve.forwardRef((e,t)=>{const{prefixCls:n="rc-collapse",destroyOnHidden:r=!1,style:i,accordion:a,className:o,children:s,collapsible:l,openMotion:c,expandIcon:u,activeKey:d,defaultActiveKey:f,onChange:p,items:h,classNames:g,styles:v}=e,y=ae(n,o),[x,w]=Rn(f,d),S=Sre(x),_=Dt(E=>{const k=Sre(E);w(k),p==null||p(k)}),C=E=>{_(a?S[0]===E?[]:[E]:S.includes(E)?S.filter(k=>k!==E):[...S,E])};xr(!s,"[rc-collapse] `children` will be removed in next major version. Please use `items` instead.");const $=kHe(h,s,{prefixCls:n,accordion:a,openMotion:c,expandIcon:u,collapsible:l,destroyOnHidden:r,onItemClick:C,activeKey:S,classNames:g,styles:v});return ve.createElement("div",Yi({ref:t,className:y,style:i,role:a?"tablist":void 0},Sr(e,{aria:!0,data:!0})),$)}),Hq=Object.assign(PHe,{Panel:kwe}),{Panel:rrn}=Hq,NHe=m.forwardRef((e,t)=>{const{getPrefixCls:n}=m.useContext(Vt),{prefixCls:r,className:i,showArrow:a=!0}=e,o=n("collapse",r),s=ae({[`${o}-no-arrow`]:!a},i);return m.createElement(Hq.Panel,{ref:t,...e,prefixCls:o,className:s})}),bE=e=>({[e.componentCls]:{[`${e.antCls}-motion-collapse-legacy`]:{overflow:"hidden","&-active":{transition:`height ${e.motionDurationMid} ${e.motionEaseInOut},
|
|
184
|
+
`]:{animationPlayState:"running"},[`${t}-move-up-leave`]:{animationName:S,animationDuration:d,animationPlayState:"paused",animationTimingFunction:u},[`${t}-move-up-leave${t}-move-up-leave-active`]:{animationPlayState:"running"},"&-rtl":{direction:"rtl",span:{direction:"rtl"}}}},{[t]:{[`${x}-wrapper`]:{..._}}},{[`${t}-notice-pure-panel`]:{..._,padding:0,textAlign:"start"}}]},G9e=e=>({zIndexPopup:e.zIndexPopupBase+Oq+10,contentBg:e.colorBgElevated,contentPadding:`${(e.controlHeightLG-e.fontSize*e.lineHeight)/2}px ${e.paddingSM}px`}),Cwe=bn("Message",e=>{const t=fn(e,{height:150});return U9e(t)},G9e),q9e={info:m.createElement(QD,null),success:m.createElement(Gh,null),error:m.createElement(Lf,null),warning:m.createElement(ly,null),loading:m.createElement(ql,null)},$we=e=>{const{prefixCls:t,type:n,icon:r,children:i,classNames:a,styles:o}=e,s=r||n&&q9e[n],l=oi(s,c=>{const u={...c==null?void 0:c.style,...o==null?void 0:o.icon};return{className:ae(c.className,a==null?void 0:a.icon),style:u}});return m.createElement("div",{className:ae(`${t}-custom-content`,`${t}-${n}`)},l,m.createElement("span",{className:a==null?void 0:a.content,style:o==null?void 0:o.content},i))},K9e=e=>{const{prefixCls:t,className:n,style:r,type:i,icon:a,content:o,classNames:s,styles:l,...c}=e,{getPrefixCls:u,className:d,style:f,classNames:p,styles:h}=sn("message"),g=t||u("message"),v=Pr(g),[y,x]=Cwe(g,v),[w,S]=cn([p,s],[h,l],{props:e});return m.createElement(zq,{...c,prefixCls:g,className:ae(d,w.root,n,y,`${g}-notice-pure-panel`,x,v),style:{...S.root,...f,...r},eventKey:"pure",duration:null,content:m.createElement($we,{prefixCls:g,type:i,icon:a,classNames:w,styles:S},o)})};function Y9e(e,t){return{motionName:t??`${e}-move-up`}}function Fq(e){let t;const n=new Promise(i=>{t=e(()=>{i(!0)})}),r=()=>{t==null||t()};return r.then=(i,a)=>n.then(i,a),r.promise=n,r}const X9e=8,Z9e=3,Q9e=({children:e,prefixCls:t})=>{const n=Pr(t),[r,i]=Cwe(t,n);return m.createElement(Swe,{classNames:{list:ae(r,i,n)}},e)},J9e=(e,{prefixCls:t,key:n})=>m.createElement(Q9e,{prefixCls:t,key:n},e),eHe=m.forwardRef((e,t)=>{const{top:n,prefixCls:r,getContainer:i,maxCount:a,duration:o=Z9e,rtl:s,transitionName:l,onAllRemoved:c,pauseOnHover:u=!0}=e,{getPrefixCls:d,direction:f,getPopupContainer:p}=sn("message"),{message:h}=m.useContext(Vt),g=r||d("message"),v=()=>({left:"50%",transform:"translateX(-50%)",top:n??X9e}),y=()=>ae({[`${g}-rtl`]:s??f==="rtl"}),x=()=>Y9e(g,l),[w,S]=cn([e==null?void 0:e.classNames,h==null?void 0:h.classNames],[e==null?void 0:e.styles,h==null?void 0:h.styles],{props:e}),[_,C]=_we({prefixCls:g,style:v,className:y,motion:x,closable:!1,duration:o,getContainer:()=>(i==null?void 0:i())||(p==null?void 0:p())||document.body,maxCount:a,onAllRemoved:c,renderNotifications:J9e,pauseOnHover:u});return m.useImperativeHandle(t,()=>({..._,prefixCls:g,message:h,classNames:w,styles:S})),C});let mre=0;function Ewe(e){const t=m.useRef(null);return Rf(),[m.useMemo(()=>{const r=l=>{var c;(c=t.current)==null||c.close(l)},i=l=>{if(!t.current){const V=()=>{};return V.then=()=>{},V}const{open:c,prefixCls:u,message:d,classNames:f,styles:p}=t.current,h=(d==null?void 0:d.className)||{},g=(d==null?void 0:d.style)||{},v=(d==null?void 0:d.classNames)||{},y=(d==null?void 0:d.styles)||{},x=`${u}-notice`,{content:w,icon:S,type:_,key:C,className:$,style:E,onClose:k,classNames:T={},styles:I={},...P}=l;let N=C;Hr(N)||(mre+=1,N=`antd-message-${mre}`);const A={...e,...l},M=Hp(v,{props:A}),R=Hp(T,{props:A}),L=Hp(y,{props:A}),z=Hp(I,{props:A}),j=eO(void 0,M,R,f),O=Dq(L,z,p);return Fq(V=>(c({...P,key:N,content:m.createElement($we,{prefixCls:u,type:_,icon:S,classNames:j,styles:O},w),placement:"top",className:ae({[`${x}-${_}`]:_},$,h,j.root),style:{...O.root,...g,...E},onClose:()=>{k==null||k(),V()}}),()=>{r(N)}))},o={open:i,destroy:l=>{var c;l!==void 0?r(l):(c=t.current)==null||c.destroy()}};return["info","success","warning","error","loading"].forEach(l=>{const c=(u,d,f)=>{let p;u&&typeof u=="object"&&"content"in u?p=u:p={content:u};let h,g;typeof d=="function"?g=d:(h=d,g=f);const v={onClose:g,duration:h,...p,type:l};return i(v)};o[l]=c}),o},[]),m.createElement(eHe,{key:"message-holder",...e,ref:t})]}function tHe(e){return Ewe(e)}const $4=()=>({height:0,opacity:0}),gre=e=>{const{scrollHeight:t}=e;return{height:t,opacity:1}},nHe=e=>({height:e?e.offsetHeight:0}),E4=(e,t)=>(t==null?void 0:t.deadline)===!0||t.propertyName==="height",Lx=(e=r$)=>({motionName:`${e}-motion-collapse`,onAppearStart:$4,onEnterStart:$4,onAppearActive:gre,onEnterActive:gre,onLeaveStart:nHe,onLeaveActive:$4,onAppearEnd:E4,onEnterEnd:E4,onLeaveEnd:E4,motionDeadline:500}),Lc=(e,t,n)=>n!==void 0?n:`${e}-${t}`,rHe=e=>{const{componentCls:t,colorPrimary:n,antCls:r}=e,[,i]=Jn(r,"wave");return{[t]:{position:"absolute",background:"transparent",pointerEvents:"none",boxSizing:"border-box",color:i("color",n),boxShadow:"0 0 0 0 currentcolor",opacity:.2,"&.wave-motion-appear":{transition:[`box-shadow 0.4s ${e.motionEaseOutCirc}`,`opacity 2s ${e.motionEaseOutCirc}`].join(","),"&-active":{boxShadow:"0 0 0 6px currentcolor",opacity:0},"&.wave-quick":{transition:[`box-shadow ${e.motionDurationSlow} ${e.motionEaseInOut}`,`opacity ${e.motionDurationSlow} ${e.motionEaseInOut}`].join(",")}}}}},iHe=H8e("Wave",rHe),yE=`${r$}-wave-target`;function vre(e){return e&&typeof e=="string"&&e!=="#fff"&&e!=="#ffffff"&&e!=="rgb(255, 255, 255)"&&e!=="rgba(255, 255, 255, 1)"&&!/rgba\((?:\d*, ){3}0\)/.test(e)&&e!=="transparent"&&e!=="canvastext"}function aHe(e,t=null){const n=getComputedStyle(e),{borderTopColor:r,borderColor:i,backgroundColor:a}=n;return t&&vre(n[t])?n[t]:[r,i,a].find(vre)??null}function T4(e){return Number.isNaN(e)?0:e}const oHe=e=>{const{className:t,target:n,component:r,colorSource:i}=e,a=m.useRef(null),{getPrefixCls:o}=m.useContext(Vt),s=o(),[l]=Jn(s,"wave"),[c,u]=m.useState(null),[d,f]=m.useState([]),[p,h]=m.useState(0),[g,v]=m.useState(0),[y,x]=m.useState(0),[w,S]=m.useState(0),[_,C]=m.useState(!1),$={left:p,top:g,width:y,height:w,borderRadius:d.map(T=>`${T}px`).join(" ")};c&&($[l("color")]=c);function E(){const T=getComputedStyle(n);u(aHe(n,i));const I=T.position==="static",{borderLeftWidth:P,borderTopWidth:N}=T;h(I?n.offsetLeft:T4(-Number.parseFloat(P))),v(I?n.offsetTop:T4(-Number.parseFloat(N))),x(n.offsetWidth),S(n.offsetHeight);const{borderTopLeftRadius:A,borderTopRightRadius:M,borderBottomLeftRadius:R,borderBottomRightRadius:L}=T;f([A,M,L,R].map(z=>T4(Number.parseFloat(z))))}if(m.useEffect(()=>{if(n){const T=on(()=>{E(),C(!0)});let I;return typeof ResizeObserver<"u"&&(I=new ResizeObserver(E),I.observe(n)),()=>{on.cancel(T),I==null||I.disconnect()}}},[n]),!_)return null;const k=(r==="Checkbox"||r==="Radio")&&(n==null?void 0:n.classList.contains(yE));return m.createElement(Ti,{visible:!0,motionAppear:!0,motionName:"wave-motion",motionDeadline:5e3,onAppearEnd:(T,I)=>{var P;if(I.deadline||I.propertyName==="opacity"){const N=(P=a.current)==null?void 0:P.parentElement;s1e(N).then(()=>{N==null||N.remove()})}return!1}},({className:T},I)=>m.createElement("div",{ref:ta(a,I),className:ae(t,T,{"wave-quick":k}),style:$}))},sHe=(e,t)=>{var i;const{component:n}=t;if(n==="Checkbox"&&!((i=e.querySelector("input"))!=null&&i.checked))return;const r=document.createElement("div");r.style.position="absolute",r.style.left="0px",r.style.top="0px",e==null||e.insertBefore(r,e==null?void 0:e.firstChild),UD(m.createElement(oHe,{...t,target:e}),r)},lHe=(e,t,n,r)=>{const{wave:i}=m.useContext(Vt),[,a,o]=Za(),s=Dt(u=>{const d=e.current;if(i!=null&&i.disabled||!d)return;const f=d.querySelector(`.${yE}`)||d,{showEffect:p}=i||{};(p||sHe)(f,{className:t,token:a,component:n,event:u,hashId:o,colorSource:r})}),l=m.useRef(null);return m.useEffect(()=>()=>{on.cancel(l.current)},[]),u=>{on.cancel(l.current),l.current=on(()=>{s(u)})}},F1=e=>{const{children:t,disabled:n,component:r,colorSource:i}=e,{getPrefixCls:a}=m.useContext(Vt),o=m.useRef(null),s=a("wave"),l=iHe(s),c=lHe(o,ae(s,l),r,i);if(ve.useEffect(()=>{const d=o.current;if(!d||d.nodeType!==window.Node.ELEMENT_NODE||n)return;const f=p=>{!O1(p.target)||!d.getAttribute||d.getAttribute("disabled")||d.disabled||d.className.includes("disabled")&&!d.className.includes("disabled:")||d.getAttribute("aria-disabled")==="true"||d.className.includes("-leave")||c(p)};return d.addEventListener("click",f,!0),()=>{d.removeEventListener("click",f,!0)}},[n]),!ve.isValidElement(t))return t??null;const u=Bu(t)?ta(Mf(t),o):o;return oi(t,{ref:u})},Ii=e=>{const t=ve.useContext(yv);return ve.useMemo(()=>e?typeof e=="string"?e??t:typeof e=="function"?e(t):t:t,[e,t])},cHe=e=>{const{componentCls:t}=e;return{[t]:{display:"inline-flex","&-block":{display:"flex",width:"100%"},"&-vertical":{flexDirection:"column"},"&-rtl":{direction:"rtl"}}}},uHe=bn(["Space","Compact"],e=>[cHe(e)],()=>({}),{resetStyle:!1}),tO=m.createContext(null),id=(e,t)=>{const n=m.useContext(tO),r=m.useMemo(()=>{if(!n)return"";const{compactDirection:i,isFirstItem:a,isLastItem:o}=n,s=i==="vertical"?"-vertical-":"-";return ae(`${e}-compact${s}item`,{[`${e}-compact${s}first-item`]:a,[`${e}-compact${s}last-item`]:o,[`${e}-compact${s}item-rtl`]:t==="rtl"})},[e,t,n]);return{compactSize:n==null?void 0:n.compactSize,compactDirection:n==null?void 0:n.compactDirection,compactItemClassnames:r}},dHe=e=>{const{children:t}=e;return m.createElement(tO.Provider,{value:null},t)},fHe=e=>{const{children:t,...n}=e;return m.createElement(tO.Provider,{value:m.useMemo(()=>n,[n])},t)},Bq=e=>{const{getPrefixCls:t,direction:n}=m.useContext(Vt),{size:r,direction:i,orientation:a,block:o,prefixCls:s,className:l,rootClassName:c,children:u,vertical:d,...f}=e,[p,h]=hE(a,d,i),g=Ii(C=>r??C),v=t("space-compact",s),[y]=uHe(v),x=ae(v,y,{[`${v}-rtl`]:n==="rtl",[`${v}-block`]:o,[`${v}-vertical`]:h},l,c),w=m.useContext(tO),S=Li(u),_=m.useMemo(()=>S.map((C,$)=>{const E=(C==null?void 0:C.key)||`${v}-item-${$}`;return m.createElement(fHe,{key:E,compactSize:g,compactDirection:p,isFirstItem:$===0&&(!w||(w==null?void 0:w.isFirstItem)),isLastItem:$===S.length-1&&(!w||(w==null?void 0:w.isLastItem))},C)}),[S,w,p,g,v]);return S.length===0?null:m.createElement("div",{className:x,...f},_)},Twe=m.createContext(void 0),pHe=e=>{const{getPrefixCls:t,direction:n}=m.useContext(Vt),{prefixCls:r,size:i,className:a,...o}=e,s=t("btn-group",r),[,,l]=Za(),c=m.useMemo(()=>{switch(i){case"large":return"lg";case"small":return"sm";default:return""}},[i]),u=ae(s,{[`${s}-${c}`]:c,[`${s}-rtl`]:n==="rtl"},a,l);return m.createElement(Twe.Provider,{value:i},m.createElement("div",{...o,className:u}))},yre=/^[\u4E00-\u9FA5]{2}$/,a8=yre.test.bind(yre);function Vq(e){return e==="danger"?{danger:!0}:{type:e}}function bre(e){return typeof e=="string"}function I4(e){return e==="text"||e==="link"}function hHe(e,t,n,r){if(!Hr(e)||e==="")return;const i=t?" ":"";return typeof e!="string"&&typeof e!="number"&&bre(e.type)&&a8(e.props.children)?oi(e,a=>{const o=ae(a.className,r)||void 0,s={...n,...a.style};return{...a,children:a.children.split("").join(i),className:o,style:s}}):bre(e)?ve.createElement("span",{className:r,style:n},a8(e)?e.split("").join(i):e):mwe(e)?ve.createElement("span",{className:r,style:n},e):oi(e,a=>({...a,className:ae(a.className,r)||void 0,style:{...a.style,...n}}))}function mHe(e,t,n,r){let i=!1;const a=[];return ve.Children.forEach(e,o=>{const s=typeof o,l=s==="string"||s==="number";if(i&&l){const c=a.length-1,u=a[c];a[c]=`${u}${o}`}else a.push(o);i=l}),ve.Children.map(a,o=>hHe(o,t,n,r))}["default","primary","danger"].concat(Qt(Th));const Iwe=m.forwardRef((e,t)=>{const{className:n,style:r,children:i,prefixCls:a}=e,o=ae(`${a}-icon`,n);return ve.createElement("span",{ref:t,className:o,style:r},i)}),xre=m.forwardRef((e,t)=>{const{prefixCls:n,className:r,style:i,iconClassName:a}=e,o=ae(`${n}-loading-icon`,r);return ve.createElement(Iwe,{prefixCls:n,className:o,style:i,ref:t},ve.createElement(ql,{className:a}))}),k4=()=>({width:0,opacity:0,transform:"scale(0)"}),P4=e=>({width:e.scrollWidth,opacity:1,transform:"scale(1)"}),gHe=e=>{const{prefixCls:t,loading:n,existIcon:r,className:i,style:a,mount:o}=e,s=!!n;return r?ve.createElement(xre,{prefixCls:t,className:i,style:a}):ve.createElement(Ti,{visible:s,motionName:`${t}-loading-icon-motion`,motionAppear:!o,motionEnter:!o,motionLeave:!o,removeOnLeave:!0,onAppearStart:k4,onAppearActive:P4,onEnterStart:k4,onEnterActive:P4,onLeaveStart:P4,onLeaveActive:k4},({className:l,style:c},u)=>{const d={...a,...c};return ve.createElement(xre,{prefixCls:t,className:ae(i,l),style:d,ref:u})})},wre=(e,t)=>({[`> span, > ${e}`]:{"&:not(:last-child)":{[`&, & > ${e}`]:{"&:not(:disabled)":{borderInlineEndColor:t}}},"&:not(:first-child)":{[`&, & > ${e}`]:{"&:not(:disabled)":{borderInlineStartColor:t}}}}}),vHe=e=>{const{componentCls:t,fontSize:n,lineWidth:r,groupBorderColor:i,colorErrorHover:a}=e;return{[`${t}-group`]:[{position:"relative",display:"inline-flex",[`> span, > ${t}`]:{"&:not(:last-child)":{[`&, & > ${t}`]:{borderStartEndRadius:0,borderEndEndRadius:0}},"&:not(:first-child)":{marginInlineStart:e.calc(r).mul(-1).equal(),[`&, & > ${t}`]:{borderStartStartRadius:0,borderEndStartRadius:0}}},[t]:{position:"relative",zIndex:1,"&:hover, &:focus, &:active":{zIndex:2},"&[disabled]":{zIndex:0}},[`${t}-icon-only`]:{fontSize:n}},wre(`${t}-primary`,i),wre(`${t}-danger`,a)]}},N4=e=>Math.round(Number(e||0)),yHe=e=>{if(e instanceof _n)return e;if(e&&typeof e=="object"&&"h"in e&&"b"in e){const{b:t,...n}=e;return{...n,v:t}}return typeof e=="string"&&/hsb/.test(e)?e.replace(/hsb/,"hsv"):e};let d$=class extends _n{constructor(t){super(yHe(t))}toHsbString(){const t=this.toHsb(),n=N4(t.s*100),r=N4(t.b*100),i=N4(t.h),a=t.a,o=`hsb(${i}, ${n}%, ${r}%)`,s=`hsba(${i}, ${n}%, ${r}%, ${a.toFixed(a===0?0:2)})`;return a===1?o:s}toHsb(){const{v:t,...n}=this.toHsv();return{...n,b:t,a:this.a}}};const bHe=e=>e instanceof d$?e:new d$(e);bHe("#1677ff");const xHe=(e,t)=>(e==null?void 0:e.replace(/[^\w/]/g,"").slice(0,t?8:6))||"",wHe=(e,t)=>e?xHe(e,t):"";let MA=function(){function e(t){var r;if(Df(this,e),this.cleared=!1,t instanceof e){this.metaColor=t.metaColor.clone(),this.colors=(r=t.colors)==null?void 0:r.map(i=>({color:new e(i.color),percent:i.percent})),this.cleared=t.cleared;return}const n=Array.isArray(t);n&&t.length?(this.colors=t.map(({color:i,percent:a})=>({color:new e(i),percent:a})),this.metaColor=new d$(this.colors[0].color.metaColor)):this.metaColor=new d$(n?"":t),(!t||n&&!this.colors)&&(this.metaColor=this.metaColor.setA(0),this.cleared=!0)}return Of(e,[{key:"toHsb",value:function(){return this.metaColor.toHsb()}},{key:"toHsbString",value:function(){return this.metaColor.toHsbString()}},{key:"toHex",value:function(){return wHe(this.toHexString(),this.metaColor.a<1)}},{key:"toHexString",value:function(){return this.metaColor.toHexString()}},{key:"toRgb",value:function(){return this.metaColor.toRgb()}},{key:"toRgbString",value:function(){return this.metaColor.toRgbString()}},{key:"isGradient",value:function(){return!!this.colors&&!this.cleared}},{key:"getColors",value:function(){return this.colors||[{color:this,percent:0}]}},{key:"toCssString",value:function(){const{colors:n}=this;return n?`linear-gradient(90deg, ${n.map(i=>`${i.color.toRgbString()} ${i.percent}%`).join(", ")})`:this.metaColor.toRgbString()}},{key:"equals",value:function(n){return!n||this.isGradient()!==n.isGradient()?!1:this.isGradient()?this.colors.length===n.colors.length&&this.colors.every((r,i)=>{const a=n.colors[i];return r.percent===a.percent&&r.color.equals(a.color)}):this.toHexString()===n.toHexString()}}])}();var SHe={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"}}]},name:"right",theme:"outlined"};function o8(){return o8=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o8.apply(this,arguments)}const _He=(e,t)=>m.createElement($t,o8({},e,{ref:t,icon:SHe})),Ih=m.forwardRef(_He);function Yi(){return Yi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Yi.apply(null,arguments)}const CHe=ve.forwardRef((e,t)=>{const{prefixCls:n,forceRender:r,className:i,style:a,children:o,isActive:s,role:l,classNames:c,styles:u}=e,[d,f]=ve.useState(s||r);return ve.useEffect(()=>{(r||s)&&f(!0)},[r,s]),d?ve.createElement("div",{ref:t,className:ae(`${n}-panel`,{[`${n}-panel-active`]:s,[`${n}-panel-inactive`]:!s},i),style:a,role:l},ve.createElement("div",{className:ae(`${n}-body`,c==null?void 0:c.body),style:u==null?void 0:u.body},o)):null}),kwe=ve.forwardRef((e,t)=>{const{showArrow:n=!0,headerClass:r,isActive:i,onItemClick:a,forceRender:o,className:s,classNames:l={},styles:c={},prefixCls:u,collapsible:d,accordion:f,panelKey:p,extra:h,header:g,expandIcon:v,openMotion:y,destroyOnHidden:x,children:w,...S}=e,_=d==="disabled",C=h!=null&&typeof h!="boolean",$={onClick:()=>{a==null||a(p)},onKeyDown:N=>{(N.key==="Enter"||N.keyCode===Ct.ENTER||N.which===Ct.ENTER)&&(a==null||a(p))},role:f?"tab":"button","aria-expanded":i,"aria-disabled":_,tabIndex:_?-1:0},E=typeof v=="function"?v(e):ve.createElement("i",{className:"arrow"}),k=E&&ve.createElement("div",Yi({className:ae(`${u}-expand-icon`,l==null?void 0:l.icon),style:c==null?void 0:c.icon},["header","icon"].includes(d)?$:{}),E),T=ae(`${u}-item`,{[`${u}-item-active`]:i,[`${u}-item-disabled`]:_},s),P={className:ae(r,`${u}-header`,{[`${u}-collapsible-${d}`]:!!d},l==null?void 0:l.header),style:c==null?void 0:c.header,...["header","icon"].includes(d)?{}:$};return ve.createElement("div",Yi({},S,{ref:t,className:T}),ve.createElement("div",P,n&&k,ve.createElement("span",Yi({className:ae(`${u}-title`,l==null?void 0:l.title),style:c==null?void 0:c.title},d==="header"?$:{}),g),C&&ve.createElement("div",{className:`${u}-extra`},h)),ve.createElement(Ti,Yi({visible:i,leavedClassName:`${u}-panel-hidden`},y,{forceRender:o,removeOnLeave:x}),({className:N,style:A},M)=>ve.createElement(CHe,{ref:M,prefixCls:u,className:N,classNames:l,style:A,styles:c,isActive:i,forceRender:o,role:f?"tabpanel":void 0},w)))});function Pwe(e,t,n){if(!e||!t)return e||t;const r=Array.from(new Set([...Object.keys(e),...Object.keys(t)])),i={};return r.forEach(a=>{i[a]=n(e[a],t[a])}),i}function $He(e,t){return Pwe(e,t,(n,r)=>ae(n,r))}function EHe(e,t){return Pwe(e,t,(n,r)=>({...n,...r}))}const THe=(e,t)=>{const{prefixCls:n,accordion:r,collapsible:i,destroyOnHidden:a,onItemClick:o,activeKey:s,openMotion:l,expandIcon:c,classNames:u,styles:d}=t;return e.map((f,p)=>{const{children:h,label:g,key:v,collapsible:y,onItemClick:x,destroyOnHidden:w,classNames:S,styles:_,...C}=f,$=String(v??p),E=y??i,k=w??a,T=P=>{E!=="disabled"&&(o(P),x==null||x(P))};let I=!1;return r?I=s[0]===$:I=s.indexOf($)>-1,ve.createElement(kwe,Yi({},C,{classNames:$He(u,S),styles:EHe(d,_),prefixCls:n,key:$,panelKey:$,isActive:I,accordion:r,openMotion:l,expandIcon:c,header:g,collapsible:E,onItemClick:T,destroyOnHidden:k}),h)})},IHe=(e,t,n)=>{if(!e)return null;const{prefixCls:r,accordion:i,collapsible:a,destroyOnHidden:o,onItemClick:s,activeKey:l,openMotion:c,expandIcon:u,classNames:d,styles:f}=n,p=e.key||String(t),{header:h,headerClass:g,destroyOnHidden:v,collapsible:y,onItemClick:x}=e.props;let w=!1;i?w=l[0]===p:w=l.indexOf(p)>-1;const S=y??a,_=$=>{S!=="disabled"&&(s($),x==null||x($))},C={key:p,panelKey:p,header:h,headerClass:g,classNames:d,styles:f,isActive:w,prefixCls:r,destroyOnHidden:v??o,openMotion:c,accordion:i,children:e.props.children,onItemClick:_,expandIcon:u,collapsible:S};return typeof e.type=="string"?e:(Object.keys(C).forEach($=>{typeof C[$]>"u"&&delete C[$]}),ve.cloneElement(e,C))};function kHe(e,t,n){return Array.isArray(e)?THe(e,n):Li(t).map((r,i)=>IHe(r,i,n))}function Sre(e){let t=e;if(!Array.isArray(t)){const n=typeof t;t=n==="number"||n==="string"?[t]:[]}return t.map(n=>String(n))}const PHe=ve.forwardRef((e,t)=>{const{prefixCls:n="rc-collapse",destroyOnHidden:r=!1,style:i,accordion:a,className:o,children:s,collapsible:l,openMotion:c,expandIcon:u,activeKey:d,defaultActiveKey:f,onChange:p,items:h,classNames:g,styles:v}=e,y=ae(n,o),[x,w]=Rn(f,d),S=Sre(x),_=Dt(E=>{const k=Sre(E);w(k),p==null||p(k)}),C=E=>{_(a?S[0]===E?[]:[E]:S.includes(E)?S.filter(k=>k!==E):[...S,E])};xr(!s,"[rc-collapse] `children` will be removed in next major version. Please use `items` instead.");const $=kHe(h,s,{prefixCls:n,accordion:a,openMotion:c,expandIcon:u,collapsible:l,destroyOnHidden:r,onItemClick:C,activeKey:S,classNames:g,styles:v});return ve.createElement("div",Yi({ref:t,className:y,style:i,role:a?"tablist":void 0},Sr(e,{aria:!0,data:!0})),$)}),Hq=Object.assign(PHe,{Panel:kwe}),{Panel:nrn}=Hq,NHe=m.forwardRef((e,t)=>{const{getPrefixCls:n}=m.useContext(Vt),{prefixCls:r,className:i,showArrow:a=!0}=e,o=n("collapse",r),s=ae({[`${o}-no-arrow`]:!a},i);return m.createElement(Hq.Panel,{ref:t,...e,prefixCls:o,className:s})}),bE=e=>({[e.componentCls]:{[`${e.antCls}-motion-collapse-legacy`]:{overflow:"hidden","&-active":{transition:`height ${e.motionDurationMid} ${e.motionEaseInOut},
|
|
185
185
|
opacity ${e.motionDurationMid} ${e.motionEaseInOut} !important`}},[`${e.antCls}-motion-collapse`]:{overflow:"hidden",transition:`height ${e.motionDurationMid} ${e.motionEaseInOut},
|
|
186
186
|
opacity ${e.motionDurationMid} ${e.motionEaseInOut} !important`}}}),AHe=e=>({animationDuration:e,animationFillMode:"both"}),MHe=e=>({animationDuration:e,animationFillMode:"both"}),nO=(e,t,n,r,i=!1)=>{const a=i?"&":"";return{[`
|
|
187
187
|
${a}${e}-enter,
|
|
@@ -717,7 +717,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
717
717
|
`))+1))}const o="#".repeat(i),s=n.enter("headingAtx"),l=n.enter("phrasing");a.move(o+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
|
|
718
718
|
`,...a.current()});return/^[\t ]/.test(c)&&(c=j2(c.charCodeAt(0))+c.slice(1)),c=c?o+" "+c:o,n.options.closeAtx&&(c+=" "+o),l(),s(),c}WDe.peek=Y8t;function WDe(e){return e.value||""}function Y8t(){return"<"}UDe.peek=X8t;function UDe(e,t,n,r){const i=OQ(n),a=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let s=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(s=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),s(),e.title&&(s=n.enter(`title${a}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),s()),c+=l.move(")"),o(),c}function X8t(){return"!"}GDe.peek=Z8t;function GDe(e,t,n,r){const i=e.referenceType,a=n.enter("imageReference");let o=n.enter("label");const s=n.createTracker(r);let l=s.move("![");const c=n.safe(e.alt,{before:l,after:"]",...s.current()});l+=s.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...s.current()});return o(),n.stack=u,a(),i==="full"||!c||c!==d?l+=s.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=s.move("]"),l}function Z8t(){return"!"}qDe.peek=Q8t;function qDe(e,t,n){let r=e.value||"",i="`",a=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){const o=n.unsafe[a],s=n.compilePattern(o);let l;if(o.atBreak)for(;l=s.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function Q8t(){return"`"}function KDe(e,t){const n=TQ(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}YDe.peek=J8t;function YDe(e,t,n,r){const i=OQ(n),a=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let s,l;if(KDe(e,n)){const u=n.stack;n.stack=[],s=n.enter("autolink");let d=o.move("<");return d+=o.move(n.containerPhrasing(e,{before:d,after:">",...o.current()})),d+=o.move(">"),s(),n.stack=u,d}s=n.enter("link"),l=n.enter("label");let c=o.move("[");return c+=o.move(n.containerPhrasing(e,{before:c,after:"](",...o.current()})),c+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(n.safe(e.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(l=n.enter("destinationRaw"),c+=o.move(n.safe(e.url,{before:c,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${a}`),c+=o.move(" "+i),c+=o.move(n.safe(e.title,{before:c,after:i,...o.current()})),c+=o.move(i),l()),c+=o.move(")"),s(),c}function J8t(e,t,n){return KDe(e,n)?"<":"["}XDe.peek=eVt;function XDe(e,t,n,r){const i=e.referenceType,a=n.enter("linkReference");let o=n.enter("label");const s=n.createTracker(r);let l=s.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...s.current()});l+=s.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...s.current()});return o(),n.stack=u,a(),i==="full"||!c||c!==d?l+=s.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=s.move("]"),l}function eVt(){return"["}function LQ(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function tVt(e){const t=LQ(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function nVt(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function ZDe(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function rVt(e,t,n,r){const i=n.enter("list"),a=n.bulletCurrent;let o=e.ordered?nVt(n):LQ(n);const s=e.ordered?o==="."?")":".":tVt(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const u=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),ZDe(n)===o&&u){let d=-1;for(;++d<e.children.length;){const f=e.children[d];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=s),n.bulletCurrent=o;const c=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),c}function iVt(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function aVt(e,t,n,r){const i=iVt(n);let a=n.bulletCurrent||LQ(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const s=n.createTracker(r);s.move(a+" ".repeat(o-a.length)),s.shift(o);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,s.current()),u);return l(),c;function u(d,f,p){return f?(p?"":" ".repeat(o))+d:(p?a:a+" ".repeat(o-a.length))+d}}function oVt(e,t,n,r){const i=n.enter("paragraph"),a=n.enter("phrasing"),o=n.containerPhrasing(e,r);return a(),i(),o}const sVt=tj(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function lVt(e,t,n,r){return(e.children.some(function(o){return sVt(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function cVt(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}QDe.peek=uVt;function QDe(e,t,n,r){const i=cVt(n),a=n.enter("strong"),o=n.createTracker(r),s=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()}));const c=l.charCodeAt(0),u=BR(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(l=j2(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=BR(r.after.charCodeAt(0),d,i);f.inside&&(l=l.slice(0,-1)+j2(d));const p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+l+p}function uVt(e,t,n){return n.options.strong||"*"}function dVt(e,t,n,r){return n.safe(e.value,r)}function fVt(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function pVt(e,t,n){const r=(ZDe(n)+(n.options.ruleSpaces?" ":"")).repeat(fVt(n));return n.options.ruleSpaces?r.slice(0,-1):r}const JDe={blockquote:O8t,break:kge,code:V8t,definition:W8t,emphasis:HDe,hardBreak:kge,heading:K8t,html:WDe,image:UDe,imageReference:GDe,inlineCode:qDe,link:YDe,linkReference:XDe,list:rVt,listItem:aVt,paragraph:oVt,root:lVt,strong:QDe,text:dVt,thematicBreak:pVt};function hVt(){return{enter:{table:mVt,tableData:Pge,tableHeader:Pge,tableRow:vVt},exit:{codeText:yVt,table:gVt,tableData:M6,tableHeader:M6,tableRow:M6}}}function mVt(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function gVt(e){this.exit(e),this.data.inTable=void 0}function vVt(e){this.enter({type:"tableRow",children:[]},e)}function M6(e){this.exit(e)}function Pge(e){this.enter({type:"tableCell",children:[]},e)}function yVt(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,bVt));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function bVt(e,t){return t==="|"?t:e}function xVt(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
719
719
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:o,tableCell:l,tableRow:s}};function o(p,h,g,v){return c(u(p,g,v),p.align)}function s(p,h,g,v){const y=d(p,g,v),x=c([y]);return x.slice(0,x.indexOf(`
|
|
720
|
-
`))}function l(p,h,g,v){const y=g.enter("tableCell"),x=g.enter("phrasing"),w=g.containerPhrasing(p,{...v,before:a,after:a});return x(),y(),w}function c(p,h){return R8t(p,{align:h,alignDelimiters:r,padding:n,stringLength:i})}function u(p,h,g){const v=p.children;let y=-1;const x=[],w=h.enter("table");for(;++y<v.length;)x[y]=d(v[y],h,g);return w(),x}function d(p,h,g){const v=p.children;let y=-1;const x=[],w=h.enter("tableRow");for(;++y<v.length;)x[y]=l(v[y],p,h,g);return w(),x}function f(p,h,g){let v=JDe.inlineCode(p,h,g);return g.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function wVt(){return{exit:{taskListCheckValueChecked:Nge,taskListCheckValueUnchecked:Nge,paragraph:_Vt}}}function SVt(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:CVt}}}function Nge(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function _Vt(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let a=-1,o;for(;++a<i.length;){const s=i[a];if(s.type==="paragraph"){o=s;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function CVt(e,t,n,r){const i=e.children[0],a=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(o);let l=JDe.listItem(e,t,n,{...r,...s.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function $Vt(){return[r8t(),C8t(),I8t(),hVt(),wVt()]}function EVt(e){return{extensions:[i8t(),$8t(e),k8t(),xVt(e),SVt()]}}const TVt={tokenize:MVt,partial:!0},eOe={tokenize:RVt,partial:!0},tOe={tokenize:DVt,partial:!0},nOe={tokenize:OVt,partial:!0},IVt={tokenize:LVt,partial:!0},rOe={name:"wwwAutolink",tokenize:NVt,previous:aOe},iOe={name:"protocolAutolink",tokenize:AVt,previous:oOe},Hf={name:"emailAutolink",tokenize:PVt,previous:sOe},ld={};function kVt(){return{text:ld}}let Rm=48;for(;Rm<123;)ld[Rm]=Hf,Rm++,Rm===58?Rm=65:Rm===91&&(Rm=97);ld[43]=Hf;ld[45]=Hf;ld[46]=Hf;ld[95]=Hf;ld[72]=[Hf,iOe];ld[104]=[Hf,iOe];ld[87]=[Hf,rOe];ld[119]=[Hf,rOe];function PVt(e,t,n){const r=this;let i,a;return o;function o(d){return!pU(d)||!sOe.call(r,r.previous)||jQ(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(d))}function s(d){return pU(d)?(e.consume(d),s):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(IVt,u,c)(d):d===45||d===95||po(d)?(a=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),i=!0,l}function u(d){return a&&i&&Bo(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function NVt(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!aOe.call(r,r.previous)||jQ(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(TVt,e.attempt(eOe,e.attempt(tOe,a),n),n)(o))}function a(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function AVt(e,t,n){const r=this;let i="",a=!1;return o;function o(d){return(d===72||d===104)&&oOe.call(r,r.previous)&&!jQ(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),s):n(d)}function s(d){if(Bo(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),s;if(d===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),a?c:(a=!0,l)):n(d)}function c(d){return d===null||jR(d)||Dr(d)||Yv(d)||QL(d)?n(d):e.attempt(eOe,e.attempt(tOe,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function MVt(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),a):n(o)}function a(o){return o===null?n(o):t(o)}}function RVt(e,t,n){let r,i,a;return o;function o(c){return c===46||c===95?e.check(nOe,l,s)(c):c===null||Dr(c)||Yv(c)||c!==45&&QL(c)?l(c):(a=!0,e.consume(c),o)}function s(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!a?n(c):t(c)}}function DVt(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(nOe,t,a)(o):o===null||Dr(o)||Yv(o)?t(o):(e.consume(o),i)}function a(o){return o===41&&r++,e.consume(o),i}}function OVt(e,t,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),r):s===38?(e.consume(s),a):s===93?(e.consume(s),i):s===60||s===null||Dr(s)||Yv(s)?t(s):n(s)}function i(s){return s===null||s===40||s===91||Dr(s)||Yv(s)?t(s):r(s)}function a(s){return Bo(s)?o(s):n(s)}function o(s){return s===59?(e.consume(s),r):Bo(s)?(e.consume(s),o):n(s)}}function LVt(e,t,n){return r;function r(a){return e.consume(a),i}function i(a){return po(a)?n(a):t(a)}}function aOe(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Dr(e)}function oOe(e){return!Bo(e)}function sOe(e){return!(e===47||pU(e))}function pU(e){return e===43||e===45||e===46||e===95||po(e)}function jQ(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const jVt={tokenize:GVt,partial:!0};function zVt(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:HVt,continuation:{tokenize:WVt},exit:UVt}},text:{91:{name:"gfmFootnoteCall",tokenize:VVt},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:FVt,resolveTo:BVt}}}}function FVt(e,t,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!o||!o._balanced)return n(l);const c=Ac(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!a.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function BVt(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...s),e}function VVt(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,o;return s;function s(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(a>999||d===93&&!o||d===null||d===91||Dr(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Ac(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return Dr(d)||(o=!0),a++,e.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(e.consume(d),a++,c):c(d)}}function HVt(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,o=0,s;return l;function l(h){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(h){return h===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(h)}function u(h){if(o>999||h===93&&!s||h===null||h===91||Dr(h))return n(h);if(h===93){e.exit("chunkString");const g=e.exit("gfmFootnoteDefinitionLabelString");return a=Ac(r.sliceSerialize(g)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return Dr(h)||(s=!0),o++,e.consume(h),h===92?d:u}function d(h){return h===91||h===92||h===93?(e.consume(h),o++,u):u(h)}function f(h){return h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),i.includes(a)||i.push(a),sr(e,p,"gfmFootnoteDefinitionWhitespace")):n(h)}function p(h){return t(h)}}function WVt(e,t,n){return e.check(fT,t,e.attempt(jVt,t,n))}function UVt(e){e.exit("gfmFootnoteDefinition")}function GVt(e,t,n){const r=this;return sr(e,i,"gfmFootnoteDefinitionIndent",5);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(a):n(a)}}function qVt(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},f=[["enter",u,s],["enter",o[c][1],s],["exit",o[c][1],s],["enter",d,s]],p=s.parser.constructs.insideSpan.null;p&&Ks(f,f.length,0,JL(p,o.slice(c+1,l),s)),Ks(f,f.length,0,[["exit",d,s],["enter",o[l][1],s],["exit",o[l][1],s],["exit",u,s]]),Ks(o,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function a(o,s,l){const c=this.previous,u=this.events;let d=0;return f;function f(h){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(h):(o.enter("strikethroughSequenceTemporary"),p(h))}function p(h){const g=m1(c);if(h===126)return d>1?l(h):(o.consume(h),d++,p);if(d<2&&!n)return l(h);const v=o.exit("strikethroughSequenceTemporary"),y=m1(h);return v._open=!y||y===2&&!!g,v._close=!g||g===2&&!!y,s(h)}}}class KVt{constructor(){this.map=[]}add(t,n,r){YVt(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function YVt(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function XVt(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function ZVt(){return{flow:{null:{name:"table",tokenize:QVt,resolveAll:JVt}}}}function QVt(e,t,n){const r=this;let i=0,a=0,o;return s;function s(T){let I=r.events.length-1;for(;I>-1;){const A=r.events[I][1].type;if(A==="lineEnding"||A==="linePrefix")I--;else break}const P=I>-1?r.events[I][1].type:null,N=P==="tableHead"||P==="tableRow"?C:l;return N===C&&r.parser.lazy[r.now().line]?n(T):N(T)}function l(T){return e.enter("tableHead"),e.enter("tableRow"),c(T)}function c(T){return T===124||(o=!0,a+=1),u(T)}function u(T){return T===null?n(T):un(T)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),p):n(T):Qn(T)?sr(e,u,"whitespace")(T):(a+=1,o&&(o=!1,i+=1),T===124?(e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),d(T)))}function d(T){return T===null||T===124||Dr(T)?(e.exit("data"),u(T)):(e.consume(T),T===92?f:d)}function f(T){return T===92||T===124?(e.consume(T),d):d(T)}function p(T){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(T):(e.enter("tableDelimiterRow"),o=!1,Qn(T)?sr(e,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):h(T))}function h(T){return T===45||T===58?v(T):T===124?(o=!0,e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),g):_(T)}function g(T){return Qn(T)?sr(e,v,"whitespace")(T):v(T)}function v(T){return T===58?(a+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(T),e.exit("tableDelimiterMarker"),y):T===45?(a+=1,y(T)):T===null||un(T)?S(T):_(T)}function y(T){return T===45?(e.enter("tableDelimiterFiller"),x(T)):_(T)}function x(T){return T===45?(e.consume(T),x):T===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(T),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(T))}function w(T){return Qn(T)?sr(e,S,"whitespace")(T):S(T)}function S(T){return T===124?h(T):T===null||un(T)?!o||i!==a?_(T):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(T)):_(T)}function _(T){return n(T)}function C(T){return e.enter("tableRow"),$(T)}function $(T){return T===124?(e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),$):T===null||un(T)?(e.exit("tableRow"),t(T)):Qn(T)?sr(e,$,"whitespace")(T):(e.enter("data"),E(T))}function E(T){return T===null||T===124||Dr(T)?(e.exit("data"),$(T)):(e.consume(T),T===92?k:E)}function k(T){return T===92||T===124?(e.consume(T),E):E(T)}}function JVt(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,l=0,c,u,d;const f=new KVt;for(;++n<e.length;){const p=e[n],h=p[1];p[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(Age(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},f.add(n,0,[["enter",c,t]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},f.add(n,0,[["enter",u,t]])),i=h.type==="tableDelimiterRow"?2:u?3:1):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=pP(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):h.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=pP(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):h.type==="tableHead"?(s=!0,l=n):h.type==="tableRow"||h.type==="tableDelimiterRow"?(l=n,a[1]!==0?(o[0]=o[1],d=pP(f,t,a,i,n,d)):o[1]!==0&&(d=pP(f,t,o,i,n,d)),i=0):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Age(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=XVt(t.events,n))}return e}function pP(e,t,n,r,i,a){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},Y0(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const l=Y0(t.events,n[1]);if(a={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const c=Y0(t.events,n[2]),u=Y0(t.events,n[3]),d={type:s,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const h=n[2]+1,g=n[3]-n[2]-1;e.add(h,g,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(a.end=Object.assign({},Y0(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function Age(e,t,n,r,i){const a=[],o=Y0(t.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,t])),r.end=Object.assign({},o),a.push(["exit",r,t]),e.add(n+1,0,a)}function Y0(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const e9t={name:"tasklistCheck",tokenize:n9t};function t9t(){return{text:{91:e9t}}}function n9t(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),a)}function a(l){return Dr(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(l)}function s(l){return un(l)?t(l):Qn(l)?e.check({tokenize:r9t},t,n)(l):n(l)}}function r9t(e,t,n){return sr(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function i9t(e){return vDe([kVt(),zVt(),qVt(e),ZVt(),t9t()])}const a9t={};function Pg(e){const t=this,n=e||a9t,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(i9t(n)),a.push($Vt()),o.push(EVt(n))}let Mge;function o9t(){return Mge??(Mge=Promise.resolve().then(()=>require("./mermaid.core-BEoXBBmj.cjs")).then(e=>e.mermaid_core).then(e=>e.default)),Mge}const lOe=[/graph\s*(TD|TB|BT|RL|LR)/i,/flowchart\s*(TD|TB|BT|RL|LR)/i,/sequenceDiagram/i,/classDiagram/i,/stateDiagram/i,/erDiagram/i,/\bgantt\b/i,/\bpie\b/i,/\bjourney\b/i,/gitGraph/i,/xychart-beta/i,/\bquadrantChart\b/i],zQ=[/^graph\s*(TD|TB|BT|RL|LR)/i,/^flowchart\s*(TD|TB|BT|RL|LR)/i,/^sequenceDiagram/i,/^classDiagram/i,/^stateDiagram/i,/^erDiagram/i,/^gantt/i,/^pie/i,/^journey/i,/^gitGraph/i,/^xychart-beta/i,/^quadrantChart/i],cOe=["graph","flowchart","sequenceDiagram","classDiagram","stateDiagram","erDiagram","gantt","pie","journey","gitGraph","xychart-beta","quadrantChart"],s9t=[/^#{1,6}\s/,/^\|.*\|/,/^[-*+]\s/,/^\d+\.\s/,/^>\s/,/^!\[/,/^\[.*\]\(.*\)/,/^<button\b/i,/^<div\b/i,/^<table\b/i];function uOe(e,t){let n=t,r=!1;for(let i=t+1;i<e.length;i++){const a=e[i],o=a.trim();if(o===""){r=!0;continue}if(s9t.some(s=>s.test(o))||r&&!a.startsWith(" ")&&!a.startsWith(" ")&&!(/^(subgraph|end|style|classDef|click|linkStyle|class\s|section|title|dateFormat|axisFormat|x-axis|y-axis|line|bar|participant|actor|Note|loop|alt|opt|par|rect|activate|deactivate|%%)/i.test(o)||/-->|==>|-.->|-->/i.test(o)||zQ.some(l=>l.test(o))))break;n=i,r=!1}return n}function Ib({chart:e}){const t=m.useRef(null),[n,r]=m.useState(null);return m.useEffect(()=>{const i=t.current;if(!i)return;let a=!1;return i.replaceChildren(),r(null),e?((async()=>{try{const s=await o9t();if(a)return;s.initialize({startOnLoad:!0,look:"handDrawn",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0});const l=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,{svg:c}=await s.render(l,e);!a&&t.current===i&&(i.innerHTML=c)}catch(s){a||r(s instanceof Error?s.message:"图表渲染失败")}})(),()=>{a=!0}):()=>{a=!0}},[e]),b.jsxs("div",{className:"wandox-mermaid-chart",children:[n&&b.jsxs("div",{style:{padding:12,background:"#fff2f0",borderRadius:4,border:"1px solid #ffccc7",color:"#ff4d4f",fontSize:12},children:[b.jsx("div",{style:{fontWeight:500,marginBottom:4},children:"Mermaid 图表渲染失败"}),b.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:n})]}),b.jsx("div",{ref:t,className:"wandox-mermaid-content",hidden:!!n})]})}const FQ=m.createContext({});function l9t(e){const t=[],n=/<button[^>]*>([^<]*)<\/button>/gi,r=/data-id=["']([^"']*)["']/i,i=/data-playbook-id=["']([^"']*)["']/i,a=/data-playbook-name=["']([^"']*)["']/i,o=/data-playbook-params='([^']*)'/i,s=/data-input-fields='([^']*)'/i,l=[],c=/```[\s\S]*?```|`[^`]+`/g;let u=c.exec(e);for(;u!==null;)l.push({start:u.index,end:u.index+u[0].length}),u=c.exec(e);const d=g=>l.some(v=>g>=v.start&&g<v.end);let f=0;const p=[];let h=n.exec(e);for(;h!==null;){if(d(h.index)){h=n.exec(e);continue}const g=h[0],v=h[1],y=r.exec(g),x=i.exec(g),w=a.exec(g),S=o.exec(g),_=s.exec(g);if((y||x)&&w){let C={};if(S)try{C=JSON.parse(S[1].replace(/"/g,'"').replace(/'/g,"'"))}catch{}let $=[];if(_)try{$=JSON.parse(_[1].replace(/"/g,'"').replace(/'/g,"'"))}catch{}p.push({index:h.index,length:g.length,info:{id:y==null?void 0:y[1],playbookId:x==null?void 0:x[1],playbookName:w[1],playbookParams:C,buttonText:v||w[1],inputFields:$}})}h=n.exec(e)}p.sort((g,v)=>g.index-v.index);for(const g of p)g.index>f&&t.push({text:e.slice(f,g.index),buttons:[]}),t.push({text:"",buttons:[g.info]}),f=g.index+g.length;return f<e.length&&t.push({text:e.slice(f),buttons:[]}),t.length>0?t:[{text:e,buttons:[]}]}function c9t(e){const t=[],n=[],r=/```[\s\S]*?```|`[^`]+`/g;let i=r.exec(e);for(;i!==null;)n.push({start:i.index,end:i.index+i[0].length}),i=r.exec(e);const a=u=>n.some(d=>u>=d.start&&u<d.end),o=/\[\[([^|\[\]]+)\|([^|\[\]]+)\|([^|\[\]]+)\|(\{[^[\]]*\})\]\]/g,s=[...e.matchAll(o)];let l=0;const c=[];for(const u of s){if(a(u.index??0))continue;const d=u[0],f=u[1],p=u[2],h=u[3],g=u[4];let v={};try{v=JSON.parse(g)}catch{}c.push({index:u.index??0,length:d.length,info:{id:p,playbookId:void 0,playbookName:f,playbookParams:v,buttonText:f,inputFields:[],playbookType:h}})}c.sort((u,d)=>u.index-d.index),l=0;for(const u of c)u.index>l&&t.push({text:e.slice(l,u.index),buttons:[]}),t.push({text:"",buttons:[u.info]}),l=u.index+u.length;return l<e.length&&t.push({text:e.slice(l),buttons:[]}),t.length>0?t:[{text:e,buttons:[]}]}function u9t(e){if(e){if(typeof e=="object"&&"data"in e){const t=e.data;if(t&&typeof t=="object")return t}return e}}function Rge({info:e}){const{onExecutePlaybook:t,onFillPlaybookParams:n,getPlaybookDetail:r}=m.useContext(FQ),[i,a]=m.useState(!1),[o,s]=m.useState(e.playbookId||""),l=(d,f)=>f.length===0?!1:(n&&n({playbookId:d,playbookName:e.playbookName,inputFields:f.map(p=>({...p,label:p.label||p.name})),initialParams:e.playbookParams,playbookType:e.playbookType}),!0),c=d=>{const f=(d==null?void 0:d.playbookId)||o||e.playbookId;f&&t&&t({message:e.playbookName,playbook_id:f,playbook_params:e.playbookParams,playbook_type:e.playbookType})},u=async()=>{var d;if(!i){if(!e.id){if(l(e.playbookId||"",e.inputFields))return;c();return}a(!0);try{if(!r){if(l(e.playbookId||"",e.inputFields))return;c();return}const f=u9t(await r(e.id)),p=String((f==null?void 0:f.playbook_id)||e.playbookId||"");p&&s(p);const h=((d=f.content)==null?void 0:d.yaml_content)||"";let g=[];if(h)try{const v=FE.parse(h),y=v==null?void 0:v.params;Array.isArray(y)&&y.length>0?g=y:y&&typeof y=="object"&&(g=Object.values(y))}catch{}g.length>0?l(p,g):c({playbookId:p})}catch{if(l(e.playbookId||"",e.inputFields))return;c()}finally{a(!1)}}};return b.jsxs("button",{type:"button",className:"wandox-playbook-button","data-id":e.id,"data-playbook-id":o||e.playbookId,"data-playbook-name":e.playbookName,"data-playbook-params":JSON.stringify(e.playbookParams),"data-input-fields":JSON.stringify(e.inputFields),onClick:u,disabled:i,children:[i?b.jsx(ql,{className:"wandox-playbook-button-icon"}):b.jsx(Fc,{className:"wandox-playbook-button-icon"}),b.jsx("span",{children:e.buttonText})]})}const Dge={a({href:e,children:t,...n}){return e&&KRe(String(e))?b.jsx(p1,{src:String(e),alt:"图片预览",size:"small"}):b.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",...n,children:t})},table({children:e,...t}){return b.jsx("div",{className:"wandox-native-table-wrapper",children:b.jsx("table",{className:"wandox-native-table",...t,children:e})})},img({src:e,alt:t}){return e?b.jsx(p1,{src:String(e),alt:t||"图片预览",size:"small"}):null},code({className:e,children:t,...n}){const r=/language-(\w+)/.exec(e||"");if(r&&r[1]==="mermaid"){const i=String(t).replace(/\n$/,"");if(cOe.some(a=>i.toLowerCase().includes(a.toLowerCase())))return b.jsx(Ib,{chart:i})}return b.jsx("code",{className:e,...n,children:t})}};function hP({content:e}){if(!e||e.trim()==="")return null;const t=e.replace(/```[\s\S]*?```/g,"").replace(/`[^`]+`/g,"");if(t.includes("[[")&&(t.includes("|standard|")||t.includes("|exploration|")||t.includes("|fast_action|")||t.includes("|patrol|"))){const i=c9t(e),a=[];let o=[];const s=()=>{o.length>0&&(a.push(b.jsx("div",{className:"wandox-playbook-button-group",children:o.map((l,c)=>b.jsx(Rge,{info:l},`btn-${c}`))},`btn-group-${a.length}`)),o=[])};for(let l=0;l<i.length;l++){const c=i[l];c.buttons.length>0?o.push(...c.buttons):c.text.trim()&&(s(),a.push(b.jsx(FN,{content:c.text},`text-${l}`)))}return s(),b.jsx("div",{className:"wandox-markdown-with-buttons",children:a})}if(/<button[^>]*data-playbook-id/i.test(t)){const i=l9t(e),a=[];let o=[];const s=()=>{o.length>0&&(a.push(b.jsx("div",{className:"wandox-playbook-button-group",children:o.map((l,c)=>b.jsx(Rge,{info:l},`btn-${c}`))},`btn-group-${a.length}`)),o=[])};for(let l=0;l<i.length;l++){const c=i[l];c.buttons.length>0?o.push(...c.buttons):c.text.trim()&&(s(),a.push(b.jsx(FN,{content:c.text},`text-${l}`)))}return s(),b.jsx("div",{className:"wandox-markdown-with-buttons",children:a})}return b.jsx(FN,{content:e})}function FN({content:e}){if(!e||e.trim()==="")return null;const t=lOe.some(r=>r.test(e)),n=e.includes("```mermaid");if(t&&!n){const r=e.split(`
|
|
720
|
+
`))}function l(p,h,g,v){const y=g.enter("tableCell"),x=g.enter("phrasing"),w=g.containerPhrasing(p,{...v,before:a,after:a});return x(),y(),w}function c(p,h){return R8t(p,{align:h,alignDelimiters:r,padding:n,stringLength:i})}function u(p,h,g){const v=p.children;let y=-1;const x=[],w=h.enter("table");for(;++y<v.length;)x[y]=d(v[y],h,g);return w(),x}function d(p,h,g){const v=p.children;let y=-1;const x=[],w=h.enter("tableRow");for(;++y<v.length;)x[y]=l(v[y],p,h,g);return w(),x}function f(p,h,g){let v=JDe.inlineCode(p,h,g);return g.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function wVt(){return{exit:{taskListCheckValueChecked:Nge,taskListCheckValueUnchecked:Nge,paragraph:_Vt}}}function SVt(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:CVt}}}function Nge(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function _Vt(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let a=-1,o;for(;++a<i.length;){const s=i[a];if(s.type==="paragraph"){o=s;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function CVt(e,t,n,r){const i=e.children[0],a=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(o);let l=JDe.listItem(e,t,n,{...r,...s.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function $Vt(){return[r8t(),C8t(),I8t(),hVt(),wVt()]}function EVt(e){return{extensions:[i8t(),$8t(e),k8t(),xVt(e),SVt()]}}const TVt={tokenize:MVt,partial:!0},eOe={tokenize:RVt,partial:!0},tOe={tokenize:DVt,partial:!0},nOe={tokenize:OVt,partial:!0},IVt={tokenize:LVt,partial:!0},rOe={name:"wwwAutolink",tokenize:NVt,previous:aOe},iOe={name:"protocolAutolink",tokenize:AVt,previous:oOe},Hf={name:"emailAutolink",tokenize:PVt,previous:sOe},ld={};function kVt(){return{text:ld}}let Rm=48;for(;Rm<123;)ld[Rm]=Hf,Rm++,Rm===58?Rm=65:Rm===91&&(Rm=97);ld[43]=Hf;ld[45]=Hf;ld[46]=Hf;ld[95]=Hf;ld[72]=[Hf,iOe];ld[104]=[Hf,iOe];ld[87]=[Hf,rOe];ld[119]=[Hf,rOe];function PVt(e,t,n){const r=this;let i,a;return o;function o(d){return!pU(d)||!sOe.call(r,r.previous)||jQ(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(d))}function s(d){return pU(d)?(e.consume(d),s):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(IVt,u,c)(d):d===45||d===95||po(d)?(a=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),i=!0,l}function u(d){return a&&i&&Bo(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function NVt(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!aOe.call(r,r.previous)||jQ(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(TVt,e.attempt(eOe,e.attempt(tOe,a),n),n)(o))}function a(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function AVt(e,t,n){const r=this;let i="",a=!1;return o;function o(d){return(d===72||d===104)&&oOe.call(r,r.previous)&&!jQ(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),s):n(d)}function s(d){if(Bo(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),s;if(d===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),a?c:(a=!0,l)):n(d)}function c(d){return d===null||jR(d)||Dr(d)||Yv(d)||QL(d)?n(d):e.attempt(eOe,e.attempt(tOe,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function MVt(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),a):n(o)}function a(o){return o===null?n(o):t(o)}}function RVt(e,t,n){let r,i,a;return o;function o(c){return c===46||c===95?e.check(nOe,l,s)(c):c===null||Dr(c)||Yv(c)||c!==45&&QL(c)?l(c):(a=!0,e.consume(c),o)}function s(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!a?n(c):t(c)}}function DVt(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(nOe,t,a)(o):o===null||Dr(o)||Yv(o)?t(o):(e.consume(o),i)}function a(o){return o===41&&r++,e.consume(o),i}}function OVt(e,t,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),r):s===38?(e.consume(s),a):s===93?(e.consume(s),i):s===60||s===null||Dr(s)||Yv(s)?t(s):n(s)}function i(s){return s===null||s===40||s===91||Dr(s)||Yv(s)?t(s):r(s)}function a(s){return Bo(s)?o(s):n(s)}function o(s){return s===59?(e.consume(s),r):Bo(s)?(e.consume(s),o):n(s)}}function LVt(e,t,n){return r;function r(a){return e.consume(a),i}function i(a){return po(a)?n(a):t(a)}}function aOe(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Dr(e)}function oOe(e){return!Bo(e)}function sOe(e){return!(e===47||pU(e))}function pU(e){return e===43||e===45||e===46||e===95||po(e)}function jQ(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const jVt={tokenize:GVt,partial:!0};function zVt(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:HVt,continuation:{tokenize:WVt},exit:UVt}},text:{91:{name:"gfmFootnoteCall",tokenize:VVt},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:FVt,resolveTo:BVt}}}}function FVt(e,t,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!o||!o._balanced)return n(l);const c=Ac(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!a.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function BVt(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...s),e}function VVt(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,o;return s;function s(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(a>999||d===93&&!o||d===null||d===91||Dr(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Ac(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return Dr(d)||(o=!0),a++,e.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(e.consume(d),a++,c):c(d)}}function HVt(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,o=0,s;return l;function l(h){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(h){return h===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(h)}function u(h){if(o>999||h===93&&!s||h===null||h===91||Dr(h))return n(h);if(h===93){e.exit("chunkString");const g=e.exit("gfmFootnoteDefinitionLabelString");return a=Ac(r.sliceSerialize(g)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return Dr(h)||(s=!0),o++,e.consume(h),h===92?d:u}function d(h){return h===91||h===92||h===93?(e.consume(h),o++,u):u(h)}function f(h){return h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),i.includes(a)||i.push(a),sr(e,p,"gfmFootnoteDefinitionWhitespace")):n(h)}function p(h){return t(h)}}function WVt(e,t,n){return e.check(fT,t,e.attempt(jVt,t,n))}function UVt(e){e.exit("gfmFootnoteDefinition")}function GVt(e,t,n){const r=this;return sr(e,i,"gfmFootnoteDefinitionIndent",5);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(a):n(a)}}function qVt(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},f=[["enter",u,s],["enter",o[c][1],s],["exit",o[c][1],s],["enter",d,s]],p=s.parser.constructs.insideSpan.null;p&&Ks(f,f.length,0,JL(p,o.slice(c+1,l),s)),Ks(f,f.length,0,[["exit",d,s],["enter",o[l][1],s],["exit",o[l][1],s],["exit",u,s]]),Ks(o,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function a(o,s,l){const c=this.previous,u=this.events;let d=0;return f;function f(h){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(h):(o.enter("strikethroughSequenceTemporary"),p(h))}function p(h){const g=m1(c);if(h===126)return d>1?l(h):(o.consume(h),d++,p);if(d<2&&!n)return l(h);const v=o.exit("strikethroughSequenceTemporary"),y=m1(h);return v._open=!y||y===2&&!!g,v._close=!g||g===2&&!!y,s(h)}}}class KVt{constructor(){this.map=[]}add(t,n,r){YVt(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function YVt(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function XVt(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function ZVt(){return{flow:{null:{name:"table",tokenize:QVt,resolveAll:JVt}}}}function QVt(e,t,n){const r=this;let i=0,a=0,o;return s;function s(T){let I=r.events.length-1;for(;I>-1;){const A=r.events[I][1].type;if(A==="lineEnding"||A==="linePrefix")I--;else break}const P=I>-1?r.events[I][1].type:null,N=P==="tableHead"||P==="tableRow"?C:l;return N===C&&r.parser.lazy[r.now().line]?n(T):N(T)}function l(T){return e.enter("tableHead"),e.enter("tableRow"),c(T)}function c(T){return T===124||(o=!0,a+=1),u(T)}function u(T){return T===null?n(T):un(T)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),p):n(T):Qn(T)?sr(e,u,"whitespace")(T):(a+=1,o&&(o=!1,i+=1),T===124?(e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),d(T)))}function d(T){return T===null||T===124||Dr(T)?(e.exit("data"),u(T)):(e.consume(T),T===92?f:d)}function f(T){return T===92||T===124?(e.consume(T),d):d(T)}function p(T){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(T):(e.enter("tableDelimiterRow"),o=!1,Qn(T)?sr(e,h,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):h(T))}function h(T){return T===45||T===58?v(T):T===124?(o=!0,e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),g):_(T)}function g(T){return Qn(T)?sr(e,v,"whitespace")(T):v(T)}function v(T){return T===58?(a+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(T),e.exit("tableDelimiterMarker"),y):T===45?(a+=1,y(T)):T===null||un(T)?S(T):_(T)}function y(T){return T===45?(e.enter("tableDelimiterFiller"),x(T)):_(T)}function x(T){return T===45?(e.consume(T),x):T===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(T),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(T))}function w(T){return Qn(T)?sr(e,S,"whitespace")(T):S(T)}function S(T){return T===124?h(T):T===null||un(T)?!o||i!==a?_(T):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(T)):_(T)}function _(T){return n(T)}function C(T){return e.enter("tableRow"),$(T)}function $(T){return T===124?(e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),$):T===null||un(T)?(e.exit("tableRow"),t(T)):Qn(T)?sr(e,$,"whitespace")(T):(e.enter("data"),E(T))}function E(T){return T===null||T===124||Dr(T)?(e.exit("data"),$(T)):(e.consume(T),T===92?k:E)}function k(T){return T===92||T===124?(e.consume(T),E):E(T)}}function JVt(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,l=0,c,u,d;const f=new KVt;for(;++n<e.length;){const p=e[n],h=p[1];p[0]==="enter"?h.type==="tableHead"?(s=!1,l!==0&&(Age(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},f.add(n,0,[["enter",c,t]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},f.add(n,0,[["enter",u,t]])),i=h.type==="tableDelimiterRow"?2:u?3:1):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=pP(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):h.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=pP(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):h.type==="tableHead"?(s=!0,l=n):h.type==="tableRow"||h.type==="tableDelimiterRow"?(l=n,a[1]!==0?(o[0]=o[1],d=pP(f,t,a,i,n,d)):o[1]!==0&&(d=pP(f,t,o,i,n,d)),i=0):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Age(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=XVt(t.events,n))}return e}function pP(e,t,n,r,i,a){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},Y0(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const l=Y0(t.events,n[1]);if(a={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const c=Y0(t.events,n[2]),u=Y0(t.events,n[3]),d={type:s,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const h=n[2]+1,g=n[3]-n[2]-1;e.add(h,g,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(a.end=Object.assign({},Y0(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function Age(e,t,n,r,i){const a=[],o=Y0(t.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,t])),r.end=Object.assign({},o),a.push(["exit",r,t]),e.add(n+1,0,a)}function Y0(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const e9t={name:"tasklistCheck",tokenize:n9t};function t9t(){return{text:{91:e9t}}}function n9t(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),a)}function a(l){return Dr(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(l)}function s(l){return un(l)?t(l):Qn(l)?e.check({tokenize:r9t},t,n)(l):n(l)}}function r9t(e,t,n){return sr(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function i9t(e){return vDe([kVt(),zVt(),qVt(e),ZVt(),t9t()])}const a9t={};function Pg(e){const t=this,n=e||a9t,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(i9t(n)),a.push($Vt()),o.push(EVt(n))}let Mge;function o9t(){return Mge??(Mge=Promise.resolve().then(()=>require("./mermaid.core-BAGOfCjo.cjs")).then(e=>e.mermaid_core).then(e=>e.default)),Mge}const lOe=[/graph\s*(TD|TB|BT|RL|LR)/i,/flowchart\s*(TD|TB|BT|RL|LR)/i,/sequenceDiagram/i,/classDiagram/i,/stateDiagram/i,/erDiagram/i,/\bgantt\b/i,/\bpie\b/i,/\bjourney\b/i,/gitGraph/i,/xychart-beta/i,/\bquadrantChart\b/i],zQ=[/^graph\s*(TD|TB|BT|RL|LR)/i,/^flowchart\s*(TD|TB|BT|RL|LR)/i,/^sequenceDiagram/i,/^classDiagram/i,/^stateDiagram/i,/^erDiagram/i,/^gantt/i,/^pie/i,/^journey/i,/^gitGraph/i,/^xychart-beta/i,/^quadrantChart/i],cOe=["graph","flowchart","sequenceDiagram","classDiagram","stateDiagram","erDiagram","gantt","pie","journey","gitGraph","xychart-beta","quadrantChart"],s9t=[/^#{1,6}\s/,/^\|.*\|/,/^[-*+]\s/,/^\d+\.\s/,/^>\s/,/^!\[/,/^\[.*\]\(.*\)/,/^<button\b/i,/^<div\b/i,/^<table\b/i];function uOe(e,t){let n=t,r=!1;for(let i=t+1;i<e.length;i++){const a=e[i],o=a.trim();if(o===""){r=!0;continue}if(s9t.some(s=>s.test(o))||r&&!a.startsWith(" ")&&!a.startsWith(" ")&&!(/^(subgraph|end|style|classDef|click|linkStyle|class\s|section|title|dateFormat|axisFormat|x-axis|y-axis|line|bar|participant|actor|Note|loop|alt|opt|par|rect|activate|deactivate|%%)/i.test(o)||/-->|==>|-.->|-->/i.test(o)||zQ.some(l=>l.test(o))))break;n=i,r=!1}return n}function Ib({chart:e}){const t=m.useRef(null),[n,r]=m.useState(null);return m.useEffect(()=>{const i=t.current;if(!i)return;let a=!1;return i.replaceChildren(),r(null),e?((async()=>{try{const s=await o9t();if(a)return;s.initialize({startOnLoad:!0,look:"handDrawn",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0});const l=`mermaid-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,{svg:c}=await s.render(l,e);!a&&t.current===i&&(i.innerHTML=c)}catch(s){a||r(s instanceof Error?s.message:"图表渲染失败")}})(),()=>{a=!0}):()=>{a=!0}},[e]),b.jsxs("div",{className:"wandox-mermaid-chart",children:[n&&b.jsxs("div",{style:{padding:12,background:"#fff2f0",borderRadius:4,border:"1px solid #ffccc7",color:"#ff4d4f",fontSize:12},children:[b.jsx("div",{style:{fontWeight:500,marginBottom:4},children:"Mermaid 图表渲染失败"}),b.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:n})]}),b.jsx("div",{ref:t,className:"wandox-mermaid-content",hidden:!!n})]})}const FQ=m.createContext({});function l9t(e){const t=[],n=/<button[^>]*>([^<]*)<\/button>/gi,r=/data-id=["']([^"']*)["']/i,i=/data-playbook-id=["']([^"']*)["']/i,a=/data-playbook-name=["']([^"']*)["']/i,o=/data-playbook-params='([^']*)'/i,s=/data-input-fields='([^']*)'/i,l=[],c=/```[\s\S]*?```|`[^`]+`/g;let u=c.exec(e);for(;u!==null;)l.push({start:u.index,end:u.index+u[0].length}),u=c.exec(e);const d=g=>l.some(v=>g>=v.start&&g<v.end);let f=0;const p=[];let h=n.exec(e);for(;h!==null;){if(d(h.index)){h=n.exec(e);continue}const g=h[0],v=h[1],y=r.exec(g),x=i.exec(g),w=a.exec(g),S=o.exec(g),_=s.exec(g);if((y||x)&&w){let C={};if(S)try{C=JSON.parse(S[1].replace(/"/g,'"').replace(/'/g,"'"))}catch{}let $=[];if(_)try{$=JSON.parse(_[1].replace(/"/g,'"').replace(/'/g,"'"))}catch{}p.push({index:h.index,length:g.length,info:{id:y==null?void 0:y[1],playbookId:x==null?void 0:x[1],playbookName:w[1],playbookParams:C,buttonText:v||w[1],inputFields:$}})}h=n.exec(e)}p.sort((g,v)=>g.index-v.index);for(const g of p)g.index>f&&t.push({text:e.slice(f,g.index),buttons:[]}),t.push({text:"",buttons:[g.info]}),f=g.index+g.length;return f<e.length&&t.push({text:e.slice(f),buttons:[]}),t.length>0?t:[{text:e,buttons:[]}]}function c9t(e){const t=[],n=[],r=/```[\s\S]*?```|`[^`]+`/g;let i=r.exec(e);for(;i!==null;)n.push({start:i.index,end:i.index+i[0].length}),i=r.exec(e);const a=u=>n.some(d=>u>=d.start&&u<d.end),o=/\[\[([^|\[\]]+)\|([^|\[\]]+)\|([^|\[\]]+)\|(\{[^[\]]*\})\]\]/g,s=[...e.matchAll(o)];let l=0;const c=[];for(const u of s){if(a(u.index??0))continue;const d=u[0],f=u[1],p=u[2],h=u[3],g=u[4];let v={};try{v=JSON.parse(g)}catch{}c.push({index:u.index??0,length:d.length,info:{id:p,playbookId:void 0,playbookName:f,playbookParams:v,buttonText:f,inputFields:[],playbookType:h}})}c.sort((u,d)=>u.index-d.index),l=0;for(const u of c)u.index>l&&t.push({text:e.slice(l,u.index),buttons:[]}),t.push({text:"",buttons:[u.info]}),l=u.index+u.length;return l<e.length&&t.push({text:e.slice(l),buttons:[]}),t.length>0?t:[{text:e,buttons:[]}]}function u9t(e){if(e){if(typeof e=="object"&&"data"in e){const t=e.data;if(t&&typeof t=="object")return t}return e}}function Rge({info:e}){const{onExecutePlaybook:t,onFillPlaybookParams:n,getPlaybookDetail:r}=m.useContext(FQ),[i,a]=m.useState(!1),[o,s]=m.useState(e.playbookId||""),l=(d,f)=>f.length===0?!1:(n&&n({playbookId:d,playbookName:e.playbookName,inputFields:f.map(p=>({...p,label:p.label||p.name})),initialParams:e.playbookParams,playbookType:e.playbookType}),!0),c=d=>{const f=(d==null?void 0:d.playbookId)||o||e.playbookId;f&&t&&t({message:e.playbookName,playbook_id:f,playbook_params:e.playbookParams,playbook_type:e.playbookType})},u=async()=>{var d;if(!i){if(!e.id){if(l(e.playbookId||"",e.inputFields))return;c();return}a(!0);try{if(!r){if(l(e.playbookId||"",e.inputFields))return;c();return}const f=u9t(await r(e.id)),p=String((f==null?void 0:f.playbook_id)||e.playbookId||"");p&&s(p);const h=((d=f.content)==null?void 0:d.yaml_content)||"";let g=[];if(h)try{const v=FE.parse(h),y=v==null?void 0:v.params;Array.isArray(y)&&y.length>0?g=y:y&&typeof y=="object"&&(g=Object.values(y))}catch{}g.length>0?l(p,g):c({playbookId:p})}catch{if(l(e.playbookId||"",e.inputFields))return;c()}finally{a(!1)}}};return b.jsxs("button",{type:"button",className:"wandox-playbook-button","data-id":e.id,"data-playbook-id":o||e.playbookId,"data-playbook-name":e.playbookName,"data-playbook-params":JSON.stringify(e.playbookParams),"data-input-fields":JSON.stringify(e.inputFields),onClick:u,disabled:i,children:[i?b.jsx(ql,{className:"wandox-playbook-button-icon"}):b.jsx(Fc,{className:"wandox-playbook-button-icon"}),b.jsx("span",{children:e.buttonText})]})}const Dge={a({href:e,children:t,...n}){return e&&KRe(String(e))?b.jsx(p1,{src:String(e),alt:"图片预览",size:"small"}):b.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",...n,children:t})},table({children:e,...t}){return b.jsx("div",{className:"wandox-native-table-wrapper",children:b.jsx("table",{className:"wandox-native-table",...t,children:e})})},img({src:e,alt:t}){return e?b.jsx(p1,{src:String(e),alt:t||"图片预览",size:"small"}):null},code({className:e,children:t,...n}){const r=/language-(\w+)/.exec(e||"");if(r&&r[1]==="mermaid"){const i=String(t).replace(/\n$/,"");if(cOe.some(a=>i.toLowerCase().includes(a.toLowerCase())))return b.jsx(Ib,{chart:i})}return b.jsx("code",{className:e,...n,children:t})}};function hP({content:e}){if(!e||e.trim()==="")return null;const t=e.replace(/```[\s\S]*?```/g,"").replace(/`[^`]+`/g,"");if(t.includes("[[")&&(t.includes("|standard|")||t.includes("|exploration|")||t.includes("|fast_action|")||t.includes("|patrol|"))){const i=c9t(e),a=[];let o=[];const s=()=>{o.length>0&&(a.push(b.jsx("div",{className:"wandox-playbook-button-group",children:o.map((l,c)=>b.jsx(Rge,{info:l},`btn-${c}`))},`btn-group-${a.length}`)),o=[])};for(let l=0;l<i.length;l++){const c=i[l];c.buttons.length>0?o.push(...c.buttons):c.text.trim()&&(s(),a.push(b.jsx(FN,{content:c.text},`text-${l}`)))}return s(),b.jsx("div",{className:"wandox-markdown-with-buttons",children:a})}if(/<button[^>]*data-playbook-id/i.test(t)){const i=l9t(e),a=[];let o=[];const s=()=>{o.length>0&&(a.push(b.jsx("div",{className:"wandox-playbook-button-group",children:o.map((l,c)=>b.jsx(Rge,{info:l},`btn-${c}`))},`btn-group-${a.length}`)),o=[])};for(let l=0;l<i.length;l++){const c=i[l];c.buttons.length>0?o.push(...c.buttons):c.text.trim()&&(s(),a.push(b.jsx(FN,{content:c.text},`text-${l}`)))}return s(),b.jsx("div",{className:"wandox-markdown-with-buttons",children:a})}return b.jsx(FN,{content:e})}function FN({content:e}){if(!e||e.trim()==="")return null;const t=lOe.some(r=>r.test(e)),n=e.includes("```mermaid");if(t&&!n){const r=e.split(`
|
|
721
721
|
`);let i=-1;for(let a=0;a<r.length;a++){const o=r[a].trim();if(zQ.some(s=>s.test(o))){i=a;break}}if(i!==-1){const a=uOe(r,i),o=r.slice(0,i).join(`
|
|
722
722
|
`).trim();let s=r.slice(i,a+1).join(`
|
|
723
723
|
`).trim();const l=r.slice(a+1).join(`
|
|
@@ -765,31 +765,31 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
765
765
|
`),Ie=Me.slice(Re+1),De=Ie.lastIndexOf("@");if(De!==-1&&((De>0?Ie[De-1]:" ")===" "||De===0)){const nt=Ie.slice(De+1);if(!nt.includes(" ")&&!nt.includes(`
|
|
766
766
|
`)){H(Re+1+De),D(nt),V(!0);return}}V(!1)},be=ce=>{if(O&&W.length>0){if(ce.key==="ArrowDown"){ce.preventDefault(),q(de=>de<W.length-1?de+1:0);return}if(ce.key==="ArrowUp"){ce.preventDefault(),q(de=>de>0?de-1:W.length-1);return}if(ce.key==="Enter"||ce.key==="Tab"){ce.preventDefault(),Ce(W[U]);return}if(ce.key==="Escape"){ce.preventDefault(),V(!1);return}}if(ce.key==="Enter"&&!ce.shiftKey&&!r){if(!S.trim()&&T&&n&&P.length===0){ce.preventDefault(),z();return}(S.trim()||P.length>0)&&(ce.preventDefault(),je())}if(ce.key===" "&&!r&&!S.trim()&&T&&n&&P.length===0){ce.preventDefault(),z();return}},Ce=ce=>{if(V(!1),!ce.input_fields||ce.input_fields.length===0){_(""),J(null),I(!0),o(ce.name,ce.playbook_id);return}const de=S.slice(0,F),_e=S.slice(F+1+B.length);if(h){_(`${de}${_e}`),h(ce);return}J(ce);const Me=ce.input_fields.map(De=>`${De.label}: `).join(`
|
|
767
767
|
`),Re=`${de}${ce.name},请提供以下参数:
|
|
768
|
-
${Me}${_e}`,Ie=Re.indexOf(": ")+2;_(Re),setTimeout(()=>{var De;if(C.current){C.current.focus();const Ue=(De=C.current.resizableTextArea)==null?void 0:De.textArea;Ue==null||Ue.setSelectionRange(Ie,Ie)}},0)},Ae=()=>{J(null),_("")},je=async()=>{if(!S.trim()&&P.length===0||r)return;let ce=[];if(P.length>0){ce=await he();for(const Me of P)URL.revokeObjectURL(Me.previewUrl);N([])}const de=S.trim(),_e=X==null?void 0:X.playbook_id;_(""),J(null),Z.clear(),I(!0),o(de,_e,ce.length>0?ce:void 0)};return b.jsxs("div",{className:"wandox-chat-input",style:{position:"relative"},onDragEnter:ye,onDragLeave:Te,onDragOver:Ee,onDrop:we,children:[A&&b.jsx("div",{className:"wandox-chat-input-drag-overlay",children:b.jsxs("div",{className:"wandox-chat-input-drag-content",children:[b.jsx(ppt,{style:{fontSize:32,marginBottom:8}}),b.jsx("div",{children:"释放以发送图片"})]})}),b.jsx("input",{ref:R,type:"file",accept:"image/png,image/jpeg,image/jpg,image/gif,image/webp,image/bmp",multiple:!0,style:{display:"none"},onChange:ne}),O&&W.length>0&&b.jsx("div",{className:"wandox-mention-list",ref:$,children:b.jsx("div",{className:"wandox-mention-items",children:W.map((ce,de)=>b.jsxs("div",{className:`wandox-mention-item ${de===U?"wandox-mention-item--active":""}`,onClick:()=>Ce(ce),onKeyDown:()=>{},onMouseEnter:()=>q(de),children:[b.jsx("div",{className:"wandox-mention-item-icon",children:"📋"}),b.jsxs("div",{className:"wandox-mention-item-content",children:[b.jsxs("div",{className:"wandox-mention-item-name",children:[ce.name,ce.input_fields&&ce.input_fields.length>0&&b.jsx("span",{className:"wandox-mention-item-tag",children:t("recommendation.params")})]}),ce.description&&b.jsx("div",{className:"wandox-mention-item-desc",children:ce.description})]})]},ce.playbook_id))})}),O&&W.length===0&&Y.length>0&&b.jsx("div",{className:"wandox-mention-list",ref:$,children:b.jsx("div",{className:"wandox-mention-empty",children:t("chatInput.noMatchingScenarios")})}),O&&Y.length===0&&b.jsx("div",{className:"wandox-mention-list",ref:$,children:b.jsx("div",{className:"wandox-mention-empty",children:t("chatInput.noAvailableScenarios")})}),b.jsx(MOe,{open:E&&!O&&!r,rewrittenQuestion:Z.rewrittenQuestion,questions:Z.questions,loading:Z.loading,placement:"top",onSelectRewrite:ce=>{var de;_(ce),Z.clear(),(de=C.current)==null||de.focus()},onSelectQuestion:ce=>{_(""),J(null),I(!0),Z.clear(),o(ce.title)}}),X&&b.jsx("div",{className:"wandox-chat-input-tag",children:b.jsx(ji,{color:"blue",closable:!0,onClose:Ae,closeIcon:b.jsx(ga,{}),children:X.name})}),T&&n&&!r&&b.jsx("button",{className:"wandox-search-suggestion",onClick:z,onKeyDown:j,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:ce=>{ce.currentTarget.style.color="#1890ff"},onMouseLeave:ce=>{ce.currentTarget.style.color="#999"},children:n}),P.length>0&&b.jsx("div",{className:"wandox-chat-input-previews",children:P.map(ce=>b.jsxs("div",{className:"wandox-chat-input-preview-item",children:[b.jsx("img",{src:ce.previewUrl,alt:ce.file.name,className:"wandox-chat-input-preview-img"}),b.jsx("button",{type:"button",className:"wandox-chat-input-preview-remove",onClick:()=>fe(ce.id),title:"删除",children:b.jsx(ga,{})})]},ce.id))}),b.jsx(n7t,{ref:C,placeholder:T&&n&&!r?"":s||t("chat.input.placeholder"),value:S,disabled:r,onChange:ge,onKeyDown:be,onPaste:le,onFocus:()=>k(!0),onBlur:()=>window.setTimeout(()=>k(!1),120),autoSize:{minRows:1,maxRows:6},className:"wandox-chat-textarea",style:{position:"relative",zIndex:2,background:"transparent"}}),b.jsxs("div",{className:"wandox-chat-input-actions",children:[b.jsx("button",{type:"button",className:"wandox-chat-input-icon-btn",title:"上传图片",disabled:r,onClick:se,children:b.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2",stroke:"currentColor",strokeWidth:"2"}),b.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor"}),b.jsx("polyline",{points:"21 15 16 10 5 21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),b.jsx("button",{type:"button",className:`wandox-chat-input-icon-btn wandox-chat-input-send-btn${r?" wandox-chat-input-stop-btn":""}`,disabled:r?i||!a:!S.trim()&&P.length===0,onClick:r?a:je,title:r?i?"正在停止":"停止":t("chat.send"),children:r?b.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("circle",{cx:"12",cy:"12",r:"8",stroke:"currentColor",strokeWidth:"2"}),b.jsx("rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",fill:"currentColor"})]}):b.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{d:"M12 19V5M12 5L5 12M12 5L19 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})}const C_=[{id:"robot",name:"机器人",description:"紫色渐变机器人头像",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsxs("g",{clipPath:"url(#clip0_2019_548)",children:[b.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)"}),b.jsx("path",{d:"M24 12L28 16L24 20L20 16L24 12Z",fill:"white",fillOpacity:"0.95"}),b.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"}),b.jsx("path",{d:"M16 28L12 24L16 20L20 24L16 28Z",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M32 28L28 24L32 20L36 24L32 28Z",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M24 36L20 32L24 28L28 32L24 36Z",fill:"white",fillOpacity:"0.8"})]}),b.jsxs("defs",{children:[b.jsxs("linearGradient",{id:"paint0_linear_2019_548",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[b.jsx("stop",{stopColor:"#8B5CF6"}),b.jsx("stop",{offset:"1",stopColor:"#6366F1"})]}),b.jsx("clipPath",{id:"clip0_2019_548",children:b.jsx("rect",{width:"48",height:"48",fill:"white"})})]})]},"icon-robot")},{id:"amazon",name:"亚马逊",description:"橙色渐变亚马逊图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.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)"}),b.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"}),b.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"}),b.jsx("defs",{children:b.jsxs("linearGradient",{id:"paint0_linear_2026_532",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[b.jsx("stop",{stopColor:"#FF6B35"}),b.jsx("stop",{offset:"1",stopColor:"#F7931E"})]})})]},"icon-amazon")},{id:"star",name:"星星",description:"绿色渐变星星图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsxs("g",{clipPath:"url(#clip0_2019_574)",children:[b.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)"}),b.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"}),b.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"}),b.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"}),b.jsx("path",{d:"M16 22V26H20M32 22V26H28M24 26V22",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),b.jsx("path",{d:"M18 30L14 34M30 30L34 34M24 34V36",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),b.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"}),b.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"}),b.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"})]}),b.jsxs("defs",{children:[b.jsxs("linearGradient",{id:"paint0_linear_2019_574",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[b.jsx("stop",{stopColor:"#10B981"}),b.jsx("stop",{offset:"1",stopColor:"#059669"})]}),b.jsx("clipPath",{id:"clip0_2019_574",children:b.jsx("rect",{width:"48",height:"48",fill:"white"})})]})]},"icon-star")},{id:"gear",name:"齿轮",description:"绿色渐变齿轮图标",component:b.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad4",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#14B8A6"}),b.jsx("stop",{offset:"100%",stopColor:"#0891B2"})]})}),b.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad4)"}),b.jsx("circle",{cx:"20",cy:"20",r:"5",stroke:"white",strokeWidth:"2.5",fill:"none",strokeOpacity:"0.95"}),b.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:b.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad5",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#EC4899"}),b.jsx("stop",{offset:"100%",stopColor:"#A855F7"})]})}),b.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad5)"}),b.jsx("path",{d:"M10 30L26 14L30 18L14 34L10 30Z",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"28",cy:"12",r:"2",fill:"white",fillOpacity:"0.8"}),b.jsx("circle",{cx:"32",cy:"18",r:"1.5",fill:"white",fillOpacity:"0.7"}),b.jsx("circle",{cx:"24",cy:"8",r:"1.5",fill:"white",fillOpacity:"0.7"})]},"icon-magic")},{id:"rocket",name:"火箭",description:"青色渐变火箭图标",component:b.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad6",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#06B6D4"}),b.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),b.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad6)"}),b.jsx("path",{d:"M20 8C20 8 28 12 28 22L24 26L20 24L16 26L12 22C12 12 20 8 20 8Z",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"20",cy:"17",r:"2.5",fill:"url(#grad6)"}),b.jsx("path",{d:"M16 28L14 32L18 30L16 28Z",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M24 28L26 32L22 30L24 28Z",fill:"white",fillOpacity:"0.8"})]},"icon-rocket")},{id:"music",name:"音乐",description:"粉紫渐变音乐图标",component:b.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad7",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#EC4899"}),b.jsx("stop",{offset:"100%",stopColor:"#8B5CF6"})]})}),b.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad7)"}),b.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:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad8",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#06B6D4"}),b.jsx("stop",{offset:"100%",stopColor:"#10B981"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad8)"}),b.jsx("circle",{cx:"24",cy:"24",r:"12",stroke:"white",strokeWidth:"2",fill:"none",strokeOpacity:"0.95"}),b.jsx("path",{d:"M24 12L30 18L24 24L18 18L24 12Z",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M24 24L30 30L24 36L18 30L24 24Z",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M12 24L18 30L24 24L18 18L12 24Z",fill:"white",fillOpacity:"0.7"}),b.jsx("path",{d:"M24 24L30 18L36 24L30 30L24 24Z",fill:"white",fillOpacity:"0.7"})]},"icon-sports")},{id:"games",name:"游戏",description:"红橙渐变游戏图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad9",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#EF4444"}),b.jsx("stop",{offset:"100%",stopColor:"#F97316"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad9)"}),b.jsx("rect",{x:"12",y:"16",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.95"}),b.jsx("rect",{x:"28",y:"16",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.95"}),b.jsx("rect",{x:"20",y:"24",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.8"}),b.jsx("rect",{x:"12",y:"32",width:"8",height:"4",rx:"1",fill:"white",fillOpacity:"0.7"}),b.jsx("rect",{x:"28",y:"32",width:"8",height:"4",rx:"1",fill:"white",fillOpacity:"0.7"})]},"icon-games")},{id:"expenses",name:"财务",description:"金黄渐变财务图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad10",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#F59E0B"}),b.jsx("stop",{offset:"100%",stopColor:"#EAB308"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad10)"}),b.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"}),b.jsx("rect",{x:"20",y:"34",width:"8",height:"2",rx:"1",fill:"white",fillOpacity:"0.8"}),b.jsx("circle",{cx:"21",cy:"20",r:"1.5",fill:"url(#grad10)"}),b.jsx("circle",{cx:"27",cy:"20",r:"1.5",fill:"url(#grad10)"})]},"icon-expenses")},{id:"sciences",name:"科学",description:"青蓝渐变科学图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad11",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#0EA5E9"}),b.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad11)"}),b.jsx("path",{d:"M12 36L20 28L28 36L36 28",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.95"}),b.jsx("circle",{cx:"24",cy:"16",r:"4",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M24 20V28",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.7"}),b.jsx("circle",{cx:"16",cy:"32",r:"2",fill:"white",fillOpacity:"0.7"}),b.jsx("circle",{cx:"32",cy:"32",r:"2",fill:"white",fillOpacity:"0.7"})]},"icon-sciences")},{id:"magic-wand",name:"魔法",description:"紫粉渐变魔法图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad12",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#8B5CF6"}),b.jsx("stop",{offset:"100%",stopColor:"#EC4899"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad12)"}),b.jsx("path",{d:"M12 36L24 24L36 36L24 48L12 36Z",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"28",cy:"12",r:"2",fill:"white",fillOpacity:"0.8"}),b.jsx("circle",{cx:"36",cy:"20",r:"1.5",fill:"white",fillOpacity:"0.7"}),b.jsx("circle",{cx:"20",cy:"8",r:"1.5",fill:"white",fillOpacity:"0.7"}),b.jsx("circle",{cx:"32",cy:"4",r:"1",fill:"white",fillOpacity:"0.6"})]},"icon-magic-wand")},{id:"animals",name:"动物",description:"绿棕渐变动物图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad13",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#10B981"}),b.jsx("stop",{offset:"100%",stopColor:"#92400E"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad13)"}),b.jsx("ellipse",{cx:"24",cy:"28",rx:"10",ry:"8",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"20",cy:"26",r:"2",fill:"url(#grad13)"}),b.jsx("circle",{cx:"28",cy:"26",r:"2",fill:"url(#grad13)"}),b.jsx("path",{d:"M24 30C22 32 20 33 18 33",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.8"}),b.jsx("circle",{cx:"18",cy:"18",r:"4",fill:"white",fillOpacity:"0.8"}),b.jsx("circle",{cx:"30",cy:"18",r:"4",fill:"white",fillOpacity:"0.8"})]},"icon-animals")},{id:"travel",name:"旅行",description:"天蓝渐变旅行图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad14",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#0EA5E9"}),b.jsx("stop",{offset:"100%",stopColor:"#06B6D4"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad14)"}),b.jsx("path",{d:"M8 32L16 16L32 16L40 32L32 40L16 40L8 32Z",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"24",cy:"24",r:"3",fill:"url(#grad14)"}),b.jsx("path",{d:"M24 28V32",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),b.jsx("rect",{x:"12",y:"36",width:"4",height:"2",rx:"1",fill:"white",fillOpacity:"0.7"}),b.jsx("rect",{x:"32",y:"36",width:"4",height:"2",rx:"1",fill:"white",fillOpacity:"0.7"})]},"icon-travel")},{id:"nature",name:"自然",description:"绿色渐变自然图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad15",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#22C55E"}),b.jsx("stop",{offset:"100%",stopColor:"#10B981"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad15)"}),b.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"}),b.jsx("path",{d:"M24 12V20",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),b.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:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad16",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#1E40AF"}),b.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad16)"}),b.jsx("path",{d:"M24 8L8 16V24C8 32 14 38 24 40C34 38 40 32 40 24V16L24 8Z",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"24",cy:"22",r:"4",fill:"url(#grad16)"}),b.jsx("path",{d:"M24 26V30",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),b.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:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad17",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#EF4444"}),b.jsx("stop",{offset:"100%",stopColor:"#DC2626"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad17)"}),b.jsx("rect",{x:"20",y:"12",width:"8",height:"24",rx:"4",fill:"white",fillOpacity:"0.95"}),b.jsx("rect",{x:"12",y:"20",width:"24",height:"8",rx:"4",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"24",cy:"24",r:"2",fill:"url(#grad17)"})]},"icon-health")},{id:"food",name:"美食",description:"橙色渐变美食图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad18",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#FB923C"}),b.jsx("stop",{offset:"100%",stopColor:"#F97316"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad18)"}),b.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"}),b.jsx("circle",{cx:"20",cy:"20",r:"1.5",fill:"url(#grad18)"}),b.jsx("circle",{cx:"28",cy:"20",r:"1.5",fill:"url(#grad18)"}),b.jsx("path",{d:"M24 24C22 26 20 27 18 27",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.8"}),b.jsx("path",{d:"M12 32L8 36L12 40",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.7"})]},"icon-food")}],r7t="robot",ag=e=>{if(!e){const n=C_.find(r=>r.id===r7t);return(n==null?void 0:n.component)||C_[0].component}const t=C_.find(n=>n.id===e);return(t==null?void 0:t.component)||C_[0].component},i7t=new Map(C_.map(e=>[e.id,e]));function a7t({active:e,agents:t,collapsed:n,onToggle:r,className:i,activeView:a="chat",onViewChange:o,onToolboxOpen:s,showLogout:l,onLogout:c,sidebarAgentMode:u=!1,onToggleSidebarMode:d,onAgentSelect:f}){const p=localStorage.getItem("sso_domain")||"",h=[{key:"chat",icon:b.jsx(v2e,{}),title:"对话"},...["maiduo","eccang"].includes(p)?[{key:"plan",icon:b.jsx(Yft,{}),title:"自动化Beta"}]:[],{key:"professional",icon:b.jsx(h2e,{}),title:"专业智能体"}],v=[...p==="yunduo"?[]:[{key:"toolbox",icon:b.jsx(Lpt,{}),label:"工具箱"},{key:"goals",icon:b.jsx(xft,{}),label:"目标追踪"}],{key:"settings",icon:b.jsx(Apt,{}),label:"系统设置"}];return b.jsx("div",{className:"wandox-aside-wrap",children:b.jsxs("div",{className:`wandox-aside ${n?"wandox-aside--collapsed":""} ${i||""}`,"aria-hidden":n,children:[b.jsxs("div",{className:"wandox-aside-header",children:[b.jsx("span",{className:"wandox-aside-header__title",children:"AI 智能体"}),r&&b.jsx("button",{type:"button",className:"wandox-aside-header-toggle",onClick:r,"aria-label":n?"展开侧边栏":"收起侧边栏",title:n?"展开侧边栏":"收起侧边栏",children:b.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",fill:"none",viewBox:"0 0 24 24",children:[b.jsx("title",{children:n?"展开侧边栏":"收起侧边栏"}),b.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"})]})})]}),b.jsx("div",{className:"wandox-aside-main-nav",children:b.jsx("div",{className:"wandox-aside-nav-list",children:h.map(y=>{const x=a===y.key,w=y.key==="professional";return b.jsxs("div",{children:[b.jsxs("div",{className:`wandox-aside-nav-item-wrap${x?" wandox-aside-nav-item-wrap--active":""}`,children:[b.jsxs("button",{type:"button",onClick:()=>o==null?void 0:o(y.key),className:`wandox-aside-nav-item${x?" wandox-aside-nav-item--active":""}`,children:[b.jsx("span",{className:"wandox-aside-nav-icon",children:y.icon}),b.jsx("span",{className:"wandox-aside-nav-title",children:y.title})]}),w&&!n&&d&&b.jsx(or,{title:u?"收起列表":"展开列表",placement:"right",children:b.jsx("button",{type:"button",className:`wandox-aside-mode-toggle${u?" wandox-aside-mode-toggle--active":""}`,onClick:S=>{S.stopPropagation(),d()},children:u?b.jsx(nY,{style:{fontSize:11}}):b.jsx(nw,{style:{fontSize:11}})})})]}),w&&(u||n)&&b.jsx("div",{className:"wandox-aside-agent-list",children:t.map(S=>{const _=S.agent_id;if(!_)return null;const C=e===_&&a==="professional";return b.jsx(or,{title:S.name,placement:"right",children:b.jsxs("button",{type:"button",className:`wandox-aside-agent-item${C?" wandox-aside-agent-item--active":""}`,onClick:()=>{f==null||f(_),a!=="professional"&&(o==null||o("professional"))},children:[b.jsx("span",{className:"wandox-aside-agent-icon",children:ag(S.icon)}),b.jsx("span",{className:"wandox-aside-agent-name",children:S.name})]})},_)})})]},y.key)})})}),b.jsxs("div",{className:"wandox-aside-bottom",children:[b.jsx("p",{className:"wandox-aside-group-label",children:"系统功能"}),b.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 b.jsxs("button",{type:"button",onClick:()=>{if(y.key==="toolbox"){s==null||s();return}o==null||o(y.key)},className:`wandox-aside-nav-item${x?" wandox-aside-nav-item--active":""}`,children:[b.jsx("span",{className:"wandox-aside-nav-icon",children:y.icon}),b.jsx("span",{className:"wandox-aside-nav-title",children:y.label})]},y.key)}),l&&b.jsxs("button",{type:"button",onClick:c,className:"wandox-aside-nav-item wandox-aside-nav-item--logout",children:[b.jsx("span",{className:"wandox-aside-nav-icon",children:b.jsx(ypt,{})}),b.jsx("span",{className:"wandox-aside-nav-title",children:"退出登录"})]})]}),b.jsx("div",{style:{height:8}})]})]})})}function o7t({title:e="正在进入指定智能体",description:t="正在加载智能体与剧本信息..."}){return b.jsxs("output",{className:"wandox-initial-route-loading","aria-label":e,children:[b.jsxs("div",{className:"wandox-initial-route-loading-aura","aria-hidden":"true",children:[Array.from({length:12},(n,r)=>({angle:r*30,delay:r*.08})).map(({angle:n,delay:r})=>b.jsx("span",{className:"wandox-chat-history-ray",style:{"--ray-angle":`${n}deg`,"--ray-delay":`${r}s`}},n)),b.jsx("div",{className:"wandox-chat-empty-icon",children:b.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:[b.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"}),b.jsx("path",{d:"M20 2v4"}),b.jsx("path",{d:"M22 4h-4"}),b.jsx("circle",{cx:"4",cy:"20",r:"2"})]})})]}),b.jsx("div",{className:"wandox-initial-route-loading-title",children:e}),b.jsx("div",{className:"wandox-initial-route-loading-text",children:t})]})}function s7t(e){const{children:t}=e;return b.jsx("div",{className:"wandox-layout wandox-root",children:b.jsx("main",{className:"wandox-layout-content",style:{padding:0},children:t})})}const l7t="wandox_use_map_tree_goals_v2",c7t=/^\?+$/;function u7t(e){return`${l7t}:${e||"all"}`}function ive(e){const t=e,n=Array.isArray(t==null?void 0:t.roles)?t:t==null?void 0:t.data;return Array.isArray(n==null?void 0:n.roles)?n.roles.map(r=>{const i=(r.goals||[]).filter(a=>a.playbook!==null).map(a=>({...a,icon:ave(a.icon),items:(a.items||[]).filter(o=>o.playbook_id)})).filter(a=>{var o;return(a.items||[]).length>0||!!(a.playbook_id||(o=a.playbook)!=null&&o.playbook_id)});return{...r,icon:ave(r.icon),goals:i,goal_count:i.length}}).filter(r=>(r.goals||[]).length>0):[]}function ave(e){const t=String(e||"").trim();if(!(!t||c7t.test(t)))return t}function d7t({agentId:e,onPlaybookClick:t,onSelectPlaybook:n,expanded:r,onExpandedChange:i}){const[a,o]=m.useState(!1),[s,l]=m.useState(!1),[c,u]=m.useState(!1),[d,f]=m.useState([]),[p,h]=m.useState(""),[g,v]=m.useState(""),y=m.useMemo(()=>e==null?"":String(e).trim(),[e]),x=r??a,w=m.useMemo(()=>d.find(C=>C.role_code===p)||d[0],[d,p]);m.useEffect(()=>{u(!1),f([]),h(""),v("")},[y]),m.useEffect(()=>{if(!x||c)return;let C=!1;const $=u7t(y);return(async()=>{l(!0),v("");try{const k=window.localStorage.getItem($);if(k)try{const P=ive(JSON.parse(k));P.length>0&&(f(P),h(P[0].role_code))}catch{window.localStorage.removeItem($)}const T=await Rgt({agent_id:y,role_id:null});if(C)return;const I=ive(T.data);f(I),h(P=>{var N;return P||((N=I[0])==null?void 0:N.role_code)||""}),window.localStorage.setItem($,JSON.stringify(T.data||{roles:[]}))}catch{C||v("使用地图加载失败")}finally{C||(u(!0),l(!1))}})(),()=>{C=!0}},[x,c,y]);const S=C=>{var T,I;const $=C.playbook_id||((T=C.playbook)==null?void 0:T.playbook_id),E=((I=C.playbook)==null?void 0:I.name)||C.title||C.name||"执行";if(!$)return;if(o(!1),i==null||i(!1),gU(C).length>0&&n){n(h7t(C),E);return}t({message:E,playbook_id:$})},_=()=>{const C=!x;o(C),i==null||i(C)};return b.jsxs("div",{className:`wandox-use-map${x?" wandox-use-map--expanded":""}`,children:[b.jsx("div",{className:"wandox-use-map-toolbar",children:b.jsxs("button",{type:"button",className:"wandox-use-map-toggle",onClick:_,"aria-expanded":x,children:[b.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--use-map","aria-hidden":"true",children:b.jsx(f2e,{})}),b.jsx("span",{className:"wandox-use-map-toggle-text",children:"使用地图"}),b.jsx("span",{className:"wandox-use-map-toggle-arrow","aria-hidden":"true",children:"⌄"})]})}),x&&b.jsx("div",{className:`wandox-use-map-panel${d.length===0?" wandox-use-map-panel--compact":""}`,children:(!c||s)&&d.length===0?b.jsxs("div",{className:"wandox-use-map-loading",children:[b.jsx("span",{className:"wandox-heartbeat-loader","aria-hidden":"true",children:b.jsx("svg",{width:"48",height:"24",viewBox:"0 0 48 24",fill:"none",children:b.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"})})}),b.jsx("span",{children:"正在加载使用地图"})]}):g?b.jsxs("div",{className:"wandox-use-map-empty",children:[b.jsx("div",{className:"wandox-use-map-empty-title",children:g}),b.jsx("button",{type:"button",className:"wandox-use-map-retry",onClick:()=>u(!1),children:"重新加载"})]}):d.length===0?b.jsxs("div",{className:"wandox-use-map-empty",children:[b.jsx("div",{className:"wandox-use-map-empty-title",children:"暂无使用地图"}),b.jsx("div",{className:"wandox-use-map-empty-desc",children:"当前智能体还没有配置岗位目标剧本"})]}):b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"wandox-use-map-roles",role:"tablist","aria-label":"岗位",children:d.map(C=>{var $;return b.jsxs("button",{type:"button",role:"tab","aria-selected":(w==null?void 0:w.role_code)===C.role_code,className:`wandox-use-map-role${(w==null?void 0:w.role_code)===C.role_code?" active":""}`,onClick:()=>h(C.role_code),children:[b.jsx("span",{className:"wandox-use-map-role-icon",children:C.icon||"◎"}),b.jsx("span",{className:"wandox-use-map-role-name",children:C.name}),b.jsx("span",{className:"wandox-use-map-role-count",children:C.goal_count||(($=C.goals)==null?void 0:$.length)||0})]},C.id)})}),b.jsx("div",{className:"wandox-use-map-goals",children:((w==null?void 0:w.goals)||[]).map(C=>{var $;return b.jsxs("section",{className:"wandox-use-map-goal-group",children:[b.jsxs("div",{className:"wandox-use-map-goal-group-head",children:[b.jsx("span",{className:"wandox-use-map-goal-group-icon",children:C.icon||"◇"}),b.jsx("span",{className:"wandox-use-map-goal-group-name",children:C.name}),b.jsxs("span",{className:"wandox-use-map-goal-group-count",children:[(($=C.items)==null?void 0:$.length)||0," 个剧本"]}),(C.description||C.subtitle)&&b.jsxs("span",{className:"wandox-use-map-goal-group-desc",children:["· ",C.description||C.subtitle]})]}),b.jsx("div",{className:"wandox-use-map-goal-items",children:(C.items||[]).map(E=>{var I,P,N;const k=gU(E).length>0,T=f7t(E.tags);return b.jsxs("button",{type:"button",className:`wandox-use-map-playbook-card${E.is_featured?" wandox-use-map-playbook-card--featured":""}`,onClick:()=>S(E),children:[b.jsx("div",{className:"wandox-use-map-playbook-title",children:b.jsx("span",{className:"wandox-use-map-playbook-name",children:E.title||E.name||((I=E.playbook)==null?void 0:I.name)||"未命名剧本"})}),(E.is_featured||k)&&b.jsxs("div",{className:"wandox-use-map-playbook-badges",children:[E.is_featured&&b.jsx(ji,{color:"gold",className:"wandox-use-map-tag wandox-use-map-featured-tag",children:"精品"}),k&&b.jsx("span",{className:"wandox-use-map-param-badge",children:"参数"})]}),(E.subtitle||E.description||((P=E.playbook)==null?void 0:P.description))&&b.jsx("div",{className:"wandox-use-map-playbook-desc",children:E.subtitle||E.description||((N=E.playbook)==null?void 0:N.description)}),T.length>0&&b.jsx("div",{className:"wandox-use-map-playbook-tags",children:T.map((A,M)=>b.jsx(ji,{color:A.variant==="soft"?void 0:A.color,className:"wandox-use-map-tag",style:p7t(A),children:A.name},`${A.name}-${M}`))})]},`${C.id}-${E.id||E.playbook_id}`)})})]},C.id)})})]})})]})}function gU(e){var t;return e.input_fields||((t=e.playbook)==null?void 0:t.input_fields)||[]}function f7t(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=typeof(n==null?void 0:n.name)=="string"?n.name.trim():"";return r&&t.push({...n,name:r}),t},[]):[]}function p7t(e){if(!(e.variant!=="soft"||!e.color))return{color:e.color,borderColor:ove(e.color,.28),backgroundColor:ove(e.color,.08)}}function ove(e,t){const n=e.trim().replace("#","");if(!/^[0-9a-fA-F]{6}$/.test(n))return e;const r=Number.parseInt(n.slice(0,2),16),i=Number.parseInt(n.slice(2,4),16),a=Number.parseInt(n.slice(4,6),16);return`rgba(${r}, ${i}, ${a}, ${t})`}function h7t(e){var n;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:((n=e.playbook)==null?void 0:n.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:gU(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}}function v1(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ROe(e){return v1(e)?v1(e.data)?e.data:e:{}}function sve(e){return(Array.isArray(e)?e.map(n=>[void 0,n]):v1(e)?Object.entries(e):[]).flatMap(([n,r])=>{if(!v1(r))return[];const i=String(r.name||n||"").trim();return i?[{...r,name:i,label:String(r.label||i),type:String(r.type||"string")}]:[]})}function m7t(e){const t=ROe(e),n=v1(t.content)?t.content:{},r=n.yaml_content;if(typeof r=="string"&&r.trim())try{const i=FE.parse(r);return sve(v1(i)?i.params:void 0)}catch{}for(const i of[t.input_fields,n.input_fields]){const a=sve(i);if(a.length>0)return a}return[]}function g7t(e,t){const n=ROe(t),r=m7t(n);return{...e,...n,playbook_id:String(n.playbook_id||e.playbook_id),name:String(n.name||e.name),input_fields:r}}function v7t(e){if(!e)return"";const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/864e5),r=Math.floor(t/36e5);return n===1?"昨天":n>1?`${n} 天前`:r>=1?`${r} 小时前`:"刚刚"}const Om=e=>String(e.playbook_id||e.code||e.name);function y7t({label:e}){return b.jsxs("output",{className:"wandox-scene-list-loading","aria-label":e,children:[b.jsx("span",{className:"wandox-heartbeat-loader","aria-hidden":"true",children:b.jsx("svg",{width:"48",height:"24",viewBox:"0 0 48 24",fill:"none",children:b.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"})})}),b.jsx("span",{children:e})]})}function DOe({playbooks:e,playbookLoading:t,onPlaybookClick:n,onSelectPlaybook:r,recommendations:i=[],userPlaybooks:a=[],userPlaybooksLoading:o=!1,onLoadUserPlaybooks:s,agentId:l,recentRefreshKey:c=0}){const[u,d]=m.useState("playbooks"),[f,p]=m.useState(!1),[h,g]=m.useState(!1),[v,y]=m.useState("全部"),[x,w]=m.useState(""),[S,_]=m.useState(null),[C,$]=m.useState(""),[E,k]=m.useState(!1),[T,I]=m.useState([]),[P,N]=m.useState(!1),[A,M]=m.useState(""),R=m.useRef(!1),L=m.useRef(new Map),z=m.useMemo(()=>u==="recommendations"?t&&i.length===0:u==="user"?o:P||t&&e.length===0,[t,P,u,e.length,i.length,o]),j=m.useMemo(()=>l==null?"":String(l).trim(),[l]);m.useEffect(()=>{if(!j){I([]),N(!1);return}let Y=!1;return(async()=>{N(!0);try{const ee=await Xmt({limit:8,agent_id:j});Y||I(ee.data||[])}catch{Y||I([])}finally{Y||N(!1)}})(),()=>{Y=!0}},[j,c]);const O=m.useRef(null),[V,B]=m.useState(5),D=m.useCallback(()=>{if(!O.current)return;const Y=O.current.offsetWidth;if(Y===0)return;const ee=Math.floor(Y/(200+12));B(Math.max(2,ee))},[]);m.useEffect(()=>{const Y=setTimeout(D,100);return()=>clearTimeout(Y)},[D,u,f]),m.useEffect(()=>{u==="recommendations"&&i.length===0&&d("playbooks")},[i.length,u]),m.useEffect(()=>{u!=="user"||!j||s==null||s()},[u,j,s]),m.useEffect(()=>{if(!O.current)return;const Y=new ResizeObserver(()=>{D()});return Y.observe(O.current),()=>Y.disconnect()},[D]);const F=m.useMemo(()=>new Set(T.map(Om)),[T]),H=m.useMemo(()=>new Set(a.map(Om)),[a]),W=m.useMemo(()=>{const Y=new Map;for(const Z of T.filter(re=>!H.has(Om(re))))Y.set(Om(Z),Z);for(const Z of e){const re=Om(Z);Y.has(re)||Y.set(re,Z)}return Array.from(Y.values())},[e,T,H]),K=u==="playbooks"?W:u==="recommendations"?i:a,U=u==="playbooks"?e:K,q=K.length>(V??5)&&U.length>0,Q=m.useMemo(()=>{const Y=new Map;Y.set("全部",U.length);for(const Z of U){const re=Z.category_name||"未分类";Y.set(re,(Y.get(re)||0)+1)}return Array.from(Y.entries()).map(([Z,re])=>({name:Z,count:re}))},[U]),G=m.useMemo(()=>{let Y=U;if(v!=="全部"&&(Y=Y.filter(Z=>(Z.category_name||"未分类")===v)),x.trim()){const Z=x.trim().toLowerCase();Y=Y.filter(re=>{var ee;return re.name.toLowerCase().includes(Z)||((ee=re.description)==null?void 0:ee.toLowerCase().includes(Z))})}return Y},[U,v,x]),X=m.useCallback(Y=>{const Z=String(Y.playbook_id||"").trim();if(!Z)return Promise.reject(new Error("缺少 playbook_id"));const re=L.current.get(Z);if(re)return re;const ee=BE({playbook_id:Z}).then(({data:te})=>g7t(Y,te)).finally(()=>{L.current.delete(Z)});return L.current.set(Z,ee),ee},[]),J=m.useCallback(async(Y,Z=!1)=>{var re;if(!R.current){R.current=!0,M(Y.playbook_id);try{const ee=await X(Y);if(Z&&(g(!1),y("全部"),w("")),(re=ee.input_fields)!=null&&re.length&&r){r(ee,ee.name);return}n({message:ee.name,playbook_id:ee.playbook_id})}catch{Ze.error("剧本参数加载失败,请稍后重试")}finally{R.current=!1,M("")}}},[X,n,r]);return b.jsxs("div",{className:"wandox-pro-scenes-panel",children:[b.jsxs("div",{className:"wandox-hub-section-header",children:[b.jsxs("div",{className:"wandox-scene-tabs",children:[b.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&u==="playbooks"?" active":""}`,onClick:()=>{d("playbooks"),p(!1)},children:[b.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--playbooks","aria-hidden":"true",children:b.jsx(p2e,{})}),b.jsx("span",{children:"默认场景"})]}),i.length>0&&b.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&u==="recommendations"?" active":""}`,onClick:()=>{d("recommendations"),p(!1)},children:[b.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--recommendations","aria-hidden":"true",children:b.jsx(h2e,{})}),b.jsx("span",{children:"推荐场景"})]}),b.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&u==="user"?" active":""}`,onClick:()=>{d("user"),p(!1)},children:[b.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--user","aria-hidden":"true",children:b.jsx(Vpt,{})}),b.jsx("span",{children:"我的场景"})]}),b.jsx(d7t,{agentId:j,onPlaybookClick:n,onSelectPlaybook:r,expanded:f,onExpandedChange:Y=>{p(Y),Y&&d("playbooks")}})]}),q&&!f&&b.jsxs("button",{type:"button",className:"wandox-scene-view-all",onClick:()=>g(!0),children:["查看全部 ",U.length," 个"]})]}),b.jsx("div",{className:"wandox-tab-content",children:!f&&b.jsx("div",{className:"wandox-hub-section",children:z?b.jsx(y7t,{label:u==="user"?"正在加载我的场景":u==="recommendations"?"正在匹配推荐场景":"正在加载场景"}):K.length>0?b.jsxs("div",{className:"wandox-scroll-row",ref:O,children:[K.slice(0,V??5).map(Y=>{const Z=A===Y.playbook_id,re=()=>void J(Y),ee=u==="playbooks"&&F.has(Om(Y)),te=u==="user"?"用户":ee?"近期":Y.badge==="new"?"New":Y.badge==="recommend"?"推荐":Y.badge==="featured"?"精选":Y.category_name||Y.type||"推荐",oe=Y.video_duration?`${Math.floor(Y.video_duration/60)}:${String(Y.video_duration%60).padStart(2,"0")}`:"",fe=async we=>{var le;we.stopPropagation(),_(Y),k(!0);try{const se=await Ase({playbook_id:Y.playbook_id});$(((le=se.data)==null?void 0:le.video_url)||Y.video_url||"")}catch{$(Y.video_url||"")}finally{k(!1)}},he={daily:"每日",weekly:"每周",monthly:"每月"},ye=Y.is_subscribed?`🔔订阅${Y.execution_frequency&&Y.execution_frequency!=="none"?`·${he[Y.execution_frequency]}自动跑`:""}`:"",Te=[Y.description,ye].filter(Boolean).join(" "),Ee=[Y.last_executed_at&&v7t(Y.last_executed_at),Y.execution_count!==void 0&&`已跑 ${Y.execution_count} 次`].filter(Boolean).join(" · ");return b.jsxs("div",{className:"wandox-card",children:[b.jsxs("div",{className:"wandox-card-corner",children:[b.jsx("span",{className:"wandox-card-tag",children:te}),Y.video_url&&b.jsxs("button",{type:"button",className:"wandox-card-video",onClick:fe,children:["▶ ",oe?` ${oe}`:"0:00"," 演示"]})]}),b.jsxs("button",{type:"button",className:"wandox-card-main",onClick:re,disabled:Z,"aria-busy":Z,children:[b.jsx("div",{className:"wandox-card-title",children:Y.name}),b.jsx("div",{className:"wandox-card-desc",children:Z?"正在加载参数...":ee&&Ee||Te})]})]},Om(Y))}),q&&b.jsxs("button",{type:"button",className:"wandox-card wandox-card-more",onClick:()=>g(!0),children:[b.jsxs("div",{className:"wandox-card-more-title",children:["查看全部 ",U.length," 个"]}),b.jsx("div",{className:"wandox-card-more-desc",children:"按场景浏览"})]})]}):b.jsx("div",{className:"wandox-empty-slot",children:b.jsxs("div",{className:"wandox-empty",children:[b.jsx("div",{className:"wandox-empty-text",children:u==="playbooks"?"暂无默认场景":u==="recommendations"?"暂无推荐场景":"暂无我的场景"}),b.jsx("div",{className:"wandox-empty-desc",children:u==="playbooks"?"请联系管理员添加场景剧本":u==="recommendations"?"系统会根据情况推荐相关场景":"我创建的场景会显示在这里"})]})})})}),b.jsx(rr,{open:h,onCancel:()=>{g(!1),y("全部"),w("")},footer:null,width:900,closable:!1,centered:!0,styles:{container:{padding:0,overflow:"hidden"},body:{height:"90vh"}},zIndex:1e4,children:b.jsxs("div",{className:"wandox-playbook-browser",children:[b.jsxs("div",{className:"wandox-playbook-sidebar",children:[b.jsx("div",{className:"wandox-playbook-sidebar-title",children:"场景分类"}),b.jsx("div",{className:"wandox-playbook-categories",children:Q.map(Y=>b.jsxs("button",{type:"button",className:`wandox-playbook-category-item${v===Y.name?" active":""}`,onClick:()=>y(Y.name),children:[b.jsx("span",{className:"wandox-playbook-category-name",children:Y.name}),b.jsx("span",{className:"wandox-playbook-category-count",children:Y.count})]},Y.name))})]}),b.jsxs("div",{className:"wandox-playbook-main",children:[b.jsx("div",{className:"wandox-playbook-search",children:b.jsx(Kt,{placeholder:"搜索场景名称或描述...",prefix:b.jsx(dy,{style:{color:"#9ca3af"}}),value:x,onChange:Y=>w(Y.target.value),allowClear:!0})}),b.jsx("div",{className:"wandox-playbook-list",children:G.length===0?b.jsx(ei,{description:"暂无剧本",style:{marginTop:80}}):G.map(Y=>{const Z=Y.input_fields&&Y.input_fields.length>0,re=A===Y.playbook_id,ee=!!Y.video_url,te=()=>void J(Y,!0),oe=Y.video_duration?`${Math.floor(Y.video_duration/60)}:${String(Y.video_duration%60).padStart(2,"0")}`:"",fe=async()=>{var he;_(Y),k(!0);try{const ye=await Ase({playbook_id:Y.playbook_id});$(((he=ye.data)==null?void 0:he.video_url)||Y.video_url||"")}catch{Ze.error("视频加载失败"),$(Y.video_url||"")}finally{k(!1)}};return b.jsx("div",{className:"wandox-playbook-list-item",children:b.jsxs("div",{className:"wandox-playbook-list-item-content",children:[b.jsx("div",{className:"wandox-playbook-list-item-icon",children:ee?b.jsx("button",{className:"wandox-playbook-video-icon",title:"包含演示视频",onClick:fe,type:"button",children:b.jsx(Fc,{})}):b.jsx("div",{className:"wandox-playbook-no-video-icon",children:b.jsx(n$e,{})})}),b.jsxs("div",{className:"wandox-playbook-list-item-body",children:[b.jsx("div",{className:"wandox-playbook-list-item-header",children:b.jsxs("div",{className:"wandox-playbook-list-item-title",children:[Y.name,Y.badge&&b.jsx("span",{className:`wandox-scene-badge wandox-scene-badge--${Y.badge}`,children:Y.badge==="new"?"New":Y.badge==="recommend"?"推荐":"精选"})]})}),Y.description&&b.jsx("div",{className:"wandox-playbook-list-item-desc",children:Y.description}),Y.last_execution_remark&&b.jsxs("div",{className:"wandox-playbook-list-item-remark",children:[b.jsx("span",{className:"wandox-playbook-list-item-remark-icon",children:"💡"}),b.jsxs("span",{children:["上次:",Y.last_execution_remark]})]})]}),b.jsxs("div",{className:"wandox-playbook-list-item-actions",children:[b.jsx("button",{type:"button",className:"wandox-playbook-list-item-btn",onClick:te,disabled:re,"aria-busy":re,children:re?"加载中":Z?"参数":"运行"}),ee&&b.jsxs("button",{type:"button",className:"wandox-playbook-demo-link",onClick:fe,children:["看演示",oe?` ${oe}`:""]})]})]})},Y.playbook_id)})})]})]})}),S&&b.jsx(rr,{open:!0,onCancel:()=>{_(null),$("")},footer:null,centered:!0,width:800,title:b.jsxs("span",{children:[b.jsx(Fc,{style:{marginRight:8,color:"#7c3aed"}}),S.name," · 演示视频",S.video_duration&&b.jsxs("span",{style:{marginLeft:12,fontSize:13,color:"#9ca3af",fontWeight:"normal"},children:["时长 ",Math.floor(S.video_duration/60),":",String(S.video_duration%60).padStart(2,"0")]}),S.view_count!==void 0&&b.jsxs("span",{style:{marginLeft:12,fontSize:13,color:"#9ca3af",fontWeight:"normal"},children:["👁 ",S.view_count," 次播放"]})]}),styles:{body:{padding:"12px 0 0"}},zIndex:10001,children:E?b.jsx("div",{style:{height:400,display:"flex",alignItems:"center",justifyContent:"center",background:"#000",borderRadius:8},children:b.jsx(Ri.Node,{active:!0,style:{width:200,height:200}})}):b.jsx("video",{src:C,controls:!0,autoPlay:!0,style:{width:"100%",borderRadius:8,display:"block",maxHeight:"70vh",background:"#000"},children:b.jsx("track",{kind:"captions"})})})]})}const OOe=[{name:"country",label:"国家/地区"},{name:"state",label:"州/省"},{name:"province",label:"省"},{name:"city",label:"城市"},{name:"postal_code",label:"邮政编码"},{name:"address_line1",label:"地址"}],b7t=Object.fromEntries(OOe.map(e=>[e.name,e.label]));function z2(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R0(e){return typeof e=="string"?e.trim():String(e??"").trim()}function x7t(e,t){return!z2(e)||!Array.isArray(e[t])?[]:e[t].map(String).filter(Boolean)}function w7t(e,t){if(!z2(e)||!z2(e.postal_code_patterns))return;const n=e.postal_code_patterns[t];return typeof n=="string"?n:void 0}function aj(e){const t=String(e.type||"").toLowerCase(),n=String(e.widget||"").toLowerCase();return t==="address"||n==="address"}function S7t(){return[...OOe]}function LOe(e,t){if(!z2(e))return"请输入有效地址";const n=x7t(t,"required_fields"),r=n.length>0?n:["country","city","postal_code","address_line1"];for(const l of r)if(!R0(e[l]))return`请填写${b7t[l]||`地址字段 ${l}`}`;if(n.length===0&&!R0(e.state)&&!R0(e.province))return"请填写州/省";const i=R0(e.country).toUpperCase(),a=R0(e.postal_code),o=w7t(t,i);if(a&&o)try{if(!new RegExp(o).test(a))return"邮政编码格式不正确"}catch{return"地址邮编规则配置无效"}const s=z2(t)&&typeof t.max_length=="number"?t.max_length:200;return R0(e.address_line1).length>s?`地址行不能超过 ${s} 个字符`:""}var jOe={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Xs,function(){var n="month",r="quarter";return function(i,a){var o=a.prototype;o.quarter=function(c){return this.$utils().u(c)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(c-1))};var s=o.add;o.add=function(c,u){return c=Number(c),this.$utils().p(u)===r?this.add(3*c,n):s.bind(this)(c,u)};var l=o.startOf;o.startOf=function(c,u){var d=this.$utils(),f=!!d.u(u)||u;if(d.p(c)===r){var p=this.quarter()-1;return f?this.month(3*p).startOf(n).startOf("day"):this.month(3*p+2).endOf(n).endOf("day")}return l.bind(this)(c,u)}}})})(jOe);var _7t=jOe.exports;const C7t=Co(_7t);In.extend(mK);In.extend(C7t);In.extend(b_e);const $7t={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 hT(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 bu(e){var n;const t=hT(e.type);if(t)return(n=e.format)!=null&&n.trim()?e.format.trim():mT(e)==="time"?"HH:mm:ss":GQ(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":$7t[t]}function mT(e){const t=hT(e.type);return t?t==="time"||t==="timerange"?"time":"date":null}function y1(e){const t=hT(e.type);return e.range??(t==="daterange"||t==="datetimerange"||t==="timerange")}function GQ(e){const t=hT(e.type);return e.show_time??(t==="datetime"||t==="datetimerange")}function b1(e,t){return["date","week","month","quarter","year"].includes(t||"")?t:e==="YYYY"?"year":e==="YYYY-MM"?"month":"date"}function ov(e){return e!=null&&e.includes("ss")?"HH:mm:ss":"HH:mm"}function sv(e,t,n){if(e==null||e===""||typeof e!="string"&&typeof e!="number"&&!(e instanceof Date)&&!In.isDayjs(e))return null;let r;if(typeof e=="string"&&/^\d{1,2}:\d{2}(?::\d{2})?$/.test(e))r=In(`2000-01-01 ${e}`);else if(typeof e=="string"&&n==="quarter"){const i=e.match(/^(\d{4}).*?Q([1-4])/i);r=i?In(`${i[1]}-01-01`).quarter(Number(i[2])):In(e)}else if(typeof e=="string"&&n==="week"){const i=e.match(/^(\d{4})\D+(\d{1,2})/);r=i?In(`${i[1]}-01-01`).week(Number(i[2])):In(e)}else typeof e=="string"&&t?(r=In(e,t,!0),r.isValid()||(r=In(e))):r=In(e);return r.isValid()?r:null}function SC(e,t,n){return!Array.isArray(e)||e.length!==2?null:[sv(e[0],t,n),sv(e[1],t,n)]}function qQ({field:e,value:t,size:n,disabled:r=!1,readOnly:i=!1,status:a,onChange:o}){const s=mT(e),l=bu(e),c=y1(e),u={size:n,style:{width:"100%"},format:l,disabled:r,allowClear:!i,inputReadOnly:i,open:i?!1:void 0,status:a};if(s==="date"){const d=GQ(e),f=b1(l,e.picker),p=d?"日期时间":"日期",h={...u,picker:f,showTime:d?{format:ov(l)}:!1};return c?b.jsx(ui.RangePicker,{...h,value:SC(t,l,f),placeholder:[`请选择开始${p}`,`请选择结束${p}`],onChange:(g,v)=>o(v)}):b.jsx(ui,{...h,value:sv(t,l,f),placeholder:e.placeholder||`请选择${p}`,onChange:(g,v)=>o(v)})}return s==="time"?c?b.jsx(Ua.RangePicker,{...u,value:SC(t,l),placeholder:["请选择开始时间","请选择结束时间"],onChange:(d,f)=>o(f)}):b.jsx(Ua,{...u,value:sv(t,l),placeholder:e.placeholder||"请选择时间",onChange:(d,f)=>o(f)}):null}function lve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _C(e){return["array","list","tags","multi_select","multiselect"].includes(String(e||"").toLowerCase())}function zOe(e){return(e==null?void 0:e.includes("image"))??!1}function oj(e){const t=(e.ui_component||e.widget||e.type||"string").toLowerCase();return hT(t)||t}function FOe(e){return oj(e)==="segmented"||e.type.toLowerCase()==="segmented"}function cve(e){var t;return(t=e.options)!=null&&t.length?e.options:(e.enum||[]).map(n=>({value:n,label:n}))}function E7t(e){return e==null?"":typeof e=="string"||typeof e=="number"||typeof e=="bigint"?e:String(e)}function T7t(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 vU(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 n=JSON.parse(t);if(Array.isArray(n))return n.map(r=>String(r))}catch{}}return[String(e)]}function If(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function x1(e,t={}){const n={};for(const r of e){const i=t[r.name];i!==void 0&&i!==""?n[r.name]=_C(r.type)?vU(i):i:r.default!==void 0&&r.default!==""?n[r.name]=_C(r.type)?vU(r.default):r.default:r.type.toLowerCase()==="boolean"?n[r.name]=!1:["number","integer","float"].includes(r.type.toLowerCase())?n[r.name]=void 0:_C(r.type)?n[r.name]=[]:n[r.name]=""}return n}function $_(e,t){return Array.isArray(e)?e.some(n=>$_(n,t)):String(e??"")===String(t??"")}function I7t(e){return Array.isArray(e)?e.filter(lve):lve(e)?"field"in e||"name"in e||"param"in e?[e]:Object.entries(e).map(([t,n])=>({field:t,equals:n})):[]}function k7t(e,t){const n=String(e.field??e.name??e.param??"");if(!n)return!0;const r=t[n],i=e.equals!==void 0||e.value!==void 0,a=e.equals??e.value;return!(i&&!$_(r,a)||e.not_equals!==void 0&&$_(r,e.not_equals)||Array.isArray(e.in)&&!e.in.some(o=>$_(r,o))||Array.isArray(e.not_in)&&e.not_in.some(o=>$_(r,o))||e.truthy===!0&&!r||e.empty===!0&&!If(r)||e.empty===!1&&If(r))}function gT(e,t){return e.filter(n=>{const r=I7t(n.visible_when);return r.length===0||r.every(i=>k7t(i,t))})}function BOe(e,t){return e.reduce((n,r)=>(n[r.name]=t[r.name],n),{})}function P7t(e){return Array.isArray(e)?e.map(t=>String(t)):e?[String(e)]:[]}function yU(e){return e!=null&&e!==""}function N7t(e,t){const n=_C(e.type),r=vU(t),i=yU(t)?String(t):void 0;return{isMulti:n,selectValue:n?r:i,isEmptySelect:n?r.length===0:i===void 0,hasCurrentSelection:n?r.length>0:i!==void 0}}function KQ({field:e,value:t,readOnly:n=!1,size:r,uploading:i=!1,imageUploadMode:a="picture",fileNameMap:o={},getOptionState:s,onChange:l,onUpload:c,onDownloadTemplate:u,draftValue:d,onDraftChange:f,onDraftCommit:p,selectSearchValue:h,onSelectSearchChange:g,onSelectAllowEmptySearch:v}){var C,$,E,k;const y=d??String(E7t(t)),x=oj(e),w={...e,type:x},S=T=>l(e.name,T),_=()=>{var O,V;const T=s(e),I=e.options_from_skill?T.options:cve(e),P=!!(e.options_from_skill||(O=e.enum)!=null&&O.length||(V=e.options)!=null&&V.length),N=T.waitingForDependencies?"请先选择关联参数":T.placeholder||e.placeholder||"请选择",{isMulti:A,selectValue:M,isEmptySelect:R,hasCurrentSelection:L}=N7t(e,t),z=g!==void 0,j=()=>{v==null||v(e.name),h&&(g==null||g(e.name,""))};return b.jsx(tn,{allowClear:!n,showSearch:!n,size:r,autoClearSearchValue:!z,optionFilterProp:"label",filterOption:(B,D)=>{const F=B.trim().toLowerCase();return F?String((D==null?void 0:D.label)??(D==null?void 0:D.value)??"").toLowerCase().includes(F):!0},mode:A?P?"multiple":"tags":void 0,value:M,searchValue:n||!z?void 0:h,placeholder:R?N:void 0,options:I,loading:!n&&T.loading,disabled:!n&&T.waitingForDependencies,open:n?!1:void 0,tabIndex:n?-1:void 0,"aria-readonly":n,tokenSeparators:A&&!P?[","]:void 0,notFoundContent:T.loading?b.jsx(vr,{size:"small"}):T.error||null,onInputKeyDown:B=>{["Backspace","Delete","Escape"].includes(B.key)&&(v==null||v(e.name))},onSearch:z?B=>g(e.name,B):void 0,onChange:B=>{S(B);const D=Array.isArray(B)?B.length>0:yU(B);(L||D)&&j()},onClear:j,onBlur:j})};if(FOe(e)){const T=cve(e);return T.length===0?_():b.jsx(DK,{className:"wandox-agent-input-field-control__segmented",options:T,value:yU(t)?String(t):void 0,disabled:n,onChange:S})}if(aj(e)){const T=t&&typeof t=="object"&&!Array.isArray(t)?t:{},I=(P,N)=>{n||S({...T,[P]:N})};return b.jsxs("div",{className:"wandox-agent-input-field-control__address",children:[S7t().map(({name:P,label:N})=>b.jsx(Kt,{size:r,value:String(T[P]??""),readOnly:n,placeholder:N,onChange:A=>I(P,A.target.value)},P)),b.jsx(Kt,{size:r,value:String(T.address_line2??""),readOnly:n,placeholder:"地址补充",onChange:P=>I("address_line2",P.target.value)})]})}if(mT(w))return b.jsx(qQ,{field:w,value:t,size:r,readOnly:n,disabled:n,onChange:S});switch(x){case"file":{const T=e.max_files??1,I=P7t(t),P=I.length<T,N=A=>{S(T<=1?"":I.filter((M,R)=>R!==A))};if(a==="picture"&&zOe(e.file_type)){const A=I.map((M,R)=>({uid:String(R),name:o[M]||M.split("/").pop()||`image_${R+1}`,status:"done",url:M}));return b.jsx(zc,{className:"wandox-agent-input-field-control__picture",accept:e.file_type||void 0,listType:"picture-card",fileList:A,customRequest:n?void 0:c(e.name,T),onRemove:n?void 0:M=>(N(Number(M.uid)),!0),disabled:n||i,maxCount:T,showUploadList:{showRemoveIcon:!n},children:P&&!n&&b.jsxs("div",{children:[i?b.jsx(vr,{size:"small"}):b.jsx(Uo,{}),b.jsx("div",{className:"wandox-agent-input-field-control__upload-text",children:"上传图片"})]})})}return b.jsxs("div",{className:"wandox-agent-input-field-control__files",children:[I.map((A,M)=>b.jsxs("div",{className:"wandox-agent-input-field-control__file",children:[b.jsx("span",{children:o[A]||A.split("/").pop()||A}),!n&&b.jsx(Et,{type:"text",size:"small",danger:!0,"aria-label":"移除文件",icon:b.jsx(hf,{}),onClick:()=>N(M)})]},A)),e.file_templates&&e.file_templates.length>0&&b.jsxs("div",{className:"wandox-agent-input-field-control__templates",children:[b.jsx("span",{children:"模板文件"}),e.file_templates.map((A,M)=>b.jsx(Et,{size:"small",onClick:()=>u==null?void 0:u(A),children:A.name||"下载模板"},`${A.path}-${A.name||M}`))]}),P&&!n&&b.jsxs(zc.Dragger,{accept:e.file_type||void 0,showUploadList:!1,customRequest:c(e.name,T),disabled:i,children:[b.jsx("p",{className:"ant-upload-drag-icon",children:i?b.jsx(vr,{size:"small"}):b.jsx(OE,{})}),b.jsx("p",{className:"ant-upload-text",children:i?"上传中...":"点击或拖拽文件上传"}),T>1&&b.jsxs("p",{className:"ant-upload-hint",children:["已上传 ",I.length,"/",T]})]})]})}case"boolean":return b.jsx(yo,{size:r==="small"?"small":"default",checked:!!t,disabled:n,onChange:S});case"number":case"integer":case"float":return b.jsx(zo,{size:r,value:T7t(t),readOnly:n,placeholder:e.placeholder||"请输入",onChange:S});case"select":case"array":case"list":case"tags":case"multi_select":case"multiselect":return _();case"string":return(C=e.enum)!=null&&C.length||($=e.options)!=null&&$.length||e.options_from_skill?_():b.jsx(Kt,{size:r,value:y,readOnly:n,placeholder:e.placeholder||"请输入",onChange:n?void 0:T=>f?f(e.name,T.target.value):S(T.target.value),onBlur:n?void 0:T=>p==null?void 0:p(e.name,T.target.value)});default:return(E=e.enum)!=null&&E.length||(k=e.options)!=null&&k.length||e.options_from_skill?_():b.jsx(Kt.TextArea,{value:y,readOnly:n,autoSize:{minRows:2,maxRows:8},placeholder:e.placeholder||"请输入",onChange:n?void 0:T=>f?f(e.name,T.target.value):S(T.target.value),onBlur:n?void 0:T=>p==null?void 0:p(e.name,T.target.value)})}}const VOe=/\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}/g,A7t=/^\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}$/;function lv(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bU(e,t){return t.split(".").reduce((n,r)=>{if(lv(n))return n[r]},e)}function M7t(e){return e==null||e===""}function R7t(e){const t=new Set,n=r=>{if(typeof r=="string"){for(const i of r.matchAll(VOe))i[1]&&t.add(i[1]);return}if(Array.isArray(r)){r.forEach(n);return}lv(r)&&Object.values(r).forEach(n)};return n(e),Array.from(t)}function D7t(e,t){const n=e.split(".")[0],r=t.find(i=>i.name===e||i.name===n);return r?!!r.required:!0}function xU(e,t){if(typeof e=="string"){const n=e.match(A7t);return n!=null&&n[1]?bU(t,n[1]):e.replace(VOe,(r,i)=>{const a=bU(t,i);return a==null?"":String(a)})}return Array.isArray(e)?e.map(n=>xU(n,t)):lv(e)?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,xU(r,t)])):e}function O7t(e){const t=lv(e)&&"data"in e?e.data:e,n=[t];lv(t)&&(n.push(t.output_data,t.options,t.items,t.data,t.result,t.results,t.list),lv(t.output)&&n.push(t.output.output_data,t.output.options,t.output.items,t.output.data));for(const r of n)if(Array.isArray(r))return r;return[]}function L7t(e){let t;return{options:O7t(e).map(r=>{if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return{value:String(r),label:String(r)};if(!lv(r))return null;const i=r.value??r.key??r.code??r.id??r.name??r.label;if(i==null)return null;const a=r.label??r.name??r.title??r.text??r.value??i;if(String(i)===""){const o=String(a||"");return o&&!t&&(t=o),null}return{value:String(i),label:String(a)}}).filter(r=>!!r),placeholder:t}}function j7t(e){return(e.enum||[]).map(t=>({value:t,label:t}))}function sj(e,t,n){const[r,i]=m.useState({}),a=m.useRef({}),o=m.useRef({}),s=m.useMemo(()=>e.filter(l=>!!l.options_from_skill),[e]);return m.useEffect(()=>{const l=new Set(s.map(c=>c.name));for(const c of Object.keys(a.current))l.has(c)||(delete a.current[c],delete o.current[c]);i(c=>{const u=Object.fromEntries(Object.entries(c).filter(([d])=>l.has(d)));return Object.keys(u).length===Object.keys(c).length?c:u})},[s]),m.useEffect(()=>{for(const l of s){if(!l.options_from_skill)continue;const u=R7t(l.options_params).filter(g=>D7t(g,e)&&M7t(bU(t,g))),d=xU(l.options_params||{},t),f=JSON.stringify({skill_id:l.options_from_skill,params:d,missing:u});if(a.current[l.name]===f)continue;const p=a.current[l.name]!==void 0||u.length>0;a.current[l.name]=f,o.current[l.name]=(o.current[l.name]||0)+1;const h=o.current[l.name];if(p&&n(g=>g[l.name]===void 0||g[l.name]===""?g:{...g,[l.name]:void 0}),u.length>0){i(g=>({...g,[l.name]:{options:[],loading:!1,waitingForDependencies:!0}}));continue}i(g=>{var v,y;return{...g,[l.name]:{options:((v=g[l.name])==null?void 0:v.options)||[],loading:!0,placeholder:(y=g[l.name])==null?void 0:y.placeholder,waitingForDependencies:!1}}}),PEe({},{skill_id:l.options_from_skill,params:d}).then(g=>{if(o.current[l.name]!==h)return;const v=L7t(g);i(y=>({...y,[l.name]:{options:v.options,loading:!1,placeholder:v.placeholder,waitingForDependencies:!1}}))}).catch(g=>{if(o.current[l.name]!==h)return;const v=g instanceof Error?g.message:"动态选项加载失败";i(y=>({...y,[l.name]:{options:[],loading:!1,error:v,waitingForDependencies:!1}}))})}},[s,e,t,n]),{getFieldState(l){return l.options_from_skill?r[l.name]||{options:[],loading:!1,waitingForDependencies:!1}:{options:j7t(l),loading:!1,waitingForDependencies:!1}}}}function w1(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ng(e,t=""){return typeof e=="string"?e:e==null?t:String(e)}function sc(e){return typeof e=="string"?e:void 0}const z7t=["date","week","month","quarter","year"];function F7t(e){return typeof e=="string"&&z7t.includes(e)}function uve(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 B7t(e){if(!Array.isArray(e))return;const t=e.map(n=>{if(!w1(n))return null;const r=Ng(n.path);return r?{name:Ng(n.name,r.split("/").pop()||r),path:r}:null}).filter(n=>!!n);return t.length>0?t:void 0}function V7t(e){if(!Array.isArray(e))return;const t=e.map(n=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return{value:String(n),label:String(n)};if(!w1(n))return null;const r=n.value??n.key??n.code??n.id??n.name??n.label;return r==null||r===""?null:{value:String(r),label:Ng(n.label??n.title??n.text??n.name??r,String(r))}}).filter(n=>!!n);return t.length>0?t:void 0}function H6(e){const t=w1(e)?e:{};return{name:Ng(t.name),label:Ng(t.label,Ng(t.name)),type:Ng(t.type,"string"),required:typeof t.required=="boolean"?t.required:!0,default:t.default,mock:t.mock,format:sc(t.format),picker:F7t(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(n=>String(n)):void 0,options:V7t(t.options),placeholder:sc(t.placeholder),options_from_skill:sc(t.options_from_skill),options_params:w1(t.options_params)?t.options_params:void 0,file_type:sc(t.file_type),max_files:uve(t.max_files),description:sc(t.description),hint:sc(t.hint??t.label_hint??t.helper_text),file_templates:B7t(t.file_templates),group:sc(t.group??t.group_key??t.form_group),group_label:sc(t.group_label??t.group_title),group_description:sc(t.group_description??t.group_subtitle),ui_component:sc(t.ui_component??t.component??t.render_as),widget:sc(t.widget),address_validation:t.address_validation??t.addressValidation,span:uve(t.span??t.col_span??t.column_span),visible_when:t.visible_when??t.visibleWhen}}function YQ(e){return Array.isArray(e)?e.map(H6).filter(t=>!!t.name):w1(e)?Object.entries(e).map(([t,n])=>w1(n)?H6({...n,name:n.name??t}):H6({name:t,label:t,type:"string",default:n})).filter(t=>!!t.name):[]}function H7t(e){return e instanceof Error?e.message:"上传失败"}function W7t({open:e,playbook:t,onClose:n,onSubmit:r}){const i=m.useMemo(()=>YQ(t==null?void 0:t.input_fields),[t]),[a,o]=m.useState({}),[s,l]=m.useState({}),[c,u]=m.useState({}),d=sj(i,a,o),f=m.useMemo(()=>gT(i,a),[i,a]);m.useEffect(()=>{e&&(o(x1(i,(t==null?void 0:t.initial_params)??{})),l({}),u({}))},[i,e,t==null?void 0:t.initial_params]);const p=m.useCallback((v,y)=>{o(x=>({...x,[v]:y}))},[]),h=m.useCallback((v,y)=>async({file:x,onSuccess:w,onError:S})=>{var _,C;l($=>({...$,[v]:!0}));try{const $=x,E=await Sy($),k=(_=E==null?void 0:E.data)==null?void 0:_.url,T=((C=E==null?void 0:E.data)==null?void 0:C.name)||$.name;if(!k)throw new Error("上传结果缺少文件地址");u(I=>({...I,[k]:T})),o(I=>{if(y<=1)return{...I,[v]:k};const P=Array.isArray(I[v])?I[v]:I[v]?[I[v]]:[];return{...I,[v]:[...P,k]}}),w==null||w(E),Ze.success("上传成功")}catch($){const E=$ instanceof Error?$:new Error(H7t($));S==null||S(E),Ze.error(E.message)}finally{l($=>({...$,[v]:!1}))}},[]),g=()=>{if(!t)return;const v=f.filter(y=>y.required&&If(a[y.name]));if(v.length>0){Ze.warning(`请填写必填参数:${v.map(y=>y.label).join("、")}`);return}r(t,a)};return b.jsxs(X1,{className:"wandox-playbook-params-drawer",title:b.jsxs("div",{className:"wandox-playbook-params-drawer__title",children:[b.jsx("span",{className:"wandox-playbook-params-drawer__title-main",children:"填写执行参数"}),b.jsx("span",{className:"wandox-playbook-params-drawer__title-sub",children:t==null?void 0:t.name})]}),open:e,width:640,destroyOnHidden:!0,maskClosable:!1,onClose:n,footer:b.jsx("div",{className:"wandox-playbook-params-drawer__footer",children:b.jsxs(pa,{children:[b.jsx(Et,{onClick:n,children:"取消"}),b.jsx(Et,{type:"primary",onClick:g,children:"开始执行"})]})}),children:[b.jsxs("div",{className:"wandox-playbook-params-drawer__intro",children:[b.jsx("span",{children:"填写本次运行需要的参数"}),b.jsxs("span",{children:[f.length," 项"]})]}),b.jsxs(pn,{layout:"vertical",className:"wandox-playbook-params-drawer__form",children:[f.map(v=>b.jsx(pn.Item,{required:v.required,label:b.jsxs("span",{className:"wandox-playbook-params-drawer__label",children:[v.label,v.description||v.hint?b.jsx(or,{title:v.description||v.hint,children:b.jsx(ME,{"aria-label":`${v.label}说明`})}):null]}),children:b.jsx(KQ,{field:v,value:a[v.name],uploading:!!s[v.name],fileNameMap:c,getOptionState:d.getFieldState,onChange:p,onUpload:h,onDownloadTemplate:y=>window.open(y.path,"_blank","noopener,noreferrer")})},v.name)),f.length===0?b.jsxs("div",{className:"wandox-playbook-params-drawer__empty",children:[b.jsx(vr,{size:"small"})," 正在读取参数配置"]}):null]})]})}function U7t({playbooks:e,onPlaybookClick:t,onPlaybookDelete:n,activePlaybookId:r}){const{t:i}=ad(),[a,o]=m.useState(""),[s,l]=m.useState(!1),[c,u]=m.useState(null),[d,f]=m.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()))}),h=(y,x)=>{x.stopPropagation(),u(y),l(!0)},g=async()=>{if(c){f(!0);try{await Kmt(c.playbook_id),n==null||n(c.playbook_id),l(!1),u(null)}catch{}finally{f(!1)}}},v=()=>{l(!1),u(null)};return b.jsxs("div",{className:"wandox-solidified-list",children:[b.jsx("div",{className:"wandox-solidified-list-search",children:b.jsx(Kt.Search,{placeholder:"搜索",value:a,onChange:y=>o(y.target.value),allowClear:!0,enterButton:!1})}),b.jsx("div",{className:"wandox-solidified-list-content",children:p.length===0?b.jsx(ei,{description:i(a?"noData":"solidified.empty"),image:ei.PRESENTED_IMAGE_SIMPLE}):b.jsx("div",{className:"wandox-solidified-list-grid",children:p.map(y=>b.jsxs("div",{className:`wandox-solidified-card ${r===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:[b.jsx("div",{className:"wandox-solidified-card-icon",children:b.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2",fill:"none"}),b.jsx("path",{d:"M9 3v18M15 3v18M3 9h18M3 15h18",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor"})]})}),b.jsxs("div",{className:"wandox-solidified-card-content",children:[b.jsx("div",{className:"wandox-solidified-card-name",children:y.name}),y.description&&b.jsx("div",{className:"wandox-solidified-card-desc",children:y.description})]}),b.jsx("button",{type:"button",className:"wandox-solidified-card-delete",onClick:x=>h(y,x),title:i("solidified.delete"),children:b.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:b.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))})}),b.jsx(rr,{title:i("solidified.deleteConfirm"),open:s,onOk:g,onCancel:v,okText:i("confirm"),cancelText:i("cancel"),okButtonProps:{danger:!0,loading:d},children:b.jsxs("p",{children:[i("solidified.deleteConfirm")," 「",c==null?void 0:c.name,"」?"]})})]})}function G7t({inputParams:e,onSearch:t,loading:n=!1}){const[r]=pn.useForm();m.useEffect(()=>{const o={};for(const s of e)s.default!==void 0&&s.default!==null&&s.default!==""&&(o[s.name]=s.default);r.setFieldsValue(o)},[e,r]);const i=()=>{r.validateFields().then(o=>{const s={};for(const l of Object.keys(o)){const c=o[l];c!=null&&c!==""&&(s[l]=c)}t(s)})},a=o=>{const{name:s,type:l,description:c}=o,u={placeholder:c||`请输入${s}`};switch(l){case"integer":return b.jsx(zo,{...u,style:{width:"100%"}});case"array":return b.jsx(Kt,{...u});case"boolean":return b.jsx(Kt,{...u});case"string":default:return b.jsx(Kt,{...u})}};return b.jsx("div",{className:"wandox-solidify-params-form",children:b.jsxs(pn,{form:r,layout:"inline",onFinish:i,style:{marginBottom:16},children:[e.map(o=>b.jsx(pn.Item,{name:o.name,label:o.description||o.name,rules:[{required:o.required,message:`请输入${o.description||o.name}`}],style:{marginBottom:8},children:a(o)},o.name)),b.jsx(pn.Item,{style:{marginBottom:8},children:b.jsx(Et,{type:"primary",htmlType:"submit",loading:n,children:"查询"})})]})})}const D0={fontSize:13,fontWeight:600,color:"#374151",marginBottom:6};function q7t({open:e,onClose:t,onSuccess:n,editingSchedule:r,webhooks:i}){const a=!r,[o,s]=m.useState(""),[l,c]=m.useState(!0),[u,d]=m.useState(""),[f,p]=m.useState(0),[h,g]=m.useState(""),[v,y]=m.useState(""),[x,w]=m.useState(""),[S,_]=m.useState([]),[C,$]=m.useState({}),[E,k]=m.useState(!1),[T,I]=m.useState({}),[P,N]=m.useState({}),[A,M]=m.useState([]),[R,L]=m.useState([]),[z,j]=m.useState(!1),[O,V]=m.useState(!1),B=m.useCallback(async(U,q)=>{var Q;if(!U){_([]),$({});return}k(!0);try{const{data:G}=await BE({playbook_id:U}),X=((Q=G==null?void 0:G.content)==null?void 0:Q.yaml_content)||"";let J=[];if(X)try{const Y=FE.parse(X),Z=Y==null?void 0:Y.params;Array.isArray(Z)&&Z.length>0?J=Z:Z&&typeof Z=="object"&&(J=Object.values(Z))}catch{}if(_(J),J.length>0){const Y={};for(const Z of J){const re=q==null?void 0:q[Z.name];re!==void 0?Y[Z.name]=re:Z.default!==void 0&&Z.default!==null&&(Y[Z.name]=Z.default)}$(Y)}else $({})}catch{_([])}k(!1)},[]),D=m.useCallback(async()=>{var U,q;j(!0);try{const[Q,G]=await Promise.all([Gmt({page:1,page_size:200}),NY({page:1,page_size:100})]),X=((U=Q==null?void 0:Q.data)==null?void 0:U.items)??(Array.isArray(Q==null?void 0:Q.data)?Q==null?void 0:Q.data:[]),J=((q=G==null?void 0:G.data)==null?void 0:q.items)??(Array.isArray(G==null?void 0:G.data)?G==null?void 0:G.data:[]);M(X.map(Y=>({value:Y.playbook_id??String(Y.id),label:Y.name}))),L(J.map(Y=>({value:String(Y.id),label:Y.name})))}catch{}j(!1)},[]);m.useEffect(()=>{if(e)if(p(U=>U+1),I({}),N({}),r){s(r.name||""),c(r.is_active),d(r.cron_expression||"");const U=r.playbook_params||{};$(U),B(r.playbook_id||"",U)}else s(""),c(!0),d(""),g(""),y(""),w(""),_([]),$({}),D()},[e,r,B,D]),m.useEffect(()=>{a&&(h?B(h):(_([]),$({})))},[h,a,B]);const F=(U,q)=>{$(Q=>({...Q,[U]:q}))},H=U=>async({file:q,onSuccess:Q,onError:G})=>{var X,J;I(Y=>({...Y,[U.name]:!0}));try{const Y=q,Z=await Sy(Y),re=(X=Z==null?void 0:Z.data)==null?void 0:X.url,ee=((J=Z==null?void 0:Z.data)==null?void 0:J.name)||Y.name||(re==null?void 0:re.split("/").pop())||"未知文件";if(!re)throw new Error("上传失败");N(oe=>({...oe,[re]:ee})),(U.max_files??1)<=1?F(U.name,re):$(oe=>{const fe=Array.isArray(oe[U.name])?oe[U.name]:oe[U.name]?[oe[U.name]]:[];return{...oe,[U.name]:[...fe,re]}}),Q==null||Q(Z),Ze.success("上传成功")}catch(Y){G==null||G(Y instanceof Error?Y:new Error("文件上传失败")),Ze.error(Y instanceof Error?Y.message:"文件上传失败")}finally{I(Y=>({...Y,[U.name]:!1}))}},W=U=>{const q=C[U.name];if(mT(U))return b.jsx(qQ,{field:U,value:q,onChange:Q=>F(U.name,Q)});switch(U.type){case"string":return b.jsx(Kt.TextArea,{value:q??"",onChange:Q=>F(U.name,Q.target.value),autoSize:{minRows:1,maxRows:4},placeholder:U.description||""});case"number":case"integer":case"float":return b.jsx(zo,{style:{width:"100%"},value:q,onChange:Q=>F(U.name,Q),placeholder:U.description||"",precision:U.type==="integer"?0:void 0,size:"small"});case"boolean":return b.jsx(yo,{size:"small",checked:!!q,onChange:Q=>F(U.name,Q)});case"array":case"object":return b.jsx(Kt.TextArea,{value:typeof q=="string"?q:q!=null?JSON.stringify(q):"",onChange:Q=>F(U.name,Q.target.value),autoSize:{minRows:1,maxRows:4},placeholder:U.description||"JSON 格式"});case"file":{const Q=U.max_files??1,G=Array.isArray(q)?q.map(String):q?[String(q)]:[],X=G.length<Q,J=Y=>{Q<=1?F(U.name,""):F(U.name,G.filter((Z,re)=>re!==Y))};return b.jsxs("div",{children:[G.length>0&&b.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:G.map((Y,Z)=>b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minHeight:30,padding:"4px 8px",border:"1px solid #e5e7eb",borderRadius:6,background:"#fff"},children:[b.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12},children:P[Y]||Y.split("/").pop()||Y}),b.jsx(Et,{type:"text",size:"small",danger:!0,onClick:()=>J(Z),children:"删除"})]},Y))}),X&&b.jsx(zc,{accept:U.file_type||void 0,showUploadList:!1,customRequest:H(U),disabled:!!T[U.name],children:b.jsx(Et,{size:"small",icon:b.jsx(OE,{}),loading:!!T[U.name],children:T[U.name]?"上传中...":"点击上传"})})]})}default:return b.jsx(Kt,{value:q??"",onChange:Q=>F(U.name,Q.target.value),placeholder:U.description||"",size:"small"})}},K=async()=>{if(!o.trim()){Ze.warning("请输入任务名称");return}if(!u.trim()){Ze.warning("请配置调度频率");return}if(a&&!h){Ze.warning("请选择剧本");return}const U=S.length>0?C:void 0;V(!0);try{r?(await REe(r.schedule_id,{},{name:o,cron_expression:u,schedule_type:"custom",is_active:l,playbook_params:U}),Ze.success("更新成功")):(await AEe({},{name:o,agent_id:v,playbook_id:h,webhook_id:x,cron_expression:u,schedule_type:"custom",playbook_params:U}),Ze.success("创建成功")),n(),t()}catch(q){Ze.error((q==null?void 0:q.message)||"操作失败")}finally{V(!1)}};return b.jsxs(rr,{title:null,open:e,onOk:K,onCancel:t,okText:"保存",cancelText:"取消",width:540,confirmLoading:O,closable:!1,children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b.jsx(fa,{style:{fontSize:20,color:"#722ed1"}}),b.jsx("span",{style:{fontSize:16,fontWeight:600,color:"#111827"},children:a?"新增定时任务":"编辑定时任务"})]}),b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b.jsx("span",{style:{fontSize:13,color:l?"#111827":"#9ca3af"},children:l?"已启用":"已禁用"}),b.jsx(yo,{checked:l,onChange:c})]})]}),b.jsxs("div",{style:{marginBottom:16},children:[b.jsxs("div",{style:D0,children:["任务名称 ",b.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),b.jsx(Kt,{value:o,onChange:U=>s(U.target.value),placeholder:"请输入任务名称",style:{borderRadius:8}})]}),a&&b.jsxs(vr,{spinning:z,children:[b.jsxs("div",{style:{marginBottom:16},children:[b.jsxs("div",{style:D0,children:["剧本 ",b.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),b.jsx(tn,{style:{width:"100%"},value:h||void 0,onChange:U=>g(U),options:A,placeholder:"请选择剧本",showSearch:!0,filterOption:(U,q)=>{var Q;return(Q=q==null?void 0:q.label)==null?void 0:Q.toLowerCase().includes(U.toLowerCase())}})]}),b.jsxs("div",{style:{marginBottom:16},children:[b.jsx("div",{style:D0,children:"智能体"}),b.jsx(tn,{style:{width:"100%"},value:v||void 0,onChange:U=>y(U),options:R,placeholder:"请选择智能体(可选)",showSearch:!0,allowClear:!0,filterOption:(U,q)=>{var Q;return(Q=q==null?void 0:q.label)==null?void 0:Q.toLowerCase().includes(U.toLowerCase())}})]}),b.jsxs("div",{style:{marginBottom:16},children:[b.jsx("div",{style:D0,children:"通知 Webhook"}),b.jsx(tn,{style:{width:"100%"},value:x||void 0,onChange:U=>w(U),options:i.map(U=>({value:U.webhook_id,label:U.name})),placeholder:"请选择 Webhook(可选)",allowClear:!0})]})]}),b.jsxs("div",{style:{marginBottom:16},children:[b.jsx("div",{style:D0,children:"调度频率"}),b.jsx(HQ,{defaultValue:r==null?void 0:r.cron_expression,onChange:U=>d(U)},f)]}),E&&b.jsxs("div",{style:{textAlign:"center",padding:"12px 0"},children:[b.jsx(vr,{size:"small"}),b.jsx("span",{style:{marginLeft:8,fontSize:12,color:"#9ca3af"},children:"加载参数配置..."})]}),!E&&S.length>0&&b.jsxs("div",{style:{marginBottom:16},children:[b.jsx("div",{style:D0,children:"执行参数"}),b.jsx("div",{style:{background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:8,padding:"12px 16px"},children:S.map(U=>b.jsxs("div",{style:{marginBottom:12},children:[b.jsxs("div",{style:{fontSize:12,fontWeight:500,color:"#374151",marginBottom:4},children:[U.label||U.name,U.required&&b.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),U.description&&b.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginBottom:4},children:U.description}),W(U)]},U.name))})]})]})}const K7t={daily:"每天",weekly:"每周",monthly:"每月",workday:"工作日",custom:"自定义"},Y7t={1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六",7:"周日",0:"周日"};function X7t(e){const t=rj(e),n=`${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=>Y7t[i]||"").filter(Boolean).join("、")} ${n}`;case"month":return t.interval===1?`每月 ${t.monthDay} 号 ${n}`:`每 ${t.interval} 月 ${t.monthDay} 号 ${n}`;case"year":return`每年 ${t.yearMonth} 月 ${t.yearDay} 日 ${n}`;case"day":return t.interval===1?`每天 ${n}`:`每 ${t.interval} 天 ${n}`;case"custom":return t.customCron.trim()?`自定义:${t.customCron.trim()}`:e;default:return e}}const Z7t=({className:e})=>{const[t,n]=m.useState([]),[r,i]=m.useState(!1),[a,o]=m.useState(!1),[s,l]=m.useState(null),[c]=pn.useForm(),[u,d]=m.useState(),[f,p]=m.useState([]),[h,g]=m.useState(!1),[v,y]=m.useState(!1),[x,w]=m.useState(null);m.useEffect(()=>{_(),P()},[]);const S=[{label:"钉钉",value:"dingtalk"},{label:"飞书",value:"feishu"},{label:"企业微信",value:"wecom"}],_=async()=>{try{i(!0);const L=await ZO({});L!=null&&L.data&&n(L.data)}catch(L){Ze.error((L==null?void 0:L.message)||"加载失败")}finally{i(!1)}},C=()=>{l(null),c.resetFields(),d(void 0),o(!0)},$=async L=>{try{i(!0);const z=await tgt(L.webhook_id,{}),j=(z==null?void 0:z.data)||L;l(j),d(j.platform),c.setFieldsValue({...j,notify_time:j.notify_start_time&&j.notify_end_time?[In(j.notify_start_time,"HH:mm:ss"),In(j.notify_end_time,"HH:mm:ss")]:void 0}),o(!0)}catch(z){Ze.error((z==null?void 0:z.message)||"获取详情失败")}finally{i(!1)}},E=async L=>{try{i(!0),await igt(L.webhook_id,{}),Ze.success("测试消息发送成功")}catch(z){Ze.error((z==null?void 0:z.message)||"测试失败")}finally{i(!1)}},k=L=>{rr.confirm({title:"确认删除",content:`确定要删除 Webhook "${L.name}" 吗?`,okText:"确定",cancelText:"取消",onOk:async()=>{try{await rgt(L.webhook_id,{}),Ze.success("删除成功"),_()}catch(z){Ze.error((z==null?void 0:z.message)||"删除失败")}}})},T=async()=>{var L,z,j,O;try{const V=await c.validateFields();i(!0);const B={name:V.name,description:V.description,platform:V.platform,webhook_url:V.webhook_url,secret:V.secret,notify_start_time:(z=(L=V.notify_time)==null?void 0:L[0])==null?void 0:z.format("HH:mm:ss"),notify_end_time:(O=(j=V.notify_time)==null?void 0:j[1])==null?void 0:O.format("HH:mm:ss"),is_active:V.is_active,is_default:V.is_default};s?(await ngt(s.webhook_id,{},B),Ze.success("更新成功")):(await NEe({},B),Ze.success("创建成功")),o(!1),c.resetFields(),_()}catch(V){Ze.error((V==null?void 0:V.message)||"操作失败")}finally{i(!1)}},I=[{title:"名称",dataIndex:"name",key:"name",width:150,render:(L,z)=>{const j={dingtalk:b.jsx(Qft,{style:{color:"#1677ff"}}),feishu:b.jsx(v2e,{style:{color:"#1677ff"}}),wecom:b.jsx(Kpt,{style:{color:"#1677ff"}})};return b.jsxs(pa,{size:4,children:[j[z.platform],b.jsx("span",{children:L})]})}},{title:"描述",dataIndex:"description",key:"description",ellipsis:!0},{title:"通知时段",key:"notify_time",width:150,render:(L,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:80,render:L=>b.jsx("span",{style:{color:L?"#52c41a":"#999"},children:L?"启用":"禁用"})},{title:"默认",dataIndex:"is_default",key:"is_default",width:80,render:L=>L?b.jsx("span",{style:{color:"#1890ff"},children:"是"}):"否"},{title:"操作",key:"action",width:210,render:(L,z)=>b.jsxs(pa,{size:0,children:[b.jsx(Et,{type:"link",size:"small",icon:b.jsx(G$,{}),onClick:()=>$(z),className:"wandox-webhook-action-btn",children:b.jsx("span",{className:"wandox-webhook-action-text",children:"编辑"})}),b.jsx(Et,{type:"link",size:"small",icon:b.jsx(lY,{}),onClick:()=>E(z),className:"wandox-webhook-action-btn",children:b.jsx("span",{className:"wandox-webhook-action-text",children:"测试"})}),b.jsx(Et,{type:"link",size:"small",danger:!0,icon:b.jsx(hf,{}),onClick:()=>k(z),className:"wandox-webhook-action-btn",children:b.jsx("span",{className:"wandox-webhook-action-text",children:"删除"})})]})}],P=async()=>{try{g(!0);const L=await MEe({});if(L!=null&&L.data){const z=Array.isArray(L.data)?L.data:L.data.items||[];p(z)}}catch{}finally{g(!1)}},N=L=>{if(L.cron_expression)return X7t(L.cron_expression);const z=K7t[L.schedule_type]||L.schedule_type,j=L.schedule_time||"--:--";return`${z} ${j}`},A=L=>{w(L),y(!0)},M=L=>{rr.confirm({title:"确认删除",content:`确定要删除定时任务「${L.name}」吗?`,okText:"确定",cancelText:"取消",onOk:async()=>{try{await DEe(L.schedule_id,{}),Ze.success("删除成功"),P()}catch(z){Ze.error((z==null?void 0:z.message)||"删除失败")}}})},R=[{title:"任务名称",dataIndex:"name",key:"name",width:150,render:L=>b.jsxs(pa,{size:4,children:[b.jsx(fa,{style:{color:"#722ed1"}}),b.jsx("span",{children:L})]})},{title:"调度规则",key:"schedule_desc",width:180,render:(L,z)=>b.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:N(z)})},{title:"Webhook",dataIndex:"webhook_name",key:"agent_name",width:120,ellipsis:!0,render:L=>L||"-"},{title:"状态",dataIndex:"is_active",key:"is_active",width:70,render:L=>b.jsx(ji,{color:L?"green":"default",children:L?"启用":"禁用"})},{title:"操作",key:"action",width:140,render:(L,z)=>b.jsxs(pa,{size:0,children:[b.jsx(Et,{type:"link",size:"small",icon:b.jsx(G$,{}),onClick:()=>A(z),className:"wandox-webhook-action-btn",children:b.jsx("span",{className:"wandox-webhook-action-text",children:"编辑"})}),b.jsx(Et,{type:"link",size:"small",danger:!0,icon:b.jsx(hf,{}),onClick:()=>M(z),className:"wandox-webhook-action-btn",children:b.jsx("span",{className:"wandox-webhook-action-text",children:"删除"})})]})}];return b.jsxs("div",{className:`wandox-webhook-management ${e||""}`,children:[b.jsx("div",{className:"wandox-webhook-header",children:b.jsx(Et,{type:"primary",size:"middle",icon:b.jsx(Uo,{}),onClick:C,style:{borderRadius:"6px",fontWeight:500,boxShadow:"0 2px 4px rgba(24, 144, 255, 0.2)"},children:"新增"})}),b.jsx(Xo,{size:"small",columns:I,dataSource:t,rowKey:"webhook_id",loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:L=>`共 ${L} 条`},scroll:{x:770}}),b.jsx(RK,{style:{margin:"16px 0 12px"}}),b.jsx("div",{className:"wandox-schedule-section-header",style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:b.jsxs("div",{className:"wandox-schedule-section-title",children:[b.jsx(fa,{style:{color:"#722ed1",marginRight:6}}),"定时任务"]})}),b.jsx(Xo,{size:"small",columns:R,dataSource:f,rowKey:"schedule_id",loading:h,pagination:{pageSize:10,showSizeChanger:!0,showTotal:L=>`共 ${L} 条`},scroll:{x:780}}),b.jsx(rr,{title:s?"编辑 Webhook":"新增 Webhook",open:a,onOk:T,onCancel:()=>{o(!1),c.resetFields()},width:600,confirmLoading:r,okText:"确定",cancelText:"取消",children:b.jsxs(pn,{form:c,layout:"horizontal",initialValues:{is_active:!0,is_default:!1},labelCol:{flex:"0 0 80px"},style:{paddingTop:16},children:[b.jsx(pn.Item,{label:"名称",name:"name",rules:[{required:!0,message:"请输入名称"}],children:b.jsx(Kt,{placeholder:"请输入 Webhook 名称"})}),b.jsx(pn.Item,{label:"描述",name:"description",children:b.jsx(Kt.TextArea,{rows:2,placeholder:"请输入描述(可选)"})}),b.jsx(pn.Item,{label:"平台",name:"platform",rules:[{required:!0,message:"请选择平台"}],children:b.jsx(tn,{options:S,placeholder:"请选择平台",onChange:L=>d(L)})}),b.jsx(pn.Item,{label:"URL",name:"webhook_url",rules:[{required:!0,message:"请输入 Webhook URL"},{type:"url",message:"请输入有效的 URL"}],children:b.jsx(Kt,{placeholder:"https://...",autoComplete:"off"})}),u!=="wecom"&&b.jsx(pn.Item,{label:"签名密钥",name:"secret",rules:[{required:u==="dingtalk"||u==="feishu",message:"请输入签名密钥"}],children:b.jsx(Kt.Password,{placeholder:"请输入签名密钥",autoComplete:"new-password"})}),b.jsx(pn.Item,{label:"通知时段",name:"notify_time",children:b.jsx(Ua.RangePicker,{format:"HH:mm",placeholder:["开始时间","结束时间"],style:{width:"100%"}})}),b.jsx(pn.Item,{label:"启用",name:"is_active",valuePropName:"checked",children:b.jsx(yo,{})}),b.jsx(pn.Item,{label:"设为默认",name:"is_default",valuePropName:"checked",children:b.jsx(yo,{})})]})}),b.jsx(q7t,{open:v,onClose:()=>{y(!1),w(null)},onSuccess:P,editingSchedule:x,webhooks:t})]})},{RangePicker:drn}=ui;function Q7t({open:e,loading:t,playbooks:n,activePlaybookId:r,onClose:i,onPlaybookClick:a,onPlaybookDelete:o}){return b.jsx(X1,{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:b.jsx(U7t,{playbooks:n,onPlaybookClick:a,onPlaybookDelete:o,activePlaybookId:r})})}const J7t=["智能体对话(不限Token)","默认场景全功能","巡检机器人定时任务"],eWt=["智能体对话","非 ASIN 查询场景","巡检机器人定时任务"];function CC(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function nf(e){return e==null?!1:typeof e=="string"?e.trim().length>0:!0}function tWt(e){if(Array.isArray(e)){if(e.length===0)return null;const t=e.find(n=>CC(n)?Object.keys(n).length>0:nf(n));return CC(t)?t:nf(t)?{value:t}:null}return CC(e)?Object.keys(e).length>0?e:null:nf(e)?{value:e}:null}function Sc(e,t,n=0){if(e){for(const r of t){const i=e[r];if(nf(i))return i}if(!(n>=2))for(const r of Object.values(e)){if(CC(r)){const i=Sc(r,t,n+1);if(nf(i))return i}if(Array.isArray(r))for(const i of r){if(!CC(i))continue;const a=Sc(i,t,n+1);if(nf(a))return a}}}}function lj(e){if(nf(e))return String(e).trim()}function O0(e){const t=lj(e);if(!t)return;const n=t.match(/^(\d{4}-\d{2}-\d{2})/);return(n==null?void 0:n[1])||t}function wU(e){if(!nf(e))return;if(typeof e=="number"&&Number.isFinite(e))return new Intl.NumberFormat("en-US").format(e);const t=String(e).trim(),n=t.replace(/,/g,""),r=Number(n);return n&&Number.isFinite(r)?new Intl.NumberFormat("en-US").format(r):t}function dve(e,t){if(!nf(e))return t;const n=String(e).trim();return["infinite","unlimited","∞"].includes(n.toLowerCase())?"∞ 无限":wU(e)||t}function nWt(e){const t=lj(e==null?void 0:e.package_name);if(!(!t||t==="无限算力年卡"))return t}function rWt(e){const t=lj(Sc(e,["asin_usage","asin_usage_text","asin_used_display","usage_text"]));if(t)return t;const n=wU(Sc(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=wU(Sc(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(!(!n&&!r))return`${n||"-"} / ${r||"-"}`}function iWt(e){const t=Sc(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=Sc(e,["total_asin","asin_total","total_asin_count","asin_total_count","asin_limit","asin_quota","asin_num","total_count","total_num","limit","quota","total"]),r=Number(String(t??"").replace(/,/g,"")),i=Number(String(n??"").replace(/,/g,""));if(!(!Number.isFinite(r)||!Number.isFinite(i)||i<=0))return Math.min(Math.round(r/i*100),100)}function XQ(e){var n,r,i,a,o,s,l;if(!e)return null;const t=tWt(e.competitive_asin_info);return t?{kind:"competitiveAsin",badgeText:"包年权益",packageName:lj(Sc(t,["package_name","packageName","plan_name","benefit_name","name","title","package_type"]))||nWt(e.package_info)||"竞品智能体包年权益",subtitle:"竞品智能体专属权益",remainingLabel:"剩余算力(非ASIN查询):",remainingValue:dve(Sc(t,["token_num","tokenNum","remaining_token","token_remaining","remaining_power","power_remaining"])??((n=e.package_info)==null?void 0:n.token_num),"∞ 无限"),asinUsage:rWt(t),asinUsagePercent:iWt(t),endTime:O0(Sc(t,["end_time","endTime","expire_time","expired_at","expires_at","end_date","package_end_time"]))||O0((r=e.package_info)==null?void 0:r.end_time)||"-",startTime:O0(Sc(t,["start_time","startTime","open_time","opened_at","started_at","start_date","package_start_time"]))||O0((i=e.package_info)==null?void 0:i.start_time)||"-",coverageTitle:"无限算力覆盖范围",coverageItems:eWt}:e.is_free?{kind:"free",badgeText:"无限算力",packageName:((a=e.package_info)==null?void 0:a.package_name)||"无限算力年卡",subtitle:"亚马逊智能体专属权益",remainingLabel:"剩余算力:",remainingValue:dve((o=e.package_info)==null?void 0:o.token_num,"∞ 无限"),endTime:O0((s=e.package_info)==null?void 0:s.end_time)||"2027-03-18",startTime:O0((l=e.package_info)==null?void 0:l.start_time)||"2026-03-18",coverageTitle:"无限算力覆盖范围",coverageItems:J7t}:null}const aWt=[{label:"钉钉",value:"dingtalk"},{label:"飞书",value:"feishu"},{label:"企业微信",value:"wecom"}];function HOe({open:e,onClose:t,onSuccess:n}){const{t:r}=ad(),[i]=pn.useForm(),[a,o]=m.useState(!1),[s,l]=m.useState(),c=async()=>{try{const d=await i.validateFields();o(!0);const f={name:d.name,platform:d.platform,webhook_url:d.webhook_url,secret:d.secret||void 0},p=await NEe({},f);p!=null&&p.data?(Ze.success(r("webhook.createSuccess")),n({webhook_id:p.data.webhook_id||p.data.id,name:d.name,platform:d.platform}),i.resetFields(),t()):Ze.error(r("webhook.createFailed"))}catch(d){d instanceof Error&&Ze.error(d.message||r("webhook.createFailed"))}finally{o(!1)}},u=()=>{i.resetFields(),l(void 0),t()};return b.jsx(rr,{title:r("webhook.quickAdd"),open:e,onOk:c,onCancel:u,confirmLoading:a,width:480,destroyOnHidden:!0,zIndex:1e4,children:b.jsxs(pn,{form:i,layout:"vertical",preserve:!1,children:[b.jsx(pn.Item,{label:r("webhook.name"),name:"name",rules:[{required:!0,message:r("webhook.nameRequired")}],children:b.jsx(Kt,{placeholder:r("webhook.namePlaceholder")})}),b.jsx(pn.Item,{label:r("webhook.platform"),name:"platform",rules:[{required:!0,message:r("webhook.platformRequired")}],children:b.jsx(tn,{options:aWt,placeholder:r("webhook.platformPlaceholder"),onChange:d=>l(d)})}),b.jsx(pn.Item,{label:"Webhook URL",name:"webhook_url",rules:[{required:!0,message:r("webhook.urlRequired")},{type:"url",message:r("webhook.urlInvalid")}],children:b.jsx(Kt,{placeholder:"https://...",autoComplete:"off"})}),s!=="wecom"&&b.jsx(pn.Item,{label:r("webhook.secret"),name:"secret",rules:[{required:s==="dingtalk"||s==="feishu",message:r("webhook.secretRequired")}],children:b.jsx(Kt.Password,{placeholder:r("webhook.secretPlaceholder"),autoComplete:"new-password"})})]})})}const oWt="https://ai.maiduox.com/#/aitools/operation/product";function sWt(e){const{title:t,widgets:n,ssoDomain:r,ssoToken:i,ssoCompany:a,onExecuteComplete:o,activeAgent:s,agents:l,childAgents:c,externalRobotName:u,externalShowPanel:d,agentSwitcher:f}=e;e.onWidgetsUpdate,e.count,ad();const[p,h]=m.useState(!1),[g,v]=m.useState(!1),[y,x]=m.useState(null),[w,S]=m.useState(null),[_,C]=m.useState("results"),[$,E]=m.useState(!1),[k,T]=m.useState([]),[I,P]=m.useState(null),[N,A]=m.useState({}),[M,R]=m.useState([]),[L,z]=m.useState(!1),[j,O]=m.useState(null),[V,B]=m.useState(void 0),[D,F]=m.useState(!1),[H,W]=m.useState(!1),K=m.useMemo(()=>(c||[]).map(se=>se.name),[c]),U=m.useMemo(()=>!s||s==="default"?null:(l==null?void 0:l.find(ne=>ne.agent_id===s||ne.agent_code===s))||null,[s,l]),q=m.useMemo(()=>XQ(U),[U]);m.useEffect(()=>{S(null)},[s]),m.useEffect(()=>{Q(),c&&c.length>0&&G()},[c]),m.useEffect(()=>{if(d&&(h(!0),u)){const se=K.find(ne=>ne===u);se?S(se):K.length>0}},[d,u,K]);const Q=async()=>{try{const se=await ZO({});se!=null&&se.data&&R(se.data.map(ne=>({webhook_id:ne.webhook_id,name:ne.name,platform:ne.platform})))}catch{}},G=async()=>{try{const se={};await Promise.all(c.map(async ne=>{var ge;try{const be=await ogt(ne.agent_id,{});(ge=be==null?void 0:be.data)!=null&&ge.webhook_id&&(se[ne.agent_id]=be.data.webhook_id)}catch{}})),A(se)}catch{}},X=m.useMemo(()=>w?n.filter(se=>{var be;const ne=(be=se.title)==null?void 0:be.match(/^(.+?)\s*巡检结果$/);return(ne?ne[1]:se.agent_name)===w}):n,[n,w]),J=m.useMemo(()=>{if(!w)return"";const se=(c||[]).find(ne=>ne.name===w);return(se==null?void 0:se.agent_id)||""},[w,c]),Y=r==="maiduo"&&w==="差评监控",Z=se=>{const ne=w===se?null:se;S(ne),ne&&h(!0)},re=se=>{O(se),B(N[se.agent_id]),z(!0)},ee=m.useCallback(async se=>{if(se){E(!0);try{const ne=await Wmt({agent_id:se,limit:50});if(ne!=null&&ne.data&&Array.isArray(ne.data)){const ge=ne.data.map((be,Ce)=>({id:be.id||be.execute_id||`record_${Ce}`,action_name:be.action_name||be.display_name||"未知动作",action_id:be.action_id||"",status:be.status||"pending",created_at:be.created_at||"",completed_at:be.completed_at,action_params:be.action_params,output_type:be.output_type,output_data:be.output_data,outputs:be.outputs,error:be.error})).sort((be,Ce)=>new Date(Ce.created_at).getTime()-new Date(be.created_at).getTime());T(ge)}else T([])}catch{T([])}finally{E(!1)}}},[]),te=se=>{if(!se)return"";try{const ne=new Date(se),ge=ne.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),be=ne.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${ge} ${be}`}catch{return se}},oe=se=>({pending:"等待中",running:"执行中",success:"成功",failed:"失败"})[se]||se,fe=se=>({pending:"wandox-exec-status--pending",running:"wandox-exec-status--running",success:"wandox-exec-status--success",failed:"wandox-exec-status--failed"})[se]||"";m.useEffect(()=>{_==="history"&&J&&ee(J)},[_,J,ee]);const he=async()=>{if(!j||!V){Ze.warning("请选择 Webhook");return}try{F(!0),await agt({},{agent_id:j.agent_id,webhook_id:V}),Ze.success("绑定成功"),z(!1),G()}catch(se){Ze.error((se==null?void 0:se.message)||"绑定失败")}finally{F(!1)}},ye=async()=>{if(j)try{F(!0),await sgt(j.agent_id,{}),Ze.success("解绑成功"),z(!1),B(void 0),G()}catch(se){Ze.error((se==null?void 0:se.message)||"解绑失败")}finally{F(!1)}},Te=se=>{x(se),v(!0)},Ee=()=>{v(!1),x(null)},we=se=>{if(!se)return"";try{const ne=new Date(se),ge=ne.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),be=ne.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${ge}
|
|
769
|
-
${be}`}catch{return se}},le=(se,ne)=>{const ge={high:"#ff4d4f",medium:"#faad14",low:"#52c41a"};return b.jsxs("div",{className:"wandox-timeline-item",children:[b.jsxs("div",{className:"wandox-timeline-dot-wrapper",children:[b.jsx("span",{className:"wandox-timeline-time",style:{whiteSpace:"pre-line"},children:we(se.timestamp||"")}),b.jsx("div",{className:"wandox-timeline-dot",style:{background:ge[se.priority]}}),!ne&&b.jsx("div",{className:"wandox-timeline-line"})]}),b.jsxs("div",{className:"wandox-widget-card",children:[b.jsx("div",{className:"wandox-widget-title",children:se.title}),se.ui_payload&&b.jsx("div",{className:"wandox-widget-content wandox-markdown-content",children:b.jsx(Ci,{payload:se.ui_payload})}),se.actions&&se.actions.length>0&&b.jsx("div",{className:"wandox-widget-actions",children:b.jsxs("button",{type:"button",className:"wandox-widget-view-detail-btn",onClick:()=>Te(se),children:[b.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img",children:[b.jsx("title",{children:"快速执行"}),b.jsx("path",{d:"M13 2L3 14H12L11 22L21 10H12L13 2Z",fill:"currentColor"})]}),"快速执行 (",se.actions.length,")"]})})]})]},se.id||`${se.type}_${se.title}_${se.timestamp}`)};return b.jsxs("div",{className:"wandox-widget-section",children:[b.jsxs("div",{className:"wandox-section-header",children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f??b.jsx("span",{className:"wandox-widget-section-title",children:t}),q&&b.jsx(W1,{title:b.jsx("div",{style:{paddingBottom:"8px",borderBottom:"1px solid #f0f0f0"},children:b.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},children:[b.jsxs("div",{children:[b.jsx("strong",{children:q.packageName}),b.jsx("div",{style:{color:"#999",fontSize:"11px",fontWeight:400},children:q.subtitle})]}),b.jsx(xv,{count:"生效中",style:{backgroundColor:"#52c41a",fontSize:"10px",lineHeight:"18px",height:"18px",minWidth:"50px"}})]})}),content:b.jsxs("div",{style:{fontSize:"12px",lineHeight:"1.6",minWidth:"280px"},children:[b.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[b.jsx("div",{style:{color:"#999"},children:"套餐类型:"}),b.jsx("strong",{children:q.packageName})]}),q.asinUsage&&b.jsxs("div",{style:{marginBottom:q.asinUsagePercent!=null?"4px":"8px",display:"flex",justifyContent:"space-between",gap:"16px"},children:[b.jsx("div",{style:{color:"#999"},children:"ASIN 已用:"}),b.jsx("strong",{style:{color:"#9444f5"},children:q.asinUsage})]}),q.asinUsagePercent!=null&&b.jsx("div",{style:{marginBottom:"8px"},children:b.jsx("div",{style:{height:"6px",borderRadius:"3px",background:"#f0eaff",overflow:"hidden"},children:b.jsx("div",{style:{height:"100%",width:`${q.asinUsagePercent}%`,borderRadius:"3px",background:"linear-gradient(90deg, #9444f5, #b47aff)",transition:"width 0.3s ease"}})})}),b.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[b.jsx("div",{style:{color:"#999"},children:q.remainingLabel}),b.jsx("strong",{style:{color:"#9444f5",fontWeight:"bold"},children:q.remainingValue})]}),b.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[b.jsx("div",{style:{color:"#999"},children:"到期时间:"}),b.jsx("strong",{children:q.endTime})]}),b.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[b.jsx("div",{style:{color:"#999"},children:"开通时间:"}),b.jsx("strong",{children:q.startTime})]}),b.jsxs("div",{style:{padding:"8px 12px",background:"#faf8ff",borderRadius:"8px"},children:[b.jsx("div",{style:{marginBottom:"4px",color:"#9444f5",fontSize:"13px",fontWeight:"bold"},children:q.coverageTitle}),b.jsx("div",{style:{fontSize:"11px",color:"#666",lineHeight:"2"},children:q.coverageItems.map(se=>b.jsxs("div",{children:[b.jsx(ff,{style:{marginRight:"6px",color:"#9444f5"}}),se]},se))})]})]}),placement:"bottom",trigger:"hover",children:b.jsx(xv,{count:q.badgeText,style:{backgroundColor:"#9444f5",cursor:"pointer"}})})]}),b.jsx("div",{className:"wandox-inspection-controls",children:b.jsxs("button",{type:"button",className:`wandox-inspection-agent-btn ${p?"wandox-inspection-agent-btn--expanded":""}`,onClick:()=>{p?(h(!1),S(null)):h(!0)},children:[b.jsxs("span",{className:"wandox-inspection-agent-icon",children:[b.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("circle",{cx:"12",cy:"12",r:"4",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor"})]}),b.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-1"}),b.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-2"}),b.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-3"})]}),b.jsxs("span",{className:"wandox-inspection-agent-text",children:["巡检机器人(",K.length,")"]})]})})]}),p&&b.jsxs("div",{className:"wandox-timeline-list",children:[b.jsxs("div",{className:"wandox-agent-filter-row wandox-agent-filter-row--with-close",children:[b.jsxs("div",{className:"wandox-agent-filter-chips",children:[c.length>0&&b.jsx("button",{type:"button",className:`wandox-agent-filter-chip ${w===null?"active":""}`,onClick:()=>S(null),children:"全部"}),c.map(se=>{const ne=!!N[se.agent_id];return b.jsxs("div",{className:`wandox-agent-filter-chip-compound ${w===se.name?"active":""}`,children:[b.jsx("button",{type:"button",className:"wandox-agent-filter-chip-name",onClick:()=>Z(se.name),children:se.name}),b.jsx("button",{type:"button",className:`wandox-agent-filter-chip-webhook ${ne?"bound":""}`,onClick:()=>re(se),title:ne?"已绑定 Webhook,点击修改":"绑定 Webhook 通知",children:ne?b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"wandox-webhook-dot","aria-hidden":"true"}),b.jsx("span",{className:"wandox-webhook-label",children:"已通知"})]}):b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"wandox-webhook-plus","aria-hidden":"true",children:"+"}),b.jsx("span",{className:"wandox-webhook-label",children:"通知"})]})})]},se.agent_id)})]}),b.jsx("button",{type:"button",className:"wandox-timeline-list-close",onClick:()=>{h(!1),S(null),C("results")},title:"关闭",children:"✕"})]}),Y&&b.jsxs("div",{className:"wandox-negative-review-notice",children:[b.jsx("span",{className:"wandox-negative-review-notice-icon","aria-hidden":"true",children:"ℹ️"}),b.jsxs("span",{children:["差评监控需要先设置需要监控的ASIN,请前往AI工具》",b.jsx("a",{href:oWt,target:"_blank",rel:"noreferrer",className:"wandox-negative-review-notice-link",children:"新老诊断"}),"进行设置。每个asin每一次都需要0.01算力。"]})]}),b.jsx("div",{className:"wandox-timeline-tabs-header",children:b.jsxs("div",{className:"wandox-timeline-tabs-nav",children:[b.jsxs("button",{type:"button",className:`wandox-timeline-tab-btn ${_==="results"?"active":""}`,onClick:()=>C("results"),children:["巡检结果",X.length>0&&b.jsx("span",{className:"wandox-timeline-tab-badge",children:X.length})]}),b.jsx("button",{type:"button",className:`wandox-timeline-tab-btn ${_==="history"?"active":""}`,onClick:()=>C("history"),children:"执行记录"})]})}),_==="results"?b.jsx("div",{className:"wandox-timeline-list-content",children:X.length>0?X.sort((se,ne)=>{const ge=se.timestamp?new Date(se.timestamp).getTime():0;return(ne.timestamp?new Date(ne.timestamp).getTime():0)-ge}).map((se,ne,ge)=>le(se,ne===ge.length-1)):b.jsxs("div",{className:"wandox-empty-state",children:[b.jsx("div",{className:"wandox-empty-icon",children:"�"}),b.jsx("div",{className:"wandox-empty-text",children:w?"没有符合筛选条件的数据":"暂无工作区数据"}),b.jsx("div",{className:"wandox-empty-desc",children:w?"请调整筛选条件":"工作区数据将在这里显示"})]})}):b.jsx("div",{className:"wandox-timeline-list-content wandox-history-panel",children:w?$?b.jsxs("div",{className:"wandox-loading-state",children:[b.jsx("span",{className:"wandox-spinner wandox-spinner--small"}),b.jsx("span",{children:"加载中..."})]}):k.length===0?b.jsx("div",{className:"wandox-empty-state",children:b.jsx("div",{className:"wandox-empty-text",children:"暂无执行记录"})}):b.jsx("div",{className:"wandox-exec-history-list",children:k.map(se=>b.jsxs("div",{className:"wandox-exec-history-item",children:[b.jsxs("div",{className:"wandox-exec-history-header",onClick:()=>P(I===se.id?null:se.id),onKeyDown:ne=>ne.key==="Enter"&&P(I===se.id?null:se.id),role:"button",tabIndex:0,children:[b.jsxs("div",{className:"wandox-exec-history-info",children:[b.jsx("span",{className:"wandox-exec-history-name",children:se.action_name}),b.jsx("span",{className:"wandox-exec-history-time",children:te(se.created_at)})]}),b.jsxs("div",{className:"wandox-exec-history-status-wrapper",children:[b.jsx("span",{className:`wandox-exec-status ${fe(se.status)}`,children:oe(se.status)}),b.jsx("span",{className:"wandox-exec-history-arrow","aria-hidden":"true",children:I===se.id?"▼":"▶"})]})]}),I===se.id&&b.jsxs("div",{className:"wandox-exec-history-detail",children:[se.action_params&&Object.keys(se.action_params).length>0&&b.jsxs("div",{className:"wandox-exec-params",children:[b.jsx("div",{className:"wandox-exec-section-label",children:"执行参数"}),b.jsx("div",{className:"wandox-exec-params-list",children:Object.entries(se.action_params).map(([ne,ge])=>b.jsxs("div",{className:"wandox-exec-param-item",children:[b.jsxs("span",{className:"wandox-exec-param-key",children:[ne,":"]}),b.jsx("span",{className:"wandox-exec-param-value",children:typeof ge=="object"?JSON.stringify(ge):String(ge)})]},ne))})]}),se.error?b.jsxs("div",{className:"wandox-exec-error",children:[b.jsx("span",{className:"wandox-exec-error-label",children:"错误信息:"}),b.jsx("span",{className:"wandox-exec-error-msg",children:se.error})]}):se.output_type&&se.output_data?b.jsxs("div",{className:"wandox-exec-outputs",children:[b.jsx("div",{className:"wandox-exec-section-label",children:"执行结果"}),b.jsx(Ci,{payload:{type:se.output_type,...se.output_data}})]}):se.outputs?b.jsxs("div",{className:"wandox-exec-outputs",children:[b.jsx("div",{className:"wandox-exec-section-label",children:"执行结果"}),b.jsx(Ci,{payload:se.outputs})]}):b.jsx("div",{className:"wandox-exec-no-output",children:"暂无输出结果"})]})]},se.id))}):b.jsxs("div",{className:"wandox-empty-state",children:[b.jsx("div",{className:"wandox-empty-icon",children:"🤖"}),b.jsx("div",{className:"wandox-empty-text",children:"请先选择机器人"}),b.jsx("div",{className:"wandox-empty-desc",children:"在上方选择一个机器人查看执行记录"})]})})]}),b.jsx(vOe,{open:g,title:(y==null?void 0:y.title)||"动作详情",actions:(y==null?void 0:y.actions)||[],widgetId:y==null?void 0:y.id,ssoToken:i,ssoDomain:r,ssoCompany:a,onClose:Ee,onExecuteComplete:o}),b.jsx(rr,{title:b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[b.jsxs("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[b.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"}),b.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"}),b.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"}),b.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"})]}),b.jsx("span",{children:"配置 Webhook 通知"})]}),open:L,onCancel:()=>{z(!1),O(null),B(void 0)},width:520,footer:null,centered:!0,children:b.jsxs("div",{style:{padding:"8px 0"},children:[b.jsxs("div",{style:{marginBottom:"20px",padding:"12px 16px",background:"#f5f7fa",borderRadius:"8px",border:"1px solid #e8eaed"},children:[b.jsx("div",{style:{fontSize:"13px",color:"#666",marginBottom:"4px"},children:"智能体"}),b.jsx("div",{style:{fontSize:"15px",color:"#1a1a1a",fontWeight:500},children:j==null?void 0:j.name})]}),b.jsxs("div",{style:{marginBottom:"20px"},children:[b.jsx("div",{style:{marginBottom:"8px",fontSize:"14px",color:"#333",fontWeight:500},children:"选择 通知地址"}),b.jsx(tn,{style:{width:"100%"},size:"large",placeholder:"请选择 通知地址",value:V,onChange:B,options:M.map(se=>({label:`${se.name} (${se.platform==="dingtalk"?"钉钉":se.platform==="feishu"?"飞书":"企业微信"})`,value:se.webhook_id})),disabled:D,popupRender:se=>b.jsxs(b.Fragment,{children:[se,b.jsx(RK,{style:{margin:"8px 0"}}),b.jsx(pa,{style:{padding:"0 8px 4px"},children:b.jsx(Et,{type:"text",icon:b.jsx("span",{children:"+"}),onClick:()=>W(!0),children:"添加新的通知地址"})})]})}),M.length===0&&b.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:[b.jsx("span",{children:"⚠️"}),b.jsx("span",{children:'暂无可用的 通知地址,请先在"通知配置"中创建'})]})]}),b.jsxs("div",{style:{padding:"12px 16px",background:"#f0f9ff",borderRadius:"8px",border:"1px solid #bae7ff",marginBottom:"20px"},children:[b.jsx("div",{style:{fontSize:"13px",color:"#0958d9",fontWeight:500,marginBottom:"8px"},children:"💡 功能说明"}),b.jsxs("div",{style:{fontSize:"13px",color:"#096dd9",lineHeight:"1.8"},children:[b.jsx("div",{children:"• 绑定后,该智能体执行完成时会自动发送通知"}),b.jsx("div",{children:"• 通知内容包含执行结果和相关信息"}),b.jsx("div",{children:"• 可随时修改或解除绑定"})]})]}),b.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"},children:[N[(j==null?void 0:j.agent_id)||""]&&b.jsx("button",{type:"button",onClick:ye,disabled:D,style:{marginRight:"auto",padding:"8px 20px",border:"1px solid #ff4d4f",borderRadius:"6px",background:"#fff",color:"#ff4d4f",cursor:D?"not-allowed":"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s",opacity:D?.6:1},onMouseEnter:se=>{D||(se.currentTarget.style.background="#fff1f0")},onMouseLeave:se=>{se.currentTarget.style.background="#fff"},children:"解除绑定"}),b.jsx("button",{type:"button",onClick:()=>{z(!1),O(null),B(void 0)},disabled:D,style:{padding:"8px 24px",border:"1px solid #d9d9d9",borderRadius:"6px",background:"#fff",color:"#333",cursor:D?"not-allowed":"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s",opacity:D?.6:1},onMouseEnter:se=>{D||(se.currentTarget.style.background="#fafafa")},onMouseLeave:se=>{se.currentTarget.style.background="#fff"},children:"取消"}),b.jsx("button",{type:"button",onClick:he,disabled:D||!V,style:{padding:"8px 24px",border:"none",borderRadius:"6px",background:D||!V?"#d9d9d9":"#1890ff",color:"#fff",cursor:D||!V?"not-allowed":"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s"},onMouseEnter:se=>{!D&&V&&(se.currentTarget.style.background="#40a9ff")},onMouseLeave:se=>{!D&&V&&(se.currentTarget.style.background="#1890ff")},children:D?"保存中...":"保存"})]})]})}),b.jsx(HOe,{open:H,onClose:()=>W(!1),onSuccess:se=>{R(ne=>[...ne,se]),B(se.webhook_id)}})]})}function Lm(e,t){return e.role!=="assistant"?!1:t.message_id&&e.message_id?e.message_id===t.message_id:e.id===t.id}function fve(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 WOe=new Set(["completed","failed","stopped"]),lWt=new Set(["thinking","recommend"]),vP={running:0,completed:1,failed:2,stopped:3};function SU(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _U(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)&&t>=0?t:void 0}function cWt(e){const t=String(e||"").toLowerCase();return t==="running"||t==="failed"||t==="stopped"?t:"completed"}function UOe(e,t){if(!SU(e))return;const n=typeof e.type=="string"&&e.type.trim()?e.type.trim():void 0;if(!n)return;const r=_U(e.sequence),i=SU(e.data)?e.data:{};return{...typeof e.event_id=="string"&&e.event_id?{event_id:e.event_id}:{},type:n,sequence:r===void 0?t:r,...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 L0(e){return e==null?"":String(e).trim()}function uWt(e,t){const n=L0(e.data.task_id),r=L0(t.data.task_id);if(n&&r)return n===r;const i=L0(e.data.step_index),a=L0(t.data.step_index);if(i&&a)return i===a;const o=L0(e.data.step_name||e.data.title),s=L0(t.data.step_name||t.data.title);return!!(o&&s&&o===s)}function GOe(e){return e.reduce((t,n)=>{if(n.type!=="output")return t.push(n),t;let r=-1;for(let a=t.length-1;a>=0;a-=1)if(t[a].type==="step"&&uWt(n,t[a])){r=a;break}if(r<0)return t.push(n),t;const i=t[r];return t[r]={...i,...n,event_id:i.event_id||n.event_id,type:"step",sequence:i.sequence,data:{...i.data,...n.data}},t},[])}function ZQ(e){if(!SU(e))return;const t=GOe((Array.isArray(e.events)?e.events:[]).map((o,s)=>UOe(o,s+1)).filter(o=>!!o).sort((o,s)=>o.sequence-s.sequence)),n=cWt(e.status),r=e.duration_ms===null?null:_U(e.duration_ms),i=typeof e.started_at=="string"&&e.started_at.trim().length>0;if(t.length===0&&n!=="running"&&r==null&&!i)return;const a=_U(e.total);return{status:n,...e.origin==="live"||e.origin==="history"?{origin:e.origin}:{},duration_ms:r,total:a===void 0?t.length:a,truncated:e.truncated===!0,events:t,...i?{started_at:e.started_at}:{}}}function CU(e=new Date().toISOString()){return{status:"running",origin:"live",duration_ms:0,total:0,truncated:!1,events:[],started_at:e}}function $U(e,t,n=Date.now()){const r=ZQ(e.process)??CU(e.timestamp||new Date(n).toISOString());if(WOe.has(r.status))return e;const i=r.events.reduce((u,d)=>Math.max(u,d.sequence),0)+1,a=UOe({...t,sequence:t.sequence??i,timestamp:t.timestamp||new Date(n).toISOString()},i);if(!a)return e;let o=[...r.events];const s=a.event_id?o.findIndex(u=>u.event_id===a.event_id):-1;s>=0?o[s]={...o[s],...a,sequence:o[s].sequence}:(o.push(a),o.sort((u,d)=>u.sequence-d.sequence)),o=GOe(o);const l=Date.parse(r.started_at||e.timestamp),c=Number.isFinite(l)?Math.max(r.duration_ms||0,n-l):r.duration_ms;return{...e,process:{...r,status:"running",duration_ms:c,total:o.length,events:o}}}function VN(e,t,n=Date.now()){const r=ZQ(e.process);if(!r||WOe.has(r.status)&&vP[r.status]>=vP[t])return e;const i=r.events.filter(c=>!lWt.has(c.type)),a=Date.parse(r.started_at||e.timestamp),o=Number.isFinite(a)?Math.max(0,n-a):void 0,s=r.duration_ms==null?o:o===void 0?r.duration_ms:Math.max(r.duration_ms,o),l=vP[r.status]>vP[t]?r.status:t;return{...e,process:{...r,status:l,duration_ms:s,total:i.length,events:i}}}function EU(e,t){return{...e,content:"",ui_payload:{type:"markdown",content:t,streaming:!0},stream_content_received:!0}}function TU(e,t){var r;const n={message_id:t.messageId||e.message_id,execution_id:t.executionId??e.execution_id,actions:(r=t.actions)!=null&&r.length?t.actions:void 0,execution_status:"completed"};return e.stream_content_received?{...e,...n,content:"",ui_payload:e.ui_payload?{...e.ui_payload,streaming:!1}:e.ui_payload}:{...e,...n,content:t.content||"执行完成",ui_payload:t.payload}}function dWt(e){const t=String(e??"").trim().toLowerCase();return!t||["pending","running","executing","stopping","pending_async","awaiting_async"].includes(t)}function $C(e){if(Array.isArray(e))return e.map($C);if(!e||typeof e!="object")return e;const t=e,n={...t};return Array.isArray(t.children)&&(n.children=t.children.map($C)),(t.type==="step"||t.status!==void 0)&&dWt(t.status)&&(n.status="stopped",t.message||(n.message="任务已停止")),n}function BS(e,t,n){var o;const r=t==="stopped"?"stopped":"error",a=((o=e.process)==null?void 0:o.events.some(s=>s.type===r&&s.data.message===n))?e:$U(e,{type:r,data:{message:n,status:t}});return VN(a,t)}function fWt(e,t,n){return EU(e,t)}function pve(e,t,n=!1){if(t.task_id)for(let r=e.length-1;r>=0;r-=1){const i=e[r];if(i.type==="step"&&i.task_id===t.task_id)return r}if(t.step_index!==void 0)for(let r=e.length-1;r>=0;r-=1){const i=e[r];if(i.type==="step"&&String(i.step_index)===String(t.step_index))return r}if(n)for(let r=e.length-1;r>=0;r-=1){const i=e[r],a=String(i.status||"").toLowerCase();if(i.type==="step"&&["running","pending","executing"].includes(a))return r}return-1}function pWt(e,t){var i;const n=Array.isArray(e.outputs)?[...e.outputs]:[];if(t.type==="step"){const a=pve(n,t);if(a>=0){const o=n[a];n[a]={...o,...t,children:(i=t.children)!=null&&i.length?t.children:o.children||[]}}else n.push({...t,children:t.children||[]});return{...e,outputs:n}}const r=pve(n,t);if(r>=0){const a=n[r],o=Array.isArray(a.children)?[...a.children]:[],s=o.findIndex(c=>c.streaming===!0&&(!t.task_id||!c.task_id||c.task_id===t.task_id)),l=t.content===null&&t.is_final===!0;return s>=0?l?o.splice(s,1):o[s]={...t,streaming:!1}:l||o.push(t),n[r]={...a,task_id:a.task_id||t.task_id,status:t.status||"done",children:o},{...e,outputs:n}}return t.content===null&&t.is_final===!0?e:(n.push(t),{...e,outputs:n})}function QQ(e){const{activeAgent:t,ssoToken:n,ssoDomain:r,ssoCompany:i,defaultParams:a,onMessagesUpdate:o,onRecommendationsUpdate:s}=e,[l,c]=m.useState(!1),[u,d]=m.useState(!1),[f,p]=m.useState(null),h=m.useRef(!1),g=m.useRef(null),v=m.useRef(null),y=m.useRef(null),x=m.useRef(null),w=m.useCallback(()=>!n||!r||!i?(Ze.warning("请先登录 SSO"),!1):!0,[n,r,i]),S=m.useCallback((I,P)=>({id:`msg_${Date.now()}_${Math.random()}`,role:I,content:P,timestamp:new Date().toISOString()}),[]),_=m.useCallback(async I=>{if(!w())return;if(h.current){g.current=I;return}h.current=!0;const{userMsg:P,assistantMsgId:N,assistantMsg:A}=(()=>{var B;const z=Date.now(),j={id:`msg_${z}`,role:"user",content:I.message||"",timestamp:new Date().toISOString(),...(B=I.attachments)!=null&&B.length?{attachments:I.attachments}:{}},O=`msg_${z+1}`,V={id:O,role:"assistant",content:"⏳ 正在思考...",timestamp:new Date().toISOString(),playbook_id:I.playbook_id,execution_status:"executing",process:CU()};return{userMsg:j,assistantMsgId:O,assistantMsg:V}})(),M=I._hideUserMessage===!0;o(z=>M?[...z,A]:[...z,P,A]),c(!0),x.current={assistantMsgId:N};const R=new AbortController;y.current=R;const L=()=>{var z;return y.current===R&&((z=x.current)==null?void 0:z.assistantMsgId)===N};try{const z={...I,agent_id:t,stream:!0,playbook_params:{...I.playbook_params||{}},message:I.message||"",...a||{}},{_hideUserMessage:j,...O}=z,V=await fetch(`${Gi()}/api/v1/agents/chat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"X-Tenant-ID":i,"X-Domain":r},body:JSON.stringify(O),signal:R.signal});if(!V.ok)throw new Error(`HTTP ${V.status}`);await HR(V,{assistantMsgId:N,onMessageId:B=>{if(!L())return;const D=x.current;D&&(D.anchorMessageId=B)},onQueue:B=>{L()&&(p(B),B.status==="waiting"?o(D=>D.map(F=>F.id===N?{...F,content:`⏳ ${B.message}`}:F)):B.status==="ready"&&(p(null),o(D=>D.map(F=>F.id===N?{...F,content:`⏳ ${B.message}`}:F))))},onProgress:B=>{L()&&(p(null),o(D=>D.map(F=>F.id===N?{...F,content:`⏳ ${B}`}:F)))},onProcessEvent:B=>{L()&&o(D=>D.map(F=>F.id===N?$U(F,B):F))},onContent:B=>{L()&&o(D=>D.map(F=>F.id===N?EU(F,B):F))},onComplete:(B,D,F,H,W)=>{L()&&o(K=>K.map(U=>{var q,Q;return U.id!==N||((q=U.process)==null?void 0:q.status)==="failed"||((Q=U.process)==null?void 0:Q.status)==="stopped"?U:VN(TU(U,{content:B,payload:D,actions:F,messageId:H,executionId:W}),"completed")}))},onError:(B,D)=>{L()&&o(F=>{const H=(D==null?void 0:D.cancelled)===!0,W=H?"任务已停止":`❌ ${B}`;return F.map(K=>K.id===N?BS({...K,content:K.content.startsWith("❌")?K.content:W,execution_status:H?"stopped":"failed",outputs:H&&K.outputs?$C(K.outputs):K.outputs},H?"stopped":"failed",H?"任务已停止":B):K)})},onRecommend:B=>{L()&&s(B)},onProposal:B=>{if(!L())return;const D={proposal_id:B.proposal_id,scene:B.scene,message:B.message,options:B.options||[],params:B.params,actions:B.actions};o(F=>F.map(H=>H.id===N?VN({...H,content:"",proposal:D,execution_status:"completed"},"completed"):H))}})}catch(z){(z==null?void 0:z.name)!=="AbortError"&&L()&&o(j=>j.map(O=>O.id===N?BS({...O,content:`❌ 执行出错: ${z.message||"未知错误"}`,execution_status:"failed"},"failed",z.message||"未知错误"):O))}finally{if(y.current===R&&(y.current=null,x.current=null,h.current=!1,c(!1),d(!1),g.current)){const z=g.current;g.current=null,setTimeout(()=>{var j;return(j=v.current)==null?void 0:j.call(v,z)},0)}}},[t,n,r,i,w,S,o,s]);v.current=_;const C=m.useCallback(()=>{g.current=null,p(null);const I=y.current;y.current=null,x.current=null,h.current=!1,c(!1),d(!1),I&&!I.signal.aborted&&I.abort()},[]),$=m.useCallback(async()=>{const I=y.current,P=x.current;if(!I||!P)return;const N=P.assistantMsgId,A=P.anchorMessageId,M=()=>{var R;return y.current===I&&((R=x.current)==null?void 0:R.assistantMsgId)===N};if(!A){Ze.warning("任务编号尚未就绪,请稍后再试");return}if(M()){d(!0),o(R=>R.map(L=>L.id===N?{...L,execution_status:"stopping",content:"正在停止..."}:L));try{const R=await fetch(`${Gi()}/api/v1/agents/chat/stop`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"X-Tenant-ID":i,"X-Domain":r},body:JSON.stringify({message_id:A})});if(!M())return;if(!R.ok)throw new Error(`HTTP ${R.status}`);const L=await R.json().catch(()=>null);if(!M())return;if(L&&L.success===!1)throw new Error(L.message||"停止失败");if(o(z=>z.map(j=>{var O;return j.id===N?BS({...j,message_id:(L==null?void 0:L.stopped_message_id)||((O=L==null?void 0:L.data)==null?void 0:O.stopped_message_id)||j.message_id,execution_status:"stopped",content:"任务已停止",outputs:j.outputs?$C(j.outputs):j.outputs},"stopped","任务已停止"):j})),!M())return;C()}catch(R){if(!M())return;d(!1),o(L=>L.map(z=>z.id===N?{...z,execution_status:"executing"}:z)),Ze.error(`停止失败:${R instanceof Error?R.message:"未知错误"}`)}}},[C,o,i,r,n]),E=m.useCallback(async I=>{const P=I.message_id;if(!P||h.current)return;h.current=!0,c(!0);const N=new Date().toISOString();x.current={assistantMsgId:I.id,anchorMessageId:P};const A=new AbortController;y.current=A;const M=()=>{var R;return y.current===A&&((R=x.current)==null?void 0:R.assistantMsgId)===I.id};o(R=>R.map(L=>Lm(L,I)?{...L,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:CU(N)}:L));try{const R=await fetch(`${Gi()}/api/v1/agents/chat/retrigger`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"X-Tenant-ID":i,"X-Domain":r},body:JSON.stringify({message_id:P,stream:!0}),signal:A.signal});if(!R.ok){const L=await R.json().catch(()=>null),z=[L==null?void 0:L.message,L==null?void 0:L.detail,L==null?void 0:L.error].find(j=>typeof j=="string"&&j.trim());throw R.status===409?new Error(z||"任务仍在执行,请先停止"):R.status>=500?new Error(z||"服务暂时无法完成请求,请稍后重试"):new Error(z||`请求失败(HTTP ${R.status})`)}await HR(R,{assistantMsgId:I.id,onMessageId:L=>{if(!M())return;const z=x.current;z&&(z.anchorMessageId=L)},onProgress:L=>{M()&&o(z=>z.map(j=>Lm(j,I)?{...j,content:L}:j))},onProcessEvent:L=>{M()&&o(z=>z.map(j=>Lm(j,I)?$U(j,L):j))},onContent:L=>{M()&&o(z=>z.map(j=>Lm(j,I)?EU(j,L):j))},onComplete:(L,z,j,O,V)=>{M()&&o(B=>B.map(D=>{var F,H;return!Lm(D,I)||((F=D.process)==null?void 0:F.status)==="failed"||((H=D.process)==null?void 0:H.status)==="stopped"?D:VN({...TU(D,{content:L,payload:z,actions:j,messageId:O,executionId:V}),retrigger_status:void 0,retrigger_error:void 0},"completed")}))},onError:(L,z)=>{M()&&o(j=>j.map(O=>{if(!Lm(O,I))return O;const V=(z==null?void 0:z.cancelled)===!0;return BS({...O,content:V?"任务已停止":"",execution_status:V?"stopped":"failed",retrigger_status:V?void 0:"failed",retrigger_error:V?void 0:L,outputs:V&&O.outputs?$C(O.outputs):O.outputs},V?"stopped":"failed",V?"任务已停止":L)}))},onRecommend:L=>{M()&&s(L)}})}catch(R){if(M()&&!(R instanceof DOMException&&R.name==="AbortError")){const L=R instanceof Error?R.message:"未知错误";o(z=>z.map(j=>Lm(j,I)?{...BS(j,"failed",L),content:"",execution_status:"failed",retrigger_status:"failed",retrigger_error:L}:j))}}finally{y.current===A&&(y.current=null,x.current=null,h.current=!1,c(!1),d(!1))}},[o,s,i,r,n]),k=m.useCallback(async(I,P,N)=>{if(!I.trim()&&(!N||N.length===0)){Ze.error("请输入消息");return}await _({message:I||"",playbook_id:P,...N!=null&&N.length?{attachments:N}:{}})},[_]),T=m.useCallback(async I=>{const{proposal_id:P,proposal_action:N,selected_option_id:A,filled_params:M,messageId:R,proposalMessage:L,optionTitle:z}=I;o(V=>V.map(B=>B.id===R?{...B,proposal_status:N==="confirm"?"confirmed":"rejected"}:B));let j="";if(N==="confirm"){const V=[];if(L&&V.push(L),z&&V.push(`${z}确认执行`),M&&Object.keys(M).length>0){const B=Object.entries(M).map(([D,F])=>`${D}: ${Array.isArray(F)?F.join(","):F}`).join(", ");V.push(`参数{${B}}`)}j=V.join(",")}const O={message:j,agent_id:t,stream:!0,proposal_id:P,proposal_action:N,_hideUserMessage:!0,...a||{}};N==="confirm"&&(O.selected_option_id=A,O.filled_params=M||{}),await _(O)},[t,a,_,o]);return{executing:l,stopping:u,executingRef:h,queueStatus:f,sendMessage:k,executePlaybook:_,respondToProposal:T,stopCurrent:$,retrigger:E,abort:C}}function an(e){return e==null?"":String(e).trim()}function IU(e,t){const n=an(e),r=an(t);return!!(n&&n===r)}function _l(e,t){const n=an(t);return n?IU(e.agent_id,n)||IU(e.agent_code,n):!1}function UR(e,t){return e.find(n=>_l(n,t))}function Jp(e){return an(e==null?void 0:e.agent_id)||an(e==null?void 0:e.agent_code)}function qOe(e,t){return IU(e.playbook_id,t)}function KOe(e){const t=[],n=new Set,r=i=>{if(Array.isArray(i))for(const a of i){const o=an(a==null?void 0:a.playbook_id);!o||n.has(o)||(n.add(o),t.push(a))}};if(r(e==null?void 0:e.playbooks),Array.isArray(e==null?void 0:e.playbook_groups))for(const i of e.playbook_groups)r(i.playbooks);return t}function hWt({open:e,onClose:t,ssoToken:n,ssoDomain:r,ssoCompany:i,initialAgentId:a,initialPlaybookId:o,initialPlaybookParams:s,initialMessage:l,triggerOnce:c=!1,enableCustomerService:u=!1,onReady:d}){const[f,p]=m.useState(""),[h,g]=m.useState([]),[v,y]=m.useState([]),[x,w]=m.useState([]),[S,_]=m.useState([]),[C,$]=m.useState(0),[E,k]=m.useState(1),T=bOe,[I,P]=m.useState(!1),[N,A]=m.useState(!1),[M,R]=m.useState(null),[L,z]=m.useState("1x"),[j,O]=m.useState(!1),[V,B]=m.useState(""),[D,F]=m.useState(""),[H,W]=m.useState(null),K=m.useRef(""),U=m.useMemo(()=>f&&h.find(le=>_l(le,f))||null,[f,h]),q=m.useMemo(()=>XQ(U),[U]),Q=m.useCallback(le=>{R(()=>le)},[]),{executing:G,sendMessage:X,executePlaybook:J,respondToProposal:Y,abort:Z}=QQ({activeAgent:f,ssoToken:n,ssoDomain:r,ssoCompany:i,defaultParams:s,onMessagesUpdate:_,onRecommendationsUpdate:w}),re=m.useCallback(()=>{Z(),_([]),k(1),$(0),w([]),F(""),W(null)},[Z]),ee=m.useMemo(()=>JSON.stringify({agentId:an(a),playbookId:an(o),playbookParams:s??null,message:l??null}),[a,o,s,l]),te=m.useRef(""),oe=m.useCallback(()=>{Z(),A(!1),t()},[Z,t]),fe=m.useCallback(()=>{const le=`https://ecsapi.ecgtool.com/login/sso-login?token=${encodeURIComponent(n)}&menuName=AI智能体`;window.open(le,"_blank","noopener,noreferrer")},[n]);m.useEffect(()=>{e&&ye()},[e]),m.useEffect(()=>{e||(Z(),A(!1))},[e,Z]),m.useEffect(()=>{e&&(te.current&&te.current!==ee&&Z(),te.current=ee)},[e,ee,Z]),m.useEffect(()=>{if(!e||!a||h.length===0)return;const le=UR(h,a);if(!le){const ne=an(a);K.current!==ne&&(Ze.error("指定的智能体不存在,已切换到默认智能体"),K.current=ne);const ge=Jp(h[0]);ge&&an(f)!==ge&&(re(),p(ge));return}if(K.current="",_l(le,f))return;const se=Jp(le);se&&(re(),p(se))},[e,a,h,f,re]),m.useEffect(()=>{f&&(B(""),we())},[f]),m.useEffect(()=>{O(!1)},[e,a,o,s,l]),m.useEffect(()=>{!e||!f||o||l&&(j||(X(l),O(!0)))},[e,f,l,o,c,j,X]);const he=m.useMemo(()=>!!s&&Object.keys(s).length>0,[s]);m.useEffect(()=>{var se;if(!e||!f||!o||j||a&&!h.some(ge=>_l(ge,f)&&_l(ge,a))||!V||V!==f)return;const le=v.find(ne=>qOe(ne,o));if(!le){Ze.error("指定的剧本不存在,已切换到智能体界面"),O(!0);return}if((((se=le.input_fields)==null?void 0:se.length)??0)>0&&!he){W(le);const ne=(le.input_fields??[]).map(ge=>`${ge.label}: `).join(`
|
|
768
|
+
${Me}${_e}`,Ie=Re.indexOf(": ")+2;_(Re),setTimeout(()=>{var De;if(C.current){C.current.focus();const Ue=(De=C.current.resizableTextArea)==null?void 0:De.textArea;Ue==null||Ue.setSelectionRange(Ie,Ie)}},0)},Ae=()=>{J(null),_("")},je=async()=>{if(!S.trim()&&P.length===0||r)return;let ce=[];if(P.length>0){ce=await he();for(const Me of P)URL.revokeObjectURL(Me.previewUrl);N([])}const de=S.trim(),_e=X==null?void 0:X.playbook_id;_(""),J(null),Z.clear(),I(!0),o(de,_e,ce.length>0?ce:void 0)};return b.jsxs("div",{className:"wandox-chat-input",style:{position:"relative"},onDragEnter:ye,onDragLeave:Te,onDragOver:Ee,onDrop:we,children:[A&&b.jsx("div",{className:"wandox-chat-input-drag-overlay",children:b.jsxs("div",{className:"wandox-chat-input-drag-content",children:[b.jsx(ppt,{style:{fontSize:32,marginBottom:8}}),b.jsx("div",{children:"释放以发送图片"})]})}),b.jsx("input",{ref:R,type:"file",accept:"image/png,image/jpeg,image/jpg,image/gif,image/webp,image/bmp",multiple:!0,style:{display:"none"},onChange:ne}),O&&W.length>0&&b.jsx("div",{className:"wandox-mention-list",ref:$,children:b.jsx("div",{className:"wandox-mention-items",children:W.map((ce,de)=>b.jsxs("div",{className:`wandox-mention-item ${de===U?"wandox-mention-item--active":""}`,onClick:()=>Ce(ce),onKeyDown:()=>{},onMouseEnter:()=>q(de),children:[b.jsx("div",{className:"wandox-mention-item-icon",children:"📋"}),b.jsxs("div",{className:"wandox-mention-item-content",children:[b.jsxs("div",{className:"wandox-mention-item-name",children:[ce.name,ce.input_fields&&ce.input_fields.length>0&&b.jsx("span",{className:"wandox-mention-item-tag",children:t("recommendation.params")})]}),ce.description&&b.jsx("div",{className:"wandox-mention-item-desc",children:ce.description})]})]},ce.playbook_id))})}),O&&W.length===0&&Y.length>0&&b.jsx("div",{className:"wandox-mention-list",ref:$,children:b.jsx("div",{className:"wandox-mention-empty",children:t("chatInput.noMatchingScenarios")})}),O&&Y.length===0&&b.jsx("div",{className:"wandox-mention-list",ref:$,children:b.jsx("div",{className:"wandox-mention-empty",children:t("chatInput.noAvailableScenarios")})}),b.jsx(MOe,{open:E&&!O&&!r,rewrittenQuestion:Z.rewrittenQuestion,questions:Z.questions,loading:Z.loading,placement:"top",onSelectRewrite:ce=>{var de;_(ce),Z.clear(),(de=C.current)==null||de.focus()},onSelectQuestion:ce=>{_(""),J(null),I(!0),Z.clear(),o(ce.title)}}),X&&b.jsx("div",{className:"wandox-chat-input-tag",children:b.jsx(ji,{color:"blue",closable:!0,onClose:Ae,closeIcon:b.jsx(ga,{}),children:X.name})}),T&&n&&!r&&b.jsx("button",{className:"wandox-search-suggestion",onClick:z,onKeyDown:j,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:ce=>{ce.currentTarget.style.color="#1890ff"},onMouseLeave:ce=>{ce.currentTarget.style.color="#999"},children:n}),P.length>0&&b.jsx("div",{className:"wandox-chat-input-previews",children:P.map(ce=>b.jsxs("div",{className:"wandox-chat-input-preview-item",children:[b.jsx("img",{src:ce.previewUrl,alt:ce.file.name,className:"wandox-chat-input-preview-img"}),b.jsx("button",{type:"button",className:"wandox-chat-input-preview-remove",onClick:()=>fe(ce.id),title:"删除",children:b.jsx(ga,{})})]},ce.id))}),b.jsx(n7t,{ref:C,placeholder:T&&n&&!r?"":s||t("chat.input.placeholder"),value:S,disabled:r,onChange:ge,onKeyDown:be,onPaste:le,onFocus:()=>k(!0),onBlur:()=>window.setTimeout(()=>k(!1),120),autoSize:{minRows:1,maxRows:6},className:"wandox-chat-textarea",style:{position:"relative",zIndex:2,background:"transparent"}}),b.jsxs("div",{className:"wandox-chat-input-actions",children:[b.jsx("button",{type:"button",className:"wandox-chat-input-icon-btn",title:"上传图片",disabled:r,onClick:se,children:b.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2",stroke:"currentColor",strokeWidth:"2"}),b.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor"}),b.jsx("polyline",{points:"21 15 16 10 5 21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),b.jsx("button",{type:"button",className:`wandox-chat-input-icon-btn wandox-chat-input-send-btn${r?" wandox-chat-input-stop-btn":""}`,disabled:r?i||!a:!S.trim()&&P.length===0,onClick:r?a:je,title:r?i?"正在停止":"停止":t("chat.send"),children:r?b.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("circle",{cx:"12",cy:"12",r:"8",stroke:"currentColor",strokeWidth:"2"}),b.jsx("rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",fill:"currentColor"})]}):b.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{d:"M12 19V5M12 5L5 12M12 5L19 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})}const C_=[{id:"robot",name:"机器人",description:"紫色渐变机器人头像",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsxs("g",{clipPath:"url(#clip0_2019_548)",children:[b.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)"}),b.jsx("path",{d:"M24 12L28 16L24 20L20 16L24 12Z",fill:"white",fillOpacity:"0.95"}),b.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"}),b.jsx("path",{d:"M16 28L12 24L16 20L20 24L16 28Z",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M32 28L28 24L32 20L36 24L32 28Z",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M24 36L20 32L24 28L28 32L24 36Z",fill:"white",fillOpacity:"0.8"})]}),b.jsxs("defs",{children:[b.jsxs("linearGradient",{id:"paint0_linear_2019_548",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[b.jsx("stop",{stopColor:"#8B5CF6"}),b.jsx("stop",{offset:"1",stopColor:"#6366F1"})]}),b.jsx("clipPath",{id:"clip0_2019_548",children:b.jsx("rect",{width:"48",height:"48",fill:"white"})})]})]},"icon-robot")},{id:"amazon",name:"亚马逊",description:"橙色渐变亚马逊图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.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)"}),b.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"}),b.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"}),b.jsx("defs",{children:b.jsxs("linearGradient",{id:"paint0_linear_2026_532",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[b.jsx("stop",{stopColor:"#FF6B35"}),b.jsx("stop",{offset:"1",stopColor:"#F7931E"})]})})]},"icon-amazon")},{id:"star",name:"星星",description:"绿色渐变星星图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsxs("g",{clipPath:"url(#clip0_2019_574)",children:[b.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)"}),b.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"}),b.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"}),b.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"}),b.jsx("path",{d:"M16 22V26H20M32 22V26H28M24 26V22",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),b.jsx("path",{d:"M18 30L14 34M30 30L34 34M24 34V36",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),b.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"}),b.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"}),b.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"})]}),b.jsxs("defs",{children:[b.jsxs("linearGradient",{id:"paint0_linear_2019_574",x1:"0",y1:"0",x2:"48",y2:"48",gradientUnits:"userSpaceOnUse",children:[b.jsx("stop",{stopColor:"#10B981"}),b.jsx("stop",{offset:"1",stopColor:"#059669"})]}),b.jsx("clipPath",{id:"clip0_2019_574",children:b.jsx("rect",{width:"48",height:"48",fill:"white"})})]})]},"icon-star")},{id:"gear",name:"齿轮",description:"绿色渐变齿轮图标",component:b.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad4",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#14B8A6"}),b.jsx("stop",{offset:"100%",stopColor:"#0891B2"})]})}),b.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad4)"}),b.jsx("circle",{cx:"20",cy:"20",r:"5",stroke:"white",strokeWidth:"2.5",fill:"none",strokeOpacity:"0.95"}),b.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:b.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad5",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#EC4899"}),b.jsx("stop",{offset:"100%",stopColor:"#A855F7"})]})}),b.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad5)"}),b.jsx("path",{d:"M10 30L26 14L30 18L14 34L10 30Z",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"28",cy:"12",r:"2",fill:"white",fillOpacity:"0.8"}),b.jsx("circle",{cx:"32",cy:"18",r:"1.5",fill:"white",fillOpacity:"0.7"}),b.jsx("circle",{cx:"24",cy:"8",r:"1.5",fill:"white",fillOpacity:"0.7"})]},"icon-magic")},{id:"rocket",name:"火箭",description:"青色渐变火箭图标",component:b.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad6",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#06B6D4"}),b.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),b.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad6)"}),b.jsx("path",{d:"M20 8C20 8 28 12 28 22L24 26L20 24L16 26L12 22C12 12 20 8 20 8Z",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"20",cy:"17",r:"2.5",fill:"url(#grad6)"}),b.jsx("path",{d:"M16 28L14 32L18 30L16 28Z",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M24 28L26 32L22 30L24 28Z",fill:"white",fillOpacity:"0.8"})]},"icon-rocket")},{id:"music",name:"音乐",description:"粉紫渐变音乐图标",component:b.jsxs("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad7",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#EC4899"}),b.jsx("stop",{offset:"100%",stopColor:"#8B5CF6"})]})}),b.jsx("rect",{width:"40",height:"40",rx:"12",fill:"url(#grad7)"}),b.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:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad8",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#06B6D4"}),b.jsx("stop",{offset:"100%",stopColor:"#10B981"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad8)"}),b.jsx("circle",{cx:"24",cy:"24",r:"12",stroke:"white",strokeWidth:"2",fill:"none",strokeOpacity:"0.95"}),b.jsx("path",{d:"M24 12L30 18L24 24L18 18L24 12Z",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M24 24L30 30L24 36L18 30L24 24Z",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M12 24L18 30L24 24L18 18L12 24Z",fill:"white",fillOpacity:"0.7"}),b.jsx("path",{d:"M24 24L30 18L36 24L30 30L24 24Z",fill:"white",fillOpacity:"0.7"})]},"icon-sports")},{id:"games",name:"游戏",description:"红橙渐变游戏图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad9",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#EF4444"}),b.jsx("stop",{offset:"100%",stopColor:"#F97316"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad9)"}),b.jsx("rect",{x:"12",y:"16",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.95"}),b.jsx("rect",{x:"28",y:"16",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.95"}),b.jsx("rect",{x:"20",y:"24",width:"8",height:"8",rx:"2",fill:"white",fillOpacity:"0.8"}),b.jsx("rect",{x:"12",y:"32",width:"8",height:"4",rx:"1",fill:"white",fillOpacity:"0.7"}),b.jsx("rect",{x:"28",y:"32",width:"8",height:"4",rx:"1",fill:"white",fillOpacity:"0.7"})]},"icon-games")},{id:"expenses",name:"财务",description:"金黄渐变财务图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad10",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#F59E0B"}),b.jsx("stop",{offset:"100%",stopColor:"#EAB308"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad10)"}),b.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"}),b.jsx("rect",{x:"20",y:"34",width:"8",height:"2",rx:"1",fill:"white",fillOpacity:"0.8"}),b.jsx("circle",{cx:"21",cy:"20",r:"1.5",fill:"url(#grad10)"}),b.jsx("circle",{cx:"27",cy:"20",r:"1.5",fill:"url(#grad10)"})]},"icon-expenses")},{id:"sciences",name:"科学",description:"青蓝渐变科学图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad11",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#0EA5E9"}),b.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad11)"}),b.jsx("path",{d:"M12 36L20 28L28 36L36 28",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.95"}),b.jsx("circle",{cx:"24",cy:"16",r:"4",fill:"white",fillOpacity:"0.8"}),b.jsx("path",{d:"M24 20V28",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.7"}),b.jsx("circle",{cx:"16",cy:"32",r:"2",fill:"white",fillOpacity:"0.7"}),b.jsx("circle",{cx:"32",cy:"32",r:"2",fill:"white",fillOpacity:"0.7"})]},"icon-sciences")},{id:"magic-wand",name:"魔法",description:"紫粉渐变魔法图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad12",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#8B5CF6"}),b.jsx("stop",{offset:"100%",stopColor:"#EC4899"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad12)"}),b.jsx("path",{d:"M12 36L24 24L36 36L24 48L12 36Z",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"28",cy:"12",r:"2",fill:"white",fillOpacity:"0.8"}),b.jsx("circle",{cx:"36",cy:"20",r:"1.5",fill:"white",fillOpacity:"0.7"}),b.jsx("circle",{cx:"20",cy:"8",r:"1.5",fill:"white",fillOpacity:"0.7"}),b.jsx("circle",{cx:"32",cy:"4",r:"1",fill:"white",fillOpacity:"0.6"})]},"icon-magic-wand")},{id:"animals",name:"动物",description:"绿棕渐变动物图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad13",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#10B981"}),b.jsx("stop",{offset:"100%",stopColor:"#92400E"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad13)"}),b.jsx("ellipse",{cx:"24",cy:"28",rx:"10",ry:"8",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"20",cy:"26",r:"2",fill:"url(#grad13)"}),b.jsx("circle",{cx:"28",cy:"26",r:"2",fill:"url(#grad13)"}),b.jsx("path",{d:"M24 30C22 32 20 33 18 33",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.8"}),b.jsx("circle",{cx:"18",cy:"18",r:"4",fill:"white",fillOpacity:"0.8"}),b.jsx("circle",{cx:"30",cy:"18",r:"4",fill:"white",fillOpacity:"0.8"})]},"icon-animals")},{id:"travel",name:"旅行",description:"天蓝渐变旅行图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad14",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#0EA5E9"}),b.jsx("stop",{offset:"100%",stopColor:"#06B6D4"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad14)"}),b.jsx("path",{d:"M8 32L16 16L32 16L40 32L32 40L16 40L8 32Z",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"24",cy:"24",r:"3",fill:"url(#grad14)"}),b.jsx("path",{d:"M24 28V32",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),b.jsx("rect",{x:"12",y:"36",width:"4",height:"2",rx:"1",fill:"white",fillOpacity:"0.7"}),b.jsx("rect",{x:"32",y:"36",width:"4",height:"2",rx:"1",fill:"white",fillOpacity:"0.7"})]},"icon-travel")},{id:"nature",name:"自然",description:"绿色渐变自然图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad15",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#22C55E"}),b.jsx("stop",{offset:"100%",stopColor:"#10B981"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad15)"}),b.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"}),b.jsx("path",{d:"M24 12V20",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),b.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:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad16",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#1E40AF"}),b.jsx("stop",{offset:"100%",stopColor:"#3B82F6"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad16)"}),b.jsx("path",{d:"M24 8L8 16V24C8 32 14 38 24 40C34 38 40 32 40 24V16L24 8Z",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"24",cy:"22",r:"4",fill:"url(#grad16)"}),b.jsx("path",{d:"M24 26V30",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeOpacity:"0.8"}),b.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:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad17",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#EF4444"}),b.jsx("stop",{offset:"100%",stopColor:"#DC2626"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad17)"}),b.jsx("rect",{x:"20",y:"12",width:"8",height:"24",rx:"4",fill:"white",fillOpacity:"0.95"}),b.jsx("rect",{x:"12",y:"20",width:"24",height:"8",rx:"4",fill:"white",fillOpacity:"0.95"}),b.jsx("circle",{cx:"24",cy:"24",r:"2",fill:"url(#grad17)"})]},"icon-health")},{id:"food",name:"美食",description:"橙色渐变美食图标",component:b.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("defs",{children:b.jsxs("linearGradient",{id:"grad18",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[b.jsx("stop",{offset:"0%",stopColor:"#FB923C"}),b.jsx("stop",{offset:"100%",stopColor:"#F97316"})]})}),b.jsx("rect",{width:"48",height:"48",rx:"12",fill:"url(#grad18)"}),b.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"}),b.jsx("circle",{cx:"20",cy:"20",r:"1.5",fill:"url(#grad18)"}),b.jsx("circle",{cx:"28",cy:"20",r:"1.5",fill:"url(#grad18)"}),b.jsx("path",{d:"M24 24C22 26 20 27 18 27",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeOpacity:"0.8"}),b.jsx("path",{d:"M12 32L8 36L12 40",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.7"})]},"icon-food")}],r7t="robot",ag=e=>{if(!e){const n=C_.find(r=>r.id===r7t);return(n==null?void 0:n.component)||C_[0].component}const t=C_.find(n=>n.id===e);return(t==null?void 0:t.component)||C_[0].component},i7t=new Map(C_.map(e=>[e.id,e]));function a7t({active:e,agents:t,collapsed:n,onToggle:r,className:i,activeView:a="chat",onViewChange:o,onToolboxOpen:s,showLogout:l,onLogout:c,sidebarAgentMode:u=!1,onToggleSidebarMode:d,onAgentSelect:f}){const p=localStorage.getItem("sso_domain")||"",h=[{key:"chat",icon:b.jsx(v2e,{}),title:"对话"},...["maiduo","eccang"].includes(p)?[{key:"plan",icon:b.jsx(Yft,{}),title:"自动化Beta"}]:[],{key:"professional",icon:b.jsx(h2e,{}),title:"专业智能体"}],v=[...p==="yunduo"?[]:[{key:"toolbox",icon:b.jsx(Lpt,{}),label:"工具箱"},{key:"goals",icon:b.jsx(xft,{}),label:"目标追踪"}],{key:"settings",icon:b.jsx(Apt,{}),label:"系统设置"}];return b.jsx("div",{className:"wandox-aside-wrap",children:b.jsxs("div",{className:`wandox-aside ${n?"wandox-aside--collapsed":""} ${i||""}`,"aria-hidden":n,children:[b.jsxs("div",{className:"wandox-aside-header",children:[b.jsx("span",{className:"wandox-aside-header__title",children:"AI 智能体"}),r&&b.jsx("button",{type:"button",className:"wandox-aside-header-toggle",onClick:r,"aria-label":n?"展开侧边栏":"收起侧边栏",title:n?"展开侧边栏":"收起侧边栏",children:b.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",fill:"none",viewBox:"0 0 24 24",children:[b.jsx("title",{children:n?"展开侧边栏":"收起侧边栏"}),b.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"})]})})]}),b.jsx("div",{className:"wandox-aside-main-nav",children:b.jsx("div",{className:"wandox-aside-nav-list",children:h.map(y=>{const x=a===y.key,w=y.key==="professional";return b.jsxs("div",{children:[b.jsxs("div",{className:`wandox-aside-nav-item-wrap${x?" wandox-aside-nav-item-wrap--active":""}`,children:[b.jsxs("button",{type:"button",onClick:()=>o==null?void 0:o(y.key),className:`wandox-aside-nav-item${x?" wandox-aside-nav-item--active":""}`,children:[b.jsx("span",{className:"wandox-aside-nav-icon",children:y.icon}),b.jsx("span",{className:"wandox-aside-nav-title",children:y.title})]}),w&&!n&&d&&b.jsx(or,{title:u?"收起列表":"展开列表",placement:"right",children:b.jsx("button",{type:"button",className:`wandox-aside-mode-toggle${u?" wandox-aside-mode-toggle--active":""}`,onClick:S=>{S.stopPropagation(),d()},children:u?b.jsx(nY,{style:{fontSize:11}}):b.jsx(nw,{style:{fontSize:11}})})})]}),w&&(u||n)&&b.jsx("div",{className:"wandox-aside-agent-list",children:t.map(S=>{const _=S.agent_id;if(!_)return null;const C=e===_&&a==="professional";return b.jsx(or,{title:S.name,placement:"right",children:b.jsxs("button",{type:"button",className:`wandox-aside-agent-item${C?" wandox-aside-agent-item--active":""}`,onClick:()=>{f==null||f(_),a!=="professional"&&(o==null||o("professional"))},children:[b.jsx("span",{className:"wandox-aside-agent-icon",children:ag(S.icon)}),b.jsx("span",{className:"wandox-aside-agent-name",children:S.name})]})},_)})})]},y.key)})})}),b.jsxs("div",{className:"wandox-aside-bottom",children:[b.jsx("p",{className:"wandox-aside-group-label",children:"系统功能"}),b.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 b.jsxs("button",{type:"button",onClick:()=>{if(y.key==="toolbox"){s==null||s();return}o==null||o(y.key)},className:`wandox-aside-nav-item${x?" wandox-aside-nav-item--active":""}`,children:[b.jsx("span",{className:"wandox-aside-nav-icon",children:y.icon}),b.jsx("span",{className:"wandox-aside-nav-title",children:y.label})]},y.key)}),l&&b.jsxs("button",{type:"button",onClick:c,className:"wandox-aside-nav-item wandox-aside-nav-item--logout",children:[b.jsx("span",{className:"wandox-aside-nav-icon",children:b.jsx(ypt,{})}),b.jsx("span",{className:"wandox-aside-nav-title",children:"退出登录"})]})]}),b.jsx("div",{style:{height:8}})]})]})})}function o7t({title:e="正在进入指定智能体",description:t="正在加载智能体与剧本信息..."}){return b.jsxs("output",{className:"wandox-initial-route-loading","aria-label":e,children:[b.jsxs("div",{className:"wandox-initial-route-loading-aura","aria-hidden":"true",children:[Array.from({length:12},(n,r)=>({angle:r*30,delay:r*.08})).map(({angle:n,delay:r})=>b.jsx("span",{className:"wandox-chat-history-ray",style:{"--ray-angle":`${n}deg`,"--ray-delay":`${r}s`}},n)),b.jsx("div",{className:"wandox-chat-empty-icon",children:b.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:[b.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"}),b.jsx("path",{d:"M20 2v4"}),b.jsx("path",{d:"M22 4h-4"}),b.jsx("circle",{cx:"4",cy:"20",r:"2"})]})})]}),b.jsx("div",{className:"wandox-initial-route-loading-title",children:e}),b.jsx("div",{className:"wandox-initial-route-loading-text",children:t})]})}function s7t(e){const{children:t}=e;return b.jsx("div",{className:"wandox-layout wandox-root",children:b.jsx("main",{className:"wandox-layout-content",style:{padding:0},children:t})})}const l7t="wandox_use_map_tree_goals_v2",c7t=/^\?+$/;function u7t(e){return`${l7t}:${e||"all"}`}function ive(e){const t=e,n=Array.isArray(t==null?void 0:t.roles)?t:t==null?void 0:t.data;return Array.isArray(n==null?void 0:n.roles)?n.roles.map(r=>{const i=(r.goals||[]).filter(a=>a.playbook!==null).map(a=>({...a,icon:ave(a.icon),items:(a.items||[]).filter(o=>o.playbook_id)})).filter(a=>{var o;return(a.items||[]).length>0||!!(a.playbook_id||(o=a.playbook)!=null&&o.playbook_id)});return{...r,icon:ave(r.icon),goals:i,goal_count:i.length}}).filter(r=>(r.goals||[]).length>0):[]}function ave(e){const t=String(e||"").trim();if(!(!t||c7t.test(t)))return t}function d7t({agentId:e,onPlaybookClick:t,onSelectPlaybook:n,expanded:r,onExpandedChange:i}){const[a,o]=m.useState(!1),[s,l]=m.useState(!1),[c,u]=m.useState(!1),[d,f]=m.useState([]),[p,h]=m.useState(""),[g,v]=m.useState(""),y=m.useMemo(()=>e==null?"":String(e).trim(),[e]),x=r??a,w=m.useMemo(()=>d.find(C=>C.role_code===p)||d[0],[d,p]);m.useEffect(()=>{u(!1),f([]),h(""),v("")},[y]),m.useEffect(()=>{if(!x||c)return;let C=!1;const $=u7t(y);return(async()=>{l(!0),v("");try{const k=window.localStorage.getItem($);if(k)try{const P=ive(JSON.parse(k));P.length>0&&(f(P),h(P[0].role_code))}catch{window.localStorage.removeItem($)}const T=await Rgt({agent_id:y,role_id:null});if(C)return;const I=ive(T.data);f(I),h(P=>{var N;return P||((N=I[0])==null?void 0:N.role_code)||""}),window.localStorage.setItem($,JSON.stringify(T.data||{roles:[]}))}catch{C||v("使用地图加载失败")}finally{C||(u(!0),l(!1))}})(),()=>{C=!0}},[x,c,y]);const S=C=>{var T,I;const $=C.playbook_id||((T=C.playbook)==null?void 0:T.playbook_id),E=((I=C.playbook)==null?void 0:I.name)||C.title||C.name||"执行";if(!$)return;if(o(!1),i==null||i(!1),gU(C).length>0&&n){n(h7t(C),E);return}t({message:E,playbook_id:$})},_=()=>{const C=!x;o(C),i==null||i(C)};return b.jsxs("div",{className:`wandox-use-map${x?" wandox-use-map--expanded":""}`,children:[b.jsx("div",{className:"wandox-use-map-toolbar",children:b.jsxs("button",{type:"button",className:"wandox-use-map-toggle",onClick:_,"aria-expanded":x,children:[b.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--use-map","aria-hidden":"true",children:b.jsx(f2e,{})}),b.jsx("span",{className:"wandox-use-map-toggle-text",children:"使用地图"}),b.jsx("span",{className:"wandox-use-map-toggle-arrow","aria-hidden":"true",children:"⌄"})]})}),x&&b.jsx("div",{className:`wandox-use-map-panel${d.length===0?" wandox-use-map-panel--compact":""}`,children:(!c||s)&&d.length===0?b.jsxs("div",{className:"wandox-use-map-loading",children:[b.jsx("span",{className:"wandox-heartbeat-loader","aria-hidden":"true",children:b.jsx("svg",{width:"48",height:"24",viewBox:"0 0 48 24",fill:"none",children:b.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"})})}),b.jsx("span",{children:"正在加载使用地图"})]}):g?b.jsxs("div",{className:"wandox-use-map-empty",children:[b.jsx("div",{className:"wandox-use-map-empty-title",children:g}),b.jsx("button",{type:"button",className:"wandox-use-map-retry",onClick:()=>u(!1),children:"重新加载"})]}):d.length===0?b.jsxs("div",{className:"wandox-use-map-empty",children:[b.jsx("div",{className:"wandox-use-map-empty-title",children:"暂无使用地图"}),b.jsx("div",{className:"wandox-use-map-empty-desc",children:"当前智能体还没有配置岗位目标剧本"})]}):b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"wandox-use-map-roles",role:"tablist","aria-label":"岗位",children:d.map(C=>{var $;return b.jsxs("button",{type:"button",role:"tab","aria-selected":(w==null?void 0:w.role_code)===C.role_code,className:`wandox-use-map-role${(w==null?void 0:w.role_code)===C.role_code?" active":""}`,onClick:()=>h(C.role_code),children:[b.jsx("span",{className:"wandox-use-map-role-icon",children:C.icon||"◎"}),b.jsx("span",{className:"wandox-use-map-role-name",children:C.name}),b.jsx("span",{className:"wandox-use-map-role-count",children:C.goal_count||(($=C.goals)==null?void 0:$.length)||0})]},C.id)})}),b.jsx("div",{className:"wandox-use-map-goals",children:((w==null?void 0:w.goals)||[]).map(C=>{var $;return b.jsxs("section",{className:"wandox-use-map-goal-group",children:[b.jsxs("div",{className:"wandox-use-map-goal-group-head",children:[b.jsx("span",{className:"wandox-use-map-goal-group-icon",children:C.icon||"◇"}),b.jsx("span",{className:"wandox-use-map-goal-group-name",children:C.name}),b.jsxs("span",{className:"wandox-use-map-goal-group-count",children:[(($=C.items)==null?void 0:$.length)||0," 个剧本"]}),(C.description||C.subtitle)&&b.jsxs("span",{className:"wandox-use-map-goal-group-desc",children:["· ",C.description||C.subtitle]})]}),b.jsx("div",{className:"wandox-use-map-goal-items",children:(C.items||[]).map(E=>{var I,P,N;const k=gU(E).length>0,T=f7t(E.tags);return b.jsxs("button",{type:"button",className:`wandox-use-map-playbook-card${E.is_featured?" wandox-use-map-playbook-card--featured":""}`,onClick:()=>S(E),children:[b.jsx("div",{className:"wandox-use-map-playbook-title",children:b.jsx("span",{className:"wandox-use-map-playbook-name",children:E.title||E.name||((I=E.playbook)==null?void 0:I.name)||"未命名剧本"})}),(E.is_featured||k)&&b.jsxs("div",{className:"wandox-use-map-playbook-badges",children:[E.is_featured&&b.jsx(ji,{color:"gold",className:"wandox-use-map-tag wandox-use-map-featured-tag",children:"精品"}),k&&b.jsx("span",{className:"wandox-use-map-param-badge",children:"参数"})]}),(E.subtitle||E.description||((P=E.playbook)==null?void 0:P.description))&&b.jsx("div",{className:"wandox-use-map-playbook-desc",children:E.subtitle||E.description||((N=E.playbook)==null?void 0:N.description)}),T.length>0&&b.jsx("div",{className:"wandox-use-map-playbook-tags",children:T.map((A,M)=>b.jsx(ji,{color:A.variant==="soft"?void 0:A.color,className:"wandox-use-map-tag",style:p7t(A),children:A.name},`${A.name}-${M}`))})]},`${C.id}-${E.id||E.playbook_id}`)})})]},C.id)})})]})})]})}function gU(e){var t;return e.input_fields||((t=e.playbook)==null?void 0:t.input_fields)||[]}function f7t(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=typeof(n==null?void 0:n.name)=="string"?n.name.trim():"";return r&&t.push({...n,name:r}),t},[]):[]}function p7t(e){if(!(e.variant!=="soft"||!e.color))return{color:e.color,borderColor:ove(e.color,.28),backgroundColor:ove(e.color,.08)}}function ove(e,t){const n=e.trim().replace("#","");if(!/^[0-9a-fA-F]{6}$/.test(n))return e;const r=Number.parseInt(n.slice(0,2),16),i=Number.parseInt(n.slice(2,4),16),a=Number.parseInt(n.slice(4,6),16);return`rgba(${r}, ${i}, ${a}, ${t})`}function h7t(e){var n;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:((n=e.playbook)==null?void 0:n.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:gU(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}}function v1(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ROe(e){return v1(e)?v1(e.data)?e.data:e:{}}function sve(e){return(Array.isArray(e)?e.map(n=>[void 0,n]):v1(e)?Object.entries(e):[]).flatMap(([n,r])=>{if(!v1(r))return[];const i=String(r.name||n||"").trim();return i?[{...r,name:i,label:String(r.label||i),type:String(r.type||"string")}]:[]})}function m7t(e){const t=ROe(e),n=v1(t.content)?t.content:{},r=n.yaml_content;if(typeof r=="string"&&r.trim())try{const i=FE.parse(r);return sve(v1(i)?i.params:void 0)}catch{}for(const i of[t.input_fields,n.input_fields]){const a=sve(i);if(a.length>0)return a}return[]}function g7t(e,t){const n=ROe(t),r=m7t(n);return{...e,...n,playbook_id:String(n.playbook_id||e.playbook_id),name:String(n.name||e.name),input_fields:r}}const Om=e=>String(e.playbook_id||e.code||e.name);function v7t({label:e}){return b.jsxs("output",{className:"wandox-scene-list-loading","aria-label":e,children:[b.jsx("span",{className:"wandox-heartbeat-loader","aria-hidden":"true",children:b.jsx("svg",{width:"48",height:"24",viewBox:"0 0 48 24",fill:"none",children:b.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"})})}),b.jsx("span",{children:e})]})}function DOe({playbooks:e,playbookLoading:t,onPlaybookClick:n,onSelectPlaybook:r,recommendations:i=[],userPlaybooks:a=[],userPlaybooksLoading:o=!1,onLoadUserPlaybooks:s,agentId:l,recentRefreshKey:c=0}){const[u,d]=m.useState("playbooks"),[f,p]=m.useState(!1),[h,g]=m.useState(!1),[v,y]=m.useState("全部"),[x,w]=m.useState(""),[S,_]=m.useState(null),[C,$]=m.useState(""),[E,k]=m.useState(!1),[T,I]=m.useState([]),[P,N]=m.useState(!1),[A,M]=m.useState(""),R=m.useRef(!1),L=m.useRef(new Map),z=m.useMemo(()=>u==="recommendations"?t&&i.length===0:u==="user"?o:P||t&&e.length===0,[t,P,u,e.length,i.length,o]),j=m.useMemo(()=>l==null?"":String(l).trim(),[l]);m.useEffect(()=>{if(!j){I([]),N(!1);return}let Y=!1;return(async()=>{N(!0);try{const ee=await Xmt({limit:8,agent_id:j});Y||I(ee.data||[])}catch{Y||I([])}finally{Y||N(!1)}})(),()=>{Y=!0}},[j,c]);const O=m.useRef(null),[V,B]=m.useState(5),D=m.useCallback(()=>{if(!O.current)return;const Y=O.current.offsetWidth;if(Y===0)return;const ee=Math.floor(Y/(200+12));B(Math.max(2,ee))},[]);m.useEffect(()=>{const Y=setTimeout(D,100);return()=>clearTimeout(Y)},[D,u,f]),m.useEffect(()=>{u==="recommendations"&&i.length===0&&d("playbooks")},[i.length,u]),m.useEffect(()=>{u!=="user"||!j||s==null||s()},[u,j,s]),m.useEffect(()=>{if(!O.current)return;const Y=new ResizeObserver(()=>{D()});return Y.observe(O.current),()=>Y.disconnect()},[D]);const F=m.useMemo(()=>new Set(T.map(Om)),[T]),H=m.useMemo(()=>new Set(a.map(Om)),[a]),W=m.useMemo(()=>{const Y=new Map;for(const Z of T.filter(re=>!H.has(Om(re))))Y.set(Om(Z),Z);for(const Z of e){const re=Om(Z);Y.has(re)||Y.set(re,Z)}return Array.from(Y.values())},[e,T,H]),K=u==="playbooks"?W:u==="recommendations"?i:a,U=u==="playbooks"?e:K,q=K.length>(V??5)&&U.length>0,Q=m.useMemo(()=>{const Y=new Map;Y.set("全部",U.length);for(const Z of U){const re=Z.category_name||"未分类";Y.set(re,(Y.get(re)||0)+1)}return Array.from(Y.entries()).map(([Z,re])=>({name:Z,count:re}))},[U]),G=m.useMemo(()=>{let Y=U;if(v!=="全部"&&(Y=Y.filter(Z=>(Z.category_name||"未分类")===v)),x.trim()){const Z=x.trim().toLowerCase();Y=Y.filter(re=>{var ee;return re.name.toLowerCase().includes(Z)||((ee=re.description)==null?void 0:ee.toLowerCase().includes(Z))})}return Y},[U,v,x]),X=m.useCallback(Y=>{const Z=String(Y.playbook_id||"").trim();if(!Z)return Promise.reject(new Error("缺少 playbook_id"));const re=L.current.get(Z);if(re)return re;const ee=BE({playbook_id:Z}).then(({data:te})=>g7t(Y,te)).finally(()=>{L.current.delete(Z)});return L.current.set(Z,ee),ee},[]),J=m.useCallback(async(Y,Z=!1)=>{var re;if(!R.current){R.current=!0,M(Y.playbook_id);try{const ee=await X(Y);if(Z&&(g(!1),y("全部"),w("")),(re=ee.input_fields)!=null&&re.length&&r){r(ee,ee.name);return}n({message:ee.name,playbook_id:ee.playbook_id})}catch{Ze.error("剧本参数加载失败,请稍后重试")}finally{R.current=!1,M("")}}},[X,n,r]);return b.jsxs("div",{className:"wandox-pro-scenes-panel",children:[b.jsxs("div",{className:"wandox-hub-section-header",children:[b.jsxs("div",{className:"wandox-scene-tabs",children:[b.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&u==="playbooks"?" active":""}`,onClick:()=>{d("playbooks"),p(!1)},children:[b.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--playbooks","aria-hidden":"true",children:b.jsx(p2e,{})}),b.jsx("span",{children:"默认场景"})]}),i.length>0&&b.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&u==="recommendations"?" active":""}`,onClick:()=>{d("recommendations"),p(!1)},children:[b.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--recommendations","aria-hidden":"true",children:b.jsx(h2e,{})}),b.jsx("span",{children:"推荐场景"})]}),b.jsxs("button",{type:"button",className:`wandox-scene-tab${!f&&u==="user"?" active":""}`,onClick:()=>{d("user"),p(!1)},children:[b.jsx("span",{className:"wandox-scene-tab-mark wandox-scene-tab-mark--user","aria-hidden":"true",children:b.jsx(Vpt,{})}),b.jsx("span",{children:"我的场景"})]}),b.jsx(d7t,{agentId:j,onPlaybookClick:n,onSelectPlaybook:r,expanded:f,onExpandedChange:Y=>{p(Y),Y&&d("playbooks")}})]}),q&&!f&&b.jsxs("button",{type:"button",className:"wandox-scene-view-all",onClick:()=>g(!0),children:["查看全部 ",U.length," 个"]})]}),b.jsx("div",{className:"wandox-tab-content",children:!f&&b.jsx("div",{className:"wandox-hub-section",children:z?b.jsx(v7t,{label:u==="user"?"正在加载我的场景":u==="recommendations"?"正在匹配推荐场景":"正在加载场景"}):K.length>0?b.jsxs("div",{className:"wandox-scroll-row",ref:O,children:[K.slice(0,V??5).map(Y=>{const Z=A===Y.playbook_id,re=()=>void J(Y),ee=u==="playbooks"&&F.has(Om(Y)),te=u==="user"?"用户":ee?"近期":Y.badge==="new"?"New":Y.badge==="recommend"?"推荐":Y.badge==="featured"?"精选":Y.category_name||Y.type||"推荐",oe=Y.video_duration?`${Math.floor(Y.video_duration/60)}:${String(Y.video_duration%60).padStart(2,"0")}`:"",fe=async Ee=>{var we;Ee.stopPropagation(),_(Y),k(!0);try{const le=await Ase({playbook_id:Y.playbook_id});$(((we=le.data)==null?void 0:we.video_url)||Y.video_url||"")}catch{$(Y.video_url||"")}finally{k(!1)}},he={daily:"每日",weekly:"每周",monthly:"每月"},ye=Y.is_subscribed?`🔔订阅${Y.execution_frequency&&Y.execution_frequency!=="none"?`·${he[Y.execution_frequency]}自动跑`:""}`:"",Te=[Y.description,ye].filter(Boolean).join(" ");return b.jsxs("div",{className:"wandox-card",children:[b.jsxs("div",{className:"wandox-card-corner",children:[b.jsx("span",{className:"wandox-card-tag",children:te}),Y.video_url&&b.jsxs("button",{type:"button",className:"wandox-card-video",onClick:fe,children:["▶ ",oe?` ${oe}`:"0:00"," 演示"]})]}),b.jsxs("button",{type:"button",className:"wandox-card-main",onClick:re,disabled:Z,"aria-busy":Z,children:[b.jsx("div",{className:"wandox-card-title",children:Y.name}),b.jsx("div",{className:"wandox-card-desc",children:Z?"正在加载参数...":Te})]})]},Om(Y))}),q&&b.jsxs("button",{type:"button",className:"wandox-card wandox-card-more",onClick:()=>g(!0),children:[b.jsxs("div",{className:"wandox-card-more-title",children:["查看全部 ",U.length," 个"]}),b.jsx("div",{className:"wandox-card-more-desc",children:"按场景浏览"})]})]}):b.jsx("div",{className:"wandox-empty-slot",children:b.jsxs("div",{className:"wandox-empty",children:[b.jsx("div",{className:"wandox-empty-text",children:u==="playbooks"?"暂无默认场景":u==="recommendations"?"暂无推荐场景":"暂无我的场景"}),b.jsx("div",{className:"wandox-empty-desc",children:u==="playbooks"?"请联系管理员添加场景剧本":u==="recommendations"?"系统会根据情况推荐相关场景":"我创建的场景会显示在这里"})]})})})}),b.jsx(rr,{open:h,onCancel:()=>{g(!1),y("全部"),w("")},footer:null,width:900,closable:!1,centered:!0,styles:{container:{padding:0,overflow:"hidden"},body:{height:"90vh"}},zIndex:1e4,children:b.jsxs("div",{className:"wandox-playbook-browser",children:[b.jsxs("div",{className:"wandox-playbook-sidebar",children:[b.jsx("div",{className:"wandox-playbook-sidebar-title",children:"场景分类"}),b.jsx("div",{className:"wandox-playbook-categories",children:Q.map(Y=>b.jsxs("button",{type:"button",className:`wandox-playbook-category-item${v===Y.name?" active":""}`,onClick:()=>y(Y.name),children:[b.jsx("span",{className:"wandox-playbook-category-name",children:Y.name}),b.jsx("span",{className:"wandox-playbook-category-count",children:Y.count})]},Y.name))})]}),b.jsxs("div",{className:"wandox-playbook-main",children:[b.jsx("div",{className:"wandox-playbook-search",children:b.jsx(Kt,{placeholder:"搜索场景名称或描述...",prefix:b.jsx(dy,{style:{color:"#9ca3af"}}),value:x,onChange:Y=>w(Y.target.value),allowClear:!0})}),b.jsx("div",{className:"wandox-playbook-list",children:G.length===0?b.jsx(ei,{description:"暂无剧本",style:{marginTop:80}}):G.map(Y=>{const Z=Y.input_fields&&Y.input_fields.length>0,re=A===Y.playbook_id,ee=!!Y.video_url,te=()=>void J(Y,!0),oe=Y.video_duration?`${Math.floor(Y.video_duration/60)}:${String(Y.video_duration%60).padStart(2,"0")}`:"",fe=async()=>{var he;_(Y),k(!0);try{const ye=await Ase({playbook_id:Y.playbook_id});$(((he=ye.data)==null?void 0:he.video_url)||Y.video_url||"")}catch{Ze.error("视频加载失败"),$(Y.video_url||"")}finally{k(!1)}};return b.jsx("div",{className:"wandox-playbook-list-item",children:b.jsxs("div",{className:"wandox-playbook-list-item-content",children:[b.jsx("div",{className:"wandox-playbook-list-item-icon",children:ee?b.jsx("button",{className:"wandox-playbook-video-icon",title:"包含演示视频",onClick:fe,type:"button",children:b.jsx(Fc,{})}):b.jsx("div",{className:"wandox-playbook-no-video-icon",children:b.jsx(n$e,{})})}),b.jsxs("div",{className:"wandox-playbook-list-item-body",children:[b.jsx("div",{className:"wandox-playbook-list-item-header",children:b.jsxs("div",{className:"wandox-playbook-list-item-title",children:[Y.name,Y.badge&&b.jsx("span",{className:`wandox-scene-badge wandox-scene-badge--${Y.badge}`,children:Y.badge==="new"?"New":Y.badge==="recommend"?"推荐":"精选"})]})}),Y.description&&b.jsx("div",{className:"wandox-playbook-list-item-desc",children:Y.description}),Y.last_execution_remark&&b.jsxs("div",{className:"wandox-playbook-list-item-remark",children:[b.jsx("span",{className:"wandox-playbook-list-item-remark-icon",children:"💡"}),b.jsxs("span",{children:["上次:",Y.last_execution_remark]})]})]}),b.jsxs("div",{className:"wandox-playbook-list-item-actions",children:[b.jsx("button",{type:"button",className:"wandox-playbook-list-item-btn",onClick:te,disabled:re,"aria-busy":re,children:re?"加载中":Z?"参数":"运行"}),ee&&b.jsxs("button",{type:"button",className:"wandox-playbook-demo-link",onClick:fe,children:["看演示",oe?` ${oe}`:""]})]})]})},Y.playbook_id)})})]})]})}),S&&b.jsx(rr,{open:!0,onCancel:()=>{_(null),$("")},footer:null,centered:!0,width:800,title:b.jsxs("span",{children:[b.jsx(Fc,{style:{marginRight:8,color:"#7c3aed"}}),S.name," · 演示视频",S.video_duration&&b.jsxs("span",{style:{marginLeft:12,fontSize:13,color:"#9ca3af",fontWeight:"normal"},children:["时长 ",Math.floor(S.video_duration/60),":",String(S.video_duration%60).padStart(2,"0")]}),S.view_count!==void 0&&b.jsxs("span",{style:{marginLeft:12,fontSize:13,color:"#9ca3af",fontWeight:"normal"},children:["👁 ",S.view_count," 次播放"]})]}),styles:{body:{padding:"12px 0 0"}},zIndex:10001,children:E?b.jsx("div",{style:{height:400,display:"flex",alignItems:"center",justifyContent:"center",background:"#000",borderRadius:8},children:b.jsx(Ri.Node,{active:!0,style:{width:200,height:200}})}):b.jsx("video",{src:C,controls:!0,autoPlay:!0,style:{width:"100%",borderRadius:8,display:"block",maxHeight:"70vh",background:"#000"},children:b.jsx("track",{kind:"captions"})})})]})}const OOe=[{name:"country",label:"国家/地区"},{name:"state",label:"州/省"},{name:"province",label:"省"},{name:"city",label:"城市"},{name:"postal_code",label:"邮政编码"},{name:"address_line1",label:"地址"}],y7t=Object.fromEntries(OOe.map(e=>[e.name,e.label]));function z2(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R0(e){return typeof e=="string"?e.trim():String(e??"").trim()}function b7t(e,t){return!z2(e)||!Array.isArray(e[t])?[]:e[t].map(String).filter(Boolean)}function x7t(e,t){if(!z2(e)||!z2(e.postal_code_patterns))return;const n=e.postal_code_patterns[t];return typeof n=="string"?n:void 0}function aj(e){const t=String(e.type||"").toLowerCase(),n=String(e.widget||"").toLowerCase();return t==="address"||n==="address"}function w7t(){return[...OOe]}function LOe(e,t){if(!z2(e))return"请输入有效地址";const n=b7t(t,"required_fields"),r=n.length>0?n:["country","city","postal_code","address_line1"];for(const l of r)if(!R0(e[l]))return`请填写${y7t[l]||`地址字段 ${l}`}`;if(n.length===0&&!R0(e.state)&&!R0(e.province))return"请填写州/省";const i=R0(e.country).toUpperCase(),a=R0(e.postal_code),o=x7t(t,i);if(a&&o)try{if(!new RegExp(o).test(a))return"邮政编码格式不正确"}catch{return"地址邮编规则配置无效"}const s=z2(t)&&typeof t.max_length=="number"?t.max_length:200;return R0(e.address_line1).length>s?`地址行不能超过 ${s} 个字符`:""}var jOe={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Xs,function(){var n="month",r="quarter";return function(i,a){var o=a.prototype;o.quarter=function(c){return this.$utils().u(c)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(c-1))};var s=o.add;o.add=function(c,u){return c=Number(c),this.$utils().p(u)===r?this.add(3*c,n):s.bind(this)(c,u)};var l=o.startOf;o.startOf=function(c,u){var d=this.$utils(),f=!!d.u(u)||u;if(d.p(c)===r){var p=this.quarter()-1;return f?this.month(3*p).startOf(n).startOf("day"):this.month(3*p+2).endOf(n).endOf("day")}return l.bind(this)(c,u)}}})})(jOe);var S7t=jOe.exports;const _7t=Co(S7t);In.extend(mK);In.extend(_7t);In.extend(b_e);const C7t={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 hT(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 bu(e){var n;const t=hT(e.type);if(t)return(n=e.format)!=null&&n.trim()?e.format.trim():mT(e)==="time"?"HH:mm:ss":GQ(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":C7t[t]}function mT(e){const t=hT(e.type);return t?t==="time"||t==="timerange"?"time":"date":null}function y1(e){const t=hT(e.type);return e.range??(t==="daterange"||t==="datetimerange"||t==="timerange")}function GQ(e){const t=hT(e.type);return e.show_time??(t==="datetime"||t==="datetimerange")}function b1(e,t){return["date","week","month","quarter","year"].includes(t||"")?t:e==="YYYY"?"year":e==="YYYY-MM"?"month":"date"}function ov(e){return e!=null&&e.includes("ss")?"HH:mm:ss":"HH:mm"}function sv(e,t,n){if(e==null||e===""||typeof e!="string"&&typeof e!="number"&&!(e instanceof Date)&&!In.isDayjs(e))return null;let r;if(typeof e=="string"&&/^\d{1,2}:\d{2}(?::\d{2})?$/.test(e))r=In(`2000-01-01 ${e}`);else if(typeof e=="string"&&n==="quarter"){const i=e.match(/^(\d{4}).*?Q([1-4])/i);r=i?In(`${i[1]}-01-01`).quarter(Number(i[2])):In(e)}else if(typeof e=="string"&&n==="week"){const i=e.match(/^(\d{4})\D+(\d{1,2})/);r=i?In(`${i[1]}-01-01`).week(Number(i[2])):In(e)}else typeof e=="string"&&t?(r=In(e,t,!0),r.isValid()||(r=In(e))):r=In(e);return r.isValid()?r:null}function SC(e,t,n){return!Array.isArray(e)||e.length!==2?null:[sv(e[0],t,n),sv(e[1],t,n)]}function qQ({field:e,value:t,size:n,disabled:r=!1,readOnly:i=!1,status:a,onChange:o}){const s=mT(e),l=bu(e),c=y1(e),u={size:n,style:{width:"100%"},format:l,disabled:r,allowClear:!i,inputReadOnly:i,open:i?!1:void 0,status:a};if(s==="date"){const d=GQ(e),f=b1(l,e.picker),p=d?"日期时间":"日期",h={...u,picker:f,showTime:d?{format:ov(l)}:!1};return c?b.jsx(ui.RangePicker,{...h,value:SC(t,l,f),placeholder:[`请选择开始${p}`,`请选择结束${p}`],onChange:(g,v)=>o(v)}):b.jsx(ui,{...h,value:sv(t,l,f),placeholder:e.placeholder||`请选择${p}`,onChange:(g,v)=>o(v)})}return s==="time"?c?b.jsx(Ua.RangePicker,{...u,value:SC(t,l),placeholder:["请选择开始时间","请选择结束时间"],onChange:(d,f)=>o(f)}):b.jsx(Ua,{...u,value:sv(t,l),placeholder:e.placeholder||"请选择时间",onChange:(d,f)=>o(f)}):null}function lve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _C(e){return["array","list","tags","multi_select","multiselect"].includes(String(e||"").toLowerCase())}function zOe(e){return(e==null?void 0:e.includes("image"))??!1}function oj(e){const t=(e.ui_component||e.widget||e.type||"string").toLowerCase();return hT(t)||t}function FOe(e){return oj(e)==="segmented"||e.type.toLowerCase()==="segmented"}function cve(e){var t;return(t=e.options)!=null&&t.length?e.options:(e.enum||[]).map(n=>({value:n,label:n}))}function $7t(e){return e==null?"":typeof e=="string"||typeof e=="number"||typeof e=="bigint"?e:String(e)}function E7t(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 vU(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 n=JSON.parse(t);if(Array.isArray(n))return n.map(r=>String(r))}catch{}}return[String(e)]}function If(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function x1(e,t={}){const n={};for(const r of e){const i=t[r.name];i!==void 0&&i!==""?n[r.name]=_C(r.type)?vU(i):i:r.default!==void 0&&r.default!==""?n[r.name]=_C(r.type)?vU(r.default):r.default:r.type.toLowerCase()==="boolean"?n[r.name]=!1:["number","integer","float"].includes(r.type.toLowerCase())?n[r.name]=void 0:_C(r.type)?n[r.name]=[]:n[r.name]=""}return n}function $_(e,t){return Array.isArray(e)?e.some(n=>$_(n,t)):String(e??"")===String(t??"")}function T7t(e){return Array.isArray(e)?e.filter(lve):lve(e)?"field"in e||"name"in e||"param"in e?[e]:Object.entries(e).map(([t,n])=>({field:t,equals:n})):[]}function I7t(e,t){const n=String(e.field??e.name??e.param??"");if(!n)return!0;const r=t[n],i=e.equals!==void 0||e.value!==void 0,a=e.equals??e.value;return!(i&&!$_(r,a)||e.not_equals!==void 0&&$_(r,e.not_equals)||Array.isArray(e.in)&&!e.in.some(o=>$_(r,o))||Array.isArray(e.not_in)&&e.not_in.some(o=>$_(r,o))||e.truthy===!0&&!r||e.empty===!0&&!If(r)||e.empty===!1&&If(r))}function gT(e,t){return e.filter(n=>{const r=T7t(n.visible_when);return r.length===0||r.every(i=>I7t(i,t))})}function BOe(e,t){return e.reduce((n,r)=>(n[r.name]=t[r.name],n),{})}function k7t(e){return Array.isArray(e)?e.map(t=>String(t)):e?[String(e)]:[]}function yU(e){return e!=null&&e!==""}function P7t(e,t){const n=_C(e.type),r=vU(t),i=yU(t)?String(t):void 0;return{isMulti:n,selectValue:n?r:i,isEmptySelect:n?r.length===0:i===void 0,hasCurrentSelection:n?r.length>0:i!==void 0}}function KQ({field:e,value:t,readOnly:n=!1,size:r,uploading:i=!1,imageUploadMode:a="picture",fileNameMap:o={},getOptionState:s,onChange:l,onUpload:c,onDownloadTemplate:u,draftValue:d,onDraftChange:f,onDraftCommit:p,selectSearchValue:h,onSelectSearchChange:g,onSelectAllowEmptySearch:v}){var C,$,E,k;const y=d??String($7t(t)),x=oj(e),w={...e,type:x},S=T=>l(e.name,T),_=()=>{var O,V;const T=s(e),I=e.options_from_skill?T.options:cve(e),P=!!(e.options_from_skill||(O=e.enum)!=null&&O.length||(V=e.options)!=null&&V.length),N=T.waitingForDependencies?"请先选择关联参数":T.placeholder||e.placeholder||"请选择",{isMulti:A,selectValue:M,isEmptySelect:R,hasCurrentSelection:L}=P7t(e,t),z=g!==void 0,j=()=>{v==null||v(e.name),h&&(g==null||g(e.name,""))};return b.jsx(tn,{allowClear:!n,showSearch:!n,size:r,autoClearSearchValue:!z,optionFilterProp:"label",filterOption:(B,D)=>{const F=B.trim().toLowerCase();return F?String((D==null?void 0:D.label)??(D==null?void 0:D.value)??"").toLowerCase().includes(F):!0},mode:A?P?"multiple":"tags":void 0,value:M,searchValue:n||!z?void 0:h,placeholder:R?N:void 0,options:I,loading:!n&&T.loading,disabled:!n&&T.waitingForDependencies,open:n?!1:void 0,tabIndex:n?-1:void 0,"aria-readonly":n,tokenSeparators:A&&!P?[","]:void 0,notFoundContent:T.loading?b.jsx(vr,{size:"small"}):T.error||null,onInputKeyDown:B=>{["Backspace","Delete","Escape"].includes(B.key)&&(v==null||v(e.name))},onSearch:z?B=>g(e.name,B):void 0,onChange:B=>{S(B);const D=Array.isArray(B)?B.length>0:yU(B);(L||D)&&j()},onClear:j,onBlur:j})};if(FOe(e)){const T=cve(e);return T.length===0?_():b.jsx(DK,{className:"wandox-agent-input-field-control__segmented",options:T,value:yU(t)?String(t):void 0,disabled:n,onChange:S})}if(aj(e)){const T=t&&typeof t=="object"&&!Array.isArray(t)?t:{},I=(P,N)=>{n||S({...T,[P]:N})};return b.jsxs("div",{className:"wandox-agent-input-field-control__address",children:[w7t().map(({name:P,label:N})=>b.jsx(Kt,{size:r,value:String(T[P]??""),readOnly:n,placeholder:N,onChange:A=>I(P,A.target.value)},P)),b.jsx(Kt,{size:r,value:String(T.address_line2??""),readOnly:n,placeholder:"地址补充",onChange:P=>I("address_line2",P.target.value)})]})}if(mT(w))return b.jsx(qQ,{field:w,value:t,size:r,readOnly:n,disabled:n,onChange:S});switch(x){case"file":{const T=e.max_files??1,I=k7t(t),P=I.length<T,N=A=>{S(T<=1?"":I.filter((M,R)=>R!==A))};if(a==="picture"&&zOe(e.file_type)){const A=I.map((M,R)=>({uid:String(R),name:o[M]||M.split("/").pop()||`image_${R+1}`,status:"done",url:M}));return b.jsx(zc,{className:"wandox-agent-input-field-control__picture",accept:e.file_type||void 0,listType:"picture-card",fileList:A,customRequest:n?void 0:c(e.name,T),onRemove:n?void 0:M=>(N(Number(M.uid)),!0),disabled:n||i,maxCount:T,showUploadList:{showRemoveIcon:!n},children:P&&!n&&b.jsxs("div",{children:[i?b.jsx(vr,{size:"small"}):b.jsx(Uo,{}),b.jsx("div",{className:"wandox-agent-input-field-control__upload-text",children:"上传图片"})]})})}return b.jsxs("div",{className:"wandox-agent-input-field-control__files",children:[I.map((A,M)=>b.jsxs("div",{className:"wandox-agent-input-field-control__file",children:[b.jsx("span",{children:o[A]||A.split("/").pop()||A}),!n&&b.jsx(Et,{type:"text",size:"small",danger:!0,"aria-label":"移除文件",icon:b.jsx(hf,{}),onClick:()=>N(M)})]},A)),e.file_templates&&e.file_templates.length>0&&b.jsxs("div",{className:"wandox-agent-input-field-control__templates",children:[b.jsx("span",{children:"模板文件"}),e.file_templates.map((A,M)=>b.jsx(Et,{size:"small",onClick:()=>u==null?void 0:u(A),children:A.name||"下载模板"},`${A.path}-${A.name||M}`))]}),P&&!n&&b.jsxs(zc.Dragger,{accept:e.file_type||void 0,showUploadList:!1,customRequest:c(e.name,T),disabled:i,children:[b.jsx("p",{className:"ant-upload-drag-icon",children:i?b.jsx(vr,{size:"small"}):b.jsx(OE,{})}),b.jsx("p",{className:"ant-upload-text",children:i?"上传中...":"点击或拖拽文件上传"}),T>1&&b.jsxs("p",{className:"ant-upload-hint",children:["已上传 ",I.length,"/",T]})]})]})}case"boolean":return b.jsx(yo,{size:r==="small"?"small":"default",checked:!!t,disabled:n,onChange:S});case"number":case"integer":case"float":return b.jsx(zo,{size:r,value:E7t(t),readOnly:n,placeholder:e.placeholder||"请输入",onChange:S});case"select":case"array":case"list":case"tags":case"multi_select":case"multiselect":return _();case"string":return(C=e.enum)!=null&&C.length||($=e.options)!=null&&$.length||e.options_from_skill?_():b.jsx(Kt,{size:r,value:y,readOnly:n,placeholder:e.placeholder||"请输入",onChange:n?void 0:T=>f?f(e.name,T.target.value):S(T.target.value),onBlur:n?void 0:T=>p==null?void 0:p(e.name,T.target.value)});default:return(E=e.enum)!=null&&E.length||(k=e.options)!=null&&k.length||e.options_from_skill?_():b.jsx(Kt.TextArea,{value:y,readOnly:n,autoSize:{minRows:2,maxRows:8},placeholder:e.placeholder||"请输入",onChange:n?void 0:T=>f?f(e.name,T.target.value):S(T.target.value),onBlur:n?void 0:T=>p==null?void 0:p(e.name,T.target.value)})}}const VOe=/\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}/g,N7t=/^\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}$/;function lv(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bU(e,t){return t.split(".").reduce((n,r)=>{if(lv(n))return n[r]},e)}function A7t(e){return e==null||e===""}function M7t(e){const t=new Set,n=r=>{if(typeof r=="string"){for(const i of r.matchAll(VOe))i[1]&&t.add(i[1]);return}if(Array.isArray(r)){r.forEach(n);return}lv(r)&&Object.values(r).forEach(n)};return n(e),Array.from(t)}function R7t(e,t){const n=e.split(".")[0],r=t.find(i=>i.name===e||i.name===n);return r?!!r.required:!0}function xU(e,t){if(typeof e=="string"){const n=e.match(N7t);return n!=null&&n[1]?bU(t,n[1]):e.replace(VOe,(r,i)=>{const a=bU(t,i);return a==null?"":String(a)})}return Array.isArray(e)?e.map(n=>xU(n,t)):lv(e)?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,xU(r,t)])):e}function D7t(e){const t=lv(e)&&"data"in e?e.data:e,n=[t];lv(t)&&(n.push(t.output_data,t.options,t.items,t.data,t.result,t.results,t.list),lv(t.output)&&n.push(t.output.output_data,t.output.options,t.output.items,t.output.data));for(const r of n)if(Array.isArray(r))return r;return[]}function O7t(e){let t;return{options:D7t(e).map(r=>{if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return{value:String(r),label:String(r)};if(!lv(r))return null;const i=r.value??r.key??r.code??r.id??r.name??r.label;if(i==null)return null;const a=r.label??r.name??r.title??r.text??r.value??i;if(String(i)===""){const o=String(a||"");return o&&!t&&(t=o),null}return{value:String(i),label:String(a)}}).filter(r=>!!r),placeholder:t}}function L7t(e){return(e.enum||[]).map(t=>({value:t,label:t}))}function sj(e,t,n){const[r,i]=m.useState({}),a=m.useRef({}),o=m.useRef({}),s=m.useMemo(()=>e.filter(l=>!!l.options_from_skill),[e]);return m.useEffect(()=>{const l=new Set(s.map(c=>c.name));for(const c of Object.keys(a.current))l.has(c)||(delete a.current[c],delete o.current[c]);i(c=>{const u=Object.fromEntries(Object.entries(c).filter(([d])=>l.has(d)));return Object.keys(u).length===Object.keys(c).length?c:u})},[s]),m.useEffect(()=>{for(const l of s){if(!l.options_from_skill)continue;const u=M7t(l.options_params).filter(g=>R7t(g,e)&&A7t(bU(t,g))),d=xU(l.options_params||{},t),f=JSON.stringify({skill_id:l.options_from_skill,params:d,missing:u});if(a.current[l.name]===f)continue;const p=a.current[l.name]!==void 0||u.length>0;a.current[l.name]=f,o.current[l.name]=(o.current[l.name]||0)+1;const h=o.current[l.name];if(p&&n(g=>g[l.name]===void 0||g[l.name]===""?g:{...g,[l.name]:void 0}),u.length>0){i(g=>({...g,[l.name]:{options:[],loading:!1,waitingForDependencies:!0}}));continue}i(g=>{var v,y;return{...g,[l.name]:{options:((v=g[l.name])==null?void 0:v.options)||[],loading:!0,placeholder:(y=g[l.name])==null?void 0:y.placeholder,waitingForDependencies:!1}}}),PEe({},{skill_id:l.options_from_skill,params:d}).then(g=>{if(o.current[l.name]!==h)return;const v=O7t(g);i(y=>({...y,[l.name]:{options:v.options,loading:!1,placeholder:v.placeholder,waitingForDependencies:!1}}))}).catch(g=>{if(o.current[l.name]!==h)return;const v=g instanceof Error?g.message:"动态选项加载失败";i(y=>({...y,[l.name]:{options:[],loading:!1,error:v,waitingForDependencies:!1}}))})}},[s,e,t,n]),{getFieldState(l){return l.options_from_skill?r[l.name]||{options:[],loading:!1,waitingForDependencies:!1}:{options:L7t(l),loading:!1,waitingForDependencies:!1}}}}function w1(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ng(e,t=""){return typeof e=="string"?e:e==null?t:String(e)}function sc(e){return typeof e=="string"?e:void 0}const j7t=["date","week","month","quarter","year"];function z7t(e){return typeof e=="string"&&j7t.includes(e)}function uve(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 F7t(e){if(!Array.isArray(e))return;const t=e.map(n=>{if(!w1(n))return null;const r=Ng(n.path);return r?{name:Ng(n.name,r.split("/").pop()||r),path:r}:null}).filter(n=>!!n);return t.length>0?t:void 0}function B7t(e){if(!Array.isArray(e))return;const t=e.map(n=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return{value:String(n),label:String(n)};if(!w1(n))return null;const r=n.value??n.key??n.code??n.id??n.name??n.label;return r==null||r===""?null:{value:String(r),label:Ng(n.label??n.title??n.text??n.name??r,String(r))}}).filter(n=>!!n);return t.length>0?t:void 0}function H6(e){const t=w1(e)?e:{};return{name:Ng(t.name),label:Ng(t.label,Ng(t.name)),type:Ng(t.type,"string"),required:typeof t.required=="boolean"?t.required:!0,default:t.default,mock:t.mock,format:sc(t.format),picker:z7t(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(n=>String(n)):void 0,options:B7t(t.options),placeholder:sc(t.placeholder),options_from_skill:sc(t.options_from_skill),options_params:w1(t.options_params)?t.options_params:void 0,file_type:sc(t.file_type),max_files:uve(t.max_files),description:sc(t.description),hint:sc(t.hint??t.label_hint??t.helper_text),file_templates:F7t(t.file_templates),group:sc(t.group??t.group_key??t.form_group),group_label:sc(t.group_label??t.group_title),group_description:sc(t.group_description??t.group_subtitle),ui_component:sc(t.ui_component??t.component??t.render_as),widget:sc(t.widget),address_validation:t.address_validation??t.addressValidation,span:uve(t.span??t.col_span??t.column_span),visible_when:t.visible_when??t.visibleWhen}}function YQ(e){return Array.isArray(e)?e.map(H6).filter(t=>!!t.name):w1(e)?Object.entries(e).map(([t,n])=>w1(n)?H6({...n,name:n.name??t}):H6({name:t,label:t,type:"string",default:n})).filter(t=>!!t.name):[]}function V7t(e){return e instanceof Error?e.message:"上传失败"}function H7t({open:e,playbook:t,onClose:n,onSubmit:r}){const i=m.useMemo(()=>YQ(t==null?void 0:t.input_fields),[t]),[a,o]=m.useState({}),[s,l]=m.useState({}),[c,u]=m.useState({}),d=sj(i,a,o),f=m.useMemo(()=>gT(i,a),[i,a]);m.useEffect(()=>{e&&(o(x1(i,(t==null?void 0:t.initial_params)??{})),l({}),u({}))},[i,e,t==null?void 0:t.initial_params]);const p=m.useCallback((v,y)=>{o(x=>({...x,[v]:y}))},[]),h=m.useCallback((v,y)=>async({file:x,onSuccess:w,onError:S})=>{var _,C;l($=>({...$,[v]:!0}));try{const $=x,E=await Sy($),k=(_=E==null?void 0:E.data)==null?void 0:_.url,T=((C=E==null?void 0:E.data)==null?void 0:C.name)||$.name;if(!k)throw new Error("上传结果缺少文件地址");u(I=>({...I,[k]:T})),o(I=>{if(y<=1)return{...I,[v]:k};const P=Array.isArray(I[v])?I[v]:I[v]?[I[v]]:[];return{...I,[v]:[...P,k]}}),w==null||w(E),Ze.success("上传成功")}catch($){const E=$ instanceof Error?$:new Error(V7t($));S==null||S(E),Ze.error(E.message)}finally{l($=>({...$,[v]:!1}))}},[]),g=()=>{if(!t)return;const v=f.filter(y=>y.required&&If(a[y.name]));if(v.length>0){Ze.warning(`请填写必填参数:${v.map(y=>y.label).join("、")}`);return}r(t,a)};return b.jsxs(X1,{className:"wandox-playbook-params-drawer",title:b.jsxs("div",{className:"wandox-playbook-params-drawer__title",children:[b.jsx("span",{className:"wandox-playbook-params-drawer__title-main",children:"填写执行参数"}),b.jsx("span",{className:"wandox-playbook-params-drawer__title-sub",children:t==null?void 0:t.name})]}),open:e,width:640,destroyOnHidden:!0,maskClosable:!1,onClose:n,footer:b.jsx("div",{className:"wandox-playbook-params-drawer__footer",children:b.jsxs(pa,{children:[b.jsx(Et,{onClick:n,children:"取消"}),b.jsx(Et,{type:"primary",onClick:g,children:"开始执行"})]})}),children:[b.jsxs("div",{className:"wandox-playbook-params-drawer__intro",children:[b.jsx("span",{children:"填写本次运行需要的参数"}),b.jsxs("span",{children:[f.length," 项"]})]}),b.jsxs(pn,{layout:"vertical",className:"wandox-playbook-params-drawer__form",children:[f.map(v=>b.jsx(pn.Item,{required:v.required,label:b.jsxs("span",{className:"wandox-playbook-params-drawer__label",children:[v.label,v.description||v.hint?b.jsx(or,{title:v.description||v.hint,children:b.jsx(ME,{"aria-label":`${v.label}说明`})}):null]}),children:b.jsx(KQ,{field:v,value:a[v.name],uploading:!!s[v.name],fileNameMap:c,getOptionState:d.getFieldState,onChange:p,onUpload:h,onDownloadTemplate:y=>window.open(y.path,"_blank","noopener,noreferrer")})},v.name)),f.length===0?b.jsxs("div",{className:"wandox-playbook-params-drawer__empty",children:[b.jsx(vr,{size:"small"})," 正在读取参数配置"]}):null]})]})}function W7t({playbooks:e,onPlaybookClick:t,onPlaybookDelete:n,activePlaybookId:r}){const{t:i}=ad(),[a,o]=m.useState(""),[s,l]=m.useState(!1),[c,u]=m.useState(null),[d,f]=m.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()))}),h=(y,x)=>{x.stopPropagation(),u(y),l(!0)},g=async()=>{if(c){f(!0);try{await Kmt(c.playbook_id),n==null||n(c.playbook_id),l(!1),u(null)}catch{}finally{f(!1)}}},v=()=>{l(!1),u(null)};return b.jsxs("div",{className:"wandox-solidified-list",children:[b.jsx("div",{className:"wandox-solidified-list-search",children:b.jsx(Kt.Search,{placeholder:"搜索",value:a,onChange:y=>o(y.target.value),allowClear:!0,enterButton:!1})}),b.jsx("div",{className:"wandox-solidified-list-content",children:p.length===0?b.jsx(ei,{description:i(a?"noData":"solidified.empty"),image:ei.PRESENTED_IMAGE_SIMPLE}):b.jsx("div",{className:"wandox-solidified-list-grid",children:p.map(y=>b.jsxs("div",{className:`wandox-solidified-card ${r===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:[b.jsx("div",{className:"wandox-solidified-card-icon",children:b.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2",fill:"none"}),b.jsx("path",{d:"M9 3v18M15 3v18M3 9h18M3 15h18",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor"})]})}),b.jsxs("div",{className:"wandox-solidified-card-content",children:[b.jsx("div",{className:"wandox-solidified-card-name",children:y.name}),y.description&&b.jsx("div",{className:"wandox-solidified-card-desc",children:y.description})]}),b.jsx("button",{type:"button",className:"wandox-solidified-card-delete",onClick:x=>h(y,x),title:i("solidified.delete"),children:b.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:b.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))})}),b.jsx(rr,{title:i("solidified.deleteConfirm"),open:s,onOk:g,onCancel:v,okText:i("confirm"),cancelText:i("cancel"),okButtonProps:{danger:!0,loading:d},children:b.jsxs("p",{children:[i("solidified.deleteConfirm")," 「",c==null?void 0:c.name,"」?"]})})]})}function U7t({inputParams:e,onSearch:t,loading:n=!1}){const[r]=pn.useForm();m.useEffect(()=>{const o={};for(const s of e)s.default!==void 0&&s.default!==null&&s.default!==""&&(o[s.name]=s.default);r.setFieldsValue(o)},[e,r]);const i=()=>{r.validateFields().then(o=>{const s={};for(const l of Object.keys(o)){const c=o[l];c!=null&&c!==""&&(s[l]=c)}t(s)})},a=o=>{const{name:s,type:l,description:c}=o,u={placeholder:c||`请输入${s}`};switch(l){case"integer":return b.jsx(zo,{...u,style:{width:"100%"}});case"array":return b.jsx(Kt,{...u});case"boolean":return b.jsx(Kt,{...u});case"string":default:return b.jsx(Kt,{...u})}};return b.jsx("div",{className:"wandox-solidify-params-form",children:b.jsxs(pn,{form:r,layout:"inline",onFinish:i,style:{marginBottom:16},children:[e.map(o=>b.jsx(pn.Item,{name:o.name,label:o.description||o.name,rules:[{required:o.required,message:`请输入${o.description||o.name}`}],style:{marginBottom:8},children:a(o)},o.name)),b.jsx(pn.Item,{style:{marginBottom:8},children:b.jsx(Et,{type:"primary",htmlType:"submit",loading:n,children:"查询"})})]})})}const D0={fontSize:13,fontWeight:600,color:"#374151",marginBottom:6};function G7t({open:e,onClose:t,onSuccess:n,editingSchedule:r,webhooks:i}){const a=!r,[o,s]=m.useState(""),[l,c]=m.useState(!0),[u,d]=m.useState(""),[f,p]=m.useState(0),[h,g]=m.useState(""),[v,y]=m.useState(""),[x,w]=m.useState(""),[S,_]=m.useState([]),[C,$]=m.useState({}),[E,k]=m.useState(!1),[T,I]=m.useState({}),[P,N]=m.useState({}),[A,M]=m.useState([]),[R,L]=m.useState([]),[z,j]=m.useState(!1),[O,V]=m.useState(!1),B=m.useCallback(async(U,q)=>{var Q;if(!U){_([]),$({});return}k(!0);try{const{data:G}=await BE({playbook_id:U}),X=((Q=G==null?void 0:G.content)==null?void 0:Q.yaml_content)||"";let J=[];if(X)try{const Y=FE.parse(X),Z=Y==null?void 0:Y.params;Array.isArray(Z)&&Z.length>0?J=Z:Z&&typeof Z=="object"&&(J=Object.values(Z))}catch{}if(_(J),J.length>0){const Y={};for(const Z of J){const re=q==null?void 0:q[Z.name];re!==void 0?Y[Z.name]=re:Z.default!==void 0&&Z.default!==null&&(Y[Z.name]=Z.default)}$(Y)}else $({})}catch{_([])}k(!1)},[]),D=m.useCallback(async()=>{var U,q;j(!0);try{const[Q,G]=await Promise.all([Gmt({page:1,page_size:200}),NY({page:1,page_size:100})]),X=((U=Q==null?void 0:Q.data)==null?void 0:U.items)??(Array.isArray(Q==null?void 0:Q.data)?Q==null?void 0:Q.data:[]),J=((q=G==null?void 0:G.data)==null?void 0:q.items)??(Array.isArray(G==null?void 0:G.data)?G==null?void 0:G.data:[]);M(X.map(Y=>({value:Y.playbook_id??String(Y.id),label:Y.name}))),L(J.map(Y=>({value:String(Y.id),label:Y.name})))}catch{}j(!1)},[]);m.useEffect(()=>{if(e)if(p(U=>U+1),I({}),N({}),r){s(r.name||""),c(r.is_active),d(r.cron_expression||"");const U=r.playbook_params||{};$(U),B(r.playbook_id||"",U)}else s(""),c(!0),d(""),g(""),y(""),w(""),_([]),$({}),D()},[e,r,B,D]),m.useEffect(()=>{a&&(h?B(h):(_([]),$({})))},[h,a,B]);const F=(U,q)=>{$(Q=>({...Q,[U]:q}))},H=U=>async({file:q,onSuccess:Q,onError:G})=>{var X,J;I(Y=>({...Y,[U.name]:!0}));try{const Y=q,Z=await Sy(Y),re=(X=Z==null?void 0:Z.data)==null?void 0:X.url,ee=((J=Z==null?void 0:Z.data)==null?void 0:J.name)||Y.name||(re==null?void 0:re.split("/").pop())||"未知文件";if(!re)throw new Error("上传失败");N(oe=>({...oe,[re]:ee})),(U.max_files??1)<=1?F(U.name,re):$(oe=>{const fe=Array.isArray(oe[U.name])?oe[U.name]:oe[U.name]?[oe[U.name]]:[];return{...oe,[U.name]:[...fe,re]}}),Q==null||Q(Z),Ze.success("上传成功")}catch(Y){G==null||G(Y instanceof Error?Y:new Error("文件上传失败")),Ze.error(Y instanceof Error?Y.message:"文件上传失败")}finally{I(Y=>({...Y,[U.name]:!1}))}},W=U=>{const q=C[U.name];if(mT(U))return b.jsx(qQ,{field:U,value:q,onChange:Q=>F(U.name,Q)});switch(U.type){case"string":return b.jsx(Kt.TextArea,{value:q??"",onChange:Q=>F(U.name,Q.target.value),autoSize:{minRows:1,maxRows:4},placeholder:U.description||""});case"number":case"integer":case"float":return b.jsx(zo,{style:{width:"100%"},value:q,onChange:Q=>F(U.name,Q),placeholder:U.description||"",precision:U.type==="integer"?0:void 0,size:"small"});case"boolean":return b.jsx(yo,{size:"small",checked:!!q,onChange:Q=>F(U.name,Q)});case"array":case"object":return b.jsx(Kt.TextArea,{value:typeof q=="string"?q:q!=null?JSON.stringify(q):"",onChange:Q=>F(U.name,Q.target.value),autoSize:{minRows:1,maxRows:4},placeholder:U.description||"JSON 格式"});case"file":{const Q=U.max_files??1,G=Array.isArray(q)?q.map(String):q?[String(q)]:[],X=G.length<Q,J=Y=>{Q<=1?F(U.name,""):F(U.name,G.filter((Z,re)=>re!==Y))};return b.jsxs("div",{children:[G.length>0&&b.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:G.map((Y,Z)=>b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minHeight:30,padding:"4px 8px",border:"1px solid #e5e7eb",borderRadius:6,background:"#fff"},children:[b.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12},children:P[Y]||Y.split("/").pop()||Y}),b.jsx(Et,{type:"text",size:"small",danger:!0,onClick:()=>J(Z),children:"删除"})]},Y))}),X&&b.jsx(zc,{accept:U.file_type||void 0,showUploadList:!1,customRequest:H(U),disabled:!!T[U.name],children:b.jsx(Et,{size:"small",icon:b.jsx(OE,{}),loading:!!T[U.name],children:T[U.name]?"上传中...":"点击上传"})})]})}default:return b.jsx(Kt,{value:q??"",onChange:Q=>F(U.name,Q.target.value),placeholder:U.description||"",size:"small"})}},K=async()=>{if(!o.trim()){Ze.warning("请输入任务名称");return}if(!u.trim()){Ze.warning("请配置调度频率");return}if(a&&!h){Ze.warning("请选择剧本");return}const U=S.length>0?C:void 0;V(!0);try{r?(await REe(r.schedule_id,{},{name:o,cron_expression:u,schedule_type:"custom",is_active:l,playbook_params:U}),Ze.success("更新成功")):(await AEe({},{name:o,agent_id:v,playbook_id:h,webhook_id:x,cron_expression:u,schedule_type:"custom",playbook_params:U}),Ze.success("创建成功")),n(),t()}catch(q){Ze.error((q==null?void 0:q.message)||"操作失败")}finally{V(!1)}};return b.jsxs(rr,{title:null,open:e,onOk:K,onCancel:t,okText:"保存",cancelText:"取消",width:540,confirmLoading:O,closable:!1,children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b.jsx(fa,{style:{fontSize:20,color:"#722ed1"}}),b.jsx("span",{style:{fontSize:16,fontWeight:600,color:"#111827"},children:a?"新增定时任务":"编辑定时任务"})]}),b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b.jsx("span",{style:{fontSize:13,color:l?"#111827":"#9ca3af"},children:l?"已启用":"已禁用"}),b.jsx(yo,{checked:l,onChange:c})]})]}),b.jsxs("div",{style:{marginBottom:16},children:[b.jsxs("div",{style:D0,children:["任务名称 ",b.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),b.jsx(Kt,{value:o,onChange:U=>s(U.target.value),placeholder:"请输入任务名称",style:{borderRadius:8}})]}),a&&b.jsxs(vr,{spinning:z,children:[b.jsxs("div",{style:{marginBottom:16},children:[b.jsxs("div",{style:D0,children:["剧本 ",b.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),b.jsx(tn,{style:{width:"100%"},value:h||void 0,onChange:U=>g(U),options:A,placeholder:"请选择剧本",showSearch:!0,filterOption:(U,q)=>{var Q;return(Q=q==null?void 0:q.label)==null?void 0:Q.toLowerCase().includes(U.toLowerCase())}})]}),b.jsxs("div",{style:{marginBottom:16},children:[b.jsx("div",{style:D0,children:"智能体"}),b.jsx(tn,{style:{width:"100%"},value:v||void 0,onChange:U=>y(U),options:R,placeholder:"请选择智能体(可选)",showSearch:!0,allowClear:!0,filterOption:(U,q)=>{var Q;return(Q=q==null?void 0:q.label)==null?void 0:Q.toLowerCase().includes(U.toLowerCase())}})]}),b.jsxs("div",{style:{marginBottom:16},children:[b.jsx("div",{style:D0,children:"通知 Webhook"}),b.jsx(tn,{style:{width:"100%"},value:x||void 0,onChange:U=>w(U),options:i.map(U=>({value:U.webhook_id,label:U.name})),placeholder:"请选择 Webhook(可选)",allowClear:!0})]})]}),b.jsxs("div",{style:{marginBottom:16},children:[b.jsx("div",{style:D0,children:"调度频率"}),b.jsx(HQ,{defaultValue:r==null?void 0:r.cron_expression,onChange:U=>d(U)},f)]}),E&&b.jsxs("div",{style:{textAlign:"center",padding:"12px 0"},children:[b.jsx(vr,{size:"small"}),b.jsx("span",{style:{marginLeft:8,fontSize:12,color:"#9ca3af"},children:"加载参数配置..."})]}),!E&&S.length>0&&b.jsxs("div",{style:{marginBottom:16},children:[b.jsx("div",{style:D0,children:"执行参数"}),b.jsx("div",{style:{background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:8,padding:"12px 16px"},children:S.map(U=>b.jsxs("div",{style:{marginBottom:12},children:[b.jsxs("div",{style:{fontSize:12,fontWeight:500,color:"#374151",marginBottom:4},children:[U.label||U.name,U.required&&b.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),U.description&&b.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginBottom:4},children:U.description}),W(U)]},U.name))})]})]})}const q7t={daily:"每天",weekly:"每周",monthly:"每月",workday:"工作日",custom:"自定义"},K7t={1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六",7:"周日",0:"周日"};function Y7t(e){const t=rj(e),n=`${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=>K7t[i]||"").filter(Boolean).join("、")} ${n}`;case"month":return t.interval===1?`每月 ${t.monthDay} 号 ${n}`:`每 ${t.interval} 月 ${t.monthDay} 号 ${n}`;case"year":return`每年 ${t.yearMonth} 月 ${t.yearDay} 日 ${n}`;case"day":return t.interval===1?`每天 ${n}`:`每 ${t.interval} 天 ${n}`;case"custom":return t.customCron.trim()?`自定义:${t.customCron.trim()}`:e;default:return e}}const X7t=({className:e})=>{const[t,n]=m.useState([]),[r,i]=m.useState(!1),[a,o]=m.useState(!1),[s,l]=m.useState(null),[c]=pn.useForm(),[u,d]=m.useState(),[f,p]=m.useState([]),[h,g]=m.useState(!1),[v,y]=m.useState(!1),[x,w]=m.useState(null);m.useEffect(()=>{_(),P()},[]);const S=[{label:"钉钉",value:"dingtalk"},{label:"飞书",value:"feishu"},{label:"企业微信",value:"wecom"}],_=async()=>{try{i(!0);const L=await ZO({});L!=null&&L.data&&n(L.data)}catch(L){Ze.error((L==null?void 0:L.message)||"加载失败")}finally{i(!1)}},C=()=>{l(null),c.resetFields(),d(void 0),o(!0)},$=async L=>{try{i(!0);const z=await tgt(L.webhook_id,{}),j=(z==null?void 0:z.data)||L;l(j),d(j.platform),c.setFieldsValue({...j,notify_time:j.notify_start_time&&j.notify_end_time?[In(j.notify_start_time,"HH:mm:ss"),In(j.notify_end_time,"HH:mm:ss")]:void 0}),o(!0)}catch(z){Ze.error((z==null?void 0:z.message)||"获取详情失败")}finally{i(!1)}},E=async L=>{try{i(!0),await igt(L.webhook_id,{}),Ze.success("测试消息发送成功")}catch(z){Ze.error((z==null?void 0:z.message)||"测试失败")}finally{i(!1)}},k=L=>{rr.confirm({title:"确认删除",content:`确定要删除 Webhook "${L.name}" 吗?`,okText:"确定",cancelText:"取消",onOk:async()=>{try{await rgt(L.webhook_id,{}),Ze.success("删除成功"),_()}catch(z){Ze.error((z==null?void 0:z.message)||"删除失败")}}})},T=async()=>{var L,z,j,O;try{const V=await c.validateFields();i(!0);const B={name:V.name,description:V.description,platform:V.platform,webhook_url:V.webhook_url,secret:V.secret,notify_start_time:(z=(L=V.notify_time)==null?void 0:L[0])==null?void 0:z.format("HH:mm:ss"),notify_end_time:(O=(j=V.notify_time)==null?void 0:j[1])==null?void 0:O.format("HH:mm:ss"),is_active:V.is_active,is_default:V.is_default};s?(await ngt(s.webhook_id,{},B),Ze.success("更新成功")):(await NEe({},B),Ze.success("创建成功")),o(!1),c.resetFields(),_()}catch(V){Ze.error((V==null?void 0:V.message)||"操作失败")}finally{i(!1)}},I=[{title:"名称",dataIndex:"name",key:"name",width:150,render:(L,z)=>{const j={dingtalk:b.jsx(Qft,{style:{color:"#1677ff"}}),feishu:b.jsx(v2e,{style:{color:"#1677ff"}}),wecom:b.jsx(Kpt,{style:{color:"#1677ff"}})};return b.jsxs(pa,{size:4,children:[j[z.platform],b.jsx("span",{children:L})]})}},{title:"描述",dataIndex:"description",key:"description",ellipsis:!0},{title:"通知时段",key:"notify_time",width:150,render:(L,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:80,render:L=>b.jsx("span",{style:{color:L?"#52c41a":"#999"},children:L?"启用":"禁用"})},{title:"默认",dataIndex:"is_default",key:"is_default",width:80,render:L=>L?b.jsx("span",{style:{color:"#1890ff"},children:"是"}):"否"},{title:"操作",key:"action",width:210,render:(L,z)=>b.jsxs(pa,{size:0,children:[b.jsx(Et,{type:"link",size:"small",icon:b.jsx(G$,{}),onClick:()=>$(z),className:"wandox-webhook-action-btn",children:b.jsx("span",{className:"wandox-webhook-action-text",children:"编辑"})}),b.jsx(Et,{type:"link",size:"small",icon:b.jsx(lY,{}),onClick:()=>E(z),className:"wandox-webhook-action-btn",children:b.jsx("span",{className:"wandox-webhook-action-text",children:"测试"})}),b.jsx(Et,{type:"link",size:"small",danger:!0,icon:b.jsx(hf,{}),onClick:()=>k(z),className:"wandox-webhook-action-btn",children:b.jsx("span",{className:"wandox-webhook-action-text",children:"删除"})})]})}],P=async()=>{try{g(!0);const L=await MEe({});if(L!=null&&L.data){const z=Array.isArray(L.data)?L.data:L.data.items||[];p(z)}}catch{}finally{g(!1)}},N=L=>{if(L.cron_expression)return Y7t(L.cron_expression);const z=q7t[L.schedule_type]||L.schedule_type,j=L.schedule_time||"--:--";return`${z} ${j}`},A=L=>{w(L),y(!0)},M=L=>{rr.confirm({title:"确认删除",content:`确定要删除定时任务「${L.name}」吗?`,okText:"确定",cancelText:"取消",onOk:async()=>{try{await DEe(L.schedule_id,{}),Ze.success("删除成功"),P()}catch(z){Ze.error((z==null?void 0:z.message)||"删除失败")}}})},R=[{title:"任务名称",dataIndex:"name",key:"name",width:150,render:L=>b.jsxs(pa,{size:4,children:[b.jsx(fa,{style:{color:"#722ed1"}}),b.jsx("span",{children:L})]})},{title:"调度规则",key:"schedule_desc",width:180,render:(L,z)=>b.jsx("span",{style:{fontFamily:"monospace",fontSize:12},children:N(z)})},{title:"Webhook",dataIndex:"webhook_name",key:"agent_name",width:120,ellipsis:!0,render:L=>L||"-"},{title:"状态",dataIndex:"is_active",key:"is_active",width:70,render:L=>b.jsx(ji,{color:L?"green":"default",children:L?"启用":"禁用"})},{title:"操作",key:"action",width:140,render:(L,z)=>b.jsxs(pa,{size:0,children:[b.jsx(Et,{type:"link",size:"small",icon:b.jsx(G$,{}),onClick:()=>A(z),className:"wandox-webhook-action-btn",children:b.jsx("span",{className:"wandox-webhook-action-text",children:"编辑"})}),b.jsx(Et,{type:"link",size:"small",danger:!0,icon:b.jsx(hf,{}),onClick:()=>M(z),className:"wandox-webhook-action-btn",children:b.jsx("span",{className:"wandox-webhook-action-text",children:"删除"})})]})}];return b.jsxs("div",{className:`wandox-webhook-management ${e||""}`,children:[b.jsx("div",{className:"wandox-webhook-header",children:b.jsx(Et,{type:"primary",size:"middle",icon:b.jsx(Uo,{}),onClick:C,style:{borderRadius:"6px",fontWeight:500,boxShadow:"0 2px 4px rgba(24, 144, 255, 0.2)"},children:"新增"})}),b.jsx(Xo,{size:"small",columns:I,dataSource:t,rowKey:"webhook_id",loading:r,pagination:{pageSize:10,showSizeChanger:!0,showTotal:L=>`共 ${L} 条`},scroll:{x:770}}),b.jsx(RK,{style:{margin:"16px 0 12px"}}),b.jsx("div",{className:"wandox-schedule-section-header",style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:b.jsxs("div",{className:"wandox-schedule-section-title",children:[b.jsx(fa,{style:{color:"#722ed1",marginRight:6}}),"定时任务"]})}),b.jsx(Xo,{size:"small",columns:R,dataSource:f,rowKey:"schedule_id",loading:h,pagination:{pageSize:10,showSizeChanger:!0,showTotal:L=>`共 ${L} 条`},scroll:{x:780}}),b.jsx(rr,{title:s?"编辑 Webhook":"新增 Webhook",open:a,onOk:T,onCancel:()=>{o(!1),c.resetFields()},width:600,confirmLoading:r,okText:"确定",cancelText:"取消",children:b.jsxs(pn,{form:c,layout:"horizontal",initialValues:{is_active:!0,is_default:!1},labelCol:{flex:"0 0 80px"},style:{paddingTop:16},children:[b.jsx(pn.Item,{label:"名称",name:"name",rules:[{required:!0,message:"请输入名称"}],children:b.jsx(Kt,{placeholder:"请输入 Webhook 名称"})}),b.jsx(pn.Item,{label:"描述",name:"description",children:b.jsx(Kt.TextArea,{rows:2,placeholder:"请输入描述(可选)"})}),b.jsx(pn.Item,{label:"平台",name:"platform",rules:[{required:!0,message:"请选择平台"}],children:b.jsx(tn,{options:S,placeholder:"请选择平台",onChange:L=>d(L)})}),b.jsx(pn.Item,{label:"URL",name:"webhook_url",rules:[{required:!0,message:"请输入 Webhook URL"},{type:"url",message:"请输入有效的 URL"}],children:b.jsx(Kt,{placeholder:"https://...",autoComplete:"off"})}),u!=="wecom"&&b.jsx(pn.Item,{label:"签名密钥",name:"secret",rules:[{required:u==="dingtalk"||u==="feishu",message:"请输入签名密钥"}],children:b.jsx(Kt.Password,{placeholder:"请输入签名密钥",autoComplete:"new-password"})}),b.jsx(pn.Item,{label:"通知时段",name:"notify_time",children:b.jsx(Ua.RangePicker,{format:"HH:mm",placeholder:["开始时间","结束时间"],style:{width:"100%"}})}),b.jsx(pn.Item,{label:"启用",name:"is_active",valuePropName:"checked",children:b.jsx(yo,{})}),b.jsx(pn.Item,{label:"设为默认",name:"is_default",valuePropName:"checked",children:b.jsx(yo,{})})]})}),b.jsx(G7t,{open:v,onClose:()=>{y(!1),w(null)},onSuccess:P,editingSchedule:x,webhooks:t})]})},{RangePicker:urn}=ui;function Z7t({open:e,loading:t,playbooks:n,activePlaybookId:r,onClose:i,onPlaybookClick:a,onPlaybookDelete:o}){return b.jsx(X1,{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:b.jsx(W7t,{playbooks:n,onPlaybookClick:a,onPlaybookDelete:o,activePlaybookId:r})})}const Q7t=["智能体对话(不限Token)","默认场景全功能","巡检机器人定时任务"],J7t=["智能体对话","非 ASIN 查询场景","巡检机器人定时任务"];function CC(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function nf(e){return e==null?!1:typeof e=="string"?e.trim().length>0:!0}function eWt(e){if(Array.isArray(e)){if(e.length===0)return null;const t=e.find(n=>CC(n)?Object.keys(n).length>0:nf(n));return CC(t)?t:nf(t)?{value:t}:null}return CC(e)?Object.keys(e).length>0?e:null:nf(e)?{value:e}:null}function Sc(e,t,n=0){if(e){for(const r of t){const i=e[r];if(nf(i))return i}if(!(n>=2))for(const r of Object.values(e)){if(CC(r)){const i=Sc(r,t,n+1);if(nf(i))return i}if(Array.isArray(r))for(const i of r){if(!CC(i))continue;const a=Sc(i,t,n+1);if(nf(a))return a}}}}function lj(e){if(nf(e))return String(e).trim()}function O0(e){const t=lj(e);if(!t)return;const n=t.match(/^(\d{4}-\d{2}-\d{2})/);return(n==null?void 0:n[1])||t}function wU(e){if(!nf(e))return;if(typeof e=="number"&&Number.isFinite(e))return new Intl.NumberFormat("en-US").format(e);const t=String(e).trim(),n=t.replace(/,/g,""),r=Number(n);return n&&Number.isFinite(r)?new Intl.NumberFormat("en-US").format(r):t}function dve(e,t){if(!nf(e))return t;const n=String(e).trim();return["infinite","unlimited","∞"].includes(n.toLowerCase())?"∞ 无限":wU(e)||t}function tWt(e){const t=lj(e==null?void 0:e.package_name);if(!(!t||t==="无限算力年卡"))return t}function nWt(e){const t=lj(Sc(e,["asin_usage","asin_usage_text","asin_used_display","usage_text"]));if(t)return t;const n=wU(Sc(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=wU(Sc(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(!(!n&&!r))return`${n||"-"} / ${r||"-"}`}function rWt(e){const t=Sc(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=Sc(e,["total_asin","asin_total","total_asin_count","asin_total_count","asin_limit","asin_quota","asin_num","total_count","total_num","limit","quota","total"]),r=Number(String(t??"").replace(/,/g,"")),i=Number(String(n??"").replace(/,/g,""));if(!(!Number.isFinite(r)||!Number.isFinite(i)||i<=0))return Math.min(Math.round(r/i*100),100)}function XQ(e){var n,r,i,a,o,s,l;if(!e)return null;const t=eWt(e.competitive_asin_info);return t?{kind:"competitiveAsin",badgeText:"包年权益",packageName:lj(Sc(t,["package_name","packageName","plan_name","benefit_name","name","title","package_type"]))||tWt(e.package_info)||"竞品智能体包年权益",subtitle:"竞品智能体专属权益",remainingLabel:"剩余算力(非ASIN查询):",remainingValue:dve(Sc(t,["token_num","tokenNum","remaining_token","token_remaining","remaining_power","power_remaining"])??((n=e.package_info)==null?void 0:n.token_num),"∞ 无限"),asinUsage:nWt(t),asinUsagePercent:rWt(t),endTime:O0(Sc(t,["end_time","endTime","expire_time","expired_at","expires_at","end_date","package_end_time"]))||O0((r=e.package_info)==null?void 0:r.end_time)||"-",startTime:O0(Sc(t,["start_time","startTime","open_time","opened_at","started_at","start_date","package_start_time"]))||O0((i=e.package_info)==null?void 0:i.start_time)||"-",coverageTitle:"无限算力覆盖范围",coverageItems:J7t}:e.is_free?{kind:"free",badgeText:"无限算力",packageName:((a=e.package_info)==null?void 0:a.package_name)||"无限算力年卡",subtitle:"亚马逊智能体专属权益",remainingLabel:"剩余算力:",remainingValue:dve((o=e.package_info)==null?void 0:o.token_num,"∞ 无限"),endTime:O0((s=e.package_info)==null?void 0:s.end_time)||"2027-03-18",startTime:O0((l=e.package_info)==null?void 0:l.start_time)||"2026-03-18",coverageTitle:"无限算力覆盖范围",coverageItems:Q7t}:null}const iWt=[{label:"钉钉",value:"dingtalk"},{label:"飞书",value:"feishu"},{label:"企业微信",value:"wecom"}];function HOe({open:e,onClose:t,onSuccess:n}){const{t:r}=ad(),[i]=pn.useForm(),[a,o]=m.useState(!1),[s,l]=m.useState(),c=async()=>{try{const d=await i.validateFields();o(!0);const f={name:d.name,platform:d.platform,webhook_url:d.webhook_url,secret:d.secret||void 0},p=await NEe({},f);p!=null&&p.data?(Ze.success(r("webhook.createSuccess")),n({webhook_id:p.data.webhook_id||p.data.id,name:d.name,platform:d.platform}),i.resetFields(),t()):Ze.error(r("webhook.createFailed"))}catch(d){d instanceof Error&&Ze.error(d.message||r("webhook.createFailed"))}finally{o(!1)}},u=()=>{i.resetFields(),l(void 0),t()};return b.jsx(rr,{title:r("webhook.quickAdd"),open:e,onOk:c,onCancel:u,confirmLoading:a,width:480,destroyOnHidden:!0,zIndex:1e4,children:b.jsxs(pn,{form:i,layout:"vertical",preserve:!1,children:[b.jsx(pn.Item,{label:r("webhook.name"),name:"name",rules:[{required:!0,message:r("webhook.nameRequired")}],children:b.jsx(Kt,{placeholder:r("webhook.namePlaceholder")})}),b.jsx(pn.Item,{label:r("webhook.platform"),name:"platform",rules:[{required:!0,message:r("webhook.platformRequired")}],children:b.jsx(tn,{options:iWt,placeholder:r("webhook.platformPlaceholder"),onChange:d=>l(d)})}),b.jsx(pn.Item,{label:"Webhook URL",name:"webhook_url",rules:[{required:!0,message:r("webhook.urlRequired")},{type:"url",message:r("webhook.urlInvalid")}],children:b.jsx(Kt,{placeholder:"https://...",autoComplete:"off"})}),s!=="wecom"&&b.jsx(pn.Item,{label:r("webhook.secret"),name:"secret",rules:[{required:s==="dingtalk"||s==="feishu",message:r("webhook.secretRequired")}],children:b.jsx(Kt.Password,{placeholder:r("webhook.secretPlaceholder"),autoComplete:"new-password"})})]})})}const aWt="https://ai.maiduox.com/#/aitools/operation/product";function oWt(e){const{title:t,widgets:n,ssoDomain:r,ssoToken:i,ssoCompany:a,onExecuteComplete:o,activeAgent:s,agents:l,childAgents:c,externalRobotName:u,externalShowPanel:d,agentSwitcher:f}=e;e.onWidgetsUpdate,e.count,ad();const[p,h]=m.useState(!1),[g,v]=m.useState(!1),[y,x]=m.useState(null),[w,S]=m.useState(null),[_,C]=m.useState("results"),[$,E]=m.useState(!1),[k,T]=m.useState([]),[I,P]=m.useState(null),[N,A]=m.useState({}),[M,R]=m.useState([]),[L,z]=m.useState(!1),[j,O]=m.useState(null),[V,B]=m.useState(void 0),[D,F]=m.useState(!1),[H,W]=m.useState(!1),K=m.useMemo(()=>(c||[]).map(se=>se.name),[c]),U=m.useMemo(()=>!s||s==="default"?null:(l==null?void 0:l.find(ne=>ne.agent_id===s||ne.agent_code===s))||null,[s,l]),q=m.useMemo(()=>XQ(U),[U]);m.useEffect(()=>{S(null)},[s]),m.useEffect(()=>{Q(),c&&c.length>0&&G()},[c]),m.useEffect(()=>{if(d&&(h(!0),u)){const se=K.find(ne=>ne===u);se?S(se):K.length>0}},[d,u,K]);const Q=async()=>{try{const se=await ZO({});se!=null&&se.data&&R(se.data.map(ne=>({webhook_id:ne.webhook_id,name:ne.name,platform:ne.platform})))}catch{}},G=async()=>{try{const se={};await Promise.all(c.map(async ne=>{var ge;try{const be=await ogt(ne.agent_id,{});(ge=be==null?void 0:be.data)!=null&&ge.webhook_id&&(se[ne.agent_id]=be.data.webhook_id)}catch{}})),A(se)}catch{}},X=m.useMemo(()=>w?n.filter(se=>{var be;const ne=(be=se.title)==null?void 0:be.match(/^(.+?)\s*巡检结果$/);return(ne?ne[1]:se.agent_name)===w}):n,[n,w]),J=m.useMemo(()=>{if(!w)return"";const se=(c||[]).find(ne=>ne.name===w);return(se==null?void 0:se.agent_id)||""},[w,c]),Y=r==="maiduo"&&w==="差评监控",Z=se=>{const ne=w===se?null:se;S(ne),ne&&h(!0)},re=se=>{O(se),B(N[se.agent_id]),z(!0)},ee=m.useCallback(async se=>{if(se){E(!0);try{const ne=await Wmt({agent_id:se,limit:50});if(ne!=null&&ne.data&&Array.isArray(ne.data)){const ge=ne.data.map((be,Ce)=>({id:be.id||be.execute_id||`record_${Ce}`,action_name:be.action_name||be.display_name||"未知动作",action_id:be.action_id||"",status:be.status||"pending",created_at:be.created_at||"",completed_at:be.completed_at,action_params:be.action_params,output_type:be.output_type,output_data:be.output_data,outputs:be.outputs,error:be.error})).sort((be,Ce)=>new Date(Ce.created_at).getTime()-new Date(be.created_at).getTime());T(ge)}else T([])}catch{T([])}finally{E(!1)}}},[]),te=se=>{if(!se)return"";try{const ne=new Date(se),ge=ne.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),be=ne.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${ge} ${be}`}catch{return se}},oe=se=>({pending:"等待中",running:"执行中",success:"成功",failed:"失败"})[se]||se,fe=se=>({pending:"wandox-exec-status--pending",running:"wandox-exec-status--running",success:"wandox-exec-status--success",failed:"wandox-exec-status--failed"})[se]||"";m.useEffect(()=>{_==="history"&&J&&ee(J)},[_,J,ee]);const he=async()=>{if(!j||!V){Ze.warning("请选择 Webhook");return}try{F(!0),await agt({},{agent_id:j.agent_id,webhook_id:V}),Ze.success("绑定成功"),z(!1),G()}catch(se){Ze.error((se==null?void 0:se.message)||"绑定失败")}finally{F(!1)}},ye=async()=>{if(j)try{F(!0),await sgt(j.agent_id,{}),Ze.success("解绑成功"),z(!1),B(void 0),G()}catch(se){Ze.error((se==null?void 0:se.message)||"解绑失败")}finally{F(!1)}},Te=se=>{x(se),v(!0)},Ee=()=>{v(!1),x(null)},we=se=>{if(!se)return"";try{const ne=new Date(se),ge=ne.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),be=ne.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${ge}
|
|
769
|
+
${be}`}catch{return se}},le=(se,ne)=>{const ge={high:"#ff4d4f",medium:"#faad14",low:"#52c41a"};return b.jsxs("div",{className:"wandox-timeline-item",children:[b.jsxs("div",{className:"wandox-timeline-dot-wrapper",children:[b.jsx("span",{className:"wandox-timeline-time",style:{whiteSpace:"pre-line"},children:we(se.timestamp||"")}),b.jsx("div",{className:"wandox-timeline-dot",style:{background:ge[se.priority]}}),!ne&&b.jsx("div",{className:"wandox-timeline-line"})]}),b.jsxs("div",{className:"wandox-widget-card",children:[b.jsx("div",{className:"wandox-widget-title",children:se.title}),se.ui_payload&&b.jsx("div",{className:"wandox-widget-content wandox-markdown-content",children:b.jsx(Ci,{payload:se.ui_payload})}),se.actions&&se.actions.length>0&&b.jsx("div",{className:"wandox-widget-actions",children:b.jsxs("button",{type:"button",className:"wandox-widget-view-detail-btn",onClick:()=>Te(se),children:[b.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"img",children:[b.jsx("title",{children:"快速执行"}),b.jsx("path",{d:"M13 2L3 14H12L11 22L21 10H12L13 2Z",fill:"currentColor"})]}),"快速执行 (",se.actions.length,")"]})})]})]},se.id||`${se.type}_${se.title}_${se.timestamp}`)};return b.jsxs("div",{className:"wandox-widget-section",children:[b.jsxs("div",{className:"wandox-section-header",children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f??b.jsx("span",{className:"wandox-widget-section-title",children:t}),q&&b.jsx(W1,{title:b.jsx("div",{style:{paddingBottom:"8px",borderBottom:"1px solid #f0f0f0"},children:b.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},children:[b.jsxs("div",{children:[b.jsx("strong",{children:q.packageName}),b.jsx("div",{style:{color:"#999",fontSize:"11px",fontWeight:400},children:q.subtitle})]}),b.jsx(xv,{count:"生效中",style:{backgroundColor:"#52c41a",fontSize:"10px",lineHeight:"18px",height:"18px",minWidth:"50px"}})]})}),content:b.jsxs("div",{style:{fontSize:"12px",lineHeight:"1.6",minWidth:"280px"},children:[b.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[b.jsx("div",{style:{color:"#999"},children:"套餐类型:"}),b.jsx("strong",{children:q.packageName})]}),q.asinUsage&&b.jsxs("div",{style:{marginBottom:q.asinUsagePercent!=null?"4px":"8px",display:"flex",justifyContent:"space-between",gap:"16px"},children:[b.jsx("div",{style:{color:"#999"},children:"ASIN 已用:"}),b.jsx("strong",{style:{color:"#9444f5"},children:q.asinUsage})]}),q.asinUsagePercent!=null&&b.jsx("div",{style:{marginBottom:"8px"},children:b.jsx("div",{style:{height:"6px",borderRadius:"3px",background:"#f0eaff",overflow:"hidden"},children:b.jsx("div",{style:{height:"100%",width:`${q.asinUsagePercent}%`,borderRadius:"3px",background:"linear-gradient(90deg, #9444f5, #b47aff)",transition:"width 0.3s ease"}})})}),b.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[b.jsx("div",{style:{color:"#999"},children:q.remainingLabel}),b.jsx("strong",{style:{color:"#9444f5",fontWeight:"bold"},children:q.remainingValue})]}),b.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[b.jsx("div",{style:{color:"#999"},children:"到期时间:"}),b.jsx("strong",{children:q.endTime})]}),b.jsxs("div",{style:{marginBottom:"8px",display:"flex",justifyContent:"space-between"},children:[b.jsx("div",{style:{color:"#999"},children:"开通时间:"}),b.jsx("strong",{children:q.startTime})]}),b.jsxs("div",{style:{padding:"8px 12px",background:"#faf8ff",borderRadius:"8px"},children:[b.jsx("div",{style:{marginBottom:"4px",color:"#9444f5",fontSize:"13px",fontWeight:"bold"},children:q.coverageTitle}),b.jsx("div",{style:{fontSize:"11px",color:"#666",lineHeight:"2"},children:q.coverageItems.map(se=>b.jsxs("div",{children:[b.jsx(ff,{style:{marginRight:"6px",color:"#9444f5"}}),se]},se))})]})]}),placement:"bottom",trigger:"hover",children:b.jsx(xv,{count:q.badgeText,style:{backgroundColor:"#9444f5",cursor:"pointer"}})})]}),b.jsx("div",{className:"wandox-inspection-controls",children:b.jsxs("button",{type:"button",className:`wandox-inspection-agent-btn ${p?"wandox-inspection-agent-btn--expanded":""}`,onClick:()=>{p?(h(!1),S(null)):h(!0)},children:[b.jsxs("span",{className:"wandox-inspection-agent-icon",children:[b.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("circle",{cx:"12",cy:"12",r:"4",stroke:"currentColor",strokeWidth:"1.5"}),b.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor"})]}),b.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-1"}),b.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-2"}),b.jsx("span",{className:"wandox-orbit-dot wandox-orbit-dot-3"})]}),b.jsxs("span",{className:"wandox-inspection-agent-text",children:["巡检机器人(",K.length,")"]})]})})]}),p&&b.jsxs("div",{className:"wandox-timeline-list",children:[b.jsxs("div",{className:"wandox-agent-filter-row wandox-agent-filter-row--with-close",children:[b.jsxs("div",{className:"wandox-agent-filter-chips",children:[c.length>0&&b.jsx("button",{type:"button",className:`wandox-agent-filter-chip ${w===null?"active":""}`,onClick:()=>S(null),children:"全部"}),c.map(se=>{const ne=!!N[se.agent_id];return b.jsxs("div",{className:`wandox-agent-filter-chip-compound ${w===se.name?"active":""}`,children:[b.jsx("button",{type:"button",className:"wandox-agent-filter-chip-name",onClick:()=>Z(se.name),children:se.name}),b.jsx("button",{type:"button",className:`wandox-agent-filter-chip-webhook ${ne?"bound":""}`,onClick:()=>re(se),title:ne?"已绑定 Webhook,点击修改":"绑定 Webhook 通知",children:ne?b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"wandox-webhook-dot","aria-hidden":"true"}),b.jsx("span",{className:"wandox-webhook-label",children:"已通知"})]}):b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"wandox-webhook-plus","aria-hidden":"true",children:"+"}),b.jsx("span",{className:"wandox-webhook-label",children:"通知"})]})})]},se.agent_id)})]}),b.jsx("button",{type:"button",className:"wandox-timeline-list-close",onClick:()=>{h(!1),S(null),C("results")},title:"关闭",children:"✕"})]}),Y&&b.jsxs("div",{className:"wandox-negative-review-notice",children:[b.jsx("span",{className:"wandox-negative-review-notice-icon","aria-hidden":"true",children:"ℹ️"}),b.jsxs("span",{children:["差评监控需要先设置需要监控的ASIN,请前往AI工具》",b.jsx("a",{href:aWt,target:"_blank",rel:"noreferrer",className:"wandox-negative-review-notice-link",children:"新老诊断"}),"进行设置。每个asin每一次都需要0.01算力。"]})]}),b.jsx("div",{className:"wandox-timeline-tabs-header",children:b.jsxs("div",{className:"wandox-timeline-tabs-nav",children:[b.jsxs("button",{type:"button",className:`wandox-timeline-tab-btn ${_==="results"?"active":""}`,onClick:()=>C("results"),children:["巡检结果",X.length>0&&b.jsx("span",{className:"wandox-timeline-tab-badge",children:X.length})]}),b.jsx("button",{type:"button",className:`wandox-timeline-tab-btn ${_==="history"?"active":""}`,onClick:()=>C("history"),children:"执行记录"})]})}),_==="results"?b.jsx("div",{className:"wandox-timeline-list-content",children:X.length>0?X.sort((se,ne)=>{const ge=se.timestamp?new Date(se.timestamp).getTime():0;return(ne.timestamp?new Date(ne.timestamp).getTime():0)-ge}).map((se,ne,ge)=>le(se,ne===ge.length-1)):b.jsxs("div",{className:"wandox-empty-state",children:[b.jsx("div",{className:"wandox-empty-icon",children:"�"}),b.jsx("div",{className:"wandox-empty-text",children:w?"没有符合筛选条件的数据":"暂无工作区数据"}),b.jsx("div",{className:"wandox-empty-desc",children:w?"请调整筛选条件":"工作区数据将在这里显示"})]})}):b.jsx("div",{className:"wandox-timeline-list-content wandox-history-panel",children:w?$?b.jsxs("div",{className:"wandox-loading-state",children:[b.jsx("span",{className:"wandox-spinner wandox-spinner--small"}),b.jsx("span",{children:"加载中..."})]}):k.length===0?b.jsx("div",{className:"wandox-empty-state",children:b.jsx("div",{className:"wandox-empty-text",children:"暂无执行记录"})}):b.jsx("div",{className:"wandox-exec-history-list",children:k.map(se=>b.jsxs("div",{className:"wandox-exec-history-item",children:[b.jsxs("div",{className:"wandox-exec-history-header",onClick:()=>P(I===se.id?null:se.id),onKeyDown:ne=>ne.key==="Enter"&&P(I===se.id?null:se.id),role:"button",tabIndex:0,children:[b.jsxs("div",{className:"wandox-exec-history-info",children:[b.jsx("span",{className:"wandox-exec-history-name",children:se.action_name}),b.jsx("span",{className:"wandox-exec-history-time",children:te(se.created_at)})]}),b.jsxs("div",{className:"wandox-exec-history-status-wrapper",children:[b.jsx("span",{className:`wandox-exec-status ${fe(se.status)}`,children:oe(se.status)}),b.jsx("span",{className:"wandox-exec-history-arrow","aria-hidden":"true",children:I===se.id?"▼":"▶"})]})]}),I===se.id&&b.jsxs("div",{className:"wandox-exec-history-detail",children:[se.action_params&&Object.keys(se.action_params).length>0&&b.jsxs("div",{className:"wandox-exec-params",children:[b.jsx("div",{className:"wandox-exec-section-label",children:"执行参数"}),b.jsx("div",{className:"wandox-exec-params-list",children:Object.entries(se.action_params).map(([ne,ge])=>b.jsxs("div",{className:"wandox-exec-param-item",children:[b.jsxs("span",{className:"wandox-exec-param-key",children:[ne,":"]}),b.jsx("span",{className:"wandox-exec-param-value",children:typeof ge=="object"?JSON.stringify(ge):String(ge)})]},ne))})]}),se.error?b.jsxs("div",{className:"wandox-exec-error",children:[b.jsx("span",{className:"wandox-exec-error-label",children:"错误信息:"}),b.jsx("span",{className:"wandox-exec-error-msg",children:se.error})]}):se.output_type&&se.output_data?b.jsxs("div",{className:"wandox-exec-outputs",children:[b.jsx("div",{className:"wandox-exec-section-label",children:"执行结果"}),b.jsx(Ci,{payload:{type:se.output_type,...se.output_data}})]}):se.outputs?b.jsxs("div",{className:"wandox-exec-outputs",children:[b.jsx("div",{className:"wandox-exec-section-label",children:"执行结果"}),b.jsx(Ci,{payload:se.outputs})]}):b.jsx("div",{className:"wandox-exec-no-output",children:"暂无输出结果"})]})]},se.id))}):b.jsxs("div",{className:"wandox-empty-state",children:[b.jsx("div",{className:"wandox-empty-icon",children:"🤖"}),b.jsx("div",{className:"wandox-empty-text",children:"请先选择机器人"}),b.jsx("div",{className:"wandox-empty-desc",children:"在上方选择一个机器人查看执行记录"})]})})]}),b.jsx(vOe,{open:g,title:(y==null?void 0:y.title)||"动作详情",actions:(y==null?void 0:y.actions)||[],widgetId:y==null?void 0:y.id,ssoToken:i,ssoDomain:r,ssoCompany:a,onClose:Ee,onExecuteComplete:o}),b.jsx(rr,{title:b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[b.jsxs("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[b.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"}),b.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"}),b.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"}),b.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"})]}),b.jsx("span",{children:"配置 Webhook 通知"})]}),open:L,onCancel:()=>{z(!1),O(null),B(void 0)},width:520,footer:null,centered:!0,children:b.jsxs("div",{style:{padding:"8px 0"},children:[b.jsxs("div",{style:{marginBottom:"20px",padding:"12px 16px",background:"#f5f7fa",borderRadius:"8px",border:"1px solid #e8eaed"},children:[b.jsx("div",{style:{fontSize:"13px",color:"#666",marginBottom:"4px"},children:"智能体"}),b.jsx("div",{style:{fontSize:"15px",color:"#1a1a1a",fontWeight:500},children:j==null?void 0:j.name})]}),b.jsxs("div",{style:{marginBottom:"20px"},children:[b.jsx("div",{style:{marginBottom:"8px",fontSize:"14px",color:"#333",fontWeight:500},children:"选择 通知地址"}),b.jsx(tn,{style:{width:"100%"},size:"large",placeholder:"请选择 通知地址",value:V,onChange:B,options:M.map(se=>({label:`${se.name} (${se.platform==="dingtalk"?"钉钉":se.platform==="feishu"?"飞书":"企业微信"})`,value:se.webhook_id})),disabled:D,popupRender:se=>b.jsxs(b.Fragment,{children:[se,b.jsx(RK,{style:{margin:"8px 0"}}),b.jsx(pa,{style:{padding:"0 8px 4px"},children:b.jsx(Et,{type:"text",icon:b.jsx("span",{children:"+"}),onClick:()=>W(!0),children:"添加新的通知地址"})})]})}),M.length===0&&b.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:[b.jsx("span",{children:"⚠️"}),b.jsx("span",{children:'暂无可用的 通知地址,请先在"通知配置"中创建'})]})]}),b.jsxs("div",{style:{padding:"12px 16px",background:"#f0f9ff",borderRadius:"8px",border:"1px solid #bae7ff",marginBottom:"20px"},children:[b.jsx("div",{style:{fontSize:"13px",color:"#0958d9",fontWeight:500,marginBottom:"8px"},children:"💡 功能说明"}),b.jsxs("div",{style:{fontSize:"13px",color:"#096dd9",lineHeight:"1.8"},children:[b.jsx("div",{children:"• 绑定后,该智能体执行完成时会自动发送通知"}),b.jsx("div",{children:"• 通知内容包含执行结果和相关信息"}),b.jsx("div",{children:"• 可随时修改或解除绑定"})]})]}),b.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"},children:[N[(j==null?void 0:j.agent_id)||""]&&b.jsx("button",{type:"button",onClick:ye,disabled:D,style:{marginRight:"auto",padding:"8px 20px",border:"1px solid #ff4d4f",borderRadius:"6px",background:"#fff",color:"#ff4d4f",cursor:D?"not-allowed":"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s",opacity:D?.6:1},onMouseEnter:se=>{D||(se.currentTarget.style.background="#fff1f0")},onMouseLeave:se=>{se.currentTarget.style.background="#fff"},children:"解除绑定"}),b.jsx("button",{type:"button",onClick:()=>{z(!1),O(null),B(void 0)},disabled:D,style:{padding:"8px 24px",border:"1px solid #d9d9d9",borderRadius:"6px",background:"#fff",color:"#333",cursor:D?"not-allowed":"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s",opacity:D?.6:1},onMouseEnter:se=>{D||(se.currentTarget.style.background="#fafafa")},onMouseLeave:se=>{se.currentTarget.style.background="#fff"},children:"取消"}),b.jsx("button",{type:"button",onClick:he,disabled:D||!V,style:{padding:"8px 24px",border:"none",borderRadius:"6px",background:D||!V?"#d9d9d9":"#1890ff",color:"#fff",cursor:D||!V?"not-allowed":"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s"},onMouseEnter:se=>{!D&&V&&(se.currentTarget.style.background="#40a9ff")},onMouseLeave:se=>{!D&&V&&(se.currentTarget.style.background="#1890ff")},children:D?"保存中...":"保存"})]})]})}),b.jsx(HOe,{open:H,onClose:()=>W(!1),onSuccess:se=>{R(ne=>[...ne,se]),B(se.webhook_id)}})]})}function Lm(e,t){return e.role!=="assistant"?!1:t.message_id&&e.message_id?e.message_id===t.message_id:e.id===t.id}function fve(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 WOe=new Set(["completed","failed","stopped"]),sWt=new Set(["thinking","recommend"]),vP={running:0,completed:1,failed:2,stopped:3};function SU(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _U(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)&&t>=0?t:void 0}function lWt(e){const t=String(e||"").toLowerCase();return t==="running"||t==="failed"||t==="stopped"?t:"completed"}function UOe(e,t){if(!SU(e))return;const n=typeof e.type=="string"&&e.type.trim()?e.type.trim():void 0;if(!n)return;const r=_U(e.sequence),i=SU(e.data)?e.data:{};return{...typeof e.event_id=="string"&&e.event_id?{event_id:e.event_id}:{},type:n,sequence:r===void 0?t:r,...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 L0(e){return e==null?"":String(e).trim()}function cWt(e,t){const n=L0(e.data.task_id),r=L0(t.data.task_id);if(n&&r)return n===r;const i=L0(e.data.step_index),a=L0(t.data.step_index);if(i&&a)return i===a;const o=L0(e.data.step_name||e.data.title),s=L0(t.data.step_name||t.data.title);return!!(o&&s&&o===s)}function GOe(e){return e.reduce((t,n)=>{if(n.type!=="output")return t.push(n),t;let r=-1;for(let a=t.length-1;a>=0;a-=1)if(t[a].type==="step"&&cWt(n,t[a])){r=a;break}if(r<0)return t.push(n),t;const i=t[r];return t[r]={...i,...n,event_id:i.event_id||n.event_id,type:"step",sequence:i.sequence,data:{...i.data,...n.data}},t},[])}function ZQ(e){if(!SU(e))return;const t=GOe((Array.isArray(e.events)?e.events:[]).map((o,s)=>UOe(o,s+1)).filter(o=>!!o).sort((o,s)=>o.sequence-s.sequence)),n=lWt(e.status),r=e.duration_ms===null?null:_U(e.duration_ms),i=typeof e.started_at=="string"&&e.started_at.trim().length>0;if(t.length===0&&n!=="running"&&r==null&&!i)return;const a=_U(e.total);return{status:n,...e.origin==="live"||e.origin==="history"?{origin:e.origin}:{},duration_ms:r,total:a===void 0?t.length:a,truncated:e.truncated===!0,events:t,...i?{started_at:e.started_at}:{}}}function CU(e=new Date().toISOString()){return{status:"running",origin:"live",duration_ms:0,total:0,truncated:!1,events:[],started_at:e}}function $U(e,t,n=Date.now()){const r=ZQ(e.process)??CU(e.timestamp||new Date(n).toISOString());if(WOe.has(r.status))return e;const i=r.events.reduce((u,d)=>Math.max(u,d.sequence),0)+1,a=UOe({...t,sequence:t.sequence??i,timestamp:t.timestamp||new Date(n).toISOString()},i);if(!a)return e;let o=[...r.events];const s=a.event_id?o.findIndex(u=>u.event_id===a.event_id):-1;s>=0?o[s]={...o[s],...a,sequence:o[s].sequence}:(o.push(a),o.sort((u,d)=>u.sequence-d.sequence)),o=GOe(o);const l=Date.parse(r.started_at||e.timestamp),c=Number.isFinite(l)?Math.max(r.duration_ms||0,n-l):r.duration_ms;return{...e,process:{...r,status:"running",duration_ms:c,total:o.length,events:o}}}function VN(e,t,n=Date.now()){const r=ZQ(e.process);if(!r||WOe.has(r.status)&&vP[r.status]>=vP[t])return e;const i=r.events.filter(c=>!sWt.has(c.type)),a=Date.parse(r.started_at||e.timestamp),o=Number.isFinite(a)?Math.max(0,n-a):void 0,s=r.duration_ms==null?o:o===void 0?r.duration_ms:Math.max(r.duration_ms,o),l=vP[r.status]>vP[t]?r.status:t;return{...e,process:{...r,status:l,duration_ms:s,total:i.length,events:i}}}function EU(e,t){return{...e,content:"",ui_payload:{type:"markdown",content:t,streaming:!0},stream_content_received:!0}}function TU(e,t){var r;const n={message_id:t.messageId||e.message_id,execution_id:t.executionId??e.execution_id,actions:(r=t.actions)!=null&&r.length?t.actions:void 0,execution_status:"completed"};return e.stream_content_received?{...e,...n,content:"",ui_payload:e.ui_payload?{...e.ui_payload,streaming:!1}:e.ui_payload}:{...e,...n,content:t.content||"执行完成",ui_payload:t.payload}}function uWt(e){const t=String(e??"").trim().toLowerCase();return!t||["pending","running","executing","stopping","pending_async","awaiting_async"].includes(t)}function $C(e){if(Array.isArray(e))return e.map($C);if(!e||typeof e!="object")return e;const t=e,n={...t};return Array.isArray(t.children)&&(n.children=t.children.map($C)),(t.type==="step"||t.status!==void 0)&&uWt(t.status)&&(n.status="stopped",t.message||(n.message="任务已停止")),n}function BS(e,t,n){var o;const r=t==="stopped"?"stopped":"error",a=((o=e.process)==null?void 0:o.events.some(s=>s.type===r&&s.data.message===n))?e:$U(e,{type:r,data:{message:n,status:t}});return VN(a,t)}function dWt(e,t,n){return EU(e,t)}function pve(e,t,n=!1){if(t.task_id)for(let r=e.length-1;r>=0;r-=1){const i=e[r];if(i.type==="step"&&i.task_id===t.task_id)return r}if(t.step_index!==void 0)for(let r=e.length-1;r>=0;r-=1){const i=e[r];if(i.type==="step"&&String(i.step_index)===String(t.step_index))return r}if(n)for(let r=e.length-1;r>=0;r-=1){const i=e[r],a=String(i.status||"").toLowerCase();if(i.type==="step"&&["running","pending","executing"].includes(a))return r}return-1}function fWt(e,t){var i;const n=Array.isArray(e.outputs)?[...e.outputs]:[];if(t.type==="step"){const a=pve(n,t);if(a>=0){const o=n[a];n[a]={...o,...t,children:(i=t.children)!=null&&i.length?t.children:o.children||[]}}else n.push({...t,children:t.children||[]});return{...e,outputs:n}}const r=pve(n,t);if(r>=0){const a=n[r],o=Array.isArray(a.children)?[...a.children]:[],s=o.findIndex(c=>c.streaming===!0&&(!t.task_id||!c.task_id||c.task_id===t.task_id)),l=t.content===null&&t.is_final===!0;return s>=0?l?o.splice(s,1):o[s]={...t,streaming:!1}:l||o.push(t),n[r]={...a,task_id:a.task_id||t.task_id,status:t.status||"done",children:o},{...e,outputs:n}}return t.content===null&&t.is_final===!0?e:(n.push(t),{...e,outputs:n})}function QQ(e){const{activeAgent:t,ssoToken:n,ssoDomain:r,ssoCompany:i,defaultParams:a,onMessagesUpdate:o,onRecommendationsUpdate:s}=e,[l,c]=m.useState(!1),[u,d]=m.useState(!1),[f,p]=m.useState(null),h=m.useRef(!1),g=m.useRef(null),v=m.useRef(null),y=m.useRef(null),x=m.useRef(null),w=m.useCallback(()=>!n||!r||!i?(Ze.warning("请先登录 SSO"),!1):!0,[n,r,i]),S=m.useCallback((I,P)=>({id:`msg_${Date.now()}_${Math.random()}`,role:I,content:P,timestamp:new Date().toISOString()}),[]),_=m.useCallback(async I=>{if(!w())return;if(h.current){g.current=I;return}h.current=!0;const{userMsg:P,assistantMsgId:N,assistantMsg:A}=(()=>{var B;const z=Date.now(),j={id:`msg_${z}`,role:"user",content:I.message||"",timestamp:new Date().toISOString(),...(B=I.attachments)!=null&&B.length?{attachments:I.attachments}:{}},O=`msg_${z+1}`,V={id:O,role:"assistant",content:"⏳ 正在思考...",timestamp:new Date().toISOString(),playbook_id:I.playbook_id,execution_status:"executing",process:CU()};return{userMsg:j,assistantMsgId:O,assistantMsg:V}})(),M=I._hideUserMessage===!0;o(z=>M?[...z,A]:[...z,P,A]),c(!0),x.current={assistantMsgId:N};const R=new AbortController;y.current=R;const L=()=>{var z;return y.current===R&&((z=x.current)==null?void 0:z.assistantMsgId)===N};try{const z={...I,agent_id:t,stream:!0,playbook_params:{...I.playbook_params||{}},message:I.message||"",...a||{}},{_hideUserMessage:j,...O}=z,V=await fetch(`${Gi()}/api/v1/agents/chat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"X-Tenant-ID":i,"X-Domain":r},body:JSON.stringify(O),signal:R.signal});if(!V.ok)throw new Error(`HTTP ${V.status}`);await HR(V,{assistantMsgId:N,onMessageId:B=>{if(!L())return;const D=x.current;D&&(D.anchorMessageId=B)},onQueue:B=>{L()&&(p(B),B.status==="waiting"?o(D=>D.map(F=>F.id===N?{...F,content:`⏳ ${B.message}`}:F)):B.status==="ready"&&(p(null),o(D=>D.map(F=>F.id===N?{...F,content:`⏳ ${B.message}`}:F))))},onProgress:B=>{L()&&(p(null),o(D=>D.map(F=>F.id===N?{...F,content:`⏳ ${B}`}:F)))},onProcessEvent:B=>{L()&&o(D=>D.map(F=>F.id===N?$U(F,B):F))},onContent:B=>{L()&&o(D=>D.map(F=>F.id===N?EU(F,B):F))},onComplete:(B,D,F,H,W)=>{L()&&o(K=>K.map(U=>{var q,Q;return U.id!==N||((q=U.process)==null?void 0:q.status)==="failed"||((Q=U.process)==null?void 0:Q.status)==="stopped"?U:VN(TU(U,{content:B,payload:D,actions:F,messageId:H,executionId:W}),"completed")}))},onError:(B,D)=>{L()&&o(F=>{const H=(D==null?void 0:D.cancelled)===!0,W=H?"任务已停止":`❌ ${B}`;return F.map(K=>K.id===N?BS({...K,content:K.content.startsWith("❌")?K.content:W,execution_status:H?"stopped":"failed",outputs:H&&K.outputs?$C(K.outputs):K.outputs},H?"stopped":"failed",H?"任务已停止":B):K)})},onRecommend:B=>{L()&&s(B)},onProposal:B=>{if(!L())return;const D={proposal_id:B.proposal_id,scene:B.scene,message:B.message,options:B.options||[],params:B.params,actions:B.actions};o(F=>F.map(H=>H.id===N?VN({...H,content:"",proposal:D,execution_status:"completed"},"completed"):H))}})}catch(z){(z==null?void 0:z.name)!=="AbortError"&&L()&&o(j=>j.map(O=>O.id===N?BS({...O,content:`❌ 执行出错: ${z.message||"未知错误"}`,execution_status:"failed"},"failed",z.message||"未知错误"):O))}finally{if(y.current===R&&(y.current=null,x.current=null,h.current=!1,c(!1),d(!1),g.current)){const z=g.current;g.current=null,setTimeout(()=>{var j;return(j=v.current)==null?void 0:j.call(v,z)},0)}}},[t,n,r,i,w,S,o,s]);v.current=_;const C=m.useCallback(()=>{g.current=null,p(null);const I=y.current;y.current=null,x.current=null,h.current=!1,c(!1),d(!1),I&&!I.signal.aborted&&I.abort()},[]),$=m.useCallback(async()=>{const I=y.current,P=x.current;if(!I||!P)return;const N=P.assistantMsgId,A=P.anchorMessageId,M=()=>{var R;return y.current===I&&((R=x.current)==null?void 0:R.assistantMsgId)===N};if(!A){Ze.warning("任务编号尚未就绪,请稍后再试");return}if(M()){d(!0),o(R=>R.map(L=>L.id===N?{...L,execution_status:"stopping",content:"正在停止..."}:L));try{const R=await fetch(`${Gi()}/api/v1/agents/chat/stop`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"X-Tenant-ID":i,"X-Domain":r},body:JSON.stringify({message_id:A})});if(!M())return;if(!R.ok)throw new Error(`HTTP ${R.status}`);const L=await R.json().catch(()=>null);if(!M())return;if(L&&L.success===!1)throw new Error(L.message||"停止失败");if(o(z=>z.map(j=>{var O;return j.id===N?BS({...j,message_id:(L==null?void 0:L.stopped_message_id)||((O=L==null?void 0:L.data)==null?void 0:O.stopped_message_id)||j.message_id,execution_status:"stopped",content:"任务已停止",outputs:j.outputs?$C(j.outputs):j.outputs},"stopped","任务已停止"):j})),!M())return;C()}catch(R){if(!M())return;d(!1),o(L=>L.map(z=>z.id===N?{...z,execution_status:"executing"}:z)),Ze.error(`停止失败:${R instanceof Error?R.message:"未知错误"}`)}}},[C,o,i,r,n]),E=m.useCallback(async I=>{const P=I.message_id;if(!P||h.current)return;h.current=!0,c(!0);const N=new Date().toISOString();x.current={assistantMsgId:I.id,anchorMessageId:P};const A=new AbortController;y.current=A;const M=()=>{var R;return y.current===A&&((R=x.current)==null?void 0:R.assistantMsgId)===I.id};o(R=>R.map(L=>Lm(L,I)?{...L,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:CU(N)}:L));try{const R=await fetch(`${Gi()}/api/v1/agents/chat/retrigger`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"X-Tenant-ID":i,"X-Domain":r},body:JSON.stringify({message_id:P,stream:!0}),signal:A.signal});if(!R.ok){const L=await R.json().catch(()=>null),z=[L==null?void 0:L.message,L==null?void 0:L.detail,L==null?void 0:L.error].find(j=>typeof j=="string"&&j.trim());throw R.status===409?new Error(z||"任务仍在执行,请先停止"):R.status>=500?new Error(z||"服务暂时无法完成请求,请稍后重试"):new Error(z||`请求失败(HTTP ${R.status})`)}await HR(R,{assistantMsgId:I.id,onMessageId:L=>{if(!M())return;const z=x.current;z&&(z.anchorMessageId=L)},onProgress:L=>{M()&&o(z=>z.map(j=>Lm(j,I)?{...j,content:L}:j))},onProcessEvent:L=>{M()&&o(z=>z.map(j=>Lm(j,I)?$U(j,L):j))},onContent:L=>{M()&&o(z=>z.map(j=>Lm(j,I)?EU(j,L):j))},onComplete:(L,z,j,O,V)=>{M()&&o(B=>B.map(D=>{var F,H;return!Lm(D,I)||((F=D.process)==null?void 0:F.status)==="failed"||((H=D.process)==null?void 0:H.status)==="stopped"?D:VN({...TU(D,{content:L,payload:z,actions:j,messageId:O,executionId:V}),retrigger_status:void 0,retrigger_error:void 0},"completed")}))},onError:(L,z)=>{M()&&o(j=>j.map(O=>{if(!Lm(O,I))return O;const V=(z==null?void 0:z.cancelled)===!0;return BS({...O,content:V?"任务已停止":"",execution_status:V?"stopped":"failed",retrigger_status:V?void 0:"failed",retrigger_error:V?void 0:L,outputs:V&&O.outputs?$C(O.outputs):O.outputs},V?"stopped":"failed",V?"任务已停止":L)}))},onRecommend:L=>{M()&&s(L)}})}catch(R){if(M()&&!(R instanceof DOMException&&R.name==="AbortError")){const L=R instanceof Error?R.message:"未知错误";o(z=>z.map(j=>Lm(j,I)?{...BS(j,"failed",L),content:"",execution_status:"failed",retrigger_status:"failed",retrigger_error:L}:j))}}finally{y.current===A&&(y.current=null,x.current=null,h.current=!1,c(!1),d(!1))}},[o,s,i,r,n]),k=m.useCallback(async(I,P,N)=>{if(!I.trim()&&(!N||N.length===0)){Ze.error("请输入消息");return}await _({message:I||"",playbook_id:P,...N!=null&&N.length?{attachments:N}:{}})},[_]),T=m.useCallback(async I=>{const{proposal_id:P,proposal_action:N,selected_option_id:A,filled_params:M,messageId:R,proposalMessage:L,optionTitle:z}=I;o(V=>V.map(B=>B.id===R?{...B,proposal_status:N==="confirm"?"confirmed":"rejected"}:B));let j="";if(N==="confirm"){const V=[];if(L&&V.push(L),z&&V.push(`${z}确认执行`),M&&Object.keys(M).length>0){const B=Object.entries(M).map(([D,F])=>`${D}: ${Array.isArray(F)?F.join(","):F}`).join(", ");V.push(`参数{${B}}`)}j=V.join(",")}const O={message:j,agent_id:t,stream:!0,proposal_id:P,proposal_action:N,_hideUserMessage:!0,...a||{}};N==="confirm"&&(O.selected_option_id=A,O.filled_params=M||{}),await _(O)},[t,a,_,o]);return{executing:l,stopping:u,executingRef:h,queueStatus:f,sendMessage:k,executePlaybook:_,respondToProposal:T,stopCurrent:$,retrigger:E,abort:C}}function an(e){return e==null?"":String(e).trim()}function IU(e,t){const n=an(e),r=an(t);return!!(n&&n===r)}function _l(e,t){const n=an(t);return n?IU(e.agent_id,n)||IU(e.agent_code,n):!1}function UR(e,t){return e.find(n=>_l(n,t))}function Jp(e){return an(e==null?void 0:e.agent_id)||an(e==null?void 0:e.agent_code)}function qOe(e,t){return IU(e.playbook_id,t)}function KOe(e){const t=[],n=new Set,r=i=>{if(Array.isArray(i))for(const a of i){const o=an(a==null?void 0:a.playbook_id);!o||n.has(o)||(n.add(o),t.push(a))}};if(r(e==null?void 0:e.playbooks),Array.isArray(e==null?void 0:e.playbook_groups))for(const i of e.playbook_groups)r(i.playbooks);return t}function pWt({open:e,onClose:t,ssoToken:n,ssoDomain:r,ssoCompany:i,initialAgentId:a,initialPlaybookId:o,initialPlaybookParams:s,initialMessage:l,triggerOnce:c=!1,enableCustomerService:u=!1,onReady:d}){const[f,p]=m.useState(""),[h,g]=m.useState([]),[v,y]=m.useState([]),[x,w]=m.useState([]),[S,_]=m.useState([]),[C,$]=m.useState(0),[E,k]=m.useState(1),T=bOe,[I,P]=m.useState(!1),[N,A]=m.useState(!1),[M,R]=m.useState(null),[L,z]=m.useState("1x"),[j,O]=m.useState(!1),[V,B]=m.useState(""),[D,F]=m.useState(""),[H,W]=m.useState(null),K=m.useRef(""),U=m.useMemo(()=>f&&h.find(le=>_l(le,f))||null,[f,h]),q=m.useMemo(()=>XQ(U),[U]),Q=m.useCallback(le=>{R(()=>le)},[]),{executing:G,sendMessage:X,executePlaybook:J,respondToProposal:Y,abort:Z}=QQ({activeAgent:f,ssoToken:n,ssoDomain:r,ssoCompany:i,defaultParams:s,onMessagesUpdate:_,onRecommendationsUpdate:w}),re=m.useCallback(()=>{Z(),_([]),k(1),$(0),w([]),F(""),W(null)},[Z]),ee=m.useMemo(()=>JSON.stringify({agentId:an(a),playbookId:an(o),playbookParams:s??null,message:l??null}),[a,o,s,l]),te=m.useRef(""),oe=m.useCallback(()=>{Z(),A(!1),t()},[Z,t]),fe=m.useCallback(()=>{const le=`https://ecsapi.ecgtool.com/login/sso-login?token=${encodeURIComponent(n)}&menuName=AI智能体`;window.open(le,"_blank","noopener,noreferrer")},[n]);m.useEffect(()=>{e&&ye()},[e]),m.useEffect(()=>{e||(Z(),A(!1))},[e,Z]),m.useEffect(()=>{e&&(te.current&&te.current!==ee&&Z(),te.current=ee)},[e,ee,Z]),m.useEffect(()=>{if(!e||!a||h.length===0)return;const le=UR(h,a);if(!le){const ne=an(a);K.current!==ne&&(Ze.error("指定的智能体不存在,已切换到默认智能体"),K.current=ne);const ge=Jp(h[0]);ge&&an(f)!==ge&&(re(),p(ge));return}if(K.current="",_l(le,f))return;const se=Jp(le);se&&(re(),p(se))},[e,a,h,f,re]),m.useEffect(()=>{f&&(B(""),we())},[f]),m.useEffect(()=>{O(!1)},[e,a,o,s,l]),m.useEffect(()=>{!e||!f||o||l&&(j||(X(l),O(!0)))},[e,f,l,o,c,j,X]);const he=m.useMemo(()=>!!s&&Object.keys(s).length>0,[s]);m.useEffect(()=>{var se;if(!e||!f||!o||j||a&&!h.some(ge=>_l(ge,f)&&_l(ge,a))||!V||V!==f)return;const le=v.find(ne=>qOe(ne,o));if(!le){Ze.error("指定的剧本不存在,已切换到智能体界面"),O(!0);return}if((((se=le.input_fields)==null?void 0:se.length)??0)>0&&!he){W(le);const ne=(le.input_fields??[]).map(ge=>`${ge.label}: `).join(`
|
|
770
770
|
`);F(`${le.name},请提供以下参数:
|
|
771
771
|
${ne}`)}else J({message:l||le.name||"",playbook_id:o,...s?{playbook_params:s}:{}});O(!0)},[e,f,V,v,a,h,o,s,he,l,j,J]),m.useEffect(()=>{d&&d({clearMessages:()=>_([]),getMessages:()=>S,abort:Z,showInspectionResults:le=>{}})},[d,S,Z]);const ye=async()=>{P(!0);try{const{data:le}=await XO({page:1,page_size:99}),se=le||[];if(g(se),!a){const ne=Jp(se[0]);ne&&p(ne)}}catch{}P(!1)},Te=async()=>{_([]),P(!0);try{const{data:le}=await gM({agent_id:f,page:1,page_size:T}),se=(le==null?void 0:le.items)||[];_([...se].reverse()),k(1),$((le==null?void 0:le.total)||0)}catch{}finally{P(!1)}},Ee=async()=>{if(S.length>=C)return;const le=E+1;P(!0);try{const{data:se}=await gM({agent_id:f,page:le,page_size:T}),ne=(se==null?void 0:se.items)||[];if(ne.length>0){const ge=[...ne].reverse();_(be=>[...ge,...be]),k(le),$((se==null?void 0:se.total)||0)}}catch(se){throw se}finally{P(!1)}},we=async()=>{const le=f;P(!0);try{const{data:se}=await PY({agent_id:le});y(KOe(se))}catch{}finally{P(!1),B(le)}};return e?b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"wandox-floating-drawer-mask",onClick:oe,onKeyDown:le=>le.key==="Escape"&&oe(),role:"button",tabIndex:0,"aria-label":"关闭抽屉"}),b.jsxs("div",{className:`wandox-floating-drawer wandox-floating-drawer-${L}`,children:[b.jsxs("div",{className:"wandox-floating-drawer-header",children:[b.jsxs("div",{className:"wandox-floating-drawer-title-group",children:[b.jsx("div",{className:"wandox-floating-drawer-title",children:(U==null?void 0:U.name)||"AI 助手"}),u&&b.jsxs("button",{type:"button",className:"wandox-floating-drawer-service",onClick:fe,title:"联系客服","aria-label":"联系客服",children:[b.jsx(Gft,{}),b.jsx("span",{children:"人工客服"})]}),q&&b.jsx(W1,{title:b.jsx("div",{style:{fontWeight:"bold"},children:b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[b.jsx("span",{children:q.packageName}),b.jsx(xv,{count:"生效中",style:{backgroundColor:"#52c41a",fontSize:"10px",lineHeight:"18px",height:"18px",minWidth:"50px"}})]})}),content:b.jsxs("div",{style:{fontSize:"12px",lineHeight:"1.6",minWidth:"280px"},children:[b.jsxs("div",{style:{marginBottom:"8px"},children:[b.jsx("strong",{children:"套餐类型:"}),q.packageName]}),b.jsx("div",{style:{color:"#999",fontSize:"11px",marginTop:"-4px",marginBottom:"8px"},children:q.subtitle}),q.asinUsage&&b.jsxs("div",{style:{marginBottom:q.asinUsagePercent!=null?"4px":"8px"},children:[b.jsx("strong",{children:"ASIN 已用:"}),b.jsx("span",{style:{color:"#9444f5",fontWeight:"bold"},children:q.asinUsage})]}),q.asinUsagePercent!=null&&b.jsx("div",{style:{marginBottom:"8px"},children:b.jsx("div",{style:{height:"6px",borderRadius:"3px",background:"#f0eaff",overflow:"hidden"},children:b.jsx("div",{style:{height:"100%",width:`${q.asinUsagePercent}%`,borderRadius:"3px",background:"linear-gradient(90deg, #9444f5, #b47aff)",transition:"width 0.3s ease"}})})}),b.jsxs("div",{style:{marginBottom:"8px"},children:[b.jsx("strong",{children:q.remainingLabel}),b.jsx("span",{style:{color:"#52c41a",fontWeight:"bold"},children:q.remainingValue})]}),b.jsxs("div",{style:{marginBottom:"8px"},children:[b.jsx("strong",{children:"到期时间:"}),q.endTime]}),b.jsxs("div",{children:[b.jsx("strong",{children:"开通时间:"}),q.startTime]}),b.jsxs("div",{style:{marginTop:"12px",paddingTop:"8px",borderTop:"1px solid #f0f0f0"},children:[b.jsx("div",{style:{fontSize:"11px",color:"#666",marginBottom:"4px"},children:b.jsxs("strong",{children:[q.coverageTitle,":"]})}),b.jsx("div",{style:{fontSize:"11px",color:"#666",lineHeight:"1.4"},children:q.coverageItems.map(le=>b.jsxs("div",{children:["• ",le]},le))})]})]}),placement:"bottomLeft",trigger:"hover",children:b.jsx(xv,{count:q.badgeText,style:{backgroundColor:"#faad14",fontSize:"10px",lineHeight:"18px",height:"18px",minWidth:"60px",cursor:"pointer"}})})]}),b.jsxs("div",{className:"wandox-floating-drawer-actions",children:[b.jsxs("div",{className:"wandox-floating-drawer-size-group",children:[b.jsx("button",{type:"button",className:`wandox-floating-drawer-size-btn ${L==="1x"?"active":""}`,onClick:()=>z("1x"),title:"1倍大小",children:"1x"}),b.jsx("button",{type:"button",className:`wandox-floating-drawer-size-btn ${L==="2x"?"active":""}`,onClick:()=>z("2x"),title:"2倍大小",children:"2x"}),b.jsx("button",{type:"button",className:`wandox-floating-drawer-size-btn ${L==="fullscreen"?"active":""}`,onClick:()=>z("fullscreen"),title:"全屏",children:b.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[b.jsx("title",{children:"全屏"}),b.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"})]})})]}),b.jsx("button",{type:"button",className:"wandox-floating-drawer-close",onClick:oe,"aria-label":"关闭",children:b.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:[b.jsx("title",{children:"关闭"}),b.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"})]})})]})]}),b.jsxs("div",{className:"wandox-floating-drawer-body wandox-root",children:[b.jsx($Oe,{messages:S,playbooks:v,messagesTotal:C,loadMoreMessages:Ee,loading:I,executing:G,activeAgent:Jp(U)||f,onExecutePlaybook:J,onFillPlaybookParams:le=>{var be;const se={playbook_id:le.playbookId,name:le.playbookName,input_fields:le.inputFields};W(se);const ne=((be=le.inputFields)==null?void 0:be.map(Ce=>`${Ce.label}: `).join(`
|
|
772
772
|
`))||"",ge=`${le.playbookName},请提供以下参数:
|
|
773
773
|
${ne}`;F(ge)},onActionClick:le=>{le.action_id?(A(!0),M&&M({action_id:le.action_id,action_params:le.params})):le.playbook_id&&J({message:le.display_name||"执行",playbook_id:le.playbook_id,...le.params?{playbook_params:le.params}:{}})},onRespondToProposal:Y}),b.jsxs("div",{className:"wandox-floating-drawer-footer",children:[b.jsx(DOe,{playbooks:v,playbookLoading:I,onPlaybookClick:J,onSelectPlaybook:le=>{var ge;W(le);const se=((ge=le.input_fields)==null?void 0:ge.map(be=>`${be.label}: `).join(`
|
|
774
774
|
`))||"",ne=`${le.name},请提供以下参数:
|
|
775
|
-
${se}`;F(ne)},recommendations:x,agentId:f}),b.jsx(UQ,{executing:G,onSend:X,playbooks:v,recommendations:x,value:D,onValueChange:F,selectedPlaybook:H,onSelectedPlaybookChange:W,ssoToken:n,ssoDomain:r,ssoCompany:i})]})]})]}),b.jsx(gOe,{open:N,ssoToken:n,ssoDomain:r,ssoCompany:i,onClose:()=>A(!1),onExecuteAction:Q,onExecuteComplete:Te})]}):null}const YOe=m.createContext(void 0),mWt=()=>{const e=m.useContext(YOe);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e},gWt=({children:e})=>{const[t,n]=m.useState(()=>localStorage.getItem("theme")||"light");m.useEffect(()=>{localStorage.setItem("theme",t),document.documentElement.setAttribute("data-theme",t);const a=document.querySelector('meta[name="theme-color"]');a&&a.setAttribute("content",t==="dark"?"#1a1a1a":"#ffffff")},[t]);const i={theme:t,toggleTheme:()=>{n(a=>a==="light"?"dark":"light")},setTheme:n};return b.jsx(YOe.Provider,{value:i,children:e})};function vWt({children:e,client:t=Fmt}){return b.jsx(Imt,{client:t,children:e})}function EC({children:e,queryClient:t}){return b.jsx(vWt,{client:t,children:b.jsx(gWt,{children:e})})}class XOe{constructor(t,n,r,i=kY()){Be(this,"ballContainer",null);Be(this,"drawerContainer",null);Be(this,"ballRoot",null);Be(this,"drawerRoot",null);Be(this,"ssoToken");Be(this,"ssoDomain");Be(this,"ssoCompany");Be(this,"queryClient");Be(this,"registeredConfig",null);Be(this,"currentConfig",null);Be(this,"drawerMethods",null);Be(this,"state",{drawerOpen:!1});this.ssoToken=t,this.ssoDomain=n,this.ssoCompany=r,this.queryClient=i}registerFloatingBall(t){this.registeredConfig=t,this.enable()}setFloatingBallConfig(t){this.currentConfig={...this.registeredConfig||{},...t}}clearMessages(){this.drawerMethods&&this.drawerMethods.clearMessages()}getMessages(){return this.drawerMethods?this.drawerMethods.getMessages():[]}enable(){this.ballContainer,this.ensureBallRoot(),this.ensureDrawerRoot(),this.renderBall(),this.renderDrawer()}ensureBallRoot(){this.ballContainer&&this.ballRoot||(this.ballContainer=document.createElement("div"),this.ballContainer.id="wandox-floating-ball-root",document.body.appendChild(this.ballContainer),this.ballRoot=qg(this.ballContainer))}ensureDrawerRoot(){this.drawerContainer&&this.drawerRoot||(this.drawerContainer=document.createElement("div"),this.drawerContainer.id="wandox-floating-drawer-root",document.body.appendChild(this.drawerContainer),this.drawerRoot=qg(this.drawerContainer))}renderBall(){this.ballRoot&&this.ballRoot.render(b.jsx(EC,{queryClient:this.queryClient,children:b.jsx(Bmt,{onClick:()=>{const t=this.currentConfig||this.registeredConfig;this.state={drawerOpen:!0,initialAgentId:t==null?void 0:t.agentId,initialPlaybookId:t==null?void 0:t.playbookId,initialPlaybookParams:t==null?void 0:t.playbookParams,initialMessage:t==null?void 0:t.message,triggerOnce:!!this.currentConfig},this.currentConfig&&(this.currentConfig=null),this.renderDrawer()}})}))}openDrawer(t,n,r,i=!0,a,o){(!this.ballContainer||!this.drawerContainer)&&this.enable(),this.openDrawerInternal(t,n,r,i,a,o)}openDrawerOnly(t,n,r,i=!0,a,o){this.ensureDrawerRoot(),this.openDrawerInternal(t,n,r,i,a,o)}openDrawerInternal(t,n,r,i=!0,a,o){var c;const s=i?this.registeredConfig:null,l={drawerOpen:!0,initialAgentId:r??(s==null?void 0:s.agentId),initialPlaybookId:t??(s==null?void 0:s.playbookId),initialPlaybookParams:a??(s==null?void 0:s.playbookParams),initialMessage:n??(s==null?void 0:s.message),enableCustomerService:o};this.shouldInterruptDrawer(l)&&((c=this.drawerMethods)==null||c.abort()),this.state=l,this.renderDrawer()}openDrawerWithPlaybook(t){var r;this.drawerContainer||this.enable();const n={drawerOpen:!0,initialAgentId:t.agentId,initialPlaybookId:t.playbookId,initialPlaybookParams:t.playbookParams,initialMessage:t.message,enableCustomerService:t.enableCustomerService};this.shouldInterruptDrawer(n)&&((r=this.drawerMethods)==null||r.abort()),this.state=n,this.renderDrawer()}closeDrawer(){var t;(t=this.drawerMethods)==null||t.abort(),this.state={...this.state,drawerOpen:!1},this.renderDrawer()}showInspectionResults(t){var n,r;this.drawerMethods&&((r=(n=this.drawerMethods).showInspectionResults)==null||r.call(n,t))}shouldInterruptDrawer(t){return this.state.drawerOpen?this.state.initialAgentId!==t.initialAgentId||this.state.initialPlaybookId!==t.initialPlaybookId||this.state.initialPlaybookParams!==t.initialPlaybookParams||this.state.initialMessage!==t.initialMessage:!1}renderDrawer(){this.drawerRoot&&this.drawerRoot.render(b.jsx(EC,{queryClient:this.queryClient,children:b.jsx(hWt,{open:this.state.drawerOpen,onClose:()=>this.closeDrawer(),ssoToken:this.ssoToken,ssoDomain:this.ssoDomain,ssoCompany:this.ssoCompany,initialAgentId:this.state.initialAgentId,initialPlaybookId:this.state.initialPlaybookId,initialPlaybookParams:this.state.initialPlaybookParams,initialMessage:this.state.initialMessage,triggerOnce:this.state.triggerOnce,enableCustomerService:this.state.enableCustomerService===!0,onReady:t=>{this.drawerMethods=t}})}))}destroy(){var t;(t=this.drawerMethods)==null||t.abort(),this.ballRoot&&(this.ballRoot.unmount(),this.ballRoot=null),this.drawerRoot&&(this.drawerRoot.unmount(),this.drawerRoot=null),this.ballContainer&&(this.ballContainer.remove(),this.ballContainer=null),this.drawerContainer&&(this.drawerContainer.remove(),this.drawerContainer=null)}}const yWt={bottomRight:"bottom-right",bottomLeft:"bottom-left",topRight:"top-right",topLeft:"top-left",center:"center","bottom-right":"bottom-right","bottom-left":"bottom-left","top-right":"top-right","top-left":"top-left"};function bWt(e){return e?yWt[e]:"bottom-right"}function hve(e){if(e!=null)return typeof e=="number"?`${e}px`:e}function xWt(e){return typeof e=="function"?e:()=>e}function wWt(e){return e.outputs?Array.isArray(e.outputs)?e.outputs:[e.outputs]:[]}function mve(e){return!!e&&/^⏳/.test(e.trim())}function kU(e){return!!e&&/^❌/.test(e.trim())}function SWt(e,t,n){if(n)return"执行失败";if(e)return"执行中";const r=[...t].reverse().find(i=>i.role==="assistant");return r?kU(r.content)?"执行失败":"执行完成":"准备中"}function TC(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function GR(...e){const t=e.find(n=>typeof n=="string"&&n.trim());return typeof t=="string"?t:void 0}function PU(e){return(e==null?void 0:e.replace(/\s+/g," ").trim())||""}function NU(e,t=0){if(t>3)return"";if(typeof e=="string")return PU(e);if(!e||typeof e!="object"||Array.isArray(e))return"";const n=e;if(n.type==="step")return"";const r=GR(n.content,n.text,n.body,n.message,n.summary);return r?PU(r):NU(n.content,t+1)}function W6(e,t){const n=NU(e),r=typeof t=="string"?PU(t):NU(t);return n.length<16||r.length<16?!1:n===r||n.includes(r)||r.includes(n)}async function _Wt(e){const t=await e.text();if(t.trim())try{return JSON.parse(t)}catch{return t}}function CWt(e,t){const n=TC(e),r=TC(n==null?void 0:n.data),i=n==null?void 0:n.code;if(!(!((n==null?void 0:n.success)===!1||typeof i=="number"&&i>=400||typeof i=="string"&&/^\d+$/.test(i)&&Number(i)>=400)&&t.ok))return GR(r==null?void 0:r.message,n==null?void 0:n.message,e)||`HTTP ${t.status}`}function $Wt(e){const t=TC(e),n=t&&"data"in t?t.data:e,r=TC(n),i=(r==null?void 0:r.outputs)??(t==null?void 0:t.outputs),a=TC(i),o=GR(r==null?void 0:r.summary,r==null?void 0:r.message,t==null?void 0:t.message)||"执行完成",s=GR(r==null?void 0:r.message_id,t==null?void 0:t.message_id),l=(a==null?void 0:a.actions)??(r==null?void 0:r.actions)??(t==null?void 0:t.actions),c=Array.isArray(l)?l:void 0;return i!=null?{content:o,outputs:i,actions:c,messageId:s}:{content:o,uiPayload:(r==null?void 0:r.ui_payload)??(r==null?void 0:r.payload)??(r==null?void 0:r.result)??n,actions:c,messageId:s}}function ZOe({options:e,ssoToken:t,ssoDomain:n,ssoCompany:r,defaultAgentId:i,defaultPlaybookId:a,popup:o=!1,popupConfig:s,executionMode:l="chat",onClose:c,onReady:u}){const[d,f]=m.useState([]),[p,h]=m.useState([]),[g,v]=m.useState(""),[y,x]=m.useState(),[w,S]=m.useState(!1),[_,C]=m.useState(!1),$=m.useRef(""),E=m.useRef(0),k=m.useRef(null),T=an(e.playbookId)||an(a),I=an(e.agentId)||an(i),P=e.message||"剧本执行",N=e.message||P,A=e.playbookParams||{},M=an(e.sessionId),R=m.useMemo(()=>JSON.stringify({executionMode:l,agentId:I,playbookId:T,playbookParams:A,message:N,sessionId:M}),[l,I,T,A,N,M]),L=m.useCallback(ee=>{f(te=>xWt(ee)(te))},[]),z=m.useCallback(ee=>{h(ee)},[]),{executing:j,executePlaybook:O,abort:V}=QQ({activeAgent:g,ssoToken:t,ssoDomain:n,ssoCompany:r,onMessagesUpdate:L,onRecommendationsUpdate:z}),B=m.useCallback(async()=>{if(!T)return;if(!t||!n||!r){x("请先登录 SSO");return}const ee=E.current+1;E.current=ee;const oe=`msg_${Date.now()+1}`,fe={id:oe,role:"assistant",content:"⏳ 正在执行...",timestamp:new Date().toISOString(),playbook_id:T};k.current&&!k.current.signal.aborted&&k.current.abort(),f([fe]),S(!0);try{const he=new AbortController;k.current=he;const ye=Gi(),Te=await fetch(`${ye}/api/v1/playbooks/run/${encodeURIComponent(T)}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`,"X-Tenant-ID":r,"X-Domain":n},body:JSON.stringify({stream:1,agent_id:g,params:A,...M?{session_id:M}:{}}),signal:he.signal}),Ee=Te.headers.get("content-type")||"";if(!Te.ok||Ee.includes("application/json")){const we=await _Wt(Te),le=CWt(we,Te);if(le){f(ne=>ne.map(ge=>ge.id===oe?{...ge,content:`❌ ${le}`}:ge));return}const se=$Wt(we);f(ne=>ne.map(ge=>ge.id===oe?{...ge,message_id:se.messageId,content:se.content,outputs:se.outputs,ui_payload:se.uiPayload,actions:se.actions&&se.actions.length>0?se.actions:void 0}:ge));return}if(await HR(Te,{assistantMsgId:oe,onQueue:we=>{E.current===ee&&f(le=>le.map(se=>se.id===oe?{...se,content:`⏳ ${we.message}`}:se))},onProgress:we=>{E.current===ee&&f(le=>le.map(se=>se.id===oe?{...se,content:`⏳ ${we}`}:se))},onContent:(we,le)=>{E.current===ee&&f(se=>se.map(ne=>ne.id===oe?fWt(ne,we,le):ne))},onOutput:we=>{E.current===ee&&f(le=>le.map(se=>se.id===oe?pWt(se,we):se))},onComplete:(we,le,se,ne)=>{E.current===ee&&f(ge=>ge.map(be=>be.id===oe?TU(be,{content:we,payload:le,actions:se,messageId:ne}):be))},onError:we=>{E.current===ee&&f(le=>{var ge;const se=le.find(be=>be.id===oe),ne=`❌ ${we}`;return(se==null?void 0:se.content)===ne||(ge=se==null?void 0:se.content)!=null&&ge.startsWith("❌")?le:le.map(be=>be.id===oe?{...be,content:ne}:be)})},onRecommend:we=>{E.current===ee&&h(we)}}),E.current!==ee)return}catch(he){if(E.current!==ee||(he==null?void 0:he.name)==="AbortError")return;const ye=he instanceof Error?he.message:(he==null?void 0:he.message)||"未知错误";f(Te=>Te.map(Ee=>Ee.id===oe?{...Ee,content:`❌ 执行出错: ${ye}`}:Ee))}finally{E.current===ee&&(S(!1),k.current=null)}},[g,T,A,M,r,n,t]),D=m.useCallback((ee=!0)=>{E.current+=1,k.current&&!k.current.signal.aborted&&k.current.abort(),k.current=null,ee&&S(!1)},[]),F=m.useCallback(async()=>{if(g){if(!T){x("缺少 playbookId");return}if(x(void 0),f([]),l==="run"){await B();return}await O({message:N,playbook_id:T,playbook_params:A})}},[g,O,l,N,T,A,B]);m.useEffect(()=>{let ee=!1;return(async()=>{if(x(void 0),I){v(I);return}try{const oe=await XO({page:1,page_size:1});if(ee)return;const fe=Array.isArray(oe.data)?oe.data[0]:void 0,he=Jp(fe);he?v(he):x("缺少 agentId,且未获取到可用智能体")}catch(oe){ee||x(oe instanceof Error?oe.message:"智能体列表加载失败")}})(),()=>{ee=!0}},[I]),m.useEffect(()=>{!g||y||$.current!==R&&($.current=R,F())},[g,R,F,y]);const H=o&&(s==null?void 0:s.minimizable)!==!1,W=m.useCallback(()=>{H&&C(!0)},[H]),K=m.useCallback(()=>{C(!1)},[]);m.useEffect(()=>{const ee=l==="run"?D:V;u==null||u({abort:ee,rerun:()=>{$.current="",F()},minimize:W,restore:K})},[V,D,l,W,u,K,F]),m.useEffect(()=>()=>{l==="run"?D(!1):V()},[V,D,l]);const U=l==="run"?w:j,q=SWt(U,d,y),Q=y||d.some(ee=>kU(ee.content))?"error":U?"running":d.length>0?"done":"idle",G=bWt(s==null?void 0:s.placement),X=(s==null?void 0:s.zIndex)??2147483e3,J=o?{width:hve(s==null?void 0:s.width),height:hve(s==null?void 0:s.height),zIndex:X}:void 0,Y={zIndex:X>0?X-1:X},Z=G==="center"?"bottom-right":G;if(o&&_)return b.jsx("button",{type:"button",className:`wandox-sdk-exec-ball wandox-sdk-exec-ball--${Z} wandox-sdk-exec-ball--${Q}`,style:{zIndex:X},onClick:K,"aria-label":`打开执行弹窗,当前状态:${q}`,title:`剧本执行:${q}`,children:b.jsx("span",{className:"wandox-sdk-exec-ball__surface","aria-hidden":"true",children:b.jsxs("span",{className:"wandox-sdk-exec-ball__status",children:[b.jsx("span",{}),b.jsx("span",{}),b.jsx("span",{})]})})});const re=b.jsxs("div",{className:`wandox-sdk-exec wandox-root${o?` wandox-sdk-exec--popup wandox-sdk-exec--${G}`:""}`,style:J,children:[b.jsxs("div",{className:"wandox-sdk-exec__header",children:[b.jsxs("div",{className:"wandox-sdk-exec__heading",children:[b.jsx("div",{className:"wandox-sdk-exec__title",children:P}),b.jsxs("div",{className:"wandox-sdk-exec__meta",children:[b.jsx("span",{className:`wandox-sdk-exec__status wandox-sdk-exec__status--${Q}`,children:q}),T&&b.jsx("span",{className:"wandox-sdk-exec__id",children:T})]})]}),b.jsxs("div",{className:"wandox-sdk-exec__actions",children:[b.jsx("button",{type:"button",className:"wandox-sdk-exec__icon-btn",onClick:()=>{$.current="",F()},"aria-label":"重跑",title:"重跑",children:b.jsx(yy,{})}),H&&b.jsx("button",{type:"button",className:"wandox-sdk-exec__icon-btn",onClick:W,"aria-label":"缩小",title:"缩小",children:b.jsx(OK,{})}),c&&b.jsx("button",{type:"button",className:"wandox-sdk-exec__close",onClick:c,"aria-label":"关闭",title:"关闭",children:b.jsx(ga,{})})]})]}),b.jsxs("div",{className:"wandox-sdk-exec__body",children:[y?b.jsx("div",{className:"wandox-sdk-exec__error",children:y}):d.length===0?b.jsxs("div",{className:"wandox-sdk-exec__empty",children:[b.jsx("span",{className:"wandox-sdk-exec__spinner"}),b.jsx("span",{children:"正在准备执行"})]}):d.filter(ee=>ee.role==="assistant").map(ee=>{const te=wWt(ee),oe=ee.content&&!mve(ee.content)&&ee.content!=="执行完成",fe=oe?te.filter(ye=>!W6(ye,ee.content)):te,he=!!ee.ui_payload&&!(oe&&W6(ee.ui_payload,ee.content))&&!fe.some(ye=>W6(ye,ee.ui_payload));return b.jsxs("div",{className:"wandox-sdk-exec__message",children:[mve(ee.content)&&b.jsxs("div",{className:"wandox-sdk-exec__progress",children:[b.jsx("span",{className:"wandox-sdk-exec__spinner"}),b.jsx("span",{children:ee.content.replace(/^⏳\s*/,"")})]}),fe.length>0&&b.jsx("div",{className:"wandox-sdk-exec__outputs",children:fe.map((ye,Te)=>b.jsx("div",{className:"wandox-sdk-exec__card",children:b.jsx(Ci,{payload:ye})},`${ee.id}-output-${Te}`))}),he&&b.jsx("div",{className:"wandox-sdk-exec__card",children:b.jsx(Ci,{payload:ee.ui_payload})}),oe&&b.jsx("div",{className:`wandox-sdk-exec__card${kU(ee.content)?" wandox-sdk-exec__card--error":""}`,children:b.jsx(Ci,{payload:ee.content})})]},ee.id)}),p.length>0&&b.jsxs("div",{className:"wandox-sdk-exec__hint",children:["已生成 ",p.length," 条推荐"]})]})]});return o&&(s!=null&&s.mask)?b.jsxs(b.Fragment,{children:[s.maskClosable===!1?b.jsx("div",{className:"wandox-sdk-exec-mask",style:Y,"aria-hidden":"true"}):b.jsx("button",{type:"button",className:"wandox-sdk-exec-mask",style:Y,onClick:c,"aria-label":"关闭执行弹窗"}),re]}):re}const EWt=({tabs:e,defaultActiveIndex:t=0,className:n="",onTabChange:r})=>{const[i,a]=m.useState(t),o=m.useRef(null),s=m.useRef(null);m.useEffect(()=>{(()=>{if(!s.current||!o.current)return;const d=o.current.querySelector('[aria-selected="true"]');if(!d)return;const f=window.getComputedStyle(o.current),p=Number.parseFloat(f.paddingLeft)||0,h=o.current.getBoundingClientRect(),g=d.getBoundingClientRect(),v=g.left-h.left-p,y=g.width;s.current.style.transform=`translateX(${v}px)`,s.current.style.width=`${y}px`})()},[i]),m.useEffect(()=>{const u=()=>{if(!s.current||!o.current)return;const f=o.current.querySelector('[aria-selected="true"]');if(!f)return;const p=window.getComputedStyle(o.current),h=Number.parseFloat(p.paddingLeft)||0,g=o.current.getBoundingClientRect(),v=f.getBoundingClientRect(),y=v.left-g.left-h,x=v.width;s.current.style.transform=`translateX(${y}px)`,s.current.style.width=`${x}px`},d=new ResizeObserver(u);return o.current&&d.observe(o.current),()=>{d.disconnect()}},[]);const l=u=>{u!==i&&(a(u),r==null||r(u,e[u]))},c=u=>{const{key:d}=u,f=e.length;let p=i;switch(d){case"ArrowRight":case"ArrowDown":p=(i+1)%f;break;case"ArrowLeft":case"ArrowUp":p=(i-1+f)%f;break;case"Home":p=0;break;case"End":p=f-1;break;default:return}u.preventDefault(),l(p);const h=o.current;if(h){const g=h.children[p+1];g==null||g.focus()}};return b.jsxs("div",{className:`tabs-component ${n}`,children:[b.jsxs("div",{ref:o,className:"tabs-nav",role:"tablist","aria-label":"Tabs",onKeyDown:c,children:[b.jsx("div",{ref:s,className:"tab-indicator","aria-hidden":"true"}),e.map((u,d)=>b.jsxs("button",{className:"tab-btn",role:"tab","aria-selected":d===i,"aria-controls":`panel-${u.id}`,id:`tab-${u.id}`,tabIndex:d===i?0:-1,type:"button",onClick:()=>l(d),children:[u.icon&&b.jsx("span",{className:"tab-icon",children:u.icon}),b.jsx("span",{children:u.label})]},u.id))]}),b.jsx("div",{className:"tabs-content",children:e.map((u,d)=>b.jsx("section",{className:"tab-panel",role:"tabpanel",id:`panel-${u.id}`,"aria-labelledby":`tab-${u.id}`,"aria-hidden":d!==i,tabIndex:d===i?0:-1,children:u.content},u.id))})]})};function TWt(){const{language:e,setLanguage:t,t:n}=ad(),{theme:r,setTheme:i}=mWt(),[a,o]=m.useState(!1),[s,l]=m.useState(null),[c,u]=m.useState(null),[d,f]=m.useState([]),[p,h]=m.useState([]),[g]=m.useState([In().subtract(6,"day"),In()]);m.useEffect(()=>{v(),y()},[]);const v=async()=>{try{const T=await lgt({});T!=null&&T.data&&l(T.data)}catch{}},y=async()=>{var T,I;if(g)try{o(!0);const P=g[0].format("YYYY-MM-DD"),N=g[1].format("YYYY-MM-DD"),[A,M,R]=await Promise.all([cgt({start_date:P,end_date:N}),ugt({start_date:P,end_date:N}),dgt({start_date:P,end_date:N,limit:50})]);if(A!=null&&A.data&&u(A.data),(T=M==null?void 0:M.data)!=null&&T.items){const L=[...M.data.items].sort((z,j)=>z.stat_date.localeCompare(j.stat_date));f(L)}(I=R==null?void 0:R.data)!=null&&I.items&&h(R.data.items)}catch(P){const N=P instanceof Error?P.message:"加载统计数据失败";Ze.error(N)}finally{o(!1)}},x=()=>{if(d.length<2)return{current:0,trend:"stable",percentage:0};const T=d.slice(-7),I=d.slice(-14,-7),P=T.reduce((M,R)=>M+R.total_tokens,0),N=I.reduce((M,R)=>M+R.total_tokens,0);if(N===0)return{current:P,trend:"stable",percentage:0};const A=(P-N)/N*100;return{current:P,trend:A>0?"positive":A<0?"negative":"stable",percentage:Math.abs(A)}},w=()=>{if(!s||!c)return 0;const T=c.avg_daily_tokens;return T===0?0:Math.floor(s.credits_balance/T)};m.useEffect(()=>{d.length>0&&S()},[d]);const S=()=>{const T=document.getElementById("token-trend-chart");if(!T)return;const I=kL(T),P={tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}},formatter:A=>{const M=Array.isArray(A)?A:[A];if(M.length===0)return"";let R=`<div style="font-weight: 600; margin-bottom: 4px;">${M[0].axisValue}</div>`;for(const L of M){const z=L.seriesName.includes("Token")?L.value.toLocaleString():L.value;R+=`<div style="display: flex; align-items: center; margin: 2px 0;">
|
|
775
|
+
${se}`;F(ne)},recommendations:x,agentId:f}),b.jsx(UQ,{executing:G,onSend:X,playbooks:v,recommendations:x,value:D,onValueChange:F,selectedPlaybook:H,onSelectedPlaybookChange:W,ssoToken:n,ssoDomain:r,ssoCompany:i})]})]})]}),b.jsx(gOe,{open:N,ssoToken:n,ssoDomain:r,ssoCompany:i,onClose:()=>A(!1),onExecuteAction:Q,onExecuteComplete:Te})]}):null}const YOe=m.createContext(void 0),hWt=()=>{const e=m.useContext(YOe);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e},mWt=({children:e})=>{const[t,n]=m.useState(()=>localStorage.getItem("theme")||"light");m.useEffect(()=>{localStorage.setItem("theme",t),document.documentElement.setAttribute("data-theme",t);const a=document.querySelector('meta[name="theme-color"]');a&&a.setAttribute("content",t==="dark"?"#1a1a1a":"#ffffff")},[t]);const i={theme:t,toggleTheme:()=>{n(a=>a==="light"?"dark":"light")},setTheme:n};return b.jsx(YOe.Provider,{value:i,children:e})};function gWt({children:e,client:t=Fmt}){return b.jsx(Imt,{client:t,children:e})}function EC({children:e,queryClient:t}){return b.jsx(gWt,{client:t,children:b.jsx(mWt,{children:e})})}class XOe{constructor(t,n,r,i=kY()){Be(this,"ballContainer",null);Be(this,"drawerContainer",null);Be(this,"ballRoot",null);Be(this,"drawerRoot",null);Be(this,"ssoToken");Be(this,"ssoDomain");Be(this,"ssoCompany");Be(this,"queryClient");Be(this,"registeredConfig",null);Be(this,"currentConfig",null);Be(this,"drawerMethods",null);Be(this,"state",{drawerOpen:!1});this.ssoToken=t,this.ssoDomain=n,this.ssoCompany=r,this.queryClient=i}registerFloatingBall(t){this.registeredConfig=t,this.enable()}setFloatingBallConfig(t){this.currentConfig={...this.registeredConfig||{},...t}}clearMessages(){this.drawerMethods&&this.drawerMethods.clearMessages()}getMessages(){return this.drawerMethods?this.drawerMethods.getMessages():[]}enable(){this.ballContainer,this.ensureBallRoot(),this.ensureDrawerRoot(),this.renderBall(),this.renderDrawer()}ensureBallRoot(){this.ballContainer&&this.ballRoot||(this.ballContainer=document.createElement("div"),this.ballContainer.id="wandox-floating-ball-root",document.body.appendChild(this.ballContainer),this.ballRoot=qg(this.ballContainer))}ensureDrawerRoot(){this.drawerContainer&&this.drawerRoot||(this.drawerContainer=document.createElement("div"),this.drawerContainer.id="wandox-floating-drawer-root",document.body.appendChild(this.drawerContainer),this.drawerRoot=qg(this.drawerContainer))}renderBall(){this.ballRoot&&this.ballRoot.render(b.jsx(EC,{queryClient:this.queryClient,children:b.jsx(Bmt,{onClick:()=>{const t=this.currentConfig||this.registeredConfig;this.state={drawerOpen:!0,initialAgentId:t==null?void 0:t.agentId,initialPlaybookId:t==null?void 0:t.playbookId,initialPlaybookParams:t==null?void 0:t.playbookParams,initialMessage:t==null?void 0:t.message,triggerOnce:!!this.currentConfig},this.currentConfig&&(this.currentConfig=null),this.renderDrawer()}})}))}openDrawer(t,n,r,i=!0,a,o){(!this.ballContainer||!this.drawerContainer)&&this.enable(),this.openDrawerInternal(t,n,r,i,a,o)}openDrawerOnly(t,n,r,i=!0,a,o){this.ensureDrawerRoot(),this.openDrawerInternal(t,n,r,i,a,o)}openDrawerInternal(t,n,r,i=!0,a,o){var c;const s=i?this.registeredConfig:null,l={drawerOpen:!0,initialAgentId:r??(s==null?void 0:s.agentId),initialPlaybookId:t??(s==null?void 0:s.playbookId),initialPlaybookParams:a??(s==null?void 0:s.playbookParams),initialMessage:n??(s==null?void 0:s.message),enableCustomerService:o};this.shouldInterruptDrawer(l)&&((c=this.drawerMethods)==null||c.abort()),this.state=l,this.renderDrawer()}openDrawerWithPlaybook(t){var r;this.drawerContainer||this.enable();const n={drawerOpen:!0,initialAgentId:t.agentId,initialPlaybookId:t.playbookId,initialPlaybookParams:t.playbookParams,initialMessage:t.message,enableCustomerService:t.enableCustomerService};this.shouldInterruptDrawer(n)&&((r=this.drawerMethods)==null||r.abort()),this.state=n,this.renderDrawer()}closeDrawer(){var t;(t=this.drawerMethods)==null||t.abort(),this.state={...this.state,drawerOpen:!1},this.renderDrawer()}showInspectionResults(t){var n,r;this.drawerMethods&&((r=(n=this.drawerMethods).showInspectionResults)==null||r.call(n,t))}shouldInterruptDrawer(t){return this.state.drawerOpen?this.state.initialAgentId!==t.initialAgentId||this.state.initialPlaybookId!==t.initialPlaybookId||this.state.initialPlaybookParams!==t.initialPlaybookParams||this.state.initialMessage!==t.initialMessage:!1}renderDrawer(){this.drawerRoot&&this.drawerRoot.render(b.jsx(EC,{queryClient:this.queryClient,children:b.jsx(pWt,{open:this.state.drawerOpen,onClose:()=>this.closeDrawer(),ssoToken:this.ssoToken,ssoDomain:this.ssoDomain,ssoCompany:this.ssoCompany,initialAgentId:this.state.initialAgentId,initialPlaybookId:this.state.initialPlaybookId,initialPlaybookParams:this.state.initialPlaybookParams,initialMessage:this.state.initialMessage,triggerOnce:this.state.triggerOnce,enableCustomerService:this.state.enableCustomerService===!0,onReady:t=>{this.drawerMethods=t}})}))}destroy(){var t;(t=this.drawerMethods)==null||t.abort(),this.ballRoot&&(this.ballRoot.unmount(),this.ballRoot=null),this.drawerRoot&&(this.drawerRoot.unmount(),this.drawerRoot=null),this.ballContainer&&(this.ballContainer.remove(),this.ballContainer=null),this.drawerContainer&&(this.drawerContainer.remove(),this.drawerContainer=null)}}const vWt={bottomRight:"bottom-right",bottomLeft:"bottom-left",topRight:"top-right",topLeft:"top-left",center:"center","bottom-right":"bottom-right","bottom-left":"bottom-left","top-right":"top-right","top-left":"top-left"};function yWt(e){return e?vWt[e]:"bottom-right"}function hve(e){if(e!=null)return typeof e=="number"?`${e}px`:e}function bWt(e){return typeof e=="function"?e:()=>e}function xWt(e){return e.outputs?Array.isArray(e.outputs)?e.outputs:[e.outputs]:[]}function mve(e){return!!e&&/^⏳/.test(e.trim())}function kU(e){return!!e&&/^❌/.test(e.trim())}function wWt(e,t,n){if(n)return"执行失败";if(e)return"执行中";const r=[...t].reverse().find(i=>i.role==="assistant");return r?kU(r.content)?"执行失败":"执行完成":"准备中"}function TC(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function GR(...e){const t=e.find(n=>typeof n=="string"&&n.trim());return typeof t=="string"?t:void 0}function PU(e){return(e==null?void 0:e.replace(/\s+/g," ").trim())||""}function NU(e,t=0){if(t>3)return"";if(typeof e=="string")return PU(e);if(!e||typeof e!="object"||Array.isArray(e))return"";const n=e;if(n.type==="step")return"";const r=GR(n.content,n.text,n.body,n.message,n.summary);return r?PU(r):NU(n.content,t+1)}function W6(e,t){const n=NU(e),r=typeof t=="string"?PU(t):NU(t);return n.length<16||r.length<16?!1:n===r||n.includes(r)||r.includes(n)}async function SWt(e){const t=await e.text();if(t.trim())try{return JSON.parse(t)}catch{return t}}function _Wt(e,t){const n=TC(e),r=TC(n==null?void 0:n.data),i=n==null?void 0:n.code;if(!(!((n==null?void 0:n.success)===!1||typeof i=="number"&&i>=400||typeof i=="string"&&/^\d+$/.test(i)&&Number(i)>=400)&&t.ok))return GR(r==null?void 0:r.message,n==null?void 0:n.message,e)||`HTTP ${t.status}`}function CWt(e){const t=TC(e),n=t&&"data"in t?t.data:e,r=TC(n),i=(r==null?void 0:r.outputs)??(t==null?void 0:t.outputs),a=TC(i),o=GR(r==null?void 0:r.summary,r==null?void 0:r.message,t==null?void 0:t.message)||"执行完成",s=GR(r==null?void 0:r.message_id,t==null?void 0:t.message_id),l=(a==null?void 0:a.actions)??(r==null?void 0:r.actions)??(t==null?void 0:t.actions),c=Array.isArray(l)?l:void 0;return i!=null?{content:o,outputs:i,actions:c,messageId:s}:{content:o,uiPayload:(r==null?void 0:r.ui_payload)??(r==null?void 0:r.payload)??(r==null?void 0:r.result)??n,actions:c,messageId:s}}function ZOe({options:e,ssoToken:t,ssoDomain:n,ssoCompany:r,defaultAgentId:i,defaultPlaybookId:a,popup:o=!1,popupConfig:s,executionMode:l="chat",onClose:c,onReady:u}){const[d,f]=m.useState([]),[p,h]=m.useState([]),[g,v]=m.useState(""),[y,x]=m.useState(),[w,S]=m.useState(!1),[_,C]=m.useState(!1),$=m.useRef(""),E=m.useRef(0),k=m.useRef(null),T=an(e.playbookId)||an(a),I=an(e.agentId)||an(i),P=e.message||"剧本执行",N=e.message||P,A=e.playbookParams||{},M=an(e.sessionId),R=m.useMemo(()=>JSON.stringify({executionMode:l,agentId:I,playbookId:T,playbookParams:A,message:N,sessionId:M}),[l,I,T,A,N,M]),L=m.useCallback(ee=>{f(te=>bWt(ee)(te))},[]),z=m.useCallback(ee=>{h(ee)},[]),{executing:j,executePlaybook:O,abort:V}=QQ({activeAgent:g,ssoToken:t,ssoDomain:n,ssoCompany:r,onMessagesUpdate:L,onRecommendationsUpdate:z}),B=m.useCallback(async()=>{if(!T)return;if(!t||!n||!r){x("请先登录 SSO");return}const ee=E.current+1;E.current=ee;const oe=`msg_${Date.now()+1}`,fe={id:oe,role:"assistant",content:"⏳ 正在执行...",timestamp:new Date().toISOString(),playbook_id:T};k.current&&!k.current.signal.aborted&&k.current.abort(),f([fe]),S(!0);try{const he=new AbortController;k.current=he;const ye=Gi(),Te=await fetch(`${ye}/api/v1/playbooks/run/${encodeURIComponent(T)}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`,"X-Tenant-ID":r,"X-Domain":n},body:JSON.stringify({stream:1,agent_id:g,params:A,...M?{session_id:M}:{}}),signal:he.signal}),Ee=Te.headers.get("content-type")||"";if(!Te.ok||Ee.includes("application/json")){const we=await SWt(Te),le=_Wt(we,Te);if(le){f(ne=>ne.map(ge=>ge.id===oe?{...ge,content:`❌ ${le}`}:ge));return}const se=CWt(we);f(ne=>ne.map(ge=>ge.id===oe?{...ge,message_id:se.messageId,content:se.content,outputs:se.outputs,ui_payload:se.uiPayload,actions:se.actions&&se.actions.length>0?se.actions:void 0}:ge));return}if(await HR(Te,{assistantMsgId:oe,onQueue:we=>{E.current===ee&&f(le=>le.map(se=>se.id===oe?{...se,content:`⏳ ${we.message}`}:se))},onProgress:we=>{E.current===ee&&f(le=>le.map(se=>se.id===oe?{...se,content:`⏳ ${we}`}:se))},onContent:(we,le)=>{E.current===ee&&f(se=>se.map(ne=>ne.id===oe?dWt(ne,we,le):ne))},onOutput:we=>{E.current===ee&&f(le=>le.map(se=>se.id===oe?fWt(se,we):se))},onComplete:(we,le,se,ne)=>{E.current===ee&&f(ge=>ge.map(be=>be.id===oe?TU(be,{content:we,payload:le,actions:se,messageId:ne}):be))},onError:we=>{E.current===ee&&f(le=>{var ge;const se=le.find(be=>be.id===oe),ne=`❌ ${we}`;return(se==null?void 0:se.content)===ne||(ge=se==null?void 0:se.content)!=null&&ge.startsWith("❌")?le:le.map(be=>be.id===oe?{...be,content:ne}:be)})},onRecommend:we=>{E.current===ee&&h(we)}}),E.current!==ee)return}catch(he){if(E.current!==ee||(he==null?void 0:he.name)==="AbortError")return;const ye=he instanceof Error?he.message:(he==null?void 0:he.message)||"未知错误";f(Te=>Te.map(Ee=>Ee.id===oe?{...Ee,content:`❌ 执行出错: ${ye}`}:Ee))}finally{E.current===ee&&(S(!1),k.current=null)}},[g,T,A,M,r,n,t]),D=m.useCallback((ee=!0)=>{E.current+=1,k.current&&!k.current.signal.aborted&&k.current.abort(),k.current=null,ee&&S(!1)},[]),F=m.useCallback(async()=>{if(g){if(!T){x("缺少 playbookId");return}if(x(void 0),f([]),l==="run"){await B();return}await O({message:N,playbook_id:T,playbook_params:A})}},[g,O,l,N,T,A,B]);m.useEffect(()=>{let ee=!1;return(async()=>{if(x(void 0),I){v(I);return}try{const oe=await XO({page:1,page_size:1});if(ee)return;const fe=Array.isArray(oe.data)?oe.data[0]:void 0,he=Jp(fe);he?v(he):x("缺少 agentId,且未获取到可用智能体")}catch(oe){ee||x(oe instanceof Error?oe.message:"智能体列表加载失败")}})(),()=>{ee=!0}},[I]),m.useEffect(()=>{!g||y||$.current!==R&&($.current=R,F())},[g,R,F,y]);const H=o&&(s==null?void 0:s.minimizable)!==!1,W=m.useCallback(()=>{H&&C(!0)},[H]),K=m.useCallback(()=>{C(!1)},[]);m.useEffect(()=>{const ee=l==="run"?D:V;u==null||u({abort:ee,rerun:()=>{$.current="",F()},minimize:W,restore:K})},[V,D,l,W,u,K,F]),m.useEffect(()=>()=>{l==="run"?D(!1):V()},[V,D,l]);const U=l==="run"?w:j,q=wWt(U,d,y),Q=y||d.some(ee=>kU(ee.content))?"error":U?"running":d.length>0?"done":"idle",G=yWt(s==null?void 0:s.placement),X=(s==null?void 0:s.zIndex)??2147483e3,J=o?{width:hve(s==null?void 0:s.width),height:hve(s==null?void 0:s.height),zIndex:X}:void 0,Y={zIndex:X>0?X-1:X},Z=G==="center"?"bottom-right":G;if(o&&_)return b.jsx("button",{type:"button",className:`wandox-sdk-exec-ball wandox-sdk-exec-ball--${Z} wandox-sdk-exec-ball--${Q}`,style:{zIndex:X},onClick:K,"aria-label":`打开执行弹窗,当前状态:${q}`,title:`剧本执行:${q}`,children:b.jsx("span",{className:"wandox-sdk-exec-ball__surface","aria-hidden":"true",children:b.jsxs("span",{className:"wandox-sdk-exec-ball__status",children:[b.jsx("span",{}),b.jsx("span",{}),b.jsx("span",{})]})})});const re=b.jsxs("div",{className:`wandox-sdk-exec wandox-root${o?` wandox-sdk-exec--popup wandox-sdk-exec--${G}`:""}`,style:J,children:[b.jsxs("div",{className:"wandox-sdk-exec__header",children:[b.jsxs("div",{className:"wandox-sdk-exec__heading",children:[b.jsx("div",{className:"wandox-sdk-exec__title",children:P}),b.jsxs("div",{className:"wandox-sdk-exec__meta",children:[b.jsx("span",{className:`wandox-sdk-exec__status wandox-sdk-exec__status--${Q}`,children:q}),T&&b.jsx("span",{className:"wandox-sdk-exec__id",children:T})]})]}),b.jsxs("div",{className:"wandox-sdk-exec__actions",children:[b.jsx("button",{type:"button",className:"wandox-sdk-exec__icon-btn",onClick:()=>{$.current="",F()},"aria-label":"重跑",title:"重跑",children:b.jsx(yy,{})}),H&&b.jsx("button",{type:"button",className:"wandox-sdk-exec__icon-btn",onClick:W,"aria-label":"缩小",title:"缩小",children:b.jsx(OK,{})}),c&&b.jsx("button",{type:"button",className:"wandox-sdk-exec__close",onClick:c,"aria-label":"关闭",title:"关闭",children:b.jsx(ga,{})})]})]}),b.jsxs("div",{className:"wandox-sdk-exec__body",children:[y?b.jsx("div",{className:"wandox-sdk-exec__error",children:y}):d.length===0?b.jsxs("div",{className:"wandox-sdk-exec__empty",children:[b.jsx("span",{className:"wandox-sdk-exec__spinner"}),b.jsx("span",{children:"正在准备执行"})]}):d.filter(ee=>ee.role==="assistant").map(ee=>{const te=xWt(ee),oe=ee.content&&!mve(ee.content)&&ee.content!=="执行完成",fe=oe?te.filter(ye=>!W6(ye,ee.content)):te,he=!!ee.ui_payload&&!(oe&&W6(ee.ui_payload,ee.content))&&!fe.some(ye=>W6(ye,ee.ui_payload));return b.jsxs("div",{className:"wandox-sdk-exec__message",children:[mve(ee.content)&&b.jsxs("div",{className:"wandox-sdk-exec__progress",children:[b.jsx("span",{className:"wandox-sdk-exec__spinner"}),b.jsx("span",{children:ee.content.replace(/^⏳\s*/,"")})]}),fe.length>0&&b.jsx("div",{className:"wandox-sdk-exec__outputs",children:fe.map((ye,Te)=>b.jsx("div",{className:"wandox-sdk-exec__card",children:b.jsx(Ci,{payload:ye})},`${ee.id}-output-${Te}`))}),he&&b.jsx("div",{className:"wandox-sdk-exec__card",children:b.jsx(Ci,{payload:ee.ui_payload})}),oe&&b.jsx("div",{className:`wandox-sdk-exec__card${kU(ee.content)?" wandox-sdk-exec__card--error":""}`,children:b.jsx(Ci,{payload:ee.content})})]},ee.id)}),p.length>0&&b.jsxs("div",{className:"wandox-sdk-exec__hint",children:["已生成 ",p.length," 条推荐"]})]})]});return o&&(s!=null&&s.mask)?b.jsxs(b.Fragment,{children:[s.maskClosable===!1?b.jsx("div",{className:"wandox-sdk-exec-mask",style:Y,"aria-hidden":"true"}):b.jsx("button",{type:"button",className:"wandox-sdk-exec-mask",style:Y,onClick:c,"aria-label":"关闭执行弹窗"}),re]}):re}const $Wt=({tabs:e,defaultActiveIndex:t=0,className:n="",onTabChange:r})=>{const[i,a]=m.useState(t),o=m.useRef(null),s=m.useRef(null);m.useEffect(()=>{(()=>{if(!s.current||!o.current)return;const d=o.current.querySelector('[aria-selected="true"]');if(!d)return;const f=window.getComputedStyle(o.current),p=Number.parseFloat(f.paddingLeft)||0,h=o.current.getBoundingClientRect(),g=d.getBoundingClientRect(),v=g.left-h.left-p,y=g.width;s.current.style.transform=`translateX(${v}px)`,s.current.style.width=`${y}px`})()},[i]),m.useEffect(()=>{const u=()=>{if(!s.current||!o.current)return;const f=o.current.querySelector('[aria-selected="true"]');if(!f)return;const p=window.getComputedStyle(o.current),h=Number.parseFloat(p.paddingLeft)||0,g=o.current.getBoundingClientRect(),v=f.getBoundingClientRect(),y=v.left-g.left-h,x=v.width;s.current.style.transform=`translateX(${y}px)`,s.current.style.width=`${x}px`},d=new ResizeObserver(u);return o.current&&d.observe(o.current),()=>{d.disconnect()}},[]);const l=u=>{u!==i&&(a(u),r==null||r(u,e[u]))},c=u=>{const{key:d}=u,f=e.length;let p=i;switch(d){case"ArrowRight":case"ArrowDown":p=(i+1)%f;break;case"ArrowLeft":case"ArrowUp":p=(i-1+f)%f;break;case"Home":p=0;break;case"End":p=f-1;break;default:return}u.preventDefault(),l(p);const h=o.current;if(h){const g=h.children[p+1];g==null||g.focus()}};return b.jsxs("div",{className:`tabs-component ${n}`,children:[b.jsxs("div",{ref:o,className:"tabs-nav",role:"tablist","aria-label":"Tabs",onKeyDown:c,children:[b.jsx("div",{ref:s,className:"tab-indicator","aria-hidden":"true"}),e.map((u,d)=>b.jsxs("button",{className:"tab-btn",role:"tab","aria-selected":d===i,"aria-controls":`panel-${u.id}`,id:`tab-${u.id}`,tabIndex:d===i?0:-1,type:"button",onClick:()=>l(d),children:[u.icon&&b.jsx("span",{className:"tab-icon",children:u.icon}),b.jsx("span",{children:u.label})]},u.id))]}),b.jsx("div",{className:"tabs-content",children:e.map((u,d)=>b.jsx("section",{className:"tab-panel",role:"tabpanel",id:`panel-${u.id}`,"aria-labelledby":`tab-${u.id}`,"aria-hidden":d!==i,tabIndex:d===i?0:-1,children:u.content},u.id))})]})};function EWt(){const{language:e,setLanguage:t,t:n}=ad(),{theme:r,setTheme:i}=hWt(),[a,o]=m.useState(!1),[s,l]=m.useState(null),[c,u]=m.useState(null),[d,f]=m.useState([]),[p,h]=m.useState([]),[g]=m.useState([In().subtract(6,"day"),In()]);m.useEffect(()=>{v(),y()},[]);const v=async()=>{try{const T=await lgt({});T!=null&&T.data&&l(T.data)}catch{}},y=async()=>{var T,I;if(g)try{o(!0);const P=g[0].format("YYYY-MM-DD"),N=g[1].format("YYYY-MM-DD"),[A,M,R]=await Promise.all([cgt({start_date:P,end_date:N}),ugt({start_date:P,end_date:N}),dgt({start_date:P,end_date:N,limit:50})]);if(A!=null&&A.data&&u(A.data),(T=M==null?void 0:M.data)!=null&&T.items){const L=[...M.data.items].sort((z,j)=>z.stat_date.localeCompare(j.stat_date));f(L)}(I=R==null?void 0:R.data)!=null&&I.items&&h(R.data.items)}catch(P){const N=P instanceof Error?P.message:"加载统计数据失败";Ze.error(N)}finally{o(!1)}},x=()=>{if(d.length<2)return{current:0,trend:"stable",percentage:0};const T=d.slice(-7),I=d.slice(-14,-7),P=T.reduce((M,R)=>M+R.total_tokens,0),N=I.reduce((M,R)=>M+R.total_tokens,0);if(N===0)return{current:P,trend:"stable",percentage:0};const A=(P-N)/N*100;return{current:P,trend:A>0?"positive":A<0?"negative":"stable",percentage:Math.abs(A)}},w=()=>{if(!s||!c)return 0;const T=c.avg_daily_tokens;return T===0?0:Math.floor(s.credits_balance/T)};m.useEffect(()=>{d.length>0&&S()},[d]);const S=()=>{const T=document.getElementById("token-trend-chart");if(!T)return;const I=kL(T),P={tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}},formatter:A=>{const M=Array.isArray(A)?A:[A];if(M.length===0)return"";let R=`<div style="font-weight: 600; margin-bottom: 4px;">${M[0].axisValue}</div>`;for(const L of M){const z=L.seriesName.includes("Token")?L.value.toLocaleString():L.value;R+=`<div style="display: flex; align-items: center; margin: 2px 0;">
|
|
776
776
|
<span style="display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: ${L.color}; margin-right: 6px;"></span>
|
|
777
777
|
<span style="flex: 1;">${L.seriesName}:</span>
|
|
778
778
|
<span style="font-weight: 600; margin-left: 12px;">${z}</span>
|
|
779
|
-
</div>`}return R}},legend:{data:["输入 Token","输出 Token","调用次数"],top:10,textStyle:{fontSize:12}},grid:{left:"3%",right:"4%",bottom:"8%",top:"15%",containLabel:!0},xAxis:{type:"category",boundaryGap:!1,data:d.map(A=>A.stat_date),axisLine:{lineStyle:{color:"#e8eaed"}},axisLabel:{color:"#5f6368",fontSize:11}},yAxis:[{type:"value",name:"Token 数量",nameTextStyle:{color:"#5f6368",fontSize:11},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:"#5f6368",fontSize:11,formatter:A=>A>=1e6?`${(A/1e6).toFixed(1)}M`:A>=1e3?`${(A/1e3).toFixed(1)}K`:A.toString()},splitLine:{lineStyle:{color:"#f1f3f4",type:"dashed"}}},{type:"value",name:"调用次数",nameTextStyle:{color:"#5f6368",fontSize:11},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:"#5f6368",fontSize:11},splitLine:{show:!1}}],series:[{name:"输入 Token",type:"line",data:d.map(A=>A.total_prompt_tokens),smooth:!0,symbol:"circle",symbolSize:6,lineStyle:{width:2},itemStyle:{color:"#1890ff"},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(24, 144, 255, 0.2)"},{offset:1,color:"rgba(24, 144, 255, 0.02)"}]}}},{name:"输出 Token",type:"line",data:d.map(A=>A.total_completion_tokens),smooth:!0,symbol:"circle",symbolSize:6,lineStyle:{width:2},itemStyle:{color:"#52c41a"},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(82, 196, 26, 0.2)"},{offset:1,color:"rgba(82, 196, 26, 0.02)"}]}}},{name:"调用次数",type:"line",yAxisIndex:1,data:d.map(A=>A.total_calls),smooth:!0,symbol:"circle",symbolSize:6,lineStyle:{width:2},itemStyle:{color:"#722ed1"}}]};I.setOption(P);const N=()=>{I.resize()};return window.addEventListener("resize",N),()=>{window.removeEventListener("resize",N),I.dispose()}},_=x(),C=w(),$=[{id:"overview",label:"总览",icon:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),b.jsx("polyline",{points:"9,22 9,12 15,12 15,22"})]}),content:b.jsxs("div",{className:"settings-overview-content",children:[b.jsxs("header",{className:"panel-header",children:[b.jsx("div",{className:"panel-icon-wrapper",children:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),b.jsx("polyline",{points:"9,22 9,12 15,12 15,22"})]})}),b.jsxs("div",{children:[b.jsx("h2",{className:"panel-title",children:"算力币总览"}),b.jsx("p",{className:"panel-subtitle",children:"算力币余额、使用情况和系统状态一览"})]})]}),b.jsxs("div",{className:"panel-body",children:[b.jsx("p",{children:"算力币是系统中的核心资源,用于AI模型调用和各项服务。以下是您的算力币使用情况和相关统计信息。"}),b.jsxs("div",{className:"credits-overview-grid",children:[s?b.jsxs("div",{className:"credits-main-card",children:[b.jsx("div",{className:"credits-icon",children:b.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:b.jsx("path",{d:"M12 2L2 7v10c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V7l-10-5z"})})}),b.jsxs("div",{className:"credits-info",children:[b.jsx("div",{className:"credits-title",children:"算力币余额"}),b.jsx("div",{className:"credits-value",children:s.credits_balance.toFixed(2)}),b.jsx("div",{className:"credits-desc",children:"可用余额"})]})]}):b.jsxs("div",{className:"credits-main-card",children:[b.jsx("div",{className:"credits-icon",children:b.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:b.jsx("path",{d:"M12 2L2 7v10c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V7l-10-5z"})})}),b.jsxs("div",{className:"credits-info",children:[b.jsx("div",{className:"credits-title",children:"算力币余额"}),b.jsx("div",{className:"credits-value",children:"--"}),b.jsx("div",{className:"credits-desc",children:"加载中..."})]})]}),b.jsxs("div",{className:"grid grid-4",children:[b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:s?s.credits_total.toFixed(2):"--"}),b.jsx("div",{className:"stat-label",children:"总算力币"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:s?s.credits_use.toFixed(2):"--"}),b.jsx("div",{className:"stat-label",children:"已使用量"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:s?s.credits_balance.toFixed(2):"--"}),b.jsx("div",{className:"stat-label",children:"剩余数量"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:s?`${(s.credits_use/s.credits_total*100).toFixed(1)}%`:"--"}),b.jsx("div",{className:"stat-label",children:"使用率"})]})]})]}),b.jsxs("div",{className:"credits-details",children:[b.jsx("h3",{children:"使用详情"}),b.jsxs("div",{className:"grid grid-3",children:[b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"本月消耗"}),b.jsx("div",{className:"detail-value",children:_.current.toLocaleString()}),b.jsxs("div",{className:`detail-trend ${_.trend}`,children:[_.trend==="positive"?"↑":_.trend==="negative"?"↓":"→"," ",_.percentage.toFixed(1),"%"]})]}),b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"日均消耗"}),b.jsx("div",{className:"detail-value",children:c?c.avg_daily_tokens.toLocaleString():"--"}),b.jsx("div",{className:"detail-trend stable",children:"→ 0%"})]}),b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"预计可用天数"}),b.jsx("div",{className:"detail-value",children:C}),b.jsx("div",{className:"detail-trend stable",children:"→ 0%"})]})]})]})]})]})},{id:"tokens",label:"算力统计",icon:b.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:b.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})}),content:b.jsxs("div",{className:"settings-tokens-content",children:[b.jsxs("header",{className:"panel-header",children:[b.jsx("div",{className:"panel-icon-wrapper",children:b.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:b.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})})}),b.jsxs("div",{children:[b.jsx("h2",{className:"panel-title",children:"算力统计"}),b.jsx("p",{className:"panel-subtitle",children:"AI模型调用的详细数据分析和趋势监控"})]})]}),b.jsxs("div",{className:"panel-body",children:[c&&b.jsx("div",{className:"token-overview-cards",children:b.jsxs("div",{className:"grid grid-4",children:[b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:c.total_tokens.toLocaleString()}),b.jsx("div",{className:"stat-label",children:"总 Token 消耗"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:c.total_calls.toLocaleString()}),b.jsx("div",{className:"stat-label",children:"总调用次数"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsxs("div",{className:"stat-value",children:[c.success_count,"/",c.total_calls]}),b.jsx("div",{className:"stat-label",children:"成功/总次数"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:c.avg_daily_tokens.toLocaleString()}),b.jsx("div",{className:"stat-label",children:"日均 Token 消耗"})]})]})}),b.jsxs("div",{className:"token-chart-section",children:[b.jsx("h3",{children:"Token 使用趋势"}),b.jsx("div",{id:"token-trend-chart",style:{width:"100%",height:350,marginBottom:24}})]}),p.length>0&&b.jsxs("div",{className:"agent-stats-section",children:[b.jsx("h3",{children:"Agent 使用统计"}),b.jsx("div",{className:"agent-stats-grid",children:p.slice(0,6).map(T=>b.jsxs("div",{className:"agent-stat-card",children:[b.jsx("div",{className:"agent-name",children:T.agent_name||"-"}),b.jsx("div",{className:"agent-tokens",children:T.total_tokens.toLocaleString()}),b.jsxs("div",{className:"agent-calls",children:[T.total_calls," 次调用"]}),b.jsxs("div",{className:"agent-success-rate",children:["成功率:"," ",T.total_calls>0?(T.success_count/T.total_calls*100).toFixed(1):0,"%"]})]},T.agent_id))})]}),c&&b.jsxs("div",{className:"detailed-stats",children:[b.jsx("h3",{children:"详细统计"}),b.jsxs("div",{className:"grid grid-3",children:[b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"输入 Token"}),b.jsx("div",{className:"detail-value",children:c.total_prompt_tokens.toLocaleString()}),b.jsx("div",{className:"detail-desc",children:"用户输入的总 Token 数"})]}),b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"输出 Token"}),b.jsx("div",{className:"detail-value",children:c.total_completion_tokens.toLocaleString()}),b.jsx("div",{className:"detail-desc",children:"AI生成的总 Token 数"})]}),b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"统计天数"}),b.jsx("div",{className:"detail-value",children:c.days}),b.jsx("div",{className:"detail-desc",children:"数据统计的时间范围"})]})]})]}),!c&&!a&&b.jsx("div",{className:"loading-state",children:b.jsx("div",{className:"loading-message",children:"正在加载统计数据..."})})]})]})},{id:"notifications",label:"通知配置",icon:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),b.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),content:b.jsxs("div",{className:"settings-notifications-content",children:[b.jsxs("header",{className:"panel-header",children:[b.jsx("div",{className:"panel-icon-wrapper",children:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),b.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),b.jsxs("div",{children:[b.jsx("h2",{className:"panel-title",children:"通知配置"}),b.jsx("p",{className:"panel-subtitle",children:"配置Webhook通知,实时接收系统重要事件"})]})]}),b.jsx("div",{className:"panel-body",children:b.jsx(Z7t,{})})]})},{id:"settings",label:"系统设置",icon:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("circle",{cx:"12",cy:"12",r:"3"}),b.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),content:b.jsxs("div",{className:"settings-system-content",children:[b.jsxs("header",{className:"panel-header",children:[b.jsx("div",{className:"panel-icon-wrapper",children:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("circle",{cx:"12",cy:"12",r:"3"}),b.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),b.jsxs("div",{children:[b.jsx("h2",{className:"panel-title",children:"系统设置"}),b.jsx("p",{className:"panel-subtitle",children:"配置系统基础参数和高级选项"})]})]}),b.jsx("div",{className:"panel-body",children:b.jsxs("div",{className:"settings-section",children:[b.jsxs("div",{className:"settings-item",children:[b.jsxs("div",{className:"settings-item-info",children:[b.jsx("h4",{children:"界面语言"}),b.jsx("p",{children:"选择系统显示语言,切换后立即生效"})]}),b.jsx("div",{className:"settings-item-control",children:b.jsx(tn,{value:e,onChange:T=>t(T),style:{width:180},options:[{label:n("settings.language.zh"),value:"zh-CN"},{label:n("settings.language.en"),value:"en-US"}]})})]}),b.jsxs("div",{className:"settings-item",children:[b.jsxs("div",{className:"settings-item-info",children:[b.jsx("h4",{children:"主题模式"}),b.jsx("p",{children:"选择界面主题外观"})]}),b.jsx("div",{className:"settings-item-control",children:b.jsx(tn,{value:r,onChange:T=>i(T),style:{width:180},options:[{label:"浅色模式",value:"light"},{label:"深色模式",value:"dark"}]})})]}),b.jsxs("div",{className:"settings-item",children:[b.jsxs("div",{className:"settings-item-info",children:[b.jsx("h4",{children:"API超时设置"}),b.jsx("p",{children:"设置API请求的超时时间(秒)"})]}),b.jsx("div",{className:"settings-item-control",children:b.jsx(tn,{defaultValue:"30",style:{width:180},options:[{label:"10秒",value:"10"},{label:"30秒",value:"30"},{label:"60秒",value:"60"},{label:"120秒",value:"120"}]})})]}),b.jsxs("div",{className:"settings-item",children:[b.jsxs("div",{className:"settings-item-info",children:[b.jsx("h4",{children:"日志级别"}),b.jsx("p",{children:"设置系统日志记录的详细程度"})]}),b.jsx("div",{className:"settings-item-control",children:b.jsx(tn,{defaultValue:"info",style:{width:180},options:[{label:"错误",value:"error"},{label:"警告",value:"warn"},{label:"信息",value:"info"},{label:"调试",value:"debug"}]})})]})]})})]})}],E=(T,I)=>{},k=$.filter(T=>T.id!=="settings");return b.jsx("div",{className:"wandox-settings-with-tabs",children:b.jsx("div",{className:"settings-container",children:b.jsx(EWt,{tabs:k,onTabChange:E,className:"settings-tabs"})})})}function sx(e){if(typeof e=="number"&&Number.isFinite(e))return Math.trunc(e);if(typeof e=="string"&&e.trim()){const t=Number(e);if(Number.isFinite(t))return Math.trunc(t)}return null}function QOe(e,t){const n=sx(t);if(n==null)return-1;const r=e.findIndex(a=>a.step_index===n);if(r>=0)return r;if(n>=0&&n<e.length)return n;const i=n-1;return i>=0&&i<e.length?i:-1}function IWt(e,t){return t.step_id?e.findIndex(n=>n.step_id===t.step_id):QOe(e,t.step_index)}function JQ(e,t,n){const r=sx(e.step_index)??t,i=e.step_id||`step_${r}`;return{id:r,execution_id:0,step_id:i,step_index:r,step_name:e.playbook_name||e.step_name||`步骤 ${r+1}`,playbook_id:i,status:n,business_status:e.business_status}}function VS(e,t,n){const r=IWt(e,t);if(r>=0)return e.map((o,s)=>s===r?n(o):o);const i=sx(t.step_index);if(i==null&&!t.step_id)return e;const a=i??e.length;return[...e,n(JQ(t,a,"pending"))].sort((o,s)=>o.step_index-s.step_index)}function kWt(e,t){const n=sx(e.parent_step_index),r=sx(e.substep_index);return n==null||r==null?null:{id:`${n}:${r}`,parent_step_index:n,parent_step_name:e.parent_step_name,substep_index:r,substep_total:sx(e.substep_total)??r,substep_name:e.substep_name||`子步骤 ${r}`,skill_id:e.skill_id,status:t,message:e.message,success:e.success,duration_ms:e.duration_ms,output_type:e.output_type,output_fields_map:e.output_fields_map,output_content:e.output_content,error:e.error??e.error_message??null,is_stop_on_empty:e.is_stop_on_empty}}function gve(e,t){const n=e??[];return(n.some(i=>i.substep_index===t.substep_index)?n.map(i=>i.substep_index!==t.substep_index?i:{...i,...t,message:t.message??i.message,skill_id:t.skill_id??i.skill_id,output_type:t.output_type??i.output_type,output_content:t.status==="running"?void 0:t.output_content,output_fields_map:t.status==="running"?void 0:t.output_fields_map,duration_ms:t.status==="running"?void 0:t.duration_ms,error:t.status==="running"?null:t.error,success:t.status==="running"?void 0:t.success}):[...n,t]).sort((i,a)=>i.substep_index-a.substep_index)}function PWt(e,t){return t?!e||/^步骤\s*\d+$/i.test(e)||/^step[_\s-]?\d+$/i.test(e)?t:e:e||""}function vve(e,t,n){const r=kWt(t,n);if(!r)return e;const i=QOe(e,r.parent_step_index);if(i>=0)return e.map((o,s)=>s!==i?o:{...o,status:n==="running"&&o.status!=="failed"||o.status==="pending"?"running":o.status,step_name:PWt(o.step_name,r.parent_step_name),substeps:gve(o.substeps,r)});const a=JQ({...t,step_index:r.parent_step_index,step_id:`step_${r.parent_step_index}`,step_name:r.parent_step_name},r.parent_step_index,"running");return[...e,{...a,substeps:gve(void 0,r)}].sort((o,s)=>o.step_index-s.step_index)}function F2(e){return{page:e.page,pageSize:e.pageSize}}function NWt(e){return{...F2(e),sceneId:e.sceneId??null,isTemplate:e.isTemplate??null}}function AWt(e){return{...F2(e),category:e.category??null,keyword:e.keyword??null}}function MWt(e){return{agentId:e.agentId,...F2(e),status:e.status??null,statuses:e.statuses?[...e.statuses]:null,businessStatuses:e.businessStatuses?[...e.businessStatuses]:null,triggerType:e.triggerType??null,startDate:e.startDate??null,endDate:e.endDate??null}}const jy=["automation"],eJ=[...jy,"agents"],yve=[...eJ,"list"],bve=[...eJ,"detail"],JOe=[...jy,"market"],tJ=[...JOe,"templates"],xve=[...tJ,"list"],wve=[...tJ,"detail"],Sve=[...JOe,"recommendations"],vT=[...jy,"executions"],_ve=[...vT,"list"],Cve=[...vT,"detail"],$ve=[...vT,"steps"],U6=[...vT,"waiting-input"],eLe=[...jy,"results"],Eve=[...eLe,"detail"],tLe=[...jy,"transfers"],nJ=[...tLe,"list"],Tve=[...nJ,"sent"],Ive=[...nJ,"inbox"],nLe=[...jy,"schedules"],G6=[...nLe,"list"],rLe=[...jy,"webhooks"],kve=[...rLe,"list"],Yn={agents:{all:eJ,lists:yve,list:e=>[...yve,NWt(e)],details:bve,detail:e=>[...bve,e]},market:{templates:{all:tJ,lists:xve,list:e=>[...xve,AWt(e)],details:wve,detail:e=>[...wve,e]},recommendations:{all:Sve,byTemplate:e=>[...Sve,e]}},executions:{all:vT,lists:_ve,list:e=>[..._ve,MWt(e)],details:Cve,detail:e=>[...Cve,e],steps:{all:$ve,byExecution:e=>[...$ve,e]},waitingInputs:{all:U6,forExecution:e=>[...U6,e],byExecution:(e,t=null)=>[...U6,e,t]}},results:{all:eLe,details:Eve,detail:e=>[...Eve,e]},transfers:{all:tLe,lists:nJ,sentLists:Tve,inboxLists:Ive,sent:e=>[...Tve,F2(e)],inbox:e=>[...Ive,F2(e)]},schedules:{all:nLe,lists:G6,byAgent:e=>[...G6,e],list:(e,t)=>[...G6,e,{includeDisabled:t.includeDisabled}]},webhooks:{all:rLe,lists:kve,list:(e={})=>[...kve,{platform:e.platform??null,domain:e.domain??null}]}};function Qr(e,t=!1,n){return{queryKey:e,exact:t,predicate:n}}function yP(e){return Qr(Yn.executions.lists,!1,t=>{const n=t.queryKey[t.queryKey.length-1];return typeof n=="object"&&n!==null&&"agentId"in n&&n.agentId===e})}function RWt(e){switch(e.type){case"agent-created":return{invalidate:[Qr(Yn.agents.lists)],remove:[]};case"agent-updated":return{invalidate:[Qr(Yn.agents.lists),Qr(Yn.agents.detail(e.agentId),!0)],remove:[]};case"agent-deleted":return{invalidate:[Qr(Yn.agents.lists),Qr(Yn.market.templates.lists),Qr(Yn.market.recommendations.all)],remove:[Qr(Yn.agents.detail(e.agentId),!0),Qr(Yn.schedules.byAgent(e.agentId)),yP(e.agentId)]};case"market-template-enabled":return{invalidate:[Qr(Yn.agents.lists),Qr(Yn.market.templates.lists),Qr(e.sourceTemplateId!=null?Yn.market.recommendations.byTemplate(e.sourceTemplateId):Yn.market.recommendations.all)],remove:[]};case"execution-cancelled":return{invalidate:[...e.agentId?[yP(e.agentId)]:[],Qr(Yn.executions.detail(e.executionId),!0)],remove:[Qr(Yn.executions.waitingInputs.forExecution(e.executionId))]};case"execution-deleted":return{invalidate:e.agentId?[yP(e.agentId)]:[],remove:[Qr(Yn.executions.detail(e.executionId),!0),Qr(Yn.executions.steps.byExecution(e.executionId)),Qr(Yn.executions.waitingInputs.forExecution(e.executionId))]};case"transfer-created":return{invalidate:[Qr(Yn.transfers.sentLists)],remove:[]};case"transfer-rejected":return{invalidate:[Qr(Yn.transfers.inboxLists)],remove:[]};case"transfer-accepted":return{invalidate:[Qr(Yn.transfers.inboxLists),...e.agentId?[yP(e.agentId)]:[],...e.createdAgent?[Qr(Yn.agents.lists)]:[]],remove:[]};case"schedule-saved":case"schedule-deleted":return{invalidate:[Qr(Yn.schedules.byAgent(e.agentId)),Qr(Yn.agents.lists),Qr(Yn.agents.detail(e.agentId),!0)],remove:[]}}}async function Ys(e,t,n={}){const r=RWt(t);for(const i of r.remove)e.removeQueries(i);await Promise.all(r.invalidate.map(i=>e.invalidateQueries({...i,refetchType:n.refetchType??"active"})))}function j0(e){return e.data??e.results??e}const Er=NOe((e,t)=>({scenes:[],scenePlaybooks:[],scenesLoading:!1,playbooksLoading:!1,agents:[],agentsLoading:!1,mainTab:"agents",expandedAgentId:null,inlineResultFilter:"all",executionRecords:[],executionsLoading:!1,selectedExecutionId:null,latestExecutionMap:{},latestExecutionLoading:!1,showAgentDrawer:!1,editingAgent:null,formName:"",formSceneId:null,formPlaybooks:[],formDescription:"",formScheduleEnabled:!1,formScheduleType:"daily",formScheduleCron:"",formScheduleParams:{},showExecDrawer:!1,execStep:"params",execInputData:{},executingAgent:null,execSkipAutoStart:!1,currentExecutionId:null,executionSteps:[],executionProgress:0,latestSSEEvent:null,showResultModal:!1,activeResult:null,transfers:[],transfersLoading:!1,showAgentPickModal:!1,activeTransferId:null,pendingTransferId:null,_transferCreateChain:!1,_transferFanOutEnabled:!1,showTransferModal:!1,transferTargetResultId:null,scheduleModalAgentId:null,setMainTab:n=>e({mainTab:n,expandedAgentId:null}),setExpandedAgentId:n=>e({expandedAgentId:n,inlineResultFilter:"all",selectedExecutionId:null}),setInlineResultFilter:n=>e({inlineResultFilter:n,selectedExecutionId:null}),setSelectedExecutionId:n=>e({selectedExecutionId:n}),setShowAgentDrawer:n=>e({showAgentDrawer:n}),setEditingAgent:n=>e({editingAgent:n}),setFormName:n=>e({formName:n}),setFormSceneId:n=>e({formSceneId:n}),setFormPlaybooks:n=>e({formPlaybooks:n}),setFormDescription:n=>e({formDescription:n}),setFormScheduleEnabled:n=>e({formScheduleEnabled:n}),resetForm:()=>e({formName:"",formSceneId:null,formPlaybooks:[],formDescription:"",formScheduleEnabled:!1,formScheduleType:"daily",formScheduleCron:"",formScheduleParams:{},editingAgent:null,pendingTransferId:null}),setShowExecDrawer:n=>e({showExecDrawer:n}),setExecStep:n=>e({execStep:n}),setExecInputData:n=>e({execInputData:n}),setExecutingAgent:n=>e({executingAgent:n}),setExecSkipAutoStart:n=>e({execSkipAutoStart:n}),setCurrentExecutionId:n=>e({currentExecutionId:n}),setExecutionSteps:n=>e({executionSteps:n}),setExecutionProgress:n=>e({executionProgress:n}),setLatestSSEEvent:n=>e({latestSSEEvent:n}),setShowResultModal:n=>e({showResultModal:n}),setActiveResult:n=>e({activeResult:n}),setShowAgentPickModal:n=>e({showAgentPickModal:n}),setActiveTransferId:n=>e({activeTransferId:n}),setPendingTransferId:n=>e({pendingTransferId:n}),setShowTransferModal:(n,r)=>e({showTransferModal:n,transferTargetResultId:r??null}),setScheduleModalAgentId:n=>e({scheduleModalAgentId:n}),loadScenes:async()=>{e({scenesLoading:!0});try{const n=await pgt(),r=j0(n),i=r.items??(Array.isArray(r)?r:[]);e({scenes:i})}catch{}e({scenesLoading:!1})},loadScenePlaybooks:async n=>{e({playbooksLoading:!0});try{const r=await hgt(n),i=j0(r),a=Array.isArray(i)?i:i.items??[];e({scenePlaybooks:a})}catch{e({scenePlaybooks:[]})}e({playbooksLoading:!1})},loadAgents:async()=>{e({agentsLoading:!0});try{const n=await NY({page:1,page_size:100}),r=j0(n),i=r.items??(Array.isArray(r)?r:[]);e({agents:i})}catch{}e({agentsLoading:!1})},loadExecutions:async n=>{e({executionsLoading:!0});try{const r=await OH({agent_id:n,page:1,page_size:50}),i=j0(r),a=i.items??(Array.isArray(i)?i:[]);e({executionRecords:a})}catch{e({executionRecords:[]})}e({executionsLoading:!1})},loadLatestExecutions:async()=>{const{agents:n}=t();if(n.length===0)return;e({latestExecutionLoading:!0});const r={};await Promise.all(n.map(async i=>{try{const a=await OH({agent_id:i.id,page:1,page_size:1}),o=j0(a),s=o.items??(Array.isArray(o)?o:[]);r[i.id]=s.length>0?s[0]:null}catch{r[i.id]=null}})),e({latestExecutionMap:r,latestExecutionLoading:!1})},loadTransfers:async()=>{e({transfersLoading:!0});try{const n=await LEe({page:1,page_size:50}),r=j0(n),i=r.items??(Array.isArray(r)?r:[]);e({transfers:i})}catch{e({transfers:[]})}e({transfersLoading:!1})}}));function DWt(e,t){const n=t.length;if(typeof e=="string"){const o=t.findIndex(s=>s.step_id===e);if(o>=0)return o}const r=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e):null;if(r==null||!Number.isFinite(r))return null;const i=Math.trunc(r);if(i>=0&&i<n)return i;const a=i-1;return a>=0&&a<n?a:null}function iLe(e){if(typeof e=="number"&&Number.isFinite(e))return Math.trunc(e);if(typeof e=="string"&&e.trim()){const t=Number(e);if(Number.isFinite(t))return Math.trunc(t)}return null}function qR(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function aLe(e,t="pending"){return qR(e)?String(e.status??e.execution_status??e.state??e.step_status??t).toLowerCase():t}function OWt(e){return qR(e)?aLe(e)==="skipped"||e.skipped===!0||e.is_skipped===!0:!1}function LWt(e){const t=aLe(e);return t==="skipped"?"skipped":t==="failed"||t==="cancelled"||t==="timeout"?"failed":t==="waiting"||t==="waiting_input"||t==="pending_input"?"waiting_input":t==="completed"||t==="complete"||t==="success"||t==="succeeded"?"completed":t==="awaiting_async"?"awaiting_async":t==="pending_async"?"pending_async":t==="running"?"running":"pending"}function jWt(e,t){const n=iLe(e.step_index)??t,r=e.step_id||`step_${n}`;return{id:n,execution_id:0,step_id:r,step_index:n,step_name:e.step_name??e.playbook_name??`步骤 ${n+1}`,playbook_id:e.playbook_id??r,status:LWt(e),requires_human_confirm:!!e.requires_human_confirm,business_status:null,business_status_prefix:e.business_status_prefix??null,skip_if:e.skip_if??null}}function zWt(e,t){const n=iLe(e.start_from_step??e.resume_from_step);return n!=null&&n>=0&&(t===0||n<t)?n:null}function rJ(){const e=m.useRef(null),t=Er,n=wa(),r=m.useCallback((f,p)=>{var g;const h=t.getState();switch(f){case"execution_init":h.setCurrentExecutionId(p.execution_record_id??null),p.steps&&h.setExecutionSteps(p.steps.filter(v=>!OWt(v)).map(jWt)),h.setExecutionProgress(0);break;case"execution_started":h.setCurrentExecutionId(p.execution_record_id??h.currentExecutionId??null);{const v=zWt(p,h.executionSteps.length);if(h.executionSteps.length>0&&v!=null)h.setExecutionSteps(h.executionSteps.map((x,w)=>w<v?x.status==="failed"?x:{...x,status:"completed"}:w===v?{...x,status:"running",output_data:void 0,duration_ms:void 0,completed_at:void 0,substeps:[]}:{...x,status:"pending",output_data:void 0,duration_ms:void 0,completed_at:void 0,substeps:void 0}));else if(!h.executionSteps.length&&p.total_steps&&p.total_steps>0){const x=v??0;h.setExecutionSteps(Array.from({length:p.total_steps},(w,S)=>JQ({...p,step_index:S,step_id:`step_${S}`},S,S<x?"completed":S===x?"running":"pending")))}const y=h.executionSteps.length||p.total_steps||1;h.setExecutionProgress(v!=null?Math.round(v/y*100):0)}break;case"resume_init":h.setCurrentExecutionId(p.execution_record_id??h.currentExecutionId??null);{const v=DWt(p.start_from_step??p.resume_from_step,h.executionSteps);if(v!=null){const y=h.executionSteps.map((w,S)=>S<v?w:{...w,status:S===v?"running":"pending",output_data:void 0,duration_ms:void 0,completed_at:void 0,substeps:void 0});h.setExecutionSteps(y);const x=h.executionSteps.length||1;h.setExecutionProgress(Math.round(v/x*100))}}break;case"re_executing":case"step_running":{const v=VS(h.executionSteps,p,y=>({...y,status:"running",step_name:y.step_name||p.playbook_name||p.step_name||"",business_status:p.business_status??y.business_status,substeps:[]}));h.setExecutionSteps(v)}break;case"step_awaiting_async":case"step_pending_async":{const v=VS(h.executionSteps,p,y=>({...y,status:"awaiting_async",step_name:y.step_name||p.playbook_name||p.step_name||"",business_status:p.business_status??y.business_status}));h.setExecutionSteps(v)}break;case"substep_running":h.setExecutionSteps(vve(h.executionSteps,p,"running"));break;case"substep_completed":h.setExecutionSteps(vve(h.executionSteps,p,p.success===!1?"failed":"completed"));break;case"step_completed":{const v=h.executionSteps.length||1;{const y=VS(h.executionSteps,p,w=>({...w,status:"completed",output_data:p.output??p.output_data,duration_ms:p.duration_ms,business_status:p.business_status??w.business_status}));h.setExecutionSteps(y);const x=y.filter(w=>w.status==="completed").length;h.setExecutionProgress(Math.round(x/v*100))}break}case"step_failed":{const v=VS(h.executionSteps,p,y=>({...y,status:"failed",business_status:p.business_status??y.business_status}));h.setExecutionSteps(v)}break;case"waiting_input":{const v=VS(h.executionSteps,p,y=>({...y,status:"waiting_input",requires_human_confirm:!0,human_confirm_triggered:!0,business_status:p.business_status??y.business_status}));h.setExecutionSteps(v)}break;case"execution_completed":h.setExecutionProgress(100);break}(g=h.setLatestSSEEvent)==null||g.call(h,{...p,type:f})},[]),i=m.useCallback(async f=>{const p=new TextDecoder;let h="",g=null;const v=x=>{const w=x.trim();if(!w||w.startsWith(":"))return!1;if(w.startsWith("event:"))return g=w.substring(6).trim(),!1;if(w.startsWith("data:")&&g){const S=w.substring(5).trim();if(S==="[DONE]")return g=null,!0;try{const _=JSON.parse(S);r(g,_)}catch{}g=null}return!1};for(;;){const{done:x,value:w}=await f.read();if(x)break;h+=p.decode(w,{stream:!0});const S=h.split(`
|
|
779
|
+
</div>`}return R}},legend:{data:["输入 Token","输出 Token","调用次数"],top:10,textStyle:{fontSize:12}},grid:{left:"3%",right:"4%",bottom:"8%",top:"15%",containLabel:!0},xAxis:{type:"category",boundaryGap:!1,data:d.map(A=>A.stat_date),axisLine:{lineStyle:{color:"#e8eaed"}},axisLabel:{color:"#5f6368",fontSize:11}},yAxis:[{type:"value",name:"Token 数量",nameTextStyle:{color:"#5f6368",fontSize:11},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:"#5f6368",fontSize:11,formatter:A=>A>=1e6?`${(A/1e6).toFixed(1)}M`:A>=1e3?`${(A/1e3).toFixed(1)}K`:A.toString()},splitLine:{lineStyle:{color:"#f1f3f4",type:"dashed"}}},{type:"value",name:"调用次数",nameTextStyle:{color:"#5f6368",fontSize:11},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:"#5f6368",fontSize:11},splitLine:{show:!1}}],series:[{name:"输入 Token",type:"line",data:d.map(A=>A.total_prompt_tokens),smooth:!0,symbol:"circle",symbolSize:6,lineStyle:{width:2},itemStyle:{color:"#1890ff"},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(24, 144, 255, 0.2)"},{offset:1,color:"rgba(24, 144, 255, 0.02)"}]}}},{name:"输出 Token",type:"line",data:d.map(A=>A.total_completion_tokens),smooth:!0,symbol:"circle",symbolSize:6,lineStyle:{width:2},itemStyle:{color:"#52c41a"},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(82, 196, 26, 0.2)"},{offset:1,color:"rgba(82, 196, 26, 0.02)"}]}}},{name:"调用次数",type:"line",yAxisIndex:1,data:d.map(A=>A.total_calls),smooth:!0,symbol:"circle",symbolSize:6,lineStyle:{width:2},itemStyle:{color:"#722ed1"}}]};I.setOption(P);const N=()=>{I.resize()};return window.addEventListener("resize",N),()=>{window.removeEventListener("resize",N),I.dispose()}},_=x(),C=w(),$=[{id:"overview",label:"总览",icon:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),b.jsx("polyline",{points:"9,22 9,12 15,12 15,22"})]}),content:b.jsxs("div",{className:"settings-overview-content",children:[b.jsxs("header",{className:"panel-header",children:[b.jsx("div",{className:"panel-icon-wrapper",children:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),b.jsx("polyline",{points:"9,22 9,12 15,12 15,22"})]})}),b.jsxs("div",{children:[b.jsx("h2",{className:"panel-title",children:"算力币总览"}),b.jsx("p",{className:"panel-subtitle",children:"算力币余额、使用情况和系统状态一览"})]})]}),b.jsxs("div",{className:"panel-body",children:[b.jsx("p",{children:"算力币是系统中的核心资源,用于AI模型调用和各项服务。以下是您的算力币使用情况和相关统计信息。"}),b.jsxs("div",{className:"credits-overview-grid",children:[s?b.jsxs("div",{className:"credits-main-card",children:[b.jsx("div",{className:"credits-icon",children:b.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:b.jsx("path",{d:"M12 2L2 7v10c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V7l-10-5z"})})}),b.jsxs("div",{className:"credits-info",children:[b.jsx("div",{className:"credits-title",children:"算力币余额"}),b.jsx("div",{className:"credits-value",children:s.credits_balance.toFixed(2)}),b.jsx("div",{className:"credits-desc",children:"可用余额"})]})]}):b.jsxs("div",{className:"credits-main-card",children:[b.jsx("div",{className:"credits-icon",children:b.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:b.jsx("path",{d:"M12 2L2 7v10c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V7l-10-5z"})})}),b.jsxs("div",{className:"credits-info",children:[b.jsx("div",{className:"credits-title",children:"算力币余额"}),b.jsx("div",{className:"credits-value",children:"--"}),b.jsx("div",{className:"credits-desc",children:"加载中..."})]})]}),b.jsxs("div",{className:"grid grid-4",children:[b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:s?s.credits_total.toFixed(2):"--"}),b.jsx("div",{className:"stat-label",children:"总算力币"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:s?s.credits_use.toFixed(2):"--"}),b.jsx("div",{className:"stat-label",children:"已使用量"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:s?s.credits_balance.toFixed(2):"--"}),b.jsx("div",{className:"stat-label",children:"剩余数量"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:s?`${(s.credits_use/s.credits_total*100).toFixed(1)}%`:"--"}),b.jsx("div",{className:"stat-label",children:"使用率"})]})]})]}),b.jsxs("div",{className:"credits-details",children:[b.jsx("h3",{children:"使用详情"}),b.jsxs("div",{className:"grid grid-3",children:[b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"本月消耗"}),b.jsx("div",{className:"detail-value",children:_.current.toLocaleString()}),b.jsxs("div",{className:`detail-trend ${_.trend}`,children:[_.trend==="positive"?"↑":_.trend==="negative"?"↓":"→"," ",_.percentage.toFixed(1),"%"]})]}),b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"日均消耗"}),b.jsx("div",{className:"detail-value",children:c?c.avg_daily_tokens.toLocaleString():"--"}),b.jsx("div",{className:"detail-trend stable",children:"→ 0%"})]}),b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"预计可用天数"}),b.jsx("div",{className:"detail-value",children:C}),b.jsx("div",{className:"detail-trend stable",children:"→ 0%"})]})]})]})]})]})},{id:"tokens",label:"算力统计",icon:b.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:b.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})}),content:b.jsxs("div",{className:"settings-tokens-content",children:[b.jsxs("header",{className:"panel-header",children:[b.jsx("div",{className:"panel-icon-wrapper",children:b.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:b.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z"})})}),b.jsxs("div",{children:[b.jsx("h2",{className:"panel-title",children:"算力统计"}),b.jsx("p",{className:"panel-subtitle",children:"AI模型调用的详细数据分析和趋势监控"})]})]}),b.jsxs("div",{className:"panel-body",children:[c&&b.jsx("div",{className:"token-overview-cards",children:b.jsxs("div",{className:"grid grid-4",children:[b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:c.total_tokens.toLocaleString()}),b.jsx("div",{className:"stat-label",children:"总 Token 消耗"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:c.total_calls.toLocaleString()}),b.jsx("div",{className:"stat-label",children:"总调用次数"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsxs("div",{className:"stat-value",children:[c.success_count,"/",c.total_calls]}),b.jsx("div",{className:"stat-label",children:"成功/总次数"})]}),b.jsxs("article",{className:"stat-card",children:[b.jsx("div",{className:"stat-value",children:c.avg_daily_tokens.toLocaleString()}),b.jsx("div",{className:"stat-label",children:"日均 Token 消耗"})]})]})}),b.jsxs("div",{className:"token-chart-section",children:[b.jsx("h3",{children:"Token 使用趋势"}),b.jsx("div",{id:"token-trend-chart",style:{width:"100%",height:350,marginBottom:24}})]}),p.length>0&&b.jsxs("div",{className:"agent-stats-section",children:[b.jsx("h3",{children:"Agent 使用统计"}),b.jsx("div",{className:"agent-stats-grid",children:p.slice(0,6).map(T=>b.jsxs("div",{className:"agent-stat-card",children:[b.jsx("div",{className:"agent-name",children:T.agent_name||"-"}),b.jsx("div",{className:"agent-tokens",children:T.total_tokens.toLocaleString()}),b.jsxs("div",{className:"agent-calls",children:[T.total_calls," 次调用"]}),b.jsxs("div",{className:"agent-success-rate",children:["成功率:"," ",T.total_calls>0?(T.success_count/T.total_calls*100).toFixed(1):0,"%"]})]},T.agent_id))})]}),c&&b.jsxs("div",{className:"detailed-stats",children:[b.jsx("h3",{children:"详细统计"}),b.jsxs("div",{className:"grid grid-3",children:[b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"输入 Token"}),b.jsx("div",{className:"detail-value",children:c.total_prompt_tokens.toLocaleString()}),b.jsx("div",{className:"detail-desc",children:"用户输入的总 Token 数"})]}),b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"输出 Token"}),b.jsx("div",{className:"detail-value",children:c.total_completion_tokens.toLocaleString()}),b.jsx("div",{className:"detail-desc",children:"AI生成的总 Token 数"})]}),b.jsxs("div",{className:"detail-card",children:[b.jsx("div",{className:"detail-label",children:"统计天数"}),b.jsx("div",{className:"detail-value",children:c.days}),b.jsx("div",{className:"detail-desc",children:"数据统计的时间范围"})]})]})]}),!c&&!a&&b.jsx("div",{className:"loading-state",children:b.jsx("div",{className:"loading-message",children:"正在加载统计数据..."})})]})]})},{id:"notifications",label:"通知配置",icon:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),b.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),content:b.jsxs("div",{className:"settings-notifications-content",children:[b.jsxs("header",{className:"panel-header",children:[b.jsx("div",{className:"panel-icon-wrapper",children:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),b.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),b.jsxs("div",{children:[b.jsx("h2",{className:"panel-title",children:"通知配置"}),b.jsx("p",{className:"panel-subtitle",children:"配置Webhook通知,实时接收系统重要事件"})]})]}),b.jsx("div",{className:"panel-body",children:b.jsx(X7t,{})})]})},{id:"settings",label:"系统设置",icon:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("circle",{cx:"12",cy:"12",r:"3"}),b.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),content:b.jsxs("div",{className:"settings-system-content",children:[b.jsxs("header",{className:"panel-header",children:[b.jsx("div",{className:"panel-icon-wrapper",children:b.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[b.jsx("circle",{cx:"12",cy:"12",r:"3"}),b.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),b.jsxs("div",{children:[b.jsx("h2",{className:"panel-title",children:"系统设置"}),b.jsx("p",{className:"panel-subtitle",children:"配置系统基础参数和高级选项"})]})]}),b.jsx("div",{className:"panel-body",children:b.jsxs("div",{className:"settings-section",children:[b.jsxs("div",{className:"settings-item",children:[b.jsxs("div",{className:"settings-item-info",children:[b.jsx("h4",{children:"界面语言"}),b.jsx("p",{children:"选择系统显示语言,切换后立即生效"})]}),b.jsx("div",{className:"settings-item-control",children:b.jsx(tn,{value:e,onChange:T=>t(T),style:{width:180},options:[{label:n("settings.language.zh"),value:"zh-CN"},{label:n("settings.language.en"),value:"en-US"}]})})]}),b.jsxs("div",{className:"settings-item",children:[b.jsxs("div",{className:"settings-item-info",children:[b.jsx("h4",{children:"主题模式"}),b.jsx("p",{children:"选择界面主题外观"})]}),b.jsx("div",{className:"settings-item-control",children:b.jsx(tn,{value:r,onChange:T=>i(T),style:{width:180},options:[{label:"浅色模式",value:"light"},{label:"深色模式",value:"dark"}]})})]}),b.jsxs("div",{className:"settings-item",children:[b.jsxs("div",{className:"settings-item-info",children:[b.jsx("h4",{children:"API超时设置"}),b.jsx("p",{children:"设置API请求的超时时间(秒)"})]}),b.jsx("div",{className:"settings-item-control",children:b.jsx(tn,{defaultValue:"30",style:{width:180},options:[{label:"10秒",value:"10"},{label:"30秒",value:"30"},{label:"60秒",value:"60"},{label:"120秒",value:"120"}]})})]}),b.jsxs("div",{className:"settings-item",children:[b.jsxs("div",{className:"settings-item-info",children:[b.jsx("h4",{children:"日志级别"}),b.jsx("p",{children:"设置系统日志记录的详细程度"})]}),b.jsx("div",{className:"settings-item-control",children:b.jsx(tn,{defaultValue:"info",style:{width:180},options:[{label:"错误",value:"error"},{label:"警告",value:"warn"},{label:"信息",value:"info"},{label:"调试",value:"debug"}]})})]})]})})]})}],E=(T,I)=>{},k=$.filter(T=>T.id!=="settings");return b.jsx("div",{className:"wandox-settings-with-tabs",children:b.jsx("div",{className:"settings-container",children:b.jsx($Wt,{tabs:k,onTabChange:E,className:"settings-tabs"})})})}function sx(e){if(typeof e=="number"&&Number.isFinite(e))return Math.trunc(e);if(typeof e=="string"&&e.trim()){const t=Number(e);if(Number.isFinite(t))return Math.trunc(t)}return null}function QOe(e,t){const n=sx(t);if(n==null)return-1;const r=e.findIndex(a=>a.step_index===n);if(r>=0)return r;if(n>=0&&n<e.length)return n;const i=n-1;return i>=0&&i<e.length?i:-1}function TWt(e,t){return t.step_id?e.findIndex(n=>n.step_id===t.step_id):QOe(e,t.step_index)}function JQ(e,t,n){const r=sx(e.step_index)??t,i=e.step_id||`step_${r}`;return{id:r,execution_id:0,step_id:i,step_index:r,step_name:e.playbook_name||e.step_name||`步骤 ${r+1}`,playbook_id:i,status:n,business_status:e.business_status}}function VS(e,t,n){const r=TWt(e,t);if(r>=0)return e.map((o,s)=>s===r?n(o):o);const i=sx(t.step_index);if(i==null&&!t.step_id)return e;const a=i??e.length;return[...e,n(JQ(t,a,"pending"))].sort((o,s)=>o.step_index-s.step_index)}function IWt(e,t){const n=sx(e.parent_step_index),r=sx(e.substep_index);return n==null||r==null?null:{id:`${n}:${r}`,parent_step_index:n,parent_step_name:e.parent_step_name,substep_index:r,substep_total:sx(e.substep_total)??r,substep_name:e.substep_name||`子步骤 ${r}`,skill_id:e.skill_id,status:t,message:e.message,success:e.success,duration_ms:e.duration_ms,output_type:e.output_type,output_fields_map:e.output_fields_map,output_content:e.output_content,error:e.error??e.error_message??null,is_stop_on_empty:e.is_stop_on_empty}}function gve(e,t){const n=e??[];return(n.some(i=>i.substep_index===t.substep_index)?n.map(i=>i.substep_index!==t.substep_index?i:{...i,...t,message:t.message??i.message,skill_id:t.skill_id??i.skill_id,output_type:t.output_type??i.output_type,output_content:t.status==="running"?void 0:t.output_content,output_fields_map:t.status==="running"?void 0:t.output_fields_map,duration_ms:t.status==="running"?void 0:t.duration_ms,error:t.status==="running"?null:t.error,success:t.status==="running"?void 0:t.success}):[...n,t]).sort((i,a)=>i.substep_index-a.substep_index)}function kWt(e,t){return t?!e||/^步骤\s*\d+$/i.test(e)||/^step[_\s-]?\d+$/i.test(e)?t:e:e||""}function vve(e,t,n){const r=IWt(t,n);if(!r)return e;const i=QOe(e,r.parent_step_index);if(i>=0)return e.map((o,s)=>s!==i?o:{...o,status:n==="running"&&o.status!=="failed"||o.status==="pending"?"running":o.status,step_name:kWt(o.step_name,r.parent_step_name),substeps:gve(o.substeps,r)});const a=JQ({...t,step_index:r.parent_step_index,step_id:`step_${r.parent_step_index}`,step_name:r.parent_step_name},r.parent_step_index,"running");return[...e,{...a,substeps:gve(void 0,r)}].sort((o,s)=>o.step_index-s.step_index)}function F2(e){return{page:e.page,pageSize:e.pageSize}}function PWt(e){return{...F2(e),sceneId:e.sceneId??null,isTemplate:e.isTemplate??null}}function NWt(e){return{...F2(e),category:e.category??null,keyword:e.keyword??null}}function AWt(e){return{agentId:e.agentId,...F2(e),status:e.status??null,statuses:e.statuses?[...e.statuses]:null,businessStatuses:e.businessStatuses?[...e.businessStatuses]:null,triggerType:e.triggerType??null,startDate:e.startDate??null,endDate:e.endDate??null}}const jy=["automation"],eJ=[...jy,"agents"],yve=[...eJ,"list"],bve=[...eJ,"detail"],JOe=[...jy,"market"],tJ=[...JOe,"templates"],xve=[...tJ,"list"],wve=[...tJ,"detail"],Sve=[...JOe,"recommendations"],vT=[...jy,"executions"],_ve=[...vT,"list"],Cve=[...vT,"detail"],$ve=[...vT,"steps"],U6=[...vT,"waiting-input"],eLe=[...jy,"results"],Eve=[...eLe,"detail"],tLe=[...jy,"transfers"],nJ=[...tLe,"list"],Tve=[...nJ,"sent"],Ive=[...nJ,"inbox"],nLe=[...jy,"schedules"],G6=[...nLe,"list"],rLe=[...jy,"webhooks"],kve=[...rLe,"list"],Yn={agents:{all:eJ,lists:yve,list:e=>[...yve,PWt(e)],details:bve,detail:e=>[...bve,e]},market:{templates:{all:tJ,lists:xve,list:e=>[...xve,NWt(e)],details:wve,detail:e=>[...wve,e]},recommendations:{all:Sve,byTemplate:e=>[...Sve,e]}},executions:{all:vT,lists:_ve,list:e=>[..._ve,AWt(e)],details:Cve,detail:e=>[...Cve,e],steps:{all:$ve,byExecution:e=>[...$ve,e]},waitingInputs:{all:U6,forExecution:e=>[...U6,e],byExecution:(e,t=null)=>[...U6,e,t]}},results:{all:eLe,details:Eve,detail:e=>[...Eve,e]},transfers:{all:tLe,lists:nJ,sentLists:Tve,inboxLists:Ive,sent:e=>[...Tve,F2(e)],inbox:e=>[...Ive,F2(e)]},schedules:{all:nLe,lists:G6,byAgent:e=>[...G6,e],list:(e,t)=>[...G6,e,{includeDisabled:t.includeDisabled}]},webhooks:{all:rLe,lists:kve,list:(e={})=>[...kve,{platform:e.platform??null,domain:e.domain??null}]}};function Qr(e,t=!1,n){return{queryKey:e,exact:t,predicate:n}}function yP(e){return Qr(Yn.executions.lists,!1,t=>{const n=t.queryKey[t.queryKey.length-1];return typeof n=="object"&&n!==null&&"agentId"in n&&n.agentId===e})}function MWt(e){switch(e.type){case"agent-created":return{invalidate:[Qr(Yn.agents.lists)],remove:[]};case"agent-updated":return{invalidate:[Qr(Yn.agents.lists),Qr(Yn.agents.detail(e.agentId),!0)],remove:[]};case"agent-deleted":return{invalidate:[Qr(Yn.agents.lists),Qr(Yn.market.templates.lists),Qr(Yn.market.recommendations.all)],remove:[Qr(Yn.agents.detail(e.agentId),!0),Qr(Yn.schedules.byAgent(e.agentId)),yP(e.agentId)]};case"market-template-enabled":return{invalidate:[Qr(Yn.agents.lists),Qr(Yn.market.templates.lists),Qr(e.sourceTemplateId!=null?Yn.market.recommendations.byTemplate(e.sourceTemplateId):Yn.market.recommendations.all)],remove:[]};case"execution-cancelled":return{invalidate:[...e.agentId?[yP(e.agentId)]:[],Qr(Yn.executions.detail(e.executionId),!0)],remove:[Qr(Yn.executions.waitingInputs.forExecution(e.executionId))]};case"execution-deleted":return{invalidate:e.agentId?[yP(e.agentId)]:[],remove:[Qr(Yn.executions.detail(e.executionId),!0),Qr(Yn.executions.steps.byExecution(e.executionId)),Qr(Yn.executions.waitingInputs.forExecution(e.executionId))]};case"transfer-created":return{invalidate:[Qr(Yn.transfers.sentLists)],remove:[]};case"transfer-rejected":return{invalidate:[Qr(Yn.transfers.inboxLists)],remove:[]};case"transfer-accepted":return{invalidate:[Qr(Yn.transfers.inboxLists),...e.agentId?[yP(e.agentId)]:[],...e.createdAgent?[Qr(Yn.agents.lists)]:[]],remove:[]};case"schedule-saved":case"schedule-deleted":return{invalidate:[Qr(Yn.schedules.byAgent(e.agentId)),Qr(Yn.agents.lists),Qr(Yn.agents.detail(e.agentId),!0)],remove:[]}}}async function Ys(e,t,n={}){const r=MWt(t);for(const i of r.remove)e.removeQueries(i);await Promise.all(r.invalidate.map(i=>e.invalidateQueries({...i,refetchType:n.refetchType??"active"})))}function j0(e){return e.data??e.results??e}const Er=NOe((e,t)=>({scenes:[],scenePlaybooks:[],scenesLoading:!1,playbooksLoading:!1,agents:[],agentsLoading:!1,mainTab:"agents",expandedAgentId:null,inlineResultFilter:"all",executionRecords:[],executionsLoading:!1,selectedExecutionId:null,latestExecutionMap:{},latestExecutionLoading:!1,showAgentDrawer:!1,editingAgent:null,formName:"",formSceneId:null,formPlaybooks:[],formDescription:"",formScheduleEnabled:!1,formScheduleType:"daily",formScheduleCron:"",formScheduleParams:{},showExecDrawer:!1,execStep:"params",execInputData:{},executingAgent:null,execSkipAutoStart:!1,currentExecutionId:null,executionSteps:[],executionProgress:0,latestSSEEvent:null,showResultModal:!1,activeResult:null,transfers:[],transfersLoading:!1,showAgentPickModal:!1,activeTransferId:null,pendingTransferId:null,_transferCreateChain:!1,_transferFanOutEnabled:!1,showTransferModal:!1,transferTargetResultId:null,scheduleModalAgentId:null,setMainTab:n=>e({mainTab:n,expandedAgentId:null}),setExpandedAgentId:n=>e({expandedAgentId:n,inlineResultFilter:"all",selectedExecutionId:null}),setInlineResultFilter:n=>e({inlineResultFilter:n,selectedExecutionId:null}),setSelectedExecutionId:n=>e({selectedExecutionId:n}),setShowAgentDrawer:n=>e({showAgentDrawer:n}),setEditingAgent:n=>e({editingAgent:n}),setFormName:n=>e({formName:n}),setFormSceneId:n=>e({formSceneId:n}),setFormPlaybooks:n=>e({formPlaybooks:n}),setFormDescription:n=>e({formDescription:n}),setFormScheduleEnabled:n=>e({formScheduleEnabled:n}),resetForm:()=>e({formName:"",formSceneId:null,formPlaybooks:[],formDescription:"",formScheduleEnabled:!1,formScheduleType:"daily",formScheduleCron:"",formScheduleParams:{},editingAgent:null,pendingTransferId:null}),setShowExecDrawer:n=>e({showExecDrawer:n}),setExecStep:n=>e({execStep:n}),setExecInputData:n=>e({execInputData:n}),setExecutingAgent:n=>e({executingAgent:n}),setExecSkipAutoStart:n=>e({execSkipAutoStart:n}),setCurrentExecutionId:n=>e({currentExecutionId:n}),setExecutionSteps:n=>e({executionSteps:n}),setExecutionProgress:n=>e({executionProgress:n}),setLatestSSEEvent:n=>e({latestSSEEvent:n}),setShowResultModal:n=>e({showResultModal:n}),setActiveResult:n=>e({activeResult:n}),setShowAgentPickModal:n=>e({showAgentPickModal:n}),setActiveTransferId:n=>e({activeTransferId:n}),setPendingTransferId:n=>e({pendingTransferId:n}),setShowTransferModal:(n,r)=>e({showTransferModal:n,transferTargetResultId:r??null}),setScheduleModalAgentId:n=>e({scheduleModalAgentId:n}),loadScenes:async()=>{e({scenesLoading:!0});try{const n=await pgt(),r=j0(n),i=r.items??(Array.isArray(r)?r:[]);e({scenes:i})}catch{}e({scenesLoading:!1})},loadScenePlaybooks:async n=>{e({playbooksLoading:!0});try{const r=await hgt(n),i=j0(r),a=Array.isArray(i)?i:i.items??[];e({scenePlaybooks:a})}catch{e({scenePlaybooks:[]})}e({playbooksLoading:!1})},loadAgents:async()=>{e({agentsLoading:!0});try{const n=await NY({page:1,page_size:100}),r=j0(n),i=r.items??(Array.isArray(r)?r:[]);e({agents:i})}catch{}e({agentsLoading:!1})},loadExecutions:async n=>{e({executionsLoading:!0});try{const r=await OH({agent_id:n,page:1,page_size:50}),i=j0(r),a=i.items??(Array.isArray(i)?i:[]);e({executionRecords:a})}catch{e({executionRecords:[]})}e({executionsLoading:!1})},loadLatestExecutions:async()=>{const{agents:n}=t();if(n.length===0)return;e({latestExecutionLoading:!0});const r={};await Promise.all(n.map(async i=>{try{const a=await OH({agent_id:i.id,page:1,page_size:1}),o=j0(a),s=o.items??(Array.isArray(o)?o:[]);r[i.id]=s.length>0?s[0]:null}catch{r[i.id]=null}})),e({latestExecutionMap:r,latestExecutionLoading:!1})},loadTransfers:async()=>{e({transfersLoading:!0});try{const n=await LEe({page:1,page_size:50}),r=j0(n),i=r.items??(Array.isArray(r)?r:[]);e({transfers:i})}catch{e({transfers:[]})}e({transfersLoading:!1})}}));function RWt(e,t){const n=t.length;if(typeof e=="string"){const o=t.findIndex(s=>s.step_id===e);if(o>=0)return o}const r=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e):null;if(r==null||!Number.isFinite(r))return null;const i=Math.trunc(r);if(i>=0&&i<n)return i;const a=i-1;return a>=0&&a<n?a:null}function iLe(e){if(typeof e=="number"&&Number.isFinite(e))return Math.trunc(e);if(typeof e=="string"&&e.trim()){const t=Number(e);if(Number.isFinite(t))return Math.trunc(t)}return null}function qR(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function aLe(e,t="pending"){return qR(e)?String(e.status??e.execution_status??e.state??e.step_status??t).toLowerCase():t}function DWt(e){return qR(e)?aLe(e)==="skipped"||e.skipped===!0||e.is_skipped===!0:!1}function OWt(e){const t=aLe(e);return t==="skipped"?"skipped":t==="failed"||t==="cancelled"||t==="timeout"?"failed":t==="waiting"||t==="waiting_input"||t==="pending_input"?"waiting_input":t==="completed"||t==="complete"||t==="success"||t==="succeeded"?"completed":t==="awaiting_async"?"awaiting_async":t==="pending_async"?"pending_async":t==="running"?"running":"pending"}function LWt(e,t){const n=iLe(e.step_index)??t,r=e.step_id||`step_${n}`;return{id:n,execution_id:0,step_id:r,step_index:n,step_name:e.step_name??e.playbook_name??`步骤 ${n+1}`,playbook_id:e.playbook_id??r,status:OWt(e),requires_human_confirm:!!e.requires_human_confirm,business_status:null,business_status_prefix:e.business_status_prefix??null,skip_if:e.skip_if??null}}function jWt(e,t){const n=iLe(e.start_from_step??e.resume_from_step);return n!=null&&n>=0&&(t===0||n<t)?n:null}function rJ(){const e=m.useRef(null),t=Er,n=wa(),r=m.useCallback((f,p)=>{var g;const h=t.getState();switch(f){case"execution_init":h.setCurrentExecutionId(p.execution_record_id??null),p.steps&&h.setExecutionSteps(p.steps.filter(v=>!DWt(v)).map(LWt)),h.setExecutionProgress(0);break;case"execution_started":h.setCurrentExecutionId(p.execution_record_id??h.currentExecutionId??null);{const v=jWt(p,h.executionSteps.length);if(h.executionSteps.length>0&&v!=null)h.setExecutionSteps(h.executionSteps.map((x,w)=>w<v?x.status==="failed"?x:{...x,status:"completed"}:w===v?{...x,status:"running",output_data:void 0,duration_ms:void 0,completed_at:void 0,substeps:[]}:{...x,status:"pending",output_data:void 0,duration_ms:void 0,completed_at:void 0,substeps:void 0}));else if(!h.executionSteps.length&&p.total_steps&&p.total_steps>0){const x=v??0;h.setExecutionSteps(Array.from({length:p.total_steps},(w,S)=>JQ({...p,step_index:S,step_id:`step_${S}`},S,S<x?"completed":S===x?"running":"pending")))}const y=h.executionSteps.length||p.total_steps||1;h.setExecutionProgress(v!=null?Math.round(v/y*100):0)}break;case"resume_init":h.setCurrentExecutionId(p.execution_record_id??h.currentExecutionId??null);{const v=RWt(p.start_from_step??p.resume_from_step,h.executionSteps);if(v!=null){const y=h.executionSteps.map((w,S)=>S<v?w:{...w,status:S===v?"running":"pending",output_data:void 0,duration_ms:void 0,completed_at:void 0,substeps:void 0});h.setExecutionSteps(y);const x=h.executionSteps.length||1;h.setExecutionProgress(Math.round(v/x*100))}}break;case"re_executing":case"step_running":{const v=VS(h.executionSteps,p,y=>({...y,status:"running",step_name:y.step_name||p.playbook_name||p.step_name||"",business_status:p.business_status??y.business_status,substeps:[]}));h.setExecutionSteps(v)}break;case"step_awaiting_async":case"step_pending_async":{const v=VS(h.executionSteps,p,y=>({...y,status:"awaiting_async",step_name:y.step_name||p.playbook_name||p.step_name||"",business_status:p.business_status??y.business_status}));h.setExecutionSteps(v)}break;case"substep_running":h.setExecutionSteps(vve(h.executionSteps,p,"running"));break;case"substep_completed":h.setExecutionSteps(vve(h.executionSteps,p,p.success===!1?"failed":"completed"));break;case"step_completed":{const v=h.executionSteps.length||1;{const y=VS(h.executionSteps,p,w=>({...w,status:"completed",output_data:p.output??p.output_data,duration_ms:p.duration_ms,business_status:p.business_status??w.business_status}));h.setExecutionSteps(y);const x=y.filter(w=>w.status==="completed").length;h.setExecutionProgress(Math.round(x/v*100))}break}case"step_failed":{const v=VS(h.executionSteps,p,y=>({...y,status:"failed",business_status:p.business_status??y.business_status}));h.setExecutionSteps(v)}break;case"waiting_input":{const v=VS(h.executionSteps,p,y=>({...y,status:"waiting_input",requires_human_confirm:!0,human_confirm_triggered:!0,business_status:p.business_status??y.business_status}));h.setExecutionSteps(v)}break;case"execution_completed":h.setExecutionProgress(100);break}(g=h.setLatestSSEEvent)==null||g.call(h,{...p,type:f})},[]),i=m.useCallback(async f=>{const p=new TextDecoder;let h="",g=null;const v=x=>{const w=x.trim();if(!w||w.startsWith(":"))return!1;if(w.startsWith("event:"))return g=w.substring(6).trim(),!1;if(w.startsWith("data:")&&g){const S=w.substring(5).trim();if(S==="[DONE]")return g=null,!0;try{const _=JSON.parse(S);r(g,_)}catch{}g=null}return!1};for(;;){const{done:x,value:w}=await f.read();if(x)break;h+=p.decode(w,{stream:!0});const S=h.split(`
|
|
780
780
|
`);h=S.pop()??"";for(const _ of S)if(v(_)){await f.cancel().catch(()=>{});return}}const y=p.decode();if(y&&(h+=y),h.trim()){for(const x of h.split(`
|
|
781
|
-
`))if(v(x)){await f.cancel().catch(()=>{});return}}},[r]),a=m.useCallback(async(f,p,h={})=>{var S;(S=e.current)==null||S.abort();const g=new AbortController;e.current=g;const v=localStorage.getItem("sso_token")||"",y=localStorage.getItem("sso_domain")||"",x=localStorage.getItem("sso_company")||"",w=Gi();try{const _=await fetch(`${w}/api/v1/custom-agents/execute/${f}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`,"X-Domain":y,"X-Tenant-ID":x},body:JSON.stringify({input_data:p,...h.executionTitle?{execution_title:h.executionTitle}:{}}),signal:g.signal});if(!_.ok)throw new Error(`HTTP ${_.status}`);if(!_.body)throw new Error("No response body");await i(_.body.getReader())}catch(_){if(_.name!=="AbortError")throw _}},[i]),o=m.useCallback(async(f,p,h={})=>{var S;(S=e.current)==null||S.abort();const g=new AbortController;e.current=g;const v=localStorage.getItem("sso_token")||"",y=localStorage.getItem("sso_domain")||"",x=localStorage.getItem("sso_company")||"",w=Gi();try{const _=await fetch(`${w}/api/v1/custom-agents/results/recommended-execute`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",Authorization:`Bearer ${v}`,"X-Domain":y,"X-Tenant-ID":x},body:JSON.stringify({result_id:f,recommended_template_id:p,input_data:h.inputData??{},...h.executionTitle?{execution_title:h.executionTitle}:{}}),signal:g.signal});if(!_.ok)throw new Error(`HTTP ${_.status}`);const C=_.headers.get("content-type")||"";if(!_.body||!C.includes("text/event-stream")){const $=await _.json().catch(()=>null);throw qR($)&&typeof $.message=="string"&&$.message?new Error($.message):new Error("推荐智能体执行失败")}await i(_.body.getReader())}catch(_){if(_.name!=="AbortError")throw _}},[i]),s=m.useCallback(async f=>{var x;(x=e.current)==null||x.abort();const p=new AbortController;e.current=p;const h=localStorage.getItem("sso_token")||"",g=localStorage.getItem("sso_domain")||"",v=localStorage.getItem("sso_company")||"",y=Gi();try{const w=await fetch(`${y}/api/v1/custom-agents/executions/stream/${f}`,{headers:{Authorization:`Bearer ${h}`,"X-Domain":g,"X-Tenant-ID":v},signal:p.signal});if(!w.ok)throw new Error(`HTTP ${w.status}`);if(!w.body)throw new Error("No response body");await i(w.body.getReader())}catch(w){if(w.name!=="AbortError")throw w}},[i]),l=m.useCallback(()=>{var f;(f=e.current)==null||f.abort(),e.current=null},[]),c=m.useCallback(async(f,p,h,g={})=>{var C;(C=e.current)==null||C.abort();const v=new AbortController;e.current=v,t.getState().setCurrentExecutionId(f);const y=localStorage.getItem("sso_token")||"",x=localStorage.getItem("sso_domain")||"",w=localStorage.getItem("sso_company")||"",S=Gi(),_={step_id:p,input_data:h};g.action&&(_.action=g.action),g.action!=="return_previous"&&g.confirmedInput!==void 0?_.confirmed_input=g.confirmedInput:(!g.action||g.action==="input"||g.action==="modify")&&(_.confirmed_input=h),g.modifiedParams!==void 0&&(_.modified_params=g.modifiedParams);try{const $=await fetch(`${S}/api/v1/custom-agents/executions/resume/${f}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`,"X-Domain":x,"X-Tenant-ID":w},body:JSON.stringify(_),signal:v.signal});if(!$.ok)throw new Error(`HTTP ${$.status}`);const E=$.headers.get("content-type")||"";if(!$.body||!E.includes("text/event-stream")){$.body&&await $.text().catch(()=>"");return}await i($.body.getReader())}catch($){if($.name!=="AbortError")throw $}},[i]),u=m.useCallback(async(f,p)=>{var w;(w=e.current)==null||w.abort();const h=new AbortController;e.current=h;const g=localStorage.getItem("sso_token")||"",v=localStorage.getItem("sso_domain")||"",y=localStorage.getItem("sso_company")||"",x=Gi();try{const S=await fetch(`${x}/api/v1/custom-agents/executions/resume/${f}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",Authorization:`Bearer ${g}`,"X-Domain":v,"X-Tenant-ID":y},body:JSON.stringify({step_id:p,action:"re_execute"}),signal:h.signal});if(!S.ok){const C=await S.json().catch(()=>null);throw new Error(qR(C)&&typeof C.message=="string"&&C.message?C.message:`HTTP ${S.status}`)}const _=S.headers.get("content-type")||"";S.body&&_.includes("text/event-stream")?await i(S.body.getReader()):S.body&&await S.text().catch(()=>"")}catch(S){if(!(S instanceof DOMException&&S.name==="AbortError"))throw S}},[i]),d=m.useCallback(async(f,p)=>{var w;(w=e.current)==null||w.abort();const h=new AbortController;e.current=h;const g=localStorage.getItem("sso_token")||"",v=localStorage.getItem("sso_domain")||"",y=localStorage.getItem("sso_company")||"",x=Gi();try{const S=await fetch(`${x}/api/v1/custom-agents/transfers/accept/${f}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`,"X-Domain":v,"X-Tenant-ID":y},body:JSON.stringify(p),signal:h.signal});if(!S.ok)throw new Error(`HTTP ${S.status}`);if(!S.body)throw new Error("No response body");await i(S.body.getReader()),await Ys(n,{type:"transfer-accepted",createdAgent:p.action==="create_new",agentId:p.agent_id})}catch(S){if(S.name!=="AbortError")throw S}},[i,n]);return{startExecution:a,startRecommendedExecution:o,resumeExecution:c,reExecuteStep:u,reconnect:s,acceptTransfer:d,abort:l}}function fp(e){return e!=null&&e!==""}function oLe(e){return String(e.widget??e["ui:widget"]??e.ui_component??e.component??"").toLowerCase()}function sLe(e){const t=oLe(e);return t==="file"||t==="upload"||e.type==="file"||e.format==="binary"||e.format==="file"||typeof e.file_type=="string"}function FWt(e){return typeof e=="string"?{url:e}:e}function BWt({path:e,schema:t,value:n,values:r,disabled:i,uploadDisabled:a,uploadFile:o,onChange:s}){const[l,c]=m.useState(!1),[u,d]=m.useState(0),[f,p]=m.useState(""),[h,g]=m.useState({}),v=m.useRef([]);m.useEffect(()=>()=>{for(const E of v.current)E.abort()},[]);const y=t.type==="array"||Number(t.max_files??t.maxItems??1)>1,x=Number(t.max_files??t.maxItems??1),w=Array.isArray(n)?n.map(String):fp(n)?[String(n)]:[],S=w.map((E,k)=>({uid:String(k),name:h[E]||E.split("/").pop()||`file_${k+1}`,status:"done",url:E})),_=async({file:E,onSuccess:k,onError:T})=>{if(!o){const P=new Error("未配置文件上传器");p(P.message),T==null||T(P);return}const I=new AbortController;v.current.push(I),c(!0),d(0),p("");try{const P=FWt(await o({file:E,path:e,schema:t,values:r,signal:I.signal,onProgress:d}));if(I.signal.aborted)return;const N=P.name;N&&g(A=>({...A,[P.url]:N})),s(e,y?[...w,P.url]:P.url),k==null||k(P)}catch(P){if(I.signal.aborted)return;const N=P instanceof Error?P:new Error("文件上传失败");p(N.message),T==null||T(N)}finally{c(!1),v.current=v.current.filter(P=>P!==I)}},C=String(t.accept??t.file_type??t.contentMediaType??"")||void 0,$=i||a;return b.jsxs("div",{className:"schema-dynamic-form__upload",children:[b.jsx(zc,{accept:C,fileList:S,customRequest:_,disabled:$||l,maxCount:Number.isFinite(x)?x:void 0,onRemove:$?void 0:E=>{const k=w.filter((T,I)=>I!==Number(E.uid));return s(e,y?k:""),!0},children:w.length<x&&b.jsx(Et,{disabled:$,icon:l?b.jsx(vr,{size:"small"}):b.jsx(tpt,{}),children:l?`上传中 ${Math.round(u)}%`:"上传文件"})}),f&&b.jsx("div",{className:"schema-dynamic-form__async-error",children:f})]})}function Ut(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mi(e){return Array.isArray(e)?e:[]}function ls(e,t=""){return typeof e=="string"?e:t}function IC(e){return e.map(String).join(".")}function AU(e,t){return t.reduce((n,r)=>{if(Array.isArray(n)&&typeof r=="number")return n[r];if(Ut(n))return n[String(r)]},e)}function kC(e,t,n){if(t.length===0)return Ut(n)?n:e;const[r,...i]=t;if(typeof r=="number")return e;const a=e[r];if(i.length===0)return{...e,[r]:n};if(typeof i[0]=="number"){const s=Array.isArray(a)?[...a]:[],[l,...c]=i;if(c.length===0)s[l]=n;else{const u=Ut(s[l])?s[l]:{};s[l]=kC(u,c,n)}return{...e,[r]:s}}const o=Ut(a)?a:{};return{...e,[r]:kC(o,i,n)}}function VWt(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function iJ(e,t){if(t.startsWith("#/"))return t.slice(2).split("/").map(VWt).reduce((n,r)=>{if(Ut(n))return n[r]},e)}function Ag(e,t){if("if"in t)return{...e,allOf:[...Mi(e.allOf),t]};const n=Ut(e.properties)?e.properties:{},r=Ut(t.properties)?t.properties:{},i={...n};for(const[s,l]of Object.entries(r))i[s]=Ag(Ut(n[s])?n[s]:{},Ut(l)?l:{});const a=Array.from(new Set([...Mi(e.required),...Mi(t.required)])),o={...e,...t,...Object.keys(n).length||Object.keys(r).length?{properties:i}:{},...a.length?{required:a}:{}};for(const s of["items","not","$defs","definitions"])Ut(e[s])&&Ut(t[s])&&(o[s]=Ag(e[s],t[s]));return(e.allOf||t.allOf)&&(o.allOf=[...Mi(e.allOf),...Mi(t.allOf)]),o}function HWt(e,t){return"const"in e?Object.is(e.const,t):Array.isArray(e.enum)?e.enum.some(n=>Object.is(n,t)):e.type==="object"?Ut(t):e.type==="array"?Array.isArray(t):e.type==="string"?typeof t=="string":e.type==="number"||e.type==="integer"?typeof t=="number":e.type==="boolean"?typeof t=="boolean":!1}function WWt(e){return Object.fromEntries(Object.entries(e).filter(([t])=>!["allOf","if","then","else"].includes(t)))}function B2(e){return Array.isArray(e)?e.some(B2):Ut(e)?Object.values(e).some(B2):e!=null&&e!==""}function Pve(e,t){if(Object.is(e,t))return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!="object")return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function UWt(e,t){return e==="array"?Array.isArray(t):e==="object"?Ut(t):e==="integer"?Number.isInteger(t):e==="number"?typeof t=="number":e==="boolean"?typeof t=="boolean":e==="string"?typeof t=="string":e==="null"?t===null:!0}function pp(e,t,n,r=new Set){if(!Ut(t))return!0;let i=t,a=r;if(typeof i.$ref=="string"&&!r.has(i.$ref)){const u=i.$ref,d=iJ(e,u);i=Ag(Ut(d)?d:{},Object.fromEntries(Object.entries(i).filter(([f])=>f!=="$ref"))),a=new Set(r).add(u)}const o=Mi(i.allOf);if(o.length&&!o.every(u=>pp(e,u,n,a)))return!1;const s=Mi(i.anyOf);if(s.length&&!s.some(u=>pp(e,u,n,a)))return!1;const l=Mi(i.oneOf);if(l.length&&l.filter(u=>pp(e,u,n,a)).length!==1||i.not!==void 0&&pp(e,i.not,n,a))return!1;const c=Mi(i.required).map(String);if(c.length&&(!Ut(n)||!c.every(u=>B2(n[u]))))return!1;if(Ut(i.properties)){if(!Ut(n))return!1;for(const[u,d]of Object.entries(i.properties))if(n[u]!==void 0&&!pp(e,d,n[u],a))return!1}return!(i.contains!==void 0&&(!Array.isArray(n)||!n.some(u=>pp(e,i.contains,u,a)))||i.items!==void 0&&Array.isArray(n)&&!n.every(u=>pp(e,i.items,u,a))||Array.isArray(i.enum)&&!i.enum.some(u=>Pve(u,n))||"const"in i&&!Pve(i.const,n)||i.type!==void 0&&!(Array.isArray(i.type)?i.type.map(String):[String(i.type)]).some(d=>UWt(d,n)))}function Yr(e,t,n,r=new Set){if(!Ut(t))return{};let i={...t};if(typeof i.$ref=="string"&&!r.has(i.$ref)){const s=i.$ref,l=iJ(e,s),c=new Set(r).add(s);i=Ag(Yr(e,l,n,c),Object.fromEntries(Object.entries(i).filter(([u])=>u!=="$ref")))}let a=WWt(i);for(const s of Mi(i.allOf))a=Ag(a,Yr(e,s,n,r));if("if"in i&&n!==void 0){const s=pp(e,i.if,n,r)?i.then:i.else;a=Ag(a,Yr(e,s,n,r))}const o=Mi(a.oneOf).length?Mi(a.oneOf):Mi(a.anyOf);if(o.length){const s=o.find(l=>HWt(Yr(e,l,n,r),n))??o[0];a=Ag(a,Yr(e,s,n,r))}return a}function S1(e){const t=Ut(e.not)?e.not:{};return new Set(Mi(t.required).map(String))}function V2(e,t,n){const r=Yr(e,t,n);if(kb(r))return!1;const i=Vh(r,n);if(i==="array")return Array.isArray(n)&&n.some(a=>V2(e,r.items,a));if(i==="object"){if(!Ut(n))return!1;const a=Ut(r.properties)?r.properties:{},o=S1(r);return Object.entries(n).some(([s,l])=>{if(o.has(s))return!1;const c=a[s];return c?V2(e,c,l):B2(l)})}return B2(n)}function og(e,t,n,r=0){if(r>24)return!0;const i=Yr(e,t,n);if(kb(i))return!1;const a=Vh(i,n);if(a==="array")return(Array.isArray(n)&&n.length>0?n:[void 0]).some(s=>og(e,i.items,s,r+1));if(a==="object"){const o=Ut(i.properties)?i.properties:{},s=Ut(n)?n:{},l=S1(i);return Object.entries(o).some(([c,u])=>!l.has(c)&&og(e,u,s[c],r+1))}return!0}function KR(e,t,n=e,r=t){const i=Yr(e,n,t),a=Vh(i,t);if(a==="array"){if(!Array.isArray(t))return t;const u=Array.isArray(r)?r:[];return t.map((d,f)=>KR(e,d,i.items,u[f]))}if(a!=="object"||!Ut(t)||!Ut(i.properties))return t;const o=i.properties,s=Ut(r)?r:{},l=S1(i),c=new Set(Mi(i.required).map(String));return Object.fromEntries(Object.entries(t).filter(([u])=>{if(l.has(u))return!1;if(c.has(u))return!0;const d=o[u];return d?V2(e,d,s[u]):u in s}).map(([u,d])=>[u,KR(e,d,o[u],s[u])]))}function YR(e,t,n=e,r=[]){let i=t,a=Yr(e,n,i);if(Vh(a,i)==="array"&&Array.isArray(i))return i.map((d,f)=>YR(e,d,a.items,r[0]===f?r.slice(1):[]));if(!Ut(i)||!Ut(a.properties))return i;let s=a.properties,l=S1(a);const c=typeof r[0]=="string"?r[0]:void 0;if(c&&l.has(c)){const d=Object.fromEntries(Object.entries(i).filter(([h])=>h===c||!l.has(h))),f=Yr(e,n,d),p=S1(f);p.has(c)||(i=d,a=f,l=p,Ut(f.properties)&&(s=f.properties))}const u=Ut(i)?i:{};return Object.fromEntries(Object.entries(u).filter(([d])=>!l.has(d)).map(([d,f])=>[d,YR(e,f,s[d],c===d?r.slice(1):[])]))}function Vh(e,t){const n=Array.isArray(e.type)?e.type.find(r=>r!=="null"):e.type;return typeof n=="string"?n:Ut(e.properties)?"object":e.items||Array.isArray(t)?"array":Ut(t)?"object":"string"}function XR(e,t){return ls(t.title,e)}function lLe(e){return ls(e.description)}function GWt(e,t){if(!Ut(e.propertyGroups))return[];const n=[],r=new Set;for(const[a,o]of Object.entries(e.propertyGroups)){if(!Ut(o))continue;const s=Mi(o.propertyNames??o.properties??o.fields??o.items).map(String).filter(u=>u in t&&!r.has(u));if(!s.length)continue;for(const u of s)r.add(u);const l=Number(o.columns),c=Number.isFinite(l)?Math.min(Math.max(Math.trunc(l),1),4):void 0;n.push({key:a,title:ls(o.title??o.label,a),description:ls(o.description)||void 0,propertyNames:s,...c?{columns:c}:{}})}const i=Object.keys(t).filter(a=>!r.has(a));return i.length&&n.push({key:"__ungrouped",title:"其他字段",propertyNames:i}),n}function kb(e){return e.hidden===!0||e["x-hidden"]===!0}function qWt(e){return e.readOnly===!0||e.readonly===!0}function Nve(e,t){const n=Yr(e,t),r=Array.isArray(n.enum)?n.enum:[],i=Mi(n.oneOf).length?Mi(n.oneOf):Mi(n.anyOf),a=i.map(u=>Yr(e,u)).find(u=>Array.isArray(u.enum)&&u.enum.length>0),o=i.map(u=>Yr(e,u)).filter(u=>"const"in u).map(u=>({value:u.const,label:ls(u.title,String(u.const??""))})),s=r.length?r:Array.isArray(a==null?void 0:a.enum)?a.enum:[];if(!s.length)return o;const l=r.length?n:a??{},c=Array.isArray(l.enumNames)?l.enumNames:Array.isArray(l["x-enumNames"])?l["x-enumNames"]:[];return s.map((u,d)=>({value:u,label:String(c[d]??u)}))}function KWt(e,t){const n=Yr(e,t);return[...Mi(n.oneOf),...Mi(n.anyOf)].some(i=>{const a=Yr(e,i);return(Array.isArray(a.type)?a.type.map(String):[String(a.type??"")]).includes("string")&&a.enum===void 0&&a.const===void 0})}function cLe(e){return e.options_from_skill??e.optionsSource??e["x-options-source"]??e["x-optionsSource"]}function YWt(e){const t=e.options_params??e.optionsParams??e["x-options-params"]??e["x-optionsParams"];return Ut(t)?t:{}}const uLe=/\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}/g,XWt=/^\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}$/;function aJ(e){const t=new Set,n=r=>{if(typeof r=="string"){for(const i of r.matchAll(uLe))i[1]&&t.add(i[1]);return}Array.isArray(r)?r.forEach(n):Ut(r)&&Object.values(r).forEach(n)};return n(e),Array.from(t)}function MU(e,t){if(typeof e=="string"){const n=e.match(XWt);return n!=null&&n[1]?AU(t,n[1].split(".")):e.replace(uLe,(r,i)=>{const a=AU(t,i.split("."));return a==null?"":String(a)})}return Array.isArray(e)?e.map(n=>MU(n,t)):Ut(e)?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,MU(r,t)])):e}function ZR(e,t=e){const n=Yr(e,t);if("default"in n)return n.default;if("const"in n)return n.const;if(Array.isArray(n.enum)&&n.enum.length===1)return n.enum[0];const r=Vh(n);if(r==="object"){const i=Ut(n.properties)?n.properties:{},a={};for(const[o,s]of Object.entries(i)){const l=ZR(e,s);l!==void 0&&(a[o]=l)}return a}if(r==="array"){const i=typeof n.minItems=="number"?n.minItems:0;if(i<=0)return;const a=ZR(e,n.items);return a===void 0?void 0:Array.from({length:i},()=>a)}}function Ave(e,t){const n=(i,a,o)=>{if(!o)return i;if(Array.isArray(a))return Array.isArray(i)?a.map((s,l)=>n(i[l]??i[0],s,!0)):a;if(Ut(a)){const s=Ut(i)?i:{};return Object.fromEntries(Array.from(new Set([...Object.keys(s),...Object.keys(a)])).map(l=>[l,n(s[l],a[l],Object.prototype.hasOwnProperty.call(a,l))]))}return a},r=n(e,t,t!==void 0);return Ut(r)?r:{}}const Mve=new Map;function ZWt(e){return e==null||e===""}function QWt(e){if(Array.isArray(e))return e;if(!Ut(e))return[];const t="data"in e?e.data:e;if(Array.isArray(t))return t;if(!Ut(t))return[];const n=[t.options,t.items,t.results,t.list,t.output_data,t.data];return Ut(t.output)&&n.push(t.output.options,t.output.items,t.output.results,t.output.list,t.output.output_data,t.output.data),n.find(Array.isArray)??[]}function JWt(e){let t;return{options:QWt(e).map(r=>{if(["string","number","boolean"].includes(typeof r))return{value:r,label:String(r)};if(!Ut(r))return null;const i=r.value??r.key??r.code??r.id??r.name??r.label;if(!["string","number","boolean"].includes(typeof i))return null;const a=String(r.label??r.title??r.text??r.name??i);return String(i)===""?(a&&!t&&(t=a),null):{value:i,label:a}}).filter(r=>r!==null),placeholder:t}}function eUt({schema:e,path:t,values:n,search:r,loadOptions:i}){const a=cLe(e),o=YWt(e),s=m.useMemo(()=>aJ(o),[o]),l=e.optionsBlockingDependencies??e["x-options-blocking-dependencies"],d=(Array.isArray(l)?l.map(String):s).map(w=>AU(n,w.split("."))).some(ZWt),f=MU(o,n),p=e.remoteSearch===!0||e["x-remote-search"]===!0,h=JSON.stringify({source:a,params:f,waitingForDependencies:d}),g=JSON.stringify({path:IC(t),dependencySignature:h,search:p?r:""}),[v,y]=m.useState({options:[],loading:!1}),x=m.useRef({path:t,schema:e,params:f,values:n,search:p?r:""});return x.current={path:t,schema:e,params:f,values:n,search:p?r:""},m.useEffect(()=>{if(!a||d){y({options:[],loading:!1});return}if(!i){y({options:[],loading:!1,error:"未配置动态选项加载器"});return}const w=Mve.get(g);if(w){y({...w,loading:!1});return}const S=new AbortController;y(C=>({...C,loading:!0,error:void 0}));const _=x.current;return i({path:_.path,schema:_.schema,source:a,params:_.params,values:_.values,search:_.search,signal:S.signal}).then(C=>{if(S.signal.aborted)return;const $=JWt(C);Mve.set(g,$),y({...$,loading:!1})}).catch(C=>{S.signal.aborted||y({options:[],loading:!1,error:C instanceof Error?C.message:"动态选项加载失败"})}),()=>S.abort()},[g,i,a,d]),{...v,waitingForDependencies:d,dependencySignature:h,hasDynamicSource:a!=null&&a!==""}}function tUt({name:e,path:t,schema:n,rootSchema:r,value:i,values:a,required:o,errors:s,disabled:l,loadOptions:c,uploadFile:u,disableFileUpload:d,onChange:f}){const p=Yr(r,n,i),h=Vh(p,i),g=oLe(p),v=XR(e,p),y=lLe(p),x=s[IC(t)],[w,S]=m.useState(""),_=m.useMemo(()=>Nve(r,p),[r,p]),C=m.useMemo(()=>KWt(r,p),[r,p]),$=eUt({schema:p,path:t,values:a,search:w,loadOptions:c}),E=$.hasDynamicSource?$.options:_,k=m.useRef();m.useEffect(()=>{const I=p.clearOnOptionsChange===!0||p["x-clear-on-options-change"]===!0;if(!$.hasDynamicSource||!I){k.current=void 0;return}const P=k.current;k.current=$.dependencySignature;const N=Array.isArray(i)?i.length>0:fp(i),A=P!==void 0&&P!==$.dependencySignature;N&&($.waitingForDependencies||A)&&f(t,h==="array"?[]:void 0)},[$.dependencySignature,$.hasDynamicSource,$.waitingForDependencies,f,t,p,h,i]);let T;if(sLe(p))T=b.jsx(BWt,{path:t,schema:p,value:i,values:a,disabled:l,uploadDisabled:d,uploadFile:u,onChange:f});else if(h==="array"){const I=Yr(r,p.items),P=Nve(r,I),N=E.length?E:P;T=b.jsx(tn,{mode:N.length?"multiple":"tags",showSearch:!0,allowClear:!0,value:Array.isArray(i)?i:[],options:N,loading:$.loading,disabled:l||$.waitingForDependencies,placeholder:$.waitingForDependencies?"请先填写关联字段":$.placeholder||ls(p.placeholder,"请选择"),optionFilterProp:"label",filterOption:(A,M)=>String((M==null?void 0:M.label)??"").toLowerCase().includes(A.trim().toLowerCase()),onSearch:S,onChange:A=>f(t,A)})}else if(E.length||cLe(p)){const I=E.map(M=>({value:String(M.value),label:M.label})),P=$.waitingForDependencies?"请先填写关联字段":$.placeholder||ls(p.placeholder,g==="select"?"请选择":"请选择或输入"),N=M=>{const R=E.find(L=>String(L.value)===M);return(R==null?void 0:R.value)??M};T=g==="select"||g!=="autocomplete"&&_.length>0&&!C?b.jsx(tn,{allowClear:!0,showSearch:!0,value:fp(i)?String(i):void 0,options:I,loading:$.loading,disabled:l||$.waitingForDependencies,placeholder:P,optionFilterProp:"label",filterOption:(M,R)=>String((R==null?void 0:R.label)??(R==null?void 0:R.value)??"").toLowerCase().includes(M.trim().toLowerCase()),onSearch:S,onChange:M=>f(t,M===void 0?void 0:N(M)),notFoundContent:$.loading?b.jsx(vr,{size:"small"}):null}):b.jsx(uO,{allowClear:!0,value:fp(i)?String(i):"",options:I,disabled:l||$.waitingForDependencies,placeholder:P,filterOption:(M,R)=>String((R==null?void 0:R.label)??(R==null?void 0:R.value)??"").toLowerCase().includes(M.trim().toLowerCase()),onSearch:S,onChange:M=>f(t,M),onSelect:M=>f(t,N(M)),notFoundContent:$.loading?b.jsx(vr,{size:"small"}):null})}else if(h==="boolean")T=b.jsx(yo,{checked:!!i,disabled:l,onChange:I=>f(t,I)});else if(h==="number"||h==="integer")T=b.jsx(zo,{style:{width:"100%"},value:typeof i=="number"?i:null,disabled:l,min:typeof p.minimum=="number"?p.minimum:void 0,max:typeof p.maximum=="number"?p.maximum:void 0,placeholder:ls(p.placeholder,"请输入"),step:typeof p.multipleOf=="number"?p.multipleOf:void 0,precision:h==="integer"?0:void 0,onChange:I=>f(t,I)});else if(g==="date"||g==="datetime"||p.format==="date"||p.format==="date-time"){const I=g==="datetime"||p.format==="date-time"||p["x-temporal-show-time"]===!0?"datetime":"date",P=bu({type:I,format:ls(p["x-temporal-format"]),picker:ls(p["x-temporal-picker"]),show_time:typeof p["x-temporal-show-time"]=="boolean"?p["x-temporal-show-time"]:void 0});T=b.jsx(ui,{style:{width:"100%"},value:fp(i)?In(String(i)):null,picker:I==="date"?b1(P,ls(p["x-temporal-picker"])):void 0,showTime:I==="datetime"?{format:ov(P)}:!1,format:P,disabled:l,onChange:(N,A)=>f(t,A)})}else if(p.format==="time"||g==="time"){const I=bu({type:"time",format:ls(p["x-temporal-format"])});T=b.jsx(Ua,{style:{width:"100%"},value:fp(i)?In(String(i),"HH:mm"):null,format:I,disabled:l,onChange:(P,N)=>f(t,N)})}else g==="textarea"||p.format==="textarea"||Number(p.maxLength??0)>240?T=b.jsx(Kt.TextArea,{autoSize:{minRows:2,maxRows:10},value:fp(i)?String(i):"",disabled:l,placeholder:ls(p.placeholder,"请输入"),onChange:I=>f(t,I.target.value)}):T=b.jsx(Kt,{type:p.format==="uri"||p.format==="url"?"url":void 0,value:fp(i)?String(i):"",disabled:l,placeholder:ls(p.placeholder,"请输入"),onChange:I=>f(t,I.target.value)});return b.jsx(pn.Item,{label:v,required:o,className:["schema-dynamic-form__property",p.fullWidth===!0||p["x-full-width"]===!0?"schema-dynamic-form__field--full-width":void 0].filter(Boolean).join(" "),tooltip:y||void 0,validateStatus:x?"error":void 0,help:x||$.error||void 0,children:T})}function RU(e){const{name:t,path:n,rootSchema:r,values:i,required:a=!1,forcePrimaryRequired:o=!1,errors:s,disabled:l,respectReadonly:c,showArrayControls:u,groupDisplay:d,groupAccordion:f,destroyInactiveGroups:p,defaultExpandedGroupKeys:h,expandedGroupKeys:g,onExpandedGroupKeysChange:v,visibleFieldPaths:y,loadOptions:x,uploadFile:w,disableFileUpload:S,onChange:_}=e,C=Yr(r,e.schema,e.value),$=e.value,E=e.sourceValue,k=Vh(C,$),T=l||c&&qWt(C),I=XR(t,C),P=lLe(C),N=s[IC(n)],A=M=>{if(!y)return!0;const R=IC(M);return Array.from(y).some(L=>L===R||L.startsWith(`${R}.`)||R.startsWith(`${L}.`))};if(kb(C)||!og(r,C,$))return null;if(k==="object"){const M=Ut(C.properties)?C.properties:{},R=S1(C),L=Object.fromEntries(Object.entries(M).filter(([U])=>!R.has(U))),z=new Set((Array.isArray(C.required)?C.required.map(String):[]).filter(U=>!R.has(U))),j=n.length===0||a||V2(r,C,E),O=o?Object.keys(L).find(U=>U==="value"&&!kb(Yr(r,L[U])))??Object.keys(L).find(U=>!kb(Yr(r,L[U]))):void 0,V=GWt(C,L),B=U=>{const q=[...n,U];if(!A(q))return null;const Q=Ut(L[U])?L[U]:{},G=Ut($)?$[U]:void 0;if(!og(r,Q,G))return null;const X=Ut(E)?E[U]:void 0;return b.jsx(RU,{...e,name:U,path:q,schema:Q,value:G,sourceValue:X,required:j&&(z.has(U)||O===U),forcePrimaryRequired:!1},U)},D=U=>U?{"--schema-dynamic-form-columns":U}:void 0,F=V.map(U=>({...U,propertyNames:U.propertyNames.filter(q=>{const Q=[...n,q],G=Ut(L[q])?L[q]:{},X=Ut($)?$[q]:void 0;return A(Q)&&og(r,G,X)})})).filter(U=>U.propertyNames.length>0),H=F.map(U=>b.jsxs("section",{className:"schema-dynamic-form__group",children:[b.jsxs("div",{className:"schema-dynamic-form__group-heading",children:[b.jsx("strong",{children:U.title}),U.description&&b.jsx("span",{children:U.description})]}),b.jsx("div",{className:"schema-dynamic-form__group-fields",style:D(U.columns),children:U.propertyNames.map(B)})]},U.key)),W=F.map(U=>({key:U.key,label:b.jsxs("div",{className:"schema-dynamic-form__collapse-label",children:[b.jsxs("span",{className:"schema-dynamic-form__collapse-copy",children:[b.jsx("strong",{children:U.title}),U.description&&b.jsx("span",{children:U.description})]}),b.jsxs("span",{className:"schema-dynamic-form__collapse-count",children:[U.propertyNames.length," 项"]})]}),children:b.jsx("div",{className:"schema-dynamic-form__group-fields",style:D(U.columns),children:U.propertyNames.map(B)})})),K=F.length?d==="collapse"?b.jsx(Gq,{className:"schema-dynamic-form__collapse",accordion:f,destroyOnHidden:p,...n.length===0&&g!==void 0?{activeKey:g}:{defaultActiveKey:h},onChange:n.length===0&&v?U=>v((Array.isArray(U)?U:[U]).map(String)):void 0,expandIconPlacement:"end",items:W}):H:Object.keys(L).filter(U=>{const q=Ut($)?$[U]:void 0;return og(r,L[U],q)}).map(B);return n.length===0?b.jsx(b.Fragment,{children:K}):typeof n[n.length-1]=="number"?b.jsx("div",{className:"schema-dynamic-form__object schema-dynamic-form__object--array-item",children:K}):b.jsx(pn.Item,{label:I,required:a,tooltip:P||void 0,className:"schema-dynamic-form__property schema-dynamic-form__property--object",validateStatus:N?"error":void 0,help:N||void 0,children:b.jsx("div",{className:"schema-dynamic-form__object schema-dynamic-form__object--nested",children:K})})}if(k==="array"&&!sLe(C)){const M=Ut(C.items)?C.items:{};if(Vh(Yr(r,M))==="object"){const L=Array.isArray($)?$:[],z=Array.isArray(E)?E:[],j=Ut(M.properties)?M.properties:{},O=Object.keys(j).filter(q=>(L.length===0?A([...n,0,q]):L.some((Q,G)=>A([...n,G,q])))&&!kb(Yr(r,j[q]))),V=L.map((q,Q)=>({row:q,index:Q})).filter(({row:q,index:Q})=>A([...n,Q])&&og(r,M,q));if(V.length===0&&!u)return null;const B=O.length===1,D=!u&&V.length<=1,H=!(n.length===1&&D&&B&&XR(O[0],Yr(r,j[O[0]]))===I),W=Number(C.minItems??0),K=Number(C.maxItems??Number.POSITIVE_INFINITY),U=()=>{const q=ZR(r,M);_(n,[...L,Ut(q)?q:{}])};return b.jsx(pn.Item,{label:H?I:void 0,required:H?a:!1,tooltip:H&&P?P:void 0,className:`schema-dynamic-form__property${H?" schema-dynamic-form__property--nested":" schema-dynamic-form__property--flat"}`,validateStatus:N?"error":void 0,help:N||void 0,children:b.jsxs("div",{className:`schema-dynamic-form__array${D?" schema-dynamic-form__array--compact":""}`,children:[V.map(({row:q,index:Q})=>b.jsxs("div",{className:`schema-dynamic-form__array-row${D?" schema-dynamic-form__array-row--compact":" schema-dynamic-form__array-row--multiple"}${D&&n.length>1?" schema-dynamic-form__array-row--framed":""}`,children:[(!D||u)&&b.jsxs("div",{className:"schema-dynamic-form__array-row-heading",children:[b.jsxs("span",{children:["第 ",Q+1," 项"]}),u&&b.jsx(or,{title:"删除",children:b.jsx(Et,{type:"text",danger:!0,icon:b.jsx(hf,{}),disabled:T||L.length<=W,onClick:()=>_(n,L.filter((G,X)=>X!==Q))})})]}),b.jsx(RU,{...e,name:String(Q),path:[...n,Q],schema:M,value:q,sourceValue:z[Q],required:a||V2(r,C,E),forcePrimaryRequired:n.length===1&&a})]},`${IC(n)}-${Q}`)),u&&b.jsx(Et,{type:"dashed",icon:b.jsx(Uo,{}),disabled:T||L.length>=K,onClick:U,children:"添加一项"})]})})}}return b.jsx(tUt,{name:t,path:n,schema:C,rootSchema:r,value:$,values:i,required:a,errors:s,disabled:T,loadOptions:x,uploadFile:w,disableFileUpload:S,onChange:_})}var DU={exports:{}},dLe={},Mc={},_1={},yT={},Wn={},H2={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class n extends t{constructor(x){if(super(),!e.IDENTIFIER.test(x))throw new Error("CodeGen: name must be a valid identifier");this.str=x}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=n;class r extends t{constructor(x){super(),this._items=typeof x=="string"?[x]:x}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const x=this._items[0];return x===""||x==='""'}get str(){var x;return(x=this._str)!==null&&x!==void 0?x:this._str=this._items.reduce((w,S)=>`${w}${S}`,"")}get names(){var x;return(x=this._names)!==null&&x!==void 0?x:this._names=this._items.reduce((w,S)=>(S instanceof n&&(w[S.str]=(w[S.str]||0)+1),w),{})}}e._Code=r,e.nil=new r("");function i(y,...x){const w=[y[0]];let S=0;for(;S<x.length;)s(w,x[S]),w.push(y[++S]);return new r(w)}e._=i;const a=new r("+");function o(y,...x){const w=[p(y[0])];let S=0;for(;S<x.length;)w.push(a),s(w,x[S]),w.push(a,p(y[++S]));return l(w),new r(w)}e.str=o;function s(y,x){x instanceof r?y.push(...x._items):x instanceof n?y.push(x):y.push(d(x))}e.addCodeArg=s;function l(y){let x=1;for(;x<y.length-1;){if(y[x]===a){const w=c(y[x-1],y[x+1]);if(w!==void 0){y.splice(x-1,3,w);continue}y[x++]="+"}x++}}function c(y,x){if(x==='""')return y;if(y==='""')return x;if(typeof y=="string")return x instanceof n||y[y.length-1]!=='"'?void 0:typeof x!="string"?`${y.slice(0,-1)}${x}"`:x[0]==='"'?y.slice(0,-1)+x.slice(1):void 0;if(typeof x=="string"&&x[0]==='"'&&!(y instanceof n))return`"${y}${x.slice(1)}`}function u(y,x){return x.emptyStr()?y:y.emptyStr()?x:o`${y}${x}`}e.strConcat=u;function d(y){return typeof y=="number"||typeof y=="boolean"||y===null?y:p(Array.isArray(y)?y.join(","):y)}function f(y){return new r(p(y))}e.stringify=f;function p(y){return JSON.stringify(y).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.safeStringify=p;function h(y){return typeof y=="string"&&e.IDENTIFIER.test(y)?new r(`.${y}`):i`[${y}]`}e.getProperty=h;function g(y){if(typeof y=="string"&&e.IDENTIFIER.test(y))return new r(`${y}`);throw new Error(`CodeGen: invalid export name: ${y}, use explicit $id name mapping`)}e.getEsmExportName=g;function v(y){return new r(y.toString())}e.regexpCode=v})(H2);var OU={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=H2;class n extends Error{constructor(c){super(`CodeGen: "code" for ${c} not defined`),this.value=c.value}}var r;(function(l){l[l.Started=0]="Started",l[l.Completed=1]="Completed"})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class i{constructor({prefixes:c,parent:u}={}){this._names={},this._prefixes=c,this._parent=u}toName(c){return c instanceof t.Name?c:this.name(c)}name(c){return new t.Name(this._newName(c))}_newName(c){const u=this._names[c]||this._nameGroup(c);return`${c}${u.index++}`}_nameGroup(c){var u,d;if(!((d=(u=this._parent)===null||u===void 0?void 0:u._prefixes)===null||d===void 0)&&d.has(c)||this._prefixes&&!this._prefixes.has(c))throw new Error(`CodeGen: prefix "${c}" is not allowed in this scope`);return this._names[c]={prefix:c,index:0}}}e.Scope=i;class a extends t.Name{constructor(c,u){super(u),this.prefix=c}setValue(c,{property:u,itemIndex:d}){this.value=c,this.scopePath=(0,t._)`.${new t.Name(u)}[${d}]`}}e.ValueScopeName=a;const o=(0,t._)`\n`;class s extends i{constructor(c){super(c),this._values={},this._scope=c.scope,this.opts={...c,_n:c.lines?o:t.nil}}get(){return this._scope}name(c){return new a(c,this._newName(c))}value(c,u){var d;if(u.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const f=this.toName(c),{prefix:p}=f,h=(d=u.key)!==null&&d!==void 0?d:u.ref;let g=this._values[p];if(g){const x=g.get(h);if(x)return x}else g=this._values[p]=new Map;g.set(h,f);const v=this._scope[p]||(this._scope[p]=[]),y=v.length;return v[y]=u.ref,f.setValue(u,{property:p,itemIndex:y}),f}getValue(c,u){const d=this._values[c];if(d)return d.get(u)}scopeRefs(c,u=this._values){return this._reduceValues(u,d=>{if(d.scopePath===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return(0,t._)`${c}${d.scopePath}`})}scopeCode(c=this._values,u,d){return this._reduceValues(c,f=>{if(f.value===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return f.value.code},u,d)}_reduceValues(c,u,d={},f){let p=t.nil;for(const h in c){const g=c[h];if(!g)continue;const v=d[h]=d[h]||new Map;g.forEach(y=>{if(v.has(y))return;v.set(y,r.Started);let x=u(y);if(x){const w=this.opts.es5?e.varKinds.var:e.varKinds.const;p=(0,t._)`${p}${w} ${y} = ${x};${this.opts._n}`}else if(x=f==null?void 0:f(y))p=(0,t._)`${p}${x}${this.opts._n}`;else throw new n(y);v.set(y,r.Completed)})}return p}}e.ValueScope=s})(OU);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=H2,n=OU;var r=H2;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=OU;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class a{optimizeNodes(){return this}optimizeNames(F,H){return this}}class o extends a{constructor(F,H,W){super(),this.varKind=F,this.name=H,this.rhs=W}render({es5:F,_n:H}){const W=F?n.varKinds.var:this.varKind,K=this.rhs===void 0?"":` = ${this.rhs}`;return`${W} ${this.name}${K};`+H}optimizeNames(F,H){if(F[this.name.str])return this.rhs&&(this.rhs=A(this.rhs,F,H)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class s extends a{constructor(F,H,W){super(),this.lhs=F,this.rhs=H,this.sideEffects=W}render({_n:F}){return`${this.lhs} = ${this.rhs};`+F}optimizeNames(F,H){if(!(this.lhs instanceof t.Name&&!F[this.lhs.str]&&!this.sideEffects))return this.rhs=A(this.rhs,F,H),this}get names(){const F=this.lhs instanceof t.Name?{}:{...this.lhs.names};return N(F,this.rhs)}}class l extends s{constructor(F,H,W,K){super(F,W,K),this.op=H}render({_n:F}){return`${this.lhs} ${this.op}= ${this.rhs};`+F}}class c extends a{constructor(F){super(),this.label=F,this.names={}}render({_n:F}){return`${this.label}:`+F}}class u extends a{constructor(F){super(),this.label=F,this.names={}}render({_n:F}){return`break${this.label?` ${this.label}`:""};`+F}}class d extends a{constructor(F){super(),this.error=F}render({_n:F}){return`throw ${this.error};`+F}get names(){return this.error.names}}class f extends a{constructor(F){super(),this.code=F}render({_n:F}){return`${this.code};`+F}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(F,H){return this.code=A(this.code,F,H),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class p extends a{constructor(F=[]){super(),this.nodes=F}render(F){return this.nodes.reduce((H,W)=>H+W.render(F),"")}optimizeNodes(){const{nodes:F}=this;let H=F.length;for(;H--;){const W=F[H].optimizeNodes();Array.isArray(W)?F.splice(H,1,...W):W?F[H]=W:F.splice(H,1)}return F.length>0?this:void 0}optimizeNames(F,H){const{nodes:W}=this;let K=W.length;for(;K--;){const U=W[K];U.optimizeNames(F,H)||(M(F,U.names),W.splice(K,1))}return W.length>0?this:void 0}get names(){return this.nodes.reduce((F,H)=>P(F,H.names),{})}}class h extends p{render(F){return"{"+F._n+super.render(F)+"}"+F._n}}class g extends p{}class v extends h{}v.kind="else";class y extends h{constructor(F,H){super(H),this.condition=F}render(F){let H=`if(${this.condition})`+super.render(F);return this.else&&(H+="else "+this.else.render(F)),H}optimizeNodes(){super.optimizeNodes();const F=this.condition;if(F===!0)return this.nodes;let H=this.else;if(H){const W=H.optimizeNodes();H=this.else=Array.isArray(W)?new v(W):W}if(H)return F===!1?H instanceof y?H:H.nodes:this.nodes.length?this:new y(R(F),H instanceof y?[H]:H.nodes);if(!(F===!1||!this.nodes.length))return this}optimizeNames(F,H){var W;if(this.else=(W=this.else)===null||W===void 0?void 0:W.optimizeNames(F,H),!!(super.optimizeNames(F,H)||this.else))return this.condition=A(this.condition,F,H),this}get names(){const F=super.names;return N(F,this.condition),this.else&&P(F,this.else.names),F}}y.kind="if";class x extends h{}x.kind="for";class w extends x{constructor(F){super(),this.iteration=F}render(F){return`for(${this.iteration})`+super.render(F)}optimizeNames(F,H){if(super.optimizeNames(F,H))return this.iteration=A(this.iteration,F,H),this}get names(){return P(super.names,this.iteration.names)}}class S extends x{constructor(F,H,W,K){super(),this.varKind=F,this.name=H,this.from=W,this.to=K}render(F){const H=F.es5?n.varKinds.var:this.varKind,{name:W,from:K,to:U}=this;return`for(${H} ${W}=${K}; ${W}<${U}; ${W}++)`+super.render(F)}get names(){const F=N(super.names,this.from);return N(F,this.to)}}class _ extends x{constructor(F,H,W,K){super(),this.loop=F,this.varKind=H,this.name=W,this.iterable=K}render(F){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(F)}optimizeNames(F,H){if(super.optimizeNames(F,H))return this.iterable=A(this.iterable,F,H),this}get names(){return P(super.names,this.iterable.names)}}class C extends h{constructor(F,H,W){super(),this.name=F,this.args=H,this.async=W}render(F){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(F)}}C.kind="func";class $ extends p{render(F){return"return "+super.render(F)}}$.kind="return";class E extends h{render(F){let H="try"+super.render(F);return this.catch&&(H+=this.catch.render(F)),this.finally&&(H+=this.finally.render(F)),H}optimizeNodes(){var F,H;return super.optimizeNodes(),(F=this.catch)===null||F===void 0||F.optimizeNodes(),(H=this.finally)===null||H===void 0||H.optimizeNodes(),this}optimizeNames(F,H){var W,K;return super.optimizeNames(F,H),(W=this.catch)===null||W===void 0||W.optimizeNames(F,H),(K=this.finally)===null||K===void 0||K.optimizeNames(F,H),this}get names(){const F=super.names;return this.catch&&P(F,this.catch.names),this.finally&&P(F,this.finally.names),F}}class k extends h{constructor(F){super(),this.error=F}render(F){return`catch(${this.error})`+super.render(F)}}k.kind="catch";class T extends h{render(F){return"finally"+super.render(F)}}T.kind="finally";class I{constructor(F,H={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...H,_n:H.lines?`
|
|
782
|
-
`:""},this._extScope=F,this._scope=new n.Scope({parent:F}),this._nodes=[new g]}toString(){return this._root.render(this.opts)}name(F){return this._scope.name(F)}scopeName(F){return this._extScope.name(F)}scopeValue(F,H){const W=this._extScope.value(F,H);return(this._values[W.prefix]||(this._values[W.prefix]=new Set)).add(W),W}getScopeValue(F,H){return this._extScope.getValue(F,H)}scopeRefs(F){return this._extScope.scopeRefs(F,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(F,H,W,K){const U=this._scope.toName(H);return W!==void 0&&K&&(this._constants[U.str]=W),this._leafNode(new o(F,U,W)),U}const(F,H,W){return this._def(n.varKinds.const,F,H,W)}let(F,H,W){return this._def(n.varKinds.let,F,H,W)}var(F,H,W){return this._def(n.varKinds.var,F,H,W)}assign(F,H,W){return this._leafNode(new s(F,H,W))}add(F,H){return this._leafNode(new l(F,e.operators.ADD,H))}code(F){return typeof F=="function"?F():F!==t.nil&&this._leafNode(new f(F)),this}object(...F){const H=["{"];for(const[W,K]of F)H.length>1&&H.push(","),H.push(W),(W!==K||this.opts.es5)&&(H.push(":"),(0,t.addCodeArg)(H,K));return H.push("}"),new t._Code(H)}if(F,H,W){if(this._blockNode(new y(F)),H&&W)this.code(H).else().code(W).endIf();else if(H)this.code(H).endIf();else if(W)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(F){return this._elseNode(new y(F))}else(){return this._elseNode(new v)}endIf(){return this._endBlockNode(y,v)}_for(F,H){return this._blockNode(F),H&&this.code(H).endFor(),this}for(F,H){return this._for(new w(F),H)}forRange(F,H,W,K,U=this.opts.es5?n.varKinds.var:n.varKinds.let){const q=this._scope.toName(F);return this._for(new S(U,q,H,W),()=>K(q))}forOf(F,H,W,K=n.varKinds.const){const U=this._scope.toName(F);if(this.opts.es5){const q=H instanceof t.Name?H:this.var("_arr",H);return this.forRange("_i",0,(0,t._)`${q}.length`,Q=>{this.var(U,(0,t._)`${q}[${Q}]`),W(U)})}return this._for(new _("of",K,U,H),()=>W(U))}forIn(F,H,W,K=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(F,(0,t._)`Object.keys(${H})`,W);const U=this._scope.toName(F);return this._for(new _("in",K,U,H),()=>W(U))}endFor(){return this._endBlockNode(x)}label(F){return this._leafNode(new c(F))}break(F){return this._leafNode(new u(F))}return(F){const H=new $;if(this._blockNode(H),this.code(F),H.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode($)}try(F,H,W){if(!H&&!W)throw new Error('CodeGen: "try" without "catch" and "finally"');const K=new E;if(this._blockNode(K),this.code(F),H){const U=this.name("e");this._currNode=K.catch=new k(U),H(U)}return W&&(this._currNode=K.finally=new T,this.code(W)),this._endBlockNode(k,T)}throw(F){return this._leafNode(new d(F))}block(F,H){return this._blockStarts.push(this._nodes.length),F&&this.code(F).endBlock(H),this}endBlock(F){const H=this._blockStarts.pop();if(H===void 0)throw new Error("CodeGen: not in self-balancing block");const W=this._nodes.length-H;if(W<0||F!==void 0&&W!==F)throw new Error(`CodeGen: wrong number of nodes: ${W} vs ${F} expected`);return this._nodes.length=H,this}func(F,H=t.nil,W,K){return this._blockNode(new C(F,H,W)),K&&this.code(K).endFunc(),this}endFunc(){return this._endBlockNode(C)}optimize(F=1){for(;F-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(F){return this._currNode.nodes.push(F),this}_blockNode(F){this._currNode.nodes.push(F),this._nodes.push(F)}_endBlockNode(F,H){const W=this._currNode;if(W instanceof F||H&&W instanceof H)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${H?`${F.kind}/${H.kind}`:F.kind}"`)}_elseNode(F){const H=this._currNode;if(!(H instanceof y))throw new Error('CodeGen: "else" without "if"');return this._currNode=H.else=F,this}get _root(){return this._nodes[0]}get _currNode(){const F=this._nodes;return F[F.length-1]}set _currNode(F){const H=this._nodes;H[H.length-1]=F}}e.CodeGen=I;function P(D,F){for(const H in F)D[H]=(D[H]||0)+(F[H]||0);return D}function N(D,F){return F instanceof t._CodeOrName?P(D,F.names):D}function A(D,F,H){if(D instanceof t.Name)return W(D);if(!K(D))return D;return new t._Code(D._items.reduce((U,q)=>(q instanceof t.Name&&(q=W(q)),q instanceof t._Code?U.push(...q._items):U.push(q),U),[]));function W(U){const q=H[U.str];return q===void 0||F[U.str]!==1?U:(delete F[U.str],q)}function K(U){return U instanceof t._Code&&U._items.some(q=>q instanceof t.Name&&F[q.str]===1&&H[q.str]!==void 0)}}function M(D,F){for(const H in F)D[H]=(D[H]||0)-(F[H]||0)}function R(D){return typeof D=="boolean"||typeof D=="number"||D===null?!D:(0,t._)`!${B(D)}`}e.not=R;const L=V(e.operators.AND);function z(...D){return D.reduce(L)}e.and=z;const j=V(e.operators.OR);function O(...D){return D.reduce(j)}e.or=O;function V(D){return(F,H)=>F===t.nil?H:H===t.nil?F:(0,t._)`${B(F)} ${D} ${B(H)}`}function B(D){return D instanceof t.Name?D:(0,t._)`(${D})`}})(Wn);var zt={};Object.defineProperty(zt,"__esModule",{value:!0});zt.checkStrictMode=zt.getErrorPath=zt.Type=zt.useFunc=zt.setEvaluated=zt.evaluatedPropsToName=zt.mergeEvaluated=zt.eachItem=zt.unescapeJsonPointer=zt.escapeJsonPointer=zt.escapeFragment=zt.unescapeFragment=zt.schemaRefOrVal=zt.schemaHasRulesButRef=zt.schemaHasRules=zt.checkUnknownRules=zt.alwaysValidSchema=zt.toHash=void 0;const Rr=Wn,nUt=H2;function rUt(e){const t={};for(const n of e)t[n]=!0;return t}zt.toHash=rUt;function iUt(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(fLe(e,t),!pLe(t,e.self.RULES.all))}zt.alwaysValidSchema=iUt;function fLe(e,t=e.schema){const{opts:n,self:r}=e;if(!n.strictSchema||typeof t=="boolean")return;const i=r.RULES.keywords;for(const a in t)i[a]||gLe(e,`unknown keyword: "${a}"`)}zt.checkUnknownRules=fLe;function pLe(e,t){if(typeof e=="boolean")return!e;for(const n in e)if(t[n])return!0;return!1}zt.schemaHasRules=pLe;function aUt(e,t){if(typeof e=="boolean")return!e;for(const n in e)if(n!=="$ref"&&t.all[n])return!0;return!1}zt.schemaHasRulesButRef=aUt;function oUt({topSchemaRef:e,schemaPath:t},n,r,i){if(!i){if(typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="string")return(0,Rr._)`${n}`}return(0,Rr._)`${e}${t}${(0,Rr.getProperty)(r)}`}zt.schemaRefOrVal=oUt;function sUt(e){return hLe(decodeURIComponent(e))}zt.unescapeFragment=sUt;function lUt(e){return encodeURIComponent(oJ(e))}zt.escapeFragment=lUt;function oJ(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}zt.escapeJsonPointer=oJ;function hLe(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}zt.unescapeJsonPointer=hLe;function cUt(e,t){if(Array.isArray(e))for(const n of e)t(n);else t(e)}zt.eachItem=cUt;function Rve({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:r}){return(i,a,o,s)=>{const l=o===void 0?a:o instanceof Rr.Name?(a instanceof Rr.Name?e(i,a,o):t(i,a,o),o):a instanceof Rr.Name?(t(i,o,a),a):n(a,o);return s===Rr.Name&&!(l instanceof Rr.Name)?r(i,l):l}}zt.mergeEvaluated={props:Rve({mergeNames:(e,t,n)=>e.if((0,Rr._)`${n} !== true && ${t} !== undefined`,()=>{e.if((0,Rr._)`${t} === true`,()=>e.assign(n,!0),()=>e.assign(n,(0,Rr._)`${n} || {}`).code((0,Rr._)`Object.assign(${n}, ${t})`))}),mergeToName:(e,t,n)=>e.if((0,Rr._)`${n} !== true`,()=>{t===!0?e.assign(n,!0):(e.assign(n,(0,Rr._)`${n} || {}`),sJ(e,n,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:mLe}),items:Rve({mergeNames:(e,t,n)=>e.if((0,Rr._)`${n} !== true && ${t} !== undefined`,()=>e.assign(n,(0,Rr._)`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`)),mergeToName:(e,t,n)=>e.if((0,Rr._)`${n} !== true`,()=>e.assign(n,t===!0?!0:(0,Rr._)`${n} > ${t} ? ${n} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function mLe(e,t){if(t===!0)return e.var("props",!0);const n=e.var("props",(0,Rr._)`{}`);return t!==void 0&&sJ(e,n,t),n}zt.evaluatedPropsToName=mLe;function sJ(e,t,n){Object.keys(n).forEach(r=>e.assign((0,Rr._)`${t}${(0,Rr.getProperty)(r)}`,!0))}zt.setEvaluated=sJ;const Dve={};function uUt(e,t){return e.scopeValue("func",{ref:t,code:Dve[t.code]||(Dve[t.code]=new nUt._Code(t.code))})}zt.useFunc=uUt;var LU;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(LU||(zt.Type=LU={}));function dUt(e,t,n){if(e instanceof Rr.Name){const r=t===LU.Num;return n?r?(0,Rr._)`"[" + ${e} + "]"`:(0,Rr._)`"['" + ${e} + "']"`:r?(0,Rr._)`"/" + ${e}`:(0,Rr._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,Rr.getProperty)(e).toString():"/"+oJ(e)}zt.getErrorPath=dUt;function gLe(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw new Error(t);e.self.logger.warn(t)}}zt.checkStrictMode=gLe;var cd={};Object.defineProperty(cd,"__esModule",{value:!0});const ro=Wn,fUt={data:new ro.Name("data"),valCxt:new ro.Name("valCxt"),instancePath:new ro.Name("instancePath"),parentData:new ro.Name("parentData"),parentDataProperty:new ro.Name("parentDataProperty"),rootData:new ro.Name("rootData"),dynamicAnchors:new ro.Name("dynamicAnchors"),vErrors:new ro.Name("vErrors"),errors:new ro.Name("errors"),this:new ro.Name("this"),self:new ro.Name("self"),scope:new ro.Name("scope"),json:new ro.Name("json"),jsonPos:new ro.Name("jsonPos"),jsonLen:new ro.Name("jsonLen"),jsonPart:new ro.Name("jsonPart")};cd.default=fUt;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=Wn,n=zt,r=cd;e.keywordError={message:({keyword:v})=>(0,t.str)`must pass "${v}" keyword validation`},e.keyword$DataError={message:({keyword:v,schemaType:y})=>y?(0,t.str)`"${v}" keyword must be ${y} ($data)`:(0,t.str)`"${v}" keyword is invalid ($data)`};function i(v,y=e.keywordError,x,w){const{it:S}=v,{gen:_,compositeRule:C,allErrors:$}=S,E=d(v,y,x);w??(C||$)?l(_,E):c(S,(0,t._)`[${E}]`)}e.reportError=i;function a(v,y=e.keywordError,x){const{it:w}=v,{gen:S,compositeRule:_,allErrors:C}=w,$=d(v,y,x);l(S,$),_||C||c(w,r.default.vErrors)}e.reportExtraError=a;function o(v,y){v.assign(r.default.errors,y),v.if((0,t._)`${r.default.vErrors} !== null`,()=>v.if(y,()=>v.assign((0,t._)`${r.default.vErrors}.length`,y),()=>v.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:v,keyword:y,schemaValue:x,data:w,errsCount:S,it:_}){if(S===void 0)throw new Error("ajv implementation error");const C=v.name("err");v.forRange("i",S,r.default.errors,$=>{v.const(C,(0,t._)`${r.default.vErrors}[${$}]`),v.if((0,t._)`${C}.instancePath === undefined`,()=>v.assign((0,t._)`${C}.instancePath`,(0,t.strConcat)(r.default.instancePath,_.errorPath))),v.assign((0,t._)`${C}.schemaPath`,(0,t.str)`${_.errSchemaPath}/${y}`),_.opts.verbose&&(v.assign((0,t._)`${C}.schema`,x),v.assign((0,t._)`${C}.data`,w))})}e.extendErrors=s;function l(v,y){const x=v.const("err",y);v.if((0,t._)`${r.default.vErrors} === null`,()=>v.assign(r.default.vErrors,(0,t._)`[${x}]`),(0,t._)`${r.default.vErrors}.push(${x})`),v.code((0,t._)`${r.default.errors}++`)}function c(v,y){const{gen:x,validateName:w,schemaEnv:S}=v;S.$async?x.throw((0,t._)`new ${v.ValidationError}(${y})`):(x.assign((0,t._)`${w}.errors`,y),x.return(!1))}const u={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function d(v,y,x){const{createErrors:w}=v.it;return w===!1?(0,t._)`{}`:f(v,y,x)}function f(v,y,x={}){const{gen:w,it:S}=v,_=[p(S,x),h(v,x)];return g(v,y,_),w.object(..._)}function p({errorPath:v},{instancePath:y}){const x=y?(0,t.str)`${v}${(0,n.getErrorPath)(y,n.Type.Str)}`:v;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,x)]}function h({keyword:v,it:{errSchemaPath:y}},{schemaPath:x,parentSchema:w}){let S=w?y:(0,t.str)`${y}/${v}`;return x&&(S=(0,t.str)`${S}${(0,n.getErrorPath)(x,n.Type.Str)}`),[u.schemaPath,S]}function g(v,{params:y,message:x},w){const{keyword:S,data:_,schemaValue:C,it:$}=v,{opts:E,propertyName:k,topSchemaRef:T,schemaPath:I}=$;w.push([u.keyword,S],[u.params,typeof y=="function"?y(v):y||(0,t._)`{}`]),E.messages&&w.push([u.message,typeof x=="function"?x(v):x]),E.verbose&&w.push([u.schema,C],[u.parentSchema,(0,t._)`${T}${I}`],[r.default.data,_]),k&&w.push([u.propertyName,k])}})(yT);Object.defineProperty(_1,"__esModule",{value:!0});_1.boolOrEmptySchema=_1.topBoolOrEmptySchema=void 0;const pUt=yT,hUt=Wn,mUt=cd,gUt={message:"boolean schema is false"};function vUt(e){const{gen:t,schema:n,validateName:r}=e;n===!1?vLe(e,!1):typeof n=="object"&&n.$async===!0?t.return(mUt.default.data):(t.assign((0,hUt._)`${r}.errors`,null),t.return(!0))}_1.topBoolOrEmptySchema=vUt;function yUt(e,t){const{gen:n,schema:r}=e;r===!1?(n.var(t,!1),vLe(e)):n.var(t,!0)}_1.boolOrEmptySchema=yUt;function vLe(e,t){const{gen:n,data:r}=e,i={gen:n,keyword:"false schema",data:r,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,pUt.reportError)(i,gUt,void 0,t)}var la={},Xv={};Object.defineProperty(Xv,"__esModule",{value:!0});Xv.getRules=Xv.isJSONType=void 0;const bUt=["string","number","integer","boolean","null","object","array"],xUt=new Set(bUt);function wUt(e){return typeof e=="string"&&xUt.has(e)}Xv.isJSONType=wUt;function SUt(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Xv.getRules=SUt;var rf={};Object.defineProperty(rf,"__esModule",{value:!0});rf.shouldUseRule=rf.shouldUseGroup=rf.schemaHasRulesForType=void 0;function _Ut({schema:e,self:t},n){const r=t.RULES.types[n];return r&&r!==!0&&yLe(e,r)}rf.schemaHasRulesForType=_Ut;function yLe(e,t){return t.rules.some(n=>bLe(e,n))}rf.shouldUseGroup=yLe;function bLe(e,t){var n;return e[t.keyword]!==void 0||((n=t.definition.implements)===null||n===void 0?void 0:n.some(r=>e[r]!==void 0))}rf.shouldUseRule=bLe;Object.defineProperty(la,"__esModule",{value:!0});la.reportTypeError=la.checkDataTypes=la.checkDataType=la.coerceAndCheckDataType=la.getJSONTypes=la.getSchemaTypes=la.DataType=void 0;const CUt=Xv,$Ut=rf,EUt=yT,jn=Wn,xLe=zt;var lx;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(lx||(la.DataType=lx={}));function TUt(e){const t=wLe(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}la.getSchemaTypes=TUt;function wLe(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(CUt.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}la.getJSONTypes=wLe;function IUt(e,t){const{gen:n,data:r,opts:i}=e,a=kUt(t,i.coerceTypes),o=t.length>0&&!(a.length===0&&t.length===1&&(0,$Ut.schemaHasRulesForType)(e,t[0]));if(o){const s=lJ(t,r,i.strictNumbers,lx.Wrong);n.if(s,()=>{a.length?PUt(e,t,a):cJ(e)})}return o}la.coerceAndCheckDataType=IUt;const SLe=new Set(["string","number","integer","boolean","null"]);function kUt(e,t){return t?e.filter(n=>SLe.has(n)||t==="array"&&n==="array"):[]}function PUt(e,t,n){const{gen:r,data:i,opts:a}=e,o=r.let("dataType",(0,jn._)`typeof ${i}`),s=r.let("coerced",(0,jn._)`undefined`);a.coerceTypes==="array"&&r.if((0,jn._)`${o} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>r.assign(i,(0,jn._)`${i}[0]`).assign(o,(0,jn._)`typeof ${i}`).if(lJ(t,i,a.strictNumbers),()=>r.assign(s,i))),r.if((0,jn._)`${s} !== undefined`);for(const c of n)(SLe.has(c)||c==="array"&&a.coerceTypes==="array")&&l(c);r.else(),cJ(e),r.endIf(),r.if((0,jn._)`${s} !== undefined`,()=>{r.assign(i,s),NUt(e,s)});function l(c){switch(c){case"string":r.elseIf((0,jn._)`${o} == "number" || ${o} == "boolean"`).assign(s,(0,jn._)`"" + ${i}`).elseIf((0,jn._)`${i} === null`).assign(s,(0,jn._)`""`);return;case"number":r.elseIf((0,jn._)`${o} == "boolean" || ${i} === null
|
|
781
|
+
`))if(v(x)){await f.cancel().catch(()=>{});return}}},[r]),a=m.useCallback(async(f,p,h={})=>{var S;(S=e.current)==null||S.abort();const g=new AbortController;e.current=g;const v=localStorage.getItem("sso_token")||"",y=localStorage.getItem("sso_domain")||"",x=localStorage.getItem("sso_company")||"",w=Gi();try{const _=await fetch(`${w}/api/v1/custom-agents/execute/${f}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v}`,"X-Domain":y,"X-Tenant-ID":x},body:JSON.stringify({input_data:p,...h.executionTitle?{execution_title:h.executionTitle}:{}}),signal:g.signal});if(!_.ok)throw new Error(`HTTP ${_.status}`);if(!_.body)throw new Error("No response body");await i(_.body.getReader())}catch(_){if(_.name!=="AbortError")throw _}},[i]),o=m.useCallback(async(f,p,h={})=>{var S;(S=e.current)==null||S.abort();const g=new AbortController;e.current=g;const v=localStorage.getItem("sso_token")||"",y=localStorage.getItem("sso_domain")||"",x=localStorage.getItem("sso_company")||"",w=Gi();try{const _=await fetch(`${w}/api/v1/custom-agents/results/recommended-execute`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",Authorization:`Bearer ${v}`,"X-Domain":y,"X-Tenant-ID":x},body:JSON.stringify({result_id:f,recommended_template_id:p,input_data:h.inputData??{},...h.executionTitle?{execution_title:h.executionTitle}:{}}),signal:g.signal});if(!_.ok)throw new Error(`HTTP ${_.status}`);const C=_.headers.get("content-type")||"";if(!_.body||!C.includes("text/event-stream")){const $=await _.json().catch(()=>null);throw qR($)&&typeof $.message=="string"&&$.message?new Error($.message):new Error("推荐智能体执行失败")}await i(_.body.getReader())}catch(_){if(_.name!=="AbortError")throw _}},[i]),s=m.useCallback(async f=>{var x;(x=e.current)==null||x.abort();const p=new AbortController;e.current=p;const h=localStorage.getItem("sso_token")||"",g=localStorage.getItem("sso_domain")||"",v=localStorage.getItem("sso_company")||"",y=Gi();try{const w=await fetch(`${y}/api/v1/custom-agents/executions/stream/${f}`,{headers:{Authorization:`Bearer ${h}`,"X-Domain":g,"X-Tenant-ID":v},signal:p.signal});if(!w.ok)throw new Error(`HTTP ${w.status}`);if(!w.body)throw new Error("No response body");await i(w.body.getReader())}catch(w){if(w.name!=="AbortError")throw w}},[i]),l=m.useCallback(()=>{var f;(f=e.current)==null||f.abort(),e.current=null},[]),c=m.useCallback(async(f,p,h,g={})=>{var C;(C=e.current)==null||C.abort();const v=new AbortController;e.current=v,t.getState().setCurrentExecutionId(f);const y=localStorage.getItem("sso_token")||"",x=localStorage.getItem("sso_domain")||"",w=localStorage.getItem("sso_company")||"",S=Gi(),_={step_id:p,input_data:h};g.action&&(_.action=g.action),g.action!=="return_previous"&&g.confirmedInput!==void 0?_.confirmed_input=g.confirmedInput:(!g.action||g.action==="input"||g.action==="modify")&&(_.confirmed_input=h),g.modifiedParams!==void 0&&(_.modified_params=g.modifiedParams);try{const $=await fetch(`${S}/api/v1/custom-agents/executions/resume/${f}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`,"X-Domain":x,"X-Tenant-ID":w},body:JSON.stringify(_),signal:v.signal});if(!$.ok)throw new Error(`HTTP ${$.status}`);const E=$.headers.get("content-type")||"";if(!$.body||!E.includes("text/event-stream")){$.body&&await $.text().catch(()=>"");return}await i($.body.getReader())}catch($){if($.name!=="AbortError")throw $}},[i]),u=m.useCallback(async(f,p)=>{var w;(w=e.current)==null||w.abort();const h=new AbortController;e.current=h;const g=localStorage.getItem("sso_token")||"",v=localStorage.getItem("sso_domain")||"",y=localStorage.getItem("sso_company")||"",x=Gi();try{const S=await fetch(`${x}/api/v1/custom-agents/executions/resume/${f}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",Authorization:`Bearer ${g}`,"X-Domain":v,"X-Tenant-ID":y},body:JSON.stringify({step_id:p,action:"re_execute"}),signal:h.signal});if(!S.ok){const C=await S.json().catch(()=>null);throw new Error(qR(C)&&typeof C.message=="string"&&C.message?C.message:`HTTP ${S.status}`)}const _=S.headers.get("content-type")||"";S.body&&_.includes("text/event-stream")?await i(S.body.getReader()):S.body&&await S.text().catch(()=>"")}catch(S){if(!(S instanceof DOMException&&S.name==="AbortError"))throw S}},[i]),d=m.useCallback(async(f,p)=>{var w;(w=e.current)==null||w.abort();const h=new AbortController;e.current=h;const g=localStorage.getItem("sso_token")||"",v=localStorage.getItem("sso_domain")||"",y=localStorage.getItem("sso_company")||"",x=Gi();try{const S=await fetch(`${x}/api/v1/custom-agents/transfers/accept/${f}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`,"X-Domain":v,"X-Tenant-ID":y},body:JSON.stringify(p),signal:h.signal});if(!S.ok)throw new Error(`HTTP ${S.status}`);if(!S.body)throw new Error("No response body");await i(S.body.getReader()),await Ys(n,{type:"transfer-accepted",createdAgent:p.action==="create_new",agentId:p.agent_id})}catch(S){if(S.name!=="AbortError")throw S}},[i,n]);return{startExecution:a,startRecommendedExecution:o,resumeExecution:c,reExecuteStep:u,reconnect:s,acceptTransfer:d,abort:l}}function fp(e){return e!=null&&e!==""}function oLe(e){return String(e.widget??e["ui:widget"]??e.ui_component??e.component??"").toLowerCase()}function sLe(e){const t=oLe(e);return t==="file"||t==="upload"||e.type==="file"||e.format==="binary"||e.format==="file"||typeof e.file_type=="string"}function zWt(e){return typeof e=="string"?{url:e}:e}function FWt({path:e,schema:t,value:n,values:r,disabled:i,uploadDisabled:a,uploadFile:o,onChange:s}){const[l,c]=m.useState(!1),[u,d]=m.useState(0),[f,p]=m.useState(""),[h,g]=m.useState({}),v=m.useRef([]);m.useEffect(()=>()=>{for(const E of v.current)E.abort()},[]);const y=t.type==="array"||Number(t.max_files??t.maxItems??1)>1,x=Number(t.max_files??t.maxItems??1),w=Array.isArray(n)?n.map(String):fp(n)?[String(n)]:[],S=w.map((E,k)=>({uid:String(k),name:h[E]||E.split("/").pop()||`file_${k+1}`,status:"done",url:E})),_=async({file:E,onSuccess:k,onError:T})=>{if(!o){const P=new Error("未配置文件上传器");p(P.message),T==null||T(P);return}const I=new AbortController;v.current.push(I),c(!0),d(0),p("");try{const P=zWt(await o({file:E,path:e,schema:t,values:r,signal:I.signal,onProgress:d}));if(I.signal.aborted)return;const N=P.name;N&&g(A=>({...A,[P.url]:N})),s(e,y?[...w,P.url]:P.url),k==null||k(P)}catch(P){if(I.signal.aborted)return;const N=P instanceof Error?P:new Error("文件上传失败");p(N.message),T==null||T(N)}finally{c(!1),v.current=v.current.filter(P=>P!==I)}},C=String(t.accept??t.file_type??t.contentMediaType??"")||void 0,$=i||a;return b.jsxs("div",{className:"schema-dynamic-form__upload",children:[b.jsx(zc,{accept:C,fileList:S,customRequest:_,disabled:$||l,maxCount:Number.isFinite(x)?x:void 0,onRemove:$?void 0:E=>{const k=w.filter((T,I)=>I!==Number(E.uid));return s(e,y?k:""),!0},children:w.length<x&&b.jsx(Et,{disabled:$,icon:l?b.jsx(vr,{size:"small"}):b.jsx(tpt,{}),children:l?`上传中 ${Math.round(u)}%`:"上传文件"})}),f&&b.jsx("div",{className:"schema-dynamic-form__async-error",children:f})]})}function Ut(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mi(e){return Array.isArray(e)?e:[]}function ls(e,t=""){return typeof e=="string"?e:t}function IC(e){return e.map(String).join(".")}function AU(e,t){return t.reduce((n,r)=>{if(Array.isArray(n)&&typeof r=="number")return n[r];if(Ut(n))return n[String(r)]},e)}function kC(e,t,n){if(t.length===0)return Ut(n)?n:e;const[r,...i]=t;if(typeof r=="number")return e;const a=e[r];if(i.length===0)return{...e,[r]:n};if(typeof i[0]=="number"){const s=Array.isArray(a)?[...a]:[],[l,...c]=i;if(c.length===0)s[l]=n;else{const u=Ut(s[l])?s[l]:{};s[l]=kC(u,c,n)}return{...e,[r]:s}}const o=Ut(a)?a:{};return{...e,[r]:kC(o,i,n)}}function BWt(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function iJ(e,t){if(t.startsWith("#/"))return t.slice(2).split("/").map(BWt).reduce((n,r)=>{if(Ut(n))return n[r]},e)}function Ag(e,t){if("if"in t)return{...e,allOf:[...Mi(e.allOf),t]};const n=Ut(e.properties)?e.properties:{},r=Ut(t.properties)?t.properties:{},i={...n};for(const[s,l]of Object.entries(r))i[s]=Ag(Ut(n[s])?n[s]:{},Ut(l)?l:{});const a=Array.from(new Set([...Mi(e.required),...Mi(t.required)])),o={...e,...t,...Object.keys(n).length||Object.keys(r).length?{properties:i}:{},...a.length?{required:a}:{}};for(const s of["items","not","$defs","definitions"])Ut(e[s])&&Ut(t[s])&&(o[s]=Ag(e[s],t[s]));return(e.allOf||t.allOf)&&(o.allOf=[...Mi(e.allOf),...Mi(t.allOf)]),o}function VWt(e,t){return"const"in e?Object.is(e.const,t):Array.isArray(e.enum)?e.enum.some(n=>Object.is(n,t)):e.type==="object"?Ut(t):e.type==="array"?Array.isArray(t):e.type==="string"?typeof t=="string":e.type==="number"||e.type==="integer"?typeof t=="number":e.type==="boolean"?typeof t=="boolean":!1}function HWt(e){return Object.fromEntries(Object.entries(e).filter(([t])=>!["allOf","if","then","else"].includes(t)))}function B2(e){return Array.isArray(e)?e.some(B2):Ut(e)?Object.values(e).some(B2):e!=null&&e!==""}function Pve(e,t){if(Object.is(e,t))return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!="object")return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function WWt(e,t){return e==="array"?Array.isArray(t):e==="object"?Ut(t):e==="integer"?Number.isInteger(t):e==="number"?typeof t=="number":e==="boolean"?typeof t=="boolean":e==="string"?typeof t=="string":e==="null"?t===null:!0}function pp(e,t,n,r=new Set){if(!Ut(t))return!0;let i=t,a=r;if(typeof i.$ref=="string"&&!r.has(i.$ref)){const u=i.$ref,d=iJ(e,u);i=Ag(Ut(d)?d:{},Object.fromEntries(Object.entries(i).filter(([f])=>f!=="$ref"))),a=new Set(r).add(u)}const o=Mi(i.allOf);if(o.length&&!o.every(u=>pp(e,u,n,a)))return!1;const s=Mi(i.anyOf);if(s.length&&!s.some(u=>pp(e,u,n,a)))return!1;const l=Mi(i.oneOf);if(l.length&&l.filter(u=>pp(e,u,n,a)).length!==1||i.not!==void 0&&pp(e,i.not,n,a))return!1;const c=Mi(i.required).map(String);if(c.length&&(!Ut(n)||!c.every(u=>B2(n[u]))))return!1;if(Ut(i.properties)){if(!Ut(n))return!1;for(const[u,d]of Object.entries(i.properties))if(n[u]!==void 0&&!pp(e,d,n[u],a))return!1}return!(i.contains!==void 0&&(!Array.isArray(n)||!n.some(u=>pp(e,i.contains,u,a)))||i.items!==void 0&&Array.isArray(n)&&!n.every(u=>pp(e,i.items,u,a))||Array.isArray(i.enum)&&!i.enum.some(u=>Pve(u,n))||"const"in i&&!Pve(i.const,n)||i.type!==void 0&&!(Array.isArray(i.type)?i.type.map(String):[String(i.type)]).some(d=>WWt(d,n)))}function Yr(e,t,n,r=new Set){if(!Ut(t))return{};let i={...t};if(typeof i.$ref=="string"&&!r.has(i.$ref)){const s=i.$ref,l=iJ(e,s),c=new Set(r).add(s);i=Ag(Yr(e,l,n,c),Object.fromEntries(Object.entries(i).filter(([u])=>u!=="$ref")))}let a=HWt(i);for(const s of Mi(i.allOf))a=Ag(a,Yr(e,s,n,r));if("if"in i&&n!==void 0){const s=pp(e,i.if,n,r)?i.then:i.else;a=Ag(a,Yr(e,s,n,r))}const o=Mi(a.oneOf).length?Mi(a.oneOf):Mi(a.anyOf);if(o.length){const s=o.find(l=>VWt(Yr(e,l,n,r),n))??o[0];a=Ag(a,Yr(e,s,n,r))}return a}function S1(e){const t=Ut(e.not)?e.not:{};return new Set(Mi(t.required).map(String))}function V2(e,t,n){const r=Yr(e,t,n);if(kb(r))return!1;const i=Vh(r,n);if(i==="array")return Array.isArray(n)&&n.some(a=>V2(e,r.items,a));if(i==="object"){if(!Ut(n))return!1;const a=Ut(r.properties)?r.properties:{},o=S1(r);return Object.entries(n).some(([s,l])=>{if(o.has(s))return!1;const c=a[s];return c?V2(e,c,l):B2(l)})}return B2(n)}function og(e,t,n,r=0){if(r>24)return!0;const i=Yr(e,t,n);if(kb(i))return!1;const a=Vh(i,n);if(a==="array")return(Array.isArray(n)&&n.length>0?n:[void 0]).some(s=>og(e,i.items,s,r+1));if(a==="object"){const o=Ut(i.properties)?i.properties:{},s=Ut(n)?n:{},l=S1(i);return Object.entries(o).some(([c,u])=>!l.has(c)&&og(e,u,s[c],r+1))}return!0}function KR(e,t,n=e,r=t){const i=Yr(e,n,t),a=Vh(i,t);if(a==="array"){if(!Array.isArray(t))return t;const u=Array.isArray(r)?r:[];return t.map((d,f)=>KR(e,d,i.items,u[f]))}if(a!=="object"||!Ut(t)||!Ut(i.properties))return t;const o=i.properties,s=Ut(r)?r:{},l=S1(i),c=new Set(Mi(i.required).map(String));return Object.fromEntries(Object.entries(t).filter(([u])=>{if(l.has(u))return!1;if(c.has(u))return!0;const d=o[u];return d?V2(e,d,s[u]):u in s}).map(([u,d])=>[u,KR(e,d,o[u],s[u])]))}function YR(e,t,n=e,r=[]){let i=t,a=Yr(e,n,i);if(Vh(a,i)==="array"&&Array.isArray(i))return i.map((d,f)=>YR(e,d,a.items,r[0]===f?r.slice(1):[]));if(!Ut(i)||!Ut(a.properties))return i;let s=a.properties,l=S1(a);const c=typeof r[0]=="string"?r[0]:void 0;if(c&&l.has(c)){const d=Object.fromEntries(Object.entries(i).filter(([h])=>h===c||!l.has(h))),f=Yr(e,n,d),p=S1(f);p.has(c)||(i=d,a=f,l=p,Ut(f.properties)&&(s=f.properties))}const u=Ut(i)?i:{};return Object.fromEntries(Object.entries(u).filter(([d])=>!l.has(d)).map(([d,f])=>[d,YR(e,f,s[d],c===d?r.slice(1):[])]))}function Vh(e,t){const n=Array.isArray(e.type)?e.type.find(r=>r!=="null"):e.type;return typeof n=="string"?n:Ut(e.properties)?"object":e.items||Array.isArray(t)?"array":Ut(t)?"object":"string"}function XR(e,t){return ls(t.title,e)}function lLe(e){return ls(e.description)}function UWt(e,t){if(!Ut(e.propertyGroups))return[];const n=[],r=new Set;for(const[a,o]of Object.entries(e.propertyGroups)){if(!Ut(o))continue;const s=Mi(o.propertyNames??o.properties??o.fields??o.items).map(String).filter(u=>u in t&&!r.has(u));if(!s.length)continue;for(const u of s)r.add(u);const l=Number(o.columns),c=Number.isFinite(l)?Math.min(Math.max(Math.trunc(l),1),4):void 0;n.push({key:a,title:ls(o.title??o.label,a),description:ls(o.description)||void 0,propertyNames:s,...c?{columns:c}:{}})}const i=Object.keys(t).filter(a=>!r.has(a));return i.length&&n.push({key:"__ungrouped",title:"其他字段",propertyNames:i}),n}function kb(e){return e.hidden===!0||e["x-hidden"]===!0}function GWt(e){return e.readOnly===!0||e.readonly===!0}function Nve(e,t){const n=Yr(e,t),r=Array.isArray(n.enum)?n.enum:[],i=Mi(n.oneOf).length?Mi(n.oneOf):Mi(n.anyOf),a=i.map(u=>Yr(e,u)).find(u=>Array.isArray(u.enum)&&u.enum.length>0),o=i.map(u=>Yr(e,u)).filter(u=>"const"in u).map(u=>({value:u.const,label:ls(u.title,String(u.const??""))})),s=r.length?r:Array.isArray(a==null?void 0:a.enum)?a.enum:[];if(!s.length)return o;const l=r.length?n:a??{},c=Array.isArray(l.enumNames)?l.enumNames:Array.isArray(l["x-enumNames"])?l["x-enumNames"]:[];return s.map((u,d)=>({value:u,label:String(c[d]??u)}))}function qWt(e,t){const n=Yr(e,t);return[...Mi(n.oneOf),...Mi(n.anyOf)].some(i=>{const a=Yr(e,i);return(Array.isArray(a.type)?a.type.map(String):[String(a.type??"")]).includes("string")&&a.enum===void 0&&a.const===void 0})}function cLe(e){return e.options_from_skill??e.optionsSource??e["x-options-source"]??e["x-optionsSource"]}function KWt(e){const t=e.options_params??e.optionsParams??e["x-options-params"]??e["x-optionsParams"];return Ut(t)?t:{}}const uLe=/\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}/g,YWt=/^\$\{\s*\{?\s*params\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}$/;function aJ(e){const t=new Set,n=r=>{if(typeof r=="string"){for(const i of r.matchAll(uLe))i[1]&&t.add(i[1]);return}Array.isArray(r)?r.forEach(n):Ut(r)&&Object.values(r).forEach(n)};return n(e),Array.from(t)}function MU(e,t){if(typeof e=="string"){const n=e.match(YWt);return n!=null&&n[1]?AU(t,n[1].split(".")):e.replace(uLe,(r,i)=>{const a=AU(t,i.split("."));return a==null?"":String(a)})}return Array.isArray(e)?e.map(n=>MU(n,t)):Ut(e)?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,MU(r,t)])):e}function ZR(e,t=e){const n=Yr(e,t);if("default"in n)return n.default;if("const"in n)return n.const;if(Array.isArray(n.enum)&&n.enum.length===1)return n.enum[0];const r=Vh(n);if(r==="object"){const i=Ut(n.properties)?n.properties:{},a={};for(const[o,s]of Object.entries(i)){const l=ZR(e,s);l!==void 0&&(a[o]=l)}return a}if(r==="array"){const i=typeof n.minItems=="number"?n.minItems:0;if(i<=0)return;const a=ZR(e,n.items);return a===void 0?void 0:Array.from({length:i},()=>a)}}function Ave(e,t){const n=(i,a,o)=>{if(!o)return i;if(Array.isArray(a))return Array.isArray(i)?a.map((s,l)=>n(i[l]??i[0],s,!0)):a;if(Ut(a)){const s=Ut(i)?i:{};return Object.fromEntries(Array.from(new Set([...Object.keys(s),...Object.keys(a)])).map(l=>[l,n(s[l],a[l],Object.prototype.hasOwnProperty.call(a,l))]))}return a},r=n(e,t,t!==void 0);return Ut(r)?r:{}}const Mve=new Map;function XWt(e){return e==null||e===""}function ZWt(e){if(Array.isArray(e))return e;if(!Ut(e))return[];const t="data"in e?e.data:e;if(Array.isArray(t))return t;if(!Ut(t))return[];const n=[t.options,t.items,t.results,t.list,t.output_data,t.data];return Ut(t.output)&&n.push(t.output.options,t.output.items,t.output.results,t.output.list,t.output.output_data,t.output.data),n.find(Array.isArray)??[]}function QWt(e){let t;return{options:ZWt(e).map(r=>{if(["string","number","boolean"].includes(typeof r))return{value:r,label:String(r)};if(!Ut(r))return null;const i=r.value??r.key??r.code??r.id??r.name??r.label;if(!["string","number","boolean"].includes(typeof i))return null;const a=String(r.label??r.title??r.text??r.name??i);return String(i)===""?(a&&!t&&(t=a),null):{value:i,label:a}}).filter(r=>r!==null),placeholder:t}}function JWt({schema:e,path:t,values:n,search:r,loadOptions:i}){const a=cLe(e),o=KWt(e),s=m.useMemo(()=>aJ(o),[o]),l=e.optionsBlockingDependencies??e["x-options-blocking-dependencies"],d=(Array.isArray(l)?l.map(String):s).map(w=>AU(n,w.split("."))).some(XWt),f=MU(o,n),p=e.remoteSearch===!0||e["x-remote-search"]===!0,h=JSON.stringify({source:a,params:f,waitingForDependencies:d}),g=JSON.stringify({path:IC(t),dependencySignature:h,search:p?r:""}),[v,y]=m.useState({options:[],loading:!1}),x=m.useRef({path:t,schema:e,params:f,values:n,search:p?r:""});return x.current={path:t,schema:e,params:f,values:n,search:p?r:""},m.useEffect(()=>{if(!a||d){y({options:[],loading:!1});return}if(!i){y({options:[],loading:!1,error:"未配置动态选项加载器"});return}const w=Mve.get(g);if(w){y({...w,loading:!1});return}const S=new AbortController;y(C=>({...C,loading:!0,error:void 0}));const _=x.current;return i({path:_.path,schema:_.schema,source:a,params:_.params,values:_.values,search:_.search,signal:S.signal}).then(C=>{if(S.signal.aborted)return;const $=QWt(C);Mve.set(g,$),y({...$,loading:!1})}).catch(C=>{S.signal.aborted||y({options:[],loading:!1,error:C instanceof Error?C.message:"动态选项加载失败"})}),()=>S.abort()},[g,i,a,d]),{...v,waitingForDependencies:d,dependencySignature:h,hasDynamicSource:a!=null&&a!==""}}function eUt({name:e,path:t,schema:n,rootSchema:r,value:i,values:a,required:o,errors:s,disabled:l,loadOptions:c,uploadFile:u,disableFileUpload:d,onChange:f}){const p=Yr(r,n,i),h=Vh(p,i),g=oLe(p),v=XR(e,p),y=lLe(p),x=s[IC(t)],[w,S]=m.useState(""),_=m.useMemo(()=>Nve(r,p),[r,p]),C=m.useMemo(()=>qWt(r,p),[r,p]),$=JWt({schema:p,path:t,values:a,search:w,loadOptions:c}),E=$.hasDynamicSource?$.options:_,k=m.useRef();m.useEffect(()=>{const I=p.clearOnOptionsChange===!0||p["x-clear-on-options-change"]===!0;if(!$.hasDynamicSource||!I){k.current=void 0;return}const P=k.current;k.current=$.dependencySignature;const N=Array.isArray(i)?i.length>0:fp(i),A=P!==void 0&&P!==$.dependencySignature;N&&($.waitingForDependencies||A)&&f(t,h==="array"?[]:void 0)},[$.dependencySignature,$.hasDynamicSource,$.waitingForDependencies,f,t,p,h,i]);let T;if(sLe(p))T=b.jsx(FWt,{path:t,schema:p,value:i,values:a,disabled:l,uploadDisabled:d,uploadFile:u,onChange:f});else if(h==="array"){const I=Yr(r,p.items),P=Nve(r,I),N=E.length?E:P;T=b.jsx(tn,{mode:N.length?"multiple":"tags",showSearch:!0,allowClear:!0,value:Array.isArray(i)?i:[],options:N,loading:$.loading,disabled:l||$.waitingForDependencies,placeholder:$.waitingForDependencies?"请先填写关联字段":$.placeholder||ls(p.placeholder,"请选择"),optionFilterProp:"label",filterOption:(A,M)=>String((M==null?void 0:M.label)??"").toLowerCase().includes(A.trim().toLowerCase()),onSearch:S,onChange:A=>f(t,A)})}else if(E.length||cLe(p)){const I=E.map(M=>({value:String(M.value),label:M.label})),P=$.waitingForDependencies?"请先填写关联字段":$.placeholder||ls(p.placeholder,g==="select"?"请选择":"请选择或输入"),N=M=>{const R=E.find(L=>String(L.value)===M);return(R==null?void 0:R.value)??M};T=g==="select"||g!=="autocomplete"&&_.length>0&&!C?b.jsx(tn,{allowClear:!0,showSearch:!0,value:fp(i)?String(i):void 0,options:I,loading:$.loading,disabled:l||$.waitingForDependencies,placeholder:P,optionFilterProp:"label",filterOption:(M,R)=>String((R==null?void 0:R.label)??(R==null?void 0:R.value)??"").toLowerCase().includes(M.trim().toLowerCase()),onSearch:S,onChange:M=>f(t,M===void 0?void 0:N(M)),notFoundContent:$.loading?b.jsx(vr,{size:"small"}):null}):b.jsx(uO,{allowClear:!0,value:fp(i)?String(i):"",options:I,disabled:l||$.waitingForDependencies,placeholder:P,filterOption:(M,R)=>String((R==null?void 0:R.label)??(R==null?void 0:R.value)??"").toLowerCase().includes(M.trim().toLowerCase()),onSearch:S,onChange:M=>f(t,M),onSelect:M=>f(t,N(M)),notFoundContent:$.loading?b.jsx(vr,{size:"small"}):null})}else if(h==="boolean")T=b.jsx(yo,{checked:!!i,disabled:l,onChange:I=>f(t,I)});else if(h==="number"||h==="integer")T=b.jsx(zo,{style:{width:"100%"},value:typeof i=="number"?i:null,disabled:l,min:typeof p.minimum=="number"?p.minimum:void 0,max:typeof p.maximum=="number"?p.maximum:void 0,placeholder:ls(p.placeholder,"请输入"),step:typeof p.multipleOf=="number"?p.multipleOf:void 0,precision:h==="integer"?0:void 0,onChange:I=>f(t,I)});else if(g==="date"||g==="datetime"||p.format==="date"||p.format==="date-time"){const I=g==="datetime"||p.format==="date-time"||p["x-temporal-show-time"]===!0?"datetime":"date",P=bu({type:I,format:ls(p["x-temporal-format"]),picker:ls(p["x-temporal-picker"]),show_time:typeof p["x-temporal-show-time"]=="boolean"?p["x-temporal-show-time"]:void 0});T=b.jsx(ui,{style:{width:"100%"},value:fp(i)?In(String(i)):null,picker:I==="date"?b1(P,ls(p["x-temporal-picker"])):void 0,showTime:I==="datetime"?{format:ov(P)}:!1,format:P,disabled:l,onChange:(N,A)=>f(t,A)})}else if(p.format==="time"||g==="time"){const I=bu({type:"time",format:ls(p["x-temporal-format"])});T=b.jsx(Ua,{style:{width:"100%"},value:fp(i)?In(String(i),"HH:mm"):null,format:I,disabled:l,onChange:(P,N)=>f(t,N)})}else g==="textarea"||p.format==="textarea"||Number(p.maxLength??0)>240?T=b.jsx(Kt.TextArea,{autoSize:{minRows:2,maxRows:10},value:fp(i)?String(i):"",disabled:l,placeholder:ls(p.placeholder,"请输入"),onChange:I=>f(t,I.target.value)}):T=b.jsx(Kt,{type:p.format==="uri"||p.format==="url"?"url":void 0,value:fp(i)?String(i):"",disabled:l,placeholder:ls(p.placeholder,"请输入"),onChange:I=>f(t,I.target.value)});return b.jsx(pn.Item,{label:v,required:o,className:["schema-dynamic-form__property",p.fullWidth===!0||p["x-full-width"]===!0?"schema-dynamic-form__field--full-width":void 0].filter(Boolean).join(" "),tooltip:y||void 0,validateStatus:x?"error":void 0,help:x||$.error||void 0,children:T})}function RU(e){const{name:t,path:n,rootSchema:r,values:i,required:a=!1,forcePrimaryRequired:o=!1,errors:s,disabled:l,respectReadonly:c,showArrayControls:u,groupDisplay:d,groupAccordion:f,destroyInactiveGroups:p,defaultExpandedGroupKeys:h,expandedGroupKeys:g,onExpandedGroupKeysChange:v,visibleFieldPaths:y,loadOptions:x,uploadFile:w,disableFileUpload:S,onChange:_}=e,C=Yr(r,e.schema,e.value),$=e.value,E=e.sourceValue,k=Vh(C,$),T=l||c&&GWt(C),I=XR(t,C),P=lLe(C),N=s[IC(n)],A=M=>{if(!y)return!0;const R=IC(M);return Array.from(y).some(L=>L===R||L.startsWith(`${R}.`)||R.startsWith(`${L}.`))};if(kb(C)||!og(r,C,$))return null;if(k==="object"){const M=Ut(C.properties)?C.properties:{},R=S1(C),L=Object.fromEntries(Object.entries(M).filter(([U])=>!R.has(U))),z=new Set((Array.isArray(C.required)?C.required.map(String):[]).filter(U=>!R.has(U))),j=n.length===0||a||V2(r,C,E),O=o?Object.keys(L).find(U=>U==="value"&&!kb(Yr(r,L[U])))??Object.keys(L).find(U=>!kb(Yr(r,L[U]))):void 0,V=UWt(C,L),B=U=>{const q=[...n,U];if(!A(q))return null;const Q=Ut(L[U])?L[U]:{},G=Ut($)?$[U]:void 0;if(!og(r,Q,G))return null;const X=Ut(E)?E[U]:void 0;return b.jsx(RU,{...e,name:U,path:q,schema:Q,value:G,sourceValue:X,required:j&&(z.has(U)||O===U),forcePrimaryRequired:!1},U)},D=U=>U?{"--schema-dynamic-form-columns":U}:void 0,F=V.map(U=>({...U,propertyNames:U.propertyNames.filter(q=>{const Q=[...n,q],G=Ut(L[q])?L[q]:{},X=Ut($)?$[q]:void 0;return A(Q)&&og(r,G,X)})})).filter(U=>U.propertyNames.length>0),H=F.map(U=>b.jsxs("section",{className:"schema-dynamic-form__group",children:[b.jsxs("div",{className:"schema-dynamic-form__group-heading",children:[b.jsx("strong",{children:U.title}),U.description&&b.jsx("span",{children:U.description})]}),b.jsx("div",{className:"schema-dynamic-form__group-fields",style:D(U.columns),children:U.propertyNames.map(B)})]},U.key)),W=F.map(U=>({key:U.key,label:b.jsxs("div",{className:"schema-dynamic-form__collapse-label",children:[b.jsxs("span",{className:"schema-dynamic-form__collapse-copy",children:[b.jsx("strong",{children:U.title}),U.description&&b.jsx("span",{children:U.description})]}),b.jsxs("span",{className:"schema-dynamic-form__collapse-count",children:[U.propertyNames.length," 项"]})]}),children:b.jsx("div",{className:"schema-dynamic-form__group-fields",style:D(U.columns),children:U.propertyNames.map(B)})})),K=F.length?d==="collapse"?b.jsx(Gq,{className:"schema-dynamic-form__collapse",accordion:f,destroyOnHidden:p,...n.length===0&&g!==void 0?{activeKey:g}:{defaultActiveKey:h},onChange:n.length===0&&v?U=>v((Array.isArray(U)?U:[U]).map(String)):void 0,expandIconPlacement:"end",items:W}):H:Object.keys(L).filter(U=>{const q=Ut($)?$[U]:void 0;return og(r,L[U],q)}).map(B);return n.length===0?b.jsx(b.Fragment,{children:K}):typeof n[n.length-1]=="number"?b.jsx("div",{className:"schema-dynamic-form__object schema-dynamic-form__object--array-item",children:K}):b.jsx(pn.Item,{label:I,required:a,tooltip:P||void 0,className:"schema-dynamic-form__property schema-dynamic-form__property--object",validateStatus:N?"error":void 0,help:N||void 0,children:b.jsx("div",{className:"schema-dynamic-form__object schema-dynamic-form__object--nested",children:K})})}if(k==="array"&&!sLe(C)){const M=Ut(C.items)?C.items:{};if(Vh(Yr(r,M))==="object"){const L=Array.isArray($)?$:[],z=Array.isArray(E)?E:[],j=Ut(M.properties)?M.properties:{},O=Object.keys(j).filter(q=>(L.length===0?A([...n,0,q]):L.some((Q,G)=>A([...n,G,q])))&&!kb(Yr(r,j[q]))),V=L.map((q,Q)=>({row:q,index:Q})).filter(({row:q,index:Q})=>A([...n,Q])&&og(r,M,q));if(V.length===0&&!u)return null;const B=O.length===1,D=!u&&V.length<=1,H=!(n.length===1&&D&&B&&XR(O[0],Yr(r,j[O[0]]))===I),W=Number(C.minItems??0),K=Number(C.maxItems??Number.POSITIVE_INFINITY),U=()=>{const q=ZR(r,M);_(n,[...L,Ut(q)?q:{}])};return b.jsx(pn.Item,{label:H?I:void 0,required:H?a:!1,tooltip:H&&P?P:void 0,className:`schema-dynamic-form__property${H?" schema-dynamic-form__property--nested":" schema-dynamic-form__property--flat"}`,validateStatus:N?"error":void 0,help:N||void 0,children:b.jsxs("div",{className:`schema-dynamic-form__array${D?" schema-dynamic-form__array--compact":""}`,children:[V.map(({row:q,index:Q})=>b.jsxs("div",{className:`schema-dynamic-form__array-row${D?" schema-dynamic-form__array-row--compact":" schema-dynamic-form__array-row--multiple"}${D&&n.length>1?" schema-dynamic-form__array-row--framed":""}`,children:[(!D||u)&&b.jsxs("div",{className:"schema-dynamic-form__array-row-heading",children:[b.jsxs("span",{children:["第 ",Q+1," 项"]}),u&&b.jsx(or,{title:"删除",children:b.jsx(Et,{type:"text",danger:!0,icon:b.jsx(hf,{}),disabled:T||L.length<=W,onClick:()=>_(n,L.filter((G,X)=>X!==Q))})})]}),b.jsx(RU,{...e,name:String(Q),path:[...n,Q],schema:M,value:q,sourceValue:z[Q],required:a||V2(r,C,E),forcePrimaryRequired:n.length===1&&a})]},`${IC(n)}-${Q}`)),u&&b.jsx(Et,{type:"dashed",icon:b.jsx(Uo,{}),disabled:T||L.length>=K,onClick:U,children:"添加一项"})]})})}}return b.jsx(eUt,{name:t,path:n,schema:C,rootSchema:r,value:$,values:i,required:a,errors:s,disabled:T,loadOptions:x,uploadFile:w,disableFileUpload:S,onChange:_})}var DU={exports:{}},dLe={},Mc={},_1={},yT={},Wn={},H2={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class n extends t{constructor(x){if(super(),!e.IDENTIFIER.test(x))throw new Error("CodeGen: name must be a valid identifier");this.str=x}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=n;class r extends t{constructor(x){super(),this._items=typeof x=="string"?[x]:x}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const x=this._items[0];return x===""||x==='""'}get str(){var x;return(x=this._str)!==null&&x!==void 0?x:this._str=this._items.reduce((w,S)=>`${w}${S}`,"")}get names(){var x;return(x=this._names)!==null&&x!==void 0?x:this._names=this._items.reduce((w,S)=>(S instanceof n&&(w[S.str]=(w[S.str]||0)+1),w),{})}}e._Code=r,e.nil=new r("");function i(y,...x){const w=[y[0]];let S=0;for(;S<x.length;)s(w,x[S]),w.push(y[++S]);return new r(w)}e._=i;const a=new r("+");function o(y,...x){const w=[p(y[0])];let S=0;for(;S<x.length;)w.push(a),s(w,x[S]),w.push(a,p(y[++S]));return l(w),new r(w)}e.str=o;function s(y,x){x instanceof r?y.push(...x._items):x instanceof n?y.push(x):y.push(d(x))}e.addCodeArg=s;function l(y){let x=1;for(;x<y.length-1;){if(y[x]===a){const w=c(y[x-1],y[x+1]);if(w!==void 0){y.splice(x-1,3,w);continue}y[x++]="+"}x++}}function c(y,x){if(x==='""')return y;if(y==='""')return x;if(typeof y=="string")return x instanceof n||y[y.length-1]!=='"'?void 0:typeof x!="string"?`${y.slice(0,-1)}${x}"`:x[0]==='"'?y.slice(0,-1)+x.slice(1):void 0;if(typeof x=="string"&&x[0]==='"'&&!(y instanceof n))return`"${y}${x.slice(1)}`}function u(y,x){return x.emptyStr()?y:y.emptyStr()?x:o`${y}${x}`}e.strConcat=u;function d(y){return typeof y=="number"||typeof y=="boolean"||y===null?y:p(Array.isArray(y)?y.join(","):y)}function f(y){return new r(p(y))}e.stringify=f;function p(y){return JSON.stringify(y).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.safeStringify=p;function h(y){return typeof y=="string"&&e.IDENTIFIER.test(y)?new r(`.${y}`):i`[${y}]`}e.getProperty=h;function g(y){if(typeof y=="string"&&e.IDENTIFIER.test(y))return new r(`${y}`);throw new Error(`CodeGen: invalid export name: ${y}, use explicit $id name mapping`)}e.getEsmExportName=g;function v(y){return new r(y.toString())}e.regexpCode=v})(H2);var OU={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=H2;class n extends Error{constructor(c){super(`CodeGen: "code" for ${c} not defined`),this.value=c.value}}var r;(function(l){l[l.Started=0]="Started",l[l.Completed=1]="Completed"})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class i{constructor({prefixes:c,parent:u}={}){this._names={},this._prefixes=c,this._parent=u}toName(c){return c instanceof t.Name?c:this.name(c)}name(c){return new t.Name(this._newName(c))}_newName(c){const u=this._names[c]||this._nameGroup(c);return`${c}${u.index++}`}_nameGroup(c){var u,d;if(!((d=(u=this._parent)===null||u===void 0?void 0:u._prefixes)===null||d===void 0)&&d.has(c)||this._prefixes&&!this._prefixes.has(c))throw new Error(`CodeGen: prefix "${c}" is not allowed in this scope`);return this._names[c]={prefix:c,index:0}}}e.Scope=i;class a extends t.Name{constructor(c,u){super(u),this.prefix=c}setValue(c,{property:u,itemIndex:d}){this.value=c,this.scopePath=(0,t._)`.${new t.Name(u)}[${d}]`}}e.ValueScopeName=a;const o=(0,t._)`\n`;class s extends i{constructor(c){super(c),this._values={},this._scope=c.scope,this.opts={...c,_n:c.lines?o:t.nil}}get(){return this._scope}name(c){return new a(c,this._newName(c))}value(c,u){var d;if(u.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const f=this.toName(c),{prefix:p}=f,h=(d=u.key)!==null&&d!==void 0?d:u.ref;let g=this._values[p];if(g){const x=g.get(h);if(x)return x}else g=this._values[p]=new Map;g.set(h,f);const v=this._scope[p]||(this._scope[p]=[]),y=v.length;return v[y]=u.ref,f.setValue(u,{property:p,itemIndex:y}),f}getValue(c,u){const d=this._values[c];if(d)return d.get(u)}scopeRefs(c,u=this._values){return this._reduceValues(u,d=>{if(d.scopePath===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return(0,t._)`${c}${d.scopePath}`})}scopeCode(c=this._values,u,d){return this._reduceValues(c,f=>{if(f.value===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return f.value.code},u,d)}_reduceValues(c,u,d={},f){let p=t.nil;for(const h in c){const g=c[h];if(!g)continue;const v=d[h]=d[h]||new Map;g.forEach(y=>{if(v.has(y))return;v.set(y,r.Started);let x=u(y);if(x){const w=this.opts.es5?e.varKinds.var:e.varKinds.const;p=(0,t._)`${p}${w} ${y} = ${x};${this.opts._n}`}else if(x=f==null?void 0:f(y))p=(0,t._)`${p}${x}${this.opts._n}`;else throw new n(y);v.set(y,r.Completed)})}return p}}e.ValueScope=s})(OU);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=H2,n=OU;var r=H2;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=OU;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class a{optimizeNodes(){return this}optimizeNames(F,H){return this}}class o extends a{constructor(F,H,W){super(),this.varKind=F,this.name=H,this.rhs=W}render({es5:F,_n:H}){const W=F?n.varKinds.var:this.varKind,K=this.rhs===void 0?"":` = ${this.rhs}`;return`${W} ${this.name}${K};`+H}optimizeNames(F,H){if(F[this.name.str])return this.rhs&&(this.rhs=A(this.rhs,F,H)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class s extends a{constructor(F,H,W){super(),this.lhs=F,this.rhs=H,this.sideEffects=W}render({_n:F}){return`${this.lhs} = ${this.rhs};`+F}optimizeNames(F,H){if(!(this.lhs instanceof t.Name&&!F[this.lhs.str]&&!this.sideEffects))return this.rhs=A(this.rhs,F,H),this}get names(){const F=this.lhs instanceof t.Name?{}:{...this.lhs.names};return N(F,this.rhs)}}class l extends s{constructor(F,H,W,K){super(F,W,K),this.op=H}render({_n:F}){return`${this.lhs} ${this.op}= ${this.rhs};`+F}}class c extends a{constructor(F){super(),this.label=F,this.names={}}render({_n:F}){return`${this.label}:`+F}}class u extends a{constructor(F){super(),this.label=F,this.names={}}render({_n:F}){return`break${this.label?` ${this.label}`:""};`+F}}class d extends a{constructor(F){super(),this.error=F}render({_n:F}){return`throw ${this.error};`+F}get names(){return this.error.names}}class f extends a{constructor(F){super(),this.code=F}render({_n:F}){return`${this.code};`+F}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(F,H){return this.code=A(this.code,F,H),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class p extends a{constructor(F=[]){super(),this.nodes=F}render(F){return this.nodes.reduce((H,W)=>H+W.render(F),"")}optimizeNodes(){const{nodes:F}=this;let H=F.length;for(;H--;){const W=F[H].optimizeNodes();Array.isArray(W)?F.splice(H,1,...W):W?F[H]=W:F.splice(H,1)}return F.length>0?this:void 0}optimizeNames(F,H){const{nodes:W}=this;let K=W.length;for(;K--;){const U=W[K];U.optimizeNames(F,H)||(M(F,U.names),W.splice(K,1))}return W.length>0?this:void 0}get names(){return this.nodes.reduce((F,H)=>P(F,H.names),{})}}class h extends p{render(F){return"{"+F._n+super.render(F)+"}"+F._n}}class g extends p{}class v extends h{}v.kind="else";class y extends h{constructor(F,H){super(H),this.condition=F}render(F){let H=`if(${this.condition})`+super.render(F);return this.else&&(H+="else "+this.else.render(F)),H}optimizeNodes(){super.optimizeNodes();const F=this.condition;if(F===!0)return this.nodes;let H=this.else;if(H){const W=H.optimizeNodes();H=this.else=Array.isArray(W)?new v(W):W}if(H)return F===!1?H instanceof y?H:H.nodes:this.nodes.length?this:new y(R(F),H instanceof y?[H]:H.nodes);if(!(F===!1||!this.nodes.length))return this}optimizeNames(F,H){var W;if(this.else=(W=this.else)===null||W===void 0?void 0:W.optimizeNames(F,H),!!(super.optimizeNames(F,H)||this.else))return this.condition=A(this.condition,F,H),this}get names(){const F=super.names;return N(F,this.condition),this.else&&P(F,this.else.names),F}}y.kind="if";class x extends h{}x.kind="for";class w extends x{constructor(F){super(),this.iteration=F}render(F){return`for(${this.iteration})`+super.render(F)}optimizeNames(F,H){if(super.optimizeNames(F,H))return this.iteration=A(this.iteration,F,H),this}get names(){return P(super.names,this.iteration.names)}}class S extends x{constructor(F,H,W,K){super(),this.varKind=F,this.name=H,this.from=W,this.to=K}render(F){const H=F.es5?n.varKinds.var:this.varKind,{name:W,from:K,to:U}=this;return`for(${H} ${W}=${K}; ${W}<${U}; ${W}++)`+super.render(F)}get names(){const F=N(super.names,this.from);return N(F,this.to)}}class _ extends x{constructor(F,H,W,K){super(),this.loop=F,this.varKind=H,this.name=W,this.iterable=K}render(F){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(F)}optimizeNames(F,H){if(super.optimizeNames(F,H))return this.iterable=A(this.iterable,F,H),this}get names(){return P(super.names,this.iterable.names)}}class C extends h{constructor(F,H,W){super(),this.name=F,this.args=H,this.async=W}render(F){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(F)}}C.kind="func";class $ extends p{render(F){return"return "+super.render(F)}}$.kind="return";class E extends h{render(F){let H="try"+super.render(F);return this.catch&&(H+=this.catch.render(F)),this.finally&&(H+=this.finally.render(F)),H}optimizeNodes(){var F,H;return super.optimizeNodes(),(F=this.catch)===null||F===void 0||F.optimizeNodes(),(H=this.finally)===null||H===void 0||H.optimizeNodes(),this}optimizeNames(F,H){var W,K;return super.optimizeNames(F,H),(W=this.catch)===null||W===void 0||W.optimizeNames(F,H),(K=this.finally)===null||K===void 0||K.optimizeNames(F,H),this}get names(){const F=super.names;return this.catch&&P(F,this.catch.names),this.finally&&P(F,this.finally.names),F}}class k extends h{constructor(F){super(),this.error=F}render(F){return`catch(${this.error})`+super.render(F)}}k.kind="catch";class T extends h{render(F){return"finally"+super.render(F)}}T.kind="finally";class I{constructor(F,H={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...H,_n:H.lines?`
|
|
782
|
+
`:""},this._extScope=F,this._scope=new n.Scope({parent:F}),this._nodes=[new g]}toString(){return this._root.render(this.opts)}name(F){return this._scope.name(F)}scopeName(F){return this._extScope.name(F)}scopeValue(F,H){const W=this._extScope.value(F,H);return(this._values[W.prefix]||(this._values[W.prefix]=new Set)).add(W),W}getScopeValue(F,H){return this._extScope.getValue(F,H)}scopeRefs(F){return this._extScope.scopeRefs(F,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(F,H,W,K){const U=this._scope.toName(H);return W!==void 0&&K&&(this._constants[U.str]=W),this._leafNode(new o(F,U,W)),U}const(F,H,W){return this._def(n.varKinds.const,F,H,W)}let(F,H,W){return this._def(n.varKinds.let,F,H,W)}var(F,H,W){return this._def(n.varKinds.var,F,H,W)}assign(F,H,W){return this._leafNode(new s(F,H,W))}add(F,H){return this._leafNode(new l(F,e.operators.ADD,H))}code(F){return typeof F=="function"?F():F!==t.nil&&this._leafNode(new f(F)),this}object(...F){const H=["{"];for(const[W,K]of F)H.length>1&&H.push(","),H.push(W),(W!==K||this.opts.es5)&&(H.push(":"),(0,t.addCodeArg)(H,K));return H.push("}"),new t._Code(H)}if(F,H,W){if(this._blockNode(new y(F)),H&&W)this.code(H).else().code(W).endIf();else if(H)this.code(H).endIf();else if(W)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(F){return this._elseNode(new y(F))}else(){return this._elseNode(new v)}endIf(){return this._endBlockNode(y,v)}_for(F,H){return this._blockNode(F),H&&this.code(H).endFor(),this}for(F,H){return this._for(new w(F),H)}forRange(F,H,W,K,U=this.opts.es5?n.varKinds.var:n.varKinds.let){const q=this._scope.toName(F);return this._for(new S(U,q,H,W),()=>K(q))}forOf(F,H,W,K=n.varKinds.const){const U=this._scope.toName(F);if(this.opts.es5){const q=H instanceof t.Name?H:this.var("_arr",H);return this.forRange("_i",0,(0,t._)`${q}.length`,Q=>{this.var(U,(0,t._)`${q}[${Q}]`),W(U)})}return this._for(new _("of",K,U,H),()=>W(U))}forIn(F,H,W,K=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(F,(0,t._)`Object.keys(${H})`,W);const U=this._scope.toName(F);return this._for(new _("in",K,U,H),()=>W(U))}endFor(){return this._endBlockNode(x)}label(F){return this._leafNode(new c(F))}break(F){return this._leafNode(new u(F))}return(F){const H=new $;if(this._blockNode(H),this.code(F),H.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode($)}try(F,H,W){if(!H&&!W)throw new Error('CodeGen: "try" without "catch" and "finally"');const K=new E;if(this._blockNode(K),this.code(F),H){const U=this.name("e");this._currNode=K.catch=new k(U),H(U)}return W&&(this._currNode=K.finally=new T,this.code(W)),this._endBlockNode(k,T)}throw(F){return this._leafNode(new d(F))}block(F,H){return this._blockStarts.push(this._nodes.length),F&&this.code(F).endBlock(H),this}endBlock(F){const H=this._blockStarts.pop();if(H===void 0)throw new Error("CodeGen: not in self-balancing block");const W=this._nodes.length-H;if(W<0||F!==void 0&&W!==F)throw new Error(`CodeGen: wrong number of nodes: ${W} vs ${F} expected`);return this._nodes.length=H,this}func(F,H=t.nil,W,K){return this._blockNode(new C(F,H,W)),K&&this.code(K).endFunc(),this}endFunc(){return this._endBlockNode(C)}optimize(F=1){for(;F-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(F){return this._currNode.nodes.push(F),this}_blockNode(F){this._currNode.nodes.push(F),this._nodes.push(F)}_endBlockNode(F,H){const W=this._currNode;if(W instanceof F||H&&W instanceof H)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${H?`${F.kind}/${H.kind}`:F.kind}"`)}_elseNode(F){const H=this._currNode;if(!(H instanceof y))throw new Error('CodeGen: "else" without "if"');return this._currNode=H.else=F,this}get _root(){return this._nodes[0]}get _currNode(){const F=this._nodes;return F[F.length-1]}set _currNode(F){const H=this._nodes;H[H.length-1]=F}}e.CodeGen=I;function P(D,F){for(const H in F)D[H]=(D[H]||0)+(F[H]||0);return D}function N(D,F){return F instanceof t._CodeOrName?P(D,F.names):D}function A(D,F,H){if(D instanceof t.Name)return W(D);if(!K(D))return D;return new t._Code(D._items.reduce((U,q)=>(q instanceof t.Name&&(q=W(q)),q instanceof t._Code?U.push(...q._items):U.push(q),U),[]));function W(U){const q=H[U.str];return q===void 0||F[U.str]!==1?U:(delete F[U.str],q)}function K(U){return U instanceof t._Code&&U._items.some(q=>q instanceof t.Name&&F[q.str]===1&&H[q.str]!==void 0)}}function M(D,F){for(const H in F)D[H]=(D[H]||0)-(F[H]||0)}function R(D){return typeof D=="boolean"||typeof D=="number"||D===null?!D:(0,t._)`!${B(D)}`}e.not=R;const L=V(e.operators.AND);function z(...D){return D.reduce(L)}e.and=z;const j=V(e.operators.OR);function O(...D){return D.reduce(j)}e.or=O;function V(D){return(F,H)=>F===t.nil?H:H===t.nil?F:(0,t._)`${B(F)} ${D} ${B(H)}`}function B(D){return D instanceof t.Name?D:(0,t._)`(${D})`}})(Wn);var zt={};Object.defineProperty(zt,"__esModule",{value:!0});zt.checkStrictMode=zt.getErrorPath=zt.Type=zt.useFunc=zt.setEvaluated=zt.evaluatedPropsToName=zt.mergeEvaluated=zt.eachItem=zt.unescapeJsonPointer=zt.escapeJsonPointer=zt.escapeFragment=zt.unescapeFragment=zt.schemaRefOrVal=zt.schemaHasRulesButRef=zt.schemaHasRules=zt.checkUnknownRules=zt.alwaysValidSchema=zt.toHash=void 0;const Rr=Wn,tUt=H2;function nUt(e){const t={};for(const n of e)t[n]=!0;return t}zt.toHash=nUt;function rUt(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(fLe(e,t),!pLe(t,e.self.RULES.all))}zt.alwaysValidSchema=rUt;function fLe(e,t=e.schema){const{opts:n,self:r}=e;if(!n.strictSchema||typeof t=="boolean")return;const i=r.RULES.keywords;for(const a in t)i[a]||gLe(e,`unknown keyword: "${a}"`)}zt.checkUnknownRules=fLe;function pLe(e,t){if(typeof e=="boolean")return!e;for(const n in e)if(t[n])return!0;return!1}zt.schemaHasRules=pLe;function iUt(e,t){if(typeof e=="boolean")return!e;for(const n in e)if(n!=="$ref"&&t.all[n])return!0;return!1}zt.schemaHasRulesButRef=iUt;function aUt({topSchemaRef:e,schemaPath:t},n,r,i){if(!i){if(typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="string")return(0,Rr._)`${n}`}return(0,Rr._)`${e}${t}${(0,Rr.getProperty)(r)}`}zt.schemaRefOrVal=aUt;function oUt(e){return hLe(decodeURIComponent(e))}zt.unescapeFragment=oUt;function sUt(e){return encodeURIComponent(oJ(e))}zt.escapeFragment=sUt;function oJ(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}zt.escapeJsonPointer=oJ;function hLe(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}zt.unescapeJsonPointer=hLe;function lUt(e,t){if(Array.isArray(e))for(const n of e)t(n);else t(e)}zt.eachItem=lUt;function Rve({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:r}){return(i,a,o,s)=>{const l=o===void 0?a:o instanceof Rr.Name?(a instanceof Rr.Name?e(i,a,o):t(i,a,o),o):a instanceof Rr.Name?(t(i,o,a),a):n(a,o);return s===Rr.Name&&!(l instanceof Rr.Name)?r(i,l):l}}zt.mergeEvaluated={props:Rve({mergeNames:(e,t,n)=>e.if((0,Rr._)`${n} !== true && ${t} !== undefined`,()=>{e.if((0,Rr._)`${t} === true`,()=>e.assign(n,!0),()=>e.assign(n,(0,Rr._)`${n} || {}`).code((0,Rr._)`Object.assign(${n}, ${t})`))}),mergeToName:(e,t,n)=>e.if((0,Rr._)`${n} !== true`,()=>{t===!0?e.assign(n,!0):(e.assign(n,(0,Rr._)`${n} || {}`),sJ(e,n,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:mLe}),items:Rve({mergeNames:(e,t,n)=>e.if((0,Rr._)`${n} !== true && ${t} !== undefined`,()=>e.assign(n,(0,Rr._)`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`)),mergeToName:(e,t,n)=>e.if((0,Rr._)`${n} !== true`,()=>e.assign(n,t===!0?!0:(0,Rr._)`${n} > ${t} ? ${n} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function mLe(e,t){if(t===!0)return e.var("props",!0);const n=e.var("props",(0,Rr._)`{}`);return t!==void 0&&sJ(e,n,t),n}zt.evaluatedPropsToName=mLe;function sJ(e,t,n){Object.keys(n).forEach(r=>e.assign((0,Rr._)`${t}${(0,Rr.getProperty)(r)}`,!0))}zt.setEvaluated=sJ;const Dve={};function cUt(e,t){return e.scopeValue("func",{ref:t,code:Dve[t.code]||(Dve[t.code]=new tUt._Code(t.code))})}zt.useFunc=cUt;var LU;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(LU||(zt.Type=LU={}));function uUt(e,t,n){if(e instanceof Rr.Name){const r=t===LU.Num;return n?r?(0,Rr._)`"[" + ${e} + "]"`:(0,Rr._)`"['" + ${e} + "']"`:r?(0,Rr._)`"/" + ${e}`:(0,Rr._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,Rr.getProperty)(e).toString():"/"+oJ(e)}zt.getErrorPath=uUt;function gLe(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw new Error(t);e.self.logger.warn(t)}}zt.checkStrictMode=gLe;var cd={};Object.defineProperty(cd,"__esModule",{value:!0});const ro=Wn,dUt={data:new ro.Name("data"),valCxt:new ro.Name("valCxt"),instancePath:new ro.Name("instancePath"),parentData:new ro.Name("parentData"),parentDataProperty:new ro.Name("parentDataProperty"),rootData:new ro.Name("rootData"),dynamicAnchors:new ro.Name("dynamicAnchors"),vErrors:new ro.Name("vErrors"),errors:new ro.Name("errors"),this:new ro.Name("this"),self:new ro.Name("self"),scope:new ro.Name("scope"),json:new ro.Name("json"),jsonPos:new ro.Name("jsonPos"),jsonLen:new ro.Name("jsonLen"),jsonPart:new ro.Name("jsonPart")};cd.default=dUt;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=Wn,n=zt,r=cd;e.keywordError={message:({keyword:v})=>(0,t.str)`must pass "${v}" keyword validation`},e.keyword$DataError={message:({keyword:v,schemaType:y})=>y?(0,t.str)`"${v}" keyword must be ${y} ($data)`:(0,t.str)`"${v}" keyword is invalid ($data)`};function i(v,y=e.keywordError,x,w){const{it:S}=v,{gen:_,compositeRule:C,allErrors:$}=S,E=d(v,y,x);w??(C||$)?l(_,E):c(S,(0,t._)`[${E}]`)}e.reportError=i;function a(v,y=e.keywordError,x){const{it:w}=v,{gen:S,compositeRule:_,allErrors:C}=w,$=d(v,y,x);l(S,$),_||C||c(w,r.default.vErrors)}e.reportExtraError=a;function o(v,y){v.assign(r.default.errors,y),v.if((0,t._)`${r.default.vErrors} !== null`,()=>v.if(y,()=>v.assign((0,t._)`${r.default.vErrors}.length`,y),()=>v.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:v,keyword:y,schemaValue:x,data:w,errsCount:S,it:_}){if(S===void 0)throw new Error("ajv implementation error");const C=v.name("err");v.forRange("i",S,r.default.errors,$=>{v.const(C,(0,t._)`${r.default.vErrors}[${$}]`),v.if((0,t._)`${C}.instancePath === undefined`,()=>v.assign((0,t._)`${C}.instancePath`,(0,t.strConcat)(r.default.instancePath,_.errorPath))),v.assign((0,t._)`${C}.schemaPath`,(0,t.str)`${_.errSchemaPath}/${y}`),_.opts.verbose&&(v.assign((0,t._)`${C}.schema`,x),v.assign((0,t._)`${C}.data`,w))})}e.extendErrors=s;function l(v,y){const x=v.const("err",y);v.if((0,t._)`${r.default.vErrors} === null`,()=>v.assign(r.default.vErrors,(0,t._)`[${x}]`),(0,t._)`${r.default.vErrors}.push(${x})`),v.code((0,t._)`${r.default.errors}++`)}function c(v,y){const{gen:x,validateName:w,schemaEnv:S}=v;S.$async?x.throw((0,t._)`new ${v.ValidationError}(${y})`):(x.assign((0,t._)`${w}.errors`,y),x.return(!1))}const u={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function d(v,y,x){const{createErrors:w}=v.it;return w===!1?(0,t._)`{}`:f(v,y,x)}function f(v,y,x={}){const{gen:w,it:S}=v,_=[p(S,x),h(v,x)];return g(v,y,_),w.object(..._)}function p({errorPath:v},{instancePath:y}){const x=y?(0,t.str)`${v}${(0,n.getErrorPath)(y,n.Type.Str)}`:v;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,x)]}function h({keyword:v,it:{errSchemaPath:y}},{schemaPath:x,parentSchema:w}){let S=w?y:(0,t.str)`${y}/${v}`;return x&&(S=(0,t.str)`${S}${(0,n.getErrorPath)(x,n.Type.Str)}`),[u.schemaPath,S]}function g(v,{params:y,message:x},w){const{keyword:S,data:_,schemaValue:C,it:$}=v,{opts:E,propertyName:k,topSchemaRef:T,schemaPath:I}=$;w.push([u.keyword,S],[u.params,typeof y=="function"?y(v):y||(0,t._)`{}`]),E.messages&&w.push([u.message,typeof x=="function"?x(v):x]),E.verbose&&w.push([u.schema,C],[u.parentSchema,(0,t._)`${T}${I}`],[r.default.data,_]),k&&w.push([u.propertyName,k])}})(yT);Object.defineProperty(_1,"__esModule",{value:!0});_1.boolOrEmptySchema=_1.topBoolOrEmptySchema=void 0;const fUt=yT,pUt=Wn,hUt=cd,mUt={message:"boolean schema is false"};function gUt(e){const{gen:t,schema:n,validateName:r}=e;n===!1?vLe(e,!1):typeof n=="object"&&n.$async===!0?t.return(hUt.default.data):(t.assign((0,pUt._)`${r}.errors`,null),t.return(!0))}_1.topBoolOrEmptySchema=gUt;function vUt(e,t){const{gen:n,schema:r}=e;r===!1?(n.var(t,!1),vLe(e)):n.var(t,!0)}_1.boolOrEmptySchema=vUt;function vLe(e,t){const{gen:n,data:r}=e,i={gen:n,keyword:"false schema",data:r,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,fUt.reportError)(i,mUt,void 0,t)}var la={},Xv={};Object.defineProperty(Xv,"__esModule",{value:!0});Xv.getRules=Xv.isJSONType=void 0;const yUt=["string","number","integer","boolean","null","object","array"],bUt=new Set(yUt);function xUt(e){return typeof e=="string"&&bUt.has(e)}Xv.isJSONType=xUt;function wUt(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Xv.getRules=wUt;var rf={};Object.defineProperty(rf,"__esModule",{value:!0});rf.shouldUseRule=rf.shouldUseGroup=rf.schemaHasRulesForType=void 0;function SUt({schema:e,self:t},n){const r=t.RULES.types[n];return r&&r!==!0&&yLe(e,r)}rf.schemaHasRulesForType=SUt;function yLe(e,t){return t.rules.some(n=>bLe(e,n))}rf.shouldUseGroup=yLe;function bLe(e,t){var n;return e[t.keyword]!==void 0||((n=t.definition.implements)===null||n===void 0?void 0:n.some(r=>e[r]!==void 0))}rf.shouldUseRule=bLe;Object.defineProperty(la,"__esModule",{value:!0});la.reportTypeError=la.checkDataTypes=la.checkDataType=la.coerceAndCheckDataType=la.getJSONTypes=la.getSchemaTypes=la.DataType=void 0;const _Ut=Xv,CUt=rf,$Ut=yT,jn=Wn,xLe=zt;var lx;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(lx||(la.DataType=lx={}));function EUt(e){const t=wLe(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}la.getSchemaTypes=EUt;function wLe(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(_Ut.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}la.getJSONTypes=wLe;function TUt(e,t){const{gen:n,data:r,opts:i}=e,a=IUt(t,i.coerceTypes),o=t.length>0&&!(a.length===0&&t.length===1&&(0,CUt.schemaHasRulesForType)(e,t[0]));if(o){const s=lJ(t,r,i.strictNumbers,lx.Wrong);n.if(s,()=>{a.length?kUt(e,t,a):cJ(e)})}return o}la.coerceAndCheckDataType=TUt;const SLe=new Set(["string","number","integer","boolean","null"]);function IUt(e,t){return t?e.filter(n=>SLe.has(n)||t==="array"&&n==="array"):[]}function kUt(e,t,n){const{gen:r,data:i,opts:a}=e,o=r.let("dataType",(0,jn._)`typeof ${i}`),s=r.let("coerced",(0,jn._)`undefined`);a.coerceTypes==="array"&&r.if((0,jn._)`${o} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>r.assign(i,(0,jn._)`${i}[0]`).assign(o,(0,jn._)`typeof ${i}`).if(lJ(t,i,a.strictNumbers),()=>r.assign(s,i))),r.if((0,jn._)`${s} !== undefined`);for(const c of n)(SLe.has(c)||c==="array"&&a.coerceTypes==="array")&&l(c);r.else(),cJ(e),r.endIf(),r.if((0,jn._)`${s} !== undefined`,()=>{r.assign(i,s),PUt(e,s)});function l(c){switch(c){case"string":r.elseIf((0,jn._)`${o} == "number" || ${o} == "boolean"`).assign(s,(0,jn._)`"" + ${i}`).elseIf((0,jn._)`${i} === null`).assign(s,(0,jn._)`""`);return;case"number":r.elseIf((0,jn._)`${o} == "boolean" || ${i} === null
|
|
783
783
|
|| (${o} == "string" && ${i} && ${i} == +${i})`).assign(s,(0,jn._)`+${i}`);return;case"integer":r.elseIf((0,jn._)`${o} === "boolean" || ${i} === null
|
|
784
784
|
|| (${o} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(s,(0,jn._)`+${i}`);return;case"boolean":r.elseIf((0,jn._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(s,!1).elseIf((0,jn._)`${i} === "true" || ${i} === 1`).assign(s,!0);return;case"null":r.elseIf((0,jn._)`${i} === "" || ${i} === 0 || ${i} === false`),r.assign(s,null);return;case"array":r.elseIf((0,jn._)`${o} === "string" || ${o} === "number"
|
|
785
|
-
|| ${o} === "boolean" || ${i} === null`).assign(s,(0,jn._)`[${i}]`)}}}function NUt({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,jn._)`${t} !== undefined`,()=>e.assign((0,jn._)`${t}[${n}]`,r))}function jU(e,t,n,r=lx.Correct){const i=r===lx.Correct?jn.operators.EQ:jn.operators.NEQ;let a;switch(e){case"null":return(0,jn._)`${t} ${i} null`;case"array":a=(0,jn._)`Array.isArray(${t})`;break;case"object":a=(0,jn._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":a=o((0,jn._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":a=o();break;default:return(0,jn._)`typeof ${t} ${i} ${e}`}return r===lx.Correct?a:(0,jn.not)(a);function o(s=jn.nil){return(0,jn.and)((0,jn._)`typeof ${t} == "number"`,s,n?(0,jn._)`isFinite(${t})`:jn.nil)}}la.checkDataType=jU;function lJ(e,t,n,r){if(e.length===1)return jU(e[0],t,n,r);let i;const a=(0,xLe.toHash)(e);if(a.array&&a.object){const o=(0,jn._)`typeof ${t} != "object"`;i=a.null?o:(0,jn._)`!${t} || ${o}`,delete a.null,delete a.array,delete a.object}else i=jn.nil;a.number&&delete a.integer;for(const o in a)i=(0,jn.and)(i,jU(o,t,n,r));return i}la.checkDataTypes=lJ;const AUt={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,jn._)`{type: ${e}}`:(0,jn._)`{type: ${t}}`};function cJ(e){const t=MUt(e);(0,EUt.reportError)(t,AUt)}la.reportTypeError=cJ;function MUt(e){const{gen:t,data:n,schema:r}=e,i=(0,xLe.schemaRefOrVal)(e,r,"type");return{gen:t,keyword:"type",data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}var cj={};Object.defineProperty(cj,"__esModule",{value:!0});cj.assignDefaults=void 0;const z0=Wn,RUt=zt;function DUt(e,t){const{properties:n,items:r}=e.schema;if(t==="object"&&n)for(const i in n)Ove(e,i,n[i].default);else t==="array"&&Array.isArray(r)&&r.forEach((i,a)=>Ove(e,a,i.default))}cj.assignDefaults=DUt;function Ove(e,t,n){const{gen:r,compositeRule:i,data:a,opts:o}=e;if(n===void 0)return;const s=(0,z0._)`${a}${(0,z0.getProperty)(t)}`;if(i){(0,RUt.checkStrictMode)(e,`default is ignored for: ${s}`);return}let l=(0,z0._)`${s} === undefined`;o.useDefaults==="empty"&&(l=(0,z0._)`${l} || ${s} === null || ${s} === ""`),r.if(l,(0,z0._)`${s} = ${(0,z0.stringify)(n)}`)}var Iu={},Xn={};Object.defineProperty(Xn,"__esModule",{value:!0});Xn.validateUnion=Xn.validateArray=Xn.usePattern=Xn.callValidateCode=Xn.schemaProperties=Xn.allSchemaProperties=Xn.noPropertyInData=Xn.propertyInData=Xn.isOwnProperty=Xn.hasPropFunc=Xn.reportMissingProp=Xn.checkMissingProp=Xn.checkReportMissingProp=void 0;const Xr=Wn,uJ=zt,ip=cd,OUt=zt;function LUt(e,t){const{gen:n,data:r,it:i}=e;n.if(fJ(n,r,t,i.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Xr._)`${t}`},!0),e.error()})}Xn.checkReportMissingProp=LUt;function jUt({gen:e,data:t,it:{opts:n}},r,i){return(0,Xr.or)(...r.map(a=>(0,Xr.and)(fJ(e,t,a,n.ownProperties),(0,Xr._)`${i} = ${a}`)))}Xn.checkMissingProp=jUt;function zUt(e,t){e.setParams({missingProperty:t},!0),e.error()}Xn.reportMissingProp=zUt;function _Le(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Xr._)`Object.prototype.hasOwnProperty`})}Xn.hasPropFunc=_Le;function dJ(e,t,n){return(0,Xr._)`${_Le(e)}.call(${t}, ${n})`}Xn.isOwnProperty=dJ;function FUt(e,t,n,r){const i=(0,Xr._)`${t}${(0,Xr.getProperty)(n)} !== undefined`;return r?(0,Xr._)`${i} && ${dJ(e,t,n)}`:i}Xn.propertyInData=FUt;function fJ(e,t,n,r){const i=(0,Xr._)`${t}${(0,Xr.getProperty)(n)} === undefined`;return r?(0,Xr.or)(i,(0,Xr.not)(dJ(e,t,n))):i}Xn.noPropertyInData=fJ;function CLe(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Xn.allSchemaProperties=CLe;function BUt(e,t){return CLe(t).filter(n=>!(0,uJ.alwaysValidSchema)(e,t[n]))}Xn.schemaProperties=BUt;function VUt({schemaCode:e,data:t,it:{gen:n,topSchemaRef:r,schemaPath:i,errorPath:a},it:o},s,l,c){const u=c?(0,Xr._)`${e}, ${t}, ${r}${i}`:t,d=[[ip.default.instancePath,(0,Xr.strConcat)(ip.default.instancePath,a)],[ip.default.parentData,o.parentData],[ip.default.parentDataProperty,o.parentDataProperty],[ip.default.rootData,ip.default.rootData]];o.opts.dynamicRef&&d.push([ip.default.dynamicAnchors,ip.default.dynamicAnchors]);const f=(0,Xr._)`${u}, ${n.object(...d)}`;return l!==Xr.nil?(0,Xr._)`${s}.call(${l}, ${f})`:(0,Xr._)`${s}(${f})`}Xn.callValidateCode=VUt;const HUt=(0,Xr._)`new RegExp`;function WUt({gen:e,it:{opts:t}},n){const r=t.unicodeRegExp?"u":"",{regExp:i}=t.code,a=i(n,r);return e.scopeValue("pattern",{key:a.toString(),ref:a,code:(0,Xr._)`${i.code==="new RegExp"?HUt:(0,OUt.useFunc)(e,i)}(${n}, ${r})`})}Xn.usePattern=WUt;function UUt(e){const{gen:t,data:n,keyword:r,it:i}=e,a=t.name("valid");if(i.allErrors){const s=t.let("valid",!0);return o(()=>t.assign(s,!1)),s}return t.var(a,!0),o(()=>t.break()),a;function o(s){const l=t.const("len",(0,Xr._)`${n}.length`);t.forRange("i",0,l,c=>{e.subschema({keyword:r,dataProp:c,dataPropType:uJ.Type.Num},a),t.if((0,Xr.not)(a),s)})}}Xn.validateArray=UUt;function GUt(e){const{gen:t,schema:n,keyword:r,it:i}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some(l=>(0,uJ.alwaysValidSchema)(i,l))&&!i.opts.unevaluated)return;const o=t.let("valid",!1),s=t.name("_valid");t.block(()=>n.forEach((l,c)=>{const u=e.subschema({keyword:r,schemaProp:c,compositeRule:!0},s);t.assign(o,(0,Xr._)`${o} || ${s}`),e.mergeValidEvaluated(u,s)||t.if((0,Xr.not)(o))})),e.result(o,()=>e.reset(),()=>e.error(!0))}Xn.validateUnion=GUt;Object.defineProperty(Iu,"__esModule",{value:!0});Iu.validateKeywordUsage=Iu.validSchemaType=Iu.funcKeywordCode=Iu.macroKeywordCode=void 0;const Mo=Wn,sg=cd,qUt=Xn,KUt=yT;function YUt(e,t){const{gen:n,keyword:r,schema:i,parentSchema:a,it:o}=e,s=t.macro.call(o.self,i,a,o),l=$Le(n,r,s);o.opts.validateSchema!==!1&&o.self.validateSchema(s,!0);const c=n.name("valid");e.subschema({schema:s,schemaPath:Mo.nil,errSchemaPath:`${o.errSchemaPath}/${r}`,topSchemaRef:l,compositeRule:!0},c),e.pass(c,()=>e.error(!0))}Iu.macroKeywordCode=YUt;function XUt(e,t){var n;const{gen:r,keyword:i,schema:a,parentSchema:o,$data:s,it:l}=e;QUt(l,t);const c=!s&&t.compile?t.compile.call(l.self,a,o,l):t.validate,u=$Le(r,i,c),d=r.let("valid");e.block$data(d,f),e.ok((n=t.valid)!==null&&n!==void 0?n:d);function f(){if(t.errors===!1)g(),t.modifying&&Lve(e),v(()=>e.error());else{const y=t.async?p():h();t.modifying&&Lve(e),v(()=>ZUt(e,y))}}function p(){const y=r.let("ruleErrs",null);return r.try(()=>g((0,Mo._)`await `),x=>r.assign(d,!1).if((0,Mo._)`${x} instanceof ${l.ValidationError}`,()=>r.assign(y,(0,Mo._)`${x}.errors`),()=>r.throw(x))),y}function h(){const y=(0,Mo._)`${u}.errors`;return r.assign(y,null),g(Mo.nil),y}function g(y=t.async?(0,Mo._)`await `:Mo.nil){const x=l.opts.passContext?sg.default.this:sg.default.self,w=!("compile"in t&&!s||t.schema===!1);r.assign(d,(0,Mo._)`${y}${(0,qUt.callValidateCode)(e,u,x,w)}`,t.modifying)}function v(y){var x;r.if((0,Mo.not)((x=t.valid)!==null&&x!==void 0?x:d),y)}}Iu.funcKeywordCode=XUt;function Lve(e){const{gen:t,data:n,it:r}=e;t.if(r.parentData,()=>t.assign(n,(0,Mo._)`${r.parentData}[${r.parentDataProperty}]`))}function ZUt(e,t){const{gen:n}=e;n.if((0,Mo._)`Array.isArray(${t})`,()=>{n.assign(sg.default.vErrors,(0,Mo._)`${sg.default.vErrors} === null ? ${t} : ${sg.default.vErrors}.concat(${t})`).assign(sg.default.errors,(0,Mo._)`${sg.default.vErrors}.length`),(0,KUt.extendErrors)(e)},()=>e.error())}function QUt({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function $Le(e,t,n){if(n===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof n=="function"?{ref:n}:{ref:n,code:(0,Mo.stringify)(n)})}function JUt(e,t,n=!1){return!t.length||t.some(r=>r==="array"?Array.isArray(e):r==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==r||n&&typeof e>"u")}Iu.validSchemaType=JUt;function eGt({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw new Error("ajv implementation error");const o=i.dependencies;if(o!=null&&o.some(s=>!Object.prototype.hasOwnProperty.call(e,s)))throw new Error(`parent schema must have dependencies of ${a}: ${o.join(",")}`);if(i.validateSchema&&!i.validateSchema(e[a])){const l=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema==="log")n.logger.error(l);else throw new Error(l)}}Iu.validateKeywordUsage=eGt;var Ch={};Object.defineProperty(Ch,"__esModule",{value:!0});Ch.extendSubschemaMode=Ch.extendSubschemaData=Ch.getSubschema=void 0;const _u=Wn,ELe=zt;function tGt(e,{keyword:t,schemaProp:n,schema:r,schemaPath:i,errSchemaPath:a,topSchemaRef:o}){if(t!==void 0&&r!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){const s=e.schema[t];return n===void 0?{schema:s,schemaPath:(0,_u._)`${e.schemaPath}${(0,_u.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:s[n],schemaPath:(0,_u._)`${e.schemaPath}${(0,_u.getProperty)(t)}${(0,_u.getProperty)(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,ELe.escapeFragment)(n)}`}}if(r!==void 0){if(i===void 0||a===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:r,schemaPath:i,topSchemaRef:o,errSchemaPath:a}}throw new Error('either "keyword" or "schema" must be passed')}Ch.getSubschema=tGt;function nGt(e,t,{dataProp:n,dataPropType:r,data:i,dataTypes:a,propertyName:o}){if(i!==void 0&&n!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:s}=t;if(n!==void 0){const{errorPath:c,dataPathArr:u,opts:d}=t,f=s.let("data",(0,_u._)`${t.data}${(0,_u.getProperty)(n)}`,!0);l(f),e.errorPath=(0,_u.str)`${c}${(0,ELe.getErrorPath)(n,r,d.jsPropertySyntax)}`,e.parentDataProperty=(0,_u._)`${n}`,e.dataPathArr=[...u,e.parentDataProperty]}if(i!==void 0){const c=i instanceof _u.Name?i:s.let("data",i,!0);l(c),o!==void 0&&(e.propertyName=o)}a&&(e.dataTypes=a);function l(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c]}}Ch.extendSubschemaData=nGt;function rGt(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}Ch.extendSubschemaMode=rGt;var Va={},TLe=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n},ILe={exports:{}},eh=ILe.exports=function(e,t,n){typeof t=="function"&&(n=t,t={}),n=t.cb||n;var r=typeof n=="function"?n:n.pre||function(){},i=n.post||function(){};HN(t,r,i,e,"",e)};eh.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};eh.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};eh.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};eh.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function HN(e,t,n,r,i,a,o,s,l,c){if(r&&typeof r=="object"&&!Array.isArray(r)){t(r,i,a,o,s,l,c);for(var u in r){var d=r[u];if(Array.isArray(d)){if(u in eh.arrayKeywords)for(var f=0;f<d.length;f++)HN(e,t,n,d[f],i+"/"+u+"/"+f,a,i,u,r,f)}else if(u in eh.propsKeywords){if(d&&typeof d=="object")for(var p in d)HN(e,t,n,d[p],i+"/"+u+"/"+iGt(p),a,i,u,r,p)}else(u in eh.keywords||e.allKeys&&!(u in eh.skipKeywords))&&HN(e,t,n,d,i+"/"+u,a,i,u,r)}n(r,i,a,o,s,l,c)}}function iGt(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var aGt=ILe.exports;Object.defineProperty(Va,"__esModule",{value:!0});Va.getSchemaRefs=Va.resolveUrl=Va.normalizeId=Va._getFullPath=Va.getFullPath=Va.inlineRef=void 0;const oGt=zt,sGt=TLe,lGt=aGt,cGt=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function uGt(e,t=!0){return typeof e=="boolean"?!0:t===!0?!zU(e):t?kLe(e)<=t:!1}Va.inlineRef=uGt;const dGt=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function zU(e){for(const t in e){if(dGt.has(t))return!0;const n=e[t];if(Array.isArray(n)&&n.some(zU)||typeof n=="object"&&zU(n))return!0}return!1}function kLe(e){let t=0;for(const n in e){if(n==="$ref")return 1/0;if(t++,!cGt.has(n)&&(typeof e[n]=="object"&&(0,oGt.eachItem)(e[n],r=>t+=kLe(r)),t===1/0))return 1/0}return t}function PLe(e,t="",n){n!==!1&&(t=cx(t));const r=e.parse(t);return NLe(e,r)}Va.getFullPath=PLe;function NLe(e,t){return e.serialize(t).split("#")[0]+"#"}Va._getFullPath=NLe;const fGt=/#\/?$/;function cx(e){return e?e.replace(fGt,""):""}Va.normalizeId=cx;function pGt(e,t,n){return n=cx(n),e.resolve(t,n)}Va.resolveUrl=pGt;const hGt=/^[a-z_][-a-z0-9._]*$/i;function mGt(e,t){if(typeof e=="boolean")return{};const{schemaId:n,uriResolver:r}=this.opts,i=cx(e[n]||t),a={"":i},o=PLe(r,i,!1),s={},l=new Set;return lGt(e,{allKeys:!0},(d,f,p,h)=>{if(h===void 0)return;const g=o+f;let v=a[h];typeof d[n]=="string"&&(v=y.call(this,d[n])),x.call(this,d.$anchor),x.call(this,d.$dynamicAnchor),a[f]=v;function y(w){const S=this.opts.uriResolver.resolve;if(w=cx(v?S(v,w):w),l.has(w))throw u(w);l.add(w);let _=this.refs[w];return typeof _=="string"&&(_=this.refs[_]),typeof _=="object"?c(d,_.schema,w):w!==cx(g)&&(w[0]==="#"?(c(d,s[w],w),s[w]=d):this.refs[w]=g),w}function x(w){if(typeof w=="string"){if(!hGt.test(w))throw new Error(`invalid anchor "${w}"`);y.call(this,`#${w}`)}}}),s;function c(d,f,p){if(f!==void 0&&!sGt(d,f))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Va.getSchemaRefs=mGt;Object.defineProperty(Mc,"__esModule",{value:!0});Mc.getData=Mc.KeywordCxt=Mc.validateFunctionCode=void 0;const ALe=_1,jve=la,pJ=rf,QR=la,gGt=cj,PC=Iu,q6=Ch,Zt=Wn,Sn=cd,vGt=Va,af=zt,HS=yT;function yGt(e){if(DLe(e)&&(OLe(e),RLe(e))){wGt(e);return}MLe(e,()=>(0,ALe.topBoolOrEmptySchema)(e))}Mc.validateFunctionCode=yGt;function MLe({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,Zt._)`${Sn.default.data}, ${Sn.default.valCxt}`,r.$async,()=>{e.code((0,Zt._)`"use strict"; ${zve(n,i)}`),xGt(e,i),e.code(a)}):e.func(t,(0,Zt._)`${Sn.default.data}, ${bGt(i)}`,r.$async,()=>e.code(zve(n,i)).code(a))}function bGt(e){return(0,Zt._)`{${Sn.default.instancePath}="", ${Sn.default.parentData}, ${Sn.default.parentDataProperty}, ${Sn.default.rootData}=${Sn.default.data}${e.dynamicRef?(0,Zt._)`, ${Sn.default.dynamicAnchors}={}`:Zt.nil}}={}`}function xGt(e,t){e.if(Sn.default.valCxt,()=>{e.var(Sn.default.instancePath,(0,Zt._)`${Sn.default.valCxt}.${Sn.default.instancePath}`),e.var(Sn.default.parentData,(0,Zt._)`${Sn.default.valCxt}.${Sn.default.parentData}`),e.var(Sn.default.parentDataProperty,(0,Zt._)`${Sn.default.valCxt}.${Sn.default.parentDataProperty}`),e.var(Sn.default.rootData,(0,Zt._)`${Sn.default.valCxt}.${Sn.default.rootData}`),t.dynamicRef&&e.var(Sn.default.dynamicAnchors,(0,Zt._)`${Sn.default.valCxt}.${Sn.default.dynamicAnchors}`)},()=>{e.var(Sn.default.instancePath,(0,Zt._)`""`),e.var(Sn.default.parentData,(0,Zt._)`undefined`),e.var(Sn.default.parentDataProperty,(0,Zt._)`undefined`),e.var(Sn.default.rootData,Sn.default.data),t.dynamicRef&&e.var(Sn.default.dynamicAnchors,(0,Zt._)`{}`)})}function wGt(e){const{schema:t,opts:n,gen:r}=e;MLe(e,()=>{n.$comment&&t.$comment&&jLe(e),EGt(e),r.let(Sn.default.vErrors,null),r.let(Sn.default.errors,0),n.unevaluated&&SGt(e),LLe(e),kGt(e)})}function SGt(e){const{gen:t,validateName:n}=e;e.evaluated=t.const("evaluated",(0,Zt._)`${n}.evaluated`),t.if((0,Zt._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Zt._)`${e.evaluated}.props`,(0,Zt._)`undefined`)),t.if((0,Zt._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Zt._)`${e.evaluated}.items`,(0,Zt._)`undefined`))}function zve(e,t){const n=typeof e=="object"&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,Zt._)`/*# sourceURL=${n} */`:Zt.nil}function _Gt(e,t){if(DLe(e)&&(OLe(e),RLe(e))){CGt(e,t);return}(0,ALe.boolOrEmptySchema)(e,t)}function RLe({schema:e,self:t}){if(typeof e=="boolean")return!e;for(const n in e)if(t.RULES.all[n])return!0;return!1}function DLe(e){return typeof e.schema!="boolean"}function CGt(e,t){const{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&jLe(e),TGt(e),IGt(e);const a=r.const("_errs",Sn.default.errors);LLe(e,a),r.var(t,(0,Zt._)`${a} === ${Sn.default.errors}`)}function OLe(e){(0,af.checkUnknownRules)(e),$Gt(e)}function LLe(e,t){if(e.opts.jtd)return Fve(e,[],!1,t);const n=(0,jve.getSchemaTypes)(e.schema),r=(0,jve.coerceAndCheckDataType)(e,n);Fve(e,n,!r,t)}function $Gt(e){const{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,af.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function EGt(e){const{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,af.checkStrictMode)(e,"default is ignored in the schema root")}function TGt(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,vGt.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function IGt(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function jLe({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){const a=n.$comment;if(i.$comment===!0)e.code((0,Zt._)`${Sn.default.self}.logger.log(${a})`);else if(typeof i.$comment=="function"){const o=(0,Zt.str)`${r}/$comment`,s=e.scopeValue("root",{ref:t.root});e.code((0,Zt._)`${Sn.default.self}.opts.$comment(${a}, ${o}, ${s}.schema)`)}}function kGt(e){const{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,Zt._)`${Sn.default.errors} === 0`,()=>t.return(Sn.default.data),()=>t.throw((0,Zt._)`new ${i}(${Sn.default.vErrors})`)):(t.assign((0,Zt._)`${r}.errors`,Sn.default.vErrors),a.unevaluated&&PGt(e),t.return((0,Zt._)`${Sn.default.errors} === 0`))}function PGt({gen:e,evaluated:t,props:n,items:r}){n instanceof Zt.Name&&e.assign((0,Zt._)`${t}.props`,n),r instanceof Zt.Name&&e.assign((0,Zt._)`${t}.items`,r)}function Fve(e,t,n,r){const{gen:i,schema:a,data:o,allErrors:s,opts:l,self:c}=e,{RULES:u}=c;if(a.$ref&&(l.ignoreKeywordsWithRef||!(0,af.schemaHasRulesButRef)(a,u))){i.block(()=>BLe(e,"$ref",u.all.$ref.definition));return}l.jtd||NGt(e,t),i.block(()=>{for(const f of u.rules)d(f);d(u.post)});function d(f){(0,pJ.shouldUseGroup)(a,f)&&(f.type?(i.if((0,QR.checkDataType)(f.type,o,l.strictNumbers)),Bve(e,f),t.length===1&&t[0]===f.type&&n&&(i.else(),(0,QR.reportTypeError)(e)),i.endIf()):Bve(e,f),s||i.if((0,Zt._)`${Sn.default.errors} === ${r||0}`))}}function Bve(e,t){const{gen:n,schema:r,opts:{useDefaults:i}}=e;i&&(0,gGt.assignDefaults)(e,t.type),n.block(()=>{for(const a of t.rules)(0,pJ.shouldUseRule)(r,a)&&BLe(e,a.keyword,a.definition,t.type)})}function NGt(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(AGt(e,t),e.opts.allowUnionTypes||MGt(e,t),RGt(e,e.dataTypes))}function AGt(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(n=>{zLe(e.dataTypes,n)||hJ(e,`type "${n}" not allowed by context "${e.dataTypes.join(",")}"`)}),OGt(e,t)}}function MGt(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&hJ(e,"use allowUnionTypes to allow union type keyword")}function RGt(e,t){const n=e.self.RULES.all;for(const r in n){const i=n[r];if(typeof i=="object"&&(0,pJ.shouldUseRule)(e.schema,i)){const{type:a}=i.definition;a.length&&!a.some(o=>DGt(t,o))&&hJ(e,`missing type "${a.join(",")}" for keyword "${r}"`)}}}function DGt(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function zLe(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function OGt(e,t){const n=[];for(const r of e.dataTypes)zLe(t,r)?n.push(r):t.includes("integer")&&r==="number"&&n.push("integer");e.dataTypes=n}function hJ(e,t){const n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,af.checkStrictMode)(e,t,e.opts.strictTypes)}class FLe{constructor(t,n,r){if((0,PC.validateKeywordUsage)(t,n,r),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=r,this.data=t.data,this.schema=t.schema[r],this.$data=n.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,af.schemaRefOrVal)(t,this.schema,r,this.$data),this.schemaType=n.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=n,this.$data)this.schemaCode=t.gen.const("vSchema",VLe(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,PC.validSchemaType)(this.schema,n.schemaType,n.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(n.schemaType)}`);("code"in n?n.trackErrors:n.errors!==!1)&&(this.errsCount=t.gen.const("_errs",Sn.default.errors))}result(t,n,r){this.failResult((0,Zt.not)(t),n,r)}failResult(t,n,r){this.gen.if(t),r?r():this.error(),n?(this.gen.else(),n(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,n){this.failResult((0,Zt.not)(t),void 0,n)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:n}=this;this.fail((0,Zt._)`${n} !== undefined && (${(0,Zt.or)(this.invalid$data(),t)})`)}error(t,n,r){if(n){this.setParams(n),this._error(t,r),this.setParams({});return}this._error(t,r)}_error(t,n){(t?HS.reportExtraError:HS.reportError)(this,this.def.error,n)}$dataError(){(0,HS.reportError)(this,this.def.$dataError||HS.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,HS.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,n){n?Object.assign(this.params,t):this.params=t}block$data(t,n,r=Zt.nil){this.gen.block(()=>{this.check$data(t,r),n()})}check$data(t=Zt.nil,n=Zt.nil){if(!this.$data)return;const{gen:r,schemaCode:i,schemaType:a,def:o}=this;r.if((0,Zt.or)((0,Zt._)`${i} === undefined`,n)),t!==Zt.nil&&r.assign(t,!0),(a.length||o.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),t!==Zt.nil&&r.assign(t,!1)),r.else()}invalid$data(){const{gen:t,schemaCode:n,schemaType:r,def:i,it:a}=this;return(0,Zt.or)(o(),s());function o(){if(r.length){if(!(n instanceof Zt.Name))throw new Error("ajv implementation error");const l=Array.isArray(r)?r:[r];return(0,Zt._)`${(0,QR.checkDataTypes)(l,n,a.opts.strictNumbers,QR.DataType.Wrong)}`}return Zt.nil}function s(){if(i.validateSchema){const l=t.scopeValue("validate$data",{ref:i.validateSchema});return(0,Zt._)`!${l}(${n})`}return Zt.nil}}subschema(t,n){const r=(0,q6.getSubschema)(this.it,t);(0,q6.extendSubschemaData)(r,this.it,t),(0,q6.extendSubschemaMode)(r,t);const i={...this.it,...r,items:void 0,props:void 0};return _Gt(i,n),i}mergeEvaluated(t,n){const{it:r,gen:i}=this;r.opts.unevaluated&&(r.props!==!0&&t.props!==void 0&&(r.props=af.mergeEvaluated.props(i,t.props,r.props,n)),r.items!==!0&&t.items!==void 0&&(r.items=af.mergeEvaluated.items(i,t.items,r.items,n)))}mergeValidEvaluated(t,n){const{it:r,gen:i}=this;if(r.opts.unevaluated&&(r.props!==!0||r.items!==!0))return i.if(n,()=>this.mergeEvaluated(t,Zt.Name)),!0}}Mc.KeywordCxt=FLe;function BLe(e,t,n,r){const i=new FLe(e,n,t);"code"in n?n.code(i,r):i.$data&&n.validate?(0,PC.funcKeywordCode)(i,n):"macro"in n?(0,PC.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,PC.funcKeywordCode)(i,n)}const LGt=/^\/(?:[^~]|~0|~1)*$/,jGt=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function VLe(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e==="")return Sn.default.rootData;if(e[0]==="/"){if(!LGt.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);i=e,a=Sn.default.rootData}else{const c=jGt.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);const u=+c[1];if(i=c[2],i==="#"){if(u>=t)throw new Error(l("property/index",u));return r[t-u]}if(u>t)throw new Error(l("data",u));if(a=n[t-u],!i)return a}let o=a;const s=i.split("/");for(const c of s)c&&(a=(0,Zt._)`${a}${(0,Zt.getProperty)((0,af.unescapeJsonPointer)(c))}`,o=(0,Zt._)`${o} && ${a}`);return o;function l(c,u){return`Cannot access ${c} ${u} levels up, current level is ${t}`}}Mc.getData=VLe;var bT={};Object.defineProperty(bT,"__esModule",{value:!0});class zGt extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}bT.default=zGt;var Pw={};Object.defineProperty(Pw,"__esModule",{value:!0});const K6=Va;class FGt extends Error{constructor(t,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,K6.resolveUrl)(t,n,r),this.missingSchema=(0,K6.normalizeId)((0,K6.getFullPath)(t,this.missingRef))}}Pw.default=FGt;var vs={};Object.defineProperty(vs,"__esModule",{value:!0});vs.resolveSchema=vs.getCompilingSchema=vs.resolveRef=vs.compileSchema=vs.SchemaEnv=void 0;const lc=Wn,BGt=bT,jm=cd,xc=Va,Vve=zt,VGt=Mc;class uj{constructor(t){var n;this.refs={},this.dynamicAnchors={};let r;typeof t.schema=="object"&&(r=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(n=t.baseId)!==null&&n!==void 0?n:(0,xc.normalizeId)(r==null?void 0:r[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=r==null?void 0:r.$async,this.refs={}}}vs.SchemaEnv=uj;function mJ(e){const t=HLe.call(this,e);if(t)return t;const n=(0,xc.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:r,lines:i}=this.opts.code,{ownProperties:a}=this.opts,o=new lc.CodeGen(this.scope,{es5:r,lines:i,ownProperties:a});let s;e.$async&&(s=o.scopeValue("Error",{ref:BGt.default,code:(0,lc._)`require("ajv/dist/runtime/validation_error").default`}));const l=o.scopeName("validate");e.validateName=l;const c={gen:o,allErrors:this.opts.allErrors,data:jm.default.data,parentData:jm.default.parentData,parentDataProperty:jm.default.parentDataProperty,dataNames:[jm.default.data],dataPathArr:[lc.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,lc.stringify)(e.schema)}:{ref:e.schema}),validateName:l,ValidationError:s,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:lc.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,lc._)`""`,opts:this.opts,self:this};let u;try{this._compilations.add(e),(0,VGt.validateFunctionCode)(c),o.optimize(this.opts.code.optimize);const d=o.toString();u=`${o.scopeRefs(jm.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,e));const p=new Function(`${jm.default.self}`,`${jm.default.scope}`,u)(this,this.scope.get());if(this.scope.value(l,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:l,validateCode:d,scopeValues:o._values}),this.opts.unevaluated){const{props:h,items:g}=c;p.evaluated={props:h instanceof lc.Name?void 0:h,items:g instanceof lc.Name?void 0:g,dynamicProps:h instanceof lc.Name,dynamicItems:g instanceof lc.Name},p.source&&(p.source.evaluated=(0,lc.stringify)(p.evaluated))}return e.validate=p,e}catch(d){throw delete e.validate,delete e.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(e)}}vs.compileSchema=mJ;function HGt(e,t,n){var r;n=(0,xc.resolveUrl)(this.opts.uriResolver,t,n);const i=e.refs[n];if(i)return i;let a=GGt.call(this,e,n);if(a===void 0){const o=(r=e.localRefs)===null||r===void 0?void 0:r[n],{schemaId:s}=this.opts;o&&(a=new uj({schema:o,schemaId:s,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=WGt.call(this,a)}vs.resolveRef=HGt;function WGt(e){return(0,xc.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:mJ.call(this,e)}function HLe(e){for(const t of this._compilations)if(UGt(t,e))return t}vs.getCompilingSchema=HLe;function UGt(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function GGt(e,t){let n;for(;typeof(n=this.refs[t])=="string";)t=n;return n||this.schemas[t]||dj.call(this,e,t)}function dj(e,t){const n=this.opts.uriResolver.parse(t),r=(0,xc._getFullPath)(this.opts.uriResolver,n);let i=(0,xc.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===i)return Y6.call(this,n,e);const a=(0,xc.normalizeId)(r),o=this.refs[a]||this.schemas[a];if(typeof o=="string"){const s=dj.call(this,e,o);return typeof(s==null?void 0:s.schema)!="object"?void 0:Y6.call(this,n,s)}if(typeof(o==null?void 0:o.schema)=="object"){if(o.validate||mJ.call(this,o),a===(0,xc.normalizeId)(t)){const{schema:s}=o,{schemaId:l}=this.opts,c=s[l];return c&&(i=(0,xc.resolveUrl)(this.opts.uriResolver,i,c)),new uj({schema:s,schemaId:l,root:e,baseId:i})}return Y6.call(this,n,o)}}vs.resolveSchema=dj;const qGt=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Y6(e,{baseId:t,schema:n,root:r}){var i;if(((i=e.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(const s of e.fragment.slice(1).split("/")){if(typeof n=="boolean")return;const l=n[(0,Vve.unescapeFragment)(s)];if(l===void 0)return;n=l;const c=typeof n=="object"&&n[this.opts.schemaId];!qGt.has(s)&&c&&(t=(0,xc.resolveUrl)(this.opts.uriResolver,t,c))}let a;if(typeof n!="boolean"&&n.$ref&&!(0,Vve.schemaHasRulesButRef)(n,this.RULES)){const s=(0,xc.resolveUrl)(this.opts.uriResolver,t,n.$ref);a=dj.call(this,r,s)}const{schemaId:o}=this.opts;if(a=a||new uj({schema:n,schemaId:o,root:r,baseId:t}),a.schema!==a.root.schema)return a}const KGt="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",YGt="Meta-schema for $data reference (JSON AnySchema extension proposal)",XGt="object",ZGt=["$data"],QGt={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},JGt=!1,eqt={$id:KGt,description:YGt,type:XGt,required:ZGt,properties:QGt,additionalProperties:JGt};var gJ={},fj={exports:{}};const tqt=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),WLe=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),vJ=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),ULe=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),nqt=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function GLe(e){let t="",n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[r]}return t}const rqt=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Hve(e){return e.length=0,!0}function iqt(e,t,n){if(e.length){const r=GLe(e);if(r!=="")t.push(r);else return n.error=!0,!1;e.length=0}return!0}function aqt(e){let t=0;const n={error:!1,address:"",zone:""},r=[],i=[];let a=!1,o=!1,s=iqt;for(let l=0;l<e.length;l++){const c=e[l];if(!(c==="["||c==="]"))if(c===":"){if(a===!0&&(o=!0),!s(i,r,n))break;if(++t>7){n.error=!0;break}l>0&&e[l-1]===":"&&(a=!0),r.push(":");continue}else if(c==="%"){if(!s(i,r,n))break;s=Hve}else{i.push(c);continue}}return i.length&&(s===Hve?n.zone=i.join(""):o?r.push(i.join("")):r.push(GLe(i))),n.address=r.join(""),n}function qLe(e){if(oqt(e,":")<2)return{host:e,isIPV6:!1};const t=aqt(e);if(t.error)return{host:e,isIPV6:!1};{let n=t.address,r=t.address;return t.zone&&(n+="%"+t.zone,r+="%25"+t.zone),{host:n,isIPV6:!0,escapedHost:r}}}function oqt(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function sqt(e){let t=e;const n=[];let r=-1,i=0;for(;i=t.length;){if(i===1){if(t===".")break;if(t==="/"){n.push("/");break}else{n.push(t);break}}else if(i===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){n.push("/");break}}else if(i===3&&t==="/.."){n.length!==0&&n.pop(),n.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf("/",1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join("")}const lqt={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},cqt=/[@/?#:]/g,uqt=/[@/?#]/g;function KLe(e,t){const n=t?uqt:cqt;return n.lastIndex=0,e.replace(n,r=>lqt[r])}function dqt(e,t=!1){if(e.indexOf("%")===-1)return e;let n="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){const i=e.slice(r+1,r+3);if(vJ(i)){const a=i.toUpperCase(),o=String.fromCharCode(parseInt(a,16));t&&ULe(o)?n+=o:n+="%"+a,r+=2;continue}}n+=e[r]}return n}function fqt(e){let t="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){const r=e.slice(n+1,n+3);if(vJ(r)){const i=r.toUpperCase(),a=String.fromCharCode(parseInt(i,16));a!=="."&&ULe(a)?t+=a:t+="%"+i,n+=2;continue}}nqt(e[n])?t+=e[n]:t+=escape(e[n])}return t}function pqt(e){let t="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){const r=e.slice(n+1,n+3);if(vJ(r)){t+="%"+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function hqt(e){const t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let n=unescape(e.host);if(!WLe(n)){const r=qLe(n);r.isIPV6===!0?n=`[${r.escapedHost}]`:n=KLe(n,!1)}t.push(n)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}var YLe={nonSimpleDomain:rqt,recomposeAuthority:hqt,reescapeHostDelimiters:KLe,normalizePercentEncoding:dqt,normalizePathEncoding:fqt,escapePreservingEscapes:pqt,removeDotSegments:sqt,isIPv4:WLe,isUUID:tqt,normalizeIPv6:qLe};const{isUUID:mqt}=YLe,gqt=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function XLe(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function ZLe(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function QLe(e){const t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function vqt(e){return e.secure=XLe(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function yqt(e){if((e.port===(XLe(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,n]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function bqt(e,t){if(!e.path)return e.error="URN can not be parsed",e;const n=e.path.match(gqt);if(n){const r=t.scheme||e.scheme||"urn";e.nid=n[1].toLowerCase(),e.nss=n[2];const i=`${r}:${t.nid||e.nid}`,a=yJ(i);e.path=void 0,a&&(e=a.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function xqt(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");const n=t.scheme||e.scheme||"urn",r=e.nid.toLowerCase(),i=`${n}:${t.nid||r}`,a=yJ(i);a&&(e=a.serialize(e,t));const o=e,s=e.nss;return o.path=`${r||t.nid}:${s}`,t.skipEscape=!0,o}function wqt(e,t){const n=e;return n.uuid=n.nss,n.nss=void 0,!t.tolerant&&(!n.uuid||!mqt(n.uuid))&&(n.error=n.error||"UUID is not valid."),n}function Sqt(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t}const JLe={scheme:"http",domainHost:!0,parse:ZLe,serialize:QLe},_qt={scheme:"https",domainHost:JLe.domainHost,parse:ZLe,serialize:QLe},WN={scheme:"ws",domainHost:!0,parse:vqt,serialize:yqt},Cqt={scheme:"wss",domainHost:WN.domainHost,parse:WN.parse,serialize:WN.serialize},$qt={scheme:"urn",parse:bqt,serialize:xqt,skipNormalize:!0},Eqt={scheme:"urn:uuid",parse:wqt,serialize:Sqt,skipNormalize:!0},JR={http:JLe,https:_qt,ws:WN,wss:Cqt,urn:$qt,"urn:uuid":Eqt};Object.setPrototypeOf(JR,null);function yJ(e){return e&&(JR[e]||JR[e.toLowerCase()])||void 0}var Tqt={SCHEMES:JR,getSchemeHandler:yJ};const{normalizeIPv6:Iqt,removeDotSegments:E_,recomposeAuthority:kqt,normalizePercentEncoding:Pqt,normalizePathEncoding:Nqt,escapePreservingEscapes:Aqt,reescapeHostDelimiters:Mqt,isIPv4:Rqt,nonSimpleDomain:Dqt}=YLe,{SCHEMES:Oqt,getSchemeHandler:eje}=Tqt;function Lqt(e,t){return typeof e=="string"?e=Vqt(e,t):typeof e=="object"&&(e=C1(Zv(e,t),t)),e}function jqt(e,t,n){const r=n?Object.assign({scheme:"null"},n):{scheme:"null"},i=tje(C1(e,r),C1(t,r),r,!0);return r.skipEscape=!0,Zv(i,r)}function tje(e,t,n,r){const i={};return r||(e=C1(Zv(e,n),n),t=C1(Zv(t,n),n)),n=n||{},!n.tolerant&&t.scheme?(i.scheme=t.scheme,i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=E_(t.path||""),i.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=E_(t.path||""),i.query=t.query):(t.path?(t.path[0]==="/"?i.path=E_(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?i.path="/"+t.path:e.path?i.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:i.path=t.path,i.path=E_(i.path)),i.query=t.query):(i.path=e.path,t.query!==void 0?i.query=t.query:i.query=e.query),i.userinfo=e.userinfo,i.host=e.host,i.port=e.port),i.scheme=e.scheme),i.fragment=t.fragment,i}function zqt(e,t,n){const r=Wve(e,n),i=Wve(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function Zv(e,t){const n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},r=Object.assign({},t),i=[],a=eje(r.scheme||n.scheme);a&&a.serialize&&a.serialize(n,r),n.path!==void 0&&(r.skipEscape?n.path=Pqt(n.path):(n.path=Aqt(n.path),n.scheme!==void 0&&(n.path=n.path.split("%3A").join(":")))),r.reference!=="suffix"&&n.scheme&&i.push(n.scheme,":");const o=kqt(n);if(o!==void 0&&(r.reference!=="suffix"&&i.push("//"),i.push(o),n.path&&n.path[0]!=="/"&&i.push("/")),n.path!==void 0){let s=n.path;!r.absolutePath&&(!a||!a.absolutePath)&&(s=E_(s)),o===void 0&&s[0]==="/"&&s[1]==="/"&&(s="/%2F"+s.slice(2)),i.push(s)}return n.query!==void 0&&i.push("?",n.query),n.fragment!==void 0&&i.push("#",n.fragment),i.join("")}const Fqt=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Bqt(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function nje(e,t){const n=Object.assign({},t),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let i=!1,a=!1;n.reference==="suffix"&&(n.scheme?e=n.scheme+":"+e:e="//"+e);const o=e.match(Fqt);if(o){r.scheme=o[1],r.userinfo=o[3],r.host=o[4],r.port=parseInt(o[5],10),r.path=o[6]||"",r.query=o[7],r.fragment=o[8],isNaN(r.port)&&(r.port=o[5]);const s=Bqt(r,o);if(s!==void 0&&(r.error=r.error||s,i=!0),r.host)if(Rqt(r.host)===!1){const u=Iqt(r.host);r.host=u.host.toLowerCase(),a=u.isIPV6}else a=!0;r.scheme===void 0&&r.userinfo===void 0&&r.host===void 0&&r.port===void 0&&r.query===void 0&&!r.path?r.reference="same-document":r.scheme===void 0?r.reference="relative":r.fragment===void 0?r.reference="absolute":r.reference="uri",n.reference&&n.reference!=="suffix"&&n.reference!==r.reference&&(r.error=r.error||"URI is not a "+n.reference+" reference.");const l=eje(n.scheme||r.scheme);if(!n.unicodeSupport&&(!l||!l.unicodeSupport)&&r.host&&(n.domainHost||l&&l.domainHost)&&a===!1&&Dqt(r.host))try{r.host=new URL("http://"+r.host).hostname}catch(c){r.error=r.error||"Host's domain name can not be converted to ASCII: "+c}if((!l||l&&!l.skipNormalize)&&(e.indexOf("%")!==-1&&(r.scheme!==void 0&&(r.scheme=unescape(r.scheme)),r.host!==void 0&&(r.host=Mqt(unescape(r.host),a))),r.path&&(r.path=Nqt(r.path)),r.fragment))try{r.fragment=encodeURI(decodeURIComponent(r.fragment))}catch{r.error=r.error||"URI malformed"}l&&l.parse&&l.parse(r,n)}else r.error=r.error||"URI can not be parsed.";return{parsed:r,malformedAuthorityOrPort:i}}function C1(e,t){return nje(e,t).parsed}function Vqt(e,t){return rje(e,t).normalized}function rje(e,t){const{parsed:n,malformedAuthorityOrPort:r}=nje(e,t);return{normalized:r?e:Zv(n,t),malformedAuthorityOrPort:r}}function Wve(e,t){if(typeof e=="string"){const{normalized:n,malformedAuthorityOrPort:r}=rje(e,t);return r?void 0:n}if(typeof e=="object")return Zv(e,t)}const bJ={SCHEMES:Oqt,normalize:Lqt,resolve:jqt,resolveComponent:tje,equal:zqt,serialize:Zv,parse:C1};fj.exports=bJ;fj.exports.default=bJ;fj.exports.fastUri=bJ;var Hqt=fj.exports;Object.defineProperty(gJ,"__esModule",{value:!0});const ije=Hqt;ije.code='require("ajv/dist/runtime/uri").default';gJ.default=ije;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Mc;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var n=Wn;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return n.CodeGen}});const r=bT,i=Pw,a=Xv,o=vs,s=Wn,l=Va,c=la,u=zt,d=eqt,f=gJ,p=(O,V)=>new RegExp(O,V);p.code="new RegExp";const h=["removeAdditional","useDefaults","coerceTypes"],g=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),v={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},y={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},x=200;function w(O){var V,B,D,F,H,W,K,U,q,Q,G,X,J,Y,Z,re,ee,te,oe,fe,he,ye,Te,Ee,we;const le=O.strict,se=(V=O.code)===null||V===void 0?void 0:V.optimize,ne=se===!0||se===void 0?1:se||0,ge=(D=(B=O.code)===null||B===void 0?void 0:B.regExp)!==null&&D!==void 0?D:p,be=(F=O.uriResolver)!==null&&F!==void 0?F:f.default;return{strictSchema:(W=(H=O.strictSchema)!==null&&H!==void 0?H:le)!==null&&W!==void 0?W:!0,strictNumbers:(U=(K=O.strictNumbers)!==null&&K!==void 0?K:le)!==null&&U!==void 0?U:!0,strictTypes:(Q=(q=O.strictTypes)!==null&&q!==void 0?q:le)!==null&&Q!==void 0?Q:"log",strictTuples:(X=(G=O.strictTuples)!==null&&G!==void 0?G:le)!==null&&X!==void 0?X:"log",strictRequired:(Y=(J=O.strictRequired)!==null&&J!==void 0?J:le)!==null&&Y!==void 0?Y:!1,code:O.code?{...O.code,optimize:ne,regExp:ge}:{optimize:ne,regExp:ge},loopRequired:(Z=O.loopRequired)!==null&&Z!==void 0?Z:x,loopEnum:(re=O.loopEnum)!==null&&re!==void 0?re:x,meta:(ee=O.meta)!==null&&ee!==void 0?ee:!0,messages:(te=O.messages)!==null&&te!==void 0?te:!0,inlineRefs:(oe=O.inlineRefs)!==null&&oe!==void 0?oe:!0,schemaId:(fe=O.schemaId)!==null&&fe!==void 0?fe:"$id",addUsedSchema:(he=O.addUsedSchema)!==null&&he!==void 0?he:!0,validateSchema:(ye=O.validateSchema)!==null&&ye!==void 0?ye:!0,validateFormats:(Te=O.validateFormats)!==null&&Te!==void 0?Te:!0,unicodeRegExp:(Ee=O.unicodeRegExp)!==null&&Ee!==void 0?Ee:!0,int32range:(we=O.int32range)!==null&&we!==void 0?we:!0,uriResolver:be}}class S{constructor(V={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,V=this.opts={...V,...w(V)};const{es5:B,lines:D}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:g,es5:B,lines:D}),this.logger=P(V.logger);const F=V.validateFormats;V.validateFormats=!1,this.RULES=(0,a.getRules)(),_.call(this,v,V,"NOT SUPPORTED"),_.call(this,y,V,"DEPRECATED","warn"),this._metaOpts=T.call(this),V.formats&&E.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),V.keywords&&k.call(this,V.keywords),typeof V.meta=="object"&&this.addMetaSchema(V.meta),$.call(this),V.validateFormats=F}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:V,meta:B,schemaId:D}=this.opts;let F=d;D==="id"&&(F={...d},F.id=F.$id,delete F.$id),B&&V&&this.addMetaSchema(F,F[D],!1)}defaultMeta(){const{meta:V,schemaId:B}=this.opts;return this.opts.defaultMeta=typeof V=="object"?V[B]||V:void 0}validate(V,B){let D;if(typeof V=="string"){if(D=this.getSchema(V),!D)throw new Error(`no schema with key or ref "${V}"`)}else D=this.compile(V);const F=D(B);return"$async"in D||(this.errors=D.errors),F}compile(V,B){const D=this._addSchema(V,B);return D.validate||this._compileSchemaEnv(D)}compileAsync(V,B){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:D}=this.opts;return F.call(this,V,B);async function F(Q,G){await H.call(this,Q.$schema);const X=this._addSchema(Q,G);return X.validate||W.call(this,X)}async function H(Q){Q&&!this.getSchema(Q)&&await F.call(this,{$ref:Q},!0)}async function W(Q){try{return this._compileSchemaEnv(Q)}catch(G){if(!(G instanceof i.default))throw G;return K.call(this,G),await U.call(this,G.missingSchema),W.call(this,Q)}}function K({missingSchema:Q,missingRef:G}){if(this.refs[Q])throw new Error(`AnySchema ${Q} is loaded but ${G} cannot be resolved`)}async function U(Q){const G=await q.call(this,Q);this.refs[Q]||await H.call(this,G.$schema),this.refs[Q]||this.addSchema(G,Q,B)}async function q(Q){const G=this._loading[Q];if(G)return G;try{return await(this._loading[Q]=D(Q))}finally{delete this._loading[Q]}}}addSchema(V,B,D,F=this.opts.validateSchema){if(Array.isArray(V)){for(const W of V)this.addSchema(W,void 0,D,F);return this}let H;if(typeof V=="object"){const{schemaId:W}=this.opts;if(H=V[W],H!==void 0&&typeof H!="string")throw new Error(`schema ${W} must be string`)}return B=(0,l.normalizeId)(B||H),this._checkUnique(B),this.schemas[B]=this._addSchema(V,D,B,F,!0),this}addMetaSchema(V,B,D=this.opts.validateSchema){return this.addSchema(V,B,!0,D),this}validateSchema(V,B){if(typeof V=="boolean")return!0;let D;if(D=V.$schema,D!==void 0&&typeof D!="string")throw new Error("$schema must be a string");if(D=D||this.opts.defaultMeta||this.defaultMeta(),!D)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const F=this.validate(D,V);if(!F&&B){const H="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(H);else throw new Error(H)}return F}getSchema(V){let B;for(;typeof(B=C.call(this,V))=="string";)V=B;if(B===void 0){const{schemaId:D}=this.opts,F=new o.SchemaEnv({schema:{},schemaId:D});if(B=o.resolveSchema.call(this,F,V),!B)return;this.refs[V]=B}return B.validate||this._compileSchemaEnv(B)}removeSchema(V){if(V instanceof RegExp)return this._removeAllSchemas(this.schemas,V),this._removeAllSchemas(this.refs,V),this;switch(typeof V){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const B=C.call(this,V);return typeof B=="object"&&this._cache.delete(B.schema),delete this.schemas[V],delete this.refs[V],this}case"object":{const B=V;this._cache.delete(B);let D=V[this.opts.schemaId];return D&&(D=(0,l.normalizeId)(D),delete this.schemas[D],delete this.refs[D]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(V){for(const B of V)this.addKeyword(B);return this}addKeyword(V,B){let D;if(typeof V=="string")D=V,typeof B=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),B.keyword=D);else if(typeof V=="object"&&B===void 0){if(B=V,D=B.keyword,Array.isArray(D)&&!D.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(A.call(this,D,B),!B)return(0,u.eachItem)(D,H=>M.call(this,H)),this;L.call(this,B);const F={...B,type:(0,c.getJSONTypes)(B.type),schemaType:(0,c.getJSONTypes)(B.schemaType)};return(0,u.eachItem)(D,F.type.length===0?H=>M.call(this,H,F):H=>F.type.forEach(W=>M.call(this,H,F,W))),this}getKeyword(V){const B=this.RULES.all[V];return typeof B=="object"?B.definition:!!B}removeKeyword(V){const{RULES:B}=this;delete B.keywords[V],delete B.all[V];for(const D of B.rules){const F=D.rules.findIndex(H=>H.keyword===V);F>=0&&D.rules.splice(F,1)}return this}addFormat(V,B){return typeof B=="string"&&(B=new RegExp(B)),this.formats[V]=B,this}errorsText(V=this.errors,{separator:B=", ",dataVar:D="data"}={}){return!V||V.length===0?"No errors":V.map(F=>`${D}${F.instancePath} ${F.message}`).reduce((F,H)=>F+B+H)}$dataMetaSchema(V,B){const D=this.RULES.all;V=JSON.parse(JSON.stringify(V));for(const F of B){const H=F.split("/").slice(1);let W=V;for(const K of H)W=W[K];for(const K in D){const U=D[K];if(typeof U!="object")continue;const{$data:q}=U.definition,Q=W[K];q&&Q&&(W[K]=j(Q))}}return V}_removeAllSchemas(V,B){for(const D in V){const F=V[D];(!B||B.test(D))&&(typeof F=="string"?delete V[D]:F&&!F.meta&&(this._cache.delete(F.schema),delete V[D]))}}_addSchema(V,B,D,F=this.opts.validateSchema,H=this.opts.addUsedSchema){let W;const{schemaId:K}=this.opts;if(typeof V=="object")W=V[K];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof V!="boolean")throw new Error("schema must be object or boolean")}let U=this._cache.get(V);if(U!==void 0)return U;D=(0,l.normalizeId)(W||D);const q=l.getSchemaRefs.call(this,V,D);return U=new o.SchemaEnv({schema:V,schemaId:K,meta:B,baseId:D,localRefs:q}),this._cache.set(U.schema,U),H&&!D.startsWith("#")&&(D&&this._checkUnique(D),this.refs[D]=U),F&&this.validateSchema(V,!0),U}_checkUnique(V){if(this.schemas[V]||this.refs[V])throw new Error(`schema with key or id "${V}" already exists`)}_compileSchemaEnv(V){if(V.meta?this._compileMetaSchema(V):o.compileSchema.call(this,V),!V.validate)throw new Error("ajv implementation error");return V.validate}_compileMetaSchema(V){const B=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,V)}finally{this.opts=B}}}S.ValidationError=r.default,S.MissingRefError=i.default,e.default=S;function _(O,V,B,D="error"){for(const F in O){const H=F;H in V&&this.logger[D](`${B}: option ${F}. ${O[H]}`)}}function C(O){return O=(0,l.normalizeId)(O),this.schemas[O]||this.refs[O]}function $(){const O=this.opts.schemas;if(O)if(Array.isArray(O))this.addSchema(O);else for(const V in O)this.addSchema(O[V],V)}function E(){for(const O in this.opts.formats){const V=this.opts.formats[O];V&&this.addFormat(O,V)}}function k(O){if(Array.isArray(O)){this.addVocabulary(O);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const V in O){const B=O[V];B.keyword||(B.keyword=V),this.addKeyword(B)}}function T(){const O={...this.opts};for(const V of h)delete O[V];return O}const I={log(){},warn(){},error(){}};function P(O){if(O===!1)return I;if(O===void 0)return console;if(O.log&&O.warn&&O.error)return O;throw new Error("logger must implement log, warn and error methods")}const N=/^[a-z_$][a-z0-9_$:-]*$/i;function A(O,V){const{RULES:B}=this;if((0,u.eachItem)(O,D=>{if(B.keywords[D])throw new Error(`Keyword ${D} is already defined`);if(!N.test(D))throw new Error(`Keyword ${D} has invalid name`)}),!!V&&V.$data&&!("code"in V||"validate"in V))throw new Error('$data keyword must have "code" or "validate" function')}function M(O,V,B){var D;const F=V==null?void 0:V.post;if(B&&F)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:H}=this;let W=F?H.post:H.rules.find(({type:U})=>U===B);if(W||(W={type:B,rules:[]},H.rules.push(W)),H.keywords[O]=!0,!V)return;const K={keyword:O,definition:{...V,type:(0,c.getJSONTypes)(V.type),schemaType:(0,c.getJSONTypes)(V.schemaType)}};V.before?R.call(this,W,K,V.before):W.rules.push(K),H.all[O]=K,(D=V.implements)===null||D===void 0||D.forEach(U=>this.addKeyword(U))}function R(O,V,B){const D=O.rules.findIndex(F=>F.keyword===B);D>=0?O.rules.splice(D,0,V):(O.rules.push(V),this.logger.warn(`rule ${B} is not defined`))}function L(O){let{metaSchema:V}=O;V!==void 0&&(O.$data&&this.opts.$data&&(V=j(V)),O.validateSchema=this.compile(V,!0))}const z={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function j(O){return{anyOf:[O,z]}}})(dLe);var xJ={},wJ={},SJ={};Object.defineProperty(SJ,"__esModule",{value:!0});const Wqt={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};SJ.default=Wqt;var Qv={};Object.defineProperty(Qv,"__esModule",{value:!0});Qv.callRef=Qv.getValidate=void 0;const Uqt=Pw,Uve=Xn,ss=Wn,F0=cd,Gve=vs,bP=zt,Gqt={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:n,it:r}=e,{baseId:i,schemaEnv:a,validateName:o,opts:s,self:l}=r,{root:c}=a;if((n==="#"||n==="#/")&&i===c.baseId)return d();const u=Gve.resolveRef.call(l,c,i,n);if(u===void 0)throw new Uqt.default(r.opts.uriResolver,i,n);if(u instanceof Gve.SchemaEnv)return f(u);return p(u);function d(){if(a===c)return UN(e,o,a,a.$async);const h=t.scopeValue("root",{ref:c});return UN(e,(0,ss._)`${h}.validate`,c,c.$async)}function f(h){const g=aje(e,h);UN(e,g,h,h.$async)}function p(h){const g=t.scopeValue("schema",s.code.source===!0?{ref:h,code:(0,ss.stringify)(h)}:{ref:h}),v=t.name("valid"),y=e.subschema({schema:h,dataTypes:[],schemaPath:ss.nil,topSchemaRef:g,errSchemaPath:n},v);e.mergeEvaluated(y),e.ok(v)}}};function aje(e,t){const{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):(0,ss._)`${n.scopeValue("wrapper",{ref:t})}.validate`}Qv.getValidate=aje;function UN(e,t,n,r){const{gen:i,it:a}=e,{allErrors:o,schemaEnv:s,opts:l}=a,c=l.passContext?F0.default.this:ss.nil;r?u():d();function u(){if(!s.$async)throw new Error("async schema referenced by sync schema");const h=i.let("valid");i.try(()=>{i.code((0,ss._)`await ${(0,Uve.callValidateCode)(e,t,c)}`),p(t),o||i.assign(h,!0)},g=>{i.if((0,ss._)`!(${g} instanceof ${a.ValidationError})`,()=>i.throw(g)),f(g),o||i.assign(h,!1)}),e.ok(h)}function d(){e.result((0,Uve.callValidateCode)(e,t,c),()=>p(t),()=>f(t))}function f(h){const g=(0,ss._)`${h}.errors`;i.assign(F0.default.vErrors,(0,ss._)`${F0.default.vErrors} === null ? ${g} : ${F0.default.vErrors}.concat(${g})`),i.assign(F0.default.errors,(0,ss._)`${F0.default.vErrors}.length`)}function p(h){var g;if(!a.opts.unevaluated)return;const v=(g=n==null?void 0:n.validate)===null||g===void 0?void 0:g.evaluated;if(a.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(a.props=bP.mergeEvaluated.props(i,v.props,a.props));else{const y=i.var("props",(0,ss._)`${h}.evaluated.props`);a.props=bP.mergeEvaluated.props(i,y,a.props,ss.Name)}if(a.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(a.items=bP.mergeEvaluated.items(i,v.items,a.items));else{const y=i.var("items",(0,ss._)`${h}.evaluated.items`);a.items=bP.mergeEvaluated.items(i,y,a.items,ss.Name)}}}Qv.callRef=UN;Qv.default=Gqt;Object.defineProperty(wJ,"__esModule",{value:!0});const qqt=SJ,Kqt=Qv,Yqt=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",qqt.default,Kqt.default];wJ.default=Yqt;var _J={},CJ={};Object.defineProperty(CJ,"__esModule",{value:!0});const eD=Wn,ap=eD.operators,tD={maximum:{okStr:"<=",ok:ap.LTE,fail:ap.GT},minimum:{okStr:">=",ok:ap.GTE,fail:ap.LT},exclusiveMaximum:{okStr:"<",ok:ap.LT,fail:ap.GTE},exclusiveMinimum:{okStr:">",ok:ap.GT,fail:ap.LTE}},Xqt={message:({keyword:e,schemaCode:t})=>(0,eD.str)`must be ${tD[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,eD._)`{comparison: ${tD[e].okStr}, limit: ${t}}`},Zqt={keyword:Object.keys(tD),type:"number",schemaType:"number",$data:!0,error:Xqt,code(e){const{keyword:t,data:n,schemaCode:r}=e;e.fail$data((0,eD._)`${n} ${tD[t].fail} ${r} || isNaN(${n})`)}};CJ.default=Zqt;var $J={};Object.defineProperty($J,"__esModule",{value:!0});const NC=Wn,Qqt={message:({schemaCode:e})=>(0,NC.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,NC._)`{multipleOf: ${e}}`},Jqt={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Qqt,code(e){const{gen:t,data:n,schemaCode:r,it:i}=e,a=i.opts.multipleOfPrecision,o=t.let("res"),s=a?(0,NC._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${a}`:(0,NC._)`${o} !== parseInt(${o})`;e.fail$data((0,NC._)`(${r} === 0 || (${o} = ${n}/${r}, ${s}))`)}};$J.default=Jqt;var EJ={},TJ={};Object.defineProperty(TJ,"__esModule",{value:!0});function oje(e){const t=e.length;let n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)===56320&&r++);return n}TJ.default=oje;oje.code='require("ajv/dist/runtime/ucs2length").default';Object.defineProperty(EJ,"__esModule",{value:!0});const lg=Wn,eKt=zt,tKt=TJ,nKt={message({keyword:e,schemaCode:t}){const n=e==="maxLength"?"more":"fewer";return(0,lg.str)`must NOT have ${n} than ${t} characters`},params:({schemaCode:e})=>(0,lg._)`{limit: ${e}}`},rKt={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:nKt,code(e){const{keyword:t,data:n,schemaCode:r,it:i}=e,a=t==="maxLength"?lg.operators.GT:lg.operators.LT,o=i.opts.unicode===!1?(0,lg._)`${n}.length`:(0,lg._)`${(0,eKt.useFunc)(e.gen,tKt.default)}(${n})`;e.fail$data((0,lg._)`${o} ${a} ${r}`)}};EJ.default=rKt;var IJ={};Object.defineProperty(IJ,"__esModule",{value:!0});const iKt=Xn,aKt=zt,Pb=Wn,oKt={message:({schemaCode:e})=>(0,Pb.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Pb._)`{pattern: ${e}}`},sKt={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:oKt,code(e){const{gen:t,data:n,$data:r,schema:i,schemaCode:a,it:o}=e,s=o.opts.unicodeRegExp?"u":"";if(r){const{regExp:l}=o.opts.code,c=l.code==="new RegExp"?(0,Pb._)`new RegExp`:(0,aKt.useFunc)(t,l),u=t.let("valid");t.try(()=>t.assign(u,(0,Pb._)`${c}(${a}, ${s}).test(${n})`),()=>t.assign(u,!1)),e.fail$data((0,Pb._)`!${u}`)}else{const l=(0,iKt.usePattern)(e,i);e.fail$data((0,Pb._)`!${l}.test(${n})`)}}};IJ.default=sKt;var kJ={};Object.defineProperty(kJ,"__esModule",{value:!0});const AC=Wn,lKt={message({keyword:e,schemaCode:t}){const n=e==="maxProperties"?"more":"fewer";return(0,AC.str)`must NOT have ${n} than ${t} properties`},params:({schemaCode:e})=>(0,AC._)`{limit: ${e}}`},cKt={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:lKt,code(e){const{keyword:t,data:n,schemaCode:r}=e,i=t==="maxProperties"?AC.operators.GT:AC.operators.LT;e.fail$data((0,AC._)`Object.keys(${n}).length ${i} ${r}`)}};kJ.default=cKt;var PJ={};Object.defineProperty(PJ,"__esModule",{value:!0});const WS=Xn,MC=Wn,uKt=zt,dKt={message:({params:{missingProperty:e}})=>(0,MC.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,MC._)`{missingProperty: ${e}}`},fKt={keyword:"required",type:"object",schemaType:"array",$data:!0,error:dKt,code(e){const{gen:t,schema:n,schemaCode:r,data:i,$data:a,it:o}=e,{opts:s}=o;if(!a&&n.length===0)return;const l=n.length>=s.loopRequired;if(o.allErrors?c():u(),s.strictRequired){const p=e.parentSchema.properties,{definedProperties:h}=e.it;for(const g of n)if((p==null?void 0:p[g])===void 0&&!h.has(g)){const v=o.schemaEnv.baseId+o.errSchemaPath,y=`required property "${g}" is not defined at "${v}" (strictRequired)`;(0,uKt.checkStrictMode)(o,y,o.opts.strictRequired)}}function c(){if(l||a)e.block$data(MC.nil,d);else for(const p of n)(0,WS.checkReportMissingProp)(e,p)}function u(){const p=t.let("missing");if(l||a){const h=t.let("valid",!0);e.block$data(h,()=>f(p,h)),e.ok(h)}else t.if((0,WS.checkMissingProp)(e,n,p)),(0,WS.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",r,p=>{e.setParams({missingProperty:p}),t.if((0,WS.noPropertyInData)(t,i,p,s.ownProperties),()=>e.error())})}function f(p,h){e.setParams({missingProperty:p}),t.forOf(p,r,()=>{t.assign(h,(0,WS.propertyInData)(t,i,p,s.ownProperties)),t.if((0,MC.not)(h),()=>{e.error(),t.break()})},MC.nil)}}};PJ.default=fKt;var NJ={};Object.defineProperty(NJ,"__esModule",{value:!0});const RC=Wn,pKt={message({keyword:e,schemaCode:t}){const n=e==="maxItems"?"more":"fewer";return(0,RC.str)`must NOT have ${n} than ${t} items`},params:({schemaCode:e})=>(0,RC._)`{limit: ${e}}`},hKt={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:pKt,code(e){const{keyword:t,data:n,schemaCode:r}=e,i=t==="maxItems"?RC.operators.GT:RC.operators.LT;e.fail$data((0,RC._)`${n}.length ${i} ${r}`)}};NJ.default=hKt;var AJ={},xT={};Object.defineProperty(xT,"__esModule",{value:!0});const sje=TLe;sje.code='require("ajv/dist/runtime/equal").default';xT.default=sje;Object.defineProperty(AJ,"__esModule",{value:!0});const X6=la,La=Wn,mKt=zt,gKt=xT,vKt={message:({params:{i:e,j:t}})=>(0,La.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,La._)`{i: ${e}, j: ${t}}`},yKt={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:vKt,code(e){const{gen:t,data:n,$data:r,schema:i,parentSchema:a,schemaCode:o,it:s}=e;if(!r&&!i)return;const l=t.let("valid"),c=a.items?(0,X6.getSchemaTypes)(a.items):[];e.block$data(l,u,(0,La._)`${o} === false`),e.ok(l);function u(){const h=t.let("i",(0,La._)`${n}.length`),g=t.let("j");e.setParams({i:h,j:g}),t.assign(l,!0),t.if((0,La._)`${h} > 1`,()=>(d()?f:p)(h,g))}function d(){return c.length>0&&!c.some(h=>h==="object"||h==="array")}function f(h,g){const v=t.name("item"),y=(0,X6.checkDataTypes)(c,v,s.opts.strictNumbers,X6.DataType.Wrong),x=t.const("indices",(0,La._)`{}`);t.for((0,La._)`;${h}--;`,()=>{t.let(v,(0,La._)`${n}[${h}]`),t.if(y,(0,La._)`continue`),c.length>1&&t.if((0,La._)`typeof ${v} == "string"`,(0,La._)`${v} += "_"`),t.if((0,La._)`typeof ${x}[${v}] == "number"`,()=>{t.assign(g,(0,La._)`${x}[${v}]`),e.error(),t.assign(l,!1).break()}).code((0,La._)`${x}[${v}] = ${h}`)})}function p(h,g){const v=(0,mKt.useFunc)(t,gKt.default),y=t.name("outer");t.label(y).for((0,La._)`;${h}--;`,()=>t.for((0,La._)`${g} = ${h}; ${g}--;`,()=>t.if((0,La._)`${v}(${n}[${h}], ${n}[${g}])`,()=>{e.error(),t.assign(l,!1).break(y)})))}}};AJ.default=yKt;var MJ={};Object.defineProperty(MJ,"__esModule",{value:!0});const FU=Wn,bKt=zt,xKt=xT,wKt={message:"must be equal to constant",params:({schemaCode:e})=>(0,FU._)`{allowedValue: ${e}}`},SKt={keyword:"const",$data:!0,error:wKt,code(e){const{gen:t,data:n,$data:r,schemaCode:i,schema:a}=e;r||a&&typeof a=="object"?e.fail$data((0,FU._)`!${(0,bKt.useFunc)(t,xKt.default)}(${n}, ${i})`):e.fail((0,FU._)`${a} !== ${n}`)}};MJ.default=SKt;var RJ={};Object.defineProperty(RJ,"__esModule",{value:!0});const T_=Wn,_Kt=zt,CKt=xT,$Kt={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,T_._)`{allowedValues: ${e}}`},EKt={keyword:"enum",schemaType:"array",$data:!0,error:$Kt,code(e){const{gen:t,data:n,$data:r,schema:i,schemaCode:a,it:o}=e;if(!r&&i.length===0)throw new Error("enum must have non-empty array");const s=i.length>=o.opts.loopEnum;let l;const c=()=>l??(l=(0,_Kt.useFunc)(t,CKt.default));let u;if(s||r)u=t.let("valid"),e.block$data(u,d);else{if(!Array.isArray(i))throw new Error("ajv implementation error");const p=t.const("vSchema",a);u=(0,T_.or)(...i.map((h,g)=>f(p,g)))}e.pass(u);function d(){t.assign(u,!1),t.forOf("v",a,p=>t.if((0,T_._)`${c()}(${n}, ${p})`,()=>t.assign(u,!0).break()))}function f(p,h){const g=i[h];return typeof g=="object"&&g!==null?(0,T_._)`${c()}(${n}, ${p}[${h}])`:(0,T_._)`${n} === ${g}`}}};RJ.default=EKt;Object.defineProperty(_J,"__esModule",{value:!0});const TKt=CJ,IKt=$J,kKt=EJ,PKt=IJ,NKt=kJ,AKt=PJ,MKt=NJ,RKt=AJ,DKt=MJ,OKt=RJ,LKt=[TKt.default,IKt.default,kKt.default,PKt.default,NKt.default,AKt.default,MKt.default,RKt.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},DKt.default,OKt.default];_J.default=LKt;var DJ={},Nw={};Object.defineProperty(Nw,"__esModule",{value:!0});Nw.validateAdditionalItems=void 0;const cg=Wn,BU=zt,jKt={message:({params:{len:e}})=>(0,cg.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,cg._)`{limit: ${e}}`},zKt={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:jKt,code(e){const{parentSchema:t,it:n}=e,{items:r}=t;if(!Array.isArray(r)){(0,BU.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas');return}lje(e,r)}};function lje(e,t){const{gen:n,schema:r,data:i,keyword:a,it:o}=e;o.items=!0;const s=n.const("len",(0,cg._)`${i}.length`);if(r===!1)e.setParams({len:t.length}),e.pass((0,cg._)`${s} <= ${t.length}`);else if(typeof r=="object"&&!(0,BU.alwaysValidSchema)(o,r)){const c=n.var("valid",(0,cg._)`${s} <= ${t.length}`);n.if((0,cg.not)(c),()=>l(c)),e.ok(c)}function l(c){n.forRange("i",t.length,s,u=>{e.subschema({keyword:a,dataProp:u,dataPropType:BU.Type.Num},c),o.allErrors||n.if((0,cg.not)(c),()=>n.break())})}}Nw.validateAdditionalItems=lje;Nw.default=zKt;var OJ={},Aw={};Object.defineProperty(Aw,"__esModule",{value:!0});Aw.validateTuple=void 0;const qve=Wn,GN=zt,FKt=Xn,BKt={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:n}=e;if(Array.isArray(t))return cje(e,"additionalItems",t);n.items=!0,!(0,GN.alwaysValidSchema)(n,t)&&e.ok((0,FKt.validateArray)(e))}};function cje(e,t,n=e.schema){const{gen:r,parentSchema:i,data:a,keyword:o,it:s}=e;u(i),s.opts.unevaluated&&n.length&&s.items!==!0&&(s.items=GN.mergeEvaluated.items(r,n.length,s.items));const l=r.name("valid"),c=r.const("len",(0,qve._)`${a}.length`);n.forEach((d,f)=>{(0,GN.alwaysValidSchema)(s,d)||(r.if((0,qve._)`${c} > ${f}`,()=>e.subschema({keyword:o,schemaProp:f,dataProp:f},l)),e.ok(l))});function u(d){const{opts:f,errSchemaPath:p}=s,h=n.length,g=h===d.minItems&&(h===d.maxItems||d[t]===!1);if(f.strictTuples&&!g){const v=`"${o}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,GN.checkStrictMode)(s,v,f.strictTuples)}}}Aw.validateTuple=cje;Aw.default=BKt;Object.defineProperty(OJ,"__esModule",{value:!0});const VKt=Aw,HKt={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,VKt.validateTuple)(e,"items")};OJ.default=HKt;var LJ={};Object.defineProperty(LJ,"__esModule",{value:!0});const Kve=Wn,WKt=zt,UKt=Xn,GKt=Nw,qKt={message:({params:{len:e}})=>(0,Kve.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Kve._)`{limit: ${e}}`},KKt={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:qKt,code(e){const{schema:t,parentSchema:n,it:r}=e,{prefixItems:i}=n;r.items=!0,!(0,WKt.alwaysValidSchema)(r,t)&&(i?(0,GKt.validateAdditionalItems)(e,i):e.ok((0,UKt.validateArray)(e)))}};LJ.default=KKt;var jJ={};Object.defineProperty(jJ,"__esModule",{value:!0});const wl=Wn,xP=zt,YKt={message:({params:{min:e,max:t}})=>t===void 0?(0,wl.str)`must contain at least ${e} valid item(s)`:(0,wl.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,wl._)`{minContains: ${e}}`:(0,wl._)`{minContains: ${e}, maxContains: ${t}}`},XKt={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:YKt,code(e){const{gen:t,schema:n,parentSchema:r,data:i,it:a}=e;let o,s;const{minContains:l,maxContains:c}=r;a.opts.next?(o=l===void 0?1:l,s=c):o=1;const u=t.const("len",(0,wl._)`${i}.length`);if(e.setParams({min:o,max:s}),s===void 0&&o===0){(0,xP.checkStrictMode)(a,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(s!==void 0&&o>s){(0,xP.checkStrictMode)(a,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,xP.alwaysValidSchema)(a,n)){let g=(0,wl._)`${u} >= ${o}`;s!==void 0&&(g=(0,wl._)`${g} && ${u} <= ${s}`),e.pass(g);return}a.items=!0;const d=t.name("valid");s===void 0&&o===1?p(d,()=>t.if(d,()=>t.break())):o===0?(t.let(d,!0),s!==void 0&&t.if((0,wl._)`${i}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){const g=t.name("_valid"),v=t.let("count",0);p(g,()=>t.if(g,()=>h(v)))}function p(g,v){t.forRange("i",0,u,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:xP.Type.Num,compositeRule:!0},g),v()})}function h(g){t.code((0,wl._)`${g}++`),s===void 0?t.if((0,wl._)`${g} >= ${o}`,()=>t.assign(d,!0).break()):(t.if((0,wl._)`${g} > ${s}`,()=>t.assign(d,!1).break()),o===1?t.assign(d,!0):t.if((0,wl._)`${g} >= ${o}`,()=>t.assign(d,!0)))}}};jJ.default=XKt;var uje={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=Wn,n=zt,r=Xn;e.error={message:({params:{property:l,depsCount:c,deps:u}})=>{const d=c===1?"property":"properties";return(0,t.str)`must have ${d} ${u} when property ${l} is present`},params:({params:{property:l,depsCount:c,deps:u,missingProperty:d}})=>(0,t._)`{property: ${l},
|
|
785
|
+
|| ${o} === "boolean" || ${i} === null`).assign(s,(0,jn._)`[${i}]`)}}}function PUt({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,jn._)`${t} !== undefined`,()=>e.assign((0,jn._)`${t}[${n}]`,r))}function jU(e,t,n,r=lx.Correct){const i=r===lx.Correct?jn.operators.EQ:jn.operators.NEQ;let a;switch(e){case"null":return(0,jn._)`${t} ${i} null`;case"array":a=(0,jn._)`Array.isArray(${t})`;break;case"object":a=(0,jn._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":a=o((0,jn._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":a=o();break;default:return(0,jn._)`typeof ${t} ${i} ${e}`}return r===lx.Correct?a:(0,jn.not)(a);function o(s=jn.nil){return(0,jn.and)((0,jn._)`typeof ${t} == "number"`,s,n?(0,jn._)`isFinite(${t})`:jn.nil)}}la.checkDataType=jU;function lJ(e,t,n,r){if(e.length===1)return jU(e[0],t,n,r);let i;const a=(0,xLe.toHash)(e);if(a.array&&a.object){const o=(0,jn._)`typeof ${t} != "object"`;i=a.null?o:(0,jn._)`!${t} || ${o}`,delete a.null,delete a.array,delete a.object}else i=jn.nil;a.number&&delete a.integer;for(const o in a)i=(0,jn.and)(i,jU(o,t,n,r));return i}la.checkDataTypes=lJ;const NUt={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,jn._)`{type: ${e}}`:(0,jn._)`{type: ${t}}`};function cJ(e){const t=AUt(e);(0,$Ut.reportError)(t,NUt)}la.reportTypeError=cJ;function AUt(e){const{gen:t,data:n,schema:r}=e,i=(0,xLe.schemaRefOrVal)(e,r,"type");return{gen:t,keyword:"type",data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}var cj={};Object.defineProperty(cj,"__esModule",{value:!0});cj.assignDefaults=void 0;const z0=Wn,MUt=zt;function RUt(e,t){const{properties:n,items:r}=e.schema;if(t==="object"&&n)for(const i in n)Ove(e,i,n[i].default);else t==="array"&&Array.isArray(r)&&r.forEach((i,a)=>Ove(e,a,i.default))}cj.assignDefaults=RUt;function Ove(e,t,n){const{gen:r,compositeRule:i,data:a,opts:o}=e;if(n===void 0)return;const s=(0,z0._)`${a}${(0,z0.getProperty)(t)}`;if(i){(0,MUt.checkStrictMode)(e,`default is ignored for: ${s}`);return}let l=(0,z0._)`${s} === undefined`;o.useDefaults==="empty"&&(l=(0,z0._)`${l} || ${s} === null || ${s} === ""`),r.if(l,(0,z0._)`${s} = ${(0,z0.stringify)(n)}`)}var Iu={},Xn={};Object.defineProperty(Xn,"__esModule",{value:!0});Xn.validateUnion=Xn.validateArray=Xn.usePattern=Xn.callValidateCode=Xn.schemaProperties=Xn.allSchemaProperties=Xn.noPropertyInData=Xn.propertyInData=Xn.isOwnProperty=Xn.hasPropFunc=Xn.reportMissingProp=Xn.checkMissingProp=Xn.checkReportMissingProp=void 0;const Xr=Wn,uJ=zt,ip=cd,DUt=zt;function OUt(e,t){const{gen:n,data:r,it:i}=e;n.if(fJ(n,r,t,i.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Xr._)`${t}`},!0),e.error()})}Xn.checkReportMissingProp=OUt;function LUt({gen:e,data:t,it:{opts:n}},r,i){return(0,Xr.or)(...r.map(a=>(0,Xr.and)(fJ(e,t,a,n.ownProperties),(0,Xr._)`${i} = ${a}`)))}Xn.checkMissingProp=LUt;function jUt(e,t){e.setParams({missingProperty:t},!0),e.error()}Xn.reportMissingProp=jUt;function _Le(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Xr._)`Object.prototype.hasOwnProperty`})}Xn.hasPropFunc=_Le;function dJ(e,t,n){return(0,Xr._)`${_Le(e)}.call(${t}, ${n})`}Xn.isOwnProperty=dJ;function zUt(e,t,n,r){const i=(0,Xr._)`${t}${(0,Xr.getProperty)(n)} !== undefined`;return r?(0,Xr._)`${i} && ${dJ(e,t,n)}`:i}Xn.propertyInData=zUt;function fJ(e,t,n,r){const i=(0,Xr._)`${t}${(0,Xr.getProperty)(n)} === undefined`;return r?(0,Xr.or)(i,(0,Xr.not)(dJ(e,t,n))):i}Xn.noPropertyInData=fJ;function CLe(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Xn.allSchemaProperties=CLe;function FUt(e,t){return CLe(t).filter(n=>!(0,uJ.alwaysValidSchema)(e,t[n]))}Xn.schemaProperties=FUt;function BUt({schemaCode:e,data:t,it:{gen:n,topSchemaRef:r,schemaPath:i,errorPath:a},it:o},s,l,c){const u=c?(0,Xr._)`${e}, ${t}, ${r}${i}`:t,d=[[ip.default.instancePath,(0,Xr.strConcat)(ip.default.instancePath,a)],[ip.default.parentData,o.parentData],[ip.default.parentDataProperty,o.parentDataProperty],[ip.default.rootData,ip.default.rootData]];o.opts.dynamicRef&&d.push([ip.default.dynamicAnchors,ip.default.dynamicAnchors]);const f=(0,Xr._)`${u}, ${n.object(...d)}`;return l!==Xr.nil?(0,Xr._)`${s}.call(${l}, ${f})`:(0,Xr._)`${s}(${f})`}Xn.callValidateCode=BUt;const VUt=(0,Xr._)`new RegExp`;function HUt({gen:e,it:{opts:t}},n){const r=t.unicodeRegExp?"u":"",{regExp:i}=t.code,a=i(n,r);return e.scopeValue("pattern",{key:a.toString(),ref:a,code:(0,Xr._)`${i.code==="new RegExp"?VUt:(0,DUt.useFunc)(e,i)}(${n}, ${r})`})}Xn.usePattern=HUt;function WUt(e){const{gen:t,data:n,keyword:r,it:i}=e,a=t.name("valid");if(i.allErrors){const s=t.let("valid",!0);return o(()=>t.assign(s,!1)),s}return t.var(a,!0),o(()=>t.break()),a;function o(s){const l=t.const("len",(0,Xr._)`${n}.length`);t.forRange("i",0,l,c=>{e.subschema({keyword:r,dataProp:c,dataPropType:uJ.Type.Num},a),t.if((0,Xr.not)(a),s)})}}Xn.validateArray=WUt;function UUt(e){const{gen:t,schema:n,keyword:r,it:i}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some(l=>(0,uJ.alwaysValidSchema)(i,l))&&!i.opts.unevaluated)return;const o=t.let("valid",!1),s=t.name("_valid");t.block(()=>n.forEach((l,c)=>{const u=e.subschema({keyword:r,schemaProp:c,compositeRule:!0},s);t.assign(o,(0,Xr._)`${o} || ${s}`),e.mergeValidEvaluated(u,s)||t.if((0,Xr.not)(o))})),e.result(o,()=>e.reset(),()=>e.error(!0))}Xn.validateUnion=UUt;Object.defineProperty(Iu,"__esModule",{value:!0});Iu.validateKeywordUsage=Iu.validSchemaType=Iu.funcKeywordCode=Iu.macroKeywordCode=void 0;const Mo=Wn,sg=cd,GUt=Xn,qUt=yT;function KUt(e,t){const{gen:n,keyword:r,schema:i,parentSchema:a,it:o}=e,s=t.macro.call(o.self,i,a,o),l=$Le(n,r,s);o.opts.validateSchema!==!1&&o.self.validateSchema(s,!0);const c=n.name("valid");e.subschema({schema:s,schemaPath:Mo.nil,errSchemaPath:`${o.errSchemaPath}/${r}`,topSchemaRef:l,compositeRule:!0},c),e.pass(c,()=>e.error(!0))}Iu.macroKeywordCode=KUt;function YUt(e,t){var n;const{gen:r,keyword:i,schema:a,parentSchema:o,$data:s,it:l}=e;ZUt(l,t);const c=!s&&t.compile?t.compile.call(l.self,a,o,l):t.validate,u=$Le(r,i,c),d=r.let("valid");e.block$data(d,f),e.ok((n=t.valid)!==null&&n!==void 0?n:d);function f(){if(t.errors===!1)g(),t.modifying&&Lve(e),v(()=>e.error());else{const y=t.async?p():h();t.modifying&&Lve(e),v(()=>XUt(e,y))}}function p(){const y=r.let("ruleErrs",null);return r.try(()=>g((0,Mo._)`await `),x=>r.assign(d,!1).if((0,Mo._)`${x} instanceof ${l.ValidationError}`,()=>r.assign(y,(0,Mo._)`${x}.errors`),()=>r.throw(x))),y}function h(){const y=(0,Mo._)`${u}.errors`;return r.assign(y,null),g(Mo.nil),y}function g(y=t.async?(0,Mo._)`await `:Mo.nil){const x=l.opts.passContext?sg.default.this:sg.default.self,w=!("compile"in t&&!s||t.schema===!1);r.assign(d,(0,Mo._)`${y}${(0,GUt.callValidateCode)(e,u,x,w)}`,t.modifying)}function v(y){var x;r.if((0,Mo.not)((x=t.valid)!==null&&x!==void 0?x:d),y)}}Iu.funcKeywordCode=YUt;function Lve(e){const{gen:t,data:n,it:r}=e;t.if(r.parentData,()=>t.assign(n,(0,Mo._)`${r.parentData}[${r.parentDataProperty}]`))}function XUt(e,t){const{gen:n}=e;n.if((0,Mo._)`Array.isArray(${t})`,()=>{n.assign(sg.default.vErrors,(0,Mo._)`${sg.default.vErrors} === null ? ${t} : ${sg.default.vErrors}.concat(${t})`).assign(sg.default.errors,(0,Mo._)`${sg.default.vErrors}.length`),(0,qUt.extendErrors)(e)},()=>e.error())}function ZUt({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function $Le(e,t,n){if(n===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof n=="function"?{ref:n}:{ref:n,code:(0,Mo.stringify)(n)})}function QUt(e,t,n=!1){return!t.length||t.some(r=>r==="array"?Array.isArray(e):r==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==r||n&&typeof e>"u")}Iu.validSchemaType=QUt;function JUt({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw new Error("ajv implementation error");const o=i.dependencies;if(o!=null&&o.some(s=>!Object.prototype.hasOwnProperty.call(e,s)))throw new Error(`parent schema must have dependencies of ${a}: ${o.join(",")}`);if(i.validateSchema&&!i.validateSchema(e[a])){const l=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema==="log")n.logger.error(l);else throw new Error(l)}}Iu.validateKeywordUsage=JUt;var Ch={};Object.defineProperty(Ch,"__esModule",{value:!0});Ch.extendSubschemaMode=Ch.extendSubschemaData=Ch.getSubschema=void 0;const _u=Wn,ELe=zt;function eGt(e,{keyword:t,schemaProp:n,schema:r,schemaPath:i,errSchemaPath:a,topSchemaRef:o}){if(t!==void 0&&r!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){const s=e.schema[t];return n===void 0?{schema:s,schemaPath:(0,_u._)`${e.schemaPath}${(0,_u.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:s[n],schemaPath:(0,_u._)`${e.schemaPath}${(0,_u.getProperty)(t)}${(0,_u.getProperty)(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,ELe.escapeFragment)(n)}`}}if(r!==void 0){if(i===void 0||a===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:r,schemaPath:i,topSchemaRef:o,errSchemaPath:a}}throw new Error('either "keyword" or "schema" must be passed')}Ch.getSubschema=eGt;function tGt(e,t,{dataProp:n,dataPropType:r,data:i,dataTypes:a,propertyName:o}){if(i!==void 0&&n!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:s}=t;if(n!==void 0){const{errorPath:c,dataPathArr:u,opts:d}=t,f=s.let("data",(0,_u._)`${t.data}${(0,_u.getProperty)(n)}`,!0);l(f),e.errorPath=(0,_u.str)`${c}${(0,ELe.getErrorPath)(n,r,d.jsPropertySyntax)}`,e.parentDataProperty=(0,_u._)`${n}`,e.dataPathArr=[...u,e.parentDataProperty]}if(i!==void 0){const c=i instanceof _u.Name?i:s.let("data",i,!0);l(c),o!==void 0&&(e.propertyName=o)}a&&(e.dataTypes=a);function l(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c]}}Ch.extendSubschemaData=tGt;function nGt(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}Ch.extendSubschemaMode=nGt;var Va={},TLe=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n},ILe={exports:{}},eh=ILe.exports=function(e,t,n){typeof t=="function"&&(n=t,t={}),n=t.cb||n;var r=typeof n=="function"?n:n.pre||function(){},i=n.post||function(){};HN(t,r,i,e,"",e)};eh.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};eh.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};eh.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};eh.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function HN(e,t,n,r,i,a,o,s,l,c){if(r&&typeof r=="object"&&!Array.isArray(r)){t(r,i,a,o,s,l,c);for(var u in r){var d=r[u];if(Array.isArray(d)){if(u in eh.arrayKeywords)for(var f=0;f<d.length;f++)HN(e,t,n,d[f],i+"/"+u+"/"+f,a,i,u,r,f)}else if(u in eh.propsKeywords){if(d&&typeof d=="object")for(var p in d)HN(e,t,n,d[p],i+"/"+u+"/"+rGt(p),a,i,u,r,p)}else(u in eh.keywords||e.allKeys&&!(u in eh.skipKeywords))&&HN(e,t,n,d,i+"/"+u,a,i,u,r)}n(r,i,a,o,s,l,c)}}function rGt(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var iGt=ILe.exports;Object.defineProperty(Va,"__esModule",{value:!0});Va.getSchemaRefs=Va.resolveUrl=Va.normalizeId=Va._getFullPath=Va.getFullPath=Va.inlineRef=void 0;const aGt=zt,oGt=TLe,sGt=iGt,lGt=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function cGt(e,t=!0){return typeof e=="boolean"?!0:t===!0?!zU(e):t?kLe(e)<=t:!1}Va.inlineRef=cGt;const uGt=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function zU(e){for(const t in e){if(uGt.has(t))return!0;const n=e[t];if(Array.isArray(n)&&n.some(zU)||typeof n=="object"&&zU(n))return!0}return!1}function kLe(e){let t=0;for(const n in e){if(n==="$ref")return 1/0;if(t++,!lGt.has(n)&&(typeof e[n]=="object"&&(0,aGt.eachItem)(e[n],r=>t+=kLe(r)),t===1/0))return 1/0}return t}function PLe(e,t="",n){n!==!1&&(t=cx(t));const r=e.parse(t);return NLe(e,r)}Va.getFullPath=PLe;function NLe(e,t){return e.serialize(t).split("#")[0]+"#"}Va._getFullPath=NLe;const dGt=/#\/?$/;function cx(e){return e?e.replace(dGt,""):""}Va.normalizeId=cx;function fGt(e,t,n){return n=cx(n),e.resolve(t,n)}Va.resolveUrl=fGt;const pGt=/^[a-z_][-a-z0-9._]*$/i;function hGt(e,t){if(typeof e=="boolean")return{};const{schemaId:n,uriResolver:r}=this.opts,i=cx(e[n]||t),a={"":i},o=PLe(r,i,!1),s={},l=new Set;return sGt(e,{allKeys:!0},(d,f,p,h)=>{if(h===void 0)return;const g=o+f;let v=a[h];typeof d[n]=="string"&&(v=y.call(this,d[n])),x.call(this,d.$anchor),x.call(this,d.$dynamicAnchor),a[f]=v;function y(w){const S=this.opts.uriResolver.resolve;if(w=cx(v?S(v,w):w),l.has(w))throw u(w);l.add(w);let _=this.refs[w];return typeof _=="string"&&(_=this.refs[_]),typeof _=="object"?c(d,_.schema,w):w!==cx(g)&&(w[0]==="#"?(c(d,s[w],w),s[w]=d):this.refs[w]=g),w}function x(w){if(typeof w=="string"){if(!pGt.test(w))throw new Error(`invalid anchor "${w}"`);y.call(this,`#${w}`)}}}),s;function c(d,f,p){if(f!==void 0&&!oGt(d,f))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Va.getSchemaRefs=hGt;Object.defineProperty(Mc,"__esModule",{value:!0});Mc.getData=Mc.KeywordCxt=Mc.validateFunctionCode=void 0;const ALe=_1,jve=la,pJ=rf,QR=la,mGt=cj,PC=Iu,q6=Ch,Zt=Wn,Sn=cd,gGt=Va,af=zt,HS=yT;function vGt(e){if(DLe(e)&&(OLe(e),RLe(e))){xGt(e);return}MLe(e,()=>(0,ALe.topBoolOrEmptySchema)(e))}Mc.validateFunctionCode=vGt;function MLe({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,Zt._)`${Sn.default.data}, ${Sn.default.valCxt}`,r.$async,()=>{e.code((0,Zt._)`"use strict"; ${zve(n,i)}`),bGt(e,i),e.code(a)}):e.func(t,(0,Zt._)`${Sn.default.data}, ${yGt(i)}`,r.$async,()=>e.code(zve(n,i)).code(a))}function yGt(e){return(0,Zt._)`{${Sn.default.instancePath}="", ${Sn.default.parentData}, ${Sn.default.parentDataProperty}, ${Sn.default.rootData}=${Sn.default.data}${e.dynamicRef?(0,Zt._)`, ${Sn.default.dynamicAnchors}={}`:Zt.nil}}={}`}function bGt(e,t){e.if(Sn.default.valCxt,()=>{e.var(Sn.default.instancePath,(0,Zt._)`${Sn.default.valCxt}.${Sn.default.instancePath}`),e.var(Sn.default.parentData,(0,Zt._)`${Sn.default.valCxt}.${Sn.default.parentData}`),e.var(Sn.default.parentDataProperty,(0,Zt._)`${Sn.default.valCxt}.${Sn.default.parentDataProperty}`),e.var(Sn.default.rootData,(0,Zt._)`${Sn.default.valCxt}.${Sn.default.rootData}`),t.dynamicRef&&e.var(Sn.default.dynamicAnchors,(0,Zt._)`${Sn.default.valCxt}.${Sn.default.dynamicAnchors}`)},()=>{e.var(Sn.default.instancePath,(0,Zt._)`""`),e.var(Sn.default.parentData,(0,Zt._)`undefined`),e.var(Sn.default.parentDataProperty,(0,Zt._)`undefined`),e.var(Sn.default.rootData,Sn.default.data),t.dynamicRef&&e.var(Sn.default.dynamicAnchors,(0,Zt._)`{}`)})}function xGt(e){const{schema:t,opts:n,gen:r}=e;MLe(e,()=>{n.$comment&&t.$comment&&jLe(e),$Gt(e),r.let(Sn.default.vErrors,null),r.let(Sn.default.errors,0),n.unevaluated&&wGt(e),LLe(e),IGt(e)})}function wGt(e){const{gen:t,validateName:n}=e;e.evaluated=t.const("evaluated",(0,Zt._)`${n}.evaluated`),t.if((0,Zt._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Zt._)`${e.evaluated}.props`,(0,Zt._)`undefined`)),t.if((0,Zt._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Zt._)`${e.evaluated}.items`,(0,Zt._)`undefined`))}function zve(e,t){const n=typeof e=="object"&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,Zt._)`/*# sourceURL=${n} */`:Zt.nil}function SGt(e,t){if(DLe(e)&&(OLe(e),RLe(e))){_Gt(e,t);return}(0,ALe.boolOrEmptySchema)(e,t)}function RLe({schema:e,self:t}){if(typeof e=="boolean")return!e;for(const n in e)if(t.RULES.all[n])return!0;return!1}function DLe(e){return typeof e.schema!="boolean"}function _Gt(e,t){const{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&jLe(e),EGt(e),TGt(e);const a=r.const("_errs",Sn.default.errors);LLe(e,a),r.var(t,(0,Zt._)`${a} === ${Sn.default.errors}`)}function OLe(e){(0,af.checkUnknownRules)(e),CGt(e)}function LLe(e,t){if(e.opts.jtd)return Fve(e,[],!1,t);const n=(0,jve.getSchemaTypes)(e.schema),r=(0,jve.coerceAndCheckDataType)(e,n);Fve(e,n,!r,t)}function CGt(e){const{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,af.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function $Gt(e){const{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,af.checkStrictMode)(e,"default is ignored in the schema root")}function EGt(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,gGt.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function TGt(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function jLe({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){const a=n.$comment;if(i.$comment===!0)e.code((0,Zt._)`${Sn.default.self}.logger.log(${a})`);else if(typeof i.$comment=="function"){const o=(0,Zt.str)`${r}/$comment`,s=e.scopeValue("root",{ref:t.root});e.code((0,Zt._)`${Sn.default.self}.opts.$comment(${a}, ${o}, ${s}.schema)`)}}function IGt(e){const{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,Zt._)`${Sn.default.errors} === 0`,()=>t.return(Sn.default.data),()=>t.throw((0,Zt._)`new ${i}(${Sn.default.vErrors})`)):(t.assign((0,Zt._)`${r}.errors`,Sn.default.vErrors),a.unevaluated&&kGt(e),t.return((0,Zt._)`${Sn.default.errors} === 0`))}function kGt({gen:e,evaluated:t,props:n,items:r}){n instanceof Zt.Name&&e.assign((0,Zt._)`${t}.props`,n),r instanceof Zt.Name&&e.assign((0,Zt._)`${t}.items`,r)}function Fve(e,t,n,r){const{gen:i,schema:a,data:o,allErrors:s,opts:l,self:c}=e,{RULES:u}=c;if(a.$ref&&(l.ignoreKeywordsWithRef||!(0,af.schemaHasRulesButRef)(a,u))){i.block(()=>BLe(e,"$ref",u.all.$ref.definition));return}l.jtd||PGt(e,t),i.block(()=>{for(const f of u.rules)d(f);d(u.post)});function d(f){(0,pJ.shouldUseGroup)(a,f)&&(f.type?(i.if((0,QR.checkDataType)(f.type,o,l.strictNumbers)),Bve(e,f),t.length===1&&t[0]===f.type&&n&&(i.else(),(0,QR.reportTypeError)(e)),i.endIf()):Bve(e,f),s||i.if((0,Zt._)`${Sn.default.errors} === ${r||0}`))}}function Bve(e,t){const{gen:n,schema:r,opts:{useDefaults:i}}=e;i&&(0,mGt.assignDefaults)(e,t.type),n.block(()=>{for(const a of t.rules)(0,pJ.shouldUseRule)(r,a)&&BLe(e,a.keyword,a.definition,t.type)})}function PGt(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(NGt(e,t),e.opts.allowUnionTypes||AGt(e,t),MGt(e,e.dataTypes))}function NGt(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(n=>{zLe(e.dataTypes,n)||hJ(e,`type "${n}" not allowed by context "${e.dataTypes.join(",")}"`)}),DGt(e,t)}}function AGt(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&hJ(e,"use allowUnionTypes to allow union type keyword")}function MGt(e,t){const n=e.self.RULES.all;for(const r in n){const i=n[r];if(typeof i=="object"&&(0,pJ.shouldUseRule)(e.schema,i)){const{type:a}=i.definition;a.length&&!a.some(o=>RGt(t,o))&&hJ(e,`missing type "${a.join(",")}" for keyword "${r}"`)}}}function RGt(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function zLe(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function DGt(e,t){const n=[];for(const r of e.dataTypes)zLe(t,r)?n.push(r):t.includes("integer")&&r==="number"&&n.push("integer");e.dataTypes=n}function hJ(e,t){const n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,af.checkStrictMode)(e,t,e.opts.strictTypes)}class FLe{constructor(t,n,r){if((0,PC.validateKeywordUsage)(t,n,r),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=r,this.data=t.data,this.schema=t.schema[r],this.$data=n.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,af.schemaRefOrVal)(t,this.schema,r,this.$data),this.schemaType=n.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=n,this.$data)this.schemaCode=t.gen.const("vSchema",VLe(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,PC.validSchemaType)(this.schema,n.schemaType,n.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(n.schemaType)}`);("code"in n?n.trackErrors:n.errors!==!1)&&(this.errsCount=t.gen.const("_errs",Sn.default.errors))}result(t,n,r){this.failResult((0,Zt.not)(t),n,r)}failResult(t,n,r){this.gen.if(t),r?r():this.error(),n?(this.gen.else(),n(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,n){this.failResult((0,Zt.not)(t),void 0,n)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:n}=this;this.fail((0,Zt._)`${n} !== undefined && (${(0,Zt.or)(this.invalid$data(),t)})`)}error(t,n,r){if(n){this.setParams(n),this._error(t,r),this.setParams({});return}this._error(t,r)}_error(t,n){(t?HS.reportExtraError:HS.reportError)(this,this.def.error,n)}$dataError(){(0,HS.reportError)(this,this.def.$dataError||HS.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,HS.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,n){n?Object.assign(this.params,t):this.params=t}block$data(t,n,r=Zt.nil){this.gen.block(()=>{this.check$data(t,r),n()})}check$data(t=Zt.nil,n=Zt.nil){if(!this.$data)return;const{gen:r,schemaCode:i,schemaType:a,def:o}=this;r.if((0,Zt.or)((0,Zt._)`${i} === undefined`,n)),t!==Zt.nil&&r.assign(t,!0),(a.length||o.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),t!==Zt.nil&&r.assign(t,!1)),r.else()}invalid$data(){const{gen:t,schemaCode:n,schemaType:r,def:i,it:a}=this;return(0,Zt.or)(o(),s());function o(){if(r.length){if(!(n instanceof Zt.Name))throw new Error("ajv implementation error");const l=Array.isArray(r)?r:[r];return(0,Zt._)`${(0,QR.checkDataTypes)(l,n,a.opts.strictNumbers,QR.DataType.Wrong)}`}return Zt.nil}function s(){if(i.validateSchema){const l=t.scopeValue("validate$data",{ref:i.validateSchema});return(0,Zt._)`!${l}(${n})`}return Zt.nil}}subschema(t,n){const r=(0,q6.getSubschema)(this.it,t);(0,q6.extendSubschemaData)(r,this.it,t),(0,q6.extendSubschemaMode)(r,t);const i={...this.it,...r,items:void 0,props:void 0};return SGt(i,n),i}mergeEvaluated(t,n){const{it:r,gen:i}=this;r.opts.unevaluated&&(r.props!==!0&&t.props!==void 0&&(r.props=af.mergeEvaluated.props(i,t.props,r.props,n)),r.items!==!0&&t.items!==void 0&&(r.items=af.mergeEvaluated.items(i,t.items,r.items,n)))}mergeValidEvaluated(t,n){const{it:r,gen:i}=this;if(r.opts.unevaluated&&(r.props!==!0||r.items!==!0))return i.if(n,()=>this.mergeEvaluated(t,Zt.Name)),!0}}Mc.KeywordCxt=FLe;function BLe(e,t,n,r){const i=new FLe(e,n,t);"code"in n?n.code(i,r):i.$data&&n.validate?(0,PC.funcKeywordCode)(i,n):"macro"in n?(0,PC.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,PC.funcKeywordCode)(i,n)}const OGt=/^\/(?:[^~]|~0|~1)*$/,LGt=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function VLe(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e==="")return Sn.default.rootData;if(e[0]==="/"){if(!OGt.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);i=e,a=Sn.default.rootData}else{const c=LGt.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);const u=+c[1];if(i=c[2],i==="#"){if(u>=t)throw new Error(l("property/index",u));return r[t-u]}if(u>t)throw new Error(l("data",u));if(a=n[t-u],!i)return a}let o=a;const s=i.split("/");for(const c of s)c&&(a=(0,Zt._)`${a}${(0,Zt.getProperty)((0,af.unescapeJsonPointer)(c))}`,o=(0,Zt._)`${o} && ${a}`);return o;function l(c,u){return`Cannot access ${c} ${u} levels up, current level is ${t}`}}Mc.getData=VLe;var bT={};Object.defineProperty(bT,"__esModule",{value:!0});class jGt extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}bT.default=jGt;var Pw={};Object.defineProperty(Pw,"__esModule",{value:!0});const K6=Va;class zGt extends Error{constructor(t,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,K6.resolveUrl)(t,n,r),this.missingSchema=(0,K6.normalizeId)((0,K6.getFullPath)(t,this.missingRef))}}Pw.default=zGt;var vs={};Object.defineProperty(vs,"__esModule",{value:!0});vs.resolveSchema=vs.getCompilingSchema=vs.resolveRef=vs.compileSchema=vs.SchemaEnv=void 0;const lc=Wn,FGt=bT,jm=cd,xc=Va,Vve=zt,BGt=Mc;class uj{constructor(t){var n;this.refs={},this.dynamicAnchors={};let r;typeof t.schema=="object"&&(r=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(n=t.baseId)!==null&&n!==void 0?n:(0,xc.normalizeId)(r==null?void 0:r[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=r==null?void 0:r.$async,this.refs={}}}vs.SchemaEnv=uj;function mJ(e){const t=HLe.call(this,e);if(t)return t;const n=(0,xc.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:r,lines:i}=this.opts.code,{ownProperties:a}=this.opts,o=new lc.CodeGen(this.scope,{es5:r,lines:i,ownProperties:a});let s;e.$async&&(s=o.scopeValue("Error",{ref:FGt.default,code:(0,lc._)`require("ajv/dist/runtime/validation_error").default`}));const l=o.scopeName("validate");e.validateName=l;const c={gen:o,allErrors:this.opts.allErrors,data:jm.default.data,parentData:jm.default.parentData,parentDataProperty:jm.default.parentDataProperty,dataNames:[jm.default.data],dataPathArr:[lc.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,lc.stringify)(e.schema)}:{ref:e.schema}),validateName:l,ValidationError:s,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:lc.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,lc._)`""`,opts:this.opts,self:this};let u;try{this._compilations.add(e),(0,BGt.validateFunctionCode)(c),o.optimize(this.opts.code.optimize);const d=o.toString();u=`${o.scopeRefs(jm.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,e));const p=new Function(`${jm.default.self}`,`${jm.default.scope}`,u)(this,this.scope.get());if(this.scope.value(l,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:l,validateCode:d,scopeValues:o._values}),this.opts.unevaluated){const{props:h,items:g}=c;p.evaluated={props:h instanceof lc.Name?void 0:h,items:g instanceof lc.Name?void 0:g,dynamicProps:h instanceof lc.Name,dynamicItems:g instanceof lc.Name},p.source&&(p.source.evaluated=(0,lc.stringify)(p.evaluated))}return e.validate=p,e}catch(d){throw delete e.validate,delete e.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(e)}}vs.compileSchema=mJ;function VGt(e,t,n){var r;n=(0,xc.resolveUrl)(this.opts.uriResolver,t,n);const i=e.refs[n];if(i)return i;let a=UGt.call(this,e,n);if(a===void 0){const o=(r=e.localRefs)===null||r===void 0?void 0:r[n],{schemaId:s}=this.opts;o&&(a=new uj({schema:o,schemaId:s,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=HGt.call(this,a)}vs.resolveRef=VGt;function HGt(e){return(0,xc.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:mJ.call(this,e)}function HLe(e){for(const t of this._compilations)if(WGt(t,e))return t}vs.getCompilingSchema=HLe;function WGt(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function UGt(e,t){let n;for(;typeof(n=this.refs[t])=="string";)t=n;return n||this.schemas[t]||dj.call(this,e,t)}function dj(e,t){const n=this.opts.uriResolver.parse(t),r=(0,xc._getFullPath)(this.opts.uriResolver,n);let i=(0,xc.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===i)return Y6.call(this,n,e);const a=(0,xc.normalizeId)(r),o=this.refs[a]||this.schemas[a];if(typeof o=="string"){const s=dj.call(this,e,o);return typeof(s==null?void 0:s.schema)!="object"?void 0:Y6.call(this,n,s)}if(typeof(o==null?void 0:o.schema)=="object"){if(o.validate||mJ.call(this,o),a===(0,xc.normalizeId)(t)){const{schema:s}=o,{schemaId:l}=this.opts,c=s[l];return c&&(i=(0,xc.resolveUrl)(this.opts.uriResolver,i,c)),new uj({schema:s,schemaId:l,root:e,baseId:i})}return Y6.call(this,n,o)}}vs.resolveSchema=dj;const GGt=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Y6(e,{baseId:t,schema:n,root:r}){var i;if(((i=e.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(const s of e.fragment.slice(1).split("/")){if(typeof n=="boolean")return;const l=n[(0,Vve.unescapeFragment)(s)];if(l===void 0)return;n=l;const c=typeof n=="object"&&n[this.opts.schemaId];!GGt.has(s)&&c&&(t=(0,xc.resolveUrl)(this.opts.uriResolver,t,c))}let a;if(typeof n!="boolean"&&n.$ref&&!(0,Vve.schemaHasRulesButRef)(n,this.RULES)){const s=(0,xc.resolveUrl)(this.opts.uriResolver,t,n.$ref);a=dj.call(this,r,s)}const{schemaId:o}=this.opts;if(a=a||new uj({schema:n,schemaId:o,root:r,baseId:t}),a.schema!==a.root.schema)return a}const qGt="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",KGt="Meta-schema for $data reference (JSON AnySchema extension proposal)",YGt="object",XGt=["$data"],ZGt={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},QGt=!1,JGt={$id:qGt,description:KGt,type:YGt,required:XGt,properties:ZGt,additionalProperties:QGt};var gJ={},fj={exports:{}};const eqt=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),WLe=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),vJ=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),ULe=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),tqt=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function GLe(e){let t="",n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[r]}return t}const nqt=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Hve(e){return e.length=0,!0}function rqt(e,t,n){if(e.length){const r=GLe(e);if(r!=="")t.push(r);else return n.error=!0,!1;e.length=0}return!0}function iqt(e){let t=0;const n={error:!1,address:"",zone:""},r=[],i=[];let a=!1,o=!1,s=rqt;for(let l=0;l<e.length;l++){const c=e[l];if(!(c==="["||c==="]"))if(c===":"){if(a===!0&&(o=!0),!s(i,r,n))break;if(++t>7){n.error=!0;break}l>0&&e[l-1]===":"&&(a=!0),r.push(":");continue}else if(c==="%"){if(!s(i,r,n))break;s=Hve}else{i.push(c);continue}}return i.length&&(s===Hve?n.zone=i.join(""):o?r.push(i.join("")):r.push(GLe(i))),n.address=r.join(""),n}function qLe(e){if(aqt(e,":")<2)return{host:e,isIPV6:!1};const t=iqt(e);if(t.error)return{host:e,isIPV6:!1};{let n=t.address,r=t.address;return t.zone&&(n+="%"+t.zone,r+="%25"+t.zone),{host:n,isIPV6:!0,escapedHost:r}}}function aqt(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function oqt(e){let t=e;const n=[];let r=-1,i=0;for(;i=t.length;){if(i===1){if(t===".")break;if(t==="/"){n.push("/");break}else{n.push(t);break}}else if(i===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){n.push("/");break}}else if(i===3&&t==="/.."){n.length!==0&&n.pop(),n.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf("/",1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join("")}const sqt={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},lqt=/[@/?#:]/g,cqt=/[@/?#]/g;function KLe(e,t){const n=t?cqt:lqt;return n.lastIndex=0,e.replace(n,r=>sqt[r])}function uqt(e,t=!1){if(e.indexOf("%")===-1)return e;let n="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){const i=e.slice(r+1,r+3);if(vJ(i)){const a=i.toUpperCase(),o=String.fromCharCode(parseInt(a,16));t&&ULe(o)?n+=o:n+="%"+a,r+=2;continue}}n+=e[r]}return n}function dqt(e){let t="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){const r=e.slice(n+1,n+3);if(vJ(r)){const i=r.toUpperCase(),a=String.fromCharCode(parseInt(i,16));a!=="."&&ULe(a)?t+=a:t+="%"+i,n+=2;continue}}tqt(e[n])?t+=e[n]:t+=escape(e[n])}return t}function fqt(e){let t="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){const r=e.slice(n+1,n+3);if(vJ(r)){t+="%"+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function pqt(e){const t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let n=unescape(e.host);if(!WLe(n)){const r=qLe(n);r.isIPV6===!0?n=`[${r.escapedHost}]`:n=KLe(n,!1)}t.push(n)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}var YLe={nonSimpleDomain:nqt,recomposeAuthority:pqt,reescapeHostDelimiters:KLe,normalizePercentEncoding:uqt,normalizePathEncoding:dqt,escapePreservingEscapes:fqt,removeDotSegments:oqt,isIPv4:WLe,isUUID:eqt,normalizeIPv6:qLe};const{isUUID:hqt}=YLe,mqt=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function XLe(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function ZLe(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function QLe(e){const t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function gqt(e){return e.secure=XLe(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function vqt(e){if((e.port===(XLe(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,n]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function yqt(e,t){if(!e.path)return e.error="URN can not be parsed",e;const n=e.path.match(mqt);if(n){const r=t.scheme||e.scheme||"urn";e.nid=n[1].toLowerCase(),e.nss=n[2];const i=`${r}:${t.nid||e.nid}`,a=yJ(i);e.path=void 0,a&&(e=a.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function bqt(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");const n=t.scheme||e.scheme||"urn",r=e.nid.toLowerCase(),i=`${n}:${t.nid||r}`,a=yJ(i);a&&(e=a.serialize(e,t));const o=e,s=e.nss;return o.path=`${r||t.nid}:${s}`,t.skipEscape=!0,o}function xqt(e,t){const n=e;return n.uuid=n.nss,n.nss=void 0,!t.tolerant&&(!n.uuid||!hqt(n.uuid))&&(n.error=n.error||"UUID is not valid."),n}function wqt(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t}const JLe={scheme:"http",domainHost:!0,parse:ZLe,serialize:QLe},Sqt={scheme:"https",domainHost:JLe.domainHost,parse:ZLe,serialize:QLe},WN={scheme:"ws",domainHost:!0,parse:gqt,serialize:vqt},_qt={scheme:"wss",domainHost:WN.domainHost,parse:WN.parse,serialize:WN.serialize},Cqt={scheme:"urn",parse:yqt,serialize:bqt,skipNormalize:!0},$qt={scheme:"urn:uuid",parse:xqt,serialize:wqt,skipNormalize:!0},JR={http:JLe,https:Sqt,ws:WN,wss:_qt,urn:Cqt,"urn:uuid":$qt};Object.setPrototypeOf(JR,null);function yJ(e){return e&&(JR[e]||JR[e.toLowerCase()])||void 0}var Eqt={SCHEMES:JR,getSchemeHandler:yJ};const{normalizeIPv6:Tqt,removeDotSegments:E_,recomposeAuthority:Iqt,normalizePercentEncoding:kqt,normalizePathEncoding:Pqt,escapePreservingEscapes:Nqt,reescapeHostDelimiters:Aqt,isIPv4:Mqt,nonSimpleDomain:Rqt}=YLe,{SCHEMES:Dqt,getSchemeHandler:eje}=Eqt;function Oqt(e,t){return typeof e=="string"?e=Bqt(e,t):typeof e=="object"&&(e=C1(Zv(e,t),t)),e}function Lqt(e,t,n){const r=n?Object.assign({scheme:"null"},n):{scheme:"null"},i=tje(C1(e,r),C1(t,r),r,!0);return r.skipEscape=!0,Zv(i,r)}function tje(e,t,n,r){const i={};return r||(e=C1(Zv(e,n),n),t=C1(Zv(t,n),n)),n=n||{},!n.tolerant&&t.scheme?(i.scheme=t.scheme,i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=E_(t.path||""),i.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=E_(t.path||""),i.query=t.query):(t.path?(t.path[0]==="/"?i.path=E_(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?i.path="/"+t.path:e.path?i.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:i.path=t.path,i.path=E_(i.path)),i.query=t.query):(i.path=e.path,t.query!==void 0?i.query=t.query:i.query=e.query),i.userinfo=e.userinfo,i.host=e.host,i.port=e.port),i.scheme=e.scheme),i.fragment=t.fragment,i}function jqt(e,t,n){const r=Wve(e,n),i=Wve(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function Zv(e,t){const n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},r=Object.assign({},t),i=[],a=eje(r.scheme||n.scheme);a&&a.serialize&&a.serialize(n,r),n.path!==void 0&&(r.skipEscape?n.path=kqt(n.path):(n.path=Nqt(n.path),n.scheme!==void 0&&(n.path=n.path.split("%3A").join(":")))),r.reference!=="suffix"&&n.scheme&&i.push(n.scheme,":");const o=Iqt(n);if(o!==void 0&&(r.reference!=="suffix"&&i.push("//"),i.push(o),n.path&&n.path[0]!=="/"&&i.push("/")),n.path!==void 0){let s=n.path;!r.absolutePath&&(!a||!a.absolutePath)&&(s=E_(s)),o===void 0&&s[0]==="/"&&s[1]==="/"&&(s="/%2F"+s.slice(2)),i.push(s)}return n.query!==void 0&&i.push("?",n.query),n.fragment!==void 0&&i.push("#",n.fragment),i.join("")}const zqt=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Fqt(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function nje(e,t){const n=Object.assign({},t),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let i=!1,a=!1;n.reference==="suffix"&&(n.scheme?e=n.scheme+":"+e:e="//"+e);const o=e.match(zqt);if(o){r.scheme=o[1],r.userinfo=o[3],r.host=o[4],r.port=parseInt(o[5],10),r.path=o[6]||"",r.query=o[7],r.fragment=o[8],isNaN(r.port)&&(r.port=o[5]);const s=Fqt(r,o);if(s!==void 0&&(r.error=r.error||s,i=!0),r.host)if(Mqt(r.host)===!1){const u=Tqt(r.host);r.host=u.host.toLowerCase(),a=u.isIPV6}else a=!0;r.scheme===void 0&&r.userinfo===void 0&&r.host===void 0&&r.port===void 0&&r.query===void 0&&!r.path?r.reference="same-document":r.scheme===void 0?r.reference="relative":r.fragment===void 0?r.reference="absolute":r.reference="uri",n.reference&&n.reference!=="suffix"&&n.reference!==r.reference&&(r.error=r.error||"URI is not a "+n.reference+" reference.");const l=eje(n.scheme||r.scheme);if(!n.unicodeSupport&&(!l||!l.unicodeSupport)&&r.host&&(n.domainHost||l&&l.domainHost)&&a===!1&&Rqt(r.host))try{r.host=new URL("http://"+r.host).hostname}catch(c){r.error=r.error||"Host's domain name can not be converted to ASCII: "+c}if((!l||l&&!l.skipNormalize)&&(e.indexOf("%")!==-1&&(r.scheme!==void 0&&(r.scheme=unescape(r.scheme)),r.host!==void 0&&(r.host=Aqt(unescape(r.host),a))),r.path&&(r.path=Pqt(r.path)),r.fragment))try{r.fragment=encodeURI(decodeURIComponent(r.fragment))}catch{r.error=r.error||"URI malformed"}l&&l.parse&&l.parse(r,n)}else r.error=r.error||"URI can not be parsed.";return{parsed:r,malformedAuthorityOrPort:i}}function C1(e,t){return nje(e,t).parsed}function Bqt(e,t){return rje(e,t).normalized}function rje(e,t){const{parsed:n,malformedAuthorityOrPort:r}=nje(e,t);return{normalized:r?e:Zv(n,t),malformedAuthorityOrPort:r}}function Wve(e,t){if(typeof e=="string"){const{normalized:n,malformedAuthorityOrPort:r}=rje(e,t);return r?void 0:n}if(typeof e=="object")return Zv(e,t)}const bJ={SCHEMES:Dqt,normalize:Oqt,resolve:Lqt,resolveComponent:tje,equal:jqt,serialize:Zv,parse:C1};fj.exports=bJ;fj.exports.default=bJ;fj.exports.fastUri=bJ;var Vqt=fj.exports;Object.defineProperty(gJ,"__esModule",{value:!0});const ije=Vqt;ije.code='require("ajv/dist/runtime/uri").default';gJ.default=ije;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Mc;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var n=Wn;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return n.CodeGen}});const r=bT,i=Pw,a=Xv,o=vs,s=Wn,l=Va,c=la,u=zt,d=JGt,f=gJ,p=(O,V)=>new RegExp(O,V);p.code="new RegExp";const h=["removeAdditional","useDefaults","coerceTypes"],g=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),v={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},y={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},x=200;function w(O){var V,B,D,F,H,W,K,U,q,Q,G,X,J,Y,Z,re,ee,te,oe,fe,he,ye,Te,Ee,we;const le=O.strict,se=(V=O.code)===null||V===void 0?void 0:V.optimize,ne=se===!0||se===void 0?1:se||0,ge=(D=(B=O.code)===null||B===void 0?void 0:B.regExp)!==null&&D!==void 0?D:p,be=(F=O.uriResolver)!==null&&F!==void 0?F:f.default;return{strictSchema:(W=(H=O.strictSchema)!==null&&H!==void 0?H:le)!==null&&W!==void 0?W:!0,strictNumbers:(U=(K=O.strictNumbers)!==null&&K!==void 0?K:le)!==null&&U!==void 0?U:!0,strictTypes:(Q=(q=O.strictTypes)!==null&&q!==void 0?q:le)!==null&&Q!==void 0?Q:"log",strictTuples:(X=(G=O.strictTuples)!==null&&G!==void 0?G:le)!==null&&X!==void 0?X:"log",strictRequired:(Y=(J=O.strictRequired)!==null&&J!==void 0?J:le)!==null&&Y!==void 0?Y:!1,code:O.code?{...O.code,optimize:ne,regExp:ge}:{optimize:ne,regExp:ge},loopRequired:(Z=O.loopRequired)!==null&&Z!==void 0?Z:x,loopEnum:(re=O.loopEnum)!==null&&re!==void 0?re:x,meta:(ee=O.meta)!==null&&ee!==void 0?ee:!0,messages:(te=O.messages)!==null&&te!==void 0?te:!0,inlineRefs:(oe=O.inlineRefs)!==null&&oe!==void 0?oe:!0,schemaId:(fe=O.schemaId)!==null&&fe!==void 0?fe:"$id",addUsedSchema:(he=O.addUsedSchema)!==null&&he!==void 0?he:!0,validateSchema:(ye=O.validateSchema)!==null&&ye!==void 0?ye:!0,validateFormats:(Te=O.validateFormats)!==null&&Te!==void 0?Te:!0,unicodeRegExp:(Ee=O.unicodeRegExp)!==null&&Ee!==void 0?Ee:!0,int32range:(we=O.int32range)!==null&&we!==void 0?we:!0,uriResolver:be}}class S{constructor(V={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,V=this.opts={...V,...w(V)};const{es5:B,lines:D}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:g,es5:B,lines:D}),this.logger=P(V.logger);const F=V.validateFormats;V.validateFormats=!1,this.RULES=(0,a.getRules)(),_.call(this,v,V,"NOT SUPPORTED"),_.call(this,y,V,"DEPRECATED","warn"),this._metaOpts=T.call(this),V.formats&&E.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),V.keywords&&k.call(this,V.keywords),typeof V.meta=="object"&&this.addMetaSchema(V.meta),$.call(this),V.validateFormats=F}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:V,meta:B,schemaId:D}=this.opts;let F=d;D==="id"&&(F={...d},F.id=F.$id,delete F.$id),B&&V&&this.addMetaSchema(F,F[D],!1)}defaultMeta(){const{meta:V,schemaId:B}=this.opts;return this.opts.defaultMeta=typeof V=="object"?V[B]||V:void 0}validate(V,B){let D;if(typeof V=="string"){if(D=this.getSchema(V),!D)throw new Error(`no schema with key or ref "${V}"`)}else D=this.compile(V);const F=D(B);return"$async"in D||(this.errors=D.errors),F}compile(V,B){const D=this._addSchema(V,B);return D.validate||this._compileSchemaEnv(D)}compileAsync(V,B){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:D}=this.opts;return F.call(this,V,B);async function F(Q,G){await H.call(this,Q.$schema);const X=this._addSchema(Q,G);return X.validate||W.call(this,X)}async function H(Q){Q&&!this.getSchema(Q)&&await F.call(this,{$ref:Q},!0)}async function W(Q){try{return this._compileSchemaEnv(Q)}catch(G){if(!(G instanceof i.default))throw G;return K.call(this,G),await U.call(this,G.missingSchema),W.call(this,Q)}}function K({missingSchema:Q,missingRef:G}){if(this.refs[Q])throw new Error(`AnySchema ${Q} is loaded but ${G} cannot be resolved`)}async function U(Q){const G=await q.call(this,Q);this.refs[Q]||await H.call(this,G.$schema),this.refs[Q]||this.addSchema(G,Q,B)}async function q(Q){const G=this._loading[Q];if(G)return G;try{return await(this._loading[Q]=D(Q))}finally{delete this._loading[Q]}}}addSchema(V,B,D,F=this.opts.validateSchema){if(Array.isArray(V)){for(const W of V)this.addSchema(W,void 0,D,F);return this}let H;if(typeof V=="object"){const{schemaId:W}=this.opts;if(H=V[W],H!==void 0&&typeof H!="string")throw new Error(`schema ${W} must be string`)}return B=(0,l.normalizeId)(B||H),this._checkUnique(B),this.schemas[B]=this._addSchema(V,D,B,F,!0),this}addMetaSchema(V,B,D=this.opts.validateSchema){return this.addSchema(V,B,!0,D),this}validateSchema(V,B){if(typeof V=="boolean")return!0;let D;if(D=V.$schema,D!==void 0&&typeof D!="string")throw new Error("$schema must be a string");if(D=D||this.opts.defaultMeta||this.defaultMeta(),!D)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const F=this.validate(D,V);if(!F&&B){const H="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(H);else throw new Error(H)}return F}getSchema(V){let B;for(;typeof(B=C.call(this,V))=="string";)V=B;if(B===void 0){const{schemaId:D}=this.opts,F=new o.SchemaEnv({schema:{},schemaId:D});if(B=o.resolveSchema.call(this,F,V),!B)return;this.refs[V]=B}return B.validate||this._compileSchemaEnv(B)}removeSchema(V){if(V instanceof RegExp)return this._removeAllSchemas(this.schemas,V),this._removeAllSchemas(this.refs,V),this;switch(typeof V){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const B=C.call(this,V);return typeof B=="object"&&this._cache.delete(B.schema),delete this.schemas[V],delete this.refs[V],this}case"object":{const B=V;this._cache.delete(B);let D=V[this.opts.schemaId];return D&&(D=(0,l.normalizeId)(D),delete this.schemas[D],delete this.refs[D]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(V){for(const B of V)this.addKeyword(B);return this}addKeyword(V,B){let D;if(typeof V=="string")D=V,typeof B=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),B.keyword=D);else if(typeof V=="object"&&B===void 0){if(B=V,D=B.keyword,Array.isArray(D)&&!D.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(A.call(this,D,B),!B)return(0,u.eachItem)(D,H=>M.call(this,H)),this;L.call(this,B);const F={...B,type:(0,c.getJSONTypes)(B.type),schemaType:(0,c.getJSONTypes)(B.schemaType)};return(0,u.eachItem)(D,F.type.length===0?H=>M.call(this,H,F):H=>F.type.forEach(W=>M.call(this,H,F,W))),this}getKeyword(V){const B=this.RULES.all[V];return typeof B=="object"?B.definition:!!B}removeKeyword(V){const{RULES:B}=this;delete B.keywords[V],delete B.all[V];for(const D of B.rules){const F=D.rules.findIndex(H=>H.keyword===V);F>=0&&D.rules.splice(F,1)}return this}addFormat(V,B){return typeof B=="string"&&(B=new RegExp(B)),this.formats[V]=B,this}errorsText(V=this.errors,{separator:B=", ",dataVar:D="data"}={}){return!V||V.length===0?"No errors":V.map(F=>`${D}${F.instancePath} ${F.message}`).reduce((F,H)=>F+B+H)}$dataMetaSchema(V,B){const D=this.RULES.all;V=JSON.parse(JSON.stringify(V));for(const F of B){const H=F.split("/").slice(1);let W=V;for(const K of H)W=W[K];for(const K in D){const U=D[K];if(typeof U!="object")continue;const{$data:q}=U.definition,Q=W[K];q&&Q&&(W[K]=j(Q))}}return V}_removeAllSchemas(V,B){for(const D in V){const F=V[D];(!B||B.test(D))&&(typeof F=="string"?delete V[D]:F&&!F.meta&&(this._cache.delete(F.schema),delete V[D]))}}_addSchema(V,B,D,F=this.opts.validateSchema,H=this.opts.addUsedSchema){let W;const{schemaId:K}=this.opts;if(typeof V=="object")W=V[K];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof V!="boolean")throw new Error("schema must be object or boolean")}let U=this._cache.get(V);if(U!==void 0)return U;D=(0,l.normalizeId)(W||D);const q=l.getSchemaRefs.call(this,V,D);return U=new o.SchemaEnv({schema:V,schemaId:K,meta:B,baseId:D,localRefs:q}),this._cache.set(U.schema,U),H&&!D.startsWith("#")&&(D&&this._checkUnique(D),this.refs[D]=U),F&&this.validateSchema(V,!0),U}_checkUnique(V){if(this.schemas[V]||this.refs[V])throw new Error(`schema with key or id "${V}" already exists`)}_compileSchemaEnv(V){if(V.meta?this._compileMetaSchema(V):o.compileSchema.call(this,V),!V.validate)throw new Error("ajv implementation error");return V.validate}_compileMetaSchema(V){const B=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,V)}finally{this.opts=B}}}S.ValidationError=r.default,S.MissingRefError=i.default,e.default=S;function _(O,V,B,D="error"){for(const F in O){const H=F;H in V&&this.logger[D](`${B}: option ${F}. ${O[H]}`)}}function C(O){return O=(0,l.normalizeId)(O),this.schemas[O]||this.refs[O]}function $(){const O=this.opts.schemas;if(O)if(Array.isArray(O))this.addSchema(O);else for(const V in O)this.addSchema(O[V],V)}function E(){for(const O in this.opts.formats){const V=this.opts.formats[O];V&&this.addFormat(O,V)}}function k(O){if(Array.isArray(O)){this.addVocabulary(O);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const V in O){const B=O[V];B.keyword||(B.keyword=V),this.addKeyword(B)}}function T(){const O={...this.opts};for(const V of h)delete O[V];return O}const I={log(){},warn(){},error(){}};function P(O){if(O===!1)return I;if(O===void 0)return console;if(O.log&&O.warn&&O.error)return O;throw new Error("logger must implement log, warn and error methods")}const N=/^[a-z_$][a-z0-9_$:-]*$/i;function A(O,V){const{RULES:B}=this;if((0,u.eachItem)(O,D=>{if(B.keywords[D])throw new Error(`Keyword ${D} is already defined`);if(!N.test(D))throw new Error(`Keyword ${D} has invalid name`)}),!!V&&V.$data&&!("code"in V||"validate"in V))throw new Error('$data keyword must have "code" or "validate" function')}function M(O,V,B){var D;const F=V==null?void 0:V.post;if(B&&F)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:H}=this;let W=F?H.post:H.rules.find(({type:U})=>U===B);if(W||(W={type:B,rules:[]},H.rules.push(W)),H.keywords[O]=!0,!V)return;const K={keyword:O,definition:{...V,type:(0,c.getJSONTypes)(V.type),schemaType:(0,c.getJSONTypes)(V.schemaType)}};V.before?R.call(this,W,K,V.before):W.rules.push(K),H.all[O]=K,(D=V.implements)===null||D===void 0||D.forEach(U=>this.addKeyword(U))}function R(O,V,B){const D=O.rules.findIndex(F=>F.keyword===B);D>=0?O.rules.splice(D,0,V):(O.rules.push(V),this.logger.warn(`rule ${B} is not defined`))}function L(O){let{metaSchema:V}=O;V!==void 0&&(O.$data&&this.opts.$data&&(V=j(V)),O.validateSchema=this.compile(V,!0))}const z={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function j(O){return{anyOf:[O,z]}}})(dLe);var xJ={},wJ={},SJ={};Object.defineProperty(SJ,"__esModule",{value:!0});const Hqt={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};SJ.default=Hqt;var Qv={};Object.defineProperty(Qv,"__esModule",{value:!0});Qv.callRef=Qv.getValidate=void 0;const Wqt=Pw,Uve=Xn,ss=Wn,F0=cd,Gve=vs,bP=zt,Uqt={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:n,it:r}=e,{baseId:i,schemaEnv:a,validateName:o,opts:s,self:l}=r,{root:c}=a;if((n==="#"||n==="#/")&&i===c.baseId)return d();const u=Gve.resolveRef.call(l,c,i,n);if(u===void 0)throw new Wqt.default(r.opts.uriResolver,i,n);if(u instanceof Gve.SchemaEnv)return f(u);return p(u);function d(){if(a===c)return UN(e,o,a,a.$async);const h=t.scopeValue("root",{ref:c});return UN(e,(0,ss._)`${h}.validate`,c,c.$async)}function f(h){const g=aje(e,h);UN(e,g,h,h.$async)}function p(h){const g=t.scopeValue("schema",s.code.source===!0?{ref:h,code:(0,ss.stringify)(h)}:{ref:h}),v=t.name("valid"),y=e.subschema({schema:h,dataTypes:[],schemaPath:ss.nil,topSchemaRef:g,errSchemaPath:n},v);e.mergeEvaluated(y),e.ok(v)}}};function aje(e,t){const{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):(0,ss._)`${n.scopeValue("wrapper",{ref:t})}.validate`}Qv.getValidate=aje;function UN(e,t,n,r){const{gen:i,it:a}=e,{allErrors:o,schemaEnv:s,opts:l}=a,c=l.passContext?F0.default.this:ss.nil;r?u():d();function u(){if(!s.$async)throw new Error("async schema referenced by sync schema");const h=i.let("valid");i.try(()=>{i.code((0,ss._)`await ${(0,Uve.callValidateCode)(e,t,c)}`),p(t),o||i.assign(h,!0)},g=>{i.if((0,ss._)`!(${g} instanceof ${a.ValidationError})`,()=>i.throw(g)),f(g),o||i.assign(h,!1)}),e.ok(h)}function d(){e.result((0,Uve.callValidateCode)(e,t,c),()=>p(t),()=>f(t))}function f(h){const g=(0,ss._)`${h}.errors`;i.assign(F0.default.vErrors,(0,ss._)`${F0.default.vErrors} === null ? ${g} : ${F0.default.vErrors}.concat(${g})`),i.assign(F0.default.errors,(0,ss._)`${F0.default.vErrors}.length`)}function p(h){var g;if(!a.opts.unevaluated)return;const v=(g=n==null?void 0:n.validate)===null||g===void 0?void 0:g.evaluated;if(a.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(a.props=bP.mergeEvaluated.props(i,v.props,a.props));else{const y=i.var("props",(0,ss._)`${h}.evaluated.props`);a.props=bP.mergeEvaluated.props(i,y,a.props,ss.Name)}if(a.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(a.items=bP.mergeEvaluated.items(i,v.items,a.items));else{const y=i.var("items",(0,ss._)`${h}.evaluated.items`);a.items=bP.mergeEvaluated.items(i,y,a.items,ss.Name)}}}Qv.callRef=UN;Qv.default=Uqt;Object.defineProperty(wJ,"__esModule",{value:!0});const Gqt=SJ,qqt=Qv,Kqt=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Gqt.default,qqt.default];wJ.default=Kqt;var _J={},CJ={};Object.defineProperty(CJ,"__esModule",{value:!0});const eD=Wn,ap=eD.operators,tD={maximum:{okStr:"<=",ok:ap.LTE,fail:ap.GT},minimum:{okStr:">=",ok:ap.GTE,fail:ap.LT},exclusiveMaximum:{okStr:"<",ok:ap.LT,fail:ap.GTE},exclusiveMinimum:{okStr:">",ok:ap.GT,fail:ap.LTE}},Yqt={message:({keyword:e,schemaCode:t})=>(0,eD.str)`must be ${tD[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,eD._)`{comparison: ${tD[e].okStr}, limit: ${t}}`},Xqt={keyword:Object.keys(tD),type:"number",schemaType:"number",$data:!0,error:Yqt,code(e){const{keyword:t,data:n,schemaCode:r}=e;e.fail$data((0,eD._)`${n} ${tD[t].fail} ${r} || isNaN(${n})`)}};CJ.default=Xqt;var $J={};Object.defineProperty($J,"__esModule",{value:!0});const NC=Wn,Zqt={message:({schemaCode:e})=>(0,NC.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,NC._)`{multipleOf: ${e}}`},Qqt={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Zqt,code(e){const{gen:t,data:n,schemaCode:r,it:i}=e,a=i.opts.multipleOfPrecision,o=t.let("res"),s=a?(0,NC._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${a}`:(0,NC._)`${o} !== parseInt(${o})`;e.fail$data((0,NC._)`(${r} === 0 || (${o} = ${n}/${r}, ${s}))`)}};$J.default=Qqt;var EJ={},TJ={};Object.defineProperty(TJ,"__esModule",{value:!0});function oje(e){const t=e.length;let n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)===56320&&r++);return n}TJ.default=oje;oje.code='require("ajv/dist/runtime/ucs2length").default';Object.defineProperty(EJ,"__esModule",{value:!0});const lg=Wn,Jqt=zt,eKt=TJ,tKt={message({keyword:e,schemaCode:t}){const n=e==="maxLength"?"more":"fewer";return(0,lg.str)`must NOT have ${n} than ${t} characters`},params:({schemaCode:e})=>(0,lg._)`{limit: ${e}}`},nKt={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:tKt,code(e){const{keyword:t,data:n,schemaCode:r,it:i}=e,a=t==="maxLength"?lg.operators.GT:lg.operators.LT,o=i.opts.unicode===!1?(0,lg._)`${n}.length`:(0,lg._)`${(0,Jqt.useFunc)(e.gen,eKt.default)}(${n})`;e.fail$data((0,lg._)`${o} ${a} ${r}`)}};EJ.default=nKt;var IJ={};Object.defineProperty(IJ,"__esModule",{value:!0});const rKt=Xn,iKt=zt,Pb=Wn,aKt={message:({schemaCode:e})=>(0,Pb.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Pb._)`{pattern: ${e}}`},oKt={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:aKt,code(e){const{gen:t,data:n,$data:r,schema:i,schemaCode:a,it:o}=e,s=o.opts.unicodeRegExp?"u":"";if(r){const{regExp:l}=o.opts.code,c=l.code==="new RegExp"?(0,Pb._)`new RegExp`:(0,iKt.useFunc)(t,l),u=t.let("valid");t.try(()=>t.assign(u,(0,Pb._)`${c}(${a}, ${s}).test(${n})`),()=>t.assign(u,!1)),e.fail$data((0,Pb._)`!${u}`)}else{const l=(0,rKt.usePattern)(e,i);e.fail$data((0,Pb._)`!${l}.test(${n})`)}}};IJ.default=oKt;var kJ={};Object.defineProperty(kJ,"__esModule",{value:!0});const AC=Wn,sKt={message({keyword:e,schemaCode:t}){const n=e==="maxProperties"?"more":"fewer";return(0,AC.str)`must NOT have ${n} than ${t} properties`},params:({schemaCode:e})=>(0,AC._)`{limit: ${e}}`},lKt={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:sKt,code(e){const{keyword:t,data:n,schemaCode:r}=e,i=t==="maxProperties"?AC.operators.GT:AC.operators.LT;e.fail$data((0,AC._)`Object.keys(${n}).length ${i} ${r}`)}};kJ.default=lKt;var PJ={};Object.defineProperty(PJ,"__esModule",{value:!0});const WS=Xn,MC=Wn,cKt=zt,uKt={message:({params:{missingProperty:e}})=>(0,MC.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,MC._)`{missingProperty: ${e}}`},dKt={keyword:"required",type:"object",schemaType:"array",$data:!0,error:uKt,code(e){const{gen:t,schema:n,schemaCode:r,data:i,$data:a,it:o}=e,{opts:s}=o;if(!a&&n.length===0)return;const l=n.length>=s.loopRequired;if(o.allErrors?c():u(),s.strictRequired){const p=e.parentSchema.properties,{definedProperties:h}=e.it;for(const g of n)if((p==null?void 0:p[g])===void 0&&!h.has(g)){const v=o.schemaEnv.baseId+o.errSchemaPath,y=`required property "${g}" is not defined at "${v}" (strictRequired)`;(0,cKt.checkStrictMode)(o,y,o.opts.strictRequired)}}function c(){if(l||a)e.block$data(MC.nil,d);else for(const p of n)(0,WS.checkReportMissingProp)(e,p)}function u(){const p=t.let("missing");if(l||a){const h=t.let("valid",!0);e.block$data(h,()=>f(p,h)),e.ok(h)}else t.if((0,WS.checkMissingProp)(e,n,p)),(0,WS.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",r,p=>{e.setParams({missingProperty:p}),t.if((0,WS.noPropertyInData)(t,i,p,s.ownProperties),()=>e.error())})}function f(p,h){e.setParams({missingProperty:p}),t.forOf(p,r,()=>{t.assign(h,(0,WS.propertyInData)(t,i,p,s.ownProperties)),t.if((0,MC.not)(h),()=>{e.error(),t.break()})},MC.nil)}}};PJ.default=dKt;var NJ={};Object.defineProperty(NJ,"__esModule",{value:!0});const RC=Wn,fKt={message({keyword:e,schemaCode:t}){const n=e==="maxItems"?"more":"fewer";return(0,RC.str)`must NOT have ${n} than ${t} items`},params:({schemaCode:e})=>(0,RC._)`{limit: ${e}}`},pKt={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:fKt,code(e){const{keyword:t,data:n,schemaCode:r}=e,i=t==="maxItems"?RC.operators.GT:RC.operators.LT;e.fail$data((0,RC._)`${n}.length ${i} ${r}`)}};NJ.default=pKt;var AJ={},xT={};Object.defineProperty(xT,"__esModule",{value:!0});const sje=TLe;sje.code='require("ajv/dist/runtime/equal").default';xT.default=sje;Object.defineProperty(AJ,"__esModule",{value:!0});const X6=la,La=Wn,hKt=zt,mKt=xT,gKt={message:({params:{i:e,j:t}})=>(0,La.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,La._)`{i: ${e}, j: ${t}}`},vKt={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:gKt,code(e){const{gen:t,data:n,$data:r,schema:i,parentSchema:a,schemaCode:o,it:s}=e;if(!r&&!i)return;const l=t.let("valid"),c=a.items?(0,X6.getSchemaTypes)(a.items):[];e.block$data(l,u,(0,La._)`${o} === false`),e.ok(l);function u(){const h=t.let("i",(0,La._)`${n}.length`),g=t.let("j");e.setParams({i:h,j:g}),t.assign(l,!0),t.if((0,La._)`${h} > 1`,()=>(d()?f:p)(h,g))}function d(){return c.length>0&&!c.some(h=>h==="object"||h==="array")}function f(h,g){const v=t.name("item"),y=(0,X6.checkDataTypes)(c,v,s.opts.strictNumbers,X6.DataType.Wrong),x=t.const("indices",(0,La._)`{}`);t.for((0,La._)`;${h}--;`,()=>{t.let(v,(0,La._)`${n}[${h}]`),t.if(y,(0,La._)`continue`),c.length>1&&t.if((0,La._)`typeof ${v} == "string"`,(0,La._)`${v} += "_"`),t.if((0,La._)`typeof ${x}[${v}] == "number"`,()=>{t.assign(g,(0,La._)`${x}[${v}]`),e.error(),t.assign(l,!1).break()}).code((0,La._)`${x}[${v}] = ${h}`)})}function p(h,g){const v=(0,hKt.useFunc)(t,mKt.default),y=t.name("outer");t.label(y).for((0,La._)`;${h}--;`,()=>t.for((0,La._)`${g} = ${h}; ${g}--;`,()=>t.if((0,La._)`${v}(${n}[${h}], ${n}[${g}])`,()=>{e.error(),t.assign(l,!1).break(y)})))}}};AJ.default=vKt;var MJ={};Object.defineProperty(MJ,"__esModule",{value:!0});const FU=Wn,yKt=zt,bKt=xT,xKt={message:"must be equal to constant",params:({schemaCode:e})=>(0,FU._)`{allowedValue: ${e}}`},wKt={keyword:"const",$data:!0,error:xKt,code(e){const{gen:t,data:n,$data:r,schemaCode:i,schema:a}=e;r||a&&typeof a=="object"?e.fail$data((0,FU._)`!${(0,yKt.useFunc)(t,bKt.default)}(${n}, ${i})`):e.fail((0,FU._)`${a} !== ${n}`)}};MJ.default=wKt;var RJ={};Object.defineProperty(RJ,"__esModule",{value:!0});const T_=Wn,SKt=zt,_Kt=xT,CKt={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,T_._)`{allowedValues: ${e}}`},$Kt={keyword:"enum",schemaType:"array",$data:!0,error:CKt,code(e){const{gen:t,data:n,$data:r,schema:i,schemaCode:a,it:o}=e;if(!r&&i.length===0)throw new Error("enum must have non-empty array");const s=i.length>=o.opts.loopEnum;let l;const c=()=>l??(l=(0,SKt.useFunc)(t,_Kt.default));let u;if(s||r)u=t.let("valid"),e.block$data(u,d);else{if(!Array.isArray(i))throw new Error("ajv implementation error");const p=t.const("vSchema",a);u=(0,T_.or)(...i.map((h,g)=>f(p,g)))}e.pass(u);function d(){t.assign(u,!1),t.forOf("v",a,p=>t.if((0,T_._)`${c()}(${n}, ${p})`,()=>t.assign(u,!0).break()))}function f(p,h){const g=i[h];return typeof g=="object"&&g!==null?(0,T_._)`${c()}(${n}, ${p}[${h}])`:(0,T_._)`${n} === ${g}`}}};RJ.default=$Kt;Object.defineProperty(_J,"__esModule",{value:!0});const EKt=CJ,TKt=$J,IKt=EJ,kKt=IJ,PKt=kJ,NKt=PJ,AKt=NJ,MKt=AJ,RKt=MJ,DKt=RJ,OKt=[EKt.default,TKt.default,IKt.default,kKt.default,PKt.default,NKt.default,AKt.default,MKt.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},RKt.default,DKt.default];_J.default=OKt;var DJ={},Nw={};Object.defineProperty(Nw,"__esModule",{value:!0});Nw.validateAdditionalItems=void 0;const cg=Wn,BU=zt,LKt={message:({params:{len:e}})=>(0,cg.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,cg._)`{limit: ${e}}`},jKt={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:LKt,code(e){const{parentSchema:t,it:n}=e,{items:r}=t;if(!Array.isArray(r)){(0,BU.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas');return}lje(e,r)}};function lje(e,t){const{gen:n,schema:r,data:i,keyword:a,it:o}=e;o.items=!0;const s=n.const("len",(0,cg._)`${i}.length`);if(r===!1)e.setParams({len:t.length}),e.pass((0,cg._)`${s} <= ${t.length}`);else if(typeof r=="object"&&!(0,BU.alwaysValidSchema)(o,r)){const c=n.var("valid",(0,cg._)`${s} <= ${t.length}`);n.if((0,cg.not)(c),()=>l(c)),e.ok(c)}function l(c){n.forRange("i",t.length,s,u=>{e.subschema({keyword:a,dataProp:u,dataPropType:BU.Type.Num},c),o.allErrors||n.if((0,cg.not)(c),()=>n.break())})}}Nw.validateAdditionalItems=lje;Nw.default=jKt;var OJ={},Aw={};Object.defineProperty(Aw,"__esModule",{value:!0});Aw.validateTuple=void 0;const qve=Wn,GN=zt,zKt=Xn,FKt={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:n}=e;if(Array.isArray(t))return cje(e,"additionalItems",t);n.items=!0,!(0,GN.alwaysValidSchema)(n,t)&&e.ok((0,zKt.validateArray)(e))}};function cje(e,t,n=e.schema){const{gen:r,parentSchema:i,data:a,keyword:o,it:s}=e;u(i),s.opts.unevaluated&&n.length&&s.items!==!0&&(s.items=GN.mergeEvaluated.items(r,n.length,s.items));const l=r.name("valid"),c=r.const("len",(0,qve._)`${a}.length`);n.forEach((d,f)=>{(0,GN.alwaysValidSchema)(s,d)||(r.if((0,qve._)`${c} > ${f}`,()=>e.subschema({keyword:o,schemaProp:f,dataProp:f},l)),e.ok(l))});function u(d){const{opts:f,errSchemaPath:p}=s,h=n.length,g=h===d.minItems&&(h===d.maxItems||d[t]===!1);if(f.strictTuples&&!g){const v=`"${o}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,GN.checkStrictMode)(s,v,f.strictTuples)}}}Aw.validateTuple=cje;Aw.default=FKt;Object.defineProperty(OJ,"__esModule",{value:!0});const BKt=Aw,VKt={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,BKt.validateTuple)(e,"items")};OJ.default=VKt;var LJ={};Object.defineProperty(LJ,"__esModule",{value:!0});const Kve=Wn,HKt=zt,WKt=Xn,UKt=Nw,GKt={message:({params:{len:e}})=>(0,Kve.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Kve._)`{limit: ${e}}`},qKt={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:GKt,code(e){const{schema:t,parentSchema:n,it:r}=e,{prefixItems:i}=n;r.items=!0,!(0,HKt.alwaysValidSchema)(r,t)&&(i?(0,UKt.validateAdditionalItems)(e,i):e.ok((0,WKt.validateArray)(e)))}};LJ.default=qKt;var jJ={};Object.defineProperty(jJ,"__esModule",{value:!0});const wl=Wn,xP=zt,KKt={message:({params:{min:e,max:t}})=>t===void 0?(0,wl.str)`must contain at least ${e} valid item(s)`:(0,wl.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,wl._)`{minContains: ${e}}`:(0,wl._)`{minContains: ${e}, maxContains: ${t}}`},YKt={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:KKt,code(e){const{gen:t,schema:n,parentSchema:r,data:i,it:a}=e;let o,s;const{minContains:l,maxContains:c}=r;a.opts.next?(o=l===void 0?1:l,s=c):o=1;const u=t.const("len",(0,wl._)`${i}.length`);if(e.setParams({min:o,max:s}),s===void 0&&o===0){(0,xP.checkStrictMode)(a,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(s!==void 0&&o>s){(0,xP.checkStrictMode)(a,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,xP.alwaysValidSchema)(a,n)){let g=(0,wl._)`${u} >= ${o}`;s!==void 0&&(g=(0,wl._)`${g} && ${u} <= ${s}`),e.pass(g);return}a.items=!0;const d=t.name("valid");s===void 0&&o===1?p(d,()=>t.if(d,()=>t.break())):o===0?(t.let(d,!0),s!==void 0&&t.if((0,wl._)`${i}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){const g=t.name("_valid"),v=t.let("count",0);p(g,()=>t.if(g,()=>h(v)))}function p(g,v){t.forRange("i",0,u,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:xP.Type.Num,compositeRule:!0},g),v()})}function h(g){t.code((0,wl._)`${g}++`),s===void 0?t.if((0,wl._)`${g} >= ${o}`,()=>t.assign(d,!0).break()):(t.if((0,wl._)`${g} > ${s}`,()=>t.assign(d,!1).break()),o===1?t.assign(d,!0):t.if((0,wl._)`${g} >= ${o}`,()=>t.assign(d,!0)))}}};jJ.default=YKt;var uje={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=Wn,n=zt,r=Xn;e.error={message:({params:{property:l,depsCount:c,deps:u}})=>{const d=c===1?"property":"properties";return(0,t.str)`must have ${d} ${u} when property ${l} is present`},params:({params:{property:l,depsCount:c,deps:u,missingProperty:d}})=>(0,t._)`{property: ${l},
|
|
786
786
|
missingProperty: ${d},
|
|
787
787
|
depsCount: ${c},
|
|
788
|
-
deps: ${u}}`};const i={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(l){const[c,u]=a(l);o(l,c),s(l,u)}};function a({schema:l}){const c={},u={};for(const d in l){if(d==="__proto__")continue;const f=Array.isArray(l[d])?c:u;f[d]=l[d]}return[c,u]}function o(l,c=l.schema){const{gen:u,data:d,it:f}=l;if(Object.keys(c).length===0)return;const p=u.let("missing");for(const h in c){const g=c[h];if(g.length===0)continue;const v=(0,r.propertyInData)(u,d,h,f.opts.ownProperties);l.setParams({property:h,depsCount:g.length,deps:g.join(", ")}),f.allErrors?u.if(v,()=>{for(const y of g)(0,r.checkReportMissingProp)(l,y)}):(u.if((0,t._)`${v} && (${(0,r.checkMissingProp)(l,g,p)})`),(0,r.reportMissingProp)(l,p),u.else())}}e.validatePropertyDeps=o;function s(l,c=l.schema){const{gen:u,data:d,keyword:f,it:p}=l,h=u.name("valid");for(const g in c)(0,n.alwaysValidSchema)(p,c[g])||(u.if((0,r.propertyInData)(u,d,g,p.opts.ownProperties),()=>{const v=l.subschema({keyword:f,schemaProp:g},h);l.mergeValidEvaluated(v,h)},()=>u.var(h,!0)),l.ok(h))}e.validateSchemaDeps=s,e.default=i})(uje);var zJ={};Object.defineProperty(zJ,"__esModule",{value:!0});const dje=Wn,ZKt=zt,QKt={message:"property name must be valid",params:({params:e})=>(0,dje._)`{propertyName: ${e.propertyName}}`},JKt={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:QKt,code(e){const{gen:t,schema:n,data:r,it:i}=e;if((0,ZKt.alwaysValidSchema)(i,n))return;const a=t.name("valid");t.forIn("key",r,o=>{e.setParams({propertyName:o}),e.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},a),t.if((0,dje.not)(a),()=>{e.error(!0),i.allErrors||t.break()})}),e.ok(a)}};zJ.default=JKt;var pj={};Object.defineProperty(pj,"__esModule",{value:!0});const wP=Xn,uc=Wn,eYt=cd,SP=zt,tYt={message:"must NOT have additional properties",params:({params:e})=>(0,uc._)`{additionalProperty: ${e.additionalProperty}}`},nYt={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:tYt,code(e){const{gen:t,schema:n,parentSchema:r,data:i,errsCount:a,it:o}=e;if(!a)throw new Error("ajv implementation error");const{allErrors:s,opts:l}=o;if(o.props=!0,l.removeAdditional!=="all"&&(0,SP.alwaysValidSchema)(o,n))return;const c=(0,wP.allSchemaProperties)(r.properties),u=(0,wP.allSchemaProperties)(r.patternProperties);d(),e.ok((0,uc._)`${a} === ${eYt.default.errors}`);function d(){t.forIn("key",i,v=>{!c.length&&!u.length?h(v):t.if(f(v),()=>h(v))})}function f(v){let y;if(c.length>8){const x=(0,SP.schemaRefOrVal)(o,r.properties,"properties");y=(0,wP.isOwnProperty)(t,x,v)}else c.length?y=(0,uc.or)(...c.map(x=>(0,uc._)`${v} === ${x}`)):y=uc.nil;return u.length&&(y=(0,uc.or)(y,...u.map(x=>(0,uc._)`${(0,wP.usePattern)(e,x)}.test(${v})`))),(0,uc.not)(y)}function p(v){t.code((0,uc._)`delete ${i}[${v}]`)}function h(v){if(l.removeAdditional==="all"||l.removeAdditional&&n===!1){p(v);return}if(n===!1){e.setParams({additionalProperty:v}),e.error(),s||t.break();return}if(typeof n=="object"&&!(0,SP.alwaysValidSchema)(o,n)){const y=t.name("valid");l.removeAdditional==="failing"?(g(v,y,!1),t.if((0,uc.not)(y),()=>{e.reset(),p(v)})):(g(v,y),s||t.if((0,uc.not)(y),()=>t.break()))}}function g(v,y,x){const w={keyword:"additionalProperties",dataProp:v,dataPropType:SP.Type.Str};x===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(w,y)}}};pj.default=nYt;var FJ={};Object.defineProperty(FJ,"__esModule",{value:!0});const rYt=Mc,Yve=Xn,Z6=zt,Xve=pj,iYt={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,parentSchema:r,data:i,it:a}=e;a.opts.removeAdditional==="all"&&r.additionalProperties===void 0&&Xve.default.code(new rYt.KeywordCxt(a,Xve.default,"additionalProperties"));const o=(0,Yve.allSchemaProperties)(n);for(const d of o)a.definedProperties.add(d);a.opts.unevaluated&&o.length&&a.props!==!0&&(a.props=Z6.mergeEvaluated.props(t,(0,Z6.toHash)(o),a.props));const s=o.filter(d=>!(0,Z6.alwaysValidSchema)(a,n[d]));if(s.length===0)return;const l=t.name("valid");for(const d of s)c(d)?u(d):(t.if((0,Yve.propertyInData)(t,i,d,a.opts.ownProperties)),u(d),a.allErrors||t.else().var(l,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(l);function c(d){return a.opts.useDefaults&&!a.compositeRule&&n[d].default!==void 0}function u(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},l)}}};FJ.default=iYt;var BJ={};Object.defineProperty(BJ,"__esModule",{value:!0});const Zve=Xn,_P=Wn,Qve=zt,Jve=zt,aYt={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,data:r,parentSchema:i,it:a}=e,{opts:o}=a,s=(0,Zve.allSchemaProperties)(n),l=s.filter(g=>(0,Qve.alwaysValidSchema)(a,n[g]));if(s.length===0||l.length===s.length&&(!a.opts.unevaluated||a.props===!0))return;const c=o.strictSchema&&!o.allowMatchingProperties&&i.properties,u=t.name("valid");a.props!==!0&&!(a.props instanceof _P.Name)&&(a.props=(0,Jve.evaluatedPropsToName)(t,a.props));const{props:d}=a;f();function f(){for(const g of s)c&&p(g),a.allErrors?h(g):(t.var(u,!0),h(g),t.if(u))}function p(g){for(const v in c)new RegExp(g).test(v)&&(0,Qve.checkStrictMode)(a,`property ${v} matches pattern ${g} (use allowMatchingProperties)`)}function h(g){t.forIn("key",r,v=>{t.if((0,_P._)`${(0,Zve.usePattern)(e,g)}.test(${v})`,()=>{const y=l.includes(g);y||e.subschema({keyword:"patternProperties",schemaProp:g,dataProp:v,dataPropType:Jve.Type.Str},u),a.opts.unevaluated&&d!==!0?t.assign((0,_P._)`${d}[${v}]`,!0):!y&&!a.allErrors&&t.if((0,_P.not)(u),()=>t.break())})})}}};BJ.default=aYt;var VJ={};Object.defineProperty(VJ,"__esModule",{value:!0});const oYt=zt,sYt={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:n,it:r}=e;if((0,oYt.alwaysValidSchema)(r,n)){e.fail();return}const i=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),e.failResult(i,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};VJ.default=sYt;var HJ={};Object.defineProperty(HJ,"__esModule",{value:!0});const lYt=Xn,cYt={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:lYt.validateUnion,error:{message:"must match a schema in anyOf"}};HJ.default=cYt;var WJ={};Object.defineProperty(WJ,"__esModule",{value:!0});const qN=Wn,uYt=zt,dYt={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,qN._)`{passingSchemas: ${e.passing}}`},fYt={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:dYt,code(e){const{gen:t,schema:n,parentSchema:r,it:i}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(i.opts.discriminator&&r.discriminator)return;const a=n,o=t.let("valid",!1),s=t.let("passing",null),l=t.name("_valid");e.setParams({passing:s}),t.block(c),e.result(o,()=>e.reset(),()=>e.error(!0));function c(){a.forEach((u,d)=>{let f;(0,uYt.alwaysValidSchema)(i,u)?t.var(l,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},l),d>0&&t.if((0,qN._)`${l} && ${o}`).assign(o,!1).assign(s,(0,qN._)`[${s}, ${d}]`).else(),t.if(l,()=>{t.assign(o,!0),t.assign(s,d),f&&e.mergeEvaluated(f,qN.Name)})})}}};WJ.default=fYt;var UJ={};Object.defineProperty(UJ,"__esModule",{value:!0});const pYt=zt,hYt={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:n,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");const i=t.name("valid");n.forEach((a,o)=>{if((0,pYt.alwaysValidSchema)(r,a))return;const s=e.subschema({keyword:"allOf",schemaProp:o},i);e.ok(i),e.mergeEvaluated(s)})}};UJ.default=hYt;var GJ={};Object.defineProperty(GJ,"__esModule",{value:!0});const nD=Wn,fje=zt,mYt={message:({params:e})=>(0,nD.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,nD._)`{failingKeyword: ${e.ifClause}}`},gYt={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:mYt,code(e){const{gen:t,parentSchema:n,it:r}=e;n.then===void 0&&n.else===void 0&&(0,fje.checkStrictMode)(r,'"if" without "then" and "else" is ignored');const i=eye(r,"then"),a=eye(r,"else");if(!i&&!a)return;const o=t.let("valid",!0),s=t.name("_valid");if(l(),e.reset(),i&&a){const u=t.let("ifClause");e.setParams({ifClause:u}),t.if(s,c("then",u),c("else",u))}else i?t.if(s,c("then")):t.if((0,nD.not)(s),c("else"));e.pass(o,()=>e.error(!0));function l(){const u=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},s);e.mergeEvaluated(u)}function c(u,d){return()=>{const f=e.subschema({keyword:u},s);t.assign(o,s),e.mergeValidEvaluated(f,o),d?t.assign(d,(0,nD._)`${u}`):e.setParams({ifClause:u})}}}};function eye(e,t){const n=e.schema[t];return n!==void 0&&!(0,fje.alwaysValidSchema)(e,n)}GJ.default=gYt;var qJ={};Object.defineProperty(qJ,"__esModule",{value:!0});const vYt=zt,yYt={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){t.if===void 0&&(0,vYt.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};qJ.default=yYt;Object.defineProperty(DJ,"__esModule",{value:!0});const bYt=Nw,xYt=OJ,wYt=Aw,SYt=LJ,_Yt=jJ,CYt=uje,$Yt=zJ,EYt=pj,TYt=FJ,IYt=BJ,kYt=VJ,PYt=HJ,NYt=WJ,AYt=UJ,MYt=GJ,RYt=qJ;function DYt(e=!1){const t=[kYt.default,PYt.default,NYt.default,AYt.default,MYt.default,RYt.default,$Yt.default,EYt.default,CYt.default,TYt.default,IYt.default];return e?t.push(xYt.default,SYt.default):t.push(bYt.default,wYt.default),t.push(_Yt.default),t}DJ.default=DYt;var KJ={},YJ={};Object.defineProperty(YJ,"__esModule",{value:!0});const ki=Wn,OYt={message:({schemaCode:e})=>(0,ki.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ki._)`{format: ${e}}`},LYt={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:OYt,code(e,t){const{gen:n,data:r,$data:i,schema:a,schemaCode:o,it:s}=e,{opts:l,errSchemaPath:c,schemaEnv:u,self:d}=s;if(!l.validateFormats)return;i?f():p();function f(){const h=n.scopeValue("formats",{ref:d.formats,code:l.code.formats}),g=n.const("fDef",(0,ki._)`${h}[${o}]`),v=n.let("fType"),y=n.let("format");n.if((0,ki._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>n.assign(v,(0,ki._)`${g}.type || "string"`).assign(y,(0,ki._)`${g}.validate`),()=>n.assign(v,(0,ki._)`"string"`).assign(y,g)),e.fail$data((0,ki.or)(x(),w()));function x(){return l.strictSchema===!1?ki.nil:(0,ki._)`${o} && !${y}`}function w(){const S=u.$async?(0,ki._)`(${g}.async ? await ${y}(${r}) : ${y}(${r}))`:(0,ki._)`${y}(${r})`,_=(0,ki._)`(typeof ${y} == "function" ? ${S} : ${y}.test(${r}))`;return(0,ki._)`${y} && ${y} !== true && ${v} === ${t} && !${_}`}}function p(){const h=d.formats[a];if(!h){x();return}if(h===!0)return;const[g,v,y]=w(h);g===t&&e.pass(S());function x(){if(l.strictSchema===!1){d.logger.warn(_());return}throw new Error(_());function _(){return`unknown format "${a}" ignored in schema at path "${c}"`}}function w(_){const C=_ instanceof RegExp?(0,ki.regexpCode)(_):l.code.formats?(0,ki._)`${l.code.formats}${(0,ki.getProperty)(a)}`:void 0,$=n.scopeValue("formats",{key:a,ref:_,code:C});return typeof _=="object"&&!(_ instanceof RegExp)?[_.type||"string",_.validate,(0,ki._)`${$}.validate`]:["string",_,$]}function S(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!u.$async)throw new Error("async format in sync schema");return(0,ki._)`await ${y}(${r})`}return typeof v=="function"?(0,ki._)`${y}(${r})`:(0,ki._)`${y}.test(${r})`}}}};YJ.default=LYt;Object.defineProperty(KJ,"__esModule",{value:!0});const jYt=YJ,zYt=[jYt.default];KJ.default=zYt;var $1={};Object.defineProperty($1,"__esModule",{value:!0});$1.contentVocabulary=$1.metadataVocabulary=void 0;$1.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];$1.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(xJ,"__esModule",{value:!0});const FYt=wJ,BYt=_J,VYt=DJ,HYt=KJ,tye=$1,WYt=[FYt.default,BYt.default,(0,VYt.default)(),HYt.default,tye.metadataVocabulary,tye.contentVocabulary];xJ.default=WYt;var XJ={},hj={};Object.defineProperty(hj,"__esModule",{value:!0});hj.DiscrError=void 0;var nye;(function(e){e.Tag="tag",e.Mapping="mapping"})(nye||(hj.DiscrError=nye={}));Object.defineProperty(XJ,"__esModule",{value:!0});const X0=Wn,VU=hj,rye=vs,UYt=Pw,GYt=zt,qYt={message:({params:{discrError:e,tagName:t}})=>e===VU.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>(0,X0._)`{error: ${e}, tag: ${n}, tagValue: ${t}}`},KYt={keyword:"discriminator",type:"object",schemaType:"object",error:qYt,code(e){const{gen:t,data:n,schema:r,parentSchema:i,it:a}=e,{oneOf:o}=i;if(!a.opts.discriminator)throw new Error("discriminator: requires discriminator option");const s=r.propertyName;if(typeof s!="string")throw new Error("discriminator: requires propertyName");if(r.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");const l=t.let("valid",!1),c=t.const("tag",(0,X0._)`${n}${(0,X0.getProperty)(s)}`);t.if((0,X0._)`typeof ${c} == "string"`,()=>u(),()=>e.error(!1,{discrError:VU.DiscrError.Tag,tag:c,tagName:s})),e.ok(l);function u(){const p=f();t.if(!1);for(const h in p)t.elseIf((0,X0._)`${c} === ${h}`),t.assign(l,d(p[h]));t.else(),e.error(!1,{discrError:VU.DiscrError.Mapping,tag:c,tagName:s}),t.endIf()}function d(p){const h=t.name("valid"),g=e.subschema({keyword:"oneOf",schemaProp:p},h);return e.mergeEvaluated(g,X0.Name),h}function f(){var p;const h={},g=y(i);let v=!0;for(let S=0;S<o.length;S++){let _=o[S];if(_!=null&&_.$ref&&!(0,GYt.schemaHasRulesButRef)(_,a.self.RULES)){const $=_.$ref;if(_=rye.resolveRef.call(a.self,a.schemaEnv.root,a.baseId,$),_ instanceof rye.SchemaEnv&&(_=_.schema),_===void 0)throw new UYt.default(a.opts.uriResolver,a.baseId,$)}const C=(p=_==null?void 0:_.properties)===null||p===void 0?void 0:p[s];if(typeof C!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${s}"`);v=v&&(g||y(_)),x(C,S)}if(!v)throw new Error(`discriminator: "${s}" must be required`);return h;function y({required:S}){return Array.isArray(S)&&S.includes(s)}function x(S,_){if(S.const)w(S.const,_);else if(S.enum)for(const C of S.enum)w(C,_);else throw new Error(`discriminator: "properties/${s}" must have "const" or "enum"`)}function w(S,_){if(typeof S!="string"||S in h)throw new Error(`discriminator: "${s}" values must be unique strings`);h[S]=_}}}};XJ.default=KYt;const YYt="http://json-schema.org/draft-07/schema#",XYt="http://json-schema.org/draft-07/schema#",ZYt="Core schema meta-schema",QYt={schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},JYt=["object","boolean"],eXt={$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},tXt={$schema:YYt,$id:XYt,title:ZYt,definitions:QYt,type:JYt,properties:eXt,default:!0};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const n=dLe,r=xJ,i=XJ,a=tXt,o=["/properties"],s="http://json-schema.org/draft-07/schema";class l extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(h=>this.addVocabulary(h)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const h=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(h,s,!1),this.refs["http://json-schema.org/schema"]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}}t.Ajv=l,e.exports=t=l,e.exports.Ajv=l,Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var c=Mc;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var u=Wn;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=bT;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return d.default}});var f=Pw;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return f.default}})})(DU,DU.exports);var pje=DU.exports;const hje=Co(pje);var HU={exports:{}},mje={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(I,P){return{validate:I,compare:P}}e.fullFormats={date:t(a,o),time:t(l(!0),c),"date-time":t(f(!0),p),"iso-time":t(l(),u),"iso-date-time":t(f(),h),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:y,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:T,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:w,int32:{type:"number",validate:C},int64:{type:"number",validate:$},float:{type:"number",validate:E},double:{type:"number",validate:E},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,c),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,h),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(I){return I%4===0&&(I%100!==0||I%400===0)}const r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(I){const P=r.exec(I);if(!P)return!1;const N=+P[1],A=+P[2],M=+P[3];return A>=1&&A<=12&&M>=1&&M<=(A===2&&n(N)?29:i[A])}function o(I,P){if(I&&P)return I>P?1:I<P?-1:0}const s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function l(I){return function(N){const A=s.exec(N);if(!A)return!1;const M=+A[1],R=+A[2],L=+A[3],z=A[4],j=A[5]==="-"?-1:1,O=+(A[6]||0),V=+(A[7]||0);if(O>23||V>59||I&&!z)return!1;if(M<=23&&R<=59&&L<60)return!0;const B=R-V*j,D=M-O*j-(B<0?1:0);return(D===23||D===-1)&&(B===59||B===-1)&&L<61}}function c(I,P){if(!(I&&P))return;const N=new Date("2020-01-01T"+I).valueOf(),A=new Date("2020-01-01T"+P).valueOf();if(N&&A)return N-A}function u(I,P){if(!(I&&P))return;const N=s.exec(I),A=s.exec(P);if(N&&A)return I=N[1]+N[2]+N[3],P=A[1]+A[2]+A[3],I>P?1:I<P?-1:0}const d=/t|\s/i;function f(I){const P=l(I);return function(A){const M=A.split(d);return M.length===2&&a(M[0])&&P(M[1])}}function p(I,P){if(!(I&&P))return;const N=new Date(I).valueOf(),A=new Date(P).valueOf();if(N&&A)return N-A}function h(I,P){if(!(I&&P))return;const[N,A]=I.split(d),[M,R]=P.split(d),L=o(N,M);if(L!==void 0)return L||c(A,R)}const g=/\/|:/,v=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function y(I){return g.test(I)&&v.test(I)}const x=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function w(I){return x.lastIndex=0,x.test(I)}const S=-2147483648,_=2**31-1;function C(I){return Number.isInteger(I)&&I<=_&&I>=S}function $(I){return Number.isInteger(I)}function E(){return!0}const k=/[^\\]\\Z/;function T(I){if(k.test(I))return!1;try{return new RegExp(I),!0}catch{return!1}}})(mje);var gje={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=pje,n=Wn,r=n.operators,i={formatMaximum:{okStr:"<=",ok:r.LTE,fail:r.GT},formatMinimum:{okStr:">=",ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:"<",ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:">",ok:r.GT,fail:r.LTE}},a={message:({keyword:s,schemaCode:l})=>(0,n.str)`should be ${i[s].okStr} ${l}`,params:({keyword:s,schemaCode:l})=>(0,n._)`{comparison: ${i[s].okStr}, limit: ${l}}`};e.formatLimitDefinition={keyword:Object.keys(i),type:"string",schemaType:"string",$data:!0,error:a,code(s){const{gen:l,data:c,schemaCode:u,keyword:d,it:f}=s,{opts:p,self:h}=f;if(!p.validateFormats)return;const g=new t.KeywordCxt(f,h.RULES.all.format.definition,"format");g.$data?v():y();function v(){const w=l.scopeValue("formats",{ref:h.formats,code:p.code.formats}),S=l.const("fmt",(0,n._)`${w}[${g.schemaCode}]`);s.fail$data((0,n.or)((0,n._)`typeof ${S} != "object"`,(0,n._)`${S} instanceof RegExp`,(0,n._)`typeof ${S}.compare != "function"`,x(S)))}function y(){const w=g.schema,S=h.formats[w];if(!S||S===!0)return;if(typeof S!="object"||S instanceof RegExp||typeof S.compare!="function")throw new Error(`"${d}": format "${w}" does not define "compare" function`);const _=l.scopeValue("formats",{key:w,ref:S,code:p.code.formats?(0,n._)`${p.code.formats}${(0,n.getProperty)(w)}`:void 0});s.fail$data(x(_))}function x(w){return(0,n._)`${w}.compare(${c}, ${u}) ${i[d].fail} 0`}},dependencies:["format"]};const o=s=>(s.addKeyword(e.formatLimitDefinition),s);e.default=o})(gje);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n=mje,r=gje,i=Wn,a=new i.Name("fullFormats"),o=new i.Name("fastFormats"),s=(c,u={keywords:!0})=>{if(Array.isArray(u))return l(c,u,n.fullFormats,a),c;const[d,f]=u.mode==="fast"?[n.fastFormats,o]:[n.fullFormats,a],p=u.formats||n.formatNames;return l(c,p,d,f),u.keywords&&(0,r.default)(c),c};s.get=(c,u="full")=>{const f=(u==="fast"?n.fastFormats:n.fullFormats)[c];if(!f)throw new Error(`Unknown format "${c}"`);return f};function l(c,u,d,f){var p,h;(p=(h=c.opts.code).formats)!==null&&p!==void 0||(h.formats=(0,i._)`require("ajv-formats/dist/formats").${f}`);for(const g of u)c.addFormat(g,d[g])}e.exports=t=s,Object.defineProperty(t,"__esModule",{value:!0}),t.default=s})(HU,HU.exports);var nXt=HU.exports;const vje=Co(nXt),iye=new WeakMap;function rXt(e){const t=iye.get(e);if(t)return t;const n=new hje({allErrors:!0,strict:!1,validateSchema:!1,multipleOfPrecision:8});vje(n);const{$schema:r,...i}=e,a=n.compile(i);return iye.set(e,a),a}function iXt(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function aXt(e){return e.split("/").slice(1).map(iXt).join(".")}function oXt(e){const t=e.params;return typeof t.missingProperty=="string"?t.missingProperty:""}function sXt(e,t){const n=t.split(".").filter(Boolean);let r=e;for(const i of n){if(!Ut(r))return{};if(typeof r.$ref=="string"&&(r=iJ(e,r.$ref)),!Ut(r))return{};if((r.type==="array"||/^\d+$/.test(i))&&(r=r.items,/^\d+$/.test(i)))continue;if(!Ut(r))return{};r=(Ut(r.properties)?r.properties:{})[i]}return Ut(r)?r:{}}function lXt(e){const t=aXt(e.instancePath);if(e.keyword!=="required")return t;const n=oXt(e);return[t,n].filter(Boolean).join(".")}function cXt(e,t,n){const r=sXt(t,n),i=n.split("."),a=i[i.length-1]||"字段",o=XR(a,r);return e.keyword==="required"?`请输入${o}`:e.keyword==="enum"?`${o}不在可选范围内`:e.keyword==="format"||e.keyword==="pattern"?`${o}格式不正确`:e.keyword==="type"?`${o}类型不正确`:e.keyword==="minLength"?`${o}长度不足`:e.keyword==="maxLength"?`${o}长度超出限制`:e.keyword==="minimum"||e.keyword==="exclusiveMinimum"?`${o}数值过小`:e.keyword==="maximum"||e.keyword==="exclusiveMaximum"?`${o}数值过大`:e.keyword==="multipleOf"?`${o}数值不符合步进要求`:e.keyword==="minItems"?`${o}数量不足`:e.keyword==="maxItems"?`${o}数量超出限制`:e.keyword==="not"?`${o}与当前条件组合冲突`:`${o}不符合规则`}function aye(e,t,n=t){const r=YR(e,t),i=KR(e,r,e,n),a=Ut(i)?i:t;try{const o=rXt(e);if(o(a))return{valid:!0,errors:{},value:a};const l={};for(const c of o.errors||[]){if(c.keyword==="if"||c.keyword==="additionalProperties")continue;const u=lXt(c);!u||l[u]||(l[u]=cXt(c,e,u))}return{valid:Object.keys(l).length===0,errors:l,value:a}}catch(o){return{valid:!1,errors:{$schema:o instanceof Error?o.message:"Schema 校验失败"},value:a}}}function US(e,t,n=[]){const r=YR(e,t,e,n);return Ut(r)?r:{}}const yje=m.forwardRef(function({schema:t,value:n,defaultValue:r,onChange:i,onSubmit:a,onValidationChange:o,externalErrors:s={},loadOptions:l,uploadFile:c,disableFileUpload:u=!1,disabled:d=!1,respectReadonly:f=!1,showArrayControls:p=!0,groupDisplay:h="collapse",groupAccordion:g=!1,destroyInactiveGroups:v=!1,defaultExpandedGroupKeys:y=[],expandedGroupKeys:x,onExpandedGroupKeysChange:w,visibleFieldPaths:S,validateTrigger:_="submit",formSize:C="small",formLayout:$="vertical",formLabelAlign:E,formLabelCol:k,formWrapperCol:T,formId:I,className:P,emptyContent:N=null,footer:A},M){const[R]=pn.useForm(),L=Ut(t.properties)?t.properties:{},z=m.useMemo(()=>({type:"object",...t,properties:L}),[L,t]),j=m.useMemo(()=>ZR(z),[z]),O=m.useMemo(()=>US(z,Ave(j,r)),[r,z,j]),V=n!==void 0,[B,D]=m.useState(O),[F,H]=m.useState(()=>new Map),W=m.useMemo(()=>US(z,V&&n!==void 0?n:B),[V,B,z,n]),K=m.useMemo(()=>{const re=US(z,Ave(j,W));return Array.from(F.values()).reduce((ee,te)=>kC(ee,te,void 0),re)},[F,z,j,W]),[U,q]=m.useState({}),Q=m.useMemo(()=>S===void 0?void 0:new Set(S),[S]),G=m.useMemo(()=>({...U,...s}),[U,s]);m.useEffect(()=>{V||D(O)},[V,O]);const X=m.useCallback(()=>{const re=aye(z,K,W);return q(re.errors),o==null||o(re),re},[K,o,z,W]),J=m.useCallback((re,ee)=>{const te=US(z,kC(W,re,ee),re),oe=re.map(String).join(".");H(Te=>{const Ee=new Map(Te);return ee===void 0?Ee.set(oe,[...re]):Ee.delete(oe),Ee});const fe=US(z,kC(K,re,ee),re),he=KR(z,fe,z,te),ye=Ut(he)?he:te;if(V||D(ye),i==null||i(ye),q(Te=>Object.fromEntries(Object.entries(Te).filter(([Ee])=>Ee!==oe&&!Ee.startsWith(`${oe}.`)))),_==="change"){const Te=aye(z,fe,ye);q(Te.errors),o==null||o(Te)}},[V,K,i,o,z,W,_]),Y=m.useCallback(()=>{const re=X();re.valid&&(a==null||a(re.value))},[a,X]);m.useImperativeHandle(M,()=>({validate:X,getValue:()=>K,reset:()=>{V||D(O),H(new Map),i==null||i(O),q({})},submit:()=>R.submit()}),[V,K,R,O,i,X]);const Z=Object.keys(L).length>0;return b.jsxs(pn,{form:R,id:I,size:C,layout:$,labelAlign:E,labelCol:k,wrapperCol:T,colon:!1,className:["schema-dynamic-form",P].filter(Boolean).join(" "),onFinish:Y,children:[Z?b.jsx(RU,{name:"",path:[],schema:z,rootSchema:z,value:K,sourceValue:W,values:K,errors:G,disabled:d,respectReadonly:f,showArrayControls:p,groupDisplay:h,groupAccordion:g,destroyInactiveGroups:v,defaultExpandedGroupKeys:y,expandedGroupKeys:x,onExpandedGroupKeysChange:w,visibleFieldPaths:Q,loadOptions:l,uploadFile:c,disableFileUpload:u,onChange:J}):N,typeof A=="function"?A(K):A]})}),uXt=/^\$\{\s*\{?\s*(result|params)\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}$/,dXt=new Set(["properties","$schema","$id","$defs","definitions","type","required","allOf","anyOf","oneOf","additionalProperties","output_type","output_fields_map","execution_steps","job_id"]),fXt=["battery","num_batteries","number_of_lithium_metal_cells","number_of_lithium_ion_cells","lithium_battery","has_multiple_battery_powered_components","contains_battery_or_cell","battery_contains_free_unabsorbed_liquid","is_battery_non_spillable","non_lithium_battery_packaging","has_replaceable_battery","non_lithium_battery_energy_content","has_less_than_30_percent_state_of_charge","battery_installation_device_type"];function vt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Q6(e,t){return t.split(".").reduce((n,r)=>{if(vt(n))return n[r]},e)}function bje(e){return vt(e)&&"value"in e}function pXt(e){return vt(e)?Object.values(e).some(bje):!1}function WU(e){return bje(e)?e.value:e}function hXt(e){return vt(e)&&vt(e.properties)&&(typeof e.$schema=="string"||typeof e.$id=="string"||typeof e.type=="string"||Array.isArray(e.required))}function Nb(e){let t=e;if(typeof t=="string"&&t.trim())try{t=JSON.parse(t)}catch{t=e}return!Array.isArray(t)||!t.every(vt)?t:Object.assign({},...t)}function oye(e){const t=Array.isArray(e)?e[0]:e;if(typeof t=="boolean")return t;if(vt(t)&&typeof t.value=="boolean")return t.value}function mXt(e){const t=oye(e.batteries_required),n=oye(e.batteries_included);if(t!==!1&&n!==!1)return e;const r={...e};for(const i of fXt)delete r[i];return r}function mj(e){return vt(e)&&vt(e.data)&&(e.output_type==="dynamic_form"||pXt(e.data)||vt(e.data.properties)||vt(e.data.listing_data))?e.data:vt(e)&&vt(e.output)?mj(e.output):e}function gXt(e){if(!vt(e)||!vt(e.properties))return;const t=Object.entries(e).filter(([n])=>!dXt.has(n));if(t.length)return Object.fromEntries(t)}function J6(e,t){if(vt(e))return WU(e[t])}function xje(e,t){if(!vt(e))return;const n=J6(e,t);if(n!==void 0)return t==="listing_data"?Nb(n):n;const r=J6(e,"listing_data");if(t==="listing_data"&&r!==void 0)return Nb(r);const i=J6(r,t);if(i!==void 0)return t==="listing_data"?Nb(i):i;if(t==="listing_data")return Nb(gXt(e))}function vXt(e,t){return xje(e.submitted_input,t)}function wje(e,t){const n=mj(e.output);return xje(n,t)}function rD(e){return vt(e)?Object.values(e).some(t=>vt(t)&&("type"in t||"title"in t||"items"in t)):!1}function wT(e){if(!vt(e))return null;if(vt(e.properties)&&rD(e.properties))return e.properties;if(vt(e.properties)){const t=wT(e.properties);if(t)return t}return rD(e)?e:null}function W2(e){const t=n=>{if(!vt(n))return null;if(hXt(n))return n;if(vt(n.properties)){const r=t(n.properties);if(r)return r}return wT(n)?n:null};if(vt(e)&&vt(e.data)&&vt(e.data.properties))return t(e.data.properties);if(vt(e)&&vt(e.data)){const n=t(e.data);if(n)return n}return vt(e)&&vt(e.output)?W2(e.output):vt(e)?t(e):null}function KN(e){return wT(W2(e))}function Mg(e,t){if(typeof e!="string")return e;const n=e.match(uXt);if(!(n!=null&&n[1])||!n[2])return e;if(n[1]==="params")return Q6(t.input,n[2]);const r=mj(t.output),i=Q6(r,n[2]);if(i!==void 0)return i;if(vt(t.output)&&vt(t.output.data)){const a=Q6(t.output.data,n[2]);if(a!==void 0)return a}}function yXt(e){let t="";for(let n=0;n<e.length;n+=1){const r=e[n];if(r!=="'"&&r!=='"'){t+=r;continue}const i=r;let a="";for(n+=1;n<e.length;){const o=e[n];if(o==="\\"){const s=e[n+1];if(s!==void 0){a+={b:"\b",f:"\f",n:`
|
|
789
|
-
`,r:"\r",t:" ","\\":"\\",'"':'"',"'":"'"}[s]??`\\${s}`,n+=2;continue}}if(o===i)break;a+=o,n+=1}t+=JSON.stringify(a)}return t.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function ZJ(e){if(vt(e))return e;if(typeof e!="string"||!e.trim())return null;try{const t=JSON.parse(e);return vt(t)?t:null}catch{try{const t=JSON.parse(yXt(e));return vt(t)?t:null}catch{return null}}}function mu(e){const t=Nb(e);return vt(t)?mXt(t):null}function Ei(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function bXt(e){return new TextEncoder().encode(e).length}function hl(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function xXt(e,t){if(t===0)return!0;const n=e/t;return Math.abs(n-Math.round(n))<Number.EPSILON*100}const wXt=["item_name","bullet_point","generic_keyword","product_description","main_product_image_locator"],SXt={item_name:"标题",bullet_point:"五点描述",generic_keyword:"搜索关键词",product_description:"产品描述",main_product_image_locator:"主图"};function _Xt(e,t,n){const r=new Set(Object.keys(t)),i=vt(e)?n.schemaArray(e.propertyFocus).map(a=>String(a).trim()).filter(a=>a&&r.has(a)):[];return i.length?i:wXt.filter(a=>r.has(a))}function Z0(e,t,n,r){const i=mu(n);if(!i)return null;const a=r.getEffectiveSchemaProperties(e,t,i),o=r.getEffectiveSchemaRoot(e,t,i);if(!a)return null;const s=_Xt(o,a,r);return s.length?{effectiveRoot:o,properties:a,propertyNames:s,schemaValue:i}:null}function Sje(e,t,n,r){return SXt[e]||r.getSchemaTitle(e,t,n)}function QJ(e,t,n,r,i){if(e.includes("image_locator")){const a=i.getVisibleProperties(t,n,r).find(([o])=>o==="media_location");if(a)return a[0]}return i.getPrimaryVisibleChildName(t,n,r)}function _je(e,t,n,r,i){return i.getChildProperties(e,t,n)[r]||{}}function sye(e,t,n){const r=n.resolveSchemaRef(e,t);return vt(r)?hl(r.maxLength):void 0}function JJ(e,t,n,r,i){return i.getSchemaRows(e,t,n,r).map(a=>i.schemaRecord(a))}function GS(e,t,n,r,i){const a=t[n];return a?JJ(e,n,a,r,i).map(o=>{const s=QJ(n,a,r,o,i);return i.schemaString(o[s]).trim()}).filter(Boolean):[]}function Cje(e,t,n,r){const i=Z0(e,t,n,r);if(!i)return e.required&&Ei(n)?{[e.name]:`请输入${e.label}`}:{};const{effectiveRoot:a,properties:o,propertyNames:s,schemaValue:l}=i,c=r.getSchemaDefinitions(e,t),u={};for(const d of s){const f=o[d];if(!f||r.isHiddenSchema(f,c))continue;const p=r.hasRawSchemaPropertyValue(f,l[d],c),h=JJ(l,d,f,c,r);for(const[g,v]of h.entries()){const y=QJ(d,f,c,v,r);if(!y)continue;const x=_je(f,c,v,y,r),w=v[y],S=Sje(d,f,c,r),_=r.isSchemaChildRequiredForForm(d,f,y,v,c,a,l[d]),C=r.schemaErrorKey(e.name,d,y,g);if(_&&Ei(w)||r.shouldValidateMissingNestedSchemaValue(x,w,c,_||p&&r.hasRawSchemaPropertyValue(x,w,c))){u[C]=`请输入${S}`;continue}const $=r.getSchemaValueConstraintError(w,x,S,c);$&&(u[C]=$)}}return u}const{Text:CXt}=ec;function $Xt({properties:e,value:t,definitions:n,helpers:r}){const i=GS(t,e,"item_name",n,r)[0]||"商品标题将显示在这里",a=GS(t,e,"bullet_point",n,r).slice(0,5),o=GS(t,e,"product_description",n,r)[0]||"",s=GS(t,e,"generic_keyword",n,r)[0]||"",l=GS(t,e,"main_product_image_locator",n,r).find(u=>/^https?:\/\//i.test(u)),c=a.length?a:o?[o]:[];return b.jsxs("aside",{className:"wandox-amazon-listing-focus__preview",children:[b.jsx("div",{className:"wandox-amazon-listing-focus__preview-head",children:"AMAZON 前台效果预览 · 实时"}),b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-main",children:[b.jsx("div",{className:"wandox-amazon-listing-focus__preview-image",children:l?b.jsx("img",{className:"wandox-amazon-listing-focus__preview-image-content",src:l,alt:"商品主图预览"}):b.jsx("span",{children:"主图占位"})}),b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-info",children:[b.jsx("div",{className:"wandox-amazon-listing-focus__preview-title",children:i}),b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-rating",children:[b.jsx("span",{className:"wandox-amazon-listing-focus__preview-stars",children:"★★★★★"}),b.jsx("span",{className:"wandox-amazon-listing-focus__preview-rating-link",children:"1,286 ratings"})]}),b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-price",children:[b.jsx("span",{className:"wandox-amazon-listing-focus__preview-price-currency",children:"$"}),b.jsx("span",{className:"wandox-amazon-listing-focus__preview-price-main",children:"29"}),b.jsx("span",{className:"wandox-amazon-listing-focus__preview-price-decimal",children:"99"})]}),b.jsx("div",{className:"wandox-amazon-listing-focus__preview-delivery",children:"✓prime · FREE delivery"})]})]}),b.jsx("div",{className:"wandox-amazon-listing-focus__preview-divider"}),b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-about",children:[b.jsx("strong",{className:"wandox-amazon-listing-focus__preview-about-title",children:"About this item"}),c.length?b.jsx("ul",{className:"wandox-amazon-listing-focus__preview-bullets",children:c.map(u=>b.jsx("li",{children:u},u))}):b.jsx("p",{className:"wandox-amazon-listing-focus__preview-empty",children:"五点描述会显示在这里"}),s&&b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-keywords",children:["关键词:",s]})]})]})}function EXt({field:e,context:t,definitions:n,helpers:r,disabled:i=!1,errors:a,showOnlyMissing:o,onShowOnlyMissingChange:s,usesExecutionFormLayout:l,createSchemaItemDefaults:c,getForbiddenSchemaNames:u,isReadonlySchema:d,isTopLevelSchemaPropertyRequired:f,renderSchemaForm:p,setErrors:h,updateField:g,updateSchemaRow:v}){const{effectiveRoot:y,properties:x,propertyNames:w,schemaValue:S}=t,_=u(y),C=(P,N,A,M,R)=>{if(i)return;const L=S[P],z=Array.isArray(L)?[...L]:[r.schemaRecord(L)],j={...c(N,n),...r.schemaRecord(z[A]),[M]:R};g(e.name,{...S,[P]:v(L,N,A,j,n)}),h(O=>{const V=r.schemaErrorKey(e.name,P,M,A);if(!O[V]&&!O[e.name])return O;const B={...O};return delete B[V],delete B[e.name],B})},$=P=>{const N=x[P];if(!N||_.has(P)||r.isHiddenSchema(N,n))return null;const A=JJ(S,P,N,n,r),M=A.map((D,F)=>{const H=QJ(P,N,n,D,r);if(!H)return null;const W=_je(N,n,D,H,r);if(r.isHiddenSchema(W,n))return null;const K=r.schemaErrorKey(e.name,P,H,F);return{childName:H,childSchema:W,errorKey:K,row:D,rowIndex:F}}).filter(D=>D!==null);if(!M.length)return null;const R=Sje(P,N,n,r),L=M[0],z=r.schemaString(L.row[L.childName]),j=sye(L.childSchema,n,r),O=P==="bullet_point"||A.length>1,V=P.includes("image_locator"),B=f(y,P)||M.some(({childName:D,row:F})=>r.isSchemaChildRequiredForForm(P,N,D,F,n,y,S[P]));return b.jsxs("section",{className:`wandox-amazon-listing-focus__section wandox-amazon-listing-focus__section--${P}`,children:[b.jsxs("div",{className:"wandox-amazon-listing-focus__section-head",children:[b.jsxs("span",{className:"wandox-amazon-listing-focus__section-title",children:[R,B&&b.jsx("span",{className:"wandox-amazon-listing-focus__required",children:"*"})]}),!O&&j!=null&&b.jsxs("span",{className:"wandox-amazon-listing-focus__counter",children:[z.length," / ",j]})]}),b.jsx("div",{className:"wandox-amazon-listing-focus__rows",children:M.map(({childName:D,childSchema:F,errorKey:H,row:W,rowIndex:K})=>{const U=d(N,n)||d(F,n),q=r.schemaString(W[D]),Q=sye(F,n,r),G=a[H],X=`请输入${R}`,J=Y=>{i||U||C(P,N,K,D,Y)};return b.jsxs("div",{className:"wandox-amazon-listing-focus__field-row",children:[V?b.jsx(Kt,{size:l?"middle":"small",className:"wandox-amazon-listing-focus__input",value:q,onChange:Y=>J(Y.target.value),placeholder:X,status:G?"error":void 0,disabled:i||U}):b.jsx(Kt.TextArea,{size:l?"middle":"small",className:"wandox-amazon-listing-focus__text-area",autoSize:{minRows:P==="product_description"?3:2,maxRows:24},value:q,onChange:Y=>J(Y.target.value),placeholder:X,status:G?"error":void 0,disabled:i||U,showCount:O&&Q!=null?{formatter:({count:Y})=>`${Y} / ${Q}`}:!1}),G&&b.jsx("div",{className:"wandox-amazon-listing-focus__error",children:G})]},`${P}-${K}-${D}`)})})]},P)},E=w.map($).filter(Boolean),k=new Set(w),T=Object.fromEntries(Object.entries(x).filter(([P])=>!k.has(P))),I=Object.keys(T).length>0;return b.jsxs("div",{className:"wandox-amazon-listing-focus-shell",children:[b.jsxs("div",{className:"wandox-amazon-listing-focus",children:[b.jsx("div",{className:"wandox-amazon-listing-focus__editor",children:E.length?E:b.jsx(CXt,{type:"secondary",children:"暂无可编辑的重点字段"})}),b.jsx($Xt,{properties:x,value:S,definitions:n,helpers:r})]}),I&&b.jsxs("section",{className:"wandox-amazon-listing-focus__remaining",children:[b.jsxs("div",{className:"wandox-amazon-listing-focus__remaining-head",children:[b.jsxs("div",{children:[b.jsx("div",{className:"wandox-amazon-listing-focus__remaining-title",children:"其他刊登参数"}),b.jsx("div",{className:"wandox-amazon-listing-focus__remaining-desc",children:"继续补充和校验模板返回的其他动态表单字段"})]}),b.jsxs("div",{className:"wandox-amazon-listing-focus__remaining-filter",children:[b.jsx("span",{children:"只看需处理项"}),b.jsx(yo,{size:"small",checked:o,onChange:s})]})]}),p(e,T,S)]})]})}function DC(e,t){return t==="input"?e.has("input")||e.has("modify"):e.has(t)}function TXt(e,t){return!!t&&DC(e,"return_previous")}function IXt(e){return e.has("input")?"input":e.has("modify")?"modify":"confirm"}function kXt({actions:e,canReExecute:t,hasInputFields:n,hasOnClose:r,isFormMode:i,mode:a,returnStepId:o}){const s=[],l=[];return TXt(e,o)&&s.push({key:"return_previous",label:"返回上一步",command:"submitReturnPrevious",loading:!0}),a==="review"&&DC(e,"confirm")&&l.push({key:"confirm",label:"确认通过",command:"submitConfirm",loading:!0,primary:!0}),a==="review"&&DC(e,"input")&&n&&l.push({key:"switch_input",label:"修改后确认",command:"switchInput"}),a==="review"&&t&&l.push({key:"switch_re_execute",label:"重新生成",command:"switchReExecute"}),a==="input"&&!i&&l.push({key:"switch_review",label:"返回",command:"switchReview"}),a==="input"&&l.push({key:"submit_input",label:i?"确认提交":"提交修改",command:"submitInput",loading:!0,primary:!0}),a==="re_execute"&&l.push({key:"cancel_re_execute",label:"取消修改",command:"cancelReExecute"},{key:"submit_re_execute",label:"确认重新生成",command:"submitReExecute",loading:!0,primary:!0}),t&&i&&a==="input"&&l.push({key:"form_switch_re_execute",label:"重新生成",command:"switchReExecute"}),DC(e,"cancel")&&a!=="re_execute"&&l.push({key:"cancel",label:"取消执行",command:"submitCancel",danger:!0,loading:!0}),r&&l.push({key:"close",label:"收起",command:"close",disabledWhenSubmitting:!0}),{left:s,right:l}}function PXt(e){return typeof e=="string"?!!e.trim():typeof e=="number"?Number.isFinite(e):typeof e=="boolean"}function Jv(e){if(!Array.isArray(e))return;const t=new Set,n=[];for(const r of e){let i,a;if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")i=r,a=r;else if(r&&typeof r=="object"&&!Array.isArray(r)){const c=r;a=c.value??c.label,i=c.label??a}else continue;if(!PXt(a))continue;const o=String(i??"").trim();if(!o)continue;const s=typeof a=="string"?a.trim():a,l=String(s);t.has(l)||(t.add(l),n.push({label:o,value:s}))}return n.length?n:void 0}function Cl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function NXt(e){return Array.isArray(e)?e:[]}function AXt(e){const t=Cl(e.not)?e.not:{};return new Set(NXt(t.required).map(String))}function Ed(e){if(!Cl(e))return e;const t={...e};Cl(t.properties)&&(t.properties=Object.fromEntries(Object.entries(t.properties).map(([n,r])=>[n,Ed(r)]))),Cl(t.$defs)&&(t.$defs=Object.fromEntries(Object.entries(t.$defs).map(([n,r])=>[n,Ed(r)]))),Cl(t.definitions)&&(t.definitions=Object.fromEntries(Object.entries(t.definitions).map(([n,r])=>[n,Ed(r)]))),Cl(t.items)&&(t.items=Ed(t.items)),Cl(t.additionalProperties)&&(t.additionalProperties=Ed(t.additionalProperties));for(const n of["allOf","anyOf","oneOf"])Array.isArray(t[n])&&(t[n]=t[n].map(Ed));for(const n of["if","then","else","not"])Cl(t[n])&&(t[n]=Ed(t[n]));return t}function MXt({root:e,properties:t}){if(!Cl(e))return{eligible:!1,reason:"missing-schema"};if(!t||Object.keys(t).length===0)return{eligible:!1,reason:"missing-properties"};const n=Ed(e),r=AXt(n),i=Object.fromEntries(Object.entries(t).filter(([o])=>!r.has(o)).map(([o,s])=>[o,Ed(s)]));if(Object.keys(i).length===0)return{eligible:!1,reason:"missing-properties"};const a={...n,type:"object",properties:i};return Array.isArray(n.required)&&(a.required=n.required.map(String).filter(o=>o in i)),{eligible:!0,schema:a}}function RXt(e,t){const n=`${t}.`;return Array.from(e).filter(r=>r.startsWith(n)).map(r=>r.slice(n.length))}function DXt(e,t,n){const r=`${t}.`,i=Cl(n==null?void 0:n.properties)?n.properties:{};return Object.fromEntries(Object.entries(e).filter(([a])=>a.startsWith(r)).map(([a,o])=>{const s=a.slice(r.length).split("."),l=i[s[0]],c=Cl(l)?l:{},u=n?Yr(n,c):c,d=Cl(u)?u.type:void 0;return!(d==="array"||Array.isArray(d)&&d.includes("array"))&&/^\d+$/.test(s[1]||"")&&s.splice(1,1),[s.join("."),o]}))}function OXt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function iD(e){return new DOMException(e,"AbortError")}const $je=async({source:e,params:t,signal:n})=>{const r=typeof e=="string"||typeof e=="number"?String(e).trim():"";if(!r)throw new Error("动态选项缺少技能标识");if(n.aborted)throw iD("动态选项请求已取消");const i=await PEe({},{skill_id:r,params:t});if(n.aborted)throw iD("动态选项请求已取消");return i},Eje=async({file:e,signal:t,onProgress:n})=>{if(t.aborted)throw iD("文件上传已取消");n(10);const r=await Sy(e);if(t.aborted)throw iD("文件上传已取消");const i=OXt(r==null?void 0:r.data)?r.data:{},a=typeof i.url=="string"?i.url.trim():"";if(!a)throw new Error(typeof i.message=="string"?i.message:"文件上传失败");return n(100),{url:a,name:typeof i.name=="string"?i.name:e.name,meta:r}};function Ym(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function UU(e){return Array.isArray(e)?e:[]}function lye(e){return Ym(e)?e:{}}function LXt(e,t){return Array.from(new Set([...UU(e),...UU(t)].map(String)))}function YN(e,t){const n=lye(e),r=lye(t);if("if"in r)return{...n,allOf:[...UU(n.allOf),r]};const i={...n};for(const[a,o]of Object.entries(r)){const s=i[a];if(a==="required"){i[a]=LXt(s,o);continue}if((a==="properties"||a==="$defs"||a==="definitions")&&Ym(s)&&Ym(o)){i[a]={...s};for(const[l,c]of Object.entries(o))i[a]={...i[a],[l]:YN(s[l],c)};continue}if((a==="items"||a==="not")&&Ym(s)&&Ym(o)){i[a]=YN(s,o);continue}if(Ym(s)&&Ym(o)&&!["if","then","else"].includes(a)){i[a]=YN(s,o);continue}i[a]=o}return i}const{Text:Ip}=ec,Tje=!1,jXt=["confirm","input","re_execute","cancel"],aD="amazon_listing_focus",cye=new WeakMap;function zXt(e,t){return(Br(e.type).length?Br(e.type).map(String):typeof e.type=="string"?[e.type]:[]).includes(t)}function FXt(e,t={}){const n=Ma(e,t);return vt(n)&&zXt(n,"string")&&n.enum===void 0&&n.const===void 0}function uye(e,t={}){const n=Ma(e,t);return vt(n)?Br(n.anyOf).some(r=>FXt(r,t)):!1}function eee(e,t,n,r={}){if(Ei(e))return"";const i=Ma(t,r);if(!vt(i))return"";const a=cD(i,r);if(a.length&&!uye(i,r)&&!new Set(a.map(p=>p.value)).has(String(e)))return`${n}不在可选范围内`;if(i.type==="array"){const f=cD(i.items,r);if(f.length&&Array.isArray(e)&&!uye(i.items,r)){const g=new Set(f.map(v=>v.value));if(e.some(v=>!g.has(String(v))))return`${n}包含无效选项`}const p=hl(i.minItems),h=hl(i.maxItems);if(Array.isArray(e)){if(p!=null&&e.length<p)return`${n}至少选择 ${p} 项`;if(h!=null&&e.length>h)return`${n}最多选择 ${h} 项`;if(i.items)for(const g of e){const v=eee(g,i.items,n,r);if(v)return v}}return""}if(i.type==="number"||i.type==="integer"){if(typeof e!="number"||Number.isNaN(e))return`${n}请输入数字`;if(i.type==="integer"&&!Number.isInteger(e))return`${n}请输入整数`;const f=hl(i.minimum),p=hl(i.maximum),h=hl(i.exclusiveMinimum),g=hl(i.exclusiveMaximum),v=hl(i.multipleOf);return f!=null&&e<f?`${n}不能小于 ${f}`:p!=null&&e>p?`${n}不能大于 ${p}`:h!=null&&e<=h?`${n}必须大于 ${h}`:g!=null&&e>=g?`${n}必须小于 ${g}`:v!=null&&!xXt(e,v)?`${n}必须是 ${v} 的倍数`:""}const o=String(e),s=hl(i.minLength),l=hl(i.maxLength),c=hl(i.minUtf8ByteLength),u=hl(i.maxUtf8ByteLength);if(s!=null&&o.length<s)return`${n}至少 ${s} 个字符`;if(l!=null&&o.length>l)return`${n}最多 ${l} 个字符`;const d=bXt(o);if(c!=null&&d<c)return`${n}至少 ${c} 字节`;if(u!=null&&d>u)return`${n}最多 ${u} 字节`;if(typeof i.pattern=="string")try{if(!new RegExp(i.pattern).test(o))return`${n}格式不正确`}catch{return""}return i.format==="uri"&&!/^(https?:\/\/|s3:\/\/)/i.test(o)?`${n}请输入有效链接`:""}function dye(e,t){const n=e!=null&&e.length?e:t;return(Jv(n)||[]).map(r=>({value:String(r.value),label:r.label}))}function ux(e){return e.type.trim().toLowerCase()}function Q0(e){return ux(e)===aD}function oD(e){const t=ux(e);return t==="json_editor"||t==="object"||t===aD}function GU(e){return e==="array"||e==="list"||e==="tags"}function BXt(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 VXt(e,t,n){const r=ux(e);if(n==="re_execute"){const u=t?WU(Mg(e.value,t)):e.value;if(u!==void 0)return u;const d=t?Mg(e.default,t):e.default;return d!==void 0?d:r==="boolean"?!1:["number","integer","float"].includes(r)?void 0:r==="checkbox"||GU(r)?[]:""}if(t){const u=vXt(t,e.name);if(u!==void 0)return u;const d=wje(t,e.name);if(d!==void 0)return d}const i=t?WU(Mg(e.value,t)):e.value,a=ZJ(i),o=W2(a)||a,s=KN(a)||(vt(a)&&rD(a)?a:null),l=gj(o);if((r==="json_editor"||r==="object")&&s)return Object.fromEntries(Object.entries(s).map(([u,d])=>[u,[_T(d,l)]]));if(i!==void 0)return i;if(e.value!==void 0)return e.value;const c=t?Mg(e.default,t):e.default;if(c!==void 0)return c;if(r==="boolean")return!1;if(!["number","integer","float"].includes(r))return r==="checkbox"||GU(r)?[]:""}function CP(e,t,n){return Object.fromEntries(e.map(r=>[r.name,VXt(r,t,n)]))}function HXt(e,t){const n=KN(t.output);if(e.name==="listing_data"&&n&&wje(t,e.name)!==void 0||vt(n)&&e.name in n)return n;const r=mj(t.output);if(vt(r)&&vt(r.properties)&&r[e.name]!==void 0)return KN(r);const i=Mg(e.value,t),a=ZJ(i);if(vt(a)&&vt(a.properties)){const o=KN(a);if(o)return o}return rD(a)?a:null}function tee(e,t){const n=W2(t.output);if(n)return n;const r=Mg(e.value,t),i=ZJ(r);return W2(i)||(vt(i)?i:null)}function WXt(e,t){if(!vt(e)||!vt(e.propertyGroups))return[];const n=new Set(Object.keys(t)),r=new Set,i=[];for(const[o,s]of Object.entries(e.propertyGroups)){if(!vt(s))continue;const l=Br(s.propertyNames).map(String).filter(c=>n.has(c)&&!r.has(c));if(l.length){for(const c of l)r.add(c);i.push({key:o,title:sD(s.title)||o,description:sD(s.description),propertyNames:l})}}const a=Object.keys(t).filter(o=>!r.has(o));return a.length&&i.push({key:"__ungrouped",title:"其他",propertyNames:a}),i}function sD(e){return typeof e=="string"?e:""}function Br(e){return Array.isArray(e)?e:[]}function Xa(e){return vt(e)?e:{}}function gj(e){if(!vt(e))return{};const t=e.$defs??e.definitions;return vt(t)?t:{}}function U2(e,t){const n=tee(e,t);return gj(n)}function Ma(e,t){if(!vt(e)||typeof e.$ref!="string")return e;const n=e.$ref,i=["#/$defs/","#/definitions/"].find(l=>n.startsWith(l));if(!i)return e;const a=n.slice(i.length),o=t[a];if(!vt(o))return e;const s=Object.fromEntries(Object.entries(e).filter(([l])=>l!=="$ref"));return{...o,...s}}function nee(e){return Object.fromEntries(Object.entries(e).filter(([t])=>!["allOf","anyOf","oneOf","if","then","else"].includes(t)))}function UXt(e){return Object.keys(nee(e)).some(t=>!["if","then","else"].includes(t))}function qU(e){return Array.isArray(e)?e.some(qU):vt(e)?Object.values(e).some(qU):!Ei(e)}function KU(e,t){if(Object.is(e,t))return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!="object")return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function GXt(e,t){return e==="array"?Array.isArray(t):e==="object"?vt(t):e==="integer"?Number.isInteger(t):e==="number"?typeof t=="number":e==="boolean"?typeof t=="boolean":e==="string"?typeof t=="string":e==="null"?t===null:!0}function Td(e,t,n={}){const r=Ma(e,n);if(!vt(r))return!0;const i=Br(r.allOf);if(i.length&&!i.every(l=>Td(l,t,n)))return!1;const a=Br(r.anyOf);if(a.length&&!a.some(l=>Td(l,t,n)))return!1;const o=Br(r.oneOf);if(o.length&&o.filter(l=>Td(l,t,n)).length!==1||r.not!==void 0&&Td(r.not,t,n))return!1;const s=Br(r.required).map(String);if(s.length&&(!vt(t)||!s.every(l=>qU(t[l]))))return!1;if(vt(r.properties)){if(!vt(t))return!1;for(const[l,c]of Object.entries(r.properties))if(t[l]!==void 0&&!Td(c,t[l],n))return!1}return!(r.contains!==void 0&&!(Array.isArray(t)?t:vt(t)?[t]:[]).some(c=>Td(r.contains,c,n))||r.items!==void 0&&Array.isArray(t)&&(!t.length||!t.every(l=>Td(r.items,l,n)))||r.enum!==void 0&&!Br(r.enum).some(c=>KU(c,t))||r.const!==void 0&&!KU(r.const,t)||r.type!==void 0&&!(Br(r.type).length?Br(r.type).map(String):[String(r.type)]).some(c=>GXt(c,t)))}function lD(e,t,n){const r=Ma(e,n);if(!vt(r))return[];if("if"in r){const o=Td(r.if,t,n)?r.then:r.else;return lD(o,t,n)}const i=[];for(const a of Br(r.allOf))i.push(...lD(a,t,n));return UXt(r)&&i.push(nee(r)),i}function E1(e,t,n={}){const r=Ma(e,n);if(!vt(r))return r;const i=[];for(const a of Br(r.allOf))i.push(...lD(a,t,n));if("if"in r){const o=Td(r.if,t,n)?r.then:r.else;i.push(...lD(o,t,n))}return i.reduce((a,o)=>YN(a,o),nee(r))}function cv(e,t,n){const r=tee(e,t);if(!r)return null;const i=gj(r);return Xa(E1(r,n,i))}function kd(e,t,n){const r=cv(e,t,n);return wT(r)||HXt(e,t)}function ey(e){const t=Xa(e),n=Xa(t.not);return new Set(Br(n.required).map(String))}function G2(e){const t=Xa(e),n=ey(t);return new Set(Br(t.required).map(String).filter(r=>!n.has(r)))}function qXt(e){const t=cye.get(e);if(t)return t;const n=new hje({allErrors:!0,strict:!1,validateSchema:!1,multipleOfPrecision:8});vje(n);const{$schema:r,...i}=e,a=n.compile(i);return cye.set(e,a),a}function Ije(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function KXt(e){return e.split("/").slice(1).map(Ije)}function YXt(e,t){const n=t.replace(/^#/,"").split("/").slice(1).map(Ije);let r=e;for(const i of n)if(Array.isArray(r))r=r[Number(i)];else if(vt(r))r=r[i];else return;return r}function XXt(e,t){if(e.keyword!=="not")return"";const n=YXt(t,e.schemaPath);if(!vt(n))return"";const r=Br(n.required);return r.length>0?String(r[0]):""}function ZXt(e){const t=e.params;return typeof t.missingProperty=="string"?t.missingProperty:""}function QXt(e,t,n){const r=vj(e,t,n),i=dd(e,t,n);return i.find(([a])=>r.has(a))||i[0]||["value",{}]}function JXt(e,t,n,r){const i=KXt(e.instancePath);let a=i[0]||"",o=Number.isInteger(Number(i[1]))?Number(i[1]):0,s=i[2]||"";const l=XXt(e,t);if(l&&(s=l),e.keyword==="required"){const p=ZXt(e);a?s||(s=p):(a=p,o=0)}const u=Xa(t.properties)[a],d=wj(r,a,u,n),f=Xa(d[o]);if(!s&&u){const[p]=QXt(u,n,f);s=p}return{propertyName:a,rowIndex:o,childName:s||"value",propertySchema:u,childSchema:u?ud(u,n,f)[s]:void 0}}function eZt(e,t,n){const r=ree(t.childName,t.childSchema,n);return e.keyword==="required"?`请输入${r}`:e.keyword==="enum"?`${r}不在可选范围内`:e.keyword==="format"||e.keyword==="pattern"?`${r}格式不正确`:e.keyword==="type"?`${r}类型不正确`:e.keyword==="minLength"?`${r}长度不足`:e.keyword==="maxLength"?`${r}长度超出限制`:e.keyword==="minimum"?`${r}数值过小`:e.keyword==="maximum"?`${r}数值过大`:e.keyword==="multipleOf"?`${r}数值不符合步进要求`:e.keyword==="not"?`${r}与当前条件组合冲突`:`${r}不符合规则`}function YU(e,t,n){const r=E1(e,t,n);if(!vt(r))return t;if(r.type==="array"&&Array.isArray(t)){const s=r.items;return t.map(l=>YU(s,l,n))}if(!vt(t)||!vt(r.properties))return t;const i=ey(r),a=G2(r),o={};for(const[s,l]of Object.entries(t)){if(i.has(s))continue;const c=r.properties[s];c&&(!a.has(s)&&T1(c,l,n)||(o[s]=YU(c,l,n)))}return o}function tZt(e,t,n){const r=tee(e,t);if(!r)return{};try{const i=gj(r),a=qXt(r),o=Rje(e,t,n),s=YU(r,o,i);if(a(s))return{};const l={};for(const c of a.errors||[]){if(c.keyword==="if"||c.keyword==="additionalProperties")continue;const u=JXt(c,r,i,Xa(o));if(!u.propertyName||u.propertySchema&&kf(u.propertySchema,i)||u.childSchema&&kf(u.childSchema,i))continue;const d=bj(e.name,u.propertyName,u.childName,u.rowIndex);l[d]||(l[d]=eZt(c,u,i))}return l}catch{return{}}}function ree(e,t,n={}){const r=Ma(t,n);return vt(r)&&sD(r.title)||e}function cD(e,t={}){const n=Ma(e,t);if(!vt(n))return[];const r=Br(n.enum),i=Br(n.anyOf).map(l=>Ma(l,t)).find(l=>vt(l)&&Br(l.enum).length>0),a=vt(i)?Br(i.enum):[],o=r.length?r:a||[],s=r.length?Br(n.enumNames):vt(i)?Br(i.enumNames):[];return o.map((l,c)=>({value:String(l),label:String(s[c]??l),rawValue:l}))}function kf(e,t={}){const n=Ma(e,t);return vt(n)&&n.hidden===!0}function nZt(e,t={}){return Ma(e,t),Tje}function iee(e,t={},n){const r=E1(e,n,t);if(!vt(r))return{};const i=vt(r.items)?Ma(r.items,t):r,a=Array.isArray(n)?n[0]:n;return Xa(E1(i,a,t))}function ud(e,t={},n){const r=iee(e,t,n);if(vt(r.properties))return r.properties;const i=Xa(E1(e,n,t));return vt(i.properties)?i.properties:{}}function rZt(e,t,n={}){const r=Ma(e,n);if(!vt(r))return!0;const i=Br(r.selectors).map(String);if(!i.length)return!0;const a=Xa(r.type==="array"?xj(e,t,n)[0]:t),o=ud(e,n,a);return i.every(s=>{const l=o[s],c=a[s];return l===void 0||Ei(c)?!0:!ST(l,n,c)||Pf(l,c,n)})}function dd(e,t={},n){const r=iee(e,t,n),i=ey(r);return Object.entries(ud(e,t,n)).filter(([a,o])=>!i.has(a)&&!kf(o,t)&&rZt(o,vt(n)?n[a]:void 0,t))}function vj(e,t={},n){const r=iee(e,t,n),i=G2(r);return i.size?i:G2(E1(e,n,t))}function ST(e,t={},n){return dd(e,t,n).length>0}function yj(e,t={},n){const r=dd(e,t,n);return r.length?(r.find(([a])=>a==="value")||r[0])[0]:""}function kje(e,t){return G2(e).has(t)}function Pje(e,t,n={}){return dd(e,n,t).some(([r,i])=>{const a=t[r];return ST(i,n,a)?!T1(i,a,n):!Ei(a)})}function T1(e,t,n={}){if(Ei(t))return!0;const r=Array.isArray(t)?t.map(Xa):[Xa(t)];return r.some(a=>dd(e,n,a).length>0)?r.every(a=>!Pje(e,a,n)):!1}function Pf(e,t,n={}){if(Ei(t))return!1;if(Array.isArray(t))return t.some(i=>Pf(e,i,n));if(!vt(t))return!0;const r=ud(e,n,t);return Object.entries(t).some(([i,a])=>{if(Ei(a))return!1;const o=r[i];return o?kf(o,n)?!1:ST(o,n,a)?Pf(o,a,n):!0:!0})}function Nje(e,t,n={}){return(Array.isArray(t)?t.length?t.map(Xa):[{}]:[Xa(t)]).some(i=>{const a=vj(e,n,i);return dd(e,n,i).some(([o,s])=>{const l=i[o];return a.has(o)&&Ei(l)?!0:(a.has(o)||!T1(s,l,n))&&Nje(s,l,n)})})}function aee(e,t,n,r=!1){return!r&&T1(e,t,n)||!Nje(e,t,n)?!1:r||ST(e,n,t)||!T1(e,t,n)}function oee(e,t,n,r,i,a,o){const s=kje(a,e);return s&&n===yj(t,i,r)?!0:!s&&!Pf(t,o,i)?!1:vj(t,i,r).has(n)}function bj(e,t,n,r=0){return`${e}.${t}.${r}.${n}`}const hp={getEffectiveSchemaProperties:kd,getEffectiveSchemaRoot:cv,getSchemaDefinitions:U2,getSchemaTitle:ree,getVisibleProperties:dd,getPrimaryVisibleChildName:yj,getChildProperties:ud,resolveSchemaRef:Ma,getSchemaRows:wj,schemaRecord:Xa,schemaArray:Br,schemaString:sD,isHiddenSchema:kf,hasRawSchemaPropertyValue:Pf,isSchemaChildRequiredForForm:oee,shouldValidateMissingNestedSchemaValue:aee,getSchemaValueConstraintError:eee,schemaErrorKey:bj};function iZt(e){const t=Array.from(new Set(Object.values(e))).filter(Boolean);t.length&&rr.warning({title:"表单校验未通过",content:b.jsxs("div",{style:{display:"grid",gap:8},children:[b.jsx(Ip,{type:"secondary",children:"请先处理以下字段后再提交。"}),b.jsx("ul",{style:{margin:0,paddingLeft:18},children:t.slice(0,8).map(n=>b.jsx("li",{children:n},n))}),t.length>8&&b.jsxs(Ip,{type:"secondary",children:["还有 ",t.length-8," 个字段需要处理。"]})]}),okText:"知道了"})}function _T(e,t={}){return Object.fromEntries(Object.entries(ud(e,t)).map(([n,r])=>{const i=Ma(r,t);if(vt(i)&&i.default!==void 0)return[n,i.default];if(vt(i)&&i.const!==void 0)return[n,i.const];if(vt(i)){const a=Br(i.enum);if(a.length===1)return[n,a[0]]}return vt(i)&&i.type==="boolean"?[n,!1]:vt(i)&&(i.type==="number"||i.type==="integer")?[n,void 0]:[n,""]}))}function fye(e){return e===!1||e===0?!0:typeof e=="string"?e.trim()!=="":Array.isArray(e)?e.length>0:e!=null}function Aje(e,t={}){const n=Ma(e,t);if(!vt(n))return;if(n.default!==void 0)return n.default;if(n.const!==void 0)return n.const;const r=Br(n.enum);if(r.length===1)return r[0];if(n.type==="array"&&n.items){const i=_T(n,t);return Object.values(i).some(fye)?[i]:void 0}if(n.type==="object"&&vt(n.properties)){const i=Object.fromEntries(Object.entries(n.properties).map(([a,o])=>[a,Aje(o,t)]));return Object.values(i).some(fye)?i:void 0}}function aZt(e){if(typeof e!="string"&&typeof e!="number")return;const t=String(e).trim();if(/^\d+$/.test(t)){if(t.length===12)return"upc";if(t.length===13)return"ean";if(t.length===8||t.length===14)return"gtin"}}function Mje(e,t,n){const r=cD(e,n);if(!r.length)return t;const i=r.find(a=>KU(a.rawValue,t)||a.value===String(t)||a.label===String(t));return(i==null?void 0:i.rawValue)??t}function pye(e,t,n,r){const i=ud(e,r,n);if(vt(t)&&!("value"in i)){const a=t.value,o=yj(e,r,n),s=i[o];if(o&&s&&Ei(n[o])&&!Ei(a)){const l=ST(s,r,a)?xj(s,a,r):Mje(s,a,r);return{...n,[o]:l}}}if(Ei(n.type)&&"value"in n&&"type"in i){const a=new Set(cD(i.type,r).map(s=>String(s.rawValue))),o=aZt(t);if(o&&a.has(o))return{...n,type:o}}return n}function xj(e,t,n){const r=i=>{const a=_T(e,n);if(vt(i)){const o={...a,...i};return pye(e,i,o,n)}if(!Ei(i)){const o=yj(e,n,a)||"value",s=ud(e,n,a)[o];return pye(e,i,{...a,[o]:Mje(s,i,n)},n)}return a};return Array.isArray(t)?t.length?t.map(r):[r({})]:[r(t)]}function wj(e,t,n,r){const i=e[t];return xj(n,i,r)}function hye(e,t,n){const r=new Set;for(const i of e){const a=n[i.name];if(Q0(i))for(const d of Object.keys(Cje(i,t,a,hp)))r.add(d);if(!oD(i)){i.required&&Ei(a)&&r.add(i.name);continue}const o=U2(i,t),s=mu(a),l=kd(i,t,s),c=cv(i,t,s),u=ey(c);if(!l||!s){i.required&&Ei(a)&&r.add(i.name);continue}for(const[d,f]of Object.entries(l)){if(u.has(d)||kf(f,o))continue;const p=Pf(f,s[d],o);wj(s,d,f,o).forEach((g,v)=>{const y=Xa(g);for(const[x]of dd(f,o,y)){const w=y[x],S=ud(f,o,y)[x],_=oee(d,f,x,y,o,c,s[d]);(_&&Ei(w)||aee(S,w,o,_||p&&Pf(S,w,o)))&&r.add(bj(i.name,d,x,v))}})}}return r}function oZt(e,t){if(t.has(e.name))return!0;const n=`${e.name}.`;for(const r of t)if(r.startsWith(n))return!0;return!1}function sZt(e,t,n){const r=ud(e,n,t),i=vj(e,n,t),a={..._T(e,n),...t};for(const[o,s]of Object.entries(a)){const l=r[o];if(!l){Ei(s)&&delete a[o];continue}if(kf(l,n)){!i.has(o)&&Ei(s)&&delete a[o];continue}if(!i.has(o)&&Ei(s)){delete a[o];continue}a[o]=XU(l,s,n,i.has(o))}return a}function XU(e,t,n,r){const i=xj(e,t,n);if(!i.some(l=>dd(e,n,l).length>0))return t;const o=i.map(l=>sZt(e,l,n)).filter(l=>r||Pje(e,l,n)),s=Ma(e,n);return vt(s)&&s.type==="array"?o:o[0]}function Rje(e,t,n){const r=mu(n);if(!r)return n;const i=U2(e,t),a=cv(e,t,r),o=wT(a)||kd(e,t,r);if(!o)return n;const s=ey(a),l=G2(a),c={};for(const[u,d]of Object.entries(o)){if(s.has(u))continue;if(kf(d,i)){const g=r[u]??Aje(d,i);g!==void 0&&(c[u]=XU(d,g,i,!0));continue}const f=r[u],p=l.has(u);if(!p&&T1(d,f,i))continue;const h=XU(d,f,i,p);h!==void 0&&(c[u]=h)}return c}function mye(e,t,n){const r={...t};for(const i of e){if(!oD(i))continue;const a=r[i.name];if(typeof a=="string")try{r[i.name]=a.trim()?JSON.parse(a):{}}catch{r[i.name]=a}r[i.name]=Rje(i,n,r[i.name])}return"listing_data"in r&&(r.listing_data=Nb(r.listing_data)),r}function gye(e){return e==null||e===""?b.jsx(Ip,{type:"secondary",children:"空"}):typeof e=="boolean"?e?"是":"否":typeof e=="object"?b.jsx("pre",{style:{margin:0,padding:"8px 10px",background:"#f8fafc",border:"1px solid #e5e7eb",borderRadius:6,maxHeight:220,overflow:"auto",fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e,null,2)}):String(e)}function lZt(e,t=!1,n=""){return!t&&!n?e:b.jsxs(pa,{size:6,align:"center",children:[b.jsx("span",{children:e}),n?b.jsx(or,{title:n,children:b.jsx(ME,{style:{color:"#9ca3af",cursor:"help",fontSize:13}})}):null,t?b.jsx(ji,{color:"default",style:{marginInlineEnd:0,color:"#6b7280"},children:"只读"}):null]})}function vye(e,t,n){return Math.min(Math.max(e,t),n)}function see({data:e,submitting:t,compact:n,actionsPlacement:r="inline",showOnlyMissing:i,onShowOnlyMissingChange:a,hideFilterToggle:o=!1,hideFilterSummary:s=!1,hideTimeoutAlert:l=!1,hideStepText:c=!1,executionFormLayout:u=!1,hideActions:d=!1,previewOnly:f=!1,disableBusinessEffects:p=!1,onValuesChange:h,onSubmit:g,onClose:v}){var Ye,Se;const y=e.confirm_type==="form"||!(e.confirm_fields||[]).length&&!!((Ye=e.input_fields)!=null&&Ye.length),x=y?"input":"review",[w,S]=m.useState(x),[_,C]=m.useState(()=>CP(x==="input"?e.input_fields||[]:[],e,x)),[$,E]=m.useState({}),[k,T]=m.useState(()=>new Set),[I,P]=m.useState(!1),[N,A]=m.useState(()=>new Set),M=m.useRef(null),R=m.useRef(null),L=m.useRef(null),[z,j]=m.useState({visible:!1,thumbHeight:0,thumbTop:0}),O=i??I,V=m.useCallback(me=>{i===void 0&&P(me),a==null||a(me)},[i,a]),B=m.useMemo(()=>{var pe;const me=(pe=e.actions)!=null&&pe.length?e.actions:jXt;return new Set(me)},[e.actions]),D=DC(B,"re_execute")&&(e.max_retries==null||(e.retry_count??0)<e.max_retries),F=m.useMemo(()=>w==="re_execute"?e.re_execute_params||[]:w==="input"?e.input_fields||[]:[],[e.input_fields,e.re_execute_params,w]),H=m.useMemo(()=>F.some(me=>{const pe=mu(_[me.name]);return Q0(me)?!!Z0(me,e,pe,hp):ux(me)!=="json_editor"?!1:!!(pe&&kd(me,e,pe))}),[F,e,_]),W=m.useMemo(()=>F.some(me=>Q0(me)?!!Z0(me,e,mu(_[me.name]),hp):!1),[F,e,_]),K=w==="re_execute"||u&&w==="input"&&!H,U=K?16:4,q=me=>me==="re_execute"?e.re_execute_params||[]:me==="input"?e.input_fields||[]:[],Q=me=>{S(me),C(CP(q(me),e,me)),E({}),T(new Set),V(!1),A(new Set)},G=f||p,X=m.useMemo(()=>G?[]:F,[F,G]),J=sj(X,_,C);m.useEffect(()=>{var xe;const me=e.confirm_type==="form"||!(e.confirm_fields||[]).length&&((xe=e.input_fields)!=null&&xe.length)?"input":"review";S(me);const pe=me==="input"?e.input_fields||[]:[];C(CP(pe,e,me)),E({}),T(new Set),P(!1),A(new Set)},[e]),m.useEffect(()=>{C(CP(F,e,w)),E({}),T(new Set),P(!1),A(new Set)},[F,e,w]);const Y=m.useMemo(()=>hye(F,e,_),[F,e,_]),re=m.useMemo(()=>new Set([...Y,...Object.keys($)]),[Y,$]).size;m.useEffect(()=>{if(r!=="bottom"){j({visible:!1,thumbHeight:0,thumbTop:0});return}const me=M.current;if(!me)return;let pe=0;const xe=()=>{var ke;if(pe=0,!(me.scrollHeight>me.clientHeight+1)){j(Ke=>Ke.visible?{visible:!1,thumbHeight:0,thumbTop:0}:Ke);return}const Qe=((ke=R.current)==null?void 0:ke.clientHeight)??0;if(Qe<=0)return;const it=Math.max(Math.min(36,Qe),Math.round(me.clientHeight/me.scrollHeight*Qe)),st=Math.max(0,Qe-it),Ft=Math.max(1,me.scrollHeight-me.clientHeight),Ne=Math.round(me.scrollTop/Ft*st);j(Ke=>Ke.visible&&Ke.thumbHeight===it&&Ke.thumbTop===Ne?Ke:{visible:!0,thumbHeight:it,thumbTop:Ne})},Le=()=>{pe||(pe=window.requestAnimationFrame(xe))};Le(),me.addEventListener("scroll",Le,{passive:!0}),window.addEventListener("resize",Le);const $e=typeof ResizeObserver<"u"?new ResizeObserver(Le):null;$e==null||$e.observe(me),R.current&&($e==null||$e.observe(R.current));for(const ze of Array.from(me.children))$e==null||$e.observe(ze);return()=>{pe&&window.cancelAnimationFrame(pe),me.removeEventListener("scroll",Le),window.removeEventListener("resize",Le),$e==null||$e.disconnect()}},[r]);const ee=me=>{const pe=M.current;if(!pe||!z.visible)return null;const xe=me.clientHeight,Le=Math.max(0,xe-z.thumbHeight),$e=Math.max(0,pe.scrollHeight-pe.clientHeight);return $e<=0?null:{body:pe,maxScrollTop:$e,maxThumbTop:Le}},te=(me,pe,xe,Le)=>{me.scrollTop=xe>0?pe/xe*Le:0},oe=me=>{const pe=ee(me.currentTarget);if(!pe)return;me.preventDefault(),me.stopPropagation();const xe=me.currentTarget.querySelector("span"),Le=(xe==null?void 0:xe.contains(me.target))??!1;let $e=pe.body.scrollTop;if(!Le){const ze=me.currentTarget.getBoundingClientRect(),Qe=vye(me.clientY-ze.top-z.thumbHeight/2,0,pe.maxThumbTop);te(pe.body,Qe,pe.maxThumbTop,pe.maxScrollTop),$e=pe.body.scrollTop}L.current={pointerId:me.pointerId,startY:me.clientY,startScrollTop:$e,maxScrollTop:pe.maxScrollTop,maxThumbTop:pe.maxThumbTop},me.currentTarget.setPointerCapture(me.pointerId)},fe=me=>{const pe=L.current,xe=M.current;if(!pe||!xe||pe.pointerId!==me.pointerId)return;me.preventDefault(),me.stopPropagation();const Le=me.clientY-pe.startY,$e=pe.startScrollTop+(pe.maxThumbTop>0?Le/pe.maxThumbTop*pe.maxScrollTop:0);xe.scrollTop=vye($e,0,pe.maxScrollTop)},he=me=>{var pe;((pe=L.current)==null?void 0:pe.pointerId)===me.pointerId&&(L.current=null)},ye=m.useCallback((me,pe)=>new Set([...hye(me,e,_),...Object.keys(pe)]),[e,_]),Te=m.useCallback((me,pe)=>{const xe=ye(me,pe),Le=[];for(const $e of me){if(!Q0($e))continue;const ze=mu(_[$e.name]),Qe=Z0($e,e,ze,hp);if(!Qe)continue;const it=new Set(Qe.propertyNames);for(const st of Object.keys(Qe.properties))it.has(st)||Le.push(`${$e.name}.${st}`)}return Le.length?new Set(Array.from(xe).filter($e=>Le.some(ze=>$e===ze||$e.startsWith(`${ze}.`)))):xe},[e,ye,_]),Ee=m.useCallback(me=>{const pe={};for(const xe of me){if(xe.required&&Ei(_[xe.name])&&(pe[xe.name]=`请输入${xe.label}`),Q0(xe)&&Object.assign(pe,Cje(xe,e,_[xe.name],hp)),!oD(xe))continue;const Le=U2(xe,e),$e=_[xe.name],ze=mu($e),Qe=kd(xe,e,ze),it=cv(xe,e,ze),st=ey(it);if(!(!Qe||!ze)){for(const[Ft,Ne]of Object.entries(Qe)){if(st.has(Ft)||kf(Ne,Le))continue;const ke=Pf(Ne,ze[Ft],Le),Ke=wj(ze,Ft,Ne,Le);for(const[Je,We]of Ke.entries()){const Oe=Xa(We);for(const[Xe,at]of dd(Ne,Le,Oe)){const mt=bj(xe.name,Ft,Xe,Je),ot=ree(Xe,at,Le),wt=Oe[Xe],Pt=oee(Ft,Ne,Xe,Oe,Le,it,ze[Ft]);if(Pt&&Ei(wt)||aee(at,wt,Le,Pt||ke&&Pf(at,wt,Le))){pe[mt]||(pe[mt]=`请输入${ot}`);continue}const Yt=eee(wt,at,ot,Le);Yt&&(pe[mt]||(pe[mt]=Yt))}}}for(const[Ft,Ne]of Object.entries(tZt(xe,e,ze)))pe[Ft]||(pe[Ft]=Ne)}}return pe},[e,_]),we=m.useCallback((me,pe)=>{const xe=Object.keys(pe);xe.length&&T(Le=>{const $e=new Set(Le);for(const ze of me){const Qe=mu(_[ze.name]);if(!Qe)continue;const it=cv(ze,e,Qe),st=kd(ze,e,Qe);if(st)for(const Ft of WXt(it,st))Ft.propertyNames.some(ke=>xe.some(Ke=>Ke.startsWith(`${ze.name}.${ke}.`)))&&$e.add(`${ze.name}:${Ft.key}`)}return $e})},[e,_]),le=me=>{if(!me){V(!1),A(new Set);return}const pe=Ee(F),xe=Te(F,pe),Le=Object.fromEntries(Object.entries(pe).filter(([$e])=>xe.has($e)));E(Le),we(F,Le),V(!0),A(xe)},se=(me,pe)=>{const xe={..._,[me]:pe};C(xe),h==null||h(xe),E(Le=>{if(!Le[me])return Le;const $e={...Le};return delete $e[me],$e})},ne=(me,pe)=>{const xe={..._,[me]:pe};C(xe),h==null||h(xe),E(Le=>{const $e=`${me}.`,ze=Object.fromEntries(Object.entries(Le).filter(([Qe])=>Qe!==me&&!Qe.startsWith($e)));return Object.keys(ze).length===Object.keys(Le).length?Le:ze})},ge=(me,pe)=>{const xe=`${me}:`;T(Le=>{const $e=new Set(Array.from(Le).filter(ze=>!ze.startsWith(xe)));for(const ze of pe)$e.add(`${xe}${ze}`);return $e})},be=me=>{const pe=Ee(me);return E(pe),we(me,pe),O&&A(Te(me,pe)),Object.keys(pe).length>0?(iZt(pe),!1):!0},Ce=(me,pe,xe,Le,$e)=>{const ze=Ma(pe,$e);if(Array.isArray(me)||vt(ze)&&ze.type==="array"){const Qe=Array.isArray(me)?[...me]:[];return Qe[xe]=Le,Qe}return Le},Ae=(me,pe,xe)=>{const Le=cv(me,e,xe),$e=MXt({root:Le,properties:pe});if(!$e.eligible||!$e.schema)return null;const ze=`${me.name}:`,Qe=Array.from(k).filter(st=>st.startsWith(ze)).map(st=>st.slice(ze.length)),it=O?RXt(N,me.name):void 0;return b.jsx(yje,{schema:$e.schema,value:xe,onChange:st=>ne(me.name,st),externalErrors:DXt($,me.name,$e.schema),loadOptions:G?void 0:$je,uploadFile:G?void 0:Eje,disableFileUpload:G,disabled:f,respectReadonly:Tje,showArrayControls:!1,groupDisplay:"collapse",groupAccordion:!1,destroyInactiveGroups:!1,expandedGroupKeys:Qe,onExpandedGroupKeysChange:st=>ge(me.name,st),visibleFieldPaths:it,className:"human-confirm-panel__schema-dynamic-form"})},je=(me,pe)=>{const xe=U2(me,e);return b.jsx(EXt,{field:me,context:pe,definitions:xe,helpers:hp,disabled:f,errors:$,showOnlyMissing:O,onShowOnlyMissingChange:le,usesExecutionFormLayout:K,createSchemaItemDefaults:_T,getForbiddenSchemaNames:ey,isReadonlySchema:nZt,isTopLevelSchemaPropertyRequired:kje,renderSchemaForm:Ae,setErrors:E,updateField:se,updateSchemaRow:Ce})},ce=()=>{g({action:"confirm",inputData:{approved:!0}})},de=()=>{if(!be(F))return;const me=mye(F,_,e);g({action:IXt(B),inputData:me,confirmedInput:me})},_e=()=>{g({action:"return_previous",inputData:{}})},Me=()=>{if(!be(F))return;const me=mye(F,_,e);g({action:"re_execute",inputData:{request_regenerate:!0},modifiedParams:me})},Re=()=>{g({action:"cancel",inputData:{}})},Ie=kXt({actions:B,canReExecute:D,hasInputFields:!!((Se=e.input_fields)!=null&&Se.length),hasOnClose:!!v,isFormMode:y,mode:w,returnStepId:e.return_step_id}),De=me=>{me==="submitConfirm"&&ce(),me==="submitInput"&&de(),me==="submitReturnPrevious"&&_e(),me==="submitReExecute"&&Me(),me==="submitCancel"&&Re(),me==="switchInput"&&Q("input"),me==="switchReview"&&Q("review"),me==="switchReExecute"&&Q("re_execute"),me==="cancelReExecute"&&Q(y?"input":"review"),me==="close"&&(v==null||v())},Ue=me=>b.jsx(Et,{type:me.primary?"primary":void 0,danger:me.danger,loading:me.loading?t:!1,disabled:me.disabledWhenSubmitting?t:void 0,onClick:()=>De(me.command),children:me.label},me.key),nt=me=>{var Ft,Ne;const pe=_[me.name],xe=$[me.name]?"error":void 0,Le=me.placeholder||`请输入${me.label}`,$e=ux(me);if($e==="boolean")return b.jsx(yo,{size:K?"default":"small",checked:!!pe,onChange:ke=>se(me.name,ke)});if(["number","integer","float"].includes($e))return b.jsx(zo,{size:K?"middle":"small",style:{width:"100%"},value:BXt(pe),onChange:ke=>se(me.name,ke),placeholder:Le,status:xe,precision:$e==="integer"?0:void 0});const ze=GU($e),Qe=!!((Ft=me.options)!=null&&Ft.length||(Ne=me.enum)!=null&&Ne.length);if($e==="select"||$e==="radio"||$e==="segmented"||ze||($e==="string"||$e==="url")&&(Qe||!!me.options_from_skill)){const ke=J.getFieldState(me),Ke=me.options_from_skill?ke.options:dye(me.options,me.enum),Je=!!(me.options_from_skill||Qe),We=ke.waitingForDependencies?"请先选择关联参数":ke.placeholder||me.placeholder||`请选择${me.label}`,Oe=ze?Array.isArray(pe)?pe.map(String):pe==null||pe===""?[]:[String(pe)]:pe==null||pe===""?void 0:String(pe);return $e==="radio"||$e==="segmented"?b.jsx(my.Group,{value:pe,onChange:Xe=>se(me.name,Xe.target.value),options:Ke}):b.jsx(tn,{size:K?"middle":"small",style:{width:"100%"},value:Oe,mode:ze?Je?"multiple":"tags":void 0,onChange:Xe=>se(me.name,Xe),placeholder:Oe===void 0?We:void 0,options:Ke,loading:ke.loading,disabled:ke.waitingForDependencies,allowClear:!0,showSearch:!0,tokenSeparators:ze&&!Je?[","]:void 0,optionFilterProp:"label",status:xe,notFoundContent:ke.loading?b.jsx(vr,{size:"small"}):ke.error||null})}if($e==="checkbox")return b.jsx(pf.Group,{value:Array.isArray(pe)?pe:[],onChange:ke=>se(me.name,ke),options:dye(me.options,me.enum)});const st={...me,type:$e};if(mT(st))return b.jsx(qQ,{field:st,value:pe,size:K?"middle":"small",status:xe,onChange:ke=>se(me.name,ke)});if($e==="date"){const ke=bu(me);return b.jsx(ui,{size:K?"middle":"small",style:{width:"100%"},value:sv(pe),picker:b1(ke),format:ke,placeholder:me.placeholder||"请选择日期",status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="daterange"){const ke=bu(me);return b.jsx(ui.RangePicker,{size:K?"middle":"small",style:{width:"100%"},value:SC(pe),picker:b1(ke),format:ke,status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="datetime"){const ke=bu(me);return b.jsx(ui,{size:K?"middle":"small",style:{width:"100%"},value:sv(pe),showTime:{format:ov(ke)},format:ke,placeholder:me.placeholder||"请选择日期时间",status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="datetimerange"){const ke=bu(me);return b.jsx(ui.RangePicker,{size:K?"middle":"small",style:{width:"100%"},value:SC(pe),showTime:{format:ov(ke)},format:ke,placeholder:["请选择开始日期时间","请选择结束日期时间"],status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="time"){const ke=bu(me);return b.jsx(Ua,{size:K?"middle":"small",style:{width:"100%"},value:sv(pe),format:ke,placeholder:me.placeholder||"请选择时间",status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="timerange"){const ke=bu(me);return b.jsx(Ua.RangePicker,{size:K?"middle":"small",style:{width:"100%"},value:SC(pe),format:ke,status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="textarea"||$e==="text")return b.jsx(Kt.TextArea,{size:K?"middle":"small",autoSize:{minRows:2,maxRows:U},value:typeof pe=="string"?pe:String(pe??""),onChange:ke=>se(me.name,ke.target.value),placeholder:Le,status:xe});if($e==="string"||$e==="url")return b.jsx(Kt,{size:K?"middle":"small",value:typeof pe=="string"?pe:String(pe??""),onChange:ke=>se(me.name,ke.target.value),placeholder:Le,status:xe});if($e===aD){const ke=Z0(me,e,pe,hp);return ke?je(me,ke):b.jsx(Kt.TextArea,{size:K?"middle":"small",className:"human-confirm-panel__json-textarea",autoSize:{minRows:2,maxRows:U},value:typeof pe=="string"?pe:JSON.stringify(pe??{},null,2),onChange:Ke=>se(me.name,Ke.target.value),placeholder:Le,status:xe})}if($e==="json_editor"||$e==="object"){const ke=mu(pe),Ke=kd(me,e,ke);return Ke&&ke?Ae(me,Ke,ke):b.jsx(Kt.TextArea,{size:K?"middle":"small",className:"human-confirm-panel__json-textarea",autoSize:{minRows:2,maxRows:U},value:typeof pe=="string"?pe:JSON.stringify(pe??{},null,2),onChange:Je=>se(me.name,Je.target.value),placeholder:Le,status:xe})}return b.jsx(Kt.TextArea,{size:K?"middle":"small",autoSize:{minRows:2,maxRows:U},value:typeof pe=="string"?pe:String(pe??""),onChange:ke=>se(me.name,ke.target.value),placeholder:Le,status:xe})},ct=()=>{if(!F.length)return b.jsx(Ip,{type:"secondary",children:"暂无输入字段配置"});const me=O?F.filter(pe=>Q0(pe)||oZt(pe,N)):F;return b.jsxs(pn,{size:K?void 0:"small",layout:"vertical",component:"div",className:`human-confirm-panel__fields${K?" wandox-human-confirm-panel__fields--re-execute":""}`,colon:!1,labelAlign:"left",children:[!s||!o&&!W?b.jsxs("div",{className:"human-confirm-panel__filter",style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"8px 10px",border:"1px solid #eef2f7",borderRadius:8,background:"#f8fafc"},children:[!s&&b.jsx(Ip,{type:"secondary",style:{fontSize:12},children:re>0?`还有 ${re} 项内容需要补充或修正`:"当前表单内容已通过基础检查"}),!o&&!W&&b.jsxs(pa,{size:6,children:[b.jsx(Ip,{style:{fontSize:12,color:"#374151"},children:"只看需处理项"}),b.jsx(yo,{size:"small",checked:O,onChange:le})]})]}):null,O&&!me.length?b.jsx(c$,{type:"success",showIcon:!0,message:"暂无需要处理的表单项",style:{borderRadius:8}}):null,me.map(pe=>{const xe=ux(pe),Le=oD(pe)?mu(_[pe.name]):null,$e=!!(Le&&(xe===aD?Z0(pe,e,Le,hp):(xe==="json_editor"||xe==="object")&&kd(pe,e,Le))),ze=!!(Le&&(xe==="json_editor"||xe==="object")&&kd(pe,e,Le));return b.jsx(pn.Item,{className:`human-confirm-panel__field${$e?" human-confirm-panel__field--schema":""}${ze?" human-confirm-panel__field--dynamic-schema":""}${K&&!$e?" wandox-human-confirm-panel__field--re-execute":""}`,label:$e?void 0:K?lZt(pe.label,!1,pe.description):pe.label,required:$e?!1:pe.required,validateStatus:$[pe.name]?"error":void 0,help:$[pe.name]||void 0,style:{marginBottom:0},children:nt(pe)},pe.name)})]})},ht=()=>{const me=e.confirm_fields||[];return me.length?b.jsx("div",{className:"human-confirm-panel__review-list",children:me.map(pe=>b.jsxs("div",{className:"human-confirm-panel__review-item",children:[b.jsx(Ip,{type:"secondary",className:"human-confirm-panel__review-label",children:pe.label}),b.jsx("div",{className:"human-confirm-panel__review-value",children:gye(Mg(pe.value,e))})]},pe.name||pe.label))}):e.output?b.jsx("div",{className:"human-confirm-panel__review-output",children:gye(e.output)}):null},Ve=b.jsxs("div",{ref:M,className:`human-confirm-panel__body${w==="review"?" human-confirm-panel__body--review":w==="input"?" human-confirm-panel__body--input":" human-confirm-panel__body--re-execute"}${K?" wandox-human-confirm-panel__body--re-execute":""}`,style:{display:"flex",flexDirection:"column",gap:12,flex:r==="bottom"?1:void 0,minHeight:r==="bottom"?0:void 0},children:[e.playbook_name&&!n&&!c&&b.jsxs(Ip,{type:"secondary",style:{fontSize:12},children:["步骤: ",e.playbook_name]}),e.timeout_minutes!=null&&!l&&b.jsx(c$,{type:"info",showIcon:!0,message:`请在 ${e.timeout_minutes} 分钟内处理`,style:{padding:"6px 10px",borderRadius:6}}),w==="review"?ht():ct()]});return b.jsx(Ts,{componentDisabled:f||void 0,children:b.jsxs("div",{className:`human-confirm-panel${n?" human-confirm-panel--compact":""}${r==="bottom"?" human-confirm-panel--bottom-actions":""}${f?" human-confirm-panel--preview-only":""}`,style:{display:"flex",flexDirection:"column",gap:12,minHeight:r==="bottom"?"100%":void 0},children:[r==="bottom"?b.jsxs("div",{className:"wandox-human-confirm-panel__body-shell",children:[Ve,b.jsx("div",{ref:R,className:`wandox-human-confirm-panel__scrollbar${z.visible?"":" wandox-human-confirm-panel__scrollbar--hidden"}`,"aria-hidden":"true",onPointerDown:oe,onPointerMove:fe,onPointerUp:he,onPointerCancel:he,onLostPointerCapture:he,children:b.jsx("span",{style:{height:z.thumbHeight,transform:`translateY(${z.thumbTop}px)`}})})]}):Ve,!d&&b.jsxs("div",{className:"human-confirm-panel__actions",style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:r==="bottom"?0:void 0,marginTop:r==="bottom"?"auto":void 0},children:[b.jsx(pa,{wrap:!0,children:Ie.left.map(Ue)}),b.jsx(pa,{wrap:!0,style:{justifyContent:"flex-end"},children:Ie.right.map(Ue)})]})]})})}const Dje="amazon_listing_focus";function ka(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Kr(e){return typeof e=="string"&&e?e:void 0}function yd(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()&&Number.isFinite(Number(e)))return Number(e)}function Oje(e){return typeof e=="boolean"?e:void 0}function cZt(e){return ka(e)&&"value"in e}function uZt(e){return!ka(e)||!ka(e.data)?null:e.output_type==="dynamic_form"||Object.values(e.data).some(cZt)?e.data:null}function lee(e){if(!ka(e))return null;if(ka(e.output))return lee(e.output);const t=ka(e.data)?e.data:e;return(ka(t.listing_data)||Array.isArray(t.listing_data))&&ka(t.properties)?t:null}function Lje(e){const t=lee(e),n=t==null?void 0:t.properties;return!ka(n)||!Array.isArray(n.propertyFocus)?[]:n.propertyFocus.map(r=>typeof r=="string"?r.trim():"").filter(Boolean)}function jje(e,t){var r,i;const n=Kr(e.type);return n||(Kr(e.options_from_skill)||(r=Jv(e.options))!=null&&r.length||(i=Jv(e.enum))!=null&&i.length?"select":ka(t)?"json_editor":"text")}function eF(e){if(Array.isArray(e))return e.map((t,n)=>{var i;const r=String(t.name||t.label||`field_${n+1}`);return{...t,name:r,type:jje(t,t.value),label:String(t.label||r),required:Oje(t.required)??!0,description:Kr(t.description),placeholder:Kr(t.placeholder),options:Jv(t.options),enum:(i=Jv(t.enum))==null?void 0:i.map(a=>String(a.value)),default:t.default,file_type:Kr(t.file_type),options_from_skill:Kr(t.options_from_skill),options_params:ka(t.options_params)?t.options_params:void 0}})}function dZt(e){const t=lee(e);if(t)return[{name:"listing_data",type:Lje(e).length?Dje:"json_editor",label:"刊登内容确认",required:!0,value:t.listing_data}];const n=uZt(e);if(!n)return;const r=Object.entries(n).map(([i,a])=>{var l;if(!ka(a))return null;const o=a.value,s=jje(a,o);return{name:i,type:s,label:Kr(a.label)||i,required:Oje(a.required),description:Kr(a.description),placeholder:Kr(a.placeholder),options:Jv(a.options),enum:(l=Jv(a.enum))==null?void 0:l.map(c=>String(c.value)),default:a.default,value:o,file_type:Kr(a.file_type),options_from_skill:Kr(a.options_from_skill),options_params:ka(a.options_params)?a.options_params:void 0}}).filter(i=>!!i);return r.length?r:void 0}function fZt(e,t){if(!(e!=null&&e.length)||!Lje(t).length)return e;let n=!1;const r=e.map(i=>{const a=i.type.trim().toLowerCase(),o=i.name==="listing_data",s=a==="json_editor"&&(o||e.length===1);return!o&&!s?i:(n=!0,{...i,name:o?i.name:"listing_data",type:Dje,label:i.label||"刊登内容确认",required:i.required??!0})});return n?r:e}function pZt(e,t){if(!(e!=null&&e.length)||!(t!=null&&t.length))return e;const n=new Map(t.map(r=>[r.name,r]));return e.map(r=>{var o,s,l,c,u,d;const i=n.get(r.name);if(!i)return r;const a=!!(i.options_from_skill||(o=i.options)!=null&&o.length||(s=i.enum)!=null&&s.length);return{...r,type:a&&!r.options_from_skill&&!((l=r.options)!=null&&l.length)&&!((c=r.enum)!=null&&c.length)?i.type:r.type,description:r.description??i.description,placeholder:r.placeholder??i.placeholder,options:(u=r.options)!=null&&u.length?r.options:i.options,enum:(d=r.enum)!=null&&d.length?r.enum:i.enum,file_type:r.file_type??i.file_type,options_from_skill:r.options_from_skill??i.options_from_skill,options_params:r.options_params&&Object.keys(r.options_params).length>0?r.options_params:i.options_params}})}function zje(e,t){if(t!=null&&t>0)return`step_${t}`;const n=e==null?void 0:e.match(/^step_(\d+)$/);if(!n)return;const r=Number(n[1]);if(!(!Number.isFinite(r)||r<=1))return`step_${r-1}`}function Rg(e,t){var r;if(!e)return;if(e.return_step_id)return e.return_step_id;const n=e.step_id;if(n&&(t!=null&&t.length)){const i=t.findIndex(a=>a.step_id===n);if(i>0)return(r=t[i-1])==null?void 0:r.step_id}return zje(n,e.step_index)}function Sj(e){const t=ka(e.human_input_config)?e.human_input_config:{},n=String(e.step_id??""),r=yd(e.step_index),i=e.output??e.output_data,a=ka(e.human_input_data)?e.human_input_data:{},o=ka(a.input_data)?a.input_data:void 0,s=fZt(eF(e.input_fields??t.input_fields)??dZt(i),i),l=eF(e.re_execute_params??t.re_execute_params),c=pZt(s,l),u=Kr(e.return_step_id)||Kr(e.previous_step_id)||Kr(e.prev_step_id)||Kr(t.return_step_id)||Kr(t.previous_step_id)||Kr(t.prev_step_id)||zje(n,r);return{step_id:n,step_index:r,return_step_id:u,step_db_id:yd(e.step_db_id)??yd(e.id),playbook_name:Kr(e.playbook_name)??Kr(e.step_name),message:Kr(e.message)??Kr(t.message),confirm_type:Kr(e.confirm_type)??Kr(t.confirm_type),position:Kr(e.position)??Kr(t.position),actions:Array.isArray(e.actions)?e.actions.map(String):Array.isArray(t.actions)?t.actions.map(String):void 0,confirm_fields:eF(e.confirm_fields??t.confirm_fields),input_fields:c,re_execute_params:l,retry_count:yd(e.retry_count)??yd(t.retry_count),max_retries:yd(e.max_retries)??yd(t.max_retries),timeout_minutes:yd(e.timeout_minutes)??yd(t.timeout_minutes),output:i,input:e.input??e.input_data,submitted_input:o}}async function I1(e,t){const n=await $gt({execution_id:e,...t?{step_id:t}:{}}),r=n,i=r.data??r.results??n,o=(Array.isArray(i)?i:ka(i)&&Array.isArray(i.items)?i.items:[])[0];return ka(o)?Sj(o):null}const hZt={createAgent:mgt,updateAgent:vgt,deleteAgent:ygt,enableMarketTemplate:Ngt,enableRecommendedTemplate:Mgt,cancelExecution:_gt,deleteExecution:Cgt,createTransfer:Tgt,rejectTransfer:kgt,createSchedule:xgt,updateSchedule:wgt,deleteSchedule:Sgt},dl={agents:["automation-mutation","agents"],market:["automation-mutation","market"],executions:["automation-mutation","executions"],transfers:["automation-mutation","transfers"],schedules:["automation-mutation","schedules"]};function mZt(e=hZt){return{agents:{create:()=>({mutationKey:[...dl.agents,"create"],mutationFn:t=>e.createAgent(t)}),update:()=>({mutationKey:[...dl.agents,"update"],mutationFn:({agentId:t,data:n})=>e.updateAgent(t,n)}),delete:()=>({mutationKey:[...dl.agents,"delete"],mutationFn:t=>e.deleteAgent(t)})},market:{enableTemplate:()=>({mutationKey:[...dl.market,"enable-template"],mutationFn:t=>e.enableMarketTemplate(t)}),enableRecommendedTemplate:()=>({mutationKey:[...dl.market,"enable-recommended-template"],mutationFn:t=>e.enableRecommendedTemplate({template_id:t})})},executions:{cancel:()=>({mutationKey:[...dl.executions,"cancel"],mutationFn:t=>e.cancelExecution(t)}),delete:()=>({mutationKey:[...dl.executions,"delete"],mutationFn:async({executionId:t,cancelFirst:n})=>(n&&await e.cancelExecution(t),e.deleteExecution(t))})},transfers:{create:()=>({mutationKey:[...dl.transfers,"create"],mutationFn:({resultId:t,data:n})=>e.createTransfer(t,n)}),reject:()=>({mutationKey:[...dl.transfers,"reject"],mutationFn:t=>e.rejectTransfer(t)})},schedules:{create:()=>({mutationKey:[...dl.schedules,"create"],mutationFn:({agentId:t,data:n})=>e.createSchedule(t,n)}),update:()=>({mutationKey:[...dl.schedules,"update"],mutationFn:({scheduleId:t,data:n})=>e.updateSchedule(t,n)}),delete:()=>({mutationKey:[...dl.schedules,"delete"],mutationFn:({scheduleId:t})=>e.deleteSchedule(t)})}}}const Bl=mZt(),{Text:tF}=ec;function cee({open:e,onClose:t,resultId:n}){const{transferTargetResultId:r}=Er(),i=n??r,[a,o]=m.useState([]),[s,l]=m.useState([]),[c,u]=m.useState(""),[d,f]=m.useState(!1),p=wa(),h=Ll({...Bl.transfers.create(),onSuccess:()=>Ys(p,{type:"transfer-created"})});m.useEffect(()=>{e&&(f(!0),fgt().then(w=>{const S=w.data??w.results??w,_=S.items??(Array.isArray(S)?S:[]),C=localStorage.getItem("sso_user_id")||localStorage.getItem("sso_username")||"",$=[..._].sort((E,k)=>{const T=E.user_id===C||E.username===C?-1:0,I=k.user_id===C||k.username===C?-1:0;return T-I});o($)}).catch(()=>{}).finally(()=>f(!1)))},[e]);const g=async()=>{if(!s.length){Ze.warning("请至少选择一位用户");return}if(!i){Ze.warning("缺少结果 ID");return}try{const w=localStorage.getItem("sso_company")||"";await h.mutateAsync({resultId:i,data:{targets:s.map(_=>({user_id:_,company_code:w,type:"to_user"})),message:c||void 0}});const S=a.filter(_=>s.includes(_.user_id)).map(_=>_.display_name||_.username).join("、");Ze.success(`已流转给 ${S}`),l([]),u(""),t()}catch(w){Ze.error(w instanceof Error?w.message:"流转失败")}},v=()=>{l([]),u(""),t()},y=localStorage.getItem("sso_user_id")||localStorage.getItem("sso_username")||"",x=a.map(w=>({value:w.user_id,label:w.user_id===y||w.username===y?`${w.display_name||w.username}(我)`:w.display_name||w.username,desc:w.username}));return b.jsx(rr,{title:"👤 对内流转",open:e,onCancel:v,onOk:g,okText:"确认流转",cancelText:"取消",width:420,confirmLoading:h.isPending,children:b.jsxs(pa,{orientation:"vertical",style:{width:"100%"},size:16,children:[b.jsxs("div",{children:[b.jsx(tF,{type:"secondary",style:{display:"block",marginBottom:8},children:"选择接收结果的内部用户:"}),b.jsx(tn,{mode:"multiple",style:{width:"100%"},placeholder:"搜索并选择用户...",value:s,onChange:l,loading:d,showSearch:!0,filterOption:(w,S)=>((S==null?void 0:S.label)??"").toLowerCase().includes(w.toLowerCase()),options:x,optionRender:w=>{var S;return b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#1677ff",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:600,flexShrink:0},children:((S=w.label)==null?void 0:S[0])??"?"}),b.jsxs("div",{children:[b.jsx("div",{style:{fontSize:13},children:w.label}),w.data.desc&&b.jsx("div",{style:{fontSize:11,color:"#9ca3af"},children:w.data.desc})]})]})}})]}),b.jsxs("div",{children:[b.jsx(tF,{type:"secondary",style:{display:"block",marginBottom:6},children:"留言(可选)"}),b.jsx(Kt.TextArea,{rows:2,value:c,onChange:w=>u(w.target.value),placeholder:"附上说明信息..."})]}),b.jsx(c$,{type:"info",showIcon:!0,style:{fontSize:12},title:b.jsxs("span",{children:["流转后接收方可在 ",b.jsx(tF,{strong:!0,children:"结果收件箱"})," 中查看"]})})]})})}function Wd(e,t,n,r){return e?{type:e,content:t,fields_map:n||void 0,title:r}:t}function I_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function gZt(e){return e.map(t=>I_(t)?t:{value:t})}function Fje(e){if(!I_(e))return e;const t=typeof e.output_type=="string"?e.output_type:"",n=e.data??e.output,r=Array.isArray(e.output_fields_map)?e.output_fields_map:void 0,i=typeof e.title=="string"?e.title:void 0;if(t!=="dynamic_form"){if(t==="card"&&I_(n)&&typeof n.content=="string")return n.content;if(Array.isArray(n)){const a=gZt(n),o=r!=null&&r.length?r:n.every(s=>!I_(s))?[{name:"value",label:"结果"}]:void 0;return Wd("table",a,o,i)}return I_(n)?t==="debug"&&!(r!=null&&r.length)?Wd("debug",n,void 0,i):Wd("card",n,r,i):t?Wd(t,n,r,i):q2(e)}}function q2(e){var n,r;if(!e||typeof e!="object")return e;const t=e;return typeof t.type=="string"?e:t.output_type?Wd(t.output_type,t.data??t.output,t.output_fields_map,t.title):((n=t.output)==null?void 0:n.content)!==void 0?t.output.content:t.output!==void 0?t.output:((r=t.data)==null?void 0:r.content)!==void 0?t.data.content:t.content!==void 0?t.content:e}const{Text:yye}=ec,nF={pending:"待执行",running:"执行中",awaiting_async:"等待异步结果",waiting_input:"等待人工确认",completed:"已完成",failed:"失败"};function vZt(e){return e==="completed"?"finish":e==="failed"?"error":e==="running"||e==="awaiting_async"||e==="waiting_input"?"process":"wait"}function yZt(e,t){if(!e.length)return 0;const n=e.findIndex(i=>i.status==="running"||i.status==="awaiting_async"||i.status==="waiting_input");if(n>=0)return n;if(t==="completed")return e.length-1;const r=e.findIndex(i=>i.status==="pending");return r>=0?r:0}function $P(e){return e!=null?`${(e/1e3).toFixed(1)}s`:void 0}const bZt={pending:"待执行",running:"执行中",completed:"已完成",failed:"失败"};function uee(e){var t;return(t=e==null?void 0:e.substeps)!=null&&t.length?e.substeps.find(n=>n.status==="running")??e.substeps[e.substeps.length-1]:null}function xZt(e){const t=e.find(n=>n.status==="running"||n.status==="awaiting_async");return uee(t)}function wZt(e){if(!Array.isArray(e))return;const t=[];for(const n of e){const r=n.name||n.key;r&&t.push({name:r,label:n.label||r,type:n.type})}return t}function SZt(e){return e.output_content===void 0?null:!e.output_type||e.output_type==="text"?e.output_content:Wd(e.output_type,e.output_content,wZt(e.output_fields_map),e.substep_name)}function _Zt(e){var i;if(!((i=e==null?void 0:e.substeps)!=null&&i.length))return"";const t=uee(e),n=(t==null?void 0:t.substep_total)||e.substeps.length,r=e.substeps.filter(a=>a.status==="completed").length;return(t==null?void 0:t.status)==="running"?t.message||`正在执行:${t.substep_name}`:(t==null?void 0:t.status)==="failed"?`${t.substep_name} 执行失败`:`${r}/${n} 个子步骤已完成`}function CZt({agentId:e,inputData:t,onFinish:n,onCompleted:r,onRerun:i,onBackToParams:a,hasInputParams:o,skipAutoStart:s}){const{executionSteps:l,latestSSEEvent:c,currentExecutionId:u}=Er(),{startExecution:d,resumeExecution:f,abort:p}=rJ(),[h,g]=m.useState("running"),[v,y]=m.useState(null),[x,w]=m.useState(null),[S,_]=m.useState(null),[C,$]=m.useState(!1),[E,k]=m.useState(!1),[T,I]=m.useState(null),[P,N]=m.useState(null),[A,M]=m.useState(null),R=m.useRef(!1),L=m.useRef(r),z=m.useRef(l),j=m.useRef(u);m.useEffect(()=>{L.current=r},[r]),m.useEffect(()=>{z.current=l},[l]),m.useEffect(()=>{j.current=u},[u]),m.useEffect(()=>{if(!s&&!R.current)return R.current=!0,d(e,t).catch(ee=>{const te=ee instanceof Error?ee.message:"执行失败";y(te),g("failed")}),()=>{p()}},[p,e,t,s,d]),m.useEffect(()=>{var te,oe,fe;if(!c)return;const ee=c;switch(ee.type){case"execution_init":M(((oe=(te=ee.steps)==null?void 0:te[0])==null?void 0:oe.step_id)??null);break;case"execution_started":g("running");break;case"resume_init":g("running");break;case"re_executing":g("running"),ee.step_id&&M(ee.step_id);break;case"step_running":g("running"),ee.step_id&&M(ee.step_id);break;case"step_awaiting_async":case"step_pending_async":g("running"),ee.step_id&&M(ee.step_id);break;case"step_completed":ee.step_id&&M(ee.step_id);break;case"step_failed":y(ee.error||ee.error_message||"执行失败"),ee.step_id&&M(ee.step_id);break;case"waiting_input":g("waiting_input"),ee.step_id&&M(ee.step_id),w(ee.step_id??null);{const he=Sj(ee);_({...he,return_step_id:Rg(he,z.current)});const ye=j.current;ye&&I1(ye,ee.step_id).then(Te=>{if(!Te)return;const Ee={...Te,return_step_id:Rg(Te,z.current)};w(Ee.step_id),_(Ee),M(Ee.step_id)}).catch(()=>{})}break;case"execution_completed":g("completed"),ee.final_output&&I(ee.final_output),ee.result_id&&N(ee.result_id),(fe=L.current)==null||fe.call(L,ee.result_id??null);break;case"execution_failed":g("failed"),y(ee.error||ee.error_message||"执行失败");break;case"timeout":y("执行超时"),g("failed");break}},[c]);const O=async ee=>{const te=(S==null?void 0:S.step_id)||x,oe=ee.action==="return_previous"?Rg(S,l):te;if(!(!u||!oe)){g("running"),w(null),_(null),$(!0);try{if(await f(Number(u),oe,ee.inputData,{action:ee.action,confirmedInput:ee.confirmedInput,modifiedParams:ee.modifiedParams}),ee.action==="return_previous"){const fe=await I1(u,oe);if(fe){const he={...fe,return_step_id:Rg(fe,l)};w(he.step_id),_(he),M(he.step_id),g("waiting_input")}return}ee.action==="cancel"&&(y("执行已取消"),g("cancelled"))}catch(fe){const he=fe instanceof Error?fe.message:"恢复执行失败";y(he),g("failed")}finally{$(!1)}}},V=ee=>q2(ee),B=yZt(l,h),D=l[B],H=l.find(ee=>ee.step_id===A)||D,W=H?V(H.output_data):null,K=(H==null?void 0:H.substeps)??[],U=xZt(l),q=D?uee(D):null,Q=(H==null?void 0:H.status)==="completed"&&W!=null,G=!!(H&&(Q||K.length>0)),X=l.map((ee,te)=>{const oe=te===B,fe=$P(ee.duration_ms),he=_Zt(ee);let ye=nF[ee.status]||ee.status||"";return oe&&h==="waiting_input"?ye="待人工处理":oe&&he?ye=he:oe&&(ee.status==="running"||ee.status==="awaiting_async")?ye="处理中":ee.status==="completed"?ye=fe?`耗时 ${fe}`:"已完成":ee.requires_human_confirm&&ee.status==="pending"&&(ye="待人工确认"),{key:ee.step_id,status:vZt(ee.status),title:ee.step_name||`步骤 ${te+1}`,description:b.jsx("span",{className:"exec-tracker__step-desc",children:ye})}}),J=()=>{if(T)try{const ee=T.output_type||"debug",te=T.output,oe=T.output_fields_map,fe=new Date().toISOString().slice(0,10);if(ee==="table"&&Array.isArray(te)){const he=Array.isArray(oe)&&oe.length>0?oe.map(ne=>({name:ne.name,label:ne.label||ne.name})):Object.keys(te[0]||{}).map(ne=>({name:ne,label:ne})),ye=he.map(ne=>ne.label).join(","),Te=te.map(ne=>he.map(ge=>{const be=ne[ge.name],Ce=be==null?"":String(be);return Ce.includes(",")||Ce.includes('"')||Ce.includes(`
|
|
788
|
+
deps: ${u}}`};const i={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(l){const[c,u]=a(l);o(l,c),s(l,u)}};function a({schema:l}){const c={},u={};for(const d in l){if(d==="__proto__")continue;const f=Array.isArray(l[d])?c:u;f[d]=l[d]}return[c,u]}function o(l,c=l.schema){const{gen:u,data:d,it:f}=l;if(Object.keys(c).length===0)return;const p=u.let("missing");for(const h in c){const g=c[h];if(g.length===0)continue;const v=(0,r.propertyInData)(u,d,h,f.opts.ownProperties);l.setParams({property:h,depsCount:g.length,deps:g.join(", ")}),f.allErrors?u.if(v,()=>{for(const y of g)(0,r.checkReportMissingProp)(l,y)}):(u.if((0,t._)`${v} && (${(0,r.checkMissingProp)(l,g,p)})`),(0,r.reportMissingProp)(l,p),u.else())}}e.validatePropertyDeps=o;function s(l,c=l.schema){const{gen:u,data:d,keyword:f,it:p}=l,h=u.name("valid");for(const g in c)(0,n.alwaysValidSchema)(p,c[g])||(u.if((0,r.propertyInData)(u,d,g,p.opts.ownProperties),()=>{const v=l.subschema({keyword:f,schemaProp:g},h);l.mergeValidEvaluated(v,h)},()=>u.var(h,!0)),l.ok(h))}e.validateSchemaDeps=s,e.default=i})(uje);var zJ={};Object.defineProperty(zJ,"__esModule",{value:!0});const dje=Wn,XKt=zt,ZKt={message:"property name must be valid",params:({params:e})=>(0,dje._)`{propertyName: ${e.propertyName}}`},QKt={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:ZKt,code(e){const{gen:t,schema:n,data:r,it:i}=e;if((0,XKt.alwaysValidSchema)(i,n))return;const a=t.name("valid");t.forIn("key",r,o=>{e.setParams({propertyName:o}),e.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},a),t.if((0,dje.not)(a),()=>{e.error(!0),i.allErrors||t.break()})}),e.ok(a)}};zJ.default=QKt;var pj={};Object.defineProperty(pj,"__esModule",{value:!0});const wP=Xn,uc=Wn,JKt=cd,SP=zt,eYt={message:"must NOT have additional properties",params:({params:e})=>(0,uc._)`{additionalProperty: ${e.additionalProperty}}`},tYt={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:eYt,code(e){const{gen:t,schema:n,parentSchema:r,data:i,errsCount:a,it:o}=e;if(!a)throw new Error("ajv implementation error");const{allErrors:s,opts:l}=o;if(o.props=!0,l.removeAdditional!=="all"&&(0,SP.alwaysValidSchema)(o,n))return;const c=(0,wP.allSchemaProperties)(r.properties),u=(0,wP.allSchemaProperties)(r.patternProperties);d(),e.ok((0,uc._)`${a} === ${JKt.default.errors}`);function d(){t.forIn("key",i,v=>{!c.length&&!u.length?h(v):t.if(f(v),()=>h(v))})}function f(v){let y;if(c.length>8){const x=(0,SP.schemaRefOrVal)(o,r.properties,"properties");y=(0,wP.isOwnProperty)(t,x,v)}else c.length?y=(0,uc.or)(...c.map(x=>(0,uc._)`${v} === ${x}`)):y=uc.nil;return u.length&&(y=(0,uc.or)(y,...u.map(x=>(0,uc._)`${(0,wP.usePattern)(e,x)}.test(${v})`))),(0,uc.not)(y)}function p(v){t.code((0,uc._)`delete ${i}[${v}]`)}function h(v){if(l.removeAdditional==="all"||l.removeAdditional&&n===!1){p(v);return}if(n===!1){e.setParams({additionalProperty:v}),e.error(),s||t.break();return}if(typeof n=="object"&&!(0,SP.alwaysValidSchema)(o,n)){const y=t.name("valid");l.removeAdditional==="failing"?(g(v,y,!1),t.if((0,uc.not)(y),()=>{e.reset(),p(v)})):(g(v,y),s||t.if((0,uc.not)(y),()=>t.break()))}}function g(v,y,x){const w={keyword:"additionalProperties",dataProp:v,dataPropType:SP.Type.Str};x===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(w,y)}}};pj.default=tYt;var FJ={};Object.defineProperty(FJ,"__esModule",{value:!0});const nYt=Mc,Yve=Xn,Z6=zt,Xve=pj,rYt={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,parentSchema:r,data:i,it:a}=e;a.opts.removeAdditional==="all"&&r.additionalProperties===void 0&&Xve.default.code(new nYt.KeywordCxt(a,Xve.default,"additionalProperties"));const o=(0,Yve.allSchemaProperties)(n);for(const d of o)a.definedProperties.add(d);a.opts.unevaluated&&o.length&&a.props!==!0&&(a.props=Z6.mergeEvaluated.props(t,(0,Z6.toHash)(o),a.props));const s=o.filter(d=>!(0,Z6.alwaysValidSchema)(a,n[d]));if(s.length===0)return;const l=t.name("valid");for(const d of s)c(d)?u(d):(t.if((0,Yve.propertyInData)(t,i,d,a.opts.ownProperties)),u(d),a.allErrors||t.else().var(l,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(l);function c(d){return a.opts.useDefaults&&!a.compositeRule&&n[d].default!==void 0}function u(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},l)}}};FJ.default=rYt;var BJ={};Object.defineProperty(BJ,"__esModule",{value:!0});const Zve=Xn,_P=Wn,Qve=zt,Jve=zt,iYt={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,data:r,parentSchema:i,it:a}=e,{opts:o}=a,s=(0,Zve.allSchemaProperties)(n),l=s.filter(g=>(0,Qve.alwaysValidSchema)(a,n[g]));if(s.length===0||l.length===s.length&&(!a.opts.unevaluated||a.props===!0))return;const c=o.strictSchema&&!o.allowMatchingProperties&&i.properties,u=t.name("valid");a.props!==!0&&!(a.props instanceof _P.Name)&&(a.props=(0,Jve.evaluatedPropsToName)(t,a.props));const{props:d}=a;f();function f(){for(const g of s)c&&p(g),a.allErrors?h(g):(t.var(u,!0),h(g),t.if(u))}function p(g){for(const v in c)new RegExp(g).test(v)&&(0,Qve.checkStrictMode)(a,`property ${v} matches pattern ${g} (use allowMatchingProperties)`)}function h(g){t.forIn("key",r,v=>{t.if((0,_P._)`${(0,Zve.usePattern)(e,g)}.test(${v})`,()=>{const y=l.includes(g);y||e.subschema({keyword:"patternProperties",schemaProp:g,dataProp:v,dataPropType:Jve.Type.Str},u),a.opts.unevaluated&&d!==!0?t.assign((0,_P._)`${d}[${v}]`,!0):!y&&!a.allErrors&&t.if((0,_P.not)(u),()=>t.break())})})}}};BJ.default=iYt;var VJ={};Object.defineProperty(VJ,"__esModule",{value:!0});const aYt=zt,oYt={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:n,it:r}=e;if((0,aYt.alwaysValidSchema)(r,n)){e.fail();return}const i=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),e.failResult(i,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};VJ.default=oYt;var HJ={};Object.defineProperty(HJ,"__esModule",{value:!0});const sYt=Xn,lYt={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:sYt.validateUnion,error:{message:"must match a schema in anyOf"}};HJ.default=lYt;var WJ={};Object.defineProperty(WJ,"__esModule",{value:!0});const qN=Wn,cYt=zt,uYt={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,qN._)`{passingSchemas: ${e.passing}}`},dYt={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:uYt,code(e){const{gen:t,schema:n,parentSchema:r,it:i}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(i.opts.discriminator&&r.discriminator)return;const a=n,o=t.let("valid",!1),s=t.let("passing",null),l=t.name("_valid");e.setParams({passing:s}),t.block(c),e.result(o,()=>e.reset(),()=>e.error(!0));function c(){a.forEach((u,d)=>{let f;(0,cYt.alwaysValidSchema)(i,u)?t.var(l,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},l),d>0&&t.if((0,qN._)`${l} && ${o}`).assign(o,!1).assign(s,(0,qN._)`[${s}, ${d}]`).else(),t.if(l,()=>{t.assign(o,!0),t.assign(s,d),f&&e.mergeEvaluated(f,qN.Name)})})}}};WJ.default=dYt;var UJ={};Object.defineProperty(UJ,"__esModule",{value:!0});const fYt=zt,pYt={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:n,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");const i=t.name("valid");n.forEach((a,o)=>{if((0,fYt.alwaysValidSchema)(r,a))return;const s=e.subschema({keyword:"allOf",schemaProp:o},i);e.ok(i),e.mergeEvaluated(s)})}};UJ.default=pYt;var GJ={};Object.defineProperty(GJ,"__esModule",{value:!0});const nD=Wn,fje=zt,hYt={message:({params:e})=>(0,nD.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,nD._)`{failingKeyword: ${e.ifClause}}`},mYt={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:hYt,code(e){const{gen:t,parentSchema:n,it:r}=e;n.then===void 0&&n.else===void 0&&(0,fje.checkStrictMode)(r,'"if" without "then" and "else" is ignored');const i=eye(r,"then"),a=eye(r,"else");if(!i&&!a)return;const o=t.let("valid",!0),s=t.name("_valid");if(l(),e.reset(),i&&a){const u=t.let("ifClause");e.setParams({ifClause:u}),t.if(s,c("then",u),c("else",u))}else i?t.if(s,c("then")):t.if((0,nD.not)(s),c("else"));e.pass(o,()=>e.error(!0));function l(){const u=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},s);e.mergeEvaluated(u)}function c(u,d){return()=>{const f=e.subschema({keyword:u},s);t.assign(o,s),e.mergeValidEvaluated(f,o),d?t.assign(d,(0,nD._)`${u}`):e.setParams({ifClause:u})}}}};function eye(e,t){const n=e.schema[t];return n!==void 0&&!(0,fje.alwaysValidSchema)(e,n)}GJ.default=mYt;var qJ={};Object.defineProperty(qJ,"__esModule",{value:!0});const gYt=zt,vYt={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){t.if===void 0&&(0,gYt.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};qJ.default=vYt;Object.defineProperty(DJ,"__esModule",{value:!0});const yYt=Nw,bYt=OJ,xYt=Aw,wYt=LJ,SYt=jJ,_Yt=uje,CYt=zJ,$Yt=pj,EYt=FJ,TYt=BJ,IYt=VJ,kYt=HJ,PYt=WJ,NYt=UJ,AYt=GJ,MYt=qJ;function RYt(e=!1){const t=[IYt.default,kYt.default,PYt.default,NYt.default,AYt.default,MYt.default,CYt.default,$Yt.default,_Yt.default,EYt.default,TYt.default];return e?t.push(bYt.default,wYt.default):t.push(yYt.default,xYt.default),t.push(SYt.default),t}DJ.default=RYt;var KJ={},YJ={};Object.defineProperty(YJ,"__esModule",{value:!0});const ki=Wn,DYt={message:({schemaCode:e})=>(0,ki.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ki._)`{format: ${e}}`},OYt={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:DYt,code(e,t){const{gen:n,data:r,$data:i,schema:a,schemaCode:o,it:s}=e,{opts:l,errSchemaPath:c,schemaEnv:u,self:d}=s;if(!l.validateFormats)return;i?f():p();function f(){const h=n.scopeValue("formats",{ref:d.formats,code:l.code.formats}),g=n.const("fDef",(0,ki._)`${h}[${o}]`),v=n.let("fType"),y=n.let("format");n.if((0,ki._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>n.assign(v,(0,ki._)`${g}.type || "string"`).assign(y,(0,ki._)`${g}.validate`),()=>n.assign(v,(0,ki._)`"string"`).assign(y,g)),e.fail$data((0,ki.or)(x(),w()));function x(){return l.strictSchema===!1?ki.nil:(0,ki._)`${o} && !${y}`}function w(){const S=u.$async?(0,ki._)`(${g}.async ? await ${y}(${r}) : ${y}(${r}))`:(0,ki._)`${y}(${r})`,_=(0,ki._)`(typeof ${y} == "function" ? ${S} : ${y}.test(${r}))`;return(0,ki._)`${y} && ${y} !== true && ${v} === ${t} && !${_}`}}function p(){const h=d.formats[a];if(!h){x();return}if(h===!0)return;const[g,v,y]=w(h);g===t&&e.pass(S());function x(){if(l.strictSchema===!1){d.logger.warn(_());return}throw new Error(_());function _(){return`unknown format "${a}" ignored in schema at path "${c}"`}}function w(_){const C=_ instanceof RegExp?(0,ki.regexpCode)(_):l.code.formats?(0,ki._)`${l.code.formats}${(0,ki.getProperty)(a)}`:void 0,$=n.scopeValue("formats",{key:a,ref:_,code:C});return typeof _=="object"&&!(_ instanceof RegExp)?[_.type||"string",_.validate,(0,ki._)`${$}.validate`]:["string",_,$]}function S(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!u.$async)throw new Error("async format in sync schema");return(0,ki._)`await ${y}(${r})`}return typeof v=="function"?(0,ki._)`${y}(${r})`:(0,ki._)`${y}.test(${r})`}}}};YJ.default=OYt;Object.defineProperty(KJ,"__esModule",{value:!0});const LYt=YJ,jYt=[LYt.default];KJ.default=jYt;var $1={};Object.defineProperty($1,"__esModule",{value:!0});$1.contentVocabulary=$1.metadataVocabulary=void 0;$1.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];$1.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(xJ,"__esModule",{value:!0});const zYt=wJ,FYt=_J,BYt=DJ,VYt=KJ,tye=$1,HYt=[zYt.default,FYt.default,(0,BYt.default)(),VYt.default,tye.metadataVocabulary,tye.contentVocabulary];xJ.default=HYt;var XJ={},hj={};Object.defineProperty(hj,"__esModule",{value:!0});hj.DiscrError=void 0;var nye;(function(e){e.Tag="tag",e.Mapping="mapping"})(nye||(hj.DiscrError=nye={}));Object.defineProperty(XJ,"__esModule",{value:!0});const X0=Wn,VU=hj,rye=vs,WYt=Pw,UYt=zt,GYt={message:({params:{discrError:e,tagName:t}})=>e===VU.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>(0,X0._)`{error: ${e}, tag: ${n}, tagValue: ${t}}`},qYt={keyword:"discriminator",type:"object",schemaType:"object",error:GYt,code(e){const{gen:t,data:n,schema:r,parentSchema:i,it:a}=e,{oneOf:o}=i;if(!a.opts.discriminator)throw new Error("discriminator: requires discriminator option");const s=r.propertyName;if(typeof s!="string")throw new Error("discriminator: requires propertyName");if(r.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");const l=t.let("valid",!1),c=t.const("tag",(0,X0._)`${n}${(0,X0.getProperty)(s)}`);t.if((0,X0._)`typeof ${c} == "string"`,()=>u(),()=>e.error(!1,{discrError:VU.DiscrError.Tag,tag:c,tagName:s})),e.ok(l);function u(){const p=f();t.if(!1);for(const h in p)t.elseIf((0,X0._)`${c} === ${h}`),t.assign(l,d(p[h]));t.else(),e.error(!1,{discrError:VU.DiscrError.Mapping,tag:c,tagName:s}),t.endIf()}function d(p){const h=t.name("valid"),g=e.subschema({keyword:"oneOf",schemaProp:p},h);return e.mergeEvaluated(g,X0.Name),h}function f(){var p;const h={},g=y(i);let v=!0;for(let S=0;S<o.length;S++){let _=o[S];if(_!=null&&_.$ref&&!(0,UYt.schemaHasRulesButRef)(_,a.self.RULES)){const $=_.$ref;if(_=rye.resolveRef.call(a.self,a.schemaEnv.root,a.baseId,$),_ instanceof rye.SchemaEnv&&(_=_.schema),_===void 0)throw new WYt.default(a.opts.uriResolver,a.baseId,$)}const C=(p=_==null?void 0:_.properties)===null||p===void 0?void 0:p[s];if(typeof C!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${s}"`);v=v&&(g||y(_)),x(C,S)}if(!v)throw new Error(`discriminator: "${s}" must be required`);return h;function y({required:S}){return Array.isArray(S)&&S.includes(s)}function x(S,_){if(S.const)w(S.const,_);else if(S.enum)for(const C of S.enum)w(C,_);else throw new Error(`discriminator: "properties/${s}" must have "const" or "enum"`)}function w(S,_){if(typeof S!="string"||S in h)throw new Error(`discriminator: "${s}" values must be unique strings`);h[S]=_}}}};XJ.default=qYt;const KYt="http://json-schema.org/draft-07/schema#",YYt="http://json-schema.org/draft-07/schema#",XYt="Core schema meta-schema",ZYt={schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},QYt=["object","boolean"],JYt={$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},eXt={$schema:KYt,$id:YYt,title:XYt,definitions:ZYt,type:QYt,properties:JYt,default:!0};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const n=dLe,r=xJ,i=XJ,a=eXt,o=["/properties"],s="http://json-schema.org/draft-07/schema";class l extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(h=>this.addVocabulary(h)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const h=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(h,s,!1),this.refs["http://json-schema.org/schema"]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}}t.Ajv=l,e.exports=t=l,e.exports.Ajv=l,Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var c=Mc;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var u=Wn;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=bT;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return d.default}});var f=Pw;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return f.default}})})(DU,DU.exports);var pje=DU.exports;const hje=Co(pje);var HU={exports:{}},mje={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(I,P){return{validate:I,compare:P}}e.fullFormats={date:t(a,o),time:t(l(!0),c),"date-time":t(f(!0),p),"iso-time":t(l(),u),"iso-date-time":t(f(),h),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:y,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:T,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:w,int32:{type:"number",validate:C},int64:{type:"number",validate:$},float:{type:"number",validate:E},double:{type:"number",validate:E},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,c),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,h),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(I){return I%4===0&&(I%100!==0||I%400===0)}const r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(I){const P=r.exec(I);if(!P)return!1;const N=+P[1],A=+P[2],M=+P[3];return A>=1&&A<=12&&M>=1&&M<=(A===2&&n(N)?29:i[A])}function o(I,P){if(I&&P)return I>P?1:I<P?-1:0}const s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function l(I){return function(N){const A=s.exec(N);if(!A)return!1;const M=+A[1],R=+A[2],L=+A[3],z=A[4],j=A[5]==="-"?-1:1,O=+(A[6]||0),V=+(A[7]||0);if(O>23||V>59||I&&!z)return!1;if(M<=23&&R<=59&&L<60)return!0;const B=R-V*j,D=M-O*j-(B<0?1:0);return(D===23||D===-1)&&(B===59||B===-1)&&L<61}}function c(I,P){if(!(I&&P))return;const N=new Date("2020-01-01T"+I).valueOf(),A=new Date("2020-01-01T"+P).valueOf();if(N&&A)return N-A}function u(I,P){if(!(I&&P))return;const N=s.exec(I),A=s.exec(P);if(N&&A)return I=N[1]+N[2]+N[3],P=A[1]+A[2]+A[3],I>P?1:I<P?-1:0}const d=/t|\s/i;function f(I){const P=l(I);return function(A){const M=A.split(d);return M.length===2&&a(M[0])&&P(M[1])}}function p(I,P){if(!(I&&P))return;const N=new Date(I).valueOf(),A=new Date(P).valueOf();if(N&&A)return N-A}function h(I,P){if(!(I&&P))return;const[N,A]=I.split(d),[M,R]=P.split(d),L=o(N,M);if(L!==void 0)return L||c(A,R)}const g=/\/|:/,v=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function y(I){return g.test(I)&&v.test(I)}const x=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function w(I){return x.lastIndex=0,x.test(I)}const S=-2147483648,_=2**31-1;function C(I){return Number.isInteger(I)&&I<=_&&I>=S}function $(I){return Number.isInteger(I)}function E(){return!0}const k=/[^\\]\\Z/;function T(I){if(k.test(I))return!1;try{return new RegExp(I),!0}catch{return!1}}})(mje);var gje={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=pje,n=Wn,r=n.operators,i={formatMaximum:{okStr:"<=",ok:r.LTE,fail:r.GT},formatMinimum:{okStr:">=",ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:"<",ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:">",ok:r.GT,fail:r.LTE}},a={message:({keyword:s,schemaCode:l})=>(0,n.str)`should be ${i[s].okStr} ${l}`,params:({keyword:s,schemaCode:l})=>(0,n._)`{comparison: ${i[s].okStr}, limit: ${l}}`};e.formatLimitDefinition={keyword:Object.keys(i),type:"string",schemaType:"string",$data:!0,error:a,code(s){const{gen:l,data:c,schemaCode:u,keyword:d,it:f}=s,{opts:p,self:h}=f;if(!p.validateFormats)return;const g=new t.KeywordCxt(f,h.RULES.all.format.definition,"format");g.$data?v():y();function v(){const w=l.scopeValue("formats",{ref:h.formats,code:p.code.formats}),S=l.const("fmt",(0,n._)`${w}[${g.schemaCode}]`);s.fail$data((0,n.or)((0,n._)`typeof ${S} != "object"`,(0,n._)`${S} instanceof RegExp`,(0,n._)`typeof ${S}.compare != "function"`,x(S)))}function y(){const w=g.schema,S=h.formats[w];if(!S||S===!0)return;if(typeof S!="object"||S instanceof RegExp||typeof S.compare!="function")throw new Error(`"${d}": format "${w}" does not define "compare" function`);const _=l.scopeValue("formats",{key:w,ref:S,code:p.code.formats?(0,n._)`${p.code.formats}${(0,n.getProperty)(w)}`:void 0});s.fail$data(x(_))}function x(w){return(0,n._)`${w}.compare(${c}, ${u}) ${i[d].fail} 0`}},dependencies:["format"]};const o=s=>(s.addKeyword(e.formatLimitDefinition),s);e.default=o})(gje);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n=mje,r=gje,i=Wn,a=new i.Name("fullFormats"),o=new i.Name("fastFormats"),s=(c,u={keywords:!0})=>{if(Array.isArray(u))return l(c,u,n.fullFormats,a),c;const[d,f]=u.mode==="fast"?[n.fastFormats,o]:[n.fullFormats,a],p=u.formats||n.formatNames;return l(c,p,d,f),u.keywords&&(0,r.default)(c),c};s.get=(c,u="full")=>{const f=(u==="fast"?n.fastFormats:n.fullFormats)[c];if(!f)throw new Error(`Unknown format "${c}"`);return f};function l(c,u,d,f){var p,h;(p=(h=c.opts.code).formats)!==null&&p!==void 0||(h.formats=(0,i._)`require("ajv-formats/dist/formats").${f}`);for(const g of u)c.addFormat(g,d[g])}e.exports=t=s,Object.defineProperty(t,"__esModule",{value:!0}),t.default=s})(HU,HU.exports);var tXt=HU.exports;const vje=Co(tXt),iye=new WeakMap;function nXt(e){const t=iye.get(e);if(t)return t;const n=new hje({allErrors:!0,strict:!1,validateSchema:!1,multipleOfPrecision:8});vje(n);const{$schema:r,...i}=e,a=n.compile(i);return iye.set(e,a),a}function rXt(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function iXt(e){return e.split("/").slice(1).map(rXt).join(".")}function aXt(e){const t=e.params;return typeof t.missingProperty=="string"?t.missingProperty:""}function oXt(e,t){const n=t.split(".").filter(Boolean);let r=e;for(const i of n){if(!Ut(r))return{};if(typeof r.$ref=="string"&&(r=iJ(e,r.$ref)),!Ut(r))return{};if((r.type==="array"||/^\d+$/.test(i))&&(r=r.items,/^\d+$/.test(i)))continue;if(!Ut(r))return{};r=(Ut(r.properties)?r.properties:{})[i]}return Ut(r)?r:{}}function sXt(e){const t=iXt(e.instancePath);if(e.keyword!=="required")return t;const n=aXt(e);return[t,n].filter(Boolean).join(".")}function lXt(e,t,n){const r=oXt(t,n),i=n.split("."),a=i[i.length-1]||"字段",o=XR(a,r);return e.keyword==="required"?`请输入${o}`:e.keyword==="enum"?`${o}不在可选范围内`:e.keyword==="format"||e.keyword==="pattern"?`${o}格式不正确`:e.keyword==="type"?`${o}类型不正确`:e.keyword==="minLength"?`${o}长度不足`:e.keyword==="maxLength"?`${o}长度超出限制`:e.keyword==="minimum"||e.keyword==="exclusiveMinimum"?`${o}数值过小`:e.keyword==="maximum"||e.keyword==="exclusiveMaximum"?`${o}数值过大`:e.keyword==="multipleOf"?`${o}数值不符合步进要求`:e.keyword==="minItems"?`${o}数量不足`:e.keyword==="maxItems"?`${o}数量超出限制`:e.keyword==="not"?`${o}与当前条件组合冲突`:`${o}不符合规则`}function aye(e,t,n=t){const r=YR(e,t),i=KR(e,r,e,n),a=Ut(i)?i:t;try{const o=nXt(e);if(o(a))return{valid:!0,errors:{},value:a};const l={};for(const c of o.errors||[]){if(c.keyword==="if"||c.keyword==="additionalProperties")continue;const u=sXt(c);!u||l[u]||(l[u]=lXt(c,e,u))}return{valid:Object.keys(l).length===0,errors:l,value:a}}catch(o){return{valid:!1,errors:{$schema:o instanceof Error?o.message:"Schema 校验失败"},value:a}}}function US(e,t,n=[]){const r=YR(e,t,e,n);return Ut(r)?r:{}}const yje=m.forwardRef(function({schema:t,value:n,defaultValue:r,onChange:i,onSubmit:a,onValidationChange:o,externalErrors:s={},loadOptions:l,uploadFile:c,disableFileUpload:u=!1,disabled:d=!1,respectReadonly:f=!1,showArrayControls:p=!0,groupDisplay:h="collapse",groupAccordion:g=!1,destroyInactiveGroups:v=!1,defaultExpandedGroupKeys:y=[],expandedGroupKeys:x,onExpandedGroupKeysChange:w,visibleFieldPaths:S,validateTrigger:_="submit",formSize:C="small",formLayout:$="vertical",formLabelAlign:E,formLabelCol:k,formWrapperCol:T,formId:I,className:P,emptyContent:N=null,footer:A},M){const[R]=pn.useForm(),L=Ut(t.properties)?t.properties:{},z=m.useMemo(()=>({type:"object",...t,properties:L}),[L,t]),j=m.useMemo(()=>ZR(z),[z]),O=m.useMemo(()=>US(z,Ave(j,r)),[r,z,j]),V=n!==void 0,[B,D]=m.useState(O),[F,H]=m.useState(()=>new Map),W=m.useMemo(()=>US(z,V&&n!==void 0?n:B),[V,B,z,n]),K=m.useMemo(()=>{const re=US(z,Ave(j,W));return Array.from(F.values()).reduce((ee,te)=>kC(ee,te,void 0),re)},[F,z,j,W]),[U,q]=m.useState({}),Q=m.useMemo(()=>S===void 0?void 0:new Set(S),[S]),G=m.useMemo(()=>({...U,...s}),[U,s]);m.useEffect(()=>{V||D(O)},[V,O]);const X=m.useCallback(()=>{const re=aye(z,K,W);return q(re.errors),o==null||o(re),re},[K,o,z,W]),J=m.useCallback((re,ee)=>{const te=US(z,kC(W,re,ee),re),oe=re.map(String).join(".");H(Te=>{const Ee=new Map(Te);return ee===void 0?Ee.set(oe,[...re]):Ee.delete(oe),Ee});const fe=US(z,kC(K,re,ee),re),he=KR(z,fe,z,te),ye=Ut(he)?he:te;if(V||D(ye),i==null||i(ye),q(Te=>Object.fromEntries(Object.entries(Te).filter(([Ee])=>Ee!==oe&&!Ee.startsWith(`${oe}.`)))),_==="change"){const Te=aye(z,fe,ye);q(Te.errors),o==null||o(Te)}},[V,K,i,o,z,W,_]),Y=m.useCallback(()=>{const re=X();re.valid&&(a==null||a(re.value))},[a,X]);m.useImperativeHandle(M,()=>({validate:X,getValue:()=>K,reset:()=>{V||D(O),H(new Map),i==null||i(O),q({})},submit:()=>R.submit()}),[V,K,R,O,i,X]);const Z=Object.keys(L).length>0;return b.jsxs(pn,{form:R,id:I,size:C,layout:$,labelAlign:E,labelCol:k,wrapperCol:T,colon:!1,className:["schema-dynamic-form",P].filter(Boolean).join(" "),onFinish:Y,children:[Z?b.jsx(RU,{name:"",path:[],schema:z,rootSchema:z,value:K,sourceValue:W,values:K,errors:G,disabled:d,respectReadonly:f,showArrayControls:p,groupDisplay:h,groupAccordion:g,destroyInactiveGroups:v,defaultExpandedGroupKeys:y,expandedGroupKeys:x,onExpandedGroupKeysChange:w,visibleFieldPaths:Q,loadOptions:l,uploadFile:c,disableFileUpload:u,onChange:J}):N,typeof A=="function"?A(K):A]})}),cXt=/^\$\{\s*\{?\s*(result|params)\.([a-zA-Z0-9_.-]+)\s*\}?\s*\}$/,uXt=new Set(["properties","$schema","$id","$defs","definitions","type","required","allOf","anyOf","oneOf","additionalProperties","output_type","output_fields_map","execution_steps","job_id"]),dXt=["battery","num_batteries","number_of_lithium_metal_cells","number_of_lithium_ion_cells","lithium_battery","has_multiple_battery_powered_components","contains_battery_or_cell","battery_contains_free_unabsorbed_liquid","is_battery_non_spillable","non_lithium_battery_packaging","has_replaceable_battery","non_lithium_battery_energy_content","has_less_than_30_percent_state_of_charge","battery_installation_device_type"];function vt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Q6(e,t){return t.split(".").reduce((n,r)=>{if(vt(n))return n[r]},e)}function bje(e){return vt(e)&&"value"in e}function fXt(e){return vt(e)?Object.values(e).some(bje):!1}function WU(e){return bje(e)?e.value:e}function pXt(e){return vt(e)&&vt(e.properties)&&(typeof e.$schema=="string"||typeof e.$id=="string"||typeof e.type=="string"||Array.isArray(e.required))}function Nb(e){let t=e;if(typeof t=="string"&&t.trim())try{t=JSON.parse(t)}catch{t=e}return!Array.isArray(t)||!t.every(vt)?t:Object.assign({},...t)}function oye(e){const t=Array.isArray(e)?e[0]:e;if(typeof t=="boolean")return t;if(vt(t)&&typeof t.value=="boolean")return t.value}function hXt(e){const t=oye(e.batteries_required),n=oye(e.batteries_included);if(t!==!1&&n!==!1)return e;const r={...e};for(const i of dXt)delete r[i];return r}function mj(e){return vt(e)&&vt(e.data)&&(e.output_type==="dynamic_form"||fXt(e.data)||vt(e.data.properties)||vt(e.data.listing_data))?e.data:vt(e)&&vt(e.output)?mj(e.output):e}function mXt(e){if(!vt(e)||!vt(e.properties))return;const t=Object.entries(e).filter(([n])=>!uXt.has(n));if(t.length)return Object.fromEntries(t)}function J6(e,t){if(vt(e))return WU(e[t])}function xje(e,t){if(!vt(e))return;const n=J6(e,t);if(n!==void 0)return t==="listing_data"?Nb(n):n;const r=J6(e,"listing_data");if(t==="listing_data"&&r!==void 0)return Nb(r);const i=J6(r,t);if(i!==void 0)return t==="listing_data"?Nb(i):i;if(t==="listing_data")return Nb(mXt(e))}function gXt(e,t){return xje(e.submitted_input,t)}function wje(e,t){const n=mj(e.output);return xje(n,t)}function rD(e){return vt(e)?Object.values(e).some(t=>vt(t)&&("type"in t||"title"in t||"items"in t)):!1}function wT(e){if(!vt(e))return null;if(vt(e.properties)&&rD(e.properties))return e.properties;if(vt(e.properties)){const t=wT(e.properties);if(t)return t}return rD(e)?e:null}function W2(e){const t=n=>{if(!vt(n))return null;if(pXt(n))return n;if(vt(n.properties)){const r=t(n.properties);if(r)return r}return wT(n)?n:null};if(vt(e)&&vt(e.data)&&vt(e.data.properties))return t(e.data.properties);if(vt(e)&&vt(e.data)){const n=t(e.data);if(n)return n}return vt(e)&&vt(e.output)?W2(e.output):vt(e)?t(e):null}function KN(e){return wT(W2(e))}function Mg(e,t){if(typeof e!="string")return e;const n=e.match(cXt);if(!(n!=null&&n[1])||!n[2])return e;if(n[1]==="params")return Q6(t.input,n[2]);const r=mj(t.output),i=Q6(r,n[2]);if(i!==void 0)return i;if(vt(t.output)&&vt(t.output.data)){const a=Q6(t.output.data,n[2]);if(a!==void 0)return a}}function vXt(e){let t="";for(let n=0;n<e.length;n+=1){const r=e[n];if(r!=="'"&&r!=='"'){t+=r;continue}const i=r;let a="";for(n+=1;n<e.length;){const o=e[n];if(o==="\\"){const s=e[n+1];if(s!==void 0){a+={b:"\b",f:"\f",n:`
|
|
789
|
+
`,r:"\r",t:" ","\\":"\\",'"':'"',"'":"'"}[s]??`\\${s}`,n+=2;continue}}if(o===i)break;a+=o,n+=1}t+=JSON.stringify(a)}return t.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function ZJ(e){if(vt(e))return e;if(typeof e!="string"||!e.trim())return null;try{const t=JSON.parse(e);return vt(t)?t:null}catch{try{const t=JSON.parse(vXt(e));return vt(t)?t:null}catch{return null}}}function mu(e){const t=Nb(e);return vt(t)?hXt(t):null}function Ei(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function yXt(e){return new TextEncoder().encode(e).length}function hl(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function bXt(e,t){if(t===0)return!0;const n=e/t;return Math.abs(n-Math.round(n))<Number.EPSILON*100}const xXt=["item_name","bullet_point","generic_keyword","product_description","main_product_image_locator"],wXt={item_name:"标题",bullet_point:"五点描述",generic_keyword:"搜索关键词",product_description:"产品描述",main_product_image_locator:"主图"};function SXt(e,t,n){const r=new Set(Object.keys(t)),i=vt(e)?n.schemaArray(e.propertyFocus).map(a=>String(a).trim()).filter(a=>a&&r.has(a)):[];return i.length?i:xXt.filter(a=>r.has(a))}function Z0(e,t,n,r){const i=mu(n);if(!i)return null;const a=r.getEffectiveSchemaProperties(e,t,i),o=r.getEffectiveSchemaRoot(e,t,i);if(!a)return null;const s=SXt(o,a,r);return s.length?{effectiveRoot:o,properties:a,propertyNames:s,schemaValue:i}:null}function Sje(e,t,n,r){return wXt[e]||r.getSchemaTitle(e,t,n)}function QJ(e,t,n,r,i){if(e.includes("image_locator")){const a=i.getVisibleProperties(t,n,r).find(([o])=>o==="media_location");if(a)return a[0]}return i.getPrimaryVisibleChildName(t,n,r)}function _je(e,t,n,r,i){return i.getChildProperties(e,t,n)[r]||{}}function sye(e,t,n){const r=n.resolveSchemaRef(e,t);return vt(r)?hl(r.maxLength):void 0}function JJ(e,t,n,r,i){return i.getSchemaRows(e,t,n,r).map(a=>i.schemaRecord(a))}function GS(e,t,n,r,i){const a=t[n];return a?JJ(e,n,a,r,i).map(o=>{const s=QJ(n,a,r,o,i);return i.schemaString(o[s]).trim()}).filter(Boolean):[]}function Cje(e,t,n,r){const i=Z0(e,t,n,r);if(!i)return e.required&&Ei(n)?{[e.name]:`请输入${e.label}`}:{};const{effectiveRoot:a,properties:o,propertyNames:s,schemaValue:l}=i,c=r.getSchemaDefinitions(e,t),u={};for(const d of s){const f=o[d];if(!f||r.isHiddenSchema(f,c))continue;const p=r.hasRawSchemaPropertyValue(f,l[d],c),h=JJ(l,d,f,c,r);for(const[g,v]of h.entries()){const y=QJ(d,f,c,v,r);if(!y)continue;const x=_je(f,c,v,y,r),w=v[y],S=Sje(d,f,c,r),_=r.isSchemaChildRequiredForForm(d,f,y,v,c,a,l[d]),C=r.schemaErrorKey(e.name,d,y,g);if(_&&Ei(w)||r.shouldValidateMissingNestedSchemaValue(x,w,c,_||p&&r.hasRawSchemaPropertyValue(x,w,c))){u[C]=`请输入${S}`;continue}const $=r.getSchemaValueConstraintError(w,x,S,c);$&&(u[C]=$)}}return u}const{Text:_Xt}=ec;function CXt({properties:e,value:t,definitions:n,helpers:r}){const i=GS(t,e,"item_name",n,r)[0]||"商品标题将显示在这里",a=GS(t,e,"bullet_point",n,r).slice(0,5),o=GS(t,e,"product_description",n,r)[0]||"",s=GS(t,e,"generic_keyword",n,r)[0]||"",l=GS(t,e,"main_product_image_locator",n,r).find(u=>/^https?:\/\//i.test(u)),c=a.length?a:o?[o]:[];return b.jsxs("aside",{className:"wandox-amazon-listing-focus__preview",children:[b.jsx("div",{className:"wandox-amazon-listing-focus__preview-head",children:"AMAZON 前台效果预览 · 实时"}),b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-main",children:[b.jsx("div",{className:"wandox-amazon-listing-focus__preview-image",children:l?b.jsx("img",{className:"wandox-amazon-listing-focus__preview-image-content",src:l,alt:"商品主图预览"}):b.jsx("span",{children:"主图占位"})}),b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-info",children:[b.jsx("div",{className:"wandox-amazon-listing-focus__preview-title",children:i}),b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-rating",children:[b.jsx("span",{className:"wandox-amazon-listing-focus__preview-stars",children:"★★★★★"}),b.jsx("span",{className:"wandox-amazon-listing-focus__preview-rating-link",children:"1,286 ratings"})]}),b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-price",children:[b.jsx("span",{className:"wandox-amazon-listing-focus__preview-price-currency",children:"$"}),b.jsx("span",{className:"wandox-amazon-listing-focus__preview-price-main",children:"29"}),b.jsx("span",{className:"wandox-amazon-listing-focus__preview-price-decimal",children:"99"})]}),b.jsx("div",{className:"wandox-amazon-listing-focus__preview-delivery",children:"✓prime · FREE delivery"})]})]}),b.jsx("div",{className:"wandox-amazon-listing-focus__preview-divider"}),b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-about",children:[b.jsx("strong",{className:"wandox-amazon-listing-focus__preview-about-title",children:"About this item"}),c.length?b.jsx("ul",{className:"wandox-amazon-listing-focus__preview-bullets",children:c.map(u=>b.jsx("li",{children:u},u))}):b.jsx("p",{className:"wandox-amazon-listing-focus__preview-empty",children:"五点描述会显示在这里"}),s&&b.jsxs("div",{className:"wandox-amazon-listing-focus__preview-keywords",children:["关键词:",s]})]})]})}function $Xt({field:e,context:t,definitions:n,helpers:r,disabled:i=!1,errors:a,showOnlyMissing:o,onShowOnlyMissingChange:s,usesExecutionFormLayout:l,createSchemaItemDefaults:c,getForbiddenSchemaNames:u,isReadonlySchema:d,isTopLevelSchemaPropertyRequired:f,renderSchemaForm:p,setErrors:h,updateField:g,updateSchemaRow:v}){const{effectiveRoot:y,properties:x,propertyNames:w,schemaValue:S}=t,_=u(y),C=(P,N,A,M,R)=>{if(i)return;const L=S[P],z=Array.isArray(L)?[...L]:[r.schemaRecord(L)],j={...c(N,n),...r.schemaRecord(z[A]),[M]:R};g(e.name,{...S,[P]:v(L,N,A,j,n)}),h(O=>{const V=r.schemaErrorKey(e.name,P,M,A);if(!O[V]&&!O[e.name])return O;const B={...O};return delete B[V],delete B[e.name],B})},$=P=>{const N=x[P];if(!N||_.has(P)||r.isHiddenSchema(N,n))return null;const A=JJ(S,P,N,n,r),M=A.map((D,F)=>{const H=QJ(P,N,n,D,r);if(!H)return null;const W=_je(N,n,D,H,r);if(r.isHiddenSchema(W,n))return null;const K=r.schemaErrorKey(e.name,P,H,F);return{childName:H,childSchema:W,errorKey:K,row:D,rowIndex:F}}).filter(D=>D!==null);if(!M.length)return null;const R=Sje(P,N,n,r),L=M[0],z=r.schemaString(L.row[L.childName]),j=sye(L.childSchema,n,r),O=P==="bullet_point"||A.length>1,V=P.includes("image_locator"),B=f(y,P)||M.some(({childName:D,row:F})=>r.isSchemaChildRequiredForForm(P,N,D,F,n,y,S[P]));return b.jsxs("section",{className:`wandox-amazon-listing-focus__section wandox-amazon-listing-focus__section--${P}`,children:[b.jsxs("div",{className:"wandox-amazon-listing-focus__section-head",children:[b.jsxs("span",{className:"wandox-amazon-listing-focus__section-title",children:[R,B&&b.jsx("span",{className:"wandox-amazon-listing-focus__required",children:"*"})]}),!O&&j!=null&&b.jsxs("span",{className:"wandox-amazon-listing-focus__counter",children:[z.length," / ",j]})]}),b.jsx("div",{className:"wandox-amazon-listing-focus__rows",children:M.map(({childName:D,childSchema:F,errorKey:H,row:W,rowIndex:K})=>{const U=d(N,n)||d(F,n),q=r.schemaString(W[D]),Q=sye(F,n,r),G=a[H],X=`请输入${R}`,J=Y=>{i||U||C(P,N,K,D,Y)};return b.jsxs("div",{className:"wandox-amazon-listing-focus__field-row",children:[V?b.jsx(Kt,{size:l?"middle":"small",className:"wandox-amazon-listing-focus__input",value:q,onChange:Y=>J(Y.target.value),placeholder:X,status:G?"error":void 0,disabled:i||U}):b.jsx(Kt.TextArea,{size:l?"middle":"small",className:"wandox-amazon-listing-focus__text-area",autoSize:{minRows:P==="product_description"?3:2,maxRows:24},value:q,onChange:Y=>J(Y.target.value),placeholder:X,status:G?"error":void 0,disabled:i||U,showCount:O&&Q!=null?{formatter:({count:Y})=>`${Y} / ${Q}`}:!1}),G&&b.jsx("div",{className:"wandox-amazon-listing-focus__error",children:G})]},`${P}-${K}-${D}`)})})]},P)},E=w.map($).filter(Boolean),k=new Set(w),T=Object.fromEntries(Object.entries(x).filter(([P])=>!k.has(P))),I=Object.keys(T).length>0;return b.jsxs("div",{className:"wandox-amazon-listing-focus-shell",children:[b.jsxs("div",{className:"wandox-amazon-listing-focus",children:[b.jsx("div",{className:"wandox-amazon-listing-focus__editor",children:E.length?E:b.jsx(_Xt,{type:"secondary",children:"暂无可编辑的重点字段"})}),b.jsx(CXt,{properties:x,value:S,definitions:n,helpers:r})]}),I&&b.jsxs("section",{className:"wandox-amazon-listing-focus__remaining",children:[b.jsxs("div",{className:"wandox-amazon-listing-focus__remaining-head",children:[b.jsxs("div",{children:[b.jsx("div",{className:"wandox-amazon-listing-focus__remaining-title",children:"其他刊登参数"}),b.jsx("div",{className:"wandox-amazon-listing-focus__remaining-desc",children:"继续补充和校验模板返回的其他动态表单字段"})]}),b.jsxs("div",{className:"wandox-amazon-listing-focus__remaining-filter",children:[b.jsx("span",{children:"只看需处理项"}),b.jsx(yo,{size:"small",checked:o,onChange:s})]})]}),p(e,T,S)]})]})}function DC(e,t){return t==="input"?e.has("input")||e.has("modify"):e.has(t)}function EXt(e,t){return!!t&&DC(e,"return_previous")}function TXt(e){return e.has("input")?"input":e.has("modify")?"modify":"confirm"}function IXt({actions:e,canReExecute:t,hasInputFields:n,hasOnClose:r,isFormMode:i,mode:a,returnStepId:o}){const s=[],l=[];return EXt(e,o)&&s.push({key:"return_previous",label:"返回上一步",command:"submitReturnPrevious",loading:!0}),a==="review"&&DC(e,"confirm")&&l.push({key:"confirm",label:"确认通过",command:"submitConfirm",loading:!0,primary:!0}),a==="review"&&DC(e,"input")&&n&&l.push({key:"switch_input",label:"修改后确认",command:"switchInput"}),a==="review"&&t&&l.push({key:"switch_re_execute",label:"重新生成",command:"switchReExecute"}),a==="input"&&!i&&l.push({key:"switch_review",label:"返回",command:"switchReview"}),a==="input"&&l.push({key:"submit_input",label:i?"确认提交":"提交修改",command:"submitInput",loading:!0,primary:!0}),a==="re_execute"&&l.push({key:"cancel_re_execute",label:"取消修改",command:"cancelReExecute"},{key:"submit_re_execute",label:"确认重新生成",command:"submitReExecute",loading:!0,primary:!0}),t&&i&&a==="input"&&l.push({key:"form_switch_re_execute",label:"重新生成",command:"switchReExecute"}),DC(e,"cancel")&&a!=="re_execute"&&l.push({key:"cancel",label:"取消执行",command:"submitCancel",danger:!0,loading:!0}),r&&l.push({key:"close",label:"收起",command:"close",disabledWhenSubmitting:!0}),{left:s,right:l}}function kXt(e){return typeof e=="string"?!!e.trim():typeof e=="number"?Number.isFinite(e):typeof e=="boolean"}function Jv(e){if(!Array.isArray(e))return;const t=new Set,n=[];for(const r of e){let i,a;if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")i=r,a=r;else if(r&&typeof r=="object"&&!Array.isArray(r)){const c=r;a=c.value??c.label,i=c.label??a}else continue;if(!kXt(a))continue;const o=String(i??"").trim();if(!o)continue;const s=typeof a=="string"?a.trim():a,l=String(s);t.has(l)||(t.add(l),n.push({label:o,value:s}))}return n.length?n:void 0}function Cl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function PXt(e){return Array.isArray(e)?e:[]}function NXt(e){const t=Cl(e.not)?e.not:{};return new Set(PXt(t.required).map(String))}function Ed(e){if(!Cl(e))return e;const t={...e};Cl(t.properties)&&(t.properties=Object.fromEntries(Object.entries(t.properties).map(([n,r])=>[n,Ed(r)]))),Cl(t.$defs)&&(t.$defs=Object.fromEntries(Object.entries(t.$defs).map(([n,r])=>[n,Ed(r)]))),Cl(t.definitions)&&(t.definitions=Object.fromEntries(Object.entries(t.definitions).map(([n,r])=>[n,Ed(r)]))),Cl(t.items)&&(t.items=Ed(t.items)),Cl(t.additionalProperties)&&(t.additionalProperties=Ed(t.additionalProperties));for(const n of["allOf","anyOf","oneOf"])Array.isArray(t[n])&&(t[n]=t[n].map(Ed));for(const n of["if","then","else","not"])Cl(t[n])&&(t[n]=Ed(t[n]));return t}function AXt({root:e,properties:t}){if(!Cl(e))return{eligible:!1,reason:"missing-schema"};if(!t||Object.keys(t).length===0)return{eligible:!1,reason:"missing-properties"};const n=Ed(e),r=NXt(n),i=Object.fromEntries(Object.entries(t).filter(([o])=>!r.has(o)).map(([o,s])=>[o,Ed(s)]));if(Object.keys(i).length===0)return{eligible:!1,reason:"missing-properties"};const a={...n,type:"object",properties:i};return Array.isArray(n.required)&&(a.required=n.required.map(String).filter(o=>o in i)),{eligible:!0,schema:a}}function MXt(e,t){const n=`${t}.`;return Array.from(e).filter(r=>r.startsWith(n)).map(r=>r.slice(n.length))}function RXt(e,t,n){const r=`${t}.`,i=Cl(n==null?void 0:n.properties)?n.properties:{};return Object.fromEntries(Object.entries(e).filter(([a])=>a.startsWith(r)).map(([a,o])=>{const s=a.slice(r.length).split("."),l=i[s[0]],c=Cl(l)?l:{},u=n?Yr(n,c):c,d=Cl(u)?u.type:void 0;return!(d==="array"||Array.isArray(d)&&d.includes("array"))&&/^\d+$/.test(s[1]||"")&&s.splice(1,1),[s.join("."),o]}))}function DXt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function iD(e){return new DOMException(e,"AbortError")}const $je=async({source:e,params:t,signal:n})=>{const r=typeof e=="string"||typeof e=="number"?String(e).trim():"";if(!r)throw new Error("动态选项缺少技能标识");if(n.aborted)throw iD("动态选项请求已取消");const i=await PEe({},{skill_id:r,params:t});if(n.aborted)throw iD("动态选项请求已取消");return i},Eje=async({file:e,signal:t,onProgress:n})=>{if(t.aborted)throw iD("文件上传已取消");n(10);const r=await Sy(e);if(t.aborted)throw iD("文件上传已取消");const i=DXt(r==null?void 0:r.data)?r.data:{},a=typeof i.url=="string"?i.url.trim():"";if(!a)throw new Error(typeof i.message=="string"?i.message:"文件上传失败");return n(100),{url:a,name:typeof i.name=="string"?i.name:e.name,meta:r}};function Ym(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function UU(e){return Array.isArray(e)?e:[]}function lye(e){return Ym(e)?e:{}}function OXt(e,t){return Array.from(new Set([...UU(e),...UU(t)].map(String)))}function YN(e,t){const n=lye(e),r=lye(t);if("if"in r)return{...n,allOf:[...UU(n.allOf),r]};const i={...n};for(const[a,o]of Object.entries(r)){const s=i[a];if(a==="required"){i[a]=OXt(s,o);continue}if((a==="properties"||a==="$defs"||a==="definitions")&&Ym(s)&&Ym(o)){i[a]={...s};for(const[l,c]of Object.entries(o))i[a]={...i[a],[l]:YN(s[l],c)};continue}if((a==="items"||a==="not")&&Ym(s)&&Ym(o)){i[a]=YN(s,o);continue}if(Ym(s)&&Ym(o)&&!["if","then","else"].includes(a)){i[a]=YN(s,o);continue}i[a]=o}return i}const{Text:Ip}=ec,Tje=!1,LXt=["confirm","input","re_execute","cancel"],aD="amazon_listing_focus",cye=new WeakMap;function jXt(e,t){return(Br(e.type).length?Br(e.type).map(String):typeof e.type=="string"?[e.type]:[]).includes(t)}function zXt(e,t={}){const n=Ma(e,t);return vt(n)&&jXt(n,"string")&&n.enum===void 0&&n.const===void 0}function uye(e,t={}){const n=Ma(e,t);return vt(n)?Br(n.anyOf).some(r=>zXt(r,t)):!1}function eee(e,t,n,r={}){if(Ei(e))return"";const i=Ma(t,r);if(!vt(i))return"";const a=cD(i,r);if(a.length&&!uye(i,r)&&!new Set(a.map(p=>p.value)).has(String(e)))return`${n}不在可选范围内`;if(i.type==="array"){const f=cD(i.items,r);if(f.length&&Array.isArray(e)&&!uye(i.items,r)){const g=new Set(f.map(v=>v.value));if(e.some(v=>!g.has(String(v))))return`${n}包含无效选项`}const p=hl(i.minItems),h=hl(i.maxItems);if(Array.isArray(e)){if(p!=null&&e.length<p)return`${n}至少选择 ${p} 项`;if(h!=null&&e.length>h)return`${n}最多选择 ${h} 项`;if(i.items)for(const g of e){const v=eee(g,i.items,n,r);if(v)return v}}return""}if(i.type==="number"||i.type==="integer"){if(typeof e!="number"||Number.isNaN(e))return`${n}请输入数字`;if(i.type==="integer"&&!Number.isInteger(e))return`${n}请输入整数`;const f=hl(i.minimum),p=hl(i.maximum),h=hl(i.exclusiveMinimum),g=hl(i.exclusiveMaximum),v=hl(i.multipleOf);return f!=null&&e<f?`${n}不能小于 ${f}`:p!=null&&e>p?`${n}不能大于 ${p}`:h!=null&&e<=h?`${n}必须大于 ${h}`:g!=null&&e>=g?`${n}必须小于 ${g}`:v!=null&&!bXt(e,v)?`${n}必须是 ${v} 的倍数`:""}const o=String(e),s=hl(i.minLength),l=hl(i.maxLength),c=hl(i.minUtf8ByteLength),u=hl(i.maxUtf8ByteLength);if(s!=null&&o.length<s)return`${n}至少 ${s} 个字符`;if(l!=null&&o.length>l)return`${n}最多 ${l} 个字符`;const d=yXt(o);if(c!=null&&d<c)return`${n}至少 ${c} 字节`;if(u!=null&&d>u)return`${n}最多 ${u} 字节`;if(typeof i.pattern=="string")try{if(!new RegExp(i.pattern).test(o))return`${n}格式不正确`}catch{return""}return i.format==="uri"&&!/^(https?:\/\/|s3:\/\/)/i.test(o)?`${n}请输入有效链接`:""}function dye(e,t){const n=e!=null&&e.length?e:t;return(Jv(n)||[]).map(r=>({value:String(r.value),label:r.label}))}function ux(e){return e.type.trim().toLowerCase()}function Q0(e){return ux(e)===aD}function oD(e){const t=ux(e);return t==="json_editor"||t==="object"||t===aD}function GU(e){return e==="array"||e==="list"||e==="tags"}function FXt(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 BXt(e,t,n){const r=ux(e);if(n==="re_execute"){const u=t?WU(Mg(e.value,t)):e.value;if(u!==void 0)return u;const d=t?Mg(e.default,t):e.default;return d!==void 0?d:r==="boolean"?!1:["number","integer","float"].includes(r)?void 0:r==="checkbox"||GU(r)?[]:""}if(t){const u=gXt(t,e.name);if(u!==void 0)return u;const d=wje(t,e.name);if(d!==void 0)return d}const i=t?WU(Mg(e.value,t)):e.value,a=ZJ(i),o=W2(a)||a,s=KN(a)||(vt(a)&&rD(a)?a:null),l=gj(o);if((r==="json_editor"||r==="object")&&s)return Object.fromEntries(Object.entries(s).map(([u,d])=>[u,[_T(d,l)]]));if(i!==void 0)return i;if(e.value!==void 0)return e.value;const c=t?Mg(e.default,t):e.default;if(c!==void 0)return c;if(r==="boolean")return!1;if(!["number","integer","float"].includes(r))return r==="checkbox"||GU(r)?[]:""}function CP(e,t,n){return Object.fromEntries(e.map(r=>[r.name,BXt(r,t,n)]))}function VXt(e,t){const n=KN(t.output);if(e.name==="listing_data"&&n&&wje(t,e.name)!==void 0||vt(n)&&e.name in n)return n;const r=mj(t.output);if(vt(r)&&vt(r.properties)&&r[e.name]!==void 0)return KN(r);const i=Mg(e.value,t),a=ZJ(i);if(vt(a)&&vt(a.properties)){const o=KN(a);if(o)return o}return rD(a)?a:null}function tee(e,t){const n=W2(t.output);if(n)return n;const r=Mg(e.value,t),i=ZJ(r);return W2(i)||(vt(i)?i:null)}function HXt(e,t){if(!vt(e)||!vt(e.propertyGroups))return[];const n=new Set(Object.keys(t)),r=new Set,i=[];for(const[o,s]of Object.entries(e.propertyGroups)){if(!vt(s))continue;const l=Br(s.propertyNames).map(String).filter(c=>n.has(c)&&!r.has(c));if(l.length){for(const c of l)r.add(c);i.push({key:o,title:sD(s.title)||o,description:sD(s.description),propertyNames:l})}}const a=Object.keys(t).filter(o=>!r.has(o));return a.length&&i.push({key:"__ungrouped",title:"其他",propertyNames:a}),i}function sD(e){return typeof e=="string"?e:""}function Br(e){return Array.isArray(e)?e:[]}function Xa(e){return vt(e)?e:{}}function gj(e){if(!vt(e))return{};const t=e.$defs??e.definitions;return vt(t)?t:{}}function U2(e,t){const n=tee(e,t);return gj(n)}function Ma(e,t){if(!vt(e)||typeof e.$ref!="string")return e;const n=e.$ref,i=["#/$defs/","#/definitions/"].find(l=>n.startsWith(l));if(!i)return e;const a=n.slice(i.length),o=t[a];if(!vt(o))return e;const s=Object.fromEntries(Object.entries(e).filter(([l])=>l!=="$ref"));return{...o,...s}}function nee(e){return Object.fromEntries(Object.entries(e).filter(([t])=>!["allOf","anyOf","oneOf","if","then","else"].includes(t)))}function WXt(e){return Object.keys(nee(e)).some(t=>!["if","then","else"].includes(t))}function qU(e){return Array.isArray(e)?e.some(qU):vt(e)?Object.values(e).some(qU):!Ei(e)}function KU(e,t){if(Object.is(e,t))return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!="object")return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function UXt(e,t){return e==="array"?Array.isArray(t):e==="object"?vt(t):e==="integer"?Number.isInteger(t):e==="number"?typeof t=="number":e==="boolean"?typeof t=="boolean":e==="string"?typeof t=="string":e==="null"?t===null:!0}function Td(e,t,n={}){const r=Ma(e,n);if(!vt(r))return!0;const i=Br(r.allOf);if(i.length&&!i.every(l=>Td(l,t,n)))return!1;const a=Br(r.anyOf);if(a.length&&!a.some(l=>Td(l,t,n)))return!1;const o=Br(r.oneOf);if(o.length&&o.filter(l=>Td(l,t,n)).length!==1||r.not!==void 0&&Td(r.not,t,n))return!1;const s=Br(r.required).map(String);if(s.length&&(!vt(t)||!s.every(l=>qU(t[l]))))return!1;if(vt(r.properties)){if(!vt(t))return!1;for(const[l,c]of Object.entries(r.properties))if(t[l]!==void 0&&!Td(c,t[l],n))return!1}return!(r.contains!==void 0&&!(Array.isArray(t)?t:vt(t)?[t]:[]).some(c=>Td(r.contains,c,n))||r.items!==void 0&&Array.isArray(t)&&(!t.length||!t.every(l=>Td(r.items,l,n)))||r.enum!==void 0&&!Br(r.enum).some(c=>KU(c,t))||r.const!==void 0&&!KU(r.const,t)||r.type!==void 0&&!(Br(r.type).length?Br(r.type).map(String):[String(r.type)]).some(c=>UXt(c,t)))}function lD(e,t,n){const r=Ma(e,n);if(!vt(r))return[];if("if"in r){const o=Td(r.if,t,n)?r.then:r.else;return lD(o,t,n)}const i=[];for(const a of Br(r.allOf))i.push(...lD(a,t,n));return WXt(r)&&i.push(nee(r)),i}function E1(e,t,n={}){const r=Ma(e,n);if(!vt(r))return r;const i=[];for(const a of Br(r.allOf))i.push(...lD(a,t,n));if("if"in r){const o=Td(r.if,t,n)?r.then:r.else;i.push(...lD(o,t,n))}return i.reduce((a,o)=>YN(a,o),nee(r))}function cv(e,t,n){const r=tee(e,t);if(!r)return null;const i=gj(r);return Xa(E1(r,n,i))}function kd(e,t,n){const r=cv(e,t,n);return wT(r)||VXt(e,t)}function ey(e){const t=Xa(e),n=Xa(t.not);return new Set(Br(n.required).map(String))}function G2(e){const t=Xa(e),n=ey(t);return new Set(Br(t.required).map(String).filter(r=>!n.has(r)))}function GXt(e){const t=cye.get(e);if(t)return t;const n=new hje({allErrors:!0,strict:!1,validateSchema:!1,multipleOfPrecision:8});vje(n);const{$schema:r,...i}=e,a=n.compile(i);return cye.set(e,a),a}function Ije(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function qXt(e){return e.split("/").slice(1).map(Ije)}function KXt(e,t){const n=t.replace(/^#/,"").split("/").slice(1).map(Ije);let r=e;for(const i of n)if(Array.isArray(r))r=r[Number(i)];else if(vt(r))r=r[i];else return;return r}function YXt(e,t){if(e.keyword!=="not")return"";const n=KXt(t,e.schemaPath);if(!vt(n))return"";const r=Br(n.required);return r.length>0?String(r[0]):""}function XXt(e){const t=e.params;return typeof t.missingProperty=="string"?t.missingProperty:""}function ZXt(e,t,n){const r=vj(e,t,n),i=dd(e,t,n);return i.find(([a])=>r.has(a))||i[0]||["value",{}]}function QXt(e,t,n,r){const i=qXt(e.instancePath);let a=i[0]||"",o=Number.isInteger(Number(i[1]))?Number(i[1]):0,s=i[2]||"";const l=YXt(e,t);if(l&&(s=l),e.keyword==="required"){const p=XXt(e);a?s||(s=p):(a=p,o=0)}const u=Xa(t.properties)[a],d=wj(r,a,u,n),f=Xa(d[o]);if(!s&&u){const[p]=ZXt(u,n,f);s=p}return{propertyName:a,rowIndex:o,childName:s||"value",propertySchema:u,childSchema:u?ud(u,n,f)[s]:void 0}}function JXt(e,t,n){const r=ree(t.childName,t.childSchema,n);return e.keyword==="required"?`请输入${r}`:e.keyword==="enum"?`${r}不在可选范围内`:e.keyword==="format"||e.keyword==="pattern"?`${r}格式不正确`:e.keyword==="type"?`${r}类型不正确`:e.keyword==="minLength"?`${r}长度不足`:e.keyword==="maxLength"?`${r}长度超出限制`:e.keyword==="minimum"?`${r}数值过小`:e.keyword==="maximum"?`${r}数值过大`:e.keyword==="multipleOf"?`${r}数值不符合步进要求`:e.keyword==="not"?`${r}与当前条件组合冲突`:`${r}不符合规则`}function YU(e,t,n){const r=E1(e,t,n);if(!vt(r))return t;if(r.type==="array"&&Array.isArray(t)){const s=r.items;return t.map(l=>YU(s,l,n))}if(!vt(t)||!vt(r.properties))return t;const i=ey(r),a=G2(r),o={};for(const[s,l]of Object.entries(t)){if(i.has(s))continue;const c=r.properties[s];c&&(!a.has(s)&&T1(c,l,n)||(o[s]=YU(c,l,n)))}return o}function eZt(e,t,n){const r=tee(e,t);if(!r)return{};try{const i=gj(r),a=GXt(r),o=Rje(e,t,n),s=YU(r,o,i);if(a(s))return{};const l={};for(const c of a.errors||[]){if(c.keyword==="if"||c.keyword==="additionalProperties")continue;const u=QXt(c,r,i,Xa(o));if(!u.propertyName||u.propertySchema&&kf(u.propertySchema,i)||u.childSchema&&kf(u.childSchema,i))continue;const d=bj(e.name,u.propertyName,u.childName,u.rowIndex);l[d]||(l[d]=JXt(c,u,i))}return l}catch{return{}}}function ree(e,t,n={}){const r=Ma(t,n);return vt(r)&&sD(r.title)||e}function cD(e,t={}){const n=Ma(e,t);if(!vt(n))return[];const r=Br(n.enum),i=Br(n.anyOf).map(l=>Ma(l,t)).find(l=>vt(l)&&Br(l.enum).length>0),a=vt(i)?Br(i.enum):[],o=r.length?r:a||[],s=r.length?Br(n.enumNames):vt(i)?Br(i.enumNames):[];return o.map((l,c)=>({value:String(l),label:String(s[c]??l),rawValue:l}))}function kf(e,t={}){const n=Ma(e,t);return vt(n)&&n.hidden===!0}function tZt(e,t={}){return Ma(e,t),Tje}function iee(e,t={},n){const r=E1(e,n,t);if(!vt(r))return{};const i=vt(r.items)?Ma(r.items,t):r,a=Array.isArray(n)?n[0]:n;return Xa(E1(i,a,t))}function ud(e,t={},n){const r=iee(e,t,n);if(vt(r.properties))return r.properties;const i=Xa(E1(e,n,t));return vt(i.properties)?i.properties:{}}function nZt(e,t,n={}){const r=Ma(e,n);if(!vt(r))return!0;const i=Br(r.selectors).map(String);if(!i.length)return!0;const a=Xa(r.type==="array"?xj(e,t,n)[0]:t),o=ud(e,n,a);return i.every(s=>{const l=o[s],c=a[s];return l===void 0||Ei(c)?!0:!ST(l,n,c)||Pf(l,c,n)})}function dd(e,t={},n){const r=iee(e,t,n),i=ey(r);return Object.entries(ud(e,t,n)).filter(([a,o])=>!i.has(a)&&!kf(o,t)&&nZt(o,vt(n)?n[a]:void 0,t))}function vj(e,t={},n){const r=iee(e,t,n),i=G2(r);return i.size?i:G2(E1(e,n,t))}function ST(e,t={},n){return dd(e,t,n).length>0}function yj(e,t={},n){const r=dd(e,t,n);return r.length?(r.find(([a])=>a==="value")||r[0])[0]:""}function kje(e,t){return G2(e).has(t)}function Pje(e,t,n={}){return dd(e,n,t).some(([r,i])=>{const a=t[r];return ST(i,n,a)?!T1(i,a,n):!Ei(a)})}function T1(e,t,n={}){if(Ei(t))return!0;const r=Array.isArray(t)?t.map(Xa):[Xa(t)];return r.some(a=>dd(e,n,a).length>0)?r.every(a=>!Pje(e,a,n)):!1}function Pf(e,t,n={}){if(Ei(t))return!1;if(Array.isArray(t))return t.some(i=>Pf(e,i,n));if(!vt(t))return!0;const r=ud(e,n,t);return Object.entries(t).some(([i,a])=>{if(Ei(a))return!1;const o=r[i];return o?kf(o,n)?!1:ST(o,n,a)?Pf(o,a,n):!0:!0})}function Nje(e,t,n={}){return(Array.isArray(t)?t.length?t.map(Xa):[{}]:[Xa(t)]).some(i=>{const a=vj(e,n,i);return dd(e,n,i).some(([o,s])=>{const l=i[o];return a.has(o)&&Ei(l)?!0:(a.has(o)||!T1(s,l,n))&&Nje(s,l,n)})})}function aee(e,t,n,r=!1){return!r&&T1(e,t,n)||!Nje(e,t,n)?!1:r||ST(e,n,t)||!T1(e,t,n)}function oee(e,t,n,r,i,a,o){const s=kje(a,e);return s&&n===yj(t,i,r)?!0:!s&&!Pf(t,o,i)?!1:vj(t,i,r).has(n)}function bj(e,t,n,r=0){return`${e}.${t}.${r}.${n}`}const hp={getEffectiveSchemaProperties:kd,getEffectiveSchemaRoot:cv,getSchemaDefinitions:U2,getSchemaTitle:ree,getVisibleProperties:dd,getPrimaryVisibleChildName:yj,getChildProperties:ud,resolveSchemaRef:Ma,getSchemaRows:wj,schemaRecord:Xa,schemaArray:Br,schemaString:sD,isHiddenSchema:kf,hasRawSchemaPropertyValue:Pf,isSchemaChildRequiredForForm:oee,shouldValidateMissingNestedSchemaValue:aee,getSchemaValueConstraintError:eee,schemaErrorKey:bj};function rZt(e){const t=Array.from(new Set(Object.values(e))).filter(Boolean);t.length&&rr.warning({title:"表单校验未通过",content:b.jsxs("div",{style:{display:"grid",gap:8},children:[b.jsx(Ip,{type:"secondary",children:"请先处理以下字段后再提交。"}),b.jsx("ul",{style:{margin:0,paddingLeft:18},children:t.slice(0,8).map(n=>b.jsx("li",{children:n},n))}),t.length>8&&b.jsxs(Ip,{type:"secondary",children:["还有 ",t.length-8," 个字段需要处理。"]})]}),okText:"知道了"})}function _T(e,t={}){return Object.fromEntries(Object.entries(ud(e,t)).map(([n,r])=>{const i=Ma(r,t);if(vt(i)&&i.default!==void 0)return[n,i.default];if(vt(i)&&i.const!==void 0)return[n,i.const];if(vt(i)){const a=Br(i.enum);if(a.length===1)return[n,a[0]]}return vt(i)&&i.type==="boolean"?[n,!1]:vt(i)&&(i.type==="number"||i.type==="integer")?[n,void 0]:[n,""]}))}function fye(e){return e===!1||e===0?!0:typeof e=="string"?e.trim()!=="":Array.isArray(e)?e.length>0:e!=null}function Aje(e,t={}){const n=Ma(e,t);if(!vt(n))return;if(n.default!==void 0)return n.default;if(n.const!==void 0)return n.const;const r=Br(n.enum);if(r.length===1)return r[0];if(n.type==="array"&&n.items){const i=_T(n,t);return Object.values(i).some(fye)?[i]:void 0}if(n.type==="object"&&vt(n.properties)){const i=Object.fromEntries(Object.entries(n.properties).map(([a,o])=>[a,Aje(o,t)]));return Object.values(i).some(fye)?i:void 0}}function iZt(e){if(typeof e!="string"&&typeof e!="number")return;const t=String(e).trim();if(/^\d+$/.test(t)){if(t.length===12)return"upc";if(t.length===13)return"ean";if(t.length===8||t.length===14)return"gtin"}}function Mje(e,t,n){const r=cD(e,n);if(!r.length)return t;const i=r.find(a=>KU(a.rawValue,t)||a.value===String(t)||a.label===String(t));return(i==null?void 0:i.rawValue)??t}function pye(e,t,n,r){const i=ud(e,r,n);if(vt(t)&&!("value"in i)){const a=t.value,o=yj(e,r,n),s=i[o];if(o&&s&&Ei(n[o])&&!Ei(a)){const l=ST(s,r,a)?xj(s,a,r):Mje(s,a,r);return{...n,[o]:l}}}if(Ei(n.type)&&"value"in n&&"type"in i){const a=new Set(cD(i.type,r).map(s=>String(s.rawValue))),o=iZt(t);if(o&&a.has(o))return{...n,type:o}}return n}function xj(e,t,n){const r=i=>{const a=_T(e,n);if(vt(i)){const o={...a,...i};return pye(e,i,o,n)}if(!Ei(i)){const o=yj(e,n,a)||"value",s=ud(e,n,a)[o];return pye(e,i,{...a,[o]:Mje(s,i,n)},n)}return a};return Array.isArray(t)?t.length?t.map(r):[r({})]:[r(t)]}function wj(e,t,n,r){const i=e[t];return xj(n,i,r)}function hye(e,t,n){const r=new Set;for(const i of e){const a=n[i.name];if(Q0(i))for(const d of Object.keys(Cje(i,t,a,hp)))r.add(d);if(!oD(i)){i.required&&Ei(a)&&r.add(i.name);continue}const o=U2(i,t),s=mu(a),l=kd(i,t,s),c=cv(i,t,s),u=ey(c);if(!l||!s){i.required&&Ei(a)&&r.add(i.name);continue}for(const[d,f]of Object.entries(l)){if(u.has(d)||kf(f,o))continue;const p=Pf(f,s[d],o);wj(s,d,f,o).forEach((g,v)=>{const y=Xa(g);for(const[x]of dd(f,o,y)){const w=y[x],S=ud(f,o,y)[x],_=oee(d,f,x,y,o,c,s[d]);(_&&Ei(w)||aee(S,w,o,_||p&&Pf(S,w,o)))&&r.add(bj(i.name,d,x,v))}})}}return r}function aZt(e,t){if(t.has(e.name))return!0;const n=`${e.name}.`;for(const r of t)if(r.startsWith(n))return!0;return!1}function oZt(e,t,n){const r=ud(e,n,t),i=vj(e,n,t),a={..._T(e,n),...t};for(const[o,s]of Object.entries(a)){const l=r[o];if(!l){Ei(s)&&delete a[o];continue}if(kf(l,n)){!i.has(o)&&Ei(s)&&delete a[o];continue}if(!i.has(o)&&Ei(s)){delete a[o];continue}a[o]=XU(l,s,n,i.has(o))}return a}function XU(e,t,n,r){const i=xj(e,t,n);if(!i.some(l=>dd(e,n,l).length>0))return t;const o=i.map(l=>oZt(e,l,n)).filter(l=>r||Pje(e,l,n)),s=Ma(e,n);return vt(s)&&s.type==="array"?o:o[0]}function Rje(e,t,n){const r=mu(n);if(!r)return n;const i=U2(e,t),a=cv(e,t,r),o=wT(a)||kd(e,t,r);if(!o)return n;const s=ey(a),l=G2(a),c={};for(const[u,d]of Object.entries(o)){if(s.has(u))continue;if(kf(d,i)){const g=r[u]??Aje(d,i);g!==void 0&&(c[u]=XU(d,g,i,!0));continue}const f=r[u],p=l.has(u);if(!p&&T1(d,f,i))continue;const h=XU(d,f,i,p);h!==void 0&&(c[u]=h)}return c}function mye(e,t,n){const r={...t};for(const i of e){if(!oD(i))continue;const a=r[i.name];if(typeof a=="string")try{r[i.name]=a.trim()?JSON.parse(a):{}}catch{r[i.name]=a}r[i.name]=Rje(i,n,r[i.name])}return"listing_data"in r&&(r.listing_data=Nb(r.listing_data)),r}function gye(e){return e==null||e===""?b.jsx(Ip,{type:"secondary",children:"空"}):typeof e=="boolean"?e?"是":"否":typeof e=="object"?b.jsx("pre",{style:{margin:0,padding:"8px 10px",background:"#f8fafc",border:"1px solid #e5e7eb",borderRadius:6,maxHeight:220,overflow:"auto",fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e,null,2)}):String(e)}function sZt(e,t=!1,n=""){return!t&&!n?e:b.jsxs(pa,{size:6,align:"center",children:[b.jsx("span",{children:e}),n?b.jsx(or,{title:n,children:b.jsx(ME,{style:{color:"#9ca3af",cursor:"help",fontSize:13}})}):null,t?b.jsx(ji,{color:"default",style:{marginInlineEnd:0,color:"#6b7280"},children:"只读"}):null]})}function vye(e,t,n){return Math.min(Math.max(e,t),n)}function see({data:e,submitting:t,compact:n,actionsPlacement:r="inline",showOnlyMissing:i,onShowOnlyMissingChange:a,hideFilterToggle:o=!1,hideFilterSummary:s=!1,hideTimeoutAlert:l=!1,hideStepText:c=!1,executionFormLayout:u=!1,hideActions:d=!1,previewOnly:f=!1,disableBusinessEffects:p=!1,onValuesChange:h,onSubmit:g,onClose:v}){var Ye,Se;const y=e.confirm_type==="form"||!(e.confirm_fields||[]).length&&!!((Ye=e.input_fields)!=null&&Ye.length),x=y?"input":"review",[w,S]=m.useState(x),[_,C]=m.useState(()=>CP(x==="input"?e.input_fields||[]:[],e,x)),[$,E]=m.useState({}),[k,T]=m.useState(()=>new Set),[I,P]=m.useState(!1),[N,A]=m.useState(()=>new Set),M=m.useRef(null),R=m.useRef(null),L=m.useRef(null),[z,j]=m.useState({visible:!1,thumbHeight:0,thumbTop:0}),O=i??I,V=m.useCallback(me=>{i===void 0&&P(me),a==null||a(me)},[i,a]),B=m.useMemo(()=>{var pe;const me=(pe=e.actions)!=null&&pe.length?e.actions:LXt;return new Set(me)},[e.actions]),D=DC(B,"re_execute")&&(e.max_retries==null||(e.retry_count??0)<e.max_retries),F=m.useMemo(()=>w==="re_execute"?e.re_execute_params||[]:w==="input"?e.input_fields||[]:[],[e.input_fields,e.re_execute_params,w]),H=m.useMemo(()=>F.some(me=>{const pe=mu(_[me.name]);return Q0(me)?!!Z0(me,e,pe,hp):ux(me)!=="json_editor"?!1:!!(pe&&kd(me,e,pe))}),[F,e,_]),W=m.useMemo(()=>F.some(me=>Q0(me)?!!Z0(me,e,mu(_[me.name]),hp):!1),[F,e,_]),K=w==="re_execute"||u&&w==="input"&&!H,U=K?16:4,q=me=>me==="re_execute"?e.re_execute_params||[]:me==="input"?e.input_fields||[]:[],Q=me=>{S(me),C(CP(q(me),e,me)),E({}),T(new Set),V(!1),A(new Set)},G=f||p,X=m.useMemo(()=>G?[]:F,[F,G]),J=sj(X,_,C);m.useEffect(()=>{var xe;const me=e.confirm_type==="form"||!(e.confirm_fields||[]).length&&((xe=e.input_fields)!=null&&xe.length)?"input":"review";S(me);const pe=me==="input"?e.input_fields||[]:[];C(CP(pe,e,me)),E({}),T(new Set),P(!1),A(new Set)},[e]),m.useEffect(()=>{C(CP(F,e,w)),E({}),T(new Set),P(!1),A(new Set)},[F,e,w]);const Y=m.useMemo(()=>hye(F,e,_),[F,e,_]),re=m.useMemo(()=>new Set([...Y,...Object.keys($)]),[Y,$]).size;m.useEffect(()=>{if(r!=="bottom"){j({visible:!1,thumbHeight:0,thumbTop:0});return}const me=M.current;if(!me)return;let pe=0;const xe=()=>{var ke;if(pe=0,!(me.scrollHeight>me.clientHeight+1)){j(Ke=>Ke.visible?{visible:!1,thumbHeight:0,thumbTop:0}:Ke);return}const Qe=((ke=R.current)==null?void 0:ke.clientHeight)??0;if(Qe<=0)return;const it=Math.max(Math.min(36,Qe),Math.round(me.clientHeight/me.scrollHeight*Qe)),st=Math.max(0,Qe-it),Ft=Math.max(1,me.scrollHeight-me.clientHeight),Ne=Math.round(me.scrollTop/Ft*st);j(Ke=>Ke.visible&&Ke.thumbHeight===it&&Ke.thumbTop===Ne?Ke:{visible:!0,thumbHeight:it,thumbTop:Ne})},Le=()=>{pe||(pe=window.requestAnimationFrame(xe))};Le(),me.addEventListener("scroll",Le,{passive:!0}),window.addEventListener("resize",Le);const $e=typeof ResizeObserver<"u"?new ResizeObserver(Le):null;$e==null||$e.observe(me),R.current&&($e==null||$e.observe(R.current));for(const ze of Array.from(me.children))$e==null||$e.observe(ze);return()=>{pe&&window.cancelAnimationFrame(pe),me.removeEventListener("scroll",Le),window.removeEventListener("resize",Le),$e==null||$e.disconnect()}},[r]);const ee=me=>{const pe=M.current;if(!pe||!z.visible)return null;const xe=me.clientHeight,Le=Math.max(0,xe-z.thumbHeight),$e=Math.max(0,pe.scrollHeight-pe.clientHeight);return $e<=0?null:{body:pe,maxScrollTop:$e,maxThumbTop:Le}},te=(me,pe,xe,Le)=>{me.scrollTop=xe>0?pe/xe*Le:0},oe=me=>{const pe=ee(me.currentTarget);if(!pe)return;me.preventDefault(),me.stopPropagation();const xe=me.currentTarget.querySelector("span"),Le=(xe==null?void 0:xe.contains(me.target))??!1;let $e=pe.body.scrollTop;if(!Le){const ze=me.currentTarget.getBoundingClientRect(),Qe=vye(me.clientY-ze.top-z.thumbHeight/2,0,pe.maxThumbTop);te(pe.body,Qe,pe.maxThumbTop,pe.maxScrollTop),$e=pe.body.scrollTop}L.current={pointerId:me.pointerId,startY:me.clientY,startScrollTop:$e,maxScrollTop:pe.maxScrollTop,maxThumbTop:pe.maxThumbTop},me.currentTarget.setPointerCapture(me.pointerId)},fe=me=>{const pe=L.current,xe=M.current;if(!pe||!xe||pe.pointerId!==me.pointerId)return;me.preventDefault(),me.stopPropagation();const Le=me.clientY-pe.startY,$e=pe.startScrollTop+(pe.maxThumbTop>0?Le/pe.maxThumbTop*pe.maxScrollTop:0);xe.scrollTop=vye($e,0,pe.maxScrollTop)},he=me=>{var pe;((pe=L.current)==null?void 0:pe.pointerId)===me.pointerId&&(L.current=null)},ye=m.useCallback((me,pe)=>new Set([...hye(me,e,_),...Object.keys(pe)]),[e,_]),Te=m.useCallback((me,pe)=>{const xe=ye(me,pe),Le=[];for(const $e of me){if(!Q0($e))continue;const ze=mu(_[$e.name]),Qe=Z0($e,e,ze,hp);if(!Qe)continue;const it=new Set(Qe.propertyNames);for(const st of Object.keys(Qe.properties))it.has(st)||Le.push(`${$e.name}.${st}`)}return Le.length?new Set(Array.from(xe).filter($e=>Le.some(ze=>$e===ze||$e.startsWith(`${ze}.`)))):xe},[e,ye,_]),Ee=m.useCallback(me=>{const pe={};for(const xe of me){if(xe.required&&Ei(_[xe.name])&&(pe[xe.name]=`请输入${xe.label}`),Q0(xe)&&Object.assign(pe,Cje(xe,e,_[xe.name],hp)),!oD(xe))continue;const Le=U2(xe,e),$e=_[xe.name],ze=mu($e),Qe=kd(xe,e,ze),it=cv(xe,e,ze),st=ey(it);if(!(!Qe||!ze)){for(const[Ft,Ne]of Object.entries(Qe)){if(st.has(Ft)||kf(Ne,Le))continue;const ke=Pf(Ne,ze[Ft],Le),Ke=wj(ze,Ft,Ne,Le);for(const[Je,We]of Ke.entries()){const Oe=Xa(We);for(const[Xe,at]of dd(Ne,Le,Oe)){const mt=bj(xe.name,Ft,Xe,Je),ot=ree(Xe,at,Le),wt=Oe[Xe],Pt=oee(Ft,Ne,Xe,Oe,Le,it,ze[Ft]);if(Pt&&Ei(wt)||aee(at,wt,Le,Pt||ke&&Pf(at,wt,Le))){pe[mt]||(pe[mt]=`请输入${ot}`);continue}const Yt=eee(wt,at,ot,Le);Yt&&(pe[mt]||(pe[mt]=Yt))}}}for(const[Ft,Ne]of Object.entries(eZt(xe,e,ze)))pe[Ft]||(pe[Ft]=Ne)}}return pe},[e,_]),we=m.useCallback((me,pe)=>{const xe=Object.keys(pe);xe.length&&T(Le=>{const $e=new Set(Le);for(const ze of me){const Qe=mu(_[ze.name]);if(!Qe)continue;const it=cv(ze,e,Qe),st=kd(ze,e,Qe);if(st)for(const Ft of HXt(it,st))Ft.propertyNames.some(ke=>xe.some(Ke=>Ke.startsWith(`${ze.name}.${ke}.`)))&&$e.add(`${ze.name}:${Ft.key}`)}return $e})},[e,_]),le=me=>{if(!me){V(!1),A(new Set);return}const pe=Ee(F),xe=Te(F,pe),Le=Object.fromEntries(Object.entries(pe).filter(([$e])=>xe.has($e)));E(Le),we(F,Le),V(!0),A(xe)},se=(me,pe)=>{const xe={..._,[me]:pe};C(xe),h==null||h(xe),E(Le=>{if(!Le[me])return Le;const $e={...Le};return delete $e[me],$e})},ne=(me,pe)=>{const xe={..._,[me]:pe};C(xe),h==null||h(xe),E(Le=>{const $e=`${me}.`,ze=Object.fromEntries(Object.entries(Le).filter(([Qe])=>Qe!==me&&!Qe.startsWith($e)));return Object.keys(ze).length===Object.keys(Le).length?Le:ze})},ge=(me,pe)=>{const xe=`${me}:`;T(Le=>{const $e=new Set(Array.from(Le).filter(ze=>!ze.startsWith(xe)));for(const ze of pe)$e.add(`${xe}${ze}`);return $e})},be=me=>{const pe=Ee(me);return E(pe),we(me,pe),O&&A(Te(me,pe)),Object.keys(pe).length>0?(rZt(pe),!1):!0},Ce=(me,pe,xe,Le,$e)=>{const ze=Ma(pe,$e);if(Array.isArray(me)||vt(ze)&&ze.type==="array"){const Qe=Array.isArray(me)?[...me]:[];return Qe[xe]=Le,Qe}return Le},Ae=(me,pe,xe)=>{const Le=cv(me,e,xe),$e=AXt({root:Le,properties:pe});if(!$e.eligible||!$e.schema)return null;const ze=`${me.name}:`,Qe=Array.from(k).filter(st=>st.startsWith(ze)).map(st=>st.slice(ze.length)),it=O?MXt(N,me.name):void 0;return b.jsx(yje,{schema:$e.schema,value:xe,onChange:st=>ne(me.name,st),externalErrors:RXt($,me.name,$e.schema),loadOptions:G?void 0:$je,uploadFile:G?void 0:Eje,disableFileUpload:G,disabled:f,respectReadonly:Tje,showArrayControls:!1,groupDisplay:"collapse",groupAccordion:!1,destroyInactiveGroups:!1,expandedGroupKeys:Qe,onExpandedGroupKeysChange:st=>ge(me.name,st),visibleFieldPaths:it,className:"human-confirm-panel__schema-dynamic-form"})},je=(me,pe)=>{const xe=U2(me,e);return b.jsx($Xt,{field:me,context:pe,definitions:xe,helpers:hp,disabled:f,errors:$,showOnlyMissing:O,onShowOnlyMissingChange:le,usesExecutionFormLayout:K,createSchemaItemDefaults:_T,getForbiddenSchemaNames:ey,isReadonlySchema:tZt,isTopLevelSchemaPropertyRequired:kje,renderSchemaForm:Ae,setErrors:E,updateField:se,updateSchemaRow:Ce})},ce=()=>{g({action:"confirm",inputData:{approved:!0}})},de=()=>{if(!be(F))return;const me=mye(F,_,e);g({action:TXt(B),inputData:me,confirmedInput:me})},_e=()=>{g({action:"return_previous",inputData:{}})},Me=()=>{if(!be(F))return;const me=mye(F,_,e);g({action:"re_execute",inputData:{request_regenerate:!0},modifiedParams:me})},Re=()=>{g({action:"cancel",inputData:{}})},Ie=IXt({actions:B,canReExecute:D,hasInputFields:!!((Se=e.input_fields)!=null&&Se.length),hasOnClose:!!v,isFormMode:y,mode:w,returnStepId:e.return_step_id}),De=me=>{me==="submitConfirm"&&ce(),me==="submitInput"&&de(),me==="submitReturnPrevious"&&_e(),me==="submitReExecute"&&Me(),me==="submitCancel"&&Re(),me==="switchInput"&&Q("input"),me==="switchReview"&&Q("review"),me==="switchReExecute"&&Q("re_execute"),me==="cancelReExecute"&&Q(y?"input":"review"),me==="close"&&(v==null||v())},Ue=me=>b.jsx(Et,{type:me.primary?"primary":void 0,danger:me.danger,loading:me.loading?t:!1,disabled:me.disabledWhenSubmitting?t:void 0,onClick:()=>De(me.command),children:me.label},me.key),nt=me=>{var Ft,Ne;const pe=_[me.name],xe=$[me.name]?"error":void 0,Le=me.placeholder||`请输入${me.label}`,$e=ux(me);if($e==="boolean")return b.jsx(yo,{size:K?"default":"small",checked:!!pe,onChange:ke=>se(me.name,ke)});if(["number","integer","float"].includes($e))return b.jsx(zo,{size:K?"middle":"small",style:{width:"100%"},value:FXt(pe),onChange:ke=>se(me.name,ke),placeholder:Le,status:xe,precision:$e==="integer"?0:void 0});const ze=GU($e),Qe=!!((Ft=me.options)!=null&&Ft.length||(Ne=me.enum)!=null&&Ne.length);if($e==="select"||$e==="radio"||$e==="segmented"||ze||($e==="string"||$e==="url")&&(Qe||!!me.options_from_skill)){const ke=J.getFieldState(me),Ke=me.options_from_skill?ke.options:dye(me.options,me.enum),Je=!!(me.options_from_skill||Qe),We=ke.waitingForDependencies?"请先选择关联参数":ke.placeholder||me.placeholder||`请选择${me.label}`,Oe=ze?Array.isArray(pe)?pe.map(String):pe==null||pe===""?[]:[String(pe)]:pe==null||pe===""?void 0:String(pe);return $e==="radio"||$e==="segmented"?b.jsx(my.Group,{value:pe,onChange:Xe=>se(me.name,Xe.target.value),options:Ke}):b.jsx(tn,{size:K?"middle":"small",style:{width:"100%"},value:Oe,mode:ze?Je?"multiple":"tags":void 0,onChange:Xe=>se(me.name,Xe),placeholder:Oe===void 0?We:void 0,options:Ke,loading:ke.loading,disabled:ke.waitingForDependencies,allowClear:!0,showSearch:!0,tokenSeparators:ze&&!Je?[","]:void 0,optionFilterProp:"label",status:xe,notFoundContent:ke.loading?b.jsx(vr,{size:"small"}):ke.error||null})}if($e==="checkbox")return b.jsx(pf.Group,{value:Array.isArray(pe)?pe:[],onChange:ke=>se(me.name,ke),options:dye(me.options,me.enum)});const st={...me,type:$e};if(mT(st))return b.jsx(qQ,{field:st,value:pe,size:K?"middle":"small",status:xe,onChange:ke=>se(me.name,ke)});if($e==="date"){const ke=bu(me);return b.jsx(ui,{size:K?"middle":"small",style:{width:"100%"},value:sv(pe),picker:b1(ke),format:ke,placeholder:me.placeholder||"请选择日期",status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="daterange"){const ke=bu(me);return b.jsx(ui.RangePicker,{size:K?"middle":"small",style:{width:"100%"},value:SC(pe),picker:b1(ke),format:ke,status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="datetime"){const ke=bu(me);return b.jsx(ui,{size:K?"middle":"small",style:{width:"100%"},value:sv(pe),showTime:{format:ov(ke)},format:ke,placeholder:me.placeholder||"请选择日期时间",status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="datetimerange"){const ke=bu(me);return b.jsx(ui.RangePicker,{size:K?"middle":"small",style:{width:"100%"},value:SC(pe),showTime:{format:ov(ke)},format:ke,placeholder:["请选择开始日期时间","请选择结束日期时间"],status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="time"){const ke=bu(me);return b.jsx(Ua,{size:K?"middle":"small",style:{width:"100%"},value:sv(pe),format:ke,placeholder:me.placeholder||"请选择时间",status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="timerange"){const ke=bu(me);return b.jsx(Ua.RangePicker,{size:K?"middle":"small",style:{width:"100%"},value:SC(pe),format:ke,status:xe,onChange:(Ke,Je)=>se(me.name,Je)})}if($e==="textarea"||$e==="text")return b.jsx(Kt.TextArea,{size:K?"middle":"small",autoSize:{minRows:2,maxRows:U},value:typeof pe=="string"?pe:String(pe??""),onChange:ke=>se(me.name,ke.target.value),placeholder:Le,status:xe});if($e==="string"||$e==="url")return b.jsx(Kt,{size:K?"middle":"small",value:typeof pe=="string"?pe:String(pe??""),onChange:ke=>se(me.name,ke.target.value),placeholder:Le,status:xe});if($e===aD){const ke=Z0(me,e,pe,hp);return ke?je(me,ke):b.jsx(Kt.TextArea,{size:K?"middle":"small",className:"human-confirm-panel__json-textarea",autoSize:{minRows:2,maxRows:U},value:typeof pe=="string"?pe:JSON.stringify(pe??{},null,2),onChange:Ke=>se(me.name,Ke.target.value),placeholder:Le,status:xe})}if($e==="json_editor"||$e==="object"){const ke=mu(pe),Ke=kd(me,e,ke);return Ke&&ke?Ae(me,Ke,ke):b.jsx(Kt.TextArea,{size:K?"middle":"small",className:"human-confirm-panel__json-textarea",autoSize:{minRows:2,maxRows:U},value:typeof pe=="string"?pe:JSON.stringify(pe??{},null,2),onChange:Je=>se(me.name,Je.target.value),placeholder:Le,status:xe})}return b.jsx(Kt.TextArea,{size:K?"middle":"small",autoSize:{minRows:2,maxRows:U},value:typeof pe=="string"?pe:String(pe??""),onChange:ke=>se(me.name,ke.target.value),placeholder:Le,status:xe})},ct=()=>{if(!F.length)return b.jsx(Ip,{type:"secondary",children:"暂无输入字段配置"});const me=O?F.filter(pe=>Q0(pe)||aZt(pe,N)):F;return b.jsxs(pn,{size:K?void 0:"small",layout:"vertical",component:"div",className:`human-confirm-panel__fields${K?" wandox-human-confirm-panel__fields--re-execute":""}`,colon:!1,labelAlign:"left",children:[!s||!o&&!W?b.jsxs("div",{className:"human-confirm-panel__filter",style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"8px 10px",border:"1px solid #eef2f7",borderRadius:8,background:"#f8fafc"},children:[!s&&b.jsx(Ip,{type:"secondary",style:{fontSize:12},children:re>0?`还有 ${re} 项内容需要补充或修正`:"当前表单内容已通过基础检查"}),!o&&!W&&b.jsxs(pa,{size:6,children:[b.jsx(Ip,{style:{fontSize:12,color:"#374151"},children:"只看需处理项"}),b.jsx(yo,{size:"small",checked:O,onChange:le})]})]}):null,O&&!me.length?b.jsx(c$,{type:"success",showIcon:!0,message:"暂无需要处理的表单项",style:{borderRadius:8}}):null,me.map(pe=>{const xe=ux(pe),Le=oD(pe)?mu(_[pe.name]):null,$e=!!(Le&&(xe===aD?Z0(pe,e,Le,hp):(xe==="json_editor"||xe==="object")&&kd(pe,e,Le))),ze=!!(Le&&(xe==="json_editor"||xe==="object")&&kd(pe,e,Le));return b.jsx(pn.Item,{className:`human-confirm-panel__field${$e?" human-confirm-panel__field--schema":""}${ze?" human-confirm-panel__field--dynamic-schema":""}${K&&!$e?" wandox-human-confirm-panel__field--re-execute":""}`,label:$e?void 0:K?sZt(pe.label,!1,pe.description):pe.label,required:$e?!1:pe.required,validateStatus:$[pe.name]?"error":void 0,help:$[pe.name]||void 0,style:{marginBottom:0},children:nt(pe)},pe.name)})]})},ht=()=>{const me=e.confirm_fields||[];return me.length?b.jsx("div",{className:"human-confirm-panel__review-list",children:me.map(pe=>b.jsxs("div",{className:"human-confirm-panel__review-item",children:[b.jsx(Ip,{type:"secondary",className:"human-confirm-panel__review-label",children:pe.label}),b.jsx("div",{className:"human-confirm-panel__review-value",children:gye(Mg(pe.value,e))})]},pe.name||pe.label))}):e.output?b.jsx("div",{className:"human-confirm-panel__review-output",children:gye(e.output)}):null},Ve=b.jsxs("div",{ref:M,className:`human-confirm-panel__body${w==="review"?" human-confirm-panel__body--review":w==="input"?" human-confirm-panel__body--input":" human-confirm-panel__body--re-execute"}${K?" wandox-human-confirm-panel__body--re-execute":""}`,style:{display:"flex",flexDirection:"column",gap:12,flex:r==="bottom"?1:void 0,minHeight:r==="bottom"?0:void 0},children:[e.playbook_name&&!n&&!c&&b.jsxs(Ip,{type:"secondary",style:{fontSize:12},children:["步骤: ",e.playbook_name]}),e.timeout_minutes!=null&&!l&&b.jsx(c$,{type:"info",showIcon:!0,message:`请在 ${e.timeout_minutes} 分钟内处理`,style:{padding:"6px 10px",borderRadius:6}}),w==="review"?ht():ct()]});return b.jsx(Ts,{componentDisabled:f||void 0,children:b.jsxs("div",{className:`human-confirm-panel${n?" human-confirm-panel--compact":""}${r==="bottom"?" human-confirm-panel--bottom-actions":""}${f?" human-confirm-panel--preview-only":""}`,style:{display:"flex",flexDirection:"column",gap:12,minHeight:r==="bottom"?"100%":void 0},children:[r==="bottom"?b.jsxs("div",{className:"wandox-human-confirm-panel__body-shell",children:[Ve,b.jsx("div",{ref:R,className:`wandox-human-confirm-panel__scrollbar${z.visible?"":" wandox-human-confirm-panel__scrollbar--hidden"}`,"aria-hidden":"true",onPointerDown:oe,onPointerMove:fe,onPointerUp:he,onPointerCancel:he,onLostPointerCapture:he,children:b.jsx("span",{style:{height:z.thumbHeight,transform:`translateY(${z.thumbTop}px)`}})})]}):Ve,!d&&b.jsxs("div",{className:"human-confirm-panel__actions",style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:r==="bottom"?0:void 0,marginTop:r==="bottom"?"auto":void 0},children:[b.jsx(pa,{wrap:!0,children:Ie.left.map(Ue)}),b.jsx(pa,{wrap:!0,style:{justifyContent:"flex-end"},children:Ie.right.map(Ue)})]})]})})}const Dje="amazon_listing_focus";function ka(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Kr(e){return typeof e=="string"&&e?e:void 0}function yd(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()&&Number.isFinite(Number(e)))return Number(e)}function Oje(e){return typeof e=="boolean"?e:void 0}function lZt(e){return ka(e)&&"value"in e}function cZt(e){return!ka(e)||!ka(e.data)?null:e.output_type==="dynamic_form"||Object.values(e.data).some(lZt)?e.data:null}function lee(e){if(!ka(e))return null;if(ka(e.output))return lee(e.output);const t=ka(e.data)?e.data:e;return(ka(t.listing_data)||Array.isArray(t.listing_data))&&ka(t.properties)?t:null}function Lje(e){const t=lee(e),n=t==null?void 0:t.properties;return!ka(n)||!Array.isArray(n.propertyFocus)?[]:n.propertyFocus.map(r=>typeof r=="string"?r.trim():"").filter(Boolean)}function jje(e,t){var r,i;const n=Kr(e.type);return n||(Kr(e.options_from_skill)||(r=Jv(e.options))!=null&&r.length||(i=Jv(e.enum))!=null&&i.length?"select":ka(t)?"json_editor":"text")}function eF(e){if(Array.isArray(e))return e.map((t,n)=>{var i;const r=String(t.name||t.label||`field_${n+1}`);return{...t,name:r,type:jje(t,t.value),label:String(t.label||r),required:Oje(t.required)??!0,description:Kr(t.description),placeholder:Kr(t.placeholder),options:Jv(t.options),enum:(i=Jv(t.enum))==null?void 0:i.map(a=>String(a.value)),default:t.default,file_type:Kr(t.file_type),options_from_skill:Kr(t.options_from_skill),options_params:ka(t.options_params)?t.options_params:void 0}})}function uZt(e){const t=lee(e);if(t)return[{name:"listing_data",type:Lje(e).length?Dje:"json_editor",label:"刊登内容确认",required:!0,value:t.listing_data}];const n=cZt(e);if(!n)return;const r=Object.entries(n).map(([i,a])=>{var l;if(!ka(a))return null;const o=a.value,s=jje(a,o);return{name:i,type:s,label:Kr(a.label)||i,required:Oje(a.required),description:Kr(a.description),placeholder:Kr(a.placeholder),options:Jv(a.options),enum:(l=Jv(a.enum))==null?void 0:l.map(c=>String(c.value)),default:a.default,value:o,file_type:Kr(a.file_type),options_from_skill:Kr(a.options_from_skill),options_params:ka(a.options_params)?a.options_params:void 0}}).filter(i=>!!i);return r.length?r:void 0}function dZt(e,t){if(!(e!=null&&e.length)||!Lje(t).length)return e;let n=!1;const r=e.map(i=>{const a=i.type.trim().toLowerCase(),o=i.name==="listing_data",s=a==="json_editor"&&(o||e.length===1);return!o&&!s?i:(n=!0,{...i,name:o?i.name:"listing_data",type:Dje,label:i.label||"刊登内容确认",required:i.required??!0})});return n?r:e}function fZt(e,t){if(!(e!=null&&e.length)||!(t!=null&&t.length))return e;const n=new Map(t.map(r=>[r.name,r]));return e.map(r=>{var o,s,l,c,u,d;const i=n.get(r.name);if(!i)return r;const a=!!(i.options_from_skill||(o=i.options)!=null&&o.length||(s=i.enum)!=null&&s.length);return{...r,type:a&&!r.options_from_skill&&!((l=r.options)!=null&&l.length)&&!((c=r.enum)!=null&&c.length)?i.type:r.type,description:r.description??i.description,placeholder:r.placeholder??i.placeholder,options:(u=r.options)!=null&&u.length?r.options:i.options,enum:(d=r.enum)!=null&&d.length?r.enum:i.enum,file_type:r.file_type??i.file_type,options_from_skill:r.options_from_skill??i.options_from_skill,options_params:r.options_params&&Object.keys(r.options_params).length>0?r.options_params:i.options_params}})}function zje(e,t){if(t!=null&&t>0)return`step_${t}`;const n=e==null?void 0:e.match(/^step_(\d+)$/);if(!n)return;const r=Number(n[1]);if(!(!Number.isFinite(r)||r<=1))return`step_${r-1}`}function Rg(e,t){var r;if(!e)return;if(e.return_step_id)return e.return_step_id;const n=e.step_id;if(n&&(t!=null&&t.length)){const i=t.findIndex(a=>a.step_id===n);if(i>0)return(r=t[i-1])==null?void 0:r.step_id}return zje(n,e.step_index)}function Sj(e){const t=ka(e.human_input_config)?e.human_input_config:{},n=String(e.step_id??""),r=yd(e.step_index),i=e.output??e.output_data,a=ka(e.human_input_data)?e.human_input_data:{},o=ka(a.input_data)?a.input_data:void 0,s=dZt(eF(e.input_fields??t.input_fields)??uZt(i),i),l=eF(e.re_execute_params??t.re_execute_params),c=fZt(s,l),u=Kr(e.return_step_id)||Kr(e.previous_step_id)||Kr(e.prev_step_id)||Kr(t.return_step_id)||Kr(t.previous_step_id)||Kr(t.prev_step_id)||zje(n,r);return{step_id:n,step_index:r,return_step_id:u,step_db_id:yd(e.step_db_id)??yd(e.id),playbook_name:Kr(e.playbook_name)??Kr(e.step_name),message:Kr(e.message)??Kr(t.message),confirm_type:Kr(e.confirm_type)??Kr(t.confirm_type),position:Kr(e.position)??Kr(t.position),actions:Array.isArray(e.actions)?e.actions.map(String):Array.isArray(t.actions)?t.actions.map(String):void 0,confirm_fields:eF(e.confirm_fields??t.confirm_fields),input_fields:c,re_execute_params:l,retry_count:yd(e.retry_count)??yd(t.retry_count),max_retries:yd(e.max_retries)??yd(t.max_retries),timeout_minutes:yd(e.timeout_minutes)??yd(t.timeout_minutes),output:i,input:e.input??e.input_data,submitted_input:o}}async function I1(e,t){const n=await $gt({execution_id:e,...t?{step_id:t}:{}}),r=n,i=r.data??r.results??n,o=(Array.isArray(i)?i:ka(i)&&Array.isArray(i.items)?i.items:[])[0];return ka(o)?Sj(o):null}const pZt={createAgent:mgt,updateAgent:vgt,deleteAgent:ygt,enableMarketTemplate:Ngt,enableRecommendedTemplate:Mgt,cancelExecution:_gt,deleteExecution:Cgt,createTransfer:Tgt,rejectTransfer:kgt,createSchedule:xgt,updateSchedule:wgt,deleteSchedule:Sgt},dl={agents:["automation-mutation","agents"],market:["automation-mutation","market"],executions:["automation-mutation","executions"],transfers:["automation-mutation","transfers"],schedules:["automation-mutation","schedules"]};function hZt(e=pZt){return{agents:{create:()=>({mutationKey:[...dl.agents,"create"],mutationFn:t=>e.createAgent(t)}),update:()=>({mutationKey:[...dl.agents,"update"],mutationFn:({agentId:t,data:n})=>e.updateAgent(t,n)}),delete:()=>({mutationKey:[...dl.agents,"delete"],mutationFn:t=>e.deleteAgent(t)})},market:{enableTemplate:()=>({mutationKey:[...dl.market,"enable-template"],mutationFn:t=>e.enableMarketTemplate(t)}),enableRecommendedTemplate:()=>({mutationKey:[...dl.market,"enable-recommended-template"],mutationFn:t=>e.enableRecommendedTemplate({template_id:t})})},executions:{cancel:()=>({mutationKey:[...dl.executions,"cancel"],mutationFn:t=>e.cancelExecution(t)}),delete:()=>({mutationKey:[...dl.executions,"delete"],mutationFn:async({executionId:t,cancelFirst:n})=>(n&&await e.cancelExecution(t),e.deleteExecution(t))})},transfers:{create:()=>({mutationKey:[...dl.transfers,"create"],mutationFn:({resultId:t,data:n})=>e.createTransfer(t,n)}),reject:()=>({mutationKey:[...dl.transfers,"reject"],mutationFn:t=>e.rejectTransfer(t)})},schedules:{create:()=>({mutationKey:[...dl.schedules,"create"],mutationFn:({agentId:t,data:n})=>e.createSchedule(t,n)}),update:()=>({mutationKey:[...dl.schedules,"update"],mutationFn:({scheduleId:t,data:n})=>e.updateSchedule(t,n)}),delete:()=>({mutationKey:[...dl.schedules,"delete"],mutationFn:({scheduleId:t})=>e.deleteSchedule(t)})}}}const Bl=hZt(),{Text:tF}=ec;function cee({open:e,onClose:t,resultId:n}){const{transferTargetResultId:r}=Er(),i=n??r,[a,o]=m.useState([]),[s,l]=m.useState([]),[c,u]=m.useState(""),[d,f]=m.useState(!1),p=wa(),h=Ll({...Bl.transfers.create(),onSuccess:()=>Ys(p,{type:"transfer-created"})});m.useEffect(()=>{e&&(f(!0),fgt().then(w=>{const S=w.data??w.results??w,_=S.items??(Array.isArray(S)?S:[]),C=localStorage.getItem("sso_user_id")||localStorage.getItem("sso_username")||"",$=[..._].sort((E,k)=>{const T=E.user_id===C||E.username===C?-1:0,I=k.user_id===C||k.username===C?-1:0;return T-I});o($)}).catch(()=>{}).finally(()=>f(!1)))},[e]);const g=async()=>{if(!s.length){Ze.warning("请至少选择一位用户");return}if(!i){Ze.warning("缺少结果 ID");return}try{const w=localStorage.getItem("sso_company")||"";await h.mutateAsync({resultId:i,data:{targets:s.map(_=>({user_id:_,company_code:w,type:"to_user"})),message:c||void 0}});const S=a.filter(_=>s.includes(_.user_id)).map(_=>_.display_name||_.username).join("、");Ze.success(`已流转给 ${S}`),l([]),u(""),t()}catch(w){Ze.error(w instanceof Error?w.message:"流转失败")}},v=()=>{l([]),u(""),t()},y=localStorage.getItem("sso_user_id")||localStorage.getItem("sso_username")||"",x=a.map(w=>({value:w.user_id,label:w.user_id===y||w.username===y?`${w.display_name||w.username}(我)`:w.display_name||w.username,desc:w.username}));return b.jsx(rr,{title:"👤 对内流转",open:e,onCancel:v,onOk:g,okText:"确认流转",cancelText:"取消",width:420,confirmLoading:h.isPending,children:b.jsxs(pa,{orientation:"vertical",style:{width:"100%"},size:16,children:[b.jsxs("div",{children:[b.jsx(tF,{type:"secondary",style:{display:"block",marginBottom:8},children:"选择接收结果的内部用户:"}),b.jsx(tn,{mode:"multiple",style:{width:"100%"},placeholder:"搜索并选择用户...",value:s,onChange:l,loading:d,showSearch:!0,filterOption:(w,S)=>((S==null?void 0:S.label)??"").toLowerCase().includes(w.toLowerCase()),options:x,optionRender:w=>{var S;return b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#1677ff",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:600,flexShrink:0},children:((S=w.label)==null?void 0:S[0])??"?"}),b.jsxs("div",{children:[b.jsx("div",{style:{fontSize:13},children:w.label}),w.data.desc&&b.jsx("div",{style:{fontSize:11,color:"#9ca3af"},children:w.data.desc})]})]})}})]}),b.jsxs("div",{children:[b.jsx(tF,{type:"secondary",style:{display:"block",marginBottom:6},children:"留言(可选)"}),b.jsx(Kt.TextArea,{rows:2,value:c,onChange:w=>u(w.target.value),placeholder:"附上说明信息..."})]}),b.jsx(c$,{type:"info",showIcon:!0,style:{fontSize:12},title:b.jsxs("span",{children:["流转后接收方可在 ",b.jsx(tF,{strong:!0,children:"结果收件箱"})," 中查看"]})})]})})}function Wd(e,t,n,r){return e?{type:e,content:t,fields_map:n||void 0,title:r}:t}function I_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mZt(e){return e.map(t=>I_(t)?t:{value:t})}function Fje(e){if(!I_(e))return e;const t=typeof e.output_type=="string"?e.output_type:"",n=e.data??e.output,r=Array.isArray(e.output_fields_map)?e.output_fields_map:void 0,i=typeof e.title=="string"?e.title:void 0;if(t!=="dynamic_form"){if(t==="card"&&I_(n)&&typeof n.content=="string")return n.content;if(Array.isArray(n)){const a=mZt(n),o=r!=null&&r.length?r:n.every(s=>!I_(s))?[{name:"value",label:"结果"}]:void 0;return Wd("table",a,o,i)}return I_(n)?t==="debug"&&!(r!=null&&r.length)?Wd("debug",n,void 0,i):Wd("card",n,r,i):t?Wd(t,n,r,i):q2(e)}}function q2(e){var n,r;if(!e||typeof e!="object")return e;const t=e;return typeof t.type=="string"?e:t.output_type?Wd(t.output_type,t.data??t.output,t.output_fields_map,t.title):((n=t.output)==null?void 0:n.content)!==void 0?t.output.content:t.output!==void 0?t.output:((r=t.data)==null?void 0:r.content)!==void 0?t.data.content:t.content!==void 0?t.content:e}const{Text:yye}=ec,nF={pending:"待执行",running:"执行中",awaiting_async:"等待异步结果",waiting_input:"等待人工确认",completed:"已完成",failed:"失败"};function gZt(e){return e==="completed"?"finish":e==="failed"?"error":e==="running"||e==="awaiting_async"||e==="waiting_input"?"process":"wait"}function vZt(e,t){if(!e.length)return 0;const n=e.findIndex(i=>i.status==="running"||i.status==="awaiting_async"||i.status==="waiting_input");if(n>=0)return n;if(t==="completed")return e.length-1;const r=e.findIndex(i=>i.status==="pending");return r>=0?r:0}function $P(e){return e!=null?`${(e/1e3).toFixed(1)}s`:void 0}const yZt={pending:"待执行",running:"执行中",completed:"已完成",failed:"失败"};function uee(e){var t;return(t=e==null?void 0:e.substeps)!=null&&t.length?e.substeps.find(n=>n.status==="running")??e.substeps[e.substeps.length-1]:null}function bZt(e){const t=e.find(n=>n.status==="running"||n.status==="awaiting_async");return uee(t)}function xZt(e){if(!Array.isArray(e))return;const t=[];for(const n of e){const r=n.name||n.key;r&&t.push({name:r,label:n.label||r,type:n.type})}return t}function wZt(e){return e.output_content===void 0?null:!e.output_type||e.output_type==="text"?e.output_content:Wd(e.output_type,e.output_content,xZt(e.output_fields_map),e.substep_name)}function SZt(e){var i;if(!((i=e==null?void 0:e.substeps)!=null&&i.length))return"";const t=uee(e),n=(t==null?void 0:t.substep_total)||e.substeps.length,r=e.substeps.filter(a=>a.status==="completed").length;return(t==null?void 0:t.status)==="running"?t.message||`正在执行:${t.substep_name}`:(t==null?void 0:t.status)==="failed"?`${t.substep_name} 执行失败`:`${r}/${n} 个子步骤已完成`}function _Zt({agentId:e,inputData:t,onFinish:n,onCompleted:r,onRerun:i,onBackToParams:a,hasInputParams:o,skipAutoStart:s}){const{executionSteps:l,latestSSEEvent:c,currentExecutionId:u}=Er(),{startExecution:d,resumeExecution:f,abort:p}=rJ(),[h,g]=m.useState("running"),[v,y]=m.useState(null),[x,w]=m.useState(null),[S,_]=m.useState(null),[C,$]=m.useState(!1),[E,k]=m.useState(!1),[T,I]=m.useState(null),[P,N]=m.useState(null),[A,M]=m.useState(null),R=m.useRef(!1),L=m.useRef(r),z=m.useRef(l),j=m.useRef(u);m.useEffect(()=>{L.current=r},[r]),m.useEffect(()=>{z.current=l},[l]),m.useEffect(()=>{j.current=u},[u]),m.useEffect(()=>{if(!s&&!R.current)return R.current=!0,d(e,t).catch(ee=>{const te=ee instanceof Error?ee.message:"执行失败";y(te),g("failed")}),()=>{p()}},[p,e,t,s,d]),m.useEffect(()=>{var te,oe,fe;if(!c)return;const ee=c;switch(ee.type){case"execution_init":M(((oe=(te=ee.steps)==null?void 0:te[0])==null?void 0:oe.step_id)??null);break;case"execution_started":g("running");break;case"resume_init":g("running");break;case"re_executing":g("running"),ee.step_id&&M(ee.step_id);break;case"step_running":g("running"),ee.step_id&&M(ee.step_id);break;case"step_awaiting_async":case"step_pending_async":g("running"),ee.step_id&&M(ee.step_id);break;case"step_completed":ee.step_id&&M(ee.step_id);break;case"step_failed":y(ee.error||ee.error_message||"执行失败"),ee.step_id&&M(ee.step_id);break;case"waiting_input":g("waiting_input"),ee.step_id&&M(ee.step_id),w(ee.step_id??null);{const he=Sj(ee);_({...he,return_step_id:Rg(he,z.current)});const ye=j.current;ye&&I1(ye,ee.step_id).then(Te=>{if(!Te)return;const Ee={...Te,return_step_id:Rg(Te,z.current)};w(Ee.step_id),_(Ee),M(Ee.step_id)}).catch(()=>{})}break;case"execution_completed":g("completed"),ee.final_output&&I(ee.final_output),ee.result_id&&N(ee.result_id),(fe=L.current)==null||fe.call(L,ee.result_id??null);break;case"execution_failed":g("failed"),y(ee.error||ee.error_message||"执行失败");break;case"timeout":y("执行超时"),g("failed");break}},[c]);const O=async ee=>{const te=(S==null?void 0:S.step_id)||x,oe=ee.action==="return_previous"?Rg(S,l):te;if(!(!u||!oe)){g("running"),w(null),_(null),$(!0);try{if(await f(Number(u),oe,ee.inputData,{action:ee.action,confirmedInput:ee.confirmedInput,modifiedParams:ee.modifiedParams}),ee.action==="return_previous"){const fe=await I1(u,oe);if(fe){const he={...fe,return_step_id:Rg(fe,l)};w(he.step_id),_(he),M(he.step_id),g("waiting_input")}return}ee.action==="cancel"&&(y("执行已取消"),g("cancelled"))}catch(fe){const he=fe instanceof Error?fe.message:"恢复执行失败";y(he),g("failed")}finally{$(!1)}}},V=ee=>q2(ee),B=vZt(l,h),D=l[B],H=l.find(ee=>ee.step_id===A)||D,W=H?V(H.output_data):null,K=(H==null?void 0:H.substeps)??[],U=bZt(l),q=D?uee(D):null,Q=(H==null?void 0:H.status)==="completed"&&W!=null,G=!!(H&&(Q||K.length>0)),X=l.map((ee,te)=>{const oe=te===B,fe=$P(ee.duration_ms),he=SZt(ee);let ye=nF[ee.status]||ee.status||"";return oe&&h==="waiting_input"?ye="待人工处理":oe&&he?ye=he:oe&&(ee.status==="running"||ee.status==="awaiting_async")?ye="处理中":ee.status==="completed"?ye=fe?`耗时 ${fe}`:"已完成":ee.requires_human_confirm&&ee.status==="pending"&&(ye="待人工确认"),{key:ee.step_id,status:gZt(ee.status),title:ee.step_name||`步骤 ${te+1}`,description:b.jsx("span",{className:"exec-tracker__step-desc",children:ye})}}),J=()=>{if(T)try{const ee=T.output_type||"debug",te=T.output,oe=T.output_fields_map,fe=new Date().toISOString().slice(0,10);if(ee==="table"&&Array.isArray(te)){const he=Array.isArray(oe)&&oe.length>0?oe.map(ne=>({name:ne.name,label:ne.label||ne.name})):Object.keys(te[0]||{}).map(ne=>({name:ne,label:ne})),ye=he.map(ne=>ne.label).join(","),Te=te.map(ne=>he.map(ge=>{const be=ne[ge.name],Ce=be==null?"":String(be);return Ce.includes(",")||Ce.includes('"')||Ce.includes(`
|
|
790
790
|
`)?`"${Ce.replace(/"/g,'""')}"`:Ce}).join(",")),Ee=`\uFEFF${[ye,...Te].join(`
|
|
791
|
-
`)}`,we=new Blob([Ee],{type:"text/csv;charset=utf-8;"}),le=URL.createObjectURL(we),se=document.createElement("a");se.href=le,se.download=`执行结果_${fe}.csv`,se.click(),URL.revokeObjectURL(le)}else{const he=JSON.stringify(te??T,null,2),ye=new Blob([he],{type:"application/json"}),Te=URL.createObjectURL(ye),Ee=document.createElement("a");Ee.href=Te,Ee.download=`执行结果_${fe}.json`,Ee.click(),URL.revokeObjectURL(Te)}Ze.success("导出成功")}catch{Ze.error("导出失败")}},Z=!!(o&&a||i)?b.jsxs("div",{className:"exec-tracker__run-actions",children:[o&&a&&b.jsx(Et,{block:!0,icon:b.jsx(Tpt,{}),onClick:a,children:"返回修改参数"}),i&&b.jsx(Et,{block:!0,icon:b.jsx(yy,{}),onClick:i,children:"再次执行"})]}):null,re=h==="completed"?b.jsxs(b.Fragment,{children:[Z,b.jsxs("div",{className:"exec-tracker__run-actions exec-tracker__run-actions--primary",children:[T&&b.jsx(Et,{block:!0,icon:b.jsx(rw,{}),onClick:J,children:"导出"}),b.jsx(Et,{type:"primary",block:!0,onClick:()=>k(!0),children:"流转给用户"})]})]}):h==="failed"||h==="cancelled"?b.jsxs(b.Fragment,{children:[Z,b.jsx(Et,{block:!0,className:"exec-tracker__actions",onClick:n,children:"返回智能体列表"})]}):null;return b.jsxs("div",{className:"exec-tracker",children:[b.jsxs("div",{className:"exec-tracker__content",children:[l.length>1&&b.jsx("div",{className:"exec-tracker__flow",children:b.jsx(I$e,{current:B,size:"small",labelPlacement:"vertical",className:"exec-tracker__flow-steps",onChange:ee=>{var te;return M(((te=l[ee])==null?void 0:te.step_id)??null)},items:X})}),l.length===1&&D&&b.jsxs("div",{className:`exec-tracker__single-flow exec-tracker__single-flow--${D.status||h}`,children:[b.jsx("span",{className:"exec-tracker__single-flow-mark","aria-hidden":"true"}),b.jsxs("div",{children:[b.jsx("div",{className:"exec-tracker__single-flow-title",children:D.step_name||"当前流程"}),b.jsxs("div",{className:"exec-tracker__single-flow-meta",children:[b.jsx("span",{children:nF[D.status]||D.status||"执行中"}),D.playbook_id&&b.jsx("span",{children:D.playbook_id}),q&&b.jsx("span",{children:q.substep_name}),D.duration_ms!=null&&b.jsx("span",{children:$P(D.duration_ms)})]})]})]}),h==="running"&&!G&&b.jsxs("output",{className:"exec-tracker__running","aria-live":"polite",children:[b.jsxs("div",{className:"exec-tracker__running-track","aria-hidden":"true",children:[b.jsx("span",{}),b.jsx("span",{}),b.jsx("span",{})]}),b.jsxs("div",{className:"exec-tracker__running-caption",children:[b.jsx("span",{className:"exec-tracker__running-dot","aria-hidden":"true"}),b.jsx("span",{children:U?U.message||`正在执行:${U.substep_name}`:"后台处理中,结果会自动更新"})]})]}),G&&H&&b.jsxs("div",{className:"exec-tracker__step-detail",children:[b.jsxs("div",{className:"exec-tracker__step-detail-header",children:[b.jsxs("div",{children:[b.jsx("div",{className:"exec-tracker__step-detail-title",children:H.step_name||`步骤 ${H.step_index+1}`}),b.jsxs("div",{className:"exec-tracker__step-detail-meta",children:[b.jsx("span",{children:H.step_id}),H.playbook_id&&b.jsx("span",{children:H.playbook_id}),H.duration_ms!=null&&b.jsx("span",{children:$P(H.duration_ms)})]})]}),b.jsx(ji,{color:H.status==="failed"?"error":H.status==="completed"?"success":H.status==="pending"?"default":"processing",children:nF[H.status]||H.status})]}),Q?b.jsx("div",{className:"exec-tracker__step-detail-content",children:b.jsx(Ci,{payload:W})}):null,K.length>0?b.jsx("div",{className:"wandox-exec-tracker-substeps",children:K.map(ee=>{const te=SZt(ee),oe=$P(ee.duration_ms);return b.jsxs("div",{className:`wandox-exec-tracker-substeps__item wandox-exec-tracker-substeps__item--${ee.status}`,children:[b.jsx("span",{className:"wandox-exec-tracker-substeps__dot","aria-hidden":"true"}),b.jsxs("div",{className:"wandox-exec-tracker-substeps__body",children:[b.jsxs("div",{className:"wandox-exec-tracker-substeps__head",children:[b.jsxs("strong",{children:[ee.substep_index,". ",ee.substep_name]}),b.jsx(ji,{color:ee.status==="failed"?"error":ee.status==="completed"?"success":ee.status==="running"?"processing":"default",children:bZt[ee.status]})]}),b.jsxs("div",{className:"wandox-exec-tracker-substeps__meta",children:[ee.skill_id&&b.jsx("span",{children:ee.skill_id}),oe&&b.jsx("span",{children:oe}),ee.is_stop_on_empty&&b.jsx("span",{children:"数据为空已停止"})]}),ee.error?b.jsx("div",{className:"wandox-exec-tracker-substeps__error",children:ee.error}):null,te!==null?b.jsx("div",{className:"wandox-exec-tracker-substeps__preview",children:b.jsx(Ci,{payload:te})}):null]})]},ee.id)})}):null]}),h==="waiting_input"&&b.jsxs("div",{className:"exec-tracker__human",children:[b.jsxs("div",{className:"exec-tracker__human-header",children:[b.jsx("span",{className:"exec-tracker__human-icon",children:"!"}),b.jsxs("div",{children:[b.jsx("div",{className:"exec-tracker__human-title",children:(S==null?void 0:S.message)||"需要人工确认"}),(S==null?void 0:S.playbook_name)&&b.jsx("div",{className:"exec-tracker__human-sub",children:S.playbook_name})]})]}),b.jsx("div",{className:"exec-tracker__input-form",children:S&&b.jsx(see,{data:S,submitting:C,actionsPlacement:"bottom",onSubmit:O})})]}),h==="completed"&&b.jsxs("div",{className:"exec-tracker__result",children:[b.jsxs("div",{className:"exec-tracker__result-header",children:[b.jsx(Gh,{style:{color:"#52c41a"}}),b.jsx(yye,{strong:!0,style:{color:"#389e0d"},children:"执行结果"})]}),b.jsx("div",{className:"exec-tracker__result-body",children:T?T.output_type==="debug"?b.jsx(Ci,{payload:Wd("card",T.output,T.output_fields_map,T.title)}):b.jsx(Ci,{payload:q2(T)}):b.jsx(yye,{type:"secondary",style:{fontSize:12},children:"执行完成,结果已保存"})})]}),(h==="failed"||h==="cancelled")&&b.jsx("div",{className:"exec-tracker__failure",children:v&&b.jsxs("div",{className:"exec-tracker__failure-message",children:[b.jsx("div",{className:"exec-tracker__failure-title",children:h==="cancelled"?"执行已取消":"执行失败"}),b.jsx("div",{className:"exec-tracker__failure-text",children:v})]})})]}),re&&b.jsx("div",{className:"exec-tracker__footer",children:re}),b.jsx(cee,{open:E,onClose:()=>k(!1),resultId:P??void 0})]})}const $Zt=[{category:"数据提取与筛选",templates:[{name:"字段抽取",content:"从数据中提取以下字段:[字段1、字段2、字段3],以 JSON 数组形式输出,字段不存在时填 null。"},{name:"条件筛选",content:"筛选出满足以下条件的条目:[条件描述],保留原始字段结构输出。"},{name:"ASIN 属性提取",content:"从商品数据中提取 ASIN、标题、品牌、价格、评分、评论数、BSR 排名,以表格形式输出。"}]},{category:"汇总与统计",templates:[{name:"分组统计",content:"按 [分组维度] 对数据分组,统计每组的 [指标],按该指标降序排列,输出前 [N] 项。"},{name:"对比分析",content:"对比 [对象A] 和 [对象B] 在以下维度的差异:[维度列表],用表格输出,最后一句话总结核心差异。"},{name:"销售趋势汇总",content:"按日期汇总销售数据,计算每日销量、销售额、均价,标注环比变化超过20%的异常日期。"}]},{category:"摘要与总结",templates:[{name:"结构化摘要",content:'对数据进行摘要,输出:一句话结论、3个关键发现、值得关注的异常点(若无则写"无")。语言简洁。'},{name:"精简总结",content:"用不超过 [N] 字总结核心内容,面向 [运营/老板/工程师],只保留有决策价值的信息。"},{name:"评论情感汇总",content:"分析商品评论,汇总正面评价TOP3要点、负面评价TOP3要点、改进建议,以结构化列表输出。"}]},{category:"分类与质检",templates:[{name:"多标签分类",content:'为每条数据打标签,候选标签:[标签列表],一条可多标签,无匹配标注"其他"。'},{name:"数据校验",content:"检查数据异常项,异常定义:[规则描述],输出异常条目及原因,无异常返回空数组。"},{name:"Listing 质量检查",content:"检查 Listing 的标题长度、要点数量、图片数量、A+内容是否完整,输出各项得分和改进建议。"}]},{category:"转换与改写",templates:[{name:"格式转换",content:"将数据从 [原格式] 转换为 [目标格式],保持字段语义一致,不新增不删减。"},{name:"多语言翻译",content:"将 [字段名/全部文本] 翻译为 [目标语言],保留专有名词原文,其他结构不变。"}]}];function EZt({onSelect:e}){return b.jsxs("div",{className:"afd-prompt-templates",children:[b.jsx("div",{className:"afd-prompt-templates-title",children:"提示词模板"}),b.jsx(Gq,{ghost:!0,size:"small",items:$Zt.map((t,n)=>({key:String(n),label:b.jsx("span",{style:{fontSize:12,fontWeight:500,color:"#374151"},children:t.category}),children:b.jsx("div",{className:"afd-prompt-tpl-list",children:t.templates.map((r,i)=>b.jsxs("div",{className:"afd-prompt-tpl-item",onClick:()=>e(r.content),children:[b.jsx("span",{className:"afd-prompt-tpl-name",children:r.name}),b.jsxs("span",{className:"afd-prompt-tpl-preview",children:[r.content.slice(0,40),"..."]})]},i))})}))})]})}function bye(e,t){return e instanceof Error&&e.message||typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:t}function TZt(){var ee;const{showAgentDrawer:e,editingAgent:t,pendingTransferId:n,formName:r,formSceneId:i,formPlaybooks:a,playbooksLoading:o,scenesLoading:s,scenes:l,scenePlaybooks:c,setShowAgentDrawer:u,setEditingAgent:d,setFormName:f,setFormSceneId:p,setFormPlaybooks:h,resetForm:g,loadScenes:v,loadScenePlaybooks:y}=Er(),{acceptTransfer:x}=rJ(),w=wa(),S=Ll({...Bl.agents.create(),onSuccess:()=>Ys(w,{type:"agent-created"})}),_=Ll({...Bl.agents.update(),onSuccess:(te,{agentId:oe})=>Ys(w,{type:"agent-updated",agentId:oe})}),C=S.isPending||_.isPending,$=!!t,E=!!n,[k,T]=m.useState("config"),[I,P]=m.useState(!1),[N,A]=m.useState(!1);m.useEffect(()=>{e||T("config")},[e]),m.useEffect(()=>{e&&v()},[e]),m.useEffect(()=>{t&&e&&(f(t.name),p(t.scene_id),t.description&&Er.setState({formDescription:t.description}),t.playbooks&&t.playbooks.length>0?h(t.playbooks.map(te=>({playbook_id:te.playbook_id,params:te.params&&typeof te.params=="object"&&!Array.isArray(te.params)?te.params:{}}))):t.playbook_ids&&t.playbook_ids.length>0&&h(t.playbook_ids.map(te=>({playbook_id:te,params:{}}))))},[t,e]),m.useEffect(()=>{i&&y(i)},[i]);const M=async()=>{if(E){if(!n||!i)return;T("executing");const te=a[0],oe=(te==null?void 0:te.params)??{};try{await x(n,{action:"create_new",new_agent:{name:r.trim(),scene_id:i,playbook_ids:a.map(fe=>fe.playbook_id),playbooks:a.map(fe=>({playbook_id:fe.playbook_id,params:fe.params})),input_data:oe,description:Er.getState().formDescription||void 0,result_config:[]},create_execution_chain:I,fan_out_enabled:N})}catch(fe){Ze.error(bye(fe,"创建失败"))}}else{const te=Er.getState();try{if(t)await _.mutateAsync({agentId:t.id,data:{name:r.trim(),description:te.formDescription||void 0,playbooks:a,status:t.status}}),Ze.success("智能体更新成功");else{if(!i)return;await S.mutateAsync({name:r.trim(),scene_id:i,playbooks:a,input_data:{},description:te.formDescription||void 0,schedule_enabled:te.formScheduleEnabled||void 0,schedule_type:te.formScheduleEnabled?te.formScheduleType:void 0,schedule_cron:te.formScheduleEnabled?te.formScheduleCron:void 0,schedule_params:te.formScheduleEnabled?te.formScheduleParams:void 0}),Ze.success("智能体创建成功")}g(),u(!1)}catch(oe){Ze.error(bye(oe,t?"更新失败":"创建失败"))}}},R=()=>{g(),d(null),u(!1),T("config")},L=te=>{p(te),h([])},z=te=>{h([...a,{playbook_id:te,params:{}}])},j=te=>{h(a.filter((oe,fe)=>fe!==te))},O=(te,oe,fe)=>{const he=[...a];he[te]={...he[te],params:{...he[te].params,[oe]:fe}},h(he)},[V,B]=m.useState({}),D=async(te,oe,fe)=>{var ye;const he=`${te}-${oe}`;B(Te=>({...Te,[he]:!0}));try{const Ee=(ye=(await Sy(fe)).data)==null?void 0:ye.url;Ee?(O(te,oe,Ee),Ze.success(`${fe.name} 上传成功`)):Ze.error("上传失败,未获取到文件地址")}catch{Ze.error("文件上传失败")}finally{B(Te=>({...Te,[he]:!1}))}},[F,H]=m.useState(null),W=te=>{H(te)},K=(te,oe)=>{if(te.preventDefault(),F===null||F===oe)return;const fe=[...a],[he]=fe.splice(F,1);fe.splice(oe,0,he),h(fe),H(oe)},U=()=>{H(null)},q=te=>c.find(oe=>oe.playbook_id===te),Q=te=>{var oe;return((oe=q(te))==null?void 0:oe.name)??te},G=m.useMemo(()=>a.map((te,oe)=>({entry:te,idx:oe,pb:q(te.playbook_id)})).filter(({idx:te,pb:oe})=>(E?!0:te>0)&&(oe==null?void 0:oe.input_params)&&oe.input_params.length>0),[a,c,E]),X=()=>r.trim()?i?a.length===0?(Ze.warning("请至少选择一个分析技能"),!1):!0:(Ze.warning("请选择场景"),!1):(Ze.warning("请输入智能体名称"),!1),J=()=>{if(k==="config"){if(!X())return;G.length>0?T("params"):M()}else if(k==="params"){if(!Z())return;M()}},Y=()=>{k==="params"&&T("config")},Z=()=>{for(const{entry:te,pb:oe}of G)for(const fe of oe.input_params)if(fe.required&&!te.params[fe.name]&&te.params[fe.name]!==0)return Ze.warning(`请填写「${oe.name}」的参数「${fe.label||fe.name}」`),!1;return!0},re=()=>k==="executing"?b.jsx("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:b.jsx("button",{type:"button",className:"afd-cancel",onClick:R,children:"关闭"})}):k==="config"?G.length>0?b.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b.jsx("button",{type:"button",className:"afd-cancel",onClick:R,children:"取消"}),b.jsx(Et,{type:"primary",icon:b.jsx(Aft,{}),onClick:J,style:{borderRadius:8,fontWeight:500},children:"下一步"})]}):b.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b.jsx("button",{type:"button",className:"afd-cancel",onClick:R,children:"取消"}),b.jsx(Et,{type:"primary",icon:E?b.jsx(Fc,{}):$?b.jsx(ff,{}):b.jsx(Uo,{}),onClick:J,loading:C,style:{borderRadius:8,fontWeight:500},children:E?"创建并执行":$?"保存修改":"创建智能体"})]}):b.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b.jsx(Et,{icon:b.jsx(q$,{}),onClick:Y,style:{borderRadius:8},children:"上一步"}),b.jsx(Et,{type:"primary",icon:E?b.jsx(Fc,{}):$?b.jsx(ff,{}):b.jsx(Uo,{}),onClick:J,loading:C,style:{borderRadius:8,fontWeight:500},children:E?"创建并执行":$?"保存修改":"创建智能体"})]});return b.jsxs(X1,{title:null,open:e,onClose:R,size:640,closable:!1,maskClosable:!0,styles:{body:{padding:0},footer:{padding:"12px 24px",borderTop:"1px solid #f0f0f0"}},footer:re(),children:[b.jsxs("div",{className:"afd-header",children:[b.jsx("div",{className:"afd-header-title",children:E?"创建智能体并接受流转":$?"编辑智能体":"新建智能体"}),b.jsxs("div",{className:"afd-header-sub",children:[k==="config"&&"配置智能体的场景和技能",k==="params"&&"补充技能所需的参数信息",k==="executing"&&"正在创建智能体并执行"]}),b.jsxs("div",{className:"afd-steps",children:[b.jsxs("span",{className:`afd-step${k==="config"?" afd-step--active":" afd-step--done"}`,children:[b.jsx("span",{className:"afd-step-num",children:"1"})," 基础配置"]}),G.length>0&&b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"afd-step-arrow",children:"→"}),b.jsxs("span",{className:`afd-step${k==="params"?" afd-step--active":k==="executing"?" afd-step--done":""}`,children:[b.jsx("span",{className:"afd-step-num",children:"2"})," 补充参数"]})]}),E&&b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"afd-step-arrow",children:"→"}),b.jsxs("span",{className:`afd-step${k==="executing"?" afd-step--active":""}`,children:[b.jsx("span",{className:"afd-step-num",children:G.length>0?3:2})," 执行"]})]})]})]}),k==="config"&&b.jsxs("div",{className:"afd-body",children:[b.jsxs("div",{className:"afd-section",children:[b.jsxs("div",{className:"afd-label",children:["智能体名称 ",b.jsx("span",{className:"afd-required",children:"*"})]}),b.jsx(Kt,{value:r,onChange:te=>f(te.target.value),placeholder:"例如:亚马逊差评分析套件",style:{borderRadius:8}})]}),b.jsxs("div",{className:"afd-section",children:[b.jsxs("div",{className:"afd-label",children:[b.jsx(p2e,{style:{color:"#8b5cf6",marginRight:6}}),"应用场景"]}),b.jsx("div",{className:"afd-hint",children:"选择场景后,系统将推荐对应的分析技能"}),b.jsx("div",{className:"afd-scene-grid",children:s?b.jsx(vr,{size:"small",style:{padding:20}}):l.length===0?b.jsx("div",{className:"afd-empty",children:"暂无可用场景"}):l.map(te=>{const oe=i===te.id;return b.jsxs("button",{type:"button",className:`afd-scene-card${oe?" afd-scene-card--active":""}`,onClick:()=>L(te.id),children:[b.jsx("span",{className:"afd-scene-icon",children:te.icon||"📋"}),b.jsx("span",{className:"afd-scene-name",children:te.name}),te.description&&b.jsx("span",{className:"afd-scene-desc",children:te.description})]},te.id)})})]}),b.jsxs("div",{className:"afd-section",children:[b.jsxs("div",{className:"afd-label",children:[b.jsx(lY,{style:{color:"#f59e0b",marginRight:6}}),"分析技能",b.jsx("span",{className:"afd-label-sub",children:"点击左侧添加,右侧可拖拽排序"})]}),i?o?b.jsx(vr,{size:"small"}):c.length===0?b.jsx("div",{className:"afd-empty",children:"该场景暂无可用技能"}):b.jsxs("div",{className:"afd-skill-split",children:[b.jsxs("div",{className:"afd-skill-left",children:[b.jsx("div",{className:"afd-skill-col-title",children:"可选技能"}),c.map(te=>b.jsxs("button",{type:"button",className:"afd-skill-add-row",onClick:()=>z(te.playbook_id),children:[b.jsx(Uo,{style:{fontSize:11,color:"#8b5cf6"}}),b.jsxs("div",{className:"afd-skill-info",children:[b.jsx("div",{className:"afd-skill-name",children:te.name}),te.description&&b.jsx("div",{className:"afd-skill-desc",children:te.description})]}),te.is_required&&b.jsx("span",{className:"afd-skill-tag afd-skill-tag--required",children:"必选"}),te.is_recommended_combo&&!te.is_required&&b.jsx("span",{className:"afd-skill-tag afd-skill-tag--rec",children:"推荐"})]},te.playbook_id))]}),b.jsxs("div",{className:"afd-skill-right",children:[b.jsxs("div",{className:"afd-skill-col-title",children:["执行顺序 (",a.length,")"]}),a.length===0?b.jsx("div",{className:"afd-empty",style:{padding:"20px 0"},children:"点击左侧技能添加"}):a.map((te,oe)=>{const fe=q(te.playbook_id),he=(fe==null?void 0:fe.input_params)&&fe.input_params.length>0;return b.jsxs("div",{className:`afd-skill-sorted-row${F===oe?" afd-skill-sorted-row--dragging":""}`,draggable:!0,onDragStart:()=>W(oe),onDragOver:ye=>K(ye,oe),onDragEnd:U,children:[b.jsx(Y$e,{className:"afd-drag-handle"}),b.jsx("span",{className:"afd-skill-num",children:oe+1}),b.jsx("span",{className:"afd-skill-sorted-name",children:Q(te.playbook_id)}),oe===0&&he&&!E&&b.jsx("span",{style:{fontSize:10,color:"#8b5cf6",whiteSpace:"nowrap"},children:"执行时输入"}),(oe===0&&he&&E||oe>0&&he)&&b.jsx("span",{style:{fontSize:10,color:"#f59e0b",whiteSpace:"nowrap"},children:"需填参数"}),b.jsx("button",{type:"button",className:"afd-skill-remove",onClick:()=>j(oe),children:b.jsx(g2e,{})})]},`${te.playbook_id}-${oe}`)})]})]}):b.jsx("div",{className:"afd-empty",children:"请先选择场景"})]}),E&&b.jsxs("div",{className:"afd-section",children:[b.jsx("div",{className:"afd-label",children:"执行链配置"}),b.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b.jsx(yo,{size:"small",checked:I,onChange:P}),b.jsx("span",{style:{fontSize:13,color:I?"#111827":"#9ca3af"},children:I?"跟进新结果(执行完成后自动创建执行链)":"不跟进新结果"})]}),b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b.jsx(yo,{size:"small",checked:N,onChange:A}),b.jsx("span",{style:{fontSize:13,color:N?"#111827":"#9ca3af"},children:N?"按行执行结果(将表格数据逐行拆分执行)":"不按行执行"})]})]})]})]}),k==="params"&&b.jsxs("div",{className:"afd-body",children:[b.jsx("div",{className:"afd-params-hint",children:E?"以下技能需要补充参数,所有参数将在创建时一并提交。":`以下技能需要补充参数,第一个技能「${Q((ee=a[0])==null?void 0:ee.playbook_id)}」的参数将在执行时由用户输入。`}),G.map(({entry:te,idx:oe,pb:fe})=>b.jsxs("div",{className:"afd-params-card",children:[b.jsxs("div",{className:"afd-params-card-header",children:[b.jsx("span",{className:"afd-skill-num",children:oe+1}),b.jsx("span",{className:"afd-params-card-name",children:fe.name}),fe.description&&b.jsx("span",{className:"afd-params-card-desc",children:fe.description})]}),b.jsx("div",{className:"afd-params-card-body",children:fe.input_params.map(he=>{const ye=`${oe}-${he.name}`,Te=V[ye],Ee=te.params[he.name];return b.jsxs("div",{className:"afd-param-row",children:[b.jsxs("label",{className:"afd-param-label",children:[he.label||he.name,he.required&&b.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),he.description&&b.jsx("div",{className:"afd-param-desc",children:he.description}),he.type==="file"?b.jsx("div",{className:"afd-file-upload",children:Ee?b.jsxs("div",{className:"afd-file-uploaded",children:[b.jsx(eY,{style:{color:"#8b5cf6"}}),b.jsx("span",{className:"afd-file-name",title:Ee,children:Ee.split("/").pop()||Ee}),b.jsx("button",{type:"button",className:"afd-file-remove",onClick:()=>O(oe,he.name,""),children:b.jsx(hf,{})})]}):b.jsxs(zc.Dragger,{showUploadList:!1,accept:he.file_type||void 0,beforeUpload:we=>(D(oe,he.name,we),!1),disabled:Te,style:{padding:"8px 0"},children:[b.jsx("p",{className:"ant-upload-drag-icon",style:{marginBottom:4},children:Te?b.jsx(ql,{style:{fontSize:24,color:"#8b5cf6"}}):b.jsx(OE,{style:{fontSize:24,color:"#8b5cf6"}})}),b.jsx("p",{className:"ant-upload-text",style:{fontSize:13,margin:0},children:Te?"上传中...":"点击或拖拽文件到此处上传"})]})}):he.enum&&he.enum.length>0?b.jsx(tn,{size:"small",style:{width:"100%"},value:te.params[he.name]??he.default,onChange:we=>O(oe,he.name,we),placeholder:`请选择${he.label||he.name}`,allowClear:!0,children:he.enum.map(we=>b.jsx(tn.Option,{value:we,children:we},we))}):/prompt|提示词/i.test(he.name)||/prompt|提示词/i.test(he.label||"")?b.jsxs("div",{className:"afd-prompt-area",children:[b.jsx(Kt.TextArea,{value:te.params[he.name]??he.default??"",onChange:le=>O(oe,he.name,le.target.value),placeholder:"输入提示词,或从下方模板中选择...",autoSize:{minRows:4,maxRows:12},style:{fontSize:13}}),b.jsx(EZt,{onSelect:le=>O(oe,he.name,le)})]}):b.jsx(Kt,{size:"small",value:te.params[he.name]??he.default??"",onChange:le=>O(oe,he.name,le.target.value),placeholder:`请输入${he.label||he.name}`})]},he.name)})})]},`${te.playbook_id}-${oe}`))]}),k==="executing"&&E&&b.jsx("div",{className:"afd-body",children:b.jsx("div",{style:{background:"#fff",borderRadius:12,padding:24,border:"1px solid #e5e7eb"},children:b.jsx(CZt,{agentId:0,inputData:{},skipAutoStart:!0,onFinish:()=>{}})})})]})}const{Text:IZt}=ec;function kZt(e){return e.data??e.results??e}function xye(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function K2(e){return typeof e=="string"&&e.trim()?e:null}function Y2(e){if(!xye(e))return null;const t=Array.isArray(e.execution_steps)?e.execution_steps:[];for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(!xye(r))continue;const i=Y2(r.output_data)??Y2(r.output),a=K2(r.error_message);if(i)return i;if(a)return a}return K2(e.error_message)}function dee(e){if(!e)return null;const t=Y2(e.output_data),n=K2(e.error_message);return t??n}function PZt(e){for(let t=e.length-1;t>=0;t-=1){const n=dee(e[t]);if(n)return n}return null}function ZU(e){return e?e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`:"-"}function Bje(e){return e?new Date(e).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"-"}function NZt({title:e="执行失败",message:t,stepName:n,duration:r}){return b.jsxs("div",{className:"rdd-failure-notice",children:[b.jsx("div",{className:"rdd-failure-icon",children:b.jsx(ga,{})}),b.jsxs("div",{className:"rdd-failure-main",children:[b.jsx("div",{className:"rdd-failure-title",children:e}),(n||r)&&b.jsxs("div",{className:"rdd-failure-meta",children:[n&&b.jsxs("span",{className:"rdd-failure-chip",children:["失败步骤:",n]}),r&&b.jsxs("span",{className:"rdd-failure-chip",children:["耗时:",r]})]}),t&&b.jsx("div",{className:"rdd-failure-message",children:t})]})]})}function AZt({step:e,index:t,defaultExpanded:n}){const[r,i]=m.useState(n??!1),a=m.useRef(null);m.useEffect(()=>{i(n??!1)},[n,e.step_id]);const o=e.status==="completed",s=e.status==="failed",l=e.output_data,c=l==null?void 0:l.output_type,u=l==null?void 0:l.output_fields_map,d=(l==null?void 0:l.data)??(l==null?void 0:l.output),f=Fje(l),p=dee(e),h=d!=null||l!=null,g=p||h,v=c==="table"&&Array.isArray(d),y=m.useCallback(async x=>{x.stopPropagation();const w=e.step_name||`步骤${t+1}`,S=new Date().toISOString().slice(0,10);if(v){const _=Array.isArray(u)&&u.length>0?u.map(P=>({name:P.name,label:P.label||P.name})):Object.keys(d[0]||{}).map(P=>({name:P,label:P})),C=_.map(P=>P.label).join(","),$=d.map(P=>_.map(N=>{const A=P[N.name];if(A==null)return"";const M=typeof A=="object"?JSON.stringify(A):String(A);return M.includes(",")||M.includes('"')||M.includes(`
|
|
791
|
+
`)}`,we=new Blob([Ee],{type:"text/csv;charset=utf-8;"}),le=URL.createObjectURL(we),se=document.createElement("a");se.href=le,se.download=`执行结果_${fe}.csv`,se.click(),URL.revokeObjectURL(le)}else{const he=JSON.stringify(te??T,null,2),ye=new Blob([he],{type:"application/json"}),Te=URL.createObjectURL(ye),Ee=document.createElement("a");Ee.href=Te,Ee.download=`执行结果_${fe}.json`,Ee.click(),URL.revokeObjectURL(Te)}Ze.success("导出成功")}catch{Ze.error("导出失败")}},Z=!!(o&&a||i)?b.jsxs("div",{className:"exec-tracker__run-actions",children:[o&&a&&b.jsx(Et,{block:!0,icon:b.jsx(Tpt,{}),onClick:a,children:"返回修改参数"}),i&&b.jsx(Et,{block:!0,icon:b.jsx(yy,{}),onClick:i,children:"再次执行"})]}):null,re=h==="completed"?b.jsxs(b.Fragment,{children:[Z,b.jsxs("div",{className:"exec-tracker__run-actions exec-tracker__run-actions--primary",children:[T&&b.jsx(Et,{block:!0,icon:b.jsx(rw,{}),onClick:J,children:"导出"}),b.jsx(Et,{type:"primary",block:!0,onClick:()=>k(!0),children:"流转给用户"})]})]}):h==="failed"||h==="cancelled"?b.jsxs(b.Fragment,{children:[Z,b.jsx(Et,{block:!0,className:"exec-tracker__actions",onClick:n,children:"返回智能体列表"})]}):null;return b.jsxs("div",{className:"exec-tracker",children:[b.jsxs("div",{className:"exec-tracker__content",children:[l.length>1&&b.jsx("div",{className:"exec-tracker__flow",children:b.jsx(I$e,{current:B,size:"small",labelPlacement:"vertical",className:"exec-tracker__flow-steps",onChange:ee=>{var te;return M(((te=l[ee])==null?void 0:te.step_id)??null)},items:X})}),l.length===1&&D&&b.jsxs("div",{className:`exec-tracker__single-flow exec-tracker__single-flow--${D.status||h}`,children:[b.jsx("span",{className:"exec-tracker__single-flow-mark","aria-hidden":"true"}),b.jsxs("div",{children:[b.jsx("div",{className:"exec-tracker__single-flow-title",children:D.step_name||"当前流程"}),b.jsxs("div",{className:"exec-tracker__single-flow-meta",children:[b.jsx("span",{children:nF[D.status]||D.status||"执行中"}),D.playbook_id&&b.jsx("span",{children:D.playbook_id}),q&&b.jsx("span",{children:q.substep_name}),D.duration_ms!=null&&b.jsx("span",{children:$P(D.duration_ms)})]})]})]}),h==="running"&&!G&&b.jsxs("output",{className:"exec-tracker__running","aria-live":"polite",children:[b.jsxs("div",{className:"exec-tracker__running-track","aria-hidden":"true",children:[b.jsx("span",{}),b.jsx("span",{}),b.jsx("span",{})]}),b.jsxs("div",{className:"exec-tracker__running-caption",children:[b.jsx("span",{className:"exec-tracker__running-dot","aria-hidden":"true"}),b.jsx("span",{children:U?U.message||`正在执行:${U.substep_name}`:"后台处理中,结果会自动更新"})]})]}),G&&H&&b.jsxs("div",{className:"exec-tracker__step-detail",children:[b.jsxs("div",{className:"exec-tracker__step-detail-header",children:[b.jsxs("div",{children:[b.jsx("div",{className:"exec-tracker__step-detail-title",children:H.step_name||`步骤 ${H.step_index+1}`}),b.jsxs("div",{className:"exec-tracker__step-detail-meta",children:[b.jsx("span",{children:H.step_id}),H.playbook_id&&b.jsx("span",{children:H.playbook_id}),H.duration_ms!=null&&b.jsx("span",{children:$P(H.duration_ms)})]})]}),b.jsx(ji,{color:H.status==="failed"?"error":H.status==="completed"?"success":H.status==="pending"?"default":"processing",children:nF[H.status]||H.status})]}),Q?b.jsx("div",{className:"exec-tracker__step-detail-content",children:b.jsx(Ci,{payload:W})}):null,K.length>0?b.jsx("div",{className:"wandox-exec-tracker-substeps",children:K.map(ee=>{const te=wZt(ee),oe=$P(ee.duration_ms);return b.jsxs("div",{className:`wandox-exec-tracker-substeps__item wandox-exec-tracker-substeps__item--${ee.status}`,children:[b.jsx("span",{className:"wandox-exec-tracker-substeps__dot","aria-hidden":"true"}),b.jsxs("div",{className:"wandox-exec-tracker-substeps__body",children:[b.jsxs("div",{className:"wandox-exec-tracker-substeps__head",children:[b.jsxs("strong",{children:[ee.substep_index,". ",ee.substep_name]}),b.jsx(ji,{color:ee.status==="failed"?"error":ee.status==="completed"?"success":ee.status==="running"?"processing":"default",children:yZt[ee.status]})]}),b.jsxs("div",{className:"wandox-exec-tracker-substeps__meta",children:[ee.skill_id&&b.jsx("span",{children:ee.skill_id}),oe&&b.jsx("span",{children:oe}),ee.is_stop_on_empty&&b.jsx("span",{children:"数据为空已停止"})]}),ee.error?b.jsx("div",{className:"wandox-exec-tracker-substeps__error",children:ee.error}):null,te!==null?b.jsx("div",{className:"wandox-exec-tracker-substeps__preview",children:b.jsx(Ci,{payload:te})}):null]})]},ee.id)})}):null]}),h==="waiting_input"&&b.jsxs("div",{className:"exec-tracker__human",children:[b.jsxs("div",{className:"exec-tracker__human-header",children:[b.jsx("span",{className:"exec-tracker__human-icon",children:"!"}),b.jsxs("div",{children:[b.jsx("div",{className:"exec-tracker__human-title",children:(S==null?void 0:S.message)||"需要人工确认"}),(S==null?void 0:S.playbook_name)&&b.jsx("div",{className:"exec-tracker__human-sub",children:S.playbook_name})]})]}),b.jsx("div",{className:"exec-tracker__input-form",children:S&&b.jsx(see,{data:S,submitting:C,actionsPlacement:"bottom",onSubmit:O})})]}),h==="completed"&&b.jsxs("div",{className:"exec-tracker__result",children:[b.jsxs("div",{className:"exec-tracker__result-header",children:[b.jsx(Gh,{style:{color:"#52c41a"}}),b.jsx(yye,{strong:!0,style:{color:"#389e0d"},children:"执行结果"})]}),b.jsx("div",{className:"exec-tracker__result-body",children:T?T.output_type==="debug"?b.jsx(Ci,{payload:Wd("card",T.output,T.output_fields_map,T.title)}):b.jsx(Ci,{payload:q2(T)}):b.jsx(yye,{type:"secondary",style:{fontSize:12},children:"执行完成,结果已保存"})})]}),(h==="failed"||h==="cancelled")&&b.jsx("div",{className:"exec-tracker__failure",children:v&&b.jsxs("div",{className:"exec-tracker__failure-message",children:[b.jsx("div",{className:"exec-tracker__failure-title",children:h==="cancelled"?"执行已取消":"执行失败"}),b.jsx("div",{className:"exec-tracker__failure-text",children:v})]})})]}),re&&b.jsx("div",{className:"exec-tracker__footer",children:re}),b.jsx(cee,{open:E,onClose:()=>k(!1),resultId:P??void 0})]})}const CZt=[{category:"数据提取与筛选",templates:[{name:"字段抽取",content:"从数据中提取以下字段:[字段1、字段2、字段3],以 JSON 数组形式输出,字段不存在时填 null。"},{name:"条件筛选",content:"筛选出满足以下条件的条目:[条件描述],保留原始字段结构输出。"},{name:"ASIN 属性提取",content:"从商品数据中提取 ASIN、标题、品牌、价格、评分、评论数、BSR 排名,以表格形式输出。"}]},{category:"汇总与统计",templates:[{name:"分组统计",content:"按 [分组维度] 对数据分组,统计每组的 [指标],按该指标降序排列,输出前 [N] 项。"},{name:"对比分析",content:"对比 [对象A] 和 [对象B] 在以下维度的差异:[维度列表],用表格输出,最后一句话总结核心差异。"},{name:"销售趋势汇总",content:"按日期汇总销售数据,计算每日销量、销售额、均价,标注环比变化超过20%的异常日期。"}]},{category:"摘要与总结",templates:[{name:"结构化摘要",content:'对数据进行摘要,输出:一句话结论、3个关键发现、值得关注的异常点(若无则写"无")。语言简洁。'},{name:"精简总结",content:"用不超过 [N] 字总结核心内容,面向 [运营/老板/工程师],只保留有决策价值的信息。"},{name:"评论情感汇总",content:"分析商品评论,汇总正面评价TOP3要点、负面评价TOP3要点、改进建议,以结构化列表输出。"}]},{category:"分类与质检",templates:[{name:"多标签分类",content:'为每条数据打标签,候选标签:[标签列表],一条可多标签,无匹配标注"其他"。'},{name:"数据校验",content:"检查数据异常项,异常定义:[规则描述],输出异常条目及原因,无异常返回空数组。"},{name:"Listing 质量检查",content:"检查 Listing 的标题长度、要点数量、图片数量、A+内容是否完整,输出各项得分和改进建议。"}]},{category:"转换与改写",templates:[{name:"格式转换",content:"将数据从 [原格式] 转换为 [目标格式],保持字段语义一致,不新增不删减。"},{name:"多语言翻译",content:"将 [字段名/全部文本] 翻译为 [目标语言],保留专有名词原文,其他结构不变。"}]}];function $Zt({onSelect:e}){return b.jsxs("div",{className:"afd-prompt-templates",children:[b.jsx("div",{className:"afd-prompt-templates-title",children:"提示词模板"}),b.jsx(Gq,{ghost:!0,size:"small",items:CZt.map((t,n)=>({key:String(n),label:b.jsx("span",{style:{fontSize:12,fontWeight:500,color:"#374151"},children:t.category}),children:b.jsx("div",{className:"afd-prompt-tpl-list",children:t.templates.map((r,i)=>b.jsxs("div",{className:"afd-prompt-tpl-item",onClick:()=>e(r.content),children:[b.jsx("span",{className:"afd-prompt-tpl-name",children:r.name}),b.jsxs("span",{className:"afd-prompt-tpl-preview",children:[r.content.slice(0,40),"..."]})]},i))})}))})]})}function bye(e,t){return e instanceof Error&&e.message||typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:t}function EZt(){var ee;const{showAgentDrawer:e,editingAgent:t,pendingTransferId:n,formName:r,formSceneId:i,formPlaybooks:a,playbooksLoading:o,scenesLoading:s,scenes:l,scenePlaybooks:c,setShowAgentDrawer:u,setEditingAgent:d,setFormName:f,setFormSceneId:p,setFormPlaybooks:h,resetForm:g,loadScenes:v,loadScenePlaybooks:y}=Er(),{acceptTransfer:x}=rJ(),w=wa(),S=Ll({...Bl.agents.create(),onSuccess:()=>Ys(w,{type:"agent-created"})}),_=Ll({...Bl.agents.update(),onSuccess:(te,{agentId:oe})=>Ys(w,{type:"agent-updated",agentId:oe})}),C=S.isPending||_.isPending,$=!!t,E=!!n,[k,T]=m.useState("config"),[I,P]=m.useState(!1),[N,A]=m.useState(!1);m.useEffect(()=>{e||T("config")},[e]),m.useEffect(()=>{e&&v()},[e]),m.useEffect(()=>{t&&e&&(f(t.name),p(t.scene_id),t.description&&Er.setState({formDescription:t.description}),t.playbooks&&t.playbooks.length>0?h(t.playbooks.map(te=>({playbook_id:te.playbook_id,params:te.params&&typeof te.params=="object"&&!Array.isArray(te.params)?te.params:{}}))):t.playbook_ids&&t.playbook_ids.length>0&&h(t.playbook_ids.map(te=>({playbook_id:te,params:{}}))))},[t,e]),m.useEffect(()=>{i&&y(i)},[i]);const M=async()=>{if(E){if(!n||!i)return;T("executing");const te=a[0],oe=(te==null?void 0:te.params)??{};try{await x(n,{action:"create_new",new_agent:{name:r.trim(),scene_id:i,playbook_ids:a.map(fe=>fe.playbook_id),playbooks:a.map(fe=>({playbook_id:fe.playbook_id,params:fe.params})),input_data:oe,description:Er.getState().formDescription||void 0,result_config:[]},create_execution_chain:I,fan_out_enabled:N})}catch(fe){Ze.error(bye(fe,"创建失败"))}}else{const te=Er.getState();try{if(t)await _.mutateAsync({agentId:t.id,data:{name:r.trim(),description:te.formDescription||void 0,playbooks:a,status:t.status}}),Ze.success("智能体更新成功");else{if(!i)return;await S.mutateAsync({name:r.trim(),scene_id:i,playbooks:a,input_data:{},description:te.formDescription||void 0,schedule_enabled:te.formScheduleEnabled||void 0,schedule_type:te.formScheduleEnabled?te.formScheduleType:void 0,schedule_cron:te.formScheduleEnabled?te.formScheduleCron:void 0,schedule_params:te.formScheduleEnabled?te.formScheduleParams:void 0}),Ze.success("智能体创建成功")}g(),u(!1)}catch(oe){Ze.error(bye(oe,t?"更新失败":"创建失败"))}}},R=()=>{g(),d(null),u(!1),T("config")},L=te=>{p(te),h([])},z=te=>{h([...a,{playbook_id:te,params:{}}])},j=te=>{h(a.filter((oe,fe)=>fe!==te))},O=(te,oe,fe)=>{const he=[...a];he[te]={...he[te],params:{...he[te].params,[oe]:fe}},h(he)},[V,B]=m.useState({}),D=async(te,oe,fe)=>{var ye;const he=`${te}-${oe}`;B(Te=>({...Te,[he]:!0}));try{const Ee=(ye=(await Sy(fe)).data)==null?void 0:ye.url;Ee?(O(te,oe,Ee),Ze.success(`${fe.name} 上传成功`)):Ze.error("上传失败,未获取到文件地址")}catch{Ze.error("文件上传失败")}finally{B(Te=>({...Te,[he]:!1}))}},[F,H]=m.useState(null),W=te=>{H(te)},K=(te,oe)=>{if(te.preventDefault(),F===null||F===oe)return;const fe=[...a],[he]=fe.splice(F,1);fe.splice(oe,0,he),h(fe),H(oe)},U=()=>{H(null)},q=te=>c.find(oe=>oe.playbook_id===te),Q=te=>{var oe;return((oe=q(te))==null?void 0:oe.name)??te},G=m.useMemo(()=>a.map((te,oe)=>({entry:te,idx:oe,pb:q(te.playbook_id)})).filter(({idx:te,pb:oe})=>(E?!0:te>0)&&(oe==null?void 0:oe.input_params)&&oe.input_params.length>0),[a,c,E]),X=()=>r.trim()?i?a.length===0?(Ze.warning("请至少选择一个分析技能"),!1):!0:(Ze.warning("请选择场景"),!1):(Ze.warning("请输入智能体名称"),!1),J=()=>{if(k==="config"){if(!X())return;G.length>0?T("params"):M()}else if(k==="params"){if(!Z())return;M()}},Y=()=>{k==="params"&&T("config")},Z=()=>{for(const{entry:te,pb:oe}of G)for(const fe of oe.input_params)if(fe.required&&!te.params[fe.name]&&te.params[fe.name]!==0)return Ze.warning(`请填写「${oe.name}」的参数「${fe.label||fe.name}」`),!1;return!0},re=()=>k==="executing"?b.jsx("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:b.jsx("button",{type:"button",className:"afd-cancel",onClick:R,children:"关闭"})}):k==="config"?G.length>0?b.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b.jsx("button",{type:"button",className:"afd-cancel",onClick:R,children:"取消"}),b.jsx(Et,{type:"primary",icon:b.jsx(Aft,{}),onClick:J,style:{borderRadius:8,fontWeight:500},children:"下一步"})]}):b.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b.jsx("button",{type:"button",className:"afd-cancel",onClick:R,children:"取消"}),b.jsx(Et,{type:"primary",icon:E?b.jsx(Fc,{}):$?b.jsx(ff,{}):b.jsx(Uo,{}),onClick:J,loading:C,style:{borderRadius:8,fontWeight:500},children:E?"创建并执行":$?"保存修改":"创建智能体"})]}):b.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b.jsx(Et,{icon:b.jsx(q$,{}),onClick:Y,style:{borderRadius:8},children:"上一步"}),b.jsx(Et,{type:"primary",icon:E?b.jsx(Fc,{}):$?b.jsx(ff,{}):b.jsx(Uo,{}),onClick:J,loading:C,style:{borderRadius:8,fontWeight:500},children:E?"创建并执行":$?"保存修改":"创建智能体"})]});return b.jsxs(X1,{title:null,open:e,onClose:R,size:640,closable:!1,maskClosable:!0,styles:{body:{padding:0},footer:{padding:"12px 24px",borderTop:"1px solid #f0f0f0"}},footer:re(),children:[b.jsxs("div",{className:"afd-header",children:[b.jsx("div",{className:"afd-header-title",children:E?"创建智能体并接受流转":$?"编辑智能体":"新建智能体"}),b.jsxs("div",{className:"afd-header-sub",children:[k==="config"&&"配置智能体的场景和技能",k==="params"&&"补充技能所需的参数信息",k==="executing"&&"正在创建智能体并执行"]}),b.jsxs("div",{className:"afd-steps",children:[b.jsxs("span",{className:`afd-step${k==="config"?" afd-step--active":" afd-step--done"}`,children:[b.jsx("span",{className:"afd-step-num",children:"1"})," 基础配置"]}),G.length>0&&b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"afd-step-arrow",children:"→"}),b.jsxs("span",{className:`afd-step${k==="params"?" afd-step--active":k==="executing"?" afd-step--done":""}`,children:[b.jsx("span",{className:"afd-step-num",children:"2"})," 补充参数"]})]}),E&&b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"afd-step-arrow",children:"→"}),b.jsxs("span",{className:`afd-step${k==="executing"?" afd-step--active":""}`,children:[b.jsx("span",{className:"afd-step-num",children:G.length>0?3:2})," 执行"]})]})]})]}),k==="config"&&b.jsxs("div",{className:"afd-body",children:[b.jsxs("div",{className:"afd-section",children:[b.jsxs("div",{className:"afd-label",children:["智能体名称 ",b.jsx("span",{className:"afd-required",children:"*"})]}),b.jsx(Kt,{value:r,onChange:te=>f(te.target.value),placeholder:"例如:亚马逊差评分析套件",style:{borderRadius:8}})]}),b.jsxs("div",{className:"afd-section",children:[b.jsxs("div",{className:"afd-label",children:[b.jsx(p2e,{style:{color:"#8b5cf6",marginRight:6}}),"应用场景"]}),b.jsx("div",{className:"afd-hint",children:"选择场景后,系统将推荐对应的分析技能"}),b.jsx("div",{className:"afd-scene-grid",children:s?b.jsx(vr,{size:"small",style:{padding:20}}):l.length===0?b.jsx("div",{className:"afd-empty",children:"暂无可用场景"}):l.map(te=>{const oe=i===te.id;return b.jsxs("button",{type:"button",className:`afd-scene-card${oe?" afd-scene-card--active":""}`,onClick:()=>L(te.id),children:[b.jsx("span",{className:"afd-scene-icon",children:te.icon||"📋"}),b.jsx("span",{className:"afd-scene-name",children:te.name}),te.description&&b.jsx("span",{className:"afd-scene-desc",children:te.description})]},te.id)})})]}),b.jsxs("div",{className:"afd-section",children:[b.jsxs("div",{className:"afd-label",children:[b.jsx(lY,{style:{color:"#f59e0b",marginRight:6}}),"分析技能",b.jsx("span",{className:"afd-label-sub",children:"点击左侧添加,右侧可拖拽排序"})]}),i?o?b.jsx(vr,{size:"small"}):c.length===0?b.jsx("div",{className:"afd-empty",children:"该场景暂无可用技能"}):b.jsxs("div",{className:"afd-skill-split",children:[b.jsxs("div",{className:"afd-skill-left",children:[b.jsx("div",{className:"afd-skill-col-title",children:"可选技能"}),c.map(te=>b.jsxs("button",{type:"button",className:"afd-skill-add-row",onClick:()=>z(te.playbook_id),children:[b.jsx(Uo,{style:{fontSize:11,color:"#8b5cf6"}}),b.jsxs("div",{className:"afd-skill-info",children:[b.jsx("div",{className:"afd-skill-name",children:te.name}),te.description&&b.jsx("div",{className:"afd-skill-desc",children:te.description})]}),te.is_required&&b.jsx("span",{className:"afd-skill-tag afd-skill-tag--required",children:"必选"}),te.is_recommended_combo&&!te.is_required&&b.jsx("span",{className:"afd-skill-tag afd-skill-tag--rec",children:"推荐"})]},te.playbook_id))]}),b.jsxs("div",{className:"afd-skill-right",children:[b.jsxs("div",{className:"afd-skill-col-title",children:["执行顺序 (",a.length,")"]}),a.length===0?b.jsx("div",{className:"afd-empty",style:{padding:"20px 0"},children:"点击左侧技能添加"}):a.map((te,oe)=>{const fe=q(te.playbook_id),he=(fe==null?void 0:fe.input_params)&&fe.input_params.length>0;return b.jsxs("div",{className:`afd-skill-sorted-row${F===oe?" afd-skill-sorted-row--dragging":""}`,draggable:!0,onDragStart:()=>W(oe),onDragOver:ye=>K(ye,oe),onDragEnd:U,children:[b.jsx(Y$e,{className:"afd-drag-handle"}),b.jsx("span",{className:"afd-skill-num",children:oe+1}),b.jsx("span",{className:"afd-skill-sorted-name",children:Q(te.playbook_id)}),oe===0&&he&&!E&&b.jsx("span",{style:{fontSize:10,color:"#8b5cf6",whiteSpace:"nowrap"},children:"执行时输入"}),(oe===0&&he&&E||oe>0&&he)&&b.jsx("span",{style:{fontSize:10,color:"#f59e0b",whiteSpace:"nowrap"},children:"需填参数"}),b.jsx("button",{type:"button",className:"afd-skill-remove",onClick:()=>j(oe),children:b.jsx(g2e,{})})]},`${te.playbook_id}-${oe}`)})]})]}):b.jsx("div",{className:"afd-empty",children:"请先选择场景"})]}),E&&b.jsxs("div",{className:"afd-section",children:[b.jsx("div",{className:"afd-label",children:"执行链配置"}),b.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b.jsx(yo,{size:"small",checked:I,onChange:P}),b.jsx("span",{style:{fontSize:13,color:I?"#111827":"#9ca3af"},children:I?"跟进新结果(执行完成后自动创建执行链)":"不跟进新结果"})]}),b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b.jsx(yo,{size:"small",checked:N,onChange:A}),b.jsx("span",{style:{fontSize:13,color:N?"#111827":"#9ca3af"},children:N?"按行执行结果(将表格数据逐行拆分执行)":"不按行执行"})]})]})]})]}),k==="params"&&b.jsxs("div",{className:"afd-body",children:[b.jsx("div",{className:"afd-params-hint",children:E?"以下技能需要补充参数,所有参数将在创建时一并提交。":`以下技能需要补充参数,第一个技能「${Q((ee=a[0])==null?void 0:ee.playbook_id)}」的参数将在执行时由用户输入。`}),G.map(({entry:te,idx:oe,pb:fe})=>b.jsxs("div",{className:"afd-params-card",children:[b.jsxs("div",{className:"afd-params-card-header",children:[b.jsx("span",{className:"afd-skill-num",children:oe+1}),b.jsx("span",{className:"afd-params-card-name",children:fe.name}),fe.description&&b.jsx("span",{className:"afd-params-card-desc",children:fe.description})]}),b.jsx("div",{className:"afd-params-card-body",children:fe.input_params.map(he=>{const ye=`${oe}-${he.name}`,Te=V[ye],Ee=te.params[he.name];return b.jsxs("div",{className:"afd-param-row",children:[b.jsxs("label",{className:"afd-param-label",children:[he.label||he.name,he.required&&b.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),he.description&&b.jsx("div",{className:"afd-param-desc",children:he.description}),he.type==="file"?b.jsx("div",{className:"afd-file-upload",children:Ee?b.jsxs("div",{className:"afd-file-uploaded",children:[b.jsx(eY,{style:{color:"#8b5cf6"}}),b.jsx("span",{className:"afd-file-name",title:Ee,children:Ee.split("/").pop()||Ee}),b.jsx("button",{type:"button",className:"afd-file-remove",onClick:()=>O(oe,he.name,""),children:b.jsx(hf,{})})]}):b.jsxs(zc.Dragger,{showUploadList:!1,accept:he.file_type||void 0,beforeUpload:we=>(D(oe,he.name,we),!1),disabled:Te,style:{padding:"8px 0"},children:[b.jsx("p",{className:"ant-upload-drag-icon",style:{marginBottom:4},children:Te?b.jsx(ql,{style:{fontSize:24,color:"#8b5cf6"}}):b.jsx(OE,{style:{fontSize:24,color:"#8b5cf6"}})}),b.jsx("p",{className:"ant-upload-text",style:{fontSize:13,margin:0},children:Te?"上传中...":"点击或拖拽文件到此处上传"})]})}):he.enum&&he.enum.length>0?b.jsx(tn,{size:"small",style:{width:"100%"},value:te.params[he.name]??he.default,onChange:we=>O(oe,he.name,we),placeholder:`请选择${he.label||he.name}`,allowClear:!0,children:he.enum.map(we=>b.jsx(tn.Option,{value:we,children:we},we))}):/prompt|提示词/i.test(he.name)||/prompt|提示词/i.test(he.label||"")?b.jsxs("div",{className:"afd-prompt-area",children:[b.jsx(Kt.TextArea,{value:te.params[he.name]??he.default??"",onChange:le=>O(oe,he.name,le.target.value),placeholder:"输入提示词,或从下方模板中选择...",autoSize:{minRows:4,maxRows:12},style:{fontSize:13}}),b.jsx($Zt,{onSelect:le=>O(oe,he.name,le)})]}):b.jsx(Kt,{size:"small",value:te.params[he.name]??he.default??"",onChange:le=>O(oe,he.name,le.target.value),placeholder:`请输入${he.label||he.name}`})]},he.name)})})]},`${te.playbook_id}-${oe}`))]}),k==="executing"&&E&&b.jsx("div",{className:"afd-body",children:b.jsx("div",{style:{background:"#fff",borderRadius:12,padding:24,border:"1px solid #e5e7eb"},children:b.jsx(_Zt,{agentId:0,inputData:{},skipAutoStart:!0,onFinish:()=>{}})})})]})}const{Text:TZt}=ec;function IZt(e){return e.data??e.results??e}function xye(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function K2(e){return typeof e=="string"&&e.trim()?e:null}function Y2(e){if(!xye(e))return null;const t=Array.isArray(e.execution_steps)?e.execution_steps:[];for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(!xye(r))continue;const i=Y2(r.output_data)??Y2(r.output),a=K2(r.error_message);if(i)return i;if(a)return a}return K2(e.error_message)}function dee(e){if(!e)return null;const t=Y2(e.output_data),n=K2(e.error_message);return t??n}function kZt(e){for(let t=e.length-1;t>=0;t-=1){const n=dee(e[t]);if(n)return n}return null}function ZU(e){return e?e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`:"-"}function Bje(e){return e?new Date(e).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"-"}function PZt({title:e="执行失败",message:t,stepName:n,duration:r}){return b.jsxs("div",{className:"rdd-failure-notice",children:[b.jsx("div",{className:"rdd-failure-icon",children:b.jsx(ga,{})}),b.jsxs("div",{className:"rdd-failure-main",children:[b.jsx("div",{className:"rdd-failure-title",children:e}),(n||r)&&b.jsxs("div",{className:"rdd-failure-meta",children:[n&&b.jsxs("span",{className:"rdd-failure-chip",children:["失败步骤:",n]}),r&&b.jsxs("span",{className:"rdd-failure-chip",children:["耗时:",r]})]}),t&&b.jsx("div",{className:"rdd-failure-message",children:t})]})]})}function NZt({step:e,index:t,defaultExpanded:n}){const[r,i]=m.useState(n??!1),a=m.useRef(null);m.useEffect(()=>{i(n??!1)},[n,e.step_id]);const o=e.status==="completed",s=e.status==="failed",l=e.output_data,c=l==null?void 0:l.output_type,u=l==null?void 0:l.output_fields_map,d=(l==null?void 0:l.data)??(l==null?void 0:l.output),f=Fje(l),p=dee(e),h=d!=null||l!=null,g=p||h,v=c==="table"&&Array.isArray(d),y=m.useCallback(async x=>{x.stopPropagation();const w=e.step_name||`步骤${t+1}`,S=new Date().toISOString().slice(0,10);if(v){const _=Array.isArray(u)&&u.length>0?u.map(P=>({name:P.name,label:P.label||P.name})):Object.keys(d[0]||{}).map(P=>({name:P,label:P})),C=_.map(P=>P.label).join(","),$=d.map(P=>_.map(N=>{const A=P[N.name];if(A==null)return"";const M=typeof A=="object"?JSON.stringify(A):String(A);return M.includes(",")||M.includes('"')||M.includes(`
|
|
792
792
|
`)?`"${M.replace(/"/g,'""')}"`:M}).join(",")),E="\uFEFF"+[C,...$].join(`
|
|
793
|
-
`),k=new Blob([E],{type:"text/csv;charset=utf-8;"}),T=URL.createObjectURL(k),I=document.createElement("a");I.href=T,I.download=`${w}_${S}.csv`,I.click(),URL.revokeObjectURL(T)}else{const C=JSON.stringify(d??l,null,2),$=new Blob([C],{type:"application/json;charset=utf-8;"}),E=URL.createObjectURL($),k=document.createElement("a");k.href=E,k.download=`${w}_${S}.json`,k.click(),URL.revokeObjectURL(E)}},[e,t,v,d,u]);return b.jsxs("div",{className:`rdd-step${s?" rdd-step--fail":""}`,children:[b.jsxs("button",{type:"button",className:"rdd-step-header",onClick:()=>i(x=>!x),children:[b.jsx("span",{className:"rdd-step-idx",children:t+1}),o?b.jsx(Gh,{style:{color:"#52c41a",fontSize:14}}):s?b.jsx(Lf,{style:{color:"#ef4444",fontSize:14}}):b.jsx(fa,{style:{color:"#9ca3af",fontSize:14}}),b.jsx("span",{className:"rdd-step-name",children:e.step_name}),e.duration_ms!=null&&b.jsx("span",{className:"rdd-step-dur",children:ZU(e.duration_ms)}),h&&b.jsx(or,{title:v?"导出 CSV":"导出 JSON",children:b.jsx("span",{className:"rdd-step-export",onClick:y,role:"button",tabIndex:0,onKeyDown:x=>{x.key==="Enter"&&y(x)},children:b.jsx(rw,{style:{fontSize:12}})})}),b.jsx("span",{className:"rdd-step-arrow",children:r?b.jsx(nY,{}):b.jsx(nw,{})})]}),r&&g&&b.jsx("div",{className:"rdd-step-body",ref:a,children:p?b.jsx("div",{className:"rdd-step-error-text",children:p}):b.jsx(Ci,{payload:f})})]})}function MZt({lineage:e}){return e.length===0?b.jsx("div",{className:"rdd-empty",children:"暂无流转记录"}):b.jsx("div",{className:"rdd-lineage",children:e.map((t,n)=>b.jsxs("div",{className:"rdd-lineage-item",children:[b.jsx("div",{className:"rdd-lineage-dot",style:{background:t.status==="accepted"?"#52c41a":"#faad14"}}),n<e.length-1&&b.jsx("div",{className:"rdd-lineage-line"}),b.jsxs("div",{className:`rdd-lineage-card${t.status==="accepted"?" rdd-lineage-card--ok":""}`,children:[b.jsxs("div",{className:"rdd-lineage-row",children:[b.jsx(f2e,{style:{color:"#9ca3af",fontSize:11}}),b.jsxs("span",{children:["流转给 ",b.jsx("strong",{children:t.target_nick_name??t.target_user_id})]}),b.jsx(ji,{color:t.status==="accepted"?"success":t.status==="pending"?"warning":"default",style:{fontSize:10,margin:0},children:t.status==="accepted"?"已接受":t.status==="pending"?"待处理":t.status}),b.jsx("span",{className:"rdd-lineage-time",children:Bje(t.created_at)})]}),t.transfer_message&&b.jsxs("div",{className:"rdd-lineage-msg",children:["💬 ",t.transfer_message]})]})]},n))})}function RZt(){const{activeResult:e,showResultModal:t,setShowResultModal:n,setActiveResult:r}=Er(),[i,a]=m.useState(null),[o,s]=m.useState(!1),[l,c]=m.useState(!1),[u,d]=m.useState("x1"),f=u==="full"?"100vw":u==="x2"?1400:900,p=[{key:"x1",label:"x1"},{key:"x2",label:"x2"},{key:"full",label:"全屏"}];m.useEffect(()=>{if(!(e!=null&&e.execution_id)){a(null);return}s(!0),OEe(e.execution_id).then(R=>a(kZt(R))).catch(()=>a(null)).finally(()=>s(!1))},[e==null?void 0:e.execution_id]);const h=()=>{n(!1),r(null),a(null)},g=i==null?void 0:i.execution,v=i==null?void 0:i.result,y=((i==null?void 0:i.steps)??[]).filter(R=>R.status!=="skipped"),x=(i==null?void 0:i.transfers)??[],w=v==null?void 0:v.result_data,S=w==null?void 0:w.output,_=w==null?void 0:w.output_type,C=w==null?void 0:w.output_fields_map,$=_?Wd(_==="debug"?"card":_,S,C,w==null?void 0:w.title):q2(w),E=_?null:Y2(w)??Y2(S)??PZt(y)??K2(g==null?void 0:g.error_message)??K2(e==null?void 0:e.error_message),k=(v==null?void 0:v.result_summary)??(g==null?void 0:g.result_summary)??(e==null?void 0:e.result_summary)??"",T=(v==null?void 0:v.id)??(e==null?void 0:e.id),I=(g==null?void 0:g.status)==="completed",P=(g==null?void 0:g.status)==="failed",N=y.findIndex(R=>R.status==="failed"),A=y.find(R=>dee(R))??(N>=0?y[N]:void 0),M=(A==null?void 0:A.duration_ms)!=null?ZU(A.duration_ms):void 0;return b.jsx(X1,{className:"wandox-root",title:"执行结果详情",closable:{placement:"end"},open:t&&!!e,onClose:h,size:f,extra:b.jsx("div",{className:"rdd-size-switch",children:p.map(({key:R,label:L})=>b.jsx("button",{type:"button",className:`rdd-size-btn${u===R?" rdd-size-btn--active":""}`,onClick:()=>d(R),children:L},R))}),styles:{header:{paddingBottom:0,border:0},body:{padding:0}},children:o?b.jsx("div",{style:{textAlign:"center",padding:"80px 0"},children:b.jsx(vr,{})}):e&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"rdd-header",children:g&&b.jsx("div",{className:"rdd-header-row2",children:b.jsxs("div",{className:"rdd-meta",children:[b.jsx(ji,{color:I?"success":P?"error":"processing",style:{fontSize:11,margin:0,borderRadius:4},children:I?"成功":P?"失败":g.status}),b.jsx("span",{className:"rdd-meta-sep"}),b.jsxs("span",{className:"rdd-meta-item",children:[b.jsx(fa,{})," ",Bje(g.started_at)]}),g.duration_ms!=null&&b.jsxs("span",{className:"rdd-meta-item",children:["耗时 ",ZU(g.duration_ms)]}),b.jsx(ji,{color:g.trigger_type==="scheduled"?"orange":"blue",style:{fontSize:10,margin:0,borderRadius:4},children:g.trigger_type==="scheduled"?"定时":"手动"})]})})}),b.jsx("div",{className:"rdd-tabs-wrap",children:b.jsx(CO,{size:"small",className:"rdd-tabs",items:[{key:"result",label:"执行结果",children:b.jsxs("div",{className:"rdd-tab-content",children:[b.jsx("div",{className:"rdd-result-output",children:_==="card"&&S&&typeof S=="object"&&!Array.isArray(S)&&S.content?b.jsx(Ci,{payload:S.content}):_?b.jsx(Ci,{payload:$}):S!=null&&S.content?b.jsx(Ci,{payload:S.content}):typeof S=="string"?b.jsx(Ci,{payload:S}):E?b.jsx(NZt,{message:E,stepName:A==null?void 0:A.step_name,duration:M}):k?b.jsx(Ci,{payload:k}):b.jsx(IZt,{type:"secondary",children:"暂无结果内容"})}),b.jsx(cee,{open:l,onClose:()=>c(!1),resultId:T})]})},{key:"steps",label:`执行步骤${y.length?` (${y.length})`:""}`,children:b.jsx("div",{className:"rdd-tab-content",children:y.length>0?y.map((R,L)=>b.jsx(AZt,{step:R,index:L,defaultExpanded:L===N},R.step_id)):b.jsx("div",{className:"rdd-empty",children:"暂无步骤记录"})})},{key:"lineage",label:`推送记录${x.length?` (${x.length})`:""}`,children:b.jsx("div",{className:"rdd-tab-content",children:b.jsx(MZt,{lineage:x})})}]})})]})})}const fee="0 9 * * *",DZt=["周日","周一","周二","周三","周四","周五","周六"];function k1(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function OC(e,t){return e instanceof Error||k1(e)&&typeof e.message=="string"?e.message:t}function pee(e){return k1(e)?e.data??e.result??e.results??e:e}function P1(e){return e?String(e.schedule_id??e.schedule_code??e.task_id??e.id??""):""}function Vje(e){return(e==null?void 0:e.name)||(e==null?void 0:e.schedule_name)||(e==null?void 0:e.title)||"未命名任务"}function OZt(e){return(e==null?void 0:e.schedule_params)??(e==null?void 0:e.playbook_params)??(e==null?void 0:e.params)??(e==null?void 0:e.input_data)??{}}function Hje(e,t){return(e==null?void 0:e.schedule_cron)||(e==null?void 0:e.cron_expression)||t||fee}function Wje(e){return e?typeof e.is_enabled=="boolean"?e.is_enabled:typeof e.enabled=="boolean"?e.enabled:typeof e.is_active=="boolean"?e.is_active:!0:!0}function Uje(e){return!!(e&&e.trim().split(/\s+/).length>=5)}function LZt(e){if(!e||!Uje(e))return"未设置频率";const t=rj(e),n=`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`;switch(t.unit){case"hour":return t.minute>0?`每 ${t.interval} 小时第 ${t.minute} 分执行`:`每 ${t.interval} 小时执行一次`;case"day":return t.interval===1?`每天 ${n} 执行`:`每 ${t.interval} 天 ${n} 执行`;case"week":return`每周 ${t.weekDays.length?t.weekDays.map(i=>DZt[i]||`周${i}`).join("、"):"周一"} ${n} 执行`;case"month":return t.interval===1?`每月第 ${t.monthDay} 天 ${n} 执行`:`每 ${t.interval} 个月第 ${t.monthDay} 天 ${n} 执行`;case"year":return`每年 ${t.yearMonth} 月 ${t.yearDay} 日 ${n} 执行`;case"custom":return"自定义高级规则";default:return"未设置频率"}}function jZt(e){var n;const t=(n=e.schedule_display)==null?void 0:n.trim();return t&&!Uje(t)?t:LZt(Hje(e,t))}function zZt(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function FZt(e){const t=pee(e),n=k1(t)?t.items??t.records??t.rows??t.schedules??t.list??t.data:t;return Array.isArray(n)?n.filter(k1).map(r=>r):[]}function Gje(e){if(!k1(e))return null;const t=e.webhook_id??e.id;if(!t)return null;const n=typeof e.name=="string"&&e.name.trim()?e.name:String(t);return{webhook_id:String(t),name:n,platform:typeof e.platform=="string"?e.platform:void 0,is_active:typeof e.is_active=="boolean"?e.is_active:void 0,is_default:typeof e.is_default=="boolean"?e.is_default:void 0}}function BZt(e){const t=pee(e),n=k1(t)?t.items??t.records??t.rows??t.webhooks??t.list??t.data:t;return Array.isArray(n)?n.map(Gje).filter(r=>!!r):[]}function VZt(e){switch(e){case"dingtalk":return"钉钉";case"feishu":case"lark":return"飞书";case"wecom":case"wechat_work":return"企微";default:return e||""}}function wye(e){const t=VZt(e.platform);return t?`${e.name} (${t})`:e.name}function HZt(e,t){var n;return e!=null&&e.webhook_id?e.webhook_id:((n=t.find(r=>r.is_default&&r.is_active!==!1))==null?void 0:n.webhook_id)||""}function qje(e,t,n){return{mode:"create",activeScheduleId:"",taskName:e!=null&&e.name?`${e.name} 定时任务`:"定时任务",enabled:!0,webhookId:HZt(e,n),cron:(e==null?void 0:e.schedule_cron)||fee,values:x1(t,(e==null?void 0:e.schedule_params)??{})}}function WZt(e,t,n){return{mode:"edit",activeScheduleId:P1(e),taskName:Vje(e),enabled:Wje(e),webhookId:e.webhook_id||"",cron:Hje(e,t==null?void 0:t.schedule_cron),values:x1(n,OZt(e))}}function UZt(e,t){if(!e.taskName.trim())return"请输入任务名称";if(!e.webhookId)return"请选择通知地址";if(e.enabled&&!e.cron.trim())return"请设置调度频率";const n=gT(t,e.values);for(const r of n){const i=e.values[r.name];if(r.required&&i!==0&&i!==!1&&If(i))return`请填写「${r.label||r.name}」`;if(aj(r)&&!If(i)){const a=LOe(i,r.address_validation);if(a)return`${r.label||r.name}:${a}`}}return""}function GZt(e,t){const n=e.cron||fee,r=gT(t,e.values);return{name:e.taskName.trim(),is_enabled:e.enabled,schedule_type:rj(n).unit,schedule_cron:n,schedule_params:t.length>0?BOe(r,e.values):void 0,webhook_id:e.webhookId}}function qZt(){return{draft:qje(null,[],[]),editorRevision:0,quickAddWebhookOpen:!1}}function KZt(e,t){switch(t.type){case"apply_draft":return{...e,draft:t.draft,editorRevision:e.editorRevision+1};case"patch_draft":return{...e,draft:{...e.draft,...t.patch}};case"set_values":{const n=typeof t.next=="function"?t.next(e.draft.values):t.next;return{...e,draft:{...e.draft,values:n}}}case"set_quick_add_open":return{...e,quickAddWebhookOpen:t.open};default:return e}}function YZt(e,t){const[n,r]=m.useReducer(KZt,void 0,qZt),i=m.useRef(""),a=m.useRef((e==null?void 0:e.id)??null);m.useEffect(()=>{a.current!==((e==null?void 0:e.id)??null)&&(a.current=(e==null?void 0:e.id)??null,i.current="")},[e==null?void 0:e.id]),m.useEffect(()=>{i.current=n.draft.activeScheduleId},[n.draft.activeScheduleId]);const o=m.useCallback(S=>{i.current=S.activeScheduleId,r({type:"apply_draft",draft:S})},[]),s=m.useCallback(S=>{o(qje(e,t,S))},[e,o,t]),l=m.useCallback(S=>{o(WZt(S,e,t))},[e,o,t]),c=m.useCallback((S,_,C)=>{const $=C?S.find(T=>P1(T)===C):null,E=i.current?S.find(T=>P1(T)===i.current):null,k=$||E||S[0];k?l(k):s(_)},[l,s]),u=m.useCallback(S=>{i.current===S&&(i.current="")},[]),d=m.useCallback(S=>{r({type:"patch_draft",patch:{taskName:S}})},[]),f=m.useCallback(S=>{r({type:"patch_draft",patch:{enabled:S}})},[]),p=m.useCallback(S=>{r({type:"patch_draft",patch:{webhookId:S}})},[]),h=m.useCallback(S=>{r({type:"patch_draft",patch:{cron:S}})},[]),g=m.useCallback(S=>{r({type:"set_values",next:S})},[]),v=m.useCallback((S,_)=>{r({type:"set_values",next:C=>({...C,[S]:_})})},[]),y=m.useCallback((S,_)=>{r({type:"set_values",next:C=>{const $=Array.isArray(C[S])?C[S]:C[S]?[C[S]]:[];return{...C,[S]:[...$,_]}}})},[]),x=m.useCallback(()=>{r({type:"set_quick_add_open",open:!0})},[]),w=m.useCallback(()=>{r({type:"set_quick_add_open",open:!1})},[]);return{...n,startCreate:s,editSchedule:l,selectScheduleList:c,clearActiveSchedule:u,updateTaskName:d,updateEnabled:f,updateWebhook:p,updateCron:h,updateValues:g,updateField:v,appendFieldValue:y,openQuickAddWebhook:x,closeQuickAddWebhook:w}}const Kje={saving:!1,deletingId:"",saveError:"",uploading:{},fileNameMap:{}};function XZt(e,t){switch(t.type){case"reset":return Kje;case"set_saving":return{...e,saving:t.saving};case"set_deleting":return{...e,deletingId:t.scheduleId};case"set_save_error":return{...e,saveError:t.error};case"set_uploading":return{...e,uploading:{...e.uploading,[t.fieldName]:t.uploading}};case"remember_file_name":return{...e,fileNameMap:{...e.fileNameMap,[t.url]:t.name}};default:return e}}function ZZt({agent:e,open:t,draft:n,draftRevision:r,inputFields:i,refreshSchedules:a,clearActiveSchedule:o,updateField:s,appendFieldValue:l}){const c=wa(),u=Ll({...Bl.schedules.create(),onSuccess:(S,{agentId:_})=>Ys(c,{type:"schedule-saved",agentId:_})}),d=Ll({...Bl.schedules.update(),onSuccess:(S,{agentId:_})=>Ys(c,{type:"schedule-saved",agentId:_})}),f=Ll({...Bl.schedules.delete(),onSuccess:(S,{agentId:_})=>Ys(c,{type:"schedule-deleted",agentId:_})}),[p,h]=m.useReducer(XZt,Kje),g=t?(e==null?void 0:e.id)??null:null,v=m.useRef(r);m.useEffect(()=>{g!==null&&h({type:"reset"})},[g]),m.useEffect(()=>{v.current!==r&&(v.current=r,h({type:"set_save_error",error:""}))},[r]);const y=m.useCallback((S,_)=>async({file:C,onSuccess:$,onError:E})=>{var k,T;h({type:"set_uploading",fieldName:S,uploading:!0});try{const I=C,P=await Sy(I),N=(k=P==null?void 0:P.data)==null?void 0:k.url;if(!N)throw new Error("上传失败");const A=((T=P==null?void 0:P.data)==null?void 0:T.name)||I.name||N.split("/").pop()||"未知文件";h({type:"remember_file_name",url:N,name:A}),_<=1?s(S,N):l(S,N),$==null||$(P),Ze.success("文件上传成功")}catch(I){E==null||E(I instanceof Error?I:new Error("文件上传失败")),Ze.error(OC(I,"文件上传失败"))}finally{h({type:"set_uploading",fieldName:S,uploading:!1})}},[l,s]),x=m.useCallback(async()=>{if(!e)return;const S=UZt(n,i);if(S){Ze.warning(S);return}h({type:"set_save_error",error:""}),h({type:"set_saving",saving:!0});try{const _=GZt(n,i);if(n.mode==="edit"&&n.activeScheduleId)await d.mutateAsync({agentId:e.id,scheduleId:n.activeScheduleId,data:_}),Ze.success("定时任务已更新"),a(n.activeScheduleId);else{const C=await u.mutateAsync({agentId:e.id,data:_}),$=pee(C),E=$&&typeof $=="object"&&!Array.isArray($)?P1($):"";Ze.success("定时任务已创建"),a(E||void 0)}}catch(_){h({type:"set_save_error",error:OC(_,"保存失败")})}finally{h({type:"set_saving",saving:!1})}},[e,u,n,i,a,d]),w=m.useCallback(async S=>{const _=P1(S);if(_){h({type:"set_deleting",scheduleId:_});try{if(!e)return;await f.mutateAsync({agentId:e.id,scheduleId:_}),Ze.success("定时任务已删除"),o(_),a()}catch(C){Ze.error(OC(C,"删除失败"))}finally{h({type:"set_deleting",scheduleId:""})}}},[e,o,f,a]);return{...p,handleFileUpload:y,save:x,deleteSchedule:w}}const QZt={includeDisabled:!0},JZt={},eQt={getSchedules:bgt,getWebhooks:ZO};function tQt(e){return{includeDisabled:e.includeDisabled}}function nQt(e){return{platform:e.platform,domain:e.domain}}function rQt(e=eQt){return{schedules:{list:(t,n)=>{const r=t,i=tQt(n);return{queryKey:Yn.schedules.list(r,i),queryFn:async()=>{const a=await e.getSchedules(r,{include_disabled:i.includeDisabled});return FZt(a)}}}},webhooks:{list:(t={})=>{const n=nQt(t);return{queryKey:Yn.webhooks.list(n),queryFn:async()=>{const r=await e.getWebhooks({platform:n.platform,domain:n.domain});return BZt(r)}}}}}}function iQt(e,t){return[t,...(e??[]).filter(n=>n.webhook_id!==t.webhook_id)]}const Sye=rQt(),aQt=0,oQt=[],sQt=[];function lQt(e,t){const n=wa(),[r,i]=m.useState(0),a=m.useRef(null),o=t&&e!==null,s=m.useMemo(()=>Sye.schedules.list(e??aQt,QZt),[e]),l=m.useMemo(()=>Sye.webhooks.list(JZt),[]),c=mf({...s,enabled:o}),u=mf({...l,enabled:o});m.useEffect(()=>{if(!o||e===null){a.current=null;return}if(c.isFetching||u.isFetching)return;const p=String(e);a.current!==p&&(a.current=p,i(h=>h+1))},[e,o,c.isFetching,u.isFetching]);const d=m.useCallback(()=>n.getQueryData(s.queryKey)??[],[n,s.queryKey]),f=m.useCallback(p=>{n.setQueryData(l.queryKey,h=>iQt(h,p))},[n,l.queryKey]);return{schedules:c.data??oQt,webhooks:u.data??sQt,listLoading:o&&c.isFetching,webhookLoading:o&&u.isFetching,scheduleError:c.error?OC(c.error,"获取定时任务失败"):"",webhookError:u.error?OC(u.error,"获取通知地址失败"):"",initialLoadRevision:r,getCachedSchedules:d,prependWebhook:f}}function cQt(e,t){const n=m.useMemo(()=>YQ(e==null?void 0:e.input_params),[e==null?void 0:e.input_params]),r=lQt((e==null?void 0:e.id)??null,t),i=YZt(e,n),a=m.useRef(0);m.useEffect(()=>{r.webhookError&&Ze.error(r.webhookError)},[r.webhookError]),m.useEffect(()=>{r.scheduleError&&Ze.error(r.scheduleError)},[r.scheduleError]),m.useEffect(()=>{r.initialLoadRevision===0||a.current===r.initialLoadRevision||(a.current=r.initialLoadRevision,i.selectScheduleList(r.schedules,r.webhooks))},[i.selectScheduleList,r.initialLoadRevision,r.schedules,r.webhooks]);const o=m.useCallback(()=>{i.startCreate(r.webhooks)},[i.startCreate,r.webhooks]),s=m.useCallback(h=>{i.selectScheduleList(r.getCachedSchedules(),r.webhooks,h)},[i.selectScheduleList,r.getCachedSchedules,r.webhooks]),l=sj(n,i.draft.values,i.updateValues),c=m.useMemo(()=>gT(n,i.draft.values),[n,i.draft.values]),u=ZZt({agent:e,open:t,draft:i.draft,draftRevision:i.editorRevision,inputFields:n,refreshSchedules:s,clearActiveSchedule:i.clearActiveSchedule,updateField:i.updateField,appendFieldValue:i.appendFieldValue}),d=m.useCallback(h=>{const g=Gje(h);g&&(r.prependWebhook(g),i.updateWebhook(g.webhook_id))},[i.updateWebhook,r.prependWebhook]),f=m.useMemo(()=>new Map(r.webhooks.map(h=>[h.webhook_id,wye(h)])),[r.webhooks]),p=m.useMemo(()=>{const h=new Set,g=r.webhooks.map(v=>(h.add(v.webhook_id),{value:v.webhook_id,label:`${wye(v)}${v.is_default?" · 默认":""}`,disabled:v.is_active===!1}));return i.draft.webhookId&&!h.has(i.draft.webhookId)&&g.unshift({value:i.draft.webhookId,label:`当前通知地址 (${i.draft.webhookId})`,disabled:!1}),g},[i.draft.webhookId,r.webhooks]);return{schedules:r.schedules,webhooks:r.webhooks,listLoading:r.listLoading,webhookLoading:r.webhookLoading,draft:i.draft,editorRevision:i.editorRevision,quickAddWebhookOpen:i.quickAddWebhookOpen,saving:u.saving,deletingId:u.deletingId,saveError:u.saveError,uploading:u.uploading,fileNameMap:u.fileNameMap,inputFields:n,visibleInputFields:c,dynamicOptions:l,webhookNameById:f,webhookOptions:p,startCreate:o,editSchedule:i.editSchedule,updateTaskName:i.updateTaskName,updateEnabled:i.updateEnabled,updateWebhook:i.updateWebhook,updateCron:i.updateCron,updateField:i.updateField,handleFileUpload:u.handleFileUpload,save:u.save,deleteSchedule:u.deleteSchedule,openQuickAddWebhook:i.openQuickAddWebhook,closeQuickAddWebhook:i.closeQuickAddWebhook,addCreatedWebhook:d}}const{Text:_ye}=ec;function uQt({agent:e,open:t,onClose:n}){const r=cQt(e,t),{schedules:i,webhooks:a,draft:o,editorRevision:s,listLoading:l,webhookLoading:c,quickAddWebhookOpen:u,saving:d,deletingId:f,saveError:p,uploading:h,fileNameMap:g,inputFields:v,visibleInputFields:y,dynamicOptions:x,webhookNameById:w,webhookOptions:S,startCreate:_,editSchedule:C,updateTaskName:$,updateEnabled:E,updateWebhook:k,updateCron:T,updateField:I,handleFileUpload:P,save:N,deleteSchedule:A,openQuickAddWebhook:M,closeQuickAddWebhook:R,addCreatedWebhook:L}=r,z=j=>{const O=jZt(j),V=zZt(j.next_run_at),B=j.webhook_id?j.webhook_name||w.get(j.webhook_id)||j.webhook_id:"";return b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"sm-task-item-frequency",children:O}),(V||B)&&b.jsxs("span",{className:"sm-task-item-extra",children:[V&&b.jsxs("span",{children:["下次执行 ",V]}),B&&b.jsxs("span",{children:["通知 ",B]})]})]})};return b.jsxs(rr,{title:null,open:t,onCancel:n,width:920,centered:!0,footer:b.jsxs("div",{className:"sm-footer",children:[b.jsx(Et,{onClick:n,children:"关闭"}),b.jsx(Et,{type:"primary",loading:d,onClick:N,children:o.mode==="edit"?"保存修改":"创建任务"})]}),className:"schedule-modal",closable:!1,styles:{container:{padding:0}},children:[b.jsxs("div",{className:"sm-header",children:[b.jsx(fa,{className:"sm-header-icon"}),b.jsxs("div",{children:[b.jsx("div",{className:"sm-header-title",children:"定时触发配置"}),b.jsx("div",{className:"sm-header-sub",children:(e==null?void 0:e.name)||"当前智能体"})]}),b.jsx(Et,{type:"primary",icon:b.jsx(Uo,{}),onClick:()=>_(),children:"创建任务"})]}),b.jsxs("div",{className:"sm-layout",children:[b.jsxs("aside",{className:"sm-task-panel",children:[b.jsx("div",{className:"sm-task-panel-head",children:b.jsxs("div",{children:[b.jsx("div",{className:"sm-task-panel-title",children:"已创建任务"}),b.jsxs("div",{className:"sm-task-panel-count",children:[i.length," 个定时任务"]})]})}),b.jsx(vr,{spinning:l,children:i.length===0?b.jsx("div",{className:"sm-task-empty",children:b.jsx(ei,{image:ei.PRESENTED_IMAGE_SIMPLE,description:"暂无定时任务"})}):b.jsx("div",{className:"sm-task-list",children:i.map(j=>{const O=P1(j),V=o.mode==="edit"&&o.activeScheduleId===O,B=Wje(j);return b.jsxs("div",{className:`sm-task-item${V?" sm-task-item--active":""}`,children:[b.jsx("button",{type:"button",className:"sm-task-select",onClick:()=>C(j),children:b.jsxs("div",{className:"sm-task-item-main",children:[b.jsxs("div",{className:"sm-task-item-title",children:[b.jsx("span",{children:Vje(j)}),b.jsx(ji,{color:B?"green":"default",children:B?"启用":"停用"})]}),b.jsx("div",{className:"sm-task-item-meta",children:z(j)})]})}),b.jsx("div",{className:"sm-task-actions",children:b.jsx(kO,{title:"删除定时任务",description:"删除后不可恢复,确认删除?",okText:"删除",cancelText:"取消",okButtonProps:{danger:!0,loading:f===O},onConfirm:D=>{D==null||D.stopPropagation(),A(j)},onCancel:D=>D==null?void 0:D.stopPropagation(),children:b.jsx(Et,{type:"text",size:"small",danger:!0,icon:b.jsx(hf,{}),onClick:D=>D.stopPropagation()})})})]},O||j.name)})})})]}),b.jsxs("section",{className:"sm-editor",children:[b.jsxs("div",{className:"sm-editor-head",children:[b.jsxs("div",{children:[b.jsx("div",{className:"sm-editor-title",children:o.mode==="edit"?"编辑任务定时器":"创建任务定时器"}),b.jsx("div",{className:"sm-editor-sub",children:"频率和执行参数沿用当前智能体的配置表单"})]}),b.jsxs("div",{className:"sm-header-switch",children:[b.jsx(_ye,{type:"secondary",style:{fontSize:12},children:o.enabled?"已启用":"已停用"}),b.jsx(yo,{size:"small",checked:o.enabled,onChange:E})]})]}),b.jsxs("div",{className:"sm-body",children:[b.jsxs("div",{className:"sm-section",children:[b.jsxs("div",{className:"sm-label",children:["任务名称",b.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),b.jsx(Kt,{value:o.taskName,onChange:j=>$(j.target.value),placeholder:"例如:每日店铺表现分析"})]}),b.jsxs("div",{className:"sm-section",children:[b.jsxs("div",{className:"sm-field-head",children:[b.jsxs("div",{children:[b.jsxs("div",{className:"sm-label",children:["通知地址",b.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),b.jsx("div",{className:"sm-param-hint",children:"任务触发后的消息通知地址"})]}),b.jsx(Et,{size:"small",onClick:M,children:"添加通知地址"})]}),b.jsx(tn,{allowClear:!0,showSearch:!0,loading:c,disabled:c,value:o.webhookId||void 0,onChange:j=>k(j||""),placeholder:"请选择通知 Webhook",optionFilterProp:"label",options:S}),!c&&a.length===0&&b.jsx("div",{className:"sm-inline-alert",children:"暂无可用通知地址,请添加一个通知地址。"})]}),o.enabled?b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"sm-section",children:[b.jsx("div",{className:"sm-label",children:"调度频率"}),b.jsx("div",{className:"sm-param-hint",children:"设置智能体自动执行的时间间隔和触发时间"}),b.jsx(HQ,{defaultValue:o.cron,onChange:T},s)]}),v.length>0&&b.jsxs("div",{className:"sm-section",children:[b.jsx("div",{className:"sm-label",children:"执行参数"}),b.jsx("div",{className:"sm-param-hint",children:"定时执行时使用的参数,与手动执行时填写的参数一致"}),b.jsx("div",{className:"sm-form-panel",children:b.jsx("div",{className:"sm-dynamic-fields",children:y.map(j=>b.jsxs("div",{className:"sm-field-item",children:[b.jsxs("div",{className:"sm-field-label",children:[b.jsx("span",{children:j.label||j.name}),j.required&&b.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"}),j.description&&b.jsx(or,{title:j.description,children:b.jsx(ME,{className:"sm-field-label__hint","aria-label":`${j.label||j.name}说明`})})]}),b.jsx(KQ,{field:j,value:o.values[j.name],size:"middle",imageUploadMode:"dragger",uploading:!!h[j.name],fileNameMap:g,getOptionState:x.getFieldState,onChange:I,onUpload:P})]},j.name))})})]})]}):b.jsxs("div",{className:"sm-disabled-hint",children:[b.jsx(fa,{style:{fontSize:28,color:"#d1d5db"}}),b.jsx(_ye,{type:"secondary",style:{fontSize:13},children:"任务已停用,保存后不会自动触发"})]}),p&&b.jsx("div",{className:"sm-save-error",children:p})]})]})]}),b.jsx(HOe,{open:u,onClose:R,onSuccess:L})]})}function dQt({agentsCount:e,error:t,onOpenMarket:n}){return b.jsx("section",{className:"automation-empty-state",children:b.jsxs("div",{children:[b.jsx("span",{className:`automation-badge automation-badge--${t?"red":"blue"}`,children:t?"加载失败":"空状态"}),b.jsx("h2",{children:t?"智能体列表读取失败":e>0?"请选择一个智能体":"还没有启用智能体"}),b.jsx("p",{children:t||(e>0?"从智能体中心选择一个智能体后,再进入驾驶舱运行。":"先到智能体中心启用一个模板,系统会创建用户专属智能体,再进入驾驶舱。")}),b.jsx("button",{type:"button",className:"automation-action-button automation-action-button--primary",onClick:n,children:"去智能体中心"})]})})}const fQt="正在加载内容,请稍候";function CT({className:e}){return b.jsx("output",{className:["automation-loading-state",e].filter(Boolean).join(" "),"aria-live":"polite",children:b.jsxs("div",{className:"automation-loading-state__content",children:[b.jsx(vr,{}),b.jsx("span",{children:fQt})]})})}function pQt({embedded:e,agentName:t,cockpitTransitionLoading:n,historyPanel:r,workbenchPanel:i,onReturnToAgentSelection:a}){return b.jsxs(b.Fragment,{children:[!e&&b.jsx("header",{className:"wandox-automation-page-header",children:b.jsxs("div",{className:"automation-workbench-head",children:[b.jsxs("div",{children:[b.jsx("h2",{children:t}),b.jsx("p",{className:"automation-workbench-head__meta",children:"切换阶段查看本次执行的参数、过程和结果"})]}),b.jsx(Et,{className:"wandox-automation-page-header__back",icon:b.jsx(q$,{}),onClick:a,children:"返回智能体选择"})]})}),b.jsxs("section",{className:`automation-workspace${n?" is-loading":""}`,children:[n&&b.jsx(CT,{className:"automation-workspace-loading"}),r,i]})]})}function lt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function QU(e,t=""){return typeof e=="string"?e:e==null?t:String(e)}function Od(e){return typeof e=="string"?e:void 0}function hQt(e){return Array.isArray(e)?e.map(t=>typeof t=="string"||typeof t=="number"?String(t):lt(t)?QU(t.name??t.field??t.key):"").filter(Boolean):[]}function Ud(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 _j(e){if(!(e==null||e===""))return String(e)}function Yje(e){if(e==null)return!1;const t=String(e).trim();return t?/^\d+$/.test(t)||/^[0-9a-f]{24,}$/i.test(t)||/^[0-9a-f]{8}-[0-9a-f-]{13,}$/i.test(t)||/^(step|playbook|workflow|copy_workflow|agent_exec|execution|custom_agent|result)[_-]/i.test(t):!1}function mQt(e){if(e==null)return"";const t=String(e).trim();return!t||Yje(t)?"":t}function Rc(...e){for(const t of e){const n=mQt(t);if(n)return n}return""}function Ai(e,t){return e instanceof Error||lt(e)&&typeof e.message=="string"?e.message:t}function rl(e){return lt(e)?e.data??e.results??e:e}function B0(e){const t=rl(e),n=lt(t)?t.items??t.records??t.rows??t.schedules??t.list??t.data:t;return Array.isArray(n)?n:[]}function gQt(e,t){const n=rl(e),r=[lt(e)&<(e.meta)?e.meta.total:void 0,lt(n)&<(n.meta)?n.meta.total:void 0,lt(n)?n.total:void 0];for(const i of r){const a=Number(i);if(Number.isFinite(a)&&a>=0)return a}return t}function Mw(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=new Date,r=t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate();return t.toLocaleString("zh-CN",r?{hour:"2-digit",minute:"2-digit"}:{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Xje(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t}function Al(e){return String(e).padStart(2,"0")}function Cye(e,t=0,n=0){const r=new Date(e);return r.setHours(t,n,0,0),r}function vQt(e){const t=e==null?void 0:e.trim();if(!t||t==="未知时间")return null;const n=new Date,r=t.match(/(\d{1,2}):(\d{2})/);if(t==="刚刚")return n;if(t.startsWith("昨天")){const a=new Date(n);return a.setDate(a.getDate()-1),Cye(a,Number((r==null?void 0:r[1])??0),Number((r==null?void 0:r[2])??0))}if(/^\d{1,2}:\d{2}$/.test(t))return Cye(n,Number((r==null?void 0:r[1])??0),Number((r==null?void 0:r[2])??0));const i=t.match(/^(\d{1,2})[/-](\d{1,2})(?:\s+(\d{1,2}):(\d{2}))?/);return i?new Date(n.getFullYear(),Number(i[1])-1,Number(i[2]),Number(i[3]??0),Number(i[4]??0)):null}function Zje(e){return Xje(e.occurredAt)??vQt(e.time)}function $ye(e){var t;return((t=Zje(e))==null?void 0:t.getTime())??0}function yQt(e){return`${e.getFullYear()}-${Al(e.getMonth()+1)}-${Al(e.getDate())}`}function hee(e){return e.map((t,n)=>({run:t,index:n})).sort((t,n)=>$ye(n.run)-$ye(t.run)||t.index-n.index).map(t=>t.run)}function zy(e){return e==null||e===""?"-":typeof e=="string"?e.length>80?`${e.slice(0,80)}...`:e:typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?`${e.length} 条`:lt(e)?JSON.stringify(e).slice(0,80):String(e)}function Hc(e,...t){for(const n of t){const r=zy(n);if(r!=="-")return r}return e}function Eye(e){return e==null||e===""?"-":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e,null,2)}function ni(e){return e==null||e===""?!1:Array.isArray(e)?e.length>0:lt(e)?Object.keys(e).length>0:!0}function $T(e){const t=String(e??"").toLowerCase();return t==="failed"||t==="cancelled"||t==="timeout"?"failed":t==="waiting"||t==="waiting_input"||t==="pending_input"?"waiting":t==="running"||t==="pending"||t==="pending_async"||t==="awaiting_async"?"running":"completed"}function X2(e){const t=String(e??"pending").toLowerCase();return t==="failed"||t==="cancelled"||t==="timeout"?"failed":t==="waiting"||t==="waiting_input"||t==="pending_input"?"waiting":t==="running"||t==="pending_async"||t==="awaiting_async"?"running":t==="completed"||t==="complete"||t==="success"||t==="succeeded"?"completed":"pending"}function Qje(e){const t=zy(e);return t==="等待人工确认"||t==="等待确认"||t==="待人工处理"}function Jje(e){const t=zy(e);return/^已完成\s*\d+\s*个步骤/.test(t)||t.includes("耗时")}function ty(e){return e.status==="running"?"正在执行":e.status==="awaiting_async"||e.status==="pending_async"?"等待异步结果":e.status==="waiting_input"?"等待人工确认":e.status==="failed"?Hc("执行失败",e.error_message,e.result_summary):e.status==="cancelled"?"执行已取消":e.status==="timeout"?"执行超时":Qje(e.result_summary)||Jje(e.result_summary)?"执行完成":Hc("执行完成",e.result_summary)}function Cj(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const n=t.toLowerCase();return["waiting","waiting_input","pending_input"].includes(n)?"waiting":["failed","failure","error","cancelled","timeout"].includes(n)?"failed":["completed","complete","success","succeeded"].includes(n)?"completed":["running","pending","pending_async","awaiting_async"].includes(n)?"running":t.endsWith("待确认")?"waiting":t.endsWith("失败")?"failed":t.endsWith("成功")?"completed":t.endsWith("执行中")||t.endsWith("待执行")?"running":null}function Rw(e){return e?e.status==="failed"||Cj(e.businessStatus)==="failed":!1}function bQt(e){return!!(e!=null&&e.resultId&&e.status==="completed"&&!Rw(e))}function xQt(e){const t=Zje(e);if(t)return`${Al(t.getMonth()+1)}/${Al(t.getDate())} ${Al(t.getHours())}:${Al(t.getMinutes())}`;const n=e.time.match(/(\d{1,2}):(\d{2})/);return n?`--/-- ${Al(Number(n[1]))}:${n[2]}`:e.time}function JU(e){if(e.status==="waiting"||e.status==="failed")return"attention";const t=Cj(e.businessStatus);return t==="waiting"||t==="failed"?"attention":e.status==="running"||t==="running"?"running":"completed"}function mee(e){const t=JU(e),n=Cj(e.businessStatus);return e.status==="failed"||n==="failed"?"failed":e.status==="waiting"?"waiting":t==="attention"?n==="waiting"?"waiting":"failed":t==="running"?"running":n??"completed"}function wQt(e){var i;const t=mee(e);if((i=e.businessStatus)!=null&&i.trim()&&Cj(e.businessStatus)===t)return e.businessStatus.trim();if(t==="waiting")return"待确认";if(t==="failed")return"失败";if(t==="completed")return"已完成";const n=e.steps.find(a=>a.status==="running"),r=(n==null?void 0:n.title)??"";return/(?:AI|生成|仿写|分析)/i.test(r)?"AI 生成中":/(?:提交|刊登)/.test(r)?"刊登中":/(?:查询|异步)/.test(r)?"查询中":"进行中"}function SQt(e,t){return["automation-history-task-card",`automation-history-task-card--${mee(e)}`,t?"automation-history-task-card--active":""].filter(Boolean).join(" ")}function _Qt(e,t){const n=e.title.trim(),r=n===String(e.id)||/^(?:agent[_-])?exec(?:ution)?[_-]/i.test(n);return n&&!r?n:t}function CQt(e){var r,i;const t=((r=e.listErrorMessage)==null?void 0:r.trim())||((i=e.listResultSummary)==null?void 0:i.trim());if(t)return t;const n=e.steps.find(a=>["waiting","running","failed"].includes(a.status));return(n==null?void 0:n.description)||e.resultTitle||(n==null?void 0:n.title)||e.summary||"执行任务"}function $Qt(e){return[e.triggerType==="scheduled"||e.trigger==="定时运行"?"定时执行":"手动执行",xQt(e)].filter(Boolean).join(" · ")}function EQt({children:e,tone:t="gray"}){return b.jsx("span",{className:`automation-badge automation-badge--${t}`,children:e})}function TQt({model:e,actions:t,footer:n}){const{agentName:r,hasSchedule:i,mode:a,error:o,loading:s,filteredRunCount:l,runCount:c,statusFilter:u,groups:d,recordTotal:f,pagination:{page:p,pageCount:h},deletingExecutionId:g,activeRunId:v}=e,{createRun:y,configureSchedule:x,changeStatusFilter:w,reload:S,openRun:_,openWaitingRun:C,removeRun:$,changePage:E}=t,k=T=>{const I=a!=="run"&&v===T.id,P=SQt(T,I),N=mee(T),A=T.recordId!=null&&g===T.recordId;return b.jsxs("div",{className:"automation-history-task-card-shell",children:[b.jsxs("button",{type:"button",className:P,title:T.summary,onClick:()=>T.status==="waiting"?C(T):_(T.id),children:[b.jsxs("div",{className:"automation-history-task-card__head",children:[b.jsx("strong",{children:_Qt(T,r)}),b.jsxs("span",{className:`automation-history-task-card__state automation-history-task-card__state--${N}`,children:[b.jsx("i",{}),wQt(T)]})]}),b.jsx("span",{className:"automation-history-task-card__subtitle",children:CQt(T)}),b.jsx("small",{children:$Qt(T)})]}),b.jsx(or,{title:A?"正在删除":"删除执行记录",placement:"top",children:b.jsx("button",{type:"button",className:"automation-history-task-card__delete","aria-label":`删除执行记录:${T.title}`,disabled:g!=null||T.recordId==null,onClick:()=>$(T),children:A?b.jsx(vr,{size:"small"}):b.jsx(hf,{"aria-hidden":"true"})})})]},T.id)};return b.jsxs("section",{className:"automation-panel automation-history-panel",children:[!o&&b.jsxs("div",{className:"wandox-automation-cockpit-actions",children:[b.jsxs("button",{type:"button",className:`wandox-automation-cockpit-action wandox-automation-cockpit-action--run${a==="run"?" wandox-automation-cockpit-action--selected":""}`,onClick:y,children:[b.jsx(Uo,{"aria-hidden":"true"}),b.jsx("strong",{children:"新建任务"})]}),b.jsx(or,{title:i?"已配置定时触发":"配置定时触发",placement:"right",children:b.jsxs("button",{type:"button",className:`wandox-automation-cockpit-action wandox-automation-cockpit-action--schedule-${i?"active":"idle"}`,onClick:x,"aria-label":i?"已配置定时触发":"配置定时触发",children:[b.jsx(fa,{"aria-hidden":"true"}),b.jsx("strong",{children:"定时触发"})]})})]}),!o&&b.jsx("div",{className:"automation-history-status-filters",role:"tablist","aria-label":"任务状态筛选",children:[["all","全部"],["attention","待处理"],["running","进行中"],["completed","已完成"]].map(([T,I])=>b.jsx("button",{type:"button",role:"tab","aria-selected":u===T,className:u===T?"is-active":"",onClick:()=>w(T),children:I},T))}),b.jsxs("div",{className:`automation-history-list${!o&&!s&&l===0?" is-empty":""}`,children:[o&&b.jsxs("button",{type:"button",className:"automation-memory-card automation-memory-card--failed",onClick:S,children:[b.jsxs("span",{className:"automation-memory-card__contacts","aria-hidden":"true",children:[b.jsx("i",{}),b.jsx("i",{}),b.jsx("i",{})]}),b.jsxs("div",{className:"automation-memory-card__head",children:[b.jsx("span",{className:"automation-memory-card__status",children:"失败"}),b.jsx(EQt,{tone:"red",children:"重试"})]}),b.jsx("strong",{children:"执行历史读取失败"}),b.jsx("small",{children:o}),b.jsx("span",{className:"automation-memory-card__action",children:"重新读取"})]}),!o&&!s&&l===0&&b.jsxs("div",{className:"automation-history-empty",children:[b.jsx("span",{className:"automation-history-empty-icon",children:b.jsx(fa,{})}),b.jsxs("div",{children:[b.jsx("strong",{children:c>0?"当前筛选暂无任务":"暂无执行历史"}),b.jsx("small",{children:c>0?"切换状态筛选查看其他任务。":"首次运行后,记录会显示在这里。"})]})]}),!o&&d.map(T=>b.jsxs("section",{className:`automation-history-task-group automation-history-task-group--${T.key}`,children:[b.jsxs("div",{className:"automation-history-task-group__head",children:[b.jsx("span",{children:T.label}),b.jsx("em",{children:" · "}),b.jsx("em",{children:T.runs.length})]}),b.jsx("div",{className:"automation-history-task-group__stack",children:T.runs.map(k)})]},T.key))]}),!o&&!s&&f>0&&b.jsxs("nav",{className:"automation-history-pagination","aria-label":"执行任务分页",children:[b.jsx("button",{type:"button","aria-label":"上一页",disabled:p<=1,onClick:()=>E(Math.max(1,p-1)),children:"‹"}),b.jsxs("span",{className:"automation-history-pagination__summary",children:[p," / ",h]}),b.jsx("button",{type:"button","aria-label":"下一页",disabled:p>=h,onClick:()=>E(Math.min(h,p+1)),children:"›"})]}),n]})}const e4e="wandox-automation-live-execution-traces-v1",gee=12;function IQt(){if(typeof window>"u")return[];try{const e=JSON.parse(window.sessionStorage.getItem(e4e)||"[]");return Array.isArray(e)?e.filter(t=>lt(t)&&typeof t.executionId=="string"&&typeof t.agentId=="number"&&typeof t.agentName=="string"&&typeof t.updatedAt=="string"&&Array.isArray(t.steps)).slice(0,gee):[]}catch{return[]}}function kQt(e){if(!(typeof window>"u"))try{window.sessionStorage.setItem(e4e,JSON.stringify(e.slice(0,gee)))}catch{}}function PQt(e){return e.replace(/\s*·\s*(待执行|执行中|等待确认|已完成|执行失败)$/,"").trim()}function NQt(e){return e==="running"?"RUN":e==="waiting"?"HOLD":e==="completed"?"DONE":e==="failed"?"ERR":"QUEUE"}function AQt(e){return e==="running"?"LIVE":e==="waiting"?"PAUSED":e==="completed"?"SYNCED":e==="failed"?"HALTED":"STANDBY"}function MQt(e){if(!e)return"--:--:--";const t=new Date(e);return Number.isNaN(t.getTime())?"--:--:--":`${Al(t.getHours())}:${Al(t.getMinutes())}:${Al(t.getSeconds())}`}function RQt(e,t,n,r){const i=new Map(t.map(a=>[a.id,a]));return e.map(a=>{const o=i.get(a.id);if(a.status==="pending")return{...a,occurredAt:o==null?void 0:o.occurredAt};const s=!o||o.status!==a.status||o.title!==a.title||o.detail!==a.detail;return{...a,occurredAt:s?n:o.occurredAt??r??n}})}function DQt(e,t){const n=e.find(i=>i.executionId===t.executionId);return[{...t,steps:RQt(t.steps,(n==null?void 0:n.steps)??[],t.updatedAt,n==null?void 0:n.updatedAt)},...e.filter(i=>i.executionId!==t.executionId)].slice(0,gee)}function OQt(e){return e==="running"?"执行中":e==="waiting"?"等待确认":e==="completed"?"已完成":e==="failed"?"执行失败":"待执行"}function LQt({trace:e,steps:t,stepsRef:n}){const r=(e==null?void 0:e.status)??"empty";return b.jsxs("section",{className:`wandox-automation-live-trace wandox-automation-live-trace--${r}`,"aria-label":"实时执行动态",children:[b.jsxs("div",{className:"wandox-automation-live-trace__terminal-bar","aria-hidden":"true",children:[b.jsxs("span",{className:"wandox-automation-live-trace__terminal-lights",children:[b.jsx("i",{}),b.jsx("i",{}),b.jsx("i",{})]}),b.jsx("strong",{children:"实时执行动态"}),b.jsx("em",{className:`wandox-automation-live-trace__stream-status wandox-automation-live-trace__stream-status--${r}`,children:AQt(r)})]}),t.length>0?b.jsx("div",{ref:n,className:"wandox-automation-live-trace__steps",role:"log","aria-live":"polite",children:t.map(i=>{const a=PQt(i.detail);return b.jsxs("div",{className:`wandox-automation-live-trace__step wandox-automation-live-trace__step--${i.status} wandox-automation-live-trace__step--${i.kind??"step"}`,children:[b.jsx("time",{dateTime:i.occurredAt,children:MQt(i.status==="pending"?void 0:i.occurredAt??(e==null?void 0:e.updatedAt))}),b.jsxs("div",{className:"wandox-automation-live-trace__copy",children:[b.jsxs("strong",{title:i.title,children:[b.jsx("b",{children:"$"})," ",i.title]}),b.jsxs("span",{className:"wandox-automation-live-trace__state","aria-label":OQt(i.status),children:["[",NQt(i.status),"]"]}),a&&b.jsxs("small",{children:[b.jsx("b",{children:"›"}),a]})]})]},i.id)})}):b.jsxs("div",{className:"wandox-automation-live-trace__empty",children:[b.jsx("time",{children:"--:--:--"}),b.jsxs("div",{children:[b.jsxs("strong",{children:[b.jsx("b",{children:"$"})," waiting_for_substep_events"]}),b.jsx("small",{children:"监听后台执行流..."})]}),b.jsx("span",{"aria-hidden":"true",children:"[IDLE]"})]})]})}function jQt({embedded:e,agentName:t,cockpitTransitionLoading:n,history:r,activeLiveExecutionTrace:i,activeLiveExecutionSubsteps:a,liveTraceStepsRef:o,workbenchMode:s,activeRunFailed:l,activeWorkbenchStageKey:c,waitingActiveStageKey:u,selectedWorkbenchStepHasConfirmPreview:d,renderWorkbenchFlow:f,renderFailedTaskRerunAction:p,onReturnToAgentSelection:h}){return b.jsx(pQt,{embedded:e,agentName:t,cockpitTransitionLoading:n,onReturnToAgentSelection:h,historyPanel:b.jsx(TQt,{...r,footer:b.jsx(LQt,{trace:i,steps:a,stepsRef:o})}),workbenchPanel:b.jsx("section",{className:`automation-workbench automation-workbench--flow automation-workbench--${s}${s==="detail"&&l?" is-failed":""}`,children:b.jsx("div",{className:`automation-workbench-body automation-workbench-body--flow${s==="waiting"&&c.startsWith("step:")&&c===u?" is-waiting-step":""}${c.startsWith("step:")?" is-step-stage":""}${d?" is-confirm-preview-stage":""}${c==="params"?" is-params-stage":""}${c==="complete"?" is-complete-stage":""}`,children:s==="run"?f():b.jsxs("div",{className:"wandox-automation-flow-layout",children:[f(),p()]})})})})}function zQt({model:e,actions:t,slots:n}){return b.jsx(jQt,{embedded:e.embedded,agentName:e.agentName,cockpitTransitionLoading:e.transitionLoading,onReturnToAgentSelection:t.back,history:{model:e.history,actions:t.history},activeLiveExecutionTrace:e.liveTrace.active,activeLiveExecutionSubsteps:e.liveTrace.substeps,liveTraceStepsRef:e.liveTrace.stepsRef,workbenchMode:e.workbench.mode,activeRunFailed:e.workbench.activeRunFailed,activeWorkbenchStageKey:e.workbench.activeStageKey,waitingActiveStageKey:e.workbench.waitingActiveStageKey,selectedWorkbenchStepHasConfirmPreview:e.workbench.selectedStepHasConfirmPreview,renderWorkbenchFlow:n.renderWorkbenchFlow,renderFailedTaskRerunAction:n.renderFailedTaskRerunAction})}function FQt({open:e,agents:t,loading:n=!1,sender:r,summary:i,onClose:a,onConfirm:o,onCreateAgent:s}){const[l,c]=m.useState(null),[u,d]=m.useState("");m.useEffect(()=>{e&&(c(null),d(""))},[e]);const f=m.useMemo(()=>{const h=u.trim().toLowerCase();return h?t.filter(g=>{var v;return g.name.toLowerCase().includes(h)||((v=g.description)==null?void 0:v.toLowerCase().includes(h))}):t},[t,u]),p=m.useMemo(()=>t.find(h=>h.id===l)??null,[t,l]);return b.jsxs(rr,{className:"wandox-inbox-process",open:e,title:null,footer:null,width:680,centered:!0,destroyOnHidden:!0,onCancel:a,children:[b.jsxs("div",{className:"wandox-inbox-process__header",children:[b.jsx("span",{className:"wandox-inbox-process__eyebrow",children:"收件箱流转"}),b.jsx("h2",{className:"wandox-inbox-process__title",children:"选择承接智能体"}),b.jsx("p",{className:"wandox-inbox-process__description",children:"选择后进入驾驶舱,继续配置本次任务并查看完整执行过程。"})]}),b.jsxs("div",{className:"wandox-inbox-process__steps","aria-label":"流转处理步骤",children:[b.jsxs("div",{className:"wandox-inbox-process__step wandox-inbox-process__step--active",children:[b.jsx("span",{className:"wandox-inbox-process__step-number",children:"1"}),b.jsx("span",{className:"wandox-inbox-process__step-copy",children:"选择智能体"})]}),b.jsx("span",{className:"wandox-inbox-process__step-line","aria-hidden":"true"}),b.jsxs("div",{className:"wandox-inbox-process__step",children:[b.jsx("span",{className:"wandox-inbox-process__step-number",children:"2"}),b.jsx("span",{className:"wandox-inbox-process__step-copy",children:"配置任务"})]}),b.jsx("span",{className:"wandox-inbox-process__step-line","aria-hidden":"true"}),b.jsxs("div",{className:"wandox-inbox-process__step",children:[b.jsx("span",{className:"wandox-inbox-process__step-number",children:"3"}),b.jsx("span",{className:"wandox-inbox-process__step-copy",children:"执行并记录"})]})]}),b.jsxs("div",{className:"wandox-inbox-process__source",children:[b.jsx("span",{className:"wandox-inbox-process__source-avatar","aria-hidden":"true",children:(r||"同事").slice(0,1)}),b.jsxs("div",{className:"wandox-inbox-process__source-copy",children:[b.jsxs("span",{className:"wandox-inbox-process__source-label",children:[r||"同事"," 转交的执行结果"]}),b.jsx("strong",{className:"wandox-inbox-process__source-summary",children:i||"当前执行结果将作为本次任务的上游数据"})]})]}),b.jsx(Kt,{className:"wandox-inbox-process__search",value:u,prefix:b.jsx(dy,{}),placeholder:"搜索智能体",allowClear:!0,onChange:h=>d(h.target.value)}),b.jsx("div",{className:"wandox-inbox-process__agent-list",children:n?b.jsxs("div",{className:"wandox-inbox-process__state",children:[b.jsx(vr,{size:"small"}),b.jsx("span",{className:"wandox-inbox-process__state-text",children:"正在读取智能体"})]}):f.length>0?f.map(h=>{const g=l===h.id;return b.jsxs("button",{type:"button",className:`wandox-inbox-process__agent${g?" wandox-inbox-process__agent--selected":""}`,"aria-pressed":g,onClick:()=>c(h.id),children:[b.jsx("span",{className:"wandox-inbox-process__agent-avatar","aria-hidden":"true",children:h.name.slice(0,1)}),b.jsxs("span",{className:"wandox-inbox-process__agent-copy",children:[b.jsx("strong",{className:"wandox-inbox-process__agent-name",children:h.name}),b.jsx("span",{className:"wandox-inbox-process__agent-description",children:h.description||"进入驾驶舱后配置本次运行参数"})]}),b.jsx("span",{className:"wandox-inbox-process__agent-check","aria-hidden":"true",children:g&&b.jsx(ff,{})})]},h.id)}):b.jsxs("div",{className:"wandox-inbox-process__empty",children:[b.jsx(ei,{image:ei.PRESENTED_IMAGE_SIMPLE,description:u?"没有匹配的智能体":"暂无可用智能体"}),!u&&b.jsxs("button",{type:"button",className:"wandox-inbox-process__create-link",onClick:s,children:[b.jsx(Uo,{}),"创建智能体承接"]})]})}),b.jsxs("div",{className:"wandox-inbox-process__footer",children:[b.jsx("span",{className:"wandox-inbox-process__footer-note",children:"流转来源会自动关联到新的执行记忆。"}),b.jsxs("div",{className:"wandox-inbox-process__footer-actions",children:[b.jsx("button",{type:"button",className:"wandox-inbox-process__button wandox-inbox-process__button--secondary",onClick:a,children:"取消"}),b.jsx("button",{type:"button",className:"wandox-inbox-process__button wandox-inbox-process__button--primary",disabled:!p,onClick:()=>p&&o(p),children:"下一步:配置任务"})]})]})]})}function ET(e){return e===!0||e===1||e==="true"||e==="1"}function BQt(e){return e.title.replace(/(已记住上次选择)$/,"")}function VQt(e,t){if(!lt(e))return null;const n=lt(e.layout)?e.layout:{},r=QU(e.key??e.id??e.name,`group_${t+1}`),i=hQt(e.fields??e.field_names??e.params??e.items);return!r||i.length===0?null:{key:r,title:QU(e.title??e.label??e.name,r),description:Od(e.description??e.subtitle??e.helper),fields:i,columns:Ud(e.columns??e.column??n.columns),remember_last:ET(e.remember_last??e.rememberLast??e.remember)}}function HQt(e){return lt(e)?{title:Od(e.title??e.form_title),description:Od(e.description??e.subtitle??e.form_description),footerNote:Od(e.footer_note??e.footerNote??e.note),submitLabel:Od(e.submit_label??e.submitLabel??e.primary_action_text),draftLabel:Od(e.draft_label??e.draftLabel??e.secondary_action_text),showDraft:typeof e.show_draft=="boolean"?e.show_draft:typeof e.showDraft=="boolean"?e.showDraft:void 0}:{}}function WQt(e){if(!lt(e))return null;const t=e.plan_yaml??e.yaml_content;if(typeof t!="string"||!t.trim())return null;try{const n=FE.parse(t);return lt(n)?n:null}catch{return null}}function UQt(e){const t=rl(e),n=[],r=[],i=s=>{lt(s)&&!n.includes(s)&&n.push(s)};i(t),lt(t)&&(i(t.agent),i(t.custom_agent),i(t.detail),i(t.template),i(t.market_template));const a=n.map(WQt).filter(s=>!!s);for(const s of a)r.push(s),i(s);const o=n.map(s=>s.params_schema).filter(lt);for(const s of o)i(s);return{data:t,records:n,planRecords:r}}function GQt(e,t){const n=new Map(e.map(o=>[o.name,o])),r=[],i=new Set;Array.isArray(t)&&t.forEach((o,s)=>{const l=VQt(o,s);if(!l)return;const c=l.fields.filter(u=>n.has(u));if(c.length!==0){r.push({...l,fields:c});for(const u of c)i.add(u)}});for(const o of e){const s=o.group;if(!s||i.has(o.name))continue;let l=r.find(c=>c.key===s);l||(l={key:s,title:o.group_label||s,description:o.group_description,fields:[]},r.push(l)),l.fields.push(o.name),i.add(o.name)}if(r.length===0)return[];const a=e.filter(o=>!i.has(o.name));return a.length>0&&r.push({key:"__ungrouped",title:"其他参数",fields:a.map(o=>o.name)}),r}function eG(e){const{data:t,records:n,planRecords:r}=UQt(e),a=[Array.isArray(t)?t:void 0,...n.flatMap(c=>[c.input_params,c.x_input_params]),...r.map(c=>c.params)].find(c=>Array.isArray(c)||lt(c)),o=YQ(a),s=n.flatMap(c=>[c.form_groups,c.input_form_groups,c.x_form_groups]).find(Array.isArray),l=n.map(c=>c.form_ui??c.input_form_ui??c.form_config).find(lt);return{fields:o,formGroups:GQt(o,s),formUi:HQt(l)}}function qQt(e){return eG(e).fields}const t4e=gT;function KQt(e,t){if(t.length===0)return[];const n=new Set(e.map(o=>o.name)),r=new Set,i=t.map(o=>{const s=o.fields.filter(l=>n.has(l));for(const l of s)r.add(l);return{...o,fields:s}}).filter(o=>o.fields.length>0),a=e.filter(o=>!r.has(o.name));return a.length>0&&i.push({key:"__ungrouped",title:"其他参数",fields:a.map(o=>o.name)}),i}const YQt="wandox_run_form_remember_v1";function tG(e){const t=localStorage.getItem("sso_domain")||"default",n=localStorage.getItem("sso_company")||"default",r=localStorage.getItem("sso_user_id")||localStorage.getItem("sso_username")||"default";return`${YQt}:${t}:${n}:${r}:${e}`}function n4e(e){return new Set(e.filter(t=>ET(t.remember_last)).flatMap(t=>t.fields))}function r4e(e,t){return e.filter(n=>ET(n.remember_last)).filter(n=>n.fields.some(r=>!If(t[r]))).map(n=>n.key)}function Tye(e,t,n){const r=n4e(n);if(r.size===0)return{values:{},groupKeys:[]};try{const i=localStorage.getItem(tG(e));if(!i)return{values:{},groupKeys:[]};const a=JSON.parse(i),o=lt(a==null?void 0:a.values)?a.values:lt(a)?a:{},s=new Set(t.map(c=>c.name)),l=Object.fromEntries(Object.entries(o).filter(([c,u])=>s.has(c)&&r.has(c)&&!If(u)));return{values:l,groupKeys:r4e(n,l)}}catch{return localStorage.removeItem(tG(e)),{values:{},groupKeys:[]}}}function XQt(e,t,n,r){const i=n4e(n);if(i.size===0)return[];const a=tG(e);let o={};try{const l=localStorage.getItem(a);if(l){const c=JSON.parse(l);o=lt(c==null?void 0:c.values)?{...c.values}:lt(c)?{...c}:{}}}catch{o={}}for(const l of t){if(!i.has(l.name))continue;const c=r[l.name];If(c)?delete o[l.name]:o[l.name]=c}const s=r4e(n,o);return localStorage.setItem(a,JSON.stringify({values:o,updatedAt:Date.now()})),s}function vee(e){const t=e;return lt(t)?t.output_type==="dynamic_form"&<(t.output_data)?t.output_data.data??t.output_data:t.output_type==="dynamic_form"&<(t.data)?t.data:t.output_data??t.output??t.final_output??t.result_data??t.data??t:t}const ZQt=new Set(["execution_id","id","trigger_type","trigger_display","started_at","completed_at","duration_ms","result_id","result_data","result_summary","output","output_data","output_type","output_fields_map","previous_step_output","previous_step_outputs","step_output","step_outputs","listing_data","listing_code","job_id","human_input_data","human_input_config","modified_params","confirmed_input"]),QQt={upload_excel:"上传文件",file_path:"上传文件",file:"上传文件",store_account:"店铺账号",marketplace_id:"站点",site:"站点",language:"语言",target_language:"语言",product_type:"产品品类",product_category:"产品品类",sku:"产品 SKU",product_sku:"产品 SKU",product_description:"产品描述",description:"产品描述",main_image:"主产品图",main_pic:"主产品图",images:"产品图片",sample_image:"样品图片"};function Gd(e){return e.trim().replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}const JQt=["execution_title","task_title","product_sku","sku","asin","order_id","order_no","listing_id","task_name","custom_goal","goal"],eJt=["product_name","item_name","product_title","title","name"];function Iye(e,t){for(const n of t){const r=Object.entries(e).find(([a])=>Gd(a)===n);if(!r)continue;const i=r[1];if((typeof i=="string"||typeof i=="number")&&String(i).trim())return String(i).trim()}return""}function tJt(e){const t=Iye(e,JQt),n=Iye(e,eJt),i=[t,n].filter((a,o,s)=>a&&s.indexOf(a)===o).join(" · ");return i?i.slice(0,256):void 0}function yee(e){const t=Gd(e);return ZQt.has(t)||t.endsWith("_output")||t.endsWith("_outputs")||t.includes("previous_step")}function nJt(e,t=new Map){const n=Gd(e);return t.get(e)||t.get(n)||QQt[n]||e.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function rJt(...e){const t=new Map;for(const n of e){const r=Array.isArray(n)?n:qQt(n);for(const i of r)!i.name||!i.label||(t.set(i.name,i.label),t.set(Gd(i.name),i.label))}return t}function kye(e){try{const n=new URL(e).pathname.split("/").filter(Boolean).pop();return n?decodeURIComponent(n):e}catch{return e.split("/").filter(Boolean).pop()||e}}function Pye(e,t){const n=Gd(e);return n.includes("file")||n.includes("excel")||n.includes("image")||n.includes("pic")?!0:typeof t=="string"&&/^https?:\/\//i.test(t)&&/\.(xlsx?|csv|png|jpe?g|webp|gif|pdf)(\?|$)/i.test(t)}function i4e(e,t){if(typeof t=="string")return Pye(e,t)?kye(t):t.length>120?`${t.slice(0,120)}...`:t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"":t.every(n=>typeof n=="string"&&Pye(e,n))?t.map(n=>kye(String(n))).join("、"):`${t.length} 项`;if(lt(t)){const n=Object.keys(t).filter(r=>!yee(r));return n.length===0?"":`${n.length} 项配置`}return zy(t)}function bee(e,t=new Map){const n=vee(e);return lt(n)?Object.entries(n).filter(([r,i])=>!yee(r)&&ni(i)).map(([r,i])=>[nJt(r,t),i4e(r,i)]).filter(([,r])=>ni(r)).slice(0,12):[]}function _c(e){const t=vee(e);return lt(t)?Object.entries(t).some(([n,r])=>!yee(n)&&ni(r)):!1}function a4e(...e){return e.find(_c)}function TT(e){const t=vee(e);return lt(t)&&_c(t)?{...t}:void 0}function xee(e){return!!(e!=null&&e.some(([,t])=>ni(t)&&t!=="-"))}function wee(e,t,n=new Map){const r=bee(t,n),i=TT(t);if(r.length===0&&!i)return e;const a=xee(e.params),o=_c(e.inputValues);return(a||r.length===0)&&(o||!i)?e:{...e,params:a?e.params:r,inputValues:o?e.inputValues:i}}function o4e(e,t){const n=Object.entries((t==null?void 0:t.inputValues)??{}),r=new Map(((t==null?void 0:t.params)??[]).map(([i,a])=>[Gd(i),a]));return e.reduce((i,a)=>{const o=Gd(a.name),s=n.find(([c])=>Gd(c)===o),l=r.get(Gd(a.label||a.name))??r.get(o);return i[a.name]=(s==null?void 0:s[1])??l??"",i},{})}function iJt(e){const t=String(e??"pending").toLowerCase();return["failed","cancelled","timeout"].includes(t)?"failed":["waiting","waiting_input","pending_input"].includes(t)?"waiting":["running","pending_async","awaiting_async"].includes(t)?"running":["completed","complete","success","succeeded"].includes(t)?"completed":"pending"}function aJt(e){return e==="running"?"正在执行":e==="awaiting_async"||e==="pending_async"?"等待异步结果":e==="waiting_input"?"等待人工确认":e==="failed"?"执行失败":e==="cancelled"?"执行已取消":e==="timeout"?"执行超时":"执行完成"}function See(e){const t=Rc(e.agent_name)||"执行步骤",n=String(e.status??"pending");return[{id:String(e.execution_id??e.id),title:n==="waiting_input"?"等待人工确认":t,description:e.summary||aJt(e.status),event:n,humanConfirm:n==="waiting_input",humanConfirmTriggered:n==="waiting_input",businessStatus:typeof e.business_status=="string"?e.business_status:void 0,status:iJt(e.status)}]}function oJt({event:e,existing:t,eventExecutionId:n,eventAgentName:r,isRecommended:i,pendingExecutionTitle:a,runInputData:o,nextSteps:s,nextStatus:l,nextStepError:c,eventTime:u}){var h;const d=String(n),f=bee(o),p=TT(o);return{id:d,resultId:e.result_id?String(e.result_id):t==null?void 0:t.resultId,title:((h=e.execution_title)==null?void 0:h.trim())||(t==null?void 0:t.title)||a||r,time:(t==null?void 0:t.time)||Mw(u),occurredAt:(t==null?void 0:t.occurredAt)||u,trigger:i?"推荐执行":"手动运行",status:l,businessStatus:e.business_status??(t==null?void 0:t.businessStatus),summary:l==="waiting"?"等待人工确认":l==="completed"?"执行完成":l==="failed"?c:"正在执行",resultTitle:(t==null?void 0:t.resultTitle)||(l==="failed"?"执行失败":r),resultContent:t==null?void 0:t.resultContent,resultPayload:t==null?void 0:t.resultPayload,params:xee(t==null?void 0:t.params)?(t==null?void 0:t.params)??[]:f,inputValues:_c(t==null?void 0:t.inputValues)?t==null?void 0:t.inputValues:p,steps:s.length>0?s:(t==null?void 0:t.steps)||See({id:n,execution_id:d,agent_name:r,status:e.type==="waiting_input"?"waiting_input":l==="failed"?"failed":l==="completed"?"completed":"running",summary:l==="failed"?c:l==="waiting"?"等待人工确认":l==="completed"?"执行完成":"正在执行"}),outputs:(t==null?void 0:t.outputs)||[],detailData:t==null?void 0:t.detailData}}function _ee(e){return Array.isArray(e)?e.filter(t=>!$j(t)).length:void 0}function IT(e,t="pending"){return lt(e)?String(e.status??t).toLowerCase():t}function $j(e){return lt(e)?IT(e)==="skipped"||e.skipped===!0||e.is_skipped===!0:!1}function sJt(e){return lt(e)?!!(ni(e.human_input_data)||ni(e.submitted_input)||ni(e.confirmed_input)||ni(e.human_input_at)||ni(e.human_input_by)||e.human_confirm_triggered===!0):!1}function s4e(e){if(!Array.isArray(e))return"";const t=e.find(r=>lt(r)?["failed","cancelled","timeout"].includes(IT(r)):!1);if(!lt(t))return"";const n=Cee(t.output_data);return n||Hc("",t.error_message,t.message)}function Cee(e){if(!lt(e))return"";const t=lt(e.data)?e.data:{};return Hc("",e.error_message,t.error_message,e.error,t.error)}function lJt(e){if(!lt(e))return"";const t=lt(e.data)?e.data:{};return Hc("",e.message,t.message,e.detail,t.detail)}function l4e(e,t){return!Array.isArray(e)||e.length===0?See({...t,summary:ty(t)}):e.filter(r=>!$j(r)).map((r,i)=>{const a=lt(r)?r:{},o=a.output_data,s=lt(a.playbook)?a.playbook:{},l=lt(a.workflow)?a.workflow:{},c=IT(a),u=X2(c),d=u==="failed"?Hc("",a.error_message,Cee(o)):"",f=u==="waiting"||sJt(a),p=Hc("",d,a.business_status,a.description,s.description,l.description,u==="failed"?a.message:"",lJt(o)),h=a.duration_ms?`耗时 ${Math.round(Number(a.duration_ms)/1e3)} 秒`:"",g=Rc(a.step_name,a.playbook_name,a.name,a.title,s.name,l.name)||`步骤 ${i+1}`;return{id:String(a.step_id??a.id??`step_${i+1}`),title:g,description:[p,h].filter(Boolean).join(" · "),event:c,humanConfirm:u==="waiting"||!!(a.requires_human_confirm??a.requires_human_input??a.human_confirm??a.human_confirm_enabled),humanConfirmTriggered:f,businessStatus:Od(a.business_status),status:u,rawData:a}})}function c4e(e,t){if(!Array.isArray(e)||t==null||t<0)return;const n=e[t];return lt(n)?_j(n.step_id):void 0}function Nye(e){const t=(e==null?void 0:e.trim())??"";return!t||/^步骤\s*\d+$/i.test(t)||Yje(t)}function $ee(e){return lt(e)&<(e.result_data)?e.result_data:e}function u4e(e){return lt(e)?e.output_type==="dynamic_form"&<(e.output_data)?e.output_data.data??e.output_data:e.output_type==="dynamic_form"&<(e.data)?e.data:e.output_data??e.output??e.final_output??e.result_data??e.data??e:e}function cJt(e){const t=$ee(e);return lt(t)?t.output_type==="dynamic_form"&<(t.output_data)?t.output_data.data??t.output_data:t.output_type==="dynamic_form"&<(t.data)?t.data:t.output_type?t.output??t.data??t.output_data??t.content??t:u4e(t):t}function d4e(e){const t=$ee(e);if(!ni(t))return;if(!lt(t))return t;const n=typeof t.output_type=="string"?t.output_type:"",r=t.output??t.data??t.output_data??t.content,i=Array.isArray(t.output_fields_map)?t.output_fields_map:void 0;return n==="card"&<(r)&&typeof r.content=="string"?r.content:n?Wd(n==="debug"?"card":n,r,i,typeof t.title=="string"?t.title:void 0):lt(r)&&typeof r.content=="string"?r.content:typeof r=="string"?r:q2(t)}function uJt(e){const t=lt(e.rawData)?e.rawData:void 0,n=(t==null?void 0:t.output_data)??(t==null?void 0:t.output)??(t==null?void 0:t.result_data);if(ni(n))return Fje(n)}function Eee(...e){const t=new Map;for(const n of e)if(!(!lt(n)||!Array.isArray(n.output_fields_map)))for(const r of n.output_fields_map){if(!lt(r))continue;const i=String(r.name??""),a=String(r.label??"");i&&a&&t.set(i,a)}return t}function dJt(e){const t=$ee(e);return lt(t)&&typeof t.output_type=="string"?t.output_type:""}function fJt(e){if(typeof e=="string")return e;if(!lt(e))return"";const n=[e.content,e.markdown,e.text,lt(e.output)?e.output.content:void 0,lt(e.data)?e.data.content:void 0].find(r=>typeof r=="string"&&r.trim());return typeof n=="string"?n:""}function pJt(e){const n=e.split(/\r?\n/).map(r=>r.trim()).map(r=>r.replace(/^[-*]\s+/,"").trim()).map(r=>r.replace(/^\*\*[^*::]+[::]\*\*\s*/,"").trim()).filter(Boolean)[0]||"";return n.length>42?`${n.slice(0,42)}...`:n}function nG(e){return e.replace(/^#+\s*/,"").replace(/\*\*/g,"").trim()}function f4e(e,t){var i;if(typeof e!="string")return e;const n=e.split(/\r?\n/),r=n.findIndex(a=>a.trim());if(r<0||nG(n[r])!==nG(t))return e;for(n.splice(r,1);((i=n[r])==null?void 0:i.trim())==="";)n.splice(r,1);return n.join(`
|
|
794
|
-
`)}function hJt(e,t){const n=e.toLowerCase(),r=(t||"").toLowerCase();return["model","usage","provider"].includes(n)||["模型名称","模型提供者","usage"].some(i=>r.includes(i.toLowerCase()))}function Tee(e,t=new Map,n=8){const r=cJt(e);return Array.isArray(r)?[["结果条数",`${r.length} 条`]]:lt(r)?Object.entries(r).filter(([i,a])=>!["content","execution_steps","output_fields_map","output_type"].includes(i)&&!hJt(i,t.get(i))&&ni(a)).slice(0,n).map(([i,a])=>[t.get(i)??i,zy(a)]):typeof r=="string"&&r.trim()?[["输出内容",r.length>80?`${r.slice(0,80)}...`:r]]:[]}function mJt(e){return $T(e.status)==="completed"&&(Qje(e.result_summary)||Jje(e.result_summary))?"执行完成":Hc(ty(e),e.result_summary,e.error_message)}function gJt(e,t){return $T(e.status)==="completed"&&t?`已完成 ${t} 个步骤`:ty(e)}function p4e(e,t,n){const r=d4e(e),i=s4e(n),a=dJt(e),o=fJt(r),s=mJt(t),c=(o&&a!=="dynamic_form"?pJt(o):"")||s,u=c&&o?String(f4e(o,c)):o,d=u&&u!==o?u:r,f=_ee(n);return{title:c,subtitle:i||gJt(t,f),content:u,payload:d,meta:Tee(e,Eee(e),3),detailData:ni(e)?e:void 0}}function h4e(e){const t=rl(e);return lt(t)?lt(t.result)?t.result:t:{}}function vJt(e){const t=rl(e),n=h4e(e);return n.result_data??n.output_data??n.output??n.data??(lt(t)?t.result_data??t.output_data??t.output??t.data:t)}function yJt(e){const t=rl(e),n=h4e(e);return lt(t)?String(n.result_summary??t.result_summary??""):""}function bJt({loading:e,error:t,detail:n,onRetry:r}){if(e)return b.jsxs("div",{className:"automation-inbox-result-empty",children:[b.jsx(vr,{size:"small"}),b.jsx("span",{children:"正在读取执行结果"})]});if(t)return b.jsxs("div",{className:"automation-inbox-result-empty is-error",children:[b.jsx(Upt,{}),b.jsx("span",{children:t}),b.jsx("button",{type:"button",className:"automation-action-button automation-action-button--compact automation-action-button--danger",onClick:r,children:"重试"})]});if(!n)return b.jsxs("div",{className:"automation-inbox-result-empty",children:[b.jsx(Zg,{}),b.jsx("span",{children:"暂无执行结果"})]});const i=vJt(n),a=yJt(n),o=ni(i)?d4e(i):a;return ni(o)?b.jsx(Ci,{payload:o}):b.jsxs("div",{className:"automation-inbox-result-empty",children:[b.jsx(Zg,{}),b.jsx("span",{children:"暂无执行结果内容"})]})}function xJt({model:e,actions:t}){const{embedded:n,transferCount:r,loading:i,groups:a,active:o,rejectingTransferId:s}=e,l=(o==null?void 0:o.transfer)??null,c=(o==null?void 0:o.pending)??!1,u=(o==null?void 0:o.sender)??"",d=(o==null?void 0:o.time)??"",f=o==null?void 0:o.resultContent,{back:p,refresh:h,selectTransfer:g,process:v,createAgent:y,reject:x}=t;return b.jsxs(b.Fragment,{children:[!n&&b.jsx("header",{className:"wandox-automation-page-header",children:b.jsxs("div",{className:"automation-workbench-head",children:[b.jsxs("div",{children:[b.jsx("h2",{children:"结果收件箱"}),b.jsx("p",{className:"automation-workbench-head__meta",children:"查看同事转交的执行结果和后续处理入口"})]}),b.jsx(Et,{className:"wandox-automation-page-header__back",icon:b.jsx(q$,{}),onClick:p,children:"返回智能体选择"})]})}),b.jsxs("section",{className:"automation-workspace automation-workspace--inbox",children:[b.jsxs("section",{className:"automation-panel automation-history-panel automation-history-panel--inbox",children:[b.jsxs("div",{className:"automation-panel-head",children:[b.jsx("div",{children:b.jsx("h2",{children:"收件记录"})}),b.jsx("button",{type:"button",className:"wandox-automation-inbox-refresh","aria-label":"刷新收件",title:"刷新收件",onClick:h,disabled:i,children:i?b.jsx(vr,{size:"small"}):b.jsx(yy,{})})]}),b.jsx("div",{className:`automation-history-list automation-inbox-memory-list${!i&&r===0?" is-empty":""}`,children:i&&r===0?b.jsxs("div",{className:"automation-history-empty",children:[b.jsx("span",{className:"automation-history-empty-icon",children:b.jsx(vr,{size:"small"})}),b.jsxs("div",{children:[b.jsx("strong",{children:"正在读取收件"}),b.jsx("small",{children:"收件列表会按转交时间展示。"})]})]}):r===0?b.jsxs("div",{className:"automation-history-empty",children:[b.jsx("span",{className:"automation-history-empty-icon",children:b.jsx(Zg,{})}),b.jsxs("div",{children:[b.jsx("strong",{children:"暂无收件"}),b.jsx("small",{children:"同事转交执行结果后,会出现在这里。"})]})]}):a.map(w=>b.jsxs("div",{className:"automation-memory-group",children:[b.jsx("div",{className:"automation-memory-date",children:b.jsx("span",{children:w.label})}),b.jsx("div",{className:"automation-memory-stack",children:w.items.map(S=>{const _=(l==null?void 0:l.id)===S.id;return b.jsxs("button",{type:"button",className:`automation-inbox-memory-card automation-inbox-memory-card--${S.runStatus}${_?" automation-inbox-memory-card--active":""}`,title:S.summary,onClick:()=>g(S.id),children:[b.jsx("span",{className:"automation-inbox-memory-card__icon","aria-hidden":"true",children:b.jsx(Zg,{})}),b.jsxs("div",{className:"automation-inbox-memory-card__main",children:[b.jsx("strong",{children:S.primaryText}),b.jsx("small",{children:S.time})]}),b.jsx("span",{className:"automation-inbox-memory-card__state",children:S.statusText})]},S.id)})})]},w.key))})]}),b.jsx("section",{className:`automation-workbench automation-workbench--inbox${(l==null?void 0:l.status)==="rejected"?" is-failed":""}${l&&c?" has-footer":""}`,children:b.jsxs("div",{className:"wandox-automation-inbox-detail",children:[b.jsx("div",{className:"automation-workbench-body wandox-automation-inbox-detail__body",children:i&&!l?b.jsxs("section",{className:"automation-workbench-empty wandox-automation-inbox-detail__empty",children:[b.jsx(vr,{}),b.jsx("strong",{children:"正在读取收件详情"}),b.jsx("span",{children:"读取完成后会显示当前收件。"})]}):l?b.jsxs("section",{className:"wandox-automation-inbox-bubble",children:[b.jsxs("div",{className:"wandox-automation-inbox-bubble__head",children:[b.jsx("span",{className:"wandox-automation-inbox-bubble__avatar","aria-hidden":"true",children:(u||"同事").slice(0,1)}),b.jsxs("div",{className:"wandox-automation-inbox-bubble__meta",children:[b.jsx("span",{className:"wandox-automation-inbox-bubble__sender",children:u||"同事"}),b.jsx("span",{className:"wandox-automation-inbox-bubble__action",children:"转交"}),d&&b.jsx("span",{className:"wandox-automation-inbox-bubble__time",children:d})]})]}),b.jsx("div",{className:"wandox-automation-inbox-bubble__content",children:b.jsx("div",{className:"automation-inbox-result-content",children:f})})]}):b.jsxs("section",{className:"automation-workbench-empty wandox-automation-inbox-detail__empty",children:[b.jsx(Zg,{}),b.jsx("strong",{children:"暂无收件"}),b.jsx("span",{children:"有新的结果流转时,这里会显示处理入口。"})]})}),l&&c&&b.jsxs("div",{className:"automation-workbench-footer wandox-automation-inbox-detail__footer",children:[b.jsx("div",{className:"wandox-automation-inbox-detail__footer-note",children:"处理当前流转结果,或创建一个新智能体承接后续执行。"}),b.jsxs("div",{className:"wandox-automation-inbox-detail__footer-actions",children:[b.jsxs("button",{type:"button",className:"automation-inbox-action-button automation-inbox-action-button--process",onClick:()=>v(l),children:[b.jsx(Fc,{}),"处理"]}),b.jsxs("button",{type:"button",className:"automation-inbox-action-button automation-inbox-action-button--create",onClick:()=>y(l),children:[b.jsx(Uo,{}),"创建智能体"]}),b.jsxs("button",{type:"button",className:"automation-inbox-action-button automation-inbox-action-button--reject",disabled:s===l.id,onClick:()=>x(l),children:[b.jsx(ga,{}),s===l.id?"拒绝中":"拒绝"]})]})]})]})})]})]})}function wJt({model:e,actions:t}){return b.jsxs(b.Fragment,{children:[b.jsx(xJt,{model:{embedded:e.embedded,transferCount:e.transferCount,loading:e.loading,groups:e.groups,active:e.active?{...e.active,resultContent:b.jsx(bJt,{loading:e.result.loading,error:e.result.error,detail:e.result.detail,onRetry:t.retryResult})}:null,rejectingTransferId:e.rejectingTransferId},actions:{back:t.back,refresh:t.refresh,selectTransfer:t.selectTransfer,process:t.process,createAgent:t.createAgent,reject:t.reject}}),b.jsx(FQt,{open:!!e.process.transfer,agents:e.process.agents,loading:e.process.loading,sender:e.process.sender,summary:e.process.summary,onClose:t.closeProcess,onConfirm:t.continueProcess,onCreateAgent:t.createAgentFromProcess})]})}const SJt=(...e)=>["automation-action-button",...e].filter(Boolean).join(" ");function Aye({children:e,tone:t="gray"}){return b.jsx("span",{className:`automation-badge automation-badge--${t}`,children:e})}function _Jt(e){return e?typeof e.has_schedule=="boolean"?e.has_schedule:!!(e.schedule_enabled||e.schedule_cron||e.next_run_at):!1}function CJt(e){if(e.my_status==="enabled")return"已启用";const t=e.input_data_schema,n=Array.isArray(t)?t.length:0,r=Array.isArray(e.tags)?e.tags.slice(0,2).join(" · "):"";return n>0?`${n} 个运行参数`:r||e.category||"可启用"}function $Jt({embedded:e,agentsLoading:t,marketLoading:n,marketError:r,marketTemplates:i,availableAgents:a,subscribingTemplateId:o,deletingAgentId:s,onReloadMarket:l,onEnableMarketTemplate:c,onSelectAgent:u,onDeleteCustomAgent:d}){const f=i.filter(p=>p.my_status!=="enabled");return b.jsxs("section",{className:"automation-market",children:[b.jsxs("section",{className:"automation-center-section",children:[!e&&b.jsx("div",{className:"automation-panel-head",children:b.jsxs("div",{children:[b.jsxs("div",{className:"automation-center-title",children:[b.jsx("h2",{children:"可用智能体"}),b.jsx(Aye,{tone:"blue",children:t?"加载中":`${a.length} 个`})]}),b.jsx("p",{children:"选择一个工作对象进入驾驶舱。"})]})}),t&&a.length===0?b.jsxs("div",{className:"automation-agent-empty",children:[b.jsx("strong",{children:"正在读取智能体列表"}),b.jsx("p",{children:"读取完成后会显示可用智能体。"})]}):a.length>0?b.jsx("div",{className:"automation-agent-card-grid",children:a.map(p=>{const h=s===p.id,g=p.is_from_market?"移除":"删除",v=_Jt(p);return b.jsxs("article",{className:"automation-agent-card",children:[b.jsx("h3",{children:p.name}),b.jsx("p",{children:p.description||p.scene_name||"进入驾驶舱后可以运行、查看历史和配置定时任务。"}),b.jsxs("div",{className:"automation-agent-card-meta",children:[b.jsxs("span",{children:[p.execution_count??0," 次运行"]}),b.jsx("span",{className:v?"automation-agent-card-meta__schedule automation-agent-card-meta__schedule--active":"automation-agent-card-meta__schedule",children:v?"已配置定时":"未配置定时"})]}),b.jsxs("div",{className:"automation-card-actions",children:[b.jsx(Et,{type:"primary",className:"automation-card-action-button",autoInsertSpace:!1,onClick:()=>u(p),children:"进入驾驶舱"}),b.jsx(Et,{danger:!0,className:"automation-card-action-button",autoInsertSpace:!1,disabled:h,loading:h,onClick:()=>d(p),children:h?`${g}中`:g})]})]},`agent-${p.id}`)})}):b.jsxs("div",{className:"automation-agent-empty",children:[b.jsx("strong",{children:t?"正在读取智能体列表":"暂无可用智能体"}),b.jsx("p",{children:t?"读取完成后会显示可用智能体。":"可通过头部创建入口添加智能体。"})]})]}),n&&f.length===0?b.jsx("section",{className:"automation-center-section",children:b.jsxs("div",{className:"automation-agent-empty",children:[b.jsx("strong",{children:"正在读取可启用模板"}),b.jsx("p",{children:"读取市场模板和启用状态。"})]})}):r&&f.length===0?b.jsx("section",{className:"automation-center-section",children:b.jsxs("div",{className:"automation-agent-empty",children:[b.jsx("strong",{children:"可启用模板读取失败"}),b.jsx("p",{children:r}),b.jsx("button",{type:"button",className:SJt(),onClick:l,children:"重新加载"})]})}):f.length>0?b.jsxs("section",{className:"automation-center-section",children:[!e&&b.jsx("div",{className:"automation-panel-head",children:b.jsxs("div",{children:[b.jsxs("div",{className:"automation-center-title",children:[b.jsx("h2",{children:"可启用模板"}),b.jsx(Aye,{tone:"violet",children:n?"加载中":`${f.length} 个`})]}),b.jsx("p",{children:"启用后会添加到你的智能体列表。"})]})}),b.jsx("div",{className:"automation-agent-card-grid",children:f.map(p=>{const h=o===p.id;return b.jsxs("article",{className:"automation-agent-card",children:[b.jsx("h3",{children:p.name}),b.jsx("p",{children:p.description||p.category||"启用后会添加到你的智能体中心。"}),b.jsxs("div",{className:"automation-agent-card-meta",children:[b.jsx("span",{children:"市场模板"}),b.jsx("span",{children:CJt(p)})]}),b.jsx("div",{className:"automation-card-actions",children:b.jsx(Et,{type:"primary",className:"automation-card-action-button",autoInsertSpace:!1,disabled:h,loading:h,onClick:()=>c(p),children:h?"启用中":"启用"})})]},`market-${p.id}`)})})]}):null]})}function EJt({model:e,actions:t}){return b.jsx($Jt,{...e,onReloadMarket:t.reload,onEnableMarketTemplate:t.enableTemplate,onSelectAgent:t.selectAgent,onDeleteCustomAgent:t.deleteAgent})}function TJt({text:e}){return e?b.jsx("div",{className:"automation-toast",children:e}):null}function IJt({view:e,market:t,inbox:n,cockpit:r,empty:i,transferModal:a,scheduleModal:o,toast:s}){return b.jsxs("main",{className:"automation",children:[e==="market"?b.jsx(EJt,{...t}):e==="inbox"?b.jsx(wJt,{...n}):r?b.jsx(zQt,{...r}):b.jsx(dQt,{...i}),b.jsx(cee,{...a}),b.jsx(uQt,{...o}),b.jsx(TZt,{}),b.jsx(RZt,{}),b.jsx(TJt,{text:s})]})}function kJt(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)&&t>0?t:null}function PJt(e,t){return kJt(t??e.execution_record_id??e.execution_id)}function NJt(e,{selectedAgentId:t,recommendedAgentId:n}){return e.agent_id?e.agent_id===t||e.agent_id===n&&n!=null:!0}function AJt(){const e=m.useRef(""),t=m.useRef(""),n=m.useCallback(()=>{e.current="",t.current=""},[]),r=m.useCallback((a,o)=>{const s=`${a}:${o||""}`;return e.current===s?!1:(e.current=s,!0)},[]),i=m.useCallback((a,o,s)=>{const l=`${a}:${o}:${String(s??"")}`;return t.current===l?!1:(t.current=l,!0)},[]);return{reset:n,shouldHandleWaiting:r,shouldHandleFinished:i}}const rG={phase:"idle",drawer:null,waitingRunId:"",waitingInfo:null,waitingLoading:!1,waitingSubmitting:!1};function MJt(e,t){if(t.type==="execution_started")return{...e,phase:"running",waitingRunId:"",waitingInfo:null,drawer:e.drawer==="run"||e.drawer==="waiting"?null:e.drawer};if(t.type==="execution_finished")return{...e,phase:t.phase,waitingRunId:"",waitingInfo:null,waitingLoading:!1,waitingSubmitting:!1,drawer:"detail"};if(t.type==="execution_cancelled")return{...rG};const n=typeof t.update=="function"?t.update(e):t.update;return{...e,...n}}function V0(e,t){return n=>{e({type:"update",update:r=>({[t]:typeof n=="function"?n(r[t]):n})})}}function RJt(){const[e,t]=m.useReducer(MJt,rG),n=m.useMemo(()=>V0(t,"phase"),[]),r=m.useMemo(()=>V0(t,"drawer"),[]),i=m.useMemo(()=>V0(t,"waitingRunId"),[]),a=m.useMemo(()=>V0(t,"waitingInfo"),[]),o=m.useMemo(()=>V0(t,"waitingLoading"),[]),s=m.useMemo(()=>V0(t,"waitingSubmitting"),[]),l=m.useCallback(()=>t({type:"update",update:{drawer:"detail"}}),[]),c=m.useCallback((T=!1)=>t({type:"update",update:I=>({drawer:"run",phase:T?I.phase:"idle"})}),[]),u=m.useCallback(T=>t({type:"update",update:{waitingRunId:T,waitingInfo:null,waitingLoading:!0,drawer:"waiting"}}),[]),d=m.useCallback(()=>t({type:"update",update:{waitingRunId:"",waitingInfo:null,waitingLoading:!1,waitingSubmitting:!1,drawer:null}}),[]),f=m.useCallback(()=>t({type:"update",update:rG}),[]),p=m.useCallback(()=>t({type:"execution_cancelled"}),[]),h=m.useCallback((T,I)=>t({type:"update",update:P=>({waitingInfo:T,waitingRunId:I??P.waitingRunId,waitingLoading:!1,drawer:"waiting"})}),[]),g=m.useCallback(()=>t({type:"execution_started"}),[]),v=m.useCallback(()=>t({type:"update",update:{phase:"running",drawer:"run",waitingRunId:"",waitingInfo:null}}),[]),y=m.useCallback(()=>t({type:"update",update:{phase:"idle",drawer:"run"}}),[]),x=m.useCallback(()=>t({type:"update",update:{phase:"failed"}}),[]),w=m.useCallback(()=>t({type:"update",update:{phase:"running"}}),[]),S=m.useCallback(()=>t({type:"update",update:{phase:"idle"}}),[]),_=m.useCallback(()=>t({type:"update",update:{phase:"review_content"}}),[]),C=m.useCallback(()=>t({type:"update",update:{phase:"review_submit"}}),[]),$=m.useCallback(()=>t({type:"update",update:{phase:"polling"}}),[]),E=m.useCallback(()=>t({type:"update",update:{phase:"completed"}}),[]),k=m.useCallback(T=>t({type:"execution_finished",phase:T}),[]);return{...e,setPhase:n,setDrawer:r,setWaitingRunId:i,setWaitingInfo:a,setWaitingLoading:o,setWaitingSubmitting:s,openDetailDrawer:l,openRunDrawer:c,beginWaiting:u,clearWaiting:d,resetExecution:f,cancelExecution:p,advanceWaiting:h,executionStarted:g,beginExecution:v,prepareRun:y,failExecution:x,setRunningPhase:w,setIdlePhase:S,setReviewContentPhase:_,setReviewSubmitPhase:C,setPollingPhase:$,setCompletedPhase:E,executionFinished:k}}function DJt(){const[e,t]=m.useState(IQt);m.useEffect(()=>{kQt(e)},[e]);const n=m.useCallback(r=>{t(i=>DQt(i,r))},[]);return{traces:e,recordEvent:n}}function m4e(...e){return e.find(ni)}function g4e(e,t){const n=e.result_data,r=Eee(n),i=Tee(n,r,3);if(i.length>0)return i;const o=[["处理状态",$T(e.status)==="completed"&&t?`已完成 ${t} 个步骤`:ty(e)],["触发方式",e.trigger_display||(e.trigger_type==="scheduled"?"定时运行":"手动运行")]];return e.duration_ms&&o.push(["耗时",`${Math.round(Number(e.duration_ms)/1e3)} 秒`]),o.filter(([,s])=>ni(s)).slice(0,3)}function v4e(e,t,n,r=new Map){return bee(t,r)}function Iee(e){if(!lt(e))return;const t=lt(e.execution)?e.execution:{},n=lt(e.workflow)?e.workflow:{},r=lt(e.chain)?e.chain:{};return m4e(e.steps,e.workflow_steps,e.execution_steps,e.playbooks,t.steps,t.workflow_steps,t.execution_steps,t.playbooks,n.steps,n.playbooks,r.steps,r.playbooks)}function Ej(e){const t=rl(e);if(!lt(t))return;const n=lt(t.execution)?t.execution:{},r=lt(t.result)?t.result:{},i=Iee(t),a=Array.isArray(i)?i.flatMap(o=>lt(o)?[o.input_data,o.input]:[]):[];return a4e(n.input_data,n.params,n.input_params,n.input,n.run_params,n.execution_params,t.input_data,t.params,t.input_params,t.input,r.input_data,r.params,r.input_params,r.input,...a)}function Tj(e,t){const n=rl(e),r=lt(n)&<(n.execution)?n.execution:{};return rJt(t,lt(n)?n.input_params:void 0,r.input_params)}function Mye(e){return ni(e)?typeof e=="string"?e.trim():zy(e):""}function OJt(e){const t=Rc(e.execution_title,e.agent_name)||"智能体执行",n=e,r=e.started_at??n.created_at??e.completed_at??n.updated_at,i=e.execution_steps??e.workflow_steps??e.steps,a=p4e(e.result_data,e,i),o=$T(e.status),s=_ee(i),l=e,c=a4e(l.input_data,l.params,l.input_params,l.input,l.run_params,l.execution_params),u=lt(l.result)?l.result:{},d=l.result_id??l.resultId??u.id??u.result_id,f=Ud(l.current_step_index);return{id:String(e.id??e.execution_id),recordId:Number.isFinite(Number(e.id))?Number(e.id):void 0,currentStepIndex:f,currentStepId:c4e(i,f),resultId:d?String(d):void 0,title:t,time:Mw(r)||"未知时间",occurredAt:r,trigger:e.trigger_type==="scheduled"?"定时运行":"手动运行",triggerType:e.trigger_type,status:o,businessStatus:e.business_status??void 0,summary:a.subtitle||(o==="completed"?"":ty(e)),resultTitle:a.title||Hc(t,e.result_summary,e.error_message),listResultSummary:Mye(e.result_summary),listErrorMessage:Mye(e.error_message),resultContent:a.content,resultPayload:a.payload,params:v4e(e,c),inputValues:TT(c),steps:See({...e,summary:ty(e)}),outputs:a.meta.length>0?a.meta:g4e(e,s),detailData:a.detailData}}function y4e(e){const t=rl(e);if(!lt(t))return;const n=lt(t.execution)?t.execution:{},r=lt(t.result)?t.result:{};return _j(r.id??r.result_id??n.result_id??t.result_id)}function LJt(e,t){return hee([t,...e.filter(n=>n.id!==t.id)])}function jJt(e,t,n){let r=!1;const i=e.map(a=>{if(a.id!==t)return a;const o=n(a);return o!==a&&(r=!0),o});return r?i:e}function zJt(e,t){const n=e.filter(r=>r.id!==t);return n.length===e.length?e:n}function FJt(e,t){return e>1&&t<=1?e-1:e}function BJt({selectedAgent:e,setActiveRunId:t,beginWaiting:n,advanceWaiting:r,clearWaiting:i,setWaitingLoading:a,getExecutionDetail:o,updateRun:s,notify:l,getErrorMessage:c}){return m.useCallback(async u=>{t(u.id);const d=Number(u.id);if(!Number.isFinite(d)){Ze.error("无法定位执行记录");return}n(u.id);try{const[f,p]=await Promise.allSettled([I1(d),o(d)]);if(p.status==="fulfilled"){const g=p.value,v=Ej(g),y=Tj(g,e==null?void 0:e.input_params);_c(v)&&s(u.id,x=>wee(x,v,y))}if(f.status==="rejected")throw f.reason;const h=f.value;if(!h){Ze.info("当前执行记录暂无待处理步骤"),i();return}r(h,u.id),l("已读取待处理表单")}catch(f){Ze.error(c(f,"加载待处理表单失败")),i()}finally{a(!1)}},[r,n,i,c,o,l,e,t,a,s])}function VJt({isExecuting:e,currentExecutionId:t,selectedAgentId:n,cancelledExecutionRef:r,abort:i,cancelExecution:a,resetLiveExecutionState:o,setActiveRunSnapshot:s,notify:l,refreshLiveRuns:c}){const u=wa(),d=Ll({...Bl.executions.cancel(),onSuccess:(f,p)=>Ys(u,{type:"execution-cancelled",executionId:p,agentId:n??void 0},{refetchType:"none"})});return m.useCallback(async()=>{if(e){r.current=!0,i(),a(),o(),s(f=>f&&f.status==="running"?{...f,status:"failed",summary:"执行已取消"}:f);try{t!=null&&Number.isFinite(Number(t))&&await d.mutateAsync(Number(t)),l("执行已取消"),n&&c()}catch(f){Ze.error(Ai(f,"取消执行失败"))}}},[i,a,d,r,t,e,l,c,o,n,s])}function HJt(e,t){return e&&!t}function WJt(e){if(!e.length)return 0;const t=e.findIndex(r=>r.status==="running"||r.status==="waiting");if(t>=0)return t;const n=e.findIndex(r=>r.status==="pending");return n>=0?n:e.length-1}function UJt(e,t,n){if(!e.length)return 0;const r=n!=null&&n.step_id?e.findIndex(o=>o.id===n.step_id):-1;if(r>=0)return r;const i=n!=null&&n.playbook_name?e.findIndex(o=>o.title===n.playbook_name):-1;if(i>=0)return i;if((n==null?void 0:n.step_index)!=null&&n.step_index>=0&&n.step_index<e.length)return n.step_index;const a=t==null?void 0:t.steps.find(o=>o.status==="waiting"||o.status==="running");if(a){const o=e.findIndex(l=>l.id===a.id);if(o>=0)return o;const s=e.findIndex(l=>l.title===a.title);if(s>=0)return s}return 0}function b4e(e,t,n=[]){const r=(e==null?void 0:e.steps.filter(s=>!Nye(s.title)))??[],i=!!(t&&r.some(s=>t.step_id&&s.id===t.step_id||t.playbook_name&&s.title===t.playbook_name));if(r.length>1||i)return r;const a=n.filter(s=>!Nye(s.title));if(a.length===0)return[];const o=UJt(a,e,t);return a.map((s,l)=>({...s,description:l===o&&(t!=null&&t.message)?t.message:s.description,humanConfirm:l===o?!0:s.humanConfirm,humanConfirmTriggered:l===o?!0:s.humanConfirmTriggered,status:l<o?"completed":l===o?"waiting":"pending"}))}function GJt(e){return e==="waiting"?"waiting_input":e==="running"?"running":e==="completed"?"completed":e==="failed"?"failed":"pending"}function qJt(e){return e==="running"?"running":e==="completed"?"completed":e==="failed"?"failed":"pending"}function x4e(e,t){return e.map((n,r)=>{var l;const i=lt(n.rawData)?n.rawData:{},a=Ud(i.step_index)??r,o=_j(i.step_id)??n.id??`step_${a}`,s=(l=n.substeps)==null?void 0:l.map((c,u)=>{var d;return{id:c.id,parent_step_index:a,parent_step_name:n.title,substep_index:u,substep_total:((d=n.substeps)==null?void 0:d.length)??u+1,substep_name:c.title,status:qJt(c.status),message:c.description}});return{id:Ud(i.id)??a,execution_id:Ud(i.execution_id)??t,step_id:o,step_index:a,step_name:Rc(i.step_name,i.playbook_name,n.title)||`步骤 ${a+1}`,playbook_id:Od(i.playbook_id)??o,status:GJt(n.status),business_status:n.businessStatus??Od(i.business_status)??null,output_data:lt(i.output_data)?i.output_data:void 0,duration_ms:Ud(i.duration_ms),requires_human_confirm:n.humanConfirm,human_confirm_triggered:n.humanConfirmTriggered,substeps:s}})}function KJt(e,t,n){const r=lt(e.rawData)?e.rawData:{};return n||(t!=null&&t>=0?`step_${t+1}`:_j(r.step_id)||e.id)}function YJt({isExecuting:e,reExecutingStepId:t,setReExecutingStepId:n,resetExecutionEvents:r,clearExecutionDetail:i,setActiveRunId:a,executionStarted:o,failExecution:s,reExecuteStep:l,notify:c,refreshLiveRuns:u}){return m.useCallback(async(d,f)=>{if(e||t||!Rw(f))return;const p=Number(f.id);if(!Number.isFinite(p)){Ze.error("无法定位执行记录");return}const h=KJt(d,f.currentStepIndex,f.currentStepId);n(d.id);try{const g=Er.getState(),v=f.steps.length>0?f.steps:[d];g.setCurrentExecutionId(p),g.setExecutionSteps(x4e(v,p)),g.setLatestSSEEvent(null),r(),i(p),a(f.id),o(),c(`正在重新执行步骤:${d.title}`),await l(p,h),u()}catch(g){s(),Ze.error(Ai(g,"步骤重新执行失败"))}finally{n("")}},[i,o,s,e,c,l,t,u,r,a,n])}function XJt({isExecuting:e,rerunningRunId:t,reExecutingStepId:n,selectedAgentId:r,resolveRetryRunFormValues:i,resetLiveExecutionState:a,pendingExecutionTitleRef:o,setRerunningRunId:s,applyRetryValues:l,prepareRun:c,setSelectedWorkbenchStageKey:u,setExpandedWorkbenchStageKeys:d,notify:f}){return m.useCallback(async p=>{if(!(e||t||n)&&r&&Rw(p)){s(p.id);try{const h=await i(p);a(),o.current="",l(h),c(),u("params"),d(["params"]),f("已回填本次参数,确认后开始执行")}catch(h){Ze.error(Ai(h,"读取本次任务参数失败"))}finally{s("")}}},[l,e,f,o,c,n,a,i,t,r,d,s,u])}function ZJt({runInputFields:e,selectedAgentInputParams:t,getExecutionDetail:n,updateRun:r}){return m.useCallback(async i=>{let a=_c(i.inputValues)?i.inputValues:void 0;const o=Number(i.id);if(!a&&Number.isFinite(o)){const c=await n(o);a=Ej(c);const u=Tj(c,t);_c(a)&&r(i.id,d=>wee(d,a,u))}const s=TT(a)??i.inputValues??{};if(e.length===0)return _c(s)?{...s}:{};const l=o4e(e,{...i,inputValues:_c(s)?s:i.inputValues});return{...x1(e,l),...l,...lt(s)?s:{}}},[n,e,t,r])}function QJt({waitingInfo:e,waitingRun:t,waitingPreviewSteps:n,runPreviewSteps:r,selectedAgentId:i,setWaitingSubmitting:a,resumeExecution:o,clearExecutionDetail:s,advanceWaiting:l,clearWaiting:c,notify:u,refreshLiveRuns:d}){return m.useCallback(async f=>{if(!e||!t)return;const p=Number(t.id);if(!Number.isFinite(p)){Ze.error("无法定位执行记录");return}const h=t.steps.map(v=>({step_id:v.id})),g=f.action==="return_previous"?Rg(e,h):e.step_id;if(!g){Ze.error("无法定位需要继续的步骤");return}a(!0);try{const v=b4e(t,e,(n==null?void 0:n.runId)===t.id?n.steps:r),y=Er.getState();if(y.setCurrentExecutionId(p),y.setExecutionSteps(x4e(v.length>0?v:t.steps,p)),y.setExecutionProgress(v.length>0?Math.round(v.filter(w=>w.status==="completed").length/v.length*100):0),y.setLatestSSEEvent(null),await o(p,g,f.inputData,{action:f.action,confirmedInput:f.confirmedInput,modifiedParams:f.modifiedParams}),s(p),f.action==="return_previous"){const w=await I1(p,g);w?(l(w),u("已返回上一步,请继续处理")):(c(),u("已返回上一步")),i&&d();return}const x=Er.getState().latestSSEEvent;if((x==null?void 0:x.type)==="waiting_input"){const w=await I1(p,x.step_id);w?(l(w,t.id),u("执行已到下一处人工确认")):c()}else c(),f.action==="cancel"?u("执行已取消"):["execution_failed","step_failed","timeout"].includes((x==null?void 0:x.type)??"")?u("继续执行失败,请查看执行详情"):u("已提交,执行记录正在刷新");i&&d()}catch(v){Ze.error(Ai(v,"继续执行失败"))}finally{a(!1)}},[l,s,c,u,d,o,r,i,a,e,n,t])}function JJt({selectedAgentId:e,currentExecutionId:t,execution:n,executions:r,runForm:i,cockpit:a,recommendations:o,agentExecution:s,resetExecutionEvents:l,pendingExecutionTitleRef:c,recommendedExecutionRef:u,setActiveRunId:d,setDeletingExecutionId:f,setModal:p,inboxRunTransfer:h,setInboxRunTransfer:g,refreshInboxTransfers:v,loadAgents:y,waitingPreviewSteps:x,notify:w}){const S=wa(),_=Ll({...Bl.executions.delete(),onSuccess:(We,{executionId:Oe})=>Ys(S,{type:"execution-deleted",executionId:Oe,agentId:e??void 0},{refetchType:"none"})}),[C,$]=m.useState(""),[E,k]=m.useState(""),[T,I]=m.useState(void 0),P=m.useRef(!1),{phase:N,setWaitingRunId:A,setWaitingInfo:M,setWaitingLoading:R,setWaitingSubmitting:L,openDetailDrawer:z,openRunDrawer:j,beginWaiting:O,clearWaiting:V,resetExecution:B,cancelExecution:D,advanceWaiting:F,executionStarted:H,beginExecution:W,prepareRun:K,failExecution:U,setIdlePhase:q}=n,{runInputFields:Q,runFormValues:G,applyRetryValues:X,resetForExecution:J,getVisibleFields:Y,persistCurrentRunValues:Z,setInputSnapshot:re,clearInputSnapshot:ee}=i,{selectedAgent:te,isLiveAgent:oe,runPreviewSteps:fe,activeRun:he,waitingRun:ye,runParametersLoading:Te,isExecuting:Ee,historyPage:we}=a.state,{refreshHistory:le,changeHistoryPage:se,setSelectedWorkbenchStageKey:ne,setExpandedWorkbenchStageKeys:ge}=a.actions,{realRuns:be,setActiveRunSnapshot:Ce,loadExecutions:Ae,getExecutionDetail:je,clearExecutionDetail:ce,updateRun:de,removeRun:_e}=r,{load:Me,enable:Re,setActionId:Ie}=o,{startExecution:De,startRecommendedExecution:Ue,resumeExecution:nt,reExecuteStep:ct,acceptTransfer:ht,abort:Ve}=s,Ye=m.useCallback(()=>{Ve(),B(),l(),u.current=null;const We=Er.getState();We.setExecutionSteps([]),We.setExecutionProgress(0),We.setCurrentExecutionId(null),We.setLatestSSEEvent(null)},[Ve,u,B,l]),Se=m.useCallback(()=>{J(e),c.current="",A(""),M(null),R(!1),L(!1),ne("params")},[c,J,e,ne,M,R,A,L]),me=m.useCallback(()=>{Ee||(q(),Ye(),Se()),j(Ee),w(Ee?"执行过程正在更新":"确认参数后开始执行")},[Ee,w,j,Ye,Se,q]),pe=BJt({selectedAgent:te,setActiveRunId:d,beginWaiting:O,advanceWaiting:F,clearWaiting:V,setWaitingLoading:R,getExecutionDetail:je,updateRun:de,notify:w,getErrorMessage:Ai}),xe=QJt({waitingInfo:n.waitingInfo,waitingRun:ye,waitingPreviewSteps:x,runPreviewSteps:fe,selectedAgentId:e,setWaitingSubmitting:L,resumeExecution:(We,Oe,Xe,at)=>nt(We,Oe,Xe,at),clearExecutionDetail:ce,advanceWaiting:F,clearWaiting:V,notify:w,refreshLiveRuns:le}),Le=ZJt({runInputFields:Q,selectedAgentInputParams:te==null?void 0:te.input_params,getExecutionDetail:je,updateRun:de});function $e(){if(!oe||!e||N==="running")return;if(Te){w("正在读取运行参数");return}const We=Y(),Oe=We.filter(Pt=>Pt.required&&If(G[Pt.name]));if(Oe.length>0){Ze.warning(`请填写必填参数: ${Oe.map(Pt=>Pt.label||Pt.name).join(", ")}`);return}const Xe=We.map(Pt=>({field:Pt,error:aj(Pt)?LOe(G[Pt.name],Pt.address_validation):""})).find(Pt=>Pt.error);if(Xe){Ze.warning(`${Xe.field.label||Xe.field.name}: ${Xe.error}`);return}const at=Z(e,We),mt=tJt(at);c.current=mt??"",re(at),P.current=!1,Ye(),W();const ot=h;w(ot?"已承接流转结果,正在创建新的执行记忆":We.length>0?"已开始执行,参数会自动复用到再次执行":"已开始执行,这个智能体无需运行参数"),(ot?ht(ot.id,{action:"use_existing_agent",agent_id:e,input_data:at,create_execution_chain:!0,fan_out_enabled:!1}):De(e,at,{executionTitle:mt})).then(()=>{ot&&(g(null),v(),le())}).catch(Pt=>{P.current||(U(),Ze.error(Ai(Pt,ot?"承接流转执行失败":"执行失败")))})}const ze=XJt({isExecuting:Ee,rerunningRunId:C,reExecutingStepId:E,selectedAgentId:e,resolveRetryRunFormValues:Le,resetLiveExecutionState:Ye,pendingExecutionTitleRef:c,setRerunningRunId:$,applyRetryValues:X,prepareRun:K,setSelectedWorkbenchStageKey:ne,setExpandedWorkbenchStageKeys:ge,notify:w}),Qe=YJt({isExecuting:Ee,reExecutingStepId:E,setReExecutingStepId:k,resetExecutionEvents:l,clearExecutionDetail:ce,setActiveRunId:d,executionStarted:H,failExecution:U,reExecuteStep:ct,notify:w,refreshLiveRuns:le}),it=VJt({isExecuting:Ee,currentExecutionId:t,selectedAgentId:e,cancelledExecutionRef:P,abort:Ve,cancelExecution:D,resetLiveExecutionState:Ye,setActiveRunSnapshot:Ce,notify:w,refreshLiveRuns:le}),st=m.useCallback(async We=>{const Oe=Ud(We.resultId);if(Oe)return Oe;const Xe=Number(We.id);if(!Number.isFinite(Xe))return;const at=await je(Xe),mt=y4e(at);if(mt)return de(We.id,ot=>({...ot,resultId:mt})),Ud(mt)},[je,de]),Ft=m.useCallback(()=>{p(null),I(void 0)},[p]),Ne=m.useCallback(async We=>{if(We.status==="completed"){d(We.id),z();try{const Oe=await st(We);Oe||Ze.warning("当前执行记录缺少结果 ID,提交时无法流转"),I(Oe),p("share")}catch(Oe){Ze.error(Ai(Oe,"结果详情读取失败")),I(void 0),p("share")}}},[z,st,d,p]),ke=m.useCallback(We=>{if(!e||We.recordId==null){Ze.error("缺少执行记录ID,无法删除");return}const Oe=We.recordId,Xe=We.status==="running"||We.status==="waiting";rr.confirm({title:Xe?"取消并删除这条执行记录?":"删除这条执行记录?",content:Xe?"当前任务仍在进行。系统将先取消执行,再删除记录。":`删除「${We.title}」后,该记录将从执行历史中移除。`,okText:Xe?"取消并删除":"删除",cancelText:"保留",okButtonProps:{danger:!0},centered:!0,onOk:async()=>{f(Oe);try{await _.mutateAsync({executionId:Oe,cancelFirst:Xe}),_e(We.id),Xe&&t===Oe&&(Ve(),D());const at=FJt(we,be.length);se(at),await Ae(e,at),Ze.success("执行记录已删除")}catch(at){throw Ze.error(Ai(at,"删除执行记录失败")),at}finally{f(null)}}})},[Ve,D,se,t,_,we,Ae,be.length,_e,e,f]),Ke=m.useCallback(async We=>{try{await Re(We.id),await Me(te==null?void 0:te.market_template_id),await y(null,!1),Ze.success("已启用智能体")}catch(Oe){await Me(te==null?void 0:te.market_template_id),Ze.error(Ai(Oe,"启用推荐智能体失败"))}finally{Ie(null)}},[Re,y,Me,te==null?void 0:te.market_template_id,Ie]),Je=m.useCallback(async We=>{if(!he||he.status!=="completed"){Ze.warning("当前结果完成后才能执行推荐智能体");return}const Oe=await st(he);if(!Oe){Ze.warning("当前结果还在同步,请稍后再试");return}const Xe=`${We.name} · 推荐执行`;Ie(We.id),Ye(),u.current={templateId:We.id,templateName:We.name,agentId:We.my_agent_id},c.current=Xe,ee(),W(),w("已开始执行推荐智能体");try{await Ue(Oe,We.id,{inputData:{},executionTitle:Xe})}catch(at){u.current=null,U(),Ze.error(Ai(at,"推荐智能体执行失败"))}finally{Ie(null)}},[he,W,ee,U,w,c,u,Ye,st,Ie,Ue]);return{state:{rerunningRunId:C,reExecutingStepId:E,transferModalResultId:T},actions:{openRunDrawer:me,openWaitingRun:pe,submitWaitingInput:xe,rerunFailedExecution:ze,reExecuteFailedStep:Qe,startRun:$e,cancelCurrentExecution:it,closeTransferModal:Ft,openShareForRun:Ne,deleteExecutionRecord:ke,enableRecommendedTemplate:Ke,executeRecommendedTemplate:Je}}}const een=new Set(["re_executing","step_running","step_awaiting_async","step_pending_async","substep_running","substep_completed","step_completed","step_failed","waiting_input","execution_completed","execution_failed","timeout"]),ten=new Set(["execution_failed","step_failed","timeout"]);function nen(e){const t=e.type==="waiting_input",n=e.type==="execution_completed",r=ten.has(e.type),i=n||r;return{status:t?"waiting":n?"completed":r?"failed":"running",phase:t?"idle":n?"completed":r?"failed":"running",waitingStepId:t&&e.step_id||null,isWaiting:t,isTerminal:i,isTerminalFailure:r,shouldCaptureLiveTrace:een.has(e.type)}}function ren(e,t){return e.filter(n=>!$j(n)).map((n,r)=>{const i=IT(n),a=X2(i),o=a==="failed"?Cee(n.output_data):"",s=!!(t&&n.step_id===t),l=Array.isArray(n.substeps)?n.substeps.map(c=>({id:c.id||`${n.step_id||r}:${c.substep_index}`,title:Rc(c.substep_name)||`子步骤 ${c.substep_index}`,description:c.error||c.message||(c.duration_ms?`耗时 ${Math.round(Number(c.duration_ms)/1e3)} 秒`:""),event:c.status,status:X2(c.status)})):void 0;return{id:String(n.step_id||`step_${r+1}`),title:Rc(n.step_name)||`步骤 ${r+1}`,description:Hc("",o,n.business_status,n.duration_ms?`耗时 ${Math.round(Number(n.duration_ms)/1e3)} 秒`:""),event:i,humanConfirm:s||a==="waiting"||!!n.requires_human_confirm,humanConfirmTriggered:s||a==="waiting"||!!n.human_confirm_triggered,businessStatus:n.business_status??void 0,status:a,substeps:l,rawData:n}})}function Rye(e){return e==="running"?"执行中":e==="waiting"?"等待确认":e==="completed"?"已完成":e==="failed"?"执行失败":"待执行"}function ien(e){return e.filter(t=>!$j(t)).flatMap((t,n)=>{const r=Array.isArray(t.substeps)?t.substeps:[],i=X2(IT(t)),a=Rc(t.step_name)||`执行步骤 ${n+1}`,o=r.filter(d=>d.status==="completed").length,s=r.length>0?i==="running"?`已完成 ${o}/${r.length} 个子步骤`:`共 ${r.length} 个子步骤`:t.duration_ms?`耗时 ${Math.round(Number(t.duration_ms)/1e3)} 秒`:t.business_status||Rye(i),l=String(t.step_id||`step_${n+1}`),c={id:`step:${l}`,index:t.step_index??n,label:String(n+1),kind:"step",title:a,detail:s,status:i},u=r.map((d,f)=>{const p=X2(d.status),h=d.error||d.message||(d.duration_ms?`耗时 ${Math.round(Number(d.duration_ms)/1e3)} 秒`:Rye(p));return{id:`substep:${l}:${d.id||d.substep_index||f+1}`,index:d.substep_index??f,label:`${n+1}.${f+1}`,kind:"substep",title:Rc(d.substep_name)||`子步骤 ${f+1}`,detail:h,status:p}});return[c,...u]})}function aen({event:e,transition:t,executionSteps:n,runPreviewSteps:r}){const i=t.waitingStepId;return{nextSteps:n.length>0?ren(n,i):r.map((o,s)=>({...o,status:i&&s===0?"waiting":o.status,humanConfirm:i&&s===0?!0:o.humanConfirm,humanConfirmTriggered:i&&s===0?!0:o.humanConfirmTriggered})),nextStatus:t.status,nextStepError:Ai(e.error||e.error_message,"执行失败")}}function oen(e){const t=Er(r=>r.latestSSEEvent),n=m.useRef(e);n.current=e,m.useEffect(()=>{var O;if(!t)return;const{enabled:r,selectedAgent:i,currentExecutionId:a,executionSteps:o,runPreviewSteps:s,runInputData:l,recommendedExecutionRef:c,pendingExecutionTitleRef:u,shouldHandleWaiting:d,shouldHandleFinished:f,recordLiveTraceEvent:p,upsertRun:h,setActiveRunId:g,executionStarted:v,setIdlePhase:y,beginWaiting:x,setWaitingInfo:w,setWaitingLoading:S,clearExecutionDetail:_,setWaitingPreviewSteps:C,executionFinished:$,refreshLiveRuns:E,notify:k}=n.current;if(!r||!i)return;const T=c.current;if(!NJt(t,{selectedAgentId:i.id,recommendedAgentId:T==null?void 0:T.agentId}))return;T&&t.agent_id&&(c.current={...T,agentId:t.agent_id});const I=t.agent_id??i.id,P=((O=t.agent_name)==null?void 0:O.trim())||(T==null?void 0:T.templateName)||i.name,N=PJt(t,a);if(!N)return;const A=String(N),M=nen(t),{nextSteps:R,nextStatus:L,nextStepError:z}=aen({event:t,transition:M,executionSteps:o,runPreviewSteps:s}),j=new Date().toISOString();if(M.shouldCaptureLiveTrace&&o.length>0&&p({executionId:A,agentId:I,agentName:P,status:L,updatedAt:j,steps:ien(o)}),h(V=>oJt({event:t,existing:V.find(B=>B.id===A),eventExecutionId:N,eventAgentName:P,isRecommended:!!T,pendingExecutionTitle:u.current,runInputData:l,nextSteps:R,nextStatus:L,nextStepError:z,eventTime:j})),g(A),L==="running"&&v(),t.type==="waiting_input"){if(!d(A,t.step_id))return;const V=Sj(t),B=R.map(F=>({step_id:F.id}));y(),x(A),w({...V,return_step_id:Rg(V,B)});let D=!1;return I1(N,t.step_id).then(F=>{D||!F||w({...F,return_step_id:Rg(F,B)})}).catch(()=>{}).finally(()=>{D||S(!1)}),()=>{D=!0}}M.isTerminal&&f(t.type,A,t.result_id||t.error||t.error_message||"")&&(_(N),C(null),$(t.type==="execution_completed"?"completed":"failed"),E(),k(t.type==="execution_completed"?"执行完成,已进入详情":"执行失败,请查看详情"),c.current=null)},[t])}function LC(e,t){const n=rl(e),r=[],i=o=>{if(!lt(o))return;const s=lt(o.execution)?o.execution:{},l=lt(o.workflow)?o.workflow:{},c=lt(o.chain)?o.chain:{},u=lt(o.agent_config)?o.agent_config:{};r.push(o.steps,o.workflow_steps,o.execution_steps,o.playbooks,s.steps,s.workflow_steps,s.execution_steps,s.playbooks,l.steps,l.playbooks,c.steps,c.playbooks,u.steps,u.playbooks,lt(o.config)?o.config.steps:void 0,lt(o.agent)?o.agent.steps:void 0,lt(o.agent)?o.agent.playbooks:void 0,lt(o.custom_agent)?o.custom_agent.steps:void 0,lt(o.custom_agent)?o.custom_agent.playbooks:void 0,lt(o.detail)?o.detail.steps:void 0,lt(o.detail)?o.detail.playbooks:void 0)};i(n),i(e);const a=r.find(Array.isArray);return!Array.isArray(a)||a.length===0?[]:a.map((o,s)=>{const l=lt(o)?o:{},c=lt(l.playbook)?l.playbook:{},u=lt(l.workflow)?l.workflow:{},d=l.step_id??l.id??l.playbook_id??`step_${s+1}`,f=Rc(l.step_name,l.playbook_name,l.name,l.title,l.skill_name,c.name,u.name);return{id:String(d),title:f||(a.length===1?Rc(t):"")||`步骤 ${s+1}`,description:Rc(l.description,c.description,u.description)||"执行配置的流程",event:"pending",humanConfirm:!!(l.requires_human_confirm??l.requires_human_input??l.human_confirm),status:"pending"}})}function H0(e){return e.some(t=>!/^步骤 \d+$/.test(t.title))}function kee(e){return LC(e,e==null?void 0:e.name)}function EP(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function rF(e){if(typeof e=="number"&&Number.isFinite(e))return String(e);if(typeof e=="string"&&e.trim())return e.trim()}function sen(e,t=0){const n=EP(e)?e:{},r=EP(n.target_user)?n.target_user:{},i=EP(n.source_result)?n.source_result:{},a=EP(n.source_execution)?n.source_execution:{},o=rF(n.source_result_id??n.result_id??i.id??i.result_id),s=rF(n.source_execution_id??n.execution_id??a.id??a.execution_id);return{id:rF(n.id??n.transfer_code)??`transfer-${t}`,target:String(n.target_nickname??n.target_username??n.target_name??r.display_name??r.nickname??r.username??n.target_user_id??"接收人"),runId:s??o??"-",executionId:s,resultId:o,time:Mw(n.created_at)||"未知时间",status:String(n.status??"pending")}}function len(e,t){const n=new Set([t.id,t.resultId].filter(r=>!!r));return!!(e.executionId&&n.has(e.executionId))||!!(e.resultId&&n.has(e.resultId))||n.has(e.runId)}const cen={page:1,pageSize:100},uen={page:1,pageSize:24},iG=10,den={page:1,pageSize:100},fen={page:1,pageSize:50},pen={getAgents:NY,getAgentDetail:ggt,getMarketTemplates:Pgt,getMarketTemplateRecommendations:Agt,getExecutions:OH,getExecutionDetail:OEe,getResultDetail:Egt,getPendingTransfers:LEe,getSentTransfers:Igt};function hen(e){return{page:e.page,pageSize:e.pageSize,sceneId:e.sceneId,isTemplate:e.isTemplate}}function men(e){return{page:e.page,pageSize:e.pageSize,category:e.category,keyword:e.keyword}}function gen(e){return{agentId:e.agentId,page:e.page,pageSize:e.pageSize,status:e.status,statuses:Dye(e.statuses),businessStatuses:Dye(e.businessStatuses),triggerType:e.triggerType,startDate:e.startDate,endDate:e.endDate}}function Dye(e){if(!e)return;const t=e.map(n=>n.trim()).filter(Boolean);return t.length?Array.from(new Set(t)):void 0}function Oye(e){return{page:e.page,pageSize:e.pageSize}}function ven(e=pen){return{agents:{list:t=>{const n=hen(t);return{queryKey:Yn.agents.list(n),queryFn:async()=>{const r=await e.getAgents({page:n.page,page_size:n.pageSize,scene_id:n.sceneId,is_template:n.isTemplate});return B0(r)}}},detail:t=>{const n=t;return{queryKey:Yn.agents.detail(n),queryFn:()=>e.getAgentDetail(n)}}},market:{templates:{list:t=>{const n=men(t);return{queryKey:Yn.market.templates.list(n),queryFn:async()=>{const r=await e.getMarketTemplates({page:n.page,page_size:n.pageSize,category:n.category,keyword:n.keyword});return B0(r)}}}},recommendations:{byTemplate:t=>{const n=t;return{queryKey:Yn.market.recommendations.byTemplate(n),queryFn:async()=>{const r=await e.getMarketTemplateRecommendations({market_template_id:n});return B0(r)}}}}},executions:{list:t=>{const n=gen(t);return{queryKey:Yn.executions.list(n),queryFn:async()=>{const r=await e.getExecutions({agent_id:n.agentId,page:n.page,page_size:n.pageSize,status:n.status,"status[]":n.statuses,"business_status[]":n.businessStatuses,trigger_type:n.triggerType,start_date:n.startDate,end_date:n.endDate}),i=B0(r),a=hee(i.map(OJt));return{runs:a,total:gQt(r,a.length)}}}},detail:t=>{const n=t;return{queryKey:Yn.executions.detail(n),queryFn:()=>e.getExecutionDetail(n)}}},results:{detail:t=>{const n=t;return{queryKey:Yn.results.detail(n),queryFn:async()=>rl(await e.getResultDetail(n))}}},transfers:{sent:t=>{const n=Oye(t);return{queryKey:Yn.transfers.sent(n),queryFn:async()=>{const r=await e.getSentTransfers({page:n.page,page_size:n.pageSize});return B0(r).map(sen)}}},inbox:t=>{const n=Oye(t);return{queryKey:Yn.transfers.inbox(n),queryFn:async()=>{const r=await e.getPendingTransfers({page:n.page,page_size:n.pageSize});return B0(r)}}}}}}const bs=ven();function yen({enabled:e,selectedAgent:t,phase:n,runConfigAgentId:r,applyInputConfig:i,setRunPreviewStepItems:a,beginInputConfigLoading:o,onInputFieldsLoaded:s,notify:l,getErrorMessage:c}){const u=wa();m.useEffect(()=>{if(!e||!t||n==="running"||r===t.id)return;let d=!1;const f=h=>{d||i(t.id,h)},p=eG(t);return a(kee(t)),o(p),u.fetchQuery(bs.agents.detail(t.id)).then(h=>{if(d)return;const g=LC(h,t.name);g.length>0&&a(g);const v=eG(h);v.fields.length>0?(s(t.id,v.fields),f(v)):f(p)}).catch(h=>{d||(f(p),p.fields.length===0&&l(c(h,"运行参数读取失败")))}),()=>{d=!0}},[i,o,e,c,l,s,n,u,r,t,a])}function ben({enabled:e,isLiveAgent:t,activeRunId:n,realRuns:r,selectedAgent:i,selectedAgentName:a,selectedAgentInputParams:o,getExecutionDetail:s,updateRun:l,drawer:c,phase:u,activeRun:d,runPreviewStepItems:f,setRunPreviewStepItems:p,workspaceMode:h,waitingRunIdForPreview:g,waitingRunStatusForPreview:v,waitingRunSummaryForPreview:y,setWaitingPreviewSteps:x}){const w=wa();m.useEffect(()=>{if(!e||!t||!n)return;const S=r.find(E=>E.id===n),_=xee(S==null?void 0:S.params)||_c(S==null?void 0:S.inputValues);if(!S||_&&(S.resultId||S.status!=="completed"))return;const C=Number(S.id);if(!Number.isFinite(C))return;let $=!1;return s(C).then(E=>{if($)return;const k=y4e(E),T=Ej(E);if(!k&&!_c(T))return;const I=Tj(E,o);l(S.id,P=>{const N=k&&P.resultId!==String(k)?{...P,resultId:String(k)}:P;return wee(N,T,I)})}).catch(()=>{}),()=>{$=!0}},[n,e,s,t,r,o,l]),m.useEffect(()=>{if(!e||c!=="run"||!a||u==="running"||H0(f))return;const S=[d,r[0]].find($=>$&&Number.isFinite(Number($.id))),_=S?Number(S.id):null;if(!_)return;let C=!1;return s(_).then($=>{if(C)return;const E=LC($,a);E.length>0&&H0(E)&&p(E)}).catch(()=>{}),()=>{C=!0}},[d,c,e,s,u,r,f,a,p]),m.useEffect(()=>{if(!e||h!=="waiting"||!i||H0(f)&&f.length>1)return;let S=!1;const _=$=>$.length>0&&($.length!==f.length||$.some((E,k)=>{var T,I;return E.id!==((T=f[k])==null?void 0:T.id)||E.title!==((I=f[k])==null?void 0:I.title)})),C=kee(i);return _(C)&&p(C),w.fetchQuery(bs.agents.detail(i.id)).then($=>{if(S)return;const E=LC($,i.name);_(E)&&p(E)}).catch(()=>{}),()=>{S=!0}},[e,f,i,w,p,h]),m.useEffect(()=>{if(!e)return;if(h!=="waiting"||!t||!g){x(null);return}const S=Number(g);if(!Number.isFinite(S)){x(null);return}let _=!1;return x(C=>(C==null?void 0:C.runId)===g?C:null),s(S).then(C=>{if(_)return;const $=rl(C);if(!lt($))return;const E=lt($.execution)?$.execution:{},k=lt($.result)?$.result:{},T=Iee($),I=v==="waiting"?"waiting_input":v,P={...E,id:E.id??S,execution_id:E.execution_id??g,status:E.status??k.status??I,result_summary:k.result_summary??E.result_summary??y},N=l4e(T,P),A=LC($,a),M=N.length>0&&H0(N)?N:A;M.length>0&&H0(M)&&x({runId:g,steps:M}),N.length>0&&H0(N)&&l(g,R=>({...R,steps:N}))}).catch(()=>{}),()=>{_=!0}},[e,s,t,a,x,l,g,v,y,h])}function xen({runs:e,isLiveAgent:t,selectedAgentName:n,selectedAgentInputParams:r,setActiveRunId:i,openDetailDrawer:a,getExecutionDetail:o,clearExecutionDetail:s,updateRun:l}){return m.useCallback(async c=>{const u=e.find(f=>f.id===c);if(i(c),a(),!t)return;const d=Number(c);if(Number.isFinite(d)){Rw(u)&&s(d);try{const f=await o(d),p=rl(f);if(!lt(p))return;const h=lt(p.execution)?p.execution:{},g=lt(p.result)?p.result:{},v=Iee(p),y=g.id??g.result_id??h.result_id,x=Ej(p),w=m4e(g.result_data,g.output_data,g.final_output,h.result_data,h.output_data,p.output_data,p.result_data),S=s4e(v),_=(u==null?void 0:u.status)==="waiting"?"waiting_input":u==null?void 0:u.status,C=(u==null?void 0:u.status)==="completed"?"completed":h.status??g.status??_,$={...h,id:h.id??d,execution_id:h.execution_id??c,agent_name:h.agent_name??p.agent_name??n,status:C,result_summary:g.result_summary??h.result_summary,result_data:w,error_message:h.error_message??g.error_message??S},E=Eee(g.output_data,g.result_data,h.result_data,p.output_data,p.result_data),k=Tj(p,r),T=Tee(w,E,3),I=p4e(w,$,v),P=$T($.status),N=l4e(v,$),A=_ee(v),M=Ud(h.current_step_index)??(u==null?void 0:u.currentStepIndex);l(c,R=>{var L;return{...R,currentStepIndex:M??R.currentStepIndex,currentStepId:c4e(v,M)??R.currentStepId,resultId:y?String(y):R.resultId,title:((L=$.execution_title)==null?void 0:L.trim())||R.title,status:P,businessStatus:$.business_status??R.businessStatus,resultTitle:I.title||Hc(R.resultTitle,$.result_summary,$.error_message),summary:I.subtitle||(P==="completed"?"":ty($)),resultContent:I.content,resultPayload:I.payload,params:v4e($,x,y,k),inputValues:TT(x),steps:N,outputs:I.meta.length>0?I.meta:T.length>0?T:g4e($,A),detailData:I.detailData}})}catch{}}},[s,o,t,a,e,r,n,i,l])}function wen({enabled:e,activeRunId:t,agentsRef:n,setAgents:r,execution:i,executions:a,runForm:o,cockpit:s,recommendations:l,executionEvents:c,runPreviewStepItems:u,setRunPreviewStepItems:d,pendingExecutionTitleRef:f,recommendedExecutionRef:p,recordLiveTraceEvent:h,setActiveRunId:g,setWaitingPreviewSteps:v,notify:y}){const x=Er(ee=>ee.currentExecutionId),w=Er(ee=>ee.executionSteps),{drawer:S,phase:_,openDetailDrawer:C,executionStarted:$,setIdlePhase:E,beginWaiting:k,setWaitingInfo:T,setWaitingLoading:I,executionFinished:P}=i,{realRuns:N,getExecutionDetail:A,clearExecutionDetail:M,updateRun:R,upsertRun:L}=a,{runInputData:z,runConfigAgentId:j,beginInputConfigLoading:O,applyInputConfig:V}=o,{state:{selectedAgent:B,isLiveAgent:D,runPreviewSteps:F,runs:H,activeRun:W,waitingRunIdForPreview:K,waitingRunStatusForPreview:U,waitingRunSummaryForPreview:q,workspaceMode:Q},actions:{refreshHistory:G}}=s,{activate:X}=l,{shouldHandleWaiting:J,shouldHandleFinished:Y}=c,Z=xen({runs:H,isLiveAgent:D,selectedAgentName:B==null?void 0:B.name,selectedAgentInputParams:B==null?void 0:B.input_params,setActiveRunId:g,openDetailDrawer:C,getExecutionDetail:A,clearExecutionDetail:M,updateRun:R});ben({enabled:e,isLiveAgent:D,activeRunId:t,realRuns:N,selectedAgent:B,selectedAgentName:B==null?void 0:B.name,selectedAgentInputParams:B==null?void 0:B.input_params,getExecutionDetail:A,updateRun:R,drawer:S,phase:_,activeRun:W,runPreviewStepItems:u,setRunPreviewStepItems:d,workspaceMode:Q,waitingRunIdForPreview:K,waitingRunStatusForPreview:U,waitingRunSummaryForPreview:q,setWaitingPreviewSteps:v});const re=m.useCallback((ee,te)=>{r(oe=>{const fe=oe.map(he=>he.id===ee?{...he,input_params:te}:he);return n.current=fe,fe})},[n,r]);return yen({enabled:e,selectedAgent:B,phase:_,runConfigAgentId:j,applyInputConfig:V,setRunPreviewStepItems:d,beginInputConfigLoading:O,onInputFieldsLoaded:re,notify:y,getErrorMessage:Ai}),m.useEffect(()=>{X(e?B==null?void 0:B.market_template_id:null)},[X,e,B==null?void 0:B.market_template_id]),oen({enabled:D,selectedAgent:B,currentExecutionId:x,executionSteps:w,runPreviewSteps:F,runInputData:z,recommendedExecutionRef:p,pendingExecutionTitleRef:f,shouldHandleWaiting:J,shouldHandleFinished:Y,recordLiveTraceEvent:h,upsertRun:L,setActiveRunId:g,executionStarted:$,setIdlePhase:E,beginWaiting:k,setWaitingInfo:T,setWaitingLoading:I,clearExecutionDetail:M,setWaitingPreviewSteps:v,executionFinished:P,refreshLiveRuns:G,notify:y}),{currentExecutionId:x,openRun:Z}}const Sen={agentId:0,page:1,pageSize:iG};function Lye(e,t){return(e==null?void 0:e.agentId)===t.agentId&&e.page===t.page&&e.pageSize===t.pageSize}function _en({enabled:e,selectedAgentIdRef:t}){var C,$;const n=wa(),[r,i]=m.useState(null),[a,o]=m.useState(null),s=m.useRef(null),l=m.useMemo(()=>bs.executions.list(a??Sen),[a]),c=mf({...l,enabled:e&&a!==null}),u=((C=c.data)==null?void 0:C.runs)??[],d=(($=c.data)==null?void 0:$.total)??0,f=m.useCallback(E=>{const k={agentId:E.agentId,page:E.page,pageSize:E.pageSize},T=!Lye(s.current,k);s.current=k,T&&i(null),o(I=>Lye(I,k)?I:k)},[]),p=m.useCallback((E,k=1)=>{f({agentId:E,page:k,pageSize:iG})},[f]),h=m.useCallback(E=>{const k=s.current;if(!k)return;const T=bs.executions.list(k);n.setQueryData(T.queryKey,E)},[n]),g=m.useCallback(E=>n.fetchQuery(bs.executions.detail(E)),[n]),v=m.useCallback(E=>{if(E==null){n.removeQueries({queryKey:Yn.executions.details});return}n.removeQueries({queryKey:Yn.executions.detail(E),exact:!0})},[n]),y=m.useCallback((E,k)=>{h(T=>{if(!T)return T;const I=jJt(T.runs,E,k);return I===T.runs?T:{...T,runs:I}})},[h]),x=m.useCallback((E=!1)=>{i(null);const k=E?t.current:null;if(k!=null){p(k);return}s.current=null,o(null)},[p,t]),w=m.useCallback(E=>{h(k=>{if(!k)return k;const T=zJt(k.runs,E);return T===k.runs?k:{runs:T,total:Math.max(0,k.total-1)}}),i(k=>(k==null?void 0:k.id)===E?null:k)},[h]),S=m.useCallback(E=>{h(k=>{const T=(k==null?void 0:k.runs)??[],I=E(T),P=T.some(A=>A.id===I.id),N=LJt(T,I);return{runs:N,total:k?k.total+(P?0:1):N.length}})},[h]),_=m.useCallback(async(E,k=1)=>{const T={agentId:E,page:k,pageSize:iG};f(T);try{const I=await n.fetchQuery({...bs.executions.list(T),staleTime:0});return t.current===E?I.runs:[]}catch{return[]}},[f,n,t]);return{realRuns:u,activeRunSnapshot:r,setActiveRunSnapshot:i,historyTotal:d,historyLoading:e&&a!==null&&c.isFetching,historyError:c.error?Ai(c.error,"加载执行历史失败"):"",loadExecutions:_,activateHistory:p,getExecutionDetail:g,clearExecutionDetail:v,updateRun:y,upsertRun:S,resetHistory:x,removeRun:w}}function Cen({embedded:e,view:t,setView:n,selectedAgentName:r,agentsCount:i,agentsError:a,pendingInboxCount:o,openInbox:s,reloadAgents:l,setDrawer:c,setModal:u,notify:d,onHeaderChange:f,onCockpitExit:p}){const[h,g]=m.useState(!1),v=m.useCallback(()=>{if(!r){Ze.info("请先选择一个智能体");return}g(!0)},[r]),y=m.useCallback(()=>{g(!1),l()},[l]),x=m.useCallback(()=>{const C=Er.getState();C.resetForm(),C.setEditingAgent(null),C.setShowAgentDrawer(!0),d("开始创建自定义智能体")},[d]),w=m.useCallback(()=>{c(null),u(null),g(!1),n("market"),p==null||p()},[p,c,u,n]),S=m.useMemo(()=>b.jsxs("div",{className:"automation-header-actions",children:[b.jsx(or,{title:o>0?`收件箱 · ${o} 条待处理`:"收件箱",children:b.jsx(xv,{dot:o>0,children:b.jsx(Et,{className:"automation-header-icon-button",icon:b.jsx(Zg,{}),"aria-label":"收件箱",onClick:s})})}),b.jsx(or,{title:"创建智能体",children:b.jsx(Et,{className:"automation-header-icon-button",icon:b.jsx(Uo,{}),"aria-label":"创建智能体",onClick:x})})]}),[x,s,o]),_=m.useMemo(()=>t==="market"?{title:"自动化Beta",subtitle:"选择一个工作对象进入驾驶舱。",actions:S}:t==="inbox"?{title:"结果收件箱",subtitle:"查看同事转交的执行结果和后续处理入口",actions:b.jsx(Et,{icon:b.jsx(q$,{}),onClick:w,children:"返回智能体选择"})}:r?{title:r,subtitle:"切换阶段查看本次执行的参数、过程和结果",actions:b.jsx(Et,{icon:b.jsx(q$,{}),onClick:w,children:"返回智能体选择"})}:{title:a?"智能体列表读取失败":i>0?"请选择一个智能体":"还没有启用智能体",subtitle:a||(i>0?"从智能体中心选择一个智能体后,再进入驾驶舱运行。":"先到智能体中心启用一个模板,系统会创建用户专属智能体,再进入驾驶舱。")},[i,a,S,w,r,t]);return m.useEffect(()=>{e&&(f==null||f(_))},[e,_,f]),{state:{scheduleModalOpen:h},actions:{openScheduleModal:v,closeScheduleModal:y,returnToAgentSelection:w}}}const $en=0,Een=[];function Ten(){const e=wa(),[t,n]=m.useState(null),[r,i]=m.useState(null),a=m.useRef(null),o=m.useMemo(()=>bs.market.recommendations.byTemplate(t??$en),[t]),s=mf({...o,enabled:t!==null}),l=Ll({...Bl.market.enableRecommendedTemplate()}),c=m.useCallback(p=>{n(p||null)},[]),u=m.useCallback(p=>{a.current=p,i(p)},[]),d=m.useCallback(async p=>{if(!p)return c(null),[];c(p);try{return await e.fetchQuery({...bs.market.recommendations.byTemplate(p),staleTime:0})}catch{return[]}},[c,e]),f=m.useCallback(async p=>{if(a.current!==null)return;const h=t;u(p);try{const g=await l.mutateAsync(p);return await Ys(e,{type:"market-template-enabled",sourceTemplateId:h},{refetchType:"none"}),g}finally{u(null)}},[t,l,e,u]);return{templates:s.data??Een,loading:t!==null&&s.isFetching,actionId:r,setActionId:u,activate:c,load:d,enable:f}}const Ien=[];function ken({active:e}){const t=wa(),n=m.useMemo(()=>bs.transfers.sent(den),[]),r=mf({...n,enabled:e}),i=m.useCallback(o=>{t.setQueryData(n.queryKey,(s=[])=>typeof o=="function"?o(s):o)},[t,n.queryKey]),a=m.useCallback(async()=>{try{return await t.fetchQuery({...n,staleTime:0})}catch{return[]}},[t,n]);return{transfers:r.data??Ien,setTransfers:i,transfersLoading:e&&r.isFetching,loadTransfers:a}}const w4e={runInputFields:[],runInputGroups:[],runInputFormUi:{},runFormValues:{},runFormInstanceKey:0,rememberedRunGroupKeys:[],runSelectSearchValues:{},runTextDraftValues:{},runInputData:{},runConfigAgentId:null,runFormLoading:!1,runUploading:{},runFileNameMap:{}};function Pen(e,t){return typeof t=="function"?t(e):t}function Nen(e,t){switch(t.type){case"begin_config_loading":return{...e,runInputFields:t.config.fields,runInputGroups:t.config.formGroups,runInputFormUi:t.config.formUi,runFormLoading:!0};case"apply_config":return{...e,runInputFields:t.config.fields,runInputGroups:t.config.formGroups,runInputFormUi:t.config.formUi,runFormValues:t.values,rememberedRunGroupKeys:t.rememberedGroupKeys,runTextDraftValues:{},runConfigAgentId:t.agentId,runFormLoading:!1};case"replace_values":{const n=Pen(e.runFormValues,t.next);return n===e.runFormValues?e:{...e,runFormValues:n}}case"update_field":return{...e,runFormValues:{...e.runFormValues,[t.name]:t.value}};case"update_text_draft":return e.runTextDraftValues[t.name]===t.value?e:{...e,runTextDraftValues:{...e.runTextDraftValues,[t.name]:t.value}};case"commit_text_field":{const n={...e.runTextDraftValues};return delete n[t.name],{...e,runTextDraftValues:n,runFormValues:{...e.runFormValues,[t.name]:t.value}}}case"update_select_search":{const n=e.runSelectSearchValues[t.name];if(!t.value&&n&&!t.allowEmpty)return e;if(!t.value){if(!n)return e;const r={...e.runSelectSearchValues};return delete r[t.name],{...e,runSelectSearchValues:r}}return n===t.value?e:{...e,runSelectSearchValues:{...e.runSelectSearchValues,[t.name]:t.value}}}case"set_input_snapshot":return{...e,runInputData:t.values};case"apply_retry_values":return{...e,runInputData:{},runFormValues:t.values,runTextDraftValues:{},runSelectSearchValues:{},runFormInstanceKey:e.runFormInstanceKey+1};case"set_remembered_group_keys":return{...e,rememberedRunGroupKeys:t.groupKeys};case"reset_execution":return{...e,runFormValues:t.values,rememberedRunGroupKeys:t.rememberedGroupKeys,runTextDraftValues:{},runInputData:{},runSelectSearchValues:{},runUploading:{},runFileNameMap:{},runFormInstanceKey:e.runFormInstanceKey+1};case"reset_agent":return{...w4e,runFormInstanceKey:e.runFormInstanceKey};case"set_uploading":return{...e,runUploading:{...e.runUploading,[t.fieldName]:t.uploading}};case"remember_file_name":return{...e,runFileNameMap:{...e.runFileNameMap,[t.url]:t.name}}}}function Aen(){const[e,t]=m.useReducer(Nen,w4e),n=m.useRef({}),{runInputFields:r,runInputGroups:i,runInputFormUi:a,runFormValues:o,runFormInstanceKey:s,rememberedRunGroupKeys:l,runSelectSearchValues:c,runTextDraftValues:u,runInputData:d,runConfigAgentId:f,runFormLoading:p,runUploading:h,runFileNameMap:g}=e,v=m.useCallback(R=>{t({type:"replace_values",next:R})},[]),y=m.useCallback((R,L)=>{t({type:"update_field",name:R,value:L})},[]),x=m.useCallback((R,L)=>{t({type:"update_text_draft",name:R,value:L})},[]),w=m.useCallback((R,L)=>{t({type:"commit_text_field",name:R,value:L})},[]),S=m.useCallback(R=>{n.current[R]=!0},[]),_=m.useCallback((R,L)=>{const z=n.current[R]===!0;n.current[R]=!1,t({type:"update_select_search",name:R,value:L,allowEmpty:z})},[]),C=m.useCallback((R,L)=>async({file:z,onSuccess:j,onError:O})=>{var V,B,D;t({type:"set_uploading",fieldName:R,uploading:!0});try{const F=z,H=await Sy(F),W=(V=H==null?void 0:H.data)==null?void 0:V.url,K=((B=H==null?void 0:H.data)==null?void 0:B.name)||F.name||(W==null?void 0:W.split("/").pop())||"未知文件";if(!W)throw new Error(((D=H==null?void 0:H.data)==null?void 0:D.message)||"上传失败");t({type:"remember_file_name",url:W,name:K}),L<=1?y(R,W):v(U=>{const q=Array.isArray(U[R])?U[R]:U[R]?[U[R]]:[];return{...U,[R]:[...q,W]}}),j==null||j(H),Ze.success("上传成功")}catch(F){O==null||O(F instanceof Error?F:new Error(Ai(F,"文件上传失败"))),Ze.error(Ai(F,"文件上传失败"))}finally{t({type:"set_uploading",fieldName:R,uploading:!1})}},[v,y]),$=m.useCallback(R=>{t({type:"begin_config_loading",config:R})},[]),E=m.useCallback((R,L)=>{const z=Tye(R,L.fields,L.formGroups);t({type:"apply_config",agentId:R,config:L,values:x1(L.fields,z.values),rememberedGroupKeys:z.groupKeys})},[]),k=m.useCallback(R=>{const L=R?Tye(R,r,i):{values:{},groupKeys:[]};n.current={},t({type:"reset_execution",values:x1(r,L.values),rememberedGroupKeys:L.groupKeys})},[r,i]),T=m.useCallback(()=>{n.current={},t({type:"reset_agent"})},[]),I=m.useCallback((R=r,L=o)=>t4e(R,L),[o,r]),P=m.useCallback((R,L=I())=>{const z=BOe(L,o),j=XQt(R,L,i,z);return t({type:"set_remembered_group_keys",groupKeys:j}),z},[I,o,i]),N=m.useCallback(R=>{t({type:"set_input_snapshot",values:R})},[]),A=m.useCallback(()=>{t({type:"set_input_snapshot",values:{}})},[]),M=m.useCallback(R=>{n.current={},t({type:"apply_retry_values",values:R})},[]);return{runInputFields:r,runInputGroups:i,runInputFormUi:a,runFormValues:o,runFormInstanceKey:s,rememberedRunGroupKeys:l,runSelectSearchValues:c,runTextDraftValues:u,runInputData:d,runConfigAgentId:f,runFormLoading:p,runUploading:h,runFileNameMap:g,replaceRunFormValues:v,updateRunField:y,updateRunTextDraftField:x,commitRunTextField:w,allowEmptyRunSelectSearch:S,updateRunSelectSearch:_,handleRunFileUpload:C,beginInputConfigLoading:$,applyInputConfig:E,resetForExecution:k,getVisibleFields:I,persistCurrentRunValues:P,setInputSnapshot:N,clearInputSnapshot:A,applyRetryValues:M,resetForAgent:T}}function S4e(e){var r,i;if(e.status!=="completed"||!e.humanConfirmTriggered||!lt(e.rawData))return null;const t=Sj(e.rawData);return!((r=t.confirm_fields)!=null&&r.length||(i=t.input_fields)!=null&&i.length||ni(t.output)||ni(t.input)||ni(t.submitted_input))?null:{...t,message:t.message||e.title,actions:["readonly"]}}function Men(e){return e==="running"?"执行中":e==="waiting"?"等待确认":e==="completed"?"已完成":e==="failed"?"执行失败":"待执行"}function Ren(e){const t=e.replace(/^\[[^\]]+\]\s*/,"").trim();return t?`AI 正在生成 ${t}`:"AI 正在生成内容"}function Den(e){var n,r;const t=(r=(n=e.description)==null?void 0:n.match(/\b\d{1,2}:\d{2}\b/))==null?void 0:r[0];return t||(e.status==="running"?"进行中":e.status==="waiting"?"待确认":e.status==="failed"?"执行失败":"")}function Oen({workspaceMode:e,isExecuting:t,phase:n,activeRun:r,activeRunFailed:i,runPreviewSteps:a,waitingRun:o,waitingInfo:s,waitingPreviewSteps:l,selectedWorkbenchStageKey:c}){return m.useMemo(()=>{const u=l&&l.runId===(o==null?void 0:o.id)?l.steps:[],d=b4e(o??void 0,s,u.length>0?u:a),f=e==="run"?a:e==="waiting"?d:(r==null?void 0:r.steps)??[],p=d.length>0?`step:${d[WJt(d)].id}`:"params",h=f.findIndex(P=>P.status==="failed"||P.status==="waiting"||P.status==="running"),g=f.reduce((P,N,A)=>N.status==="completed"?A:P,-1),v=h>=0?h:Math.max(0,g),y=f[v]?`step:${f[v].id}`:"params",x=e==="run"?n==="completed":(r==null?void 0:r.status)==="completed",w=P=>!!x||(e==="run"&&n==="idle"?!1:P<=v),S=e==="run"?n==="idle"?"params":x?"complete":y:e==="waiting"?p:x?"complete":y,_=["params",...f.flatMap((P,N)=>w(N)?[`step:${P.id}`]:[]),...x?["complete"]:[]],C=_.includes(c)?c:S,$=C.startsWith("step:")?f.find(P=>`step:${P.id}`===C):void 0,E=!!($&&S4e($)),k=e==="run"&&!t?"running":"completed",T=x?i?"failed":"completed":"pending",I=[{key:"params",kind:"params",title:e==="run"?"新建任务":"运行参数",eyebrow:"执行参数",description:e==="run"?"填写必要字段,参数会随执行记录保存。":"查看这次执行实际使用的输入。",status:k,accessible:!0},...f.map((P,N)=>({key:`step:${P.id}`,kind:"step",title:P.title,eyebrow:`执行步骤 ${N+1}`,description:P.status==="failed"?"流程已在当前步骤停止。":P.description||"执行智能体配置的流程。",status:P.status,accessible:w(N),step:P})),{key:"complete",kind:"complete",title:x?"查看结果":"提交 · 查看结果",eyebrow:"执行完成",description:x?"查看最终结果和流转记录。":"所有执行步骤结束后,这里会展示最终结果。",status:T,accessible:x}];return{waitingSteps:d,workbenchSteps:f,waitingActiveStageKey:p,currentWorkbenchStepIndex:v,currentExecutionStageKey:y,workbenchIsCompleted:x,canOpenWorkbenchStep:w,defaultWorkbenchStageKey:S,accessibleWorkbenchStageKeys:_,activeWorkbenchStageKey:C,selectedWorkbenchStep:$,selectedWorkbenchStepHasConfirmPreview:E,workbenchFlowStages:I}},[r,i,t,n,a,c,s,l,o,e])}function Len({agentKind:e,activeRunId:t,workspaceMode:n,defaultStageKey:r,accessibleStageKeys:i,activeStageKey:a,expandedStageKeys:o,setSelectedStageKey:s,setExpandedStageKeys:l,setTransitioning:c,stageContextRef:u,transitionTimerRef:d,switchTimerRef:f}){m.useEffect(()=>{const g=`${e}:${n}:${t}`,v=u.current!==g;u.current=g,s(r),l(y=>{if(v)return[r];const x=y.filter(w=>i.includes(w));return x.includes(r)?x:[...x,r]})},[i,t,e,r,l,s,u,n]);const p=m.useCallback(g=>{i.includes(g)&&(g===a&&o.includes(g)||(c(!0),s(g),l(v=>v.includes(g)?v:[...v,g]),f.current!=null&&(window.clearTimeout(f.current),f.current=null),d.current!=null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{c(!1),d.current=null},180)))},[i,a,o,l,s,c,f,d]),h=m.useCallback(g=>{f.current!=null&&(window.clearTimeout(f.current),f.current=null),d.current!=null&&(window.clearTimeout(d.current),d.current=null),c(!1),l(v=>v.filter(y=>y!==g))},[l,c,f,d]);return{selectStage:p,collapseStage:h}}const jen=[{key:"attention",label:"需要你处理"},{key:"running",label:"进行中"},{key:"completed",label:"已完成"}],zen={id:"",kind:"custom",name:"",source:"",description:"",status:"",schedule:"",nextRun:""};function Fen(e){return e?{id:String(e.id),kind:e.name.toLowerCase().includes("amazon")?"amazon":"custom",name:e.name,source:e.is_from_market?"来自智能体市场":e.origin_type==="from_transfer"?"来自结果流转":"自定义智能体",description:e.description||e.scene_name||"这个智能体已启用,可以运行、查看历史、配置定时任务。",status:e.status==="active"?"已启用":e.status==="draft"?"草稿可运行":"已归档",schedule:e.schedule_display||e.schedule_cron||"",nextRun:e.next_run_at?Mw(e.next_run_at):"暂无定时"}:zen}function Ben(e){return e?typeof e.has_schedule=="boolean"?e.has_schedule:!!(e.schedule_enabled||e.schedule_cron||e.next_run_at):!1}function Ven({runs:e,activeRunId:t,activeRunSnapshot:n}){return e.find(r=>r.id===t)??n??e[0]}function Hen(e,t){return(e==="schedule"?null:e)??((t==null?void 0:t.status)==="waiting"?"waiting":t?"detail":"run")}function Wen({runs:e,statusFilter:t,historyTotal:n,page:r,pageSize:i}){const a=hee(e),o=t==="all"?a:a.filter(d=>JU(d)===t),s=n,l=Math.max(1,Math.ceil(s/i)),c=Math.min(r,l),u=jen.map(d=>({...d,runs:o.filter(f=>JU(f)===d.key)})).filter(d=>d.runs.length>0);return{sortedRuns:a,filteredRuns:o,recordTotal:s,pageCount:l,activePage:c,groups:u}}const Uen=10;function Gen({view:e,agents:t,selectedAgentId:n,agentKind:r,realRuns:i,activeRunId:a,setActiveRunId:o,activeRunSnapshot:s,setActiveRunSnapshot:l,historyTotal:c,historyLoading:u,historyError:d,loadExecutions:f,activateHistory:p,deletingExecutionId:h,agentTransitionId:g,setAgentTransitionId:v,runFormLoading:y,runConfigAgentId:x,runPreviewStepItems:w,liveExecutionTraces:S,drawer:_,phase:C,transfers:$,waitingRunId:E,waitingInfo:k,waitingPreviewSteps:T}){const[I,P]=m.useState("all"),[N,A]=m.useState(1),[M,R]=m.useState("params"),[L,z]=m.useState(["params"]),[j,O]=m.useState(!1),V=m.useRef(""),B=m.useRef(null),D=m.useRef(""),F=m.useRef(null),H=m.useRef(null),W=m.useMemo(()=>t.find(Ie=>Ie.id===n)??null,[t,n]),K=m.useMemo(()=>Fen(W),[W]),U=!!W,q=m.useMemo(()=>w.length>0?w:kee(W),[w,W]),Q=i,G=m.useMemo(()=>Ven({runs:Q,activeRunId:a,activeRunSnapshot:s}),[a,s,Q]),X=m.useMemo(()=>Q.find(Ie=>Ie.id===E)??G,[G,Q,E]),J=Hen(_,G),Y=C==="running"||C==="review_content"||C==="review_submit"||C==="polling",Z=Rw(G),re=bQt(G),ee=m.useMemo(()=>G?$.filter(Ie=>len(Ie,G)):[],[G,$]),te=y||!!(U&&J==="run"&&W&&x!==W.id),oe=!!(e==="cockpit"&&W&&g===W.id),fe=m.useMemo(()=>S.find(Ie=>Ie.agentId===n&&Ie.steps.length>0)??null,[S,n]),he=m.useMemo(()=>(fe==null?void 0:fe.steps.filter(Ie=>Ie.kind==="substep"||Ie.id.startsWith("substep:")))??[],[fe]),ye=m.useMemo(()=>Wen({runs:Q,statusFilter:I,historyTotal:c,page:N,pageSize:Uen}),[N,I,c,Q]),{workbenchSteps:Te,waitingActiveStageKey:Ee,workbenchIsCompleted:we,defaultWorkbenchStageKey:le,accessibleWorkbenchStageKeys:se,activeWorkbenchStageKey:ne,selectedWorkbenchStepHasConfirmPreview:ge,workbenchFlowStages:be}=Oen({workspaceMode:J,isExecuting:Y,phase:C,activeRun:G,activeRunFailed:Z,runPreviewSteps:q,waitingRun:X,waitingInfo:k,waitingPreviewSteps:T,selectedWorkbenchStageKey:M}),{selectStage:Ce,collapseStage:Ae}=Len({agentKind:r,activeRunId:a,workspaceMode:J,defaultStageKey:le,accessibleStageKeys:se,activeStageKey:ne,expandedStageKeys:L,setSelectedStageKey:R,setExpandedStageKeys:z,setTransitioning:O,stageContextRef:D,transitionTimerRef:F,switchTimerRef:H}),je=`${r}:${n??""}`;m.useEffect(()=>{if(e==="cockpit"&&n){if(V.current!==je&&(V.current=je,N!==1)){A(1);return}p(n,N)}},[p,je,N,n,e]),m.useEffect(()=>{i.length!==0&&o(Ie=>{var De;return i.some(Ue=>Ue.id===Ie)?Ie:((De=i[0])==null?void 0:De.id)??""})},[i,o]),m.useEffect(()=>{if(!U||!a)return;const Ie=i.find(De=>De.id===a);Ie&&l(Ie)},[a,U,i,l]),m.useEffect(()=>{!n||g!==n||u||y||x!==n||v(null)},[g,u,x,y,n,v]),m.useEffect(()=>{if(he.length===0&&!(fe!=null&&fe.updatedAt))return;const Ie=B.current;if(!Ie)return;const De=window.requestAnimationFrame(()=>{Ie.scrollTop=Ie.scrollHeight});return()=>window.cancelAnimationFrame(De)},[he.length,fe==null?void 0:fe.updatedAt]),m.useEffect(()=>()=>{H.current!=null&&window.clearTimeout(H.current),F.current!=null&&window.clearTimeout(F.current)},[]);const ce=m.useCallback(Ie=>{P(Ie),A(1)},[]),de=m.useCallback(Ie=>{A(Ie)},[]),_e=m.useCallback(()=>{n&&f(n,N)},[N,f,n]),Me=m.useCallback(()=>{if(n){if(N===1){f(n,1);return}A(1)}},[N,f,n]);return{model:{agentName:K.name,transitionLoading:oe,history:{agentName:K.name,hasSchedule:Ben(W),mode:J,error:d,loading:u,filteredRunCount:ye.filteredRuns.length,runCount:Q.length,statusFilter:I,groups:ye.groups,recordTotal:ye.recordTotal,pagination:{page:ye.activePage,pageCount:ye.pageCount},deletingExecutionId:h,activeRunId:a},liveTrace:{active:fe,substeps:he,stepsRef:B},workbench:{mode:J,activeRunFailed:Z,activeStageKey:ne,waitingActiveStageKey:Ee,selectedStepHasConfirmPreview:ge}},state:{selectedAgent:W,agent:K,isLiveAgent:U,runPreviewSteps:q,runs:Q,activeRun:G,waitingRun:X,waitingRunIdForPreview:(X==null?void 0:X.id)??"",waitingRunStatusForPreview:X==null?void 0:X.status,waitingRunSummaryForPreview:X==null?void 0:X.summary,workspaceMode:J,runParametersLoading:te,isExecuting:Y,activeRunTransfers:ee,activeRunFailed:Z,canShareActiveRun:re,historyPage:N,workbenchSteps:Te,waitingActiveStageKey:Ee,workbenchIsCompleted:we,activeWorkbenchStageKey:ne,workbenchFlowStages:be,expandedWorkbenchStageKeys:L,workbenchStageTransitioning:j},actions:{changeHistoryStatusFilter:ce,changeHistoryPage:de,reloadHistory:_e,refreshHistory:Me,selectWorkbenchStage:Ce,collapseWorkbenchStage:Ae,setSelectedWorkbenchStageKey:R,setExpandedWorkbenchStageKeys:z}}}const qen=new Set(["string","text","textarea","url","boolean","number","integer","float","date","datetime","time","select","array","list","tags","multi_select","multiselect","file"]),jye=new Set(["segmented","source","address","daterange","datetimerange","timerange"]);function Ken(e){var n,r;const t=e.type.toLowerCase();return["string","text","textarea","url"].includes(t)&&!((n=e.enum)!=null&&n.length)&&!((r=e.options)!=null&&r.length)&&!e.options_from_skill}function _4e(e,t){const n=t.split(".")[0];return e.find(r=>r.name===t||r.name===n)}function Yen(e){var t;return(t=e.options)!=null&&t.length?e.options:(e.enum||[]).map(n=>({label:n,value:n}))}function zye(e,t,n=e){const r=Yen(t);r.length!==0&&(n.enum=r.map(i=>i.value),n.enumNames=r.map(i=>i.label))}function Xen(e,t,n){if(!t.options_from_skill)return;const r=aJ(t.options_params||{});e.options_from_skill=t.options_from_skill,e.options_params=t.options_params||{},e["x-options-blocking-dependencies"]=r.filter(i=>{var a;return((a=_4e(n,i))==null?void 0:a.required)??!0}),e["x-clear-on-options-change"]=!0}function Zen(e,t){var i,a;const n=e.type.toLowerCase(),r={title:e.label||e.name,...e.placeholder?{placeholder:e.placeholder}:{},...e.hint||e.description?{description:e.hint||e.description}:{},...e.default!==void 0?{default:e.default}:{},...(e.span??1)>1||["text","textarea","url","file"].includes(n)?{"x-full-width":!0}:{}};if(n==="boolean")r.type="boolean";else if(n==="integer")r.type="integer";else if(n==="number"||n==="float")r.type="number";else if(n==="date"||n==="datetime"||n==="time")r.type="string",r.widget=n,e.format&&(r["x-temporal-format"]=e.format),e.picker&&(r["x-temporal-picker"]=e.picker),e.show_time!==void 0&&(r["x-temporal-show-time"]=e.show_time);else if(n==="file"){const o=Math.max(e.max_files??1,1);o>1?(r.type="array",r.items={type:"string",format:"uri"},r.maxItems=o):(r.type="string",r.format="uri"),r.widget="file",r.file_type=e.file_type,r.max_files=o}else if(_C(n)){const o={type:"string"};r.type="array",r.items=o,zye(r,e,o)}else r.type="string",(n==="text"||n==="textarea"||n==="url")&&(r.widget="textarea"),zye(r,e);return(n==="select"||(i=e.enum)!=null&&i.length||(a=e.options)!=null&&a.length||e.options_from_skill)&&(r.widget="select"),Xen(r,e,t),r}function Qen(e){var t;for(const n of e){const r=n.type.toLowerCase(),i=oj(n);if(n.visible_when!==void 0)return"conditional-visibility";if(n.range||FOe(n)||aj(n)||jye.has(r)||jye.has(i))return"special-control";if(!qen.has(r))return"unsupported-type";if((t=n.file_templates)!=null&&t.length)return"file-templates"}for(const n of e)if(n.options_from_skill)for(const r of aJ(n.options_params||{})){const i=_4e(e,r);if(i&&Ken(i))return"draft-dependency"}}function Jen(e,t){return Object.fromEntries(e.map(n=>{const r=ET(n.remember_last)&&t.includes(n.key);return[n.key,{title:`${n.title.replace(/(已记住上次选择)$/,"")}${r?"(已记住上次选择)":""}`,description:n.description,propertyNames:n.fields,columns:Math.min(Math.max(n.columns??1,1),3)}]}))}function etn({fields:e,groups:t=[],rememberedGroupKeys:n=[]}){if(e.length===0)return{eligible:!1,reason:"missing-fields"};const r=Qen(e);if(r)return{eligible:!1,reason:r};const i=Object.fromEntries(e.map(s=>[s.name,Zen(s,e)])),a=e.filter(s=>s.required).map(s=>s.name);return{eligible:!0,schema:{type:"object",properties:i,...a.length?{required:a}:{},...t.length?{propertyGroups:Jen(t,n)}:{}},hasGroups:t.length>0}}function ttn({stepCount:e,isExecuting:t,runParametersLoading:n,onStartRun:r}){const i=t?"执行中":n?"读取参数":"直接开始执行";return b.jsxs("div",{className:"wandox-automation-direct-run",children:[b.jsxs("div",{className:"wandox-automation-direct-run__hero",children:[b.jsx("span",{className:"wandox-automation-direct-run__icon","aria-hidden":"true",children:b.jsx(Fc,{})}),b.jsxs("div",{className:"wandox-automation-direct-run__copy",children:[b.jsx("span",{className:"wandox-automation-direct-run__eyebrow",children:"直接执行"}),b.jsx("strong",{className:"wandox-automation-direct-run__title",children:"这个智能体无需填写运行参数"}),b.jsx("p",{className:"wandox-automation-direct-run__description",children:"系统会使用智能体默认配置运行,执行过程和最终结果会在当前页面持续更新。"})]}),b.jsx("span",{className:"wandox-automation-direct-run__badge",children:e>0?`${e} 个步骤`:"自动执行"})]}),b.jsxs("div",{className:"wandox-automation-direct-run__footer",children:[b.jsx("span",{className:"wandox-automation-direct-run__hint",children:"无需补充信息,开始后可在左侧历史记录中追踪本次运行。"}),b.jsxs("button",{type:"button",className:"automation-action-button automation-action-button--primary wandox-automation-direct-run__button",onClick:r,disabled:t||n,children:[b.jsx(Fc,{}),i]})]})]})}function Fye({status:e}){return b.jsx("span",{className:`automation-step-dot automation-step-dot--${e}`})}function ntn({value:e}){const t=u4e(e);if(!ni(t))return null;if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=Object.entries(t).filter(([r,i])=>!["execution_steps","output_fields_map","output_type"].includes(r)&&ni(i)).slice(0,16);return n.length===0?null:b.jsx("div",{className:"automation-detail-data-grid",children:n.map(([r,i])=>b.jsxs("div",{children:[b.jsx("span",{children:r}),b.jsx("pre",{children:Eye(i)})]},r))})}return b.jsx("pre",{className:"automation-detail-json",children:Eye(t)})}function rtn({steps:e,className:t}){return b.jsx("div",{className:["automation-mini-steps",t].filter(Boolean).join(" "),children:e.map(n=>{var r;return b.jsxs("div",{className:"automation-mini-step",children:[b.jsx(Fye,{status:n.status}),b.jsxs("div",{children:[b.jsx("span",{children:n.title}),(r=n.substeps)!=null&&r.length?b.jsx("div",{className:"wandox-automation-mini-substeps",children:n.substeps.map(i=>b.jsxs("div",{className:`wandox-automation-mini-substeps__item wandox-automation-mini-substeps__item--${i.status}`,children:[b.jsx(Fye,{status:i.status}),b.jsx("span",{children:i.title})]},i.id))}):null]})]},n.id)})})}function itn({run:e}){return b.jsx(rtn,{steps:e.steps})}function atn({run:e,isExecuting:t,rerunningRunId:n,reExecutingStepId:r,onRerun:i}){const a=n===e.id;return b.jsxs("div",{className:"wandox-automation-task-rerun",children:[b.jsxs("div",{className:"wandox-automation-task-rerun__copy",children:[b.jsx("strong",{children:"重新执行整个任务"}),b.jsx("span",{children:"沿用本次参数,确认后创建新的执行记录"})]}),b.jsxs("button",{type:"button",className:"automation-action-button automation-action-button--primary",onClick:()=>i(e),disabled:t||!!n||!!r,children:[b.jsx(yy,{}),a?"读取参数":"重新执行"]})]})}function otn({sender:e,isExecuting:t,onReturn:n}){return b.jsxs("div",{className:"wandox-inbox-run-context",children:[b.jsx("span",{className:"wandox-inbox-run-context__icon","aria-hidden":"true",children:b.jsx(Zg,{})}),b.jsxs("div",{className:"wandox-inbox-run-context__copy",children:[b.jsx("span",{className:"wandox-inbox-run-context__eyebrow",children:"承接流转结果"}),b.jsxs("strong",{className:"wandox-inbox-run-context__title",children:["来自 ",e||"同事"," 的执行结果"]}),b.jsx("p",{className:"wandox-inbox-run-context__description",children:"填写本次运行参数后,系统会创建新的执行记忆并保留流转来源。"})]}),!t&&b.jsx("button",{type:"button",className:"wandox-inbox-run-context__back",onClick:n,children:"返回收件箱"})]})}function stn({templates:e,loading:t,canExecute:n,actionTemplateId:r,onExecute:i,onEnable:a}){return t&&e.length===0?b.jsx("section",{className:"wandox-automation-recommendations",children:b.jsxs("div",{className:"wandox-automation-recommendations__empty",children:[b.jsx(vr,{size:"small"}),b.jsx("span",{children:"正在读取推荐智能体"})]})}):e.length===0?null:b.jsxs("section",{className:"wandox-automation-recommendations",children:[b.jsx("div",{className:"wandox-automation-recommendations__head",children:b.jsxs("div",{children:[b.jsx("h3",{children:"推荐下一步"}),b.jsx("p",{children:"基于当前执行结果继续处理。"})]})}),b.jsx("div",{className:"wandox-automation-recommendations__list",children:e.map(o=>{var f,p;const s=o.my_status||"not_enabled",l=r===o.id,c=r!==null,u=s==="disabled_by_offline",d=s==="enabled";return b.jsxs("article",{className:"wandox-automation-recommendation-card",children:[b.jsxs("div",{className:"wandox-automation-recommendation-card__main",children:[b.jsx("div",{className:"wandox-automation-recommendation-card__icon",children:o.icon?b.jsx("img",{src:o.icon,alt:""}):b.jsx(Fc,{})}),b.jsxs("div",{className:"wandox-automation-recommendation-card__content",children:[b.jsx("h4",{children:o.name}),o.description&&b.jsx("p",{children:o.description}),(o.category||((f=o.tags)==null?void 0:f.length))&&b.jsxs("div",{className:"wandox-automation-recommendation-card__tags",children:[o.category&&b.jsx("span",{children:o.category}),(p=o.tags)==null?void 0:p.slice(0,3).map(h=>b.jsx("span",{children:h},h))]})]})]}),b.jsx("div",{className:"wandox-automation-recommendation-card__action",children:u?b.jsx("button",{type:"button",className:"automation-action-button automation-action-button--compact",disabled:!0,children:"已下线"}):d?b.jsxs("button",{type:"button",className:"automation-action-button automation-action-button--primary automation-action-button--compact",disabled:!n||c,onClick:()=>i(o),children:[b.jsx(Fc,{}),l?"执行中":"使用当前结果执行"]}):b.jsxs("button",{type:"button",className:"automation-action-button automation-action-button--compact",disabled:c,onClick:()=>a(o),children:[b.jsx(Uo,{}),l?"启用中":"启用"]})})]},o.id)})})]})}function ltn({fields:e,values:t,readOnly:n,loading:r,readOnlyLoading:i,groups:a,rememberedGroupKeys:o,formInstanceKey:s,renderFieldLabel:l,getFormItemClassName:c,renderField:u}){if(r||n&&i&&e.length===0)return b.jsx(CT,{className:"automation-run-loading"});if(e.length===0)return b.jsxs("div",{className:"automation-no-params",children:[b.jsx(sY,{}),b.jsxs("div",{children:[b.jsx("strong",{children:n?"本次执行无需额外参数":"这个智能体无需填写运行参数"}),b.jsx("p",{children:n?"智能体使用默认配置进入执行步骤。":"点击开始执行后,系统会直接创建执行记录并进入流程。"})]})]});if(!n&&a.length>0){const d=new Map(e.map(f=>[f.name,f]));return b.jsx("div",{className:"automation-run-form-groups",children:a.map(f=>{const p=f.fields.map(v=>d.get(v)).filter(v=>!!v);if(p.length===0)return null;const h=Math.min(Math.max(f.columns??1,1),3),g=ET(f.remember_last)&&o.includes(f.key);return b.jsxs("section",{className:"automation-run-form-group-card",children:[b.jsxs("div",{className:"automation-run-form-group-card__head",children:[b.jsxs("strong",{className:"automation-run-form-group-card__title",children:[BQt(f),g&&b.jsx("span",{className:"automation-run-form-group-card__remembered",children:"(已记住上次选择)"})]}),f.description&&b.jsx("span",{className:"automation-run-form-group-card__description",children:f.description})]}),b.jsx(pn,{layout:"vertical",colon:!1,className:"automation-run-form automation-run-form--group-card",style:{gridTemplateColumns:`repeat(${h}, minmax(0, 1fr))`},children:p.map(v=>b.jsx(pn.Item,{label:l(v,!0),className:c(v),children:u(v,t,n)},v.name))},`${f.key}-${s}`)]},f.key)})})}return b.jsx(pn,{layout:"horizontal",colon:!1,labelAlign:"left",labelCol:{flex:"152px"},wrapperCol:{flex:1},className:`automation-run-form automation-run-form--live${n?" wandox-automation-run-form--readonly":""}`,children:e.map(d=>b.jsx(pn.Item,{label:l(d),className:c(d),children:u(d,t,n)},d.name))},n?"readonly-run-form":`editable-run-form-${s}`)}const ctn=m.forwardRef(function({hasGroups:t,presentation:n="sections",expandedGroupKeys:r,onExpandedGroupKeysChange:i,className:a,...o},s){const l=t&&n==="sections",c=t&&n==="collapse";return b.jsx(yje,{ref:s,...o,groupDisplay:n,groupAccordion:!1,destroyInactiveGroups:!1,expandedGroupKeys:c?r:void 0,onExpandedGroupKeysChange:c?i:void 0,formLayout:t?"vertical":"horizontal",formLabelAlign:t?void 0:"left",formLabelCol:t?void 0:{flex:"152px"},formWrapperCol:t?void 0:{flex:1},showArrayControls:!1,className:["wandox-automation-schema-form","wandox-automation-schema-run-form",l?"wandox-automation-schema-form--grouped":void 0,l?"wandox-automation-schema-run-form--grouped":void 0,c?"wandox-automation-schema-form--collapsible":void 0,c?"wandox-automation-schema-run-form--collapsible":void 0,a].filter(Boolean).join(" ")})});function utn({schema:e,value:t,hasGroups:n,formInstanceKey:r,onChange:i}){return b.jsx(ctn,{schema:e,value:t,formSize:"middle",onChange:i,loadOptions:$je,uploadFile:Eje,hasGroups:n,presentation:"sections"},`automation-schema-run-form-${r}`)}function C4e({children:e,tone:t="gray"}){return b.jsx("span",{className:`automation-badge automation-badge--${t}`,children:e})}function dtn(e){return e==="accepted"?"已接收":e==="rejected"?"已拒绝":e==="expired"?"已过期":e==="cancelled"?"已取消":"待查看"}function ftn(e){return e==="accepted"?"green":e==="rejected"?"red":e==="expired"||e==="cancelled"?"gray":"amber"}function ptn({transfer:e}){return b.jsxs("div",{className:"automation-transfer-item",children:[b.jsxs("div",{className:"automation-transfer-item__head",children:[b.jsx("strong",{children:e.target}),b.jsx(C4e,{tone:ftn(e.status),children:dtn(e.status)})]}),b.jsx("span",{className:"automation-transfer-item__meta",children:e.time})]})}function htn({transfers:e,emptyText:t}){return b.jsxs("section",{className:"automation-transfer-feed is-boxed",children:[b.jsxs("div",{className:"automation-panel-head compact",children:[b.jsxs("div",{children:[b.jsx("h3",{children:"流转记录"}),b.jsx("p",{children:"基于这一次执行结果。"})]}),b.jsx(C4e,{tone:"violet",children:`${e.length} 条`})]}),e.length>0?e.map(n=>b.jsx(ptn,{transfer:n},n.id)):b.jsxs("div",{className:"automation-transfer-item",children:[b.jsx("strong",{children:"暂无流转"}),b.jsx("span",{children:t})]})]})}const mtn=(...e)=>["automation-action-button",...e].filter(Boolean).join(" ");function gtn({model:e,actions:t}){const{completed:n,run:r,failed:i,running:a,hasResult:o,shareable:s,transfers:l,phase:c,mode:u,progress:{completedSteps:d,stepCount:f},result:{heading:p="执行结果",bodyPayload:h,summary:g="",showSummary:v=!1},content:{runningTransition:y,recommendedTemplates:x,runActions:w}}=e,{share:S}=t;if(!n){const _=i||c==="failed";return b.jsxs("section",{className:"wandox-automation-stage-panel wandox-automation-stage-panel--complete is-pending",children:[b.jsx("div",{className:"wandox-automation-stage-panel__head",children:b.jsxs("div",{children:[b.jsx("h3",{children:_?"本次执行未完成":u==="waiting"?"等待当前步骤处理":a?"执行正在进行":"等待开始执行"}),b.jsx("p",{children:_?"流程已在当前执行步骤停止。":u==="waiting"?"提交当前人工确认后,流程会继续运行并在这里生成结果。":"所有执行步骤结束后,这里会展示最终结果和流转记录。"})]})}),b.jsxs("div",{className:"wandox-automation-stage-empty wandox-automation-stage-empty--complete",children:[b.jsx(sY,{}),b.jsx("strong",{children:"完成结果将在流程结束后生成"}),b.jsx("span",{children:`${d}/${f} 个执行步骤已完成`})]})]})}return r?b.jsxs("div",{className:"wandox-automation-completion-stack",children:[b.jsxs("section",{className:`automation-result-summary${i?" is-failed":""}${a?" is-running":""}`,children:[(!i||a)&&b.jsx("div",{className:"automation-latest-head",children:b.jsx("h3",{className:"wandox-automation-result-heading",children:p})}),a?b.jsx("p",{children:"系统正在执行智能体流程,完成或需要人工确认后会自动更新。"}):v?b.jsx("p",{children:g}):null,a&&y,!a&&(r.resultPayload||r.resultContent)&&b.jsx("div",{className:"automation-result-content",children:b.jsx(Ci,{payload:h})}),!a&&!o&&b.jsxs("div",{className:"wandox-automation-stage-empty wandox-automation-stage-empty--result",children:[b.jsx("strong",{children:i?"本次执行未生成结果":"结果内容仍在生成"}),b.jsx("span",{children:r.summary||"查看各执行步骤了解当前进度。"})]}),!a&&!r.resultPayload&&r.outputs.length>0&&b.jsx("div",{className:"automation-output-grid",children:r.outputs.map(([_,C])=>b.jsxs("div",{children:[b.jsx("span",{children:_}),b.jsx("strong",{children:C})]},_))}),s&&b.jsx("div",{className:"wandox-automation-completion-actions",children:b.jsxs("button",{type:"button",className:mtn("automation-action-button--primary"),onClick:()=>S(r),children:[b.jsx(y2e,{}),"流转同事"]})})]}),!a&&x,s&&b.jsx(htn,{transfers:l,emptyText:"点击流转同事按钮发起协作。"}),u==="run"&&w]}):b.jsx("section",{className:"wandox-automation-stage-panel wandox-automation-stage-panel--complete",children:b.jsxs("div",{className:"wandox-automation-stage-empty wandox-automation-stage-empty--complete",children:[b.jsx(fa,{}),b.jsx("strong",{children:"暂无执行结果"}),b.jsx("span",{children:"开始执行后可在这里查看完成内容。"})]})})}function vtn({stage:e,workspaceMode:t,onSelectStage:n}){if(!e.accessible)return b.jsx("section",{className:"wandox-automation-stage-panel wandox-automation-stage-panel--collapsible wandox-automation-stage-panel--summary wandox-automation-stage-panel--pending",children:b.jsx("div",{className:"wandox-automation-stage-panel__head",children:b.jsx("div",{children:b.jsx("h3",{children:e.title})})})});const r=e.kind==="params"?t==="run"?"展开修改":"查看参数":"查看快照";return b.jsx("section",{className:"wandox-automation-stage-panel wandox-automation-stage-panel--collapsible wandox-automation-stage-panel--summary",children:b.jsxs("div",{className:"wandox-automation-stage-panel__head",children:[b.jsx("div",{children:b.jsx("h3",{children:e.title})}),b.jsx("button",{type:"button",className:"wandox-automation-stage-panel__toggle-button","aria-expanded":"false",onClick:()=>n(e.key),children:r})]})})}function ytn({workspaceMode:e,stages:t,activeStageKey:n,expandedStageKeys:r,transitioning:i,renderStageContent:a,onSelectStage:o}){if(e==="run"){const s=t.find(l=>l.kind==="params");return s?b.jsx("div",{className:"wandox-automation-run-panel",children:a(s,!1)}):null}return b.jsx("div",{className:"wandox-automation-flow",children:t.map((s,l)=>{const c=n===s.key,u=r.includes(s.key),d=["wandox-automation-flow__item",`wandox-automation-flow__item--${s.status}`,c?"is-selected":"",u?"is-expanded":"",s.accessible?"is-accessible":"is-disabled"].filter(Boolean).join(" "),f=["wandox-automation-flow__marker",`wandox-automation-flow__marker--${s.status}`,c?"is-selected":""].filter(Boolean).join(" ");return b.jsxs("div",{className:d,children:[b.jsx("span",{className:f,"aria-hidden":"true",children:s.status==="completed"?b.jsx(ff,{}):s.status==="failed"?b.jsx(ga,{}):l+1}),b.jsx("div",{className:"wandox-automation-flow__content",children:u?a(s,i&&c):b.jsx(vtn,{stage:s,workspaceMode:e,onSelectStage:o})})]},s.key)})})}function btn({workspaceMode:e,isTransitioning:t,showDirectRunPanel:n,formUi:r,historicalFields:i,historicalValues:a,historicalEmptyBody:o,runBody:s,inboxContext:l,renderFieldLabel:c,formatValue:u,stringifyValue:d,onCollapseStage:f}){const p=i.length===0?o:(()=>{const g=i.map(w=>{const S=a[w.name],_=u(w.name,S)||"-",C=typeof S=="string"?S:d(S);return{field:w,displayValue:_,isWideValue:Math.max(_.length,C.length)>44}}),v=g.filter(w=>!w.isWideValue),y=g.filter(w=>w.isWideValue),x=(w,S=!1)=>b.jsx(Tc.Item,{className:S?"wandox-automation-params-descriptions__item--wide":void 0,label:c(w.field),children:b.jsx("span",{className:`wandox-automation-params-descriptions__value${S?" wandox-automation-params-descriptions__value--wide":""}`,children:w.displayValue})},w.field.name);return b.jsxs("div",{className:"wandox-automation-params-descriptions-stack",children:[v.length>0&&b.jsx(Tc,{bordered:!1,className:"wandox-automation-params-descriptions",column:3,colon:!1,size:"small",children:v.map(w=>x(w))}),y.length>0&&b.jsx(Tc,{bordered:!1,className:"wandox-automation-params-descriptions wandox-automation-params-descriptions--wide",column:1,colon:!1,size:"small",children:y.map(w=>x(w,!0))})]})})(),h=e!=="run";return b.jsxs("section",{className:`wandox-automation-stage-panel wandox-automation-stage-panel--params${h?" wandox-automation-stage-panel--collapsible":""}${n?" wandox-automation-stage-panel--direct-run":""}`,children:[h?b.jsxs("div",{className:"wandox-automation-stage-panel__head",children:[b.jsx("div",{children:b.jsx("h3",{children:"运行参数"})}),b.jsx("button",{type:"button",className:"wandox-automation-stage-panel__toggle-button","aria-expanded":"true",onClick:()=>f("params"),children:"收起"})]}):b.jsx("div",{className:"wandox-automation-stage-panel__head",children:b.jsxs("div",{children:[b.jsx("h3",{children:r.title}),r.description&&b.jsx("p",{children:r.description})]})}),b.jsxs("div",{className:"wandox-automation-stage-panel__body",children:[l,t?b.jsx(CT,{className:"automation-workbench-stage-transition-body"}):e==="run"?s:p]})]})}const TP=(...e)=>["automation-action-button",...e.filter(Boolean)].join(" ");function xtn({model:e,actions:t}){const{formFooter:n=!1,footerNote:r,phase:i,executing:a,parametersLoading:o,visibleFieldCount:s,submitLabel:l,showDraft:c,draftLabel:u}=e,{openDetail:d,saveDraft:f,startRun:p,cancelExecution:h}=t,g=o?"读取参数":s===0?"直接开始执行":i==="failed"?"重新执行":a?"执行中":n?l:"开始执行";return b.jsxs("div",{className:`automation-workbench-inline-actions${n?" automation-workbench-inline-actions--form-footer":""}`,children:[n&&r&&b.jsx("span",{className:"automation-workbench-inline-actions__note",children:r}),b.jsx("div",{className:"automation-workbench-inline-actions__buttons",children:i==="completed"?b.jsx("button",{type:"button",className:TP("automation-action-button--primary"),onClick:d,children:"查看结果详情"}):b.jsxs(b.Fragment,{children:[a&&b.jsxs("button",{type:"button",className:TP("automation-action-button--danger"),onClick:h,children:[b.jsx(g2e,{}),"取消执行"]}),n&&c&&!a&&b.jsx("button",{type:"button",className:TP("automation-action-button--form-secondary"),onClick:f,children:u}),b.jsxs("button",{type:"button",className:TP("automation-action-button--primary",n&&"automation-action-button--form-primary"),onClick:p,disabled:a||o,children:[!n&&b.jsx(Fc,{}),g]})]})})]})}function $4e({status:e}){return b.jsx("span",{className:`automation-step-dot automation-step-dot--${e}`})}function wtn({step:e,activeRun:t,canReExecute:n,isExecuting:r,isReExecuting:i,onReExecute:a}){return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"wandox-automation-step-result wandox-automation-step-result--failed",children:b.jsx("p",{children:e.description||(t==null?void 0:t.summary)||"当前步骤执行失败。"})}),n&&t&&b.jsx("div",{className:"wandox-automation-step-actions",children:b.jsxs("button",{type:"button",className:"automation-action-button automation-action-button--primary",onClick:()=>a(e,t),disabled:r||i,children:[b.jsx(yy,{}),i?"重新执行中":"重新执行"]})})]})}function Stn({step:e}){var n;const t=(n=e.substeps)!=null&&n.length?e.substeps:[{id:`${e.id}-progress`,title:e.description||"正在处理当前步骤",event:e.event,status:"running"}];return b.jsxs("div",{className:"wandox-automation-running-step",children:[b.jsx("div",{className:"wandox-automation-running-step__list",children:t.map(r=>{const i=Den(r);return b.jsxs("div",{className:`wandox-automation-running-step__item wandox-automation-running-step__item--${r.status}`,children:[b.jsx($4e,{status:r.status}),b.jsxs("div",{className:"wandox-automation-running-step__copy",children:[b.jsx("strong",{children:r.title}),r.description&&b.jsx("span",{children:r.description})]}),i&&b.jsx("small",{children:i})]},r.id)})}),b.jsx("p",{className:"wandox-automation-running-step__hint",children:e.humanConfirm?"本步骤可能触发人工确认,实际状态会随执行进度更新。":"步骤正在后台执行,完成后会自动进入下一流程。"})]})}function _tn({step:e}){var t;return(t=e.substeps)!=null&&t.length?b.jsx("div",{className:"wandox-automation-substep-list",children:e.substeps.map(n=>b.jsxs("div",{className:`wandox-automation-substep-list__item wandox-automation-substep-list__item--${n.status}`,children:[b.jsx($4e,{status:n.status}),b.jsxs("div",{children:[b.jsx("strong",{children:n.title}),n.description&&b.jsx("span",{children:n.description})]}),b.jsx("small",{children:Men(n.status)})]},n.id))}):null}function Ctn({children:e,tone:t="gray"}){return b.jsx("span",{className:`automation-badge automation-badge--${t}`,children:e})}function $tn({step:e,waitingInfo:t,waitingLoading:n,waitingOnlyMissing:r,waitingSubmitting:i,activeRun:a,preview:o=!1,onWaitingOnlyMissingChange:s,onSubmitWaitingInput:l,onOpenWaitingRun:c}){const u=HJt(n,t);return b.jsxs("section",{className:"automation-drawer-section automation-waiting-panel wandox-automation-stage-panel--waiting",children:[b.jsxs("div",{className:"automation-panel-head compact",children:[b.jsx("div",{children:b.jsx("h3",{children:(t==null?void 0:t.message)||e.title||"需要人工确认"})}),b.jsx("div",{className:"automation-waiting-head-tools",children:b.jsx(Ctn,{tone:u||(t==null?void 0:t.timeout_minutes)!=null?"blue":"amber",children:u?"读取中":(t==null?void 0:t.timeout_minutes)!=null?`${t.timeout_minutes} 分钟内处理`:"待提交"})})]}),u?b.jsx(CT,{className:"automation-waiting-loading"}):t?b.jsx(see,{data:t,submitting:i,actionsPlacement:"bottom",showOnlyMissing:r,onShowOnlyMissingChange:s,hideFilterSummary:!0,hideTimeoutAlert:!0,hideStepText:!0,hideActions:o,disableBusinessEffects:o,executionFormLayout:!0,onSubmit:l}):b.jsxs("div",{className:"automation-waiting-empty",children:[b.jsx("span",{className:"automation-waiting-empty__icon",children:b.jsx(fa,{})}),b.jsxs("div",{className:"automation-waiting-empty__copy",children:[b.jsx("strong",{children:(a==null?void 0:a.status)==="waiting"?"确认表单待读取":"暂无待处理表单"}),b.jsx("p",{children:(a==null?void 0:a.status)==="waiting"?"读取后展示本步需要处理的字段。":"后端没有返回 waiting-input 内容,刷新执行记录后再查看。"})]}),(a==null?void 0:a.status)==="waiting"&&b.jsx("button",{type:"button",className:"automation-action-button automation-action-button--primary",onClick:()=>c(a),children:"读取确认表单"})]})]})}function Etn({model:e,actions:t,preview:n=!1}){const{step:r,transitioning:i=!1,waiting:{current:a,info:o,loading:s,onlyMissing:l,submitting:c},completedConfirmData:u,activeRun:d,executing:f,retry:{reExecutingStepId:p,rerunningRunId:h,canReExecute:g}}=e,{collapse:v,changeWaitingOnlyMissing:y,submitWaitingInput:x,openWaitingRun:w,reExecute:S}=t,_=`step:${r.id}`,C=r.status==="running";if(a)return b.jsx($tn,{step:r,waitingInfo:o,waitingLoading:s,waitingOnlyMissing:l,waitingSubmitting:c,activeRun:d,preview:n,onWaitingOnlyMissingChange:y,onSubmitWaitingInput:x,onOpenWaitingRun:w});const $=uJt(r),E=ni($),k=p===r.id;return b.jsxs("section",{className:`wandox-automation-stage-panel wandox-automation-stage-panel--step wandox-automation-stage-panel--collapsible wandox-automation-stage-panel--${r.status}${C?" wandox-automation-stage-panel--running-progress":""}${u?" wandox-automation-stage-panel--with-confirm-preview":""}`,children:[b.jsxs("div",{className:"wandox-automation-stage-panel__head",children:[b.jsx("div",{children:b.jsxs("h3",{className:C?"wandox-automation-running-step__title":void 0,children:[C&&b.jsx("span",{className:"wandox-automation-running-step__spinner","aria-hidden":"true"}),C?Ren(r.title):r.title]})}),b.jsx("button",{type:"button",className:"wandox-automation-stage-panel__toggle-button","aria-expanded":"true",onClick:()=>v(_),children:"收起"})]}),b.jsx("div",{className:"wandox-automation-stage-panel__body",children:i?b.jsx(CT,{className:"automation-workbench-stage-transition-body"}):b.jsxs(b.Fragment,{children:[r.status==="failed"?b.jsx(wtn,{step:r,activeRun:d,canReExecute:g,isExecuting:f||!!h,isReExecuting:k,onReExecute:S}):C?b.jsx(Stn,{step:r}):u?b.jsx("div",{className:"automation-step-confirm-preview",children:b.jsx(see,{data:u,actionsPlacement:"bottom",compact:!0,hideActions:!0,hideFilterToggle:!0,hideFilterSummary:!0,hideTimeoutAlert:!0,hideStepText:!0,disableBusinessEffects:n,executionFormLayout:!0,onSubmit:()=>{}})}):E?b.jsx("div",{className:"wandox-automation-step-output",children:b.jsx(Ci,{payload:$})}):b.jsx("div",{className:"wandox-automation-step-detail",children:b.jsxs("div",{children:[b.jsx("strong",{children:r.status==="completed"?"该步骤已完成":r.status==="waiting"?"该步骤等待人工处理":r.status==="running"?"该步骤正在执行":"该步骤等待执行"}),b.jsx("p",{children:r.humanConfirm?"本步骤配置了可能触发的人工确认。":"流程会自动进入后续步骤。"})]})}),!C&&b.jsx(_tn,{step:r})]})})]})}function Ttn({children:e,tone:t="gray"}){return b.jsx("span",{className:`automation-badge automation-badge--${t}`,children:e})}function Itn(e){const t=document.createElement("a");t.href=e.path,t.download=e.name,t.target="_blank",document.body.appendChild(t),t.click(),document.body.removeChild(t)}function ktn({cockpit:e,execution:t,runForm:n,recommendations:r,waitingOnlyMissing:i,setWaitingOnlyMissing:a,reExecutingStepId:o,rerunningRunId:s,inboxRunTransfer:l,inboxRunTransferSender:c,actions:u}){const{runInputFields:d,runInputGroups:f,runInputFormUi:p,runFormValues:h,runFormInstanceKey:g,rememberedRunGroupKeys:v,runSelectSearchValues:y,runTextDraftValues:x,runFormLoading:w,runUploading:S,runFileNameMap:_,replaceRunFormValues:C,updateRunField:$,updateRunTextDraftField:E,commitRunTextField:k,allowEmptyRunSelectSearch:T,updateRunSelectSearch:I,handleRunFileUpload:P,getVisibleFields:N,persistCurrentRunValues:A}=n,{phase:M,waitingInfo:R,waitingLoading:L,waitingSubmitting:z}=t,{templates:j,loading:O,actionId:V}=r,{selectedAgent:B,runPreviewSteps:D,activeRun:F,workspaceMode:H,runParametersLoading:W,isExecuting:K,activeRunTransfers:U,activeRunFailed:q,canShareActiveRun:Q,workbenchSteps:G,waitingActiveStageKey:X,workbenchIsCompleted:J,activeWorkbenchStageKey:Y,workbenchFlowStages:Z,expandedWorkbenchStageKeys:re,workbenchStageTransitioning:ee}=e.state,{collapseWorkbenchStage:te,selectWorkbenchStage:oe}=e.actions,fe=m.useMemo(()=>etn({fields:d,groups:f,rememberedGroupKeys:v}),[d,f,v]),he=sj(fe.eligible?[]:d,h,C),ye=new Set(d.map(Se=>Se.name)),Te=["store_account","product_sku","publish_mode"].every(Se=>ye.has(Se)),Ee=f.length>0,we={title:p.title||(Te?"新建刊登任务":"新建任务"),description:p.description||(Te?"填写产品信息后,AI 将自动生成 Listing 文案并完成亚马逊模版映射":Ee?"填写任务信息后,系统将自动执行后续流程":""),footerNote:p.footerNote||(Te?"两种来源拿到基本信息后,AI 统一做亚马逊模版映射,后续流程一致":Ee?"确认参数后,系统将按当前配置执行后续流程":""),submitLabel:p.submitLabel||(Te?"开始生成 Listing →":"开始执行 →"),draftLabel:p.draftLabel||"存为草稿",showDraft:p.showDraft??Ee},le=Se=>{if(Se.hint||Se.description)return Se.hint||Se.description;if(Te){if(Se.name==="category")return"决定亚马逊模版";if(Se.name==="source_skill")return"列表可扩展";if(Se.name==="competitor_refs")return"支持多个,回车添加"}},se=(Se,me=!1)=>{const pe=le(Se);return b.jsxs("span",{className:"wandox-automation-run-field-label",children:[b.jsxs("span",{children:[Se.label||Se.name,Se.required&&b.jsx("span",{className:"automation-required",children:"*"}),me&&pe&&b.jsxs("span",{className:"wandox-automation-run-field-label__inline-hint",children:["(",pe,")"]})]}),!me&&pe&&b.jsx(or,{title:pe,children:b.jsx("span",{className:"wandox-automation-run-field-label__hint","aria-label":`${Se.label||Se.name}说明`,children:b.jsx(ME,{})})})]})},ne=Se=>{var ze,Qe;const me=Se.type.toLowerCase(),pe=oj(Se),xe=["automation-run-form-item"],$e=!!!((ze=Se.enum)!=null&&ze.length||(Qe=Se.options)!=null&&Qe.length||Se.options_from_skill||["select","array","list","tags","segmented"].includes(me)||["select","segmented"].includes(pe))&&["textarea","text","url"].includes(me);return me==="file"&&xe.push("automation-run-form-item--file"),me==="file"&&zOe(Se.file_type)&&xe.push("automation-run-form-item--image"),($e||(Se.span??1)>1)&&xe.push("automation-run-form-item--wide"),xe.join(" ")},ge=(Se,me=h,pe=!1)=>b.jsx(KQ,{field:Se,value:me[Se.name],readOnly:pe,uploading:!!S[Se.name],fileNameMap:_,getOptionState:he.getFieldState,onChange:$,onUpload:P,onDownloadTemplate:Itn,draftValue:!pe&&Object.prototype.hasOwnProperty.call(x,Se.name)?x[Se.name]:void 0,onDraftChange:pe?void 0:E,onDraftCommit:pe?void 0:k,selectSearchValue:y[Se.name]||"",onSelectAllowEmptySearch:xe=>{T(xe)},onSelectSearchChange:I}),be=({fields:Se=d,values:me=h,readOnly:pe=!1}={})=>{const xe=t4e(Se,me),Le=pe?[]:KQt(xe,f);return!pe&&Se===d&&me===h&&!W&&fe.eligible&&fe.schema?b.jsx(utn,{schema:fe.schema,value:h,hasGroups:!!fe.hasGroups,formInstanceKey:g,onChange:C}):b.jsx(ltn,{fields:xe,values:me,readOnly:pe,loading:!pe&&W,readOnlyLoading:w,groups:Le,rememberedGroupKeys:v,formInstanceKey:g,renderFieldLabel:se,getFormItemClassName:ne,renderField:ge})},Ce=()=>be(),Ae=()=>b.jsx(ttn,{stepCount:D.length,isExecuting:K,runParametersLoading:W,onStartRun:u.startRun}),je=()=>!l||H!=="run"?null:b.jsx(otn,{sender:c,isExecuting:K,onReturn:u.returnToInbox}),ce=Se=>{var ze,Qe;const me=Se.steps.findIndex(it=>it.status==="running"||it.status==="waiting"),pe=me>=0?Se.steps[me]:Se.steps[0],xe=((ze=pe==null?void 0:pe.substeps)==null?void 0:ze.find(it=>it.status==="running"))??((Qe=pe==null?void 0:pe.substeps)==null?void 0:Qe[pe.substeps.length-1]),Le=Se.steps.filter(it=>it.status==="completed").length,$e=Se.steps.length||1;return b.jsxs("div",{className:"wandox-automation-running-state",children:[b.jsxs("div",{className:"wandox-automation-running-state__hero",children:[b.jsx("span",{className:"wandox-automation-running-state__pulse","aria-hidden":"true",children:b.jsx("span",{})}),b.jsxs("div",{children:[b.jsx("strong",{children:"生成中"}),b.jsx("p",{children:xe?`正在处理:${xe.title}`:pe?`正在处理:${pe.title}`:"正在创建执行记录"})]}),b.jsx(Ttn,{tone:"blue",children:`${Le}/${$e}`})]}),b.jsx(itn,{run:Se})]})},de=F?b.jsx(ntn,{value:F.detailData}):null,_e=!!(F!=null&&F.resultPayload||F!=null&&F.resultContent||de),Me=(F==null?void 0:F.status)==="running",Re=()=>{const Se=N();B!=null&&B.id&&A(B.id,Se),u.notify("草稿已保存,已记住启用记忆的分组")},Ie=(Se=!1)=>{const me=N().length;return b.jsx(xtn,{model:{formFooter:Se,footerNote:we.footerNote,phase:M,executing:K,parametersLoading:W,visibleFieldCount:me,submitLabel:we.submitLabel,showDraft:!!we.showDraft,draftLabel:we.draftLabel},actions:{openDetail:u.openDetail,saveDraft:Re,startRun:u.startRun,cancelExecution:u.cancelExecution}})},De=(Se=!1)=>{const me=d.length>0?d:((F==null?void 0:F.params)??[]).map(([$e],ze)=>({name:`history_param_${ze}`,label:$e,type:"string",required:!1})),pe=d.length>0?o4e(d,F):me.reduce(($e,ze,Qe)=>{var it;return $e[ze.name]=((it=F==null?void 0:F.params[Qe])==null?void 0:it[1])??"",$e},{}),xe=N(),Le=H==="run"&&!W&&xe.length===0;return b.jsx(btn,{workspaceMode:H,isTransitioning:Se,showDirectRunPanel:Le,formUi:we,historicalFields:me,historicalValues:pe,historicalEmptyBody:be({fields:me,values:pe,readOnly:!0}),runBody:Le?Ae():b.jsxs(b.Fragment,{children:[Ce(),Ie(!0)]}),inboxContext:je(),renderFieldLabel:se,formatValue:i4e,stringifyValue:zy,onCollapseStage:te})},Ue=(Se,me=!1)=>{const pe=S4e(Se),xe=`step:${Se.id}`,Le=H==="waiting"&&xe===X,$e=!!(F&&H!=="run"&&Rw(F));return b.jsx(Etn,{model:{step:Se,transitioning:me,waiting:{current:Le,info:R,loading:L,onlyMissing:i,submitting:z},completedConfirmData:pe,activeRun:F,executing:K,retry:{reExecutingStepId:o,rerunningRunId:s,canReExecute:$e}},actions:{collapse:te,changeWaitingOnlyMissing:a,submitWaitingInput:u.submitWaitingInput,openWaitingRun:u.openWaitingRun,reExecute:(ze,Qe)=>void u.reExecuteFailedStep(ze,Qe)}})},nt=()=>{if(!(B!=null&&B.market_template_id))return null;const Se=!!(F&&F.status==="completed"&&!q);return b.jsx(stn,{templates:j,loading:O,canExecute:Se,actionTemplateId:V,onExecute:me=>void u.executeRecommendedTemplate(me),onEnable:me=>void u.enableRecommendedTemplate(me)})},ct=()=>{const Se=Me?"生成中":_e&&nG(F==null?void 0:F.resultTitle)||"执行结果",me=f4e((F==null?void 0:F.resultPayload)??(F==null?void 0:F.resultContent),Se),pe=(F==null?void 0:F.summary.trim())??"",xe=!!(_e&&pe&&!/^(执行完成|已完成(?:\s*\d+\s*个步骤)?)$/.test(pe)&&pe!==Se);return b.jsx(gtn,{model:{completed:J,run:F,failed:q,running:Me,hasResult:_e,shareable:Q,transfers:U,phase:M,mode:H,progress:{completedSteps:G.filter(Le=>Le.status==="completed").length,stepCount:G.length},result:{heading:Se,bodyPayload:me,summary:pe,showSummary:xe},content:{runningTransition:F?ce(F):null,recommendedTemplates:nt(),runActions:Ie()}},actions:{share:Le=>void u.shareRun(Le)}})},ht=(Se,me=!1)=>Se.kind==="params"?De(me):Se.kind==="complete"?ct():Se.step?Ue(Se.step,me):null;return{renderWorkbenchFlow:()=>b.jsx(ytn,{workspaceMode:H,stages:Z,activeStageKey:Y,expandedStageKeys:re,transitioning:ee,renderStageContent:ht,onSelectStage:oe}),renderFailedTaskRerunAction:()=>H==="run"||!F||!q?null:b.jsx(atn,{run:F,isExecuting:K,rerunningRunId:s,reExecutingStepId:o,onRerun:()=>void u.rerunFailedExecution(F)})}}function aG(e){return e.transferred_nickname||e.transferred_username||e.transferred_by||"同事"}function Ij(e){return e.agent_name?`流转了「${e.agent_name}」的执行结果`:"流转了一份执行结果"}function Ptn(e){var n;const t=((n=e==null?void 0:e.transfer_message)==null?void 0:n.trim())??"";return t&&t!=="-"?t:""}function Ntn(e){return e?Ptn(e)||Ij(e):"暂无待处理结果"}function Atn(e){return e==="accepted"?"已接收":e==="rejected"?"已拒绝":"待处理"}function Mtn(e){return e==="accepted"?"completed":e==="rejected"?"failed":"waiting"}function Rtn(e){return Mw(e.created_at)||e.created_at||"未知时间"}function Dtn(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();if(r===n)return"今天";if(r===n-24*60*60*1e3)return"昨天";const i=`${Al(e.getMonth()+1)}/${Al(e.getDate())}`;return e.getFullYear()===t.getFullYear()?i:`${e.getFullYear()}/${i}`}function Otn(e){return{id:e.id,transfer:e,primaryText:Ntn(e),statusText:Atn(e.status),runStatus:Mtn(e.status),summary:Ij(e),time:Mw(e.created_at)||"未知时间"}}function Ltn(e){return e.map((t,n)=>({item:t,index:n,date:Xje(t.created_at)})).sort((t,n)=>{var r,i;return(((r=n.date)==null?void 0:r.getTime())??0)-(((i=t.date)==null?void 0:i.getTime())??0)||t.index-n.index}).reduce((t,n)=>{const r=n.date?yQt(n.date):"unknown",i=n.date?Dtn(n.date):"未知日期",a=Otn(n.item),o=t[t.length-1];return(o==null?void 0:o.key)===r?(o.items.push(a),t):(t.push({key:r,label:i,items:[a]}),t)},[])}function jtn({inboxProcessTransfer:e,agentsRef:t,loadAgents:n,setInboxProcessTransfer:r,setInboxRunTransfer:i,setRejectingTransferId:a,selectAgent:o,notify:s,resetAgentStoreForm:l,setAgentStoreFormName:c,setPendingTransferId:u,setShowAgentDrawer:d}){const f=wa(),p=Ll({...Bl.transfers.reject(),onSuccess:()=>Ys(f,{type:"transfer-rejected"})}),h=m.useCallback(async w=>{r(w),t.current.length===0&&await n(null,!1)},[t,n,r]),g=m.useCallback(w=>{const S=e;S&&(r(null),o(w),i(S),s("已进入承接任务配置"))},[e,s,o,r,i]),v=m.useCallback(w=>{r(null),l(),c(w.agent_name?`${w.agent_name}-处理`:""),u(w.id),d(!0)},[l,c,r,u,d]),y=m.useCallback(()=>{e&&v(e)},[v,e]),x=m.useCallback(w=>{rr.confirm({title:"拒绝这条流转?",content:Ij(w),okText:"拒绝",okButtonProps:{danger:!0},cancelText:"取消",centered:!0,onOk:async()=>{a(w.id);try{await p.mutateAsync(w.id),Ze.success("已拒绝")}catch(S){Ze.error(Ai(S,"操作失败"))}finally{a(null)}}})},[p,a]);return{executeInboxTransfer:h,continueInboxTransfer:g,createAgentFromInbox:v,createAgentFromInboxProcess:y,rejectInboxTransfer:x}}const ztn=0;function Ftn({view:e,activeTransfer:t}){const n=wa(),r=e==="inbox"?(t==null?void 0:t.source_result_id)??null:null,i=m.useMemo(()=>bs.results.detail(r??ztn),[r]),a=mf({...i,enabled:r!==null}),o=m.useCallback(async()=>{if(r===null)return null;try{return await n.fetchQuery({...bs.results.detail(r),staleTime:0})}catch{return null}},[n,r]);return{detail:a.data??null,loading:r!==null&&a.isFetching,error:a.error?Ai(a.error,"结果详情读取失败"):"",load:o}}const Btn=[];function Bye(e,t){Er.setState({transfers:e,transfersLoading:t})}function Vtn({active:e}){const t=wa(),n=m.useMemo(()=>bs.transfers.inbox(fen),[]),r=mf({...n,enabled:e}),i=r.data??Btn,a=e&&r.isFetching;m.useEffect(()=>{!e&&r.data===void 0||Bye(i,a)},[e,r.data,a,i]);const o=m.useCallback(async()=>{Er.setState({transfersLoading:!0});try{const s=await t.fetchQuery({...n,staleTime:0});return Bye(s,!1),s}catch{return Er.setState({transfersLoading:!1}),[]}},[n,t]);return{transfers:i,transfersLoading:a,loadTransfers:o}}function oG(e,t){return e.find(n=>n.id===t)??e[0]??null}function Htn(e,t){const n=oG(e,t);return{groups:Ltn(e),pendingCount:e.filter(r=>r.status==="pending").length,activeTransfer:n,active:n?{transfer:n,pending:n.status==="pending",sender:aG(n),time:Rtn(n)}:null}}function Wtn({view:e,agents:t,agentsLoading:n,agentsRef:r,loadAgents:i,selectAgent:a,notify:o,inboxRunTransfer:s,setInboxRunTransfer:l,setView:c,setDrawer:u,setModal:d,setAgentTransitionId:f}){const[p,h]=m.useState(null),[g,v]=m.useState(null),[y,x]=m.useState(null),{transfers:w,transfersLoading:S,loadTransfers:_}=Vtn({active:e==="inbox"}),C=Er(B=>B.resetForm),$=Er(B=>B.setFormName),E=Er(B=>B.setPendingTransferId),k=Er(B=>B.setShowAgentDrawer),T=m.useMemo(()=>Htn(w,p),[p,w]),I=Ftn({view:e,activeTransfer:T.activeTransfer}),{executeInboxTransfer:P,continueInboxTransfer:N,createAgentFromInbox:A,createAgentFromInboxProcess:M,rejectInboxTransfer:R}=jtn({inboxProcessTransfer:g,agentsRef:r,loadAgents:i,setInboxProcessTransfer:v,setInboxRunTransfer:l,setRejectingTransferId:x,selectAgent:a,notify:o,resetAgentStoreForm:C,setAgentStoreFormName:$,setPendingTransferId:E,setShowAgentDrawer:k});m.useEffect(()=>{e==="inbox"&&h(B=>{var D;return((D=oG(w,B))==null?void 0:D.id)??null})},[w,e]);const L=m.useCallback(()=>{_()},[_]),z=m.useCallback(()=>{c("inbox"),u(null),d(null),h(B=>{var D;return((D=oG(w,B))==null?void 0:D.id)??null})},[u,d,c,w]),j=m.useCallback(()=>{l(null),u(null),f(null),c("inbox")},[f,u,l,c]),O=m.useMemo(()=>({transferCount:w.length,loading:S,groups:T.groups,active:T.active,rejectingTransferId:y,result:{detail:I.detail,loading:I.loading,error:I.error},process:{transfer:g,agents:t,loading:n,sender:g?aG(g):"",summary:g?Ij(g):""}}),[t,n,I.detail,I.error,I.loading,g,T.active,T.groups,y,w.length,S]),V=m.useMemo(()=>({refresh:L,selectTransfer:h,process:P,createAgent:A,reject:R,retryResult:()=>{I.load()},closeProcess:()=>v(null),continueProcess:N,createAgentFromProcess:M}),[N,A,M,P,I.load,L,R]);return{model:O,state:{pendingCount:T.pendingCount,runTransferSender:s?aG(s):""},actions:{workspace:V,openInbox:z,refreshTransfers:L,returnToInboxFromTransfer:j}}}function Utn({active:e,agentsRef:t,selectedAgentIdRef:n,selectAgent:r,setSelectedAgentId:i,setActiveRunId:a,setView:o,resetHistory:s,setIdlePhase:l}){const c=wa(),u=m.useMemo(()=>bs.agents.list(cen),[]),d=m.useMemo(()=>bs.market.templates.list(uen),[]),f=mf({...u,enabled:e}),p=mf({...d,enabled:e}),h=f.data??[],g=p.data??[],v=m.useCallback((S,_,C=!1)=>{t.current=S,Er.setState({agents:S,agentsLoading:!1});const $=_?S.find(P=>P.id===_):null,E=n.current,k=E?S.find(P=>P.id===E):null,T=$||k||null;if(T&&($||C)&&r(T),T)return;n.current=null,i(null),s(),a(""),l();const I=Er.getState();I.setExecutionSteps([]),I.setExecutionProgress(0),I.setCurrentExecutionId(null),I.setLatestSSEEvent(null),o(P=>P==="inbox"?"inbox":"market")},[t,s,r,n,a,l,i,o]);m.useEffect(()=>{f.data&&v(f.data)},[f.data,v]);const y=m.useCallback(S=>{c.setQueryData(u.queryKey,(_=[])=>{const C=typeof S=="function"?S(_):S;return t.current=C,Er.setState({agents:C,agentsLoading:!1}),C})},[u.queryKey,t,c]),x=m.useCallback(async()=>{try{return await c.fetchQuery({...d,staleTime:0})}catch{return[]}},[d,c]),w=m.useCallback(async(S,_=!1,C=!1)=>{try{const $=await c.fetchQuery({...u,...C?{staleTime:0}:{}});return v($,S,_),$}catch{return t.current.length===0&&Er.setState({agents:[],agentsLoading:!1}),[]}},[u,t,c,v]);return{agents:h,setAgents:y,agentsLoading:h.length===0&&f.isFetching,agentsError:f.error?Ai(f.error,"加载智能体列表失败"):"",marketTemplates:g,marketLoading:p.isFetching,marketError:p.error?Ai(p.error,"加载市场模板失败"):"",loadAgents:w,loadMarketTemplates:x}}function Gtn(e){const t=[],n=new Map;for(const r of e)n.set(r.id,r),!r.is_template&&r.status==="active"&&t.push(r);return{availableAgents:t,agentById:n}}function qtn({active:e,agentsRef:t,selectedAgentIdRef:n,selectAgent:r,setSelectedAgentId:i,setActiveRunId:a,setView:o,resetHistory:s,setIdlePhase:l}){const c=wa(),u=Ll({...Bl.agents.delete(),onSuccess:(P,N)=>Ys(c,{type:"agent-deleted",agentId:N},{refetchType:"none"})}),d=Ll({...Bl.market.enableTemplate(),onSuccess:()=>Ys(c,{type:"market-template-enabled"},{refetchType:"none"})}),f=d.isPending?d.variables??null:null,p=u.isPending?u.variables??null:null,{agents:h,setAgents:g,agentsLoading:v,agentsError:y,marketTemplates:x,marketLoading:w,marketError:S,loadAgents:_,loadMarketTemplates:C}=Utn({active:e,agentsRef:t,selectedAgentIdRef:n,selectAgent:r,setSelectedAgentId:i,setActiveRunId:a,setView:o,resetHistory:s,setIdlePhase:l}),{availableAgents:$}=m.useMemo(()=>Gtn(h),[h]),E=m.useCallback(P=>{const N=P.is_from_market?"移除":"删除";rr.confirm({title:`${N}「${P.name}」?`,content:P.is_from_market?"移除后可从市场重新启用。":"删除后需要重新创建。",okText:N,cancelText:"取消",okButtonProps:{danger:!0},onOk:async()=>{try{await u.mutateAsync(P.id),Ze.success(`智能体已${N}`),n.current===P.id&&(n.current=null,i(null),s()),o("market"),await _(null,!1),await C()}catch(A){throw Ze.error(Ai(A,`${N}智能体失败`)),A}}})},[u,_,C,s,n,i,o]),k=m.useCallback(async P=>{try{await d.mutateAsync(P.id),await C(),await _(null,!1),o("market"),Ze.success("已启用智能体")}catch(N){Ze.error(Ai(N,"启用模板失败"))}},[d,_,C,o]),T=m.useMemo(()=>({agentsLoading:v,marketLoading:w,marketError:S,marketTemplates:x,availableAgents:$,subscribingTemplateId:f,deletingAgentId:p}),[v,$,p,S,w,x,f]),I=m.useMemo(()=>({reload:C,enableTemplate:k,selectAgent:r,deleteAgent:E}),[E,k,C,r]);return{agents:h,setAgents:g,agentsLoading:v,agentsError:y,loadAgents:_,loadMarketTemplates:C,model:T,actions:I}}function Ktn({embedded:e=!1,onHeaderChange:t,onCockpitEnter:n,onCockpitExit:r}){const[i,a]=m.useState("market"),o=RJt(),{drawer:s,setDrawer:l,phase:c,waitingRunId:u,setWaitingRunId:d,waitingInfo:f,setWaitingInfo:p,setWaitingLoading:h,setWaitingSubmitting:g,openDetailDrawer:v,setIdlePhase:y}=o,[x,w]=m.useState(null),[S,_]=m.useState(null),C=m.useRef([]),[$,E]=m.useState(null),k=m.useRef(null),T=Aen(),I=_en({enabled:i==="cockpit",selectedAgentIdRef:k}),{realRuns:P,activeRunSnapshot:N,setActiveRunSnapshot:A,historyTotal:M,historyLoading:R,historyError:L,loadExecutions:z,activateHistory:j,resetHistory:O}=I,[V,B]=m.useState(null),D=ken({active:i==="cockpit"}),{transfers:F}=D,[H,W]=m.useState("amazon"),[K,U]=m.useState(""),[q,Q]=m.useState(null),[G,X]=m.useState(""),J=m.useCallback(Nr=>{X(Nr),window.setTimeout(()=>X(""),1900)},[]),{runConfigAgentId:Y,runFormLoading:Z,resetForAgent:re}=T,[ee,te]=m.useState([]),{traces:oe,recordEvent:fe}=DJt(),[he,ye]=m.useState(null),[Te,Ee]=m.useState(!1),we=Ten(),le=AJt(),{reset:se}=le,ne=m.useRef(""),ge=m.useRef(null),be=rJ(),{abort:Ce}=be,Ae=m.useCallback(Nr=>{Ce(),Q(null);const Ar=Er.getState();Ar.setExecutionSteps([]),Ar.setExecutionProgress(0),Ar.setCurrentExecutionId(null),Ar.setLatestSSEEvent(null),se();const gi=Nr.name.toLowerCase().includes("amazon")?"amazon":"custom";k.current=Nr.id,B(Nr.id),E(Nr.id),W(gi),U(""),O(!0),y(),re(),te([]),d(""),p(null),h(!1),g(!1),a("cockpit"),l("run"),w(null),n==null||n()},[Ce,n,se,re,O,l,y,p,h,d,g]),{agents:je,setAgents:ce,agentsLoading:de,agentsError:_e,loadAgents:Me,model:Re,actions:Ie}=qtn({active:i==="market",agentsRef:C,selectedAgentIdRef:k,selectAgent:Ae,setSelectedAgentId:E,setActiveRunId:U,setView:a,resetHistory:O,setIdlePhase:y}),De=Gen({view:i,agents:je,selectedAgentId:$,agentKind:H,realRuns:P,activeRunId:K,setActiveRunId:U,activeRunSnapshot:N,setActiveRunSnapshot:A,historyTotal:M,historyLoading:R,historyError:L,loadExecutions:z,activateHistory:j,deletingExecutionId:S,agentTransitionId:V,setAgentTransitionId:B,runFormLoading:Z,runConfigAgentId:Y,runPreviewStepItems:ee,liveExecutionTraces:oe,drawer:s,phase:c,transfers:F,waitingRunId:u,waitingInfo:f,waitingPreviewSteps:he}),{model:Ue,state:{selectedAgent:nt,agent:ct},actions:{changeHistoryStatusFilter:ht,changeHistoryPage:Ve,reloadHistory:Ye}}=De,{model:Se,state:{pendingCount:me,runTransferSender:pe},actions:{workspace:xe,openInbox:Le,refreshTransfers:$e,returnToInboxFromTransfer:ze}}=Wtn({view:i,agents:je,agentsLoading:de,agentsRef:C,loadAgents:Me,selectAgent:Ae,notify:J,inboxRunTransfer:q,setInboxRunTransfer:Q,setView:a,setDrawer:l,setModal:w,setAgentTransitionId:B});m.useEffect(()=>{Ee(!1)},[u]);const{currentExecutionId:Qe,openRun:it}=wen({enabled:i==="cockpit",activeRunId:K,agentsRef:C,setAgents:ce,execution:o,executions:I,runForm:T,cockpit:De,recommendations:we,executionEvents:le,runPreviewStepItems:ee,setRunPreviewStepItems:te,pendingExecutionTitleRef:ne,recommendedExecutionRef:ge,recordLiveTraceEvent:fe,setActiveRunId:U,setWaitingPreviewSteps:ye,notify:J}),{state:{rerunningRunId:st,reExecutingStepId:Ft,transferModalResultId:Ne},actions:{openRunDrawer:ke,openWaitingRun:Ke,submitWaitingInput:Je,rerunFailedExecution:We,reExecuteFailedStep:Oe,startRun:Xe,cancelCurrentExecution:at,closeTransferModal:mt,openShareForRun:ot,deleteExecutionRecord:wt,enableRecommendedTemplate:Pt,executeRecommendedTemplate:Yt}}=JJt({selectedAgentId:$,currentExecutionId:Qe,execution:o,executions:I,runForm:T,cockpit:De,recommendations:we,agentExecution:be,resetExecutionEvents:se,pendingExecutionTitleRef:ne,recommendedExecutionRef:ge,setActiveRunId:U,setDeletingExecutionId:_,setModal:w,inboxRunTransfer:q,setInboxRunTransfer:Q,refreshInboxTransfers:$e,loadAgents:Me,waitingPreviewSteps:he,notify:J}),{state:{scheduleModalOpen:Un},actions:{openScheduleModal:ur,closeScheduleModal:zn,returnToAgentSelection:Fn}}=Cen({embedded:e,view:i,setView:a,selectedAgentName:nt?ct.name:null,agentsCount:je.length,agentsError:_e,pendingInboxCount:me,openInbox:Le,reloadAgents:()=>void Me(null,!1),setDrawer:l,setModal:w,notify:J,onHeaderChange:t,onCockpitExit:r}),Da=ktn({cockpit:De,execution:o,runForm:T,recommendations:we,waitingOnlyMissing:Te,setWaitingOnlyMissing:Ee,reExecutingStepId:Ft,rerunningRunId:st,inboxRunTransfer:q,inboxRunTransferSender:pe,actions:{startRun:Xe,cancelExecution:()=>void at(),openDetail:v,notify:J,openWaitingRun:Ke,submitWaitingInput:Je,reExecuteFailedStep:Oe,rerunFailedExecution:We,returnToInbox:ze,shareRun:ot,executeRecommendedTemplate:Yt,enableRecommendedTemplate:Pt}});return b.jsx(IJt,{view:i,market:{model:{embedded:e,...Re},actions:Ie},inbox:{model:{embedded:e,...Se},actions:{back:Fn,...xe}},cockpit:nt?{model:{embedded:e,...Ue},actions:{back:Fn,history:{createRun:ke,configureSchedule:ur,changeStatusFilter:ht,reload:Ye,openRun:it,openWaitingRun:Ke,removeRun:wt,changePage:Ve}},slots:Da}:null,empty:{agentsCount:je.length,error:_e,onOpenMarket:()=>a("market")},transferModal:{open:x==="share",onClose:mt,resultId:Ne},scheduleModal:{agent:nt,open:Un,onClose:zn},toast:G})}function Ytn({queueStatus:e}){if(!e)return null;const t=e.status==="waiting";return b.jsx("div",{className:"wandox-queue-overlay",children:b.jsx("div",{className:"wandox-queue-modal",children:t?b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"wandox-queue-icon wandox-queue-icon--waiting",children:b.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("circle",{cx:"32",cy:"32",r:"28",stroke:"#E5E7EB",strokeWidth:"4"}),b.jsx("path",{d:"M32 16V32L44 38",stroke:"#8B5CF6",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})}),b.jsx("div",{className:"wandox-queue-title",children:"当前使用人数较多,正在排队中..."}),b.jsxs("div",{className:"wandox-queue-stats",children:[b.jsxs("div",{className:"wandox-queue-stat",children:[b.jsx("div",{className:"wandox-queue-stat-value",children:e.position}),b.jsx("div",{className:"wandox-queue-stat-label",children:"前面还有"})]}),b.jsxs("div",{className:"wandox-queue-stat",children:[b.jsxs("div",{className:"wandox-queue-stat-value",children:["~",e.estimated_wait,"s"]}),b.jsx("div",{className:"wandox-queue-stat-label",children:"预计等待"})]})]}),b.jsxs("div",{className:"wandox-queue-tip",children:[b.jsx("span",{className:"wandox-queue-tip-icon",children:"💡"}),b.jsx("span",{children:"小贴士:等待期间可先查看其他功能模块"})]})]}):b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"wandox-queue-icon wandox-queue-icon--ready",children:b.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("rect",{x:"4",y:"4",width:"56",height:"56",rx:"8",fill:"#10B981"}),b.jsx("path",{d:"M18 32L28 42L46 22",stroke:"white",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),b.jsx("div",{className:"wandox-queue-title wandox-queue-title--ready",children:"轮到您了!"}),b.jsx("div",{className:"wandox-queue-subtitle",children:"正在处理您的请求..."})]})})})}function Xtn({open:e,actionName:t,defaultParams:n={},onCancel:r,onExecute:i}){const[a,o]=m.useState({});m.useEffect(()=>{if(e){const d={};for(const f of Object.keys(n)){const p=n[f];(typeof p=="string"||typeof p=="number")&&(d[f]=String(p))}o(d)}},[e,n]);const s=(d,f)=>{o(p=>({...p,[d]:f}))},l=d=>{d.preventDefault();const f={...n};for(const p of Object.keys(a))f[p]=a[p];i(f)},c=d=>{d.target===d.currentTarget&&r()},u=(d,f)=>typeof f=="object"&&f!==null?null:b.jsxs("div",{className:"wandox-form-item",children:[b.jsx("span",{className:"wandox-form-label",children:d}),b.jsx("input",{type:"text",className:"wandox-form-input",placeholder:`请输入 ${d}`,value:a[d]||"",onChange:p=>s(d,p.target.value)})]},d);return e?b.jsx("div",{className:"wandox-modal-overlay",onClick:c,children:b.jsxs("div",{className:"wandox-modal",style:{width:600},children:[b.jsxs("div",{className:"wandox-modal-header",children:[b.jsxs("h3",{className:"wandox-modal-title",children:["执行 Action: ",t]}),b.jsx("button",{type:"button",className:"wandox-modal-close",onClick:r,"aria-label":"关闭",children:b.jsx("svg",{width:"24",height:"24",viewBox:"0 0 16 16",fill:"currentColor",children:b.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"})})})]}),b.jsxs("div",{className:"wandox-modal-body",children:[b.jsx("div",{className:"wandox-modal-description",children:"以下是默认参数,您可以修改后执行,或直接使用默认值执行"}),b.jsxs("form",{onSubmit:l,children:[Object.keys(n).map(d=>u(d,n[d])),Object.keys(n).length===0&&b.jsx("div",{className:"wandox-empty-params",children:"该 Action 无需参数"})]})]}),b.jsxs("div",{className:"wandox-modal-footer",children:[b.jsx("button",{type:"button",className:"wandox-button wandox-button-default",onClick:r,children:"取消"}),b.jsx("button",{type:"button",className:"wandox-button wandox-button-primary",onClick:l,children:"执行"})]})]})}):null}const Vye=["要努力呀,为了想要的生活,为了人间的烟火气,为了今天的风和月。","欣赏不来别人视若珍宝的,就该保持沉默。","日子总是有意思的,了无生趣的是打不起精神的你。","我们终其一生,就是要摆脱他人的期待,找到真正的自己。","别在最好的年纪选择了安逸,那是对自己最大的辜负。","你现在的气质里,藏着你走过的路、读过的书和爱过的人。","成长就是,你终于明白有些路只能一个人走。","不是每一次努力都有收获,但每一次收获都需要努力。","生活从不眷顾因循守旧、满足现状的人,而将更多机遇留给勇于探索的人。","所有的困难都是暂时的,熬过去就是晴天。","你若盛开,清风自来。","别人笑我太疯癫,我笑他人看不穿。","走慢一点,是为了走得更远。","不必羡慕别人,你的故事才刚刚开始。","心若向阳,何惧忧伤。","人生没有白走的路,每一步都算数。","你不是在浪费时间,你是在积蓄力量。","别让昨天的遗憾,占满今天的时间。","深夜的努力,终将照亮黎明。","只要路是对的,就不怕遥远。","生活不会辜负每一个认真的人。","做一个有温度的人,遇见有光的事。","你所经历的每一次失败,都是未来成功的伏笔。","不要因为走得太远,而忘记为什么出发。","把每一天当作礼物,而不是任务。","越努力,越幸运。","你值得拥有你所渴望的一切。","别把时间花在你不喜欢的事情上,除非它能带你去你喜欢的地方。","有些事现在不做,一辈子都不会做了。","你的潜力,远比你想象的要大。","不要等到准备好了才开始,开始了才会准备好。","慢慢来,比较快。","善待自己,你已经很努力了。","每一个你讨厌的早晨,都是别人求之不得的机会。","世界上只有一种真正的英雄主义,那就是认清生活的真相后仍然热爱它。","人生不是等待风暴过去,而是学会在雨中起舞。","别总想着逃离,先想想能不能改变。","你无法控制风向,但可以调整帆的方向。","没有人能替你走你该走的路。","不要因为没有掌声而停止歌唱。","把抱怨环境的心情,用来改善环境吧。","你今天的懒惰,是明天后悔的源头。","没有人永远年轻,但永远有人正在年轻。","读书破万卷,不如行路十里。","人生最大的遗憾,是轻易放弃了本不该放弃的。","你不是失败了,你只是还没成功。","今天的苦,是明天的底气。","别把别人的看法,活成自己的枷锁。","有一种勇敢,叫做即使害怕也要继续走。","生活是场修行,凡事皆有意义。","不要和自己过不去,人生很短,开心最重要。","你现在偷的懒,都是以后还的债。","最好的时机,就是现在。","你不必完美,但你必须真实。","与其等待一个完美的开始,不如从不完美中开始。","成功不是终点,失败也不是终结,重要的是继续的勇气。","每一个坚持的背后,都有一个不为人知的故事。","改变不了环境,就改变自己。","别用你的忙来掩盖你的懒,也别用你的懒来消耗你的忙。","人生就像骑自行车,要保持平衡就必须不断前行。","昨天已经过去,明天还未到来,今天才是你拥有的全部。","宁可辛苦一阵子,不要痛苦一辈子。","不要让今日的懒惰,成为明日的遗憾。","你的态度,决定了你人生的高度。","路是走出来的,不是想出来的。","做你自己,别人的角色已经有人在演了。","年轻时以为不读书不足惜,后来方知书中有乾坤。","你若想要,便去追;你若已得,便珍惜。","最怕你一生碌碌无为,还安慰自己平凡可贵。","人生没有捷径,弯路也是路。","种一棵树最好的时间是十年前,其次是现在。","每天进步一点点,人生就会不一样。","不要只是看,要有所感悟;不要只是听,要有所行动。","心态好了,一切都好了。","你的未来,取决于你现在的决定。","好好爱自己,才有能力去爱别人。","人生路上,勿忘初心。","有梦想就去追,别给自己的平庸找借口。","世界是你的,但首先你要努力。","坚持不一定成功,但放弃一定失败。","你比你想象的更坚强,比你感觉的更勇敢。","把每一次失败都当成学费,你就赚了。","选择了远方,便只顾风雨兼程。","人生的意义不在于拿一手好牌,而在于打好一手烂牌。","不要在还可以冲刺的年纪,选择散步。","钱不是万能的,但没有钱是万万不能的。努力赚钱,才是对自己最大的尊重。","所谓天才,不过是比别人多了一点坚持。","你改变不了昨天,但你可以决定明天。","做最好的自己,才能遇见最好的别人。","不要因为懒惰而失去了本来可以拥有的东西。","人生没有返回键,但有暂停和前进。","别等别人为你喝彩,先为自己鼓掌。","与其焦虑,不如行动。","每一个优秀的人,都曾经历过一段无人问津的岁月。","你的每一步努力,都在为未来的自己铺路。","不想当将军的士兵不是好士兵,但当不了将军的士兵也可以是好士兵。","生活的艺术,就是把每一个平凡的日子过得不平凡。","人生就是一场旅行,在乎的不是目的地,而是沿途的风景。","不要因为别人的否定,而放弃对自己的肯定。","勇敢不是不害怕,而是即使害怕也还是去做。","命运给了你一手烂牌,你要做的是把它打好。","真正的强大,是内心的平静。","你所不能击垮的,终将使你更强大。","成功的人找方法,失败的人找借口。","不要总是想着明天,今天就是你最年轻的一天。","人生最重要的不是你站在哪里,而是你朝哪个方向走。","每个人都是自己人生的主角,不要沦为配角。","你现在付出的努力,都是在为未来的幸福买单。","心宽了,路才宽。","你所拥有的,比你想要的更多。","不要用战术上的勤奋,掩盖战略上的懒惰。","很多人看起来很忙,实际上只是在低水平上勤奋。","格局大了,烦恼就少了。","你的圈子,决定了你的见识;你的见识,决定了你的未来。","别总是看别人的生活,好好经营自己的就够了。","脚踏实地,仰望星空,这才是人生的正确打开方式。","吃一堑,长一智;受一挫,强一分。","每一次跌倒,都是一次重新出发的机会。","低谷的时候,沉得住气;高峰的时候,守得住心。","你一定要过得很好,这样才不辜负自己受过的苦。","少说多做,是成功的捷径。","人生苦短,别把时间浪费在不值得的人和事上。","越是艰难处,越是修心时。","机会都是留给有准备的人的。","爱拼才会赢,努力才会赢。","人生就像一杯茶,不会苦一辈子,但总会苦一阵子。","不要轻言放弃,你不知道下一秒会发生什么奇迹。","真正的成熟,是能与不完美的自己握手言和。","你所走过的弯路,都是你成长的印记。","别人可以成功,你也可以。","只有不断超越自己,才能不断创造可能。","努力不一定成功,不努力一定不成功。","当你觉得累的时候,说明你在走上坡路。","不经历风雨,怎能见彩虹。","比起抱怨,不如改变。","年轻没有失败,试错才是成长。","你的样子,将决定你世界的样子。","愿你出走半生,归来仍是少年。","有时候你以为的终点,不过是下一段旅程的起点。","今天努力工作,明天努力生活。","不要总是活在别人的评价里,你自己最清楚自己是谁。","无论多难,都要坚持做你认为对的事。","你不需要变成别人,你只需要成为更好的自己。","凡事提前准备,才能游刃有余。","没有什么是理所当然的,感恩才能幸福。","不要把安全感建立在别人身上,那是一种危险的依赖。","清醒的认识自己,是成功的第一步。","沉默是金,但行动是钻石。","用行动证明,而不是用嘴巴解释。","最终你会明白,一切都是值得的。","把目光放长远,眼前的得失不算什么。","不要让自己的懒惰成为别人勤奋的舞台。","你的每一次选择,都在塑造未来的你。","有时候沉默不是因为没话说,而是因为懂得珍惜。","你今天的努力,是明天底气的来源。","先成为你想成为的人,其他的顺其自然。","把握现在,才能拥有未来。","越简单越快乐,越复杂越烦恼。","人生没有真正的绝境,除非你自己放弃。","你比你想象的更有力量。","把每一件平凡的事做好,就是不平凡。","那些没能打败你的,终将使你更强大。","做事情要有始有终,这是对自己最基本的尊重。","不在沉默中爆发,就在沉默中消亡。","不要害怕慢,就怕站。","只要还在走,就没有到不了的地方。","自律的人,才有资格谈自由。","与其等风来,不如追风去。","你有多自律,就有多自由。","凡是过往,皆为序章。","不要在该奋斗的年纪选择了安逸。","人生难得几回搏,此时不搏何时搏。","成长的代价是失去一些幼稚,但获得了更多可能。","有梦想的人,睡觉都是在充电。","不要辜负每一个认真的早晨。","生命的意义,在于不断地自我超越。","你有权利选择,但选择了就要承担。","最大的风险,是不冒任何风险。","生活会奖励那些敢于尝试的人。","不要拿别人的错误惩罚自己。","学会放下,才能腾出手来拥抱新的可能。","所有的天才都曾是努力的凡人。","比别人优秀不是目的,成为更好的自己才是。","你不需要被所有人喜欢,但你必须喜欢自己。","保持好奇心,世界就不会无聊。","每一个平静的背后,都有一颗强大的内心。","把抱怨的时间用来思考,把悲伤的时间用来行动。","只要心里有光,哪里都是出路。","你的奋斗轨迹,就是你最好的简历。","成功不是偶然的,它是努力、坚持和学习的结果。","不要小看自己,宇宙都是从一个点开始的。","真正的自由,是不依赖任何人的底气。","你的努力,终有一天会让你站在阳光下。","生活不在别处,就在此时此刻。","每一段经历,都是人生最好的礼物。"];function Ztn(){return b.jsxs("div",{className:"wandox-hub-skeleton-card",children:[b.jsxs("div",{className:"wandox-hub-skeleton-row",children:[b.jsx(Ri.Avatar,{active:!0,size:28,shape:"circle"}),b.jsx(Ri.Input,{active:!0,style:{width:120,height:18}})]}),b.jsxs("div",{style:{display:"flex",gap:8},children:[b.jsx(Ri.Input,{active:!0,block:!0,style:{height:40,borderRadius:10}}),b.jsx(Ri.Button,{active:!0,style:{width:80,height:40,borderRadius:10}})]})]})}function Qtn(){return b.jsx("div",{className:"wandox-hub-skeleton-insights",children:[1,2,3].map(e=>b.jsx("div",{className:"wandox-hub-skeleton-insight-card",children:b.jsxs("div",{className:"wandox-hub-skeleton-insight-inner",children:[b.jsx(Ri.Input,{active:!0,style:{width:52,height:22,borderRadius:100}}),b.jsxs("div",{style:{flex:1},children:[b.jsx(Ri.Input,{active:!0,block:!0,style:{height:16,marginBottom:6}}),b.jsx(Ri.Input,{active:!0,style:{width:"70%",height:12}})]})]})},e))})}function Jtn(e){return!!e&&/^https?:\/\//.test(e)}function iF(e){if(!e)return"✦";if(Jtn(e))return b.jsx("img",{src:e,alt:""});const t=i7t.get(e);return t?t.component:e}function enn(e,t){const n=`${e||""} ${t||""}`.toLowerCase();return n.includes("red")||n.includes("critical")?"wandox-insight-severity--red":n.includes("orange")||n.includes("high")?"wandox-insight-severity--orange":n.includes("yellow")||n.includes("medium")?"wandox-insight-severity--yellow":"wandox-insight-severity--gray"}function tnn(e){const t=e.match(new RegExp("^\\p{Extended_Pictographic}","u"));return(t==null?void 0:t[0])||"📌"}function Hye(e){return e.replace(new RegExp("^\\p{Extended_Pictographic}\\s*","u"),"")}function Wye(e){var t;return e.bind_type==="playbook"&&e.bind_playbook_id&&((t=e.playbook_args)!=null&&t.length)?"执行":e.bind_type==="agent"?"找智能体聊聊":e.bind_type==="chat"?"分析一下":"查看详情"}function nnn(e,t){const n=e.asin||e.ASIN||e.sku||e.seller_sku,r=e.site||e.marketplace||e.country;if(n||r)return[n,r&&`(${r})`].filter(Boolean).join(" ");const i=Object.values(e).find(a=>a!=null&&String(a).trim());return i?String(i):`参数 ${t+1}`}function rnn(e,t){var r;const n=(r=e.query_template)==null?void 0:r.trim();return!n||!t?e.title:n.replace(/\{\{?\s*([\w.-]+)\s*\}?\}/g,(i,a)=>{const o=t[a];return o==null?i:String(o)})}function inn(e){return!e||e.status==="disabled"||e.status==="error"||!e.scenes?[]:Object.entries(e.scenes).map(([t,n])=>({name:t,total_affected:n.total_affected,suggestions_count:n.suggestions_count,cards:Array.isArray(n.cards)?n.cards:[]})).filter(t=>t.cards.length>0)}function ann({agentLoading:e,mainAgentForHub:t,mainAgentQuestions:n,agents:r,hubChatOpen:i,setHubChatOpen:a,hubChatInput:o,setHubChatInput:s,hubScrollIdx:l,hubScrollFading:c,onHubChatSend:u,onHubInputFocus:d,onHubInputBlur:f,messages:p,executing:h,hubInlineChatInput:g,setHubInlineChatInput:v,onHubInlineSend:y,onEnterProfessional:x,playbooks:w,executePlaybook:S,onRequestPlaybookParams:_,onAbort:C,onRespondToProposal:$,ssoToken:E,ssoDomain:k,ssoCompany:T}){var ge,be,Ce,Ae,je;const I=e&&!t,P=localStorage.getItem("sso_username")||"",N=localStorage.getItem("sso_user_id")||"",A=m.useRef(null),M=m.useRef(null),R=m.useMemo(()=>[],[]),[L,z]=m.useState(""),[j,O]=m.useState([]),[V,B]=m.useState(!1),[D,F]=m.useState("idle"),[H,W]=m.useState(0),[K,U]=m.useState(null),[q,Q]=m.useState(!1),G=r[0],X=(G==null?void 0:G.agent_code)||(G==null?void 0:G.agent_id)||"",J=(ge=G==null?void 0:G.questions)!=null&&ge.length?G.questions:n,Y=k!=="yunduo"&&J[l%Math.max(J.length,1)]||"今天仓库订单处理的怎么样了?",Z=m.useMemo(()=>Vye[Math.floor(Math.random()*Vye.length)],[]),re=m.useMemo(()=>({Authorization:`Bearer ${E}`,"X-Tenant-ID":T,"X-Domain":k,"Content-Type":"application/json"}),[E,T,k]),ee=m.useCallback(async(ce=!1)=>{if(!(!E||!k)){B(!0);try{const de=await fetch(`${Gi()}/api/v1/insights/${ce?"refresh":"recommendations"}`,{method:ce?"POST":"GET",headers:re});if(!de.ok)throw new Error(`HTTP ${de.status}`);const _e=await de.json(),Me=_e==null?void 0:_e.data;F((Me==null?void 0:Me.status)||"error"),W((Me==null?void 0:Me.total_cards)||0),O(inn(Me))}catch{F("error"),W(0),O([])}finally{B(!1)}}},[re,k,E]);m.useEffect(()=>{ee()},[ee]),m.useEffect(()=>{!L&&X&&z(X)},[X,L]);const te=j,oe=L||X||((be=R[0])==null?void 0:be.agent_id)||(t==null?void 0:t.agent_id),fe=AOe({token:E,domain:k,tenantId:T,agentId:oe||"",limit:5});m.useEffect(()=>{if(!q||i){fe.clear();return}fe.search(o)},[q,o,i,fe.search,fe.clear]);const he=te.length>0&&te.every(ce=>ce.cards.length===1),ye=R.slice(0,3),Te=R.slice(3),Ee=oe===X?G==null?void 0:G.name:(Ce=R.find(ce=>ce.agent_id===oe))==null?void 0:Ce.name,we=oe===X?G!=null&&G.icon?ag(G.icon):ag("robot"):iF((Ae=R.find(ce=>ce.agent_id===oe))==null?void 0:Ae.icon),le=oe===X?G==null?void 0:G.description:(je=R.find(ce=>ce.agent_id===oe))==null?void 0:je.description,se=(ce,de)=>{if(ce.bind_type==="agent"&&ce.bind_agent_code){x(ce.bind_agent_code);return}if(ce.bind_type==="playbook"&&ce.bind_playbook_id&&de){a(!0),S({message:rnn(ce,de),playbook_id:ce.bind_playbook_id,playbook_params:de});return}u(oe,ce.title)},ne=(ce,de,_e,Me=!1,Re=!1)=>{const Ie=Array.isArray(de.playbook_args)?de.playbook_args:[],De=de.bind_type==="playbook"&&!!de.bind_playbook_id&&Ie.length>0;return b.jsxs("article",{className:`wandox-insight-card${Me?" wandox-insight-card--modal":""}${Re?" wandox-insight-card--featured":""}`,children:[b.jsxs("button",{type:"button",className:"wandox-insight-card-main",onClick:()=>{Me&&U(null),se(de,Ie[0])},children:[b.jsxs("div",{className:"wandox-insight-card-top",children:[b.jsx("span",{className:`wandox-insight-severity ${enn(de.severity_color,de.priority)}`,children:de.severity_label||"观察"}),de.affected_count&&b.jsx("span",{children:de.affected_count})]}),b.jsx("h4",{children:de.title}),de.description&&b.jsx("p",{children:de.description}),b.jsxs("div",{className:"wandox-insight-card-foot",children:[b.jsx("span",{children:de.value_hint||"建议进一步确认"}),!De&&b.jsxs("strong",{children:[Wye(de)," →"]})]})]}),De&&b.jsxs("div",{className:"wandox-insight-arg-list",children:[Ie.slice(0,Me?10:3).map((Ue,nt)=>b.jsxs("button",{type:"button",className:"wandox-insight-arg-action",onClick:()=>{Me&&U(null),se(de,Ue)},children:[b.jsx("span",{children:nnn(Ue,nt)}),b.jsx("strong",{children:Wye(de)})]},`${de.title}-${nt}`)),!Me&&Ie.length>3&&b.jsxs("button",{type:"button",className:"wandox-insight-arg-more",onClick:()=>U(te.find(Ue=>Ue.name===ce)||null),children:["还有 ",Ie.length-3," 项可执行"]})]})]},`${ce}-${de.title}-${_e}`)};return b.jsx("div",{className:"wandox-view-scroll",children:b.jsxs("div",{className:"wandox-view-content wandox-hub-v2",children:[b.jsxs("div",{className:"wandox-hub-v2-header",children:[b.jsxs("div",{children:[b.jsxs("h1",{className:"wandox-hub-v2-title",children:["您好,",P||"欢迎回来"]}),b.jsx("p",{className:"wandox-hub-v2-subtitle",children:Z})]}),k!=="yunduo"&&b.jsxs("button",{type:"button",className:"wandox-hub-v2-report",onClick:()=>{const ce=new URLSearchParams;E&&ce.append("authorization",E),k&&ce.append("x-domain",k),T&&ce.append("x-tenant-id",T),N&&ce.append("user_id",N),P&&ce.append("username",P),window.open(`https://ai.wandox.com/trend-report/trend-report-6.html${ce.toString()?`?${ce.toString()}`:""}`,"_blank")},children:[b.jsx("span",{className:"wandox-hub-v2-report-logo",children:"麦"}),b.jsxs("span",{children:[b.jsx("strong",{children:"麦多趋势报告"}),b.jsx("small",{children:"第六期 已更新 →"})]})]})]}),I?b.jsx(Ztn,{}):b.jsxs("div",{ref:A,className:`wandox-hub-main-card${i?" wandox-hub-main-card--open":""}`,children:[b.jsx("div",{className:"wandox-hub-main-card-search",style:{opacity:i?0:1,maxHeight:i?0:520,transition:"opacity 0.2s ease, max-height 0.35s cubic-bezier(0.4,0,0.2,1)"},children:b.jsxs("div",{className:"wandox-hub-v2-input-panel",children:[b.jsxs("div",{className:"wandox-hub-v2-input-head",children:[b.jsxs("div",{className:"wandox-hub-v2-agent-title",children:[b.jsx("span",{className:"wandox-hub-v2-agent-mark",children:we}),b.jsxs("div",{children:[b.jsx("strong",{children:Ee||(t==null?void 0:t.name)||"通用问答"}),b.jsx("span",{children:le||"问什么都行,系统会自动分流到对应的专业能力"})]})]}),b.jsxs("div",{className:"wandox-hub-v2-chip-row",style:{display:"none"},children:[X&&b.jsxs("button",{type:"button",className:`wandox-hub-v2-chip${oe===X?" wandox-hub-v2-chip--active":""}`,onClick:()=>z(X),title:(G==null?void 0:G.description)||(G==null?void 0:G.name)||"全部",children:[b.jsx("span",{className:"wandox-hub-v2-chip-icon",children:G!=null&&G.icon?ag(G.icon):"✦"}),"全部"]}),ye.map(ce=>b.jsxs("button",{type:"button",className:`wandox-hub-v2-chip${ce.agent_id===oe?" wandox-hub-v2-chip--active":""}`,onClick:()=>z(ce.agent_id),title:ce.description||ce.name,children:[b.jsx("span",{className:"wandox-hub-v2-chip-icon",children:iF(ce.icon)}),ce.name]},ce.agent_id)),Te.length>0&&b.jsx(AE,{menu:{items:Te.map(ce=>({key:ce.agent_id,label:b.jsxs("span",{className:"wandox-hub-v2-more-item",children:[b.jsx("span",{className:"wandox-hub-v2-chip-icon",children:iF(ce.icon)}),b.jsx("span",{children:ce.name})]})})),onClick:({key:ce})=>z(String(ce))},placement:"bottomRight",children:b.jsxs("button",{type:"button",className:"wandox-hub-v2-chip wandox-hub-v2-chip--more",children:["更多 ",b.jsx(cO,{})]})})]})]}),b.jsxs("div",{className:"wandox-hub-v2-input-wrap",children:[b.jsx(Kt.TextArea,{value:o,onChange:ce=>s(ce.target.value),onPressEnter:ce=>{ce.shiftKey||(ce.preventDefault(),u(oe))},onFocus:()=>{Q(!0),d==null||d()},onBlur:()=>{window.setTimeout(()=>Q(!1),120),f==null||f()},placeholder:"请随便问,看看 AI 搭子怎么帮你避坑",autoSize:{minRows:3,maxRows:7},variant:"borderless",className:"wandox-hub-v2-textarea"}),b.jsx(MOe,{open:q,rewrittenQuestion:fe.rewrittenQuestion,questions:fe.questions,loading:fe.loading,placement:"bottom",onSelectRewrite:ce=>{s(ce),fe.clear()},onSelectQuestion:ce=>{s(""),fe.clear(),u(oe,ce.title)}})]}),b.jsxs("div",{className:"wandox-hub-v2-input-bottom",children:[b.jsxs("div",{className:"wandox-hub-v2-example",children:[b.jsx("span",{className:"wandox-hub-v2-example-label",children:"示例:"}),b.jsx("button",{type:"button",className:"wandox-hub-v2-example-text",onClick:()=>{s(Y)},style:{opacity:c?0:1,transform:c?"translateY(-4px)":"translateY(0)"},children:Y})]}),b.jsx(Et,{type:"primary",icon:b.jsx(y2e,{}),className:"wandox-hub-v2-send",onClick:()=>u(oe),children:"发送问题"})]})]})}),b.jsxs("div",{style:{height:i?"100%":0,display:"flex",flexDirection:"column",opacity:i?1:0,overflow:"hidden",transition:"opacity 0.3s ease 0.1s, max-height 0.4s cubic-bezier(0.4,0,0.2,1)",position:"relative",zIndex:i?1:-1},children:[b.jsxs("div",{className:"wandox-hub-chat-header",children:[t&&b.jsxs("div",{className:"wandox-hub-chat-agent-avatar",children:[ag(t.icon),t.is_main&&b.jsx("div",{className:"wandox-hub-chat-agent-badge"})]}),b.jsx("span",{className:"wandox-hub-chat-agent-name",children:t==null?void 0:t.name}),b.jsx("span",{className:"wandox-hub-chat-status",children:"对话中"}),b.jsx("button",{type:"button",className:"wandox-hub-chat-close",onClick:()=>{C(),a(!1)},children:"×"})]}),b.jsxs("div",{className:"wandox-chat-section__body wandox-chat-section__body--hub",children:[b.jsx(xOe,{messages:p,executing:h,ssoToken:E,ssoDomain:k,ssoCompany:T,onExecutePlaybook:ce=>S(ce),onFillPlaybookParams:ce=>_({playbook_id:ce.playbookId,name:ce.playbookName,input_fields:ce.inputFields,initial_params:ce.initialParams,playbook_type:ce.playbookType}),onRespondToProposal:$,containerRef:M,className:"wandox-hub-messages"}),b.jsx(COe,{messages:p,scrollContainerRef:M})]}),b.jsx("div",{className:"wandox-hub-chat-input-row",children:b.jsx(UQ,{executing:h,onSend:(ce,de,_e)=>y(ce,_e),playbooks:w,value:g,onValueChange:v,placeholder:"继续提问…",ssoToken:E,ssoDomain:k,ssoCompany:T,onRequestPlaybookParams:_})}),b.jsx("div",{className:"wandox-hub-chat-footer",children:b.jsx("button",{type:"button",className:"wandox-hub-chat-enter-link",onClick:()=>x(),children:"进入完整对话视图 →"})})]})]}),(V||D==="error"||D==="success"&&H>=0)&&D!=="disabled"&&b.jsxs("div",{className:"wandox-hub-section wandox-hub-v2-insights",children:[b.jsxs("div",{className:"wandox-hub-v2-section-heading",children:[b.jsxs("div",{children:[b.jsxs("div",{className:"wandox-hub-v2-section-kicker",children:[b.jsx("span",{}),b.jsx("strong",{children:"基于你的数据,建议先看"})]}),b.jsx("p",{children:"系统每天扫描你的店铺数据,自动识别出值得处理的场景"})]}),b.jsx(Et,{type:"text",size:"small",icon:b.jsx(yy,{}),className:"wandox-hub-v2-refresh",onClick:()=>ee(!0),children:"换一批"})]}),V?b.jsx(Qtn,{}):D==="error"?b.jsxs("div",{className:"wandox-insight-empty",children:[b.jsx("strong",{children:"数据获取失败,请稍后重试"}),b.jsx(Et,{type:"link",size:"small",onClick:()=>ee(),children:"重试"})]}):te.length===0?b.jsxs("div",{className:"wandox-insight-empty",children:[b.jsx("strong",{children:"暂无场景推荐,数据正常"}),b.jsx("span",{children:"当前没有扫描到需要优先处理的运营场景"})]}):b.jsx("div",{className:`wandox-insight-scene-list${he?" wandox-insight-scene-list--single-cards":""}${te.length===1?" wandox-insight-scene-list--one-scene":""}`,children:te.map(ce=>b.jsxs("section",{className:"wandox-insight-scene",children:[b.jsx("div",{className:"wandox-insight-scene-head",children:b.jsxs("div",{children:[b.jsx("strong",{children:Hye(ce.name)}),b.jsxs("span",{children:["扫描到"," ",ce.suggestions_count??ce.cards.length," ","条建议"]})]})}),b.jsx("div",{className:`wandox-insight-card-row${ce.cards.length===1?" wandox-insight-card-row--single":""}`,children:ce.cards.slice(0,4).map((de,_e)=>ne(ce.name,de,_e,!1,ce.cards.length===1))}),ce.cards.length>4&&b.jsxs("button",{type:"button",className:"wandox-insight-view-all",onClick:()=>U(ce),children:["查看全部 ",ce.cards.length," 条建议 →"]})]},ce.name))})]}),b.jsxs("div",{className:"wandox-hub-section",children:[b.jsxs("div",{className:"wandox-hub-v2-section-heading",children:[b.jsxs("div",{children:[b.jsxs("div",{className:"wandox-hub-v2-section-kicker",children:[b.jsx("span",{}),b.jsx("strong",{children:"需要执行更专业的任务?"})]}),b.jsx("p",{children:"直接进入对应专家,按业务流程一步步处理"})]}),b.jsx(Et,{type:"link",size:"small",className:"wandox-hub-v2-refresh",onClick:()=>x(),children:"全部 →"})]}),I?b.jsx("div",{className:"wandox-agent-grid",children:[1,2,3].map(ce=>b.jsxs("div",{className:"wandox-agent-entry-card",style:{pointerEvents:"none"},children:[b.jsx(Ri.Avatar,{active:!0,size:36,shape:"square",style:{borderRadius:8,flexShrink:0}}),b.jsxs("div",{style:{flex:1},children:[b.jsx(Ri.Input,{active:!0,block:!0,style:{height:14,marginBottom:6}}),b.jsx(Ri.Input,{active:!0,style:{width:"80%",height:11}})]})]},ce))}):b.jsx("div",{className:"wandox-agent-grid",children:r.filter(ce=>!ce.is_main).slice(0,4).map(ce=>{const de=XQ(ce);return b.jsxs("button",{type:"button",className:`wandox-agent-entry-card${de?" wandox-agent-entry-card--with-badge":""}`,onClick:()=>x(ce.agent_id||void 0),children:[b.jsx("div",{className:"wandox-agent-entry-icon",children:ag(ce.icon)}),b.jsxs("div",{className:"wandox-agent-entry-info",children:[b.jsx("div",{className:"wandox-agent-entry-name",children:ce.name}),b.jsx("div",{className:"wandox-agent-entry-desc",children:ce.description})]}),b.jsx(Ih,{className:"wandox-agent-entry-arrow"}),de&&b.jsx("span",{className:`wandox-agent-entry-badge wandox-agent-entry-badge--${de.kind}`,children:de.badgeText})]},ce.agent_id)})})]}),b.jsx(rr,{open:!!K,onCancel:()=>U(null),footer:null,width:920,centered:!0,className:"wandox-insight-modal",title:K?b.jsxs("div",{className:"wandox-insight-modal-title",children:[b.jsx("span",{children:tnn(K.name)}),b.jsxs("div",{children:[b.jsx("strong",{children:Hye(K.name)}),b.jsxs("small",{children:[K.cards.length," 条数据建议"]})]})]}):null,styles:{container:{padding:0}},children:K&&b.jsx("div",{className:"wandox-insight-modal-grid",children:K.cards.map((ce,de)=>ne(K.name,ce,de,!0))})})]})})}function onn(e={}){const{presetAgents:t,initialAgentId:n}=e,{setAllQuestions:r}=WQ(),[i,a]=m.useState("default"),[o,s]=m.useState([]),[l,c]=m.useState([]),[u,d]=m.useState([]),[f,p]=m.useState(!1),[h,g]=m.useState([]),[v,y]=m.useState([]),[x,w]=m.useState(!1),[S,_]=m.useState(!1),C=m.useRef(i),$=m.useRef(0),E=m.useRef(0);C.current=i;const k=m.useCallback(async()=>{var P,N;if(t&&t.length>0){s(t),a(M=>{var R,L;if(M&&M!=="default"&&t.some(z=>z.agent_code===M||z.agent_id===M))return M;if(n){const z=UR(t,n);if(z)return Jp(z);Ze.error("指定的智能体不存在,已切换到默认智能体")}return((R=t[0])==null?void 0:R.agent_code)||((L=t[0])==null?void 0:L.agent_id)||""});const A=[];for(const M of t)if(M.questions&&Array.isArray(M.questions)&&A.push(...M.questions),M.children)for(const R of M.children)R.questions&&Array.isArray(R.questions)&&A.push(...R.questions);r(A);return}w(!0);try{const{data:A}=await XO({page:1,page_size:99});if(s(A.filter(R=>!R.hidden)||[]),n){const R=UR(A||[],n);R?a(Jp(R)):(Ze.error("指定的智能体不存在,已切换到默认智能体"),a(((P=A[0])==null?void 0:P.agent_code)||""))}else a(((N=A[0])==null?void 0:N.agent_code)||"");const M=[];for(const R of A||[])if(R.questions&&Array.isArray(R.questions)&&M.push(...R.questions),R.children)for(const L of R.children)L.questions&&Array.isArray(L.questions)&&M.push(...L.questions);r(M)}catch{}w(!1)},[t,r,n]),T=m.useCallback(async()=>{if(!i||i==="default")return;const P=i,N=++$.current;w(!0),_(!1),d([]);try{const{data:A}=await PY({agent_id:P});if(N!==$.current||C.current!==P)return;c(KOe(A));const M=A.playbook_groups||[];g(M);const R=A.children||[];y(R)}catch{if(N!==$.current||C.current!==P)return;d([])}finally{N===$.current&&C.current===P&&(w(!1),_(!0))}},[i]),I=m.useCallback(async()=>{if(!i||i==="default"){d([]);return}const P=i,N=++E.current;p(!0);try{const{data:A}=await Hmt({agent_id:P});if(N!==E.current||C.current!==P)return;const M=Array.isArray(A)?A:Array.isArray(A==null?void 0:A.user_playbooks)?A.user_playbooks:[];d(M)}catch{if(N!==E.current||C.current!==P)return;d([]),Ze.error("我的场景加载失败")}finally{N===E.current&&C.current===P&&p(!1)}},[i]);return{activeAgent:i,setActiveAgent:a,agents:o,playbooks:l,userPlaybooks:u,userPlaybooksLoading:f,playbookGroups:h,childAgents:v,loading:x,setLoading:w,playbooksLoaded:S,loadAgents:k,loadPlaybooks:T,loadUserPlaybooks:I}}function Uye(e){var s;const t=e.role==="assistant"?ZQ(e.process):void 0,n={...e,process:t?{...t,origin:"history"}:void 0},r=n.execution_id??((s=n.meta_content)==null?void 0:s.execution_id),i=n.meta_content;if(!i||i.response_type!=="proposal")return r===void 0?n:{...n,execution_id:r};const a={proposal_id:i.proposal_id||"",scene:i.scene||"playbook_select",message:"",options:(i.options||[]).map(l=>({id:l.id,playbook_code:l.playbook_code,title:l.title,description:l.description||"",selected:l.id===i.selected_option_id,params:l.params||[]})),params:i.params||[],actions:{confirm:{label:"确认执行",style:"primary"},reject:{label:"都不需要",style:"secondary"}}},o=i.proposal_status==="confirmed"?"confirmed":i.proposal_status==="rejected"?"rejected":void 0;return{...n,execution_id:r,proposal:a,proposal_status:o}}function fl(e,t){return e.activeAgent===t.activeAgent&&e.webhookId===t.webhookId&&e.ssoToken===t.ssoToken&&e.ssoDomain===t.ssoDomain&&e.ssoCompany===t.ssoCompany}function Gye(e){const t=`${e.ssoDomain}\0${e.ssoCompany}\0${e.ssoToken}`;let n=2166136261;for(let r=0;r<t.length;r+=1)n^=t.charCodeAt(r),n=Math.imul(n,16777619);return(n>>>0).toString(36)}function snn(e){const{activeAgent:t,pageSize:n=bOe,webhookId:r,executePlaybook:i,isExecutingRef:a,ssoToken:o="",ssoDomain:s="",ssoCompany:l=""}=e,[c,u]=m.useState([]),[d,f]=m.useState(0),[p,h]=m.useState(1),[g,v]=m.useState(!1),y=m.useRef(t),x=m.useRef({activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l});m.useEffect(()=>{y.current=t,x.current={activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l},u([]),f(0),h(1),v(!1)},[t,r,o,s,l]);const w=m.useCallback(()=>{const T=new Date;return`${T.getFullYear()}-${String(T.getMonth()+1).padStart(2,"0")}-${String(T.getDate()).padStart(2,"0")}`},[]),S=m.useCallback(T=>{const I=w(),N=`wandox_daily_report_${Gye({ssoToken:o,ssoDomain:s,ssoCompany:l})}_${I}`,A=localStorage.getItem(N);if(!A)return!1;try{return JSON.parse(A).includes(T)}catch{return!1}},[w,o,s,l]),_=m.useCallback(T=>{const I=w(),N=`wandox_daily_report_${Gye({ssoToken:o,ssoDomain:s,ssoCompany:l})}_${I}`,A=localStorage.getItem(N);let M=[];if(A)try{M=JSON.parse(A)}catch{M=[]}M.includes(T)||(M.push(T),localStorage.setItem(N,JSON.stringify(M)))},[w,o,s,l]),C=m.useCallback(async()=>{const T=t,I={activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l};if(fl(x.current,I)&&!(a!=null&&a.current)){u([]),v(!0);try{const{data:P}=await gM({agent_id:t,page:1,page_size:n,webhook_id:r,include_process:!0});if(a!=null&&a.current||y.current!==T||!fl(x.current,I))return;const N=(P==null?void 0:P.items)||[];u([...N].reverse().map(Uye).filter(A=>!fve(A))),h(1),f((P==null?void 0:P.total)||0)}catch{}finally{fl(x.current,I)&&v(!1)}}},[t,n,r,a,o,s,l]),$=m.useCallback(async()=>{if(c.length>=d)return;const T={activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l};if(!fl(x.current,T))return;const I=p+1;v(!0);try{const{data:P}=await gM({agent_id:t,page:I,page_size:n,webhook_id:r,include_process:!0});if(!fl(x.current,T))return;const N=(P==null?void 0:P.items)||[];if(N.length>0){const A=[...N].reverse().map(Uye).filter(M=>!fve(M));u(M=>[...A,...M]),h(I),f((P==null?void 0:P.total)||0)}}catch(P){throw P}finally{fl(x.current,T)&&v(!1)}},[t,n,r,c.length,d,p,o,s,l]),E=m.useCallback(async()=>{var P,N,A;if(!t||t==="default")return!1;const T=t,I={activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l};if(!fl(x.current,I))return!1;try{const M=await Vmt({agent_id:t});if(a!=null&&a.current||y.current!==T||!fl(x.current,I))return!1;if(M!=null&&M.data){const R=M.data;if(R.outputs){let L=null;R.outputs.type==="card"&&((N=(P=R.outputs.content)==null?void 0:P.data)!=null&&N.content)?L=R.outputs.content.data.content:(A=R.outputs.content)!=null&&A.content?L=R.outputs.content.content:R.outputs.content?L=R.outputs.content:L=R.outputs;const z={id:R.playbook_id||"daily-report",role:"assistant",content:"",timestamp:new Date().toISOString(),ui_payload:L};return u(j=>{const O=j.filter(V=>V.id!=="daily-report");return[z,...O]}),!0}R.playbook_id&&R.playbook_name&&(i==null||i({message:R.playbook_name,playbook_id:R.playbook_id}))}return!1}catch{return!1}},[t,r,i,a,o,s,l]),k=m.useCallback(async()=>{const T={activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l};if(fl(x.current,T)&&t){if(v(!0),t==="default"){try{await C()}finally{fl(x.current,T)&&v(!1)}return}try{if(S(t)){await C();return}await E()?fl(x.current,T)&&_(t):await C()}catch{await C()}finally{fl(x.current,T)&&v(!1)}}},[t,r,C,E,S,_,o,s,l]);return{messages:c,setMessages:u,messagesTotal:d,messagesPage:p,loading:g,setLoading:v,loadMessages:C,loadMoreMessages:$,loadDailyReport:E,loadMessagesAndDailyReport:k}}function lnn(e){const t=e.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),n=e.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${t}
|
|
795
|
-
${n}`}function aF(e,t){return e.activeAgent===t.activeAgent&&e.webhookId===t.webhookId&&e.ssoToken===t.ssoToken&&e.ssoDomain===t.ssoDomain&&e.ssoCompany===t.ssoCompany}function cnn(e){const{activeAgent:t,webhookId:n="",ssoToken:r="",ssoDomain:i="",ssoCompany:a=""}=e,[o,s]=m.useState([]),l=m.useRef({activeAgent:t,webhookId:n,ssoToken:r,ssoDomain:i,ssoCompany:a});m.useEffect(()=>{l.current={activeAgent:t,webhookId:n,ssoToken:r,ssoDomain:i,ssoCompany:a},s([])},[t,n,r,i,a]);const c=m.useCallback(async()=>{if(!t)return;const u={activeAgent:t,webhookId:n,ssoToken:r,ssoDomain:i,ssoCompany:a};if(aF(l.current,u))try{const d=await Umt({agent_id:t,limit:10,use_cache:!1});if(!aF(l.current,u))return;if(d!=null&&d.data&&Array.isArray(d.data)){const f=d.data.map(p=>{const h=Array.isArray(p.actions)?p.actions||[]:[],g=p.ui_payload,v=g==null?void 0:g.actions,y=Array.isArray(v)?v:[],w=[...h,...y].map(_=>{const C=_;return{label:C.display_name||C.label||"执行",action_id:C.action_id,playbook_id:C.playbook_id,display_name:C.display_name,display_icon:C.display_icon,params:C.params,params_fields_map:C.params_fields_map,type:C.type,url:C.url,style:C.style,status:C.action_status||C.status||void 0,sort_order:C.sort_order,executed_job_id:C.executed_job_id,supports_batch:C.supports_batch===!0,batch_max_items:C.batch_max_items,batch_id:C.batch_id,outputs:C.outputs}}),S=p.outputs;return{type:p.widget_type||"daily_report",priority:p.priority||"medium",title:p.title||"每日战报",summary:p.summary||"",timestamp:p.created_at?lnn(new Date(p.created_at||"")):"",data:p.card_data||{},actions:w,id:p.inbox_id||"",agent_id:p.agent_id||"",read:!!p.is_read,ui_payload:S||g||{}}});if(f.length>0){const p=f.sort((h,g)=>{const v=h.timestamp?new Date(h.timestamp.replace(/\n/g," ")).getTime():0;return(g.timestamp?new Date(g.timestamp.replace(/\n/g," ")).getTime():0)-v});s(p)}else s([])}else s([])}catch(d){if(!aF(l.current,u))return;throw s([]),d}},[t,n,r,i,a]);return{widgets:o,setWidgets:s,loadDailyReports:c}}function unn(){const[e,t]=m.useState([]),[n,r]=m.useState(!1),[i,a]=m.useState(!1),[o,s]=m.useState(""),[l,c]=m.useState([]),[u,d]=m.useState(!1),[f,p]=m.useState(null),[h,g]=m.useState(!0),v=m.useRef(null),y=m.useCallback(async()=>{if(v.current)return v.current;const T=(async()=>{r(!0);try{const I=await qmt({page:1,page_size:20});return Array.isArray(I==null?void 0:I.data)?(t(I.data),a(!0),!0):(a(!1),!1)}catch{return a(!1),!1}finally{r(!1),v.current=null}})();return v.current=T,T},[]),x=m.useCallback(()=>i?Promise.resolve(!0):y(),[y,i]),w=m.useCallback(T=>{s(T),p({session_id:T,type:"dashboard_intent",intents:[],data:{}}),g(!1),(async(P={})=>{d(!0);try{const N=await Rse(T,{params:P});N.success&&N.data&&(p(N.data),N.data.input_params&&c(N.data.input_params))}catch{}finally{d(!1)}})()},[]),S=m.useCallback(T=>{if(!o)return;(async()=>{d(!0);try{const P=await Rse(o,{params:T});P.success&&P.data&&p(P.data)}catch{}finally{d(!1)}})()},[o]),_=m.useCallback(T=>{o===T&&(s(""),p(null),c([])),y()},[o,y]),C=m.useCallback(()=>{if(!o)return null;const T=e.find(I=>I.playbook_id===o);return(T==null?void 0:T.name)||null},[o,e]),$=m.useCallback((T,I)=>{p(T),g(I!==void 0?I:!0)},[]),E=m.useCallback(()=>{},[]),k=m.useCallback(()=>{s(""),p(null),c([])},[]);return{solidifiedPlaybooks:e,solidifiedPlaybooksLoading:n,solidifiedPlaybooksLoaded:i,activeSolidifiedPlaybook:o,setActiveSolidifiedPlaybook:s,solidifyInputParams:l,solidifyLoading:u,dashboardData:f,setDashboardData:p,dashboardShowSaveButton:h,setDashboardShowSaveButton:g,loadSolidifiedPlaybooks:y,ensureSolidifiedPlaybooksLoaded:x,handleSolidifiedPlaybookClick:w,handleSolidifyParamsSearch:S,handleSolidifiedPlaybookDelete:_,getCurrentSolidifiedPlaybookName:C,handleDashboardPreview:$,handleSolidifyComplete:E,clearDashboard:k}}function dnn(){const{allQuestions:e,setCurrentQuestion:t}=WQ();m.useEffect(()=>{if(e.length===0)return;const n=Math.floor(Math.random()*e.length);t(e[n]);const r=setInterval(()=>{const i=Math.floor(Math.random()*e.length);t(e[i])},1e4);return()=>{clearInterval(r)}},[e,t])}const qye={chat:{title:"对话",subtitle:""},plan:{title:"自动化",subtitle:"创建、管理并追踪自动化智能体的执行结果,支持定时触发与对内流转"},professional:{title:"专业智能体",subtitle:"深度分析与专业领域对话"},goals:{title:"目标追踪",subtitle:"跟踪关键业务指标和目标进展"},settings:{title:"系统设置",subtitle:"管理账户、智能体和系统配置"}},fnn=5*60*1e3,pnn=3;function hnn(e={}){const{showAside:t=!0,showLogout:n=!1,onLogout:r,presetAgents:i,webhookId:a,onReady:o,initialAgentId:s,initialPlaybookId:l,initialPlaybookParams:c}=e,u=localStorage.getItem("sso_token")||"",d=localStorage.getItem("sso_domain")||"maiduo",f=localStorage.getItem("sso_company")||"",h=`${Gi()}/api/v1/oss/upload2`,g=m.useCallback(async rt=>{const{data:dt}=await BE({playbook_id:rt});return dt},[]),v=m.useCallback(rt=>Ymt({session_id:rt.session_id||"",name:rt.name,description:rt.description}),[]),y=m.useCallback(rt=>kEe({session_id:rt.session_id||"",user_hint:rt.user_hint||""}),[]),{activeAgent:x,setActiveAgent:w,agents:S,playbooks:_,userPlaybooks:C,userPlaybooksLoading:$,childAgents:E,loading:k,loadAgents:T,loadPlaybooks:I,loadUserPlaybooks:P,playbooksLoaded:N}=onn({presetAgents:i,initialAgentId:s}),[A,M]=m.useState(()=>!!s),[R,L]=m.useState(!1),[z,j]=m.useState(!1),[O,V]=m.useState([]),[B,D]=m.useState(0),F=m.useRef(!1),{executing:H,stopping:W,executingRef:K,queueStatus:U,sendMessage:q,executePlaybook:Q,respondToProposal:G,stopCurrent:X,retrigger:J,abort:Y}=QQ({activeAgent:x,ssoToken:u,ssoDomain:d,ssoCompany:f,onMessagesUpdate:rt=>Z.setMessages(rt),onRecommendationsUpdate:V});m.useEffect(()=>{F.current&&!H&&D(rt=>rt+1),F.current=H},[H]);const Z=snn({activeAgent:x,webhookId:a,executePlaybook:Q,isExecutingRef:K,ssoToken:u,ssoDomain:d,ssoCompany:f}),{widgets:re,setWidgets:ee,loadDailyReports:te}=cnn({activeAgent:x,webhookId:a,ssoToken:u,ssoDomain:d,ssoCompany:f}),oe=unn();dnn();const[fe,he]=m.useState(()=>localStorage.getItem("wandox_sidebar_agent_mode")==="true"),ye=m.useCallback(()=>{he(rt=>{const dt=!rt;return localStorage.setItem("wandox_sidebar_agent_mode",String(dt)),dt})},[]),[Te,Ee]=m.useState(!1),[we,le]=m.useState(!1),[se,ne]=m.useState(!1),[ge,be]=m.useState(!1),[Ce,Ae]=m.useState(null),[je,ce]=m.useState(!1),[de,_e]=m.useState(null),[Me,Re]=m.useState(""),[Ie,De]=m.useState(null),[Ue,nt]=m.useState("chat"),[ct,ht]=m.useState(null),Ve=m.useCallback(()=>{Ee(!0),le(!1)},[]),Ye=m.useCallback(()=>{Ee(!1),le(!1)},[]),[Se,me]=m.useState(""),[pe,xe]=m.useState(0),[Le,$e]=m.useState(!1),[ze,Qe]=m.useState(!1),[it,st]=m.useState(!1),[Ft,Ne]=m.useState(""),ke=m.useRef(null),Ke=m.useRef(!1),[Je,We]=m.useState(null),[Oe,Xe]=m.useState(!1),at=k||Z.loading,mt=m.useCallback(rt=>{Ae(()=>rt)},[]);m.useEffect(()=>{o&&o({showInspectionResults:rt=>{We(rt||null),Xe(!0)}})},[o]),m.useEffect(()=>{M(!!s),L(!1),j(!1)},[s,l,c]);const ot=m.useMemo(()=>(i||[]).map(rt=>rt.agent_id||rt.agent_code||"").join("|"),[i]);m.useEffect(()=>{T()},[ot]),m.useEffect(()=>{if(x)return V([]),I(),()=>{K.current&&Y()}},[x,a,u,d,f]),m.useEffect(()=>{if(Ue!=="professional"){Ke.current=!1;return}if(!x)return;Ke.current||(Z.loadMessagesAndDailyReport(),te()),Ke.current=!1;let rt=0,dt=null;return dt=setInterval(async()=>{try{await te(),rt=0}catch{rt++,rt>=pnn&&dt&&(clearInterval(dt),dt=null)}},fnn),()=>{dt&&clearInterval(dt)}},[Ue,x,a,u,d,f]);const wt=S.find(rt=>rt.is_main)??S[0],Pt=(wt==null?void 0:wt.questions)||[];m.useEffect(()=>{xe(0),$e(!1)},[wt==null?void 0:wt.agent_id]),m.useEffect(()=>{if(Pt.length<=1||ze)return;let rt;const dt=setInterval(()=>{$e(!0),rt=setTimeout(()=>{xe(ut=>(ut+1)%Pt.length),$e(!1)},350)},3500);return()=>{clearInterval(dt),clearTimeout(rt)}},[Pt.length,ze]),m.useEffect(()=>{if(ke.current&&x&&x!=="default"){const rt=ke.current;ke.current=null,q(rt)}},[x,q]),m.useEffect(()=>{if(!s||!A||!x||x==="default"||S.length===0)return;!!UR(S,s)||M(!1)},[s,A,x,S]),m.useEffect(()=>{!s||l||R||!x||x==="default"||!S.find(dt=>_l(dt,x)&&_l(dt,s))||(L(!0),nt("professional"),oe.clearDashboard(),M(!1))},[s,l,R,x,S,oe]),m.useEffect(()=>{var vi;if(!s||!l||z||!x||x==="default"||!N||!S.find(Bi=>_l(Bi,x)&&_l(Bi,s)))return;const dt=_.find(Bi=>qOe(Bi,l));if(!dt){nt("professional"),Ze.error(`指定的剧本(${l})不存在,已切换到智能体界面`),j(!0),M(!1);return}j(!0),nt("professional"),Ke.current=!0,Z.setMessages([]),oe.clearDashboard(),De(null),Re("");const ut=c||{},Pn=Object.keys(ut).length>0,Mr=(dt.input_fields??[]).filter(Bi=>{if(!Bi.required)return!1;const Sa=ut[Bi.name];return Sa==null||Sa===""});if((((vi=dt.input_fields)==null?void 0:vi.length)??0)>0&&(!Pn||Mr.length>0)){De(dt),M(!1);return}Q({message:dt.name,playbook_id:l,playbook_params:ut}),M(!1)},[s,l,z,x,N,S,_,c]);const Yt=m.useCallback(rt=>{K.current&&(Y(),Ze.info("已中止当前剧本,切换智能体")),w(rt),Re(""),De(null),oe.clearDashboard(),Z.setMessages([]),ee([])},[Y,K,w,oe,Z,ee]),Un=(rt,dt)=>{const ut=(dt??Se).trim()||Pt[pe%Pt.length]||"",Pn=rt||(wt==null?void 0:wt.agent_id);!ut||!Pn||(me(""),st(!0),Z.setMessages([]),x===Pn?q(ut):(Ke.current=!0,ke.current=ut,w(Pn)))},ur=(rt,dt)=>{oe.handleDashboardPreview(rt,dt),nt("chat"),w("default")},zn=()=>{oe.handleSolidifyComplete(),nt("chat"),w("default")},Fn=rt=>{nt(rt),(rt==="goals"||rt==="settings"||rt==="plan"||rt==="chat")&&oe.clearDashboard()},Da=()=>{le(!1),be(!0),oe.ensureSolidifiedPlaybooksLoaded()},Nr=rt=>{be(!1),oe.handleSolidifiedPlaybookClick(rt),nt("chat"),w("default"),Re(""),De(null)},Ar=()=>{var rt,dt;if(oe.dashboardData)return b.jsx(eDe,{data:oe.dashboardData,showSaveButton:oe.dashboardShowSaveButton,onSaveSuccess:oe.loadSolidifiedPlaybooks,onSaveDashboard:v,onPreviewDashboard:y,title:oe.getCurrentSolidifiedPlaybookName()||void 0,customParamsForm:oe.solidifyInputParams.length>0?b.jsx(G7t,{inputParams:oe.solidifyInputParams,onSearch:oe.handleSolidifyParamsSearch,loading:oe.solidifyLoading}):void 0,showGlobalFilter:oe.solidifyInputParams.length>0});switch(Ue){case"chat":return b.jsx(FQ.Provider,{value:{onExecutePlaybook:Q,getPlaybookDetail:g,ossUploadUrl:h,ssoToken:u,ssoDomain:d,ssoCompany:f,onFillPlaybookParams:ut=>{const Pn={playbook_id:ut.playbookId,name:ut.playbookName,input_fields:ut.inputFields,initial_params:ut.initialParams,playbook_type:ut.playbookType};De(Pn),nt("professional")}},children:b.jsx(ann,{agentLoading:k,mainAgentForHub:wt,mainAgentQuestions:Pt,agents:S,hubChatOpen:it,setHubChatOpen:st,hubChatInput:Se,setHubChatInput:me,hubScrollIdx:pe,hubScrollFading:Le,onHubChatSend:Un,onHubInputFocus:()=>Qe(!0),onHubInputBlur:()=>Qe(!1),messages:Z.messages,executing:H,hubInlineChatInput:Ft,setHubInlineChatInput:Ne,onHubInlineSend:(ut,Pn)=>{wt!=null&&wt.agent_id&&(x!==wt.agent_id&&w(wt.agent_id),q(ut,void 0,Pn))},onEnterProfessional:ut=>{ut&&w(ut),Re(""),De(null),oe.clearDashboard(),ee([]),nt("professional")},playbooks:_,executePlaybook:Q,onRequestPlaybookParams:De,clearMessages:()=>Z.setMessages([]),onAbort:Y,onRespondToProposal:G,ssoToken:u,ssoDomain:d,ssoCompany:f})});case"goals":return b.jsx(eyt,{});case"settings":return b.jsx(TWt,{});case"plan":return b.jsx(Ktn,{embedded:!0,onHeaderChange:ht,onCockpitEnter:Ve,onCockpitExit:Ye});case"professional":return b.jsxs(b.Fragment,{children:[b.jsx(sWt,{title:((rt=S.find(ut=>_l(ut,x)))==null?void 0:rt.name)||"Wandox智能体",agentSwitcher:fe?void 0:b.jsxs("div",{style:{display:"inline-flex",alignItems:"center",height:34,background:"#fff",border:"1px solid #e5e0f0",borderRadius:10,boxSizing:"border-box",overflow:"hidden"},children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"0 0 0 8px"},children:[b.jsx("div",{style:{width:22,height:22,flexShrink:0},children:ag((dt=S.find(ut=>_l(ut,x)))==null?void 0:dt.icon)}),b.jsx(tn,{value:x,onChange:ut=>Yt(ut),options:S.map(ut=>({value:ut.agent_id,label:ut.name})),variant:"borderless",suffixIcon:b.jsx(nw,{style:{color:"#9275ff",verticalAlign:"middle"}}),style:{fontWeight:600,fontSize:14,minWidth:100,color:"#4a3a6a"},popupMatchSelectWidth:!1})]}),b.jsx("button",{type:"button",onClick:ye,title:"切换为侧边栏选择",style:{display:"flex",alignItems:"center",justifyContent:"center",width:34,height:"100%",cursor:"pointer",color:"#b0a0c8",borderLeft:"1px solid #e5e0f0",transition:"all 0.15s",background:"none",border:"none",padding:0},onMouseEnter:ut=>{ut.currentTarget.style.color="#7c3aed",ut.currentTarget.style.background="#f5f0ff"},onMouseLeave:ut=>{ut.currentTarget.style.color="#b0a0c8",ut.currentTarget.style.background="transparent"},children:b.jsx(dse,{style:{fontSize:13}})})]}),count:re.length,widgets:re,activeAgent:x,agents:S,childAgents:E,ssoDomain:d,ssoToken:u,ssoCompany:f,onWidgetsUpdate:ee,onExecuteComplete:()=>{te()},externalRobotName:Je,externalShowPanel:Oe}),b.jsx($Oe,{messages:Z.messages,playbooks:_,messagesTotal:Z.messagesTotal,loadMoreMessages:Z.loadMoreMessages,loading:at,executing:H,ssoToken:u,ssoDomain:d,ssoCompany:f,activeAgent:x,webhookId:a,onExecutePlaybook:Q,onSolidifySuccess:oe.loadSolidifiedPlaybooks,onDashboardPreview:ur,onSolidifyComplete:zn,onFillPlaybookParams:ut=>{const Pn={playbook_id:ut.playbookId,name:ut.playbookName,input_fields:ut.inputFields,initial_params:ut.initialParams,playbook_type:ut.playbookType};De(Pn)},onActionClick:ut=>{ut.action_id?(ne(!0),Ce&&Ce({action_id:ut.action_id,action_params:ut.params})):ut.playbook_id&&Q({message:ut.display_name||"执行",playbook_id:ut.playbook_id,...ut.params?{playbook_params:ut.params}:{}})},onExecuteComplete:()=>{te()},onRespondToProposal:G,onRetrigger:J}),b.jsxs("div",{className:"chat-input-area",children:[b.jsx(DOe,{playbooks:_,playbookLoading:k,onPlaybookClick:Q,onSelectPlaybook:ut=>{De(ut)},recommendations:O,userPlaybooks:C,userPlaybooksLoading:$,onLoadUserPlaybooks:P,agentId:Jp(S.find(ut=>_l(ut,x)))||x,recentRefreshKey:B}),b.jsx(UQ,{executing:H,stopping:W,onStop:X,onSend:q,playbooks:_,recommendations:O,value:Me,onValueChange:Re,onRequestPlaybookParams:De,ssoToken:u,ssoDomain:d,ssoCompany:f})]})]});default:return null}},gi=Ue==="plan"?ct??qye.plan:qye[Ue],To=(Ue==="plan"||!oe.dashboardData)&&Ue!=="professional"&&Ue!=="chat";return b.jsx(Bvt,{children:b.jsxs(s7t,{children:[b.jsx("div",{className:`wandox-aside-overlay ${we?"wandox-aside-overlay--visible":""}`,onClick:()=>le(!1),onKeyDown:rt=>rt.key==="Escape"&&le(!1),role:"button",tabIndex:0,"aria-label":"关闭侧边栏"}),t&&b.jsx(a7t,{active:x,agents:S,onChange:rt=>{le(!1),Yt(rt)},collapsed:Te,onToggle:()=>Ee(rt=>!rt),className:we?"wandox-aside--mobile-open":"",activeView:Ue,onViewChange:Fn,onToolboxOpen:Da,showLogout:n,onLogout:r,sidebarAgentMode:fe,onToggleSidebarMode:ye,onAgentSelect:rt=>Yt(rt)}),t&&Te&&b.jsx("button",{type:"button",className:"wandox-aside-floating-open",onClick:()=>Ee(!1),"aria-label":"展开侧边栏",title:"展开侧边栏",children:b.jsx(dse,{})}),b.jsxs("div",{className:"wandox-workspace",children:[b.jsxs("div",{className:"wandox-mobile-header",children:[b.jsx("button",{type:"button",className:"wandox-mobile-menu-btn",onClick:()=>{Ee(!1),le(!0)},children:"☰"}),b.jsx("h1",{className:"wandox-mobile-title",children:"Wandox"}),n&&r?b.jsx("button",{type:"button",onClick:r,style:{width:40,height:40,background:"transparent",border:"none",cursor:"pointer"},children:"退出"}):b.jsx("div",{style:{width:40}})]}),To&&b.jsxs("div",{className:"wandox-workspace-topbar",children:[b.jsxs("div",{className:"wandox-workspace-topbar-info",children:[b.jsx("h1",{className:"wandox-workspace-topbar-title",children:(gi==null?void 0:gi.title)??"您好,欢迎使用 AI 智能体"}),b.jsx("p",{className:"wandox-workspace-topbar-subtitle",children:(gi==null?void 0:gi.subtitle)??""})]}),b.jsx("div",{className:"wandox-workspace-topbar-actions",children:Ue==="plan"?ct==null?void 0:ct.actions:null})]}),b.jsx("div",{className:`wandox-workspace-container${Ue==="plan"?" wandox-workspace-container--automation":""}`,children:Ar()})]}),b.jsx(Q7t,{open:ge,loading:oe.solidifiedPlaybooksLoading,playbooks:oe.solidifiedPlaybooks,activePlaybookId:oe.activeSolidifiedPlaybook,onClose:()=>be(!1),onPlaybookClick:Nr,onPlaybookDelete:oe.handleSolidifiedPlaybookDelete}),b.jsx(gOe,{open:se,ssoToken:u,ssoDomain:d,ssoCompany:f,onClose:()=>ne(!1),onExecuteAction:mt,onExecuteComplete:()=>{setTimeout(()=>{te()},1e3)}}),b.jsx(Xtn,{open:je,actionId:(de==null?void 0:de.action_id)||"",actionName:(de==null?void 0:de.display_name)||"",defaultParams:de==null?void 0:de.params,onCancel:()=>{ce(!1),_e(null)},onExecute:rt=>{ce(!1),ne(!0),Ce&&de&&Ce({action_id:de.action_id,action_params:rt}),_e(null)}}),b.jsx(W7t,{open:!!Ie,playbook:Ie,onClose:()=>De(null),onSubmit:(rt,dt)=>{De(null),Q({message:rt.name,playbook_id:rt.playbook_id,playbook_params:dt})}}),A&&b.jsx(o7t,{}),b.jsx(Ytn,{queueStatus:U})]})})}const E4e=e=>{if(e){if("enableCustomerService"in e)return e.enableCustomerService;if("enable_customer_service"in e)return e.enable_customer_service}},Kye=e=>{const t={};return("agentId"in e||"agent_id"in e)&&(t.agentId=an(e.agentId)||an(e.agent_id)||void 0),("playbookId"in e||"playbook_id"in e)&&(t.playbookId=an(e.playbookId)||an(e.playbook_id)||void 0),("playbookParams"in e||"playbook_params"in e)&&(t.playbookParams=e.playbookParams??e.playbook_params),"message"in e&&(t.message=e.message),t},Yye=e=>{const t=E4e(e);return{hasExplicitTargetOptions:!!e&&["playbookId","playbook_id","playbookParams","playbook_params","message","agentId","agent_id"].some(r=>r in e),playbookId:an(e==null?void 0:e.playbookId)||an(e==null?void 0:e.playbook_id)||void 0,playbookParams:(e==null?void 0:e.playbookParams)??(e==null?void 0:e.playbook_params),message:e==null?void 0:e.message,agentId:an(e==null?void 0:e.agentId)||an(e==null?void 0:e.agent_id)||void 0,enableCustomerService:t}},mnn=e=>Array.isArray(e)?{agents:e,agentId:void 0,playbookId:void 0}:{agents:e==null?void 0:e.agents,agentId:an(e==null?void 0:e.agentId)||an(e==null?void 0:e.agent_id)||void 0,playbookId:an(e==null?void 0:e.playbookId)||an(e==null?void 0:e.playbook_id)||void 0,playbookParams:_o((e==null?void 0:e.playbookParams)??(e==null?void 0:e.playbook_params))},_o=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,T4e=e=>Array.isArray(e)?e.map(t=>String(t||"").trim()).filter(Boolean):[],Ab=e=>typeof e=="string"&&e.trim()?e.trim():void 0,I4e=(e={})=>{const t=e.dataParams||e.data_params||{};return{executionParams:T4e(e.executionParams||e.execution_params||t.executionParams||t.execution_params),defaultParams:_o(e.defaultParams||e.default_params||t.defaultParams||t.default_params),paramSchema:_o(e.paramSchema||e.param_schema||t.paramSchema||t.param_schema),sdkConfig:e.sdkConfig||e.sdk_config||t.sdkConfig||t.sdk_config}},gnn=(e={})=>{const t=I4e(e),n=_o(e.playbookParams??e.playbook_params??e.params);return{...t.defaultParams||{},...n||{}}},k4e=(e={})=>({agentId:an(e.agentId)||an(e.agent_id)||void 0,playbookId:an(e.playbookId)||an(e.playbook_id)||void 0,playbookParams:gnn(e),message:e.message,sessionId:an(e.sessionId)||an(e.session_id)||void 0}),vnn={bottomRight:"bottom-right",bottomLeft:"bottom-left",topRight:"top-right",topLeft:"top-left",center:"center","bottom-right":"bottom-right","bottom-left":"bottom-left","top-right":"top-right","top-left":"top-left"},ynn=e=>e&&vnn[e]||"bottom-right",Xye=e=>{if(!(e==null||e===""))return typeof e=="number"?`${e}px`:e},IP=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),oF=e=>{if(!(e==null||e==="")){if(e==="true")return!0;if(e==="false")return!1}},sF=e=>{if(!(e==null||e===""))return/^\d+$/.test(e)?Number(e):e},bnn=e=>{const t=new Set,n=e.paramSchema||e.param_schema||{},r=e.executionParams||e.execution_params||[];for(const[i,a]of Object.entries(n))(a==null?void 0:a.source)==="runtime"&&t.add(i);for(const i of r){const a=String(i||"").trim();a&&t.add(a)}return Array.from(t).map(i=>({name:i,schema:n[i]||{}}))},P4e=e=>{const t=(e||"").trim();if(!t)return{};let n;try{n=JSON.parse(t)}catch{n=gEe(t)}const r=_o(n);if(!r)throw new Error("[Wandox] data-params must be an object");return r},N4e=e=>typeof e=="string"?{...P4e(e)}:_o(e)||{},lF=e=>{const t=N4e(e),n=_o(t.defaultParams||t.default_params);return{...Object.fromEntries(Object.entries(t).filter(([i])=>i!=="defaultParams"&&i!=="default_params")),...n||{}}},xnn=e=>{const t=_o(e);return _o(t==null?void 0:t.data)||t||{}},kP=e=>typeof e=="string"||typeof e=="number"?an(e):"",Z2=e=>e.schema.label||e.name,Zye={string:"string",text:"string",textarea:"string",number:"number",integer:"integer",int:"integer",float:"float",boolean:"boolean",bool:"boolean",array:"array",list:"array",object:"object",file:"file",date:"date",daterange:"dateRange",date_range:"dateRange",datetime:"datetime",date_time:"datetime","date-time":"datetime",datetimerange:"datetimeRange",datetime_range:"datetimeRange",timerange:"timeRange",time_range:"timeRange",time:"time"},ny=e=>{const t=String(e.schema.type||"string").trim();return Zye[t]||Zye[t.toLowerCase()]||"string"},Qye=e=>e.schema.placeholder||e.schema.description||`请输入${Z2(e)}`,N1=(e,t=ny(e))=>({type:t,format:typeof e.schema.format=="string"?e.schema.format:void 0,picker:typeof e.schema.picker=="string"?e.schema.picker:void 0,show_time:typeof e.schema.show_time=="boolean"?e.schema.show_time:void 0,range:typeof e.schema.range=="boolean"?e.schema.range:void 0}),$l=(e,t=ny(e))=>bu(N1(e,t))||(t.startsWith("time")?"HH:mm:ss":"YYYY-MM-DD"),A4e=e=>{const t=e.schema.max_files??e.schema.maxFiles??e.schema.maxCount??1,n=Number(t);return Number.isFinite(n)&&n>0?n:1},M4e=e=>{const t=e.schema.file_type??e.schema.fileType??e.schema.accept;return(Array.isArray(t)?t:typeof t=="string"?[t]:[]).flatMap(r=>String(r||"").split(/[\s,]+/)).map(r=>r.trim()).filter(Boolean)},Pee=e=>{const t=e.trim();return!t||t.includes("/")||t.startsWith(".")||t.includes("*")?t:`.${t}`},wnn=e=>{const t=M4e(e).map(Pee).filter(Boolean);return t.length>0?t.join(","):void 0},Snn=e=>e.map(Pee).filter(Boolean).join("、"),_nn=(e,t)=>{if(t.length===0)return!0;const n=e.name.toLowerCase(),r=e.type.toLowerCase();return t.map(i=>Pee(i).toLowerCase()).some(i=>!i||i==="*"||i==="*/*"?!0:i.endsWith("/*")?r.startsWith(i.slice(0,-1)):i.includes("/")?r===i:n.endsWith(i))},Cnn=e=>{const t=e.schema.file_templates??e.schema.fileTemplates;return Array.isArray(t)?t.map(n=>{const r=_o(n),i=Ab(r==null?void 0:r.path);return i?{name:Ab(r==null?void 0:r.name)||"下载模板",path:i}:null}).filter(n=>!!n):[]},qS=e=>!!e&&typeof e=="object"&&typeof e.format=="function",XN=e=>{if(!e)return null;if(In.isDayjs(e))return e.isValid()?e:null;if(typeof e!="string"&&typeof e!="number"&&!(e instanceof Date))return null;const t=In(e);return t.isValid()?t:null},cF=e=>{if(!e)return null;if(In.isDayjs(e))return e.isValid()?e:null;if(typeof e!="string")return XN(e);const t=e.includes(" ")?e:`2000-01-01 ${e}`,n=In(t);return n.isValid()?n:null},PP=(e,t)=>{const n=Array.isArray(e)?e:e&&typeof e=="object"&&("start"in e||"end"in e)?[e.start,e.end]:void 0;if(!n||n.length!==2)return null;const r=t(n[0]),i=t(n[1]);return r&&i?[r,i]:null},$nn=e=>{if(typeof e=="string")return e;if(e==null||e==="")return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}},Enn=e=>(Array.isArray(e)?e:e?[e]:[]).map((n,r)=>{const i=_o(n),a=String(i?i.url||i.response||"":n||""),o=String(i?i.name||a.split("/").pop()||`file_${r+1}`:a.split("/").pop()||n||`file_${r+1}`);return{uid:String((i==null?void 0:i.uid)||`runtime-file-${r}`),name:o,status:"done",url:a||void 0,response:i==null?void 0:i.response}}),R4e=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&("fileList"in e||"manualUrl"in e),Nee=e=>Array.isArray(e)?e:R4e(e)&&Array.isArray(e.fileList)?e.fileList:[],D4e=e=>R4e(e)?String(e.manualUrl||""):"",sG=(e,t)=>({fileList:e,manualUrl:t}),Tnn=(e,t)=>{const n=t[e.name]??e.schema.defaultValue??e.schema.default,r=ny(e);return n==null?r==="boolean"?!1:r==="file"?sG([],""):"":r==="array"||r==="object"?$nn(n):r==="date"&&y1(N1(e,r))?PP(n,XN):r==="time"&&y1(N1(e,r))?PP(n,cF):r==="date"||r==="datetime"?XN(n):r==="dateRange"||r==="datetimeRange"?PP(n,XN):r==="time"?cF(n):r==="timeRange"?PP(n,cF):r==="file"?sG(Enn(n),""):n},O4e=e=>{const t=_o(e.response),n=_o(t==null?void 0:t.data);return Ab(n==null?void 0:n.url)||Ab(t==null?void 0:t.url)||Ab(e.url)||Ab(e.response)},L4e=(e,t)=>{const n=ny(e);if(n==="boolean")return!!t;if(n==="number"||n==="integer"||n==="float"){if(t===""||t==null)return;const r=Number(t);return Number.isNaN(r)?t:n==="integer"?Math.trunc(r):r}if(n==="array"||n==="object")return t===""||t==null?void 0:typeof t!="string"?t:JSON.parse(t);if((n==="date"||n==="time")&&y1(N1(e,n)))return Array.isArray(t)?t.map(r=>qS(r)?r.format($l(e,n)):r):t;if(n==="date"||n==="datetime")return qS(t)?t.format($l(e,n)):t;if(n==="dateRange"||n==="datetimeRange")return Array.isArray(t)?t.map(r=>qS(r)?r.format($l(e,n)):r):t;if(n==="time")return qS(t)?t.format($l(e,n)):t;if(n==="timeRange")return Array.isArray(t)?t.map(r=>qS(r)?r.format($l(e,n)):r):t;if(n==="file"){const r=Nee(t),i=D4e(t).trim(),a=r.map(O4e).filter(Boolean);return i&&a.push(i),A4e(e)<=1?a[a.length-1]:a}return t},j4e=e=>e==null||e===""||Array.isArray(e)&&e.length===0,Inn=async(e,t)=>{const n=ny(e),r=Z2(e);if(n==="file"&&Nee(t).some(a=>a.status==="uploading"))throw new Error(`${r}正在上传,请稍后`);let i;try{i=L4e(e,t)}catch{throw new Error(n==="array"?`${r}必须是合法 JSON 数组`:`${r}必须是合法 JSON 对象`)}if(e.schema.required&&j4e(i))throw new Error(`请输入${r}`);if(n==="array"&&i!==void 0&&!Array.isArray(i))throw new Error(`${r}必须是 JSON 数组`);if(n==="object"&&i!==void 0&&!_o(i))throw new Error(`${r}必须是 JSON 对象`)};function knn({field:e,value:t,onChange:n,customRequest:r}){const i=Nee(t),a=D4e(t),o=Cnn(e),s=A4e(e),l=s<=1,c=i.some(h=>h.status==="uploading"),u=M4e(e),d=(h,g)=>{n==null||n(sG(h,g))},f=h=>{if(_nn(h,u))return!0;const g=Snn(u);return Ze.warning(g?`${Z2(e)}仅支持上传 ${g} 文件`:"文件类型不支持"),zc.LIST_IGNORE},p=({file:h,fileList:g})=>{if(!l){d(g,a);return}if(h.status==="done"){d([],O4e(h)||a);return}if(h.status==="uploading"){d(g,a);return}d([],a)};return b.jsxs("div",{className:"wandox-sdk-runtime-file",children:[o.length>0&&b.jsx("div",{className:"wandox-sdk-runtime-file__templates",children:b.jsx("div",{className:"wandox-sdk-runtime-file__template-list",children:o.map((h,g)=>b.jsxs("a",{className:"wandox-sdk-runtime-file__template",href:h.path,target:"_blank",rel:"noreferrer",children:[b.jsx(n$e,{}),b.jsx("span",{children:h.name})]},`${h.path}-${g}`))})}),b.jsxs("div",{className:"wandox-sdk-runtime-file__controls",children:[b.jsx(zc,{accept:wnn(e),beforeUpload:f,customRequest:r,fileList:l?i.filter(h=>h.status==="uploading"):i,maxCount:s,showUploadList:!l,onChange:p,children:b.jsx(Et,{icon:b.jsx(OE,{}),loading:l&&c,children:"点击上传"})}),b.jsx(Kt,{value:a,placeholder:"或粘贴外网图片 / 文件地址",allowClear:!0,onChange:h=>d(i,h.target.value)})]})]})}function Pnn({options:e,baseParams:t,fields:n,ssoToken:r,ssoDomain:i,ssoCompany:a,popup:o=!1,popupConfig:s,onSubmit:l,onClose:c}){const u=m.useMemo(()=>Object.fromEntries(n.map(C=>[C.name,Tnn(C,t)])),[t,n]),[d]=pn.useForm(),f=ynn(s==null?void 0:s.placement),p=(s==null?void 0:s.zIndex)??2147483e3,h=o?{width:Xye(s==null?void 0:s.width),height:Xye(s==null?void 0:s.height),zIndex:p}:void 0,g={zIndex:p>0?p-1:p},v=e.message||"填写剧本参数",y=()=>async({file:C,onSuccess:$,onError:E})=>{try{const k=new FormData;k.append("file",C);const T=await fetch(`${Gi()}/api/v1/oss/upload2`,{method:"POST",headers:{Authorization:`Bearer ${r}`,"X-Tenant-ID":a,"X-Domain":i},body:k}),I=await T.json();if(!T.ok||(I==null?void 0:I.success)===!1)throw new Error((I==null?void 0:I.message)||`HTTP ${T.status}`);$==null||$(I)}catch(k){E==null||E(k instanceof Error?k:new Error("文件上传失败"))}},x=C=>{const $={};for(const E of n){const k=L4e(E,C[E.name]);j4e(k)||($[E.name]=k)}l($)},w=C=>ny(C)==="boolean"?{valuePropName:"checked"}:{},S=C=>{const $=ny(C),E=Z2(C),k=Array.isArray(C.schema.options)?C.schema.options:[];if(k.length>0)return b.jsx(tn,{style:{width:"100%"},placeholder:C.schema.placeholder||`请选择${E}`,options:k.map(T=>{const I=_o(T),P=I?I.value:T,N=String(I?I.label||P||"":T);return{value:P,label:N}})});switch($){case"number":case"integer":case"float":return b.jsx(zo,{style:{width:"100%"},precision:$==="integer"?0:void 0,placeholder:Qye(C)});case"boolean":return b.jsx(pf,{children:"启用"});case"array":case"object":return b.jsx(Kt.TextArea,{autoSize:!0,placeholder:C.schema.placeholder||"请输入 JSON"});case"file":return b.jsx(knn,{field:C,customRequest:y()});case"date":{const T=N1(C,$),I=$l(C,$),P={style:{width:"100%"},picker:b1(I,T.picker),showTime:GQ(T)?{format:ov(I)}:!1,format:I};return y1(T)?b.jsx(ui.RangePicker,{...P,placeholder:["开始时间","结束时间"]}):b.jsx(ui,{...P,placeholder:C.schema.placeholder||"选择日期"})}case"dateRange":{const T=$l(C,$);return b.jsx(ui.RangePicker,{style:{width:"100%"},picker:b1(T),format:T,placeholder:["开始日期","结束日期"]})}case"datetime":{const T=$l(C,$);return b.jsx(ui,{style:{width:"100%"},showTime:{format:ov(T)},format:T,placeholder:C.schema.placeholder||"选择日期时间"})}case"datetimeRange":{const T=$l(C,$);return b.jsx(ui.RangePicker,{style:{width:"100%"},showTime:{format:ov(T)},format:T,placeholder:["开始日期时间","结束日期时间"]})}case"time":return y1(N1(C,$))?b.jsx(Ua.RangePicker,{style:{width:"100%"},format:$l(C,$),placeholder:["开始时间","结束时间"]}):b.jsx(Ua,{style:{width:"100%"},format:$l(C,$),placeholder:C.schema.placeholder||"选择时间"});case"timeRange":return b.jsx(Ua.RangePicker,{style:{width:"100%"},format:$l(C,$),placeholder:["开始时间","结束时间"]});default:return b.jsx(Kt.TextArea,{autoSize:!0,placeholder:Qye(C)})}},_=b.jsxs("div",{className:`wandox-sdk-exec wandox-root${o?` wandox-sdk-exec--popup wandox-sdk-exec--${f}`:""}`,style:h,children:[b.jsxs("div",{className:"wandox-sdk-exec__header",children:[b.jsx("div",{className:"wandox-sdk-exec__heading",children:b.jsx("div",{className:"wandox-sdk-exec__title",children:v})}),c&&b.jsx("button",{type:"button",className:"wandox-sdk-exec__close",onClick:c,"aria-label":"关闭",title:"关闭",children:b.jsx(ga,{})})]}),b.jsx("div",{className:"wandox-sdk-exec__body",children:b.jsxs(pn,{form:d,className:"wandox-sdk-runtime-form",initialValues:u,onFinish:x,children:[b.jsx("div",{className:"wandox-sdk-runtime-form__intro",children:"请补充本次执行需要传入的参数。"}),b.jsx("div",{className:"wandox-sdk-runtime-form__fields",children:n.map(C=>b.jsx(pn.Item,{className:"wandox-sdk-runtime-field",name:C.name,label:Z2(C),rules:[{validator:($,E)=>Inn(C,E)}],...w(C),children:S(C)},C.name))}),b.jsxs("div",{className:"wandox-sdk-runtime-form__actions",children:[c&&b.jsx(Et,{className:"wandox-sdk-runtime-form__secondary",onClick:c,children:"取消"}),b.jsx(Et,{type:"primary",htmlType:"submit",className:"wandox-sdk-runtime-form__primary",children:"执行"})]})]})})]});return o&&(s!=null&&s.mask)?b.jsxs(b.Fragment,{children:[s.maskClosable===!1?b.jsx("div",{className:"wandox-sdk-exec-mask",style:g,"aria-hidden":"true"}):b.jsx("button",{type:"button",className:"wandox-sdk-exec-mask",style:g,onClick:c,"aria-label":"关闭参数弹窗"}),_]}):_}function Nnn({options:e,runtimeFields:t,ssoToken:n,ssoDomain:r,ssoCompany:i,defaultAgentId:a,defaultPlaybookId:o,popup:s=!1,popupConfig:l,onClose:c,onReady:u}){const d=m.useMemo(()=>k4e(e),[e]),[f,p]=m.useState(t.length>0?null:{});return f===null?b.jsx(Pnn,{options:e,baseParams:d.playbookParams||{},fields:t,ssoToken:n,ssoDomain:r,ssoCompany:i,popup:s,popupConfig:l,onClose:c,onSubmit:h=>p(h)}):b.jsx(ZOe,{options:{...d,playbookParams:{...d.playbookParams||{},...f}},ssoToken:n,ssoDomain:r,ssoCompany:i,defaultAgentId:a,defaultPlaybookId:o,popup:s,popupConfig:l,executionMode:"run",onClose:c,onReady:u})}const Aee={instance:null,floatingManager:null,init(e){const t=this;if(this.instance)return this.instance;if(!e.token||!e.domain)throw new Error("[Wandox] token and domain are required");const{enableCustomerService:n,enable_customer_service:r,agentId:i,agent_id:a,playbookId:o,playbook_id:s,...l}=e,c={...l},u=c.token,d=c.domain,f=c.companyCode||"",p=e.username||"",h=e.userId||e.user_id||"",g=kY();localStorage.setItem("sso_token",u),localStorage.setItem("sso_domain",d),p&&localStorage.setItem("sso_username",p),h&&localStorage.setItem("sso_user_id",h),f&&localStorage.setItem("sso_company",f),t.floatingManager=new XOe(u,d,f,g);let v=null;const y=new Map,x=new Map,w=new Map,S=new Map;let _=null,C=null,$=null;const E=new Set,k=(G={})=>({page:G.page||1,page_size:G.pageSize||G.page_size||99,status:G.status,is_auth:G.isAuth??G.is_auth}),T=(G={})=>{const X=k(G),J=JSON.stringify(X),Y=x.get(J);if(Y)return Y;const Z=XO(X).then(re=>Array.isArray(re.data)?re.data:[]).catch(re=>{throw x.delete(J),re});return x.set(J,Z),Z},I=G=>{const X=G.trim();if(!X)return Promise.reject(new Error("[Wandox] agentId is required"));const J=y.get(X);if(J)return J;const Y=PY({agent_id:X}).then(Z=>Z.data||{}).catch(Z=>{throw y.delete(X),Z});return y.set(X,Y),Y},P=G=>{if(typeof G!="string")return G;const X=document.querySelector(G);if(!X)throw new Error(`[Wandox] Container ${G} not found`);return X},N=G=>{if(!G)return document;if(typeof G!="string")return G;const X=document.querySelector(G);if(!X)throw new Error(`[Wandox] Container ${G} not found`);return X},A=(G,X,J)=>({element:G,abort:()=>{var Y;return(Y=X())==null?void 0:Y.abort()},rerun:()=>{var Y;return(Y=X())==null?void 0:Y.rerun()},minimize:()=>{var Y;return(Y=X())==null?void 0:Y.minimize()},restore:()=>{var Y;return(Y=X())==null?void 0:Y.restore()},destroy:J}),M=(G,X={},J=!1,Y,Z,re="chat")=>{var oe;const ee=k4e(X);let te=w.get(G);return te?(oe=S.get(G))==null||oe.abort():(te=qg(G),w.set(G,te)),te.render(b.jsx(EC,{queryClient:g,children:b.jsx(ZOe,{options:ee,ssoToken:u,ssoDomain:d,ssoCompany:f,popup:J,popupConfig:Z,executionMode:re,onClose:Y,onReady:fe=>{S.set(G,fe),J&&($=fe)}})})),A(G,()=>S.get(G)||null,()=>{var fe;(fe=S.get(G))==null||fe.abort(),te==null||te.unmount(),w.delete(G),S.delete(G),J&&C===G&&(_=null,$=null,C==null||C.remove(),C=null)})},R=()=>{$==null||$.abort(),_==null||_.unmount(),C&&(w.delete(C),S.delete(C),C.remove()),_=null,C=null,$=null},L=(G,X={},J=!1,Y,Z)=>{var oe;const re=I4e(X),ee=bnn(re);if(ee.length===0)return M(G,X,J,Y,Z,"run");let te=w.get(G);return te?(oe=S.get(G))==null||oe.abort():(te=qg(G),w.set(G,te)),te.render(b.jsx(EC,{queryClient:g,children:b.jsx(Nnn,{options:X,runtimeFields:ee,ssoToken:u,ssoDomain:d,ssoCompany:f,popup:J,popupConfig:Z,onClose:Y,onReady:fe=>{S.set(G,fe),J&&($=fe)}})})),A(G,()=>S.get(G)||null,()=>{var fe;(fe=S.get(G))==null||fe.abort(),te==null||te.unmount(),w.delete(G),S.delete(G),J&&C===G&&(_=null,$=null,C==null||C.remove(),C=null)})},z=(G,X={},J)=>{var re,ee,te,oe,fe,he,ye;const Y=X.popup||{},Z=G.dataset;return IP({...(J==null?void 0:J.popup)||{},...Y,placement:Z.popupPlacement||Y.placement||((re=J==null?void 0:J.popup)==null?void 0:re.placement),mask:oF(G.getAttribute("data-popup-mask"))??Y.mask??((ee=J==null?void 0:J.popup)==null?void 0:ee.mask),maskClosable:oF(G.getAttribute("data-popup-mask-closable"))??Y.maskClosable??((te=J==null?void 0:J.popup)==null?void 0:te.maskClosable),minimizable:oF(G.getAttribute("data-popup-minimizable"))??Y.minimizable??((oe=J==null?void 0:J.popup)==null?void 0:oe.minimizable),width:sF(G.getAttribute("data-popup-width"))??Y.width??((fe=J==null?void 0:J.popup)==null?void 0:fe.width),height:sF(G.getAttribute("data-popup-height"))??Y.height??((he=J==null?void 0:J.popup)==null?void 0:he.height),zIndex:sF(G.getAttribute("data-popup-z-index"))??Y.zIndex??((ye=J==null?void 0:J.popup)==null?void 0:ye.zIndex)})},j=(G,X={})=>{const J=G.getAttribute("data-container"),Y=J==null?void 0:J.trim();return Y||X.container},O=G=>{var X;if(G.hasAttribute("data-container"))return((X=G.getAttribute("data-container"))==null?void 0:X.trim())||""},V=(G,X)=>{var oe;const J=P4e(G.getAttribute("data-params")),Y=J.sdkConfig||J.sdk_config||{},Z=G.dataset,re=j(G,Y),ee=z(G,Y,X),te={...J,dataParams:J,agentId:an(Z.agentId)||an(J.agentId)||an(J.agent_id)||void 0,playbookId:an(Z.playbookId)||an(J.playbookId)||an(J.playbook_id)||void 0,message:Z.message||Z.title||J.message||((oe=G.textContent)==null?void 0:oe.trim())||"剧本执行"};return{container:re,options:te,popupConfig:ee}},B=G=>{const X=G.dataset;return an(G.getAttribute("data-component-id"))||an(G.getAttribute("data-component_id"))||an(X.componentId)||an(X.component_id)},D=G=>{const X=G.getAttribute("data-default-params")||G.getAttribute("data-default_params")||G.getAttribute("data-params");return lF(X)},F=(G={},X={})=>IP({...G,...X,popup:IP({...G.popup||{},...X.popup||{}})}),H=(G={})=>({componentId:an(G.componentId)||an(G.component_id)||void 0,defaultParams:lF(G.defaultParams||G.default_params||G.params),agentId:an(G.agentId)||an(G.agent_id)||void 0,playbookId:an(G.playbookId)||an(G.playbook_id)||void 0,message:G.message,sdkConfig:F(G.sdkConfig||G.sdk_config||{})}),W=async(G={})=>{const X=H(G),J=X.componentId;if(!J)throw new Error("[Wandox] componentId is required");const Y=await Dgt(J),Z=xnn(Y),re=N4e(Z.playbookParams||Z.playbook_params),ee=Z.sdkConfig||Z.sdk_config||re.sdkConfig||re.sdk_config||{},te=F(ee,X.sdkConfig),oe={...lF(re.defaultParams||re.default_params),...X.defaultParams,component_id:J},fe="container"in G&&G.container!==void 0?G.container||void 0:te.container,he=IP({...te.popup||{},...G.popupConfig||{}}),ye={agentId:X.agentId||kP(Z.agentId)||kP(Z.agent_id)||void 0,playbookId:X.playbookId||kP(Z.playbookId)||kP(Z.playbook_id)||void 0,message:X.message||String(Z.name||Z.title||"剧本执行"),executionParams:T4e(re.executionParams||re.execution_params),defaultParams:oe,paramSchema:_o(re.paramSchema||re.param_schema),sdkConfig:te};return{container:fe,options:ye,popupConfig:he}},K=async(G,X)=>{var re;const J=G.dataset,Y=B(G),Z=z(G,{},X);return W({componentId:Y,defaultParams:D(G),container:O(G),popupConfig:Z,agentId:J.agentId,playbookId:J.playbookId,message:J.message||J.title||((re=G.textContent)==null?void 0:re.trim())||void 0})},U=G=>{if(!G.options.playbookId)throw new Error("[Wandox] playbookId is required");if(G.container)return L(P(G.container),G.options);R();const X=document.createElement("div");X.id="wandox-playbook-execution-popup-root",document.body.appendChild(X),C=X;const J=L(X,G.options,!0,R,G.popupConfig);return _=w.get(X)||null,J},q=(G,X)=>{const J=N(G),Y=async re=>{const ee=re.target;if(!(ee instanceof Element))return;const te=ee.closest('[data-action="playbook"], [data-action="page-component"], [data-component-id], [data-component_id]');if(te instanceof HTMLElement&&!(J instanceof HTMLElement&&!J.contains(te))){re.preventDefault();try{const oe=te.getAttribute("data-action"),fe=B(te),he=oe==="page-component"||fe?await K(te,X):V(te,X);U(he)}catch{}}};J.addEventListener("click",Y);const Z={root:J,destroy:()=>{J.removeEventListener("click",Y),E.delete(Z)}};return E.add(Z),Z},Q=(G,X,J,Y,Z)=>{const re=P(G);return qg(re).render(b.jsx(EC,{queryClient:g,children:b.jsx(hnn,{presetAgents:X,initialAgentId:J,initialPlaybookId:Y,initialPlaybookParams:Z,onReady:te=>{v=te}})})),re};return t.instance={config:c,mountAssistant(G,X){const J=mnn(X),Y=J.agentId,Z=Y?J.playbookId:void 0;return Q(G,J.agents,Y,Z,Z?J.playbookParams:void 0)},getAgents(G){return T(G)},getAgentDetail(G){return I(G)},async getAgentPlaybookGroups(G){return(await I(G)).playbook_groups||[]},enableFloatingBall(){t.floatingManager&&t.floatingManager.enable()},registerFloatingBall(G){t.floatingManager&&t.floatingManager.registerFloatingBall(Kye(G))},setFloatingBallConfig(G){t.floatingManager&&t.floatingManager.setFloatingBallConfig(Kye(G))},clearMessages(){t.floatingManager&&t.floatingManager.clearMessages()},getMessages(){return t.floatingManager?t.floatingManager.getMessages():[]},openDrawer(G){if(t.floatingManager){const X=Yye(G);t.floatingManager.openDrawer(X.playbookId,X.message,X.agentId,!X.hasExplicitTargetOptions,X.playbookParams,X.enableCustomerService)}},openDrawerOnly(G){if(t.floatingManager){const X=Yye(G);t.floatingManager.openDrawerOnly(X.playbookId,X.message,X.agentId,!X.hasExplicitTargetOptions,X.playbookParams,X.enableCustomerService)}},openDrawerWithPlaybook(G){t.floatingManager&&t.floatingManager.openDrawerWithPlaybook({playbookId:an(G.playbookId)||an(G.playbook_id)||void 0,playbookParams:G.playbookParams??G.playbook_params,message:G.message,agentId:an(G.agentId)||an(G.agent_id)||void 0,enableCustomerService:E4e(G)})},mountPlaybookExecution(G,X){return M(P(G),X)},openPlaybookExecution(G,X){R();const J=document.createElement("div");return J.id="wandox-playbook-execution-popup-root",document.body.appendChild(J),C=J,M(J,G,!0,R,X),_=w.get(J)||null,A(J,()=>$,R)},mountPlaybookRun(G,X){return L(P(G),X)},openPlaybookRun(G,X){R();const J=document.createElement("div");return J.id="wandox-playbook-execution-popup-root",document.body.appendChild(J),C=J,L(J,G,!0,R,X),_=w.get(J)||null,A(J,()=>$,R)},async mountPageComponentRun(G,X){const J=await W({...X||{},container:G});return U(J)},async openPageComponentRun(G,X){const J=await W({...G||{},container:"",popupConfig:X});return U(J)},mountPlaybookActions(G,X){return q(G,X)},bindPlaybookActions(G,X){return q(G,X)},closeDrawer(){t.floatingManager&&t.floatingManager.closeDrawer()},showInspectionResults(G){v?v.showInspectionResults(G):t.floatingManager&&t.floatingManager.showInspectionResults(G)},destroy(){t.floatingManager&&(t.floatingManager.destroy(),t.floatingManager=null),R(),w.forEach((G,X)=>{var J;(J=S.get(X))==null||J.abort(),G.unmount()}),w.clear(),S.clear();for(const G of Array.from(E))G.destroy();E.clear(),y.clear(),x.clear(),g.clear(),t.instance=null}},t.instance},getInstance(){return this.instance}};typeof window<"u"&&(window.wandox=Aee);const Ann=Aee;exports.COMMENT=Sq;exports.FloatingManager=XOe;exports.KEYFRAMES=$q;exports.LAYER=m1e;exports.MEDIA=RBe;exports.SCOPE=jBe;exports.SUPPORTS=OBe;exports.commonjsGlobal=Xs;exports.compile=_B;exports.dayjs2=In;exports.dayjsAdvancedFormat=S_e;exports.dayjsCustomParseFormat=mK;exports.getDefaultExportFromCjs=Co;exports.middleware=x1e;exports.serialize=Dx;exports.stringify=CB;exports.wandox=Ann;exports.wandoxSDK=Aee;
|
|
793
|
+
`),k=new Blob([E],{type:"text/csv;charset=utf-8;"}),T=URL.createObjectURL(k),I=document.createElement("a");I.href=T,I.download=`${w}_${S}.csv`,I.click(),URL.revokeObjectURL(T)}else{const C=JSON.stringify(d??l,null,2),$=new Blob([C],{type:"application/json;charset=utf-8;"}),E=URL.createObjectURL($),k=document.createElement("a");k.href=E,k.download=`${w}_${S}.json`,k.click(),URL.revokeObjectURL(E)}},[e,t,v,d,u]);return b.jsxs("div",{className:`rdd-step${s?" rdd-step--fail":""}`,children:[b.jsxs("button",{type:"button",className:"rdd-step-header",onClick:()=>i(x=>!x),children:[b.jsx("span",{className:"rdd-step-idx",children:t+1}),o?b.jsx(Gh,{style:{color:"#52c41a",fontSize:14}}):s?b.jsx(Lf,{style:{color:"#ef4444",fontSize:14}}):b.jsx(fa,{style:{color:"#9ca3af",fontSize:14}}),b.jsx("span",{className:"rdd-step-name",children:e.step_name}),e.duration_ms!=null&&b.jsx("span",{className:"rdd-step-dur",children:ZU(e.duration_ms)}),h&&b.jsx(or,{title:v?"导出 CSV":"导出 JSON",children:b.jsx("span",{className:"rdd-step-export",onClick:y,role:"button",tabIndex:0,onKeyDown:x=>{x.key==="Enter"&&y(x)},children:b.jsx(rw,{style:{fontSize:12}})})}),b.jsx("span",{className:"rdd-step-arrow",children:r?b.jsx(nY,{}):b.jsx(nw,{})})]}),r&&g&&b.jsx("div",{className:"rdd-step-body",ref:a,children:p?b.jsx("div",{className:"rdd-step-error-text",children:p}):b.jsx(Ci,{payload:f})})]})}function AZt({lineage:e}){return e.length===0?b.jsx("div",{className:"rdd-empty",children:"暂无流转记录"}):b.jsx("div",{className:"rdd-lineage",children:e.map((t,n)=>b.jsxs("div",{className:"rdd-lineage-item",children:[b.jsx("div",{className:"rdd-lineage-dot",style:{background:t.status==="accepted"?"#52c41a":"#faad14"}}),n<e.length-1&&b.jsx("div",{className:"rdd-lineage-line"}),b.jsxs("div",{className:`rdd-lineage-card${t.status==="accepted"?" rdd-lineage-card--ok":""}`,children:[b.jsxs("div",{className:"rdd-lineage-row",children:[b.jsx(f2e,{style:{color:"#9ca3af",fontSize:11}}),b.jsxs("span",{children:["流转给 ",b.jsx("strong",{children:t.target_nick_name??t.target_user_id})]}),b.jsx(ji,{color:t.status==="accepted"?"success":t.status==="pending"?"warning":"default",style:{fontSize:10,margin:0},children:t.status==="accepted"?"已接受":t.status==="pending"?"待处理":t.status}),b.jsx("span",{className:"rdd-lineage-time",children:Bje(t.created_at)})]}),t.transfer_message&&b.jsxs("div",{className:"rdd-lineage-msg",children:["💬 ",t.transfer_message]})]})]},n))})}function MZt(){const{activeResult:e,showResultModal:t,setShowResultModal:n,setActiveResult:r}=Er(),[i,a]=m.useState(null),[o,s]=m.useState(!1),[l,c]=m.useState(!1),[u,d]=m.useState("x1"),f=u==="full"?"100vw":u==="x2"?1400:900,p=[{key:"x1",label:"x1"},{key:"x2",label:"x2"},{key:"full",label:"全屏"}];m.useEffect(()=>{if(!(e!=null&&e.execution_id)){a(null);return}s(!0),OEe(e.execution_id).then(R=>a(IZt(R))).catch(()=>a(null)).finally(()=>s(!1))},[e==null?void 0:e.execution_id]);const h=()=>{n(!1),r(null),a(null)},g=i==null?void 0:i.execution,v=i==null?void 0:i.result,y=((i==null?void 0:i.steps)??[]).filter(R=>R.status!=="skipped"),x=(i==null?void 0:i.transfers)??[],w=v==null?void 0:v.result_data,S=w==null?void 0:w.output,_=w==null?void 0:w.output_type,C=w==null?void 0:w.output_fields_map,$=_?Wd(_==="debug"?"card":_,S,C,w==null?void 0:w.title):q2(w),E=_?null:Y2(w)??Y2(S)??kZt(y)??K2(g==null?void 0:g.error_message)??K2(e==null?void 0:e.error_message),k=(v==null?void 0:v.result_summary)??(g==null?void 0:g.result_summary)??(e==null?void 0:e.result_summary)??"",T=(v==null?void 0:v.id)??(e==null?void 0:e.id),I=(g==null?void 0:g.status)==="completed",P=(g==null?void 0:g.status)==="failed",N=y.findIndex(R=>R.status==="failed"),A=y.find(R=>dee(R))??(N>=0?y[N]:void 0),M=(A==null?void 0:A.duration_ms)!=null?ZU(A.duration_ms):void 0;return b.jsx(X1,{className:"wandox-root",title:"执行结果详情",closable:{placement:"end"},open:t&&!!e,onClose:h,size:f,extra:b.jsx("div",{className:"rdd-size-switch",children:p.map(({key:R,label:L})=>b.jsx("button",{type:"button",className:`rdd-size-btn${u===R?" rdd-size-btn--active":""}`,onClick:()=>d(R),children:L},R))}),styles:{header:{paddingBottom:0,border:0},body:{padding:0}},children:o?b.jsx("div",{style:{textAlign:"center",padding:"80px 0"},children:b.jsx(vr,{})}):e&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"rdd-header",children:g&&b.jsx("div",{className:"rdd-header-row2",children:b.jsxs("div",{className:"rdd-meta",children:[b.jsx(ji,{color:I?"success":P?"error":"processing",style:{fontSize:11,margin:0,borderRadius:4},children:I?"成功":P?"失败":g.status}),b.jsx("span",{className:"rdd-meta-sep"}),b.jsxs("span",{className:"rdd-meta-item",children:[b.jsx(fa,{})," ",Bje(g.started_at)]}),g.duration_ms!=null&&b.jsxs("span",{className:"rdd-meta-item",children:["耗时 ",ZU(g.duration_ms)]}),b.jsx(ji,{color:g.trigger_type==="scheduled"?"orange":"blue",style:{fontSize:10,margin:0,borderRadius:4},children:g.trigger_type==="scheduled"?"定时":"手动"})]})})}),b.jsx("div",{className:"rdd-tabs-wrap",children:b.jsx(CO,{size:"small",className:"rdd-tabs",items:[{key:"result",label:"执行结果",children:b.jsxs("div",{className:"rdd-tab-content",children:[b.jsx("div",{className:"rdd-result-output",children:_==="card"&&S&&typeof S=="object"&&!Array.isArray(S)&&S.content?b.jsx(Ci,{payload:S.content}):_?b.jsx(Ci,{payload:$}):S!=null&&S.content?b.jsx(Ci,{payload:S.content}):typeof S=="string"?b.jsx(Ci,{payload:S}):E?b.jsx(PZt,{message:E,stepName:A==null?void 0:A.step_name,duration:M}):k?b.jsx(Ci,{payload:k}):b.jsx(TZt,{type:"secondary",children:"暂无结果内容"})}),b.jsx(cee,{open:l,onClose:()=>c(!1),resultId:T})]})},{key:"steps",label:`执行步骤${y.length?` (${y.length})`:""}`,children:b.jsx("div",{className:"rdd-tab-content",children:y.length>0?y.map((R,L)=>b.jsx(NZt,{step:R,index:L,defaultExpanded:L===N},R.step_id)):b.jsx("div",{className:"rdd-empty",children:"暂无步骤记录"})})},{key:"lineage",label:`推送记录${x.length?` (${x.length})`:""}`,children:b.jsx("div",{className:"rdd-tab-content",children:b.jsx(AZt,{lineage:x})})}]})})]})})}const fee="0 9 * * *",RZt=["周日","周一","周二","周三","周四","周五","周六"];function k1(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function OC(e,t){return e instanceof Error||k1(e)&&typeof e.message=="string"?e.message:t}function pee(e){return k1(e)?e.data??e.result??e.results??e:e}function P1(e){return e?String(e.schedule_id??e.schedule_code??e.task_id??e.id??""):""}function Vje(e){return(e==null?void 0:e.name)||(e==null?void 0:e.schedule_name)||(e==null?void 0:e.title)||"未命名任务"}function DZt(e){return(e==null?void 0:e.schedule_params)??(e==null?void 0:e.playbook_params)??(e==null?void 0:e.params)??(e==null?void 0:e.input_data)??{}}function Hje(e,t){return(e==null?void 0:e.schedule_cron)||(e==null?void 0:e.cron_expression)||t||fee}function Wje(e){return e?typeof e.is_enabled=="boolean"?e.is_enabled:typeof e.enabled=="boolean"?e.enabled:typeof e.is_active=="boolean"?e.is_active:!0:!0}function Uje(e){return!!(e&&e.trim().split(/\s+/).length>=5)}function OZt(e){if(!e||!Uje(e))return"未设置频率";const t=rj(e),n=`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`;switch(t.unit){case"hour":return t.minute>0?`每 ${t.interval} 小时第 ${t.minute} 分执行`:`每 ${t.interval} 小时执行一次`;case"day":return t.interval===1?`每天 ${n} 执行`:`每 ${t.interval} 天 ${n} 执行`;case"week":return`每周 ${t.weekDays.length?t.weekDays.map(i=>RZt[i]||`周${i}`).join("、"):"周一"} ${n} 执行`;case"month":return t.interval===1?`每月第 ${t.monthDay} 天 ${n} 执行`:`每 ${t.interval} 个月第 ${t.monthDay} 天 ${n} 执行`;case"year":return`每年 ${t.yearMonth} 月 ${t.yearDay} 日 ${n} 执行`;case"custom":return"自定义高级规则";default:return"未设置频率"}}function LZt(e){var n;const t=(n=e.schedule_display)==null?void 0:n.trim();return t&&!Uje(t)?t:OZt(Hje(e,t))}function jZt(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function zZt(e){const t=pee(e),n=k1(t)?t.items??t.records??t.rows??t.schedules??t.list??t.data:t;return Array.isArray(n)?n.filter(k1).map(r=>r):[]}function Gje(e){if(!k1(e))return null;const t=e.webhook_id??e.id;if(!t)return null;const n=typeof e.name=="string"&&e.name.trim()?e.name:String(t);return{webhook_id:String(t),name:n,platform:typeof e.platform=="string"?e.platform:void 0,is_active:typeof e.is_active=="boolean"?e.is_active:void 0,is_default:typeof e.is_default=="boolean"?e.is_default:void 0}}function FZt(e){const t=pee(e),n=k1(t)?t.items??t.records??t.rows??t.webhooks??t.list??t.data:t;return Array.isArray(n)?n.map(Gje).filter(r=>!!r):[]}function BZt(e){switch(e){case"dingtalk":return"钉钉";case"feishu":case"lark":return"飞书";case"wecom":case"wechat_work":return"企微";default:return e||""}}function wye(e){const t=BZt(e.platform);return t?`${e.name} (${t})`:e.name}function VZt(e,t){var n;return e!=null&&e.webhook_id?e.webhook_id:((n=t.find(r=>r.is_default&&r.is_active!==!1))==null?void 0:n.webhook_id)||""}function qje(e,t,n){return{mode:"create",activeScheduleId:"",taskName:e!=null&&e.name?`${e.name} 定时任务`:"定时任务",enabled:!0,webhookId:VZt(e,n),cron:(e==null?void 0:e.schedule_cron)||fee,values:x1(t,(e==null?void 0:e.schedule_params)??{})}}function HZt(e,t,n){return{mode:"edit",activeScheduleId:P1(e),taskName:Vje(e),enabled:Wje(e),webhookId:e.webhook_id||"",cron:Hje(e,t==null?void 0:t.schedule_cron),values:x1(n,DZt(e))}}function WZt(e,t){if(!e.taskName.trim())return"请输入任务名称";if(!e.webhookId)return"请选择通知地址";if(e.enabled&&!e.cron.trim())return"请设置调度频率";const n=gT(t,e.values);for(const r of n){const i=e.values[r.name];if(r.required&&i!==0&&i!==!1&&If(i))return`请填写「${r.label||r.name}」`;if(aj(r)&&!If(i)){const a=LOe(i,r.address_validation);if(a)return`${r.label||r.name}:${a}`}}return""}function UZt(e,t){const n=e.cron||fee,r=gT(t,e.values);return{name:e.taskName.trim(),is_enabled:e.enabled,schedule_type:rj(n).unit,schedule_cron:n,schedule_params:t.length>0?BOe(r,e.values):void 0,webhook_id:e.webhookId}}function GZt(){return{draft:qje(null,[],[]),editorRevision:0,quickAddWebhookOpen:!1}}function qZt(e,t){switch(t.type){case"apply_draft":return{...e,draft:t.draft,editorRevision:e.editorRevision+1};case"patch_draft":return{...e,draft:{...e.draft,...t.patch}};case"set_values":{const n=typeof t.next=="function"?t.next(e.draft.values):t.next;return{...e,draft:{...e.draft,values:n}}}case"set_quick_add_open":return{...e,quickAddWebhookOpen:t.open};default:return e}}function KZt(e,t){const[n,r]=m.useReducer(qZt,void 0,GZt),i=m.useRef(""),a=m.useRef((e==null?void 0:e.id)??null);m.useEffect(()=>{a.current!==((e==null?void 0:e.id)??null)&&(a.current=(e==null?void 0:e.id)??null,i.current="")},[e==null?void 0:e.id]),m.useEffect(()=>{i.current=n.draft.activeScheduleId},[n.draft.activeScheduleId]);const o=m.useCallback(S=>{i.current=S.activeScheduleId,r({type:"apply_draft",draft:S})},[]),s=m.useCallback(S=>{o(qje(e,t,S))},[e,o,t]),l=m.useCallback(S=>{o(HZt(S,e,t))},[e,o,t]),c=m.useCallback((S,_,C)=>{const $=C?S.find(T=>P1(T)===C):null,E=i.current?S.find(T=>P1(T)===i.current):null,k=$||E||S[0];k?l(k):s(_)},[l,s]),u=m.useCallback(S=>{i.current===S&&(i.current="")},[]),d=m.useCallback(S=>{r({type:"patch_draft",patch:{taskName:S}})},[]),f=m.useCallback(S=>{r({type:"patch_draft",patch:{enabled:S}})},[]),p=m.useCallback(S=>{r({type:"patch_draft",patch:{webhookId:S}})},[]),h=m.useCallback(S=>{r({type:"patch_draft",patch:{cron:S}})},[]),g=m.useCallback(S=>{r({type:"set_values",next:S})},[]),v=m.useCallback((S,_)=>{r({type:"set_values",next:C=>({...C,[S]:_})})},[]),y=m.useCallback((S,_)=>{r({type:"set_values",next:C=>{const $=Array.isArray(C[S])?C[S]:C[S]?[C[S]]:[];return{...C,[S]:[...$,_]}}})},[]),x=m.useCallback(()=>{r({type:"set_quick_add_open",open:!0})},[]),w=m.useCallback(()=>{r({type:"set_quick_add_open",open:!1})},[]);return{...n,startCreate:s,editSchedule:l,selectScheduleList:c,clearActiveSchedule:u,updateTaskName:d,updateEnabled:f,updateWebhook:p,updateCron:h,updateValues:g,updateField:v,appendFieldValue:y,openQuickAddWebhook:x,closeQuickAddWebhook:w}}const Kje={saving:!1,deletingId:"",saveError:"",uploading:{},fileNameMap:{}};function YZt(e,t){switch(t.type){case"reset":return Kje;case"set_saving":return{...e,saving:t.saving};case"set_deleting":return{...e,deletingId:t.scheduleId};case"set_save_error":return{...e,saveError:t.error};case"set_uploading":return{...e,uploading:{...e.uploading,[t.fieldName]:t.uploading}};case"remember_file_name":return{...e,fileNameMap:{...e.fileNameMap,[t.url]:t.name}};default:return e}}function XZt({agent:e,open:t,draft:n,draftRevision:r,inputFields:i,refreshSchedules:a,clearActiveSchedule:o,updateField:s,appendFieldValue:l}){const c=wa(),u=Ll({...Bl.schedules.create(),onSuccess:(S,{agentId:_})=>Ys(c,{type:"schedule-saved",agentId:_})}),d=Ll({...Bl.schedules.update(),onSuccess:(S,{agentId:_})=>Ys(c,{type:"schedule-saved",agentId:_})}),f=Ll({...Bl.schedules.delete(),onSuccess:(S,{agentId:_})=>Ys(c,{type:"schedule-deleted",agentId:_})}),[p,h]=m.useReducer(YZt,Kje),g=t?(e==null?void 0:e.id)??null:null,v=m.useRef(r);m.useEffect(()=>{g!==null&&h({type:"reset"})},[g]),m.useEffect(()=>{v.current!==r&&(v.current=r,h({type:"set_save_error",error:""}))},[r]);const y=m.useCallback((S,_)=>async({file:C,onSuccess:$,onError:E})=>{var k,T;h({type:"set_uploading",fieldName:S,uploading:!0});try{const I=C,P=await Sy(I),N=(k=P==null?void 0:P.data)==null?void 0:k.url;if(!N)throw new Error("上传失败");const A=((T=P==null?void 0:P.data)==null?void 0:T.name)||I.name||N.split("/").pop()||"未知文件";h({type:"remember_file_name",url:N,name:A}),_<=1?s(S,N):l(S,N),$==null||$(P),Ze.success("文件上传成功")}catch(I){E==null||E(I instanceof Error?I:new Error("文件上传失败")),Ze.error(OC(I,"文件上传失败"))}finally{h({type:"set_uploading",fieldName:S,uploading:!1})}},[l,s]),x=m.useCallback(async()=>{if(!e)return;const S=WZt(n,i);if(S){Ze.warning(S);return}h({type:"set_save_error",error:""}),h({type:"set_saving",saving:!0});try{const _=UZt(n,i);if(n.mode==="edit"&&n.activeScheduleId)await d.mutateAsync({agentId:e.id,scheduleId:n.activeScheduleId,data:_}),Ze.success("定时任务已更新"),a(n.activeScheduleId);else{const C=await u.mutateAsync({agentId:e.id,data:_}),$=pee(C),E=$&&typeof $=="object"&&!Array.isArray($)?P1($):"";Ze.success("定时任务已创建"),a(E||void 0)}}catch(_){h({type:"set_save_error",error:OC(_,"保存失败")})}finally{h({type:"set_saving",saving:!1})}},[e,u,n,i,a,d]),w=m.useCallback(async S=>{const _=P1(S);if(_){h({type:"set_deleting",scheduleId:_});try{if(!e)return;await f.mutateAsync({agentId:e.id,scheduleId:_}),Ze.success("定时任务已删除"),o(_),a()}catch(C){Ze.error(OC(C,"删除失败"))}finally{h({type:"set_deleting",scheduleId:""})}}},[e,o,f,a]);return{...p,handleFileUpload:y,save:x,deleteSchedule:w}}const ZZt={includeDisabled:!0},QZt={},JZt={getSchedules:bgt,getWebhooks:ZO};function eQt(e){return{includeDisabled:e.includeDisabled}}function tQt(e){return{platform:e.platform,domain:e.domain}}function nQt(e=JZt){return{schedules:{list:(t,n)=>{const r=t,i=eQt(n);return{queryKey:Yn.schedules.list(r,i),queryFn:async()=>{const a=await e.getSchedules(r,{include_disabled:i.includeDisabled});return zZt(a)}}}},webhooks:{list:(t={})=>{const n=tQt(t);return{queryKey:Yn.webhooks.list(n),queryFn:async()=>{const r=await e.getWebhooks({platform:n.platform,domain:n.domain});return FZt(r)}}}}}}function rQt(e,t){return[t,...(e??[]).filter(n=>n.webhook_id!==t.webhook_id)]}const Sye=nQt(),iQt=0,aQt=[],oQt=[];function sQt(e,t){const n=wa(),[r,i]=m.useState(0),a=m.useRef(null),o=t&&e!==null,s=m.useMemo(()=>Sye.schedules.list(e??iQt,ZZt),[e]),l=m.useMemo(()=>Sye.webhooks.list(QZt),[]),c=mf({...s,enabled:o}),u=mf({...l,enabled:o});m.useEffect(()=>{if(!o||e===null){a.current=null;return}if(c.isFetching||u.isFetching)return;const p=String(e);a.current!==p&&(a.current=p,i(h=>h+1))},[e,o,c.isFetching,u.isFetching]);const d=m.useCallback(()=>n.getQueryData(s.queryKey)??[],[n,s.queryKey]),f=m.useCallback(p=>{n.setQueryData(l.queryKey,h=>rQt(h,p))},[n,l.queryKey]);return{schedules:c.data??aQt,webhooks:u.data??oQt,listLoading:o&&c.isFetching,webhookLoading:o&&u.isFetching,scheduleError:c.error?OC(c.error,"获取定时任务失败"):"",webhookError:u.error?OC(u.error,"获取通知地址失败"):"",initialLoadRevision:r,getCachedSchedules:d,prependWebhook:f}}function lQt(e,t){const n=m.useMemo(()=>YQ(e==null?void 0:e.input_params),[e==null?void 0:e.input_params]),r=sQt((e==null?void 0:e.id)??null,t),i=KZt(e,n),a=m.useRef(0);m.useEffect(()=>{r.webhookError&&Ze.error(r.webhookError)},[r.webhookError]),m.useEffect(()=>{r.scheduleError&&Ze.error(r.scheduleError)},[r.scheduleError]),m.useEffect(()=>{r.initialLoadRevision===0||a.current===r.initialLoadRevision||(a.current=r.initialLoadRevision,i.selectScheduleList(r.schedules,r.webhooks))},[i.selectScheduleList,r.initialLoadRevision,r.schedules,r.webhooks]);const o=m.useCallback(()=>{i.startCreate(r.webhooks)},[i.startCreate,r.webhooks]),s=m.useCallback(h=>{i.selectScheduleList(r.getCachedSchedules(),r.webhooks,h)},[i.selectScheduleList,r.getCachedSchedules,r.webhooks]),l=sj(n,i.draft.values,i.updateValues),c=m.useMemo(()=>gT(n,i.draft.values),[n,i.draft.values]),u=XZt({agent:e,open:t,draft:i.draft,draftRevision:i.editorRevision,inputFields:n,refreshSchedules:s,clearActiveSchedule:i.clearActiveSchedule,updateField:i.updateField,appendFieldValue:i.appendFieldValue}),d=m.useCallback(h=>{const g=Gje(h);g&&(r.prependWebhook(g),i.updateWebhook(g.webhook_id))},[i.updateWebhook,r.prependWebhook]),f=m.useMemo(()=>new Map(r.webhooks.map(h=>[h.webhook_id,wye(h)])),[r.webhooks]),p=m.useMemo(()=>{const h=new Set,g=r.webhooks.map(v=>(h.add(v.webhook_id),{value:v.webhook_id,label:`${wye(v)}${v.is_default?" · 默认":""}`,disabled:v.is_active===!1}));return i.draft.webhookId&&!h.has(i.draft.webhookId)&&g.unshift({value:i.draft.webhookId,label:`当前通知地址 (${i.draft.webhookId})`,disabled:!1}),g},[i.draft.webhookId,r.webhooks]);return{schedules:r.schedules,webhooks:r.webhooks,listLoading:r.listLoading,webhookLoading:r.webhookLoading,draft:i.draft,editorRevision:i.editorRevision,quickAddWebhookOpen:i.quickAddWebhookOpen,saving:u.saving,deletingId:u.deletingId,saveError:u.saveError,uploading:u.uploading,fileNameMap:u.fileNameMap,inputFields:n,visibleInputFields:c,dynamicOptions:l,webhookNameById:f,webhookOptions:p,startCreate:o,editSchedule:i.editSchedule,updateTaskName:i.updateTaskName,updateEnabled:i.updateEnabled,updateWebhook:i.updateWebhook,updateCron:i.updateCron,updateField:i.updateField,handleFileUpload:u.handleFileUpload,save:u.save,deleteSchedule:u.deleteSchedule,openQuickAddWebhook:i.openQuickAddWebhook,closeQuickAddWebhook:i.closeQuickAddWebhook,addCreatedWebhook:d}}const{Text:_ye}=ec;function cQt({agent:e,open:t,onClose:n}){const r=lQt(e,t),{schedules:i,webhooks:a,draft:o,editorRevision:s,listLoading:l,webhookLoading:c,quickAddWebhookOpen:u,saving:d,deletingId:f,saveError:p,uploading:h,fileNameMap:g,inputFields:v,visibleInputFields:y,dynamicOptions:x,webhookNameById:w,webhookOptions:S,startCreate:_,editSchedule:C,updateTaskName:$,updateEnabled:E,updateWebhook:k,updateCron:T,updateField:I,handleFileUpload:P,save:N,deleteSchedule:A,openQuickAddWebhook:M,closeQuickAddWebhook:R,addCreatedWebhook:L}=r,z=j=>{const O=LZt(j),V=jZt(j.next_run_at),B=j.webhook_id?j.webhook_name||w.get(j.webhook_id)||j.webhook_id:"";return b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"sm-task-item-frequency",children:O}),(V||B)&&b.jsxs("span",{className:"sm-task-item-extra",children:[V&&b.jsxs("span",{children:["下次执行 ",V]}),B&&b.jsxs("span",{children:["通知 ",B]})]})]})};return b.jsxs(rr,{title:null,open:t,onCancel:n,width:920,centered:!0,footer:b.jsxs("div",{className:"sm-footer",children:[b.jsx(Et,{onClick:n,children:"关闭"}),b.jsx(Et,{type:"primary",loading:d,onClick:N,children:o.mode==="edit"?"保存修改":"创建任务"})]}),className:"schedule-modal",closable:!1,styles:{container:{padding:0}},children:[b.jsxs("div",{className:"sm-header",children:[b.jsx(fa,{className:"sm-header-icon"}),b.jsxs("div",{children:[b.jsx("div",{className:"sm-header-title",children:"定时触发配置"}),b.jsx("div",{className:"sm-header-sub",children:(e==null?void 0:e.name)||"当前智能体"})]}),b.jsx(Et,{type:"primary",icon:b.jsx(Uo,{}),onClick:()=>_(),children:"创建任务"})]}),b.jsxs("div",{className:"sm-layout",children:[b.jsxs("aside",{className:"sm-task-panel",children:[b.jsx("div",{className:"sm-task-panel-head",children:b.jsxs("div",{children:[b.jsx("div",{className:"sm-task-panel-title",children:"已创建任务"}),b.jsxs("div",{className:"sm-task-panel-count",children:[i.length," 个定时任务"]})]})}),b.jsx(vr,{spinning:l,children:i.length===0?b.jsx("div",{className:"sm-task-empty",children:b.jsx(ei,{image:ei.PRESENTED_IMAGE_SIMPLE,description:"暂无定时任务"})}):b.jsx("div",{className:"sm-task-list",children:i.map(j=>{const O=P1(j),V=o.mode==="edit"&&o.activeScheduleId===O,B=Wje(j);return b.jsxs("div",{className:`sm-task-item${V?" sm-task-item--active":""}`,children:[b.jsx("button",{type:"button",className:"sm-task-select",onClick:()=>C(j),children:b.jsxs("div",{className:"sm-task-item-main",children:[b.jsxs("div",{className:"sm-task-item-title",children:[b.jsx("span",{children:Vje(j)}),b.jsx(ji,{color:B?"green":"default",children:B?"启用":"停用"})]}),b.jsx("div",{className:"sm-task-item-meta",children:z(j)})]})}),b.jsx("div",{className:"sm-task-actions",children:b.jsx(kO,{title:"删除定时任务",description:"删除后不可恢复,确认删除?",okText:"删除",cancelText:"取消",okButtonProps:{danger:!0,loading:f===O},onConfirm:D=>{D==null||D.stopPropagation(),A(j)},onCancel:D=>D==null?void 0:D.stopPropagation(),children:b.jsx(Et,{type:"text",size:"small",danger:!0,icon:b.jsx(hf,{}),onClick:D=>D.stopPropagation()})})})]},O||j.name)})})})]}),b.jsxs("section",{className:"sm-editor",children:[b.jsxs("div",{className:"sm-editor-head",children:[b.jsxs("div",{children:[b.jsx("div",{className:"sm-editor-title",children:o.mode==="edit"?"编辑任务定时器":"创建任务定时器"}),b.jsx("div",{className:"sm-editor-sub",children:"频率和执行参数沿用当前智能体的配置表单"})]}),b.jsxs("div",{className:"sm-header-switch",children:[b.jsx(_ye,{type:"secondary",style:{fontSize:12},children:o.enabled?"已启用":"已停用"}),b.jsx(yo,{size:"small",checked:o.enabled,onChange:E})]})]}),b.jsxs("div",{className:"sm-body",children:[b.jsxs("div",{className:"sm-section",children:[b.jsxs("div",{className:"sm-label",children:["任务名称",b.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),b.jsx(Kt,{value:o.taskName,onChange:j=>$(j.target.value),placeholder:"例如:每日店铺表现分析"})]}),b.jsxs("div",{className:"sm-section",children:[b.jsxs("div",{className:"sm-field-head",children:[b.jsxs("div",{children:[b.jsxs("div",{className:"sm-label",children:["通知地址",b.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"})]}),b.jsx("div",{className:"sm-param-hint",children:"任务触发后的消息通知地址"})]}),b.jsx(Et,{size:"small",onClick:M,children:"添加通知地址"})]}),b.jsx(tn,{allowClear:!0,showSearch:!0,loading:c,disabled:c,value:o.webhookId||void 0,onChange:j=>k(j||""),placeholder:"请选择通知 Webhook",optionFilterProp:"label",options:S}),!c&&a.length===0&&b.jsx("div",{className:"sm-inline-alert",children:"暂无可用通知地址,请添加一个通知地址。"})]}),o.enabled?b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"sm-section",children:[b.jsx("div",{className:"sm-label",children:"调度频率"}),b.jsx("div",{className:"sm-param-hint",children:"设置智能体自动执行的时间间隔和触发时间"}),b.jsx(HQ,{defaultValue:o.cron,onChange:T},s)]}),v.length>0&&b.jsxs("div",{className:"sm-section",children:[b.jsx("div",{className:"sm-label",children:"执行参数"}),b.jsx("div",{className:"sm-param-hint",children:"定时执行时使用的参数,与手动执行时填写的参数一致"}),b.jsx("div",{className:"sm-form-panel",children:b.jsx("div",{className:"sm-dynamic-fields",children:y.map(j=>b.jsxs("div",{className:"sm-field-item",children:[b.jsxs("div",{className:"sm-field-label",children:[b.jsx("span",{children:j.label||j.name}),j.required&&b.jsx("span",{style:{color:"#ef4444",marginLeft:2},children:"*"}),j.description&&b.jsx(or,{title:j.description,children:b.jsx(ME,{className:"sm-field-label__hint","aria-label":`${j.label||j.name}说明`})})]}),b.jsx(KQ,{field:j,value:o.values[j.name],size:"middle",imageUploadMode:"dragger",uploading:!!h[j.name],fileNameMap:g,getOptionState:x.getFieldState,onChange:I,onUpload:P})]},j.name))})})]})]}):b.jsxs("div",{className:"sm-disabled-hint",children:[b.jsx(fa,{style:{fontSize:28,color:"#d1d5db"}}),b.jsx(_ye,{type:"secondary",style:{fontSize:13},children:"任务已停用,保存后不会自动触发"})]}),p&&b.jsx("div",{className:"sm-save-error",children:p})]})]})]}),b.jsx(HOe,{open:u,onClose:R,onSuccess:L})]})}function uQt({agentsCount:e,error:t,onOpenMarket:n}){return b.jsx("section",{className:"automation-empty-state",children:b.jsxs("div",{children:[b.jsx("span",{className:`automation-badge automation-badge--${t?"red":"blue"}`,children:t?"加载失败":"空状态"}),b.jsx("h2",{children:t?"智能体列表读取失败":e>0?"请选择一个智能体":"还没有启用智能体"}),b.jsx("p",{children:t||(e>0?"从智能体中心选择一个智能体后,再进入驾驶舱运行。":"先到智能体中心启用一个模板,系统会创建用户专属智能体,再进入驾驶舱。")}),b.jsx("button",{type:"button",className:"automation-action-button automation-action-button--primary",onClick:n,children:"去智能体中心"})]})})}const dQt="正在加载内容,请稍候";function CT({className:e}){return b.jsx("output",{className:["automation-loading-state",e].filter(Boolean).join(" "),"aria-live":"polite",children:b.jsxs("div",{className:"automation-loading-state__content",children:[b.jsx(vr,{}),b.jsx("span",{children:dQt})]})})}function fQt({embedded:e,agentName:t,cockpitTransitionLoading:n,historyPanel:r,workbenchPanel:i,onReturnToAgentSelection:a}){return b.jsxs(b.Fragment,{children:[!e&&b.jsx("header",{className:"wandox-automation-page-header",children:b.jsxs("div",{className:"automation-workbench-head",children:[b.jsxs("div",{children:[b.jsx("h2",{children:t}),b.jsx("p",{className:"automation-workbench-head__meta",children:"切换阶段查看本次执行的参数、过程和结果"})]}),b.jsx(Et,{className:"wandox-automation-page-header__back",icon:b.jsx(q$,{}),onClick:a,children:"返回智能体选择"})]})}),b.jsxs("section",{className:`automation-workspace${n?" is-loading":""}`,children:[n&&b.jsx(CT,{className:"automation-workspace-loading"}),r,i]})]})}function lt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function QU(e,t=""){return typeof e=="string"?e:e==null?t:String(e)}function Od(e){return typeof e=="string"?e:void 0}function pQt(e){return Array.isArray(e)?e.map(t=>typeof t=="string"||typeof t=="number"?String(t):lt(t)?QU(t.name??t.field??t.key):"").filter(Boolean):[]}function Ud(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 _j(e){if(!(e==null||e===""))return String(e)}function Yje(e){if(e==null)return!1;const t=String(e).trim();return t?/^\d+$/.test(t)||/^[0-9a-f]{24,}$/i.test(t)||/^[0-9a-f]{8}-[0-9a-f-]{13,}$/i.test(t)||/^(step|playbook|workflow|copy_workflow|agent_exec|execution|custom_agent|result)[_-]/i.test(t):!1}function hQt(e){if(e==null)return"";const t=String(e).trim();return!t||Yje(t)?"":t}function Rc(...e){for(const t of e){const n=hQt(t);if(n)return n}return""}function Ai(e,t){return e instanceof Error||lt(e)&&typeof e.message=="string"?e.message:t}function rl(e){return lt(e)?e.data??e.results??e:e}function B0(e){const t=rl(e),n=lt(t)?t.items??t.records??t.rows??t.schedules??t.list??t.data:t;return Array.isArray(n)?n:[]}function mQt(e,t){const n=rl(e),r=[lt(e)&<(e.meta)?e.meta.total:void 0,lt(n)&<(n.meta)?n.meta.total:void 0,lt(n)?n.total:void 0];for(const i of r){const a=Number(i);if(Number.isFinite(a)&&a>=0)return a}return t}function Mw(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=new Date,r=t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate();return t.toLocaleString("zh-CN",r?{hour:"2-digit",minute:"2-digit"}:{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Xje(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t}function Al(e){return String(e).padStart(2,"0")}function Cye(e,t=0,n=0){const r=new Date(e);return r.setHours(t,n,0,0),r}function gQt(e){const t=e==null?void 0:e.trim();if(!t||t==="未知时间")return null;const n=new Date,r=t.match(/(\d{1,2}):(\d{2})/);if(t==="刚刚")return n;if(t.startsWith("昨天")){const a=new Date(n);return a.setDate(a.getDate()-1),Cye(a,Number((r==null?void 0:r[1])??0),Number((r==null?void 0:r[2])??0))}if(/^\d{1,2}:\d{2}$/.test(t))return Cye(n,Number((r==null?void 0:r[1])??0),Number((r==null?void 0:r[2])??0));const i=t.match(/^(\d{1,2})[/-](\d{1,2})(?:\s+(\d{1,2}):(\d{2}))?/);return i?new Date(n.getFullYear(),Number(i[1])-1,Number(i[2]),Number(i[3]??0),Number(i[4]??0)):null}function Zje(e){return Xje(e.occurredAt)??gQt(e.time)}function $ye(e){var t;return((t=Zje(e))==null?void 0:t.getTime())??0}function vQt(e){return`${e.getFullYear()}-${Al(e.getMonth()+1)}-${Al(e.getDate())}`}function hee(e){return e.map((t,n)=>({run:t,index:n})).sort((t,n)=>$ye(n.run)-$ye(t.run)||t.index-n.index).map(t=>t.run)}function zy(e){return e==null||e===""?"-":typeof e=="string"?e.length>80?`${e.slice(0,80)}...`:e:typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?`${e.length} 条`:lt(e)?JSON.stringify(e).slice(0,80):String(e)}function Hc(e,...t){for(const n of t){const r=zy(n);if(r!=="-")return r}return e}function Eye(e){return e==null||e===""?"-":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e,null,2)}function ni(e){return e==null||e===""?!1:Array.isArray(e)?e.length>0:lt(e)?Object.keys(e).length>0:!0}function $T(e){const t=String(e??"").toLowerCase();return t==="failed"||t==="cancelled"||t==="timeout"?"failed":t==="waiting"||t==="waiting_input"||t==="pending_input"?"waiting":t==="running"||t==="pending"||t==="pending_async"||t==="awaiting_async"?"running":"completed"}function X2(e){const t=String(e??"pending").toLowerCase();return t==="failed"||t==="cancelled"||t==="timeout"?"failed":t==="waiting"||t==="waiting_input"||t==="pending_input"?"waiting":t==="running"||t==="pending_async"||t==="awaiting_async"?"running":t==="completed"||t==="complete"||t==="success"||t==="succeeded"?"completed":"pending"}function Qje(e){const t=zy(e);return t==="等待人工确认"||t==="等待确认"||t==="待人工处理"}function Jje(e){const t=zy(e);return/^已完成\s*\d+\s*个步骤/.test(t)||t.includes("耗时")}function ty(e){return e.status==="running"?"正在执行":e.status==="awaiting_async"||e.status==="pending_async"?"等待异步结果":e.status==="waiting_input"?"等待人工确认":e.status==="failed"?Hc("执行失败",e.error_message,e.result_summary):e.status==="cancelled"?"执行已取消":e.status==="timeout"?"执行超时":Qje(e.result_summary)||Jje(e.result_summary)?"执行完成":Hc("执行完成",e.result_summary)}function Cj(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const n=t.toLowerCase();return["waiting","waiting_input","pending_input"].includes(n)?"waiting":["failed","failure","error","cancelled","timeout"].includes(n)?"failed":["completed","complete","success","succeeded"].includes(n)?"completed":["running","pending","pending_async","awaiting_async"].includes(n)?"running":t.endsWith("待确认")?"waiting":t.endsWith("失败")?"failed":t.endsWith("成功")?"completed":t.endsWith("执行中")||t.endsWith("待执行")?"running":null}function Rw(e){return e?e.status==="failed"||Cj(e.businessStatus)==="failed":!1}function yQt(e){return!!(e!=null&&e.resultId&&e.status==="completed"&&!Rw(e))}function bQt(e){const t=Zje(e);if(t)return`${Al(t.getMonth()+1)}/${Al(t.getDate())} ${Al(t.getHours())}:${Al(t.getMinutes())}`;const n=e.time.match(/(\d{1,2}):(\d{2})/);return n?`--/-- ${Al(Number(n[1]))}:${n[2]}`:e.time}function JU(e){if(e.status==="waiting"||e.status==="failed")return"attention";const t=Cj(e.businessStatus);return t==="waiting"||t==="failed"?"attention":e.status==="running"||t==="running"?"running":"completed"}function mee(e){const t=JU(e),n=Cj(e.businessStatus);return e.status==="failed"||n==="failed"?"failed":e.status==="waiting"?"waiting":t==="attention"?n==="waiting"?"waiting":"failed":t==="running"?"running":n??"completed"}function xQt(e){var i;const t=mee(e);if((i=e.businessStatus)!=null&&i.trim()&&Cj(e.businessStatus)===t)return e.businessStatus.trim();if(t==="waiting")return"待确认";if(t==="failed")return"失败";if(t==="completed")return"已完成";const n=e.steps.find(a=>a.status==="running"),r=(n==null?void 0:n.title)??"";return/(?:AI|生成|仿写|分析)/i.test(r)?"AI 生成中":/(?:提交|刊登)/.test(r)?"刊登中":/(?:查询|异步)/.test(r)?"查询中":"进行中"}function wQt(e,t){return["automation-history-task-card",`automation-history-task-card--${mee(e)}`,t?"automation-history-task-card--active":""].filter(Boolean).join(" ")}function SQt(e,t){const n=e.title.trim(),r=n===String(e.id)||/^(?:agent[_-])?exec(?:ution)?[_-]/i.test(n);return n&&!r?n:t}function _Qt(e){var r,i;const t=((r=e.listErrorMessage)==null?void 0:r.trim())||((i=e.listResultSummary)==null?void 0:i.trim());if(t)return t;const n=e.steps.find(a=>["waiting","running","failed"].includes(a.status));return(n==null?void 0:n.description)||e.resultTitle||(n==null?void 0:n.title)||e.summary||"执行任务"}function CQt(e){return[e.triggerType==="scheduled"||e.trigger==="定时运行"?"定时执行":"手动执行",bQt(e)].filter(Boolean).join(" · ")}function $Qt({children:e,tone:t="gray"}){return b.jsx("span",{className:`automation-badge automation-badge--${t}`,children:e})}function EQt({model:e,actions:t,footer:n}){const{agentName:r,hasSchedule:i,mode:a,error:o,loading:s,filteredRunCount:l,runCount:c,statusFilter:u,groups:d,recordTotal:f,pagination:{page:p,pageCount:h},deletingExecutionId:g,activeRunId:v}=e,{createRun:y,configureSchedule:x,changeStatusFilter:w,reload:S,openRun:_,openWaitingRun:C,removeRun:$,changePage:E}=t,k=T=>{const I=a!=="run"&&v===T.id,P=wQt(T,I),N=mee(T),A=T.recordId!=null&&g===T.recordId;return b.jsxs("div",{className:"automation-history-task-card-shell",children:[b.jsxs("button",{type:"button",className:P,title:T.summary,onClick:()=>T.status==="waiting"?C(T):_(T.id),children:[b.jsxs("div",{className:"automation-history-task-card__head",children:[b.jsx("strong",{children:SQt(T,r)}),b.jsxs("span",{className:`automation-history-task-card__state automation-history-task-card__state--${N}`,children:[b.jsx("i",{}),xQt(T)]})]}),b.jsx("span",{className:"automation-history-task-card__subtitle",children:_Qt(T)}),b.jsx("small",{children:CQt(T)})]}),b.jsx(or,{title:A?"正在删除":"删除执行记录",placement:"top",children:b.jsx("button",{type:"button",className:"automation-history-task-card__delete","aria-label":`删除执行记录:${T.title}`,disabled:g!=null||T.recordId==null,onClick:()=>$(T),children:A?b.jsx(vr,{size:"small"}):b.jsx(hf,{"aria-hidden":"true"})})})]},T.id)};return b.jsxs("section",{className:"automation-panel automation-history-panel",children:[!o&&b.jsxs("div",{className:"wandox-automation-cockpit-actions",children:[b.jsxs("button",{type:"button",className:`wandox-automation-cockpit-action wandox-automation-cockpit-action--run${a==="run"?" wandox-automation-cockpit-action--selected":""}`,onClick:y,children:[b.jsx(Uo,{"aria-hidden":"true"}),b.jsx("strong",{children:"新建任务"})]}),b.jsx(or,{title:i?"已配置定时触发":"配置定时触发",placement:"right",children:b.jsxs("button",{type:"button",className:`wandox-automation-cockpit-action wandox-automation-cockpit-action--schedule-${i?"active":"idle"}`,onClick:x,"aria-label":i?"已配置定时触发":"配置定时触发",children:[b.jsx(fa,{"aria-hidden":"true"}),b.jsx("strong",{children:"定时触发"})]})})]}),!o&&b.jsx("div",{className:"automation-history-status-filters",role:"tablist","aria-label":"任务状态筛选",children:[["all","全部"],["attention","待处理"],["running","进行中"],["completed","已完成"]].map(([T,I])=>b.jsx("button",{type:"button",role:"tab","aria-selected":u===T,className:u===T?"is-active":"",onClick:()=>w(T),children:I},T))}),b.jsxs("div",{className:`automation-history-list${!o&&!s&&l===0?" is-empty":""}`,children:[o&&b.jsxs("button",{type:"button",className:"automation-memory-card automation-memory-card--failed",onClick:S,children:[b.jsxs("span",{className:"automation-memory-card__contacts","aria-hidden":"true",children:[b.jsx("i",{}),b.jsx("i",{}),b.jsx("i",{})]}),b.jsxs("div",{className:"automation-memory-card__head",children:[b.jsx("span",{className:"automation-memory-card__status",children:"失败"}),b.jsx($Qt,{tone:"red",children:"重试"})]}),b.jsx("strong",{children:"执行历史读取失败"}),b.jsx("small",{children:o}),b.jsx("span",{className:"automation-memory-card__action",children:"重新读取"})]}),!o&&!s&&l===0&&b.jsxs("div",{className:"automation-history-empty",children:[b.jsx("span",{className:"automation-history-empty-icon",children:b.jsx(fa,{})}),b.jsxs("div",{children:[b.jsx("strong",{children:c>0?"当前筛选暂无任务":"暂无执行历史"}),b.jsx("small",{children:c>0?"切换状态筛选查看其他任务。":"首次运行后,记录会显示在这里。"})]})]}),!o&&d.map(T=>b.jsxs("section",{className:`automation-history-task-group automation-history-task-group--${T.key}`,children:[b.jsxs("div",{className:"automation-history-task-group__head",children:[b.jsx("span",{children:T.label}),b.jsx("em",{children:" · "}),b.jsx("em",{children:T.runs.length})]}),b.jsx("div",{className:"automation-history-task-group__stack",children:T.runs.map(k)})]},T.key))]}),!o&&!s&&f>0&&b.jsxs("nav",{className:"automation-history-pagination","aria-label":"执行任务分页",children:[b.jsx("button",{type:"button","aria-label":"上一页",disabled:p<=1,onClick:()=>E(Math.max(1,p-1)),children:"‹"}),b.jsxs("span",{className:"automation-history-pagination__summary",children:[p," / ",h]}),b.jsx("button",{type:"button","aria-label":"下一页",disabled:p>=h,onClick:()=>E(Math.min(h,p+1)),children:"›"})]}),n]})}const e4e="wandox-automation-live-execution-traces-v1",gee=12;function TQt(){if(typeof window>"u")return[];try{const e=JSON.parse(window.sessionStorage.getItem(e4e)||"[]");return Array.isArray(e)?e.filter(t=>lt(t)&&typeof t.executionId=="string"&&typeof t.agentId=="number"&&typeof t.agentName=="string"&&typeof t.updatedAt=="string"&&Array.isArray(t.steps)).slice(0,gee):[]}catch{return[]}}function IQt(e){if(!(typeof window>"u"))try{window.sessionStorage.setItem(e4e,JSON.stringify(e.slice(0,gee)))}catch{}}function kQt(e){return e.replace(/\s*·\s*(待执行|执行中|等待确认|已完成|执行失败)$/,"").trim()}function PQt(e){return e==="running"?"RUN":e==="waiting"?"HOLD":e==="completed"?"DONE":e==="failed"?"ERR":"QUEUE"}function NQt(e){return e==="running"?"LIVE":e==="waiting"?"PAUSED":e==="completed"?"SYNCED":e==="failed"?"HALTED":"STANDBY"}function AQt(e){if(!e)return"--:--:--";const t=new Date(e);return Number.isNaN(t.getTime())?"--:--:--":`${Al(t.getHours())}:${Al(t.getMinutes())}:${Al(t.getSeconds())}`}function MQt(e,t,n,r){const i=new Map(t.map(a=>[a.id,a]));return e.map(a=>{const o=i.get(a.id);if(a.status==="pending")return{...a,occurredAt:o==null?void 0:o.occurredAt};const s=!o||o.status!==a.status||o.title!==a.title||o.detail!==a.detail;return{...a,occurredAt:s?n:o.occurredAt??r??n}})}function RQt(e,t){const n=e.find(i=>i.executionId===t.executionId);return[{...t,steps:MQt(t.steps,(n==null?void 0:n.steps)??[],t.updatedAt,n==null?void 0:n.updatedAt)},...e.filter(i=>i.executionId!==t.executionId)].slice(0,gee)}function DQt(e){return e==="running"?"执行中":e==="waiting"?"等待确认":e==="completed"?"已完成":e==="failed"?"执行失败":"待执行"}function OQt({trace:e,steps:t,stepsRef:n}){const r=(e==null?void 0:e.status)??"empty";return b.jsxs("section",{className:`wandox-automation-live-trace wandox-automation-live-trace--${r}`,"aria-label":"实时执行动态",children:[b.jsxs("div",{className:"wandox-automation-live-trace__terminal-bar","aria-hidden":"true",children:[b.jsxs("span",{className:"wandox-automation-live-trace__terminal-lights",children:[b.jsx("i",{}),b.jsx("i",{}),b.jsx("i",{})]}),b.jsx("strong",{children:"实时执行动态"}),b.jsx("em",{className:`wandox-automation-live-trace__stream-status wandox-automation-live-trace__stream-status--${r}`,children:NQt(r)})]}),t.length>0?b.jsx("div",{ref:n,className:"wandox-automation-live-trace__steps",role:"log","aria-live":"polite",children:t.map(i=>{const a=kQt(i.detail);return b.jsxs("div",{className:`wandox-automation-live-trace__step wandox-automation-live-trace__step--${i.status} wandox-automation-live-trace__step--${i.kind??"step"}`,children:[b.jsx("time",{dateTime:i.occurredAt,children:AQt(i.status==="pending"?void 0:i.occurredAt??(e==null?void 0:e.updatedAt))}),b.jsxs("div",{className:"wandox-automation-live-trace__copy",children:[b.jsxs("strong",{title:i.title,children:[b.jsx("b",{children:"$"})," ",i.title]}),b.jsxs("span",{className:"wandox-automation-live-trace__state","aria-label":DQt(i.status),children:["[",PQt(i.status),"]"]}),a&&b.jsxs("small",{children:[b.jsx("b",{children:"›"}),a]})]})]},i.id)})}):b.jsxs("div",{className:"wandox-automation-live-trace__empty",children:[b.jsx("time",{children:"--:--:--"}),b.jsxs("div",{children:[b.jsxs("strong",{children:[b.jsx("b",{children:"$"})," waiting_for_substep_events"]}),b.jsx("small",{children:"监听后台执行流..."})]}),b.jsx("span",{"aria-hidden":"true",children:"[IDLE]"})]})]})}function LQt({embedded:e,agentName:t,cockpitTransitionLoading:n,history:r,activeLiveExecutionTrace:i,activeLiveExecutionSubsteps:a,liveTraceStepsRef:o,workbenchMode:s,activeRunFailed:l,activeWorkbenchStageKey:c,waitingActiveStageKey:u,selectedWorkbenchStepHasConfirmPreview:d,renderWorkbenchFlow:f,renderFailedTaskRerunAction:p,onReturnToAgentSelection:h}){return b.jsx(fQt,{embedded:e,agentName:t,cockpitTransitionLoading:n,onReturnToAgentSelection:h,historyPanel:b.jsx(EQt,{...r,footer:b.jsx(OQt,{trace:i,steps:a,stepsRef:o})}),workbenchPanel:b.jsx("section",{className:`automation-workbench automation-workbench--flow automation-workbench--${s}${s==="detail"&&l?" is-failed":""}`,children:b.jsx("div",{className:`automation-workbench-body automation-workbench-body--flow${s==="waiting"&&c.startsWith("step:")&&c===u?" is-waiting-step":""}${c.startsWith("step:")?" is-step-stage":""}${d?" is-confirm-preview-stage":""}${c==="params"?" is-params-stage":""}${c==="complete"?" is-complete-stage":""}`,children:s==="run"?f():b.jsxs("div",{className:"wandox-automation-flow-layout",children:[f(),p()]})})})})}function jQt({model:e,actions:t,slots:n}){return b.jsx(LQt,{embedded:e.embedded,agentName:e.agentName,cockpitTransitionLoading:e.transitionLoading,onReturnToAgentSelection:t.back,history:{model:e.history,actions:t.history},activeLiveExecutionTrace:e.liveTrace.active,activeLiveExecutionSubsteps:e.liveTrace.substeps,liveTraceStepsRef:e.liveTrace.stepsRef,workbenchMode:e.workbench.mode,activeRunFailed:e.workbench.activeRunFailed,activeWorkbenchStageKey:e.workbench.activeStageKey,waitingActiveStageKey:e.workbench.waitingActiveStageKey,selectedWorkbenchStepHasConfirmPreview:e.workbench.selectedStepHasConfirmPreview,renderWorkbenchFlow:n.renderWorkbenchFlow,renderFailedTaskRerunAction:n.renderFailedTaskRerunAction})}function zQt({open:e,agents:t,loading:n=!1,sender:r,summary:i,onClose:a,onConfirm:o,onCreateAgent:s}){const[l,c]=m.useState(null),[u,d]=m.useState("");m.useEffect(()=>{e&&(c(null),d(""))},[e]);const f=m.useMemo(()=>{const h=u.trim().toLowerCase();return h?t.filter(g=>{var v;return g.name.toLowerCase().includes(h)||((v=g.description)==null?void 0:v.toLowerCase().includes(h))}):t},[t,u]),p=m.useMemo(()=>t.find(h=>h.id===l)??null,[t,l]);return b.jsxs(rr,{className:"wandox-inbox-process",open:e,title:null,footer:null,width:680,centered:!0,destroyOnHidden:!0,onCancel:a,children:[b.jsxs("div",{className:"wandox-inbox-process__header",children:[b.jsx("span",{className:"wandox-inbox-process__eyebrow",children:"收件箱流转"}),b.jsx("h2",{className:"wandox-inbox-process__title",children:"选择承接智能体"}),b.jsx("p",{className:"wandox-inbox-process__description",children:"选择后进入驾驶舱,继续配置本次任务并查看完整执行过程。"})]}),b.jsxs("div",{className:"wandox-inbox-process__steps","aria-label":"流转处理步骤",children:[b.jsxs("div",{className:"wandox-inbox-process__step wandox-inbox-process__step--active",children:[b.jsx("span",{className:"wandox-inbox-process__step-number",children:"1"}),b.jsx("span",{className:"wandox-inbox-process__step-copy",children:"选择智能体"})]}),b.jsx("span",{className:"wandox-inbox-process__step-line","aria-hidden":"true"}),b.jsxs("div",{className:"wandox-inbox-process__step",children:[b.jsx("span",{className:"wandox-inbox-process__step-number",children:"2"}),b.jsx("span",{className:"wandox-inbox-process__step-copy",children:"配置任务"})]}),b.jsx("span",{className:"wandox-inbox-process__step-line","aria-hidden":"true"}),b.jsxs("div",{className:"wandox-inbox-process__step",children:[b.jsx("span",{className:"wandox-inbox-process__step-number",children:"3"}),b.jsx("span",{className:"wandox-inbox-process__step-copy",children:"执行并记录"})]})]}),b.jsxs("div",{className:"wandox-inbox-process__source",children:[b.jsx("span",{className:"wandox-inbox-process__source-avatar","aria-hidden":"true",children:(r||"同事").slice(0,1)}),b.jsxs("div",{className:"wandox-inbox-process__source-copy",children:[b.jsxs("span",{className:"wandox-inbox-process__source-label",children:[r||"同事"," 转交的执行结果"]}),b.jsx("strong",{className:"wandox-inbox-process__source-summary",children:i||"当前执行结果将作为本次任务的上游数据"})]})]}),b.jsx(Kt,{className:"wandox-inbox-process__search",value:u,prefix:b.jsx(dy,{}),placeholder:"搜索智能体",allowClear:!0,onChange:h=>d(h.target.value)}),b.jsx("div",{className:"wandox-inbox-process__agent-list",children:n?b.jsxs("div",{className:"wandox-inbox-process__state",children:[b.jsx(vr,{size:"small"}),b.jsx("span",{className:"wandox-inbox-process__state-text",children:"正在读取智能体"})]}):f.length>0?f.map(h=>{const g=l===h.id;return b.jsxs("button",{type:"button",className:`wandox-inbox-process__agent${g?" wandox-inbox-process__agent--selected":""}`,"aria-pressed":g,onClick:()=>c(h.id),children:[b.jsx("span",{className:"wandox-inbox-process__agent-avatar","aria-hidden":"true",children:h.name.slice(0,1)}),b.jsxs("span",{className:"wandox-inbox-process__agent-copy",children:[b.jsx("strong",{className:"wandox-inbox-process__agent-name",children:h.name}),b.jsx("span",{className:"wandox-inbox-process__agent-description",children:h.description||"进入驾驶舱后配置本次运行参数"})]}),b.jsx("span",{className:"wandox-inbox-process__agent-check","aria-hidden":"true",children:g&&b.jsx(ff,{})})]},h.id)}):b.jsxs("div",{className:"wandox-inbox-process__empty",children:[b.jsx(ei,{image:ei.PRESENTED_IMAGE_SIMPLE,description:u?"没有匹配的智能体":"暂无可用智能体"}),!u&&b.jsxs("button",{type:"button",className:"wandox-inbox-process__create-link",onClick:s,children:[b.jsx(Uo,{}),"创建智能体承接"]})]})}),b.jsxs("div",{className:"wandox-inbox-process__footer",children:[b.jsx("span",{className:"wandox-inbox-process__footer-note",children:"流转来源会自动关联到新的执行记忆。"}),b.jsxs("div",{className:"wandox-inbox-process__footer-actions",children:[b.jsx("button",{type:"button",className:"wandox-inbox-process__button wandox-inbox-process__button--secondary",onClick:a,children:"取消"}),b.jsx("button",{type:"button",className:"wandox-inbox-process__button wandox-inbox-process__button--primary",disabled:!p,onClick:()=>p&&o(p),children:"下一步:配置任务"})]})]})]})}function ET(e){return e===!0||e===1||e==="true"||e==="1"}function FQt(e){return e.title.replace(/(已记住上次选择)$/,"")}function BQt(e,t){if(!lt(e))return null;const n=lt(e.layout)?e.layout:{},r=QU(e.key??e.id??e.name,`group_${t+1}`),i=pQt(e.fields??e.field_names??e.params??e.items);return!r||i.length===0?null:{key:r,title:QU(e.title??e.label??e.name,r),description:Od(e.description??e.subtitle??e.helper),fields:i,columns:Ud(e.columns??e.column??n.columns),remember_last:ET(e.remember_last??e.rememberLast??e.remember)}}function VQt(e){return lt(e)?{title:Od(e.title??e.form_title),description:Od(e.description??e.subtitle??e.form_description),footerNote:Od(e.footer_note??e.footerNote??e.note),submitLabel:Od(e.submit_label??e.submitLabel??e.primary_action_text),draftLabel:Od(e.draft_label??e.draftLabel??e.secondary_action_text),showDraft:typeof e.show_draft=="boolean"?e.show_draft:typeof e.showDraft=="boolean"?e.showDraft:void 0}:{}}function HQt(e){if(!lt(e))return null;const t=e.plan_yaml??e.yaml_content;if(typeof t!="string"||!t.trim())return null;try{const n=FE.parse(t);return lt(n)?n:null}catch{return null}}function WQt(e){const t=rl(e),n=[],r=[],i=s=>{lt(s)&&!n.includes(s)&&n.push(s)};i(t),lt(t)&&(i(t.agent),i(t.custom_agent),i(t.detail),i(t.template),i(t.market_template));const a=n.map(HQt).filter(s=>!!s);for(const s of a)r.push(s),i(s);const o=n.map(s=>s.params_schema).filter(lt);for(const s of o)i(s);return{data:t,records:n,planRecords:r}}function UQt(e,t){const n=new Map(e.map(o=>[o.name,o])),r=[],i=new Set;Array.isArray(t)&&t.forEach((o,s)=>{const l=BQt(o,s);if(!l)return;const c=l.fields.filter(u=>n.has(u));if(c.length!==0){r.push({...l,fields:c});for(const u of c)i.add(u)}});for(const o of e){const s=o.group;if(!s||i.has(o.name))continue;let l=r.find(c=>c.key===s);l||(l={key:s,title:o.group_label||s,description:o.group_description,fields:[]},r.push(l)),l.fields.push(o.name),i.add(o.name)}if(r.length===0)return[];const a=e.filter(o=>!i.has(o.name));return a.length>0&&r.push({key:"__ungrouped",title:"其他参数",fields:a.map(o=>o.name)}),r}function eG(e){const{data:t,records:n,planRecords:r}=WQt(e),a=[Array.isArray(t)?t:void 0,...n.flatMap(c=>[c.input_params,c.x_input_params]),...r.map(c=>c.params)].find(c=>Array.isArray(c)||lt(c)),o=YQ(a),s=n.flatMap(c=>[c.form_groups,c.input_form_groups,c.x_form_groups]).find(Array.isArray),l=n.map(c=>c.form_ui??c.input_form_ui??c.form_config).find(lt);return{fields:o,formGroups:UQt(o,s),formUi:VQt(l)}}function GQt(e){return eG(e).fields}const t4e=gT;function qQt(e,t){if(t.length===0)return[];const n=new Set(e.map(o=>o.name)),r=new Set,i=t.map(o=>{const s=o.fields.filter(l=>n.has(l));for(const l of s)r.add(l);return{...o,fields:s}}).filter(o=>o.fields.length>0),a=e.filter(o=>!r.has(o.name));return a.length>0&&i.push({key:"__ungrouped",title:"其他参数",fields:a.map(o=>o.name)}),i}const KQt="wandox_run_form_remember_v1";function tG(e){const t=localStorage.getItem("sso_domain")||"default",n=localStorage.getItem("sso_company")||"default",r=localStorage.getItem("sso_user_id")||localStorage.getItem("sso_username")||"default";return`${KQt}:${t}:${n}:${r}:${e}`}function n4e(e){return new Set(e.filter(t=>ET(t.remember_last)).flatMap(t=>t.fields))}function r4e(e,t){return e.filter(n=>ET(n.remember_last)).filter(n=>n.fields.some(r=>!If(t[r]))).map(n=>n.key)}function Tye(e,t,n){const r=n4e(n);if(r.size===0)return{values:{},groupKeys:[]};try{const i=localStorage.getItem(tG(e));if(!i)return{values:{},groupKeys:[]};const a=JSON.parse(i),o=lt(a==null?void 0:a.values)?a.values:lt(a)?a:{},s=new Set(t.map(c=>c.name)),l=Object.fromEntries(Object.entries(o).filter(([c,u])=>s.has(c)&&r.has(c)&&!If(u)));return{values:l,groupKeys:r4e(n,l)}}catch{return localStorage.removeItem(tG(e)),{values:{},groupKeys:[]}}}function YQt(e,t,n,r){const i=n4e(n);if(i.size===0)return[];const a=tG(e);let o={};try{const l=localStorage.getItem(a);if(l){const c=JSON.parse(l);o=lt(c==null?void 0:c.values)?{...c.values}:lt(c)?{...c}:{}}}catch{o={}}for(const l of t){if(!i.has(l.name))continue;const c=r[l.name];If(c)?delete o[l.name]:o[l.name]=c}const s=r4e(n,o);return localStorage.setItem(a,JSON.stringify({values:o,updatedAt:Date.now()})),s}function vee(e){const t=e;return lt(t)?t.output_type==="dynamic_form"&<(t.output_data)?t.output_data.data??t.output_data:t.output_type==="dynamic_form"&<(t.data)?t.data:t.output_data??t.output??t.final_output??t.result_data??t.data??t:t}const XQt=new Set(["execution_id","id","trigger_type","trigger_display","started_at","completed_at","duration_ms","result_id","result_data","result_summary","output","output_data","output_type","output_fields_map","previous_step_output","previous_step_outputs","step_output","step_outputs","listing_data","listing_code","job_id","human_input_data","human_input_config","modified_params","confirmed_input"]),ZQt={upload_excel:"上传文件",file_path:"上传文件",file:"上传文件",store_account:"店铺账号",marketplace_id:"站点",site:"站点",language:"语言",target_language:"语言",product_type:"产品品类",product_category:"产品品类",sku:"产品 SKU",product_sku:"产品 SKU",product_description:"产品描述",description:"产品描述",main_image:"主产品图",main_pic:"主产品图",images:"产品图片",sample_image:"样品图片"};function Gd(e){return e.trim().replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}const QQt=["execution_title","task_title","product_sku","sku","asin","order_id","order_no","listing_id","task_name","custom_goal","goal"],JQt=["product_name","item_name","product_title","title","name"];function Iye(e,t){for(const n of t){const r=Object.entries(e).find(([a])=>Gd(a)===n);if(!r)continue;const i=r[1];if((typeof i=="string"||typeof i=="number")&&String(i).trim())return String(i).trim()}return""}function eJt(e){const t=Iye(e,QQt),n=Iye(e,JQt),i=[t,n].filter((a,o,s)=>a&&s.indexOf(a)===o).join(" · ");return i?i.slice(0,256):void 0}function yee(e){const t=Gd(e);return XQt.has(t)||t.endsWith("_output")||t.endsWith("_outputs")||t.includes("previous_step")}function tJt(e,t=new Map){const n=Gd(e);return t.get(e)||t.get(n)||ZQt[n]||e.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function nJt(...e){const t=new Map;for(const n of e){const r=Array.isArray(n)?n:GQt(n);for(const i of r)!i.name||!i.label||(t.set(i.name,i.label),t.set(Gd(i.name),i.label))}return t}function kye(e){try{const n=new URL(e).pathname.split("/").filter(Boolean).pop();return n?decodeURIComponent(n):e}catch{return e.split("/").filter(Boolean).pop()||e}}function Pye(e,t){const n=Gd(e);return n.includes("file")||n.includes("excel")||n.includes("image")||n.includes("pic")?!0:typeof t=="string"&&/^https?:\/\//i.test(t)&&/\.(xlsx?|csv|png|jpe?g|webp|gif|pdf)(\?|$)/i.test(t)}function i4e(e,t){if(typeof t=="string")return Pye(e,t)?kye(t):t.length>120?`${t.slice(0,120)}...`:t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"":t.every(n=>typeof n=="string"&&Pye(e,n))?t.map(n=>kye(String(n))).join("、"):`${t.length} 项`;if(lt(t)){const n=Object.keys(t).filter(r=>!yee(r));return n.length===0?"":`${n.length} 项配置`}return zy(t)}function bee(e,t=new Map){const n=vee(e);return lt(n)?Object.entries(n).filter(([r,i])=>!yee(r)&&ni(i)).map(([r,i])=>[tJt(r,t),i4e(r,i)]).filter(([,r])=>ni(r)).slice(0,12):[]}function _c(e){const t=vee(e);return lt(t)?Object.entries(t).some(([n,r])=>!yee(n)&&ni(r)):!1}function a4e(...e){return e.find(_c)}function TT(e){const t=vee(e);return lt(t)&&_c(t)?{...t}:void 0}function xee(e){return!!(e!=null&&e.some(([,t])=>ni(t)&&t!=="-"))}function wee(e,t,n=new Map){const r=bee(t,n),i=TT(t);if(r.length===0&&!i)return e;const a=xee(e.params),o=_c(e.inputValues);return(a||r.length===0)&&(o||!i)?e:{...e,params:a?e.params:r,inputValues:o?e.inputValues:i}}function o4e(e,t){const n=Object.entries((t==null?void 0:t.inputValues)??{}),r=new Map(((t==null?void 0:t.params)??[]).map(([i,a])=>[Gd(i),a]));return e.reduce((i,a)=>{const o=Gd(a.name),s=n.find(([c])=>Gd(c)===o),l=r.get(Gd(a.label||a.name))??r.get(o);return i[a.name]=(s==null?void 0:s[1])??l??"",i},{})}function rJt(e){const t=String(e??"pending").toLowerCase();return["failed","cancelled","timeout"].includes(t)?"failed":["waiting","waiting_input","pending_input"].includes(t)?"waiting":["running","pending_async","awaiting_async"].includes(t)?"running":["completed","complete","success","succeeded"].includes(t)?"completed":"pending"}function iJt(e){return e==="running"?"正在执行":e==="awaiting_async"||e==="pending_async"?"等待异步结果":e==="waiting_input"?"等待人工确认":e==="failed"?"执行失败":e==="cancelled"?"执行已取消":e==="timeout"?"执行超时":"执行完成"}function See(e){const t=Rc(e.agent_name)||"执行步骤",n=String(e.status??"pending");return[{id:String(e.execution_id??e.id),title:n==="waiting_input"?"等待人工确认":t,description:e.summary||iJt(e.status),event:n,humanConfirm:n==="waiting_input",humanConfirmTriggered:n==="waiting_input",businessStatus:typeof e.business_status=="string"?e.business_status:void 0,status:rJt(e.status)}]}function aJt({event:e,existing:t,eventExecutionId:n,eventAgentName:r,isRecommended:i,pendingExecutionTitle:a,runInputData:o,nextSteps:s,nextStatus:l,nextStepError:c,eventTime:u}){var h;const d=String(n),f=bee(o),p=TT(o);return{id:d,resultId:e.result_id?String(e.result_id):t==null?void 0:t.resultId,title:((h=e.execution_title)==null?void 0:h.trim())||(t==null?void 0:t.title)||a||r,time:(t==null?void 0:t.time)||Mw(u),occurredAt:(t==null?void 0:t.occurredAt)||u,trigger:i?"推荐执行":"手动运行",status:l,businessStatus:e.business_status??(t==null?void 0:t.businessStatus),summary:l==="waiting"?"等待人工确认":l==="completed"?"执行完成":l==="failed"?c:"正在执行",resultTitle:(t==null?void 0:t.resultTitle)||(l==="failed"?"执行失败":r),resultContent:t==null?void 0:t.resultContent,resultPayload:t==null?void 0:t.resultPayload,params:xee(t==null?void 0:t.params)?(t==null?void 0:t.params)??[]:f,inputValues:_c(t==null?void 0:t.inputValues)?t==null?void 0:t.inputValues:p,steps:s.length>0?s:(t==null?void 0:t.steps)||See({id:n,execution_id:d,agent_name:r,status:e.type==="waiting_input"?"waiting_input":l==="failed"?"failed":l==="completed"?"completed":"running",summary:l==="failed"?c:l==="waiting"?"等待人工确认":l==="completed"?"执行完成":"正在执行"}),outputs:(t==null?void 0:t.outputs)||[],detailData:t==null?void 0:t.detailData}}function _ee(e){return Array.isArray(e)?e.filter(t=>!$j(t)).length:void 0}function IT(e,t="pending"){return lt(e)?String(e.status??t).toLowerCase():t}function $j(e){return lt(e)?IT(e)==="skipped"||e.skipped===!0||e.is_skipped===!0:!1}function oJt(e){return lt(e)?!!(ni(e.human_input_data)||ni(e.submitted_input)||ni(e.confirmed_input)||ni(e.human_input_at)||ni(e.human_input_by)||e.human_confirm_triggered===!0):!1}function s4e(e){if(!Array.isArray(e))return"";const t=e.find(r=>lt(r)?["failed","cancelled","timeout"].includes(IT(r)):!1);if(!lt(t))return"";const n=Cee(t.output_data);return n||Hc("",t.error_message,t.message)}function Cee(e){if(!lt(e))return"";const t=lt(e.data)?e.data:{};return Hc("",e.error_message,t.error_message,e.error,t.error)}function sJt(e){if(!lt(e))return"";const t=lt(e.data)?e.data:{};return Hc("",e.message,t.message,e.detail,t.detail)}function l4e(e,t){return!Array.isArray(e)||e.length===0?See({...t,summary:ty(t)}):e.filter(r=>!$j(r)).map((r,i)=>{const a=lt(r)?r:{},o=a.output_data,s=lt(a.playbook)?a.playbook:{},l=lt(a.workflow)?a.workflow:{},c=IT(a),u=X2(c),d=u==="failed"?Hc("",a.error_message,Cee(o)):"",f=u==="waiting"||oJt(a),p=Hc("",d,a.business_status,a.description,s.description,l.description,u==="failed"?a.message:"",sJt(o)),h=a.duration_ms?`耗时 ${Math.round(Number(a.duration_ms)/1e3)} 秒`:"",g=Rc(a.step_name,a.playbook_name,a.name,a.title,s.name,l.name)||`步骤 ${i+1}`;return{id:String(a.step_id??a.id??`step_${i+1}`),title:g,description:[p,h].filter(Boolean).join(" · "),event:c,humanConfirm:u==="waiting"||!!(a.requires_human_confirm??a.requires_human_input??a.human_confirm??a.human_confirm_enabled),humanConfirmTriggered:f,businessStatus:Od(a.business_status),status:u,rawData:a}})}function c4e(e,t){if(!Array.isArray(e)||t==null||t<0)return;const n=e[t];return lt(n)?_j(n.step_id):void 0}function Nye(e){const t=(e==null?void 0:e.trim())??"";return!t||/^步骤\s*\d+$/i.test(t)||Yje(t)}function $ee(e){return lt(e)&<(e.result_data)?e.result_data:e}function u4e(e){return lt(e)?e.output_type==="dynamic_form"&<(e.output_data)?e.output_data.data??e.output_data:e.output_type==="dynamic_form"&<(e.data)?e.data:e.output_data??e.output??e.final_output??e.result_data??e.data??e:e}function lJt(e){const t=$ee(e);return lt(t)?t.output_type==="dynamic_form"&<(t.output_data)?t.output_data.data??t.output_data:t.output_type==="dynamic_form"&<(t.data)?t.data:t.output_type?t.output??t.data??t.output_data??t.content??t:u4e(t):t}function d4e(e){const t=$ee(e);if(!ni(t))return;if(!lt(t))return t;const n=typeof t.output_type=="string"?t.output_type:"",r=t.output??t.data??t.output_data??t.content,i=Array.isArray(t.output_fields_map)?t.output_fields_map:void 0;return n==="card"&<(r)&&typeof r.content=="string"?r.content:n?Wd(n==="debug"?"card":n,r,i,typeof t.title=="string"?t.title:void 0):lt(r)&&typeof r.content=="string"?r.content:typeof r=="string"?r:q2(t)}function cJt(e){const t=lt(e.rawData)?e.rawData:void 0,n=(t==null?void 0:t.output_data)??(t==null?void 0:t.output)??(t==null?void 0:t.result_data);if(ni(n))return Fje(n)}function Eee(...e){const t=new Map;for(const n of e)if(!(!lt(n)||!Array.isArray(n.output_fields_map)))for(const r of n.output_fields_map){if(!lt(r))continue;const i=String(r.name??""),a=String(r.label??"");i&&a&&t.set(i,a)}return t}function uJt(e){const t=$ee(e);return lt(t)&&typeof t.output_type=="string"?t.output_type:""}function dJt(e){if(typeof e=="string")return e;if(!lt(e))return"";const n=[e.content,e.markdown,e.text,lt(e.output)?e.output.content:void 0,lt(e.data)?e.data.content:void 0].find(r=>typeof r=="string"&&r.trim());return typeof n=="string"?n:""}function fJt(e){const n=e.split(/\r?\n/).map(r=>r.trim()).map(r=>r.replace(/^[-*]\s+/,"").trim()).map(r=>r.replace(/^\*\*[^*::]+[::]\*\*\s*/,"").trim()).filter(Boolean)[0]||"";return n.length>42?`${n.slice(0,42)}...`:n}function nG(e){return e.replace(/^#+\s*/,"").replace(/\*\*/g,"").trim()}function f4e(e,t){var i;if(typeof e!="string")return e;const n=e.split(/\r?\n/),r=n.findIndex(a=>a.trim());if(r<0||nG(n[r])!==nG(t))return e;for(n.splice(r,1);((i=n[r])==null?void 0:i.trim())==="";)n.splice(r,1);return n.join(`
|
|
794
|
+
`)}function pJt(e,t){const n=e.toLowerCase(),r=(t||"").toLowerCase();return["model","usage","provider"].includes(n)||["模型名称","模型提供者","usage"].some(i=>r.includes(i.toLowerCase()))}function Tee(e,t=new Map,n=8){const r=lJt(e);return Array.isArray(r)?[["结果条数",`${r.length} 条`]]:lt(r)?Object.entries(r).filter(([i,a])=>!["content","execution_steps","output_fields_map","output_type"].includes(i)&&!pJt(i,t.get(i))&&ni(a)).slice(0,n).map(([i,a])=>[t.get(i)??i,zy(a)]):typeof r=="string"&&r.trim()?[["输出内容",r.length>80?`${r.slice(0,80)}...`:r]]:[]}function hJt(e){return $T(e.status)==="completed"&&(Qje(e.result_summary)||Jje(e.result_summary))?"执行完成":Hc(ty(e),e.result_summary,e.error_message)}function mJt(e,t){return $T(e.status)==="completed"&&t?`已完成 ${t} 个步骤`:ty(e)}function p4e(e,t,n){const r=d4e(e),i=s4e(n),a=uJt(e),o=dJt(r),s=hJt(t),c=(o&&a!=="dynamic_form"?fJt(o):"")||s,u=c&&o?String(f4e(o,c)):o,d=u&&u!==o?u:r,f=_ee(n);return{title:c,subtitle:i||mJt(t,f),content:u,payload:d,meta:Tee(e,Eee(e),3),detailData:ni(e)?e:void 0}}function h4e(e){const t=rl(e);return lt(t)?lt(t.result)?t.result:t:{}}function gJt(e){const t=rl(e),n=h4e(e);return n.result_data??n.output_data??n.output??n.data??(lt(t)?t.result_data??t.output_data??t.output??t.data:t)}function vJt(e){const t=rl(e),n=h4e(e);return lt(t)?String(n.result_summary??t.result_summary??""):""}function yJt({loading:e,error:t,detail:n,onRetry:r}){if(e)return b.jsxs("div",{className:"automation-inbox-result-empty",children:[b.jsx(vr,{size:"small"}),b.jsx("span",{children:"正在读取执行结果"})]});if(t)return b.jsxs("div",{className:"automation-inbox-result-empty is-error",children:[b.jsx(Upt,{}),b.jsx("span",{children:t}),b.jsx("button",{type:"button",className:"automation-action-button automation-action-button--compact automation-action-button--danger",onClick:r,children:"重试"})]});if(!n)return b.jsxs("div",{className:"automation-inbox-result-empty",children:[b.jsx(Zg,{}),b.jsx("span",{children:"暂无执行结果"})]});const i=gJt(n),a=vJt(n),o=ni(i)?d4e(i):a;return ni(o)?b.jsx(Ci,{payload:o}):b.jsxs("div",{className:"automation-inbox-result-empty",children:[b.jsx(Zg,{}),b.jsx("span",{children:"暂无执行结果内容"})]})}function bJt({model:e,actions:t}){const{embedded:n,transferCount:r,loading:i,groups:a,active:o,rejectingTransferId:s}=e,l=(o==null?void 0:o.transfer)??null,c=(o==null?void 0:o.pending)??!1,u=(o==null?void 0:o.sender)??"",d=(o==null?void 0:o.time)??"",f=o==null?void 0:o.resultContent,{back:p,refresh:h,selectTransfer:g,process:v,createAgent:y,reject:x}=t;return b.jsxs(b.Fragment,{children:[!n&&b.jsx("header",{className:"wandox-automation-page-header",children:b.jsxs("div",{className:"automation-workbench-head",children:[b.jsxs("div",{children:[b.jsx("h2",{children:"结果收件箱"}),b.jsx("p",{className:"automation-workbench-head__meta",children:"查看同事转交的执行结果和后续处理入口"})]}),b.jsx(Et,{className:"wandox-automation-page-header__back",icon:b.jsx(q$,{}),onClick:p,children:"返回智能体选择"})]})}),b.jsxs("section",{className:"automation-workspace automation-workspace--inbox",children:[b.jsxs("section",{className:"automation-panel automation-history-panel automation-history-panel--inbox",children:[b.jsxs("div",{className:"automation-panel-head",children:[b.jsx("div",{children:b.jsx("h2",{children:"收件记录"})}),b.jsx("button",{type:"button",className:"wandox-automation-inbox-refresh","aria-label":"刷新收件",title:"刷新收件",onClick:h,disabled:i,children:i?b.jsx(vr,{size:"small"}):b.jsx(yy,{})})]}),b.jsx("div",{className:`automation-history-list automation-inbox-memory-list${!i&&r===0?" is-empty":""}`,children:i&&r===0?b.jsxs("div",{className:"automation-history-empty",children:[b.jsx("span",{className:"automation-history-empty-icon",children:b.jsx(vr,{size:"small"})}),b.jsxs("div",{children:[b.jsx("strong",{children:"正在读取收件"}),b.jsx("small",{children:"收件列表会按转交时间展示。"})]})]}):r===0?b.jsxs("div",{className:"automation-history-empty",children:[b.jsx("span",{className:"automation-history-empty-icon",children:b.jsx(Zg,{})}),b.jsxs("div",{children:[b.jsx("strong",{children:"暂无收件"}),b.jsx("small",{children:"同事转交执行结果后,会出现在这里。"})]})]}):a.map(w=>b.jsxs("div",{className:"automation-memory-group",children:[b.jsx("div",{className:"automation-memory-date",children:b.jsx("span",{children:w.label})}),b.jsx("div",{className:"automation-memory-stack",children:w.items.map(S=>{const _=(l==null?void 0:l.id)===S.id;return b.jsxs("button",{type:"button",className:`automation-inbox-memory-card automation-inbox-memory-card--${S.runStatus}${_?" automation-inbox-memory-card--active":""}`,title:S.summary,onClick:()=>g(S.id),children:[b.jsx("span",{className:"automation-inbox-memory-card__icon","aria-hidden":"true",children:b.jsx(Zg,{})}),b.jsxs("div",{className:"automation-inbox-memory-card__main",children:[b.jsx("strong",{children:S.primaryText}),b.jsx("small",{children:S.time})]}),b.jsx("span",{className:"automation-inbox-memory-card__state",children:S.statusText})]},S.id)})})]},w.key))})]}),b.jsx("section",{className:`automation-workbench automation-workbench--inbox${(l==null?void 0:l.status)==="rejected"?" is-failed":""}${l&&c?" has-footer":""}`,children:b.jsxs("div",{className:"wandox-automation-inbox-detail",children:[b.jsx("div",{className:"automation-workbench-body wandox-automation-inbox-detail__body",children:i&&!l?b.jsxs("section",{className:"automation-workbench-empty wandox-automation-inbox-detail__empty",children:[b.jsx(vr,{}),b.jsx("strong",{children:"正在读取收件详情"}),b.jsx("span",{children:"读取完成后会显示当前收件。"})]}):l?b.jsxs("section",{className:"wandox-automation-inbox-bubble",children:[b.jsxs("div",{className:"wandox-automation-inbox-bubble__head",children:[b.jsx("span",{className:"wandox-automation-inbox-bubble__avatar","aria-hidden":"true",children:(u||"同事").slice(0,1)}),b.jsxs("div",{className:"wandox-automation-inbox-bubble__meta",children:[b.jsx("span",{className:"wandox-automation-inbox-bubble__sender",children:u||"同事"}),b.jsx("span",{className:"wandox-automation-inbox-bubble__action",children:"转交"}),d&&b.jsx("span",{className:"wandox-automation-inbox-bubble__time",children:d})]})]}),b.jsx("div",{className:"wandox-automation-inbox-bubble__content",children:b.jsx("div",{className:"automation-inbox-result-content",children:f})})]}):b.jsxs("section",{className:"automation-workbench-empty wandox-automation-inbox-detail__empty",children:[b.jsx(Zg,{}),b.jsx("strong",{children:"暂无收件"}),b.jsx("span",{children:"有新的结果流转时,这里会显示处理入口。"})]})}),l&&c&&b.jsxs("div",{className:"automation-workbench-footer wandox-automation-inbox-detail__footer",children:[b.jsx("div",{className:"wandox-automation-inbox-detail__footer-note",children:"处理当前流转结果,或创建一个新智能体承接后续执行。"}),b.jsxs("div",{className:"wandox-automation-inbox-detail__footer-actions",children:[b.jsxs("button",{type:"button",className:"automation-inbox-action-button automation-inbox-action-button--process",onClick:()=>v(l),children:[b.jsx(Fc,{}),"处理"]}),b.jsxs("button",{type:"button",className:"automation-inbox-action-button automation-inbox-action-button--create",onClick:()=>y(l),children:[b.jsx(Uo,{}),"创建智能体"]}),b.jsxs("button",{type:"button",className:"automation-inbox-action-button automation-inbox-action-button--reject",disabled:s===l.id,onClick:()=>x(l),children:[b.jsx(ga,{}),s===l.id?"拒绝中":"拒绝"]})]})]})]})})]})]})}function xJt({model:e,actions:t}){return b.jsxs(b.Fragment,{children:[b.jsx(bJt,{model:{embedded:e.embedded,transferCount:e.transferCount,loading:e.loading,groups:e.groups,active:e.active?{...e.active,resultContent:b.jsx(yJt,{loading:e.result.loading,error:e.result.error,detail:e.result.detail,onRetry:t.retryResult})}:null,rejectingTransferId:e.rejectingTransferId},actions:{back:t.back,refresh:t.refresh,selectTransfer:t.selectTransfer,process:t.process,createAgent:t.createAgent,reject:t.reject}}),b.jsx(zQt,{open:!!e.process.transfer,agents:e.process.agents,loading:e.process.loading,sender:e.process.sender,summary:e.process.summary,onClose:t.closeProcess,onConfirm:t.continueProcess,onCreateAgent:t.createAgentFromProcess})]})}const wJt=(...e)=>["automation-action-button",...e].filter(Boolean).join(" ");function Aye({children:e,tone:t="gray"}){return b.jsx("span",{className:`automation-badge automation-badge--${t}`,children:e})}function SJt(e){return e?typeof e.has_schedule=="boolean"?e.has_schedule:!!(e.schedule_enabled||e.schedule_cron||e.next_run_at):!1}function _Jt(e){if(e.my_status==="enabled")return"已启用";const t=e.input_data_schema,n=Array.isArray(t)?t.length:0,r=Array.isArray(e.tags)?e.tags.slice(0,2).join(" · "):"";return n>0?`${n} 个运行参数`:r||e.category||"可启用"}function CJt({embedded:e,agentsLoading:t,marketLoading:n,marketError:r,marketTemplates:i,availableAgents:a,subscribingTemplateId:o,deletingAgentId:s,onReloadMarket:l,onEnableMarketTemplate:c,onSelectAgent:u,onDeleteCustomAgent:d}){const f=i.filter(p=>p.my_status!=="enabled");return b.jsxs("section",{className:"automation-market",children:[b.jsxs("section",{className:"automation-center-section",children:[!e&&b.jsx("div",{className:"automation-panel-head",children:b.jsxs("div",{children:[b.jsxs("div",{className:"automation-center-title",children:[b.jsx("h2",{children:"可用智能体"}),b.jsx(Aye,{tone:"blue",children:t?"加载中":`${a.length} 个`})]}),b.jsx("p",{children:"选择一个工作对象进入驾驶舱。"})]})}),t&&a.length===0?b.jsxs("div",{className:"automation-agent-empty",children:[b.jsx("strong",{children:"正在读取智能体列表"}),b.jsx("p",{children:"读取完成后会显示可用智能体。"})]}):a.length>0?b.jsx("div",{className:"automation-agent-card-grid",children:a.map(p=>{const h=s===p.id,g=p.is_from_market?"移除":"删除",v=SJt(p);return b.jsxs("article",{className:"automation-agent-card",children:[b.jsx("h3",{children:p.name}),b.jsx("p",{children:p.description||p.scene_name||"进入驾驶舱后可以运行、查看历史和配置定时任务。"}),b.jsxs("div",{className:"automation-agent-card-meta",children:[b.jsxs("span",{children:[p.execution_count??0," 次运行"]}),b.jsx("span",{className:v?"automation-agent-card-meta__schedule automation-agent-card-meta__schedule--active":"automation-agent-card-meta__schedule",children:v?"已配置定时":"未配置定时"})]}),b.jsxs("div",{className:"automation-card-actions",children:[b.jsx(Et,{type:"primary",className:"automation-card-action-button",autoInsertSpace:!1,onClick:()=>u(p),children:"进入驾驶舱"}),b.jsx(Et,{danger:!0,className:"automation-card-action-button",autoInsertSpace:!1,disabled:h,loading:h,onClick:()=>d(p),children:h?`${g}中`:g})]})]},`agent-${p.id}`)})}):b.jsxs("div",{className:"automation-agent-empty",children:[b.jsx("strong",{children:t?"正在读取智能体列表":"暂无可用智能体"}),b.jsx("p",{children:t?"读取完成后会显示可用智能体。":"可通过头部创建入口添加智能体。"})]})]}),n&&f.length===0?b.jsx("section",{className:"automation-center-section",children:b.jsxs("div",{className:"automation-agent-empty",children:[b.jsx("strong",{children:"正在读取可启用模板"}),b.jsx("p",{children:"读取市场模板和启用状态。"})]})}):r&&f.length===0?b.jsx("section",{className:"automation-center-section",children:b.jsxs("div",{className:"automation-agent-empty",children:[b.jsx("strong",{children:"可启用模板读取失败"}),b.jsx("p",{children:r}),b.jsx("button",{type:"button",className:wJt(),onClick:l,children:"重新加载"})]})}):f.length>0?b.jsxs("section",{className:"automation-center-section",children:[!e&&b.jsx("div",{className:"automation-panel-head",children:b.jsxs("div",{children:[b.jsxs("div",{className:"automation-center-title",children:[b.jsx("h2",{children:"可启用模板"}),b.jsx(Aye,{tone:"violet",children:n?"加载中":`${f.length} 个`})]}),b.jsx("p",{children:"启用后会添加到你的智能体列表。"})]})}),b.jsx("div",{className:"automation-agent-card-grid",children:f.map(p=>{const h=o===p.id;return b.jsxs("article",{className:"automation-agent-card",children:[b.jsx("h3",{children:p.name}),b.jsx("p",{children:p.description||p.category||"启用后会添加到你的智能体中心。"}),b.jsxs("div",{className:"automation-agent-card-meta",children:[b.jsx("span",{children:"市场模板"}),b.jsx("span",{children:_Jt(p)})]}),b.jsx("div",{className:"automation-card-actions",children:b.jsx(Et,{type:"primary",className:"automation-card-action-button",autoInsertSpace:!1,disabled:h,loading:h,onClick:()=>c(p),children:h?"启用中":"启用"})})]},`market-${p.id}`)})})]}):null]})}function $Jt({model:e,actions:t}){return b.jsx(CJt,{...e,onReloadMarket:t.reload,onEnableMarketTemplate:t.enableTemplate,onSelectAgent:t.selectAgent,onDeleteCustomAgent:t.deleteAgent})}function EJt({text:e}){return e?b.jsx("div",{className:"automation-toast",children:e}):null}function TJt({view:e,market:t,inbox:n,cockpit:r,empty:i,transferModal:a,scheduleModal:o,toast:s}){return b.jsxs("main",{className:"automation",children:[e==="market"?b.jsx($Jt,{...t}):e==="inbox"?b.jsx(xJt,{...n}):r?b.jsx(jQt,{...r}):b.jsx(uQt,{...i}),b.jsx(cee,{...a}),b.jsx(cQt,{...o}),b.jsx(EZt,{}),b.jsx(MZt,{}),b.jsx(EJt,{text:s})]})}function IJt(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)&&t>0?t:null}function kJt(e,t){return IJt(t??e.execution_record_id??e.execution_id)}function PJt(e,{selectedAgentId:t,recommendedAgentId:n}){return e.agent_id?e.agent_id===t||e.agent_id===n&&n!=null:!0}function NJt(){const e=m.useRef(""),t=m.useRef(""),n=m.useCallback(()=>{e.current="",t.current=""},[]),r=m.useCallback((a,o)=>{const s=`${a}:${o||""}`;return e.current===s?!1:(e.current=s,!0)},[]),i=m.useCallback((a,o,s)=>{const l=`${a}:${o}:${String(s??"")}`;return t.current===l?!1:(t.current=l,!0)},[]);return{reset:n,shouldHandleWaiting:r,shouldHandleFinished:i}}const rG={phase:"idle",drawer:null,waitingRunId:"",waitingInfo:null,waitingLoading:!1,waitingSubmitting:!1};function AJt(e,t){if(t.type==="execution_started")return{...e,phase:"running",waitingRunId:"",waitingInfo:null,drawer:e.drawer==="run"||e.drawer==="waiting"?null:e.drawer};if(t.type==="execution_finished")return{...e,phase:t.phase,waitingRunId:"",waitingInfo:null,waitingLoading:!1,waitingSubmitting:!1,drawer:"detail"};if(t.type==="execution_cancelled")return{...rG};const n=typeof t.update=="function"?t.update(e):t.update;return{...e,...n}}function V0(e,t){return n=>{e({type:"update",update:r=>({[t]:typeof n=="function"?n(r[t]):n})})}}function MJt(){const[e,t]=m.useReducer(AJt,rG),n=m.useMemo(()=>V0(t,"phase"),[]),r=m.useMemo(()=>V0(t,"drawer"),[]),i=m.useMemo(()=>V0(t,"waitingRunId"),[]),a=m.useMemo(()=>V0(t,"waitingInfo"),[]),o=m.useMemo(()=>V0(t,"waitingLoading"),[]),s=m.useMemo(()=>V0(t,"waitingSubmitting"),[]),l=m.useCallback(()=>t({type:"update",update:{drawer:"detail"}}),[]),c=m.useCallback((T=!1)=>t({type:"update",update:I=>({drawer:"run",phase:T?I.phase:"idle"})}),[]),u=m.useCallback(T=>t({type:"update",update:{waitingRunId:T,waitingInfo:null,waitingLoading:!0,drawer:"waiting"}}),[]),d=m.useCallback(()=>t({type:"update",update:{waitingRunId:"",waitingInfo:null,waitingLoading:!1,waitingSubmitting:!1,drawer:null}}),[]),f=m.useCallback(()=>t({type:"update",update:rG}),[]),p=m.useCallback(()=>t({type:"execution_cancelled"}),[]),h=m.useCallback((T,I)=>t({type:"update",update:P=>({waitingInfo:T,waitingRunId:I??P.waitingRunId,waitingLoading:!1,drawer:"waiting"})}),[]),g=m.useCallback(()=>t({type:"execution_started"}),[]),v=m.useCallback(()=>t({type:"update",update:{phase:"running",drawer:"run",waitingRunId:"",waitingInfo:null}}),[]),y=m.useCallback(()=>t({type:"update",update:{phase:"idle",drawer:"run"}}),[]),x=m.useCallback(()=>t({type:"update",update:{phase:"failed"}}),[]),w=m.useCallback(()=>t({type:"update",update:{phase:"running"}}),[]),S=m.useCallback(()=>t({type:"update",update:{phase:"idle"}}),[]),_=m.useCallback(()=>t({type:"update",update:{phase:"review_content"}}),[]),C=m.useCallback(()=>t({type:"update",update:{phase:"review_submit"}}),[]),$=m.useCallback(()=>t({type:"update",update:{phase:"polling"}}),[]),E=m.useCallback(()=>t({type:"update",update:{phase:"completed"}}),[]),k=m.useCallback(T=>t({type:"execution_finished",phase:T}),[]);return{...e,setPhase:n,setDrawer:r,setWaitingRunId:i,setWaitingInfo:a,setWaitingLoading:o,setWaitingSubmitting:s,openDetailDrawer:l,openRunDrawer:c,beginWaiting:u,clearWaiting:d,resetExecution:f,cancelExecution:p,advanceWaiting:h,executionStarted:g,beginExecution:v,prepareRun:y,failExecution:x,setRunningPhase:w,setIdlePhase:S,setReviewContentPhase:_,setReviewSubmitPhase:C,setPollingPhase:$,setCompletedPhase:E,executionFinished:k}}function RJt(){const[e,t]=m.useState(TQt);m.useEffect(()=>{IQt(e)},[e]);const n=m.useCallback(r=>{t(i=>RQt(i,r))},[]);return{traces:e,recordEvent:n}}function m4e(...e){return e.find(ni)}function g4e(e,t){const n=e.result_data,r=Eee(n),i=Tee(n,r,3);if(i.length>0)return i;const o=[["处理状态",$T(e.status)==="completed"&&t?`已完成 ${t} 个步骤`:ty(e)],["触发方式",e.trigger_display||(e.trigger_type==="scheduled"?"定时运行":"手动运行")]];return e.duration_ms&&o.push(["耗时",`${Math.round(Number(e.duration_ms)/1e3)} 秒`]),o.filter(([,s])=>ni(s)).slice(0,3)}function v4e(e,t,n,r=new Map){return bee(t,r)}function Iee(e){if(!lt(e))return;const t=lt(e.execution)?e.execution:{},n=lt(e.workflow)?e.workflow:{},r=lt(e.chain)?e.chain:{};return m4e(e.steps,e.workflow_steps,e.execution_steps,e.playbooks,t.steps,t.workflow_steps,t.execution_steps,t.playbooks,n.steps,n.playbooks,r.steps,r.playbooks)}function Ej(e){const t=rl(e);if(!lt(t))return;const n=lt(t.execution)?t.execution:{},r=lt(t.result)?t.result:{},i=Iee(t),a=Array.isArray(i)?i.flatMap(o=>lt(o)?[o.input_data,o.input]:[]):[];return a4e(n.input_data,n.params,n.input_params,n.input,n.run_params,n.execution_params,t.input_data,t.params,t.input_params,t.input,r.input_data,r.params,r.input_params,r.input,...a)}function Tj(e,t){const n=rl(e),r=lt(n)&<(n.execution)?n.execution:{};return nJt(t,lt(n)?n.input_params:void 0,r.input_params)}function Mye(e){return ni(e)?typeof e=="string"?e.trim():zy(e):""}function DJt(e){const t=Rc(e.execution_title,e.agent_name)||"智能体执行",n=e,r=e.started_at??n.created_at??e.completed_at??n.updated_at,i=e.execution_steps??e.workflow_steps??e.steps,a=p4e(e.result_data,e,i),o=$T(e.status),s=_ee(i),l=e,c=a4e(l.input_data,l.params,l.input_params,l.input,l.run_params,l.execution_params),u=lt(l.result)?l.result:{},d=l.result_id??l.resultId??u.id??u.result_id,f=Ud(l.current_step_index);return{id:String(e.id??e.execution_id),recordId:Number.isFinite(Number(e.id))?Number(e.id):void 0,currentStepIndex:f,currentStepId:c4e(i,f),resultId:d?String(d):void 0,title:t,time:Mw(r)||"未知时间",occurredAt:r,trigger:e.trigger_type==="scheduled"?"定时运行":"手动运行",triggerType:e.trigger_type,status:o,businessStatus:e.business_status??void 0,summary:a.subtitle||(o==="completed"?"":ty(e)),resultTitle:a.title||Hc(t,e.result_summary,e.error_message),listResultSummary:Mye(e.result_summary),listErrorMessage:Mye(e.error_message),resultContent:a.content,resultPayload:a.payload,params:v4e(e,c),inputValues:TT(c),steps:See({...e,summary:ty(e)}),outputs:a.meta.length>0?a.meta:g4e(e,s),detailData:a.detailData}}function y4e(e){const t=rl(e);if(!lt(t))return;const n=lt(t.execution)?t.execution:{},r=lt(t.result)?t.result:{};return _j(r.id??r.result_id??n.result_id??t.result_id)}function OJt(e,t){return hee([t,...e.filter(n=>n.id!==t.id)])}function LJt(e,t,n){let r=!1;const i=e.map(a=>{if(a.id!==t)return a;const o=n(a);return o!==a&&(r=!0),o});return r?i:e}function jJt(e,t){const n=e.filter(r=>r.id!==t);return n.length===e.length?e:n}function zJt(e,t){return e>1&&t<=1?e-1:e}function FJt({selectedAgent:e,setActiveRunId:t,beginWaiting:n,advanceWaiting:r,clearWaiting:i,setWaitingLoading:a,getExecutionDetail:o,updateRun:s,notify:l,getErrorMessage:c}){return m.useCallback(async u=>{t(u.id);const d=Number(u.id);if(!Number.isFinite(d)){Ze.error("无法定位执行记录");return}n(u.id);try{const[f,p]=await Promise.allSettled([I1(d),o(d)]);if(p.status==="fulfilled"){const g=p.value,v=Ej(g),y=Tj(g,e==null?void 0:e.input_params);_c(v)&&s(u.id,x=>wee(x,v,y))}if(f.status==="rejected")throw f.reason;const h=f.value;if(!h){Ze.info("当前执行记录暂无待处理步骤"),i();return}r(h,u.id),l("已读取待处理表单")}catch(f){Ze.error(c(f,"加载待处理表单失败")),i()}finally{a(!1)}},[r,n,i,c,o,l,e,t,a,s])}function BJt({isExecuting:e,currentExecutionId:t,selectedAgentId:n,cancelledExecutionRef:r,abort:i,cancelExecution:a,resetLiveExecutionState:o,setActiveRunSnapshot:s,notify:l,refreshLiveRuns:c}){const u=wa(),d=Ll({...Bl.executions.cancel(),onSuccess:(f,p)=>Ys(u,{type:"execution-cancelled",executionId:p,agentId:n??void 0},{refetchType:"none"})});return m.useCallback(async()=>{if(e){r.current=!0,i(),a(),o(),s(f=>f&&f.status==="running"?{...f,status:"failed",summary:"执行已取消"}:f);try{t!=null&&Number.isFinite(Number(t))&&await d.mutateAsync(Number(t)),l("执行已取消"),n&&c()}catch(f){Ze.error(Ai(f,"取消执行失败"))}}},[i,a,d,r,t,e,l,c,o,n,s])}function VJt(e,t){return e&&!t}function HJt(e){if(!e.length)return 0;const t=e.findIndex(r=>r.status==="running"||r.status==="waiting");if(t>=0)return t;const n=e.findIndex(r=>r.status==="pending");return n>=0?n:e.length-1}function WJt(e,t,n){if(!e.length)return 0;const r=n!=null&&n.step_id?e.findIndex(o=>o.id===n.step_id):-1;if(r>=0)return r;const i=n!=null&&n.playbook_name?e.findIndex(o=>o.title===n.playbook_name):-1;if(i>=0)return i;if((n==null?void 0:n.step_index)!=null&&n.step_index>=0&&n.step_index<e.length)return n.step_index;const a=t==null?void 0:t.steps.find(o=>o.status==="waiting"||o.status==="running");if(a){const o=e.findIndex(l=>l.id===a.id);if(o>=0)return o;const s=e.findIndex(l=>l.title===a.title);if(s>=0)return s}return 0}function b4e(e,t,n=[]){const r=(e==null?void 0:e.steps.filter(s=>!Nye(s.title)))??[],i=!!(t&&r.some(s=>t.step_id&&s.id===t.step_id||t.playbook_name&&s.title===t.playbook_name));if(r.length>1||i)return r;const a=n.filter(s=>!Nye(s.title));if(a.length===0)return[];const o=WJt(a,e,t);return a.map((s,l)=>({...s,description:l===o&&(t!=null&&t.message)?t.message:s.description,humanConfirm:l===o?!0:s.humanConfirm,humanConfirmTriggered:l===o?!0:s.humanConfirmTriggered,status:l<o?"completed":l===o?"waiting":"pending"}))}function UJt(e){return e==="waiting"?"waiting_input":e==="running"?"running":e==="completed"?"completed":e==="failed"?"failed":"pending"}function GJt(e){return e==="running"?"running":e==="completed"?"completed":e==="failed"?"failed":"pending"}function x4e(e,t){return e.map((n,r)=>{var l;const i=lt(n.rawData)?n.rawData:{},a=Ud(i.step_index)??r,o=_j(i.step_id)??n.id??`step_${a}`,s=(l=n.substeps)==null?void 0:l.map((c,u)=>{var d;return{id:c.id,parent_step_index:a,parent_step_name:n.title,substep_index:u,substep_total:((d=n.substeps)==null?void 0:d.length)??u+1,substep_name:c.title,status:GJt(c.status),message:c.description}});return{id:Ud(i.id)??a,execution_id:Ud(i.execution_id)??t,step_id:o,step_index:a,step_name:Rc(i.step_name,i.playbook_name,n.title)||`步骤 ${a+1}`,playbook_id:Od(i.playbook_id)??o,status:UJt(n.status),business_status:n.businessStatus??Od(i.business_status)??null,output_data:lt(i.output_data)?i.output_data:void 0,duration_ms:Ud(i.duration_ms),requires_human_confirm:n.humanConfirm,human_confirm_triggered:n.humanConfirmTriggered,substeps:s}})}function qJt(e,t,n){const r=lt(e.rawData)?e.rawData:{};return n||(t!=null&&t>=0?`step_${t+1}`:_j(r.step_id)||e.id)}function KJt({isExecuting:e,reExecutingStepId:t,setReExecutingStepId:n,resetExecutionEvents:r,clearExecutionDetail:i,setActiveRunId:a,executionStarted:o,failExecution:s,reExecuteStep:l,notify:c,refreshLiveRuns:u}){return m.useCallback(async(d,f)=>{if(e||t||!Rw(f))return;const p=Number(f.id);if(!Number.isFinite(p)){Ze.error("无法定位执行记录");return}const h=qJt(d,f.currentStepIndex,f.currentStepId);n(d.id);try{const g=Er.getState(),v=f.steps.length>0?f.steps:[d];g.setCurrentExecutionId(p),g.setExecutionSteps(x4e(v,p)),g.setLatestSSEEvent(null),r(),i(p),a(f.id),o(),c(`正在重新执行步骤:${d.title}`),await l(p,h),u()}catch(g){s(),Ze.error(Ai(g,"步骤重新执行失败"))}finally{n("")}},[i,o,s,e,c,l,t,u,r,a,n])}function YJt({isExecuting:e,rerunningRunId:t,reExecutingStepId:n,selectedAgentId:r,resolveRetryRunFormValues:i,resetLiveExecutionState:a,pendingExecutionTitleRef:o,setRerunningRunId:s,applyRetryValues:l,prepareRun:c,setSelectedWorkbenchStageKey:u,setExpandedWorkbenchStageKeys:d,notify:f}){return m.useCallback(async p=>{if(!(e||t||n)&&r&&Rw(p)){s(p.id);try{const h=await i(p);a(),o.current="",l(h),c(),u("params"),d(["params"]),f("已回填本次参数,确认后开始执行")}catch(h){Ze.error(Ai(h,"读取本次任务参数失败"))}finally{s("")}}},[l,e,f,o,c,n,a,i,t,r,d,s,u])}function XJt({runInputFields:e,selectedAgentInputParams:t,getExecutionDetail:n,updateRun:r}){return m.useCallback(async i=>{let a=_c(i.inputValues)?i.inputValues:void 0;const o=Number(i.id);if(!a&&Number.isFinite(o)){const c=await n(o);a=Ej(c);const u=Tj(c,t);_c(a)&&r(i.id,d=>wee(d,a,u))}const s=TT(a)??i.inputValues??{};if(e.length===0)return _c(s)?{...s}:{};const l=o4e(e,{...i,inputValues:_c(s)?s:i.inputValues});return{...x1(e,l),...l,...lt(s)?s:{}}},[n,e,t,r])}function ZJt({waitingInfo:e,waitingRun:t,waitingPreviewSteps:n,runPreviewSteps:r,selectedAgentId:i,setWaitingSubmitting:a,resumeExecution:o,clearExecutionDetail:s,advanceWaiting:l,clearWaiting:c,notify:u,refreshLiveRuns:d}){return m.useCallback(async f=>{if(!e||!t)return;const p=Number(t.id);if(!Number.isFinite(p)){Ze.error("无法定位执行记录");return}const h=t.steps.map(v=>({step_id:v.id})),g=f.action==="return_previous"?Rg(e,h):e.step_id;if(!g){Ze.error("无法定位需要继续的步骤");return}a(!0);try{const v=b4e(t,e,(n==null?void 0:n.runId)===t.id?n.steps:r),y=Er.getState();if(y.setCurrentExecutionId(p),y.setExecutionSteps(x4e(v.length>0?v:t.steps,p)),y.setExecutionProgress(v.length>0?Math.round(v.filter(w=>w.status==="completed").length/v.length*100):0),y.setLatestSSEEvent(null),await o(p,g,f.inputData,{action:f.action,confirmedInput:f.confirmedInput,modifiedParams:f.modifiedParams}),s(p),f.action==="return_previous"){const w=await I1(p,g);w?(l(w),u("已返回上一步,请继续处理")):(c(),u("已返回上一步")),i&&d();return}const x=Er.getState().latestSSEEvent;if((x==null?void 0:x.type)==="waiting_input"){const w=await I1(p,x.step_id);w?(l(w,t.id),u("执行已到下一处人工确认")):c()}else c(),f.action==="cancel"?u("执行已取消"):["execution_failed","step_failed","timeout"].includes((x==null?void 0:x.type)??"")?u("继续执行失败,请查看执行详情"):u("已提交,执行记录正在刷新");i&&d()}catch(v){Ze.error(Ai(v,"继续执行失败"))}finally{a(!1)}},[l,s,c,u,d,o,r,i,a,e,n,t])}function QJt({selectedAgentId:e,currentExecutionId:t,execution:n,executions:r,runForm:i,cockpit:a,recommendations:o,agentExecution:s,resetExecutionEvents:l,pendingExecutionTitleRef:c,recommendedExecutionRef:u,setActiveRunId:d,setDeletingExecutionId:f,setModal:p,inboxRunTransfer:h,setInboxRunTransfer:g,refreshInboxTransfers:v,loadAgents:y,waitingPreviewSteps:x,notify:w}){const S=wa(),_=Ll({...Bl.executions.delete(),onSuccess:(We,{executionId:Oe})=>Ys(S,{type:"execution-deleted",executionId:Oe,agentId:e??void 0},{refetchType:"none"})}),[C,$]=m.useState(""),[E,k]=m.useState(""),[T,I]=m.useState(void 0),P=m.useRef(!1),{phase:N,setWaitingRunId:A,setWaitingInfo:M,setWaitingLoading:R,setWaitingSubmitting:L,openDetailDrawer:z,openRunDrawer:j,beginWaiting:O,clearWaiting:V,resetExecution:B,cancelExecution:D,advanceWaiting:F,executionStarted:H,beginExecution:W,prepareRun:K,failExecution:U,setIdlePhase:q}=n,{runInputFields:Q,runFormValues:G,applyRetryValues:X,resetForExecution:J,getVisibleFields:Y,persistCurrentRunValues:Z,setInputSnapshot:re,clearInputSnapshot:ee}=i,{selectedAgent:te,isLiveAgent:oe,runPreviewSteps:fe,activeRun:he,waitingRun:ye,runParametersLoading:Te,isExecuting:Ee,historyPage:we}=a.state,{refreshHistory:le,changeHistoryPage:se,setSelectedWorkbenchStageKey:ne,setExpandedWorkbenchStageKeys:ge}=a.actions,{realRuns:be,setActiveRunSnapshot:Ce,loadExecutions:Ae,getExecutionDetail:je,clearExecutionDetail:ce,updateRun:de,removeRun:_e}=r,{load:Me,enable:Re,setActionId:Ie}=o,{startExecution:De,startRecommendedExecution:Ue,resumeExecution:nt,reExecuteStep:ct,acceptTransfer:ht,abort:Ve}=s,Ye=m.useCallback(()=>{Ve(),B(),l(),u.current=null;const We=Er.getState();We.setExecutionSteps([]),We.setExecutionProgress(0),We.setCurrentExecutionId(null),We.setLatestSSEEvent(null)},[Ve,u,B,l]),Se=m.useCallback(()=>{J(e),c.current="",A(""),M(null),R(!1),L(!1),ne("params")},[c,J,e,ne,M,R,A,L]),me=m.useCallback(()=>{Ee||(q(),Ye(),Se()),j(Ee),w(Ee?"执行过程正在更新":"确认参数后开始执行")},[Ee,w,j,Ye,Se,q]),pe=FJt({selectedAgent:te,setActiveRunId:d,beginWaiting:O,advanceWaiting:F,clearWaiting:V,setWaitingLoading:R,getExecutionDetail:je,updateRun:de,notify:w,getErrorMessage:Ai}),xe=ZJt({waitingInfo:n.waitingInfo,waitingRun:ye,waitingPreviewSteps:x,runPreviewSteps:fe,selectedAgentId:e,setWaitingSubmitting:L,resumeExecution:(We,Oe,Xe,at)=>nt(We,Oe,Xe,at),clearExecutionDetail:ce,advanceWaiting:F,clearWaiting:V,notify:w,refreshLiveRuns:le}),Le=XJt({runInputFields:Q,selectedAgentInputParams:te==null?void 0:te.input_params,getExecutionDetail:je,updateRun:de});function $e(){if(!oe||!e||N==="running")return;if(Te){w("正在读取运行参数");return}const We=Y(),Oe=We.filter(Pt=>Pt.required&&If(G[Pt.name]));if(Oe.length>0){Ze.warning(`请填写必填参数: ${Oe.map(Pt=>Pt.label||Pt.name).join(", ")}`);return}const Xe=We.map(Pt=>({field:Pt,error:aj(Pt)?LOe(G[Pt.name],Pt.address_validation):""})).find(Pt=>Pt.error);if(Xe){Ze.warning(`${Xe.field.label||Xe.field.name}: ${Xe.error}`);return}const at=Z(e,We),mt=eJt(at);c.current=mt??"",re(at),P.current=!1,Ye(),W();const ot=h;w(ot?"已承接流转结果,正在创建新的执行记忆":We.length>0?"已开始执行,参数会自动复用到再次执行":"已开始执行,这个智能体无需运行参数"),(ot?ht(ot.id,{action:"use_existing_agent",agent_id:e,input_data:at,create_execution_chain:!0,fan_out_enabled:!1}):De(e,at,{executionTitle:mt})).then(()=>{ot&&(g(null),v(),le())}).catch(Pt=>{P.current||(U(),Ze.error(Ai(Pt,ot?"承接流转执行失败":"执行失败")))})}const ze=YJt({isExecuting:Ee,rerunningRunId:C,reExecutingStepId:E,selectedAgentId:e,resolveRetryRunFormValues:Le,resetLiveExecutionState:Ye,pendingExecutionTitleRef:c,setRerunningRunId:$,applyRetryValues:X,prepareRun:K,setSelectedWorkbenchStageKey:ne,setExpandedWorkbenchStageKeys:ge,notify:w}),Qe=KJt({isExecuting:Ee,reExecutingStepId:E,setReExecutingStepId:k,resetExecutionEvents:l,clearExecutionDetail:ce,setActiveRunId:d,executionStarted:H,failExecution:U,reExecuteStep:ct,notify:w,refreshLiveRuns:le}),it=BJt({isExecuting:Ee,currentExecutionId:t,selectedAgentId:e,cancelledExecutionRef:P,abort:Ve,cancelExecution:D,resetLiveExecutionState:Ye,setActiveRunSnapshot:Ce,notify:w,refreshLiveRuns:le}),st=m.useCallback(async We=>{const Oe=Ud(We.resultId);if(Oe)return Oe;const Xe=Number(We.id);if(!Number.isFinite(Xe))return;const at=await je(Xe),mt=y4e(at);if(mt)return de(We.id,ot=>({...ot,resultId:mt})),Ud(mt)},[je,de]),Ft=m.useCallback(()=>{p(null),I(void 0)},[p]),Ne=m.useCallback(async We=>{if(We.status==="completed"){d(We.id),z();try{const Oe=await st(We);Oe||Ze.warning("当前执行记录缺少结果 ID,提交时无法流转"),I(Oe),p("share")}catch(Oe){Ze.error(Ai(Oe,"结果详情读取失败")),I(void 0),p("share")}}},[z,st,d,p]),ke=m.useCallback(We=>{if(!e||We.recordId==null){Ze.error("缺少执行记录ID,无法删除");return}const Oe=We.recordId,Xe=We.status==="running"||We.status==="waiting";rr.confirm({title:Xe?"取消并删除这条执行记录?":"删除这条执行记录?",content:Xe?"当前任务仍在进行。系统将先取消执行,再删除记录。":`删除「${We.title}」后,该记录将从执行历史中移除。`,okText:Xe?"取消并删除":"删除",cancelText:"保留",okButtonProps:{danger:!0},centered:!0,onOk:async()=>{f(Oe);try{await _.mutateAsync({executionId:Oe,cancelFirst:Xe}),_e(We.id),Xe&&t===Oe&&(Ve(),D());const at=zJt(we,be.length);se(at),await Ae(e,at),Ze.success("执行记录已删除")}catch(at){throw Ze.error(Ai(at,"删除执行记录失败")),at}finally{f(null)}}})},[Ve,D,se,t,_,we,Ae,be.length,_e,e,f]),Ke=m.useCallback(async We=>{try{await Re(We.id),await Me(te==null?void 0:te.market_template_id),await y(null,!1),Ze.success("已启用智能体")}catch(Oe){await Me(te==null?void 0:te.market_template_id),Ze.error(Ai(Oe,"启用推荐智能体失败"))}finally{Ie(null)}},[Re,y,Me,te==null?void 0:te.market_template_id,Ie]),Je=m.useCallback(async We=>{if(!he||he.status!=="completed"){Ze.warning("当前结果完成后才能执行推荐智能体");return}const Oe=await st(he);if(!Oe){Ze.warning("当前结果还在同步,请稍后再试");return}const Xe=`${We.name} · 推荐执行`;Ie(We.id),Ye(),u.current={templateId:We.id,templateName:We.name,agentId:We.my_agent_id},c.current=Xe,ee(),W(),w("已开始执行推荐智能体");try{await Ue(Oe,We.id,{inputData:{},executionTitle:Xe})}catch(at){u.current=null,U(),Ze.error(Ai(at,"推荐智能体执行失败"))}finally{Ie(null)}},[he,W,ee,U,w,c,u,Ye,st,Ie,Ue]);return{state:{rerunningRunId:C,reExecutingStepId:E,transferModalResultId:T},actions:{openRunDrawer:me,openWaitingRun:pe,submitWaitingInput:xe,rerunFailedExecution:ze,reExecuteFailedStep:Qe,startRun:$e,cancelCurrentExecution:it,closeTransferModal:Ft,openShareForRun:Ne,deleteExecutionRecord:ke,enableRecommendedTemplate:Ke,executeRecommendedTemplate:Je}}}const JJt=new Set(["re_executing","step_running","step_awaiting_async","step_pending_async","substep_running","substep_completed","step_completed","step_failed","waiting_input","execution_completed","execution_failed","timeout"]),een=new Set(["execution_failed","step_failed","timeout"]);function ten(e){const t=e.type==="waiting_input",n=e.type==="execution_completed",r=een.has(e.type),i=n||r;return{status:t?"waiting":n?"completed":r?"failed":"running",phase:t?"idle":n?"completed":r?"failed":"running",waitingStepId:t&&e.step_id||null,isWaiting:t,isTerminal:i,isTerminalFailure:r,shouldCaptureLiveTrace:JJt.has(e.type)}}function nen(e,t){return e.filter(n=>!$j(n)).map((n,r)=>{const i=IT(n),a=X2(i),o=a==="failed"?Cee(n.output_data):"",s=!!(t&&n.step_id===t),l=Array.isArray(n.substeps)?n.substeps.map(c=>({id:c.id||`${n.step_id||r}:${c.substep_index}`,title:Rc(c.substep_name)||`子步骤 ${c.substep_index}`,description:c.error||c.message||(c.duration_ms?`耗时 ${Math.round(Number(c.duration_ms)/1e3)} 秒`:""),event:c.status,status:X2(c.status)})):void 0;return{id:String(n.step_id||`step_${r+1}`),title:Rc(n.step_name)||`步骤 ${r+1}`,description:Hc("",o,n.business_status,n.duration_ms?`耗时 ${Math.round(Number(n.duration_ms)/1e3)} 秒`:""),event:i,humanConfirm:s||a==="waiting"||!!n.requires_human_confirm,humanConfirmTriggered:s||a==="waiting"||!!n.human_confirm_triggered,businessStatus:n.business_status??void 0,status:a,substeps:l,rawData:n}})}function Rye(e){return e==="running"?"执行中":e==="waiting"?"等待确认":e==="completed"?"已完成":e==="failed"?"执行失败":"待执行"}function ren(e){return e.filter(t=>!$j(t)).flatMap((t,n)=>{const r=Array.isArray(t.substeps)?t.substeps:[],i=X2(IT(t)),a=Rc(t.step_name)||`执行步骤 ${n+1}`,o=r.filter(d=>d.status==="completed").length,s=r.length>0?i==="running"?`已完成 ${o}/${r.length} 个子步骤`:`共 ${r.length} 个子步骤`:t.duration_ms?`耗时 ${Math.round(Number(t.duration_ms)/1e3)} 秒`:t.business_status||Rye(i),l=String(t.step_id||`step_${n+1}`),c={id:`step:${l}`,index:t.step_index??n,label:String(n+1),kind:"step",title:a,detail:s,status:i},u=r.map((d,f)=>{const p=X2(d.status),h=d.error||d.message||(d.duration_ms?`耗时 ${Math.round(Number(d.duration_ms)/1e3)} 秒`:Rye(p));return{id:`substep:${l}:${d.id||d.substep_index||f+1}`,index:d.substep_index??f,label:`${n+1}.${f+1}`,kind:"substep",title:Rc(d.substep_name)||`子步骤 ${f+1}`,detail:h,status:p}});return[c,...u]})}function ien({event:e,transition:t,executionSteps:n,runPreviewSteps:r}){const i=t.waitingStepId;return{nextSteps:n.length>0?nen(n,i):r.map((o,s)=>({...o,status:i&&s===0?"waiting":o.status,humanConfirm:i&&s===0?!0:o.humanConfirm,humanConfirmTriggered:i&&s===0?!0:o.humanConfirmTriggered})),nextStatus:t.status,nextStepError:Ai(e.error||e.error_message,"执行失败")}}function aen(e){const t=Er(r=>r.latestSSEEvent),n=m.useRef(e);n.current=e,m.useEffect(()=>{var O;if(!t)return;const{enabled:r,selectedAgent:i,currentExecutionId:a,executionSteps:o,runPreviewSteps:s,runInputData:l,recommendedExecutionRef:c,pendingExecutionTitleRef:u,shouldHandleWaiting:d,shouldHandleFinished:f,recordLiveTraceEvent:p,upsertRun:h,setActiveRunId:g,executionStarted:v,setIdlePhase:y,beginWaiting:x,setWaitingInfo:w,setWaitingLoading:S,clearExecutionDetail:_,setWaitingPreviewSteps:C,executionFinished:$,refreshLiveRuns:E,notify:k}=n.current;if(!r||!i)return;const T=c.current;if(!PJt(t,{selectedAgentId:i.id,recommendedAgentId:T==null?void 0:T.agentId}))return;T&&t.agent_id&&(c.current={...T,agentId:t.agent_id});const I=t.agent_id??i.id,P=((O=t.agent_name)==null?void 0:O.trim())||(T==null?void 0:T.templateName)||i.name,N=kJt(t,a);if(!N)return;const A=String(N),M=ten(t),{nextSteps:R,nextStatus:L,nextStepError:z}=ien({event:t,transition:M,executionSteps:o,runPreviewSteps:s}),j=new Date().toISOString();if(M.shouldCaptureLiveTrace&&o.length>0&&p({executionId:A,agentId:I,agentName:P,status:L,updatedAt:j,steps:ren(o)}),h(V=>aJt({event:t,existing:V.find(B=>B.id===A),eventExecutionId:N,eventAgentName:P,isRecommended:!!T,pendingExecutionTitle:u.current,runInputData:l,nextSteps:R,nextStatus:L,nextStepError:z,eventTime:j})),g(A),L==="running"&&v(),t.type==="waiting_input"){if(!d(A,t.step_id))return;const V=Sj(t),B=R.map(F=>({step_id:F.id}));y(),x(A),w({...V,return_step_id:Rg(V,B)});let D=!1;return I1(N,t.step_id).then(F=>{D||!F||w({...F,return_step_id:Rg(F,B)})}).catch(()=>{}).finally(()=>{D||S(!1)}),()=>{D=!0}}M.isTerminal&&f(t.type,A,t.result_id||t.error||t.error_message||"")&&(_(N),C(null),$(t.type==="execution_completed"?"completed":"failed"),E(),k(t.type==="execution_completed"?"执行完成,已进入详情":"执行失败,请查看详情"),c.current=null)},[t])}function LC(e,t){const n=rl(e),r=[],i=o=>{if(!lt(o))return;const s=lt(o.execution)?o.execution:{},l=lt(o.workflow)?o.workflow:{},c=lt(o.chain)?o.chain:{},u=lt(o.agent_config)?o.agent_config:{};r.push(o.steps,o.workflow_steps,o.execution_steps,o.playbooks,s.steps,s.workflow_steps,s.execution_steps,s.playbooks,l.steps,l.playbooks,c.steps,c.playbooks,u.steps,u.playbooks,lt(o.config)?o.config.steps:void 0,lt(o.agent)?o.agent.steps:void 0,lt(o.agent)?o.agent.playbooks:void 0,lt(o.custom_agent)?o.custom_agent.steps:void 0,lt(o.custom_agent)?o.custom_agent.playbooks:void 0,lt(o.detail)?o.detail.steps:void 0,lt(o.detail)?o.detail.playbooks:void 0)};i(n),i(e);const a=r.find(Array.isArray);return!Array.isArray(a)||a.length===0?[]:a.map((o,s)=>{const l=lt(o)?o:{},c=lt(l.playbook)?l.playbook:{},u=lt(l.workflow)?l.workflow:{},d=l.step_id??l.id??l.playbook_id??`step_${s+1}`,f=Rc(l.step_name,l.playbook_name,l.name,l.title,l.skill_name,c.name,u.name);return{id:String(d),title:f||(a.length===1?Rc(t):"")||`步骤 ${s+1}`,description:Rc(l.description,c.description,u.description)||"执行配置的流程",event:"pending",humanConfirm:!!(l.requires_human_confirm??l.requires_human_input??l.human_confirm),status:"pending"}})}function H0(e){return e.some(t=>!/^步骤 \d+$/.test(t.title))}function kee(e){return LC(e,e==null?void 0:e.name)}function EP(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function rF(e){if(typeof e=="number"&&Number.isFinite(e))return String(e);if(typeof e=="string"&&e.trim())return e.trim()}function oen(e,t=0){const n=EP(e)?e:{},r=EP(n.target_user)?n.target_user:{},i=EP(n.source_result)?n.source_result:{},a=EP(n.source_execution)?n.source_execution:{},o=rF(n.source_result_id??n.result_id??i.id??i.result_id),s=rF(n.source_execution_id??n.execution_id??a.id??a.execution_id);return{id:rF(n.id??n.transfer_code)??`transfer-${t}`,target:String(n.target_nickname??n.target_username??n.target_name??r.display_name??r.nickname??r.username??n.target_user_id??"接收人"),runId:s??o??"-",executionId:s,resultId:o,time:Mw(n.created_at)||"未知时间",status:String(n.status??"pending")}}function sen(e,t){const n=new Set([t.id,t.resultId].filter(r=>!!r));return!!(e.executionId&&n.has(e.executionId))||!!(e.resultId&&n.has(e.resultId))||n.has(e.runId)}const len={page:1,pageSize:100},cen={page:1,pageSize:24},iG=10,uen={page:1,pageSize:100},den={page:1,pageSize:50},fen={getAgents:NY,getAgentDetail:ggt,getMarketTemplates:Pgt,getMarketTemplateRecommendations:Agt,getExecutions:OH,getExecutionDetail:OEe,getResultDetail:Egt,getPendingTransfers:LEe,getSentTransfers:Igt};function pen(e){return{page:e.page,pageSize:e.pageSize,sceneId:e.sceneId,isTemplate:e.isTemplate}}function hen(e){return{page:e.page,pageSize:e.pageSize,category:e.category,keyword:e.keyword}}function men(e){return{agentId:e.agentId,page:e.page,pageSize:e.pageSize,status:e.status,statuses:Dye(e.statuses),businessStatuses:Dye(e.businessStatuses),triggerType:e.triggerType,startDate:e.startDate,endDate:e.endDate}}function Dye(e){if(!e)return;const t=e.map(n=>n.trim()).filter(Boolean);return t.length?Array.from(new Set(t)):void 0}function Oye(e){return{page:e.page,pageSize:e.pageSize}}function gen(e=fen){return{agents:{list:t=>{const n=pen(t);return{queryKey:Yn.agents.list(n),queryFn:async()=>{const r=await e.getAgents({page:n.page,page_size:n.pageSize,scene_id:n.sceneId,is_template:n.isTemplate});return B0(r)}}},detail:t=>{const n=t;return{queryKey:Yn.agents.detail(n),queryFn:()=>e.getAgentDetail(n)}}},market:{templates:{list:t=>{const n=hen(t);return{queryKey:Yn.market.templates.list(n),queryFn:async()=>{const r=await e.getMarketTemplates({page:n.page,page_size:n.pageSize,category:n.category,keyword:n.keyword});return B0(r)}}}},recommendations:{byTemplate:t=>{const n=t;return{queryKey:Yn.market.recommendations.byTemplate(n),queryFn:async()=>{const r=await e.getMarketTemplateRecommendations({market_template_id:n});return B0(r)}}}}},executions:{list:t=>{const n=men(t);return{queryKey:Yn.executions.list(n),queryFn:async()=>{const r=await e.getExecutions({agent_id:n.agentId,page:n.page,page_size:n.pageSize,status:n.status,"status[]":n.statuses,"business_status[]":n.businessStatuses,trigger_type:n.triggerType,start_date:n.startDate,end_date:n.endDate}),i=B0(r),a=hee(i.map(DJt));return{runs:a,total:mQt(r,a.length)}}}},detail:t=>{const n=t;return{queryKey:Yn.executions.detail(n),queryFn:()=>e.getExecutionDetail(n)}}},results:{detail:t=>{const n=t;return{queryKey:Yn.results.detail(n),queryFn:async()=>rl(await e.getResultDetail(n))}}},transfers:{sent:t=>{const n=Oye(t);return{queryKey:Yn.transfers.sent(n),queryFn:async()=>{const r=await e.getSentTransfers({page:n.page,page_size:n.pageSize});return B0(r).map(oen)}}},inbox:t=>{const n=Oye(t);return{queryKey:Yn.transfers.inbox(n),queryFn:async()=>{const r=await e.getPendingTransfers({page:n.page,page_size:n.pageSize});return B0(r)}}}}}}const bs=gen();function ven({enabled:e,selectedAgent:t,phase:n,runConfigAgentId:r,applyInputConfig:i,setRunPreviewStepItems:a,beginInputConfigLoading:o,onInputFieldsLoaded:s,notify:l,getErrorMessage:c}){const u=wa();m.useEffect(()=>{if(!e||!t||n==="running"||r===t.id)return;let d=!1;const f=h=>{d||i(t.id,h)},p=eG(t);return a(kee(t)),o(p),u.fetchQuery(bs.agents.detail(t.id)).then(h=>{if(d)return;const g=LC(h,t.name);g.length>0&&a(g);const v=eG(h);v.fields.length>0?(s(t.id,v.fields),f(v)):f(p)}).catch(h=>{d||(f(p),p.fields.length===0&&l(c(h,"运行参数读取失败")))}),()=>{d=!0}},[i,o,e,c,l,s,n,u,r,t,a])}function yen({enabled:e,isLiveAgent:t,activeRunId:n,realRuns:r,selectedAgent:i,selectedAgentName:a,selectedAgentInputParams:o,getExecutionDetail:s,updateRun:l,drawer:c,phase:u,activeRun:d,runPreviewStepItems:f,setRunPreviewStepItems:p,workspaceMode:h,waitingRunIdForPreview:g,waitingRunStatusForPreview:v,waitingRunSummaryForPreview:y,setWaitingPreviewSteps:x}){const w=wa();m.useEffect(()=>{if(!e||!t||!n)return;const S=r.find(E=>E.id===n),_=xee(S==null?void 0:S.params)||_c(S==null?void 0:S.inputValues);if(!S||_&&(S.resultId||S.status!=="completed"))return;const C=Number(S.id);if(!Number.isFinite(C))return;let $=!1;return s(C).then(E=>{if($)return;const k=y4e(E),T=Ej(E);if(!k&&!_c(T))return;const I=Tj(E,o);l(S.id,P=>{const N=k&&P.resultId!==String(k)?{...P,resultId:String(k)}:P;return wee(N,T,I)})}).catch(()=>{}),()=>{$=!0}},[n,e,s,t,r,o,l]),m.useEffect(()=>{if(!e||c!=="run"||!a||u==="running"||H0(f))return;const S=[d,r[0]].find($=>$&&Number.isFinite(Number($.id))),_=S?Number(S.id):null;if(!_)return;let C=!1;return s(_).then($=>{if(C)return;const E=LC($,a);E.length>0&&H0(E)&&p(E)}).catch(()=>{}),()=>{C=!0}},[d,c,e,s,u,r,f,a,p]),m.useEffect(()=>{if(!e||h!=="waiting"||!i||H0(f)&&f.length>1)return;let S=!1;const _=$=>$.length>0&&($.length!==f.length||$.some((E,k)=>{var T,I;return E.id!==((T=f[k])==null?void 0:T.id)||E.title!==((I=f[k])==null?void 0:I.title)})),C=kee(i);return _(C)&&p(C),w.fetchQuery(bs.agents.detail(i.id)).then($=>{if(S)return;const E=LC($,i.name);_(E)&&p(E)}).catch(()=>{}),()=>{S=!0}},[e,f,i,w,p,h]),m.useEffect(()=>{if(!e)return;if(h!=="waiting"||!t||!g){x(null);return}const S=Number(g);if(!Number.isFinite(S)){x(null);return}let _=!1;return x(C=>(C==null?void 0:C.runId)===g?C:null),s(S).then(C=>{if(_)return;const $=rl(C);if(!lt($))return;const E=lt($.execution)?$.execution:{},k=lt($.result)?$.result:{},T=Iee($),I=v==="waiting"?"waiting_input":v,P={...E,id:E.id??S,execution_id:E.execution_id??g,status:E.status??k.status??I,result_summary:k.result_summary??E.result_summary??y},N=l4e(T,P),A=LC($,a),M=N.length>0&&H0(N)?N:A;M.length>0&&H0(M)&&x({runId:g,steps:M}),N.length>0&&H0(N)&&l(g,R=>({...R,steps:N}))}).catch(()=>{}),()=>{_=!0}},[e,s,t,a,x,l,g,v,y,h])}function ben({runs:e,isLiveAgent:t,selectedAgentName:n,selectedAgentInputParams:r,setActiveRunId:i,openDetailDrawer:a,getExecutionDetail:o,clearExecutionDetail:s,updateRun:l}){return m.useCallback(async c=>{const u=e.find(f=>f.id===c);if(i(c),a(),!t)return;const d=Number(c);if(Number.isFinite(d)){Rw(u)&&s(d);try{const f=await o(d),p=rl(f);if(!lt(p))return;const h=lt(p.execution)?p.execution:{},g=lt(p.result)?p.result:{},v=Iee(p),y=g.id??g.result_id??h.result_id,x=Ej(p),w=m4e(g.result_data,g.output_data,g.final_output,h.result_data,h.output_data,p.output_data,p.result_data),S=s4e(v),_=(u==null?void 0:u.status)==="waiting"?"waiting_input":u==null?void 0:u.status,C=(u==null?void 0:u.status)==="completed"?"completed":h.status??g.status??_,$={...h,id:h.id??d,execution_id:h.execution_id??c,agent_name:h.agent_name??p.agent_name??n,status:C,result_summary:g.result_summary??h.result_summary,result_data:w,error_message:h.error_message??g.error_message??S},E=Eee(g.output_data,g.result_data,h.result_data,p.output_data,p.result_data),k=Tj(p,r),T=Tee(w,E,3),I=p4e(w,$,v),P=$T($.status),N=l4e(v,$),A=_ee(v),M=Ud(h.current_step_index)??(u==null?void 0:u.currentStepIndex);l(c,R=>{var L;return{...R,currentStepIndex:M??R.currentStepIndex,currentStepId:c4e(v,M)??R.currentStepId,resultId:y?String(y):R.resultId,title:((L=$.execution_title)==null?void 0:L.trim())||R.title,status:P,businessStatus:$.business_status??R.businessStatus,resultTitle:I.title||Hc(R.resultTitle,$.result_summary,$.error_message),summary:I.subtitle||(P==="completed"?"":ty($)),resultContent:I.content,resultPayload:I.payload,params:v4e($,x,y,k),inputValues:TT(x),steps:N,outputs:I.meta.length>0?I.meta:T.length>0?T:g4e($,A),detailData:I.detailData}})}catch{}}},[s,o,t,a,e,r,n,i,l])}function xen({enabled:e,activeRunId:t,agentsRef:n,setAgents:r,execution:i,executions:a,runForm:o,cockpit:s,recommendations:l,executionEvents:c,runPreviewStepItems:u,setRunPreviewStepItems:d,pendingExecutionTitleRef:f,recommendedExecutionRef:p,recordLiveTraceEvent:h,setActiveRunId:g,setWaitingPreviewSteps:v,notify:y}){const x=Er(ee=>ee.currentExecutionId),w=Er(ee=>ee.executionSteps),{drawer:S,phase:_,openDetailDrawer:C,executionStarted:$,setIdlePhase:E,beginWaiting:k,setWaitingInfo:T,setWaitingLoading:I,executionFinished:P}=i,{realRuns:N,getExecutionDetail:A,clearExecutionDetail:M,updateRun:R,upsertRun:L}=a,{runInputData:z,runConfigAgentId:j,beginInputConfigLoading:O,applyInputConfig:V}=o,{state:{selectedAgent:B,isLiveAgent:D,runPreviewSteps:F,runs:H,activeRun:W,waitingRunIdForPreview:K,waitingRunStatusForPreview:U,waitingRunSummaryForPreview:q,workspaceMode:Q},actions:{refreshHistory:G}}=s,{activate:X}=l,{shouldHandleWaiting:J,shouldHandleFinished:Y}=c,Z=ben({runs:H,isLiveAgent:D,selectedAgentName:B==null?void 0:B.name,selectedAgentInputParams:B==null?void 0:B.input_params,setActiveRunId:g,openDetailDrawer:C,getExecutionDetail:A,clearExecutionDetail:M,updateRun:R});yen({enabled:e,isLiveAgent:D,activeRunId:t,realRuns:N,selectedAgent:B,selectedAgentName:B==null?void 0:B.name,selectedAgentInputParams:B==null?void 0:B.input_params,getExecutionDetail:A,updateRun:R,drawer:S,phase:_,activeRun:W,runPreviewStepItems:u,setRunPreviewStepItems:d,workspaceMode:Q,waitingRunIdForPreview:K,waitingRunStatusForPreview:U,waitingRunSummaryForPreview:q,setWaitingPreviewSteps:v});const re=m.useCallback((ee,te)=>{r(oe=>{const fe=oe.map(he=>he.id===ee?{...he,input_params:te}:he);return n.current=fe,fe})},[n,r]);return ven({enabled:e,selectedAgent:B,phase:_,runConfigAgentId:j,applyInputConfig:V,setRunPreviewStepItems:d,beginInputConfigLoading:O,onInputFieldsLoaded:re,notify:y,getErrorMessage:Ai}),m.useEffect(()=>{X(e?B==null?void 0:B.market_template_id:null)},[X,e,B==null?void 0:B.market_template_id]),aen({enabled:D,selectedAgent:B,currentExecutionId:x,executionSteps:w,runPreviewSteps:F,runInputData:z,recommendedExecutionRef:p,pendingExecutionTitleRef:f,shouldHandleWaiting:J,shouldHandleFinished:Y,recordLiveTraceEvent:h,upsertRun:L,setActiveRunId:g,executionStarted:$,setIdlePhase:E,beginWaiting:k,setWaitingInfo:T,setWaitingLoading:I,clearExecutionDetail:M,setWaitingPreviewSteps:v,executionFinished:P,refreshLiveRuns:G,notify:y}),{currentExecutionId:x,openRun:Z}}const wen={agentId:0,page:1,pageSize:iG};function Lye(e,t){return(e==null?void 0:e.agentId)===t.agentId&&e.page===t.page&&e.pageSize===t.pageSize}function Sen({enabled:e,selectedAgentIdRef:t}){var C,$;const n=wa(),[r,i]=m.useState(null),[a,o]=m.useState(null),s=m.useRef(null),l=m.useMemo(()=>bs.executions.list(a??wen),[a]),c=mf({...l,enabled:e&&a!==null}),u=((C=c.data)==null?void 0:C.runs)??[],d=(($=c.data)==null?void 0:$.total)??0,f=m.useCallback(E=>{const k={agentId:E.agentId,page:E.page,pageSize:E.pageSize},T=!Lye(s.current,k);s.current=k,T&&i(null),o(I=>Lye(I,k)?I:k)},[]),p=m.useCallback((E,k=1)=>{f({agentId:E,page:k,pageSize:iG})},[f]),h=m.useCallback(E=>{const k=s.current;if(!k)return;const T=bs.executions.list(k);n.setQueryData(T.queryKey,E)},[n]),g=m.useCallback(E=>n.fetchQuery(bs.executions.detail(E)),[n]),v=m.useCallback(E=>{if(E==null){n.removeQueries({queryKey:Yn.executions.details});return}n.removeQueries({queryKey:Yn.executions.detail(E),exact:!0})},[n]),y=m.useCallback((E,k)=>{h(T=>{if(!T)return T;const I=LJt(T.runs,E,k);return I===T.runs?T:{...T,runs:I}})},[h]),x=m.useCallback((E=!1)=>{i(null);const k=E?t.current:null;if(k!=null){p(k);return}s.current=null,o(null)},[p,t]),w=m.useCallback(E=>{h(k=>{if(!k)return k;const T=jJt(k.runs,E);return T===k.runs?k:{runs:T,total:Math.max(0,k.total-1)}}),i(k=>(k==null?void 0:k.id)===E?null:k)},[h]),S=m.useCallback(E=>{h(k=>{const T=(k==null?void 0:k.runs)??[],I=E(T),P=T.some(A=>A.id===I.id),N=OJt(T,I);return{runs:N,total:k?k.total+(P?0:1):N.length}})},[h]),_=m.useCallback(async(E,k=1)=>{const T={agentId:E,page:k,pageSize:iG};f(T);try{const I=await n.fetchQuery({...bs.executions.list(T),staleTime:0});return t.current===E?I.runs:[]}catch{return[]}},[f,n,t]);return{realRuns:u,activeRunSnapshot:r,setActiveRunSnapshot:i,historyTotal:d,historyLoading:e&&a!==null&&c.isFetching,historyError:c.error?Ai(c.error,"加载执行历史失败"):"",loadExecutions:_,activateHistory:p,getExecutionDetail:g,clearExecutionDetail:v,updateRun:y,upsertRun:S,resetHistory:x,removeRun:w}}function _en({embedded:e,view:t,setView:n,selectedAgentName:r,agentsCount:i,agentsError:a,pendingInboxCount:o,openInbox:s,reloadAgents:l,setDrawer:c,setModal:u,notify:d,onHeaderChange:f,onCockpitExit:p}){const[h,g]=m.useState(!1),v=m.useCallback(()=>{if(!r){Ze.info("请先选择一个智能体");return}g(!0)},[r]),y=m.useCallback(()=>{g(!1),l()},[l]),x=m.useCallback(()=>{const C=Er.getState();C.resetForm(),C.setEditingAgent(null),C.setShowAgentDrawer(!0),d("开始创建自定义智能体")},[d]),w=m.useCallback(()=>{c(null),u(null),g(!1),n("market"),p==null||p()},[p,c,u,n]),S=m.useMemo(()=>b.jsxs("div",{className:"automation-header-actions",children:[b.jsx(or,{title:o>0?`收件箱 · ${o} 条待处理`:"收件箱",children:b.jsx(xv,{dot:o>0,children:b.jsx(Et,{className:"automation-header-icon-button",icon:b.jsx(Zg,{}),"aria-label":"收件箱",onClick:s})})}),b.jsx(or,{title:"创建智能体",children:b.jsx(Et,{className:"automation-header-icon-button",icon:b.jsx(Uo,{}),"aria-label":"创建智能体",onClick:x})})]}),[x,s,o]),_=m.useMemo(()=>t==="market"?{title:"自动化Beta",subtitle:"选择一个工作对象进入驾驶舱。",actions:S}:t==="inbox"?{title:"结果收件箱",subtitle:"查看同事转交的执行结果和后续处理入口",actions:b.jsx(Et,{icon:b.jsx(q$,{}),onClick:w,children:"返回智能体选择"})}:r?{title:r,subtitle:"切换阶段查看本次执行的参数、过程和结果",actions:b.jsx(Et,{icon:b.jsx(q$,{}),onClick:w,children:"返回智能体选择"})}:{title:a?"智能体列表读取失败":i>0?"请选择一个智能体":"还没有启用智能体",subtitle:a||(i>0?"从智能体中心选择一个智能体后,再进入驾驶舱运行。":"先到智能体中心启用一个模板,系统会创建用户专属智能体,再进入驾驶舱。")},[i,a,S,w,r,t]);return m.useEffect(()=>{e&&(f==null||f(_))},[e,_,f]),{state:{scheduleModalOpen:h},actions:{openScheduleModal:v,closeScheduleModal:y,returnToAgentSelection:w}}}const Cen=0,$en=[];function Een(){const e=wa(),[t,n]=m.useState(null),[r,i]=m.useState(null),a=m.useRef(null),o=m.useMemo(()=>bs.market.recommendations.byTemplate(t??Cen),[t]),s=mf({...o,enabled:t!==null}),l=Ll({...Bl.market.enableRecommendedTemplate()}),c=m.useCallback(p=>{n(p||null)},[]),u=m.useCallback(p=>{a.current=p,i(p)},[]),d=m.useCallback(async p=>{if(!p)return c(null),[];c(p);try{return await e.fetchQuery({...bs.market.recommendations.byTemplate(p),staleTime:0})}catch{return[]}},[c,e]),f=m.useCallback(async p=>{if(a.current!==null)return;const h=t;u(p);try{const g=await l.mutateAsync(p);return await Ys(e,{type:"market-template-enabled",sourceTemplateId:h},{refetchType:"none"}),g}finally{u(null)}},[t,l,e,u]);return{templates:s.data??$en,loading:t!==null&&s.isFetching,actionId:r,setActionId:u,activate:c,load:d,enable:f}}const Ten=[];function Ien({active:e}){const t=wa(),n=m.useMemo(()=>bs.transfers.sent(uen),[]),r=mf({...n,enabled:e}),i=m.useCallback(o=>{t.setQueryData(n.queryKey,(s=[])=>typeof o=="function"?o(s):o)},[t,n.queryKey]),a=m.useCallback(async()=>{try{return await t.fetchQuery({...n,staleTime:0})}catch{return[]}},[t,n]);return{transfers:r.data??Ten,setTransfers:i,transfersLoading:e&&r.isFetching,loadTransfers:a}}const w4e={runInputFields:[],runInputGroups:[],runInputFormUi:{},runFormValues:{},runFormInstanceKey:0,rememberedRunGroupKeys:[],runSelectSearchValues:{},runTextDraftValues:{},runInputData:{},runConfigAgentId:null,runFormLoading:!1,runUploading:{},runFileNameMap:{}};function ken(e,t){return typeof t=="function"?t(e):t}function Pen(e,t){switch(t.type){case"begin_config_loading":return{...e,runInputFields:t.config.fields,runInputGroups:t.config.formGroups,runInputFormUi:t.config.formUi,runFormLoading:!0};case"apply_config":return{...e,runInputFields:t.config.fields,runInputGroups:t.config.formGroups,runInputFormUi:t.config.formUi,runFormValues:t.values,rememberedRunGroupKeys:t.rememberedGroupKeys,runTextDraftValues:{},runConfigAgentId:t.agentId,runFormLoading:!1};case"replace_values":{const n=ken(e.runFormValues,t.next);return n===e.runFormValues?e:{...e,runFormValues:n}}case"update_field":return{...e,runFormValues:{...e.runFormValues,[t.name]:t.value}};case"update_text_draft":return e.runTextDraftValues[t.name]===t.value?e:{...e,runTextDraftValues:{...e.runTextDraftValues,[t.name]:t.value}};case"commit_text_field":{const n={...e.runTextDraftValues};return delete n[t.name],{...e,runTextDraftValues:n,runFormValues:{...e.runFormValues,[t.name]:t.value}}}case"update_select_search":{const n=e.runSelectSearchValues[t.name];if(!t.value&&n&&!t.allowEmpty)return e;if(!t.value){if(!n)return e;const r={...e.runSelectSearchValues};return delete r[t.name],{...e,runSelectSearchValues:r}}return n===t.value?e:{...e,runSelectSearchValues:{...e.runSelectSearchValues,[t.name]:t.value}}}case"set_input_snapshot":return{...e,runInputData:t.values};case"apply_retry_values":return{...e,runInputData:{},runFormValues:t.values,runTextDraftValues:{},runSelectSearchValues:{},runFormInstanceKey:e.runFormInstanceKey+1};case"set_remembered_group_keys":return{...e,rememberedRunGroupKeys:t.groupKeys};case"reset_execution":return{...e,runFormValues:t.values,rememberedRunGroupKeys:t.rememberedGroupKeys,runTextDraftValues:{},runInputData:{},runSelectSearchValues:{},runUploading:{},runFileNameMap:{},runFormInstanceKey:e.runFormInstanceKey+1};case"reset_agent":return{...w4e,runFormInstanceKey:e.runFormInstanceKey};case"set_uploading":return{...e,runUploading:{...e.runUploading,[t.fieldName]:t.uploading}};case"remember_file_name":return{...e,runFileNameMap:{...e.runFileNameMap,[t.url]:t.name}}}}function Nen(){const[e,t]=m.useReducer(Pen,w4e),n=m.useRef({}),{runInputFields:r,runInputGroups:i,runInputFormUi:a,runFormValues:o,runFormInstanceKey:s,rememberedRunGroupKeys:l,runSelectSearchValues:c,runTextDraftValues:u,runInputData:d,runConfigAgentId:f,runFormLoading:p,runUploading:h,runFileNameMap:g}=e,v=m.useCallback(R=>{t({type:"replace_values",next:R})},[]),y=m.useCallback((R,L)=>{t({type:"update_field",name:R,value:L})},[]),x=m.useCallback((R,L)=>{t({type:"update_text_draft",name:R,value:L})},[]),w=m.useCallback((R,L)=>{t({type:"commit_text_field",name:R,value:L})},[]),S=m.useCallback(R=>{n.current[R]=!0},[]),_=m.useCallback((R,L)=>{const z=n.current[R]===!0;n.current[R]=!1,t({type:"update_select_search",name:R,value:L,allowEmpty:z})},[]),C=m.useCallback((R,L)=>async({file:z,onSuccess:j,onError:O})=>{var V,B,D;t({type:"set_uploading",fieldName:R,uploading:!0});try{const F=z,H=await Sy(F),W=(V=H==null?void 0:H.data)==null?void 0:V.url,K=((B=H==null?void 0:H.data)==null?void 0:B.name)||F.name||(W==null?void 0:W.split("/").pop())||"未知文件";if(!W)throw new Error(((D=H==null?void 0:H.data)==null?void 0:D.message)||"上传失败");t({type:"remember_file_name",url:W,name:K}),L<=1?y(R,W):v(U=>{const q=Array.isArray(U[R])?U[R]:U[R]?[U[R]]:[];return{...U,[R]:[...q,W]}}),j==null||j(H),Ze.success("上传成功")}catch(F){O==null||O(F instanceof Error?F:new Error(Ai(F,"文件上传失败"))),Ze.error(Ai(F,"文件上传失败"))}finally{t({type:"set_uploading",fieldName:R,uploading:!1})}},[v,y]),$=m.useCallback(R=>{t({type:"begin_config_loading",config:R})},[]),E=m.useCallback((R,L)=>{const z=Tye(R,L.fields,L.formGroups);t({type:"apply_config",agentId:R,config:L,values:x1(L.fields,z.values),rememberedGroupKeys:z.groupKeys})},[]),k=m.useCallback(R=>{const L=R?Tye(R,r,i):{values:{},groupKeys:[]};n.current={},t({type:"reset_execution",values:x1(r,L.values),rememberedGroupKeys:L.groupKeys})},[r,i]),T=m.useCallback(()=>{n.current={},t({type:"reset_agent"})},[]),I=m.useCallback((R=r,L=o)=>t4e(R,L),[o,r]),P=m.useCallback((R,L=I())=>{const z=BOe(L,o),j=YQt(R,L,i,z);return t({type:"set_remembered_group_keys",groupKeys:j}),z},[I,o,i]),N=m.useCallback(R=>{t({type:"set_input_snapshot",values:R})},[]),A=m.useCallback(()=>{t({type:"set_input_snapshot",values:{}})},[]),M=m.useCallback(R=>{n.current={},t({type:"apply_retry_values",values:R})},[]);return{runInputFields:r,runInputGroups:i,runInputFormUi:a,runFormValues:o,runFormInstanceKey:s,rememberedRunGroupKeys:l,runSelectSearchValues:c,runTextDraftValues:u,runInputData:d,runConfigAgentId:f,runFormLoading:p,runUploading:h,runFileNameMap:g,replaceRunFormValues:v,updateRunField:y,updateRunTextDraftField:x,commitRunTextField:w,allowEmptyRunSelectSearch:S,updateRunSelectSearch:_,handleRunFileUpload:C,beginInputConfigLoading:$,applyInputConfig:E,resetForExecution:k,getVisibleFields:I,persistCurrentRunValues:P,setInputSnapshot:N,clearInputSnapshot:A,applyRetryValues:M,resetForAgent:T}}function S4e(e){var r,i;if(e.status!=="completed"||!e.humanConfirmTriggered||!lt(e.rawData))return null;const t=Sj(e.rawData);return!((r=t.confirm_fields)!=null&&r.length||(i=t.input_fields)!=null&&i.length||ni(t.output)||ni(t.input)||ni(t.submitted_input))?null:{...t,message:t.message||e.title,actions:["readonly"]}}function Aen(e){return e==="running"?"执行中":e==="waiting"?"等待确认":e==="completed"?"已完成":e==="failed"?"执行失败":"待执行"}function Men(e){const t=e.replace(/^\[[^\]]+\]\s*/,"").trim();return t?`AI 正在生成 ${t}`:"AI 正在生成内容"}function Ren(e){var n,r;const t=(r=(n=e.description)==null?void 0:n.match(/\b\d{1,2}:\d{2}\b/))==null?void 0:r[0];return t||(e.status==="running"?"进行中":e.status==="waiting"?"待确认":e.status==="failed"?"执行失败":"")}function Den({workspaceMode:e,isExecuting:t,phase:n,activeRun:r,activeRunFailed:i,runPreviewSteps:a,waitingRun:o,waitingInfo:s,waitingPreviewSteps:l,selectedWorkbenchStageKey:c}){return m.useMemo(()=>{const u=l&&l.runId===(o==null?void 0:o.id)?l.steps:[],d=b4e(o??void 0,s,u.length>0?u:a),f=e==="run"?a:e==="waiting"?d:(r==null?void 0:r.steps)??[],p=d.length>0?`step:${d[HJt(d)].id}`:"params",h=f.findIndex(P=>P.status==="failed"||P.status==="waiting"||P.status==="running"),g=f.reduce((P,N,A)=>N.status==="completed"?A:P,-1),v=h>=0?h:Math.max(0,g),y=f[v]?`step:${f[v].id}`:"params",x=e==="run"?n==="completed":(r==null?void 0:r.status)==="completed",w=P=>!!x||(e==="run"&&n==="idle"?!1:P<=v),S=e==="run"?n==="idle"?"params":x?"complete":y:e==="waiting"?p:x?"complete":y,_=["params",...f.flatMap((P,N)=>w(N)?[`step:${P.id}`]:[]),...x?["complete"]:[]],C=_.includes(c)?c:S,$=C.startsWith("step:")?f.find(P=>`step:${P.id}`===C):void 0,E=!!($&&S4e($)),k=e==="run"&&!t?"running":"completed",T=x?i?"failed":"completed":"pending",I=[{key:"params",kind:"params",title:e==="run"?"新建任务":"运行参数",eyebrow:"执行参数",description:e==="run"?"填写必要字段,参数会随执行记录保存。":"查看这次执行实际使用的输入。",status:k,accessible:!0},...f.map((P,N)=>({key:`step:${P.id}`,kind:"step",title:P.title,eyebrow:`执行步骤 ${N+1}`,description:P.status==="failed"?"流程已在当前步骤停止。":P.description||"执行智能体配置的流程。",status:P.status,accessible:w(N),step:P})),{key:"complete",kind:"complete",title:x?"查看结果":"提交 · 查看结果",eyebrow:"执行完成",description:x?"查看最终结果和流转记录。":"所有执行步骤结束后,这里会展示最终结果。",status:T,accessible:x}];return{waitingSteps:d,workbenchSteps:f,waitingActiveStageKey:p,currentWorkbenchStepIndex:v,currentExecutionStageKey:y,workbenchIsCompleted:x,canOpenWorkbenchStep:w,defaultWorkbenchStageKey:S,accessibleWorkbenchStageKeys:_,activeWorkbenchStageKey:C,selectedWorkbenchStep:$,selectedWorkbenchStepHasConfirmPreview:E,workbenchFlowStages:I}},[r,i,t,n,a,c,s,l,o,e])}function Oen({agentKind:e,activeRunId:t,workspaceMode:n,defaultStageKey:r,accessibleStageKeys:i,activeStageKey:a,expandedStageKeys:o,setSelectedStageKey:s,setExpandedStageKeys:l,setTransitioning:c,stageContextRef:u,transitionTimerRef:d,switchTimerRef:f}){m.useEffect(()=>{const g=`${e}:${n}:${t}`,v=u.current!==g;u.current=g,s(r),l(y=>{if(v)return[r];const x=y.filter(w=>i.includes(w));return x.includes(r)?x:[...x,r]})},[i,t,e,r,l,s,u,n]);const p=m.useCallback(g=>{i.includes(g)&&(g===a&&o.includes(g)||(c(!0),s(g),l(v=>v.includes(g)?v:[...v,g]),f.current!=null&&(window.clearTimeout(f.current),f.current=null),d.current!=null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{c(!1),d.current=null},180)))},[i,a,o,l,s,c,f,d]),h=m.useCallback(g=>{f.current!=null&&(window.clearTimeout(f.current),f.current=null),d.current!=null&&(window.clearTimeout(d.current),d.current=null),c(!1),l(v=>v.filter(y=>y!==g))},[l,c,f,d]);return{selectStage:p,collapseStage:h}}const Len=[{key:"attention",label:"需要你处理"},{key:"running",label:"进行中"},{key:"completed",label:"已完成"}],jen={id:"",kind:"custom",name:"",source:"",description:"",status:"",schedule:"",nextRun:""};function zen(e){return e?{id:String(e.id),kind:e.name.toLowerCase().includes("amazon")?"amazon":"custom",name:e.name,source:e.is_from_market?"来自智能体市场":e.origin_type==="from_transfer"?"来自结果流转":"自定义智能体",description:e.description||e.scene_name||"这个智能体已启用,可以运行、查看历史、配置定时任务。",status:e.status==="active"?"已启用":e.status==="draft"?"草稿可运行":"已归档",schedule:e.schedule_display||e.schedule_cron||"",nextRun:e.next_run_at?Mw(e.next_run_at):"暂无定时"}:jen}function Fen(e){return e?typeof e.has_schedule=="boolean"?e.has_schedule:!!(e.schedule_enabled||e.schedule_cron||e.next_run_at):!1}function Ben({runs:e,activeRunId:t,activeRunSnapshot:n}){return e.find(r=>r.id===t)??n??e[0]}function Ven(e,t){return(e==="schedule"?null:e)??((t==null?void 0:t.status)==="waiting"?"waiting":t?"detail":"run")}function Hen({runs:e,statusFilter:t,historyTotal:n,page:r,pageSize:i}){const a=hee(e),o=t==="all"?a:a.filter(d=>JU(d)===t),s=n,l=Math.max(1,Math.ceil(s/i)),c=Math.min(r,l),u=Len.map(d=>({...d,runs:o.filter(f=>JU(f)===d.key)})).filter(d=>d.runs.length>0);return{sortedRuns:a,filteredRuns:o,recordTotal:s,pageCount:l,activePage:c,groups:u}}const Wen=10;function Uen({view:e,agents:t,selectedAgentId:n,agentKind:r,realRuns:i,activeRunId:a,setActiveRunId:o,activeRunSnapshot:s,setActiveRunSnapshot:l,historyTotal:c,historyLoading:u,historyError:d,loadExecutions:f,activateHistory:p,deletingExecutionId:h,agentTransitionId:g,setAgentTransitionId:v,runFormLoading:y,runConfigAgentId:x,runPreviewStepItems:w,liveExecutionTraces:S,drawer:_,phase:C,transfers:$,waitingRunId:E,waitingInfo:k,waitingPreviewSteps:T}){const[I,P]=m.useState("all"),[N,A]=m.useState(1),[M,R]=m.useState("params"),[L,z]=m.useState(["params"]),[j,O]=m.useState(!1),V=m.useRef(""),B=m.useRef(null),D=m.useRef(""),F=m.useRef(null),H=m.useRef(null),W=m.useMemo(()=>t.find(Ie=>Ie.id===n)??null,[t,n]),K=m.useMemo(()=>zen(W),[W]),U=!!W,q=m.useMemo(()=>w.length>0?w:kee(W),[w,W]),Q=i,G=m.useMemo(()=>Ben({runs:Q,activeRunId:a,activeRunSnapshot:s}),[a,s,Q]),X=m.useMemo(()=>Q.find(Ie=>Ie.id===E)??G,[G,Q,E]),J=Ven(_,G),Y=C==="running"||C==="review_content"||C==="review_submit"||C==="polling",Z=Rw(G),re=yQt(G),ee=m.useMemo(()=>G?$.filter(Ie=>sen(Ie,G)):[],[G,$]),te=y||!!(U&&J==="run"&&W&&x!==W.id),oe=!!(e==="cockpit"&&W&&g===W.id),fe=m.useMemo(()=>S.find(Ie=>Ie.agentId===n&&Ie.steps.length>0)??null,[S,n]),he=m.useMemo(()=>(fe==null?void 0:fe.steps.filter(Ie=>Ie.kind==="substep"||Ie.id.startsWith("substep:")))??[],[fe]),ye=m.useMemo(()=>Hen({runs:Q,statusFilter:I,historyTotal:c,page:N,pageSize:Wen}),[N,I,c,Q]),{workbenchSteps:Te,waitingActiveStageKey:Ee,workbenchIsCompleted:we,defaultWorkbenchStageKey:le,accessibleWorkbenchStageKeys:se,activeWorkbenchStageKey:ne,selectedWorkbenchStepHasConfirmPreview:ge,workbenchFlowStages:be}=Den({workspaceMode:J,isExecuting:Y,phase:C,activeRun:G,activeRunFailed:Z,runPreviewSteps:q,waitingRun:X,waitingInfo:k,waitingPreviewSteps:T,selectedWorkbenchStageKey:M}),{selectStage:Ce,collapseStage:Ae}=Oen({agentKind:r,activeRunId:a,workspaceMode:J,defaultStageKey:le,accessibleStageKeys:se,activeStageKey:ne,expandedStageKeys:L,setSelectedStageKey:R,setExpandedStageKeys:z,setTransitioning:O,stageContextRef:D,transitionTimerRef:F,switchTimerRef:H}),je=`${r}:${n??""}`;m.useEffect(()=>{if(e==="cockpit"&&n){if(V.current!==je&&(V.current=je,N!==1)){A(1);return}p(n,N)}},[p,je,N,n,e]),m.useEffect(()=>{i.length!==0&&o(Ie=>{var De;return i.some(Ue=>Ue.id===Ie)?Ie:((De=i[0])==null?void 0:De.id)??""})},[i,o]),m.useEffect(()=>{if(!U||!a)return;const Ie=i.find(De=>De.id===a);Ie&&l(Ie)},[a,U,i,l]),m.useEffect(()=>{!n||g!==n||u||y||x!==n||v(null)},[g,u,x,y,n,v]),m.useEffect(()=>{if(he.length===0&&!(fe!=null&&fe.updatedAt))return;const Ie=B.current;if(!Ie)return;const De=window.requestAnimationFrame(()=>{Ie.scrollTop=Ie.scrollHeight});return()=>window.cancelAnimationFrame(De)},[he.length,fe==null?void 0:fe.updatedAt]),m.useEffect(()=>()=>{H.current!=null&&window.clearTimeout(H.current),F.current!=null&&window.clearTimeout(F.current)},[]);const ce=m.useCallback(Ie=>{P(Ie),A(1)},[]),de=m.useCallback(Ie=>{A(Ie)},[]),_e=m.useCallback(()=>{n&&f(n,N)},[N,f,n]),Me=m.useCallback(()=>{if(n){if(N===1){f(n,1);return}A(1)}},[N,f,n]);return{model:{agentName:K.name,transitionLoading:oe,history:{agentName:K.name,hasSchedule:Fen(W),mode:J,error:d,loading:u,filteredRunCount:ye.filteredRuns.length,runCount:Q.length,statusFilter:I,groups:ye.groups,recordTotal:ye.recordTotal,pagination:{page:ye.activePage,pageCount:ye.pageCount},deletingExecutionId:h,activeRunId:a},liveTrace:{active:fe,substeps:he,stepsRef:B},workbench:{mode:J,activeRunFailed:Z,activeStageKey:ne,waitingActiveStageKey:Ee,selectedStepHasConfirmPreview:ge}},state:{selectedAgent:W,agent:K,isLiveAgent:U,runPreviewSteps:q,runs:Q,activeRun:G,waitingRun:X,waitingRunIdForPreview:(X==null?void 0:X.id)??"",waitingRunStatusForPreview:X==null?void 0:X.status,waitingRunSummaryForPreview:X==null?void 0:X.summary,workspaceMode:J,runParametersLoading:te,isExecuting:Y,activeRunTransfers:ee,activeRunFailed:Z,canShareActiveRun:re,historyPage:N,workbenchSteps:Te,waitingActiveStageKey:Ee,workbenchIsCompleted:we,activeWorkbenchStageKey:ne,workbenchFlowStages:be,expandedWorkbenchStageKeys:L,workbenchStageTransitioning:j},actions:{changeHistoryStatusFilter:ce,changeHistoryPage:de,reloadHistory:_e,refreshHistory:Me,selectWorkbenchStage:Ce,collapseWorkbenchStage:Ae,setSelectedWorkbenchStageKey:R,setExpandedWorkbenchStageKeys:z}}}const Gen=new Set(["string","text","textarea","url","boolean","number","integer","float","date","datetime","time","select","array","list","tags","multi_select","multiselect","file"]),jye=new Set(["segmented","source","address","daterange","datetimerange","timerange"]);function qen(e){var n,r;const t=e.type.toLowerCase();return["string","text","textarea","url"].includes(t)&&!((n=e.enum)!=null&&n.length)&&!((r=e.options)!=null&&r.length)&&!e.options_from_skill}function _4e(e,t){const n=t.split(".")[0];return e.find(r=>r.name===t||r.name===n)}function Ken(e){var t;return(t=e.options)!=null&&t.length?e.options:(e.enum||[]).map(n=>({label:n,value:n}))}function zye(e,t,n=e){const r=Ken(t);r.length!==0&&(n.enum=r.map(i=>i.value),n.enumNames=r.map(i=>i.label))}function Yen(e,t,n){if(!t.options_from_skill)return;const r=aJ(t.options_params||{});e.options_from_skill=t.options_from_skill,e.options_params=t.options_params||{},e["x-options-blocking-dependencies"]=r.filter(i=>{var a;return((a=_4e(n,i))==null?void 0:a.required)??!0}),e["x-clear-on-options-change"]=!0}function Xen(e,t){var i,a;const n=e.type.toLowerCase(),r={title:e.label||e.name,...e.placeholder?{placeholder:e.placeholder}:{},...e.hint||e.description?{description:e.hint||e.description}:{},...e.default!==void 0?{default:e.default}:{},...(e.span??1)>1||["text","textarea","url","file"].includes(n)?{"x-full-width":!0}:{}};if(n==="boolean")r.type="boolean";else if(n==="integer")r.type="integer";else if(n==="number"||n==="float")r.type="number";else if(n==="date"||n==="datetime"||n==="time")r.type="string",r.widget=n,e.format&&(r["x-temporal-format"]=e.format),e.picker&&(r["x-temporal-picker"]=e.picker),e.show_time!==void 0&&(r["x-temporal-show-time"]=e.show_time);else if(n==="file"){const o=Math.max(e.max_files??1,1);o>1?(r.type="array",r.items={type:"string",format:"uri"},r.maxItems=o):(r.type="string",r.format="uri"),r.widget="file",r.file_type=e.file_type,r.max_files=o}else if(_C(n)){const o={type:"string"};r.type="array",r.items=o,zye(r,e,o)}else r.type="string",(n==="text"||n==="textarea"||n==="url")&&(r.widget="textarea"),zye(r,e);return(n==="select"||(i=e.enum)!=null&&i.length||(a=e.options)!=null&&a.length||e.options_from_skill)&&(r.widget="select"),Yen(r,e,t),r}function Zen(e){var t;for(const n of e){const r=n.type.toLowerCase(),i=oj(n);if(n.visible_when!==void 0)return"conditional-visibility";if(n.range||FOe(n)||aj(n)||jye.has(r)||jye.has(i))return"special-control";if(!Gen.has(r))return"unsupported-type";if((t=n.file_templates)!=null&&t.length)return"file-templates"}for(const n of e)if(n.options_from_skill)for(const r of aJ(n.options_params||{})){const i=_4e(e,r);if(i&&qen(i))return"draft-dependency"}}function Qen(e,t){return Object.fromEntries(e.map(n=>{const r=ET(n.remember_last)&&t.includes(n.key);return[n.key,{title:`${n.title.replace(/(已记住上次选择)$/,"")}${r?"(已记住上次选择)":""}`,description:n.description,propertyNames:n.fields,columns:Math.min(Math.max(n.columns??1,1),3)}]}))}function Jen({fields:e,groups:t=[],rememberedGroupKeys:n=[]}){if(e.length===0)return{eligible:!1,reason:"missing-fields"};const r=Zen(e);if(r)return{eligible:!1,reason:r};const i=Object.fromEntries(e.map(s=>[s.name,Xen(s,e)])),a=e.filter(s=>s.required).map(s=>s.name);return{eligible:!0,schema:{type:"object",properties:i,...a.length?{required:a}:{},...t.length?{propertyGroups:Qen(t,n)}:{}},hasGroups:t.length>0}}function etn({stepCount:e,isExecuting:t,runParametersLoading:n,onStartRun:r}){const i=t?"执行中":n?"读取参数":"直接开始执行";return b.jsxs("div",{className:"wandox-automation-direct-run",children:[b.jsxs("div",{className:"wandox-automation-direct-run__hero",children:[b.jsx("span",{className:"wandox-automation-direct-run__icon","aria-hidden":"true",children:b.jsx(Fc,{})}),b.jsxs("div",{className:"wandox-automation-direct-run__copy",children:[b.jsx("span",{className:"wandox-automation-direct-run__eyebrow",children:"直接执行"}),b.jsx("strong",{className:"wandox-automation-direct-run__title",children:"这个智能体无需填写运行参数"}),b.jsx("p",{className:"wandox-automation-direct-run__description",children:"系统会使用智能体默认配置运行,执行过程和最终结果会在当前页面持续更新。"})]}),b.jsx("span",{className:"wandox-automation-direct-run__badge",children:e>0?`${e} 个步骤`:"自动执行"})]}),b.jsxs("div",{className:"wandox-automation-direct-run__footer",children:[b.jsx("span",{className:"wandox-automation-direct-run__hint",children:"无需补充信息,开始后可在左侧历史记录中追踪本次运行。"}),b.jsxs("button",{type:"button",className:"automation-action-button automation-action-button--primary wandox-automation-direct-run__button",onClick:r,disabled:t||n,children:[b.jsx(Fc,{}),i]})]})]})}function Fye({status:e}){return b.jsx("span",{className:`automation-step-dot automation-step-dot--${e}`})}function ttn({value:e}){const t=u4e(e);if(!ni(t))return null;if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=Object.entries(t).filter(([r,i])=>!["execution_steps","output_fields_map","output_type"].includes(r)&&ni(i)).slice(0,16);return n.length===0?null:b.jsx("div",{className:"automation-detail-data-grid",children:n.map(([r,i])=>b.jsxs("div",{children:[b.jsx("span",{children:r}),b.jsx("pre",{children:Eye(i)})]},r))})}return b.jsx("pre",{className:"automation-detail-json",children:Eye(t)})}function ntn({steps:e,className:t}){return b.jsx("div",{className:["automation-mini-steps",t].filter(Boolean).join(" "),children:e.map(n=>{var r;return b.jsxs("div",{className:"automation-mini-step",children:[b.jsx(Fye,{status:n.status}),b.jsxs("div",{children:[b.jsx("span",{children:n.title}),(r=n.substeps)!=null&&r.length?b.jsx("div",{className:"wandox-automation-mini-substeps",children:n.substeps.map(i=>b.jsxs("div",{className:`wandox-automation-mini-substeps__item wandox-automation-mini-substeps__item--${i.status}`,children:[b.jsx(Fye,{status:i.status}),b.jsx("span",{children:i.title})]},i.id))}):null]})]},n.id)})})}function rtn({run:e}){return b.jsx(ntn,{steps:e.steps})}function itn({run:e,isExecuting:t,rerunningRunId:n,reExecutingStepId:r,onRerun:i}){const a=n===e.id;return b.jsxs("div",{className:"wandox-automation-task-rerun",children:[b.jsxs("div",{className:"wandox-automation-task-rerun__copy",children:[b.jsx("strong",{children:"重新执行整个任务"}),b.jsx("span",{children:"沿用本次参数,确认后创建新的执行记录"})]}),b.jsxs("button",{type:"button",className:"automation-action-button automation-action-button--primary",onClick:()=>i(e),disabled:t||!!n||!!r,children:[b.jsx(yy,{}),a?"读取参数":"重新执行"]})]})}function atn({sender:e,isExecuting:t,onReturn:n}){return b.jsxs("div",{className:"wandox-inbox-run-context",children:[b.jsx("span",{className:"wandox-inbox-run-context__icon","aria-hidden":"true",children:b.jsx(Zg,{})}),b.jsxs("div",{className:"wandox-inbox-run-context__copy",children:[b.jsx("span",{className:"wandox-inbox-run-context__eyebrow",children:"承接流转结果"}),b.jsxs("strong",{className:"wandox-inbox-run-context__title",children:["来自 ",e||"同事"," 的执行结果"]}),b.jsx("p",{className:"wandox-inbox-run-context__description",children:"填写本次运行参数后,系统会创建新的执行记忆并保留流转来源。"})]}),!t&&b.jsx("button",{type:"button",className:"wandox-inbox-run-context__back",onClick:n,children:"返回收件箱"})]})}function otn({templates:e,loading:t,canExecute:n,actionTemplateId:r,onExecute:i,onEnable:a}){return t&&e.length===0?b.jsx("section",{className:"wandox-automation-recommendations",children:b.jsxs("div",{className:"wandox-automation-recommendations__empty",children:[b.jsx(vr,{size:"small"}),b.jsx("span",{children:"正在读取推荐智能体"})]})}):e.length===0?null:b.jsxs("section",{className:"wandox-automation-recommendations",children:[b.jsx("div",{className:"wandox-automation-recommendations__head",children:b.jsxs("div",{children:[b.jsx("h3",{children:"推荐下一步"}),b.jsx("p",{children:"基于当前执行结果继续处理。"})]})}),b.jsx("div",{className:"wandox-automation-recommendations__list",children:e.map(o=>{var f,p;const s=o.my_status||"not_enabled",l=r===o.id,c=r!==null,u=s==="disabled_by_offline",d=s==="enabled";return b.jsxs("article",{className:"wandox-automation-recommendation-card",children:[b.jsxs("div",{className:"wandox-automation-recommendation-card__main",children:[b.jsx("div",{className:"wandox-automation-recommendation-card__icon",children:o.icon?b.jsx("img",{src:o.icon,alt:""}):b.jsx(Fc,{})}),b.jsxs("div",{className:"wandox-automation-recommendation-card__content",children:[b.jsx("h4",{children:o.name}),o.description&&b.jsx("p",{children:o.description}),(o.category||((f=o.tags)==null?void 0:f.length))&&b.jsxs("div",{className:"wandox-automation-recommendation-card__tags",children:[o.category&&b.jsx("span",{children:o.category}),(p=o.tags)==null?void 0:p.slice(0,3).map(h=>b.jsx("span",{children:h},h))]})]})]}),b.jsx("div",{className:"wandox-automation-recommendation-card__action",children:u?b.jsx("button",{type:"button",className:"automation-action-button automation-action-button--compact",disabled:!0,children:"已下线"}):d?b.jsxs("button",{type:"button",className:"automation-action-button automation-action-button--primary automation-action-button--compact",disabled:!n||c,onClick:()=>i(o),children:[b.jsx(Fc,{}),l?"执行中":"使用当前结果执行"]}):b.jsxs("button",{type:"button",className:"automation-action-button automation-action-button--compact",disabled:c,onClick:()=>a(o),children:[b.jsx(Uo,{}),l?"启用中":"启用"]})})]},o.id)})})]})}function stn({fields:e,values:t,readOnly:n,loading:r,readOnlyLoading:i,groups:a,rememberedGroupKeys:o,formInstanceKey:s,renderFieldLabel:l,getFormItemClassName:c,renderField:u}){if(r||n&&i&&e.length===0)return b.jsx(CT,{className:"automation-run-loading"});if(e.length===0)return b.jsxs("div",{className:"automation-no-params",children:[b.jsx(sY,{}),b.jsxs("div",{children:[b.jsx("strong",{children:n?"本次执行无需额外参数":"这个智能体无需填写运行参数"}),b.jsx("p",{children:n?"智能体使用默认配置进入执行步骤。":"点击开始执行后,系统会直接创建执行记录并进入流程。"})]})]});if(!n&&a.length>0){const d=new Map(e.map(f=>[f.name,f]));return b.jsx("div",{className:"automation-run-form-groups",children:a.map(f=>{const p=f.fields.map(v=>d.get(v)).filter(v=>!!v);if(p.length===0)return null;const h=Math.min(Math.max(f.columns??1,1),3),g=ET(f.remember_last)&&o.includes(f.key);return b.jsxs("section",{className:"automation-run-form-group-card",children:[b.jsxs("div",{className:"automation-run-form-group-card__head",children:[b.jsxs("strong",{className:"automation-run-form-group-card__title",children:[FQt(f),g&&b.jsx("span",{className:"automation-run-form-group-card__remembered",children:"(已记住上次选择)"})]}),f.description&&b.jsx("span",{className:"automation-run-form-group-card__description",children:f.description})]}),b.jsx(pn,{layout:"vertical",colon:!1,className:"automation-run-form automation-run-form--group-card",style:{gridTemplateColumns:`repeat(${h}, minmax(0, 1fr))`},children:p.map(v=>b.jsx(pn.Item,{label:l(v,!0),className:c(v),children:u(v,t,n)},v.name))},`${f.key}-${s}`)]},f.key)})})}return b.jsx(pn,{layout:"horizontal",colon:!1,labelAlign:"left",labelCol:{flex:"152px"},wrapperCol:{flex:1},className:`automation-run-form automation-run-form--live${n?" wandox-automation-run-form--readonly":""}`,children:e.map(d=>b.jsx(pn.Item,{label:l(d),className:c(d),children:u(d,t,n)},d.name))},n?"readonly-run-form":`editable-run-form-${s}`)}const ltn=m.forwardRef(function({hasGroups:t,presentation:n="sections",expandedGroupKeys:r,onExpandedGroupKeysChange:i,className:a,...o},s){const l=t&&n==="sections",c=t&&n==="collapse";return b.jsx(yje,{ref:s,...o,groupDisplay:n,groupAccordion:!1,destroyInactiveGroups:!1,expandedGroupKeys:c?r:void 0,onExpandedGroupKeysChange:c?i:void 0,formLayout:t?"vertical":"horizontal",formLabelAlign:t?void 0:"left",formLabelCol:t?void 0:{flex:"152px"},formWrapperCol:t?void 0:{flex:1},showArrayControls:!1,className:["wandox-automation-schema-form","wandox-automation-schema-run-form",l?"wandox-automation-schema-form--grouped":void 0,l?"wandox-automation-schema-run-form--grouped":void 0,c?"wandox-automation-schema-form--collapsible":void 0,c?"wandox-automation-schema-run-form--collapsible":void 0,a].filter(Boolean).join(" ")})});function ctn({schema:e,value:t,hasGroups:n,formInstanceKey:r,onChange:i}){return b.jsx(ltn,{schema:e,value:t,formSize:"middle",onChange:i,loadOptions:$je,uploadFile:Eje,hasGroups:n,presentation:"sections"},`automation-schema-run-form-${r}`)}function C4e({children:e,tone:t="gray"}){return b.jsx("span",{className:`automation-badge automation-badge--${t}`,children:e})}function utn(e){return e==="accepted"?"已接收":e==="rejected"?"已拒绝":e==="expired"?"已过期":e==="cancelled"?"已取消":"待查看"}function dtn(e){return e==="accepted"?"green":e==="rejected"?"red":e==="expired"||e==="cancelled"?"gray":"amber"}function ftn({transfer:e}){return b.jsxs("div",{className:"automation-transfer-item",children:[b.jsxs("div",{className:"automation-transfer-item__head",children:[b.jsx("strong",{children:e.target}),b.jsx(C4e,{tone:dtn(e.status),children:utn(e.status)})]}),b.jsx("span",{className:"automation-transfer-item__meta",children:e.time})]})}function ptn({transfers:e,emptyText:t}){return b.jsxs("section",{className:"automation-transfer-feed is-boxed",children:[b.jsxs("div",{className:"automation-panel-head compact",children:[b.jsxs("div",{children:[b.jsx("h3",{children:"流转记录"}),b.jsx("p",{children:"基于这一次执行结果。"})]}),b.jsx(C4e,{tone:"violet",children:`${e.length} 条`})]}),e.length>0?e.map(n=>b.jsx(ftn,{transfer:n},n.id)):b.jsxs("div",{className:"automation-transfer-item",children:[b.jsx("strong",{children:"暂无流转"}),b.jsx("span",{children:t})]})]})}const htn=(...e)=>["automation-action-button",...e].filter(Boolean).join(" ");function mtn({model:e,actions:t}){const{completed:n,run:r,failed:i,running:a,hasResult:o,shareable:s,transfers:l,phase:c,mode:u,progress:{completedSteps:d,stepCount:f},result:{heading:p="执行结果",bodyPayload:h,summary:g="",showSummary:v=!1},content:{runningTransition:y,recommendedTemplates:x,runActions:w}}=e,{share:S}=t;if(!n){const _=i||c==="failed";return b.jsxs("section",{className:"wandox-automation-stage-panel wandox-automation-stage-panel--complete is-pending",children:[b.jsx("div",{className:"wandox-automation-stage-panel__head",children:b.jsxs("div",{children:[b.jsx("h3",{children:_?"本次执行未完成":u==="waiting"?"等待当前步骤处理":a?"执行正在进行":"等待开始执行"}),b.jsx("p",{children:_?"流程已在当前执行步骤停止。":u==="waiting"?"提交当前人工确认后,流程会继续运行并在这里生成结果。":"所有执行步骤结束后,这里会展示最终结果和流转记录。"})]})}),b.jsxs("div",{className:"wandox-automation-stage-empty wandox-automation-stage-empty--complete",children:[b.jsx(sY,{}),b.jsx("strong",{children:"完成结果将在流程结束后生成"}),b.jsx("span",{children:`${d}/${f} 个执行步骤已完成`})]})]})}return r?b.jsxs("div",{className:"wandox-automation-completion-stack",children:[b.jsxs("section",{className:`automation-result-summary${i?" is-failed":""}${a?" is-running":""}`,children:[(!i||a)&&b.jsx("div",{className:"automation-latest-head",children:b.jsx("h3",{className:"wandox-automation-result-heading",children:p})}),a?b.jsx("p",{children:"系统正在执行智能体流程,完成或需要人工确认后会自动更新。"}):v?b.jsx("p",{children:g}):null,a&&y,!a&&(r.resultPayload||r.resultContent)&&b.jsx("div",{className:"automation-result-content",children:b.jsx(Ci,{payload:h})}),!a&&!o&&b.jsxs("div",{className:"wandox-automation-stage-empty wandox-automation-stage-empty--result",children:[b.jsx("strong",{children:i?"本次执行未生成结果":"结果内容仍在生成"}),b.jsx("span",{children:r.summary||"查看各执行步骤了解当前进度。"})]}),!a&&!r.resultPayload&&r.outputs.length>0&&b.jsx("div",{className:"automation-output-grid",children:r.outputs.map(([_,C])=>b.jsxs("div",{children:[b.jsx("span",{children:_}),b.jsx("strong",{children:C})]},_))}),s&&b.jsx("div",{className:"wandox-automation-completion-actions",children:b.jsxs("button",{type:"button",className:htn("automation-action-button--primary"),onClick:()=>S(r),children:[b.jsx(y2e,{}),"流转同事"]})})]}),!a&&x,s&&b.jsx(ptn,{transfers:l,emptyText:"点击流转同事按钮发起协作。"}),u==="run"&&w]}):b.jsx("section",{className:"wandox-automation-stage-panel wandox-automation-stage-panel--complete",children:b.jsxs("div",{className:"wandox-automation-stage-empty wandox-automation-stage-empty--complete",children:[b.jsx(fa,{}),b.jsx("strong",{children:"暂无执行结果"}),b.jsx("span",{children:"开始执行后可在这里查看完成内容。"})]})})}function gtn({stage:e,workspaceMode:t,onSelectStage:n}){if(!e.accessible)return b.jsx("section",{className:"wandox-automation-stage-panel wandox-automation-stage-panel--collapsible wandox-automation-stage-panel--summary wandox-automation-stage-panel--pending",children:b.jsx("div",{className:"wandox-automation-stage-panel__head",children:b.jsx("div",{children:b.jsx("h3",{children:e.title})})})});const r=e.kind==="params"?t==="run"?"展开修改":"查看参数":"查看快照";return b.jsx("section",{className:"wandox-automation-stage-panel wandox-automation-stage-panel--collapsible wandox-automation-stage-panel--summary",children:b.jsxs("div",{className:"wandox-automation-stage-panel__head",children:[b.jsx("div",{children:b.jsx("h3",{children:e.title})}),b.jsx("button",{type:"button",className:"wandox-automation-stage-panel__toggle-button","aria-expanded":"false",onClick:()=>n(e.key),children:r})]})})}function vtn({workspaceMode:e,stages:t,activeStageKey:n,expandedStageKeys:r,transitioning:i,renderStageContent:a,onSelectStage:o}){if(e==="run"){const s=t.find(l=>l.kind==="params");return s?b.jsx("div",{className:"wandox-automation-run-panel",children:a(s,!1)}):null}return b.jsx("div",{className:"wandox-automation-flow",children:t.map((s,l)=>{const c=n===s.key,u=r.includes(s.key),d=["wandox-automation-flow__item",`wandox-automation-flow__item--${s.status}`,c?"is-selected":"",u?"is-expanded":"",s.accessible?"is-accessible":"is-disabled"].filter(Boolean).join(" "),f=["wandox-automation-flow__marker",`wandox-automation-flow__marker--${s.status}`,c?"is-selected":""].filter(Boolean).join(" ");return b.jsxs("div",{className:d,children:[b.jsx("span",{className:f,"aria-hidden":"true",children:s.status==="completed"?b.jsx(ff,{}):s.status==="failed"?b.jsx(ga,{}):l+1}),b.jsx("div",{className:"wandox-automation-flow__content",children:u?a(s,i&&c):b.jsx(gtn,{stage:s,workspaceMode:e,onSelectStage:o})})]},s.key)})})}function ytn({workspaceMode:e,isTransitioning:t,showDirectRunPanel:n,formUi:r,historicalFields:i,historicalValues:a,historicalEmptyBody:o,runBody:s,inboxContext:l,renderFieldLabel:c,formatValue:u,stringifyValue:d,onCollapseStage:f}){const p=i.length===0?o:(()=>{const g=i.map(w=>{const S=a[w.name],_=u(w.name,S)||"-",C=typeof S=="string"?S:d(S);return{field:w,displayValue:_,isWideValue:Math.max(_.length,C.length)>44}}),v=g.filter(w=>!w.isWideValue),y=g.filter(w=>w.isWideValue),x=(w,S=!1)=>b.jsx(Tc.Item,{className:S?"wandox-automation-params-descriptions__item--wide":void 0,label:c(w.field),children:b.jsx("span",{className:`wandox-automation-params-descriptions__value${S?" wandox-automation-params-descriptions__value--wide":""}`,children:w.displayValue})},w.field.name);return b.jsxs("div",{className:"wandox-automation-params-descriptions-stack",children:[v.length>0&&b.jsx(Tc,{bordered:!1,className:"wandox-automation-params-descriptions",column:3,colon:!1,size:"small",children:v.map(w=>x(w))}),y.length>0&&b.jsx(Tc,{bordered:!1,className:"wandox-automation-params-descriptions wandox-automation-params-descriptions--wide",column:1,colon:!1,size:"small",children:y.map(w=>x(w,!0))})]})})(),h=e!=="run";return b.jsxs("section",{className:`wandox-automation-stage-panel wandox-automation-stage-panel--params${h?" wandox-automation-stage-panel--collapsible":""}${n?" wandox-automation-stage-panel--direct-run":""}`,children:[h?b.jsxs("div",{className:"wandox-automation-stage-panel__head",children:[b.jsx("div",{children:b.jsx("h3",{children:"运行参数"})}),b.jsx("button",{type:"button",className:"wandox-automation-stage-panel__toggle-button","aria-expanded":"true",onClick:()=>f("params"),children:"收起"})]}):b.jsx("div",{className:"wandox-automation-stage-panel__head",children:b.jsxs("div",{children:[b.jsx("h3",{children:r.title}),r.description&&b.jsx("p",{children:r.description})]})}),b.jsxs("div",{className:"wandox-automation-stage-panel__body",children:[l,t?b.jsx(CT,{className:"automation-workbench-stage-transition-body"}):e==="run"?s:p]})]})}const TP=(...e)=>["automation-action-button",...e.filter(Boolean)].join(" ");function btn({model:e,actions:t}){const{formFooter:n=!1,footerNote:r,phase:i,executing:a,parametersLoading:o,visibleFieldCount:s,submitLabel:l,showDraft:c,draftLabel:u}=e,{openDetail:d,saveDraft:f,startRun:p,cancelExecution:h}=t,g=o?"读取参数":s===0?"直接开始执行":i==="failed"?"重新执行":a?"执行中":n?l:"开始执行";return b.jsxs("div",{className:`automation-workbench-inline-actions${n?" automation-workbench-inline-actions--form-footer":""}`,children:[n&&r&&b.jsx("span",{className:"automation-workbench-inline-actions__note",children:r}),b.jsx("div",{className:"automation-workbench-inline-actions__buttons",children:i==="completed"?b.jsx("button",{type:"button",className:TP("automation-action-button--primary"),onClick:d,children:"查看结果详情"}):b.jsxs(b.Fragment,{children:[a&&b.jsxs("button",{type:"button",className:TP("automation-action-button--danger"),onClick:h,children:[b.jsx(g2e,{}),"取消执行"]}),n&&c&&!a&&b.jsx("button",{type:"button",className:TP("automation-action-button--form-secondary"),onClick:f,children:u}),b.jsxs("button",{type:"button",className:TP("automation-action-button--primary",n&&"automation-action-button--form-primary"),onClick:p,disabled:a||o,children:[!n&&b.jsx(Fc,{}),g]})]})})]})}function $4e({status:e}){return b.jsx("span",{className:`automation-step-dot automation-step-dot--${e}`})}function xtn({step:e,activeRun:t,canReExecute:n,isExecuting:r,isReExecuting:i,onReExecute:a}){return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"wandox-automation-step-result wandox-automation-step-result--failed",children:b.jsx("p",{children:e.description||(t==null?void 0:t.summary)||"当前步骤执行失败。"})}),n&&t&&b.jsx("div",{className:"wandox-automation-step-actions",children:b.jsxs("button",{type:"button",className:"automation-action-button automation-action-button--primary",onClick:()=>a(e,t),disabled:r||i,children:[b.jsx(yy,{}),i?"重新执行中":"重新执行"]})})]})}function wtn({step:e}){var n;const t=(n=e.substeps)!=null&&n.length?e.substeps:[{id:`${e.id}-progress`,title:e.description||"正在处理当前步骤",event:e.event,status:"running"}];return b.jsxs("div",{className:"wandox-automation-running-step",children:[b.jsx("div",{className:"wandox-automation-running-step__list",children:t.map(r=>{const i=Ren(r);return b.jsxs("div",{className:`wandox-automation-running-step__item wandox-automation-running-step__item--${r.status}`,children:[b.jsx($4e,{status:r.status}),b.jsxs("div",{className:"wandox-automation-running-step__copy",children:[b.jsx("strong",{children:r.title}),r.description&&b.jsx("span",{children:r.description})]}),i&&b.jsx("small",{children:i})]},r.id)})}),b.jsx("p",{className:"wandox-automation-running-step__hint",children:e.humanConfirm?"本步骤可能触发人工确认,实际状态会随执行进度更新。":"步骤正在后台执行,完成后会自动进入下一流程。"})]})}function Stn({step:e}){var t;return(t=e.substeps)!=null&&t.length?b.jsx("div",{className:"wandox-automation-substep-list",children:e.substeps.map(n=>b.jsxs("div",{className:`wandox-automation-substep-list__item wandox-automation-substep-list__item--${n.status}`,children:[b.jsx($4e,{status:n.status}),b.jsxs("div",{children:[b.jsx("strong",{children:n.title}),n.description&&b.jsx("span",{children:n.description})]}),b.jsx("small",{children:Aen(n.status)})]},n.id))}):null}function _tn({children:e,tone:t="gray"}){return b.jsx("span",{className:`automation-badge automation-badge--${t}`,children:e})}function Ctn({step:e,waitingInfo:t,waitingLoading:n,waitingOnlyMissing:r,waitingSubmitting:i,activeRun:a,preview:o=!1,onWaitingOnlyMissingChange:s,onSubmitWaitingInput:l,onOpenWaitingRun:c}){const u=VJt(n,t);return b.jsxs("section",{className:"automation-drawer-section automation-waiting-panel wandox-automation-stage-panel--waiting",children:[b.jsxs("div",{className:"automation-panel-head compact",children:[b.jsx("div",{children:b.jsx("h3",{children:(t==null?void 0:t.message)||e.title||"需要人工确认"})}),b.jsx("div",{className:"automation-waiting-head-tools",children:b.jsx(_tn,{tone:u||(t==null?void 0:t.timeout_minutes)!=null?"blue":"amber",children:u?"读取中":(t==null?void 0:t.timeout_minutes)!=null?`${t.timeout_minutes} 分钟内处理`:"待提交"})})]}),u?b.jsx(CT,{className:"automation-waiting-loading"}):t?b.jsx(see,{data:t,submitting:i,actionsPlacement:"bottom",showOnlyMissing:r,onShowOnlyMissingChange:s,hideFilterSummary:!0,hideTimeoutAlert:!0,hideStepText:!0,hideActions:o,disableBusinessEffects:o,executionFormLayout:!0,onSubmit:l}):b.jsxs("div",{className:"automation-waiting-empty",children:[b.jsx("span",{className:"automation-waiting-empty__icon",children:b.jsx(fa,{})}),b.jsxs("div",{className:"automation-waiting-empty__copy",children:[b.jsx("strong",{children:(a==null?void 0:a.status)==="waiting"?"确认表单待读取":"暂无待处理表单"}),b.jsx("p",{children:(a==null?void 0:a.status)==="waiting"?"读取后展示本步需要处理的字段。":"后端没有返回 waiting-input 内容,刷新执行记录后再查看。"})]}),(a==null?void 0:a.status)==="waiting"&&b.jsx("button",{type:"button",className:"automation-action-button automation-action-button--primary",onClick:()=>c(a),children:"读取确认表单"})]})]})}function $tn({model:e,actions:t,preview:n=!1}){const{step:r,transitioning:i=!1,waiting:{current:a,info:o,loading:s,onlyMissing:l,submitting:c},completedConfirmData:u,activeRun:d,executing:f,retry:{reExecutingStepId:p,rerunningRunId:h,canReExecute:g}}=e,{collapse:v,changeWaitingOnlyMissing:y,submitWaitingInput:x,openWaitingRun:w,reExecute:S}=t,_=`step:${r.id}`,C=r.status==="running";if(a)return b.jsx(Ctn,{step:r,waitingInfo:o,waitingLoading:s,waitingOnlyMissing:l,waitingSubmitting:c,activeRun:d,preview:n,onWaitingOnlyMissingChange:y,onSubmitWaitingInput:x,onOpenWaitingRun:w});const $=cJt(r),E=ni($),k=p===r.id;return b.jsxs("section",{className:`wandox-automation-stage-panel wandox-automation-stage-panel--step wandox-automation-stage-panel--collapsible wandox-automation-stage-panel--${r.status}${C?" wandox-automation-stage-panel--running-progress":""}${u?" wandox-automation-stage-panel--with-confirm-preview":""}`,children:[b.jsxs("div",{className:"wandox-automation-stage-panel__head",children:[b.jsx("div",{children:b.jsxs("h3",{className:C?"wandox-automation-running-step__title":void 0,children:[C&&b.jsx("span",{className:"wandox-automation-running-step__spinner","aria-hidden":"true"}),C?Men(r.title):r.title]})}),b.jsx("button",{type:"button",className:"wandox-automation-stage-panel__toggle-button","aria-expanded":"true",onClick:()=>v(_),children:"收起"})]}),b.jsx("div",{className:"wandox-automation-stage-panel__body",children:i?b.jsx(CT,{className:"automation-workbench-stage-transition-body"}):b.jsxs(b.Fragment,{children:[r.status==="failed"?b.jsx(xtn,{step:r,activeRun:d,canReExecute:g,isExecuting:f||!!h,isReExecuting:k,onReExecute:S}):C?b.jsx(wtn,{step:r}):u?b.jsx("div",{className:"automation-step-confirm-preview",children:b.jsx(see,{data:u,actionsPlacement:"bottom",compact:!0,hideActions:!0,hideFilterToggle:!0,hideFilterSummary:!0,hideTimeoutAlert:!0,hideStepText:!0,disableBusinessEffects:n,executionFormLayout:!0,onSubmit:()=>{}})}):E?b.jsx("div",{className:"wandox-automation-step-output",children:b.jsx(Ci,{payload:$})}):b.jsx("div",{className:"wandox-automation-step-detail",children:b.jsxs("div",{children:[b.jsx("strong",{children:r.status==="completed"?"该步骤已完成":r.status==="waiting"?"该步骤等待人工处理":r.status==="running"?"该步骤正在执行":"该步骤等待执行"}),b.jsx("p",{children:r.humanConfirm?"本步骤配置了可能触发的人工确认。":"流程会自动进入后续步骤。"})]})}),!C&&b.jsx(Stn,{step:r})]})})]})}function Etn({children:e,tone:t="gray"}){return b.jsx("span",{className:`automation-badge automation-badge--${t}`,children:e})}function Ttn(e){const t=document.createElement("a");t.href=e.path,t.download=e.name,t.target="_blank",document.body.appendChild(t),t.click(),document.body.removeChild(t)}function Itn({cockpit:e,execution:t,runForm:n,recommendations:r,waitingOnlyMissing:i,setWaitingOnlyMissing:a,reExecutingStepId:o,rerunningRunId:s,inboxRunTransfer:l,inboxRunTransferSender:c,actions:u}){const{runInputFields:d,runInputGroups:f,runInputFormUi:p,runFormValues:h,runFormInstanceKey:g,rememberedRunGroupKeys:v,runSelectSearchValues:y,runTextDraftValues:x,runFormLoading:w,runUploading:S,runFileNameMap:_,replaceRunFormValues:C,updateRunField:$,updateRunTextDraftField:E,commitRunTextField:k,allowEmptyRunSelectSearch:T,updateRunSelectSearch:I,handleRunFileUpload:P,getVisibleFields:N,persistCurrentRunValues:A}=n,{phase:M,waitingInfo:R,waitingLoading:L,waitingSubmitting:z}=t,{templates:j,loading:O,actionId:V}=r,{selectedAgent:B,runPreviewSteps:D,activeRun:F,workspaceMode:H,runParametersLoading:W,isExecuting:K,activeRunTransfers:U,activeRunFailed:q,canShareActiveRun:Q,workbenchSteps:G,waitingActiveStageKey:X,workbenchIsCompleted:J,activeWorkbenchStageKey:Y,workbenchFlowStages:Z,expandedWorkbenchStageKeys:re,workbenchStageTransitioning:ee}=e.state,{collapseWorkbenchStage:te,selectWorkbenchStage:oe}=e.actions,fe=m.useMemo(()=>Jen({fields:d,groups:f,rememberedGroupKeys:v}),[d,f,v]),he=sj(fe.eligible?[]:d,h,C),ye=new Set(d.map(Se=>Se.name)),Te=["store_account","product_sku","publish_mode"].every(Se=>ye.has(Se)),Ee=f.length>0,we={title:p.title||(Te?"新建刊登任务":"新建任务"),description:p.description||(Te?"填写产品信息后,AI 将自动生成 Listing 文案并完成亚马逊模版映射":Ee?"填写任务信息后,系统将自动执行后续流程":""),footerNote:p.footerNote||(Te?"两种来源拿到基本信息后,AI 统一做亚马逊模版映射,后续流程一致":Ee?"确认参数后,系统将按当前配置执行后续流程":""),submitLabel:p.submitLabel||(Te?"开始生成 Listing →":"开始执行 →"),draftLabel:p.draftLabel||"存为草稿",showDraft:p.showDraft??Ee},le=Se=>{if(Se.hint||Se.description)return Se.hint||Se.description;if(Te){if(Se.name==="category")return"决定亚马逊模版";if(Se.name==="source_skill")return"列表可扩展";if(Se.name==="competitor_refs")return"支持多个,回车添加"}},se=(Se,me=!1)=>{const pe=le(Se);return b.jsxs("span",{className:"wandox-automation-run-field-label",children:[b.jsxs("span",{children:[Se.label||Se.name,Se.required&&b.jsx("span",{className:"automation-required",children:"*"}),me&&pe&&b.jsxs("span",{className:"wandox-automation-run-field-label__inline-hint",children:["(",pe,")"]})]}),!me&&pe&&b.jsx(or,{title:pe,children:b.jsx("span",{className:"wandox-automation-run-field-label__hint","aria-label":`${Se.label||Se.name}说明`,children:b.jsx(ME,{})})})]})},ne=Se=>{var ze,Qe;const me=Se.type.toLowerCase(),pe=oj(Se),xe=["automation-run-form-item"],$e=!!!((ze=Se.enum)!=null&&ze.length||(Qe=Se.options)!=null&&Qe.length||Se.options_from_skill||["select","array","list","tags","segmented"].includes(me)||["select","segmented"].includes(pe))&&["textarea","text","url"].includes(me);return me==="file"&&xe.push("automation-run-form-item--file"),me==="file"&&zOe(Se.file_type)&&xe.push("automation-run-form-item--image"),($e||(Se.span??1)>1)&&xe.push("automation-run-form-item--wide"),xe.join(" ")},ge=(Se,me=h,pe=!1)=>b.jsx(KQ,{field:Se,value:me[Se.name],readOnly:pe,uploading:!!S[Se.name],fileNameMap:_,getOptionState:he.getFieldState,onChange:$,onUpload:P,onDownloadTemplate:Ttn,draftValue:!pe&&Object.prototype.hasOwnProperty.call(x,Se.name)?x[Se.name]:void 0,onDraftChange:pe?void 0:E,onDraftCommit:pe?void 0:k,selectSearchValue:y[Se.name]||"",onSelectAllowEmptySearch:xe=>{T(xe)},onSelectSearchChange:I}),be=({fields:Se=d,values:me=h,readOnly:pe=!1}={})=>{const xe=t4e(Se,me),Le=pe?[]:qQt(xe,f);return!pe&&Se===d&&me===h&&!W&&fe.eligible&&fe.schema?b.jsx(ctn,{schema:fe.schema,value:h,hasGroups:!!fe.hasGroups,formInstanceKey:g,onChange:C}):b.jsx(stn,{fields:xe,values:me,readOnly:pe,loading:!pe&&W,readOnlyLoading:w,groups:Le,rememberedGroupKeys:v,formInstanceKey:g,renderFieldLabel:se,getFormItemClassName:ne,renderField:ge})},Ce=()=>be(),Ae=()=>b.jsx(etn,{stepCount:D.length,isExecuting:K,runParametersLoading:W,onStartRun:u.startRun}),je=()=>!l||H!=="run"?null:b.jsx(atn,{sender:c,isExecuting:K,onReturn:u.returnToInbox}),ce=Se=>{var ze,Qe;const me=Se.steps.findIndex(it=>it.status==="running"||it.status==="waiting"),pe=me>=0?Se.steps[me]:Se.steps[0],xe=((ze=pe==null?void 0:pe.substeps)==null?void 0:ze.find(it=>it.status==="running"))??((Qe=pe==null?void 0:pe.substeps)==null?void 0:Qe[pe.substeps.length-1]),Le=Se.steps.filter(it=>it.status==="completed").length,$e=Se.steps.length||1;return b.jsxs("div",{className:"wandox-automation-running-state",children:[b.jsxs("div",{className:"wandox-automation-running-state__hero",children:[b.jsx("span",{className:"wandox-automation-running-state__pulse","aria-hidden":"true",children:b.jsx("span",{})}),b.jsxs("div",{children:[b.jsx("strong",{children:"生成中"}),b.jsx("p",{children:xe?`正在处理:${xe.title}`:pe?`正在处理:${pe.title}`:"正在创建执行记录"})]}),b.jsx(Etn,{tone:"blue",children:`${Le}/${$e}`})]}),b.jsx(rtn,{run:Se})]})},de=F?b.jsx(ttn,{value:F.detailData}):null,_e=!!(F!=null&&F.resultPayload||F!=null&&F.resultContent||de),Me=(F==null?void 0:F.status)==="running",Re=()=>{const Se=N();B!=null&&B.id&&A(B.id,Se),u.notify("草稿已保存,已记住启用记忆的分组")},Ie=(Se=!1)=>{const me=N().length;return b.jsx(btn,{model:{formFooter:Se,footerNote:we.footerNote,phase:M,executing:K,parametersLoading:W,visibleFieldCount:me,submitLabel:we.submitLabel,showDraft:!!we.showDraft,draftLabel:we.draftLabel},actions:{openDetail:u.openDetail,saveDraft:Re,startRun:u.startRun,cancelExecution:u.cancelExecution}})},De=(Se=!1)=>{const me=d.length>0?d:((F==null?void 0:F.params)??[]).map(([$e],ze)=>({name:`history_param_${ze}`,label:$e,type:"string",required:!1})),pe=d.length>0?o4e(d,F):me.reduce(($e,ze,Qe)=>{var it;return $e[ze.name]=((it=F==null?void 0:F.params[Qe])==null?void 0:it[1])??"",$e},{}),xe=N(),Le=H==="run"&&!W&&xe.length===0;return b.jsx(ytn,{workspaceMode:H,isTransitioning:Se,showDirectRunPanel:Le,formUi:we,historicalFields:me,historicalValues:pe,historicalEmptyBody:be({fields:me,values:pe,readOnly:!0}),runBody:Le?Ae():b.jsxs(b.Fragment,{children:[Ce(),Ie(!0)]}),inboxContext:je(),renderFieldLabel:se,formatValue:i4e,stringifyValue:zy,onCollapseStage:te})},Ue=(Se,me=!1)=>{const pe=S4e(Se),xe=`step:${Se.id}`,Le=H==="waiting"&&xe===X,$e=!!(F&&H!=="run"&&Rw(F));return b.jsx($tn,{model:{step:Se,transitioning:me,waiting:{current:Le,info:R,loading:L,onlyMissing:i,submitting:z},completedConfirmData:pe,activeRun:F,executing:K,retry:{reExecutingStepId:o,rerunningRunId:s,canReExecute:$e}},actions:{collapse:te,changeWaitingOnlyMissing:a,submitWaitingInput:u.submitWaitingInput,openWaitingRun:u.openWaitingRun,reExecute:(ze,Qe)=>void u.reExecuteFailedStep(ze,Qe)}})},nt=()=>{if(!(B!=null&&B.market_template_id))return null;const Se=!!(F&&F.status==="completed"&&!q);return b.jsx(otn,{templates:j,loading:O,canExecute:Se,actionTemplateId:V,onExecute:me=>void u.executeRecommendedTemplate(me),onEnable:me=>void u.enableRecommendedTemplate(me)})},ct=()=>{const Se=Me?"生成中":_e&&nG(F==null?void 0:F.resultTitle)||"执行结果",me=f4e((F==null?void 0:F.resultPayload)??(F==null?void 0:F.resultContent),Se),pe=(F==null?void 0:F.summary.trim())??"",xe=!!(_e&&pe&&!/^(执行完成|已完成(?:\s*\d+\s*个步骤)?)$/.test(pe)&&pe!==Se);return b.jsx(mtn,{model:{completed:J,run:F,failed:q,running:Me,hasResult:_e,shareable:Q,transfers:U,phase:M,mode:H,progress:{completedSteps:G.filter(Le=>Le.status==="completed").length,stepCount:G.length},result:{heading:Se,bodyPayload:me,summary:pe,showSummary:xe},content:{runningTransition:F?ce(F):null,recommendedTemplates:nt(),runActions:Ie()}},actions:{share:Le=>void u.shareRun(Le)}})},ht=(Se,me=!1)=>Se.kind==="params"?De(me):Se.kind==="complete"?ct():Se.step?Ue(Se.step,me):null;return{renderWorkbenchFlow:()=>b.jsx(vtn,{workspaceMode:H,stages:Z,activeStageKey:Y,expandedStageKeys:re,transitioning:ee,renderStageContent:ht,onSelectStage:oe}),renderFailedTaskRerunAction:()=>H==="run"||!F||!q?null:b.jsx(itn,{run:F,isExecuting:K,rerunningRunId:s,reExecutingStepId:o,onRerun:()=>void u.rerunFailedExecution(F)})}}function aG(e){return e.transferred_nickname||e.transferred_username||e.transferred_by||"同事"}function Ij(e){return e.agent_name?`流转了「${e.agent_name}」的执行结果`:"流转了一份执行结果"}function ktn(e){var n;const t=((n=e==null?void 0:e.transfer_message)==null?void 0:n.trim())??"";return t&&t!=="-"?t:""}function Ptn(e){return e?ktn(e)||Ij(e):"暂无待处理结果"}function Ntn(e){return e==="accepted"?"已接收":e==="rejected"?"已拒绝":"待处理"}function Atn(e){return e==="accepted"?"completed":e==="rejected"?"failed":"waiting"}function Mtn(e){return Mw(e.created_at)||e.created_at||"未知时间"}function Rtn(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();if(r===n)return"今天";if(r===n-24*60*60*1e3)return"昨天";const i=`${Al(e.getMonth()+1)}/${Al(e.getDate())}`;return e.getFullYear()===t.getFullYear()?i:`${e.getFullYear()}/${i}`}function Dtn(e){return{id:e.id,transfer:e,primaryText:Ptn(e),statusText:Ntn(e.status),runStatus:Atn(e.status),summary:Ij(e),time:Mw(e.created_at)||"未知时间"}}function Otn(e){return e.map((t,n)=>({item:t,index:n,date:Xje(t.created_at)})).sort((t,n)=>{var r,i;return(((r=n.date)==null?void 0:r.getTime())??0)-(((i=t.date)==null?void 0:i.getTime())??0)||t.index-n.index}).reduce((t,n)=>{const r=n.date?vQt(n.date):"unknown",i=n.date?Rtn(n.date):"未知日期",a=Dtn(n.item),o=t[t.length-1];return(o==null?void 0:o.key)===r?(o.items.push(a),t):(t.push({key:r,label:i,items:[a]}),t)},[])}function Ltn({inboxProcessTransfer:e,agentsRef:t,loadAgents:n,setInboxProcessTransfer:r,setInboxRunTransfer:i,setRejectingTransferId:a,selectAgent:o,notify:s,resetAgentStoreForm:l,setAgentStoreFormName:c,setPendingTransferId:u,setShowAgentDrawer:d}){const f=wa(),p=Ll({...Bl.transfers.reject(),onSuccess:()=>Ys(f,{type:"transfer-rejected"})}),h=m.useCallback(async w=>{r(w),t.current.length===0&&await n(null,!1)},[t,n,r]),g=m.useCallback(w=>{const S=e;S&&(r(null),o(w),i(S),s("已进入承接任务配置"))},[e,s,o,r,i]),v=m.useCallback(w=>{r(null),l(),c(w.agent_name?`${w.agent_name}-处理`:""),u(w.id),d(!0)},[l,c,r,u,d]),y=m.useCallback(()=>{e&&v(e)},[v,e]),x=m.useCallback(w=>{rr.confirm({title:"拒绝这条流转?",content:Ij(w),okText:"拒绝",okButtonProps:{danger:!0},cancelText:"取消",centered:!0,onOk:async()=>{a(w.id);try{await p.mutateAsync(w.id),Ze.success("已拒绝")}catch(S){Ze.error(Ai(S,"操作失败"))}finally{a(null)}}})},[p,a]);return{executeInboxTransfer:h,continueInboxTransfer:g,createAgentFromInbox:v,createAgentFromInboxProcess:y,rejectInboxTransfer:x}}const jtn=0;function ztn({view:e,activeTransfer:t}){const n=wa(),r=e==="inbox"?(t==null?void 0:t.source_result_id)??null:null,i=m.useMemo(()=>bs.results.detail(r??jtn),[r]),a=mf({...i,enabled:r!==null}),o=m.useCallback(async()=>{if(r===null)return null;try{return await n.fetchQuery({...bs.results.detail(r),staleTime:0})}catch{return null}},[n,r]);return{detail:a.data??null,loading:r!==null&&a.isFetching,error:a.error?Ai(a.error,"结果详情读取失败"):"",load:o}}const Ftn=[];function Bye(e,t){Er.setState({transfers:e,transfersLoading:t})}function Btn({active:e}){const t=wa(),n=m.useMemo(()=>bs.transfers.inbox(den),[]),r=mf({...n,enabled:e}),i=r.data??Ftn,a=e&&r.isFetching;m.useEffect(()=>{!e&&r.data===void 0||Bye(i,a)},[e,r.data,a,i]);const o=m.useCallback(async()=>{Er.setState({transfersLoading:!0});try{const s=await t.fetchQuery({...n,staleTime:0});return Bye(s,!1),s}catch{return Er.setState({transfersLoading:!1}),[]}},[n,t]);return{transfers:i,transfersLoading:a,loadTransfers:o}}function oG(e,t){return e.find(n=>n.id===t)??e[0]??null}function Vtn(e,t){const n=oG(e,t);return{groups:Otn(e),pendingCount:e.filter(r=>r.status==="pending").length,activeTransfer:n,active:n?{transfer:n,pending:n.status==="pending",sender:aG(n),time:Mtn(n)}:null}}function Htn({view:e,agents:t,agentsLoading:n,agentsRef:r,loadAgents:i,selectAgent:a,notify:o,inboxRunTransfer:s,setInboxRunTransfer:l,setView:c,setDrawer:u,setModal:d,setAgentTransitionId:f}){const[p,h]=m.useState(null),[g,v]=m.useState(null),[y,x]=m.useState(null),{transfers:w,transfersLoading:S,loadTransfers:_}=Btn({active:e==="inbox"}),C=Er(B=>B.resetForm),$=Er(B=>B.setFormName),E=Er(B=>B.setPendingTransferId),k=Er(B=>B.setShowAgentDrawer),T=m.useMemo(()=>Vtn(w,p),[p,w]),I=ztn({view:e,activeTransfer:T.activeTransfer}),{executeInboxTransfer:P,continueInboxTransfer:N,createAgentFromInbox:A,createAgentFromInboxProcess:M,rejectInboxTransfer:R}=Ltn({inboxProcessTransfer:g,agentsRef:r,loadAgents:i,setInboxProcessTransfer:v,setInboxRunTransfer:l,setRejectingTransferId:x,selectAgent:a,notify:o,resetAgentStoreForm:C,setAgentStoreFormName:$,setPendingTransferId:E,setShowAgentDrawer:k});m.useEffect(()=>{e==="inbox"&&h(B=>{var D;return((D=oG(w,B))==null?void 0:D.id)??null})},[w,e]);const L=m.useCallback(()=>{_()},[_]),z=m.useCallback(()=>{c("inbox"),u(null),d(null),h(B=>{var D;return((D=oG(w,B))==null?void 0:D.id)??null})},[u,d,c,w]),j=m.useCallback(()=>{l(null),u(null),f(null),c("inbox")},[f,u,l,c]),O=m.useMemo(()=>({transferCount:w.length,loading:S,groups:T.groups,active:T.active,rejectingTransferId:y,result:{detail:I.detail,loading:I.loading,error:I.error},process:{transfer:g,agents:t,loading:n,sender:g?aG(g):"",summary:g?Ij(g):""}}),[t,n,I.detail,I.error,I.loading,g,T.active,T.groups,y,w.length,S]),V=m.useMemo(()=>({refresh:L,selectTransfer:h,process:P,createAgent:A,reject:R,retryResult:()=>{I.load()},closeProcess:()=>v(null),continueProcess:N,createAgentFromProcess:M}),[N,A,M,P,I.load,L,R]);return{model:O,state:{pendingCount:T.pendingCount,runTransferSender:s?aG(s):""},actions:{workspace:V,openInbox:z,refreshTransfers:L,returnToInboxFromTransfer:j}}}function Wtn({active:e,agentsRef:t,selectedAgentIdRef:n,selectAgent:r,setSelectedAgentId:i,setActiveRunId:a,setView:o,resetHistory:s,setIdlePhase:l}){const c=wa(),u=m.useMemo(()=>bs.agents.list(len),[]),d=m.useMemo(()=>bs.market.templates.list(cen),[]),f=mf({...u,enabled:e}),p=mf({...d,enabled:e}),h=f.data??[],g=p.data??[],v=m.useCallback((S,_,C=!1)=>{t.current=S,Er.setState({agents:S,agentsLoading:!1});const $=_?S.find(P=>P.id===_):null,E=n.current,k=E?S.find(P=>P.id===E):null,T=$||k||null;if(T&&($||C)&&r(T),T)return;n.current=null,i(null),s(),a(""),l();const I=Er.getState();I.setExecutionSteps([]),I.setExecutionProgress(0),I.setCurrentExecutionId(null),I.setLatestSSEEvent(null),o(P=>P==="inbox"?"inbox":"market")},[t,s,r,n,a,l,i,o]);m.useEffect(()=>{f.data&&v(f.data)},[f.data,v]);const y=m.useCallback(S=>{c.setQueryData(u.queryKey,(_=[])=>{const C=typeof S=="function"?S(_):S;return t.current=C,Er.setState({agents:C,agentsLoading:!1}),C})},[u.queryKey,t,c]),x=m.useCallback(async()=>{try{return await c.fetchQuery({...d,staleTime:0})}catch{return[]}},[d,c]),w=m.useCallback(async(S,_=!1,C=!1)=>{try{const $=await c.fetchQuery({...u,...C?{staleTime:0}:{}});return v($,S,_),$}catch{return t.current.length===0&&Er.setState({agents:[],agentsLoading:!1}),[]}},[u,t,c,v]);return{agents:h,setAgents:y,agentsLoading:h.length===0&&f.isFetching,agentsError:f.error?Ai(f.error,"加载智能体列表失败"):"",marketTemplates:g,marketLoading:p.isFetching,marketError:p.error?Ai(p.error,"加载市场模板失败"):"",loadAgents:w,loadMarketTemplates:x}}function Utn(e){const t=[],n=new Map;for(const r of e)n.set(r.id,r),!r.is_template&&r.status==="active"&&t.push(r);return{availableAgents:t,agentById:n}}function Gtn({active:e,agentsRef:t,selectedAgentIdRef:n,selectAgent:r,setSelectedAgentId:i,setActiveRunId:a,setView:o,resetHistory:s,setIdlePhase:l}){const c=wa(),u=Ll({...Bl.agents.delete(),onSuccess:(P,N)=>Ys(c,{type:"agent-deleted",agentId:N},{refetchType:"none"})}),d=Ll({...Bl.market.enableTemplate(),onSuccess:()=>Ys(c,{type:"market-template-enabled"},{refetchType:"none"})}),f=d.isPending?d.variables??null:null,p=u.isPending?u.variables??null:null,{agents:h,setAgents:g,agentsLoading:v,agentsError:y,marketTemplates:x,marketLoading:w,marketError:S,loadAgents:_,loadMarketTemplates:C}=Wtn({active:e,agentsRef:t,selectedAgentIdRef:n,selectAgent:r,setSelectedAgentId:i,setActiveRunId:a,setView:o,resetHistory:s,setIdlePhase:l}),{availableAgents:$}=m.useMemo(()=>Utn(h),[h]),E=m.useCallback(P=>{const N=P.is_from_market?"移除":"删除";rr.confirm({title:`${N}「${P.name}」?`,content:P.is_from_market?"移除后可从市场重新启用。":"删除后需要重新创建。",okText:N,cancelText:"取消",okButtonProps:{danger:!0},onOk:async()=>{try{await u.mutateAsync(P.id),Ze.success(`智能体已${N}`),n.current===P.id&&(n.current=null,i(null),s()),o("market"),await _(null,!1),await C()}catch(A){throw Ze.error(Ai(A,`${N}智能体失败`)),A}}})},[u,_,C,s,n,i,o]),k=m.useCallback(async P=>{try{await d.mutateAsync(P.id),await C(),await _(null,!1),o("market"),Ze.success("已启用智能体")}catch(N){Ze.error(Ai(N,"启用模板失败"))}},[d,_,C,o]),T=m.useMemo(()=>({agentsLoading:v,marketLoading:w,marketError:S,marketTemplates:x,availableAgents:$,subscribingTemplateId:f,deletingAgentId:p}),[v,$,p,S,w,x,f]),I=m.useMemo(()=>({reload:C,enableTemplate:k,selectAgent:r,deleteAgent:E}),[E,k,C,r]);return{agents:h,setAgents:g,agentsLoading:v,agentsError:y,loadAgents:_,loadMarketTemplates:C,model:T,actions:I}}function qtn({embedded:e=!1,onHeaderChange:t,onCockpitEnter:n,onCockpitExit:r}){const[i,a]=m.useState("market"),o=MJt(),{drawer:s,setDrawer:l,phase:c,waitingRunId:u,setWaitingRunId:d,waitingInfo:f,setWaitingInfo:p,setWaitingLoading:h,setWaitingSubmitting:g,openDetailDrawer:v,setIdlePhase:y}=o,[x,w]=m.useState(null),[S,_]=m.useState(null),C=m.useRef([]),[$,E]=m.useState(null),k=m.useRef(null),T=Nen(),I=Sen({enabled:i==="cockpit",selectedAgentIdRef:k}),{realRuns:P,activeRunSnapshot:N,setActiveRunSnapshot:A,historyTotal:M,historyLoading:R,historyError:L,loadExecutions:z,activateHistory:j,resetHistory:O}=I,[V,B]=m.useState(null),D=Ien({active:i==="cockpit"}),{transfers:F}=D,[H,W]=m.useState("amazon"),[K,U]=m.useState(""),[q,Q]=m.useState(null),[G,X]=m.useState(""),J=m.useCallback(Nr=>{X(Nr),window.setTimeout(()=>X(""),1900)},[]),{runConfigAgentId:Y,runFormLoading:Z,resetForAgent:re}=T,[ee,te]=m.useState([]),{traces:oe,recordEvent:fe}=RJt(),[he,ye]=m.useState(null),[Te,Ee]=m.useState(!1),we=Een(),le=NJt(),{reset:se}=le,ne=m.useRef(""),ge=m.useRef(null),be=rJ(),{abort:Ce}=be,Ae=m.useCallback(Nr=>{Ce(),Q(null);const Ar=Er.getState();Ar.setExecutionSteps([]),Ar.setExecutionProgress(0),Ar.setCurrentExecutionId(null),Ar.setLatestSSEEvent(null),se();const gi=Nr.name.toLowerCase().includes("amazon")?"amazon":"custom";k.current=Nr.id,B(Nr.id),E(Nr.id),W(gi),U(""),O(!0),y(),re(),te([]),d(""),p(null),h(!1),g(!1),a("cockpit"),l("run"),w(null),n==null||n()},[Ce,n,se,re,O,l,y,p,h,d,g]),{agents:je,setAgents:ce,agentsLoading:de,agentsError:_e,loadAgents:Me,model:Re,actions:Ie}=Gtn({active:i==="market",agentsRef:C,selectedAgentIdRef:k,selectAgent:Ae,setSelectedAgentId:E,setActiveRunId:U,setView:a,resetHistory:O,setIdlePhase:y}),De=Uen({view:i,agents:je,selectedAgentId:$,agentKind:H,realRuns:P,activeRunId:K,setActiveRunId:U,activeRunSnapshot:N,setActiveRunSnapshot:A,historyTotal:M,historyLoading:R,historyError:L,loadExecutions:z,activateHistory:j,deletingExecutionId:S,agentTransitionId:V,setAgentTransitionId:B,runFormLoading:Z,runConfigAgentId:Y,runPreviewStepItems:ee,liveExecutionTraces:oe,drawer:s,phase:c,transfers:F,waitingRunId:u,waitingInfo:f,waitingPreviewSteps:he}),{model:Ue,state:{selectedAgent:nt,agent:ct},actions:{changeHistoryStatusFilter:ht,changeHistoryPage:Ve,reloadHistory:Ye}}=De,{model:Se,state:{pendingCount:me,runTransferSender:pe},actions:{workspace:xe,openInbox:Le,refreshTransfers:$e,returnToInboxFromTransfer:ze}}=Htn({view:i,agents:je,agentsLoading:de,agentsRef:C,loadAgents:Me,selectAgent:Ae,notify:J,inboxRunTransfer:q,setInboxRunTransfer:Q,setView:a,setDrawer:l,setModal:w,setAgentTransitionId:B});m.useEffect(()=>{Ee(!1)},[u]);const{currentExecutionId:Qe,openRun:it}=xen({enabled:i==="cockpit",activeRunId:K,agentsRef:C,setAgents:ce,execution:o,executions:I,runForm:T,cockpit:De,recommendations:we,executionEvents:le,runPreviewStepItems:ee,setRunPreviewStepItems:te,pendingExecutionTitleRef:ne,recommendedExecutionRef:ge,recordLiveTraceEvent:fe,setActiveRunId:U,setWaitingPreviewSteps:ye,notify:J}),{state:{rerunningRunId:st,reExecutingStepId:Ft,transferModalResultId:Ne},actions:{openRunDrawer:ke,openWaitingRun:Ke,submitWaitingInput:Je,rerunFailedExecution:We,reExecuteFailedStep:Oe,startRun:Xe,cancelCurrentExecution:at,closeTransferModal:mt,openShareForRun:ot,deleteExecutionRecord:wt,enableRecommendedTemplate:Pt,executeRecommendedTemplate:Yt}}=QJt({selectedAgentId:$,currentExecutionId:Qe,execution:o,executions:I,runForm:T,cockpit:De,recommendations:we,agentExecution:be,resetExecutionEvents:se,pendingExecutionTitleRef:ne,recommendedExecutionRef:ge,setActiveRunId:U,setDeletingExecutionId:_,setModal:w,inboxRunTransfer:q,setInboxRunTransfer:Q,refreshInboxTransfers:$e,loadAgents:Me,waitingPreviewSteps:he,notify:J}),{state:{scheduleModalOpen:Un},actions:{openScheduleModal:ur,closeScheduleModal:zn,returnToAgentSelection:Fn}}=_en({embedded:e,view:i,setView:a,selectedAgentName:nt?ct.name:null,agentsCount:je.length,agentsError:_e,pendingInboxCount:me,openInbox:Le,reloadAgents:()=>void Me(null,!1),setDrawer:l,setModal:w,notify:J,onHeaderChange:t,onCockpitExit:r}),Da=Itn({cockpit:De,execution:o,runForm:T,recommendations:we,waitingOnlyMissing:Te,setWaitingOnlyMissing:Ee,reExecutingStepId:Ft,rerunningRunId:st,inboxRunTransfer:q,inboxRunTransferSender:pe,actions:{startRun:Xe,cancelExecution:()=>void at(),openDetail:v,notify:J,openWaitingRun:Ke,submitWaitingInput:Je,reExecuteFailedStep:Oe,rerunFailedExecution:We,returnToInbox:ze,shareRun:ot,executeRecommendedTemplate:Yt,enableRecommendedTemplate:Pt}});return b.jsx(TJt,{view:i,market:{model:{embedded:e,...Re},actions:Ie},inbox:{model:{embedded:e,...Se},actions:{back:Fn,...xe}},cockpit:nt?{model:{embedded:e,...Ue},actions:{back:Fn,history:{createRun:ke,configureSchedule:ur,changeStatusFilter:ht,reload:Ye,openRun:it,openWaitingRun:Ke,removeRun:wt,changePage:Ve}},slots:Da}:null,empty:{agentsCount:je.length,error:_e,onOpenMarket:()=>a("market")},transferModal:{open:x==="share",onClose:mt,resultId:Ne},scheduleModal:{agent:nt,open:Un,onClose:zn},toast:G})}function Ktn({queueStatus:e}){if(!e)return null;const t=e.status==="waiting";return b.jsx("div",{className:"wandox-queue-overlay",children:b.jsx("div",{className:"wandox-queue-modal",children:t?b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"wandox-queue-icon wandox-queue-icon--waiting",children:b.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("circle",{cx:"32",cy:"32",r:"28",stroke:"#E5E7EB",strokeWidth:"4"}),b.jsx("path",{d:"M32 16V32L44 38",stroke:"#8B5CF6",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})}),b.jsx("div",{className:"wandox-queue-title",children:"当前使用人数较多,正在排队中..."}),b.jsxs("div",{className:"wandox-queue-stats",children:[b.jsxs("div",{className:"wandox-queue-stat",children:[b.jsx("div",{className:"wandox-queue-stat-value",children:e.position}),b.jsx("div",{className:"wandox-queue-stat-label",children:"前面还有"})]}),b.jsxs("div",{className:"wandox-queue-stat",children:[b.jsxs("div",{className:"wandox-queue-stat-value",children:["~",e.estimated_wait,"s"]}),b.jsx("div",{className:"wandox-queue-stat-label",children:"预计等待"})]})]}),b.jsxs("div",{className:"wandox-queue-tip",children:[b.jsx("span",{className:"wandox-queue-tip-icon",children:"💡"}),b.jsx("span",{children:"小贴士:等待期间可先查看其他功能模块"})]})]}):b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"wandox-queue-icon wandox-queue-icon--ready",children:b.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[b.jsx("rect",{x:"4",y:"4",width:"56",height:"56",rx:"8",fill:"#10B981"}),b.jsx("path",{d:"M18 32L28 42L46 22",stroke:"white",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),b.jsx("div",{className:"wandox-queue-title wandox-queue-title--ready",children:"轮到您了!"}),b.jsx("div",{className:"wandox-queue-subtitle",children:"正在处理您的请求..."})]})})})}function Ytn({open:e,actionName:t,defaultParams:n={},onCancel:r,onExecute:i}){const[a,o]=m.useState({});m.useEffect(()=>{if(e){const d={};for(const f of Object.keys(n)){const p=n[f];(typeof p=="string"||typeof p=="number")&&(d[f]=String(p))}o(d)}},[e,n]);const s=(d,f)=>{o(p=>({...p,[d]:f}))},l=d=>{d.preventDefault();const f={...n};for(const p of Object.keys(a))f[p]=a[p];i(f)},c=d=>{d.target===d.currentTarget&&r()},u=(d,f)=>typeof f=="object"&&f!==null?null:b.jsxs("div",{className:"wandox-form-item",children:[b.jsx("span",{className:"wandox-form-label",children:d}),b.jsx("input",{type:"text",className:"wandox-form-input",placeholder:`请输入 ${d}`,value:a[d]||"",onChange:p=>s(d,p.target.value)})]},d);return e?b.jsx("div",{className:"wandox-modal-overlay",onClick:c,children:b.jsxs("div",{className:"wandox-modal",style:{width:600},children:[b.jsxs("div",{className:"wandox-modal-header",children:[b.jsxs("h3",{className:"wandox-modal-title",children:["执行 Action: ",t]}),b.jsx("button",{type:"button",className:"wandox-modal-close",onClick:r,"aria-label":"关闭",children:b.jsx("svg",{width:"24",height:"24",viewBox:"0 0 16 16",fill:"currentColor",children:b.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"})})})]}),b.jsxs("div",{className:"wandox-modal-body",children:[b.jsx("div",{className:"wandox-modal-description",children:"以下是默认参数,您可以修改后执行,或直接使用默认值执行"}),b.jsxs("form",{onSubmit:l,children:[Object.keys(n).map(d=>u(d,n[d])),Object.keys(n).length===0&&b.jsx("div",{className:"wandox-empty-params",children:"该 Action 无需参数"})]})]}),b.jsxs("div",{className:"wandox-modal-footer",children:[b.jsx("button",{type:"button",className:"wandox-button wandox-button-default",onClick:r,children:"取消"}),b.jsx("button",{type:"button",className:"wandox-button wandox-button-primary",onClick:l,children:"执行"})]})]})}):null}const Vye=["要努力呀,为了想要的生活,为了人间的烟火气,为了今天的风和月。","欣赏不来别人视若珍宝的,就该保持沉默。","日子总是有意思的,了无生趣的是打不起精神的你。","我们终其一生,就是要摆脱他人的期待,找到真正的自己。","别在最好的年纪选择了安逸,那是对自己最大的辜负。","你现在的气质里,藏着你走过的路、读过的书和爱过的人。","成长就是,你终于明白有些路只能一个人走。","不是每一次努力都有收获,但每一次收获都需要努力。","生活从不眷顾因循守旧、满足现状的人,而将更多机遇留给勇于探索的人。","所有的困难都是暂时的,熬过去就是晴天。","你若盛开,清风自来。","别人笑我太疯癫,我笑他人看不穿。","走慢一点,是为了走得更远。","不必羡慕别人,你的故事才刚刚开始。","心若向阳,何惧忧伤。","人生没有白走的路,每一步都算数。","你不是在浪费时间,你是在积蓄力量。","别让昨天的遗憾,占满今天的时间。","深夜的努力,终将照亮黎明。","只要路是对的,就不怕遥远。","生活不会辜负每一个认真的人。","做一个有温度的人,遇见有光的事。","你所经历的每一次失败,都是未来成功的伏笔。","不要因为走得太远,而忘记为什么出发。","把每一天当作礼物,而不是任务。","越努力,越幸运。","你值得拥有你所渴望的一切。","别把时间花在你不喜欢的事情上,除非它能带你去你喜欢的地方。","有些事现在不做,一辈子都不会做了。","你的潜力,远比你想象的要大。","不要等到准备好了才开始,开始了才会准备好。","慢慢来,比较快。","善待自己,你已经很努力了。","每一个你讨厌的早晨,都是别人求之不得的机会。","世界上只有一种真正的英雄主义,那就是认清生活的真相后仍然热爱它。","人生不是等待风暴过去,而是学会在雨中起舞。","别总想着逃离,先想想能不能改变。","你无法控制风向,但可以调整帆的方向。","没有人能替你走你该走的路。","不要因为没有掌声而停止歌唱。","把抱怨环境的心情,用来改善环境吧。","你今天的懒惰,是明天后悔的源头。","没有人永远年轻,但永远有人正在年轻。","读书破万卷,不如行路十里。","人生最大的遗憾,是轻易放弃了本不该放弃的。","你不是失败了,你只是还没成功。","今天的苦,是明天的底气。","别把别人的看法,活成自己的枷锁。","有一种勇敢,叫做即使害怕也要继续走。","生活是场修行,凡事皆有意义。","不要和自己过不去,人生很短,开心最重要。","你现在偷的懒,都是以后还的债。","最好的时机,就是现在。","你不必完美,但你必须真实。","与其等待一个完美的开始,不如从不完美中开始。","成功不是终点,失败也不是终结,重要的是继续的勇气。","每一个坚持的背后,都有一个不为人知的故事。","改变不了环境,就改变自己。","别用你的忙来掩盖你的懒,也别用你的懒来消耗你的忙。","人生就像骑自行车,要保持平衡就必须不断前行。","昨天已经过去,明天还未到来,今天才是你拥有的全部。","宁可辛苦一阵子,不要痛苦一辈子。","不要让今日的懒惰,成为明日的遗憾。","你的态度,决定了你人生的高度。","路是走出来的,不是想出来的。","做你自己,别人的角色已经有人在演了。","年轻时以为不读书不足惜,后来方知书中有乾坤。","你若想要,便去追;你若已得,便珍惜。","最怕你一生碌碌无为,还安慰自己平凡可贵。","人生没有捷径,弯路也是路。","种一棵树最好的时间是十年前,其次是现在。","每天进步一点点,人生就会不一样。","不要只是看,要有所感悟;不要只是听,要有所行动。","心态好了,一切都好了。","你的未来,取决于你现在的决定。","好好爱自己,才有能力去爱别人。","人生路上,勿忘初心。","有梦想就去追,别给自己的平庸找借口。","世界是你的,但首先你要努力。","坚持不一定成功,但放弃一定失败。","你比你想象的更坚强,比你感觉的更勇敢。","把每一次失败都当成学费,你就赚了。","选择了远方,便只顾风雨兼程。","人生的意义不在于拿一手好牌,而在于打好一手烂牌。","不要在还可以冲刺的年纪,选择散步。","钱不是万能的,但没有钱是万万不能的。努力赚钱,才是对自己最大的尊重。","所谓天才,不过是比别人多了一点坚持。","你改变不了昨天,但你可以决定明天。","做最好的自己,才能遇见最好的别人。","不要因为懒惰而失去了本来可以拥有的东西。","人生没有返回键,但有暂停和前进。","别等别人为你喝彩,先为自己鼓掌。","与其焦虑,不如行动。","每一个优秀的人,都曾经历过一段无人问津的岁月。","你的每一步努力,都在为未来的自己铺路。","不想当将军的士兵不是好士兵,但当不了将军的士兵也可以是好士兵。","生活的艺术,就是把每一个平凡的日子过得不平凡。","人生就是一场旅行,在乎的不是目的地,而是沿途的风景。","不要因为别人的否定,而放弃对自己的肯定。","勇敢不是不害怕,而是即使害怕也还是去做。","命运给了你一手烂牌,你要做的是把它打好。","真正的强大,是内心的平静。","你所不能击垮的,终将使你更强大。","成功的人找方法,失败的人找借口。","不要总是想着明天,今天就是你最年轻的一天。","人生最重要的不是你站在哪里,而是你朝哪个方向走。","每个人都是自己人生的主角,不要沦为配角。","你现在付出的努力,都是在为未来的幸福买单。","心宽了,路才宽。","你所拥有的,比你想要的更多。","不要用战术上的勤奋,掩盖战略上的懒惰。","很多人看起来很忙,实际上只是在低水平上勤奋。","格局大了,烦恼就少了。","你的圈子,决定了你的见识;你的见识,决定了你的未来。","别总是看别人的生活,好好经营自己的就够了。","脚踏实地,仰望星空,这才是人生的正确打开方式。","吃一堑,长一智;受一挫,强一分。","每一次跌倒,都是一次重新出发的机会。","低谷的时候,沉得住气;高峰的时候,守得住心。","你一定要过得很好,这样才不辜负自己受过的苦。","少说多做,是成功的捷径。","人生苦短,别把时间浪费在不值得的人和事上。","越是艰难处,越是修心时。","机会都是留给有准备的人的。","爱拼才会赢,努力才会赢。","人生就像一杯茶,不会苦一辈子,但总会苦一阵子。","不要轻言放弃,你不知道下一秒会发生什么奇迹。","真正的成熟,是能与不完美的自己握手言和。","你所走过的弯路,都是你成长的印记。","别人可以成功,你也可以。","只有不断超越自己,才能不断创造可能。","努力不一定成功,不努力一定不成功。","当你觉得累的时候,说明你在走上坡路。","不经历风雨,怎能见彩虹。","比起抱怨,不如改变。","年轻没有失败,试错才是成长。","你的样子,将决定你世界的样子。","愿你出走半生,归来仍是少年。","有时候你以为的终点,不过是下一段旅程的起点。","今天努力工作,明天努力生活。","不要总是活在别人的评价里,你自己最清楚自己是谁。","无论多难,都要坚持做你认为对的事。","你不需要变成别人,你只需要成为更好的自己。","凡事提前准备,才能游刃有余。","没有什么是理所当然的,感恩才能幸福。","不要把安全感建立在别人身上,那是一种危险的依赖。","清醒的认识自己,是成功的第一步。","沉默是金,但行动是钻石。","用行动证明,而不是用嘴巴解释。","最终你会明白,一切都是值得的。","把目光放长远,眼前的得失不算什么。","不要让自己的懒惰成为别人勤奋的舞台。","你的每一次选择,都在塑造未来的你。","有时候沉默不是因为没话说,而是因为懂得珍惜。","你今天的努力,是明天底气的来源。","先成为你想成为的人,其他的顺其自然。","把握现在,才能拥有未来。","越简单越快乐,越复杂越烦恼。","人生没有真正的绝境,除非你自己放弃。","你比你想象的更有力量。","把每一件平凡的事做好,就是不平凡。","那些没能打败你的,终将使你更强大。","做事情要有始有终,这是对自己最基本的尊重。","不在沉默中爆发,就在沉默中消亡。","不要害怕慢,就怕站。","只要还在走,就没有到不了的地方。","自律的人,才有资格谈自由。","与其等风来,不如追风去。","你有多自律,就有多自由。","凡是过往,皆为序章。","不要在该奋斗的年纪选择了安逸。","人生难得几回搏,此时不搏何时搏。","成长的代价是失去一些幼稚,但获得了更多可能。","有梦想的人,睡觉都是在充电。","不要辜负每一个认真的早晨。","生命的意义,在于不断地自我超越。","你有权利选择,但选择了就要承担。","最大的风险,是不冒任何风险。","生活会奖励那些敢于尝试的人。","不要拿别人的错误惩罚自己。","学会放下,才能腾出手来拥抱新的可能。","所有的天才都曾是努力的凡人。","比别人优秀不是目的,成为更好的自己才是。","你不需要被所有人喜欢,但你必须喜欢自己。","保持好奇心,世界就不会无聊。","每一个平静的背后,都有一颗强大的内心。","把抱怨的时间用来思考,把悲伤的时间用来行动。","只要心里有光,哪里都是出路。","你的奋斗轨迹,就是你最好的简历。","成功不是偶然的,它是努力、坚持和学习的结果。","不要小看自己,宇宙都是从一个点开始的。","真正的自由,是不依赖任何人的底气。","你的努力,终有一天会让你站在阳光下。","生活不在别处,就在此时此刻。","每一段经历,都是人生最好的礼物。"];function Xtn(){return b.jsxs("div",{className:"wandox-hub-skeleton-card",children:[b.jsxs("div",{className:"wandox-hub-skeleton-row",children:[b.jsx(Ri.Avatar,{active:!0,size:28,shape:"circle"}),b.jsx(Ri.Input,{active:!0,style:{width:120,height:18}})]}),b.jsxs("div",{style:{display:"flex",gap:8},children:[b.jsx(Ri.Input,{active:!0,block:!0,style:{height:40,borderRadius:10}}),b.jsx(Ri.Button,{active:!0,style:{width:80,height:40,borderRadius:10}})]})]})}function Ztn(){return b.jsx("div",{className:"wandox-hub-skeleton-insights",children:[1,2,3].map(e=>b.jsx("div",{className:"wandox-hub-skeleton-insight-card",children:b.jsxs("div",{className:"wandox-hub-skeleton-insight-inner",children:[b.jsx(Ri.Input,{active:!0,style:{width:52,height:22,borderRadius:100}}),b.jsxs("div",{style:{flex:1},children:[b.jsx(Ri.Input,{active:!0,block:!0,style:{height:16,marginBottom:6}}),b.jsx(Ri.Input,{active:!0,style:{width:"70%",height:12}})]})]})},e))})}function Qtn(e){return!!e&&/^https?:\/\//.test(e)}function iF(e){if(!e)return"✦";if(Qtn(e))return b.jsx("img",{src:e,alt:""});const t=i7t.get(e);return t?t.component:e}function Jtn(e,t){const n=`${e||""} ${t||""}`.toLowerCase();return n.includes("red")||n.includes("critical")?"wandox-insight-severity--red":n.includes("orange")||n.includes("high")?"wandox-insight-severity--orange":n.includes("yellow")||n.includes("medium")?"wandox-insight-severity--yellow":"wandox-insight-severity--gray"}function enn(e){const t=e.match(new RegExp("^\\p{Extended_Pictographic}","u"));return(t==null?void 0:t[0])||"📌"}function Hye(e){return e.replace(new RegExp("^\\p{Extended_Pictographic}\\s*","u"),"")}function Wye(e){var t;return e.bind_type==="playbook"&&e.bind_playbook_id&&((t=e.playbook_args)!=null&&t.length)?"执行":e.bind_type==="agent"?"找智能体聊聊":e.bind_type==="chat"?"分析一下":"查看详情"}function tnn(e,t){const n=e.asin||e.ASIN||e.sku||e.seller_sku,r=e.site||e.marketplace||e.country;if(n||r)return[n,r&&`(${r})`].filter(Boolean).join(" ");const i=Object.values(e).find(a=>a!=null&&String(a).trim());return i?String(i):`参数 ${t+1}`}function nnn(e,t){var r;const n=(r=e.query_template)==null?void 0:r.trim();return!n||!t?e.title:n.replace(/\{\{?\s*([\w.-]+)\s*\}?\}/g,(i,a)=>{const o=t[a];return o==null?i:String(o)})}function rnn(e){return!e||e.status==="disabled"||e.status==="error"||!e.scenes?[]:Object.entries(e.scenes).map(([t,n])=>({name:t,total_affected:n.total_affected,suggestions_count:n.suggestions_count,cards:Array.isArray(n.cards)?n.cards:[]})).filter(t=>t.cards.length>0)}function inn({agentLoading:e,mainAgentForHub:t,mainAgentQuestions:n,agents:r,hubChatOpen:i,setHubChatOpen:a,hubChatInput:o,setHubChatInput:s,hubScrollIdx:l,hubScrollFading:c,onHubChatSend:u,onHubInputFocus:d,onHubInputBlur:f,messages:p,executing:h,hubInlineChatInput:g,setHubInlineChatInput:v,onHubInlineSend:y,onEnterProfessional:x,playbooks:w,executePlaybook:S,onRequestPlaybookParams:_,onAbort:C,onRespondToProposal:$,ssoToken:E,ssoDomain:k,ssoCompany:T}){var ge,be,Ce,Ae,je;const I=e&&!t,P=localStorage.getItem("sso_username")||"",N=localStorage.getItem("sso_user_id")||"",A=m.useRef(null),M=m.useRef(null),R=m.useMemo(()=>[],[]),[L,z]=m.useState(""),[j,O]=m.useState([]),[V,B]=m.useState(!1),[D,F]=m.useState("idle"),[H,W]=m.useState(0),[K,U]=m.useState(null),[q,Q]=m.useState(!1),G=r[0],X=(G==null?void 0:G.agent_code)||(G==null?void 0:G.agent_id)||"",J=(ge=G==null?void 0:G.questions)!=null&&ge.length?G.questions:n,Y=k!=="yunduo"&&J[l%Math.max(J.length,1)]||"今天仓库订单处理的怎么样了?",Z=m.useMemo(()=>Vye[Math.floor(Math.random()*Vye.length)],[]),re=m.useMemo(()=>({Authorization:`Bearer ${E}`,"X-Tenant-ID":T,"X-Domain":k,"Content-Type":"application/json"}),[E,T,k]),ee=m.useCallback(async(ce=!1)=>{if(!(!E||!k)){B(!0);try{const de=await fetch(`${Gi()}/api/v1/insights/${ce?"refresh":"recommendations"}`,{method:ce?"POST":"GET",headers:re});if(!de.ok)throw new Error(`HTTP ${de.status}`);const _e=await de.json(),Me=_e==null?void 0:_e.data;F((Me==null?void 0:Me.status)||"error"),W((Me==null?void 0:Me.total_cards)||0),O(rnn(Me))}catch{F("error"),W(0),O([])}finally{B(!1)}}},[re,k,E]);m.useEffect(()=>{ee()},[ee]),m.useEffect(()=>{!L&&X&&z(X)},[X,L]);const te=j,oe=L||X||((be=R[0])==null?void 0:be.agent_id)||(t==null?void 0:t.agent_id),fe=AOe({token:E,domain:k,tenantId:T,agentId:oe||"",limit:5});m.useEffect(()=>{if(!q||i){fe.clear();return}fe.search(o)},[q,o,i,fe.search,fe.clear]);const he=te.length>0&&te.every(ce=>ce.cards.length===1),ye=R.slice(0,3),Te=R.slice(3),Ee=oe===X?G==null?void 0:G.name:(Ce=R.find(ce=>ce.agent_id===oe))==null?void 0:Ce.name,we=oe===X?G!=null&&G.icon?ag(G.icon):ag("robot"):iF((Ae=R.find(ce=>ce.agent_id===oe))==null?void 0:Ae.icon),le=oe===X?G==null?void 0:G.description:(je=R.find(ce=>ce.agent_id===oe))==null?void 0:je.description,se=(ce,de)=>{if(ce.bind_type==="agent"&&ce.bind_agent_code){x(ce.bind_agent_code);return}if(ce.bind_type==="playbook"&&ce.bind_playbook_id&&de){a(!0),S({message:nnn(ce,de),playbook_id:ce.bind_playbook_id,playbook_params:de});return}u(oe,ce.title)},ne=(ce,de,_e,Me=!1,Re=!1)=>{const Ie=Array.isArray(de.playbook_args)?de.playbook_args:[],De=de.bind_type==="playbook"&&!!de.bind_playbook_id&&Ie.length>0;return b.jsxs("article",{className:`wandox-insight-card${Me?" wandox-insight-card--modal":""}${Re?" wandox-insight-card--featured":""}`,children:[b.jsxs("button",{type:"button",className:"wandox-insight-card-main",onClick:()=>{Me&&U(null),se(de,Ie[0])},children:[b.jsxs("div",{className:"wandox-insight-card-top",children:[b.jsx("span",{className:`wandox-insight-severity ${Jtn(de.severity_color,de.priority)}`,children:de.severity_label||"观察"}),de.affected_count&&b.jsx("span",{children:de.affected_count})]}),b.jsx("h4",{children:de.title}),de.description&&b.jsx("p",{children:de.description}),b.jsxs("div",{className:"wandox-insight-card-foot",children:[b.jsx("span",{children:de.value_hint||"建议进一步确认"}),!De&&b.jsxs("strong",{children:[Wye(de)," →"]})]})]}),De&&b.jsxs("div",{className:"wandox-insight-arg-list",children:[Ie.slice(0,Me?10:3).map((Ue,nt)=>b.jsxs("button",{type:"button",className:"wandox-insight-arg-action",onClick:()=>{Me&&U(null),se(de,Ue)},children:[b.jsx("span",{children:tnn(Ue,nt)}),b.jsx("strong",{children:Wye(de)})]},`${de.title}-${nt}`)),!Me&&Ie.length>3&&b.jsxs("button",{type:"button",className:"wandox-insight-arg-more",onClick:()=>U(te.find(Ue=>Ue.name===ce)||null),children:["还有 ",Ie.length-3," 项可执行"]})]})]},`${ce}-${de.title}-${_e}`)};return b.jsx("div",{className:"wandox-view-scroll",children:b.jsxs("div",{className:"wandox-view-content wandox-hub-v2",children:[b.jsxs("div",{className:"wandox-hub-v2-header",children:[b.jsxs("div",{children:[b.jsxs("h1",{className:"wandox-hub-v2-title",children:["您好,",P||"欢迎回来"]}),b.jsx("p",{className:"wandox-hub-v2-subtitle",children:Z})]}),k!=="yunduo"&&b.jsxs("button",{type:"button",className:"wandox-hub-v2-report",onClick:()=>{const ce=new URLSearchParams;E&&ce.append("authorization",E),k&&ce.append("x-domain",k),T&&ce.append("x-tenant-id",T),N&&ce.append("user_id",N),P&&ce.append("username",P),window.open(`https://ai.wandox.com/trend-report/trend-report-6.html${ce.toString()?`?${ce.toString()}`:""}`,"_blank")},children:[b.jsx("span",{className:"wandox-hub-v2-report-logo",children:"麦"}),b.jsxs("span",{children:[b.jsx("strong",{children:"麦多趋势报告"}),b.jsx("small",{children:"第六期 已更新 →"})]})]})]}),I?b.jsx(Xtn,{}):b.jsxs("div",{ref:A,className:`wandox-hub-main-card${i?" wandox-hub-main-card--open":""}`,children:[b.jsx("div",{className:"wandox-hub-main-card-search",style:{opacity:i?0:1,maxHeight:i?0:520,transition:"opacity 0.2s ease, max-height 0.35s cubic-bezier(0.4,0,0.2,1)"},children:b.jsxs("div",{className:"wandox-hub-v2-input-panel",children:[b.jsxs("div",{className:"wandox-hub-v2-input-head",children:[b.jsxs("div",{className:"wandox-hub-v2-agent-title",children:[b.jsx("span",{className:"wandox-hub-v2-agent-mark",children:we}),b.jsxs("div",{children:[b.jsx("strong",{children:Ee||(t==null?void 0:t.name)||"通用问答"}),b.jsx("span",{children:le||"问什么都行,系统会自动分流到对应的专业能力"})]})]}),b.jsxs("div",{className:"wandox-hub-v2-chip-row",style:{display:"none"},children:[X&&b.jsxs("button",{type:"button",className:`wandox-hub-v2-chip${oe===X?" wandox-hub-v2-chip--active":""}`,onClick:()=>z(X),title:(G==null?void 0:G.description)||(G==null?void 0:G.name)||"全部",children:[b.jsx("span",{className:"wandox-hub-v2-chip-icon",children:G!=null&&G.icon?ag(G.icon):"✦"}),"全部"]}),ye.map(ce=>b.jsxs("button",{type:"button",className:`wandox-hub-v2-chip${ce.agent_id===oe?" wandox-hub-v2-chip--active":""}`,onClick:()=>z(ce.agent_id),title:ce.description||ce.name,children:[b.jsx("span",{className:"wandox-hub-v2-chip-icon",children:iF(ce.icon)}),ce.name]},ce.agent_id)),Te.length>0&&b.jsx(AE,{menu:{items:Te.map(ce=>({key:ce.agent_id,label:b.jsxs("span",{className:"wandox-hub-v2-more-item",children:[b.jsx("span",{className:"wandox-hub-v2-chip-icon",children:iF(ce.icon)}),b.jsx("span",{children:ce.name})]})})),onClick:({key:ce})=>z(String(ce))},placement:"bottomRight",children:b.jsxs("button",{type:"button",className:"wandox-hub-v2-chip wandox-hub-v2-chip--more",children:["更多 ",b.jsx(cO,{})]})})]})]}),b.jsxs("div",{className:"wandox-hub-v2-input-wrap",children:[b.jsx(Kt.TextArea,{value:o,onChange:ce=>s(ce.target.value),onPressEnter:ce=>{ce.shiftKey||(ce.preventDefault(),u(oe))},onFocus:()=>{Q(!0),d==null||d()},onBlur:()=>{window.setTimeout(()=>Q(!1),120),f==null||f()},placeholder:"请随便问,看看 AI 搭子怎么帮你避坑",autoSize:{minRows:3,maxRows:7},variant:"borderless",className:"wandox-hub-v2-textarea"}),b.jsx(MOe,{open:q,rewrittenQuestion:fe.rewrittenQuestion,questions:fe.questions,loading:fe.loading,placement:"bottom",onSelectRewrite:ce=>{s(ce),fe.clear()},onSelectQuestion:ce=>{s(""),fe.clear(),u(oe,ce.title)}})]}),b.jsxs("div",{className:"wandox-hub-v2-input-bottom",children:[b.jsxs("div",{className:"wandox-hub-v2-example",children:[b.jsx("span",{className:"wandox-hub-v2-example-label",children:"示例:"}),b.jsx("button",{type:"button",className:"wandox-hub-v2-example-text",onClick:()=>{s(Y)},style:{opacity:c?0:1,transform:c?"translateY(-4px)":"translateY(0)"},children:Y})]}),b.jsx(Et,{type:"primary",icon:b.jsx(y2e,{}),className:"wandox-hub-v2-send",onClick:()=>u(oe),children:"发送问题"})]})]})}),b.jsxs("div",{style:{height:i?"100%":0,display:"flex",flexDirection:"column",opacity:i?1:0,overflow:"hidden",transition:"opacity 0.3s ease 0.1s, max-height 0.4s cubic-bezier(0.4,0,0.2,1)",position:"relative",zIndex:i?1:-1},children:[b.jsxs("div",{className:"wandox-hub-chat-header",children:[t&&b.jsxs("div",{className:"wandox-hub-chat-agent-avatar",children:[ag(t.icon),t.is_main&&b.jsx("div",{className:"wandox-hub-chat-agent-badge"})]}),b.jsx("span",{className:"wandox-hub-chat-agent-name",children:t==null?void 0:t.name}),b.jsx("span",{className:"wandox-hub-chat-status",children:"对话中"}),b.jsx("button",{type:"button",className:"wandox-hub-chat-close",onClick:()=>{C(),a(!1)},children:"×"})]}),b.jsxs("div",{className:"wandox-chat-section__body wandox-chat-section__body--hub",children:[b.jsx(xOe,{messages:p,executing:h,ssoToken:E,ssoDomain:k,ssoCompany:T,onExecutePlaybook:ce=>S(ce),onFillPlaybookParams:ce=>_({playbook_id:ce.playbookId,name:ce.playbookName,input_fields:ce.inputFields,initial_params:ce.initialParams,playbook_type:ce.playbookType}),onRespondToProposal:$,containerRef:M,className:"wandox-hub-messages"}),b.jsx(COe,{messages:p,scrollContainerRef:M})]}),b.jsx("div",{className:"wandox-hub-chat-input-row",children:b.jsx(UQ,{executing:h,onSend:(ce,de,_e)=>y(ce,_e),playbooks:w,value:g,onValueChange:v,placeholder:"继续提问…",ssoToken:E,ssoDomain:k,ssoCompany:T,onRequestPlaybookParams:_})}),b.jsx("div",{className:"wandox-hub-chat-footer",children:b.jsx("button",{type:"button",className:"wandox-hub-chat-enter-link",onClick:()=>x(),children:"进入完整对话视图 →"})})]})]}),(V||D==="error"||D==="success"&&H>=0)&&D!=="disabled"&&b.jsxs("div",{className:"wandox-hub-section wandox-hub-v2-insights",children:[b.jsxs("div",{className:"wandox-hub-v2-section-heading",children:[b.jsxs("div",{children:[b.jsxs("div",{className:"wandox-hub-v2-section-kicker",children:[b.jsx("span",{}),b.jsx("strong",{children:"基于你的数据,建议先看"})]}),b.jsx("p",{children:"系统每天扫描你的店铺数据,自动识别出值得处理的场景"})]}),b.jsx(Et,{type:"text",size:"small",icon:b.jsx(yy,{}),className:"wandox-hub-v2-refresh",onClick:()=>ee(!0),children:"换一批"})]}),V?b.jsx(Ztn,{}):D==="error"?b.jsxs("div",{className:"wandox-insight-empty",children:[b.jsx("strong",{children:"数据获取失败,请稍后重试"}),b.jsx(Et,{type:"link",size:"small",onClick:()=>ee(),children:"重试"})]}):te.length===0?b.jsxs("div",{className:"wandox-insight-empty",children:[b.jsx("strong",{children:"暂无场景推荐,数据正常"}),b.jsx("span",{children:"当前没有扫描到需要优先处理的运营场景"})]}):b.jsx("div",{className:`wandox-insight-scene-list${he?" wandox-insight-scene-list--single-cards":""}${te.length===1?" wandox-insight-scene-list--one-scene":""}`,children:te.map(ce=>b.jsxs("section",{className:"wandox-insight-scene",children:[b.jsx("div",{className:"wandox-insight-scene-head",children:b.jsxs("div",{children:[b.jsx("strong",{children:Hye(ce.name)}),b.jsxs("span",{children:["扫描到"," ",ce.suggestions_count??ce.cards.length," ","条建议"]})]})}),b.jsx("div",{className:`wandox-insight-card-row${ce.cards.length===1?" wandox-insight-card-row--single":""}`,children:ce.cards.slice(0,4).map((de,_e)=>ne(ce.name,de,_e,!1,ce.cards.length===1))}),ce.cards.length>4&&b.jsxs("button",{type:"button",className:"wandox-insight-view-all",onClick:()=>U(ce),children:["查看全部 ",ce.cards.length," 条建议 →"]})]},ce.name))})]}),b.jsxs("div",{className:"wandox-hub-section",children:[b.jsxs("div",{className:"wandox-hub-v2-section-heading",children:[b.jsxs("div",{children:[b.jsxs("div",{className:"wandox-hub-v2-section-kicker",children:[b.jsx("span",{}),b.jsx("strong",{children:"需要执行更专业的任务?"})]}),b.jsx("p",{children:"直接进入对应专家,按业务流程一步步处理"})]}),b.jsx(Et,{type:"link",size:"small",className:"wandox-hub-v2-refresh",onClick:()=>x(),children:"全部 →"})]}),I?b.jsx("div",{className:"wandox-agent-grid",children:[1,2,3].map(ce=>b.jsxs("div",{className:"wandox-agent-entry-card",style:{pointerEvents:"none"},children:[b.jsx(Ri.Avatar,{active:!0,size:36,shape:"square",style:{borderRadius:8,flexShrink:0}}),b.jsxs("div",{style:{flex:1},children:[b.jsx(Ri.Input,{active:!0,block:!0,style:{height:14,marginBottom:6}}),b.jsx(Ri.Input,{active:!0,style:{width:"80%",height:11}})]})]},ce))}):b.jsx("div",{className:"wandox-agent-grid",children:r.filter(ce=>!ce.is_main).slice(0,4).map(ce=>{const de=XQ(ce);return b.jsxs("button",{type:"button",className:`wandox-agent-entry-card${de?" wandox-agent-entry-card--with-badge":""}`,onClick:()=>x(ce.agent_id||void 0),children:[b.jsx("div",{className:"wandox-agent-entry-icon",children:ag(ce.icon)}),b.jsxs("div",{className:"wandox-agent-entry-info",children:[b.jsx("div",{className:"wandox-agent-entry-name",children:ce.name}),b.jsx("div",{className:"wandox-agent-entry-desc",children:ce.description})]}),b.jsx(Ih,{className:"wandox-agent-entry-arrow"}),de&&b.jsx("span",{className:`wandox-agent-entry-badge wandox-agent-entry-badge--${de.kind}`,children:de.badgeText})]},ce.agent_id)})})]}),b.jsx(rr,{open:!!K,onCancel:()=>U(null),footer:null,width:920,centered:!0,className:"wandox-insight-modal",title:K?b.jsxs("div",{className:"wandox-insight-modal-title",children:[b.jsx("span",{children:enn(K.name)}),b.jsxs("div",{children:[b.jsx("strong",{children:Hye(K.name)}),b.jsxs("small",{children:[K.cards.length," 条数据建议"]})]})]}):null,styles:{container:{padding:0}},children:K&&b.jsx("div",{className:"wandox-insight-modal-grid",children:K.cards.map((ce,de)=>ne(K.name,ce,de,!0))})})]})})}function ann(e={}){const{presetAgents:t,initialAgentId:n}=e,{setAllQuestions:r}=WQ(),[i,a]=m.useState("default"),[o,s]=m.useState([]),[l,c]=m.useState([]),[u,d]=m.useState([]),[f,p]=m.useState(!1),[h,g]=m.useState([]),[v,y]=m.useState([]),[x,w]=m.useState(!1),[S,_]=m.useState(!1),C=m.useRef(i),$=m.useRef(0),E=m.useRef(0);C.current=i;const k=m.useCallback(async()=>{var P,N;if(t&&t.length>0){s(t),a(M=>{var R,L;if(M&&M!=="default"&&t.some(z=>z.agent_code===M||z.agent_id===M))return M;if(n){const z=UR(t,n);if(z)return Jp(z);Ze.error("指定的智能体不存在,已切换到默认智能体")}return((R=t[0])==null?void 0:R.agent_code)||((L=t[0])==null?void 0:L.agent_id)||""});const A=[];for(const M of t)if(M.questions&&Array.isArray(M.questions)&&A.push(...M.questions),M.children)for(const R of M.children)R.questions&&Array.isArray(R.questions)&&A.push(...R.questions);r(A);return}w(!0);try{const{data:A}=await XO({page:1,page_size:99});if(s(A.filter(R=>!R.hidden)||[]),n){const R=UR(A||[],n);R?a(Jp(R)):(Ze.error("指定的智能体不存在,已切换到默认智能体"),a(((P=A[0])==null?void 0:P.agent_code)||""))}else a(((N=A[0])==null?void 0:N.agent_code)||"");const M=[];for(const R of A||[])if(R.questions&&Array.isArray(R.questions)&&M.push(...R.questions),R.children)for(const L of R.children)L.questions&&Array.isArray(L.questions)&&M.push(...L.questions);r(M)}catch{}w(!1)},[t,r,n]),T=m.useCallback(async()=>{if(!i||i==="default")return;const P=i,N=++$.current;w(!0),_(!1),d([]);try{const{data:A}=await PY({agent_id:P});if(N!==$.current||C.current!==P)return;c(KOe(A));const M=A.playbook_groups||[];g(M);const R=A.children||[];y(R)}catch{if(N!==$.current||C.current!==P)return;d([])}finally{N===$.current&&C.current===P&&(w(!1),_(!0))}},[i]),I=m.useCallback(async()=>{if(!i||i==="default"){d([]);return}const P=i,N=++E.current;p(!0);try{const{data:A}=await Hmt({agent_id:P});if(N!==E.current||C.current!==P)return;const M=Array.isArray(A)?A:Array.isArray(A==null?void 0:A.user_playbooks)?A.user_playbooks:[];d(M)}catch{if(N!==E.current||C.current!==P)return;d([]),Ze.error("我的场景加载失败")}finally{N===E.current&&C.current===P&&p(!1)}},[i]);return{activeAgent:i,setActiveAgent:a,agents:o,playbooks:l,userPlaybooks:u,userPlaybooksLoading:f,playbookGroups:h,childAgents:v,loading:x,setLoading:w,playbooksLoaded:S,loadAgents:k,loadPlaybooks:T,loadUserPlaybooks:I}}function Uye(e){var s;const t=e.role==="assistant"?ZQ(e.process):void 0,n={...e,process:t?{...t,origin:"history"}:void 0},r=n.execution_id??((s=n.meta_content)==null?void 0:s.execution_id),i=n.meta_content;if(!i||i.response_type!=="proposal")return r===void 0?n:{...n,execution_id:r};const a={proposal_id:i.proposal_id||"",scene:i.scene||"playbook_select",message:"",options:(i.options||[]).map(l=>({id:l.id,playbook_code:l.playbook_code,title:l.title,description:l.description||"",selected:l.id===i.selected_option_id,params:l.params||[]})),params:i.params||[],actions:{confirm:{label:"确认执行",style:"primary"},reject:{label:"都不需要",style:"secondary"}}},o=i.proposal_status==="confirmed"?"confirmed":i.proposal_status==="rejected"?"rejected":void 0;return{...n,execution_id:r,proposal:a,proposal_status:o}}function fl(e,t){return e.activeAgent===t.activeAgent&&e.webhookId===t.webhookId&&e.ssoToken===t.ssoToken&&e.ssoDomain===t.ssoDomain&&e.ssoCompany===t.ssoCompany}function Gye(e){const t=`${e.ssoDomain}\0${e.ssoCompany}\0${e.ssoToken}`;let n=2166136261;for(let r=0;r<t.length;r+=1)n^=t.charCodeAt(r),n=Math.imul(n,16777619);return(n>>>0).toString(36)}function onn(e){const{activeAgent:t,pageSize:n=bOe,webhookId:r,executePlaybook:i,isExecutingRef:a,ssoToken:o="",ssoDomain:s="",ssoCompany:l=""}=e,[c,u]=m.useState([]),[d,f]=m.useState(0),[p,h]=m.useState(1),[g,v]=m.useState(!1),y=m.useRef(t),x=m.useRef({activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l});m.useEffect(()=>{y.current=t,x.current={activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l},u([]),f(0),h(1),v(!1)},[t,r,o,s,l]);const w=m.useCallback(()=>{const T=new Date;return`${T.getFullYear()}-${String(T.getMonth()+1).padStart(2,"0")}-${String(T.getDate()).padStart(2,"0")}`},[]),S=m.useCallback(T=>{const I=w(),N=`wandox_daily_report_${Gye({ssoToken:o,ssoDomain:s,ssoCompany:l})}_${I}`,A=localStorage.getItem(N);if(!A)return!1;try{return JSON.parse(A).includes(T)}catch{return!1}},[w,o,s,l]),_=m.useCallback(T=>{const I=w(),N=`wandox_daily_report_${Gye({ssoToken:o,ssoDomain:s,ssoCompany:l})}_${I}`,A=localStorage.getItem(N);let M=[];if(A)try{M=JSON.parse(A)}catch{M=[]}M.includes(T)||(M.push(T),localStorage.setItem(N,JSON.stringify(M)))},[w,o,s,l]),C=m.useCallback(async()=>{const T=t,I={activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l};if(fl(x.current,I)&&!(a!=null&&a.current)){u([]),v(!0);try{const{data:P}=await gM({agent_id:t,page:1,page_size:n,webhook_id:r,include_process:!0});if(a!=null&&a.current||y.current!==T||!fl(x.current,I))return;const N=(P==null?void 0:P.items)||[];u([...N].reverse().map(Uye).filter(A=>!fve(A))),h(1),f((P==null?void 0:P.total)||0)}catch{}finally{fl(x.current,I)&&v(!1)}}},[t,n,r,a,o,s,l]),$=m.useCallback(async()=>{if(c.length>=d)return;const T={activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l};if(!fl(x.current,T))return;const I=p+1;v(!0);try{const{data:P}=await gM({agent_id:t,page:I,page_size:n,webhook_id:r,include_process:!0});if(!fl(x.current,T))return;const N=(P==null?void 0:P.items)||[];if(N.length>0){const A=[...N].reverse().map(Uye).filter(M=>!fve(M));u(M=>[...A,...M]),h(I),f((P==null?void 0:P.total)||0)}}catch(P){throw P}finally{fl(x.current,T)&&v(!1)}},[t,n,r,c.length,d,p,o,s,l]),E=m.useCallback(async()=>{var P,N,A;if(!t||t==="default")return!1;const T=t,I={activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l};if(!fl(x.current,I))return!1;try{const M=await Vmt({agent_id:t});if(a!=null&&a.current||y.current!==T||!fl(x.current,I))return!1;if(M!=null&&M.data){const R=M.data;if(R.outputs){let L=null;R.outputs.type==="card"&&((N=(P=R.outputs.content)==null?void 0:P.data)!=null&&N.content)?L=R.outputs.content.data.content:(A=R.outputs.content)!=null&&A.content?L=R.outputs.content.content:R.outputs.content?L=R.outputs.content:L=R.outputs;const z={id:R.playbook_id||"daily-report",role:"assistant",content:"",timestamp:new Date().toISOString(),ui_payload:L};return u(j=>{const O=j.filter(V=>V.id!=="daily-report");return[z,...O]}),!0}R.playbook_id&&R.playbook_name&&(i==null||i({message:R.playbook_name,playbook_id:R.playbook_id}))}return!1}catch{return!1}},[t,r,i,a,o,s,l]),k=m.useCallback(async()=>{const T={activeAgent:t,webhookId:r||"",ssoToken:o,ssoDomain:s,ssoCompany:l};if(fl(x.current,T)&&t){if(v(!0),t==="default"){try{await C()}finally{fl(x.current,T)&&v(!1)}return}try{if(S(t)){await C();return}await E()?fl(x.current,T)&&_(t):await C()}catch{await C()}finally{fl(x.current,T)&&v(!1)}}},[t,r,C,E,S,_,o,s,l]);return{messages:c,setMessages:u,messagesTotal:d,messagesPage:p,loading:g,setLoading:v,loadMessages:C,loadMoreMessages:$,loadDailyReport:E,loadMessagesAndDailyReport:k}}function snn(e){const t=e.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"}),n=e.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return`${t}
|
|
795
|
+
${n}`}function aF(e,t){return e.activeAgent===t.activeAgent&&e.webhookId===t.webhookId&&e.ssoToken===t.ssoToken&&e.ssoDomain===t.ssoDomain&&e.ssoCompany===t.ssoCompany}function lnn(e){const{activeAgent:t,webhookId:n="",ssoToken:r="",ssoDomain:i="",ssoCompany:a=""}=e,[o,s]=m.useState([]),l=m.useRef({activeAgent:t,webhookId:n,ssoToken:r,ssoDomain:i,ssoCompany:a});m.useEffect(()=>{l.current={activeAgent:t,webhookId:n,ssoToken:r,ssoDomain:i,ssoCompany:a},s([])},[t,n,r,i,a]);const c=m.useCallback(async()=>{if(!t)return;const u={activeAgent:t,webhookId:n,ssoToken:r,ssoDomain:i,ssoCompany:a};if(aF(l.current,u))try{const d=await Umt({agent_id:t,limit:10,use_cache:!1});if(!aF(l.current,u))return;if(d!=null&&d.data&&Array.isArray(d.data)){const f=d.data.map(p=>{const h=Array.isArray(p.actions)?p.actions||[]:[],g=p.ui_payload,v=g==null?void 0:g.actions,y=Array.isArray(v)?v:[],w=[...h,...y].map(_=>{const C=_;return{label:C.display_name||C.label||"执行",action_id:C.action_id,playbook_id:C.playbook_id,display_name:C.display_name,display_icon:C.display_icon,params:C.params,params_fields_map:C.params_fields_map,type:C.type,url:C.url,style:C.style,status:C.action_status||C.status||void 0,sort_order:C.sort_order,executed_job_id:C.executed_job_id,supports_batch:C.supports_batch===!0,batch_max_items:C.batch_max_items,batch_id:C.batch_id,outputs:C.outputs}}),S=p.outputs;return{type:p.widget_type||"daily_report",priority:p.priority||"medium",title:p.title||"每日战报",summary:p.summary||"",timestamp:p.created_at?snn(new Date(p.created_at||"")):"",data:p.card_data||{},actions:w,id:p.inbox_id||"",agent_id:p.agent_id||"",read:!!p.is_read,ui_payload:S||g||{}}});if(f.length>0){const p=f.sort((h,g)=>{const v=h.timestamp?new Date(h.timestamp.replace(/\n/g," ")).getTime():0;return(g.timestamp?new Date(g.timestamp.replace(/\n/g," ")).getTime():0)-v});s(p)}else s([])}else s([])}catch(d){if(!aF(l.current,u))return;throw s([]),d}},[t,n,r,i,a]);return{widgets:o,setWidgets:s,loadDailyReports:c}}function cnn(){const[e,t]=m.useState([]),[n,r]=m.useState(!1),[i,a]=m.useState(!1),[o,s]=m.useState(""),[l,c]=m.useState([]),[u,d]=m.useState(!1),[f,p]=m.useState(null),[h,g]=m.useState(!0),v=m.useRef(null),y=m.useCallback(async()=>{if(v.current)return v.current;const T=(async()=>{r(!0);try{const I=await qmt({page:1,page_size:20});return Array.isArray(I==null?void 0:I.data)?(t(I.data),a(!0),!0):(a(!1),!1)}catch{return a(!1),!1}finally{r(!1),v.current=null}})();return v.current=T,T},[]),x=m.useCallback(()=>i?Promise.resolve(!0):y(),[y,i]),w=m.useCallback(T=>{s(T),p({session_id:T,type:"dashboard_intent",intents:[],data:{}}),g(!1),(async(P={})=>{d(!0);try{const N=await Rse(T,{params:P});N.success&&N.data&&(p(N.data),N.data.input_params&&c(N.data.input_params))}catch{}finally{d(!1)}})()},[]),S=m.useCallback(T=>{if(!o)return;(async()=>{d(!0);try{const P=await Rse(o,{params:T});P.success&&P.data&&p(P.data)}catch{}finally{d(!1)}})()},[o]),_=m.useCallback(T=>{o===T&&(s(""),p(null),c([])),y()},[o,y]),C=m.useCallback(()=>{if(!o)return null;const T=e.find(I=>I.playbook_id===o);return(T==null?void 0:T.name)||null},[o,e]),$=m.useCallback((T,I)=>{p(T),g(I!==void 0?I:!0)},[]),E=m.useCallback(()=>{},[]),k=m.useCallback(()=>{s(""),p(null),c([])},[]);return{solidifiedPlaybooks:e,solidifiedPlaybooksLoading:n,solidifiedPlaybooksLoaded:i,activeSolidifiedPlaybook:o,setActiveSolidifiedPlaybook:s,solidifyInputParams:l,solidifyLoading:u,dashboardData:f,setDashboardData:p,dashboardShowSaveButton:h,setDashboardShowSaveButton:g,loadSolidifiedPlaybooks:y,ensureSolidifiedPlaybooksLoaded:x,handleSolidifiedPlaybookClick:w,handleSolidifyParamsSearch:S,handleSolidifiedPlaybookDelete:_,getCurrentSolidifiedPlaybookName:C,handleDashboardPreview:$,handleSolidifyComplete:E,clearDashboard:k}}function unn(){const{allQuestions:e,setCurrentQuestion:t}=WQ();m.useEffect(()=>{if(e.length===0)return;const n=Math.floor(Math.random()*e.length);t(e[n]);const r=setInterval(()=>{const i=Math.floor(Math.random()*e.length);t(e[i])},1e4);return()=>{clearInterval(r)}},[e,t])}const qye={chat:{title:"对话",subtitle:""},plan:{title:"自动化",subtitle:"创建、管理并追踪自动化智能体的执行结果,支持定时触发与对内流转"},professional:{title:"专业智能体",subtitle:"深度分析与专业领域对话"},goals:{title:"目标追踪",subtitle:"跟踪关键业务指标和目标进展"},settings:{title:"系统设置",subtitle:"管理账户、智能体和系统配置"}},dnn=5*60*1e3,fnn=3;function pnn(e={}){const{showAside:t=!0,showLogout:n=!1,onLogout:r,presetAgents:i,webhookId:a,onReady:o,initialAgentId:s,initialPlaybookId:l,initialPlaybookParams:c}=e,u=localStorage.getItem("sso_token")||"",d=localStorage.getItem("sso_domain")||"maiduo",f=localStorage.getItem("sso_company")||"",h=`${Gi()}/api/v1/oss/upload2`,g=m.useCallback(async rt=>{const{data:dt}=await BE({playbook_id:rt});return dt},[]),v=m.useCallback(rt=>Ymt({session_id:rt.session_id||"",name:rt.name,description:rt.description}),[]),y=m.useCallback(rt=>kEe({session_id:rt.session_id||"",user_hint:rt.user_hint||""}),[]),{activeAgent:x,setActiveAgent:w,agents:S,playbooks:_,userPlaybooks:C,userPlaybooksLoading:$,childAgents:E,loading:k,loadAgents:T,loadPlaybooks:I,loadUserPlaybooks:P,playbooksLoaded:N}=ann({presetAgents:i,initialAgentId:s}),[A,M]=m.useState(()=>!!s),[R,L]=m.useState(!1),[z,j]=m.useState(!1),[O,V]=m.useState([]),[B,D]=m.useState(0),F=m.useRef(!1),{executing:H,stopping:W,executingRef:K,queueStatus:U,sendMessage:q,executePlaybook:Q,respondToProposal:G,stopCurrent:X,retrigger:J,abort:Y}=QQ({activeAgent:x,ssoToken:u,ssoDomain:d,ssoCompany:f,onMessagesUpdate:rt=>Z.setMessages(rt),onRecommendationsUpdate:V});m.useEffect(()=>{F.current&&!H&&D(rt=>rt+1),F.current=H},[H]);const Z=onn({activeAgent:x,webhookId:a,executePlaybook:Q,isExecutingRef:K,ssoToken:u,ssoDomain:d,ssoCompany:f}),{widgets:re,setWidgets:ee,loadDailyReports:te}=lnn({activeAgent:x,webhookId:a,ssoToken:u,ssoDomain:d,ssoCompany:f}),oe=cnn();unn();const[fe,he]=m.useState(()=>localStorage.getItem("wandox_sidebar_agent_mode")==="true"),ye=m.useCallback(()=>{he(rt=>{const dt=!rt;return localStorage.setItem("wandox_sidebar_agent_mode",String(dt)),dt})},[]),[Te,Ee]=m.useState(!1),[we,le]=m.useState(!1),[se,ne]=m.useState(!1),[ge,be]=m.useState(!1),[Ce,Ae]=m.useState(null),[je,ce]=m.useState(!1),[de,_e]=m.useState(null),[Me,Re]=m.useState(""),[Ie,De]=m.useState(null),[Ue,nt]=m.useState("chat"),[ct,ht]=m.useState(null),Ve=m.useCallback(()=>{Ee(!0),le(!1)},[]),Ye=m.useCallback(()=>{Ee(!1),le(!1)},[]),[Se,me]=m.useState(""),[pe,xe]=m.useState(0),[Le,$e]=m.useState(!1),[ze,Qe]=m.useState(!1),[it,st]=m.useState(!1),[Ft,Ne]=m.useState(""),ke=m.useRef(null),Ke=m.useRef(!1),[Je,We]=m.useState(null),[Oe,Xe]=m.useState(!1),at=k||Z.loading,mt=m.useCallback(rt=>{Ae(()=>rt)},[]);m.useEffect(()=>{o&&o({showInspectionResults:rt=>{We(rt||null),Xe(!0)}})},[o]),m.useEffect(()=>{M(!!s),L(!1),j(!1)},[s,l,c]);const ot=m.useMemo(()=>(i||[]).map(rt=>rt.agent_id||rt.agent_code||"").join("|"),[i]);m.useEffect(()=>{T()},[ot]),m.useEffect(()=>{if(x)return V([]),I(),()=>{K.current&&Y()}},[x,a,u,d,f]),m.useEffect(()=>{if(Ue!=="professional"){Ke.current=!1;return}if(!x)return;Ke.current||(Z.loadMessagesAndDailyReport(),te()),Ke.current=!1;let rt=0,dt=null;return dt=setInterval(async()=>{try{await te(),rt=0}catch{rt++,rt>=fnn&&dt&&(clearInterval(dt),dt=null)}},dnn),()=>{dt&&clearInterval(dt)}},[Ue,x,a,u,d,f]);const wt=S.find(rt=>rt.is_main)??S[0],Pt=(wt==null?void 0:wt.questions)||[];m.useEffect(()=>{xe(0),$e(!1)},[wt==null?void 0:wt.agent_id]),m.useEffect(()=>{if(Pt.length<=1||ze)return;let rt;const dt=setInterval(()=>{$e(!0),rt=setTimeout(()=>{xe(ut=>(ut+1)%Pt.length),$e(!1)},350)},3500);return()=>{clearInterval(dt),clearTimeout(rt)}},[Pt.length,ze]),m.useEffect(()=>{if(ke.current&&x&&x!=="default"){const rt=ke.current;ke.current=null,q(rt)}},[x,q]),m.useEffect(()=>{if(!s||!A||!x||x==="default"||S.length===0)return;!!UR(S,s)||M(!1)},[s,A,x,S]),m.useEffect(()=>{!s||l||R||!x||x==="default"||!S.find(dt=>_l(dt,x)&&_l(dt,s))||(L(!0),nt("professional"),oe.clearDashboard(),M(!1))},[s,l,R,x,S,oe]),m.useEffect(()=>{var vi;if(!s||!l||z||!x||x==="default"||!N||!S.find(Bi=>_l(Bi,x)&&_l(Bi,s)))return;const dt=_.find(Bi=>qOe(Bi,l));if(!dt){nt("professional"),Ze.error(`指定的剧本(${l})不存在,已切换到智能体界面`),j(!0),M(!1);return}j(!0),nt("professional"),Ke.current=!0,Z.setMessages([]),oe.clearDashboard(),De(null),Re("");const ut=c||{},Pn=Object.keys(ut).length>0,Mr=(dt.input_fields??[]).filter(Bi=>{if(!Bi.required)return!1;const Sa=ut[Bi.name];return Sa==null||Sa===""});if((((vi=dt.input_fields)==null?void 0:vi.length)??0)>0&&(!Pn||Mr.length>0)){De(dt),M(!1);return}Q({message:dt.name,playbook_id:l,playbook_params:ut}),M(!1)},[s,l,z,x,N,S,_,c]);const Yt=m.useCallback(rt=>{K.current&&(Y(),Ze.info("已中止当前剧本,切换智能体")),w(rt),Re(""),De(null),oe.clearDashboard(),Z.setMessages([]),ee([])},[Y,K,w,oe,Z,ee]),Un=(rt,dt)=>{const ut=(dt??Se).trim()||Pt[pe%Pt.length]||"",Pn=rt||(wt==null?void 0:wt.agent_id);!ut||!Pn||(me(""),st(!0),Z.setMessages([]),x===Pn?q(ut):(Ke.current=!0,ke.current=ut,w(Pn)))},ur=(rt,dt)=>{oe.handleDashboardPreview(rt,dt),nt("chat"),w("default")},zn=()=>{oe.handleSolidifyComplete(),nt("chat"),w("default")},Fn=rt=>{nt(rt),(rt==="goals"||rt==="settings"||rt==="plan"||rt==="chat")&&oe.clearDashboard()},Da=()=>{le(!1),be(!0),oe.ensureSolidifiedPlaybooksLoaded()},Nr=rt=>{be(!1),oe.handleSolidifiedPlaybookClick(rt),nt("chat"),w("default"),Re(""),De(null)},Ar=()=>{var rt,dt;if(oe.dashboardData)return b.jsx(eDe,{data:oe.dashboardData,showSaveButton:oe.dashboardShowSaveButton,onSaveSuccess:oe.loadSolidifiedPlaybooks,onSaveDashboard:v,onPreviewDashboard:y,title:oe.getCurrentSolidifiedPlaybookName()||void 0,customParamsForm:oe.solidifyInputParams.length>0?b.jsx(U7t,{inputParams:oe.solidifyInputParams,onSearch:oe.handleSolidifyParamsSearch,loading:oe.solidifyLoading}):void 0,showGlobalFilter:oe.solidifyInputParams.length>0});switch(Ue){case"chat":return b.jsx(FQ.Provider,{value:{onExecutePlaybook:Q,getPlaybookDetail:g,ossUploadUrl:h,ssoToken:u,ssoDomain:d,ssoCompany:f,onFillPlaybookParams:ut=>{const Pn={playbook_id:ut.playbookId,name:ut.playbookName,input_fields:ut.inputFields,initial_params:ut.initialParams,playbook_type:ut.playbookType};De(Pn),nt("professional")}},children:b.jsx(inn,{agentLoading:k,mainAgentForHub:wt,mainAgentQuestions:Pt,agents:S,hubChatOpen:it,setHubChatOpen:st,hubChatInput:Se,setHubChatInput:me,hubScrollIdx:pe,hubScrollFading:Le,onHubChatSend:Un,onHubInputFocus:()=>Qe(!0),onHubInputBlur:()=>Qe(!1),messages:Z.messages,executing:H,hubInlineChatInput:Ft,setHubInlineChatInput:Ne,onHubInlineSend:(ut,Pn)=>{wt!=null&&wt.agent_id&&(x!==wt.agent_id&&w(wt.agent_id),q(ut,void 0,Pn))},onEnterProfessional:ut=>{ut&&w(ut),Re(""),De(null),oe.clearDashboard(),ee([]),nt("professional")},playbooks:_,executePlaybook:Q,onRequestPlaybookParams:De,clearMessages:()=>Z.setMessages([]),onAbort:Y,onRespondToProposal:G,ssoToken:u,ssoDomain:d,ssoCompany:f})});case"goals":return b.jsx(eyt,{});case"settings":return b.jsx(EWt,{});case"plan":return b.jsx(qtn,{embedded:!0,onHeaderChange:ht,onCockpitEnter:Ve,onCockpitExit:Ye});case"professional":return b.jsxs(b.Fragment,{children:[b.jsx(oWt,{title:((rt=S.find(ut=>_l(ut,x)))==null?void 0:rt.name)||"Wandox智能体",agentSwitcher:fe?void 0:b.jsxs("div",{style:{display:"inline-flex",alignItems:"center",height:34,background:"#fff",border:"1px solid #e5e0f0",borderRadius:10,boxSizing:"border-box",overflow:"hidden"},children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"0 0 0 8px"},children:[b.jsx("div",{style:{width:22,height:22,flexShrink:0},children:ag((dt=S.find(ut=>_l(ut,x)))==null?void 0:dt.icon)}),b.jsx(tn,{value:x,onChange:ut=>Yt(ut),options:S.map(ut=>({value:ut.agent_id,label:ut.name})),variant:"borderless",suffixIcon:b.jsx(nw,{style:{color:"#9275ff",verticalAlign:"middle"}}),style:{fontWeight:600,fontSize:14,minWidth:100,color:"#4a3a6a"},popupMatchSelectWidth:!1})]}),b.jsx("button",{type:"button",onClick:ye,title:"切换为侧边栏选择",style:{display:"flex",alignItems:"center",justifyContent:"center",width:34,height:"100%",cursor:"pointer",color:"#b0a0c8",borderLeft:"1px solid #e5e0f0",transition:"all 0.15s",background:"none",border:"none",padding:0},onMouseEnter:ut=>{ut.currentTarget.style.color="#7c3aed",ut.currentTarget.style.background="#f5f0ff"},onMouseLeave:ut=>{ut.currentTarget.style.color="#b0a0c8",ut.currentTarget.style.background="transparent"},children:b.jsx(dse,{style:{fontSize:13}})})]}),count:re.length,widgets:re,activeAgent:x,agents:S,childAgents:E,ssoDomain:d,ssoToken:u,ssoCompany:f,onWidgetsUpdate:ee,onExecuteComplete:()=>{te()},externalRobotName:Je,externalShowPanel:Oe}),b.jsx($Oe,{messages:Z.messages,playbooks:_,messagesTotal:Z.messagesTotal,loadMoreMessages:Z.loadMoreMessages,loading:at,executing:H,ssoToken:u,ssoDomain:d,ssoCompany:f,activeAgent:x,webhookId:a,onExecutePlaybook:Q,onSolidifySuccess:oe.loadSolidifiedPlaybooks,onDashboardPreview:ur,onSolidifyComplete:zn,onFillPlaybookParams:ut=>{const Pn={playbook_id:ut.playbookId,name:ut.playbookName,input_fields:ut.inputFields,initial_params:ut.initialParams,playbook_type:ut.playbookType};De(Pn)},onActionClick:ut=>{ut.action_id?(ne(!0),Ce&&Ce({action_id:ut.action_id,action_params:ut.params})):ut.playbook_id&&Q({message:ut.display_name||"执行",playbook_id:ut.playbook_id,...ut.params?{playbook_params:ut.params}:{}})},onExecuteComplete:()=>{te()},onRespondToProposal:G,onRetrigger:J}),b.jsxs("div",{className:"chat-input-area",children:[b.jsx(DOe,{playbooks:_,playbookLoading:k,onPlaybookClick:Q,onSelectPlaybook:ut=>{De(ut)},recommendations:O,userPlaybooks:C,userPlaybooksLoading:$,onLoadUserPlaybooks:P,agentId:Jp(S.find(ut=>_l(ut,x)))||x,recentRefreshKey:B}),b.jsx(UQ,{executing:H,stopping:W,onStop:X,onSend:q,playbooks:_,recommendations:O,value:Me,onValueChange:Re,onRequestPlaybookParams:De,ssoToken:u,ssoDomain:d,ssoCompany:f})]})]});default:return null}},gi=Ue==="plan"?ct??qye.plan:qye[Ue],To=(Ue==="plan"||!oe.dashboardData)&&Ue!=="professional"&&Ue!=="chat";return b.jsx(Bvt,{children:b.jsxs(s7t,{children:[b.jsx("div",{className:`wandox-aside-overlay ${we?"wandox-aside-overlay--visible":""}`,onClick:()=>le(!1),onKeyDown:rt=>rt.key==="Escape"&&le(!1),role:"button",tabIndex:0,"aria-label":"关闭侧边栏"}),t&&b.jsx(a7t,{active:x,agents:S,onChange:rt=>{le(!1),Yt(rt)},collapsed:Te,onToggle:()=>Ee(rt=>!rt),className:we?"wandox-aside--mobile-open":"",activeView:Ue,onViewChange:Fn,onToolboxOpen:Da,showLogout:n,onLogout:r,sidebarAgentMode:fe,onToggleSidebarMode:ye,onAgentSelect:rt=>Yt(rt)}),t&&Te&&b.jsx("button",{type:"button",className:"wandox-aside-floating-open",onClick:()=>Ee(!1),"aria-label":"展开侧边栏",title:"展开侧边栏",children:b.jsx(dse,{})}),b.jsxs("div",{className:"wandox-workspace",children:[b.jsxs("div",{className:"wandox-mobile-header",children:[b.jsx("button",{type:"button",className:"wandox-mobile-menu-btn",onClick:()=>{Ee(!1),le(!0)},children:"☰"}),b.jsx("h1",{className:"wandox-mobile-title",children:"Wandox"}),n&&r?b.jsx("button",{type:"button",onClick:r,style:{width:40,height:40,background:"transparent",border:"none",cursor:"pointer"},children:"退出"}):b.jsx("div",{style:{width:40}})]}),To&&b.jsxs("div",{className:"wandox-workspace-topbar",children:[b.jsxs("div",{className:"wandox-workspace-topbar-info",children:[b.jsx("h1",{className:"wandox-workspace-topbar-title",children:(gi==null?void 0:gi.title)??"您好,欢迎使用 AI 智能体"}),b.jsx("p",{className:"wandox-workspace-topbar-subtitle",children:(gi==null?void 0:gi.subtitle)??""})]}),b.jsx("div",{className:"wandox-workspace-topbar-actions",children:Ue==="plan"?ct==null?void 0:ct.actions:null})]}),b.jsx("div",{className:`wandox-workspace-container${Ue==="plan"?" wandox-workspace-container--automation":""}`,children:Ar()})]}),b.jsx(Z7t,{open:ge,loading:oe.solidifiedPlaybooksLoading,playbooks:oe.solidifiedPlaybooks,activePlaybookId:oe.activeSolidifiedPlaybook,onClose:()=>be(!1),onPlaybookClick:Nr,onPlaybookDelete:oe.handleSolidifiedPlaybookDelete}),b.jsx(gOe,{open:se,ssoToken:u,ssoDomain:d,ssoCompany:f,onClose:()=>ne(!1),onExecuteAction:mt,onExecuteComplete:()=>{setTimeout(()=>{te()},1e3)}}),b.jsx(Ytn,{open:je,actionId:(de==null?void 0:de.action_id)||"",actionName:(de==null?void 0:de.display_name)||"",defaultParams:de==null?void 0:de.params,onCancel:()=>{ce(!1),_e(null)},onExecute:rt=>{ce(!1),ne(!0),Ce&&de&&Ce({action_id:de.action_id,action_params:rt}),_e(null)}}),b.jsx(H7t,{open:!!Ie,playbook:Ie,onClose:()=>De(null),onSubmit:(rt,dt)=>{De(null),Q({message:rt.name,playbook_id:rt.playbook_id,playbook_params:dt})}}),A&&b.jsx(o7t,{}),b.jsx(Ktn,{queueStatus:U})]})})}const E4e=e=>{if(e){if("enableCustomerService"in e)return e.enableCustomerService;if("enable_customer_service"in e)return e.enable_customer_service}},Kye=e=>{const t={};return("agentId"in e||"agent_id"in e)&&(t.agentId=an(e.agentId)||an(e.agent_id)||void 0),("playbookId"in e||"playbook_id"in e)&&(t.playbookId=an(e.playbookId)||an(e.playbook_id)||void 0),("playbookParams"in e||"playbook_params"in e)&&(t.playbookParams=e.playbookParams??e.playbook_params),"message"in e&&(t.message=e.message),t},Yye=e=>{const t=E4e(e);return{hasExplicitTargetOptions:!!e&&["playbookId","playbook_id","playbookParams","playbook_params","message","agentId","agent_id"].some(r=>r in e),playbookId:an(e==null?void 0:e.playbookId)||an(e==null?void 0:e.playbook_id)||void 0,playbookParams:(e==null?void 0:e.playbookParams)??(e==null?void 0:e.playbook_params),message:e==null?void 0:e.message,agentId:an(e==null?void 0:e.agentId)||an(e==null?void 0:e.agent_id)||void 0,enableCustomerService:t}},hnn=e=>Array.isArray(e)?{agents:e,agentId:void 0,playbookId:void 0}:{agents:e==null?void 0:e.agents,agentId:an(e==null?void 0:e.agentId)||an(e==null?void 0:e.agent_id)||void 0,playbookId:an(e==null?void 0:e.playbookId)||an(e==null?void 0:e.playbook_id)||void 0,playbookParams:_o((e==null?void 0:e.playbookParams)??(e==null?void 0:e.playbook_params))},_o=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,T4e=e=>Array.isArray(e)?e.map(t=>String(t||"").trim()).filter(Boolean):[],Ab=e=>typeof e=="string"&&e.trim()?e.trim():void 0,I4e=(e={})=>{const t=e.dataParams||e.data_params||{};return{executionParams:T4e(e.executionParams||e.execution_params||t.executionParams||t.execution_params),defaultParams:_o(e.defaultParams||e.default_params||t.defaultParams||t.default_params),paramSchema:_o(e.paramSchema||e.param_schema||t.paramSchema||t.param_schema),sdkConfig:e.sdkConfig||e.sdk_config||t.sdkConfig||t.sdk_config}},mnn=(e={})=>{const t=I4e(e),n=_o(e.playbookParams??e.playbook_params??e.params);return{...t.defaultParams||{},...n||{}}},k4e=(e={})=>({agentId:an(e.agentId)||an(e.agent_id)||void 0,playbookId:an(e.playbookId)||an(e.playbook_id)||void 0,playbookParams:mnn(e),message:e.message,sessionId:an(e.sessionId)||an(e.session_id)||void 0}),gnn={bottomRight:"bottom-right",bottomLeft:"bottom-left",topRight:"top-right",topLeft:"top-left",center:"center","bottom-right":"bottom-right","bottom-left":"bottom-left","top-right":"top-right","top-left":"top-left"},vnn=e=>e&&gnn[e]||"bottom-right",Xye=e=>{if(!(e==null||e===""))return typeof e=="number"?`${e}px`:e},IP=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),oF=e=>{if(!(e==null||e==="")){if(e==="true")return!0;if(e==="false")return!1}},sF=e=>{if(!(e==null||e===""))return/^\d+$/.test(e)?Number(e):e},ynn=e=>{const t=new Set,n=e.paramSchema||e.param_schema||{},r=e.executionParams||e.execution_params||[];for(const[i,a]of Object.entries(n))(a==null?void 0:a.source)==="runtime"&&t.add(i);for(const i of r){const a=String(i||"").trim();a&&t.add(a)}return Array.from(t).map(i=>({name:i,schema:n[i]||{}}))},P4e=e=>{const t=(e||"").trim();if(!t)return{};let n;try{n=JSON.parse(t)}catch{n=gEe(t)}const r=_o(n);if(!r)throw new Error("[Wandox] data-params must be an object");return r},N4e=e=>typeof e=="string"?{...P4e(e)}:_o(e)||{},lF=e=>{const t=N4e(e),n=_o(t.defaultParams||t.default_params);return{...Object.fromEntries(Object.entries(t).filter(([i])=>i!=="defaultParams"&&i!=="default_params")),...n||{}}},bnn=e=>{const t=_o(e);return _o(t==null?void 0:t.data)||t||{}},kP=e=>typeof e=="string"||typeof e=="number"?an(e):"",Z2=e=>e.schema.label||e.name,Zye={string:"string",text:"string",textarea:"string",number:"number",integer:"integer",int:"integer",float:"float",boolean:"boolean",bool:"boolean",array:"array",list:"array",object:"object",file:"file",date:"date",daterange:"dateRange",date_range:"dateRange",datetime:"datetime",date_time:"datetime","date-time":"datetime",datetimerange:"datetimeRange",datetime_range:"datetimeRange",timerange:"timeRange",time_range:"timeRange",time:"time"},ny=e=>{const t=String(e.schema.type||"string").trim();return Zye[t]||Zye[t.toLowerCase()]||"string"},Qye=e=>e.schema.placeholder||e.schema.description||`请输入${Z2(e)}`,N1=(e,t=ny(e))=>({type:t,format:typeof e.schema.format=="string"?e.schema.format:void 0,picker:typeof e.schema.picker=="string"?e.schema.picker:void 0,show_time:typeof e.schema.show_time=="boolean"?e.schema.show_time:void 0,range:typeof e.schema.range=="boolean"?e.schema.range:void 0}),$l=(e,t=ny(e))=>bu(N1(e,t))||(t.startsWith("time")?"HH:mm:ss":"YYYY-MM-DD"),A4e=e=>{const t=e.schema.max_files??e.schema.maxFiles??e.schema.maxCount??1,n=Number(t);return Number.isFinite(n)&&n>0?n:1},M4e=e=>{const t=e.schema.file_type??e.schema.fileType??e.schema.accept;return(Array.isArray(t)?t:typeof t=="string"?[t]:[]).flatMap(r=>String(r||"").split(/[\s,]+/)).map(r=>r.trim()).filter(Boolean)},Pee=e=>{const t=e.trim();return!t||t.includes("/")||t.startsWith(".")||t.includes("*")?t:`.${t}`},xnn=e=>{const t=M4e(e).map(Pee).filter(Boolean);return t.length>0?t.join(","):void 0},wnn=e=>e.map(Pee).filter(Boolean).join("、"),Snn=(e,t)=>{if(t.length===0)return!0;const n=e.name.toLowerCase(),r=e.type.toLowerCase();return t.map(i=>Pee(i).toLowerCase()).some(i=>!i||i==="*"||i==="*/*"?!0:i.endsWith("/*")?r.startsWith(i.slice(0,-1)):i.includes("/")?r===i:n.endsWith(i))},_nn=e=>{const t=e.schema.file_templates??e.schema.fileTemplates;return Array.isArray(t)?t.map(n=>{const r=_o(n),i=Ab(r==null?void 0:r.path);return i?{name:Ab(r==null?void 0:r.name)||"下载模板",path:i}:null}).filter(n=>!!n):[]},qS=e=>!!e&&typeof e=="object"&&typeof e.format=="function",XN=e=>{if(!e)return null;if(In.isDayjs(e))return e.isValid()?e:null;if(typeof e!="string"&&typeof e!="number"&&!(e instanceof Date))return null;const t=In(e);return t.isValid()?t:null},cF=e=>{if(!e)return null;if(In.isDayjs(e))return e.isValid()?e:null;if(typeof e!="string")return XN(e);const t=e.includes(" ")?e:`2000-01-01 ${e}`,n=In(t);return n.isValid()?n:null},PP=(e,t)=>{const n=Array.isArray(e)?e:e&&typeof e=="object"&&("start"in e||"end"in e)?[e.start,e.end]:void 0;if(!n||n.length!==2)return null;const r=t(n[0]),i=t(n[1]);return r&&i?[r,i]:null},Cnn=e=>{if(typeof e=="string")return e;if(e==null||e==="")return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}},$nn=e=>(Array.isArray(e)?e:e?[e]:[]).map((n,r)=>{const i=_o(n),a=String(i?i.url||i.response||"":n||""),o=String(i?i.name||a.split("/").pop()||`file_${r+1}`:a.split("/").pop()||n||`file_${r+1}`);return{uid:String((i==null?void 0:i.uid)||`runtime-file-${r}`),name:o,status:"done",url:a||void 0,response:i==null?void 0:i.response}}),R4e=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&("fileList"in e||"manualUrl"in e),Nee=e=>Array.isArray(e)?e:R4e(e)&&Array.isArray(e.fileList)?e.fileList:[],D4e=e=>R4e(e)?String(e.manualUrl||""):"",sG=(e,t)=>({fileList:e,manualUrl:t}),Enn=(e,t)=>{const n=t[e.name]??e.schema.defaultValue??e.schema.default,r=ny(e);return n==null?r==="boolean"?!1:r==="file"?sG([],""):"":r==="array"||r==="object"?Cnn(n):r==="date"&&y1(N1(e,r))?PP(n,XN):r==="time"&&y1(N1(e,r))?PP(n,cF):r==="date"||r==="datetime"?XN(n):r==="dateRange"||r==="datetimeRange"?PP(n,XN):r==="time"?cF(n):r==="timeRange"?PP(n,cF):r==="file"?sG($nn(n),""):n},O4e=e=>{const t=_o(e.response),n=_o(t==null?void 0:t.data);return Ab(n==null?void 0:n.url)||Ab(t==null?void 0:t.url)||Ab(e.url)||Ab(e.response)},L4e=(e,t)=>{const n=ny(e);if(n==="boolean")return!!t;if(n==="number"||n==="integer"||n==="float"){if(t===""||t==null)return;const r=Number(t);return Number.isNaN(r)?t:n==="integer"?Math.trunc(r):r}if(n==="array"||n==="object")return t===""||t==null?void 0:typeof t!="string"?t:JSON.parse(t);if((n==="date"||n==="time")&&y1(N1(e,n)))return Array.isArray(t)?t.map(r=>qS(r)?r.format($l(e,n)):r):t;if(n==="date"||n==="datetime")return qS(t)?t.format($l(e,n)):t;if(n==="dateRange"||n==="datetimeRange")return Array.isArray(t)?t.map(r=>qS(r)?r.format($l(e,n)):r):t;if(n==="time")return qS(t)?t.format($l(e,n)):t;if(n==="timeRange")return Array.isArray(t)?t.map(r=>qS(r)?r.format($l(e,n)):r):t;if(n==="file"){const r=Nee(t),i=D4e(t).trim(),a=r.map(O4e).filter(Boolean);return i&&a.push(i),A4e(e)<=1?a[a.length-1]:a}return t},j4e=e=>e==null||e===""||Array.isArray(e)&&e.length===0,Tnn=async(e,t)=>{const n=ny(e),r=Z2(e);if(n==="file"&&Nee(t).some(a=>a.status==="uploading"))throw new Error(`${r}正在上传,请稍后`);let i;try{i=L4e(e,t)}catch{throw new Error(n==="array"?`${r}必须是合法 JSON 数组`:`${r}必须是合法 JSON 对象`)}if(e.schema.required&&j4e(i))throw new Error(`请输入${r}`);if(n==="array"&&i!==void 0&&!Array.isArray(i))throw new Error(`${r}必须是 JSON 数组`);if(n==="object"&&i!==void 0&&!_o(i))throw new Error(`${r}必须是 JSON 对象`)};function Inn({field:e,value:t,onChange:n,customRequest:r}){const i=Nee(t),a=D4e(t),o=_nn(e),s=A4e(e),l=s<=1,c=i.some(h=>h.status==="uploading"),u=M4e(e),d=(h,g)=>{n==null||n(sG(h,g))},f=h=>{if(Snn(h,u))return!0;const g=wnn(u);return Ze.warning(g?`${Z2(e)}仅支持上传 ${g} 文件`:"文件类型不支持"),zc.LIST_IGNORE},p=({file:h,fileList:g})=>{if(!l){d(g,a);return}if(h.status==="done"){d([],O4e(h)||a);return}if(h.status==="uploading"){d(g,a);return}d([],a)};return b.jsxs("div",{className:"wandox-sdk-runtime-file",children:[o.length>0&&b.jsx("div",{className:"wandox-sdk-runtime-file__templates",children:b.jsx("div",{className:"wandox-sdk-runtime-file__template-list",children:o.map((h,g)=>b.jsxs("a",{className:"wandox-sdk-runtime-file__template",href:h.path,target:"_blank",rel:"noreferrer",children:[b.jsx(n$e,{}),b.jsx("span",{children:h.name})]},`${h.path}-${g}`))})}),b.jsxs("div",{className:"wandox-sdk-runtime-file__controls",children:[b.jsx(zc,{accept:xnn(e),beforeUpload:f,customRequest:r,fileList:l?i.filter(h=>h.status==="uploading"):i,maxCount:s,showUploadList:!l,onChange:p,children:b.jsx(Et,{icon:b.jsx(OE,{}),loading:l&&c,children:"点击上传"})}),b.jsx(Kt,{value:a,placeholder:"或粘贴外网图片 / 文件地址",allowClear:!0,onChange:h=>d(i,h.target.value)})]})]})}function knn({options:e,baseParams:t,fields:n,ssoToken:r,ssoDomain:i,ssoCompany:a,popup:o=!1,popupConfig:s,onSubmit:l,onClose:c}){const u=m.useMemo(()=>Object.fromEntries(n.map(C=>[C.name,Enn(C,t)])),[t,n]),[d]=pn.useForm(),f=vnn(s==null?void 0:s.placement),p=(s==null?void 0:s.zIndex)??2147483e3,h=o?{width:Xye(s==null?void 0:s.width),height:Xye(s==null?void 0:s.height),zIndex:p}:void 0,g={zIndex:p>0?p-1:p},v=e.message||"填写剧本参数",y=()=>async({file:C,onSuccess:$,onError:E})=>{try{const k=new FormData;k.append("file",C);const T=await fetch(`${Gi()}/api/v1/oss/upload2`,{method:"POST",headers:{Authorization:`Bearer ${r}`,"X-Tenant-ID":a,"X-Domain":i},body:k}),I=await T.json();if(!T.ok||(I==null?void 0:I.success)===!1)throw new Error((I==null?void 0:I.message)||`HTTP ${T.status}`);$==null||$(I)}catch(k){E==null||E(k instanceof Error?k:new Error("文件上传失败"))}},x=C=>{const $={};for(const E of n){const k=L4e(E,C[E.name]);j4e(k)||($[E.name]=k)}l($)},w=C=>ny(C)==="boolean"?{valuePropName:"checked"}:{},S=C=>{const $=ny(C),E=Z2(C),k=Array.isArray(C.schema.options)?C.schema.options:[];if(k.length>0)return b.jsx(tn,{style:{width:"100%"},placeholder:C.schema.placeholder||`请选择${E}`,options:k.map(T=>{const I=_o(T),P=I?I.value:T,N=String(I?I.label||P||"":T);return{value:P,label:N}})});switch($){case"number":case"integer":case"float":return b.jsx(zo,{style:{width:"100%"},precision:$==="integer"?0:void 0,placeholder:Qye(C)});case"boolean":return b.jsx(pf,{children:"启用"});case"array":case"object":return b.jsx(Kt.TextArea,{autoSize:!0,placeholder:C.schema.placeholder||"请输入 JSON"});case"file":return b.jsx(Inn,{field:C,customRequest:y()});case"date":{const T=N1(C,$),I=$l(C,$),P={style:{width:"100%"},picker:b1(I,T.picker),showTime:GQ(T)?{format:ov(I)}:!1,format:I};return y1(T)?b.jsx(ui.RangePicker,{...P,placeholder:["开始时间","结束时间"]}):b.jsx(ui,{...P,placeholder:C.schema.placeholder||"选择日期"})}case"dateRange":{const T=$l(C,$);return b.jsx(ui.RangePicker,{style:{width:"100%"},picker:b1(T),format:T,placeholder:["开始日期","结束日期"]})}case"datetime":{const T=$l(C,$);return b.jsx(ui,{style:{width:"100%"},showTime:{format:ov(T)},format:T,placeholder:C.schema.placeholder||"选择日期时间"})}case"datetimeRange":{const T=$l(C,$);return b.jsx(ui.RangePicker,{style:{width:"100%"},showTime:{format:ov(T)},format:T,placeholder:["开始日期时间","结束日期时间"]})}case"time":return y1(N1(C,$))?b.jsx(Ua.RangePicker,{style:{width:"100%"},format:$l(C,$),placeholder:["开始时间","结束时间"]}):b.jsx(Ua,{style:{width:"100%"},format:$l(C,$),placeholder:C.schema.placeholder||"选择时间"});case"timeRange":return b.jsx(Ua.RangePicker,{style:{width:"100%"},format:$l(C,$),placeholder:["开始时间","结束时间"]});default:return b.jsx(Kt.TextArea,{autoSize:!0,placeholder:Qye(C)})}},_=b.jsxs("div",{className:`wandox-sdk-exec wandox-root${o?` wandox-sdk-exec--popup wandox-sdk-exec--${f}`:""}`,style:h,children:[b.jsxs("div",{className:"wandox-sdk-exec__header",children:[b.jsx("div",{className:"wandox-sdk-exec__heading",children:b.jsx("div",{className:"wandox-sdk-exec__title",children:v})}),c&&b.jsx("button",{type:"button",className:"wandox-sdk-exec__close",onClick:c,"aria-label":"关闭",title:"关闭",children:b.jsx(ga,{})})]}),b.jsx("div",{className:"wandox-sdk-exec__body",children:b.jsxs(pn,{form:d,className:"wandox-sdk-runtime-form",initialValues:u,onFinish:x,children:[b.jsx("div",{className:"wandox-sdk-runtime-form__intro",children:"请补充本次执行需要传入的参数。"}),b.jsx("div",{className:"wandox-sdk-runtime-form__fields",children:n.map(C=>b.jsx(pn.Item,{className:"wandox-sdk-runtime-field",name:C.name,label:Z2(C),rules:[{validator:($,E)=>Tnn(C,E)}],...w(C),children:S(C)},C.name))}),b.jsxs("div",{className:"wandox-sdk-runtime-form__actions",children:[c&&b.jsx(Et,{className:"wandox-sdk-runtime-form__secondary",onClick:c,children:"取消"}),b.jsx(Et,{type:"primary",htmlType:"submit",className:"wandox-sdk-runtime-form__primary",children:"执行"})]})]})})]});return o&&(s!=null&&s.mask)?b.jsxs(b.Fragment,{children:[s.maskClosable===!1?b.jsx("div",{className:"wandox-sdk-exec-mask",style:g,"aria-hidden":"true"}):b.jsx("button",{type:"button",className:"wandox-sdk-exec-mask",style:g,onClick:c,"aria-label":"关闭参数弹窗"}),_]}):_}function Pnn({options:e,runtimeFields:t,ssoToken:n,ssoDomain:r,ssoCompany:i,defaultAgentId:a,defaultPlaybookId:o,popup:s=!1,popupConfig:l,onClose:c,onReady:u}){const d=m.useMemo(()=>k4e(e),[e]),[f,p]=m.useState(t.length>0?null:{});return f===null?b.jsx(knn,{options:e,baseParams:d.playbookParams||{},fields:t,ssoToken:n,ssoDomain:r,ssoCompany:i,popup:s,popupConfig:l,onClose:c,onSubmit:h=>p(h)}):b.jsx(ZOe,{options:{...d,playbookParams:{...d.playbookParams||{},...f}},ssoToken:n,ssoDomain:r,ssoCompany:i,defaultAgentId:a,defaultPlaybookId:o,popup:s,popupConfig:l,executionMode:"run",onClose:c,onReady:u})}const Aee={instance:null,floatingManager:null,init(e){const t=this;if(this.instance)return this.instance;if(!e.token||!e.domain)throw new Error("[Wandox] token and domain are required");const{enableCustomerService:n,enable_customer_service:r,agentId:i,agent_id:a,playbookId:o,playbook_id:s,...l}=e,c={...l},u=c.token,d=c.domain,f=c.companyCode||"",p=e.username||"",h=e.userId||e.user_id||"",g=kY();localStorage.setItem("sso_token",u),localStorage.setItem("sso_domain",d),p&&localStorage.setItem("sso_username",p),h&&localStorage.setItem("sso_user_id",h),f&&localStorage.setItem("sso_company",f),t.floatingManager=new XOe(u,d,f,g);let v=null;const y=new Map,x=new Map,w=new Map,S=new Map;let _=null,C=null,$=null;const E=new Set,k=(G={})=>({page:G.page||1,page_size:G.pageSize||G.page_size||99,status:G.status,is_auth:G.isAuth??G.is_auth}),T=(G={})=>{const X=k(G),J=JSON.stringify(X),Y=x.get(J);if(Y)return Y;const Z=XO(X).then(re=>Array.isArray(re.data)?re.data:[]).catch(re=>{throw x.delete(J),re});return x.set(J,Z),Z},I=G=>{const X=G.trim();if(!X)return Promise.reject(new Error("[Wandox] agentId is required"));const J=y.get(X);if(J)return J;const Y=PY({agent_id:X}).then(Z=>Z.data||{}).catch(Z=>{throw y.delete(X),Z});return y.set(X,Y),Y},P=G=>{if(typeof G!="string")return G;const X=document.querySelector(G);if(!X)throw new Error(`[Wandox] Container ${G} not found`);return X},N=G=>{if(!G)return document;if(typeof G!="string")return G;const X=document.querySelector(G);if(!X)throw new Error(`[Wandox] Container ${G} not found`);return X},A=(G,X,J)=>({element:G,abort:()=>{var Y;return(Y=X())==null?void 0:Y.abort()},rerun:()=>{var Y;return(Y=X())==null?void 0:Y.rerun()},minimize:()=>{var Y;return(Y=X())==null?void 0:Y.minimize()},restore:()=>{var Y;return(Y=X())==null?void 0:Y.restore()},destroy:J}),M=(G,X={},J=!1,Y,Z,re="chat")=>{var oe;const ee=k4e(X);let te=w.get(G);return te?(oe=S.get(G))==null||oe.abort():(te=qg(G),w.set(G,te)),te.render(b.jsx(EC,{queryClient:g,children:b.jsx(ZOe,{options:ee,ssoToken:u,ssoDomain:d,ssoCompany:f,popup:J,popupConfig:Z,executionMode:re,onClose:Y,onReady:fe=>{S.set(G,fe),J&&($=fe)}})})),A(G,()=>S.get(G)||null,()=>{var fe;(fe=S.get(G))==null||fe.abort(),te==null||te.unmount(),w.delete(G),S.delete(G),J&&C===G&&(_=null,$=null,C==null||C.remove(),C=null)})},R=()=>{$==null||$.abort(),_==null||_.unmount(),C&&(w.delete(C),S.delete(C),C.remove()),_=null,C=null,$=null},L=(G,X={},J=!1,Y,Z)=>{var oe;const re=I4e(X),ee=ynn(re);if(ee.length===0)return M(G,X,J,Y,Z,"run");let te=w.get(G);return te?(oe=S.get(G))==null||oe.abort():(te=qg(G),w.set(G,te)),te.render(b.jsx(EC,{queryClient:g,children:b.jsx(Pnn,{options:X,runtimeFields:ee,ssoToken:u,ssoDomain:d,ssoCompany:f,popup:J,popupConfig:Z,onClose:Y,onReady:fe=>{S.set(G,fe),J&&($=fe)}})})),A(G,()=>S.get(G)||null,()=>{var fe;(fe=S.get(G))==null||fe.abort(),te==null||te.unmount(),w.delete(G),S.delete(G),J&&C===G&&(_=null,$=null,C==null||C.remove(),C=null)})},z=(G,X={},J)=>{var re,ee,te,oe,fe,he,ye;const Y=X.popup||{},Z=G.dataset;return IP({...(J==null?void 0:J.popup)||{},...Y,placement:Z.popupPlacement||Y.placement||((re=J==null?void 0:J.popup)==null?void 0:re.placement),mask:oF(G.getAttribute("data-popup-mask"))??Y.mask??((ee=J==null?void 0:J.popup)==null?void 0:ee.mask),maskClosable:oF(G.getAttribute("data-popup-mask-closable"))??Y.maskClosable??((te=J==null?void 0:J.popup)==null?void 0:te.maskClosable),minimizable:oF(G.getAttribute("data-popup-minimizable"))??Y.minimizable??((oe=J==null?void 0:J.popup)==null?void 0:oe.minimizable),width:sF(G.getAttribute("data-popup-width"))??Y.width??((fe=J==null?void 0:J.popup)==null?void 0:fe.width),height:sF(G.getAttribute("data-popup-height"))??Y.height??((he=J==null?void 0:J.popup)==null?void 0:he.height),zIndex:sF(G.getAttribute("data-popup-z-index"))??Y.zIndex??((ye=J==null?void 0:J.popup)==null?void 0:ye.zIndex)})},j=(G,X={})=>{const J=G.getAttribute("data-container"),Y=J==null?void 0:J.trim();return Y||X.container},O=G=>{var X;if(G.hasAttribute("data-container"))return((X=G.getAttribute("data-container"))==null?void 0:X.trim())||""},V=(G,X)=>{var oe;const J=P4e(G.getAttribute("data-params")),Y=J.sdkConfig||J.sdk_config||{},Z=G.dataset,re=j(G,Y),ee=z(G,Y,X),te={...J,dataParams:J,agentId:an(Z.agentId)||an(J.agentId)||an(J.agent_id)||void 0,playbookId:an(Z.playbookId)||an(J.playbookId)||an(J.playbook_id)||void 0,message:Z.message||Z.title||J.message||((oe=G.textContent)==null?void 0:oe.trim())||"剧本执行"};return{container:re,options:te,popupConfig:ee}},B=G=>{const X=G.dataset;return an(G.getAttribute("data-component-id"))||an(G.getAttribute("data-component_id"))||an(X.componentId)||an(X.component_id)},D=G=>{const X=G.getAttribute("data-default-params")||G.getAttribute("data-default_params")||G.getAttribute("data-params");return lF(X)},F=(G={},X={})=>IP({...G,...X,popup:IP({...G.popup||{},...X.popup||{}})}),H=(G={})=>({componentId:an(G.componentId)||an(G.component_id)||void 0,defaultParams:lF(G.defaultParams||G.default_params||G.params),agentId:an(G.agentId)||an(G.agent_id)||void 0,playbookId:an(G.playbookId)||an(G.playbook_id)||void 0,message:G.message,sdkConfig:F(G.sdkConfig||G.sdk_config||{})}),W=async(G={})=>{const X=H(G),J=X.componentId;if(!J)throw new Error("[Wandox] componentId is required");const Y=await Dgt(J),Z=bnn(Y),re=N4e(Z.playbookParams||Z.playbook_params),ee=Z.sdkConfig||Z.sdk_config||re.sdkConfig||re.sdk_config||{},te=F(ee,X.sdkConfig),oe={...lF(re.defaultParams||re.default_params),...X.defaultParams,component_id:J},fe="container"in G&&G.container!==void 0?G.container||void 0:te.container,he=IP({...te.popup||{},...G.popupConfig||{}}),ye={agentId:X.agentId||kP(Z.agentId)||kP(Z.agent_id)||void 0,playbookId:X.playbookId||kP(Z.playbookId)||kP(Z.playbook_id)||void 0,message:X.message||String(Z.name||Z.title||"剧本执行"),executionParams:T4e(re.executionParams||re.execution_params),defaultParams:oe,paramSchema:_o(re.paramSchema||re.param_schema),sdkConfig:te};return{container:fe,options:ye,popupConfig:he}},K=async(G,X)=>{var re;const J=G.dataset,Y=B(G),Z=z(G,{},X);return W({componentId:Y,defaultParams:D(G),container:O(G),popupConfig:Z,agentId:J.agentId,playbookId:J.playbookId,message:J.message||J.title||((re=G.textContent)==null?void 0:re.trim())||void 0})},U=G=>{if(!G.options.playbookId)throw new Error("[Wandox] playbookId is required");if(G.container)return L(P(G.container),G.options);R();const X=document.createElement("div");X.id="wandox-playbook-execution-popup-root",document.body.appendChild(X),C=X;const J=L(X,G.options,!0,R,G.popupConfig);return _=w.get(X)||null,J},q=(G,X)=>{const J=N(G),Y=async re=>{const ee=re.target;if(!(ee instanceof Element))return;const te=ee.closest('[data-action="playbook"], [data-action="page-component"], [data-component-id], [data-component_id]');if(te instanceof HTMLElement&&!(J instanceof HTMLElement&&!J.contains(te))){re.preventDefault();try{const oe=te.getAttribute("data-action"),fe=B(te),he=oe==="page-component"||fe?await K(te,X):V(te,X);U(he)}catch{}}};J.addEventListener("click",Y);const Z={root:J,destroy:()=>{J.removeEventListener("click",Y),E.delete(Z)}};return E.add(Z),Z},Q=(G,X,J,Y,Z)=>{const re=P(G);return qg(re).render(b.jsx(EC,{queryClient:g,children:b.jsx(pnn,{presetAgents:X,initialAgentId:J,initialPlaybookId:Y,initialPlaybookParams:Z,onReady:te=>{v=te}})})),re};return t.instance={config:c,mountAssistant(G,X){const J=hnn(X),Y=J.agentId,Z=Y?J.playbookId:void 0;return Q(G,J.agents,Y,Z,Z?J.playbookParams:void 0)},getAgents(G){return T(G)},getAgentDetail(G){return I(G)},async getAgentPlaybookGroups(G){return(await I(G)).playbook_groups||[]},enableFloatingBall(){t.floatingManager&&t.floatingManager.enable()},registerFloatingBall(G){t.floatingManager&&t.floatingManager.registerFloatingBall(Kye(G))},setFloatingBallConfig(G){t.floatingManager&&t.floatingManager.setFloatingBallConfig(Kye(G))},clearMessages(){t.floatingManager&&t.floatingManager.clearMessages()},getMessages(){return t.floatingManager?t.floatingManager.getMessages():[]},openDrawer(G){if(t.floatingManager){const X=Yye(G);t.floatingManager.openDrawer(X.playbookId,X.message,X.agentId,!X.hasExplicitTargetOptions,X.playbookParams,X.enableCustomerService)}},openDrawerOnly(G){if(t.floatingManager){const X=Yye(G);t.floatingManager.openDrawerOnly(X.playbookId,X.message,X.agentId,!X.hasExplicitTargetOptions,X.playbookParams,X.enableCustomerService)}},openDrawerWithPlaybook(G){t.floatingManager&&t.floatingManager.openDrawerWithPlaybook({playbookId:an(G.playbookId)||an(G.playbook_id)||void 0,playbookParams:G.playbookParams??G.playbook_params,message:G.message,agentId:an(G.agentId)||an(G.agent_id)||void 0,enableCustomerService:E4e(G)})},mountPlaybookExecution(G,X){return M(P(G),X)},openPlaybookExecution(G,X){R();const J=document.createElement("div");return J.id="wandox-playbook-execution-popup-root",document.body.appendChild(J),C=J,M(J,G,!0,R,X),_=w.get(J)||null,A(J,()=>$,R)},mountPlaybookRun(G,X){return L(P(G),X)},openPlaybookRun(G,X){R();const J=document.createElement("div");return J.id="wandox-playbook-execution-popup-root",document.body.appendChild(J),C=J,L(J,G,!0,R,X),_=w.get(J)||null,A(J,()=>$,R)},async mountPageComponentRun(G,X){const J=await W({...X||{},container:G});return U(J)},async openPageComponentRun(G,X){const J=await W({...G||{},container:"",popupConfig:X});return U(J)},mountPlaybookActions(G,X){return q(G,X)},bindPlaybookActions(G,X){return q(G,X)},closeDrawer(){t.floatingManager&&t.floatingManager.closeDrawer()},showInspectionResults(G){v?v.showInspectionResults(G):t.floatingManager&&t.floatingManager.showInspectionResults(G)},destroy(){t.floatingManager&&(t.floatingManager.destroy(),t.floatingManager=null),R(),w.forEach((G,X)=>{var J;(J=S.get(X))==null||J.abort(),G.unmount()}),w.clear(),S.clear();for(const G of Array.from(E))G.destroy();E.clear(),y.clear(),x.clear(),g.clear(),t.instance=null}},t.instance},getInstance(){return this.instance}};typeof window<"u"&&(window.wandox=Aee);const Nnn=Aee;exports.COMMENT=Sq;exports.FloatingManager=XOe;exports.KEYFRAMES=$q;exports.LAYER=m1e;exports.MEDIA=RBe;exports.SCOPE=jBe;exports.SUPPORTS=OBe;exports.commonjsGlobal=Xs;exports.compile=_B;exports.dayjs2=In;exports.dayjsAdvancedFormat=S_e;exports.dayjsCustomParseFormat=mK;exports.getDefaultExportFromCjs=Co;exports.middleware=x1e;exports.serialize=Dx;exports.stringify=CB;exports.wandox=Nnn;exports.wandoxSDK=Aee;
|