@nocobase/plugin-workflow 1.2.1-alpha → 1.2.2-alpha

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.
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(v,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("@nocobase/utils/client"),require("react-router-dom"),require("react"),require("antd"),require("react-i18next"),require("@ant-design/icons"),require("@formily/core"),require("@formily/react"),require("lodash"),require("@formily/shared"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","@nocobase/utils/client","react-router-dom","react","antd","react-i18next","@ant-design/icons","@formily/core","@formily/react","lodash","@formily/shared","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],r):(v=typeof globalThis!="undefined"?globalThis:v||self,r(v["@nocobase/plugin-workflow"]={},v.jsxRuntime,v["@nocobase/client"],v["@nocobase/utils"],v["react-router-dom"],v.react,v.antd,v["react-i18next"],v["@ant-design/icons"],v["@formily/core"],v["@formily/react"],v.lodash,v["@formily/shared"],v.dayjs,v["@nocobase/evaluators"],v["@formily/antd-v5"]))})(this,function(v,r,i,H,oe,b,g,Q,D,ye,j,De,$t,Ho,$e,Jo){"use strict";var Or=Object.defineProperty,Tr=Object.defineProperties;var Fr=Object.getOwnPropertyDescriptors;var dt=Object.getOwnPropertySymbols;var Wo=Object.prototype.hasOwnProperty,Lo=Object.prototype.propertyIsEnumerable;var Dt=(v,r,i)=>r in v?Or(v,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):v[r]=i,C=(v,r)=>{for(var i in r||(r={}))Wo.call(r,i)&&Dt(v,i,r[i]);if(dt)for(var i of dt(r))Lo.call(r,i)&&Dt(v,i,r[i]);return v},O=(v,r)=>Tr(v,Fr(r));var zo=v=>typeof v=="symbol"?v:v+"",Z=(v,r)=>{var i={};for(var H in v)Wo.call(v,H)&&r.indexOf(H)<0&&(i[H]=v[H]);if(v!=null&&dt)for(var H of dt(v))r.indexOf(H)<0&&Lo.call(v,H)&&(i[H]=v[H]);return i};var w=(v,r,i)=>(Dt(v,typeof r!="symbol"?r+"":r,i),i);var G=(v,r,i)=>new Promise((H,oe)=>{var b=D=>{try{Q(i.next(D))}catch(ye){oe(ye)}},g=D=>{try{Q(i.throw(D))}catch(ye){oe(ye)}},Q=D=>D.done?H(D.value):Promise.resolve(D.value).then(b,g);Q((i=i.apply(v,r)).next())});const Uo=b.createContext(null),pt={didCatch:!1,error:null};class Go extends b.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=pt}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var o,n,s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];(o=(n=this.props).onReset)===null||o===void 0||o.call(n,{args:a,reason:"imperative-api"}),this.setState(pt)}}componentDidCatch(t,o){var n,s;(n=(s=this.props).onError)===null||n===void 0||n.call(s,t,o)}componentDidUpdate(t,o){const{didCatch:n}=this.state,{resetKeys:s}=this.props;if(n&&o.error!==null&&qo(t.resetKeys,s)){var a,l;(a=(l=this.props).onReset)===null||a===void 0||a.call(l,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(pt)}}render(){const{children:t,fallbackRender:o,FallbackComponent:n,fallback:s}=this.props,{didCatch:a,error:l}=this.state;let c=t;if(a){const d={error:l,resetErrorBoundary:this.resetErrorBoundary};if(b.isValidElement(s))c=s;else if(typeof o=="function")c=o(d);else if(n)c=b.createElement(n,d);else throw l}return b.createElement(Uo.Provider,{value:{didCatch:a,error:l,resetErrorBoundary:this.resetErrorBoundary}},c)}}function qo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((o,n)=>!Object.is(o,t[n]))}const Me=b.createContext({});function Y(){return b.useContext(Me)}const p="workflow";function N(e,t={}){return i.i18n.t(e,O(C({},t),{ns:p}))}function mt(){return Q.useTranslation(p)}const ne=i.createStyles(({css:e,token:t})=>({workflowPageClass:e`
10
+ (function(v,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("@nocobase/utils/client"),require("react-router-dom"),require("react"),require("antd"),require("react-i18next"),require("@ant-design/icons"),require("@formily/core"),require("@formily/reactive"),require("@formily/react"),require("lodash"),require("@formily/shared"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","@nocobase/utils/client","react-router-dom","react","antd","react-i18next","@ant-design/icons","@formily/core","@formily/reactive","@formily/react","lodash","@formily/shared","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],r):(v=typeof globalThis!="undefined"?globalThis:v||self,r(v["@nocobase/plugin-workflow"]={},v.jsxRuntime,v["@nocobase/client"],v["@nocobase/utils"],v["react-router-dom"],v.react,v.antd,v["react-i18next"],v["@ant-design/icons"],v["@formily/core"],v["@formily/reactive"],v["@formily/react"],v.lodash,v["@formily/shared"],v.dayjs,v["@nocobase/evaluators"],v["@formily/antd-v5"]))})(this,function(v,r,i,U,oe,g,b,Z,$,ie,ft,j,ke,He,Ko,$e,Pt){"use strict";var Er=Object.defineProperty,Dr=Object.defineProperties;var $r=Object.getOwnPropertyDescriptors;var mt=Object.getOwnPropertySymbols;var Go=Object.prototype.hasOwnProperty,qo=Object.prototype.propertyIsEnumerable;var It=(v,r,i)=>r in v?Er(v,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):v[r]=i,C=(v,r)=>{for(var i in r||(r={}))Go.call(r,i)&&It(v,i,r[i]);if(mt)for(var i of mt(r))qo.call(r,i)&&It(v,i,r[i]);return v},O=(v,r)=>Dr(v,$r(r));var Yo=v=>typeof v=="symbol"?v:v+"",X=(v,r)=>{var i={};for(var U in v)Go.call(v,U)&&r.indexOf(U)<0&&(i[U]=v[U]);if(v!=null&&mt)for(var U of mt(v))r.indexOf(U)<0&&qo.call(v,U)&&(i[U]=v[U]);return i};var w=(v,r,i)=>(It(v,typeof r!="symbol"?r+"":r,i),i);var G=(v,r,i)=>new Promise((U,oe)=>{var g=$=>{try{Z(i.next($))}catch(ie){oe(ie)}},b=$=>{try{Z(i.throw($))}catch(ie){oe(ie)}},Z=$=>$.done?U($.value):Promise.resolve($.value).then(g,b);Z((i=i.apply(v,r)).next())});const _o=g.createContext(null),ht={didCatch:!1,error:null};class Zo extends g.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=ht}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var o,n,s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];(o=(n=this.props).onReset)===null||o===void 0||o.call(n,{args:a,reason:"imperative-api"}),this.setState(ht)}}componentDidCatch(t,o){var n,s;(n=(s=this.props).onError)===null||n===void 0||n.call(s,t,o)}componentDidUpdate(t,o){const{didCatch:n}=this.state,{resetKeys:s}=this.props;if(n&&o.error!==null&&Qo(t.resetKeys,s)){var a,l;(a=(l=this.props).onReset)===null||a===void 0||a.call(l,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(ht)}}render(){const{children:t,fallbackRender:o,FallbackComponent:n,fallback:s}=this.props,{didCatch:a,error:l}=this.state;let c=t;if(a){const d={error:l,resetErrorBoundary:this.resetErrorBoundary};if(g.isValidElement(s))c=s;else if(typeof o=="function")c=o(d);else if(n)c=g.createElement(n,d);else throw l}return g.createElement(_o.Provider,{value:{didCatch:a,error:l,resetErrorBoundary:this.resetErrorBoundary}},c)}}function Qo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((o,n)=>!Object.is(o,t[n]))}const Me=g.createContext({});function q(){return g.useContext(Me)}const p="workflow";function N(e,t={}){return i.i18n.t(e,O(C({},t),{ns:p}))}function yt(){return Z.useTranslation(p)}const ne=i.createStyles(({css:e,token:t})=>({workflowPageClass:e`
11
11
  flex-grow: 1;
12
12
  overflow: hidden;
13
13
  display: flex;
@@ -362,12 +362,12 @@
362
362
  border-radius: 50%;
363
363
  background-color: ${t.colorText};
364
364
  color: ${t.colorBgContainer};
365
- `}));function Mt(e){var y;const{upstream:t,branchIndex:o=null}=e,n=i.usePlugin(ce),s=i.useCompile(),a=i.useAPIClient(),{workflow:l,refresh:c}=(y=Y())!=null?y:{},d=Array.from(n.instructions.getValues()),{styles:u}=ne(),f=b.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${p}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${p}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${p}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${p}" })}}`}].map(m=>{const k=d.filter(T=>T.group===m.key&&(T.isAvailable?T.isAvailable({engine:n,workflow:l,upstream:t,branchIndex:o}):!0));return O(C({},m),{type:"group",children:k.map(T=>({role:"button","aria-label":T.type,key:T.type,label:T.title,type:T.options?"subMenu":null,children:T.options?T.options.map($=>({role:"button","aria-label":$.key,key:$.key,label:$.label})):null}))})}).filter(m=>m.children.length),[o,n,d,t,l]),h=b.useCallback(k=>G(this,[k],function*({keyPath:m}){var z,U,F;const T=m.pop(),$={},[A]=m,P=n.instructions.get(T);if(A){const{value:M}=(U=(z=P.options)==null?void 0:z.find(S=>S.key===A))!=null?U:{};Object.assign($,typeof M=="function"?M():M)}l&&(yield a.resource("workflows.nodes",l.id).create({values:{type:T,upstreamId:(F=t==null?void 0:t.id)!=null?F:null,branchIndex:o,title:s(P.title),config:$}}),c())}),[a,o,n.instructions,c,t==null?void 0:t.id,l]),x=b.useMemo(()=>({onClick:h,items:s(f)}),[f,h]);return l?r.jsx("div",{className:u.addButtonClass,children:r.jsx(g.Dropdown,{trigger:["click"],menu:x,disabled:l.executed,overlayClassName:i.css`
365
+ `}));function Bt(e){var y;const{upstream:t,branchIndex:o=null}=e,n=i.usePlugin(ue),s=i.useCompile(),a=i.useAPIClient(),{workflow:l,refresh:c}=(y=q())!=null?y:{},d=Array.from(n.instructions.getValues()),{styles:u}=ne(),f=g.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${p}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${p}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${p}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${p}" })}}`}].map(m=>{const k=d.filter(F=>F.group===m.key&&(F.isAvailable?F.isAvailable({engine:n,workflow:l,upstream:t,branchIndex:o}):!0));return O(C({},m),{type:"group",children:k.map(F=>({role:"button","aria-label":F.type,key:F.type,label:F.title,type:F.options?"subMenu":null,children:F.options?F.options.map(E=>({role:"button","aria-label":E.key,key:E.key,label:E.label})):null}))})}).filter(m=>m.children.length),[o,n,d,t,l]),h=g.useCallback(k=>G(this,[k],function*({keyPath:m}){var W,J,T;const F=m.pop(),[E]=m,S=n.instructions.get(F),M=S.createDefaultConfig();if(E){const{value:I}=(J=(W=S.options)==null?void 0:W.find(A=>A.key===E))!=null?J:{};Object.assign(M,typeof I=="function"?I():I)}l&&(yield a.resource("workflows.nodes",l.id).create({values:{type:F,upstreamId:(T=t==null?void 0:t.id)!=null?T:null,branchIndex:o,title:s(S.title),config:M}}),c())}),[a,o,n.instructions,c,t==null?void 0:t.id,l]),x=g.useMemo(()=>({onClick:h,items:s(f)}),[f,h]);return l?r.jsx("div",{className:u.addButtonClass,children:r.jsx(b.Dropdown,{trigger:["click"],menu:x,disabled:l.executed,overlayClassName:i.css`
366
366
  .ant-dropdown-menu-root {
367
367
  max-height: 30em;
368
368
  overflow-y: auto;
369
369
  }
370
- `,children:r.jsx(g.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(D.PlusOutlined,{})})})}):null}const ft=(e,t)=>({getAriaLabel:b.useCallback(n=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",n].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),Yo=i.createStyles(({css:e,token:t})=>({container:e`
370
+ `,children:r.jsx(b.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx($.PlusOutlined,{})})})}):null}const gt=(e,t)=>({getAriaLabel:g.useCallback(n=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",n].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),Xo=i.createStyles(({css:e,token:t})=>({container:e`
371
371
  margin-bottom: 1.5em;
372
372
  padding: 1em;
373
373
  background-color: ${t.colorFillAlter};
@@ -392,11 +392,11 @@
392
392
  p {
393
393
  color: ${t.colorTextDescription};
394
394
  }
395
- `}));function It(e){const{label:t,title:o,description:n}=e,{styles:s}=Yo();return r.jsxs("div",{className:i.cx(s.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:t}),r.jsx("dd",{children:r.jsx(g.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]})}function Ko(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pt={exports:{}};/*!
395
+ `}));function Vt(e){const{label:t,title:o,description:n}=e,{styles:s}=Xo();return r.jsxs("div",{className:i.cx(s.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:t}),r.jsx("dd",{children:r.jsx(b.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]})}function Ro(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jt={exports:{}};/*!
396
396
  Copyright (c) 2018 Jed Watson.
397
397
  Licensed under the MIT License (MIT), see
398
398
  http://jedwatson.github.io/classnames
399
- */(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var a="",l=0;l<arguments.length;l++){var c=arguments[l];c&&(a=s(a,n(c)))}return a}function n(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return o.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var l="";for(var c in a)t.call(a,c)&&a[c]&&(l=s(l,c));return l}function s(a,l){return l?a?a+" "+l:a+l:a}e.exports?(o.default=o,e.exports=o):window.classNames=o})()})(Pt);var _o=Pt.exports;const Zo=Ko(_o),Qo=i.createStyles(({css:e,token:t})=>({statusButtonClass:e`
399
+ */(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var a="",l=0;l<arguments.length;l++){var c=arguments[l];c&&(a=s(a,n(c)))}return a}function n(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return o.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var l="";for(var c in a)t.call(a,c)&&a[c]&&(l=s(l,c));return l}function s(a,l){return l?a?a+" "+l:a+l:a}e.exports?(o.default=o,e.exports=o):window.classNames=o})()})(jt);var en=jt.exports;const tn=Ro(en),on=i.createStyles(({css:e,token:t})=>({statusButtonClass:e`
400
400
  border: none;
401
401
  .ant-tag {
402
402
  width: 100%;
@@ -408,7 +408,7 @@
408
408
  }
409
409
  `,noStatusButtonClass:e`
410
410
  border-width: 2px;
411
- `}));function Ie(e){var n;const{styles:t}=Qo();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:a}=e.statusMap[e.status];o=r.jsx(g.Tag,{color:a,children:s})}return r.jsx(g.Button,O(C({},e),{shape:"circle",size:"small",className:Zo(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const de={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},Je=[{value:de.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:r.jsx(D.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:de.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(D.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:de.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(D.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:de.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(D.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:de.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(D.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:de.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(D.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:de.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(D.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:de.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(D.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:de.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(D.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],Ue=Je.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),ie={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},ht=[{value:ie.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(D.ClockCircleOutlined,{})},{value:ie.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(D.CheckOutlined,{})},{value:ie.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(D.ExclamationOutlined,{})},{value:ie.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(D.CloseOutlined,{})},{value:ie.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(D.MinusOutlined,{rotate:90})},{value:ie.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(D.MinusOutlined,{rotate:45})},{value:ie.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(D.MinusOutlined,{})},{value:ie.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(D.RedoOutlined,{})}],Ge=ht.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});class ge{constructor(){w(this,"title");w(this,"type");w(this,"group");w(this,"description");w(this,"options");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components");w(this,"end")}}function Xo(){const e=j.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=Ce(),{workflow:a}=Y();return{run(){return G(this,null,function*(){var c,d;if(a.executed){g.message.error(N("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=t.resource("flow_nodes")).update)==null?void 0:d.call(c,{filterByTk:s.id,values:{config:e.values}}),o.setFormValueChanged(!1),o.setVisible(!1),n()})}}}const yt=b.createContext({});function Ce(){return b.useContext(yt)}function Bt(e,t){const o=[];if(!e)return[];for(let n=e.upstream;n;n=n.upstream)(typeof t!="function"||t(n))&&o.push(n);return o}function Vt(e){const t=[];if(!e)return[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}function jt({data:e}){const{styles:t}=ne(),{getAriaLabel:o}=ft(e),n=i.usePlugin(ce),{Component:s=gt,end:a}=n.instructions.get(e.type);return r.jsx(yt.Provider,{value:e,children:r.jsxs("div",{className:i.cx(t.nodeBlockClass),children:[r.jsx(s,{data:e}),!a||typeof a=="function"&&!a(e)?r.jsx(Mt,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(D.CloseOutlined,{})})]})})}function Wt(){var u;const{t:e}=Q.useTranslation(),t=i.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(u=Y())!=null?u:{},a=Ce(),{modal:l}=g.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function d(){return G(this,null,function*(){function f(){return G(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:a.id}),s()})}const h=n.filter(m=>m===a?!1:H.parse(m.config).parameters.filter(({key:$})=>$.startsWith(`$jobsMapByNodeKey.${a.key}.`)||$===`$jobsMapByNodeKey.${a.key}`).length);if(h.length){l.error({title:N("Can not delete"),content:N("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:h.map(m=>`#${m.id}`).join(", ")})});return}const y=!n.find(m=>m.upstream===a&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):N("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:y,onOk:f})})}return o.executed?null:r.jsx(g.Button,{type:"text",shape:"circle",icon:r.jsx(D.DeleteOutlined,{}),onClick:d,className:"workflow-node-remove-button"})}function Lt(){var a;const{execution:e,setViewJob:t}=Y(),{jobs:o}=(a=Ce())!=null?a:{},{styles:n}=ne();if(!e)return null;if(!o.length)return r.jsx(Ie,{className:n.nodeJobButtonClass,disabled:!0});function s({key:l}){const c=o.find(d=>d.id==l);t(c)}return o.length>1?r.jsx(g.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Ie,{statusMap:Ge,status:l.status}),r.jsx("time",{children:H.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(Ie,{statusMap:Ge,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Ie,{statusMap:Ge,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function Ro(){return{form:j.useForm()}}function gt(e){var F,M;const{data:t,children:o}=e,n=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(F=Y())!=null?F:{},{styles:c}=ne(),u=i.usePlugin(ce).instructions.get(t.type),f=a.executed?'{{t("View")}}':'{{t("Configure")}}',h=n(u.title),[x,y]=b.useState((M=t.title)!=null?M:h),[m,k]=b.useState(!1),[T,$]=b.useState(!1),A=b.useMemo(()=>{const S=De.cloneDeep(t.config);return ye.createForm({initialValues:S,disabled:a.executed})},[t,a]),P=b.useCallback(S=>{k(S),S||A.reset()},[A]),z=b.useCallback(function(S){return G(this,null,function*(){var L,J;const I=S||h;y(I),I!==t.title&&(yield(J=(L=s.resource("flow_nodes")).update)==null?void 0:J.call(L,{filterByTk:t.id,values:{title:I}}),l())})},[t]),U=b.useCallback(function(S){if(S.target===S.currentTarget){k(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let L=S.target;L&&L!==S.currentTarget&&L!==document.documentElement;L=L.parentNode)if(Array.from(L.classList).some(J=>I.has(J))){k(!0),S.stopPropagation();return}},[]);return r.jsxs("div",{className:i.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${h}-${x}`,className:i.cx(c.nodeCardClass,{configuring:m}),onClick:U,children:[r.jsxs("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(g.Tag,{children:h}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(g.Input.TextArea,{disabled:a.executed,value:x,onChange:S=>y(S.target.value),onBlur:S=>z(S.target.value),autoSize:!0}),r.jsx(Wt,{}),r.jsx(Lt,{}),r.jsx(i.ActionContextProvider,{value:{visible:m,setVisible:P,formValueChanged:T,setFormValueChanged:$},children:r.jsx(i.FormProvider,{form:A,children:r.jsx(i.SchemaComponent,{distributed:!1,scope:O(C({},u.scope),{useFormProviderProps:Ro}),components:u.components,schema:{type:"void",properties:O(C({},u.view?{view:u.view}:{}),{button:{type:"void","x-content":f,"x-component":g.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[t.id]:{type:"void",title:r.jsxs("div",{className:i.css`
411
+ `}));function Ie(e){var n;const{styles:t}=on();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:a}=e.statusMap[e.status];o=r.jsx(b.Tag,{color:a,children:s})}return r.jsx(b.Button,O(C({},e),{shape:"circle",size:"small",className:tn(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const pe={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},Ge=[{value:pe.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:r.jsx($.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:pe.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:r.jsx($.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:pe.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx($.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:pe.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:pe.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:pe.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:pe.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],qe=Ge.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),le={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},bt=[{value:le.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:r.jsx($.ClockCircleOutlined,{})},{value:le.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx($.CheckOutlined,{})},{value:le.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.ExclamationOutlined,{})},{value:le.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.CloseOutlined,{})},{value:le.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.MinusOutlined,{rotate:90})},{value:le.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{rotate:45})},{value:le.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{})},{value:le.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.RedoOutlined,{})}],Ye=bt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});class ge{constructor(){w(this,"title");w(this,"type");w(this,"group");w(this,"description");w(this,"options");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components");w(this,"end")}createDefaultConfig(){return{}}}function nn(){const e=j.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=ve(),{workflow:a}=q();return{run(){return G(this,null,function*(){var c,d;if(a.executed){b.message.error(N("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=t.resource("flow_nodes")).update)==null?void 0:d.call(c,{filterByTk:s.id,values:{config:e.values}}),e.setInitialValues(ft.toJS(e.values)),o.setFormValueChanged(!1),o.setVisible(!1),n()})}}}const vt=g.createContext({});function ve(){return g.useContext(vt)}function Pe(e=[]){const t=ve();return e.some(o=>ke.get(t.config,o)!=null)}function Wt(e,t){const o=[];if(!e)return[];for(let n=e.upstream;n;n=n.upstream)(typeof t!="function"||t(n))&&o.push(n);return o}function Lt(e){const t=[];if(!e)return[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}function zt({data:e}){const{styles:t}=ne(),{getAriaLabel:o}=gt(e),n=i.usePlugin(ue),{Component:s=xt,end:a}=n.instructions.get(e.type);return r.jsx(vt.Provider,{value:e,children:r.jsxs("div",{className:i.cx(t.nodeBlockClass),children:[r.jsx(s,{data:e}),!a||typeof a=="function"&&!a(e)?r.jsx(Bt,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx($.CloseOutlined,{})})]})})}function Jt(){var u;const{t:e}=Z.useTranslation(),t=i.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(u=q())!=null?u:{},a=ve(),{modal:l}=b.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function d(){return G(this,null,function*(){function f(){return G(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:a.id}),s()})}const h=n.filter(m=>m===a?!1:U.parse(m.config).parameters.filter(({key:E})=>E.startsWith(`$jobsMapByNodeKey.${a.key}.`)||E===`$jobsMapByNodeKey.${a.key}`).length);if(h.length){l.error({title:N("Can not delete"),content:N("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:h.map(m=>`#${m.id}`).join(", ")})});return}const y=!n.find(m=>m.upstream===a&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):N("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:y,onOk:f})})}return o.executed?null:r.jsx(b.Button,{type:"text",shape:"circle",icon:r.jsx($.DeleteOutlined,{}),onClick:d,className:"workflow-node-remove-button"})}function Ut(){var a;const{execution:e,setViewJob:t}=q(),{jobs:o}=(a=ve())!=null?a:{},{styles:n}=ne();if(!e)return null;if(!o.length)return r.jsx(Ie,{className:n.nodeJobButtonClass,disabled:!0});function s({key:l}){const c=o.find(d=>d.id==l);t(c)}return o.length>1?r.jsx(b.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Ie,{statusMap:Ye,status:l.status}),r.jsx("time",{children:U.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(Ie,{statusMap:Ye,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Ie,{statusMap:Ye,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function rn(){return{form:j.useForm()}}function xt(e){var T,I;const{data:t,children:o}=e,n=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(T=q())!=null?T:{},{styles:c}=ne(),u=i.usePlugin(ue).instructions.get(t.type),f=a.executed?'{{t("View")}}':'{{t("Configure")}}',h=n(u.title),[x,y]=g.useState((I=t.title)!=null?I:h),[m,k]=g.useState(!1),[F,E]=g.useState(!1),S=g.useMemo(()=>{const A=ke.cloneDeep(t.config);return ie.createForm({initialValues:A,disabled:a.executed})},[t,a]),M=g.useCallback(A=>{k(A),A||S.reset()},[S]),W=g.useCallback(function(A){return G(this,null,function*(){var z,H;const P=A||h;y(P),P!==t.title&&(yield(H=(z=s.resource("flow_nodes")).update)==null?void 0:H.call(z,{filterByTk:t.id,values:{title:P}}),l())})},[t]),J=g.useCallback(function(A){if(A.target===A.currentTarget){k(!0);return}const P=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let z=A.target;z&&z!==A.currentTarget&&z!==document.documentElement;z=z.parentNode)if(Array.from(z.classList).some(H=>P.has(H))){k(!0),A.stopPropagation();return}},[]);return r.jsxs("div",{className:i.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${h}-${x}`,className:i.cx(c.nodeCardClass,{configuring:m}),onClick:J,children:[r.jsxs("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(b.Tag,{children:h}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(b.Input.TextArea,{disabled:a.executed,value:x,onChange:A=>y(A.target.value),onBlur:A=>W(A.target.value),autoSize:!0}),r.jsx(Jt,{}),r.jsx(Ut,{}),r.jsx(i.ActionContextProvider,{value:{visible:m,setVisible:M,formValueChanged:F,setFormValueChanged:E},children:r.jsx(i.FormProvider,{form:S,children:r.jsx(i.SchemaComponent,{distributed:!1,scope:O(C({},u.scope),{useFormProviderProps:rn,useUpdateAction:nn}),components:u.components,schema:{type:"void",properties:O(C({},u.view?{view:u.view}:{}),{button:{type:"void","x-content":f,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[t.id]:{type:"void",title:r.jsxs("div",{className:i.css`
412
412
  display: flex;
413
413
  justify-content: space-between;
414
414
 
@@ -423,7 +423,7 @@
423
423
  code {
424
424
  font-weight: normal;
425
425
  }
426
- `,children:[r.jsx("strong",{children:t.title}),r.jsx(g.Tooltip,{title:N("Variable key of node"),children:r.jsx(g.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Drawer",properties:O(C({},u.description?{description:{type:"void","x-component":It,"x-component-props":{label:N("Node type"),title:u.title,description:u.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
426
+ `,children:[r.jsx("strong",{children:t.title}),r.jsx(b.Tooltip,{title:N("Variable key of node"),children:r.jsx(b.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Drawer",properties:O(C({},u.description?{description:{type:"void","x-component":Vt,"x-component-props":{label:N("Node type"),title:u.title,description:u.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
427
427
  .ant-input,
428
428
  .ant-select,
429
429
  .ant-cascader-picker,
@@ -435,34 +435,34 @@
435
435
  min-width: 6em;
436
436
  }
437
437
  }
438
- `},properties:u.fieldset},actions:a.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Xo}}}}})}})}})})})]}),o]})}function qe({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:a}){const{styles:l}=ne(),{getAriaLabel:c}=ft(e,o),d=[];for(let u=t;u;u=u.downstream)d.push(u);return r.jsxs("div",{className:i.cx("workflow-branch",l.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Mt,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:d.map(u=>r.jsx(jt,{data:u},u.id))}),a?r.jsx("div",{className:"end-sign",children:r.jsx(D.CloseOutlined,{})}):null]})}function en(){var a;const e=j.useForm(),t=i.useAPIClient(),{workflow:o}=(a=Y())!=null?a:{},n=i.useActionContext(),{refresh:s}=i.useResourceActionContext();return{run(){return G(this,null,function*(){if(o.executed){g.message.error(N("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield t.resource("workflows").update({filterByTk:o.id,values:{config:e.values}}),n.setFormValueChanged(!1),n.setVisible(!1),s()})}}}class bt{constructor(){w(this,"sync");w(this,"title");w(this,"description");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components");w(this,"initializers");w(this,"isActionTriggerable")}}function tn(){const e=i.useCompile(),{workflow:t,execution:o}=Y(),{styles:n}=ne(),s=vt();return o?r.jsx(i.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(D.InfoOutlined,{}),shape:"circle",size:"small",className:n.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.cx(n.nodeTitleClass),children:[r.jsx(g.Tag,{children:e(s.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:i.css`
438
+ `},properties:u.fieldset},actions:a.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useUpdateAction }}"}}}}})}})}})})})]}),o]})}function Ke({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:a}){const{styles:l}=ne(),{getAriaLabel:c}=gt(e,o),d=[];for(let u=t;u;u=u.downstream)d.push(u);return r.jsxs("div",{className:i.cx("workflow-branch",l.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Bt,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:d.map(u=>r.jsx(zt,{data:u},u.id))}),a?r.jsx("div",{className:"end-sign",children:r.jsx($.CloseOutlined,{})}):null]})}function sn(){var a;const e=j.useForm(),t=i.useAPIClient(),{workflow:o}=(a=q())!=null?a:{},n=i.useActionContext(),{refresh:s}=i.useResourceActionContext();return{run(){return G(this,null,function*(){if(o.executed){b.message.error(N("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield t.resource("workflows").update({filterByTk:o.id,values:{config:e.values}}),n.setFormValueChanged(!1),n.setVisible(!1),s()})}}}class wt{constructor(){w(this,"sync");w(this,"title");w(this,"description");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components");w(this,"initializers");w(this,"isActionTriggerable")}}function ln(){const e=i.useCompile(),{workflow:t,execution:o}=q(),{styles:n}=ne(),s=Ct();return o?r.jsx(i.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx($.InfoOutlined,{}),shape:"circle",size:"small",className:n.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.cx(n.nodeTitleClass),children:[r.jsx(b.Tag,{children:e(s.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:i.css`
439
439
  padding: 1em;
440
440
  background-color: #eee;
441
- `},"x-read-pretty":!0}}}}}}):null}function on(){return{form:j.useForm()}}const nn=()=>{const e=i.useAPIClient(),{workflow:t,refresh:o}=Y(),[n,s]=b.useState(""),[a,l]=b.useState(!1),[c,d]=b.useState(!1),{styles:u}=ne(),f=i.useCompile(),h=vt(),x=f(h.title),{fieldset:y,scope:m,components:k}=h,T=t.executed?'{{t("View")}}':'{{t("Configure")}}',$=N("Trigger");b.useEffect(()=>{var F,M;t&&s((M=(F=t.triggerTitle)!=null?F:t.title)!=null?M:x)},[t]);const A=b.useMemo(()=>{const F=De.cloneDeep(t.config);return ye.createForm({initialValues:F,disabled:t.executed})},[t]),P=b.useCallback(F=>{l(F),F||A.reset()},[A]),z=b.useCallback(function(F){return G(this,null,function*(){const M=F||x;s(M),M!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:M}}),o())})},[t]),U=b.useCallback(function(F){var S;if(F.target===F.currentTarget){l(!0);return}const M=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=F.target;I&&I!==F.currentTarget;I=I.parentNode)if(Array.from((S=I.classList)!=null?S:[]).some(L=>M.has(L))){l(!0),F.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${$}-${n}`,className:i.cx(u.nodeCardClass),onClick:U,children:[r.jsx("div",{className:i.cx(u.nodeMetaClass,"workflow-node-meta"),children:r.jsx(g.Tag,{color:"gold",children:$})}),r.jsx("div",{children:r.jsx(g.Input.TextArea,{value:n,onChange:F=>s(F.target.value),onBlur:F=>z(F.target.value),autoSize:!0,disabled:t.executed})}),r.jsx(tn,{}),r.jsx(i.ActionContextProvider,{value:{visible:a,setVisible:P,formValueChanged:c,setFormValueChanged:d},children:r.jsx(i.FormProvider,{form:A,children:r.jsx(i.SchemaComponent,{scope:O(C({},m),{useFormProviderProps:on}),components:k,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":T,"x-component":g.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:$,"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:O(C({},h.description?{description:{type:"void","x-component":It,"x-component-props":{label:N("Trigger type"),title:h.title,description:h.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
441
+ `},"x-read-pretty":!0}}}}}}):null}function an(){return{form:j.useForm()}}const cn=()=>{const e=i.useAPIClient(),{workflow:t,refresh:o}=q(),[n,s]=g.useState(""),[a,l]=g.useState(!1),[c,d]=g.useState(!1),{styles:u}=ne(),f=i.useCompile(),h=Ct(),x=f(h.title),{fieldset:y,scope:m,components:k}=h,F=t.executed?'{{t("View")}}':'{{t("Configure")}}',E=N("Trigger");g.useEffect(()=>{var T,I;t&&s((I=(T=t.triggerTitle)!=null?T:t.title)!=null?I:x)},[t]);const S=g.useMemo(()=>{const T=ke.cloneDeep(t.config);return ie.createForm({initialValues:T,disabled:t.executed})},[t]),M=g.useCallback(T=>{l(T),T||S.reset()},[S]),W=g.useCallback(function(T){return G(this,null,function*(){const I=T||x;s(I),I!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:I}}),o())})},[t]),J=g.useCallback(function(T){var A;if(T.target===T.currentTarget){l(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let P=T.target;P&&P!==T.currentTarget;P=P.parentNode)if(Array.from((A=P.classList)!=null?A:[]).some(z=>I.has(z))){l(!0),T.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${E}-${n}`,className:i.cx(u.nodeCardClass),onClick:J,children:[r.jsx("div",{className:i.cx(u.nodeMetaClass,"workflow-node-meta"),children:r.jsx(b.Tag,{color:"gold",children:E})}),r.jsx("div",{children:r.jsx(b.Input.TextArea,{value:n,onChange:T=>s(T.target.value),onBlur:T=>W(T.target.value),autoSize:!0,disabled:t.executed})}),r.jsx(ln,{}),r.jsx(i.ActionContextProvider,{value:{visible:a,setVisible:M,formValueChanged:c,setFormValueChanged:d},children:r.jsx(i.FormProvider,{form:S,children:r.jsx(i.SchemaComponent,{scope:O(C({},m),{useFormProviderProps:an}),components:k,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":F,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:E,"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:O(C({},h.description?{description:{type:"void","x-component":Vt,"x-component-props":{label:N("Trigger type"),title:h.title,description:h.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
442
442
  .ant-select.auto-width {
443
443
  width: auto;
444
444
  min-width: 6em;
445
445
  }
446
- `},properties:y},actions:C({},t.executed?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:en}}}})})}}}})})})]})};function vt(){const e=i.usePlugin(ce),{workflow:t}=Y();return e.triggers.get(t.type)}function zt({entry:e}){const{styles:t}=ne(),{workflow:o}=Y(),[n,s]=b.useState(100);return r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx(Go,{FallbackComponent:i.ErrorFallback,onError:console.error,children:r.jsx("div",{className:"workflow-canvas",style:{zoom:n/100},children:r.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
446
+ `},properties:y},actions:C({},t.executed?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:sn}}}})})}}}})})})]})};function Ct(){const e=i.usePlugin(ue),{workflow:t}=q();return e.triggers.get(t.type)}function Ht({entry:e}){const{styles:t}=ne(),{workflow:o}=q(),[n,s]=g.useState(100);return r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx(Zo,{FallbackComponent:i.ErrorFallback,onError:console.error,children:r.jsx("div",{className:"workflow-canvas",style:{zoom:n/100},children:r.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
447
447
  margin-top: 0 !important;
448
- `),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(g.Alert,{type:"warning",message:N("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:i.css`
448
+ `),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(b.Alert,{type:"warning",message:N("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:i.css`
449
449
  margin-bottom: 1em;
450
- `}):null,r.jsx(nn,{}),r.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
450
+ `}):null,r.jsx(cn,{}),r.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
451
451
  margin-top: 0 !important;
452
- `),children:r.jsx(qe,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:N("End")})]})})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(g.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:s})})]})}function xt(e){const t=new Map;e.forEach(o=>t.set(o.id,o));for(const o of t.values())o.upstreamId&&(o.upstream=t.get(o.upstreamId)),o.downstreamId&&(o.downstream=t.get(o.downstreamId))}function wt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{wt(e.properties[o],t)})}function ve(e){return`/admin/workflow/workflows/${e}`}function Ye(e){return`/admin/workflow/executions/${e}`}function rn(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function sn(){const{instructions:e}=i.usePlugin(ce),t=i.useCompile(),{viewJob:o,setViewJob:n}=Y(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},l=e.get(a.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.nodeTitleClass,children:[r.jsx(g.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:ht,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function ln(e){const{execution:t}=Y(),o=i.useAPIClient(),n=oe.useNavigate(),{styles:s}=ne(),[a,l]=b.useState([]),[c,d]=b.useState([]);b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{l(f.data)}).catch(()=>{})},[t]),b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{d(f.data.reverse())}).catch(()=>{})},[t]);const u=b.useCallback(({key:f})=>{f!=t.id&&n(Ye(f))},[t]);return t?r.jsx(g.Dropdown,{menu:{onClick:u,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:H.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Ie,{statusMap:Ue,status:f.status})})}))},children:r.jsxs(g.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(D.DownOutlined,{})]})}):null}function an(){var A;const{t:e}=Q.useTranslation(),t=i.useCompile(),{data:o,loading:n,refresh:s}=i.useResourceActionContext(),{setTitle:a}=i.useDocumentTitle(),[l,c]=b.useState(null),d=i.useApp(),u=i.useAPIClient();b.useEffect(()=>{var M;const{workflow:F}=(M=o==null?void 0:o.data)!=null?M:{};a==null||a(`${F!=null&&F.title?`${F.title} - `:""}${N("Execution history")}`)},[o==null?void 0:o.data]);const f=b.useCallback(()=>{g.Modal.confirm({title:N("Cancel the execution"),icon:r.jsx(D.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{u.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{g.message.success(e("Operation succeeded")),s()}).catch(F=>{console.error(F.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(g.Spin,{}):r.jsx(g.Result,{status:"404",title:"Not found"});const P=(A=o==null?void 0:o.data)!=null?A:{},{jobs:h=[],workflow:z={}}=P,U=z,{nodes:x=[],revisions:y=[]}=U,m=Z(U,["nodes","revisions"]),k=Z(P,["jobs","workflow"]);xt(x),rn(x,h);const T=x.find(F=>!F.upstream),$=Ue[k.status];return r.jsxs(Me.Provider,{value:{workflow:m.type?m:null,nodes:x,execution:k,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(g.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:d.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:r.jsx(g.Tooltip,{title:`Key: ${m.key}`,children:r.jsx(oe.Link,{to:ve(m.id),children:m.title})})},{title:r.jsx(ln,{})}]})}),r.jsxs("aside",{children:[r.jsx(g.Tag,{color:$.color,children:t($.label)}),k.status?null:r.jsx(g.Tooltip,{title:N("Cancel the execution"),children:r.jsx(g.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r.jsx(D.StopOutlined,{})})}),r.jsx("time",{children:H.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(zt,{entry:T}),r.jsx(sn,{})]})}const Ht=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:an}})})},Jt=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(oe.Link,{to:Ye(t),onClick:()=>o(!1),children:e("View")})},cn={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"x-component"({value:e}){const{setVisible:t}=i.useActionContext();return r.jsx(oe.Link,{to:ve(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:Je}}]},Ut={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:cn,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=Q.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return G(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.filter}),g.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"}}}}}}}}}}};function Gt(e){var a;const o=i.useCompile()(e.label),n=b.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=Ue[e.value])!=null?a:{};return r.jsx(g.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function un(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Gt,C({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function dn(t){var e=Z(t,[]);const o=e.multiple?"multiple":null;return r.jsx(g.Select,O(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Gt,children:Je.filter(n=>!!n.value&&n.value!==de.ABORTED).map(n=>r.jsx(g.Select.Option,O(C({},n),{children:r.jsx(un,C({},n))}),n.value))}))}function qt(e){const{t}=Q.useTranslation(),{refresh:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),s=i.useRecord(),a=b.useCallback(()=>{g.Modal.confirm({title:N("Cancel the execution"),icon:r.jsx(D.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:s.id}).then(()=>{g.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[s]);return r.jsxs("div",{className:i.css`
452
+ `),children:r.jsx(Ke,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:N("End")})]})})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:s})})]})}function kt(e){const t=new Map;e.forEach(o=>t.set(o.id,o));for(const o of t.values())o.upstreamId&&(o.upstream=t.get(o.upstreamId)),o.downstreamId&&(o.downstream=t.get(o.downstreamId))}function St(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{St(e.properties[o],t)})}function xe(e){return`/admin/workflow/workflows/${e}`}function _e(e){return`/admin/workflow/executions/${e}`}function un(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function dn(){const{instructions:e}=i.usePlugin(ue),t=i.useCompile(),{viewJob:o,setViewJob:n}=q(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},l=e.get(a.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.nodeTitleClass,children:[r.jsx(b.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:bt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function pn(e){const{execution:t}=q(),o=i.useAPIClient(),n=oe.useNavigate(),{styles:s}=ne(),[a,l]=g.useState([]),[c,d]=g.useState([]);g.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{l(f.data)}).catch(()=>{})},[t]),g.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{d(f.data.reverse())}).catch(()=>{})},[t]);const u=g.useCallback(({key:f})=>{f!=t.id&&n(_e(f))},[t]);return t?r.jsx(b.Dropdown,{menu:{onClick:u,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:U.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Ie,{statusMap:qe,status:f.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx($.DownOutlined,{})]})}):null}function mn(){var S;const{t:e}=Z.useTranslation(),t=i.useCompile(),{data:o,loading:n,refresh:s}=i.useResourceActionContext(),{setTitle:a}=i.useDocumentTitle(),[l,c]=g.useState(null),d=i.useApp(),u=i.useAPIClient();g.useEffect(()=>{var I;const{workflow:T}=(I=o==null?void 0:o.data)!=null?I:{};a==null||a(`${T!=null&&T.title?`${T.title} - `:""}${N("Execution history")}`)},[o==null?void 0:o.data]);const f=g.useCallback(()=>{b.Modal.confirm({title:N("Cancel the execution"),icon:r.jsx($.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{u.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{b.message.success(e("Operation succeeded")),s()}).catch(T=>{console.error(T.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const M=(S=o==null?void 0:o.data)!=null?S:{},{jobs:h=[],workflow:W={}}=M,J=W,{nodes:x=[],revisions:y=[]}=J,m=X(J,["nodes","revisions"]),k=X(M,["jobs","workflow"]);kt(x),un(x,h);const F=x.find(T=>!T.upstream),E=qe[k.status];return r.jsxs(Me.Provider,{value:{workflow:m.type?m:null,nodes:x,execution:k,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:d.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:r.jsx(b.Tooltip,{title:`Key: ${m.key}`,children:r.jsx(oe.Link,{to:xe(m.id),children:m.title})})},{title:r.jsx(pn,{})}]})}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:E.color,children:t(E.label)}),k.status?null:r.jsx(b.Tooltip,{title:N("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r.jsx($.StopOutlined,{})})}),r.jsx("time",{children:U.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Ht,{entry:F}),r.jsx(dn,{})]})}const Gt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:mn}})})},qt=()=>{const{t:e}=Z.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(oe.Link,{to:_e(t),onClick:()=>o(!1),children:e("View")})},fn={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"x-component"({value:e}){const{setVisible:t}=i.useActionContext();return r.jsx(oe.Link,{to:xe(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:Ge}}]},Yt={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:fn,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=Z.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return G(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.filter}),b.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"}}}}}}}}}}};function Kt(e){var a;const o=i.useCompile()(e.label),n=g.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=qe[e.value])!=null?a:{};return r.jsx(b.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function hn(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Kt,C({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function yn(t){var e=X(t,[]);const o=e.multiple?"multiple":null;return r.jsx(b.Select,O(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Kt,children:Ge.filter(n=>!!n.value&&n.value!==pe.ABORTED).map(n=>r.jsx(b.Select.Option,O(C({},n),{children:r.jsx(hn,C({},n))}),n.value))}))}function _t(e){const{t}=Z.useTranslation(),{refresh:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),s=i.useRecord(),a=g.useCallback(()=>{b.Modal.confirm({title:N("Cancel the execution"),icon:r.jsx($.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:s.id}).then(()=>{b.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[s]);return r.jsxs("div",{className:i.css`
453
453
  display: flex;
454
- `,children:[e.children,s.status?null:r.jsx(g.Tooltip,{title:N("Cancel the execution"),children:r.jsx(g.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx(D.StopOutlined,{})})})]})}function Yt(){const e=i.useResourceActionContext();return{onClick(){return G(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function pn(n){var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const{workflow:a}=Y(),l=O(C({},o),{request:O(C({},e),{params:O(C({},e==null?void 0:e.params),{filter:O(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))}function mn(){var F;const e=oe.useNavigate(),{t}=Q.useTranslation(),o=i.useApp(),{data:n,refresh:s,loading:a}=i.useResourceActionContext(),{resource:l}=i.useResourceContext(),{setTitle:c}=i.useDocumentTitle(),[d,u]=b.useState(!1),{styles:f}=ne(),{modal:h}=g.App.useApp();if(b.useEffect(()=>{var I;const{title:S}=(I=n==null?void 0:n.data)!=null?I:{};c==null||c(`${N("Workflow")}${S?`: ${S}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(g.Spin,{}):r.jsx(g.Result,{status:"404",title:"Not found",extra:r.jsx(g.Button,{onClick:()=>e(-1),children:N("Go back")})});const M=(F=n==null?void 0:n.data)!=null?F:{},{nodes:x=[],revisions:y=[]}=M,m=Z(M,["nodes","revisions"]);xt(x);const k=x.find(S=>!S.upstream);function T({key:S}){S!=m.id&&e(ve(S))}function $(S){return G(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:S}}),s()})}function A(){return G(this,null,function*(){const{data:{data:S}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});g.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${S.id}`)})}function P(){return G(this,null,function*(){const S=m.current?N("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:t("Are you sure you want to delete it?"),content:S,onOk(){return G(this,null,function*(){var L;yield l.destroy({filterByTk:m.id}),g.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):ve((L=y.find(J=>J.current))==null?void 0:L.id))})}})})}function z(I){return G(this,arguments,function*({key:S}){switch(S){case"history":u(!0);return;case"revision":return A();case"delete":return P()}})}const U=m.executed&&!y.find(S=>!S.executed&&new Date(S.createdAt)>new Date(m.createdAt));return r.jsxs(Me.Provider,{value:{workflow:m,nodes:x,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(g.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:r.jsx(g.Tooltip,{title:`Key: ${m.key}`,children:r.jsx("strong",{children:m.title})})}]})}),r.jsxs("aside",{children:[r.jsx(g.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:T,defaultSelectedKeys:[`${m.id}`],className:i.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:y.sort((S,I)=>I.id-S.id).map((S,I)=>({role:"button","aria-label":`version-${I}`,key:`${S.id}`,icon:S.current?r.jsx(D.RightOutlined,{}):null,className:i.cx({executed:S.executed,unexecuted:!S.executed,enabled:S.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${S.id}`}),r.jsx("time",{children:H.str2moment(S.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(g.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:N("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(D.DownOutlined,{})]})}),r.jsx(g.Switch,{checked:m.enabled,onChange:$,checkedChildren:N("On"),unCheckedChildren:N("Off")}),r.jsx(g.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:N("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:N("Copy to new version"),disabled:!U},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:z},children:r.jsx(g.Button,{"aria-label":"more",type:"text",icon:r.jsx(D.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:d,setVisible:u},children:r.jsx(i.SchemaComponent,{schema:Ut,components:{ExecutionResourceProvider:pn,ExecutionLink:Jt,ExecutionStatusColumn:qt},scope:{useRefreshActionProps:Yt}})})]})]}),r.jsx(zt,{entry:k})]})}const Kt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:mn}})})},fn=n=>{var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const a=i.useRecord(),l=O(C({},o),{request:O(C({},e),{params:O(C({},e==null?void 0:e.params),{filter:O(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))},hn=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:n}=i.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:ve(t),onClick:()=>o(!1),children:e("Configure")})};function yn(n){var s=n,{component:e="div",children:t}=s,o=Z(s,["component","children"]);const[a,l]=b.useState(!1),c=j.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[b.createElement(e,O(C({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function gn({data:e}){const{label:t,color:o,options:n}=e,s=i.useCompile();return r.jsxs(g.Space,{direction:"vertical",children:[r.jsx(g.Tag,{color:o,children:s(t)}),r.jsx(g.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(n.description)})]})}const _t={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}",optionRender:gn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},pe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},bn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:_t,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:_t},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${p}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${p}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=Q.useTranslation(),{resource:t}=i.useResourceContext(),o=i.useResourceActionContext();return{run(){return G(this,null,function*(){yield t.sync(),yield o==null?void 0:o.refresh(),g.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:pe.title,type:pe.type,sync:pe.sync,description:pe.description,options:pe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=i.useRecord();return b.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Ut}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:pe.title,enabled:pe.enabled,sync:pe.sync,description:pe.description,options:pe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=Q.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=j.useForm();return{run(){return G(this,null,function*(){yield o.revision({filterByTk:a,values:l}),g.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function vn(e){const t=j.useField(),o=i.useRecord(),n=i.usePlugin(ce);return j.useFormEffects(s=>{ye.onFieldChange("type",a=>{let l=o.id||!a.value;if(a.value){const c=n.triggers.get(a.value);c.sync!=null?(l=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(l?"disabled":"editable")})}),b.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Te,C({},e))}function xn(e){const t=i.useApp();e.visible=!!(i.usePlugin("multi-app-share-collection")||t.name!=="main")}function wn(){const e=b.useContext(i.SchemaComponentContext),{getTriggersOptions:t}=i.usePlugin(ce);return r.jsx(g.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:O(C({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:bn,components:{WorkflowLink:hn,ExecutionResourceProvider:fn,ExecutionLink:Jt,OpenDrawer:yn,ExecutionStatusSelect:dn,SyncOptionSelect:vn,ExecutionStatusColumn:qt,Tooltip:g.Tooltip},scope:{getTriggersOptions:t,useWorkflowSyncAction:xn,useRefreshActionProps:Yt}})})})}function Cn(n){var s=n,{collection:e,dataPath:t}=s,o=Z(s,["collection","dataPath"]);const{insert:a}=i.useSchemaInitializer(),{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager_deprecated(),d=i.useRecordCollectionDataSourceItems("FormItem");let u;if(typeof e=="string"){const[h,x]=i.parseCollectionName(e);u=c(x,h)}else u=e;function f(x){return G(this,arguments,function*({item:h}){const y=h.template?yield l(h):null,m={type:"void",name:$t.uid(),title:u.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:y||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};wt(m,k=>{k["x-uid"]&&delete k["x-uid"]}),a(m)})}return r.jsx(i.SchemaInitializerItem,O(C({},o),{onClick:f,items:d}))}function Pe(e){var a;const t=i.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,s;if(typeof o=="string"){const l=i.parseCollectionName(o);n=l[0],s=l[1]}else s=o;return r.jsx(i.CollectionProvider_deprecated,{dataSource:n,collection:s,children:r.jsx(Cn,C(C({},t),e))})}function kn(){return!0}const Ct=j.observer(e=>{const u=e,{filter:t=kn}=u,o=Z(u,["filter"]),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager_deprecated(),{values:a}=j.useForm(),[l,c]=i.parseCollectionName(a==null?void 0:a.collection),d=s(c,l);return r.jsx(g.Select,O(C({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(f=>{var h;return{label:n((h=f.uiSchema)==null?void 0:h.title),value:f.name}})}))},{displayName:"FieldsSelect"}),le={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},Zt={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:i.css`
454
+ `,children:[e.children,s.status?null:r.jsx(b.Tooltip,{title:N("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx($.StopOutlined,{})})})]})}function Zt(){const e=i.useResourceActionContext();return{onClick(){return G(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function gn(n){var s=n,{request:e,filter:t={}}=s,o=X(s,["request","filter"]);var c;const{workflow:a}=q(),l=O(C({},o),{request:O(C({},e),{params:O(C({},e==null?void 0:e.params),{filter:O(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))}function bn(){var T;const e=oe.useNavigate(),{t}=Z.useTranslation(),o=i.useApp(),{data:n,refresh:s,loading:a}=i.useResourceActionContext(),{resource:l}=i.useResourceContext(),{setTitle:c}=i.useDocumentTitle(),[d,u]=g.useState(!1),{styles:f}=ne(),{modal:h}=b.App.useApp();if(g.useEffect(()=>{var P;const{title:A}=(P=n==null?void 0:n.data)!=null?P:{};c==null||c(`${N("Workflow")}${A?`: ${A}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found",extra:r.jsx(b.Button,{onClick:()=>e(-1),children:N("Go back")})});const I=(T=n==null?void 0:n.data)!=null?T:{},{nodes:x=[],revisions:y=[]}=I,m=X(I,["nodes","revisions"]);kt(x);const k=x.find(A=>!A.upstream);function F({key:A}){A!=m.id&&e(xe(A))}function E(A){return G(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:A}}),s()})}function S(){return G(this,null,function*(){const{data:{data:A}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});b.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${A.id}`)})}function M(){return G(this,null,function*(){const A=m.current?N("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:t("Are you sure you want to delete it?"),content:A,onOk(){return G(this,null,function*(){var z;yield l.destroy({filterByTk:m.id}),b.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):xe((z=y.find(H=>H.current))==null?void 0:z.id))})}})})}function W(P){return G(this,arguments,function*({key:A}){switch(A){case"history":u(!0);return;case"revision":return S();case"delete":return M()}})}const J=m.executed&&!y.find(A=>!A.executed&&new Date(A.createdAt)>new Date(m.createdAt));return r.jsxs(Me.Provider,{value:{workflow:m,nodes:x,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:r.jsx(b.Tooltip,{title:`Key: ${m.key}`,children:r.jsx("strong",{children:m.title})})}]})}),r.jsxs("aside",{children:[r.jsx(b.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${m.id}`],className:i.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:y.sort((A,P)=>P.id-A.id).map((A,P)=>({role:"button","aria-label":`version-${P}`,key:`${A.id}`,icon:A.current?r.jsx($.RightOutlined,{}):null,className:i.cx({executed:A.executed,unexecuted:!A.executed,enabled:A.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${A.id}`}),r.jsx("time",{children:U.str2moment(A.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:N("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx($.DownOutlined,{})]})}),r.jsx(b.Switch,{checked:m.enabled,onChange:E,checkedChildren:N("On"),unCheckedChildren:N("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:N("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:N("Copy to new version"),disabled:!J},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:W},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx($.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:d,setVisible:u},children:r.jsx(i.SchemaComponent,{schema:Yt,components:{ExecutionResourceProvider:gn,ExecutionLink:qt,ExecutionStatusColumn:_t},scope:{useRefreshActionProps:Zt}})})]})]}),r.jsx(Ht,{entry:k})]})}const Qt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:bn}})})},vn=n=>{var s=n,{request:e,filter:t={}}=s,o=X(s,["request","filter"]);var c;const a=i.useRecord(),l=O(C({},o),{request:O(C({},e),{params:O(C({},e==null?void 0:e.params),{filter:O(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))},xn=()=>{const{t:e}=Z.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:n}=i.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:xe(t),onClick:()=>o(!1),children:e("Configure")})};function wn(n){var s=n,{component:e="div",children:t}=s,o=X(s,["component","children"]);const[a,l]=g.useState(!1),c=j.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[g.createElement(e,O(C({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Cn({data:e}){const{label:t,color:o,options:n}=e,s=i.useCompile();return r.jsxs(b.Space,{direction:"vertical",children:[r.jsx(b.Tag,{color:o,children:s(t)}),r.jsx(b.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(n.description)})]})}const Xt={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}",optionRender:Cn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},fe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},kn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Xt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:Xt},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${p}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${p}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=Z.useTranslation(),{resource:t}=i.useResourceContext(),o=i.useResourceActionContext();return{run(){return G(this,null,function*(){yield t.sync(),yield o==null?void 0:o.refresh(),b.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:fe.title,type:fe.type,sync:fe.sync,description:fe.description,options:fe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=i.useRecord();return g.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Yt}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:fe.title,enabled:fe.enabled,sync:fe.sync,description:fe.description,options:fe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=Z.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=j.useForm();return{run(){return G(this,null,function*(){yield o.revision({filterByTk:a,values:l}),b.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Sn(e){const t=j.useField(),o=i.useRecord(),n=i.usePlugin(ue);return j.useFormEffects(s=>{ie.onFieldChange("type",a=>{let l=o.id||!a.value;if(a.value){const c=n.triggers.get(a.value);c.sync!=null?(l=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(l?"disabled":"editable")})}),g.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Te,C({},e))}function An(e){const t=i.useApp();e.visible=!!(i.usePlugin("multi-app-share-collection")||t.name!=="main")}function On(){const e=g.useContext(i.SchemaComponentContext),{getTriggersOptions:t}=i.usePlugin(ue);return r.jsx(b.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:O(C({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:kn,components:{WorkflowLink:xn,ExecutionResourceProvider:vn,ExecutionLink:qt,OpenDrawer:wn,ExecutionStatusSelect:yn,SyncOptionSelect:Sn,ExecutionStatusColumn:_t,Tooltip:b.Tooltip},scope:{getTriggersOptions:t,useWorkflowSyncAction:An,useRefreshActionProps:Zt}})})})}function Fn(n){var s=n,{collection:e,dataPath:t}=s,o=X(s,["collection","dataPath"]);const{insert:a}=i.useSchemaInitializer(),{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager_deprecated(),d=i.useRecordCollectionDataSourceItems("FormItem");let u;if(typeof e=="string"){const[h,x]=i.parseCollectionName(e);u=c(x,h)}else u=e;function f(x){return G(this,arguments,function*({item:h}){const y=h.template?yield l(h):null,m={type:"void",name:He.uid(),title:u.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:y||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};St(m,k=>{k["x-uid"]&&delete k["x-uid"]}),a(m)})}return r.jsx(i.SchemaInitializerItem,O(C({},o),{onClick:f,items:d}))}function Be(e){var a;const t=i.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,s;if(typeof o=="string"){const l=i.parseCollectionName(o);n=l[0],s=l[1]}else s=o;return r.jsx(i.CollectionProvider_deprecated,{dataSource:n,collection:s,children:r.jsx(Fn,C(C({},t),e))})}function Tn(){return!0}const At=j.observer(e=>{const u=e,{filter:t=Tn}=u,o=X(u,["filter"]),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager_deprecated(),{values:a}=j.useForm(),[l,c]=i.parseCollectionName(a==null?void 0:a.collection),d=s(c,l);return r.jsx(b.Select,O(C({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(f=>{var h;return{label:n((h=f.uiSchema)==null?void 0:h.title),value:f.name}})}))},{displayName:"FieldsSelect"}),ae={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},Rt={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:i.css`
455
455
  flex-direction: column;
456
- `},"x-component":"CollectionFieldset"},Ke={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=j.useForm(),[t,o]=i.parseCollectionName(e==null?void 0:e.collection);return{options:i.useCollectionFilterOptions(o,t),className:i.css`
456
+ `},"x-component":"CollectionFieldset"},Ze={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=j.useForm(),[t,o]=i.parseCollectionName(e==null?void 0:e.collection);return{options:i.useCollectionFilterOptions(o,t),className:i.css`
457
457
  position: relative;
458
458
  width: 100%;
459
- `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Sn={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},An={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},Be={type:"array",title:`{{t("Preload associations", { ns: "${p}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=j.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},ke={label:"label",value:"value",children:"children"},Qt={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=i.usePlugin(ce),o=Ce(),n=Bt(o),s=[];return n.forEach(a=>{var d;const l=t.get(a.type),c=(d=l.useVariables)==null?void 0:d.call(l,a,e);c&&s.push(c)}),s}},Xt={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,a;const{triggers:t}=i.usePlugin(ce),{workflow:o}=Y(),n=t.get(o.type);return(a=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?a:null}},Rt={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ke,current:o}=e,{instructions:n}=i.usePlugin(ce),s=Ce(),a=o!=null?o:s,l=Vt(a),c=[];return l.forEach(d=>{var h,x;const u=n.get(d.type),f=(h=u.useScopeVariables)==null?void 0:h.call(u,d,e);f&&c.push({key:d.key,[t.value]:d.key,[t.label]:(x=d.title)!=null?x:`#${d.id}`,[t.children]:f})}),c}},eo={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ke}){return[...!e||e.includes("date")?[{key:"now",[t.label]:N("System time"),[t.value]:"now"}]:[]]}},_e={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function to(e,t){var o,n,s,a,l,c;return typeof t=="string"?(o=_e[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?kt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function kt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function St(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function At({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>to(l,d)):!0;if(kt(l)){if(o===null)return n?c||At({fields:Ot(l.target,{compile:s,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:a}):!1;const d=St(l,o),u=o.includes(l.name);return c?u:((d==null?void 0:d.length)||u)&&At({fields:Ot(l.target,{compile:s,getCollectionFields:a}),types:t,appends:d,compile:s,getCollectionFields:a}).length}else return c})}function Ze(e,t){var a,l;const o=i.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:n,disabled:!n||!n.length}}function me(e={}){var s;const t=Object.assign({},ke,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[Ze(Rt,o),Ze(Qt,o),Ze(Xt,o),Ze(eo,o)]}function Ot(e,{compile:t,getCollectionFields:o}){var u,f,h,x;const[n,s]=i.parseCollectionName(e),a=o(s,n);console.log("--------------",a);const l=[],c=[];a.forEach(y=>{if(y.isForeignKey)l.push(y);else{const m=a.find(k=>k.name===y.foreignKey);m&&l.push(m),c.push(y)}});const d=De.uniqBy(l,"name");for(let y=c.length-1;y>=0;y--){const m=c[y];if(m.type==="belongsTo"){const k=d.find(T=>T.name===m.foreignKey);k?c.splice(y,0,O(C(C({},m),k),{uiSchema:O(C({},m.uiSchema),{title:(u=k.uiSchema)!=null&&u.title?t((f=k.uiSchema)==null?void 0:f.title):k.name})})):c.splice(y,0,O(C({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:O(C({},m.uiSchema),{title:(h=m.uiSchema)!=null&&h.title?`${t((x=m.uiSchema)==null?void 0:x.title)} ID`:m.name})}))}else m.type==="context"&&m.collectionName==="users"&&c.splice(y,1)}return De.uniqBy(c,"name").filter(y=>y.interface&&!y.hidden)}function On(e){const t=St(e.field,e.appends),o=Se(C({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(s=>to(e.field,s))||(e.disabled=!0))}function Se(e){const{fields:t,collection:o,types:n,appends:s=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:d=ke}=e,u=t!=null?t:Ot(o,{compile:l,getCollectionFields:c}),f=On.bind({compile:l,getCollectionFields:c,fieldNames:d});return At({fields:u,types:n,depth:a,appends:s,compile:l,getCollectionFields:c}).map(x=>{var T;const y=l(((T=x.uiSchema)==null?void 0:T.title)||x.name),m=St(x,s),k=!kt(x)||m&&!m.length&&!s.includes(x.name)||!1;return{[d.label]:y,key:x.name,[d.value]:x.name,isLeaf:k,loadChildren:k?null:f,field:x,depth:a,appends:s,types:n}})}function Ve(e){const t=i.useApp(),{collectionManager:o}=t.dataSourceManager.getDataSource(e);return b.useCallback(n=>o.getCollectionFields(n),[o])}function oo(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.Input,C({scope:s},t))}function Tt(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.TextArea,C({scope:s},t))}function Tn(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.RawTextArea,C({scope:s},t))}function Fn(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.JSON,C({scope:s},t))}function Nn(){const e=i.useAPIClient(),t=j.useForm(),{field:o,__parent:n}=i.useBlockRequestContext(),{setVisible:s}=i.useActionContext(),a=oe.useNavigate(),l=j.useFieldSchema(),c=j.useField(),d=i.useCompile(),{modal:u}=g.App.useApp(),f=i.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return G(this,null,function*(){var $,A,P;const{onSuccess:y,skipValidator:m,triggerWorkflows:k}=($=l==null?void 0:l["x-action-settings"])!=null?$:{};m||(yield t.submit());const T=yield f();c.data=o.data||{},c.data.loading=!0;try{const z=yield e.resource("workflows").trigger({values:T,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map(U=>[U.workflowKey,U.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=z,(P=(A=n==null?void 0:n.service)==null?void 0:A.refresh)==null||P.call(A),s==null||s(!1),!(y!=null&&y.successMessage))return;y!=null&&y.manualClose?u.success({title:d(y==null?void 0:y.successMessage),onOk:()=>G(this,null,function*(){yield t.reset(),y!=null&&y.redirecting&&(y!=null&&y.redirectTo)&&(H.isURL(y.redirectTo)?window.location.href=y.redirectTo:a(y.redirectTo))})}):g.message.success(d(y==null?void 0:y.successMessage))}catch(z){c.data.loading=!1}})}}}function En(){var y;const e=i.useCompile(),t=i.useAPIClient(),o=i.useRecord(),n=j.useField(),s=j.useFieldSchema(),{field:a,__parent:l}=i.useBlockRequestContext(),{setVisible:c,setSubmitted:d}=i.useActionContext(),{modal:u}=g.App.useApp(),f=oe.useNavigate(),{onSuccess:h,triggerWorkflows:x}=(y=s==null?void 0:s["x-action-settings"])!=null?y:{};return{onClick(k,T){return G(this,null,function*(){n.data=a.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:x!=null&&x.length?x.map($=>[$.workflowKey,$.context].filter(Boolean).join("!")).join(","):void 0}),T&&T(),c==null||c(!1),d==null||d(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let $;u.success({title:e(h==null?void 0:h.successMessage),onOk(){return G(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(H.isURL(h.redirectTo)?window.location.href=h.redirectTo:f(h.redirectTo))})}})}else g.message.success(e(h==null?void 0:h.successMessage))}catch($){console.error($)}finally{n.data.loading=!1}})}}}function Dn(){const{workflow:e}=Y();return!!(e!=null&&e.executed)}function no(){const{workflow:e}=Y();return!!(e!=null&&e.allExecuted)}const Ae={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},$n=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Ae.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Ae.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Ae.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Ae.DELETED}];function Mn(e,t){var d;const[o,n]=i.parseCollectionName(e.collection),s=i.useCompile(),a=Ve(o),l=[{collectionName:n,name:"data",type:"hasOne",target:n,uiSchema:{title:N("Trigger data")}}];return Se(O(C({appends:["data",...((d=e.appends)==null?void 0:d.map(u=>`data.${u}`))||[]]},t),{fields:l,compile:s,getCollectionFields:a}))}class In extends bt{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${p}" })}}`);w(this,"description",`{{t('Triggered when data changes in the collection, such as after adding, updating, or deleting a record. Unlike "Post-action event", Collection event listens for data changes rather than HTTP requests. Unless you understand the exact meaning, it is recommended to use "Post-action event".', { ns: "${p}" })}}`);w(this,"fieldset",{collection:O(C({},le),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...le["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:$n,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${p}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ae.UPDATED})}}`}}}]},condition:O(C({},Ke),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:O(C({},Be),{"x-reactions":[...Be["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ae.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useWorkflowAnyExecuted:no});w(this,"components",{FieldsSelect:Ct});w(this,"useVariables",Mn)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Pe,collection:o.collection,dataPath:"$context.data"}:null}}const xe={STATIC:0,DATE_FIELD:1};function Pn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function ro({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=Q.useTranslation(),[s,a]=b.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:i.css`
459
+ `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Nn={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},En={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},Ve={type:"array",title:`{{t("Preload associations", { ns: "${p}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=j.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Se={label:"label",value:"value",children:"children"},eo={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=i.usePlugin(ue),o=ve(),n=Wt(o),s=[];return n.forEach(a=>{var d;const l=t.get(a.type),c=(d=l.useVariables)==null?void 0:d.call(l,a,e);c&&s.push(c)}),s}},to={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,a;const{triggers:t}=i.usePlugin(ue),{workflow:o}=q(),n=t.get(o.type);return(a=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?a:null}},oo={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Se,current:o}=e,{instructions:n}=i.usePlugin(ue),s=ve(),a=o!=null?o:s,l=Lt(a),c=[];return l.forEach(d=>{var h,x;const u=n.get(d.type),f=(h=u.useScopeVariables)==null?void 0:h.call(u,d,e);f&&c.push({key:d.key,[t.value]:d.key,[t.label]:(x=d.title)!=null?x:`#${d.id}`,[t.children]:f})}),c}},no={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=Se}){return[...!e||e.includes("date")?[{key:"now",[t.label]:N("System time"),[t.value]:"now"}]:[]]}},Qe={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function ro(e,t){var o,n,s,a,l,c;return typeof t=="string"?(o=Qe[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?Ot(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function Ot(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Ft(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function Tt({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>ro(l,d)):!0;if(Ot(l)){if(o===null)return n?c||Tt({fields:Nt(l.target,{compile:s,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:a}):!1;const d=Ft(l,o),u=o.includes(l.name);return c?u:((d==null?void 0:d.length)||u)&&Tt({fields:Nt(l.target,{compile:s,getCollectionFields:a}),types:t,appends:d,compile:s,getCollectionFields:a}).length}else return c})}function Xe(e,t){var a,l;const o=i.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:n,disabled:!n||!n.length}}function me(e={}){var s;const t=Object.assign({},Se,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[Xe(oo,o),Xe(eo,o),Xe(to,o),Xe(no,o)]}function Nt(e,{compile:t,getCollectionFields:o}){var u,f,h,x;const[n,s]=i.parseCollectionName(e),a=o(s,n);console.log("--------------",a);const l=[],c=[];a.forEach(y=>{if(y.isForeignKey)l.push(y);else{const m=a.find(k=>k.name===y.foreignKey);m&&l.push(m),c.push(y)}});const d=ke.uniqBy(l,"name");for(let y=c.length-1;y>=0;y--){const m=c[y];if(m.type==="belongsTo"){const k=d.find(F=>F.name===m.foreignKey);k?c.splice(y,0,O(C(C({},m),k),{uiSchema:O(C({},m.uiSchema),{title:(u=k.uiSchema)!=null&&u.title?t((f=k.uiSchema)==null?void 0:f.title):k.name})})):c.splice(y,0,O(C({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:O(C({},m.uiSchema),{title:(h=m.uiSchema)!=null&&h.title?`${t((x=m.uiSchema)==null?void 0:x.title)} ID`:m.name})}))}else m.type==="context"&&m.collectionName==="users"&&c.splice(y,1)}return ke.uniqBy(c,"name").filter(y=>y.interface&&!y.hidden)}function Dn(e){const t=Ft(e.field,e.appends),o=Ae(C({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(s=>ro(e.field,s))||(e.disabled=!0))}function Ae(e){const{fields:t,collection:o,types:n,appends:s=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:d=Se}=e,u=t!=null?t:Nt(o,{compile:l,getCollectionFields:c}),f=Dn.bind({compile:l,getCollectionFields:c,fieldNames:d});return Tt({fields:u,types:n,depth:a,appends:s,compile:l,getCollectionFields:c}).map(x=>{var F;const y=l(((F=x.uiSchema)==null?void 0:F.title)||x.name),m=Ft(x,s),k=!Ot(x)||m&&!m.length&&!s.includes(x.name)||!1;return{[d.label]:y,key:x.name,[d.value]:x.name,isLeaf:k,loadChildren:k?null:f,field:x,depth:a,appends:s,types:n}})}function je(e){const t=i.useApp(),{collectionManager:o}=t.dataSourceManager.getDataSource(e);return g.useCallback(n=>o.getCollectionFields(n),[o])}function so(o){var n=o,{variableOptions:e}=n,t=X(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.Input,C({scope:s},t))}function Et(o){var n=o,{variableOptions:e}=n,t=X(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.TextArea,C({scope:s},t))}function $n(o){var n=o,{variableOptions:e}=n,t=X(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.RawTextArea,C({scope:s},t))}function Mn(o){var n=o,{variableOptions:e}=n,t=X(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.JSON,C({scope:s},t))}function In(){const e=i.useAPIClient(),t=j.useForm(),{field:o,__parent:n}=i.useBlockRequestContext(),{setVisible:s}=i.useActionContext(),a=oe.useNavigate(),l=j.useFieldSchema(),c=j.useField(),d=i.useCompile(),{modal:u}=b.App.useApp(),f=i.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return G(this,null,function*(){var E,S,M;const{onSuccess:y,skipValidator:m,triggerWorkflows:k}=(E=l==null?void 0:l["x-action-settings"])!=null?E:{};m||(yield t.submit());const F=yield f();c.data=o.data||{},c.data.loading=!0;try{const W=yield e.resource("workflows").trigger({values:F,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map(J=>[J.workflowKey,J.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=W,(M=(S=n==null?void 0:n.service)==null?void 0:S.refresh)==null||M.call(S),s==null||s(!1),!(y!=null&&y.successMessage))return;y!=null&&y.manualClose?u.success({title:d(y==null?void 0:y.successMessage),onOk:()=>G(this,null,function*(){yield t.reset(),y!=null&&y.redirecting&&(y!=null&&y.redirectTo)&&(U.isURL(y.redirectTo)?window.location.href=y.redirectTo:a(y.redirectTo))})}):b.message.success(d(y==null?void 0:y.successMessage))}catch(W){c.data.loading=!1}})}}}function Pn(){var y;const e=i.useCompile(),t=i.useAPIClient(),o=i.useRecord(),n=j.useField(),s=j.useFieldSchema(),{field:a,__parent:l}=i.useBlockRequestContext(),{setVisible:c,setSubmitted:d}=i.useActionContext(),{modal:u}=b.App.useApp(),f=oe.useNavigate(),{onSuccess:h,triggerWorkflows:x}=(y=s==null?void 0:s["x-action-settings"])!=null?y:{};return{onClick(k,F){return G(this,null,function*(){n.data=a.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:x!=null&&x.length?x.map(E=>[E.workflowKey,E.context].filter(Boolean).join("!")).join(","):void 0}),F&&F(),c==null||c(!1),d==null||d(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let E;u.success({title:e(h==null?void 0:h.successMessage),onOk(){return G(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(U.isURL(h.redirectTo)?window.location.href=h.redirectTo:f(h.redirectTo))})}})}else b.message.success(e(h==null?void 0:h.successMessage))}catch(E){console.error(E)}finally{n.data.loading=!1}})}}}function Bn(){const{workflow:e}=q();return!!(e!=null&&e.executed)}function io(){const{workflow:e}=q();return!!(e!=null&&e.allExecuted)}const Oe={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Vn=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Oe.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Oe.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Oe.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Oe.DELETED}];function jn(e,t){var d;const[o,n]=i.parseCollectionName(e.collection),s=i.useCompile(),a=je(o),l=[{collectionName:n,name:"data",type:"hasOne",target:n,uiSchema:{title:N("Trigger data")}}];return Ae(O(C({appends:["data",...((d=e.appends)==null?void 0:d.map(u=>`data.${u}`))||[]]},t),{fields:l,compile:s,getCollectionFields:a}))}class Wn extends wt{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${p}" })}}`);w(this,"description",`{{t('Triggered when data changes in the collection, such as after adding, updating, or deleting a record. Unlike "Post-action event", Collection event listens for data changes rather than HTTP requests. Unless you understand the exact meaning, it is recommended to use "Post-action event".', { ns: "${p}" })}}`);w(this,"fieldset",{collection:O(C({},ae),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...ae["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:Vn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${p}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Oe.UPDATED})}}`}}}]},condition:O(C({},Ze),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:O(C({},Ve),{"x-reactions":[...Ve["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Oe.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useWorkflowAnyExecuted:io});w(this,"components",{FieldsSelect:At});w(this,"useVariables",jn)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Be,collection:o.collection,dataPath:"$context.data"}:null}}const we={STATIC:0,DATE_FIELD:1};function Ln(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function lo({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=Z.useTranslation(),[s,a]=g.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:i.css`
460
460
  display: flex;
461
461
  gap: 0.5em;
462
- `,children:[r.jsx(Ct,{value:o.field,onChange:l=>t(O(C({},o),{field:l})),filter:Pn,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(g.Select,{value:s,onChange:l=>{a(l),t(O(C({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:N("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,s?r.jsxs(r.Fragment,{children:[r.jsx(g.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(O(C({},o),{offset:(l!=null?l:0)*s}))}),r.jsx(g.Select,{value:o.unit||864e5,onChange:l=>t(O(C({},o),{unit:l})),options:[{value:864e5,label:N("Days")},{value:36e5,label:N("Hours")},{value:6e4,label:N("Minutes")},{value:1e3,label:N("Seconds")}],className:"auto-width"})]}):null]})}function Bn({value:e,onChange:t}){const{t:o}=mt(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:i.css`
462
+ `,children:[r.jsx(At,{value:o.field,onChange:l=>t(O(C({},o),{field:l})),filter:Ln,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(b.Select,{value:s,onChange:l=>{a(l),t(O(C({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:N("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,s?r.jsxs(r.Fragment,{children:[r.jsx(b.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(O(C({},o),{offset:(l!=null?l:0)*s}))}),r.jsx(b.Select,{value:o.unit||864e5,onChange:l=>t(O(C({},o),{unit:l})),options:[{value:864e5,label:N("Days")},{value:36e5,label:N("Hours")},{value:6e4,label:N("Minutes")},{value:1e3,label:N("Seconds")}],className:"auto-width"})]}):null]})}function zn({value:e,onChange:t}){const{t:o}=yt(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:i.css`
463
463
  display: flex;
464
464
  gap: 0.5em;
465
- `,children:[r.jsxs(g.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(g.Select.Option,{value:null,children:o("No end")}),r.jsx(g.Select.Option,{value:"field",children:o("By field")}),r.jsx(g.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(ro,{value:e,onChange:t}):null,n==="date"?r.jsx(g.DatePicker,{showTime:!0,value:Ho(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},re.apply(this,arguments)};function so(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function Qe(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var Vn=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],we=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],B={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function io(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Xe(e){return e.sort(function(t,o){return t-o}),e}function lo(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ae(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function ao(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function Re(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function co(e,t,o,n,s,a,l,c,d,u,f,h,x,y){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void y("reboot");var k=Vn.find(function(A){return A.name===e});k&&(e=k.value)}try{var T=function(A){if(typeof A!="string")throw new Error("Invalid cron string");var P=A.replace(/\s+/g," ").trim().split(" ");if(P.length===5)return P.map(function(z,U){return function(F,M){if(F==="*"||F==="*/1")return[];var S=Xe(lo(fo(function(L,J,ue){if(ue){L=L.toUpperCase();for(var E=0;E<ue.length;E++)L=L.replace(ue[E],"".concat(E+J))}return L}(F,M.min,M.alt).split(",").map(function(L){var J,ue=L.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(F,' for "').concat(M.type,'"'));var E=ue[0],V=ue[1];J=E==="*"?io(M.min,M.max):function(q,K,R){var ee=q.split("-");if(ee.length===1){var We=Re(ee[0]);if(isNaN(We))throw new Error('Invalid value "'.concat(K,'" for ').concat(R.type));return[We]}if(ee.length===2){var fe=Re(ee[0]),Ne=Re(ee[1]);if(isNaN(fe)||isNaN(Ne))throw new Error('Invalid value "'.concat(K,'" for ').concat(R.type));if(Ne<fe)throw new Error('Max range is less than min range in "'.concat(q,'" for ').concat(R.type));return io(fe,Ne)}throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type))}(E,F,M);var W=function(q,K){if(q!==void 0){var R=Re(q);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(q,'" for ').concat(K.type));return R}}(V,M),se=function(q,K){if(K){var R=q[0];q=q.filter(function(ee){return ee%K==R%K||ee===R})}return q}(J,W);return se}).flat(),M))),I=ho(S,M);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(M.type));return S.length===M.total?[]:S}(z,we[U])});throw new Error("Invalid cron string format")}(e),$=function(A){return A[3].length>0?"year":A[2].length>0?"month":A[4].length>0?"week":A[1].length>0?"day":A[0].length>0?"hour":"minute"}(T);y($),d(T[0]),u(T[1]),f(T[2]),h(T[3]),x(T[4])}catch(A){m=!0}}m&&(s.current=e,t(!0),ao(o,l))}function uo(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(d,u){return d.map(function(f,h){var x=we[h];return po(mo(f,x),x,u)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function po(e,t,o,n,s){var a="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);a=l&&function(c,d){for(var u=1;u<c.length;u++){var f=c[u-1];if(c[u]-f!==d)return!1}return!0}(e,l)?function(c,d,u){var f=yo(c),h=go(c),x=c.length===(h-f)/u+1;return!!(f===d.min&&h+u>d.max&&x)}(e,t,l)?"*/".concat(l):"".concat(Oe(yo(e),t,o,n,s),"-").concat(Oe(go(e),t,o,n,s),"/").concat(l):function(c){var d=[],u=null;return c.forEach(function(f,h,x){f!==x[h+1]-1?u!==null?(d.push([u,f]),u=null):d.push(f):u===null&&(u=f)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Oe(c[0],t,o,n,s),"-").concat(Oe(c[1],t,o,n,s)):Oe(c,t,o,n,s)}).join(",")}return a}function Oe(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,d=t.min,u=n&&(n===!0||n.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-d]:e<10&&(u||f)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",x=e%12||12;x<10&&u&&(x=x.toString().padStart(2,"0")),a="".concat(x).concat(h)}return a}function mo(e,t){var o=Xe(lo(fo(e,t)));if(o.length===0)return o;var n=ho(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function fo(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function ho(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function yo(e){return e[0]}function go(e){return e[e.length-1]}function je(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,d=e.humanizeLabels,u=e.disabled,f=e.readOnly,h=e.leadingZero,x=e.clockFormat,y=e.period,m=e.unit,k=e.periodicityOnDoubleClick,T=e.mode,$=so(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),A=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(E){return E.toString()})},[t]),P=b.useMemo(function(){return s?s.map(function(E,V){return{value:(m.min===0?V:V+1).toString(),label:E}}):Qe([],Array(m.total),!0).map(function(E,V){var W=m.min===0?V:V+1;return{value:W.toString(),label:Oe(W,m,d,h,x)}})},[s,h,d,x]),z=JSON.stringify(l),U=b.useCallback(function(E){var V=E.value;if(!t||t[0]!==Number(V))return r.jsx(r.Fragment,{});var W=po(mo(t,m),m,d,h,x),se=W.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:se[1]?"".concat(l.everyText||B.everyText," ").concat(se[1]):W})},[t,z,d,h,x]),F=b.useCallback(function(E){var V=Array.isArray(E)?Xe(E):[E],W=V;t&&(W=T==="single"?[]:Qe([],t,!0),V.forEach(function(se){var q=Number(se);W=t.some(function(K){return K===q})?W.filter(function(K){return K!==q}):Xe(Qe(Qe([],W,!0),[q],!1))})),W.length===m.total?a([]):a(W)},[a,t]),M=b.useCallback(function(E){if(E!==0&&E!==1){for(var V=m.total+m.min,W=[],se=m.min;se<V;se++)se%E==0&&W.push(se);var q=t&&W&&t.length===W.length&&t.every(function(R,ee){return R===W[ee]}),K=W.length===P.length;a(K||q?[]:W)}else a([])},[t,P,a]),S=b.useRef([]),I=b.useCallback(function(E){if(!f){var V=S.current;V.push({time:new Date().getTime(),value:Number(E)});var W=window.setTimeout(function(){k&&V.length>1&&V[V.length-1].time-V[V.length-2].time<300?V[V.length-1].value===V[V.length-2].value?M(Number(E)):F([V[V.length-2].value,V[V.length-1].value]):F(Number(E)),S.current=[]},300);return function(){window.clearTimeout(W)}}},[S,F,M,f,k]),L=b.useCallback(function(){f||a([])},[a,f]),J=b.useMemo(function(){var E;return ae(((E={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,E))},[c]),ue=b.useMemo(function(){var E;return ae(((E={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown"]=!0,E["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&y!=="hour"&&y!=="day",E["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(y==="day"||y==="hour"),E["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&x==="12-hour-clock",E["react-js-cron-custom-select-dropdown-grid"]=!!n,E["".concat(c,"-select-dropdown")]=!!c,E["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,E))},[c,n,x,y]);return r.jsx(g.Select,re({mode:T!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:A,onClear:L,tagRender:U,className:J,popupClassName:ue,options:P,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:u,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||y==="day"||y==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},$))}function jn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=b.useMemo(function(){var y;return ae(((y={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,y["".concat(s,"-hours")]=!!s,y))},[s]);return r.jsxs("div",re({className:x},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(je,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:we[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:f,mode:h})]}))}function Wn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=b.useMemo(function(){var y;return ae(((y={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,y["".concat(s,"-minutes")]=!!s,y))},[s]);return r.jsxs("div",re({className:x},{children:[u==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(je,{placeholder:u==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:we[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:f,mode:h}),u==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function Ln(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,d=e.leadingZero,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=!a||a.length===0,y=b.useMemo(function(){var T;return ae(((T={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!x})["".concat(s,"-field")]=!!s,T["".concat(s,"-month-days")]=!!s,T))},[s,x]),m=JSON.stringify(n),k=b.useMemo(function(){return x?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[x,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",re({className:y},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(je,{placeholder:k,value:t,setValue:o,unit:we[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:d,period:u,periodicityOnDoubleClick:f,mode:h})]})):null}function zn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,d=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=n.months||B.months,x=b.useMemo(function(){var y;return ae(((y={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,y["".concat(s,"-months")]=!!s,y))},[s]);return r.jsxs("div",re({className:x},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(je,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:h,grid:!1,value:t,unit:re(re({},we[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:d,periodicityOnDoubleClick:u,mode:f})]}))}function Hn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,u=[];d.includes("year")&&u.push({value:"year",label:n.yearOption||B.yearOption}),d.includes("month")&&u.push({value:"month",label:n.monthOption||B.monthOption}),d.includes("week")&&u.push({value:"week",label:n.weekOption||B.weekOption}),d.includes("day")&&u.push({value:"day",label:n.dayOption||B.dayOption}),d.includes("hour")&&u.push({value:"hour",label:n.hourOption||B.hourOption}),d.includes("minute")&&u.push({value:"minute",label:n.minuteOption||B.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&u.push({value:"reboot",label:n.rebootOption||B.rebootOption});var f=b.useCallback(function(m){l||o(m)},[o,l]),h=b.useMemo(function(){var m;return ae(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),x=b.useMemo(function(){var m;return ae(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),y=b.useMemo(function(){var m;return ae(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",re({className:h},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(g.Select,{defaultValue:t,value:t,onChange:f,options:u,className:x,popupClassName:y,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Jn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,d=e.readOnly,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=n.weekDays||B.weekDays,y=u==="week"||!l||l.length===0,m=b.useMemo(function(){var P;return ae(((P={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!y})["".concat(s,"-field")]=!!s,P["".concat(s,"-week-days")]=!!s,P))},[s,y]),k=JSON.stringify(n),T=b.useMemo(function(){return y?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[y,k]),$=u==="week"||!d||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),A=!d||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return $?r.jsxs("div",re({className:m},{children:[n.prefixWeekDays!==""&&(u==="week"||!A)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&u!=="week"&&A&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(je,{placeholder:T,optionsList:x,grid:!1,value:t,unit:re(re({},we[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:d,period:u,periodicityOnDoubleClick:f,mode:h})]})):null}function Un(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,d=c===void 0?B:c,u=e.value,f=u===void 0?"":u,h=e.setValue,x=e.displayError,y=x===void 0||x,m=e.onError,k=e.className,T=e.defaultPeriod,$=T===void 0?"day":T,A=e.allowEmpty,P=A===void 0?"for-default-value":A,z=e.humanizeLabels,U=z===void 0||z,F=e.humanizeValue,M=F!==void 0&&F,S=e.disabled,I=S!==void 0&&S,L=e.readOnly,J=L!==void 0&&L,ue=e.leadingZero,E=ue!==void 0&&ue,V=e.shortcuts,W=V===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:V,se=e.clockFormat,q=e.periodicityOnDoubleClick,K=q===void 0||q,R=e.mode,ee=R===void 0?"multiple":R,We=e.allowedDropdowns,fe=We===void 0?["period","months","month-days","week-days","hours","minutes"]:We,Ne=e.allowedPeriods,Cr=Ne===void 0?["year","month","week","day","hour","minute","reboot"]:Ne,Ee=b.useRef(f),Ft=b.useRef($),Ao=b.useState(),be=Ao[0],tt=Ao[1],Oo=b.useState(),Le=Oo[0],ot=Oo[1],To=b.useState(),nt=To[0],rt=To[1],Fo=b.useState(),ze=Fo[0],st=Fo[1],No=b.useState(),it=No[0],lt=No[1],Eo=b.useState(),at=Eo[0],ct=Eo[1],Do=b.useState(!1),Nt=Do[0],He=Do[1],$o=b.useState(!1),ut=$o[0],Mo=$o[1],kr=function(_){var he=b.useRef(_);return b.useEffect(function(){he.current=_},[_]),he.current}(ut),Io=JSON.stringify(d);b.useEffect(function(){co(f,He,m,P,Ee,!0,d,W,ct,lt,ot,rt,st,tt)},[]),b.useEffect(function(){f!==Ee.current&&co(f,He,m,P,Ee,!1,d,W,ct,lt,ot,rt,st,tt)},[f,Ee,Io,P,W]),b.useEffect(function(){if(!(be||at||nt||Le||ze||it)||ut||kr)ut&&Mo(!1);else{var _=be||Ft.current,he=uo(_,nt,Le,ze,it,at,M);h(he,{selectedPeriod:_}),Ee.current=he,m&&m(void 0),He(!1)}},[be,Le,nt,ze,it,at,M,ut]);var Po=b.useCallback(function(){ot(void 0),rt(void 0),st(void 0),lt(void 0),ct(void 0);var _="",he=be!=="reboot"&&be?be:Ft.current;he!==be&&tt(he),l==="fill-with-every"&&(_=uo(he,void 0,void 0,void 0,void 0,void 0)),h(_,{selectedPeriod:he}),Ee.current=_,Mo(!0),P==="never"&&l==="empty"?(He(!0),ao(m,d)):(m&&m(void 0),He(!1))},[be,h,m,l]),Sr=b.useMemo(function(){var _;return ae(((_={"react-js-cron":!0,"react-js-cron-error":Nt&&y,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(k)]=!!k,_["".concat(k,"-error")]=Nt&&y&&!!k,_["".concat(k,"-disabled")]=I&&!!k,_["".concat(k,"-read-only")]=J&&!!k,_))},[k,Nt,y,I,J]),Et=s.className,Bo=so(s,["className"]),Vo=b.useMemo(function(){var _;return ae(((_={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,_["".concat(Et)]=!!Et,_))},[k,Et]),Ar=JSON.stringify(Bo),jo=b.useMemo(function(){return o&&!J?r.jsx(g.Button,re({className:Vo,danger:!0,type:"primary",disabled:I},Bo,{onClick:Po},{children:d.clearButtonText||B.clearButtonText})):null},[o,J,Io,Vo,I,Ar,Po]),te=be||Ft.current;return r.jsxs("div",re({className:Sr},{children:[fe.includes("period")&&r.jsx(Hn,{value:te,setValue:tt,locale:d,className:k,disabled:I,readOnly:J,shortcuts:W,allowedPeriods:Cr}),te==="reboot"?jo:r.jsxs(r.Fragment,{children:[te==="year"&&fe.includes("months")&&r.jsx(zn,{value:nt,setValue:rt,locale:d,className:k,humanizeLabels:U,disabled:I,readOnly:J,period:te,periodicityOnDoubleClick:K,mode:ee}),(te==="year"||te==="month")&&fe.includes("month-days")&&r.jsx(Ln,{value:Le,setValue:ot,locale:d,className:k,weekDays:ze,disabled:I,readOnly:J,leadingZero:E,period:te,periodicityOnDoubleClick:K,mode:ee}),(te==="year"||te==="month"||te==="week")&&fe.includes("week-days")&&r.jsx(Jn,{value:ze,setValue:st,locale:d,className:k,humanizeLabels:U,monthDays:Le,disabled:I,readOnly:J,period:te,periodicityOnDoubleClick:K,mode:ee}),r.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&fe.includes("hours")&&r.jsx(jn,{value:it,setValue:lt,locale:d,className:k,disabled:I,readOnly:J,leadingZero:E,clockFormat:se,period:te,periodicityOnDoubleClick:K,mode:ee}),te!=="minute"&&fe.includes("minutes")&&r.jsx(Wn,{value:at,setValue:ct,locale:d,period:te,className:k,disabled:I,readOnly:J,leadingZero:E,clockFormat:se,periodicityOnDoubleClick:K,mode:ee}),jo]})]})]}))}const Gn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"或者",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},bo=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function vo(e){return bo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function qn(e){let t;switch(typeof e){case"number":return t=vo(e),t?t.value:"none";case"string":return"cron"}return"none"}function Yn({value:e,onChange:t}){const{t:o}=mt(),n=vo(e);return r.jsx(g.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Kn({value:e=null,onChange:t}){const{t:o}=mt(),n=qn(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=Gn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:i.css`
465
+ `,children:[r.jsxs(b.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(b.Select.Option,{value:null,children:o("No end")}),r.jsx(b.Select.Option,{value:"field",children:o("By field")}),r.jsx(b.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(lo,{value:e,onChange:t}):null,n==="date"?r.jsx(b.DatePicker,{showTime:!0,value:Ko(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},re.apply(this,arguments)};function ao(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function Re(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var Jn=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],Ce=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],B={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function co(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function et(e){return e.sort(function(t,o){return t-o}),e}function uo(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ce(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function po(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function tt(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function mo(e,t,o,n,s,a,l,c,d,u,f,h,x,y){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void y("reboot");var k=Jn.find(function(S){return S.name===e});k&&(e=k.value)}try{var F=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var M=S.replace(/\s+/g," ").trim().split(" ");if(M.length===5)return M.map(function(W,J){return function(T,I){if(T==="*"||T==="*/1")return[];var A=et(uo(go(function(z,H,de){if(de){z=z.toUpperCase();for(var D=0;D<de.length;D++)z=z.replace(de[D],"".concat(D+H))}return z}(T,I.min,I.alt).split(",").map(function(z){var H,de=z.split("/");if(de.length>2)throw new Error('Invalid value "'.concat(T,' for "').concat(I.type,'"'));var D=de[0],V=de[1];H=D==="*"?co(I.min,I.max):function(Y,K,R){var ee=Y.split("-");if(ee.length===1){var Le=tt(ee[0]);if(isNaN(Le))throw new Error('Invalid value "'.concat(K,'" for ').concat(R.type));return[Le]}if(ee.length===2){var he=tt(ee[0]),Ee=tt(ee[1]);if(isNaN(he)||isNaN(Ee))throw new Error('Invalid value "'.concat(K,'" for ').concat(R.type));if(Ee<he)throw new Error('Max range is less than min range in "'.concat(Y,'" for ').concat(R.type));return co(he,Ee)}throw new Error('Invalid value "'.concat(Y,'" for ').concat(R.type))}(D,T,I);var L=function(Y,K){if(Y!==void 0){var R=tt(Y);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(Y,'" for ').concat(K.type));return R}}(V,I),se=function(Y,K){if(K){var R=Y[0];Y=Y.filter(function(ee){return ee%K==R%K||ee===R})}return Y}(H,L);return se}).flat(),I))),P=bo(A,I);if(P!==void 0)throw new Error('Value "'.concat(P,'" out of range for ').concat(I.type));return A.length===I.total?[]:A}(W,Ce[J])});throw new Error("Invalid cron string format")}(e),E=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}(F);y(E),d(F[0]),u(F[1]),f(F[2]),h(F[3]),x(F[4])}catch(S){m=!0}}m&&(s.current=e,t(!0),po(o,l))}function fo(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(d,u){return d.map(function(f,h){var x=Ce[h];return ho(yo(f,x),x,u)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function ho(e,t,o,n,s){var a="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);a=l&&function(c,d){for(var u=1;u<c.length;u++){var f=c[u-1];if(c[u]-f!==d)return!1}return!0}(e,l)?function(c,d,u){var f=vo(c),h=xo(c),x=c.length===(h-f)/u+1;return!!(f===d.min&&h+u>d.max&&x)}(e,t,l)?"*/".concat(l):"".concat(Fe(vo(e),t,o,n,s),"-").concat(Fe(xo(e),t,o,n,s),"/").concat(l):function(c){var d=[],u=null;return c.forEach(function(f,h,x){f!==x[h+1]-1?u!==null?(d.push([u,f]),u=null):d.push(f):u===null&&(u=f)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Fe(c[0],t,o,n,s),"-").concat(Fe(c[1],t,o,n,s)):Fe(c,t,o,n,s)}).join(",")}return a}function Fe(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,d=t.min,u=n&&(n===!0||n.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-d]:e<10&&(u||f)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",x=e%12||12;x<10&&u&&(x=x.toString().padStart(2,"0")),a="".concat(x).concat(h)}return a}function yo(e,t){var o=et(uo(go(e,t)));if(o.length===0)return o;var n=bo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function go(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function bo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function vo(e){return e[0]}function xo(e){return e[e.length-1]}function We(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,d=e.humanizeLabels,u=e.disabled,f=e.readOnly,h=e.leadingZero,x=e.clockFormat,y=e.period,m=e.unit,k=e.periodicityOnDoubleClick,F=e.mode,E=ao(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=g.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(D){return D.toString()})},[t]),M=g.useMemo(function(){return s?s.map(function(D,V){return{value:(m.min===0?V:V+1).toString(),label:D}}):Re([],Array(m.total),!0).map(function(D,V){var L=m.min===0?V:V+1;return{value:L.toString(),label:Fe(L,m,d,h,x)}})},[s,h,d,x]),W=JSON.stringify(l),J=g.useCallback(function(D){var V=D.value;if(!t||t[0]!==Number(V))return r.jsx(r.Fragment,{});var L=ho(yo(t,m),m,d,h,x),se=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:se[1]?"".concat(l.everyText||B.everyText," ").concat(se[1]):L})},[t,W,d,h,x]),T=g.useCallback(function(D){var V=Array.isArray(D)?et(D):[D],L=V;t&&(L=F==="single"?[]:Re([],t,!0),V.forEach(function(se){var Y=Number(se);L=t.some(function(K){return K===Y})?L.filter(function(K){return K!==Y}):et(Re(Re([],L,!0),[Y],!1))})),L.length===m.total?a([]):a(L)},[a,t]),I=g.useCallback(function(D){if(D!==0&&D!==1){for(var V=m.total+m.min,L=[],se=m.min;se<V;se++)se%D==0&&L.push(se);var Y=t&&L&&t.length===L.length&&t.every(function(R,ee){return R===L[ee]}),K=L.length===M.length;a(K||Y?[]:L)}else a([])},[t,M,a]),A=g.useRef([]),P=g.useCallback(function(D){if(!f){var V=A.current;V.push({time:new Date().getTime(),value:Number(D)});var L=window.setTimeout(function(){k&&V.length>1&&V[V.length-1].time-V[V.length-2].time<300?V[V.length-1].value===V[V.length-2].value?I(Number(D)):T([V[V.length-2].value,V[V.length-1].value]):T(Number(D)),A.current=[]},300);return function(){window.clearTimeout(L)}}},[A,T,I,f,k]),z=g.useCallback(function(){f||a([])},[a,f]),H=g.useMemo(function(){var D;return ce(((D={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,D))},[c]),de=g.useMemo(function(){var D;return ce(((D={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown"]=!0,D["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&y!=="hour"&&y!=="day",D["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(y==="day"||y==="hour"),D["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&x==="12-hour-clock",D["react-js-cron-custom-select-dropdown-grid"]=!!n,D["".concat(c,"-select-dropdown")]=!!c,D["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,D))},[c,n,x,y]);return r.jsx(b.Select,re({mode:F!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:S,onClear:z,tagRender:J,className:H,popupClassName:de,options:M,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:P,onDeselect:P,disabled:u,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||y==="day"||y==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},E))}function Un(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=g.useMemo(function(){var y;return ce(((y={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,y["".concat(s,"-hours")]=!!s,y))},[s]);return r.jsxs("div",re({className:x},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(We,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:Ce[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:f,mode:h})]}))}function Hn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=g.useMemo(function(){var y;return ce(((y={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,y["".concat(s,"-minutes")]=!!s,y))},[s]);return r.jsxs("div",re({className:x},{children:[u==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(We,{placeholder:u==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:Ce[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:f,mode:h}),u==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function Gn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,d=e.leadingZero,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=!a||a.length===0,y=g.useMemo(function(){var F;return ce(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!x})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,x]),m=JSON.stringify(n),k=g.useMemo(function(){return x?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[x,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",re({className:y},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(We,{placeholder:k,value:t,setValue:o,unit:Ce[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:d,period:u,periodicityOnDoubleClick:f,mode:h})]})):null}function qn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,d=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=n.months||B.months,x=g.useMemo(function(){var y;return ce(((y={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,y["".concat(s,"-months")]=!!s,y))},[s]);return r.jsxs("div",re({className:x},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(We,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:h,grid:!1,value:t,unit:re(re({},Ce[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:d,periodicityOnDoubleClick:u,mode:f})]}))}function Yn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,u=[];d.includes("year")&&u.push({value:"year",label:n.yearOption||B.yearOption}),d.includes("month")&&u.push({value:"month",label:n.monthOption||B.monthOption}),d.includes("week")&&u.push({value:"week",label:n.weekOption||B.weekOption}),d.includes("day")&&u.push({value:"day",label:n.dayOption||B.dayOption}),d.includes("hour")&&u.push({value:"hour",label:n.hourOption||B.hourOption}),d.includes("minute")&&u.push({value:"minute",label:n.minuteOption||B.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&u.push({value:"reboot",label:n.rebootOption||B.rebootOption});var f=g.useCallback(function(m){l||o(m)},[o,l]),h=g.useMemo(function(){var m;return ce(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),x=g.useMemo(function(){var m;return ce(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),y=g.useMemo(function(){var m;return ce(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",re({className:h},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(b.Select,{defaultValue:t,value:t,onChange:f,options:u,className:x,popupClassName:y,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Kn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,d=e.readOnly,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=n.weekDays||B.weekDays,y=u==="week"||!l||l.length===0,m=g.useMemo(function(){var M;return ce(((M={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!y})["".concat(s,"-field")]=!!s,M["".concat(s,"-week-days")]=!!s,M))},[s,y]),k=JSON.stringify(n),F=g.useMemo(function(){return y?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[y,k]),E=u==="week"||!d||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),S=!d||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return E?r.jsxs("div",re({className:m},{children:[n.prefixWeekDays!==""&&(u==="week"||!S)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&u!=="week"&&S&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(We,{placeholder:F,optionsList:x,grid:!1,value:t,unit:re(re({},Ce[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:d,period:u,periodicityOnDoubleClick:f,mode:h})]})):null}function _n(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,d=c===void 0?B:c,u=e.value,f=u===void 0?"":u,h=e.setValue,x=e.displayError,y=x===void 0||x,m=e.onError,k=e.className,F=e.defaultPeriod,E=F===void 0?"day":F,S=e.allowEmpty,M=S===void 0?"for-default-value":S,W=e.humanizeLabels,J=W===void 0||W,T=e.humanizeValue,I=T!==void 0&&T,A=e.disabled,P=A!==void 0&&A,z=e.readOnly,H=z!==void 0&&z,de=e.leadingZero,D=de!==void 0&&de,V=e.shortcuts,L=V===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:V,se=e.clockFormat,Y=e.periodicityOnDoubleClick,K=Y===void 0||Y,R=e.mode,ee=R===void 0?"multiple":R,Le=e.allowedDropdowns,he=Le===void 0?["period","months","month-days","week-days","hours","minutes"]:Le,Ee=e.allowedPeriods,Or=Ee===void 0?["year","month","week","day","hour","minute","reboot"]:Ee,De=g.useRef(f),Dt=g.useRef(E),Do=g.useState(),be=Do[0],nt=Do[1],$o=g.useState(),ze=$o[0],rt=$o[1],Mo=g.useState(),st=Mo[0],it=Mo[1],Io=g.useState(),Je=Io[0],lt=Io[1],Po=g.useState(),at=Po[0],ct=Po[1],Bo=g.useState(),ut=Bo[0],dt=Bo[1],Vo=g.useState(!1),$t=Vo[0],Ue=Vo[1],jo=g.useState(!1),pt=jo[0],Wo=jo[1],Fr=function(_){var ye=g.useRef(_);return g.useEffect(function(){ye.current=_},[_]),ye.current}(pt),Lo=JSON.stringify(d);g.useEffect(function(){mo(f,Ue,m,M,De,!0,d,L,dt,ct,rt,it,lt,nt)},[]),g.useEffect(function(){f!==De.current&&mo(f,Ue,m,M,De,!1,d,L,dt,ct,rt,it,lt,nt)},[f,De,Lo,M,L]),g.useEffect(function(){if(!(be||ut||st||ze||Je||at)||pt||Fr)pt&&Wo(!1);else{var _=be||Dt.current,ye=fo(_,st,ze,Je,at,ut,I);h(ye,{selectedPeriod:_}),De.current=ye,m&&m(void 0),Ue(!1)}},[be,ze,st,Je,at,ut,I,pt]);var zo=g.useCallback(function(){rt(void 0),it(void 0),lt(void 0),ct(void 0),dt(void 0);var _="",ye=be!=="reboot"&&be?be:Dt.current;ye!==be&&nt(ye),l==="fill-with-every"&&(_=fo(ye,void 0,void 0,void 0,void 0,void 0)),h(_,{selectedPeriod:ye}),De.current=_,Wo(!0),M==="never"&&l==="empty"?(Ue(!0),po(m,d)):(m&&m(void 0),Ue(!1))},[be,h,m,l]),Tr=g.useMemo(function(){var _;return ce(((_={"react-js-cron":!0,"react-js-cron-error":$t&&y,"react-js-cron-disabled":P,"react-js-cron-read-only":H})["".concat(k)]=!!k,_["".concat(k,"-error")]=$t&&y&&!!k,_["".concat(k,"-disabled")]=P&&!!k,_["".concat(k,"-read-only")]=H&&!!k,_))},[k,$t,y,P,H]),Mt=s.className,Jo=ao(s,["className"]),Uo=g.useMemo(function(){var _;return ce(((_={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,_["".concat(Mt)]=!!Mt,_))},[k,Mt]),Nr=JSON.stringify(Jo),Ho=g.useMemo(function(){return o&&!H?r.jsx(b.Button,re({className:Uo,danger:!0,type:"primary",disabled:P},Jo,{onClick:zo},{children:d.clearButtonText||B.clearButtonText})):null},[o,H,Lo,Uo,P,Nr,zo]),te=be||Dt.current;return r.jsxs("div",re({className:Tr},{children:[he.includes("period")&&r.jsx(Yn,{value:te,setValue:nt,locale:d,className:k,disabled:P,readOnly:H,shortcuts:L,allowedPeriods:Or}),te==="reboot"?Ho:r.jsxs(r.Fragment,{children:[te==="year"&&he.includes("months")&&r.jsx(qn,{value:st,setValue:it,locale:d,className:k,humanizeLabels:J,disabled:P,readOnly:H,period:te,periodicityOnDoubleClick:K,mode:ee}),(te==="year"||te==="month")&&he.includes("month-days")&&r.jsx(Gn,{value:ze,setValue:rt,locale:d,className:k,weekDays:Je,disabled:P,readOnly:H,leadingZero:D,period:te,periodicityOnDoubleClick:K,mode:ee}),(te==="year"||te==="month"||te==="week")&&he.includes("week-days")&&r.jsx(Kn,{value:Je,setValue:lt,locale:d,className:k,humanizeLabels:J,monthDays:ze,disabled:P,readOnly:H,period:te,periodicityOnDoubleClick:K,mode:ee}),r.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&he.includes("hours")&&r.jsx(Un,{value:at,setValue:ct,locale:d,className:k,disabled:P,readOnly:H,leadingZero:D,clockFormat:se,period:te,periodicityOnDoubleClick:K,mode:ee}),te!=="minute"&&he.includes("minutes")&&r.jsx(Hn,{value:ut,setValue:dt,locale:d,period:te,className:k,disabled:P,readOnly:H,leadingZero:D,clockFormat:se,periodicityOnDoubleClick:K,mode:ee}),Ho]})]})]}))}const Zn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"或者",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},wo=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function Co(e){return wo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Qn(e){let t;switch(typeof e){case"number":return t=Co(e),t?t.value:"none";case"string":return"cron"}return"none"}function Xn({value:e,onChange:t}){const{t:o}=yt(),n=Co(e);return r.jsx(b.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Rn({value:e=null,onChange:t}){const{t:o}=yt(),n=Qn(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=Zn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:i.css`
466
466
  display: flex;
467
467
  flex-direction: ${n==="cron"?"column":"row"};
468
468
  align-items: flex-start;
@@ -491,7 +491,7 @@
491
491
  }
492
492
  }
493
493
  }
494
- `,children:[r.jsx(g.Select,{value:n,onChange:s,className:"auto-width",children:bo.map(l=>r.jsx(g.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Yn,{value:e,onChange:t}):null,n==="cron"?r.jsx(Un,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:a}):null]})}const _n={[xe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}}},[xe.DATE_FIELD]:{collection:O(C({},le),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...le["x-reactions"],{target:"startsOn",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}},appends:O(C({},Be),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${xe.DATE_FIELD} && $deps[1]}}`}}}]})}},Zn=[{value:xe.STATIC,label:`{{t("Based on certain date", { ns: "${p}" })}}`},{value:xe.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${p}" })}}`}],Qn=()=>{const{values:e={},clearFormGraph:t}=j.useForm(),[o,n]=b.useState(e.mode);return j.useFormEffects(()=>{ye.onFieldValueChange("mode",s=>{n(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(i.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${p}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Zn},required:!0,default:xe.STATIC}}),r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
494
+ `,children:[r.jsx(b.Select,{value:n,onChange:s,className:"auto-width",children:wo.map(l=>r.jsx(b.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Xn,{value:e,onChange:t}):null,n==="cron"?r.jsx(_n,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:a}):null]})}const er={[we.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}}},[we.DATE_FIELD]:{collection:O(C({},ae),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...ae["x-reactions"],{target:"startsOn",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}},appends:O(C({},Ve),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${we.DATE_FIELD} && $deps[1]}}`}}}]})}},tr=[{value:we.STATIC,label:`{{t("Based on certain date", { ns: "${p}" })}}`},{value:we.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${p}" })}}`}],or=()=>{const{values:e={},clearFormGraph:t}=j.useForm(),[o,n]=g.useState(e.mode);return j.useFormEffects(()=>{ie.onFieldValueChange("mode",s=>{n(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(i.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${p}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:tr},required:!0,default:we.STATIC}}),r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
495
495
  .ant-input-number {
496
496
  width: auto;
497
497
  min-width: 6em;
@@ -500,29 +500,29 @@
500
500
  .ant-picker {
501
501
  width: auto;
502
502
  }
503
- `},properties:_n[o]}}},components:{OnField:ro,RepeatField:Kn,EndsByField:Bn}})]})};function Xn(e,t){var c;const[o,n]=i.parseCollectionName(e.collection),s=i.useCompile(),a=Ve(o),l=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&l.push({key:"date",value:"date",label:N("Trigger time")}),e.mode===xe.DATE_FIELD){const[d]=Se(O(C({appends:["data",...((c=e.appends)==null?void 0:c.map(u=>`data.${u}`))||[]]},t),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:N("Trigger data")}}],compile:s,getCollectionFields:a}));d&&l.push(d)}return l}class Rn extends bt{constructor(){super(...arguments);w(this,"sync",!1);w(this,"title",`{{t("Schedule event", { ns: "${p}" })}}`);w(this,"description",`{{t("Triggered according to preset time conditions. Suitable for one-time or periodic tasks, such as sending notifications and cleaning data on a schedule.", { ns: "${p}" })}}`);w(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{ScheduleConfig:Qn});w(this,"useVariables",Xn)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Pe,collection:o.collection,dataPath:"$context.data"}:null}}function Te(e){const a=e,{options:t=[],direction:o}=a,n=Z(a,["options","direction"]),s=i.useCompile();return r.jsx(g.Radio.Group,O(C({},n),{children:r.jsx(g.Space,{direction:o,children:t.map(l=>r.jsxs(g.Radio,{value:l.value,children:[r.jsx("span",{className:i.css`
503
+ `},properties:er[o]}}},components:{OnField:lo,RepeatField:Rn,EndsByField:zn}})]})};function nr(e,t){var c;const[o,n]=i.parseCollectionName(e.collection),s=i.useCompile(),a=je(o),l=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&l.push({key:"date",value:"date",label:N("Trigger time")}),e.mode===we.DATE_FIELD){const[d]=Ae(O(C({appends:["data",...((c=e.appends)==null?void 0:c.map(u=>`data.${u}`))||[]]},t),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:N("Trigger data")}}],compile:s,getCollectionFields:a}));d&&l.push(d)}return l}class rr extends wt{constructor(){super(...arguments);w(this,"sync",!1);w(this,"title",`{{t("Schedule event", { ns: "${p}" })}}`);w(this,"description",`{{t("Triggered according to preset time conditions. Suitable for one-time or periodic tasks, such as sending notifications and cleaning data on a schedule.", { ns: "${p}" })}}`);w(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{ScheduleConfig:or});w(this,"useVariables",nr)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Be,collection:o.collection,dataPath:"$context.data"}:null}}function Te(e){const a=e,{options:t=[],direction:o}=a,n=X(a,["options","direction"]),s=i.useCompile();return r.jsx(b.Radio.Group,O(C({},n),{children:r.jsx(b.Space,{direction:o,children:t.map(l=>r.jsxs(b.Radio,{value:l.value,children:[r.jsx("span",{className:i.css`
504
504
  & + .anticon {
505
505
  margin-left: 0.25em;
506
506
  }
507
- `,children:s(l.label)}),l.tooltip&&r.jsx(g.Tooltip,{title:s(l.tooltip),children:r.jsx(D.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function xo(){const e=j.useFieldSchema(),t=i.useCompile();return r.jsxs(i.GeneralSchemaDesigner,{title:t(e.title),children:[r.jsx(i.SchemaSettingsBlockTitleItem,{}),r.jsx(i.SchemaSettingsDivider,{}),r.jsx(i.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Fe=()=>null;function er(){const a=i.useSchemaInitializerItem(),{node:t,resultTitle:o}=a,n=Z(a,["node","resultTitle"]),{insert:s}=i.useSchemaInitializer();return r.jsx(i.SchemaInitializerItem,O(C({},n),{onClick:()=>{var l;s({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(l=t.title)!=null?l:`#${t.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function tr({dataSource:e}){var s;const t=j.useFieldSchema(),{execution:o}=Y();if(!o)return t.title;const n=H.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:i.css`
507
+ `,children:s(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:s(l.tooltip),children:r.jsx($.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function ko(){const e=j.useFieldSchema(),t=i.useCompile();return r.jsxs(i.GeneralSchemaDesigner,{title:t(e.title),children:[r.jsx(i.SchemaSettingsBlockTitleItem,{}),r.jsx(i.SchemaSettingsDivider,{}),r.jsx(i.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Ne=()=>null;function sr(){const a=i.useSchemaInitializerItem(),{node:t,resultTitle:o}=a,n=X(a,["node","resultTitle"]),{insert:s}=i.useSchemaInitializer();return r.jsx(i.SchemaInitializerItem,O(C({},n),{onClick:()=>{var l;s({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(l=t.title)!=null?l:`#${t.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function ir({dataSource:e}){var s;const t=j.useFieldSchema(),{execution:o}=q();if(!o)return t.title;const n=U.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:i.css`
508
508
  margin: 0;
509
- `,children:JSON.stringify(n,null,2)})}Fe.Initializer=er,Fe.Result=tr,Fe.Designer=xo;const wo=e=>{const t=$e.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:i.css`
509
+ `,children:JSON.stringify(n,null,2)})}Ne.Initializer=sr,Ne.Result=ir,Ne.Designer=ko;const So=e=>{const t=$e.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:i.css`
510
510
  &:after {
511
511
  content: ':';
512
512
  }
513
513
  & + a {
514
514
  margin-left: 0.25em;
515
515
  }
516
- `,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class or extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Calculation", { ns: "${p}" })}}`);w(this,"type","calculation");w(this,"group","control");w(this,"description",`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${p}" })}}`);w(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:$e.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:s}){const{values:a}=s,{evaluate:l}=$e.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(c),""}catch(d){return N("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:wo});w(this,"components",{WorkflowVariableTextArea:Tt,RadioWithTooltip:Te,ValueBlock:Fe})}useVariables({key:o,title:n},{types:s,fieldNames:a=ke}){return s&&!s.some(l=>l in _e||Object.values(_e).some(c=>c.has(l)))?null:{value:o,label:n}}useInitializers(o){var n,s;return{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Fe.Initializer,node:o,resultTitle:N("Calculation result")}}}const X=new H.Registry;X.register("equal",{name:"=",type:"boolean",group:"boolean"}),X.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),X.register("gt",{name:">",type:"boolean",group:"boolean"}),X.register("gte",{name:"≥",type:"boolean",group:"boolean"}),X.register("lt",{name:"<",type:"boolean",group:"boolean"}),X.register("lte",{name:"≤",type:"boolean",group:"boolean"}),X.register("add",{name:"+",type:"number",group:"number"}),X.register("minus",{name:"-",type:"number",group:"number"}),X.register("multiple",{name:"*",type:"number",group:"number"}),X.register("divide",{name:"/",type:"number",group:"number"}),X.register("mod",{name:"%",type:"number",group:"number"}),X.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),X.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),X.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),X.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),X.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),X.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),X.register("concat",{name:`{{t("concat", { ns: "${p}" })}}`,type:"string",group:"string"});const nr=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${p}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${p}" })}}`},{value:"date",title:`{{t("Date", { ns: "${p}" })}}`}];function Co(e){return Array.from(X.getEntities()).filter(([t,o])=>o.group===e)}function rr({calculator:e,operands:t=[],onChange:o}){const n=i.useCompile(),s=me(),a=me(),l=b.useCallback(u=>o({calculator:e,operands:[u,t[1]]}),[e,o,t]),c=b.useCallback(u=>o({calculator:e,operands:[t[0],u]}),[e,o,t]),d=b.useCallback(u=>o({operands:t,calculator:u}),[o,t]);return r.jsxs("fieldset",{className:i.css`
516
+ `,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class lr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Calculation", { ns: "${p}" })}}`);w(this,"type","calculation");w(this,"group","control");w(this,"description",`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${p}" })}}`);w(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:$e.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:s}){const{values:a}=s,{evaluate:l}=$e.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(c),""}catch(d){return N("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:So});w(this,"components",{WorkflowVariableTextArea:Et,RadioWithTooltip:Te,ValueBlock:Ne})}useVariables({key:o,title:n},{types:s,fieldNames:a=Se}){return s&&!s.some(l=>l in Qe||Object.values(Qe).some(c=>c.has(l)))?null:{value:o,label:n}}useInitializers(o){var n,s;return{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Ne.Initializer,node:o,resultTitle:N("Calculation result")}}}const Q=new U.Registry;Q.register("equal",{name:"=",type:"boolean",group:"boolean"}),Q.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),Q.register("gt",{name:">",type:"boolean",group:"boolean"}),Q.register("gte",{name:"≥",type:"boolean",group:"boolean"}),Q.register("lt",{name:"<",type:"boolean",group:"boolean"}),Q.register("lte",{name:"≤",type:"boolean",group:"boolean"}),Q.register("add",{name:"+",type:"number",group:"number"}),Q.register("minus",{name:"-",type:"number",group:"number"}),Q.register("multiple",{name:"*",type:"number",group:"number"}),Q.register("divide",{name:"/",type:"number",group:"number"}),Q.register("mod",{name:"%",type:"number",group:"number"}),Q.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),Q.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),Q.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),Q.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),Q.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),Q.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),Q.register("concat",{name:`{{t("concat", { ns: "${p}" })}}`,type:"string",group:"string"});const ar=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${p}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${p}" })}}`},{value:"date",title:`{{t("Date", { ns: "${p}" })}}`}];function Ao(e){return Array.from(Q.getEntities()).filter(([t,o])=>o.group===e)}function cr({calculator:e,operands:t=[],onChange:o}){const n=i.useCompile(),s=me(),a=me(),l=g.useCallback(u=>o({calculator:e,operands:[u,t[1]]}),[e,o,t]),c=g.useCallback(u=>o({calculator:e,operands:[t[0],u]}),[e,o,t]),d=g.useCallback(u=>o({operands:t,calculator:u}),[o,t]);return r.jsxs("fieldset",{className:i.css`
517
517
  display: flex;
518
518
  gap: 0.5em;
519
519
  align-items: center;
520
520
  flex-wrap: wrap;
521
- `,children:[r.jsx(i.Variable.Input,{changeOnSelect:!0,value:t[0],onChange:l,scope:s,useTypedConstant:!0}),r.jsx(g.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:d,placeholder:N("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:nr.filter(u=>!!Co(u.value).length).map(u=>r.jsx(g.Select.OptGroup,{label:n(u.title),children:Co(u.value).map(([f,{name:h}])=>r.jsx(g.Select.Option,{value:f,children:n(h)},f))},u.value))}),r.jsx(i.Variable.Input,{changeOnSelect:!0,value:t[1],onChange:c,scope:a,useTypedConstant:!0})]})}function sr({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:i.css`
521
+ `,children:[r.jsx(i.Variable.Input,{changeOnSelect:!0,value:t[0],onChange:l,scope:s,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:d,placeholder:N("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:ar.filter(u=>!!Ao(u.value).length).map(u=>r.jsx(b.Select.OptGroup,{label:n(u.title),children:Ao(u.value).map(([f,{name:h}])=>r.jsx(b.Select.Option,{value:f,children:n(h)},f))},u.value))}),r.jsx(i.Variable.Input,{changeOnSelect:!0,value:t[1],onChange:c,scope:a,useTypedConstant:!0})]})}function ur({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:i.css`
522
522
  display: flex;
523
523
  position: relative;
524
524
  margin: 0.5em 0;
525
- `,children:[e.group?r.jsx(ko,{value:e.group,onChange:a=>t(O(C({},e),{group:a}))}):r.jsx(rr,{operands:s,calculator:n,onChange:t}),r.jsx(g.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(D.CloseCircleOutlined,{})})]})}function ko({value:e,onChange:t}){const{t:o}=Q.useTranslation(),{type:n="and",calculations:s=[]}=e;function a(){t(O(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function l(){t(O(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(u){s.splice(u,1),t(O(C({},e),{calculations:[...s]}))}function d(u,f){s.splice(u,1,f),t(O(C({},e),{calculations:[...s]}))}return r.jsxs("div",{className:i.cx("node-type-condition-group",i.css`
525
+ `,children:[e.group?r.jsx(Oo,{value:e.group,onChange:a=>t(O(C({},e),{group:a}))}):r.jsx(cr,{operands:s,calculator:n,onChange:t}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx($.CloseCircleOutlined,{})})]})}function Oo({value:e,onChange:t}){const{t:o}=Z.useTranslation(),{type:n="and",calculations:s=[]}=e;function a(){t(O(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function l(){t(O(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(u){s.splice(u,1),t(O(C({},e),{calculations:[...s]}))}function d(u,f){s.splice(u,1,f),t(O(C({},e),{calculations:[...s]}))}return r.jsxs("div",{className:i.cx("node-type-condition-group",i.css`
526
526
  position: relative;
527
527
  width: 100%;
528
528
  .node-type-condition-group {
@@ -541,18 +541,18 @@
541
541
  width: auto;
542
542
  min-width: 6em;
543
543
  }
544
- `,children:r.jsxs(Q.Trans,{children:["Meet ",r.jsxs(g.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:u=>t(O(C({},e),{type:u})),children:[r.jsx(g.Select.Option,{value:"and",children:"All"}),r.jsx(g.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:s.map((u,f)=>r.jsx(sr,{value:u,onChange:d.bind(this,f),onRemove:()=>c(f)},`${u.calculator}_${f}`))}),r.jsxs("div",{className:i.css`
544
+ `,children:r.jsxs(Z.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:u=>t(O(C({},e),{type:u})),children:[r.jsx(b.Select.Option,{value:"and",children:"All"}),r.jsx(b.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:s.map((u,f)=>r.jsx(ur,{value:u,onChange:d.bind(this,f),onRemove:()=>c(f)},`${u.calculator}_${f}`))}),r.jsxs("div",{className:i.css`
545
545
  button {
546
546
  padding: 0;
547
547
  &:not(:last-child) {
548
548
  margin-right: 1em;
549
549
  }
550
550
  }
551
- `,children:[r.jsx(g.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(g.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function ir({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(ko,{value:o.group,onChange:n=>t(O(C({},o),{group:n}))})}class lr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Condition", { ns: "${p}" })}}`);w(this,"type","condition");w(this,"group","control");w(this,"description",`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${p}" })}}`);w(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${p}" })}}`}],...Array.from($e.evaluators.getEntities()).filter(([o])=>["math.js","formula.js"].includes(o))].reduce((o,[n,s])=>o.concat(C({value:n},s)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:s}){const{values:a}=s,{evaluate:l}=$e.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(c),""}catch(d){return N("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});w(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);w(this,"scope",{renderEngineReference:wo,useWorkflowVariableOptions:me});w(this,"components",{CalculationConfig:ir,WorkflowVariableTextArea:Tt,RadioWithTooltip:Te})}Component({data:o}){const{t:n}=Q.useTranslation(),{nodes:s}=Y(),{styles:a}=ne(),{id:l,config:{rejectOnFalse:c}}=o,d=s.find(f=>f.upstreamId===l&&f.branchIndex===1),u=s.find(f=>f.upstreamId===l&&f.branchIndex===0);return r.jsx(gt,{data:o,children:c?null:r.jsxs("div",{className:a.nodeSubtreeClass,children:[r.jsxs("div",{className:a.branchBlockClass,children:[r.jsx(qe,{from:o,entry:u,branchIndex:0}),r.jsx(qe,{from:o,entry:d,branchIndex:1})]}),r.jsxs("div",{className:a.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class ar extends ge{constructor(){super(...arguments);w(this,"title",`{{t("End process", { ns: "${p}" })}}`);w(this,"type","end");w(this,"group","control");w(this,"description",`{{t("End the process immediately, with set status.", { ns: "${p}" })}}`);w(this,"fieldset",{endStatus:{type:"number",title:`{{t("End status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${p}" })}}`,value:ie.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:ie.FAILED}],required:!0,default:ie.RESOLVED}});w(this,"end",!0)}}function et({value:e,onChange:t,renderSchemaComponent:o}){const n=me();return r.jsx(i.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function cr(e){const{execution:t,nodes:o}=Y(),n=b.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),s=b.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,d)=>Object.assign(c,{[n[d.nodeId]]:d.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return b.useMemo(()=>De.get(s,e),[s,e])}function ur({collection:e,dataPath:t,children:o}){const n=j.useField(),s=b.useRef(null),{getAssociationAppends:a}=i.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),d=cr(t);let u,f;if(typeof e=="string"){const $=i.parseCollectionName(e);u=$[0],f=$[1]}else f=e;const h=b.useMemo(()=>ye.createForm({values:d,readPretty:!0}),[d]),x={appends:l},y={loading:!1,data:{data:d}},k=i.useAPIClient().resource(f),T=i.useBlockRequestContext();return r.jsx(i.CollectionProvider_deprecated,{dataSource:u,collection:f,children:r.jsx(i.RecordProvider,{record:d,parent:null,children:r.jsx(i.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:y,resource:k,__parent:T},children:r.jsx(i.FormBlockContext.Provider,{value:{params:x,form:h,field:n,service:y,updateAssociationValues:c,formBlockRef:s},children:o})})})})}function dr(e){const a=e,{options:t=[],direction:o}=a,n=Z(a,["options","direction"]),s=i.useCompile();return r.jsx(g.Checkbox.Group,O(C({},n),{children:r.jsx(g.Space,{direction:o,children:t.map(l=>r.jsxs(g.Checkbox,{value:l.value,children:[r.jsx("span",{className:i.css`
551
+ `,children:[r.jsx(b.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(b.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function dr({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(Oo,{value:o.group,onChange:n=>t(O(C({},o),{group:n}))})}class pr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Condition", { ns: "${p}" })}}`);w(this,"type","condition");w(this,"group","control");w(this,"description",`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${p}" })}}`);w(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${p}" })}}`}],...Array.from($e.evaluators.getEntities()).filter(([o])=>["math.js","formula.js"].includes(o))].reduce((o,[n,s])=>o.concat(C({value:n},s)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:s}){const{values:a}=s,{evaluate:l}=$e.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(c),""}catch(d){return N("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});w(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);w(this,"scope",{renderEngineReference:So,useWorkflowVariableOptions:me});w(this,"components",{CalculationConfig:dr,WorkflowVariableTextArea:Et,RadioWithTooltip:Te})}Component({data:o}){const{t:n}=Z.useTranslation(),{nodes:s}=q(),{styles:a}=ne(),{id:l,config:{rejectOnFalse:c}}=o,d=s.find(f=>f.upstreamId===l&&f.branchIndex===1),u=s.find(f=>f.upstreamId===l&&f.branchIndex===0);return r.jsx(xt,{data:o,children:c?null:r.jsxs("div",{className:a.nodeSubtreeClass,children:[r.jsxs("div",{className:a.branchBlockClass,children:[r.jsx(Ke,{from:o,entry:u,branchIndex:0}),r.jsx(Ke,{from:o,entry:d,branchIndex:1})]}),r.jsxs("div",{className:a.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class mr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("End process", { ns: "${p}" })}}`);w(this,"type","end");w(this,"group","control");w(this,"description",`{{t("End the process immediately, with set status.", { ns: "${p}" })}}`);w(this,"fieldset",{endStatus:{type:"number",title:`{{t("End status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${p}" })}}`,value:le.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:le.FAILED}],required:!0,default:le.RESOLVED}});w(this,"end",!0)}}function ot({value:e,onChange:t,renderSchemaComponent:o}){const n=me();return r.jsx(i.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function fr(e){const{execution:t,nodes:o}=q(),n=g.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),s=g.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,d)=>Object.assign(c,{[n[d.nodeId]]:d.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return g.useMemo(()=>ke.get(s,e),[s,e])}function hr({collection:e,dataPath:t,children:o}){const n=j.useField(),s=g.useRef(null),{getAssociationAppends:a}=i.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),d=fr(t);let u,f;if(typeof e=="string"){const E=i.parseCollectionName(e);u=E[0],f=E[1]}else f=e;const h=g.useMemo(()=>ie.createForm({values:d,readPretty:!0}),[d]),x={appends:l},y={loading:!1,data:{data:d}},k=i.useAPIClient().resource(f),F=i.useBlockRequestContext();return r.jsx(i.CollectionProvider_deprecated,{dataSource:u,collection:f,children:r.jsx(i.RecordProvider,{record:d,parent:null,children:r.jsx(i.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:y,resource:k,__parent:F},children:r.jsx(i.FormBlockContext.Provider,{value:{params:x,form:h,field:n,service:y,updateAssociationValues:c,formBlockRef:s},children:o})})})})}function yr(e){const a=e,{options:t=[],direction:o}=a,n=X(a,["options","direction"]),s=i.useCompile();return r.jsx(b.Checkbox.Group,O(C({},n),{children:r.jsx(b.Space,{direction:o,children:t.map(l=>r.jsxs(b.Checkbox,{value:l.value,children:[r.jsx("span",{className:i.css`
552
552
  & + .anticon {
553
553
  margin-left: 0.25em;
554
554
  }
555
- `,children:s(l.label)}),l.tooltip&&r.jsx(g.Tooltip,{title:s(l.tooltip),children:r.jsx(D.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function pr({key:e,title:t,config:o},n){var u,f;const[s,a]=i.parseCollectionName(o.collection),l=i.useCompile(),c=Ve(s),[d]=Se(O(C({appends:[e,...((f=(u=o.params)==null?void 0:u.appends)==null?void 0:f.map(h=>`${e}.${h}`))||[]]},n),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:l,getCollectionFields:c}));return d}class mr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Query record", { ns: "${p}" })}}`);w(this,"type","query");w(this,"group","collection");w(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:O(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean",title:`{{t("Result type", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Single record", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("The result will be an object of the first matching record only, or null if no matched record.", { ns: "${p}" })}}`},{label:`{{t("Multiple records", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The result will be an array containing matched records, or an empty one if no matching records. This can be used to be processed in a loop node.", { ns: "${p}" })}}`}]},required:!0,default:!1},params:{type:"object","x-component":"fieldset",properties:{filter:Ke,sort:Sn,pagination:An,appends:Be},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${p}" })}}`}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useSortableFields(){const o=i.useCompile(),{values:n}=j.useForm(),[s,a]=i.parseCollectionName(n.collection),l=i.useApp(),{collectionManager:c}=l.dataSourceManager.getDataSource(s);return c.getCollectionFields(a).filter(u=>{if(!u.interface)return!1;const f=l.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(u.interface);return!!(f!=null&&f.sortable)}).map(u=>{var f,h;return{value:u.name,label:(f=u==null?void 0:u.uiSchema)!=null&&f.title?o((h=u==null?void 0:u.uiSchema)==null?void 0:h.title):u.name}})}});w(this,"components",{ArrayItems:Jo.ArrayItems,FilterDynamicComponent:et,SchemaComponentContext:i.SchemaComponentContext,WorkflowVariableInput:oo,RadioWithTooltip:Te});w(this,"useVariables",pr)}useInitializers(o){var n,s;return!o.config.collection||o.config.multiple?null:{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Pe,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function fr(e){const{getCollectionFields:t}=i.useCollectionManager_deprecated(),{path:o}=j.useField(),n=o.segments[o.segments.length-1],{values:s}=j.useForm(),[a,l]=i.parseCollectionName(s==null?void 0:s.collection),c=t(l,a),{type:d}=c.find(h=>h.name===n),u=Array.isArray(e.value)?e.value.join(","):e.value,f=b.useCallback(h=>{const x=h.target.value.trim(),y=["belongsTo","hasOne"].includes(d)?x||null:x.split(",").map(m=>m.trim()).filter(m=>m!=="");e.onChange(y)},[e.onChange,d]);return r.jsx(g.Input,O(C({},e),{value:u,onChange:f}))}const So=j.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=i.useToken(),{t:a}=Q.useTranslation(),l=i.useCompile(),c=j.useForm(),{getCollectionFields:d}=i.useCollectionManager_deprecated(),u=me(),{values:f}=c,[h,x]=i.parseCollectionName(f==null?void 0:f.collection),y=d(x,h).filter(A=>A.uiSchema),m=n?y.filter(n.bind(f)):y,k=b.useMemo(()=>m.filter(A=>!e||!(A.name in e)),[m,e]),T=t||c.disabled,$=b.useMemo(()=>({onClick:({key:A})=>{o(O(C({},e),{[A]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(A=>{var P,z;return{key:A.name,label:l((z=(P=A.uiSchema)==null?void 0:P.title)!=null?z:A.name)}})}),[o,k,e]);return r.jsx("fieldset",{className:i.css`
555
+ `,children:s(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:s(l.tooltip),children:r.jsx($.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function gr({key:e,title:t,config:o},n){var u,f;const[s,a]=i.parseCollectionName(o.collection),l=i.useCompile(),c=je(s),[d]=Ae(O(C({appends:[e,...((f=(u=o.params)==null?void 0:u.appends)==null?void 0:f.map(h=>`${e}.${h}`))||[]]},n),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:l,getCollectionFields:c}));return d}class br extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Query record", { ns: "${p}" })}}`);w(this,"type","query");w(this,"group","collection");w(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:O(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean",title:`{{t("Result type", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Single record", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("The result will be an object of the first matching record only, or null if no matched record.", { ns: "${p}" })}}`},{label:`{{t("Multiple records", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The result will be an array containing matched records, or an empty one if no matching records. This can be used to be processed in a loop node.", { ns: "${p}" })}}`}]},required:!0,default:!1},params:{type:"object","x-component":"fieldset",properties:{filter:Ze,sort:Nn,pagination:En,appends:Ve},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${p}" })}}`}});w(this,"scope",{useNodeSavedConfig:Pe,useCollectionDataSource:i.useCollectionDataSource,useSortableFields(){const o=i.useCompile(),{values:n}=j.useForm(),[s,a]=i.parseCollectionName(n.collection),l=i.useApp(),{collectionManager:c}=l.dataSourceManager.getDataSource(s);return c.getCollectionFields(a).filter(u=>{if(!u.interface)return!1;const f=l.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(u.interface);return!!(f!=null&&f.sortable)}).map(u=>{var f,h;return{value:u.name,label:(f=u==null?void 0:u.uiSchema)!=null&&f.title?o((h=u==null?void 0:u.uiSchema)==null?void 0:h.title):u.name}})}});w(this,"components",{ArrayItems:Pt.ArrayItems,FilterDynamicComponent:ot,SchemaComponentContext:i.SchemaComponentContext,WorkflowVariableInput:so,RadioWithTooltip:Te});w(this,"useVariables",gr)}useInitializers(o){var n,s;return!o.config.collection||o.config.multiple?null:{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Be,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function vr(e){const{getCollectionFields:t}=i.useCollectionManager_deprecated(),{path:o}=j.useField(),n=o.segments[o.segments.length-1],{values:s}=j.useForm(),[a,l]=i.parseCollectionName(s==null?void 0:s.collection),c=t(l,a),{type:d}=c.find(h=>h.name===n),u=Array.isArray(e.value)?e.value.join(","):e.value,f=g.useCallback(h=>{const x=h.target.value.trim(),y=["belongsTo","hasOne"].includes(d)?x||null:x.split(",").map(m=>m.trim()).filter(m=>m!=="");e.onChange(y)},[e.onChange,d]);return r.jsx(b.Input,O(C({},e),{value:u,onChange:f}))}const Fo=j.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=i.useToken(),{t:a}=Z.useTranslation(),l=i.useCompile(),c=j.useForm(),{getCollectionFields:d}=i.useCollectionManager_deprecated(),u=me(),{values:f}=c,[h,x]=i.parseCollectionName(f==null?void 0:f.collection),y=d(x,h).filter(S=>S.uiSchema),m=n?y.filter(n.bind(f)):y,k=g.useMemo(()=>m.filter(S=>!e||!(S.name in e)),[m,e]),F=t||c.disabled,E=g.useMemo(()=>({onClick:({key:S})=>{o(O(C({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(S=>{var M,W;return{key:S.name,label:l((W=(M=S.uiSchema)==null?void 0:M.title)!=null?W:S.name)}})}),[o,k,e]);return r.jsx("fieldset",{className:i.css`
556
556
  margin-top: 0.5em;
557
557
 
558
558
  > .ant-formily-item {
@@ -562,8 +562,8 @@
562
562
  line-height: 32px;
563
563
  }
564
564
  }
565
- `,children:m.length?r.jsxs(i.CollectionProvider_deprecated,{name:x,dataSource:h,children:[m.filter(A=>e&&A.name in e).map(A=>{var z,U;const P=["belongsTo","hasOne","hasMany","belongsToMany"].includes(A.type)?fr:i.CollectionField;return r.jsxs(g.Form.Item,{label:l((U=(z=A.uiSchema)==null?void 0:z.title)!=null?U:A.name),labelAlign:"left",className:i.css`
565
+ `,children:m.length?r.jsxs(i.CollectionProvider_deprecated,{name:x,dataSource:h,children:[m.filter(S=>e&&S.name in e).map(S=>{var W,J;const M=["belongsTo","hasOne","hasMany","belongsToMany"].includes(S.type)?vr:i.CollectionField;return r.jsxs(b.Form.Item,{label:l((J=(W=S.uiSchema)==null?void 0:W.title)!=null?J:S.name),labelAlign:"left",className:i.css`
566
566
  .ant-form-item-control-input-content {
567
567
  display: flex;
568
568
  }
569
- `,children:[r.jsx(i.Variable.Input,{scope:u,value:e[A.name],changeOnSelect:!0,onChange:F=>{o(O(C({},e),{[A.name]:F}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[A.name]:{"x-component":P,"x-validator"(){return""}}}}})}),T?null:r.jsx(g.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(D.CloseCircleOutlined,{}),onClick:()=>{var S;const I=e,{[S=A.name]:F}=I,M=Z(I,[zo(S)]);o(M)}})]},A.name)}),k.length?r.jsx(g.Dropdown,{menu:$,children:r.jsx(g.Button,{icon:r.jsx(D.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:N("Please select collection first")})})},{displayName:"CollectionFieldSet"});function hr({key:e,title:t,config:o},n){var u,f;const[s,a]=i.parseCollectionName(o.collection),l=i.useCompile(),c=Ve(s),[d]=Se(O(C({appends:[e,...((f=(u=o.params)==null?void 0:u.appends)==null?void 0:f.map(h=>`${e}.${h}`))||[]]},n),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:l,getCollectionFields:c}));return d}class yr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Create record", { ns: "${p}" })}}`);w(this,"type","create");w(this,"group","collection");w(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:O(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:Zt,appends:Be}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{CollectionFieldset:So});w(this,"useVariables",hr)}useInitializers(o){var n,s;return o.config.collection?{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Pe,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}function gr(o){var n=o,{onChange:e}=n,t=Z(n,["onChange"]);const{getCollectionFields:s}=i.useCollectionManager_deprecated(),a=j.useForm(),{collection:l}=a.values,c=s(l),d=j.useField();function u({target:f}){const h=d.query(".values").take();if(!h)return;const x=c.reduce((y,m)=>(m.name in h.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(m.type))&&(y[m.name]=h.value[m.name]),y),{});a.setValuesIn("params.values",x),e(f.value)}return r.jsx(Te,O(C({},t),{onChange:u}))}class br extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Update record", { ns: "${p}" })}}`);w(this,"type","update");w(this,"group","collection");w(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:O(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${p}" })}}`}]},default:!1},filter:O(C({},Ke),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return H.isValidFilter(o)?"":N("Please add at least one condition")}}),values:O(C({},Zt),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(o.type)}}})}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:et,CollectionFieldset:So,IndividualHooksRadioWithTooltip:gr})}}class vr extends ge{constructor(){super(...arguments);w(this,"title",'{{t("Delete record")}}');w(this,"type","destroy");w(this,"group","collection");w(this,"description",`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:O(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:O(C({},Ke),{"x-validator"(o){return H.isValidFilter(o)?"":N("Please add at least one condition")}})}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:et})}}const xr=new i.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:i.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=i.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:i.SecondConFirm},{name:"assignFieldValues",Component:i.AssignedFieldValues},{name:"skipRequiredValidation",Component:i.SkipValidation},{name:"afterSuccessfulSubmission",Component:i.AfterSuccess,useVisible(){var t;const e=j.useFieldSchema();return $t.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:i.WorkflowConfig},{name:"delete",sort:100,Component:i.RemoveButton,useComponentProps(){const{removeButtonProps:e}=i.useSchemaToolbar();return e}}]});function wr({children:e,workflow:t,execution:o,nodes:n}){const s=i.usePlugin(ce),a=s.triggers.get(t.type).components,l=n.reduce((c,{type:d})=>Object.assign(c,s.instructions.get(d).components),{});return r.jsx(Me.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(i.SchemaComponentOptions,{components:C(C({},a),l),children:e})})}class ce extends i.Plugin{constructor(){super(...arguments);w(this,"triggers",new H.Registry);w(this,"instructions",new H.Registry);w(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(a=>{var[o,l]=a,c=l,{title:n}=c,s=Z(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}isWorkflowSync(o){var n;return(n=this.triggers.get(o.type).sync)!=null?n:o.sync}registerTrigger(o,n){if(typeof n=="function")this.triggers.register(o,new n);else if(n)this.triggers.register(o,n);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,n){if(typeof n=="function")this.instructions.register(o,new n);else if(n instanceof ge)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}load(){return G(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:ve(":id"),element:r.jsx(Kt,{})}),this.app.router.add("admin.workflow.executions.id",{path:Ye(":id"),element:r.jsx(Ht,{})}),this.app.addComponents({WorkflowPage:Kt,ExecutionPage:Ht}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:wn,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(xr),this.registerTrigger("collection",In),this.registerTrigger("schedule",Rn),this.registerInstruction("calculation",or),this.registerInstruction("condition",lr),this.registerInstruction("end",ar),this.registerInstruction("query",mr),this.registerInstruction("create",yr),this.registerInstruction("update",br),this.registerInstruction("destroy",vr)})}}v.BaseTypeSets=_e,v.Branch=qe,v.CheckboxGroupWithTooltip=dr,v.CollectionBlockInitializer=Pe,v.DetailsBlockProvider=ur,v.EXECUTION_STATUS=de,v.ExecutionContextProvider=wr,v.ExecutionStatusOptions=Je,v.ExecutionStatusOptionsMap=Ue,v.FieldsSelect=Ct,v.FilterDynamicComponent=et,v.FlowContext=Me,v.Instruction=ge,v.JOB_STATUS=ie,v.JobButton=Lt,v.JobStatusOptions=ht,v.JobStatusOptionsMap=Ge,v.Node=jt,v.NodeContext=yt,v.NodeDefaultView=gt,v.RadioWithTooltip=Te,v.RemoveButton=Wt,v.SimpleDesigner=xo,v.Trigger=bt,v.ValueBlock=Fe,v.WorkflowVariableInput=oo,v.WorkflowVariableJSON=Fn,v.WorkflowVariableRawTextArea=Tn,v.WorkflowVariableTextArea=Tt,v.default=ce,v.defaultFieldNames=ke,v.getCollectionFieldOptions=Se,v.getWorkflowDetailPath=ve,v.getWorkflowExecutionsPath=Ye,v.linkNodes=xt,v.nodesOptions=Qt,v.scopeOptions=Rt,v.systemOptions=eo,v.traverseSchema=wt,v.triggerOptions=Xt,v.useAvailableUpstreams=Bt,v.useFlowContext=Y,v.useGetAriaLabelOfAddButton=ft,v.useGetCollectionFields=Ve,v.useNodeContext=Ce,v.useRecordTriggerWorkflowsActionProps=En,v.useStyles=ne,v.useTrigger=vt,v.useTriggerWorkflowsActionProps=Nn,v.useUpstreamScopes=Vt,v.useWorkflowAnyExecuted=no,v.useWorkflowExecuted=Dn,v.useWorkflowVariableOptions=me,Object.defineProperties(v,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
569
+ `,children:[r.jsx(i.Variable.Input,{scope:u,value:e[S.name],changeOnSelect:!0,onChange:T=>{o(O(C({},e),{[S.name]:T}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":M,"x-validator"(){return""}}}}})}),F?null:r.jsx(b.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx($.CloseCircleOutlined,{}),onClick:()=>{var A;const P=e,{[A=S.name]:T}=P,I=X(P,[Yo(A)]);o(I)}})]},S.name)}),k.length?r.jsx(b.Dropdown,{menu:E,children:r.jsx(b.Button,{icon:r.jsx($.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:N("Please select collection first")})})},{displayName:"CollectionFieldSet"});function To(e,t){t(e),e!=null&&e.properties&&Object.values(e.properties).forEach(o=>{To(o,t)})}function No(){return{name:He.uid(),type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields"}}function Eo(e){const{workflow:t}=q(),{setFormValueChanged:o}=i.useActionContext();i.useAPIClient();const n=me(),s=j.useForm(),{values:a,setValuesIn:l}=s,c=ft.toJS(a.params),[d,u]=i.parseCollectionName(a.collection),f=i.useSchemaOptionsContext(),[h,x]=g.useState(e.value&&Object.keys(e.value).length?e.value:No()),y=g.useMemo(()=>ie.createForm({initialValues:c.values,disabled:t.executed,effects(){ie.onFormValuesChange(k=>{l("params.values",ft.toJS(k.values)),o(!0)})}}),[t.executed]);j.useFormEffects(()=>{ie.onFieldValueChange("collection",k=>G(this,null,function*(){y.clearFormGraph("*");const F=No();l("params.values",{}),x(F)}))});const m=g.useCallback(k=>{const[F]=Object.values(k.toJSON().properties);e.onChange(F);const E=new Set;To(F,M=>{var W;if(M["x-component"]==="AssignedField"&&(W=M["x-collection-field"])!=null&&W.startsWith(`${u}.`)){const[,J]=M["x-collection-field"].split(".");E.add(J)}});const S={};Array.from(E).forEach(M=>{M in y.values&&(S[M]=y.values[M])}),l("params.values",S)},[u,e.onChange]);return r.jsx(i.CollectionManagerProvider,{dataSource:d,children:r.jsx(i.CollectionProvider,{name:u,children:r.jsx(i.FormProvider,{form:y,children:r.jsx(Pt.FormLayout,{layout:"vertical",children:r.jsx(i.VariableScopeProvider,{scope:n,children:r.jsx(i.SchemaComponentProvider,{form:y,designable:!0,children:r.jsx(i.SchemaComponentOptions,O(C({},f),{children:r.jsx(i.SchemaComponent,{schema:h,onChange:m})}))})})})})})})}function xr({key:e,title:t,config:o},n){var u,f;const[s,a]=i.parseCollectionName(o.collection),l=i.useCompile(),c=je(s),[d]=Ae(O(C({appends:[e,...((f=(u=o.params)==null?void 0:u.appends)==null?void 0:f.map(h=>`${e}.${h}`))||[]]},n),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:l,getCollectionFields:c}));return d}class wr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Create record", { ns: "${p}" })}}`);w(this,"type","create");w(this,"group","collection");w(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:O(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection"],fulfill:{state:{display:'{{($deps[0] && $self.value) ? "visible" : "hidden"}}'}}}]},params:{type:"object",properties:{values:O(C({},Rt),{"x-reactions":[{dependencies:["collection","assignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]}),appends:Ve}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useNodeSavedConfig:Pe});w(this,"components",{CollectionFieldset:Fo,AssignedFieldsFormSchemaConfig:Eo});w(this,"useVariables",xr)}createDefaultConfig(){return{assignFormSchema:{}}}useInitializers(o){var n,s;return o.config.collection?{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Be,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}class Cr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Update record", { ns: "${p}" })}}`);w(this,"type","update");w(this,"group","collection");w(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:O(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${p}" })}}`}]},default:!1},filter:O(C({},Ze),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return U.isValidFilter(o)?"":N("Please add at least one condition")}}),values:O(C({},Rt),{"x-reactions":[{dependencies:["collection","assignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]})}},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection"],fulfill:{state:{display:'{{($deps[0] && $self.value) ? "visible" : "hidden"}}'}}}]}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useNodeSavedConfig:Pe});w(this,"components",{FilterDynamicComponent:ot,CollectionFieldset:Fo,AssignedFieldsFormSchemaConfig:Eo,RadioWithTooltip:Te})}createDefaultConfig(){return{assignForm:He.uid()}}}class kr extends ge{constructor(){super(...arguments);w(this,"title",'{{t("Delete record")}}');w(this,"type","destroy");w(this,"group","collection");w(this,"description",`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:O(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:O(C({},Ze),{"x-validator"(o){return U.isValidFilter(o)?"":N("Please add at least one condition")}})}}});w(this,"scope",{useNodeSavedConfig:Pe,useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:ot})}}const Sr=new i.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:i.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=i.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:i.SecondConFirm},{name:"assignFieldValues",Component:i.AssignedFieldValues},{name:"skipRequiredValidation",Component:i.SkipValidation},{name:"afterSuccessfulSubmission",Component:i.AfterSuccess,useVisible(){var t;const e=j.useFieldSchema();return He.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:i.WorkflowConfig},{name:"delete",sort:100,Component:i.RemoveButton,useComponentProps(){const{removeButtonProps:e}=i.useSchemaToolbar();return e}}]});function Ar({children:e,workflow:t,execution:o,nodes:n}){const s=i.usePlugin(ue),a=s.triggers.get(t.type).components,l=n.reduce((c,{type:d})=>Object.assign(c,s.instructions.get(d).components),{});return r.jsx(Me.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(i.SchemaComponentOptions,{components:C(C({},a),l),children:e})})}class ue extends i.Plugin{constructor(){super(...arguments);w(this,"triggers",new U.Registry);w(this,"instructions",new U.Registry);w(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(a=>{var[o,l]=a,c=l,{title:n}=c,s=X(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}isWorkflowSync(o){var n;return(n=this.triggers.get(o.type).sync)!=null?n:o.sync}registerTrigger(o,n){if(typeof n=="function")this.triggers.register(o,new n);else if(n)this.triggers.register(o,n);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,n){if(typeof n=="function")this.instructions.register(o,new n);else if(n instanceof ge)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}load(){return G(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:xe(":id"),element:r.jsx(Qt,{})}),this.app.router.add("admin.workflow.executions.id",{path:_e(":id"),element:r.jsx(Gt,{})}),this.app.addComponents({WorkflowPage:Qt,ExecutionPage:Gt}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:On,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(Sr),this.registerTrigger("collection",Wn),this.registerTrigger("schedule",rr),this.registerInstruction("calculation",lr),this.registerInstruction("condition",pr),this.registerInstruction("end",mr),this.registerInstruction("query",br),this.registerInstruction("create",wr),this.registerInstruction("update",Cr),this.registerInstruction("destroy",kr)})}}v.BaseTypeSets=Qe,v.Branch=Ke,v.CheckboxGroupWithTooltip=yr,v.CollectionBlockInitializer=Be,v.DetailsBlockProvider=hr,v.EXECUTION_STATUS=pe,v.ExecutionContextProvider=Ar,v.ExecutionStatusOptions=Ge,v.ExecutionStatusOptionsMap=qe,v.FieldsSelect=At,v.FilterDynamicComponent=ot,v.FlowContext=Me,v.Instruction=ge,v.JOB_STATUS=le,v.JobButton=Ut,v.JobStatusOptions=bt,v.JobStatusOptionsMap=Ye,v.Node=zt,v.NodeContext=vt,v.NodeDefaultView=xt,v.RadioWithTooltip=Te,v.RemoveButton=Jt,v.SimpleDesigner=ko,v.Trigger=wt,v.ValueBlock=Ne,v.WorkflowVariableInput=so,v.WorkflowVariableJSON=Mn,v.WorkflowVariableRawTextArea=$n,v.WorkflowVariableTextArea=Et,v.default=ue,v.defaultFieldNames=Se,v.getCollectionFieldOptions=Ae,v.getWorkflowDetailPath=xe,v.getWorkflowExecutionsPath=_e,v.linkNodes=kt,v.nodesOptions=eo,v.scopeOptions=oo,v.systemOptions=no,v.traverseSchema=St,v.triggerOptions=to,v.useAvailableUpstreams=Wt,v.useFlowContext=q,v.useGetAriaLabelOfAddButton=gt,v.useGetCollectionFields=je,v.useNodeContext=ve,v.useNodeSavedConfig=Pe,v.useRecordTriggerWorkflowsActionProps=Pn,v.useStyles=ne,v.useTrigger=Ct,v.useTriggerWorkflowsActionProps=In,v.useUpstreamScopes=Lt,v.useWorkflowAnyExecuted=io,v.useWorkflowExecuted=Bn,v.useWorkflowVariableOptions=me,Object.defineProperties(v,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});