@tachybase/module-workflow 1.6.20 → 1.6.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/client/features/exit-branch/index.d.ts +4 -0
  2. package/dist/client/index.js +40 -40
  3. package/dist/externalVersion.js +8 -8
  4. package/dist/locale/en-US.json +2 -0
  5. package/dist/locale/zh-CN.json +2 -0
  6. package/dist/node_modules/@babel/core/lib/index.js +28 -28
  7. package/dist/node_modules/@babel/core/package.json +1 -1
  8. package/dist/node_modules/@babel/preset-env/lib/index.js +40 -40
  9. package/dist/node_modules/@babel/preset-env/package.json +1 -1
  10. package/dist/node_modules/@babel/preset-react/lib/index.js +23 -23
  11. package/dist/node_modules/@babel/preset-react/package.json +1 -1
  12. package/dist/node_modules/@babel/preset-typescript/lib/index.js +28 -28
  13. package/dist/node_modules/@babel/preset-typescript/package.json +1 -1
  14. package/dist/node_modules/cron-parser/package.json +1 -1
  15. package/dist/node_modules/form-data/package.json +1 -1
  16. package/dist/node_modules/jsonata/package.json +1 -1
  17. package/dist/node_modules/lru-cache/package.json +1 -1
  18. package/dist/node_modules/mime-types/package.json +1 -1
  19. package/dist/node_modules/qrcode/package.json +1 -1
  20. package/dist/server/Plugin.js +15 -3
  21. package/dist/server/collections/executions.d.ts +1 -1
  22. package/dist/server/collections/flow_nodes.d.ts +1 -1
  23. package/dist/server/collections/jobs.d.ts +1 -1
  24. package/dist/server/collections/workflowCategories.d.ts +1 -1
  25. package/dist/server/collections/workflows.d.ts +1 -1
  26. package/dist/server/features/exit-branch/ExitBranchInstruction.d.ts +4 -0
  27. package/dist/server/features/exit-branch/ExitBranchInstruction.js +51 -0
  28. package/dist/server/features/exit-branch/Plugin.d.ts +4 -0
  29. package/dist/server/features/exit-branch/Plugin.js +45 -0
  30. package/dist/server/features/exit-branch/index.d.ts +1 -0
  31. package/dist/server/features/exit-branch/index.js +21 -0
  32. package/dist/server/features/interception/RequestInterceptionTrigger.js +5 -1
  33. package/dist/server/features/omni-trigger/CustomActionTrigger.js +5 -1
  34. package/dist/server/features/trigger-instruction/TriggerInstruction.d.ts +1 -10
  35. package/dist/server/features/trigger-instruction/TriggerInstruction.js +7 -3
  36. package/dist/server/instructions/QueryInstruction.js +1 -1
  37. package/dist/server/instructions/SelectInstruction.js +1 -1
  38. package/dist/server/triggers/ScheduleTrigger/DateFieldScheduleTrigger.js +2 -4
  39. package/package.json +15 -11
@@ -1,4 +1,4 @@
1
- (function(k,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("@tachybase/client"),require("@tego/client"),require("react/jsx-runtime"),require("react"),require("@ant-design/icons"),require("antd"),require("react-router-dom"),require("react-i18next"),require("@tachybase/schema"),require("lodash"),require("dayjs"),require("@dnd-kit/core")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client","react/jsx-runtime","react","@ant-design/icons","antd","react-router-dom","react-i18next","@tachybase/schema","lodash","dayjs","@dnd-kit/core"],s):(k=typeof globalThis!="undefined"?globalThis:k||self,s(k["@tachybase/module-workflow"]={},k["@tachybase/client"],k["@tego/client"],k.jsxRuntime,k.react,k["@ant-design/icons"],k.antd,k["react-router-dom"],k["react-i18next"],k["@tachybase/schema"],k.lodash,k.dayjs,k["@dnd-kit/core"]))})(this,function(k,s,W,r,x,H,b,se,ee,A,ae,mt,Be){"use strict";var Sc=Object.defineProperty,Ac=Object.defineProperties;var Ic=Object.getOwnPropertyDescriptors;var Wt=Object.getOwnPropertySymbols;var ir=Object.prototype.hasOwnProperty,lr=Object.prototype.propertyIsEnumerable;var ar=(k,s,W)=>s in k?Sc(k,s,{enumerable:!0,configurable:!0,writable:!0,value:W}):k[s]=W,v=(k,s)=>{for(var W in s||(s={}))ir.call(s,W)&&ar(k,W,s[W]);if(Wt)for(var W of Wt(s))lr.call(s,W)&&ar(k,W,s[W]);return k},F=(k,s)=>Ac(k,Ic(s));var cr=k=>typeof k=="symbol"?k:k+"",Q=(k,s)=>{var W={};for(var r in k)ir.call(k,r)&&s.indexOf(r)<0&&(W[r]=k[r]);if(k!=null&&Wt)for(var r of Wt(k))s.indexOf(r)<0&&lr.call(k,r)&&(W[r]=k[r]);return W};var P=(k,s,W)=>new Promise((r,x)=>{var H=ee=>{try{se(W.next(ee))}catch(A){x(A)}},b=ee=>{try{se(W.throw(ee))}catch(A){x(A)}},se=ee=>ee.done?r(ee.value):Promise.resolve(ee.value).then(H,b);se((W=W.apply(k,s)).next())});function dr({collection:e}){return e}function ur(e){return!0}function jt(e){return e.target&&e.interface}function pr(e){const t=fo.call(this,e.field.target,e);return t.length&&t.some(o=>jt(o.field))||(e.isLeaf=!0),t}function fo(e,t,o={needLeaf:!0}){const{needLeaf:n}=o,[a,i]=s.parseCollectionName(e),l=this.getCollectionFields(i,a),c=n?l:l.filter(jt),d=pr.bind(this);return c.filter(this.filter).map(u=>{var h,g,w;const p=t?`${t.value?`${t.value}.`:""}${u.name}`:u.name,f=(g=this.compile((h=u.uiSchema)==null?void 0:h.title))!=null?g:u.name,y=!this.getCollectionFields(u.target).filter(jt).filter(this.filter).length;return{pId:(w=t==null?void 0:t.key)!=null?w:null,id:p,key:p,value:p,title:f,isLeaf:y,loadChildren:y?null:d,field:u,fullTitle:t?[...t.fullTitle,f]:[f]}})}const mr=e=>{const G=e,{title:t,value:o,onChange:n,collection:a,useCollection:i=dr,filter:l=ur,rootOption:c,loadData:d,needLeaf:u=!1}=G,p=Q(G,["title","value","onChange","collection","useCollection","filter","rootOption","loadData","needLeaf"]),f=s.useCompile(),{t:y}=s.useTranslation(),[h,g]=x.useState({}),w=i({collection:a}),[C,D]=s.parseCollectionName(w),{getCollectionFields:S}=s.useCollectionManager_deprecated(C),I=Object.values(h),M=x.useMemo(()=>e.multiple?(o||[]).map(j=>h[j]).filter(Boolean):o,[o,e.multiple,h]),E=x.useCallback(j=>P(null,null,function*(){if(d!=null)return d(j);if(!j.isLeaf&&j.loadChildren){const X=j.loadChildren(j);g(B=>X.reduce((L,$)=>{var U;return Object.assign(L,{[$.value]:F(v({},$),{label:$.fullTitle.length?(U=$.fullTitle)==null?void 0:U.join(" / "):$.title})})},v({},B)))}}),[d]);x.useEffect(()=>{const j=c?F(v({},c),{id:c.value,key:c.value,title:c.label,fullTitle:c.label,isLeaf:!1}):null,B=(d===null?[]:fo.call({compile:f,getCollectionFields:S,filter:l},w,j,{needLeaf:u})).reduce((L,$)=>{var U;return Object.assign(L,{[$.value]:F(v({},$),{label:$.fullTitle.length?(U=$.fullTitle)==null?void 0:U.join(" / "):$.title})})},{});j&&(B[j.value]=j),g(B)},[w,c,l,d]),x.useEffect(()=>{const j=e.multiple?o:typeof o=="string"?[o]:o||[];if(!(j!=null&&j.length)||j.every(B=>!!h[B]))return;const X=[];j.forEach(B=>{const L=B.split(".");let $=h[L[0]];for(let U=1;U<L.length&&$;U++){const J=L.slice(0,U+1).join(".");if(h[J]){$=h[J];break}if(!$.isLeaf&&$.loadChildren){const _=$.loadChildren($);_!=null&&_.length&&(X.push(..._),$=_.find(R=>R.value===L.slice(0,U+1).join(".")))}}}),g(B=>X.reduce((L,$)=>{var U;return Object.assign(L,{[$.value]:F(v({},$),{label:$.fullTitle.length?(U=$.fullTitle)==null?void 0:U.join(" / "):$.title})})},v({},B)))},[o,I.length,e.multiple]);const N=x.useCallback(j=>{if(!e.multiple){n(j);return}const X=j.map($=>$.value).filter(Boolean),B=new Set(X),L=M.find($=>!B.has($.value));if(L){const $=`${L.value}.`;Object.keys(h).forEach(U=>{U.startsWith($)&&B.delete(U)})}else X.forEach($=>{const U=$.split(".");if(U.length)for(let J=1;J<=U.length;J++)B.add(U.slice(0,J).join("."))});n(Array.from(B))},[e.multiple,M,n,h]),V=x.useCallback(j=>{var J;const{value:X,onClose:B,disabled:L,closable:$}=j;if(!X)return null;const{fullTitle:U}=(J=h[X])!=null?J:{};return r.jsx(b.Tag,{closable:$&&!L,onClose:B,children:U==null?void 0:U.join(" / ")})},[h]),K=Array.isArray(M)?M.filter(j=>j.value in h):M,q=e.multiple?o:o!=null?[o]:[];return r.jsx(b.TreeSelect,v({"data-testid":`select-field${t?`-${t}`:""}`,value:K,placeholder:y("Select field"),showCheckedStrategy:b.TreeSelect.SHOW_ALL,treeDefaultExpandedKeys:q,allowClear:{clearIcon:r.jsx(H.CloseCircleFilled,{role:"button","aria-label":"icon-close"})},treeCheckStrictly:e.multiple,treeCheckable:e.multiple,tagRender:V,treeNodeLabelProp:"label",onChange:N,treeDataSimpleMode:!0,treeData:I,loadData:E},p))},m="workflow";function O(e,t={}){return s.i18n.t(e,F(v({},t),{ns:[m,"core"]}))}function ve(){return ee.useTranslation([m,"core"])}const T=(e,t={})=>s.tval(e,v({ns:[m,"core"]},t)),fr=()=>{const{t:e}=ve(),t=se.useNavigate(),{token:o}=s.useToken();return r.jsx(b.Tooltip,{title:e("Workflow"),children:r.jsx(b.Button,{icon:r.jsx(s.Icon,{type:"workflow",style:{color:o.colorTextHeaderMenu}}),title:e("Workflow"),onClick:()=>{t("/_admin/business-components/workflow")}})})},ft=(e,t)=>({getAriaLabel:x.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])}),go=x.createContext({}),gr=go.Provider;function hr(){return x.useContext(go)}const Ve=x.createContext({}),yr=Ve.Provider;function Y(){return x.useContext(Ve)}var _e=(e=>(e.CONTROL="control",e.COLLECTION="collection",e.EXTENDED="extended",e.MANUAL="manual",e.ADVANCED="advanced",e))(_e||{});class oe{}function xr(e){var g;const{upstream:t,branchIndex:o=null}=e,n=s.usePlugin(re),a=s.useCompile(),i=s.useAPIClient(),{workflow:l,refresh:c}=(g=Y())!=null?g:{},d=Array.from(n.instructions.getValues()),u=x.useMemo(()=>wr(d,{engine:n,workflow:l,upstream:t,branchIndex:o,compile:a}),[o,n,d,t,l]),[p,f]=x.useState(!1),y=x.useCallback(C=>P(null,[C],function*({keyPath:w}){var E,N,V;const D=w.pop(),S={},[I]=w,M=n.instructions.get(D);if(I){const{value:K}=(N=(E=M.options)==null?void 0:E.find(q=>q.key===I))!=null?N:{};Object.assign(S,typeof K=="function"?K():K)}l&&(yield i.resource("workflows.nodes",l.id).create({values:{type:D,upstreamId:(V=t==null?void 0:t.id)!=null?V:null,branchIndex:o,title:a(M.title),config:S}}),c())}),[i,o,n.instructions,c,t==null?void 0:t.id,l]),h=x.useMemo(()=>({onClick:w=>{const{keyPath:C}=w||{};(C==null?void 0:C[0])==="load"?f(!0):y(w)},items:u}),[u,y]);return{workflow:l,menu:h,isShowUploadModal:p,setIsShowUploadModal:f}}const ho=[{key:_e.CONTROL,label:O("Control")},{key:_e.COLLECTION,label:O("Collection operations")},{key:_e.MANUAL,label:O("Manual")},{key:_e.EXTENDED,label:O("Extended types")}],br={key:"hot",label:O("Hot tools")},vr={key:"load",label:O("Load")};function wr(e,{engine:t,workflow:o,upstream:n,branchIndex:a,compile:i}){const l=[],c=[];for(const d of ho){const u=e.filter(y=>{var h,g;return y.group===d.key&&((g=(h=y.isAvailable)==null?void 0:h.call(y,{engine:t,workflow:o,upstream:n,branchIndex:a}))!=null?g:!0)});let p=[];for(const y of u){const{type:h,title:g,icon:w,color:C,options:D,isHot:S}=y,I=yo(w,C),M={role:"button","aria-label":h,key:h,label:i(g),type:D?"subMenu":null,icon:I,children:D?D.map(E=>({role:"button","aria-label":E.key,key:E.key,label:i(E.label)})):null};p.push(M),S&&c.push(M)}const f=F(v({},d),{type:"group",children:p});l.push(f)}return l.unshift(F(v({},vr),{type:"group",children:[{key:"load","aria-label":"load",role:"button",label:O("Upload node"),icon:yo("ToTopOutlined","#ff92ca")}]})),l.unshift(F(v({},br),{type:"group",children:c})),l.filter(d=>d.children.length)}function yo(e,t){return r.jsx("div",{className:s.css`
1
+ (function(k,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("@tachybase/client"),require("@tego/client"),require("react/jsx-runtime"),require("react"),require("@ant-design/icons"),require("antd"),require("react-router-dom"),require("react-i18next"),require("@tachybase/schema"),require("lodash"),require("dayjs"),require("@dnd-kit/core")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client","react/jsx-runtime","react","@ant-design/icons","antd","react-router-dom","react-i18next","@tachybase/schema","lodash","dayjs","@dnd-kit/core"],s):(k=typeof globalThis!="undefined"?globalThis:k||self,s(k["@tachybase/module-workflow"]={},k["@tachybase/client"],k["@tego/client"],k.jsxRuntime,k.react,k["@ant-design/icons"],k.antd,k["react-router-dom"],k["react-i18next"],k["@tachybase/schema"],k.lodash,k.dayjs,k["@dnd-kit/core"]))})(this,function(k,s,W,r,x,H,b,se,ee,A,ae,mt,Be){"use strict";var Ic=Object.defineProperty,Fc=Object.defineProperties;var Tc=Object.getOwnPropertyDescriptors;var Wt=Object.getOwnPropertySymbols;var ir=Object.prototype.hasOwnProperty,lr=Object.prototype.propertyIsEnumerable;var ar=(k,s,W)=>s in k?Ic(k,s,{enumerable:!0,configurable:!0,writable:!0,value:W}):k[s]=W,v=(k,s)=>{for(var W in s||(s={}))ir.call(s,W)&&ar(k,W,s[W]);if(Wt)for(var W of Wt(s))lr.call(s,W)&&ar(k,W,s[W]);return k},F=(k,s)=>Fc(k,Tc(s));var cr=k=>typeof k=="symbol"?k:k+"",Q=(k,s)=>{var W={};for(var r in k)ir.call(k,r)&&s.indexOf(r)<0&&(W[r]=k[r]);if(k!=null&&Wt)for(var r of Wt(k))s.indexOf(r)<0&&lr.call(k,r)&&(W[r]=k[r]);return W};var P=(k,s,W)=>new Promise((r,x)=>{var H=ee=>{try{se(W.next(ee))}catch(A){x(A)}},b=ee=>{try{se(W.throw(ee))}catch(A){x(A)}},se=ee=>ee.done?r(ee.value):Promise.resolve(ee.value).then(H,b);se((W=W.apply(k,s)).next())});function dr({collection:e}){return e}function ur(e){return!0}function jt(e){return e.target&&e.interface}function pr(e){const t=fo.call(this,e.field.target,e);return t.length&&t.some(o=>jt(o.field))||(e.isLeaf=!0),t}function fo(e,t,o={needLeaf:!0}){const{needLeaf:n}=o,[a,i]=s.parseCollectionName(e),l=this.getCollectionFields(i,a),c=n?l:l.filter(jt),d=pr.bind(this);return c.filter(this.filter).map(u=>{var h,g,w;const p=t?`${t.value?`${t.value}.`:""}${u.name}`:u.name,f=(g=this.compile((h=u.uiSchema)==null?void 0:h.title))!=null?g:u.name,y=!this.getCollectionFields(u.target).filter(jt).filter(this.filter).length;return{pId:(w=t==null?void 0:t.key)!=null?w:null,id:p,key:p,value:p,title:f,isLeaf:y,loadChildren:y?null:d,field:u,fullTitle:t?[...t.fullTitle,f]:[f]}})}const mr=e=>{const G=e,{title:t,value:o,onChange:n,collection:a,useCollection:i=dr,filter:l=ur,rootOption:c,loadData:d,needLeaf:u=!1}=G,p=Q(G,["title","value","onChange","collection","useCollection","filter","rootOption","loadData","needLeaf"]),f=s.useCompile(),{t:y}=s.useTranslation(),[h,g]=x.useState({}),w=i({collection:a}),[C,D]=s.parseCollectionName(w),{getCollectionFields:S}=s.useCollectionManager_deprecated(C),I=Object.values(h),M=x.useMemo(()=>e.multiple?(o||[]).map(j=>h[j]).filter(Boolean):o,[o,e.multiple,h]),E=x.useCallback(j=>P(null,null,function*(){if(d!=null)return d(j);if(!j.isLeaf&&j.loadChildren){const X=j.loadChildren(j);g(B=>X.reduce((L,$)=>{var U;return Object.assign(L,{[$.value]:F(v({},$),{label:$.fullTitle.length?(U=$.fullTitle)==null?void 0:U.join(" / "):$.title})})},v({},B)))}}),[d]);x.useEffect(()=>{const j=c?F(v({},c),{id:c.value,key:c.value,title:c.label,fullTitle:c.label,isLeaf:!1}):null,B=(d===null?[]:fo.call({compile:f,getCollectionFields:S,filter:l},w,j,{needLeaf:u})).reduce((L,$)=>{var U;return Object.assign(L,{[$.value]:F(v({},$),{label:$.fullTitle.length?(U=$.fullTitle)==null?void 0:U.join(" / "):$.title})})},{});j&&(B[j.value]=j),g(B)},[w,c,l,d]),x.useEffect(()=>{const j=e.multiple?o:typeof o=="string"?[o]:o||[];if(!(j!=null&&j.length)||j.every(B=>!!h[B]))return;const X=[];j.forEach(B=>{const L=B.split(".");let $=h[L[0]];for(let U=1;U<L.length&&$;U++){const J=L.slice(0,U+1).join(".");if(h[J]){$=h[J];break}if(!$.isLeaf&&$.loadChildren){const _=$.loadChildren($);_!=null&&_.length&&(X.push(..._),$=_.find(R=>R.value===L.slice(0,U+1).join(".")))}}}),g(B=>X.reduce((L,$)=>{var U;return Object.assign(L,{[$.value]:F(v({},$),{label:$.fullTitle.length?(U=$.fullTitle)==null?void 0:U.join(" / "):$.title})})},v({},B)))},[o,I.length,e.multiple]);const N=x.useCallback(j=>{if(!e.multiple){n(j);return}const X=j.map($=>$.value).filter(Boolean),B=new Set(X),L=M.find($=>!B.has($.value));if(L){const $=`${L.value}.`;Object.keys(h).forEach(U=>{U.startsWith($)&&B.delete(U)})}else X.forEach($=>{const U=$.split(".");if(U.length)for(let J=1;J<=U.length;J++)B.add(U.slice(0,J).join("."))});n(Array.from(B))},[e.multiple,M,n,h]),V=x.useCallback(j=>{var J;const{value:X,onClose:B,disabled:L,closable:$}=j;if(!X)return null;const{fullTitle:U}=(J=h[X])!=null?J:{};return r.jsx(b.Tag,{closable:$&&!L,onClose:B,children:U==null?void 0:U.join(" / ")})},[h]),K=Array.isArray(M)?M.filter(j=>j.value in h):M,q=e.multiple?o:o!=null?[o]:[];return r.jsx(b.TreeSelect,v({"data-testid":`select-field${t?`-${t}`:""}`,value:K,placeholder:y("Select field"),showCheckedStrategy:b.TreeSelect.SHOW_ALL,treeDefaultExpandedKeys:q,allowClear:{clearIcon:r.jsx(H.CloseCircleFilled,{role:"button","aria-label":"icon-close"})},treeCheckStrictly:e.multiple,treeCheckable:e.multiple,tagRender:V,treeNodeLabelProp:"label",onChange:N,treeDataSimpleMode:!0,treeData:I,loadData:E},p))},m="workflow";function O(e,t={}){return s.i18n.t(e,F(v({},t),{ns:[m,"core"]}))}function ve(){return ee.useTranslation([m,"core"])}const T=(e,t={})=>s.tval(e,v({ns:[m,"core"]},t)),fr=()=>{const{t:e}=ve(),t=se.useNavigate(),{token:o}=s.useToken();return r.jsx(b.Tooltip,{title:e("Workflow"),children:r.jsx(b.Button,{icon:r.jsx(s.Icon,{type:"workflow",style:{color:o.colorTextHeaderMenu}}),title:e("Workflow"),onClick:()=>{t("/_admin/business-components/workflow")}})})},ft=(e,t)=>({getAriaLabel:x.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])}),go=x.createContext({}),gr=go.Provider;function hr(){return x.useContext(go)}const Ve=x.createContext({}),yr=Ve.Provider;function Y(){return x.useContext(Ve)}var _e=(e=>(e.CONTROL="control",e.COLLECTION="collection",e.EXTENDED="extended",e.MANUAL="manual",e.ADVANCED="advanced",e))(_e||{});class oe{}function xr(e){var g;const{upstream:t,branchIndex:o=null}=e,n=s.usePlugin(re),a=s.useCompile(),i=s.useAPIClient(),{workflow:l,refresh:c}=(g=Y())!=null?g:{},d=Array.from(n.instructions.getValues()),u=x.useMemo(()=>wr(d,{engine:n,workflow:l,upstream:t,branchIndex:o,compile:a}),[o,n,d,t,l]),[p,f]=x.useState(!1),y=x.useCallback(C=>P(null,[C],function*({keyPath:w}){var E,N,V;const D=w.pop(),S={},[I]=w,M=n.instructions.get(D);if(I){const{value:K}=(N=(E=M.options)==null?void 0:E.find(q=>q.key===I))!=null?N:{};Object.assign(S,typeof K=="function"?K():K)}l&&(yield i.resource("workflows.nodes",l.id).create({values:{type:D,upstreamId:(V=t==null?void 0:t.id)!=null?V:null,branchIndex:o,title:a(M.title),config:S}}),c())}),[i,o,n.instructions,c,t==null?void 0:t.id,l]),h=x.useMemo(()=>({onClick:w=>{const{keyPath:C}=w||{};(C==null?void 0:C[0])==="load"?f(!0):y(w)},items:u}),[u,y]);return{workflow:l,menu:h,isShowUploadModal:p,setIsShowUploadModal:f}}const ho=[{key:_e.CONTROL,label:O("Control")},{key:_e.COLLECTION,label:O("Collection operations")},{key:_e.MANUAL,label:O("Manual")},{key:_e.EXTENDED,label:O("Extended types")}],br={key:"hot",label:O("Hot tools")},vr={key:"load",label:O("Load")};function wr(e,{engine:t,workflow:o,upstream:n,branchIndex:a,compile:i}){const l=[],c=[];for(const d of ho){const u=e.filter(y=>{var h,g;return y.group===d.key&&((g=(h=y.isAvailable)==null?void 0:h.call(y,{engine:t,workflow:o,upstream:n,branchIndex:a}))!=null?g:!0)});let p=[];for(const y of u){const{type:h,title:g,icon:w,color:C,options:D,isHot:S}=y,I=yo(w,C),M={role:"button","aria-label":h,key:h,label:i(g),type:D?"subMenu":null,icon:I,children:D?D.map(E=>({role:"button","aria-label":E.key,key:E.key,label:i(E.label)})):null};p.push(M),S&&c.push(M)}const f=F(v({},d),{type:"group",children:p});l.push(f)}return l.unshift(F(v({},vr),{type:"group",children:[{key:"load","aria-label":"load",role:"button",label:O("Upload node"),icon:yo("ToTopOutlined","#ff92ca")}]})),l.unshift(F(v({},br),{type:"group",children:c})),l.filter(d=>d.children.length)}function yo(e,t){return r.jsx("div",{className:s.css`
2
2
  display: flex;
3
3
  justify-content: center;
4
4
  align-items: center;
@@ -415,7 +415,7 @@
415
415
  `}));function tt(e){var n;const{styles:t}=jr();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:a,color:i}=e.statusMap[e.status];o=r.jsx(b.Tag,{color:i,children:a})}return r.jsx(b.Button,F(v({},e),{shape:"circle",size:"small",className:s.cx(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const ye={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},gt=[{value:ye.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(H.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:ye.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(H.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:ye.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(H.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:ye.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(H.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:ye.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(H.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:ye.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(H.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:ye.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(H.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:ye.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(H.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:ye.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(H.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],ht=gt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});var Ce=(e=>(e[e.PENDING=0]="PENDING",e[e.RESOLVED=1]="RESOLVED",e[e.FAILED=-1]="FAILED",e[e.ERROR=-2]="ERROR",e[e.ABORTED=-3]="ABORTED",e[e.CANCELED=-4]="CANCELED",e[e.REJECTED=-5]="REJECTED",e[e.RETRY_NEEDED=-6]="RETRY_NEEDED",e))(Ce||{});const yt=[{value:0,label:`{{t("Pending", { ns: "${m}" })}}`,color:"#FFD92D",icon:r.jsx(s.Icon,{type:"HistoryOutlined"})},{value:1,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"#2DCD22",icon:r.jsx(s.Icon,{type:"CheckOutlined"})},{value:-1,label:`{{t("Failed", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"ExclamationOutlined"})},{value:-2,label:`{{t("Error", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"CloseOutlined"})},{value:-3,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:90})},{value:-4,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:45})},{value:-5,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined"})},{value:-6,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"RedoOutlined"})}],ot=yt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});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 nt(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return nt(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[a]=Object.keys(o[n]);return!(!a||typeof o[n][a]=="undefined")}):!1}function bt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{bt(e.properties[o],t)})}function Le(e,t){return`/_admin/business-components/${t||"workflow"}/${e}/workflow`}function He(e,t){return`/_admin/business-components/${t||"workflow"}/${e}/executions`}function Lr(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const a=o.get(n.nodeId);a.jobs.push(n),n.node={id:a.id,key:a.key,title:a.title,type:a.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((a,i)=>a.id-i.id)})}function zr(){const{instructions:e}=s.usePlugin(re),t=s.useCompile(),{viewJob:o,setViewJob:n}=Y();if(!o)return;o.cost=Br(o.cost/1e3);const{styles:a}=we(),{node:i={}}=o!=null?o:{},l=e.get(i.type);return r.jsx(s.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(s.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:F(v({},o),{result:JSON.stringify(o.result,null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:a.nodeTitleClass,children:[r.jsx(b.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:i.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",i.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:yt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},cost:{type:"string",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input","x-read-pretty":!0},result:{type:"string",title:`{{t("Node result", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"json"},"x-read-pretty":!0},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{copy:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:c}=ee.useTranslation();return{run(){return P(this,null,function*(){try{const u=JSON.stringify(o.result,null,2);yield navigator.clipboard.writeText(u),b.message.success(c("Copied"))}catch(u){b.message.error(c("Copy failed"))}})}}}}}}}}}}}})})}function qr(e){var y;const{execution:t}=Y(),o=s.useAPIClient(),n=se.useNavigate(),{styles:a}=we(),[i,l]=x.useState([]),[c,d]=x.useState([]),p=(y=window.location.pathname.split("business-components/")[1])==null?void 0:y.split("/")[0];x.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:h})=>{l(h.data)}).catch(()=>{})},[t]),x.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:h})=>{d(h.data.reverse())}).catch(()=>{})},[t]);const f=x.useCallback(({key:h})=>{h!==t.id&&n(He(h,p))},[t]);return t?r.jsx(b.Dropdown,{menu:{onClick:f,defaultSelectedKeys:[`${t.id}`],className:s.cx(a.dropdownClass,a.executionsDropdownRowClass),items:[...c,t,...i].map(h=>({key:h.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${h.id}`}),r.jsx("time",{children:W.str2moment(h.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(tt,{statusMap:ht,status:h.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(H.DownOutlined,{})]})}):null}function Ur(){var E,N;const{t:e}=ee.useTranslation(),t=s.useCompile(),{data:o,loading:n,refresh:a}=s.useResourceActionContext(),{setTitle:i}=s.useDocumentTitle(),[l,c]=x.useState(null),d=s.useApp(),u=s.useAPIClient(),f=(E=window.location.pathname.split("business-components/")[1])==null?void 0:E.split("/")[0],y=d.systemSettingsManager.get(`business-components.${f}`)||{};x.useEffect(()=>{var j;const{workflow:G}=(j=o==null?void 0:o.data)!=null?j:{};i==null||i(`${G!=null&&G.title?`${G.title} - `:""}${O("Execution history")}`)},[o==null?void 0:o.data]);const h=x.useCallback(()=>{b.Modal.confirm({title:O("Cancel the execution"),icon:r.jsx(H.ExclamationCircleFilled,{}),content:O("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")),a()}).catch(G=>{console.error(G.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 V=(N=o==null?void 0:o.data)!=null?N:{},{jobs:g=[],workflow:K={}}=V,q=K,{nodes:w=[],revisions:C=[]}=q,D=Q(q,["nodes","revisions"]),S=Q(V,["jobs","workflow"]);xt(w),Lr(w,g);const I=w.find(G=>!G.upstream),M=ht[S.status];return r.jsxs(Ve.Provider,{value:{workflow:D.type?D:null,nodes:w,execution:S,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(To,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(se.Link,{to:d.systemSettingsManager.getRoutePath(`business-components.${f||"workflow"}`),children:t(y.label)})},{title:r.jsx(se.Link,{to:Le(D.id,f),children:D.title})},{title:r.jsx(qr,{})}]})]}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:M.color,children:t(M.label)}),S.status?null:r.jsx(b.Tooltip,{title:O("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:h,shape:"circle",size:"small",icon:r.jsx(H.StopOutlined,{})})}),r.jsx("time",{children:W.str2moment(S.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Fo,{entry:I}),r.jsx(zr,{})]})}const zt=()=>{const e=se.useParams(),{styles:t}=we();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.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:Ur}})})};function Kr(e){return["hasMany","belongsToMany"].includes(e.type)}function _r(){const e=s.useCompile();return[vt,wt].map(t=>{var n;const o=(n=t.useOptions({types:[Kr],appends:null,depth:4}))==null?void 0:n.filter(Boolean);return{label:e(t.label),value:t.value,key:t.value,children:e(o),disabled:o&&!o.length}})}function Gr(n){var a=n,{value:e,onChange:t}=a,o=Q(a,["value","onChange"]);const{setValuesIn:i}=A.useForm(),{getCollection:l}=s.useCollectionManager_deprecated(),c=_r(),[d,u]=x.useState(c),{associatedKey:p="",name:f}=e!=null?e:{};let y=[];const h=p.match(/^{{(.*)}}$/);h&&(y=[...h[1].trim().split(".").slice(0,-1),f]);const g=C=>P(null,null,function*(){var S;const D=C[C.length-1];!((S=D.children)!=null&&S.length)&&!D.isLeaf&&D.loadChildren&&(yield D.loadChildren(D),u(I=>[...I]))});x.useEffect(()=>{P(null,null,function*(){var S;if(!y||d.length<=1)return;let D=null;for(let I=0;I<y.length;I++){const M=y[I];try{I===0?D=d.find(E=>E.value===M):(D.loadChildren&&!((S=D.children)!=null&&S.length)&&(yield D.loadChildren(D)),D=D.children.find(E=>E.value===M))}catch(E){console.error(E)}}u([...d])})},[e,d.length]);const w=x.useCallback((C,D)=>{if(!(C!=null&&C.length)){i("collection",null),t({});return}const{field:S}=D.pop();if(!S||!["hasMany","belongsToMany"].includes(S.type))return;const{collectionName:I,target:M,name:E,dataSourceKey:N}=S,K=l(I,N).fields.find(q=>q.primaryKey);i("collection",`${N}:${M}`),t({name:E,associatedKey:`{{${C.slice(0,-1).join(".")}.${K.name}}}`,associatedCollection:s.joinCollectionName(N,I)})},[t]);return r.jsx(b.Cascader,F(v({},o),{value:y,options:d,changeOnSelect:!0,onChange:w,loadData:g}))}class Hr extends oe{constructor(){super(...arguments),this.title=`{{t("Aggregate", { ns: "${m}" })}}`,this.type="aggregate",this.group="collection",this.icon="SearchOutlined",this.color="#19e8aa",this.description=`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${m}" })}}`,this.fieldset={aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],required:!0,default:"count"},associated:{type:"boolean",title:`{{t("Target type", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${m}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${m}" })}}`,value:!0}],required:!0,default:!1,"x-reactions":[{target:"collection",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"association",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",title:`{{t("Data of collection", { ns: "${m}" })}}`,"x-reactions":[{dependencies:["associated"],fulfill:{state:{display:'{{$deps[0] ? "hidden" : "visible"}}'}}},{target:"params.field",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},association:{type:"object",title:`{{t("Data of associated collection", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssociatedConfig","x-component-props":{changeOnSelect:!0},"x-reactions":[{dependencies:["associated"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],required:!0}}},field:{type:"void","x-component":"Grid.Col",properties:{"params.field":{type:"string",title:`{{t("Field to aggregate", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(t){return!t.hidden&&t.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:{type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:t}=A.useForm(),[o,n]=s.parseCollectionName(t==null?void 0:t.collection);return{options:s.useCollectionFilterOptions(n,o),className:s.css`
416
416
  position: relative;
417
417
  width: 100%;
418
- `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={SchemaComponentContext:s.SchemaComponentContext,FilterDynamicComponent:Ae,FieldsSelect:rt,ValueBlock:Ie,AssociatedConfig:Gr}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return n&&!n.some(i=>i in Pe||Object.values(Pe).some(l=>l.has(i)))?null:{[a.value]:t,[a.label]:o}}useInitializers(t){var n;const o=O("Query result");return t.config.collection?{name:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Ie.Initializer,node:t,resultTitle:o}:null}}class Jr extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",Hr)})}}const No=[{value:1e3,label:`{{t('Seconds', { ns: "workflow" })}}`},{value:6e4,label:`{{t('Minutes', { ns: "workflow" })}}`},{value:36e5,label:`{{t('Hours', { ns: "workflow" })}}`},{value:864e5,label:`{{t('Days', { ns: "workflow" })}}`},{value:6048e5,label:`{{t('Weeks', { ns: "workflow" })}}`}];function Yr(e){return No.slice().reverse().find(t=>!(e%t.value))}function Qr({value:e=6e4,onChange:t}){const o=s.useCompile(),n=Yr(e),a=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(b.InputNumber,{min:1,value:a,onChange:i=>t(Math.round(i*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:i=>t(Math.round(a*i)),className:"auto-width",options:No.map(i=>({value:i.value,label:o(i.label)}))})]})}class Zr extends oe{constructor(){super(...arguments),this.title=`{{t("Delay", { ns: "${m}" })}}`,this.type="delay",this.group="control",this.icon="ClockCircleOutlined",this.color="#cf9247",this.description=`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${m}" })}}`,this.fieldset={duration:{type:"number",title:`{{t("Duration", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${m}" })}}`,value:Ce.RESOLVED},{label:`{{t("Fail and exit", { ns: "${m}" })}}`,value:Ce.FAILED}],required:!0,default:Ce.RESOLVED}},this.components={Duration:Qr}}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:a}){return!t.isWorkflowSync(o)}}class Xr extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",Zr)})}}function Rr(e){var o;return["belongsTo","hasOne"].includes(e.type)?((o=this.getCollection(e.collectionName))==null?void 0:o.template)==="expression"?!0:this.getCollectionFields(e.target).some(n=>n.interface==="expression"):!1}function es({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),a=me({types:[Rr.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:a})}class ts extends oe{constructor(){super(...arguments),this.title=`{{t("Dynamic Calculation", { ns: "${m}" })}}`,this.type="dynamic-calculation",this.group="extended",this.icon="CalculatorOutlined",this.color="#2f79b9",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. The expression is dynamic one from an expression collections.", { ns: "${m}" })}}`,this.fieldset={expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={DynamicExpression:es,WorkflowVariableInput:ke,ValueBlock:Ie}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return n&&!n.some(i=>i in Pe||Object.values(Pe).some(l=>l.has(i)))?null:{[a.value]:t,[a.label]:o}}useInitializers(t){var o;return{name:`#${t.id}`,type:"item",title:(o=t.title)!=null?o:`#${t.id}`,Component:Ie.Initializer,node:t,resultTitle:O("Calculation result")}}}const os=A.observer(e=>{const{onChange:t}=e,o=A.useField(),n=A.useForm(),i=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=x.useState(n.getValuesIn(i)),d=s.useCompile(),{getCollectionFields:u}=s.useCollectionManager_deprecated();A.useFormEffects(()=>{A.onFormInitialValuesChange(f=>{c(f.getValuesIn(i))}),A.onFieldInputValueChange(i,f=>{c(f.value),t(null)})});const p=fe({collection:l,compile:d,getCollectionFields:u});return r.jsx(s.Variable.TextArea,F(v({},e),{scope:p}))},{displayName:"InternalExpression"});function ns(e){const{t}=ee.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=x.useMemo(()=>fe({collection:o.sourceCollection,compile:n,getCollectionFields:a}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(s.Variable.TextArea,F(v({},e),{scope:i})):r.jsx(b.Tag,{children:t("Unconfigured",{ns:m})})}const rs=A.connect(os,A.mapReadPretty(ns)),{defaultProps:ss}=s.interfacesProperties;class as extends s.CollectionFieldInterface{constructor(){super(...arguments),this.name="expression",this.type="string",this.group="advanced",this.icon="FunctionOutlined",this.order=1,this.title=`{{t("Expression", { ns: "${m}" })}}`,this.description=`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${m}" })}}`,this.sortable=!0,this.default={type:"text",uiSchema:{"x-component":"DynamicExpression"}},this.properties=v({},ss)}}class is extends s.Plugin{load(){return P(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([as]),this.app.addComponents({DynamicExpression:rs});const t=this.app.pm.get("workflow"),o=new ts;t.instructions.register(o.type,o)})}}function ls(n){var a=n,{collection:e,dataPath:t}=a,o=Q(a,["collection","dataPath"]);const{insert:i}=s.useSchemaInitializer(),{getTemplateSchemaByMode:l}=s.useSchemaTemplateManager(),{getCollection:c}=s.useCollectionManager_deprecated(),d=s.useRecordCollectionDataSourceItems("FormItem");let u;if(typeof e=="string"){const[f,y]=s.parseCollectionName(e);u=c(y,f)}else u=e;function p(y){return P(this,arguments,function*({item:f}){const h=f.template?yield l(f):null,g={type:"void",name:A.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:h||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};bt(g,w=>{w["x-uid"]&&delete w["x-uid"]}),i(g)})}return r.jsx(s.SchemaInitializerItem,F(v({},o),{onClick:p,items:d}))}function Te(e){var i;const t=s.useSchemaInitializerItem(),o=(i=e==null?void 0:e.collection)!=null?i:t.collection;let n,a;if(typeof o=="string"){const l=s.parseCollectionName(o);n=l[0],a=l[1]}else a=o;return r.jsx(s.CollectionProvider_deprecated,{dataSource:n,collection:a,children:r.jsx(ls,v(v({},t),e))})}function cs(e){const{execution:t,nodes:o}=Y(),n=x.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),a=x.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 x.useMemo(()=>ae.get(a,e),[a,e])}function qt({collection:e,dataPath:t,children:o}){const n=A.useField(),a=x.useRef(null),{getAssociationAppends:i}=s.useAssociationNames(),{appends:l,updateAssociationValues:c}=i(),d=cs(t);let u,p;if(typeof e=="string"){const D=s.parseCollectionName(e);u=D[0],p=D[1]}else p=e;const f=x.useMemo(()=>A.createForm({values:d,readPretty:!0}),[d]),y={appends:l},h={loading:!1,data:{data:d}},w=s.useAPIClient().resource(p),C=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:u,collection:p,children:r.jsx(s.RecordProvider,{record:d,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:h,resource:w,__parent:C},children:r.jsx(s.FormBlockContext.Provider,{value:{params:y,form:f,field:n,service:h,updateAssociationValues:c,formBlockRef:a},children:o})})})})}function ds(){return!0}const rt=A.observer(e=>{const u=e,{filter:t=ds}=u,o=Q(u,["filter"]),n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),{values:i}=A.useForm(),[l,c]=s.parseCollectionName(i==null?void 0:i.collection),d=a(c,l);return r.jsx(b.Select,F(v({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(p=>{var f;return{label:n((f=p.uiSchema)==null?void 0:f.title),value:p.name}})}))},{displayName:"FieldsSelect"});function us(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}const xe={label:"label",value:"value",children:"children"},Do={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var i;const t=he(),n=s.usePlugin(re).instructions.get(t.type);return((i=n.useCurrentFormVariables)==null?void 0:i.call(n,t,e))||[]}},vt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const t=s.useCompile(),{instructions:o}=s.usePlugin(re),n=he(),a=We(n),i=[];return a.forEach(l=>{var p;const c=o.get(l.type),d=`<${t(c.title)}>${l.title}`,u=(p=c.useVariables)==null?void 0:p.call(c,F(v({},l),{title:d}),e);u&&i.push(u)}),i}},wt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var a,i;const{triggers:t}=s.usePlugin(re),{workflow:o}=Y(),n=t.get(o.type);return(i=(a=n==null?void 0:n.useVariables)==null?void 0:a.call(n,o.config,e))!=null?i:null}},Ut={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=xe,current:o}=e,{instructions:n}=s.usePlugin(re),a=he(),i=o!=null?o:a,l=us(i),c=[];return l.forEach(d=>{var f,y;const u=n.get(d.type),p=(f=u.useScopeVariables)==null?void 0:f.call(u,d,e);p&&c.push({key:d.key,[t.value]:d.key,[t.label]:(y=d.title)!=null?y:`#${d.id}`,[t.children]:p})}),c}},Oo={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=xe}){return!e||e.includes("date")?[{key:"now",[t.label]:O("System time"),[t.value]:"now"}]:[]}},Pe={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 Po(e,t){var o,n,a,i,l,c;return typeof t=="string"?(o=Pe[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===((a=t.options)==null?void 0:a.collection)||((i=t.options)==null?void 0:i.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 _t(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function Gt({fields:e,types:t,appends:o,depth:n=1,compile:a,getCollectionFields:i}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>Po(l,d)):!0;if(Kt(l)){if(o===null)return n?c||Gt({fields:Ht(l.target,{compile:a,getCollectionFields:i}),types:t,depth:n-1,appends:o,compile:a,getCollectionFields:i}):!1;const d=_t(l,o),u=o.includes(l.name);return c?u:((d==null?void 0:d.length)||u)&&Gt({fields:Ht(l.target,{compile:a,getCollectionFields:i}),types:t,appends:d,compile:a,getCollectionFields:i}).length}else return c})}function st(e,t){var i,l;const o=s.useCompile(),n=(l=(i=e.useOptions)==null?void 0:i.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:a}=t;return{[a.label]:o(e.label),[a.value]:e.value,key:e[a.value],[a.children]:n,disabled:!n||!n.length}}function me(e={}){var a;const t=Object.assign({},xe,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t});return[st(Ut,o),st(vt,o),st(wt,o),st(Oo,o),s.useGlobalVariable("$env")].filter(Boolean)}function Eo(e={}){var a;const t=Object.assign({},xe,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t});return[st(Do,o)]}function Ht(e,{compile:t,getCollectionFields:o}){var d,u,p,f,y,h,g;const[n,a]=s.parseCollectionName(e),i=o(a,n),l=[],c=[];i.forEach(w=>{w.isForeignKey?l.push(w):c.push(w)});for(let w=c.length-1;w>=0;w--){const C=c[w];if(C.type==="belongsTo"){const D=l.find(S=>S.name===C.foreignKey);D?c.splice(w,0,F(v(v({},C),D),{uiSchema:F(v({},C.uiSchema),{title:(d=C.uiSchema)!=null&&d.title?`${t((u=C.uiSchema)==null?void 0:u.title)} ID`:D.name})})):c.splice(w,0,F(v({},C),{name:C.foreignKey,type:"bigInt",isForeignKey:!0,interface:C.interface,uiSchema:F(v({},C.uiSchema),{title:(p=C.uiSchema)!=null&&p.title?`${t((f=C.uiSchema)==null?void 0:f.title)} ID`:C.name})}))}else if(C.type==="context"&&C.collectionName==="users"){const D=(y=c.find(S=>S.type==="belongsTo"&&S.target==="users"&&S.foreignKey===C.name))!=null?y:{};c.splice(w,0,F(v({},C),{type:C.dataType,interface:D.interface,uiSchema:F(v({},D.uiSchema),{title:(h=D.uiSchema)!=null&&h.title?`${t((g=D.uiSchema)==null?void 0:g.title)} ID`:C.name})}))}}return c.filter(w=>w.interface&&!w.hidden)}function ps(e){const t=_t(e.field,e.appends),o=fe(v({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(a=>Po(e.field,a))||(e.disabled=!0))}function fe(e){const{fields:t,collection:o,types:n,appends:a=[],depth:i=1,compile:l,getCollectionFields:c,fieldNames:d=xe}=e,u=t!=null?t:Ht(o,{compile:l,getCollectionFields:c}),p=ps.bind({compile:l,getCollectionFields:c,fieldNames:d});return Gt({fields:u,types:n,depth:i,appends:a,compile:l,getCollectionFields:c}).map(y=>{var C;const h=l(((C=y.uiSchema)==null?void 0:C.title)||y.name),g=_t(y,a),w=!Kt(y)||g&&!g.length&&!a.includes(y.name)||!1;return{[d.label]:h,key:y.name,[d.value]:y.name,isLeaf:w,loadChildren:w?null:p,field:y,depth:i,appends:a,types:n}})}function ke(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.Input,v({scope:a},t))}function at(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.TextArea,v({scope:a},t))}function Mo(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.RawTextArea,v({scope:a},t))}function $o(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.JSON,v({scope:a},t))}function ms(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const{options:a=[]}=t,i=Eo(e),l=me(e);return r.jsx(s.Variable.CodeMirror,v({scope:[...i,...l,...a]},t))}function Ae({value:e,onChange:t,renderSchemaComponent:o}){const n=me();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Ne(e){const d=e,{options:t=[],getOptions:o=()=>[],direction:n}=d,a=Q(d,["options","getOptions","direction"]),i=s.useCompile(),l=o(),c=t.length>0?t:l;return r.jsx(b.Radio.Group,F(v({},a),{children:r.jsx(b.Space,{direction:n,children:c.map(u=>r.jsxs(b.Radio,{value:u.value,children:[r.jsx("span",{className:s.css`
418
+ `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={SchemaComponentContext:s.SchemaComponentContext,FilterDynamicComponent:Ae,FieldsSelect:rt,ValueBlock:Ie,AssociatedConfig:Gr}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return n&&!n.some(i=>i in Pe||Object.values(Pe).some(l=>l.has(i)))?null:{[a.value]:t,[a.label]:o}}useInitializers(t){var n;const o=O("Query result");return t.config.collection?{name:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Ie.Initializer,node:t,resultTitle:o}:null}}class Jr extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",Hr)})}}const No=[{value:1e3,label:`{{t('Seconds', { ns: "workflow" })}}`},{value:6e4,label:`{{t('Minutes', { ns: "workflow" })}}`},{value:36e5,label:`{{t('Hours', { ns: "workflow" })}}`},{value:864e5,label:`{{t('Days', { ns: "workflow" })}}`},{value:6048e5,label:`{{t('Weeks', { ns: "workflow" })}}`}];function Yr(e){return No.slice().reverse().find(t=>!(e%t.value))}function Qr({value:e=6e4,onChange:t}){const o=s.useCompile(),n=Yr(e),a=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(b.InputNumber,{min:1,value:a,onChange:i=>t(Math.round(i*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:i=>t(Math.round(a*i)),className:"auto-width",options:No.map(i=>({value:i.value,label:o(i.label)}))})]})}class Zr extends oe{constructor(){super(...arguments),this.title=`{{t("Delay", { ns: "${m}" })}}`,this.type="delay",this.group="control",this.icon="ClockCircleOutlined",this.color="#cf9247",this.description=`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${m}" })}}`,this.fieldset={duration:{type:"number",title:`{{t("Duration", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${m}" })}}`,value:Ce.RESOLVED},{label:`{{t("Fail and exit", { ns: "${m}" })}}`,value:Ce.FAILED}],required:!0,default:Ce.RESOLVED}},this.components={Duration:Qr}}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:a}){return!t.isWorkflowSync(o)}}class Xr extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",Zr)})}}function Rr(e){var o;return["belongsTo","hasOne"].includes(e.type)?((o=this.getCollection(e.collectionName))==null?void 0:o.template)==="expression"?!0:this.getCollectionFields(e.target).some(n=>n.interface==="expression"):!1}function es({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),a=me({types:[Rr.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:a})}class ts extends oe{constructor(){super(...arguments),this.title=`{{t("Dynamic Calculation", { ns: "${m}" })}}`,this.type="dynamic-calculation",this.group="extended",this.icon="CalculatorOutlined",this.color="#2f79b9",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. The expression is dynamic one from an expression collections.", { ns: "${m}" })}}`,this.fieldset={expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={DynamicExpression:es,WorkflowVariableInput:ke,ValueBlock:Ie}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return n&&!n.some(i=>i in Pe||Object.values(Pe).some(l=>l.has(i)))?null:{[a.value]:t,[a.label]:o}}useInitializers(t){var o;return{name:`#${t.id}`,type:"item",title:(o=t.title)!=null?o:`#${t.id}`,Component:Ie.Initializer,node:t,resultTitle:O("Calculation result")}}}const os=A.observer(e=>{const{onChange:t}=e,o=A.useField(),n=A.useForm(),i=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=x.useState(n.getValuesIn(i)),d=s.useCompile(),{getCollectionFields:u}=s.useCollectionManager_deprecated();A.useFormEffects(()=>{A.onFormInitialValuesChange(f=>{c(f.getValuesIn(i))}),A.onFieldInputValueChange(i,f=>{c(f.value),t(null)})});const p=fe({collection:l,compile:d,getCollectionFields:u});return r.jsx(s.Variable.TextArea,F(v({},e),{scope:p}))},{displayName:"InternalExpression"});function ns(e){const{t}=ee.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=x.useMemo(()=>fe({collection:o.sourceCollection,compile:n,getCollectionFields:a}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(s.Variable.TextArea,F(v({},e),{scope:i})):r.jsx(b.Tag,{children:t("Unconfigured",{ns:m})})}const rs=A.connect(os,A.mapReadPretty(ns)),{defaultProps:ss}=s.interfacesProperties;class as extends s.CollectionFieldInterface{constructor(){super(...arguments),this.name="expression",this.type="string",this.group="advanced",this.icon="FunctionOutlined",this.order=1,this.title=`{{t("Expression", { ns: "${m}" })}}`,this.description=`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${m}" })}}`,this.sortable=!0,this.default={type:"text",uiSchema:{"x-component":"DynamicExpression"}},this.properties=v({},ss)}}class is extends s.Plugin{load(){return P(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([as]),this.app.addComponents({DynamicExpression:rs});const t=this.app.pm.get("workflow"),o=new ts;t.instructions.register(o.type,o)})}}class ls extends oe{constructor(){super(...arguments),this.title=T("Exit branch"),this.type="exit-branch",this.group="control",this.icon="LogoutOutlined",this.color="#52c41a",this.description=T("Exit the current branch with success status and continue to the next node after the branch."),this.fieldset={remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}}}isAvailable(t){return t&&typeof t.branchIndex=="number"}}class cs extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("exit-branch",ls)})}}function ds(n){var a=n,{collection:e,dataPath:t}=a,o=Q(a,["collection","dataPath"]);const{insert:i}=s.useSchemaInitializer(),{getTemplateSchemaByMode:l}=s.useSchemaTemplateManager(),{getCollection:c}=s.useCollectionManager_deprecated(),d=s.useRecordCollectionDataSourceItems("FormItem");let u;if(typeof e=="string"){const[f,y]=s.parseCollectionName(e);u=c(y,f)}else u=e;function p(y){return P(this,arguments,function*({item:f}){const h=f.template?yield l(f):null,g={type:"void",name:A.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:h||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};bt(g,w=>{w["x-uid"]&&delete w["x-uid"]}),i(g)})}return r.jsx(s.SchemaInitializerItem,F(v({},o),{onClick:p,items:d}))}function Te(e){var i;const t=s.useSchemaInitializerItem(),o=(i=e==null?void 0:e.collection)!=null?i:t.collection;let n,a;if(typeof o=="string"){const l=s.parseCollectionName(o);n=l[0],a=l[1]}else a=o;return r.jsx(s.CollectionProvider_deprecated,{dataSource:n,collection:a,children:r.jsx(ds,v(v({},t),e))})}function us(e){const{execution:t,nodes:o}=Y(),n=x.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),a=x.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 x.useMemo(()=>ae.get(a,e),[a,e])}function qt({collection:e,dataPath:t,children:o}){const n=A.useField(),a=x.useRef(null),{getAssociationAppends:i}=s.useAssociationNames(),{appends:l,updateAssociationValues:c}=i(),d=us(t);let u,p;if(typeof e=="string"){const D=s.parseCollectionName(e);u=D[0],p=D[1]}else p=e;const f=x.useMemo(()=>A.createForm({values:d,readPretty:!0}),[d]),y={appends:l},h={loading:!1,data:{data:d}},w=s.useAPIClient().resource(p),C=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:u,collection:p,children:r.jsx(s.RecordProvider,{record:d,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:h,resource:w,__parent:C},children:r.jsx(s.FormBlockContext.Provider,{value:{params:y,form:f,field:n,service:h,updateAssociationValues:c,formBlockRef:a},children:o})})})})}function ps(){return!0}const rt=A.observer(e=>{const u=e,{filter:t=ps}=u,o=Q(u,["filter"]),n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),{values:i}=A.useForm(),[l,c]=s.parseCollectionName(i==null?void 0:i.collection),d=a(c,l);return r.jsx(b.Select,F(v({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(p=>{var f;return{label:n((f=p.uiSchema)==null?void 0:f.title),value:p.name}})}))},{displayName:"FieldsSelect"});function ms(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}const xe={label:"label",value:"value",children:"children"},Do={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var i;const t=he(),n=s.usePlugin(re).instructions.get(t.type);return((i=n.useCurrentFormVariables)==null?void 0:i.call(n,t,e))||[]}},vt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const t=s.useCompile(),{instructions:o}=s.usePlugin(re),n=he(),a=We(n),i=[];return a.forEach(l=>{var p;const c=o.get(l.type),d=`<${t(c.title)}>${l.title}`,u=(p=c.useVariables)==null?void 0:p.call(c,F(v({},l),{title:d}),e);u&&i.push(u)}),i}},wt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var a,i;const{triggers:t}=s.usePlugin(re),{workflow:o}=Y(),n=t.get(o.type);return(i=(a=n==null?void 0:n.useVariables)==null?void 0:a.call(n,o.config,e))!=null?i:null}},Ut={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=xe,current:o}=e,{instructions:n}=s.usePlugin(re),a=he(),i=o!=null?o:a,l=ms(i),c=[];return l.forEach(d=>{var f,y;const u=n.get(d.type),p=(f=u.useScopeVariables)==null?void 0:f.call(u,d,e);p&&c.push({key:d.key,[t.value]:d.key,[t.label]:(y=d.title)!=null?y:`#${d.id}`,[t.children]:p})}),c}},Oo={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=xe}){return!e||e.includes("date")?[{key:"now",[t.label]:O("System time"),[t.value]:"now"}]:[]}},Pe={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 Po(e,t){var o,n,a,i,l,c;return typeof t=="string"?(o=Pe[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===((a=t.options)==null?void 0:a.collection)||((i=t.options)==null?void 0:i.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 _t(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function Gt({fields:e,types:t,appends:o,depth:n=1,compile:a,getCollectionFields:i}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>Po(l,d)):!0;if(Kt(l)){if(o===null)return n?c||Gt({fields:Ht(l.target,{compile:a,getCollectionFields:i}),types:t,depth:n-1,appends:o,compile:a,getCollectionFields:i}):!1;const d=_t(l,o),u=o.includes(l.name);return c?u:((d==null?void 0:d.length)||u)&&Gt({fields:Ht(l.target,{compile:a,getCollectionFields:i}),types:t,appends:d,compile:a,getCollectionFields:i}).length}else return c})}function st(e,t){var i,l;const o=s.useCompile(),n=(l=(i=e.useOptions)==null?void 0:i.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:a}=t;return{[a.label]:o(e.label),[a.value]:e.value,key:e[a.value],[a.children]:n,disabled:!n||!n.length}}function me(e={}){var a;const t=Object.assign({},xe,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t});return[st(Ut,o),st(vt,o),st(wt,o),st(Oo,o),s.useGlobalVariable("$env")].filter(Boolean)}function Eo(e={}){var a;const t=Object.assign({},xe,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t});return[st(Do,o)]}function Ht(e,{compile:t,getCollectionFields:o}){var d,u,p,f,y,h,g;const[n,a]=s.parseCollectionName(e),i=o(a,n),l=[],c=[];i.forEach(w=>{w.isForeignKey?l.push(w):c.push(w)});for(let w=c.length-1;w>=0;w--){const C=c[w];if(C.type==="belongsTo"){const D=l.find(S=>S.name===C.foreignKey);D?c.splice(w,0,F(v(v({},C),D),{uiSchema:F(v({},C.uiSchema),{title:(d=C.uiSchema)!=null&&d.title?`${t((u=C.uiSchema)==null?void 0:u.title)} ID`:D.name})})):c.splice(w,0,F(v({},C),{name:C.foreignKey,type:"bigInt",isForeignKey:!0,interface:C.interface,uiSchema:F(v({},C.uiSchema),{title:(p=C.uiSchema)!=null&&p.title?`${t((f=C.uiSchema)==null?void 0:f.title)} ID`:C.name})}))}else if(C.type==="context"&&C.collectionName==="users"){const D=(y=c.find(S=>S.type==="belongsTo"&&S.target==="users"&&S.foreignKey===C.name))!=null?y:{};c.splice(w,0,F(v({},C),{type:C.dataType,interface:D.interface,uiSchema:F(v({},D.uiSchema),{title:(h=D.uiSchema)!=null&&h.title?`${t((g=D.uiSchema)==null?void 0:g.title)} ID`:C.name})}))}}return c.filter(w=>w.interface&&!w.hidden)}function fs(e){const t=_t(e.field,e.appends),o=fe(v({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(a=>Po(e.field,a))||(e.disabled=!0))}function fe(e){const{fields:t,collection:o,types:n,appends:a=[],depth:i=1,compile:l,getCollectionFields:c,fieldNames:d=xe}=e,u=t!=null?t:Ht(o,{compile:l,getCollectionFields:c}),p=fs.bind({compile:l,getCollectionFields:c,fieldNames:d});return Gt({fields:u,types:n,depth:i,appends:a,compile:l,getCollectionFields:c}).map(y=>{var C;const h=l(((C=y.uiSchema)==null?void 0:C.title)||y.name),g=_t(y,a),w=!Kt(y)||g&&!g.length&&!a.includes(y.name)||!1;return{[d.label]:h,key:y.name,[d.value]:y.name,isLeaf:w,loadChildren:w?null:p,field:y,depth:i,appends:a,types:n}})}function ke(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.Input,v({scope:a},t))}function at(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.TextArea,v({scope:a},t))}function Mo(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.RawTextArea,v({scope:a},t))}function $o(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.JSON,v({scope:a},t))}function gs(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const{options:a=[]}=t,i=Eo(e),l=me(e);return r.jsx(s.Variable.CodeMirror,v({scope:[...i,...l,...a]},t))}function Ae({value:e,onChange:t,renderSchemaComponent:o}){const n=me();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Ne(e){const d=e,{options:t=[],getOptions:o=()=>[],direction:n}=d,a=Q(d,["options","getOptions","direction"]),i=s.useCompile(),l=o(),c=t.length>0?t:l;return r.jsx(b.Radio.Group,F(v({},a),{children:r.jsx(b.Space,{direction:n,children:c.map(u=>r.jsxs(b.Radio,{value:u.value,children:[r.jsx("span",{className:s.css`
419
419
  & + .anticon {
420
420
  margin-left: 0.25em;
421
421
  }
@@ -423,11 +423,11 @@
423
423
  & + .anticon {
424
424
  margin-left: 0.25em;
425
425
  }
426
- `,children:a(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:a(l.tooltip),children:r.jsx(H.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function Jt(){const e=A.useFieldSchema(),t=s.useCompile();return r.jsxs(s.GeneralSchemaDesigner,{title:t(e.title),children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Ie=()=>null;function fs(){const i=s.useSchemaInitializerItem(),{node:t,resultTitle:o}=i,n=Q(i,["node","resultTitle"]),{insert:a}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(v({},n),{onClick:()=>{var l;a({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 gs({dataSource:e}){var a;const t=A.useFieldSchema(),{execution:o}=Y();if(!o)return t.title;const n=W.parse(e)({$jobsMapByNodeKey:((a=o.jobs)!=null?a:[]).reduce((i,l)=>Object.assign(i,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:s.css`
426
+ `,children:a(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:a(l.tooltip),children:r.jsx(H.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function Jt(){const e=A.useFieldSchema(),t=s.useCompile();return r.jsxs(s.GeneralSchemaDesigner,{title:t(e.title),children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Ie=()=>null;function hs(){const i=s.useSchemaInitializerItem(),{node:t,resultTitle:o}=i,n=Q(i,["node","resultTitle"]),{insert:a}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(v({},n),{onClick:()=>{var l;a({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 ys({dataSource:e}){var a;const t=A.useFieldSchema(),{execution:o}=Y();if(!o)return t.title;const n=W.parse(e)({$jobsMapByNodeKey:((a=o.jobs)!=null?a:[]).reduce((i,l)=>Object.assign(i,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:s.css`
427
427
  margin: 0;
428
- `,children:JSON.stringify(n,null,2)})}Ie.Initializer=fs,Ie.Result=gs,Ie.Designer=Jt;function Vo(n){var a=n,{component:e="div",children:t}=a,o=Q(a,["component","children"]);const[i,l]=x.useState(!1),c=A.useFieldSchema();return r.jsxs(s.ActionContextProvider,{value:{visible:i,setVisible:l,fieldSchema:c},children:[x.createElement(e,F(v({},o),{onClick(){l(!0)}}),t),r.jsx(s.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Wo(e){var i;const o=s.useCompile()(e.label),n=x.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:a}=(i=ht[e.value])!=null?i:{};return r.jsx(b.Tag,{color:a,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function hs(e){const t=s.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Wo,v({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function jo(t){var e=Q(t,[]);const o=e.multiple?"multiple":null;return r.jsx(b.Select,F(v({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Wo,children:gt.filter(n=>!!n.value&&n.value!==ye.ABORTED).map(n=>r.jsx(b.Select.Option,F(v({},n),{children:r.jsx(hs,v({},n))}),n.value))}))}function Yt(e){const{t}=ee.useTranslation(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),a=s.useCollectionRecordData(),i=x.useCallback(()=>{b.Modal.confirm({title:O("Cancel the execution"),icon:r.jsx(H.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:a.id}).then(()=>{b.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[a]);return r.jsxs("div",{className:s.css`
428
+ `,children:JSON.stringify(n,null,2)})}Ie.Initializer=hs,Ie.Result=ys,Ie.Designer=Jt;function Vo(n){var a=n,{component:e="div",children:t}=a,o=Q(a,["component","children"]);const[i,l]=x.useState(!1),c=A.useFieldSchema();return r.jsxs(s.ActionContextProvider,{value:{visible:i,setVisible:l,fieldSchema:c},children:[x.createElement(e,F(v({},o),{onClick(){l(!0)}}),t),r.jsx(s.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Wo(e){var i;const o=s.useCompile()(e.label),n=x.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:a}=(i=ht[e.value])!=null?i:{};return r.jsx(b.Tag,{color:a,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function xs(e){const t=s.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Wo,v({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function jo(t){var e=Q(t,[]);const o=e.multiple?"multiple":null;return r.jsx(b.Select,F(v({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Wo,children:gt.filter(n=>!!n.value&&n.value!==ye.ABORTED).map(n=>r.jsx(b.Select.Option,F(v({},n),{children:r.jsx(xs,v({},n))}),n.value))}))}function Yt(e){const{t}=ee.useTranslation(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),a=s.useCollectionRecordData(),i=x.useCallback(()=>{b.Modal.confirm({title:O("Cancel the execution"),icon:r.jsx(H.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:a.id}).then(()=>{b.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[a]);return r.jsxs("div",{className:s.css`
429
429
  display: flex;
430
- `,children:[e.children,a.status?null:r.jsx(b.Tooltip,{title:O("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:i,shape:"circle",size:"small",icon:r.jsx(H.StopOutlined,{})})})]})}const Lo=t=>{var e=Q(t,[]);const[o,n]=x.useState(30),a=x.useRef(null),i=l=>{var c;n(a.current.offsetWidth+50),(c=e.onChange)==null||c.call(e,l)};return x.useEffect(()=>{n(a.current.offsetWidth+50)},[]),r.jsxs("div",{style:{display:"inline-block",position:"relative",height:"100%"},children:[r.jsx(b.Input,F(v({},e),{onChange:i,style:{width:`${o}px`}})),r.jsx("span",{ref:a,style:{position:"absolute",visibility:"hidden",whiteSpace:"pre",font:"inherit"},children:e.value||e.placeholder})]})},ys=e=>e.value&&typeof e.value=="object"?r.jsx(bs,v({},e)):r.jsx(xs,v({},e)),xs=({value:e,onChange:t})=>{const o=me({types:[vs]});return r.jsx(s.Variable.Input,{scope:o,value:e,onChange:t,children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:t})})},bs=()=>{const e=A.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Ae}}}}})})};function vs(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function Qt(){const{workflow:e}=Y();return!!(e!=null&&e.executed)}function zo(){const{workflow:e}=Y();return!!(e!=null&&e.allExecuted)}const ws=()=>{const e=Qt(),t=W.ArrayItems.useArray()||{field:[]},{t:o}=ve(),[n,a]=x.useState(!1),i=x.useCallback(()=>{t.field.push(""),a(!1)},[t.field]),l=x.useCallback(()=>{t.field.push({filter:{}}),a(!1)},[t.field]);return r.jsx(b.Popover,{open:n,onOpenChange:a,content:r.jsx(Cs,{onSlecet:i,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},Cs=({onSlecet:e,onQuery:t})=>{const{t:o}=ve();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},ks=e=>{const{t}=ve(),[o,n]=x.useState(!1),a=x.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:a,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},Zt=()=>{const{t:e}=ee.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext();return r.jsx(se.Link,{to:He(t),onClick:()=>o(!1),children:e("View")})},Xt=()=>{const e=s.useCollectionRecordData(),t=s.useDataBlockResource(),o=s.useDataBlockRequest(),n=se.useNavigate();return{onClick(){return P(this,null,function*(){var i;try{const{data:{data:l}}=yield t.retry({filterByTk:e.id});if(l&&l.id){const d=(i=window.location.pathname.split("business-components/")[1])==null?void 0:i.split("/")[0];n(He(l.id,d))}else o==null||o.refresh()}catch(l){o==null||o.refresh()}})}}},qo=()=>{const t=s.useCollectionRecordData().latestExecutedTime,o=t?mt(t).format("YYYY-MM-DD HH:mm:ss"):"-";return r.jsx("div",{style:{textAlign:"left"},children:o})},Uo=A.observer(e=>{const{value:t}=e,o=s.useCompile();return!t||!Array.isArray(t)||t.length===0?r.jsx("span",{children:"-"}):r.jsx(r.Fragment,{children:t.map(n=>{const a=(n==null?void 0:n.name)||(n==null?void 0:n.id),i=n==null?void 0:n.color;return r.jsx(b.Tag,{color:i,children:o(a)},(n==null?void 0:n.id)||a)})})}),Ko=e=>{var t,o,n;if(e["category.id"])return Array.isArray(e["category.id"])?e["category.id"][0]:e["category.id"];if((t=e.category)!=null&&t.id)return Array.isArray(e.category.id)?e.category.id[0]:e.category.id;if((o=e.$and)!=null&&o.length)for(const a of e.$and){if(a["category.id"])return Array.isArray(a["category.id"])?a["category.id"][0]:a["category.id"];if((n=a.category)!=null&&n.id)return Array.isArray(a.category.id)?a.category.id[0]:a.category.id}},_o=A.observer(()=>{const{t:e}=ee.useTranslation(),t=s.useDataBlockRequest(),o=s.useDataBlockProps(),[n,a]=x.useState("all"),i=x.useRef(void 0),l=x.useRef(!1);x.useEffect(()=>{var D,S,I,M,E,N,V;if(l.current){l.current=!1;return}const u=(((D=t==null?void 0:t.params)==null?void 0:D[0])||{}).filter||{},p=((S=o==null?void 0:o.params)==null?void 0:S.filter)||{},f=Ko(u)||Ko(p);if(i.current!==f&&(i.current!==void 0||f!==void 0)){i.current=f,a("all");const K=((M=(I=t==null?void 0:t.params)==null?void 0:I[1])==null?void 0:M.filters)||{};if(K.statusFilter){delete K.statusFilter;const q=s.mergeFilter([...Object.values(K),p]);t.run(F(v({},(E=t.params)==null?void 0:E[0]),{page:1,filter:q}),{filters:K})}return}i.current=f;const g=(((V=(N=t==null?void 0:t.params)==null?void 0:N[1])==null?void 0:V.filters)||{}).statusFilter,w=u.enabled;let C="all";(g==null?void 0:g.enabled)===!0||w===!0?C="enabled":((g==null?void 0:g.enabled)===!1||w===!1)&&(C="disabled"),C!==n&&a(C)},[t==null?void 0:t.params,o]);const c=x.useCallback(d=>{var h,g,w,C;const u=d.target.value;if(u===n)return;l.current=!0,a(u);const p=v({},(g=(h=t==null?void 0:t.params)==null?void 0:h[1])==null?void 0:g.filters),f=((w=o==null?void 0:o.params)==null?void 0:w.filter)||{};u==="all"?delete p.statusFilter:p.statusFilter={enabled:u==="enabled"};const y=s.mergeFilter([...Object.values(p),f]);t.run(F(v({},(C=t.params)==null?void 0:C[0]),{page:1,filter:y}),{filters:p})},[t,o,n]);return r.jsx(b.Radio.Group,{value:n,onChange:c,optionType:"button",buttonStyle:"solid",options:[{label:e("All statuses"),value:"all"},{label:e("On"),value:"enabled"},{label:e("Off"),value:"disabled"}]})});function Ss(e,t){const o=s.useCompile(),{getCollectionFields:n}=s.useCollectionManager_deprecated();return[{label:O("ID"),value:"filterByTk"},...e.action!=="destroy"?[{label:O("Values submitted"),value:"values",children:fe(F(v({},t),{appends:null,depth:3,collection:e.collection,compile:o,getCollectionFields:n}))}]:[]]}class As extends Re{constructor(){super(...arguments),this.sync=!0,this.title=O("Interceptor"),this.description=O('Triggered before the execution of a request initiated through an action button or API, such as before adding, updating, or deleting data. Suitable for data validation and logic judgment before action, and the request could be rejected by using the "End process" node.'),this.fieldset={collection:{type:"string",title:T("Collection"),required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:T("Trigger mode"),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:T("Local mode, triggered before executing the actions bound to this workflow"),value:!1},{label:T("Global mode, triggered before executing the following actions"),value:!0}]},default:!1},actions:{type:"number",title:T("Select actions"),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:T("Create record action"),value:"create"},{label:T("Update record action"),value:"update"},{label:T("Delete record action"),value:"destroy"}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FieldsSelect:rt,RadioWithTooltip:Ne,CheckboxGroupWithTooltip:Bo},this.isActionTriggerable=(t,o)=>{const{global:n}=t;return!n&&!o.direct}}useVariables(t,o){const n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=fe(F(v({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:T("User acted")}}],compile:n,getCollectionFields:a})),l=[{label:O("Parameters"),value:"params",children:Ss(t,o)}];return[...i,{label:O("Role of user acted"),value:"roleName"},...l]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:T("Trigger data"),Component:Te,collection:t.collection,dataPath:"$context.params.values"}:null}}class Is extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerTrigger("request-interception",As)})}}class Fs extends oe{constructor(){super(...arguments),this.title=T("JS Parse"),this.type=ko,this.group=Ge,this.description=T("Get specific data from JSON result of any node BY js code;"),this.fieldset={source:{type:"string",title:T("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},JSCode:{type:"string",title:T("JSCode expression"),"x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.data
430
+ `,children:[e.children,a.status?null:r.jsx(b.Tooltip,{title:O("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:i,shape:"circle",size:"small",icon:r.jsx(H.StopOutlined,{})})})]})}const Lo=t=>{var e=Q(t,[]);const[o,n]=x.useState(30),a=x.useRef(null),i=l=>{var c;n(a.current.offsetWidth+50),(c=e.onChange)==null||c.call(e,l)};return x.useEffect(()=>{n(a.current.offsetWidth+50)},[]),r.jsxs("div",{style:{display:"inline-block",position:"relative",height:"100%"},children:[r.jsx(b.Input,F(v({},e),{onChange:i,style:{width:`${o}px`}})),r.jsx("span",{ref:a,style:{position:"absolute",visibility:"hidden",whiteSpace:"pre",font:"inherit"},children:e.value||e.placeholder})]})},bs=e=>e.value&&typeof e.value=="object"?r.jsx(ws,v({},e)):r.jsx(vs,v({},e)),vs=({value:e,onChange:t})=>{const o=me({types:[Cs]});return r.jsx(s.Variable.Input,{scope:o,value:e,onChange:t,children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:t})})},ws=()=>{const e=A.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Ae}}}}})})};function Cs(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function Qt(){const{workflow:e}=Y();return!!(e!=null&&e.executed)}function zo(){const{workflow:e}=Y();return!!(e!=null&&e.allExecuted)}const ks=()=>{const e=Qt(),t=W.ArrayItems.useArray()||{field:[]},{t:o}=ve(),[n,a]=x.useState(!1),i=x.useCallback(()=>{t.field.push(""),a(!1)},[t.field]),l=x.useCallback(()=>{t.field.push({filter:{}}),a(!1)},[t.field]);return r.jsx(b.Popover,{open:n,onOpenChange:a,content:r.jsx(Ss,{onSlecet:i,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},Ss=({onSlecet:e,onQuery:t})=>{const{t:o}=ve();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},As=e=>{const{t}=ve(),[o,n]=x.useState(!1),a=x.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:a,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},Zt=()=>{const{t:e}=ee.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext();return r.jsx(se.Link,{to:He(t),onClick:()=>o(!1),children:e("View")})},Xt=()=>{const e=s.useCollectionRecordData(),t=s.useDataBlockResource(),o=s.useDataBlockRequest(),n=se.useNavigate();return{onClick(){return P(this,null,function*(){var i;try{const{data:{data:l}}=yield t.retry({filterByTk:e.id});if(l&&l.id){const d=(i=window.location.pathname.split("business-components/")[1])==null?void 0:i.split("/")[0];n(He(l.id,d))}else o==null||o.refresh()}catch(l){o==null||o.refresh()}})}}},qo=()=>{const t=s.useCollectionRecordData().latestExecutedTime,o=t?mt(t).format("YYYY-MM-DD HH:mm:ss"):"-";return r.jsx("div",{style:{textAlign:"left"},children:o})},Uo=A.observer(e=>{const{value:t}=e,o=s.useCompile();return!t||!Array.isArray(t)||t.length===0?r.jsx("span",{children:"-"}):r.jsx(r.Fragment,{children:t.map(n=>{const a=(n==null?void 0:n.name)||(n==null?void 0:n.id),i=n==null?void 0:n.color;return r.jsx(b.Tag,{color:i,children:o(a)},(n==null?void 0:n.id)||a)})})}),Ko=e=>{var t,o,n;if(e["category.id"])return Array.isArray(e["category.id"])?e["category.id"][0]:e["category.id"];if((t=e.category)!=null&&t.id)return Array.isArray(e.category.id)?e.category.id[0]:e.category.id;if((o=e.$and)!=null&&o.length)for(const a of e.$and){if(a["category.id"])return Array.isArray(a["category.id"])?a["category.id"][0]:a["category.id"];if((n=a.category)!=null&&n.id)return Array.isArray(a.category.id)?a.category.id[0]:a.category.id}},_o=A.observer(()=>{const{t:e}=ee.useTranslation(),t=s.useDataBlockRequest(),o=s.useDataBlockProps(),[n,a]=x.useState("all"),i=x.useRef(void 0),l=x.useRef(!1);x.useEffect(()=>{var D,S,I,M,E,N,V;if(l.current){l.current=!1;return}const u=(((D=t==null?void 0:t.params)==null?void 0:D[0])||{}).filter||{},p=((S=o==null?void 0:o.params)==null?void 0:S.filter)||{},f=Ko(u)||Ko(p);if(i.current!==f&&(i.current!==void 0||f!==void 0)){i.current=f,a("all");const K=((M=(I=t==null?void 0:t.params)==null?void 0:I[1])==null?void 0:M.filters)||{};if(K.statusFilter){delete K.statusFilter;const q=s.mergeFilter([...Object.values(K),p]);t.run(F(v({},(E=t.params)==null?void 0:E[0]),{page:1,filter:q}),{filters:K})}return}i.current=f;const g=(((V=(N=t==null?void 0:t.params)==null?void 0:N[1])==null?void 0:V.filters)||{}).statusFilter,w=u.enabled;let C="all";(g==null?void 0:g.enabled)===!0||w===!0?C="enabled":((g==null?void 0:g.enabled)===!1||w===!1)&&(C="disabled"),C!==n&&a(C)},[t==null?void 0:t.params,o]);const c=x.useCallback(d=>{var h,g,w,C;const u=d.target.value;if(u===n)return;l.current=!0,a(u);const p=v({},(g=(h=t==null?void 0:t.params)==null?void 0:h[1])==null?void 0:g.filters),f=((w=o==null?void 0:o.params)==null?void 0:w.filter)||{};u==="all"?delete p.statusFilter:p.statusFilter={enabled:u==="enabled"};const y=s.mergeFilter([...Object.values(p),f]);t.run(F(v({},(C=t.params)==null?void 0:C[0]),{page:1,filter:y}),{filters:p})},[t,o,n]);return r.jsx(b.Radio.Group,{value:n,onChange:c,optionType:"button",buttonStyle:"solid",options:[{label:e("All statuses"),value:"all"},{label:e("On"),value:"enabled"},{label:e("Off"),value:"disabled"}]})});function Is(e,t){const o=s.useCompile(),{getCollectionFields:n}=s.useCollectionManager_deprecated();return[{label:O("ID"),value:"filterByTk"},...e.action!=="destroy"?[{label:O("Values submitted"),value:"values",children:fe(F(v({},t),{appends:null,depth:3,collection:e.collection,compile:o,getCollectionFields:n}))}]:[]]}class Fs extends Re{constructor(){super(...arguments),this.sync=!0,this.title=O("Interceptor"),this.description=O('Triggered before the execution of a request initiated through an action button or API, such as before adding, updating, or deleting data. Suitable for data validation and logic judgment before action, and the request could be rejected by using the "End process" node.'),this.fieldset={collection:{type:"string",title:T("Collection"),required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:T("Trigger mode"),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:T("Local mode, triggered before executing the actions bound to this workflow"),value:!1},{label:T("Global mode, triggered before executing the following actions"),value:!0}]},default:!1},actions:{type:"number",title:T("Select actions"),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:T("Create record action"),value:"create"},{label:T("Update record action"),value:"update"},{label:T("Delete record action"),value:"destroy"}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FieldsSelect:rt,RadioWithTooltip:Ne,CheckboxGroupWithTooltip:Bo},this.isActionTriggerable=(t,o)=>{const{global:n}=t;return!n&&!o.direct}}useVariables(t,o){const n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=fe(F(v({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:T("User acted")}}],compile:n,getCollectionFields:a})),l=[{label:O("Parameters"),value:"params",children:Is(t,o)}];return[...i,{label:O("Role of user acted"),value:"roleName"},...l]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:T("Trigger data"),Component:Te,collection:t.collection,dataPath:"$context.params.values"}:null}}class Ts extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerTrigger("request-interception",Fs)})}}class Ns extends oe{constructor(){super(...arguments),this.title=T("JS Parse"),this.type=ko,this.group=Ge,this.description=T("Get specific data from JSON result of any node BY js code;"),this.fieldset={source:{type:"string",title:T("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},JSCode:{type:"string",title:T("JSCode expression"),"x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.data
431
431
  ctx.body
432
432
  __ctx
433
433
  lib.JSON
@@ -441,14 +441,14 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:T("P
441
441
  button {
442
442
  padding: 0;
443
443
  }
444
- `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o,d=i.model||[];return{[c.label]:a,[c.value]:n,[c.children]:d.map(p=>({[c.label]:p.label,[c.value]:p.alias||p.path}))}}isAvailable(){return!1}}class Ts extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(ko,Fs)})}}class Ns extends oe{constructor(){super(...arguments),this.title=T("JSON Parse"),this.type=Co,this.group=Ge,this.description=T("Get specific data from JSON result of any node BY jsonata; https://jsonata.org/"),this.fieldset={source:{type:"string",title:T("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},expression:{type:"string",title:T("Query expression"),"x-decorator":"FormItem","x-component":"CodeMirror"},model:{type:"array",title:T("Properties mapping"),description:T("If the type of query result is object or array of object, could map the properties which to be accessed in subsequent nodes."),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{path:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Property path")},properties:{path:{type:"string",name:"path",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},alias:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Label")},properties:{label:{type:"string",name:"label",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
444
+ `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o,d=i.model||[];return{[c.label]:a,[c.value]:n,[c.children]:d.map(p=>({[c.label]:p.label,[c.value]:p.alias||p.path}))}}isAvailable(){return!1}}class Ds extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(ko,Ns)})}}class Os extends oe{constructor(){super(...arguments),this.title=T("JSON Parse"),this.type=Co,this.group=Ge,this.description=T("Get specific data from JSON result of any node BY jsonata; https://jsonata.org/"),this.fieldset={source:{type:"string",title:T("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},expression:{type:"string",title:T("Query expression"),"x-decorator":"FormItem","x-component":"CodeMirror"},model:{type:"array",title:T("Properties mapping"),description:T("If the type of query result is object or array of object, could map the properties which to be accessed in subsequent nodes."),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{path:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Property path")},properties:{path:{type:"string",name:"path",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},alias:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Label")},properties:{label:{type:"string",name:"label",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
445
445
  > *:not(:last-child) {
446
446
  margin-right: 0.5em;
447
447
  }
448
448
  button {
449
449
  padding: 0;
450
450
  }
451
- `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o,d=i.model||[];return{[c.label]:a,[c.value]:n,[c.children]:d.map(p=>({[c.label]:p.label,[c.value]:p.alias||p.path}))}}isAvailable(){return!1}}class Ds extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(Co,Ns)})}}function Os(e,t){let o=e,n=null;for(let a=0;a<t.length;a++){const i=t[a],l=o.find(c=>c.value===i);if(!l)return null;n=l,!l.isLeaf&&l.loadChildren&&l.loadChildren(l),l.children&&(o=l.children)}return n}class Ps extends oe{constructor(){super(...arguments),this.title=`{{t("Loop", { ns: "${m}" })}}`,this.type="loop",this.group="control",this.icon="RetweetOutlined",this.color="#0ed6ec",this.description=`{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "${m}" })}}`,this.fieldset={target:{type:"string",title:`{{t("Loop target", { ns: "${m}" })}}`,description:`{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:["string","number","null"],className:s.css`
451
+ `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o,d=i.model||[];return{[c.label]:a,[c.value]:n,[c.children]:d.map(p=>({[c.label]:p.label,[c.value]:p.alias||p.path}))}}isAvailable(){return!1}}class Ps extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(Co,Os)})}}function Es(e,t){let o=e,n=null;for(let a=0;a<t.length;a++){const i=t[a],l=o.find(c=>c.value===i);if(!l)return null;n=l,!l.isLeaf&&l.loadChildren&&l.loadChildren(l),l.children&&(o=l.children)}return n}class Ms extends oe{constructor(){super(...arguments),this.title=`{{t("Loop", { ns: "${m}" })}}`,this.type="loop",this.group="control",this.icon="RetweetOutlined",this.color="#0ed6ec",this.description=`{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "${m}" })}}`,this.fieldset={target:{type:"string",title:`{{t("Loop target", { ns: "${m}" })}}`,description:`{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:["string","number","null"],className:s.css`
452
452
  width: 100%;
453
453
 
454
454
  .variable {
@@ -460,23 +460,23 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:T("P
460
460
  }
461
461
  `},required:!0},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableInput:ke}}Component({data:t}){var i;const{nodes:o}=Y(),{styles:n}=we(),a=o.find(l=>l.upstreamId===t.id&&l.branchIndex!=null);return r.jsx(it,{data:t,children:r.jsx("div",{className:n.nodeSubtreeClass,children:r.jsxs("div",{className:s.cx(n.branchBlockClass,s.css`
462
462
  padding-left: 20em;
463
- `),children:[r.jsx(je,{from:t,entry:a,branchIndex:(i=a==null?void 0:a.branchIndex)!=null?i:0}),r.jsxs("div",{className:n.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:s.cx(n.addButtonClass,n.loopLineClass),children:r.jsx(H.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(t,o){const n=s.useCompile(),a=O("Loop target"),i=O("Loop index"),l=O("Loop length"),{target:c}=t.config;if(!c)return null;const{fieldNames:d=xe}=o;let u={key:"item",[d.value]:"item",[d.label]:a};if(typeof c=="string"&&c.startsWith("{{")&&c.endsWith("}}")){const p=c.slice(2,-2).split(".").map(h=>h.trim()),f=[Ut,vt,wt].map(h=>{const g=h.useOptions(F(v({},o),{current:t})).filter(Boolean);return{[d.label]:n(h.label),[d.value]:h.value,key:h.value,[d.children]:g,disabled:g&&!g.length}}),y=Os(f,p);u=Object.assign({},y,u)}return[u,{key:"index",[d.value]:"index",[d.label]:i},{key:"length",[d.value]:"length",[d.label]:l}]}}class Es extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("loop",Ps)})}}function Ms(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function $s({multiple:e=!1,value:t=[],onChange:o}){const n=me({types:[Ms]});return r.jsx(s.Variable.Input,{scope:n,value:t[0],onChange:a=>{o([a])},children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:a=>{o(a!=null?[a]:[])}})})}function Bs({value:e,onChange:t}){const o=r.jsx("fieldset",{children:r.jsx(W.FormLayout,{layout:"vertical",children:r.jsx(s.FormItem,{label:O("Negotiation"),children:r.jsxs(b.Radio.Group,{value:e,onChange:t,children:[r.jsx(b.Radio,{value:1,children:r.jsxs(b.Tooltip,{title:O("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:O("All pass")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:-1,children:r.jsxs(b.Tooltip,{title:O("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:O("Any pass")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})});return r.jsxs("fieldset",{className:s.css`
463
+ `),children:[r.jsx(je,{from:t,entry:a,branchIndex:(i=a==null?void 0:a.branchIndex)!=null?i:0}),r.jsxs("div",{className:n.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:s.cx(n.addButtonClass,n.loopLineClass),children:r.jsx(H.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(t,o){const n=s.useCompile(),a=O("Loop target"),i=O("Loop index"),l=O("Loop length"),{target:c}=t.config;if(!c)return null;const{fieldNames:d=xe}=o;let u={key:"item",[d.value]:"item",[d.label]:a};if(typeof c=="string"&&c.startsWith("{{")&&c.endsWith("}}")){const p=c.slice(2,-2).split(".").map(h=>h.trim()),f=[Ut,vt,wt].map(h=>{const g=h.useOptions(F(v({},o),{current:t})).filter(Boolean);return{[d.label]:n(h.label),[d.value]:h.value,key:h.value,[d.children]:g,disabled:g&&!g.length}}),y=Es(f,p);u=Object.assign({},y,u)}return[u,{key:"index",[d.value]:"index",[d.label]:i},{key:"length",[d.value]:"length",[d.label]:l}]}}class $s extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("loop",Ms)})}}function Bs(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function Vs({multiple:e=!1,value:t=[],onChange:o}){const n=me({types:[Bs]});return r.jsx(s.Variable.Input,{scope:n,value:t[0],onChange:a=>{o([a])},children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:a=>{o(a!=null?[a]:[])}})})}function Ws({value:e,onChange:t}){const o=r.jsx("fieldset",{children:r.jsx(W.FormLayout,{layout:"vertical",children:r.jsx(s.FormItem,{label:O("Negotiation"),children:r.jsxs(b.Radio.Group,{value:e,onChange:t,children:[r.jsx(b.Radio,{value:1,children:r.jsxs(b.Tooltip,{title:O("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:O("All pass")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:-1,children:r.jsxs(b.Tooltip,{title:O("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:O("Any pass")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})});return r.jsxs("fieldset",{className:s.css`
464
464
  .ant-radio-group {
465
465
  .anticon {
466
466
  margin-left: 0.5em;
467
467
  }
468
468
  }
469
- `,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),t(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:O("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:O("Separately")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:O("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:O("Collaboratively")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?o:null]})}function Go(e){var E,N,V;const t=s.useRecord(),o=A.useFieldSchema(),n=A.useField(),a=x.useRef(null),i=e.dataSource||s.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:l}=s.useAssociationNames(i),{appends:c,updateAssociationValues:d}=l(),[u]=Object.keys((E=o.toJSON().properties)!=null?E:{}),p=(N=t==null?void 0:t.result)==null?void 0:N[u],{findComponent:f}=s.useDesignable(),y=f((V=n.component)==null?void 0:V[0])||x.Fragment,h=x.useMemo(()=>A.createForm({initialValues:p}),[p]),g=x.useMemo(()=>v({appends:c},e.params),[c,e.params]),w=x.useMemo(()=>({loading:!1,data:{data:p}}),[p]),C=s.useAPIClient(),D=s.useDataSourceHeaders(i),S=C.resource(e.collection,void 0,D),I=s.useBlockRequestContext(),M=x.useMemo(()=>({params:g,form:h,field:n,service:w,updateAssociationValues:d,formBlockRef:a}),[n,h,g,w,d]);return!t.status||p?r.jsx(s.CollectionManagerProvider,{dataSource:i,children:r.jsx(s.CollectionProvider_deprecated,{collection:e.collection,children:r.jsx(s.RecordProvider,{record:p,parent:null,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:e,field:n,service:w,resource:S,__parent:I},children:r.jsx(s.FormBlockContext.Provider,{value:M,children:r.jsxs(y,F(v({},n.componentProps),{children:[r.jsx(s.FormV2.Templates,{style:{marginBottom:18},form:h}),r.jsx("div",{ref:a,children:r.jsx(A.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})})}):null}function Vs(e){return s.createFormBlockSchema(e)}function Ws(o){var n=o,{schema:e}=n,t=Q(n,["schema"]);const{getTemplateSchemaByMode:a}=s.useSchemaTemplateManager(),{insert:i}=s.useSchemaInitializer(),l=s.useRecordCollectionDataSourceItems("FormItem");function c(u){return P(this,arguments,function*({item:d}){var g;const p=d.template?yield a(d):null,f=Vs(F(v({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:Ce.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},e),{template:p}));delete f["x-acl-action-props"],delete f["x-acl-action"];const[y]=Object.keys(f.properties),h=((g=Object.entries(f.properties[y].properties).find(([w,C])=>C["x-component"]==="ActionBar"))==null?void 0:g[0])||"actions";f.properties[y].properties[h]["x-decorator"]="ActionBarProvider",f.properties[y].properties[h]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},bt(f,w=>{w["x-uid"]&&delete w["x-uid"]}),i(f)})}return r.jsx(s.SchemaInitializerItem,F(v({},t),{onClick:c,items:l}))}function Ho(){var t,o;const e=s.useSchemaInitializerItem();return r.jsx(s.CollectionProvider_deprecated,{dataSource:(t=e.schema)==null?void 0:t.dataSource,collection:(o=e.schema)==null?void 0:o.collection,children:r.jsx(Ws,v({},e))})}function Ee(e,t,o=!1){const n=[];return e?t(e)&&(!o||!e.properties)?(n.push(e),n):(e.properties&&Object.keys(e.properties).forEach(a=>{n.push(...Ee(e.properties[a],t))}),n):n}function js(){const{name:e,title:t}=s.useCollection_deprecated();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDataTemplates,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Ls={title:`{{t("Create record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=x.useMemo(()=>e.map(({key:i,displayName:l,collections:c})=>({key:i,name:i,label:l,type:"subMenu",children:c.map(d=>({name:ae.camelCase(`createRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:i,title:`{{t("Create record", { ns: "${m}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Ho}))})),[e]),[o,n]=x.useState([]),a=s.useMenuSearch({data:t,openKeys:o});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(i){n(i)}},children:a}},initializers:{},components:{CreateFormDesigner:js},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var c,d;const[a]=Object.keys(n.properties),i=n.properties[a],l=((c=Object.entries(i.properties).find(([u,p])=>p["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[a]={type:"create",title:((d=n["x-component-props"])==null?void 0:d.title)||a,actions:Ee(i.properties[l],u=>u["x-component"]==="Action").map(u=>{var p,f;return{status:u["x-decorator-props"].value,values:(f=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function Jo(e){var u,p,f,y;const[t,o]=x.useState((p=(u=e.collection)==null?void 0:u.fields)!=null?p:[]),n=s.useRecord(),a=A.useField(),i=A.useFieldSchema(),[l]=Object.keys((f=i.toJSON().properties)!=null?f:{}),c=(y=n==null?void 0:n.result)==null?void 0:y[l],d=x.useMemo(()=>A.createForm({initialValues:c}),[c]);return!n.status||c?r.jsx(s.CollectionProvider_deprecated,{collection:F(v({},e.collection),{fields:t}),children:r.jsx(s.RecordProvider,{record:c,parent:null,children:r.jsx(s.FormBlockContext.Provider,{value:{form:d,field:a,setCollectionFields:o},children:e.children})})}):null}function zs(){const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem();return r.jsx(s.SchemaInitializerItem,F(v({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:W.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[W.uid()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:customForm:configureFields"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"workflowManual:form:configureActions",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:Ce.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const Yo={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function qs(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:a="others"}=n;t[a]=t[a]||{},ae.set(t,[a,o],n)}),Object.keys(Yo).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:Yo[o],children:Object.keys(t[o]||{}).map(n=>{const a=t[o][n];return v({value:n,title:a.title,name:n},t[o][n])}).sort((n,a)=>n.order-a.order)}))}function Us(){const{interfaces:e}=s.useCollectionManager_deprecated();return qs(e).map(o=>({name:o.title,type:"itemGroup",title:o.title,children:o.children.map(n=>({name:n.name,type:"item",title:n.title,Component:Gs,fieldInterface:n.name}))}))}const Qo=x.createContext({}),Ks=e=>{const[t,o]=x.useState(null),[n,a]=x.useState(),i=Us(),l=s.useCollection_deprecated(),{setCollectionFields:c}=x.useContext(s.FormBlockContext),d=x.useMemo(()=>A.createForm(),[t]);return r.jsxs(Qo.Provider,{value:{onAddField(u){const p=ae.pick(u,["name","group","title","default","validateSchema"]),{properties:D}=u,S=D,{unique:f,type:y,layout:h,autoIncrement:g}=S,w=Q(S,["unique","type","layout","autoIncrement"]);p.properties=w;const C=ae.cloneDeep(p);delete C.properties.name["x-disabled"],o(C)},setCallback:a},children:[r.jsx(s.SchemaInitializerItems,F(v({},e),{items:i})),r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible(u){u||o(null)}},children:t?r.jsx(s.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:d},"x-component":"Action.Drawer",properties:F(v({},t.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const u=A.useForm();return{run(){return P(this,null,function*(){a(null),o(null),u.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:u,query:p,reset:f}=A.useForm(),y=[O("Field name existed in form")];return{run(){return P(this,null,function*(){var S,I,M,E;const{default:g}=t,w=W.uid();if(g.name=(S=u.name)!=null?S:w,g.uiSchema.title=(M=(I=u.uiSchema)==null?void 0:I.title)!=null?M:w,g.interface=t.name,(E=l.fields)==null?void 0:E.find(N=>N.name===g.name)){p("name").take().setFeedback({type:"error",messages:y});return}const D=W.merge(g,u);c([...l.fields,D]),n({name:g.name,type:g.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:D},"x-collection-field":`${l.name}.${g.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),f(),a(null),o(null)})}}}}}}}})},components:{ArrayTable:W.ArrayTable}}):null})]})},_s=new s.SchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:s.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:Ks});function Gs(){const e=s.useSchemaInitializerItem(),{insert:t,setVisible:o}=s.useSchemaInitializer(),{onAddField:n,setCallback:a}=x.useContext(Qo),{getInterface:i}=s.useCollectionManager_deprecated(),l=i(e.fieldInterface);return r.jsx(s.SchemaInitializerItem,v({onClick:()=>{a(()=>t),n(l),o(!1)}},e),e.fieldInterface)}const Zo={title:`{{t("Custom form", { ns: "${m}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${m}" })}}`,Component:zs}},initializers:{},components:{CustomFormBlockProvider:Jo},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var d,u;const[a]=Object.keys(n.properties),i=n.properties[a],l=Ee(i.properties.grid,p=>p["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(p=>{var f,y;return(y=(f=p["x-component-props"])==null?void 0:f.field)!=null?y:p["x-interface-options"]});const c=((d=Object.entries(i.properties).find(([p,f])=>f["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";t[a]={type:"custom",title:((u=n["x-component-props"])==null?void 0:u.title)||a,actions:Ee(i.properties[c],p=>p["x-component"]==="Action").map(p=>{var f,y;return{status:p["x-decorator-props"].value,values:(y=(f=p["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:y.values,key:p.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:Jo}}};function Hs(){const{name:e,title:t}=s.useCollection_deprecated(),o=A.useFieldSchema(),{t:n}=ee.useTranslation(),{dn:a}=s.useDesignable();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsActionModalItem,{title:n("Filter settings",{ns:m}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-use-component-props":()=>{var l;return{options:s.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:i})=>{o["x-decorator-props"].filter=i,a.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),a.refresh()}}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Js={title:`{{t("Update record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=x.useMemo(()=>e.map(({key:i,displayName:l,collections:c})=>({key:i,name:i,label:l,type:"subMenu",children:c.map(d=>({name:ae.camelCase(`updateRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:i,title:`{{t("Update record", { ns: "${m}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Ho}))})),[e]),[o,n]=x.useState([]),a=s.useMenuSearch({data:t,openKeys:o});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(i){n(i)}},children:a}},initializers:{},components:{FilterDynamicComponent:Ae,UpdateFormDesigner:Hs},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var c,d;const[a]=Object.keys(n.properties),i=n.properties[a],l=((c=Object.entries(i.properties).find(([u,p])=>p["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[a]=F(v({},n["x-decorator-props"]),{type:"update",title:((d=n["x-component-props"])==null?void 0:d.title)||a,actions:Ee(i.properties[l],u=>u["x-component"]==="Action").map(u=>{var p,f;return{status:u["x-decorator-props"].value,values:(f=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:u.name}})})}),t}},block:{scope:{},components:{}}},Me=new W.Registry;Me.register("customForm",Zo),Me.register("createForm",Ls),Me.register("updateForm",Js);function Ys(){const{workflow:e}=Y(),t=et();return t.useInitializers?t.useInitializers(e.config):null}Zo.title;const Qs=new s.SchemaInitializer({name:"workflowManual:popup:configureUserInterface:addBlock",wrap:s.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const e=s.usePlugin(re),t=he(),o=We(t),n=[Ys()].filter(Boolean),a=o.map(l=>{var d;const c=e.instructions.get(l.type);return(d=c==null?void 0:c.useInitializers)==null?void 0:d.call(c,l)}).filter(Boolean);return[...n,...a.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${m}" })}}`,children:a}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const t=s.useDataSourceManager().getAllCollections();return Array.from(Me.getValues()).map(o=>{const{useInitializer:n}=o.config;return n({allCollections:t})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Demonstration text")}}',Component:"MarkdownBlockInitializer"}]}]});function Zs(){var C,D,S;const e=x.useContext(s.SchemaComponentContext),{t}=ee.useTranslation(),o=A.useFieldSchema(),n=me(),[a,i]=x.useState(!1),[l,c]=x.useState((S=(D=(C=o==null?void 0:o["x-action-settings"])==null?void 0:C.assignedValues)==null?void 0:D.schema)!=null?S:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[d,u]=x.useState(null),{components:p}=s.useSchemaOptionsContext();x.useEffect(()=>{u(new A.Schema({properties:{grid:l}}))},[l]);const f=x.useMemo(()=>{var M,E;const I=(E=(M=o==null?void 0:o["x-action-settings"])==null?void 0:M.assignedValues)==null?void 0:E.values;return A.createForm({initialValues:ae.cloneDeep(I),values:ae.cloneDeep(I)})},[o]),y=s.useFormActiveFields(),h=t("Assign field values");function g(){i(!1)}function w(){o["x-action-settings"]||(o["x-action-settings"]={}),o["x-action-settings"].assignedValues||(o["x-action-settings"].assignedValues={}),o["x-action-settings"].assignedValues.schema=l,o["x-action-settings"].assignedValues.values=f.values,i(!1),setTimeout(()=>{var I;(I=e.refresh)==null||I.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaSettingsItem,{title:h,onClick:()=>i(!0),children:h}),r.jsx(b.Modal,{width:"50%",title:h,open:a,onCancel:g,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:g,children:t("Cancel")}),r.jsx(b.Button,{type:"primary",onClick:w,children:t("Submit")})]}),children:r.jsx(s.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(s.VariableScopeProvider,{scope:n,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:y==null?void 0:y.getActiveFieldsName,children:r.jsx(A.FormProvider,{form:f,children:r.jsxs(W.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:O("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),a&&d&&r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},e),{refresh(){c(ae.get(d.toJSON(),"properties.grid"))}}),children:r.jsx(s.SchemaComponent,{schema:d,components:p})})]})})})})})})]})}function Xs(e){return r.jsxs(s.GeneralSchemaDesigner,F(v({},e),{disableInitializer:!0,children:[r.jsx(s.Action.Designer.ButtonEditor,{}),r.jsx(Zs,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Rs(){const i=s.useSchemaInitializerItem(),{action:t,actionProps:o}=i,n=Q(i,["action","actionProps"]),{insert:a}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(v({},n),{onClick:()=>{a({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":F(v({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Xo(){const e=s.useSchemaInitializerItem(),a=e,{action:t,actionProps:o}=a,n=Q(a,["action","actionProps"]);return r.jsx(s.InitializerWithSwitch,F(v({},n),{item:e,schema:{type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":F(v({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${t}`},type:"x-action"}))}const ea=new s.SchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${m}" })}}`,Component:Rs,action:Ce.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${m}" })}}`,Component:Xo,action:Ce.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${m}" })}}`,Component:Xo,action:Ce.PENDING}]});function ta(){return{run(){}}}function oa({value:e,onChange:t}){const o=s.usePlugin(re),n=x.useContext(s.SchemaComponentContext),a=he(),i=We(a),l=A.useForm(),{workflow:c}=Y(),d={};i.forEach(f=>{const y=o.instructions.get(f.type);Object.assign(d,y.components)});const u=x.useMemo(()=>new A.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:s.css`
469
+ `,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),t(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:O("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:O("Separately")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:O("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:O("Collaboratively")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?o:null]})}function Go(e){var E,N,V;const t=s.useRecord(),o=A.useFieldSchema(),n=A.useField(),a=x.useRef(null),i=e.dataSource||s.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:l}=s.useAssociationNames(i),{appends:c,updateAssociationValues:d}=l(),[u]=Object.keys((E=o.toJSON().properties)!=null?E:{}),p=(N=t==null?void 0:t.result)==null?void 0:N[u],{findComponent:f}=s.useDesignable(),y=f((V=n.component)==null?void 0:V[0])||x.Fragment,h=x.useMemo(()=>A.createForm({initialValues:p}),[p]),g=x.useMemo(()=>v({appends:c},e.params),[c,e.params]),w=x.useMemo(()=>({loading:!1,data:{data:p}}),[p]),C=s.useAPIClient(),D=s.useDataSourceHeaders(i),S=C.resource(e.collection,void 0,D),I=s.useBlockRequestContext(),M=x.useMemo(()=>({params:g,form:h,field:n,service:w,updateAssociationValues:d,formBlockRef:a}),[n,h,g,w,d]);return!t.status||p?r.jsx(s.CollectionManagerProvider,{dataSource:i,children:r.jsx(s.CollectionProvider_deprecated,{collection:e.collection,children:r.jsx(s.RecordProvider,{record:p,parent:null,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:e,field:n,service:w,resource:S,__parent:I},children:r.jsx(s.FormBlockContext.Provider,{value:M,children:r.jsxs(y,F(v({},n.componentProps),{children:[r.jsx(s.FormV2.Templates,{style:{marginBottom:18},form:h}),r.jsx("div",{ref:a,children:r.jsx(A.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})})}):null}function js(e){return s.createFormBlockSchema(e)}function Ls(o){var n=o,{schema:e}=n,t=Q(n,["schema"]);const{getTemplateSchemaByMode:a}=s.useSchemaTemplateManager(),{insert:i}=s.useSchemaInitializer(),l=s.useRecordCollectionDataSourceItems("FormItem");function c(u){return P(this,arguments,function*({item:d}){var g;const p=d.template?yield a(d):null,f=js(F(v({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:Ce.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},e),{template:p}));delete f["x-acl-action-props"],delete f["x-acl-action"];const[y]=Object.keys(f.properties),h=((g=Object.entries(f.properties[y].properties).find(([w,C])=>C["x-component"]==="ActionBar"))==null?void 0:g[0])||"actions";f.properties[y].properties[h]["x-decorator"]="ActionBarProvider",f.properties[y].properties[h]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},bt(f,w=>{w["x-uid"]&&delete w["x-uid"]}),i(f)})}return r.jsx(s.SchemaInitializerItem,F(v({},t),{onClick:c,items:l}))}function Ho(){var t,o;const e=s.useSchemaInitializerItem();return r.jsx(s.CollectionProvider_deprecated,{dataSource:(t=e.schema)==null?void 0:t.dataSource,collection:(o=e.schema)==null?void 0:o.collection,children:r.jsx(Ls,v({},e))})}function Ee(e,t,o=!1){const n=[];return e?t(e)&&(!o||!e.properties)?(n.push(e),n):(e.properties&&Object.keys(e.properties).forEach(a=>{n.push(...Ee(e.properties[a],t))}),n):n}function zs(){const{name:e,title:t}=s.useCollection_deprecated();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDataTemplates,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const qs={title:`{{t("Create record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=x.useMemo(()=>e.map(({key:i,displayName:l,collections:c})=>({key:i,name:i,label:l,type:"subMenu",children:c.map(d=>({name:ae.camelCase(`createRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:i,title:`{{t("Create record", { ns: "${m}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Ho}))})),[e]),[o,n]=x.useState([]),a=s.useMenuSearch({data:t,openKeys:o});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(i){n(i)}},children:a}},initializers:{},components:{CreateFormDesigner:zs},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var c,d;const[a]=Object.keys(n.properties),i=n.properties[a],l=((c=Object.entries(i.properties).find(([u,p])=>p["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[a]={type:"create",title:((d=n["x-component-props"])==null?void 0:d.title)||a,actions:Ee(i.properties[l],u=>u["x-component"]==="Action").map(u=>{var p,f;return{status:u["x-decorator-props"].value,values:(f=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function Jo(e){var u,p,f,y;const[t,o]=x.useState((p=(u=e.collection)==null?void 0:u.fields)!=null?p:[]),n=s.useRecord(),a=A.useField(),i=A.useFieldSchema(),[l]=Object.keys((f=i.toJSON().properties)!=null?f:{}),c=(y=n==null?void 0:n.result)==null?void 0:y[l],d=x.useMemo(()=>A.createForm({initialValues:c}),[c]);return!n.status||c?r.jsx(s.CollectionProvider_deprecated,{collection:F(v({},e.collection),{fields:t}),children:r.jsx(s.RecordProvider,{record:c,parent:null,children:r.jsx(s.FormBlockContext.Provider,{value:{form:d,field:a,setCollectionFields:o},children:e.children})})}):null}function Us(){const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem();return r.jsx(s.SchemaInitializerItem,F(v({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:W.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[W.uid()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:customForm:configureFields"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"workflowManual:form:configureActions",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:Ce.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const Yo={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function Ks(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:a="others"}=n;t[a]=t[a]||{},ae.set(t,[a,o],n)}),Object.keys(Yo).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:Yo[o],children:Object.keys(t[o]||{}).map(n=>{const a=t[o][n];return v({value:n,title:a.title,name:n},t[o][n])}).sort((n,a)=>n.order-a.order)}))}function _s(){const{interfaces:e}=s.useCollectionManager_deprecated();return Ks(e).map(o=>({name:o.title,type:"itemGroup",title:o.title,children:o.children.map(n=>({name:n.name,type:"item",title:n.title,Component:Js,fieldInterface:n.name}))}))}const Qo=x.createContext({}),Gs=e=>{const[t,o]=x.useState(null),[n,a]=x.useState(),i=_s(),l=s.useCollection_deprecated(),{setCollectionFields:c}=x.useContext(s.FormBlockContext),d=x.useMemo(()=>A.createForm(),[t]);return r.jsxs(Qo.Provider,{value:{onAddField(u){const p=ae.pick(u,["name","group","title","default","validateSchema"]),{properties:D}=u,S=D,{unique:f,type:y,layout:h,autoIncrement:g}=S,w=Q(S,["unique","type","layout","autoIncrement"]);p.properties=w;const C=ae.cloneDeep(p);delete C.properties.name["x-disabled"],o(C)},setCallback:a},children:[r.jsx(s.SchemaInitializerItems,F(v({},e),{items:i})),r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible(u){u||o(null)}},children:t?r.jsx(s.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:d},"x-component":"Action.Drawer",properties:F(v({},t.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const u=A.useForm();return{run(){return P(this,null,function*(){a(null),o(null),u.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:u,query:p,reset:f}=A.useForm(),y=[O("Field name existed in form")];return{run(){return P(this,null,function*(){var S,I,M,E;const{default:g}=t,w=W.uid();if(g.name=(S=u.name)!=null?S:w,g.uiSchema.title=(M=(I=u.uiSchema)==null?void 0:I.title)!=null?M:w,g.interface=t.name,(E=l.fields)==null?void 0:E.find(N=>N.name===g.name)){p("name").take().setFeedback({type:"error",messages:y});return}const D=W.merge(g,u);c([...l.fields,D]),n({name:g.name,type:g.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:D},"x-collection-field":`${l.name}.${g.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),f(),a(null),o(null)})}}}}}}}})},components:{ArrayTable:W.ArrayTable}}):null})]})},Hs=new s.SchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:s.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:Gs});function Js(){const e=s.useSchemaInitializerItem(),{insert:t,setVisible:o}=s.useSchemaInitializer(),{onAddField:n,setCallback:a}=x.useContext(Qo),{getInterface:i}=s.useCollectionManager_deprecated(),l=i(e.fieldInterface);return r.jsx(s.SchemaInitializerItem,v({onClick:()=>{a(()=>t),n(l),o(!1)}},e),e.fieldInterface)}const Zo={title:`{{t("Custom form", { ns: "${m}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${m}" })}}`,Component:Us}},initializers:{},components:{CustomFormBlockProvider:Jo},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var d,u;const[a]=Object.keys(n.properties),i=n.properties[a],l=Ee(i.properties.grid,p=>p["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(p=>{var f,y;return(y=(f=p["x-component-props"])==null?void 0:f.field)!=null?y:p["x-interface-options"]});const c=((d=Object.entries(i.properties).find(([p,f])=>f["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";t[a]={type:"custom",title:((u=n["x-component-props"])==null?void 0:u.title)||a,actions:Ee(i.properties[c],p=>p["x-component"]==="Action").map(p=>{var f,y;return{status:p["x-decorator-props"].value,values:(y=(f=p["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:y.values,key:p.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:Jo}}};function Ys(){const{name:e,title:t}=s.useCollection_deprecated(),o=A.useFieldSchema(),{t:n}=ee.useTranslation(),{dn:a}=s.useDesignable();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsActionModalItem,{title:n("Filter settings",{ns:m}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-use-component-props":()=>{var l;return{options:s.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:i})=>{o["x-decorator-props"].filter=i,a.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),a.refresh()}}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Qs={title:`{{t("Update record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=x.useMemo(()=>e.map(({key:i,displayName:l,collections:c})=>({key:i,name:i,label:l,type:"subMenu",children:c.map(d=>({name:ae.camelCase(`updateRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:i,title:`{{t("Update record", { ns: "${m}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Ho}))})),[e]),[o,n]=x.useState([]),a=s.useMenuSearch({data:t,openKeys:o});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(i){n(i)}},children:a}},initializers:{},components:{FilterDynamicComponent:Ae,UpdateFormDesigner:Ys},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var c,d;const[a]=Object.keys(n.properties),i=n.properties[a],l=((c=Object.entries(i.properties).find(([u,p])=>p["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[a]=F(v({},n["x-decorator-props"]),{type:"update",title:((d=n["x-component-props"])==null?void 0:d.title)||a,actions:Ee(i.properties[l],u=>u["x-component"]==="Action").map(u=>{var p,f;return{status:u["x-decorator-props"].value,values:(f=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:u.name}})})}),t}},block:{scope:{},components:{}}},Me=new W.Registry;Me.register("customForm",Zo),Me.register("createForm",qs),Me.register("updateForm",Qs);function Zs(){const{workflow:e}=Y(),t=et();return t.useInitializers?t.useInitializers(e.config):null}Zo.title;const Xs=new s.SchemaInitializer({name:"workflowManual:popup:configureUserInterface:addBlock",wrap:s.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const e=s.usePlugin(re),t=he(),o=We(t),n=[Zs()].filter(Boolean),a=o.map(l=>{var d;const c=e.instructions.get(l.type);return(d=c==null?void 0:c.useInitializers)==null?void 0:d.call(c,l)}).filter(Boolean);return[...n,...a.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${m}" })}}`,children:a}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const t=s.useDataSourceManager().getAllCollections();return Array.from(Me.getValues()).map(o=>{const{useInitializer:n}=o.config;return n({allCollections:t})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Demonstration text")}}',Component:"MarkdownBlockInitializer"}]}]});function Rs(){var C,D,S;const e=x.useContext(s.SchemaComponentContext),{t}=ee.useTranslation(),o=A.useFieldSchema(),n=me(),[a,i]=x.useState(!1),[l,c]=x.useState((S=(D=(C=o==null?void 0:o["x-action-settings"])==null?void 0:C.assignedValues)==null?void 0:D.schema)!=null?S:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[d,u]=x.useState(null),{components:p}=s.useSchemaOptionsContext();x.useEffect(()=>{u(new A.Schema({properties:{grid:l}}))},[l]);const f=x.useMemo(()=>{var M,E;const I=(E=(M=o==null?void 0:o["x-action-settings"])==null?void 0:M.assignedValues)==null?void 0:E.values;return A.createForm({initialValues:ae.cloneDeep(I),values:ae.cloneDeep(I)})},[o]),y=s.useFormActiveFields(),h=t("Assign field values");function g(){i(!1)}function w(){o["x-action-settings"]||(o["x-action-settings"]={}),o["x-action-settings"].assignedValues||(o["x-action-settings"].assignedValues={}),o["x-action-settings"].assignedValues.schema=l,o["x-action-settings"].assignedValues.values=f.values,i(!1),setTimeout(()=>{var I;(I=e.refresh)==null||I.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaSettingsItem,{title:h,onClick:()=>i(!0),children:h}),r.jsx(b.Modal,{width:"50%",title:h,open:a,onCancel:g,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:g,children:t("Cancel")}),r.jsx(b.Button,{type:"primary",onClick:w,children:t("Submit")})]}),children:r.jsx(s.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(s.VariableScopeProvider,{scope:n,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:y==null?void 0:y.getActiveFieldsName,children:r.jsx(A.FormProvider,{form:f,children:r.jsxs(W.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:O("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),a&&d&&r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},e),{refresh(){c(ae.get(d.toJSON(),"properties.grid"))}}),children:r.jsx(s.SchemaComponent,{schema:d,components:p})})]})})})})})})]})}function ea(e){return r.jsxs(s.GeneralSchemaDesigner,F(v({},e),{disableInitializer:!0,children:[r.jsx(s.Action.Designer.ButtonEditor,{}),r.jsx(Rs,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function ta(){const i=s.useSchemaInitializerItem(),{action:t,actionProps:o}=i,n=Q(i,["action","actionProps"]),{insert:a}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(v({},n),{onClick:()=>{a({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":F(v({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Xo(){const e=s.useSchemaInitializerItem(),a=e,{action:t,actionProps:o}=a,n=Q(a,["action","actionProps"]);return r.jsx(s.InitializerWithSwitch,F(v({},n),{item:e,schema:{type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":F(v({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${t}`},type:"x-action"}))}const oa=new s.SchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${m}" })}}`,Component:ta,action:Ce.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${m}" })}}`,Component:Xo,action:Ce.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${m}" })}}`,Component:Xo,action:Ce.PENDING}]});function na(){return{run(){}}}function ra({value:e,onChange:t}){const o=s.usePlugin(re),n=x.useContext(s.SchemaComponentContext),a=he(),i=We(a),l=A.useForm(),{workflow:c}=Y(),d={};i.forEach(f=>{const y=o.instructions.get(f.type);Object.assign(d,y.components)});const u=x.useMemo(()=>new A.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:s.css`
470
470
  .ant-drawer-body {
471
471
  background: var(--tb-box-bg);
472
472
  }
473
- `},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"workflowManual:popup:configureUserInterface:addBlock"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${m}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:popup:configureUserInterface:addBlock",properties:{}}}}}}}}}}),[]),p=x.useCallback(function(){const{tabs:y}=ae.get(u.toJSON(),"properties.drawer.properties"),h=Array.from(Me.getValues()).reduce((g,w)=>Object.assign(g,w.config.parseFormOptions(y)),{});l.setValuesIn("forms",h),t(y.properties)},[l,t,u]);return r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},n),{designable:!c.executed,refresh:p}),children:r.jsx(s.SchemaComponent,{schema:u,components:F(v(v({},d),Array.from(Me.getValues()).reduce((f,y)=>Object.assign(f,y.config.components),{})),{FormBlockProvider:Go,DetailsBlockProvider:s.DetailsBlockProvider,ManualActionStatusProvider(f){return f.children},ActionBarProvider(f){return f.children},SimpleDesigner:Jt,ManualActionDesigner:Xs}),scope:{useSubmit:ta,useDetailsBlockProps:s.useFormBlockContext}})})}function na(e){const{workflow:t}=Y(),[o,n]=x.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>n(!0),disabled:!1,children:O(t.executed?"View user interface":"Configure user interface")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})}class ra extends oe{constructor(){super(...arguments),this.title=`{{t("Manual", { ns: "${m}" })}}`,this.type="manual",this.group="manual",this.icon="CoffeeOutlined",this.color="#a3243b",this.description=`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${m}" })}}`,this.fieldset={assignees:{type:"array",title:`{{t("Assignees", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}},this.components={SchemaConfigButton:na,SchemaConfig:oa,ModeConfig:Bs,AssigneesSelect:$s}}useVariables({key:t,title:o,config:n},{types:a,fieldNames:i=xe}){var p;const l=s.useCompile(),{getCollectionFields:c}=s.useCollectionManager_deprecated(),d=Object.keys((p=n.forms)!=null?p:{});if(!d.length)return null;const u=d.map(f=>{var w;const y=n.forms[f],h=fe({fields:(w=y.collection)==null?void 0:w.fields,collection:y.collection,types:a,compile:l,getCollectionFields:c}),g=l(y.title)||f;return h.length?{key:f,value:f,label:g,title:g,children:h}:null}).filter(Boolean);return u.length?{[i.value]:t,[i.label]:o,[i.children]:u}:null}useInitializers(t){var i;const{getCollection:o}=s.useCollectionManager_deprecated(),n=Object.keys((i=t.config.forms)!=null?i:{});if(!n.length||t.config.mode)return null;const a=n.map(l=>{var u,p;const c=t.config.forms[l],{fields:d=[]}=o(c.collection);return d.length?{name:(u=c.title)!=null?u:l,type:"item",title:(p=c.title)!=null?p:l,Component:Te,collection:c.collection,dataPath:`$jobsMapByNodeKey.${t.key}.${l}`}:null}).filter(Boolean);return a.length?{name:`#${t.id}`,key:"forms",type:"subMenu",title:t.title,children:a}:null}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:a}){return!t.isWorkflowSync(o)}}const sa={title:`{{t("Task", { ns: "${m}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},aa={title:`{{t("Workflow", { ns: "${m}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},ia={title:`{{t("Workflow todos", { ns: "${m}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-component":"Select",enum:yt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},la=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"NodeColumn"}),ca=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"WorkflowColumn"}),da=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.nickname)!=null?n:(o=e.value)==null?void 0:o.id},{displayName:"UserColumn"});function ua(e){const t=s.useRecord(),o=O("Unprocessed");return t.execution.status&&!t.status?r.jsx(b.Tag,{children:o}):e.children}const Rt=()=>r.jsx(s.SchemaComponent,{components:{NodeColumn:la,WorkflowColumn:ca,UserColumn:da,UserJobStatusColumn:ua},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:refresh","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${m}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status", { ns: "workflow" })}}',properties:{status:{type:"number","x-decorator":"UserJobStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:`{{t("Assignee", { ns: "${m}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}});function pa(e){var u;const{data:t}=s.useCurrentUserContext(),{userJob:o}=Y(),{status:n,result:a,userId:i}=o,l=A.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:d}=e;return n?a[c]||(d=null):((u=t==null?void 0:t.data)==null?void 0:u.id)!==i&&(d=null),d}const Ro=x.createContext(null);Ro.displayName="ManualActionStatusContext";function ma({value:e,children:t}){const{userJob:o,execution:n}=Y(),a=A.useField(),i=A.useFieldSchema();return x.useEffect(()=>{(n.status||o.status)&&(a.disabled=!0,a.visible=o.status===e&&o.result._===i.name)},[n,o,e,a,i.name]),r.jsx(Ro.Provider,{value:e,children:t})}function fa(){const e=s.useAPIClient(),{setVisible:t}=s.useActionContext(),{values:o,submit:n}=A.useForm(),a=A.useFieldSchema(),{service:i}=s.useTableBlockContext(),{userJob:l,execution:c}=Y(),{name:d}=a,{name:u}=a.parent.parent;return{run(){return P(this,null,function*(){c.status||l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[u]:o,_:d}}}),t(!1),i.refresh())})}}}function ga(e){var p;const t=s.usePlugin(re),o=s.useAPIClient(),{id:n}=s.useRecord(),[a,i]=x.useState(null),[l,c]=x.useState(null);x.useEffect(()=>{var f,y;n&&((y=(f=o.resource("users_jobs")).get)==null||y.call(f,{filterByTk:n,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:h})=>{var I;const M=(I=h==null?void 0:h.data)!=null?I:{},{node:g,workflow:E={}}=M,N=E,{nodes:w=[]}=N,C=Q(N,["nodes"]),V=M,{execution:D}=V,S=Q(V,["node","workflow","execution"]);xt(w),c(g),i({userJob:S,workflow:C,nodes:w,execution:D})}))},[o,n]);const u=We(a==null?void 0:a.nodes.find(f=>f.id===l.id)).reduce((f,{type:y})=>{var h;return Object.assign(f,(h=t.instructions.get(y))==null?void 0:h.components)},{});return l&&a?r.jsx(Ve.Provider,{value:a,children:r.jsx(s.SchemaComponent,{components:v(v({FormBlockProvider:Go,DetailsBlockProvider:qt,ActionBarProvider:pa,ManualActionStatusProvider:ma},Array.from(Me.getValues()).reduce((f,y)=>Object.assign(f,y.block.components),{})),u),scope:v({useSubmit:fa,useFormBlockProps:ha,useDetailsBlockProps:ya},Array.from(Me.getValues()).reduce((f,y)=>Object.assign(f,y.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=l.config)==null?void 0:p.schema}})}):r.jsx(b.Spin,{})}function ha(){var l;const{userJob:e,execution:t}=Y(),o=s.useRecord(),{data:n}=s.useCurrentUserContext(),{form:a}=s.useFormBlockContext(),i=t.status||e.status?o?"readPretty":"disabled":((l=n==null?void 0:n.data)==null?void 0:l.id)!==e.userId?"disabled":"editable";return x.useEffect(()=>{a==null||a.setPattern(i)},[i,a]),{form:a}}function ya(){const{form:e}=s.useFormBlockContext();return{form:e}}function xa(){const e=s.useCompile(),{status:t,updatedAt:o}=s.useRecord(),n=ot[t];return t?r.jsxs(b.Space,{children:[r.jsx("time",{className:s.css`
473
+ `},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"workflowManual:popup:configureUserInterface:addBlock"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${m}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:popup:configureUserInterface:addBlock",properties:{}}}}}}}}}}),[]),p=x.useCallback(function(){const{tabs:y}=ae.get(u.toJSON(),"properties.drawer.properties"),h=Array.from(Me.getValues()).reduce((g,w)=>Object.assign(g,w.config.parseFormOptions(y)),{});l.setValuesIn("forms",h),t(y.properties)},[l,t,u]);return r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},n),{designable:!c.executed,refresh:p}),children:r.jsx(s.SchemaComponent,{schema:u,components:F(v(v({},d),Array.from(Me.getValues()).reduce((f,y)=>Object.assign(f,y.config.components),{})),{FormBlockProvider:Go,DetailsBlockProvider:s.DetailsBlockProvider,ManualActionStatusProvider(f){return f.children},ActionBarProvider(f){return f.children},SimpleDesigner:Jt,ManualActionDesigner:ea}),scope:{useSubmit:na,useDetailsBlockProps:s.useFormBlockContext}})})}function sa(e){const{workflow:t}=Y(),[o,n]=x.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>n(!0),disabled:!1,children:O(t.executed?"View user interface":"Configure user interface")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})}class aa extends oe{constructor(){super(...arguments),this.title=`{{t("Manual", { ns: "${m}" })}}`,this.type="manual",this.group="manual",this.icon="CoffeeOutlined",this.color="#a3243b",this.description=`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${m}" })}}`,this.fieldset={assignees:{type:"array",title:`{{t("Assignees", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}},this.components={SchemaConfigButton:sa,SchemaConfig:ra,ModeConfig:Ws,AssigneesSelect:Vs}}useVariables({key:t,title:o,config:n},{types:a,fieldNames:i=xe}){var p;const l=s.useCompile(),{getCollectionFields:c}=s.useCollectionManager_deprecated(),d=Object.keys((p=n.forms)!=null?p:{});if(!d.length)return null;const u=d.map(f=>{var w;const y=n.forms[f],h=fe({fields:(w=y.collection)==null?void 0:w.fields,collection:y.collection,types:a,compile:l,getCollectionFields:c}),g=l(y.title)||f;return h.length?{key:f,value:f,label:g,title:g,children:h}:null}).filter(Boolean);return u.length?{[i.value]:t,[i.label]:o,[i.children]:u}:null}useInitializers(t){var i;const{getCollection:o}=s.useCollectionManager_deprecated(),n=Object.keys((i=t.config.forms)!=null?i:{});if(!n.length||t.config.mode)return null;const a=n.map(l=>{var u,p;const c=t.config.forms[l],{fields:d=[]}=o(c.collection);return d.length?{name:(u=c.title)!=null?u:l,type:"item",title:(p=c.title)!=null?p:l,Component:Te,collection:c.collection,dataPath:`$jobsMapByNodeKey.${t.key}.${l}`}:null}).filter(Boolean);return a.length?{name:`#${t.id}`,key:"forms",type:"subMenu",title:t.title,children:a}:null}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:a}){return!t.isWorkflowSync(o)}}const ia={title:`{{t("Task", { ns: "${m}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},la={title:`{{t("Workflow", { ns: "${m}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},ca={title:`{{t("Workflow todos", { ns: "${m}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-component":"Select",enum:yt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},da=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"NodeColumn"}),ua=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"WorkflowColumn"}),pa=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.nickname)!=null?n:(o=e.value)==null?void 0:o.id},{displayName:"UserColumn"});function ma(e){const t=s.useRecord(),o=O("Unprocessed");return t.execution.status&&!t.status?r.jsx(b.Tag,{children:o}):e.children}const Rt=()=>r.jsx(s.SchemaComponent,{components:{NodeColumn:da,WorkflowColumn:ua,UserColumn:pa,UserJobStatusColumn:ma},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:refresh","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${m}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status", { ns: "workflow" })}}',properties:{status:{type:"number","x-decorator":"UserJobStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:`{{t("Assignee", { ns: "${m}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}});function fa(e){var u;const{data:t}=s.useCurrentUserContext(),{userJob:o}=Y(),{status:n,result:a,userId:i}=o,l=A.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:d}=e;return n?a[c]||(d=null):((u=t==null?void 0:t.data)==null?void 0:u.id)!==i&&(d=null),d}const Ro=x.createContext(null);Ro.displayName="ManualActionStatusContext";function ga({value:e,children:t}){const{userJob:o,execution:n}=Y(),a=A.useField(),i=A.useFieldSchema();return x.useEffect(()=>{(n.status||o.status)&&(a.disabled=!0,a.visible=o.status===e&&o.result._===i.name)},[n,o,e,a,i.name]),r.jsx(Ro.Provider,{value:e,children:t})}function ha(){const e=s.useAPIClient(),{setVisible:t}=s.useActionContext(),{values:o,submit:n}=A.useForm(),a=A.useFieldSchema(),{service:i}=s.useTableBlockContext(),{userJob:l,execution:c}=Y(),{name:d}=a,{name:u}=a.parent.parent;return{run(){return P(this,null,function*(){c.status||l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[u]:o,_:d}}}),t(!1),i.refresh())})}}}function ya(e){var p;const t=s.usePlugin(re),o=s.useAPIClient(),{id:n}=s.useRecord(),[a,i]=x.useState(null),[l,c]=x.useState(null);x.useEffect(()=>{var f,y;n&&((y=(f=o.resource("users_jobs")).get)==null||y.call(f,{filterByTk:n,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:h})=>{var I;const M=(I=h==null?void 0:h.data)!=null?I:{},{node:g,workflow:E={}}=M,N=E,{nodes:w=[]}=N,C=Q(N,["nodes"]),V=M,{execution:D}=V,S=Q(V,["node","workflow","execution"]);xt(w),c(g),i({userJob:S,workflow:C,nodes:w,execution:D})}))},[o,n]);const u=We(a==null?void 0:a.nodes.find(f=>f.id===l.id)).reduce((f,{type:y})=>{var h;return Object.assign(f,(h=t.instructions.get(y))==null?void 0:h.components)},{});return l&&a?r.jsx(Ve.Provider,{value:a,children:r.jsx(s.SchemaComponent,{components:v(v({FormBlockProvider:Go,DetailsBlockProvider:qt,ActionBarProvider:fa,ManualActionStatusProvider:ga},Array.from(Me.getValues()).reduce((f,y)=>Object.assign(f,y.block.components),{})),u),scope:v({useSubmit:ha,useFormBlockProps:xa,useDetailsBlockProps:ba},Array.from(Me.getValues()).reduce((f,y)=>Object.assign(f,y.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=l.config)==null?void 0:p.schema}})}):r.jsx(b.Spin,{})}function xa(){var l;const{userJob:e,execution:t}=Y(),o=s.useRecord(),{data:n}=s.useCurrentUserContext(),{form:a}=s.useFormBlockContext(),i=t.status||e.status?o?"readPretty":"disabled":((l=n==null?void 0:n.data)==null?void 0:l.id)!==e.userId?"disabled":"editable";return x.useEffect(()=>{a==null||a.setPattern(i)},[i,a]),{form:a}}function ba(){const{form:e}=s.useFormBlockContext();return{form:e}}function va(){const e=s.useCompile(),{status:t,updatedAt:o}=s.useRecord(),n=ot[t];return t?r.jsxs(b.Space,{children:[r.jsx("time",{className:s.css`
474
474
  margin-right: 0.5em;
475
- `,children:mt(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function ba(){var i;const e=x.useContext(s.SchemaComponentContext),{id:t,node:o,workflow:n,status:a}=s.useRecord();return r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},e),{reset(){},designable:!1}),children:r.jsx(s.SchemaComponent,{components:{FooterStatus:xa,FlowContextProvider:ga},schema:{type:"void",name:`drawer-${t}-${a}`,"x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},title:`${n.title} - ${(i=o.title)!=null?i:`#${o.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function va({params:e={},children:t}){const o={collection:"users_jobs",resource:"users_jobs",action:"list",params:F(v({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow","execution.status"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[sa,aa,ia],children:r.jsx(s.TableBlockProvider,F(v({name:"workflow-todo"},o),{children:t}))})}Rt.Drawer=ba,Rt.Decorator=va;const wa=()=>{const e=s.useSchemaInitializerItem(),{insert:t}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(v({icon:r.jsx(H.TableOutlined,{})},e),{onClick:()=>{t({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class Ca extends s.Plugin{load(){return P(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",ra),this.app.schemaInitializerManager.add(Qs),this.app.schemaInitializerManager.add(ea),this.app.schemaInitializerManager.add(_s),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow",{name:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,type:"subMenu",icon:r.jsx(H.PartitionOutlined,{}),children:[{name:"common",title:`{{t("Common", { ns: "${m}" })}}`,type:"itemGroup",children:[{name:"todos",title:`{{t("Workflow todos", { ns: "${m}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"}]}]})})}addComponents(){this.app.addComponents({WorkflowTodo:Rt,WorkflowTodoBlockInitializer:wa})}}const en="notice",eo="workflowNotice",De="workflow";function Je(){return{t:(t,o={})=>s.i18n.t(t,v({ns:De},o))}}const ce=e=>s.tval(e,{ns:De});var Ct=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ka(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kt={exports:{}},Sa=kt.exports,tn;function Aa(){return tn||(tn=1,function(e,t){(function(o,n){n()})(Sa,function(){function o(u,p){return typeof p=="undefined"?p={autoBom:!1}:typeof p!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),p={autoBom:!p}),p.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(u.type)?new Blob(["\uFEFF",u],{type:u.type}):u}function n(u,p,f){var y=new XMLHttpRequest;y.open("GET",u),y.responseType="blob",y.onload=function(){d(y.response,p,f)},y.onerror=function(){console.error("could not download file")},y.send()}function a(u){var p=new XMLHttpRequest;p.open("HEAD",u,!1);try{p.send()}catch(f){}return 200<=p.status&&299>=p.status}function i(u){try{u.dispatchEvent(new MouseEvent("click"))}catch(f){var p=document.createEvent("MouseEvents");p.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),u.dispatchEvent(p)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Ct=="object"&&Ct.global===Ct?Ct:void 0,c=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!c?function(u,p,f){var y=l.URL||l.webkitURL,h=document.createElement("a");p=p||u.name||"download",h.download=p,h.rel="noopener",typeof u=="string"?(h.href=u,h.origin===location.origin?i(h):a(h.href)?n(u,p,f):i(h,h.target="_blank")):(h.href=y.createObjectURL(u),setTimeout(function(){y.revokeObjectURL(h.href)},4e4),setTimeout(function(){i(h)},0))}:"msSaveOrOpenBlob"in navigator?function(u,p,f){if(p=p||u.name||"download",typeof u!="string")navigator.msSaveOrOpenBlob(o(u,f),p);else if(a(u))n(u,p,f);else{var y=document.createElement("a");y.href=u,y.target="_blank",setTimeout(function(){i(y)})}}:function(u,p,f,y){if(y=y||open("","_blank"),y&&(y.document.title=y.document.body.innerText="downloading..."),typeof u=="string")return n(u,p,f);var h=u.type==="application/octet-stream",g=/constructor/i.test(l.HTMLElement)||l.safari,w=/CriOS\/[\d]+/.test(navigator.userAgent);if((w||h&&g||c)&&typeof FileReader!="undefined"){var C=new FileReader;C.onloadend=function(){var I=C.result;I=w?I:I.replace(/^data:[^;]*;/,"data:attachment/file;"),y?y.location.href=I:location=I,y=null},C.readAsDataURL(u)}else{var D=l.URL||l.webkitURL,S=D.createObjectURL(u);y?y.location=S:location.href=S,y=null,setTimeout(function(){D.revokeObjectURL(S)},4e4)}});l.saveAs=d.saveAs=d,e.exports=d})}(kt)),kt.exports}var on=Aa();const Ia=ka(on);function nn(){const{t:e}=ee.useTranslation(),t=s.useDataBlockResource(),o=s.useFilterByTk();return{run(){return P(this,null,function*(){const{data:a}=yield t.dump({filterByTk:o}),i=new Blob([JSON.stringify(a.data,null,2)],{type:"application/json"});on.saveAs(i,a.data.title+"-"+a.data.key+".json"),b.message.success(e("Operation succeeded"))})}}}function rn(){const{t:e}=ee.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n,visible:a}=s.useActionContext(),i=s.useFilterByTk(),{values:l,setInitialValues:c}=A.useForm(),d=s.useCollectionRecordData();return x.useEffect(()=>{a&&(d!=null&&d.category)&&c({category:d.category})},[a,d,c]),{run(){return P(this,null,function*(){const p=v({},l);p.category&&Array.isArray(p.category)&&(p.category=p.category.map(f=>typeof f=="object"&&(f==null?void 0:f.id)!=null?f.id:f)),yield o.revision({filterByTk:i,values:p}),b.message.success(e("Operation succeeded")),t(),n(!1)})}}}function Fa(){const e=s.useAPIClient(),t=A.useForm(),{field:o,__parent:n}=s.useBlockRequestContext(),{setVisible:a}=s.useActionContext(),i=se.useNavigate(),l=A.useFieldSchema(),c=A.useField(),d=s.useCompile(),{modal:u}=b.App.useApp(),p=s.useCollectValuesToSubmit(),f=c.componentProps.filterKeys||[];return{onClick(){return P(this,null,function*(){var D,S,I;const{onSuccess:h,skipValidator:g,triggerWorkflows:w}=(D=l==null?void 0:l["x-action-settings"])!=null?D:{};g||(yield t.submit());const C=yield p();c.data=o.data||{},c.data.loading=!0;try{const M=yield e.resource("workflows").trigger({values:C,filterKeys:f,triggerWorkflows:s.getAfterWorkflows(w),beforeWorkflows:s.getBeforeWorkflows(w)});if(c.data.loading=!1,c.data.data=M,(I=(S=n==null?void 0:n.service)==null?void 0:S.refresh)==null||I.call(S),a==null||a(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?u.success({title:d(h==null?void 0:h.successMessage),onOk:()=>P(null,null,function*(){yield t.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(W.isURL(h.redirectTo)?window.location.href=h.redirectTo:i(h.redirectTo))})}):b.message.success(d(h==null?void 0:h.successMessage))}catch(M){c.data.loading=!1}})}}}function Ta(){var y;const e=s.useCompile(),t=s.useAPIClient(),o=s.useRecord(),n=A.useField(),a=A.useFieldSchema(),{field:i,__parent:l}=s.useBlockRequestContext(),{setVisible:c}=s.useActionContext(),{modal:d}=b.App.useApp(),u=se.useNavigate(),{onSuccess:p,triggerWorkflows:f}=(y=a==null?void 0:a["x-action-settings"])!=null?y:{};return{onClick(){return P(this,null,function*(){var g,w;n.data=i.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),(w=(g=l==null?void 0:l.service)==null?void 0:g.refresh)==null||w.call(g),c==null||c(!1),!(p!=null&&p.successMessage))return;if(p!=null&&p.manualClose){let C;d.success({title:e(p==null?void 0:p.successMessage),onOk(){return P(this,null,function*(){p!=null&&p.redirecting&&(p!=null&&p.redirectTo)&&(W.isURL(p.redirectTo)?window.location.href=p.redirectTo:u(p.redirectTo))})}})}else b.message.success(e(p==null?void 0:p.successMessage))}catch(C){console.error(C)}finally{n.data.loading=!1}})}}}const Na=()=>{const e=Qt(),t=W.ArrayItems.useArray()||{field:[]},{t:o}=Je(),[n,a]=x.useState(!1),i=x.useCallback(()=>{t.field.push(""),a(!1)},[t.field]),l=x.useCallback(()=>{t.field.push({filter:{}}),a(!1)},[t.field]);return r.jsx(b.Popover,{open:!e&&n,onOpenChange:a,content:r.jsx(Da,{onSlecet:i,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},Da=({onSlecet:e,onQuery:t})=>{const{t:o}=Je();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},Oa=e=>{const{t}=Je(),[o,n]=x.useState(!1),a=x.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:a,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},Pa=e=>e.value&&typeof e.value=="object"?r.jsx(Ma,v({},e)):r.jsx(Ea,v({},e)),Ea=({value:e,onChange:t})=>{const o=me({types:[$a]});return r.jsx(s.Variable.Input,{scope:o,value:e,onChange:t,children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:t})})},Ma=()=>{const e=A.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Ae}}}}})})};function $a(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}const Ba=()=>{var d;const{workflow:e}=Y(),[t,o]=s.parseCollectionName((d=e.config)==null?void 0:d.collection),n=s.useSchemaInitializerItem(),{insert:a}=s.useSchemaInitializer(),{getTemplateSchemaByMode:i}=s.useSchemaTemplateManager(),l=s.useRecordCollectionDataSourceItems("FormItem"),c=p=>P(null,[p],function*({item:u}){const f=u.template?yield i(u):null,y=s.createReadPrettyFormBlockSchema({actionInitializers:null,resource:o,collection:o,dataSource:t,template:f,settings:"blockSettings:details"});ae.unset(y,["x-acl-action","x-acl-action-props"]);const[h]=Object.keys(y.properties);ae.set(y.properties[h],"x-component-props.useProps","usePropsNoticeDetail"),a(y)});return r.jsx(s.SchemaInitializerItem,F(v({},n),{onClick:c,items:l}))},Va=new s.SchemaInitializer({name:"NoticeDetailInitializer",wrap:s.gridRowColWrap,title:"{{t('Add block')}}",items:[{name:"notice",type:"itemGroup",title:ce("Notice blocks"),children:[{name:"detail",type:"item",title:'{{t("Details")}}',Component:Ba}]},{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){var c;const e=s.usePlugin(re),{workflow:t}=Y(),o=et(),n=he(),a=We(n),i=[(c=o.useInitializers)==null?void 0:c.call(o,t.config)].filter(Boolean),l=a.map(d=>{var p;const u=e.instructions.get(d.type);return(p=u==null?void 0:u.useInitializers)==null?void 0:p.call(u,d)}).filter(Boolean);return[...i,...l.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "workflow" })}}',children:l}]:[]].filter(Boolean)}},{name:"others",type:"itemGroup",title:'{{t("Other blocks")}}',children:[{name:"markdown",type:"item",title:'{{t("Demonstration text")}}',component:"MarkdownBlockInitializer"}]}]});class Wa extends s.Plugin{load(){return P(this,null,function*(){this.app.schemaInitializerManager.add(Va)})}}function ja(e){return{type:"void",name:e,"x-uid":e,"x-component":"Grid","x-initializer":"NoticeDetailInitializer"}}const La=e=>{const{schemaData:t,loading:o,handleChange:n}=za(e);return o?r.jsx(b.Spin,{}):r.jsx(s.SchemaComponent,{memoized:!0,scope:{},components:{},schema:t,onChange:n})};function za(e){const{value:t,onChange:o}=e,n=s.useAPIClient(),{values:a,setValuesIn:i}=A.useForm(),{data:l,loading:c}=s.useRequest(()=>P(null,null,function*(){if(t){const f=yield qa(n,t);if(f["x-uid"]===t)return f}const u=t!=null?t:W.uid(),p=ja(u);return yield Ua(n,p),o(u),p}));return{schemaData:l,loading:c,handleChange:u=>{}}}function qa(e,t){return P(this,null,function*(){var a;const{data:o}=yield e.request({url:`uiSchemas:getJsonSchema/${t}`});return(a=o.data)!=null?a:{}})}function Ua(e,t){return P(this,null,function*(){yield e.resource("uiSchemas").insert({values:t})})}const Ka={ActionStyle:s.css`
475
+ `,children:mt(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function wa(){var i;const e=x.useContext(s.SchemaComponentContext),{id:t,node:o,workflow:n,status:a}=s.useRecord();return r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},e),{reset(){},designable:!1}),children:r.jsx(s.SchemaComponent,{components:{FooterStatus:va,FlowContextProvider:ya},schema:{type:"void",name:`drawer-${t}-${a}`,"x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},title:`${n.title} - ${(i=o.title)!=null?i:`#${o.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function Ca({params:e={},children:t}){const o={collection:"users_jobs",resource:"users_jobs",action:"list",params:F(v({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow","execution.status"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[ia,la,ca],children:r.jsx(s.TableBlockProvider,F(v({name:"workflow-todo"},o),{children:t}))})}Rt.Drawer=wa,Rt.Decorator=Ca;const ka=()=>{const e=s.useSchemaInitializerItem(),{insert:t}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(v({icon:r.jsx(H.TableOutlined,{})},e),{onClick:()=>{t({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class Sa extends s.Plugin{load(){return P(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",aa),this.app.schemaInitializerManager.add(Xs),this.app.schemaInitializerManager.add(oa),this.app.schemaInitializerManager.add(Hs),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow",{name:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,type:"subMenu",icon:r.jsx(H.PartitionOutlined,{}),children:[{name:"common",title:`{{t("Common", { ns: "${m}" })}}`,type:"itemGroup",children:[{name:"todos",title:`{{t("Workflow todos", { ns: "${m}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"}]}]})})}addComponents(){this.app.addComponents({WorkflowTodo:Rt,WorkflowTodoBlockInitializer:ka})}}const en="notice",eo="workflowNotice",De="workflow";function Je(){return{t:(t,o={})=>s.i18n.t(t,v({ns:De},o))}}const ce=e=>s.tval(e,{ns:De});var Ct=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Aa(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kt={exports:{}},Ia=kt.exports,tn;function Fa(){return tn||(tn=1,function(e,t){(function(o,n){n()})(Ia,function(){function o(u,p){return typeof p=="undefined"?p={autoBom:!1}:typeof p!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),p={autoBom:!p}),p.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(u.type)?new Blob(["\uFEFF",u],{type:u.type}):u}function n(u,p,f){var y=new XMLHttpRequest;y.open("GET",u),y.responseType="blob",y.onload=function(){d(y.response,p,f)},y.onerror=function(){console.error("could not download file")},y.send()}function a(u){var p=new XMLHttpRequest;p.open("HEAD",u,!1);try{p.send()}catch(f){}return 200<=p.status&&299>=p.status}function i(u){try{u.dispatchEvent(new MouseEvent("click"))}catch(f){var p=document.createEvent("MouseEvents");p.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),u.dispatchEvent(p)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Ct=="object"&&Ct.global===Ct?Ct:void 0,c=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!c?function(u,p,f){var y=l.URL||l.webkitURL,h=document.createElement("a");p=p||u.name||"download",h.download=p,h.rel="noopener",typeof u=="string"?(h.href=u,h.origin===location.origin?i(h):a(h.href)?n(u,p,f):i(h,h.target="_blank")):(h.href=y.createObjectURL(u),setTimeout(function(){y.revokeObjectURL(h.href)},4e4),setTimeout(function(){i(h)},0))}:"msSaveOrOpenBlob"in navigator?function(u,p,f){if(p=p||u.name||"download",typeof u!="string")navigator.msSaveOrOpenBlob(o(u,f),p);else if(a(u))n(u,p,f);else{var y=document.createElement("a");y.href=u,y.target="_blank",setTimeout(function(){i(y)})}}:function(u,p,f,y){if(y=y||open("","_blank"),y&&(y.document.title=y.document.body.innerText="downloading..."),typeof u=="string")return n(u,p,f);var h=u.type==="application/octet-stream",g=/constructor/i.test(l.HTMLElement)||l.safari,w=/CriOS\/[\d]+/.test(navigator.userAgent);if((w||h&&g||c)&&typeof FileReader!="undefined"){var C=new FileReader;C.onloadend=function(){var I=C.result;I=w?I:I.replace(/^data:[^;]*;/,"data:attachment/file;"),y?y.location.href=I:location=I,y=null},C.readAsDataURL(u)}else{var D=l.URL||l.webkitURL,S=D.createObjectURL(u);y?y.location=S:location.href=S,y=null,setTimeout(function(){D.revokeObjectURL(S)},4e4)}});l.saveAs=d.saveAs=d,e.exports=d})}(kt)),kt.exports}var on=Fa();const Ta=Aa(on);function nn(){const{t:e}=ee.useTranslation(),t=s.useDataBlockResource(),o=s.useFilterByTk();return{run(){return P(this,null,function*(){const{data:a}=yield t.dump({filterByTk:o}),i=new Blob([JSON.stringify(a.data,null,2)],{type:"application/json"});on.saveAs(i,a.data.title+"-"+a.data.key+".json"),b.message.success(e("Operation succeeded"))})}}}function rn(){const{t:e}=ee.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n,visible:a}=s.useActionContext(),i=s.useFilterByTk(),{values:l,setInitialValues:c}=A.useForm(),d=s.useCollectionRecordData();return x.useEffect(()=>{a&&(d!=null&&d.category)&&c({category:d.category})},[a,d,c]),{run(){return P(this,null,function*(){const p=v({},l);p.category&&Array.isArray(p.category)&&(p.category=p.category.map(f=>typeof f=="object"&&(f==null?void 0:f.id)!=null?f.id:f)),yield o.revision({filterByTk:i,values:p}),b.message.success(e("Operation succeeded")),t(),n(!1)})}}}function Na(){const e=s.useAPIClient(),t=A.useForm(),{field:o,__parent:n}=s.useBlockRequestContext(),{setVisible:a}=s.useActionContext(),i=se.useNavigate(),l=A.useFieldSchema(),c=A.useField(),d=s.useCompile(),{modal:u}=b.App.useApp(),p=s.useCollectValuesToSubmit(),f=c.componentProps.filterKeys||[];return{onClick(){return P(this,null,function*(){var D,S,I;const{onSuccess:h,skipValidator:g,triggerWorkflows:w}=(D=l==null?void 0:l["x-action-settings"])!=null?D:{};g||(yield t.submit());const C=yield p();c.data=o.data||{},c.data.loading=!0;try{const M=yield e.resource("workflows").trigger({values:C,filterKeys:f,triggerWorkflows:s.getAfterWorkflows(w),beforeWorkflows:s.getBeforeWorkflows(w)});if(c.data.loading=!1,c.data.data=M,(I=(S=n==null?void 0:n.service)==null?void 0:S.refresh)==null||I.call(S),a==null||a(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?u.success({title:d(h==null?void 0:h.successMessage),onOk:()=>P(null,null,function*(){yield t.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(W.isURL(h.redirectTo)?window.location.href=h.redirectTo:i(h.redirectTo))})}):b.message.success(d(h==null?void 0:h.successMessage))}catch(M){c.data.loading=!1}})}}}function Da(){var y;const e=s.useCompile(),t=s.useAPIClient(),o=s.useRecord(),n=A.useField(),a=A.useFieldSchema(),{field:i,__parent:l}=s.useBlockRequestContext(),{setVisible:c}=s.useActionContext(),{modal:d}=b.App.useApp(),u=se.useNavigate(),{onSuccess:p,triggerWorkflows:f}=(y=a==null?void 0:a["x-action-settings"])!=null?y:{};return{onClick(){return P(this,null,function*(){var g,w;n.data=i.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),(w=(g=l==null?void 0:l.service)==null?void 0:g.refresh)==null||w.call(g),c==null||c(!1),!(p!=null&&p.successMessage))return;if(p!=null&&p.manualClose){let C;d.success({title:e(p==null?void 0:p.successMessage),onOk(){return P(this,null,function*(){p!=null&&p.redirecting&&(p!=null&&p.redirectTo)&&(W.isURL(p.redirectTo)?window.location.href=p.redirectTo:u(p.redirectTo))})}})}else b.message.success(e(p==null?void 0:p.successMessage))}catch(C){console.error(C)}finally{n.data.loading=!1}})}}}const Oa=()=>{const e=Qt(),t=W.ArrayItems.useArray()||{field:[]},{t:o}=Je(),[n,a]=x.useState(!1),i=x.useCallback(()=>{t.field.push(""),a(!1)},[t.field]),l=x.useCallback(()=>{t.field.push({filter:{}}),a(!1)},[t.field]);return r.jsx(b.Popover,{open:!e&&n,onOpenChange:a,content:r.jsx(Pa,{onSlecet:i,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},Pa=({onSlecet:e,onQuery:t})=>{const{t:o}=Je();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},Ea=e=>{const{t}=Je(),[o,n]=x.useState(!1),a=x.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:a,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},Ma=e=>e.value&&typeof e.value=="object"?r.jsx(Ba,v({},e)):r.jsx($a,v({},e)),$a=({value:e,onChange:t})=>{const o=me({types:[Va]});return r.jsx(s.Variable.Input,{scope:o,value:e,onChange:t,children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:t})})},Ba=()=>{const e=A.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Ae}}}}})})};function Va(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}const Wa=()=>{var d;const{workflow:e}=Y(),[t,o]=s.parseCollectionName((d=e.config)==null?void 0:d.collection),n=s.useSchemaInitializerItem(),{insert:a}=s.useSchemaInitializer(),{getTemplateSchemaByMode:i}=s.useSchemaTemplateManager(),l=s.useRecordCollectionDataSourceItems("FormItem"),c=p=>P(null,[p],function*({item:u}){const f=u.template?yield i(u):null,y=s.createReadPrettyFormBlockSchema({actionInitializers:null,resource:o,collection:o,dataSource:t,template:f,settings:"blockSettings:details"});ae.unset(y,["x-acl-action","x-acl-action-props"]);const[h]=Object.keys(y.properties);ae.set(y.properties[h],"x-component-props.useProps","usePropsNoticeDetail"),a(y)});return r.jsx(s.SchemaInitializerItem,F(v({},n),{onClick:c,items:l}))},ja=new s.SchemaInitializer({name:"NoticeDetailInitializer",wrap:s.gridRowColWrap,title:"{{t('Add block')}}",items:[{name:"notice",type:"itemGroup",title:ce("Notice blocks"),children:[{name:"detail",type:"item",title:'{{t("Details")}}',Component:Wa}]},{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){var c;const e=s.usePlugin(re),{workflow:t}=Y(),o=et(),n=he(),a=We(n),i=[(c=o.useInitializers)==null?void 0:c.call(o,t.config)].filter(Boolean),l=a.map(d=>{var p;const u=e.instructions.get(d.type);return(p=u==null?void 0:u.useInitializers)==null?void 0:p.call(u,d)}).filter(Boolean);return[...i,...l.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "workflow" })}}',children:l}]:[]].filter(Boolean)}},{name:"others",type:"itemGroup",title:'{{t("Other blocks")}}',children:[{name:"markdown",type:"item",title:'{{t("Demonstration text")}}',component:"MarkdownBlockInitializer"}]}]});class La extends s.Plugin{load(){return P(this,null,function*(){this.app.schemaInitializerManager.add(ja)})}}function za(e){return{type:"void",name:e,"x-uid":e,"x-component":"Grid","x-initializer":"NoticeDetailInitializer"}}const qa=e=>{const{schemaData:t,loading:o,handleChange:n}=Ua(e);return o?r.jsx(b.Spin,{}):r.jsx(s.SchemaComponent,{memoized:!0,scope:{},components:{},schema:t,onChange:n})};function Ua(e){const{value:t,onChange:o}=e,n=s.useAPIClient(),{values:a,setValuesIn:i}=A.useForm(),{data:l,loading:c}=s.useRequest(()=>P(null,null,function*(){if(t){const f=yield Ka(n,t);if(f["x-uid"]===t)return f}const u=t!=null?t:W.uid(),p=za(u);return yield _a(n,p),o(u),p}));return{schemaData:l,loading:c,handleChange:u=>{}}}function Ka(e,t){return P(this,null,function*(){var a;const{data:o}=yield e.request({url:`uiSchemas:getJsonSchema/${t}`});return(a=o.data)!=null?a:{}})}function _a(e,t){return P(this,null,function*(){yield e.resource("uiSchemas").insert({values:t})})}const Ga={ActionStyle:s.css`
476
476
  .ant-drawer-body {
477
477
  background: var(--tb-box-bg);
478
478
  }
479
- `},_a=()=>{const e=x.useContext(s.SchemaComponentContext),[,t]=x.useState(W.uid()),{workflow:o}=Y(),n=x.useMemo(()=>F(v({},e),{refresh:()=>t(W.uid()),designable:!o.executed}),[e,o.executed]);return r.jsx(s.SchemaComponentContext.Provider,{value:n,children:r.jsx(s.SchemaComponent,{components:{NoticeDetail:La},schema:Ga})})},Ga={name:"drawer",type:"void",title:ce("The interface of show notice detail"),"x-component":"Action.Drawer","x-component-props":{className:Ka.ActionStyle},properties:{showNoticeDetail:{type:"string","x-component":"NoticeDetail"}}};s.createStyles({});const sn={ArrayItemsStyle:s.css`
479
+ `},Ha=()=>{const e=x.useContext(s.SchemaComponentContext),[,t]=x.useState(W.uid()),{workflow:o}=Y(),n=x.useMemo(()=>F(v({},e),{refresh:()=>t(W.uid()),designable:!o.executed}),[e,o.executed]);return r.jsx(s.SchemaComponentContext.Provider,{value:n,children:r.jsx(s.SchemaComponent,{components:{NoticeDetail:qa},schema:Ja})})},Ja={name:"drawer",type:"void",title:ce("The interface of show notice detail"),"x-component":"Action.Drawer","x-component-props":{className:Ga.ActionStyle},properties:{showNoticeDetail:{type:"string","x-component":"NoticeDetail"}}};s.createStyles({});const sn={ArrayItemsStyle:s.css`
480
480
  &[disabled] {
481
481
  > .ant-formily-array-base-addition {
482
482
  display: none;
@@ -493,19 +493,19 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:T("P
493
493
  > .ant-space-item:nth-child(2) {
494
494
  flex-grow: 1;
495
495
  }
496
- `};class Ha extends oe{constructor(){super(...arguments),this.title=ce("Notice"),this.type=en,this.group=Ge,this.icon="MessageOutlined",this.color="#82e29c",this.description=ce("In the workflow, notification messages can be viewed by the notified person in the notification center."),this.components={ArrayItems:W.ArrayItems,SelectNotifiedPerson:Pa,AdditionNotifiedPerson:Na,ConfigButtonNotice:Oa,ShowNoticeDetail:_a},this.fieldset={notifiedPerson:{type:"array",title:ce("The Notified Person"),"x-decorator":"FormItem","x-component":"ArrayItems","x-component-props":{className:sn.ArrayItemsStyle},items:{type:"void","x-component":"Space","x-component-props":{className:sn.SpaceStyle},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"SelectNotifiedPerson"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:ce("Add Notified Person"),"x-component":"AdditionNotifiedPerson"}}},showNoticeDetail:{type:"void",title:ce("Show Notice Detail"),required:!0,"x-decorator":"FormItem","x-component":"ConfigButtonNotice",properties:{showNoticeDetail:{type:"void","x-component":"ShowNoticeDetail"}}}}}isAvailable(t){return!0}}class Ja extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(Wa)})}load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(en,Ha),this.app.addComponents({ArrayItems:W.ArrayItems})})}}const Ya={title:ce("Node"),name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},Qa=A.observer(()=>{const{value:e}=A.useField(),t=s.useRecord();return r.jsx(Za,{value:e,record:t})},{displayName:"ColumnStatus"}),Za=e=>{const{value:t,record:o}=e,n=ae.omit(e,["value","record"]),a=s.useCompile(),{t:i}=Je(),{option:l=Xa[t]}=n,{workflow:c,execution:d,job:u}=o!=null?o:{};return(!(c!=null&&c.enabled)||d!=null&&d.stauts||u!=null&&u.status)&&[].includes(t)?r.jsx(b.Tag,{children:i("Unprocessed")}):r.jsx(b.Tag,{color:l==null?void 0:l.color,children:a(l==null?void 0:l.label)})},an=[{value:ye.QUEUEING,label:`{{t("Assigned", { ns: "${De}" })}}`,color:"blue"},{value:ye.STARTED,label:`{{t("Pending", { ns: "${De}" })}}`,color:"gold"},{value:2,label:`{{t("Approved", { ns: "${De}" })}}`,color:"green"},{value:ye.REJECTED,label:`{{t("Rejected", { ns: "${De}" })}}`,color:"red"}],Xa=an.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),Ra={title:ce("Notice Center"),name:eo,fields:[{type:"bigInt",name:"id",interface:"number",uiSchema:{type:"number",title:"ID","x-component":"InputNumber"}},{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:ce("The Notified Person"),"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task node", { ns: "${De}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:an}},{type:"text",name:"comment",interface:"markdown",uiSchema:{type:"string","x-component":"Markdown",title:`{{t("Comment", { ns: "${De}" })}}`}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Updated at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{type:"string",name:"summary",interface:"input",uiSchema:{type:"string",title:ce("Summary"),"x-component":"ApprovalsSummary","x-component-props":{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}]},ei={title:ce("Workflow"),name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"select",uiSchema:{type:"boolean",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:[{label:'{{t("On", { ns: "workflow" })}}',value:!0},{label:'{{t("Off", { ns: "workflow" })}}',value:!1}]}}]},ti=o=>{var n=o,{children:e}=n,t=Q(n,["children"]);const{collection:a,params:i={filter:{}},action:l="list"}=t,c=s.useRecord(),d={collection:a,resource:a,action:l,params:F(v({pageSize:20,sort:["-createdAt"]},i),{filter:c!=null&&c.id?v({dataKey:`${c.id}`},i.filter):v({},i.filter)}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[ei,Ya,Ra],children:r.jsx(s.TableBlockProvider,F(v({name:a},d),{children:e}))})},ln=x.createContext({}),oi=ln.Provider;function ni(){return x.useContext(ln)}const cn=x.createContext({}),ri=cn.Provider;function si(){return x.useContext(cn)}function ai(){const{snapshot:e}=si(),{form:t}=s.useFormBlockContext();return x.useEffect(()=>{t.setValues(e)},[t,e]),{form:t}}function dn({children:e,workflow:t,execution:o,nodes:n}){const a=s.usePlugin(re),i=a.triggers.get(t.type).components,l=n.reduce((c,{type:d})=>{var u;return Object.assign(c,(u=a.instructions.get(d))==null?void 0:u.components)},{});return r.jsx(Ve.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(s.SchemaComponentOptions,{components:v(v({},i),l),children:e})})}const un=o=>{var n=o,{children:e}=n,t=Q(n,["children"]);const a=s.useSchemaComponentContext(),{t:i}=Je(),{id:l}=s.useCollectionRecordData(),{loading:c,data:d}=ii(l);if(c)return r.jsx(b.Spin,{});if(!(d!=null&&d.data))return r.jsx(b.Result,{status:"error",title:i("Submission may be withdrawn, please try refresh the list.")});const u=d.data,{node:p,workflow:f,execution:y}=u,h=p==null?void 0:p.config.showNoticeDetail,{designable:g}=t;return r.jsx(dn,{workflow:f,nodes:f.nodes,execution:y,children:r.jsx(ri,{value:u,children:r.jsx(oi,{value:{id:l,schemaId:h},children:r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},a),{designable:g}),children:e})})})})};function ii(e){const{loading:t,data:o}=s.useRequest({resource:eo,action:"get",params:{filterByTk:e,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs","user"],except:["workflow.config","workflow.options","nodes.config"],sort:["-createdAt"]}},{refreshDeps:[e]});return{loading:t,data:o}}const li=()=>r.jsx(un,{children:r.jsx(ci,{})}),ci=e=>{const{id:t,schemaId:o}=ni();return r.jsx(s.SchemaComponent,{components:{NoticeDetailProvider:un,RemoteSchemaComponent:s.RemoteSchemaComponent,SchemaComponentProvider:s.SchemaComponentProvider,DetailsBlockProvider:qt},scope:{usePropsNoticeDetail:ai,useDetailsBlockProps:s.useFormBlockContext},schema:{name:`content-${t}`,type:"void","x-component":"Tabs",properties:{detail:{type:"void",title:ce("Content Detail"),"x-component":"Tabs.TabPane",properties:{detail:{type:"void","x-decorator":"NoticeDetailProvider","x-decorator-props":{designable:!1},"x-component":"RemoteSchemaComponent","x-component-props":{uid:o,noForm:!0}}}}}}})},di=({record:e})=>{const{id:t}=e;return{name:`notice-view-${t}`,type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},properties:{content:{type:"void","x-component":"NoticeDetailContent"}}}}}},ui=()=>{const e=s.useCollectionRecordData();return r.jsx(s.SchemaComponent,{components:{NoticeDetailContent:li},schema:di({record:e})})},pi=A.observer(()=>{const e=A.useField(),t=e==null?void 0:e.value;return t!=null&&t.title?t.title:t!=null&&t.id?`#${t.id}`:""},{displayName:"ColumnNode"}),mi=A.observer(()=>{const e=A.useField(),t=e==null?void 0:e.value;return t!=null&&t.nickname?t.nickname:(t==null?void 0:t.id)!==void 0?t.id:""},{displayName:"ColumnUser"}),fi=A.observer(()=>{const{t:e}=Je(),{value:t}=A.useField(),o=(t==null?void 0:t.title)||`#${t==null?void 0:t.id}`;return t!=null&&t.enabled?o:r.jsx("span",{className:s.css`
496
+ `};class Ya extends oe{constructor(){super(...arguments),this.title=ce("Notice"),this.type=en,this.group=Ge,this.icon="MessageOutlined",this.color="#82e29c",this.description=ce("In the workflow, notification messages can be viewed by the notified person in the notification center."),this.components={ArrayItems:W.ArrayItems,SelectNotifiedPerson:Ma,AdditionNotifiedPerson:Oa,ConfigButtonNotice:Ea,ShowNoticeDetail:Ha},this.fieldset={notifiedPerson:{type:"array",title:ce("The Notified Person"),"x-decorator":"FormItem","x-component":"ArrayItems","x-component-props":{className:sn.ArrayItemsStyle},items:{type:"void","x-component":"Space","x-component-props":{className:sn.SpaceStyle},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"SelectNotifiedPerson"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:ce("Add Notified Person"),"x-component":"AdditionNotifiedPerson"}}},showNoticeDetail:{type:"void",title:ce("Show Notice Detail"),required:!0,"x-decorator":"FormItem","x-component":"ConfigButtonNotice",properties:{showNoticeDetail:{type:"void","x-component":"ShowNoticeDetail"}}}}}isAvailable(t){return!0}}class Qa extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(La)})}load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(en,Ya),this.app.addComponents({ArrayItems:W.ArrayItems})})}}const Za={title:ce("Node"),name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},Xa=A.observer(()=>{const{value:e}=A.useField(),t=s.useRecord();return r.jsx(Ra,{value:e,record:t})},{displayName:"ColumnStatus"}),Ra=e=>{const{value:t,record:o}=e,n=ae.omit(e,["value","record"]),a=s.useCompile(),{t:i}=Je(),{option:l=ei[t]}=n,{workflow:c,execution:d,job:u}=o!=null?o:{};return(!(c!=null&&c.enabled)||d!=null&&d.stauts||u!=null&&u.status)&&[].includes(t)?r.jsx(b.Tag,{children:i("Unprocessed")}):r.jsx(b.Tag,{color:l==null?void 0:l.color,children:a(l==null?void 0:l.label)})},an=[{value:ye.QUEUEING,label:`{{t("Assigned", { ns: "${De}" })}}`,color:"blue"},{value:ye.STARTED,label:`{{t("Pending", { ns: "${De}" })}}`,color:"gold"},{value:2,label:`{{t("Approved", { ns: "${De}" })}}`,color:"green"},{value:ye.REJECTED,label:`{{t("Rejected", { ns: "${De}" })}}`,color:"red"}],ei=an.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),ti={title:ce("Notice Center"),name:eo,fields:[{type:"bigInt",name:"id",interface:"number",uiSchema:{type:"number",title:"ID","x-component":"InputNumber"}},{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:ce("The Notified Person"),"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task node", { ns: "${De}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:an}},{type:"text",name:"comment",interface:"markdown",uiSchema:{type:"string","x-component":"Markdown",title:`{{t("Comment", { ns: "${De}" })}}`}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Updated at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{type:"string",name:"summary",interface:"input",uiSchema:{type:"string",title:ce("Summary"),"x-component":"ApprovalsSummary","x-component-props":{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}]},oi={title:ce("Workflow"),name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"select",uiSchema:{type:"boolean",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:[{label:'{{t("On", { ns: "workflow" })}}',value:!0},{label:'{{t("Off", { ns: "workflow" })}}',value:!1}]}}]},ni=o=>{var n=o,{children:e}=n,t=Q(n,["children"]);const{collection:a,params:i={filter:{}},action:l="list"}=t,c=s.useRecord(),d={collection:a,resource:a,action:l,params:F(v({pageSize:20,sort:["-createdAt"]},i),{filter:c!=null&&c.id?v({dataKey:`${c.id}`},i.filter):v({},i.filter)}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[oi,Za,ti],children:r.jsx(s.TableBlockProvider,F(v({name:a},d),{children:e}))})},ln=x.createContext({}),ri=ln.Provider;function si(){return x.useContext(ln)}const cn=x.createContext({}),ai=cn.Provider;function ii(){return x.useContext(cn)}function li(){const{snapshot:e}=ii(),{form:t}=s.useFormBlockContext();return x.useEffect(()=>{t.setValues(e)},[t,e]),{form:t}}function dn({children:e,workflow:t,execution:o,nodes:n}){const a=s.usePlugin(re),i=a.triggers.get(t.type).components,l=n.reduce((c,{type:d})=>{var u;return Object.assign(c,(u=a.instructions.get(d))==null?void 0:u.components)},{});return r.jsx(Ve.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(s.SchemaComponentOptions,{components:v(v({},i),l),children:e})})}const un=o=>{var n=o,{children:e}=n,t=Q(n,["children"]);const a=s.useSchemaComponentContext(),{t:i}=Je(),{id:l}=s.useCollectionRecordData(),{loading:c,data:d}=ci(l);if(c)return r.jsx(b.Spin,{});if(!(d!=null&&d.data))return r.jsx(b.Result,{status:"error",title:i("Submission may be withdrawn, please try refresh the list.")});const u=d.data,{node:p,workflow:f,execution:y}=u,h=p==null?void 0:p.config.showNoticeDetail,{designable:g}=t;return r.jsx(dn,{workflow:f,nodes:f.nodes,execution:y,children:r.jsx(ai,{value:u,children:r.jsx(ri,{value:{id:l,schemaId:h},children:r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},a),{designable:g}),children:e})})})})};function ci(e){const{loading:t,data:o}=s.useRequest({resource:eo,action:"get",params:{filterByTk:e,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs","user"],except:["workflow.config","workflow.options","nodes.config"],sort:["-createdAt"]}},{refreshDeps:[e]});return{loading:t,data:o}}const di=()=>r.jsx(un,{children:r.jsx(ui,{})}),ui=e=>{const{id:t,schemaId:o}=si();return r.jsx(s.SchemaComponent,{components:{NoticeDetailProvider:un,RemoteSchemaComponent:s.RemoteSchemaComponent,SchemaComponentProvider:s.SchemaComponentProvider,DetailsBlockProvider:qt},scope:{usePropsNoticeDetail:li,useDetailsBlockProps:s.useFormBlockContext},schema:{name:`content-${t}`,type:"void","x-component":"Tabs",properties:{detail:{type:"void",title:ce("Content Detail"),"x-component":"Tabs.TabPane",properties:{detail:{type:"void","x-decorator":"NoticeDetailProvider","x-decorator-props":{designable:!1},"x-component":"RemoteSchemaComponent","x-component-props":{uid:o,noForm:!0}}}}}}})},pi=({record:e})=>{const{id:t}=e;return{name:`notice-view-${t}`,type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},properties:{content:{type:"void","x-component":"NoticeDetailContent"}}}}}},mi=()=>{const e=s.useCollectionRecordData();return r.jsx(s.SchemaComponent,{components:{NoticeDetailContent:di},schema:pi({record:e})})},fi=A.observer(()=>{const e=A.useField(),t=e==null?void 0:e.value;return t!=null&&t.title?t.title:t!=null&&t.id?`#${t.id}`:""},{displayName:"ColumnNode"}),gi=A.observer(()=>{const e=A.useField(),t=e==null?void 0:e.value;return t!=null&&t.nickname?t.nickname:(t==null?void 0:t.id)!==void 0?t.id:""},{displayName:"ColumnUser"}),hi=A.observer(()=>{const{t:e}=Je(),{value:t}=A.useField(),o=(t==null?void 0:t.title)||`#${t==null?void 0:t.id}`;return t!=null&&t.enabled?o:r.jsx("span",{className:s.css`
497
497
  text-decoration: line-through;
498
- `,title:e("Disabled"),children:o})},{displayName:"ColumnWorkflow"}),gi={ActionbarStyle:s.css`
498
+ `,title:e("Disabled"),children:o})},{displayName:"ColumnWorkflow"}),yi={ActionbarStyle:s.css`
499
499
  margin-bottom: 16px;
500
500
  `,TableV2Style:s.css`
501
501
  .ant-table-cell {
502
502
  text-align: center;
503
503
  }
504
- `},hi=()=>r.jsx(s.SchemaComponent,{components:{ColumnNode:pi,ColumnWorkflow:fi,ColumnUser:mi,ColumnStatus:Qa,ColumnAction:ui},schema:yi}),yi={type:"void",name:"notice-center",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{className:gi.ActionbarStyle},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",tableLayout:"fixed",className:s.css`
504
+ `},xi=()=>r.jsx(s.SchemaComponent,{components:{ColumnNode:fi,ColumnWorkflow:hi,ColumnUser:gi,ColumnStatus:Xa,ColumnAction:mi},schema:bi}),bi={type:"void",name:"notice-center",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{className:yi.ActionbarStyle},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",tableLayout:"fixed",className:s.css`
505
505
  .ant-table-cell {
506
506
  text-align: center;
507
507
  }
508
- `},properties:{action:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{action:{"x-component":"ColumnAction"}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:80},title:ce("ID"),properties:{id:{type:"number","x-component":"Input","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},summary:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:ce("Summary"),properties:{summary:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:ce("The Notified Person"),properties:{user:{"x-component":"ColumnUser","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${De}" })}}`,properties:{node:{"x-component":"ColumnNode","x-read-pretty":!0}}}}}}};class xi extends s.Plugin{load(){return P(this,null,function*(){this.app.addComponents({NoticeBlockProvider:ti,NoticeCenter:hi})})}}function pn(){const e=W.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:eo,params:{appends:["user.id","user.nickname","node.id","node.title","job.id","job.status","job.result","workflow.id","workflow.title","workflow.enabled","execution.id","execution.status"]},action:"listCentralized"},"x-decorator":"NoticeBlockProvider","x-component":"CardItem","x-designer":"TableBlockDesigner","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{notice:{type:"void","x-component":"NoticeCenter"}}}}const bi=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=x.useCallback(()=>{const n=pn();e(n)},[e,pn]);return r.jsx(s.SchemaInitializerItem,F(v({},t),{onClick:o}))};class vi extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(xi)})}load(){return P(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:bi}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:ce("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class wi extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(Ja),yield this.app.pm.add(vi)})}}class Ci extends Re{constructor(){super(...arguments),this.title=T("General event"),this.description=T("Omni Trigger is a versatile trigger. You can use it to trigger workflows in a table, trigger it from another workflow, or trigger it with a form button."),this.fieldset={bindCollection:{type:"boolean",title:T("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:T("Yes"),value:!0},{label:T("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:T("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:T("Associations to use"),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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=A.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={},this.isActionTriggerable=(t,o={})=>{const{buttonAction:n}=o;return[n==="customize:triggerWorkflows",n==="submit"].some(l=>l===!0)}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=fe(F(v({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:O("User acted")}}],compile:n,getCollectionFields:a}));return[...fe({appends:["data",...((l=t.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:O("Trigger data")}}],compile:n,getCollectionFields:a}),...i,{label:O("Role of user acted"),value:"roleName"}]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:T("Trigger data"),Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const ki=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,F(v({},e),{schema:Si,item:e}))},Si={type:"void",title:T("Trigger workflow"),"x-component":"Action","x-use-component-props":"usePropsAPIRegular","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:APIRegular","x-action":"customize:triggerWorkflows","x-action-settings":{bindWorkflow:!1,updateMode:"selected",triggerWorkflows:[]},"x-component-props":{icon:"CarryOutOutlined"}},Ai=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.triggerWorkflows)}},{name:"remove",sort:100,Component:s.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}],Ii=new s.SchemaSettings({name:"actionSettings:APIRegular",items:Ai}),Fi=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),a=A.useFieldSchema(),i=x.useContext(A.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:c}=l,{t:d}=ee.useTranslation();se.useNavigate(),s.useCompile();const u=A.useField(),{modal:p,notification:f}=b.App.useApp(),y=s.useVariables(),{name:h,getField:g}=s.useCollection_deprecated(),w=s.useLocalVariables(),{run:C}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",S=>{var I,M;if(S.msg==="start")f.info({key:"workflow:regular",message:d("Start"),description:r.jsx(b.Progress,{percent:0}),duration:0});else if(S.msg==="progress"){const E=S.current+1,N=Math.floor(E/S.total*100)===100?3:0,V=`[${((I=S.loopData)==null?void 0:I.loopIndex)||""}/${((M=S.loopData)==null?void 0:M.loopLength)||""}]`;f.info({key:"workflow:regular",message:`${d("Processing")}${S.loopData?V:""}...`,description:r.jsx(b.Progress,{percent:Math.floor(E/S.total*100)}),duration:N})}else S.msg==="done"&&(f.success({key:"workflow:regular",message:d("Done"),description:r.jsx(b.Progress,{percent:100}),duration:3}),n.refresh())}),{onClick(){return P(this,null,function*(){var j,X,B,L,$,U,J;const S=(L=(B=(X=(j=l.field)==null?void 0:j.data)==null?void 0:X.selectedRowKeys)!=null?B:i==null?void 0:i.selectedRecordKeys)!=null?L:[],{filter:I}=(U=($=n.params)==null?void 0:$[0])!=null?U:{},{bindWorkflow:M=!1,triggerWorkflows:E=!1,assignedValues:N={},updateMode:V}=(J=a==null?void 0:a["x-action-settings"])!=null?J:{},K=V==="selected",q={primaryKey:c||"id",targetKeys:S};if(u.data=e.data||{},u.data.loading=!0,!E&&!M)return p.info({title:O("Not bind workflow!")});const G=Object.keys(N).map(R=>P(null,null,function*(){const z=N[R],de=g(R);if(s.isVariable(z)){const te=yield y==null?void 0:y.parseVariable(z,w);te&&s.transformVariableValue(te,{targetCollectionField:de})}}));yield Promise.all(G),p.confirm({title:O("Confirm",{ns:"core"}),content:O("Trigger workflow?"),onOk(){return P(this,null,function*(){if(M){const R={filterByTk:M,updateData:encodeURIComponent(JSON.stringify(q))};C(R)}else E&&(K?yield t.trigger({filterByTk:S,triggerWorkflows:s.getAfterWorkflows(E),beforeWorkflows:s.getBeforeWorkflows(E)}):yield t.trigger({filter:I,triggerWorkflows:s.getAfterWorkflows(E),beforeWorkflows:s.getBeforeWorkflows(E)}));u.data.loading=!1})},onCancel(){return P(this,null,function*(){u.data.loading=!1})}})})}}};class Ti extends s.Plugin{load(){return P(this,null,function*(){this.app.addComponents({APIRegularInitializer:ki}),this.app.addScopes({usePropsAPIRegular:Fi}),this.app.schemaSettingsManager.add(Ii),["table","details"].forEach(t=>{this.app.schemaInitializerManager.addItem(`${t}:configureActions`,"customize.APIRegular",{title:T("Trigger workflow"),Component:"APIRegularInitializer",name:"apiRegular",useVisible(){const o=s.useCollection();return(o.template!=="view"||(o==null?void 0:o.writableView))&&o.template!=="file"&&o.template!=="sql"}})})})}}function Ni(){const e=A.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:a}=s.useActionContext(),i=s.useFilterByTk(),l=se.useNavigate(),c=A.useFieldSchema(),d=A.useField(),u=s.useCompile(),{modal:p}=b.App.useApp(),f=s.useCollectValuesToSubmit();return d.componentProps.filterKeys,{onClick(){return P(this,null,function*(){var D,S;const{onSuccess:h,skipValidator:g,triggerWorkflows:w}=(c==null?void 0:c["x-action-settings"])||{};g||(yield e.submit());const C=yield f();d.data=t.data||{},d.data.loading=!0;try{const I=yield n.trigger({values:C,filterByTk:i,triggerWorkflows:s.getAfterWorkflows(w),beforeWorkflows:s.getBeforeWorkflows(w)});if(d.data.data=I,(S=(D=o==null?void 0:o.service)==null?void 0:D.refresh)==null||S.call(D),a==null||a(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?p.success({title:u(h==null?void 0:h.successMessage),onOk:()=>P(null,null,function*(){return yield e.reset(),(h==null?void 0:h.redirecting)&&(h==null?void 0:h.redirectTo)&&(W.isURL(h.redirectTo)?window.location.href=h.redirectTo:l(h.redirectTo))})}):b.message.success(u(h==null?void 0:h.successMessage))}catch(I){console.error(I)}finally{d.data.loading=!1}})}}}function Di(){const e=s.useCompile(),t=s.useFilterByTk(),o=A.useField(),n=A.useFieldSchema(),{field:a,resource:i}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:c}=s.useActionContext(),{modal:d}=b.App.useApp(),u=se.useNavigate(),{onSuccess:p,triggerWorkflows:f}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(h,g){return P(this,null,function*(){o.data=a.data||{},o.data.loading=!0;try{if(yield i.trigger({filterByTk:t,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),g==null||g(),l==null||l(!1),c==null||c(!0),!(p!=null&&p.successMessage))return;p!=null&&p.manualClose?d.success({title:e(p==null?void 0:p.successMessage),onOk(){p!=null&&p.redirecting&&(p!=null&&p.redirectTo)&&(W.isURL(p.redirectTo)?window.location.href=p.redirectTo:u(p.redirectTo))}}):b.message.success(e(p==null?void 0:p.successMessage))}catch(w){console.error(w)}finally{o.data.loading=!1}})}}}const to={name:"triggerWorkflow",title:T("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:T("Trigger workflow"),"x-component":"Action","x-use-component-props":"useFormWorkflowCustomActionProps","x-designer":"Action.Designer","x-action-settings":{skipValidator:!1,onSuccess:{manualClose:!0,redirecting:!1,successMessage:T("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},St={name:"triggerWorkflow",title:T("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:T("Trigger workflow"),"x-component":"Action","x-use-component-props":"useRecordWorkflowCustomTriggerActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:T("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},oo=F(v({},St),{schema:F(v({},St.schema),{"x-component":"Action.Link"})});class Oi extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(Ti)})}load(){return P(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",Ci),this.app.addScopes({useFormWorkflowCustomActionProps:Ni,useRecordWorkflowCustomTriggerActionProps:Di}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",to),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",to),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",to),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.triggerWorkflow",St),this.app.schemaInitializerManager.get("details:configureActions").add("customize.triggerWorkflow",St),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.triggerWorkflow",oo),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",oo),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",oo)})}}class Pi extends oe{constructor(){super(...arguments),this.title=`{{t("Parallel branch", { ns: "${m}" })}}`,this.type="parallel",this.group="control",this.icon="MergeOutlined",this.color="#6e93e8",this.description=`{{t("Run multiple branch processes in parallel.", { ns: "${m}" })}}`,this.fieldset={mode:{type:"string",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${m}" })}}`},{value:"allSettled",label:`{{t('All settled', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches finished', { ns: "${m}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${m}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${m}" })}}`}]},default:"all"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={RadioWithTooltip:Ne}}Component({data:t}){const{styles:o}=we(),{id:n,config:{mode:a}}=t,{workflow:i,nodes:l}=Y(),c=l.reduce((g,w)=>w.upstreamId===n&&w.branchIndex!=null?g.concat(w):g,[]).sort((g,w)=>g.branchIndex-w.branchIndex),[d,u]=x.useState(Math.max(2,c.length)),{getAriaLabel:p}=ft(t),f=O("Add branch"),y=Array(Math.max(0,d-c.length)).fill(null),h=c[c.length-1];return r.jsx(it,{data:t,children:r.jsxs("div",{className:o.nodeSubtreeClass,children:[r.jsxs("div",{className:o.branchBlockClass,children:[c.map(g=>r.jsx(je,{from:t,entry:g,branchIndex:g.branchIndex},g.id)),y.map((g,w)=>r.jsx(je,{from:t,branchIndex:(h?h.branchIndex:0)+w+1,controller:c.length+w>1?r.jsx("div",{className:s.css`
508
+ `},properties:{action:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{action:{"x-component":"ColumnAction"}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:80},title:ce("ID"),properties:{id:{type:"number","x-component":"Input","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},summary:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:ce("Summary"),properties:{summary:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:ce("The Notified Person"),properties:{user:{"x-component":"ColumnUser","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${De}" })}}`,properties:{node:{"x-component":"ColumnNode","x-read-pretty":!0}}}}}}};class vi extends s.Plugin{load(){return P(this,null,function*(){this.app.addComponents({NoticeBlockProvider:ni,NoticeCenter:xi})})}}function pn(){const e=W.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:eo,params:{appends:["user.id","user.nickname","node.id","node.title","job.id","job.status","job.result","workflow.id","workflow.title","workflow.enabled","execution.id","execution.status"]},action:"listCentralized"},"x-decorator":"NoticeBlockProvider","x-component":"CardItem","x-designer":"TableBlockDesigner","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{notice:{type:"void","x-component":"NoticeCenter"}}}}const wi=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=x.useCallback(()=>{const n=pn();e(n)},[e,pn]);return r.jsx(s.SchemaInitializerItem,F(v({},t),{onClick:o}))};class Ci extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(vi)})}load(){return P(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:wi}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:ce("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class ki extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(Qa),yield this.app.pm.add(Ci)})}}class Si extends Re{constructor(){super(...arguments),this.title=T("General event"),this.description=T("Omni Trigger is a versatile trigger. You can use it to trigger workflows in a table, trigger it from another workflow, or trigger it with a form button."),this.fieldset={bindCollection:{type:"boolean",title:T("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:T("Yes"),value:!0},{label:T("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:T("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:T("Associations to use"),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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=A.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={},this.isActionTriggerable=(t,o={})=>{const{buttonAction:n}=o;return[n==="customize:triggerWorkflows",n==="submit"].some(l=>l===!0)}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=fe(F(v({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:O("User acted")}}],compile:n,getCollectionFields:a}));return[...fe({appends:["data",...((l=t.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:O("Trigger data")}}],compile:n,getCollectionFields:a}),...i,{label:O("Role of user acted"),value:"roleName"}]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:T("Trigger data"),Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const Ai=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,F(v({},e),{schema:Ii,item:e}))},Ii={type:"void",title:T("Trigger workflow"),"x-component":"Action","x-use-component-props":"usePropsAPIRegular","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:APIRegular","x-action":"customize:triggerWorkflows","x-action-settings":{bindWorkflow:!1,updateMode:"selected",triggerWorkflows:[]},"x-component-props":{icon:"CarryOutOutlined"}},Fi=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.triggerWorkflows)}},{name:"remove",sort:100,Component:s.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}],Ti=new s.SchemaSettings({name:"actionSettings:APIRegular",items:Fi}),Ni=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),a=A.useFieldSchema(),i=x.useContext(A.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:c}=l,{t:d}=ee.useTranslation();se.useNavigate(),s.useCompile();const u=A.useField(),{modal:p,notification:f}=b.App.useApp(),y=s.useVariables(),{name:h,getField:g}=s.useCollection_deprecated(),w=s.useLocalVariables(),{run:C}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",S=>{var I,M;if(S.msg==="start")f.info({key:"workflow:regular",message:d("Start"),description:r.jsx(b.Progress,{percent:0}),duration:0});else if(S.msg==="progress"){const E=S.current+1,N=Math.floor(E/S.total*100)===100?3:0,V=`[${((I=S.loopData)==null?void 0:I.loopIndex)||""}/${((M=S.loopData)==null?void 0:M.loopLength)||""}]`;f.info({key:"workflow:regular",message:`${d("Processing")}${S.loopData?V:""}...`,description:r.jsx(b.Progress,{percent:Math.floor(E/S.total*100)}),duration:N})}else S.msg==="done"&&(f.success({key:"workflow:regular",message:d("Done"),description:r.jsx(b.Progress,{percent:100}),duration:3}),n.refresh())}),{onClick(){return P(this,null,function*(){var j,X,B,L,$,U,J;const S=(L=(B=(X=(j=l.field)==null?void 0:j.data)==null?void 0:X.selectedRowKeys)!=null?B:i==null?void 0:i.selectedRecordKeys)!=null?L:[],{filter:I}=(U=($=n.params)==null?void 0:$[0])!=null?U:{},{bindWorkflow:M=!1,triggerWorkflows:E=!1,assignedValues:N={},updateMode:V}=(J=a==null?void 0:a["x-action-settings"])!=null?J:{},K=V==="selected",q={primaryKey:c||"id",targetKeys:S};if(u.data=e.data||{},u.data.loading=!0,!E&&!M)return p.info({title:O("Not bind workflow!")});const G=Object.keys(N).map(R=>P(null,null,function*(){const z=N[R],de=g(R);if(s.isVariable(z)){const te=yield y==null?void 0:y.parseVariable(z,w);te&&s.transformVariableValue(te,{targetCollectionField:de})}}));yield Promise.all(G),p.confirm({title:O("Confirm",{ns:"core"}),content:O("Trigger workflow?"),onOk(){return P(this,null,function*(){if(M){const R={filterByTk:M,updateData:encodeURIComponent(JSON.stringify(q))};C(R)}else E&&(K?yield t.trigger({filterByTk:S,triggerWorkflows:s.getAfterWorkflows(E),beforeWorkflows:s.getBeforeWorkflows(E)}):yield t.trigger({filter:I,triggerWorkflows:s.getAfterWorkflows(E),beforeWorkflows:s.getBeforeWorkflows(E)}));u.data.loading=!1})},onCancel(){return P(this,null,function*(){u.data.loading=!1})}})})}}};class Di extends s.Plugin{load(){return P(this,null,function*(){this.app.addComponents({APIRegularInitializer:Ai}),this.app.addScopes({usePropsAPIRegular:Ni}),this.app.schemaSettingsManager.add(Ti),["table","details"].forEach(t=>{this.app.schemaInitializerManager.addItem(`${t}:configureActions`,"customize.APIRegular",{title:T("Trigger workflow"),Component:"APIRegularInitializer",name:"apiRegular",useVisible(){const o=s.useCollection();return(o.template!=="view"||(o==null?void 0:o.writableView))&&o.template!=="file"&&o.template!=="sql"}})})})}}function Oi(){const e=A.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:a}=s.useActionContext(),i=s.useFilterByTk(),l=se.useNavigate(),c=A.useFieldSchema(),d=A.useField(),u=s.useCompile(),{modal:p}=b.App.useApp(),f=s.useCollectValuesToSubmit();return d.componentProps.filterKeys,{onClick(){return P(this,null,function*(){var D,S;const{onSuccess:h,skipValidator:g,triggerWorkflows:w}=(c==null?void 0:c["x-action-settings"])||{};g||(yield e.submit());const C=yield f();d.data=t.data||{},d.data.loading=!0;try{const I=yield n.trigger({values:C,filterByTk:i,triggerWorkflows:s.getAfterWorkflows(w),beforeWorkflows:s.getBeforeWorkflows(w)});if(d.data.data=I,(S=(D=o==null?void 0:o.service)==null?void 0:D.refresh)==null||S.call(D),a==null||a(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?p.success({title:u(h==null?void 0:h.successMessage),onOk:()=>P(null,null,function*(){return yield e.reset(),(h==null?void 0:h.redirecting)&&(h==null?void 0:h.redirectTo)&&(W.isURL(h.redirectTo)?window.location.href=h.redirectTo:l(h.redirectTo))})}):b.message.success(u(h==null?void 0:h.successMessage))}catch(I){console.error(I)}finally{d.data.loading=!1}})}}}function Pi(){const e=s.useCompile(),t=s.useFilterByTk(),o=A.useField(),n=A.useFieldSchema(),{field:a,resource:i}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:c}=s.useActionContext(),{modal:d}=b.App.useApp(),u=se.useNavigate(),{onSuccess:p,triggerWorkflows:f}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(h,g){return P(this,null,function*(){o.data=a.data||{},o.data.loading=!0;try{if(yield i.trigger({filterByTk:t,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),g==null||g(),l==null||l(!1),c==null||c(!0),!(p!=null&&p.successMessage))return;p!=null&&p.manualClose?d.success({title:e(p==null?void 0:p.successMessage),onOk(){p!=null&&p.redirecting&&(p!=null&&p.redirectTo)&&(W.isURL(p.redirectTo)?window.location.href=p.redirectTo:u(p.redirectTo))}}):b.message.success(e(p==null?void 0:p.successMessage))}catch(w){console.error(w)}finally{o.data.loading=!1}})}}}const to={name:"triggerWorkflow",title:T("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:T("Trigger workflow"),"x-component":"Action","x-use-component-props":"useFormWorkflowCustomActionProps","x-designer":"Action.Designer","x-action-settings":{skipValidator:!1,onSuccess:{manualClose:!0,redirecting:!1,successMessage:T("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},St={name:"triggerWorkflow",title:T("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:T("Trigger workflow"),"x-component":"Action","x-use-component-props":"useRecordWorkflowCustomTriggerActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:T("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},oo=F(v({},St),{schema:F(v({},St.schema),{"x-component":"Action.Link"})});class Ei extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(Di)})}load(){return P(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",Si),this.app.addScopes({useFormWorkflowCustomActionProps:Oi,useRecordWorkflowCustomTriggerActionProps:Pi}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",to),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",to),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",to),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.triggerWorkflow",St),this.app.schemaInitializerManager.get("details:configureActions").add("customize.triggerWorkflow",St),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.triggerWorkflow",oo),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",oo),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",oo)})}}class Mi extends oe{constructor(){super(...arguments),this.title=`{{t("Parallel branch", { ns: "${m}" })}}`,this.type="parallel",this.group="control",this.icon="MergeOutlined",this.color="#6e93e8",this.description=`{{t("Run multiple branch processes in parallel.", { ns: "${m}" })}}`,this.fieldset={mode:{type:"string",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${m}" })}}`},{value:"allSettled",label:`{{t('All settled', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches finished', { ns: "${m}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${m}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${m}" })}}`}]},default:"all"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={RadioWithTooltip:Ne}}Component({data:t}){const{styles:o}=we(),{id:n,config:{mode:a}}=t,{workflow:i,nodes:l}=Y(),c=l.reduce((g,w)=>w.upstreamId===n&&w.branchIndex!=null?g.concat(w):g,[]).sort((g,w)=>g.branchIndex-w.branchIndex),[d,u]=x.useState(Math.max(2,c.length)),{getAriaLabel:p}=ft(t),f=O("Add branch"),y=Array(Math.max(0,d-c.length)).fill(null),h=c[c.length-1];return r.jsx(it,{data:t,children:r.jsxs("div",{className:o.nodeSubtreeClass,children:[r.jsxs("div",{className:o.branchBlockClass,children:[c.map(g=>r.jsx(je,{from:t,entry:g,branchIndex:g.branchIndex},g.id)),y.map((g,w)=>r.jsx(je,{from:t,branchIndex:(h?h.branchIndex:0)+w+1,controller:c.length+w>1?r.jsx("div",{className:s.css`
509
509
  padding-top: 2em;
510
510
 
511
511
  > button {
@@ -525,19 +525,19 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:T("P
525
525
  transform-origin: center;
526
526
  transform: rotate(-45deg);
527
527
  }
528
- `,onClick:()=>u(d+1),disabled:i.executed})})]})})}}class Ei extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction("parallel",Pi)})}}class Mi extends oe{constructor(){super(...arguments),this.title=`{{t("HTTP request", { ns: "${m}" })}}`,this.type="request",this.group="extended",this.icon="ApiOutlined",this.color="#e1ed5b",this.description=`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${m}" })}}`,this.fieldset={method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableTextArea","x-component-props":{placeholder:"https://www.tachybase.com"}},needAuthorization:{type:"string",required:!0,title:`{{t("needAuthorization", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"是",value:!0},{label:"否",value:!1}],default:!0},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${m}" })}}`,description:`{{t('"Content-Type" only support "application/json and mutipart/form-data" ', { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${m}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${m}" })}}`},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${m}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},this.components={ArrayItems:W.ArrayItems,WorkflowVariableInput:ke,WorkflowVariableTextArea:at,WorkflowVariableJSON:$o}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return{[a.value]:t,[a.label]:o}}}class $i extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",Mi)})}}class Bi extends oe{constructor(){super(...arguments),this.title=T("Response message"),this.type="response-message",this.group="extended",this.icon="SunOutlined",this.color="#07d629",this.description=T("Add response message, will be send to client when process of request ends."),this.fieldset={message:{type:"string",title:T("Message content"),description:T("Supports variables in template.",{name:"{{name}}"}),"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={},this.components={RadioWithTooltip:Ne,WorkflowVariableTextArea:at,WorkflowVariableInput:ke}}isAvailable({workflow:t}){return t.type==="request-interception"||["action","general-action"].includes(t.type)&&t.sync}}class Vi extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("response-message",Bi)})}}const{TextArea:Wi}=b.Input,ji=A.connect(n=>{var a=n,{value:e,onChange:t}=a,o=Q(a,["value","onChange"]);var S;const i=A.useForm(),l=x.useRef(null),[c,d]=x.useState(null),[u,p]=x.useState(!1),[f,y]=x.useState(null),h=(S=i.values)==null?void 0:S.codeSource,g=h==="remote";x.useEffect(()=>{const I=setTimeout(()=>{!l.current&&!u&&(console.warn("[ScriptCodeEditor] Monaco Editor failed to load within timeout, using fallback TextArea"),p(!0))},5e3);return y(I),()=>{I&&clearTimeout(I)}},[u]);const w=x.useCallback(I=>{f&&(clearTimeout(f),y(null)),l.current=I,d(null),p(!1)},[f]),C=x.useMemo(()=>({lineNumbers:"on",minimap:{enabled:!1},readOnly:g,quickSuggestions:g?!1:{other:!0,comments:!0,strings:!0},suggestOnTriggerCharacters:!g,acceptSuggestionOnCommitCharacter:!g,acceptSuggestionOnEnter:g?"off":"on",tabCompletion:g?"off":"on",wordBasedSuggestions:g?"off":"allDocuments",snippetSuggestions:g?"none":"top",autoIndent:g?"none":"full",formatOnPaste:!g,formatOnType:!g,codeLens:!g,folding:!0,bracketPairColorization:{enabled:!g},suggest:{showKeywords:!g,showSnippets:!g,showClasses:!g,showFunctions:!g,showVariables:!g,showModules:!g,showProperties:!g,showReferences:!g,showValues:!g,showEnums:!g,showEnumMembers:!g,showEvents:!g,showOperators:!g,showUnits:!g,showColors:!g,showFiles:!g,showTypeParameters:!g,showIssues:!g,showUsers:!g,showFolders:!g}}),[g]);x.useEffect(()=>{var M;const I=l.current;if(I)if(typeof I.updateOptions=="function")I.updateOptions(C);else{const E=((M=I.getEditor)==null?void 0:M.call(I))||I;E&&typeof E.updateOptions=="function"&&E.updateOptions(C)}},[h,g,C]);const D=(I="")=>{g||t(I)};if(x.useCallback(I=>{console.error("[ScriptCodeEditor] Monaco Editor error:",I),d(I),p(!0)},[]),u||c){const I=o.height||"50vh",M=typeof I=="string"?I:`${I}px`;return r.jsxs("div",{className:s.css`
528
+ `,onClick:()=>u(d+1),disabled:i.executed})})]})})}}class $i extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction("parallel",Mi)})}}class Bi extends oe{constructor(){super(...arguments),this.title=`{{t("HTTP request", { ns: "${m}" })}}`,this.type="request",this.group="extended",this.icon="ApiOutlined",this.color="#e1ed5b",this.description=`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${m}" })}}`,this.fieldset={method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableTextArea","x-component-props":{placeholder:"https://www.tachybase.com"}},needAuthorization:{type:"string",required:!0,title:`{{t("needAuthorization", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"是",value:!0},{label:"否",value:!1}],default:!0},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${m}" })}}`,description:`{{t('"Content-Type" only support "application/json and mutipart/form-data" ', { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${m}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${m}" })}}`},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${m}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},this.components={ArrayItems:W.ArrayItems,WorkflowVariableInput:ke,WorkflowVariableTextArea:at,WorkflowVariableJSON:$o}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return{[a.value]:t,[a.label]:o}}}class Vi extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",Bi)})}}class Wi extends oe{constructor(){super(...arguments),this.title=T("Response message"),this.type="response-message",this.group="extended",this.icon="SunOutlined",this.color="#07d629",this.description=T("Add response message, will be send to client when process of request ends."),this.fieldset={message:{type:"string",title:T("Message content"),description:T("Supports variables in template.",{name:"{{name}}"}),"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={},this.components={RadioWithTooltip:Ne,WorkflowVariableTextArea:at,WorkflowVariableInput:ke}}isAvailable({workflow:t}){return t.type==="request-interception"||["action","general-action"].includes(t.type)&&t.sync}}class ji extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("response-message",Wi)})}}const{TextArea:Li}=b.Input,zi=A.connect(n=>{var a=n,{value:e,onChange:t}=a,o=Q(a,["value","onChange"]);var S;const i=A.useForm(),l=x.useRef(null),[c,d]=x.useState(null),[u,p]=x.useState(!1),[f,y]=x.useState(null),h=(S=i.values)==null?void 0:S.codeSource,g=h==="remote";x.useEffect(()=>{const I=setTimeout(()=>{!l.current&&!u&&(console.warn("[ScriptCodeEditor] Monaco Editor failed to load within timeout, using fallback TextArea"),p(!0))},5e3);return y(I),()=>{I&&clearTimeout(I)}},[u]);const w=x.useCallback(I=>{f&&(clearTimeout(f),y(null)),l.current=I,d(null),p(!1)},[f]),C=x.useMemo(()=>({lineNumbers:"on",minimap:{enabled:!1},readOnly:g,quickSuggestions:g?!1:{other:!0,comments:!0,strings:!0},suggestOnTriggerCharacters:!g,acceptSuggestionOnCommitCharacter:!g,acceptSuggestionOnEnter:g?"off":"on",tabCompletion:g?"off":"on",wordBasedSuggestions:g?"off":"allDocuments",snippetSuggestions:g?"none":"top",autoIndent:g?"none":"full",formatOnPaste:!g,formatOnType:!g,codeLens:!g,folding:!0,bracketPairColorization:{enabled:!g},suggest:{showKeywords:!g,showSnippets:!g,showClasses:!g,showFunctions:!g,showVariables:!g,showModules:!g,showProperties:!g,showReferences:!g,showValues:!g,showEnums:!g,showEnumMembers:!g,showEvents:!g,showOperators:!g,showUnits:!g,showColors:!g,showFiles:!g,showTypeParameters:!g,showIssues:!g,showUsers:!g,showFolders:!g}}),[g]);x.useEffect(()=>{var M;const I=l.current;if(I)if(typeof I.updateOptions=="function")I.updateOptions(C);else{const E=((M=I.getEditor)==null?void 0:M.call(I))||I;E&&typeof E.updateOptions=="function"&&E.updateOptions(C)}},[h,g,C]);const D=(I="")=>{g||t(I)};if(x.useCallback(I=>{console.error("[ScriptCodeEditor] Monaco Editor error:",I),d(I),p(!0)},[]),u||c){const I=o.height||"50vh",M=typeof I=="string"?I:`${I}px`;return r.jsxs("div",{className:s.css`
529
529
  display: flex;
530
530
  flex-direction: column;
531
531
  height: ${M};
532
532
  `,children:[c&&r.jsx(b.Alert,{message:T("Code editor failed to load"),description:T("Monaco Editor failed to load, downgraded to basic text editor. Some features may be limited."),type:"warning",showIcon:!0,closable:!0,onClose:()=>d(null),className:s.css`
533
533
  margin-bottom: 8px;
534
- `}),r.jsx(Wi,v({value:e||"",onChange:E=>D(E.target.value),readOnly:g,placeholder:T("Please enter code..."),style:{height:`calc(${M} - ${c?"60px":"0px"})`,fontFamily:'Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace',fontSize:"14px",lineHeight:"1.5",resize:"none"}},o))]})}return x.useEffect(()=>{const I=E=>{var N,V,K,q,G;((N=E.message)!=null&&N.includes("monaco")||(V=E.message)!=null&&V.includes("Monaco")||(K=E.filename)!=null&&K.includes("monaco")||(q=E.filename)!=null&&q.includes("vs/")||(G=E.filename)!=null&&G.includes("loader.js"))&&(console.warn("[ScriptCodeEditor] Detected Monaco Editor error, will use fallback:",E.message),p(!0))},M=E=>{const N=E.reason,V=(N==null?void 0:N.message)||String(N);(V.includes("monaco")||V.includes("Monaco")||V.includes("loader"))&&(console.warn("[ScriptCodeEditor] Detected Monaco Editor promise rejection, will use fallback:",V),p(!0))};return window.addEventListener("error",I),window.addEventListener("unhandledrejection",M),()=>{window.removeEventListener("error",I),window.removeEventListener("unhandledrejection",M)}},[]),r.jsx(W.CodeEditor,v({defaultLanguage:"typescript",value:e,onChange:D,options:C,height:o.height||"50vh",onMount:w,loading:r.jsx("div",{className:s.css`
534
+ `}),r.jsx(Li,v({value:e||"",onChange:E=>D(E.target.value),readOnly:g,placeholder:T("Please enter code..."),style:{height:`calc(${M} - ${c?"60px":"0px"})`,fontFamily:'Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace',fontSize:"14px",lineHeight:"1.5",resize:"none"}},o))]})}return x.useEffect(()=>{const I=E=>{var N,V,K,q,G;((N=E.message)!=null&&N.includes("monaco")||(V=E.message)!=null&&V.includes("Monaco")||(K=E.filename)!=null&&K.includes("monaco")||(q=E.filename)!=null&&q.includes("vs/")||(G=E.filename)!=null&&G.includes("loader.js"))&&(console.warn("[ScriptCodeEditor] Detected Monaco Editor error, will use fallback:",E.message),p(!0))},M=E=>{const N=E.reason,V=(N==null?void 0:N.message)||String(N);(V.includes("monaco")||V.includes("Monaco")||V.includes("loader"))&&(console.warn("[ScriptCodeEditor] Detected Monaco Editor promise rejection, will use fallback:",V),p(!0))};return window.addEventListener("error",I),window.addEventListener("unhandledrejection",M),()=>{window.removeEventListener("error",I),window.removeEventListener("unhandledrejection",M)}},[]),r.jsx(W.CodeEditor,v({defaultLanguage:"typescript",value:e,onChange:D,options:C,height:o.height||"50vh",onMount:w,loading:r.jsx("div",{className:s.css`
535
535
  display: flex;
536
536
  align-items: center;
537
537
  justify-content: center;
538
538
  height: ${typeof o.height=="string"?o.height:o.height||"50vh"};
539
539
  color: #999;
540
- `,children:T("Loading editor...")})},o))}),{Text:no}=b.Typography,Ye={primary:"#52c41a",hover:"#73d13d"},Li=()=>{var g,w,C,D,S;const e=A.useForm(),t=s.useAPIClient(),o=he(),[n,a]=x.useState(!1),[i,l]=x.useState(!1),c=x.useRef(null),d=(g=e.values)==null?void 0:g.codeSource,u=(w=e.values)==null?void 0:w.codeType;(C=e.values)==null||C.codeUrl;const p=((D=e.values)==null?void 0:D.code)||"",f=(S=e.values)!=null&&S.lastSyncTime?new Date(e.values.lastSyncTime):null,y=x.useCallback((I=!1)=>P(null,null,function*(){var X,B,L,$,U,J;const M=e.values||{},{codeSource:E,codeType:N,codeUrl:V,codeBranch:K="main",codeAuthType:q="token",codeAuthToken:G,codeAuthUsername:j}=M;if(!(E!=="remote"||!N||!V)){I||a(!0);try{const _=yield t.request({resource:"flow_nodes",action:"syncRemoteCode",params:{values:{codeUrl:V,codeType:N,codeBranch:N==="git"?K:void 0,codeAuthType:q,codeAuthToken:G,codeAuthUsername:j,nodeId:o==null?void 0:o.id}}}),R=((X=_==null?void 0:_.data)==null?void 0:X.code)||((L=(B=_==null?void 0:_.data)==null?void 0:B.data)==null?void 0:L.code);R?(e.setValues(F(v({},e.values),{code:R,lastSyncTime:new Date().toISOString()})),c.current=R,l(!0),I||b.message.success(O("Code synced successfully"))):I||b.message.error(O("No code returned from remote source"))}catch(_){if(!I){const R=((J=(U=($=_==null?void 0:_.response)==null?void 0:$.data)==null?void 0:U.error)==null?void 0:J.message)||(_==null?void 0:_.message)||O("Failed to sync remote code");b.message.error(R)}}finally{I||a(!1)}}}),[e,t,o==null?void 0:o.id]),h=()=>P(null,null,function*(){const I=e.values||{},M=I.codeSource,E=I.codeType,N=I.codeUrl;if(M!=="remote"){b.message.warning(O("Please select remote code source first"));return}if(!E){b.message.warning(O("Please select code type first"));return}if(!N||!N.trim()){b.message.warning(O("Code URL is required for Git"));return}yield y(!1)});return x.useEffect(()=>{c.current!==null?l(p===c.current):l(!1)},[p]),d!=="remote"||!u?null:r.jsxs("div",{style:{marginBottom:8},children:[r.jsx(b.Button,{type:"primary",icon:r.jsx(s.Icon,{type:"SyncOutlined"}),loading:n,onClick:h,style:{backgroundColor:Ye.primary,borderColor:Ye.primary,marginBottom:4},onMouseEnter:I=>{I.currentTarget.style.backgroundColor=Ye.hover,I.currentTarget.style.borderColor=Ye.hover},onMouseLeave:I=>{I.currentTarget.style.backgroundColor=Ye.primary,I.currentTarget.style.borderColor=Ye.primary},children:O("Sync remote code")}),r.jsx("div",{children:r.jsxs(no,{type:"secondary",style:{fontSize:12},children:[O("Last sync time"),":"," ",f?r.jsx(no,{type:"success",children:mt(f).format("YYYY-MM-DD HH:mm:ss")}):r.jsx(no,{type:"secondary",children:"-"})]})})]})};class zi extends oe{constructor(){super(...arguments),this.title=T("Data Mapping"),this.type=So,this.group="extended",this.icon="FunctionOutlined",this.color="#d93a13",this.isHot=!0,this.description=T("Get specific data from JSON result of any node BY js code or json code;"),this.fieldset={sourceArray:{type:"array",title:T("Data source map"),description:T("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Property path")},properties:{sourcePath:{type:"string",name:"sourcePath",required:!0,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0}}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
540
+ `,children:T("Loading editor...")})},o))}),{Text:no}=b.Typography,Ye={primary:"#52c41a",hover:"#73d13d"},qi=()=>{var g,w,C,D,S;const e=A.useForm(),t=s.useAPIClient(),o=he(),[n,a]=x.useState(!1),[i,l]=x.useState(!1),c=x.useRef(null),d=(g=e.values)==null?void 0:g.codeSource,u=(w=e.values)==null?void 0:w.codeType;(C=e.values)==null||C.codeUrl;const p=((D=e.values)==null?void 0:D.code)||"",f=(S=e.values)!=null&&S.lastSyncTime?new Date(e.values.lastSyncTime):null,y=x.useCallback((I=!1)=>P(null,null,function*(){var X,B,L,$,U,J;const M=e.values||{},{codeSource:E,codeType:N,codeUrl:V,codeBranch:K="main",codeAuthType:q="token",codeAuthToken:G,codeAuthUsername:j}=M;if(!(E!=="remote"||!N||!V)){I||a(!0);try{const _=yield t.request({resource:"flow_nodes",action:"syncRemoteCode",params:{values:{codeUrl:V,codeType:N,codeBranch:N==="git"?K:void 0,codeAuthType:q,codeAuthToken:G,codeAuthUsername:j,nodeId:o==null?void 0:o.id}}}),R=((X=_==null?void 0:_.data)==null?void 0:X.code)||((L=(B=_==null?void 0:_.data)==null?void 0:B.data)==null?void 0:L.code);R?(e.setValues(F(v({},e.values),{code:R,lastSyncTime:new Date().toISOString()})),c.current=R,l(!0),I||b.message.success(O("Code synced successfully"))):I||b.message.error(O("No code returned from remote source"))}catch(_){if(!I){const R=((J=(U=($=_==null?void 0:_.response)==null?void 0:$.data)==null?void 0:U.error)==null?void 0:J.message)||(_==null?void 0:_.message)||O("Failed to sync remote code");b.message.error(R)}}finally{I||a(!1)}}}),[e,t,o==null?void 0:o.id]),h=()=>P(null,null,function*(){const I=e.values||{},M=I.codeSource,E=I.codeType,N=I.codeUrl;if(M!=="remote"){b.message.warning(O("Please select remote code source first"));return}if(!E){b.message.warning(O("Please select code type first"));return}if(!N||!N.trim()){b.message.warning(O("Code URL is required for Git"));return}yield y(!1)});return x.useEffect(()=>{c.current!==null?l(p===c.current):l(!1)},[p]),d!=="remote"||!u?null:r.jsxs("div",{style:{marginBottom:8},children:[r.jsx(b.Button,{type:"primary",icon:r.jsx(s.Icon,{type:"SyncOutlined"}),loading:n,onClick:h,style:{backgroundColor:Ye.primary,borderColor:Ye.primary,marginBottom:4},onMouseEnter:I=>{I.currentTarget.style.backgroundColor=Ye.hover,I.currentTarget.style.borderColor=Ye.hover},onMouseLeave:I=>{I.currentTarget.style.backgroundColor=Ye.primary,I.currentTarget.style.borderColor=Ye.primary},children:O("Sync remote code")}),r.jsx("div",{children:r.jsxs(no,{type:"secondary",style:{fontSize:12},children:[O("Last sync time"),":"," ",f?r.jsx(no,{type:"success",children:mt(f).format("YYYY-MM-DD HH:mm:ss")}):r.jsx(no,{type:"secondary",children:"-"})]})})]})};class Ui extends oe{constructor(){super(...arguments),this.title=T("Data Mapping"),this.type=So,this.group="extended",this.icon="FunctionOutlined",this.color="#d93a13",this.isHot=!0,this.description=T("Get specific data from JSON result of any node BY js code or json code;"),this.fieldset={sourceArray:{type:"array",title:T("Data source map"),description:T("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Property path")},properties:{sourcePath:{type:"string",name:"sourcePath",required:!0,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0}}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
541
541
  > *:not(:last-child) {
542
542
  margin-right: 0.5em;
543
543
  }
@@ -565,37 +565,37 @@ export default async function (
565
565
  button {
566
566
  padding: 0;
567
567
  }
568
- `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke,SyncRemoteCodeButton:Li,ScriptCodeEditor:ji}}useVariables(t,o){const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o,d=i.model||[];return{[c.label]:a,[c.value]:n,[c.children]:d.map(p=>({[c.label]:p.label,[c.value]:p.alias||p.path}))}}}class qi extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(So,zi)})}}class Ui extends oe{constructor(){super(...arguments),this.title=`{{t("SQL action", { ns: "${m}" })}}`,this.type="sql",this.group="collection",this.icon="ConsoleSqlOutlined",this.color="#e9bf36",this.description=`{{t("Execute a SQL statement in database.", { ns: "${m}" })}}`,this.fieldset={dataSource:{type:"string",required:!0,title:'{{t("Data source")}}',description:`{{t("Select a data source to execute SQL.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DataSourceSelect","x-component-props":{className:"auto-width",filter(t){return t.options.isDBInstance}},default:"main"},sql:{type:"string",required:!0,title:"SQL","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{rows:20,className:s.css`
568
+ `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke,SyncRemoteCodeButton:qi,ScriptCodeEditor:zi}}useVariables(t,o){const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o,d=i.model||[];return{[c.label]:a,[c.value]:n,[c.children]:d.map(p=>({[c.label]:p.label,[c.value]:p.alias||p.path}))}}}class Ki extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(So,Ui)})}}class _i extends oe{constructor(){super(...arguments),this.title=`{{t("SQL action", { ns: "${m}" })}}`,this.type="sql",this.group="collection",this.icon="ConsoleSqlOutlined",this.color="#e9bf36",this.description=`{{t("Execute a SQL statement in database.", { ns: "${m}" })}}`,this.fieldset={dataSource:{type:"string",required:!0,title:'{{t("Data source")}}',description:`{{t("Select a data source to execute SQL.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DataSourceSelect","x-component-props":{className:"auto-width",filter(t){return t.options.isDBInstance}},default:"main"},sql:{type:"string",required:!0,title:"SQL","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{rows:20,className:s.css`
569
569
  font-size: 80%;
570
570
  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
571
- `}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableRawTextArea:Mo}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return{[a.value]:t,[a.label]:o}}}class Ki extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("sql",Ui)})}}const _i=()=>{const{workflow:e}=Y();return{filterSync:e==null?void 0:e.sync,filterKey:e!=null&&e.key?{$ne:e==null?void 0:e.key}:void 0}};class Gi extends oe{constructor(){super(...arguments),this.title=T("Workflow"),this.type="trigger-instruction",this.group="extended",this.icon="NodeIndexOutlined",this.color="#0a72e9",this.fieldset={sourceArray:{type:"array",title:T("Data source map"),description:T("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Property path")},properties:{sourcePath:{type:"string",name:"sourcePath",required:!0,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0}}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
571
+ `}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableRawTextArea:Mo}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return{[a.value]:t,[a.label]:o}}}class Gi extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("sql",_i)})}}const Hi=()=>{const{workflow:e}=Y();return{filterSync:e==null?void 0:e.sync,filterKey:e!=null&&e.key?{$ne:e==null?void 0:e.key}:void 0}};class Ji extends oe{constructor(){super(...arguments),this.title=T("Workflow"),this.type="trigger-instruction",this.group="extended",this.icon="NodeIndexOutlined",this.color="#0a72e9",this.fieldset={sourceArray:{type:"array",title:T("Data source map"),description:T("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Property path")},properties:{sourcePath:{type:"string",name:"sourcePath",required:!0,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0}}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
572
572
  > *:not(:last-child) {
573
573
  margin-right: 0.5em;
574
574
  }
575
575
  button {
576
576
  padding: 0;
577
577
  }
578
- `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}},workflowKey:{type:"string",title:T("Workflow"),name:"workflowKey","x-decorator":"FormItem","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"},"x-use-component-props":_i,required:!0},bindCollection:{type:"boolean",title:T("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:T("Yes"),value:!0},{label:T("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:T("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:T("Associations to use"),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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=A.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},model:{type:"array",title:T("Properties mapping"),description:T("If the type of query result is object or array of object, could map the properties which to be accessed in subsequent nodes."),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{path:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Property path")},properties:{path:{type:"string",name:"path",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},alias:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Label")},properties:{label:{type:"string",name:"label",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
578
+ `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}},workflowKey:{type:"string",title:T("Workflow"),name:"workflowKey","x-decorator":"FormItem","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"},"x-use-component-props":Hi,required:!0},bindCollection:{type:"boolean",title:T("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:T("Yes"),value:!0},{label:T("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:T("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:T("Associations to use"),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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=A.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},model:{type:"array",title:T("Properties mapping"),description:T("If the type of query result is object or array of object, could map the properties which to be accessed in subsequent nodes."),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{path:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Property path")},properties:{path:{type:"string",name:"path",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},alias:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("Label")},properties:{label:{type:"string",name:"label",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
579
579
  > *:not(:last-child) {
580
580
  margin-right: 0.5em;
581
581
  }
582
582
  button {
583
583
  padding: 0;
584
584
  }
585
- `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){var f;const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o;if(i.model&&Array.isArray(i.model)&&i.model.length>0)return{[c.label]:a,[c.value]:n,[c.children]:i.model.map(y=>({[c.label]:y.label,[c.value]:y.alias||y.path}))};const d=s.useCompile(),{getCollectionFields:u}=s.useCollectionManager_deprecated(),[p]=fe(F(v({appends:[n,...((f=i.appends)==null?void 0:f.map(y=>`${n}.${y}`))||[]]},o),{fields:[{collectionName:i.collection,name:n,type:"hasOne",target:i.collection,uiSchema:{title:a}}],compile:d,getCollectionFields:u}));return p}}class Hi extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("trigger-instruction",Gi)})}}const Ji=s.createStyles(({css:e,token:t})=>({nodeIdClass:e`
585
+ `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){var f;const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o;if(i.model&&Array.isArray(i.model)&&i.model.length>0)return{[c.label]:a,[c.value]:n,[c.children]:i.model.map(y=>({[c.label]:y.label,[c.value]:y.alias||y.path}))};const d=s.useCompile(),{getCollectionFields:u}=s.useCollectionManager_deprecated(),[p]=fe(F(v({appends:[n,...((f=i.appends)==null?void 0:f.map(y=>`${n}.${y}`))||[]]},o),{fields:[{collectionName:i.collection,name:n,type:"hasOne",target:i.collection,uiSchema:{title:a}}],compile:d,getCollectionFields:u}));return p}}class Yi extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("trigger-instruction",Ji)})}}const Qi=s.createStyles(({css:e,token:t})=>({nodeIdClass:e`
586
586
  color: ${t.colorTextDescription};
587
587
 
588
588
  &:before {
589
589
  content: '#';
590
590
  }
591
- `}));function Yi({value:e,onChange:t}){const o=e==null,n=he(),a=We(n,d=>d.type==="variable"&&!d.config.target),{styles:i}=Ji(),l=x.useCallback(({target:d})=>{if(d.value)return t(null);a.length&&t(a[0].key)},[t,a]),c=x.useCallback((d,u)=>u.label.toLowerCase().indexOf(d.toLowerCase())>=0||`#${u.data.id}`.indexOf(d)>=0,[]);return r.jsx("fieldset",{children:r.jsx(b.Radio.Group,{value:o,onChange:l,children:r.jsxs(s.Space,{direction:"vertical",children:[r.jsx(b.Radio,{value:!0,children:O("Declare a new variable")}),r.jsxs(s.Space,{children:[r.jsx(b.Radio,{value:!1,disabled:!a.length,children:O("Assign value to an existing variable")}),!o&&r.jsx(b.Select,{options:a.map(d=>({label:d.title,value:d.key,data:d})),value:e,onChange:t,allowClear:!0,showSearch:!0,filterOption:c,optionRender:({label:d,data:u})=>r.jsxs(s.Space,{children:[r.jsx("span",{children:d}),r.jsx("span",{className:i.nodeIdClass,children:u.data.id})]})})]})]})})})}class Qi extends oe{constructor(){super(...arguments),this.title=T("Variable"),this.type="variable",this.group="control",this.icon="StrikethroughOutlined",this.color="#a35ae8",this.description=T("Assign value to a variable, for later use."),this.fieldset={target:{type:"string",title:T("Mode"),"x-decorator":"FormItem","x-component":"VariableTargetSelect"},value:{type:"string",title:T("Value"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0,changeOnSelect:!0},default:""},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={WorkflowVariableInput:ke,VariableTargetSelect:Yi}}useVariables({key:t,title:o,config:n},{types:a,fieldNames:i=xe}){return n.target?null:{[i.value]:t,[i.label]:o}}}class Zi extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("variable",Qi)})}}const mn=e=>{const t=W.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:s.css`
591
+ `}));function Zi({value:e,onChange:t}){const o=e==null,n=he(),a=We(n,d=>d.type==="variable"&&!d.config.target),{styles:i}=Qi(),l=x.useCallback(({target:d})=>{if(d.value)return t(null);a.length&&t(a[0].key)},[t,a]),c=x.useCallback((d,u)=>u.label.toLowerCase().indexOf(d.toLowerCase())>=0||`#${u.data.id}`.indexOf(d)>=0,[]);return r.jsx("fieldset",{children:r.jsx(b.Radio.Group,{value:o,onChange:l,children:r.jsxs(s.Space,{direction:"vertical",children:[r.jsx(b.Radio,{value:!0,children:O("Declare a new variable")}),r.jsxs(s.Space,{children:[r.jsx(b.Radio,{value:!1,disabled:!a.length,children:O("Assign value to an existing variable")}),!o&&r.jsx(b.Select,{options:a.map(d=>({label:d.title,value:d.key,data:d})),value:e,onChange:t,allowClear:!0,showSearch:!0,filterOption:c,optionRender:({label:d,data:u})=>r.jsxs(s.Space,{children:[r.jsx("span",{children:d}),r.jsx("span",{className:i.nodeIdClass,children:u.data.id})]})})]})]})})})}class Xi extends oe{constructor(){super(...arguments),this.title=T("Variable"),this.type="variable",this.group="control",this.icon="StrikethroughOutlined",this.color="#a35ae8",this.description=T("Assign value to a variable, for later use."),this.fieldset={target:{type:"string",title:T("Mode"),"x-decorator":"FormItem","x-component":"VariableTargetSelect"},value:{type:"string",title:T("Value"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0,changeOnSelect:!0},default:""},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={WorkflowVariableInput:ke,VariableTargetSelect:Zi}}useVariables({key:t,title:o,config:n},{types:a,fieldNames:i=xe}){return n.target?null:{[i.value]:t,[i.label]:o}}}class Ri extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("variable",Xi)})}}const mn=e=>{const t=W.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:s.css`
592
592
  &:after {
593
593
  content: ':';
594
594
  }
595
595
  & + a {
596
596
  margin-left: 0.25em;
597
597
  }
598
- `,children:s.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class Xi extends oe{constructor(){super(...arguments),this.title=`{{t("Calculation", { ns: "${m}" })}}`,this.type="calculation",this.group="control",this.icon="PlusOutlined",this.color="#c3e584",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: "${m}" })}}`,this.fieldset={engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{getOptions:W.getOptions},required:!0,default:"formula.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(t,o,{form:n}){const{values:a}=n,{evaluate:i}=W.evaluators.get(a.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return i(l),""}catch(c){return O("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},transString:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":"解析字符串公式","x-reactions":[{dependencies:["engine"],fulfill:{state:{visible:"{{$deps[0] == `formula.js`}}"}}}]},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={renderEngineReference:mn},this.components={WorkflowVariableTextArea:at,RadioWithTooltip:Ne,ValueBlock:Ie}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return n&&!n.some(i=>i in Pe||Object.values(Pe).some(l=>l.has(i)))?null:{[a.value]:t,[a.label]:o}}useInitializers(t){var o,n;return{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Ie.Initializer,node:t,resultTitle:O("Calculation result")}}}const Ri=e=>{const{editingConfig:t,setEditingConfig:o,data:n,workflow:a,children:i}=e,[l,c]=x.useState(!1),d=x.useMemo(()=>{const p=ae.cloneDeep(n.config);return A.createForm({initialValues:p,disabled:a.executed})},[n,a]),u=x.useCallback(p=>{o(p),p||d.reset()},[d]);return r.jsx(s.ActionContextProvider,{value:{visible:t,setVisible:u,formValueChanged:l,setFormValueChanged:c},children:r.jsx(s.FormProvider,{form:d,children:i})})};function el(){return{form:A.useForm()}}function tl(){const e=A.useForm(),t=s.useAPIClient(),o=s.useActionContext(),{refresh:n}=s.useResourceActionContext(),a=he(),{workflow:i}=Y();return{run(){return P(this,null,function*(){var c,d;if(i.executed){b.message.error(O("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:a.id,values:{config:e.values}}),o.setFormValueChanged(!1),b.message.success("success"),n()})}}}const ol=e=>{const{data:t,instruction:o}=e,n=(o==null?void 0:o.group)===Ge;return r.jsxs("div",{className:s.css`
598
+ `,children:s.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class el extends oe{constructor(){super(...arguments),this.title=`{{t("Calculation", { ns: "${m}" })}}`,this.type="calculation",this.group="control",this.icon="PlusOutlined",this.color="#c3e584",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: "${m}" })}}`,this.fieldset={engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{getOptions:W.getOptions},required:!0,default:"formula.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(t,o,{form:n}){const{values:a}=n,{evaluate:i}=W.evaluators.get(a.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return i(l),""}catch(c){return O("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},transString:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":"解析字符串公式","x-reactions":[{dependencies:["engine"],fulfill:{state:{visible:"{{$deps[0] == `formula.js`}}"}}}]},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={renderEngineReference:mn},this.components={WorkflowVariableTextArea:at,RadioWithTooltip:Ne,ValueBlock:Ie}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return n&&!n.some(i=>i in Pe||Object.values(Pe).some(l=>l.has(i)))?null:{[a.value]:t,[a.label]:o}}useInitializers(t){var o,n;return{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Ie.Initializer,node:t,resultTitle:O("Calculation result")}}}const tl=e=>{const{editingConfig:t,setEditingConfig:o,data:n,workflow:a,children:i}=e,[l,c]=x.useState(!1),d=x.useMemo(()=>{const p=ae.cloneDeep(n.config);return A.createForm({initialValues:p,disabled:a.executed})},[n,a]),u=x.useCallback(p=>{o(p),p||d.reset()},[d]);return r.jsx(s.ActionContextProvider,{value:{visible:t,setVisible:u,formValueChanged:l,setFormValueChanged:c},children:r.jsx(s.FormProvider,{form:d,children:i})})};function ol(){return{form:A.useForm()}}function nl(){const e=A.useForm(),t=s.useAPIClient(),o=s.useActionContext(),{refresh:n}=s.useResourceActionContext(),a=he(),{workflow:i}=Y();return{run(){return P(this,null,function*(){var c,d;if(i.executed){b.message.error(O("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:a.id,values:{config:e.values}}),o.setFormValueChanged(!1),b.message.success("success"),n()})}}}const rl=e=>{const{data:t,instruction:o}=e,n=(o==null?void 0:o.group)===Ge;return r.jsxs("div",{className:s.css`
599
599
  display: flex;
600
600
  justify-content: space-between;
601
601
 
@@ -610,7 +610,7 @@ export default async function (
610
610
  code {
611
611
  font-weight: normal;
612
612
  }
613
- `,children:[r.jsxs("strong",{children:[n&&r.jsxs("span",{className:"deprecated-tag",children:["(",O("Deprecated"),") "]}),t.title]}),r.jsxs(b.Tooltip,{title:O("Variable key of node"),children:[r.jsx(b.Tag,{children:r.jsx("code",{children:`id: ${t.id}`})}),r.jsx(b.Tag,{children:r.jsx("code",{children:`key: ${t.key}`})})]})]})};function nl(e,t){return r.jsx(ol,{data:e,instruction:t})}const rl=e=>{const{instruction:t,data:o,detailText:n,workflow:a}=e;return{type:"void",properties:F(v({},t.view?{view:t.view}:{}),{button:{type:"void","x-content":n,"x-component":"Button","x-component-props":{type:"link",className:"workflow-node-config-button"}},[o.id]:{type:"void",title:nl(o,t),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Area","x-component-props":{stickyFooter:!0},properties:F(v({actions:a.executed?null:{type:"void","x-component":"ActionArea.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action","x-component-props":{useAction(){const{t:i}=s.useTranslation();return{run(){return P(this,null,function*(){const c=new Blob([JSON.stringify(o,(d,u)=>{if(!(d==="upstream"||d==="downstream"))return u},2)],{type:"application/json"});Ia(c,o.title+"-"+o.key+".json"),b.message.success(i("Operation succeeded"))})}}}}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:tl}}}}},t.description?{description:{type:"void","x-component":wo,"x-component-props":{label:O("Node type"),title:t.title,description:t.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
613
+ `,children:[r.jsxs("strong",{children:[n&&r.jsxs("span",{className:"deprecated-tag",children:["(",O("Deprecated"),") "]}),t.title]}),r.jsxs(b.Tooltip,{title:O("Variable key of node"),children:[r.jsx(b.Tag,{children:r.jsx("code",{children:`id: ${t.id}`})}),r.jsx(b.Tag,{children:r.jsx("code",{children:`key: ${t.key}`})})]})]})};function sl(e,t){return r.jsx(rl,{data:e,instruction:t})}const al=e=>{const{instruction:t,data:o,detailText:n,workflow:a}=e;return{type:"void",properties:F(v({},t.view?{view:t.view}:{}),{button:{type:"void","x-content":n,"x-component":"Button","x-component-props":{type:"link",className:"workflow-node-config-button"}},[o.id]:{type:"void",title:sl(o,t),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Area","x-component-props":{stickyFooter:!0},properties:F(v({actions:a.executed?null:{type:"void","x-component":"ActionArea.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action","x-component-props":{useAction(){const{t:i}=s.useTranslation();return{run(){return P(this,null,function*(){const c=new Blob([JSON.stringify(o,(d,u)=>{if(!(d==="upstream"||d==="downstream"))return u},2)],{type:"application/json"});Ta(c,o.title+"-"+o.key+".json"),b.message.success(i("Operation succeeded"))})}}}}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:nl}}}}},t.description?{description:{type:"void","x-component":wo,"x-component-props":{label:O("Node type"),title:t.title,description:t.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
614
614
  .ant-input,
615
615
  .ant-select,
616
616
  .ant-cascader-picker,
@@ -622,7 +622,7 @@ export default async function (
622
622
  min-width: 6em;
623
623
  }
624
624
  }
625
- `},properties:t.fieldset}})}})}},sl=e=>{const{instruction:t,data:o,detailText:n,workflow:a}=e,i=x.useMemo(()=>rl({instruction:t,data:o,detailText:n,workflow:a}),[t,o,n,a]);return r.jsx(s.SchemaComponent,{schema:i,components:t.components,scope:F(v({},t.scope),{useFormProviderProps:el})})},al=e=>{const{instruction:t,data:o,detailText:n,workflow:a,editingConfig:i,setEditingConfig:l}=e;return r.jsx(Ri,{editingConfig:i,setEditingConfig:l,data:o,workflow:a,children:r.jsx(sl,{instruction:t,data:o,detailText:n,workflow:a})})},il=s.createStyles(({css:e,token:t})=>({nodeClass:e`
625
+ `},properties:t.fieldset}})}})}},il=e=>{const{instruction:t,data:o,detailText:n,workflow:a}=e,i=x.useMemo(()=>al({instruction:t,data:o,detailText:n,workflow:a}),[t,o,n,a]);return r.jsx(s.SchemaComponent,{schema:i,components:t.components,scope:F(v({},t.scope),{useFormProviderProps:ol})})},ll=e=>{const{instruction:t,data:o,detailText:n,workflow:a,editingConfig:i,setEditingConfig:l}=e;return r.jsx(tl,{editingConfig:i,setEditingConfig:l,data:o,workflow:a,children:r.jsx(il,{instruction:t,data:o,detailText:n,workflow:a})})},cl=s.createStyles(({css:e,token:t})=>({nodeClass:e`
626
626
  flex-shrink: 0;
627
627
  display: flex;
628
628
  flex-direction: column;
@@ -655,7 +655,7 @@ export default async function (
655
655
  padding: 0;
656
656
  display: none;
657
657
  }
658
- `})),ll=()=>{var c;const e=s.useAPIClient(),{workflow:t,nodes:o,refresh:n}=(c=Y())!=null?c:{},a=he();if(!t)return null;const i=e.resource("flow_nodes");function l(){return P(this,null,function*(){var d;yield(d=i.moveUp)==null?void 0:d.call(i,{filterByTk:a.id}),n()})}return r.jsx(b.Button,{className:"workflow-node-drag-button",type:"text",shape:"circle",icon:r.jsx(H.HolderOutlined,{}),onClick:l})},cl=s.createStyles(({css:e,token:t})=>({dropdownClass:e`
658
+ `})),dl=()=>{var c;const e=s.useAPIClient(),{workflow:t,nodes:o,refresh:n}=(c=Y())!=null?c:{},a=he();if(!t)return null;const i=e.resource("flow_nodes");function l(){return P(this,null,function*(){var d;yield(d=i.moveUp)==null?void 0:d.call(i,{filterByTk:a.id}),n()})}return r.jsx(b.Button,{className:"workflow-node-drag-button",type:"text",shape:"circle",icon:r.jsx(H.HolderOutlined,{}),onClick:l})},ul=s.createStyles(({css:e,token:t})=>({dropdownClass:e`
659
659
  background-color: red;
660
660
  max-height: 50vh;
661
661
  overflow-y: auto;
@@ -677,7 +677,7 @@ export default async function (
677
677
  display: inline-flex;
678
678
  justify-content: center;
679
679
  align-items: center;
680
- `})),dl=()=>{var i;const{execution:e,setViewJob:t}=Y(),{jobs:o}=(i=he())!=null?i:{},{styles:n}=cl();if(!e)return null;if(!o.length)return r.jsx(tt,{className:n.nodeJobButtonClass,disabled:!0});const a=l=>{const{key:c}=l,d=o.find(u=>u.id===+c);t(d)};return o.length>1?r.jsx(b.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(tt,{statusMap:ot,status:l.status}),r.jsx("time",{children:W.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),className:n.dropdownClass,onClick:a},children:r.jsx(tt,{statusMap:ot,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(tt,{statusMap:ot,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})},ul=()=>{var u;const{t:e}=ee.useTranslation(),t=s.useAPIClient(),{workflow:o,nodes:n,refresh:a}=(u=Y())!=null?u:{},i=he(),{modal:l}=b.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function d(){return P(this,null,function*(){function p(){return P(this,null,function*(){var g;yield(g=c.destroy)==null?void 0:g.call(c,{filterByTk:i.id}),a()})}const f=n.filter(g=>g===i?!1:W.parse(g.config).parameters.filter(({key:D})=>D.startsWith(`$jobsMapByNodeKey.${i.key}.`)||D===`$jobsMapByNodeKey.${i.key}`).length);if(f.length){l.error({title:O("Can not delete"),content:O("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:f.map(g=>`#${g.id}`).join(", ")})});return}const h=!n.find(g=>g.upstream===i&&g.branchIndex!=null)?e("Are you sure you want to delete it?"):O("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:h,onOk:p})})}return r.jsx(b.Button,{className:"workflow-node-remove-button",type:"text",shape:"circle",icon:r.jsx(H.DeleteOutlined,{}),onClick:d})},pl=s.createStyles(({css:e,token:t})=>({nodePoint:e`
680
+ `})),pl=()=>{var i;const{execution:e,setViewJob:t}=Y(),{jobs:o}=(i=he())!=null?i:{},{styles:n}=ul();if(!e)return null;if(!o.length)return r.jsx(tt,{className:n.nodeJobButtonClass,disabled:!0});const a=l=>{const{key:c}=l,d=o.find(u=>u.id===+c);t(d)};return o.length>1?r.jsx(b.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(tt,{statusMap:ot,status:l.status}),r.jsx("time",{children:W.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),className:n.dropdownClass,onClick:a},children:r.jsx(tt,{statusMap:ot,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(tt,{statusMap:ot,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})},ml=()=>{var u;const{t:e}=ee.useTranslation(),t=s.useAPIClient(),{workflow:o,nodes:n,refresh:a}=(u=Y())!=null?u:{},i=he(),{modal:l}=b.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function d(){return P(this,null,function*(){function p(){return P(this,null,function*(){var g;yield(g=c.destroy)==null?void 0:g.call(c,{filterByTk:i.id}),a()})}const f=n.filter(g=>g===i?!1:W.parse(g.config).parameters.filter(({key:D})=>D.startsWith(`$jobsMapByNodeKey.${i.key}.`)||D===`$jobsMapByNodeKey.${i.key}`).length);if(f.length){l.error({title:O("Can not delete"),content:O("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:f.map(g=>`#${g.id}`).join(", ")})});return}const h=!n.find(g=>g.upstream===i&&g.branchIndex!=null)?e("Are you sure you want to delete it?"):O("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:h,onOk:p})})}return r.jsx(b.Button,{className:"workflow-node-remove-button",type:"text",shape:"circle",icon:r.jsx(H.DeleteOutlined,{}),onClick:d})},fl=s.createStyles(({css:e,token:t})=>({nodePoint:e`
681
681
  position: relative;
682
682
  display: flex;
683
683
  flex-direction: row;
@@ -801,16 +801,16 @@ export default async function (
801
801
  }
802
802
  }
803
803
  }
804
- `})),ml=e=>{const{color:t,icon:o,workflow:n,editingTitle:a,configuring:i,setEditingTitle:l,onChangeTitle:c}=e,d=he(),{styles:u}=pl(),[p,f]=x.useState(!1),y=n.executed||!p,h=(d==null?void 0:d.group)===Ge,g=()=>{i&&f(!0)},w=C=>{c(C.target.value),f(!1)};return r.jsxs("div",{className:s.cx(u.nodePoint,{deprecated:h,configuring:i}),children:[r.jsx(fl,{color:t,icon:o}),r.jsx(Lo,{className:`workflow-node-edit ${y?"node-executed":""}`,readOnly:y,value:a,onChange:C=>l(C.target.value),onBlur:w,onClick:g}),r.jsx(gl,{isExecuted:n.executed})]})},fl=e=>{const{color:t,icon:o}=e;return r.jsx("div",{className:"workflow-node-prefix",style:{backgroundColor:t},children:r.jsx(s.Icon,{type:o!=null?o:"dispatcher"})})},gl=e=>{const{isExecuted:t}=e;return r.jsx("div",{className:"workflow-node-suffix",children:t?r.jsx("div",{className:"icon-button",children:r.jsx(dl,{})}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"icon-button",children:r.jsx(ul,{})}),r.jsx("div",{className:"icon-button",children:r.jsx(ll,{})})]})})},it=e=>{var M,E;const{data:t,children:o}=e,n=s.useCompile(),a=s.useAPIClient(),{workflow:i,refresh:l}=(M=Y())!=null?M:{},{styles:c}=il(),u=s.usePlugin(re).instructions.get(t.type),p=i.executed?'{{t("View")}}':'{{t("Configure")}}',f=n(u.title),{color:y,icon:h}=u,[g,w]=x.useState((E=t.title)!=null?E:f),[C,D]=x.useState(!1),S=x.useCallback(function(N){return P(this,null,function*(){var K,q;const V=N||f;w(V),V!==t.title&&(yield(q=(K=a.resource("flow_nodes")).update)==null?void 0:q.call(K,{filterByTk:t.id,values:{title:V}}),l())})},[t]),I=x.useCallback(function(N){var K,q;if(N.target===N.currentTarget){D(!0);return}(q=(K=N.target)==null?void 0:K.classList)!=null&&q.contains("workflow-node-edit")&&D(!0);const V=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let G=N.target;G&&G!==N.currentTarget&&G!==document.documentElement;G=G.parentNode)if(Array.from(G.classList).some(j=>V.has(j))){D(!0),N.stopPropagation();return}},[]);return r.jsxs("div",{className:s.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{className:s.cx(c.nodeCardClass),role:"button","aria-label":`${f}-${g}`,onClick:I,children:[r.jsx(ml,{color:y,icon:h,workflow:i,editingTitle:g,configuring:C,setEditingTitle:w,onChangeTitle:S}),r.jsx(al,{instruction:u,data:t,detailText:p,workflow:i,editingConfig:C,setEditingConfig:D})]}),o]})},ne=new W.Registry;ne.register("equal",{name:"=",type:"boolean",group:"boolean"}),ne.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),ne.register("gt",{name:">",type:"boolean",group:"boolean"}),ne.register("gte",{name:"≥",type:"boolean",group:"boolean"}),ne.register("lt",{name:"<",type:"boolean",group:"boolean"}),ne.register("lte",{name:"≤",type:"boolean",group:"boolean"}),ne.register("add",{name:"+",type:"number",group:"number"}),ne.register("minus",{name:"-",type:"number",group:"number"}),ne.register("multiple",{name:"*",type:"number",group:"number"}),ne.register("divide",{name:"/",type:"number",group:"number"}),ne.register("mod",{name:"%",type:"number",group:"number"}),ne.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),ne.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),ne.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),ne.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),ne.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),ne.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),ne.register("concat",{name:`{{t("concat", { ns: "${m}" })}}`,type:"string",group:"string"}),ne.register("isEmpty",{name:`{{t("is empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),ne.register("isNotEmpty",{name:`{{t("is not empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),ne.register("isTrue",{name:`{{t("is true", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),ne.register("isFalse",{name:`{{t("is false", { ns: "${m}" })}}`,type:"boolean",group:"existence"});const hl=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${m}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${m}" })}}`},{value:"date",title:`{{t("Date", { ns: "${m}" })}}`},{value:"existence",title:`{{t("Existence check", { ns: "${m}" })}}`}];function fn(e){return Array.from(ne.getEntities()).filter(([t,o])=>o.group===e)}function yl({calculator:e,operands:t=[],onChange:o}){const[n,a]=x.useState(e),i=s.useCompile(),l=me(),c=u=>{const p=ne.get(u);return(p==null?void 0:p.group)==="existence"},d=u=>{a(u),o({operands:t,calculator:u})};return r.jsxs("fieldset",{className:s.css`
804
+ `})),gl=e=>{const{color:t,icon:o,workflow:n,editingTitle:a,configuring:i,setEditingTitle:l,onChangeTitle:c}=e,d=he(),{styles:u}=fl(),[p,f]=x.useState(!1),y=n.executed||!p,h=(d==null?void 0:d.group)===Ge,g=()=>{i&&f(!0)},w=C=>{c(C.target.value),f(!1)};return r.jsxs("div",{className:s.cx(u.nodePoint,{deprecated:h,configuring:i}),children:[r.jsx(hl,{color:t,icon:o}),r.jsx(Lo,{className:`workflow-node-edit ${y?"node-executed":""}`,readOnly:y,value:a,onChange:C=>l(C.target.value),onBlur:w,onClick:g}),r.jsx(yl,{isExecuted:n.executed})]})},hl=e=>{const{color:t,icon:o}=e;return r.jsx("div",{className:"workflow-node-prefix",style:{backgroundColor:t},children:r.jsx(s.Icon,{type:o!=null?o:"dispatcher"})})},yl=e=>{const{isExecuted:t}=e;return r.jsx("div",{className:"workflow-node-suffix",children:t?r.jsx("div",{className:"icon-button",children:r.jsx(pl,{})}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"icon-button",children:r.jsx(ml,{})}),r.jsx("div",{className:"icon-button",children:r.jsx(dl,{})})]})})},it=e=>{var M,E;const{data:t,children:o}=e,n=s.useCompile(),a=s.useAPIClient(),{workflow:i,refresh:l}=(M=Y())!=null?M:{},{styles:c}=cl(),u=s.usePlugin(re).instructions.get(t.type),p=i.executed?'{{t("View")}}':'{{t("Configure")}}',f=n(u.title),{color:y,icon:h}=u,[g,w]=x.useState((E=t.title)!=null?E:f),[C,D]=x.useState(!1),S=x.useCallback(function(N){return P(this,null,function*(){var K,q;const V=N||f;w(V),V!==t.title&&(yield(q=(K=a.resource("flow_nodes")).update)==null?void 0:q.call(K,{filterByTk:t.id,values:{title:V}}),l())})},[t]),I=x.useCallback(function(N){var K,q;if(N.target===N.currentTarget){D(!0);return}(q=(K=N.target)==null?void 0:K.classList)!=null&&q.contains("workflow-node-edit")&&D(!0);const V=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let G=N.target;G&&G!==N.currentTarget&&G!==document.documentElement;G=G.parentNode)if(Array.from(G.classList).some(j=>V.has(j))){D(!0),N.stopPropagation();return}},[]);return r.jsxs("div",{className:s.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{className:s.cx(c.nodeCardClass),role:"button","aria-label":`${f}-${g}`,onClick:I,children:[r.jsx(gl,{color:y,icon:h,workflow:i,editingTitle:g,configuring:C,setEditingTitle:w,onChangeTitle:S}),r.jsx(ll,{instruction:u,data:t,detailText:p,workflow:i,editingConfig:C,setEditingConfig:D})]}),o]})},ne=new W.Registry;ne.register("equal",{name:"=",type:"boolean",group:"boolean"}),ne.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),ne.register("gt",{name:">",type:"boolean",group:"boolean"}),ne.register("gte",{name:"≥",type:"boolean",group:"boolean"}),ne.register("lt",{name:"<",type:"boolean",group:"boolean"}),ne.register("lte",{name:"≤",type:"boolean",group:"boolean"}),ne.register("add",{name:"+",type:"number",group:"number"}),ne.register("minus",{name:"-",type:"number",group:"number"}),ne.register("multiple",{name:"*",type:"number",group:"number"}),ne.register("divide",{name:"/",type:"number",group:"number"}),ne.register("mod",{name:"%",type:"number",group:"number"}),ne.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),ne.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),ne.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),ne.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),ne.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),ne.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),ne.register("concat",{name:`{{t("concat", { ns: "${m}" })}}`,type:"string",group:"string"}),ne.register("isEmpty",{name:`{{t("is empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),ne.register("isNotEmpty",{name:`{{t("is not empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),ne.register("isTrue",{name:`{{t("is true", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),ne.register("isFalse",{name:`{{t("is false", { ns: "${m}" })}}`,type:"boolean",group:"existence"});const xl=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${m}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${m}" })}}`},{value:"date",title:`{{t("Date", { ns: "${m}" })}}`},{value:"existence",title:`{{t("Existence check", { ns: "${m}" })}}`}];function fn(e){return Array.from(ne.getEntities()).filter(([t,o])=>o.group===e)}function bl({calculator:e,operands:t=[],onChange:o}){const[n,a]=x.useState(e),i=s.useCompile(),l=me(),c=u=>{const p=ne.get(u);return(p==null?void 0:p.group)==="existence"},d=u=>{a(u),o({operands:t,calculator:u})};return r.jsxs("fieldset",{className:s.css`
805
805
  display: flex;
806
806
  gap: 0.5em;
807
807
  align-items: center;
808
808
  flex-wrap: wrap;
809
- `,children:[r.jsx(s.Variable.Input,{value:t[0],onChange:u=>o({calculator:n,operands:[u,t[1]]}),scope:l,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:n,onChange:d,placeholder:O("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:hl.filter(u=>!!fn(u.value).length).map(u=>r.jsx(b.Select.OptGroup,{label:i(u.title),children:fn(u.value).map(([p,{name:f}])=>r.jsx(b.Select.Option,{value:p,children:i(f)},p))},u.value))}),!c(n)&&r.jsx(s.Variable.Input,{value:t[1],onChange:u=>o({calculator:n,operands:[t[0],u]}),scope:l,useTypedConstant:!0})]})}function xl({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:a=[]}=e;return r.jsxs("div",{className:s.css`
809
+ `,children:[r.jsx(s.Variable.Input,{value:t[0],onChange:u=>o({calculator:n,operands:[u,t[1]]}),scope:l,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:n,onChange:d,placeholder:O("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:xl.filter(u=>!!fn(u.value).length).map(u=>r.jsx(b.Select.OptGroup,{label:i(u.title),children:fn(u.value).map(([p,{name:f}])=>r.jsx(b.Select.Option,{value:p,children:i(f)},p))},u.value))}),!c(n)&&r.jsx(s.Variable.Input,{value:t[1],onChange:u=>o({calculator:n,operands:[t[0],u]}),scope:l,useTypedConstant:!0})]})}function vl({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:a=[]}=e;return r.jsxs("div",{className:s.css`
810
810
  display: flex;
811
811
  position: relative;
812
812
  margin: 0.5em 0;
813
- `,children:[e.group?r.jsx(gn,{value:e.group,onChange:i=>t(F(v({},e),{group:i}))}):r.jsx(yl,{operands:a,calculator:n,onChange:t}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(H.CloseCircleOutlined,{})})]})}function gn({value:e,onChange:t}){const{t:o}=ee.useTranslation(),{type:n="and",calculations:a=[]}=e;function i(){t(F(v({},e),{calculations:[...a,{not:!1,calculator:"equal"}]}))}function l(){t(F(v({},e),{calculations:[...a,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(u){a.splice(u,1),t(F(v({},e),{calculations:[...a]}))}function d(u,p){a.splice(u,1,p),t(F(v({},e),{calculations:[...a]}))}return r.jsxs("div",{className:s.cx("node-type-condition-group",s.css`
813
+ `,children:[e.group?r.jsx(gn,{value:e.group,onChange:i=>t(F(v({},e),{group:i}))}):r.jsx(bl,{operands:a,calculator:n,onChange:t}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(H.CloseCircleOutlined,{})})]})}function gn({value:e,onChange:t}){const{t:o}=ee.useTranslation(),{type:n="and",calculations:a=[]}=e;function i(){t(F(v({},e),{calculations:[...a,{not:!1,calculator:"equal"}]}))}function l(){t(F(v({},e),{calculations:[...a,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(u){a.splice(u,1),t(F(v({},e),{calculations:[...a]}))}function d(u,p){a.splice(u,1,p),t(F(v({},e),{calculations:[...a]}))}return r.jsxs("div",{className:s.cx("node-type-condition-group",s.css`
814
814
  position: relative;
815
815
  width: 100%;
816
816
  .node-type-condition-group {
@@ -829,14 +829,14 @@ export default async function (
829
829
  width: auto;
830
830
  min-width: 6em;
831
831
  }
832
- `,children:r.jsxs(ee.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:u=>t(F(v({},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:a.map((u,p)=>r.jsx(xl,{value:u,onChange:d.bind(this,p),onRemove:()=>c(p)},`${u.calculator}_${p}`))}),r.jsxs("div",{className:s.css`
832
+ `,children:r.jsxs(ee.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:u=>t(F(v({},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:a.map((u,p)=>r.jsx(vl,{value:u,onChange:d.bind(this,p),onRemove:()=>c(p)},`${u.calculator}_${p}`))}),r.jsxs("div",{className:s.css`
833
833
  button {
834
834
  padding: 0;
835
835
  &:not(:last-child) {
836
836
  margin-right: 1em;
837
837
  }
838
838
  }
839
- `,children:[r.jsx(b.Button,{type:"link",onClick:i,children:o("Add condition")}),r.jsx(b.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function bl({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(gn,{value:o.group,onChange:n=>t(F(v({},o),{group:n}))})}class vl extends oe{constructor(){super(...arguments),this.title=`{{t("Condition", { ns: "${m}" })}}`,this.type="condition",this.group="control",this.icon="QuestionOutlined",this.color="#1ab287",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: "${m}" })}}`,this.fieldset={rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${m}" })}}`}],...Array.from(W.evaluators.getEntities()).filter(([t])=>["math.js","formula.js"].includes(t))].reduce((t,[o,n])=>t.concat(v({value:o},n)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${m}" })}}`,"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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-validator"(t,o,{form:n}){const{values:a}=n,{evaluate:i}=W.evaluators.get(a.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return i(l),""}catch(c){return O("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.options=[{label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`,key:"branch",value:{rejectOnFalse:!1}}],this.scope={renderEngineReference:mn,useWorkflowVariableOptions:me},this.components={CalculationConfig:bl,WorkflowVariableTextArea:at,RadioWithTooltip:Ne}}Component({data:t}){const{t:o}=ee.useTranslation(),{nodes:n}=Y(),{styles:a}=we(),{id:i,config:{rejectOnFalse:l}}=t,c=n.find(u=>u.upstreamId===i&&u.branchIndex===1),d=n.find(u=>u.upstreamId===i&&u.branchIndex===0);return r.jsx(it,{data:t,children:l?null:r.jsxs("div",{className:a.nodeSubtreeClass,children:[r.jsxs("div",{className:a.branchBlockClass,children:[r.jsx(je,{from:t,entry:c,branchIndex:1}),r.jsx(je,{from:t,entry:d,branchIndex:0})]}),r.jsxs("div",{className:a.conditionClass,children:[r.jsx("span",{style:{right:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("Yes")}),r.jsx("span",{style:{left:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("No")})]})]})})}}function wl(e){const{getCollectionFields:t}=s.useCollectionManager_deprecated(),{path:o}=A.useField(),n=o.segments[o.segments.length-1],{values:a}=A.useForm(),[i,l]=s.parseCollectionName(a==null?void 0:a.collection),c=t(l,i),{type:d}=c.find(f=>f.name===n),u=Array.isArray(e.value)?e.value.join(","):e.value;function p(f){const y=f.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(d)?y:y.split(/[,\s]+/))}return r.jsx(b.Input,F(v({},e),{value:u,onChange:p}))}const ro=A.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:a}=s.useToken(),{t:i}=ee.useTranslation(),l=s.useCompile(),c=A.useForm(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),u=me(),{values:p}=c,[f,y]=s.parseCollectionName(p==null?void 0:p.collection),h=d(y,f).filter(S=>S.uiSchema),g=n?h.filter(n.bind(p)):h,w=x.useMemo(()=>g.filter(S=>!e||!(S.name in e)),[g,e]),C=t||c.disabled,D=x.useMemo(()=>({onClick:({key:S})=>{o(F(v({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:w.map(S=>{var I,M;return{key:S.name,label:l((M=(I=S.uiSchema)==null?void 0:I.title)!=null?M:S.name)}})}),[o,w,e]);return r.jsx("fieldset",{className:s.css`
839
+ `,children:[r.jsx(b.Button,{type:"link",onClick:i,children:o("Add condition")}),r.jsx(b.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function wl({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(gn,{value:o.group,onChange:n=>t(F(v({},o),{group:n}))})}class Cl extends oe{constructor(){super(...arguments),this.title=`{{t("Condition", { ns: "${m}" })}}`,this.type="condition",this.group="control",this.icon="QuestionOutlined",this.color="#1ab287",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: "${m}" })}}`,this.fieldset={rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${m}" })}}`}],...Array.from(W.evaluators.getEntities()).filter(([t])=>["math.js","formula.js"].includes(t))].reduce((t,[o,n])=>t.concat(v({value:o},n)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${m}" })}}`,"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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-validator"(t,o,{form:n}){const{values:a}=n,{evaluate:i}=W.evaluators.get(a.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return i(l),""}catch(c){return O("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.options=[{label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`,key:"branch",value:{rejectOnFalse:!1}}],this.scope={renderEngineReference:mn,useWorkflowVariableOptions:me},this.components={CalculationConfig:wl,WorkflowVariableTextArea:at,RadioWithTooltip:Ne}}Component({data:t}){const{t:o}=ee.useTranslation(),{nodes:n}=Y(),{styles:a}=we(),{id:i,config:{rejectOnFalse:l}}=t,c=n.find(u=>u.upstreamId===i&&u.branchIndex===1),d=n.find(u=>u.upstreamId===i&&u.branchIndex===0);return r.jsx(it,{data:t,children:l?null:r.jsxs("div",{className:a.nodeSubtreeClass,children:[r.jsxs("div",{className:a.branchBlockClass,children:[r.jsx(je,{from:t,entry:c,branchIndex:1}),r.jsx(je,{from:t,entry:d,branchIndex:0})]}),r.jsxs("div",{className:a.conditionClass,children:[r.jsx("span",{style:{right:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("Yes")}),r.jsx("span",{style:{left:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("No")})]})]})})}}function kl(e){const{getCollectionFields:t}=s.useCollectionManager_deprecated(),{path:o}=A.useField(),n=o.segments[o.segments.length-1],{values:a}=A.useForm(),[i,l]=s.parseCollectionName(a==null?void 0:a.collection),c=t(l,i),{type:d}=c.find(f=>f.name===n),u=Array.isArray(e.value)?e.value.join(","):e.value;function p(f){const y=f.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(d)?y:y.split(/[,\s]+/))}return r.jsx(b.Input,F(v({},e),{value:u,onChange:p}))}const ro=A.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:a}=s.useToken(),{t:i}=ee.useTranslation(),l=s.useCompile(),c=A.useForm(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),u=me(),{values:p}=c,[f,y]=s.parseCollectionName(p==null?void 0:p.collection),h=d(y,f).filter(S=>S.uiSchema),g=n?h.filter(n.bind(p)):h,w=x.useMemo(()=>g.filter(S=>!e||!(S.name in e)),[g,e]),C=t||c.disabled,D=x.useMemo(()=>({onClick:({key:S})=>{o(F(v({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:w.map(S=>{var I,M;return{key:S.name,label:l((M=(I=S.uiSchema)==null?void 0:I.title)!=null?M:S.name)}})}),[o,w,e]);return r.jsx("fieldset",{className:s.css`
840
840
  margin-top: 0.5em;
841
841
 
842
842
  > .ant-formily-item {
@@ -846,7 +846,7 @@ export default async function (
846
846
  line-height: 32px;
847
847
  }
848
848
  }
849
- `,children:g.length?r.jsxs(s.CollectionProvider_deprecated,{name:y,dataSource:f,children:[g.filter(S=>e&&S.name in e).map(S=>{var M,E;const I=["belongsTo","hasOne","hasMany","belongsToMany"].includes(S.type)?wl:s.CollectionField;return r.jsxs(b.Form.Item,{label:l((E=(M=S.uiSchema)==null?void 0:M.title)!=null?E:S.name),labelAlign:"left",className:s.css`
849
+ `,children:g.length?r.jsxs(s.CollectionProvider_deprecated,{name:y,dataSource:f,children:[g.filter(S=>e&&S.name in e).map(S=>{var M,E;const I=["belongsTo","hasOne","hasMany","belongsToMany"].includes(S.type)?kl:s.CollectionField;return r.jsxs(b.Form.Item,{label:l((E=(M=S.uiSchema)==null?void 0:M.title)!=null?E:S.name),labelAlign:"left",className:s.css`
850
850
  .ant-form-item-control-input-content {
851
851
  display: flex;
852
852
  }
@@ -855,13 +855,13 @@ export default async function (
855
855
  `},"x-component":"CollectionFieldset"},Qe={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=A.useForm(),[t,o]=s.parseCollectionName(e==null?void 0:e.collection);return{options:s.useCollectionFilterOptions(o,t),className:s.css`
856
856
  position: relative;
857
857
  width: 100%;
858
- `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},hn={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"}}},yn={type:"void",properties:{paginate:{type:"boolean",title:T("Pagination"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":T("Custom pagination(page number and count cannot be empty)"),default:!1},pagination:{type:"void","x-decorator":"FormItem","x-component":"Grid","x-reactions":[{dependencies:[".paginate"],fulfill:{state:{hidden:"{{ !$deps[0] }}"}}}],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}}}}}}}}},lt={type:"array",title:`{{t("Preload associations", { ns: "${m}" })}}`,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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=A.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class Cl extends oe{constructor(){super(...arguments),this.title=`{{t("Create record", { ns: "${m}" })}}`,this.type="create",this.group="collection",this.icon="FileAddOutlined",this.color="#07fa0f",this.description=`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:so,appends:lt}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={CollectionFieldset:ro}}useVariables({key:t,title:o,config:n},a){var d,u;const i=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=fe(F(v({appends:[t,...((u=(d=n.params)==null?void 0:d.appends)==null?void 0:u.map(p=>`${t}.${p}`))||[]]},a),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:i,getCollectionFields:l}));return c}useInitializers(t){var o,n;return t.config.collection?{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}:null}}class kl extends oe{constructor(){super(...arguments),this.title='{{t("Delete record")}}',this.type="destroy",this.group="collection",this.icon="ClockCircleOutlined",this.color="#fa0b07",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: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:F(v({},Qe),{"x-validator"(t){return nt(t)?"":O("Please add at least one condition")}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae}}}class Sl extends oe{constructor(){super(...arguments),this.title=`{{t("End process", { ns: "${m}" })}}`,this.type="end",this.group="control",this.icon="LogoutOutlined",this.color="#2659a1",this.description=`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`,this.fieldset={endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${m}" })}}`,value:Ce.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:Ce.FAILED}],required:!0,default:Ce.RESOLVED},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.end=!0}}class Al extends oe{constructor(){super(...arguments),this.title=`{{t("Query record", { ns: "${m}" })}}`,this.type="query",this.group="collection",this.icon="FileSearchOutlined",this.color="#55e2d1",this.description=`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${m}" })}}`},isTree:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow query for tree data", { ns: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Qe,sort:hn,pagination:yn,appends:lt},"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: "${m}" })}}`}},this.scope={useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const t=s.useCompile(),{getCollectionFields:o,getInterface:n}=s.useCollectionManager_deprecated(),{values:a}=A.useForm();return o(a.collection).filter(l=>{if(!l.interface)return!1;const c=n(l.interface);return!!(c!=null&&c.sortable)}).map(l=>{var c,d;return{value:l.name,label:(c=l==null?void 0:l.uiSchema)!=null&&c.title?t((d=l==null?void 0:l.uiSchema)==null?void 0:d.title):l.name}})}},this.components={ArrayItems:W.ArrayItems,FilterDynamicComponent:Ae,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:ke}}useVariables({key:t,title:o,config:n},a){var d,u;const i=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=fe(F(v({appends:[t,...((u=(d=n.params)==null?void 0:d.appends)==null?void 0:u.map(p=>`${t}.${p}`))||[]]},a),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:i,getCollectionFields:l}));return c}useInitializers(t){var o,n;return!t.config.collection||t.config.multiple?null:{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}}}class Il extends oe{constructor(){super(...arguments),this.title=`{{t("Select record", { ns: "${m}" })}}`,this.type="select",this.group="collection",this.icon="SelectOutlined",this.color="#a47cef",this.description=`{{t("Select records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${m}" })}}`},isTree:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow query for tree data", { ns: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Qe,sort:hn,pagination:yn,summary:{type:"array",title:`{{t("Select fields to display in the collection", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CollectionTreeSelect","x-component-props":{title:"Preload associations",needLeaf:!0,useCollection(){const{values:t}=A.useForm();return t==null?void 0:t.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}},"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: "${m}" })}}`}},this.scope={useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const t=s.useCompile(),{getCollectionFields:o,getInterface:n}=s.useCollectionManager_deprecated(),{values:a}=A.useForm();return o(a.collection).filter(l=>{if(!l.interface)return!1;const c=n(l.interface);return!!(c!=null&&c.sortable)}).map(l=>{var c,d;return{value:l.name,label:(c=l==null?void 0:l.uiSchema)!=null&&c.title?t((d=l==null?void 0:l.uiSchema)==null?void 0:d.title):l.name}})}},this.components={ArrayItems:W.ArrayItems,FilterDynamicComponent:Ae,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:ke}}useVariables({key:t,title:o,config:n},a){var d,u;const i=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=fe(F(v({appends:[t,...((u=(d=n.params)==null?void 0:d.appends)==null?void 0:u.map(p=>`${t}.${p}`))||[]]},a),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:i,getCollectionFields:l}));return c}useInitializers(t){var o,n;return!t.config.collection||t.config.multiple?null:{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}}}function Fl(o){var n=o,{onChange:e}=n,t=Q(n,["onChange"]);const{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=A.useForm(),{collection:l}=i.values,c=a(l),d=A.useField();function u({target:p}){const f=d.query(".values").take();if(!f)return;const y=c.reduce((h,g)=>(g.name in f.value&&(p.value||![].includes(g.type))&&(h[g.name]=f.value[g.name]),h),{});i.setValuesIn("params.values",y),e(p.value)}return r.jsx(Ne,F(v({},t),{onChange:u}))}class Tl extends oe{constructor(){super(...arguments),this.title=`{{t("Update record", { ns: "${m}" })}}`,this.type="update",this.group="collection",this.icon="SignatureOutlined",this.color="#f4952f",this.description=`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,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, will not record audit logs, and may not update association fields.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,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: "${m}" })}}`}]},default:!1},filter:F(v({},Qe),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return nt(t)?"":O("Please add at least one condition")}}),values:F(v({},so),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae,CollectionFieldset:ro,IndividualHooksRadioWithTooltip:Fl}}}function Nl(o){var n=o,{onChange:e}=n,t=Q(n,["onChange"]);const{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=A.useForm(),{collection:l}=i.values,c=a(l),d=A.useField();function u({target:p}){const f=d.query(".values").take();if(!f)return;const y=c.reduce((h,g)=>(g.name in f.value&&(p.value||![].includes(g.type))&&(h[g.name]=f.value[g.name]),h),{});i.setValuesIn("params.values",y),e(p.value)}return r.jsx(Ne,F(v({},t),{onChange:u}))}class Dl extends oe{constructor(){super(...arguments),this.title=`{{t("Update or create record", { ns: "${m}" })}}`,this.type="updateorcreate",this.group="collection",this.icon="FileSyncOutlined",this.color="#f6f66a",this.description=`{{t("Update or create record, if no matching record is found, a new record will be created, with the ability to assign values to fields using variables from upstream nodes.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,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, will not record audit logs, and may not update association fields.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,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: "${m}" })}}`}]},default:!1},filter:F(v({},Qe),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return nt(t)?"":O("Please add at least one condition")}}),values:F(v({},so),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae,CollectionFieldset:ro,IndividualHooksRadioWithTooltip:Nl}}}const Ol=new s.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:s.SecondConFirm},{name:"assignFieldValues",Component:s.AssignedFieldValues},{name:"skipRequiredValidation",Component:s.SkipValidation},{name:"afterSuccessfulSubmission",Component:s.AfterSuccess,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:s.WorkflowConfig},{name:"delete",sort:100,Component:s.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}]}),ze={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Pl=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:ze.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:ze.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:ze.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:ze.DELETED}];class El extends Re{constructor(){super(...arguments),this.title=`{{t("Collection event", { ns: "${m}" })}}`,this.description=`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"x-reactions":[...ue["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"blacklist",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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${m}" })}}`,className:"auto-width"},enum:Pl,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},blacklist:{type:"array",title:`{{t("Changed fields - blacklist", { ns: "${m}" })}}`,description:`{{t("Triggered only if none of the selected fields changes. When record is added or deleted, this field has no effect.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${ze.UPDATED})}}`}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${m}" })}}`,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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${ze.UPDATED})}}`}}}]},condition:F(v({},Qe),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:F(v({},lt),{"x-reactions":[...lt["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${ze.DELETED})}}`}}}]})},this.scope={useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:zo},this.components={FieldsSelect:rt}}useVariables(t,o){var c;const n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:O("Trigger data")}}];return fe(F(v({appends:["data",...((c=t.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},o),{fields:i,compile:n,getCollectionFields:a}))}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const qe={STATIC:0,DATE_FIELD:1};function Ml(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function xn({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=ee.useTranslation(),[a,i]=x.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:s.css`
858
+ `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},hn={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"}}},yn={type:"void",properties:{paginate:{type:"boolean",title:T("Pagination"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":T("Custom pagination(page number and count cannot be empty)"),default:!1},pagination:{type:"void","x-decorator":"FormItem","x-component":"Grid","x-reactions":[{dependencies:[".paginate"],fulfill:{state:{hidden:"{{ !$deps[0] }}"}}}],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}}}}}}}}},lt={type:"array",title:`{{t("Preload associations", { ns: "${m}" })}}`,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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=A.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class Sl extends oe{constructor(){super(...arguments),this.title=`{{t("Create record", { ns: "${m}" })}}`,this.type="create",this.group="collection",this.icon="FileAddOutlined",this.color="#07fa0f",this.description=`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:so,appends:lt}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={CollectionFieldset:ro}}useVariables({key:t,title:o,config:n},a){var d,u;const i=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=fe(F(v({appends:[t,...((u=(d=n.params)==null?void 0:d.appends)==null?void 0:u.map(p=>`${t}.${p}`))||[]]},a),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:i,getCollectionFields:l}));return c}useInitializers(t){var o,n;return t.config.collection?{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}:null}}class Al extends oe{constructor(){super(...arguments),this.title='{{t("Delete record")}}',this.type="destroy",this.group="collection",this.icon="ClockCircleOutlined",this.color="#fa0b07",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: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:F(v({},Qe),{"x-validator"(t){return nt(t)?"":O("Please add at least one condition")}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae}}}class Il extends oe{constructor(){super(...arguments),this.title=`{{t("End process", { ns: "${m}" })}}`,this.type="end",this.group="control",this.icon="LogoutOutlined",this.color="#2659a1",this.description=`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`,this.fieldset={endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${m}" })}}`,value:Ce.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:Ce.FAILED}],required:!0,default:Ce.RESOLVED},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.end=!0}}class Fl extends oe{constructor(){super(...arguments),this.title=`{{t("Query record", { ns: "${m}" })}}`,this.type="query",this.group="collection",this.icon="FileSearchOutlined",this.color="#55e2d1",this.description=`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${m}" })}}`},isTree:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow query for tree data", { ns: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Qe,sort:hn,pagination:yn,appends:lt},"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: "${m}" })}}`}},this.scope={useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const t=s.useCompile(),{getCollectionFields:o,getInterface:n}=s.useCollectionManager_deprecated(),{values:a}=A.useForm();return o(a.collection).filter(l=>{if(!l.interface)return!1;const c=n(l.interface);return!!(c!=null&&c.sortable)}).map(l=>{var c,d;return{value:l.name,label:(c=l==null?void 0:l.uiSchema)!=null&&c.title?t((d=l==null?void 0:l.uiSchema)==null?void 0:d.title):l.name}})}},this.components={ArrayItems:W.ArrayItems,FilterDynamicComponent:Ae,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:ke}}useVariables({key:t,title:o,config:n},a){var d,u;const i=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=fe(F(v({appends:[t,...((u=(d=n.params)==null?void 0:d.appends)==null?void 0:u.map(p=>`${t}.${p}`))||[]]},a),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:i,getCollectionFields:l}));return c}useInitializers(t){var o,n;return!t.config.collection||t.config.multiple?null:{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}}}class Tl extends oe{constructor(){super(...arguments),this.title=`{{t("Select record", { ns: "${m}" })}}`,this.type="select",this.group="collection",this.icon="SelectOutlined",this.color="#a47cef",this.description=`{{t("Select records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${m}" })}}`},isTree:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow query for tree data", { ns: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Qe,sort:hn,pagination:yn,summary:{type:"array",title:`{{t("Select fields to display in the collection", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CollectionTreeSelect","x-component-props":{title:"Preload associations",needLeaf:!0,useCollection(){const{values:t}=A.useForm();return t==null?void 0:t.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}},"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: "${m}" })}}`}},this.scope={useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const t=s.useCompile(),{getCollectionFields:o,getInterface:n}=s.useCollectionManager_deprecated(),{values:a}=A.useForm();return o(a.collection).filter(l=>{if(!l.interface)return!1;const c=n(l.interface);return!!(c!=null&&c.sortable)}).map(l=>{var c,d;return{value:l.name,label:(c=l==null?void 0:l.uiSchema)!=null&&c.title?t((d=l==null?void 0:l.uiSchema)==null?void 0:d.title):l.name}})}},this.components={ArrayItems:W.ArrayItems,FilterDynamicComponent:Ae,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:ke}}useVariables({key:t,title:o,config:n},a){var d,u;const i=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=fe(F(v({appends:[t,...((u=(d=n.params)==null?void 0:d.appends)==null?void 0:u.map(p=>`${t}.${p}`))||[]]},a),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:i,getCollectionFields:l}));return c}useInitializers(t){var o,n;return!t.config.collection||t.config.multiple?null:{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}}}function Nl(o){var n=o,{onChange:e}=n,t=Q(n,["onChange"]);const{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=A.useForm(),{collection:l}=i.values,c=a(l),d=A.useField();function u({target:p}){const f=d.query(".values").take();if(!f)return;const y=c.reduce((h,g)=>(g.name in f.value&&(p.value||![].includes(g.type))&&(h[g.name]=f.value[g.name]),h),{});i.setValuesIn("params.values",y),e(p.value)}return r.jsx(Ne,F(v({},t),{onChange:u}))}class Dl extends oe{constructor(){super(...arguments),this.title=`{{t("Update record", { ns: "${m}" })}}`,this.type="update",this.group="collection",this.icon="SignatureOutlined",this.color="#f4952f",this.description=`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,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, will not record audit logs, and may not update association fields.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,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: "${m}" })}}`}]},default:!1},filter:F(v({},Qe),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return nt(t)?"":O("Please add at least one condition")}}),values:F(v({},so),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae,CollectionFieldset:ro,IndividualHooksRadioWithTooltip:Nl}}}function Ol(o){var n=o,{onChange:e}=n,t=Q(n,["onChange"]);const{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=A.useForm(),{collection:l}=i.values,c=a(l),d=A.useField();function u({target:p}){const f=d.query(".values").take();if(!f)return;const y=c.reduce((h,g)=>(g.name in f.value&&(p.value||![].includes(g.type))&&(h[g.name]=f.value[g.name]),h),{});i.setValuesIn("params.values",y),e(p.value)}return r.jsx(Ne,F(v({},t),{onChange:u}))}class Pl extends oe{constructor(){super(...arguments),this.title=`{{t("Update or create record", { ns: "${m}" })}}`,this.type="updateorcreate",this.group="collection",this.icon="FileSyncOutlined",this.color="#f6f66a",this.description=`{{t("Update or create record, if no matching record is found, a new record will be created, with the ability to assign values to fields using variables from upstream nodes.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,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, will not record audit logs, and may not update association fields.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,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: "${m}" })}}`}]},default:!1},filter:F(v({},Qe),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return nt(t)?"":O("Please add at least one condition")}}),values:F(v({},so),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae,CollectionFieldset:ro,IndividualHooksRadioWithTooltip:Ol}}}const El=new s.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:s.SecondConFirm},{name:"assignFieldValues",Component:s.AssignedFieldValues},{name:"skipRequiredValidation",Component:s.SkipValidation},{name:"afterSuccessfulSubmission",Component:s.AfterSuccess,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:s.WorkflowConfig},{name:"delete",sort:100,Component:s.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}]}),ze={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Ml=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:ze.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:ze.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:ze.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:ze.DELETED}];class $l extends Re{constructor(){super(...arguments),this.title=`{{t("Collection event", { ns: "${m}" })}}`,this.description=`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"x-reactions":[...ue["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"blacklist",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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${m}" })}}`,className:"auto-width"},enum:Ml,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},blacklist:{type:"array",title:`{{t("Changed fields - blacklist", { ns: "${m}" })}}`,description:`{{t("Triggered only if none of the selected fields changes. When record is added or deleted, this field has no effect.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${ze.UPDATED})}}`}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${m}" })}}`,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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${ze.UPDATED})}}`}}}]},condition:F(v({},Qe),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:F(v({},lt),{"x-reactions":[...lt["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${ze.DELETED})}}`}}}]})},this.scope={useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:zo},this.components={FieldsSelect:rt}}useVariables(t,o){var c;const n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:O("Trigger data")}}];return fe(F(v({appends:["data",...((c=t.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},o),{fields:i,compile:n,getCollectionFields:a}))}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const qe={STATIC:0,DATE_FIELD:1};function Bl(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function xn({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=ee.useTranslation(),[a,i]=x.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:s.css`
859
859
  display: flex;
860
860
  gap: 0.5em;
861
- `,children:[r.jsx(rt,{value:o.field,onChange:l=>t(F(v({},o),{field:l})),filter:Ml,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(b.Select,{value:a,onChange:l=>{i(l),t(F(v({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:O("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,a?r.jsxs(r.Fragment,{children:[r.jsx(b.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(F(v({},o),{offset:(l!=null?l:0)*a}))}),r.jsx(b.Select,{value:o.unit||864e5,onChange:l=>t(F(v({},o),{unit:l})),options:[{value:864e5,label:O("Days")},{value:36e5,label:O("Hours")},{value:6e4,label:O("Minutes")},{value:1e3,label:O("Seconds")}],className:"auto-width"})]}):null]})}function $l({value:e,onChange:t}){const{t:o}=ve(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:s.css`
861
+ `,children:[r.jsx(rt,{value:o.field,onChange:l=>t(F(v({},o),{field:l})),filter:Bl,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(b.Select,{value:a,onChange:l=>{i(l),t(F(v({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:O("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,a?r.jsxs(r.Fragment,{children:[r.jsx(b.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(F(v({},o),{offset:(l!=null?l:0)*a}))}),r.jsx(b.Select,{value:o.unit||864e5,onChange:l=>t(F(v({},o),{unit:l})),options:[{value:864e5,label:O("Days")},{value:36e5,label:O("Hours")},{value:6e4,label:O("Minutes")},{value:1e3,label:O("Seconds")}],className:"auto-width"})]}):null]})}function Vl({value:e,onChange:t}){const{t:o}=ve(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:s.css`
862
862
  display: flex;
863
863
  gap: 0.5em;
864
- `,children:[r.jsxs(b.Select,{value:n,onChange:a=>{t(a?a==="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(xn,{value:e,onChange:t}):null,n==="date"?r.jsx(b.DatePicker,{showTime:!0,value:mt(e),onChange:a=>{t(a?a.toDate():null)}}):null]})}var ge=function(){return ge=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var a in t=arguments[o])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},ge.apply(this,arguments)};function bn(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 a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(o[n[a]]=e[n[a]])}return o}function At(e,t,o){if(o||arguments.length===2)for(var n,a=0,i=t.length;a<i;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}var Bl=[{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 * * * *"}],Ue=[{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"]}],Z={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 vn(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function It(e){return e.sort(function(t,o){return t-o}),e}function wn(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function Se(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 Cn(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||Z.errorInvalidCron})}function Ft(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function kn(e,t,o,n,a,i,l,c,d,u,p,f,y,h){o&&o(void 0),t(!1);var g=!1;if(!e){if(n==="always"||i&&n==="for-default-value")return;g=!0}if(!g){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var w=Bl.find(function(S){return S.name===e});w&&(e=w.value)}try{var C=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var I=S.replace(/\s+/g," ").trim().split(" ");if(I.length===5)return I.map(function(M,E){return function(N,V){if(N==="*"||N==="*/1")return[];var K=It(wn(Fn(function(G,j,X){if(X){G=G.toUpperCase();for(var B=0;B<X.length;B++)G=G.replace(X[B],"".concat(B+j))}return G}(N,V.min,V.alt).split(",").map(function(G){var j,X=G.split("/");if(X.length>2)throw new Error('Invalid value "'.concat(N,' for "').concat(V.type,'"'));var B=X[0],L=X[1];j=B==="*"?vn(V.min,V.max):function(J,_,R){var z=J.split("-");if(z.length===1){var de=Ft(z[0]);if(isNaN(de))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));return[de]}if(z.length===2){var te=Ft(z[0]),$e=Ft(z[1]);if(isNaN(te)||isNaN($e))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));if($e<te)throw new Error('Max range is less than min range in "'.concat(J,'" for ').concat(R.type));return vn(te,$e)}throw new Error('Invalid value "'.concat(J,'" for ').concat(R.type))}(B,N,V);var $=function(J,_){if(J!==void 0){var R=Ft(J);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(J,'" for ').concat(_.type));return R}}(L,V),U=function(J,_){if(_){var R=J[0];J=J.filter(function(z){return z%_==R%_||z===R})}return J}(j,$);return U}).flat(),V))),q=Tn(K,V);if(q!==void 0)throw new Error('Value "'.concat(q,'" out of range for ').concat(V.type));return K.length===V.total?[]:K}(M,Ue[E])});throw new Error("Invalid cron string format")}(e),D=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"}(C);h(D),d(C[0]),u(C[1]),p(C[2]),f(C[3]),y(C[4])}catch(S){g=!0}}g&&(a.current=e,t(!0),Cn(o,l))}function Sn(e,t,o,n,a,i,l){if(e==="reboot")return"@reboot";var c=function(d,u){return d.map(function(p,f){var y=Ue[f];return An(In(p,y),y,u)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&a?a:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function An(e,t,o,n,a){var i="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)i="*";else{var l=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);i=l&&function(c,d){for(var u=1;u<c.length;u++){var p=c[u-1];if(c[u]-p!==d)return!1}return!0}(e,l)?function(c,d,u){var p=Nn(c),f=Dn(c),y=c.length===(f-p)/u+1;return!!(p===d.min&&f+u>d.max&&y)}(e,t,l)?"*/".concat(l):"".concat(Ze(Nn(e),t,o,n,a),"-").concat(Ze(Dn(e),t,o,n,a),"/").concat(l):function(c){var d=[],u=null;return c.forEach(function(p,f,y){p!==y[f+1]-1?u!==null?(d.push([u,p]),u=null):d.push(p):u===null&&(u=p)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ze(c[0],t,o,n,a),"-").concat(Ze(c[1],t,o,n,a)):Ze(c,t,o,n,a)}).join(",")}return i}function Ze(e,t,o,n,a){var i=e.toString(),l=t.type,c=t.alt,d=t.min,u=n&&(n===!0||n.includes(l)),p=a==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?i=c[e-d]:e<10&&(u||p)&&(i=i.padStart(2,"0")),l==="hours"&&a==="12-hour-clock"){var f=e>=12?"PM":"AM",y=e%12||12;y<10&&u&&(y=y.toString().padStart(2,"0")),i="".concat(y).concat(f)}return i}function In(e,t){var o=It(wn(Fn(e,t)));if(o.length===0)return o;var n=Tn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function Fn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function Tn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function Nn(e){return e[0]}function Dn(e){return e[e.length-1]}function ct(e){var t=e.value,o=e.grid,n=o===void 0||o,a=e.optionsList,i=e.setValue,l=e.locale,c=e.className,d=e.humanizeLabels,u=e.disabled,p=e.readOnly,f=e.leadingZero,y=e.clockFormat,h=e.period,g=e.unit,w=e.periodicityOnDoubleClick,C=e.mode,D=bn(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=x.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(B){return B.toString()})},[t]),I=x.useMemo(function(){return a?a.map(function(B,L){return{value:(g.min===0?L:L+1).toString(),label:B}}):At([],Array(g.total),!0).map(function(B,L){var $=g.min===0?L:L+1;return{value:$.toString(),label:Ze($,g,d,f,y)}})},[a,f,d,y]),M=JSON.stringify(l),E=x.useCallback(function(B){var L=B.value;if(!t||t[0]!==Number(L))return r.jsx(r.Fragment,{});var $=An(In(t,g),g,d,f,y),U=$.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:U[1]?"".concat(l.everyText||Z.everyText," ").concat(U[1]):$})},[t,M,d,f,y]),N=x.useCallback(function(B){var L=Array.isArray(B)?It(B):[B],$=L;t&&($=C==="single"?[]:At([],t,!0),L.forEach(function(U){var J=Number(U);$=t.some(function(_){return _===J})?$.filter(function(_){return _!==J}):It(At(At([],$,!0),[J],!1))})),$.length===g.total?i([]):i($)},[i,t]),V=x.useCallback(function(B){if(B!==0&&B!==1){for(var L=g.total+g.min,$=[],U=g.min;U<L;U++)U%B==0&&$.push(U);var J=t&&$&&t.length===$.length&&t.every(function(R,z){return R===$[z]}),_=$.length===I.length;i(_||J?[]:$)}else i([])},[t,I,i]),K=x.useRef([]),q=x.useCallback(function(B){if(!p){var L=K.current;L.push({time:new Date().getTime(),value:Number(B)});var $=window.setTimeout(function(){w&&L.length>1&&L[L.length-1].time-L[L.length-2].time<300?L[L.length-1].value===L[L.length-2].value?V(Number(B)):N([L[L.length-2].value,L[L.length-1].value]):N(Number(B)),K.current=[]},300);return function(){window.clearTimeout($)}}},[K,N,V,p,w]),G=x.useCallback(function(){p||i([])},[i,p]),j=x.useMemo(function(){var B;return Se(((B={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,B))},[c]),X=x.useMemo(function(){var B;return Se(((B={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(g.type)]=!0,B["react-js-cron-custom-select-dropdown"]=!0,B["react-js-cron-custom-select-dropdown-".concat(g.type)]=!0,B["react-js-cron-custom-select-dropdown-minutes-large"]=g.type==="minutes"&&h!=="hour"&&h!=="day",B["react-js-cron-custom-select-dropdown-minutes-medium"]=g.type==="minutes"&&(h==="day"||h==="hour"),B["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=g.type==="hours"&&y==="12-hour-clock",B["react-js-cron-custom-select-dropdown-grid"]=!!n,B["".concat(c,"-select-dropdown")]=!!c,B["".concat(c,"-select-dropdown-").concat(g.type)]=!!c,B))},[c,n,y,h]);return r.jsx(b.Select,ge({mode:C!=="single"||w?"multiple":void 0,allowClear:!p,virtual:!1,open:!p&&void 0,value:S,onClear:G,tagRender:E,className:j,popupClassName:X,options:I,showSearch:!1,showArrow:!p,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:q,onDeselect:q,disabled:u,dropdownAlign:g.type!=="minutes"&&g.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(g.type)},D))}function Vl(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=x.useMemo(function(){var h;return Se(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(a,"-field")]=!!a,h["".concat(a,"-hours")]=!!a,h))},[a]);return r.jsxs("div",ge({className:y},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||Z.prefixHours}),r.jsx(ct,{placeholder:n.emptyHours||Z.emptyHours,value:t,unit:Ue[1],setValue:o,locale:n,className:a,disabled:i,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:p,mode:f})]}))}function Wl(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=x.useMemo(function(){var h;return Se(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(a,"-field")]=!!a,h["".concat(a,"-minutes")]=!!a,h))},[a]);return r.jsxs("div",ge({className:y},{children:[u==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||Z.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||Z.prefixMinutes}),r.jsx(ct,{placeholder:u==="hour"?n.emptyMinutesForHourPeriod||Z.emptyMinutesForHourPeriod:n.emptyMinutes||Z.emptyMinutes,value:t,unit:Ue[0],setValue:o,locale:n,className:a,disabled:i,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:p,mode:f}),u==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||Z.suffixMinutesForHourPeriod})]}))}function jl(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.weekDays,l=e.disabled,c=e.readOnly,d=e.leadingZero,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=!i||i.length===0,h=x.useMemo(function(){var C;return Se(((C={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!y})["".concat(a,"-field")]=!!a,C["".concat(a,"-month-days")]=!!a,C))},[a,y]),g=JSON.stringify(n),w=x.useMemo(function(){return y?n.emptyMonthDays||Z.emptyMonthDays:n.emptyMonthDaysShort||Z.emptyMonthDaysShort},[y,g]);return!c||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0)?r.jsxs("div",ge({className:h},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||Z.prefixMonthDays}),r.jsx(ct,{placeholder:w,value:t,setValue:o,unit:Ue[2],locale:n,className:a,disabled:l,readOnly:c,leadingZero:d,period:u,periodicityOnDoubleClick:p,mode:f})]})):null}function Ll(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.humanizeLabels,l=e.disabled,c=e.readOnly,d=e.period,u=e.periodicityOnDoubleClick,p=e.mode,f=n.months||Z.months,y=x.useMemo(function(){var h;return Se(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(a,"-field")]=!!a,h["".concat(a,"-months")]=!!a,h))},[a]);return r.jsxs("div",ge({className:y},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||Z.prefixMonths}),r.jsx(ct,{placeholder:n.emptyMonths||Z.emptyMonths,optionsList:f,grid:!1,value:t,unit:ge(ge({},Ue[3]),{alt:n.altMonths||Z.altMonths}),setValue:o,locale:n,className:a,humanizeLabels:i,disabled:l,readOnly:c,period:d,periodicityOnDoubleClick:u,mode:p})]}))}function zl(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,u=[];d.includes("year")&&u.push({value:"year",label:n.yearOption||Z.yearOption}),d.includes("month")&&u.push({value:"month",label:n.monthOption||Z.monthOption}),d.includes("week")&&u.push({value:"week",label:n.weekOption||Z.weekOption}),d.includes("day")&&u.push({value:"day",label:n.dayOption||Z.dayOption}),d.includes("hour")&&u.push({value:"hour",label:n.hourOption||Z.hourOption}),d.includes("minute")&&u.push({value:"minute",label:n.minuteOption||Z.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&u.push({value:"reboot",label:n.rebootOption||Z.rebootOption});var p=x.useCallback(function(g){l||o(g)},[o,l]),f=x.useMemo(function(){var g;return Se(((g={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(a,"-field")]=!!a,g["".concat(a,"-period")]=!!a,g))},[a]),y=x.useMemo(function(){var g;return Se(((g={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(a,"-select")]=!!a,g))},[a,n.prefixPeriod]),h=x.useMemo(function(){var g;return Se(((g={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(a,"-select-dropdown")]=!!a,g["".concat(a,"-select-dropdown-period")]=!!a,g))},[a]);return r.jsxs("div",ge({className:f},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||Z.prefixPeriod}),r.jsx(b.Select,{defaultValue:t,value:t,onChange:p,options:u,className:y,popupClassName:h,disabled:i,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function ql(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.humanizeLabels,l=e.monthDays,c=e.disabled,d=e.readOnly,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=n.weekDays||Z.weekDays,h=u==="week"||!l||l.length===0,g=x.useMemo(function(){var I;return Se(((I={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(a,"-field")]=!!a,I["".concat(a,"-week-days")]=!!a,I))},[a,h]),w=JSON.stringify(n),C=x.useMemo(function(){return h?n.emptyWeekDays||Z.emptyWeekDays:n.emptyWeekDaysShort||Z.emptyWeekDaysShort},[h,w]),D=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 D?r.jsxs("div",ge({className:g},{children:[n.prefixWeekDays!==""&&(u==="week"||!S)&&r.jsx("span",{children:n.prefixWeekDays||Z.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&u!=="week"&&S&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||Z.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(ct,{placeholder:C,optionsList:y,grid:!1,value:t,unit:ge(ge({},Ue[4]),{alt:n.altWeekDays||Z.altWeekDays}),setValue:o,locale:n,className:a,humanizeLabels:i,disabled:c,readOnly:d,period:u,periodicityOnDoubleClick:p,mode:f})]})):null}function Ul(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,a=n===void 0?{}:n,i=e.clearButtonAction,l=i===void 0?"fill-with-every":i,c=e.locale,d=c===void 0?Z:c,u=e.value,p=u===void 0?"":u,f=e.setValue,y=e.displayError,h=y===void 0||y,g=e.onError,w=e.className,C=e.defaultPeriod,D=C===void 0?"day":C,S=e.allowEmpty,I=S===void 0?"for-default-value":S,M=e.humanizeLabels,E=M===void 0||M,N=e.humanizeValue,V=N!==void 0&&N,K=e.disabled,q=K!==void 0&&K,G=e.readOnly,j=G!==void 0&&G,X=e.leadingZero,B=X!==void 0&&X,L=e.shortcuts,$=L===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:L,U=e.clockFormat,J=e.periodicityOnDoubleClick,_=J===void 0||J,R=e.mode,z=R===void 0?"multiple":R,de=e.allowedDropdowns,te=de===void 0?["period","months","month-days","week-days","hours","minutes"]:de,$e=e.allowedPeriods,vc=$e===void 0?["year","month","week","day","hour","minute","reboot"]:$e,Xe=x.useRef(p),uo=x.useRef(D),Gn=x.useState(),Oe=Gn[0],Tt=Gn[1],Hn=x.useState(),dt=Hn[0],Nt=Hn[1],Jn=x.useState(),Dt=Jn[0],Ot=Jn[1],Yn=x.useState(),ut=Yn[0],Pt=Yn[1],Qn=x.useState(),Et=Qn[0],Mt=Qn[1],Zn=x.useState(),$t=Zn[0],Bt=Zn[1],Xn=x.useState(!1),po=Xn[0],pt=Xn[1],Rn=x.useState(!1),Vt=Rn[0],er=Rn[1],wc=function(ie){var Fe=x.useRef(ie);return x.useEffect(function(){Fe.current=ie},[ie]),Fe.current}(Vt),tr=JSON.stringify(d);x.useEffect(function(){kn(p,pt,g,I,Xe,!0,d,$,Bt,Mt,Nt,Ot,Pt,Tt)},[]),x.useEffect(function(){p!==Xe.current&&kn(p,pt,g,I,Xe,!1,d,$,Bt,Mt,Nt,Ot,Pt,Tt)},[p,Xe,tr,I,$]),x.useEffect(function(){if(!(Oe||$t||Dt||dt||ut||Et)||Vt||wc)Vt&&er(!1);else{var ie=Oe||uo.current,Fe=Sn(ie,Dt,dt,ut,Et,$t,V);f(Fe,{selectedPeriod:ie}),Xe.current=Fe,g&&g(void 0),pt(!1)}},[Oe,dt,Dt,ut,Et,$t,V,Vt]);var or=x.useCallback(function(){Nt(void 0),Ot(void 0),Pt(void 0),Mt(void 0),Bt(void 0);var ie="",Fe=Oe!=="reboot"&&Oe?Oe:uo.current;Fe!==Oe&&Tt(Fe),l==="fill-with-every"&&(ie=Sn(Fe,void 0,void 0,void 0,void 0,void 0)),f(ie,{selectedPeriod:Fe}),Xe.current=ie,er(!0),I==="never"&&l==="empty"?(pt(!0),Cn(g,d)):(g&&g(void 0),pt(!1))},[Oe,f,g,l]),Cc=x.useMemo(function(){var ie;return Se(((ie={"react-js-cron":!0,"react-js-cron-error":po&&h,"react-js-cron-disabled":q,"react-js-cron-read-only":j})["".concat(w)]=!!w,ie["".concat(w,"-error")]=po&&h&&!!w,ie["".concat(w,"-disabled")]=q&&!!w,ie["".concat(w,"-read-only")]=j&&!!w,ie))},[w,po,h,q,j]),mo=a.className,nr=bn(a,["className"]),rr=x.useMemo(function(){var ie;return Se(((ie={"react-js-cron-clear-button":!0})["".concat(w,"-clear-button")]=!!w,ie["".concat(mo)]=!!mo,ie))},[w,mo]),kc=JSON.stringify(nr),sr=x.useMemo(function(){return o&&!j?r.jsx(b.Button,ge({className:rr,danger:!0,type:"primary",disabled:q},nr,{onClick:or},{children:d.clearButtonText||Z.clearButtonText})):null},[o,j,tr,rr,q,kc,or]),pe=Oe||uo.current;return r.jsxs("div",ge({className:Cc},{children:[te.includes("period")&&r.jsx(zl,{value:pe,setValue:Tt,locale:d,className:w,disabled:q,readOnly:j,shortcuts:$,allowedPeriods:vc}),pe==="reboot"?sr:r.jsxs(r.Fragment,{children:[pe==="year"&&te.includes("months")&&r.jsx(Ll,{value:Dt,setValue:Ot,locale:d,className:w,humanizeLabels:E,disabled:q,readOnly:j,period:pe,periodicityOnDoubleClick:_,mode:z}),(pe==="year"||pe==="month")&&te.includes("month-days")&&r.jsx(jl,{value:dt,setValue:Nt,locale:d,className:w,weekDays:ut,disabled:q,readOnly:j,leadingZero:B,period:pe,periodicityOnDoubleClick:_,mode:z}),(pe==="year"||pe==="month"||pe==="week")&&te.includes("week-days")&&r.jsx(ql,{value:ut,setValue:Pt,locale:d,className:w,humanizeLabels:E,monthDays:dt,disabled:q,readOnly:j,period:pe,periodicityOnDoubleClick:_,mode:z}),r.jsxs("div",{children:[pe!=="minute"&&pe!=="hour"&&te.includes("hours")&&r.jsx(Vl,{value:Et,setValue:Mt,locale:d,className:w,disabled:q,readOnly:j,leadingZero:B,clockFormat:U,period:pe,periodicityOnDoubleClick:_,mode:z}),pe!=="minute"&&te.includes("minutes")&&r.jsx(Wl,{value:$t,setValue:Bt,locale:d,period:pe,className:w,disabled:q,readOnly:j,leadingZero:B,clockFormat:U,periodicityOnDoubleClick:_,mode:z}),sr]})]})]}))}const Kl={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},On=[{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 Pn(e){return On.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function _l(e){let t;switch(typeof e){case"number":return t=Pn(e),t?t.value:"none";case"string":return"cron"}return"none"}function Gl({value:e,onChange:t}){const{t:o}=ve(),n=Pn(e);return r.jsx(b.InputNumber,{value:e/n.value,onChange:a=>t(a*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Hl({value:e=null,onChange:t}){const{t:o}=ve(),n=_l(e);function a(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const i=Kl[localStorage.getItem("TACHYBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:s.css`
864
+ `,children:[r.jsxs(b.Select,{value:n,onChange:a=>{t(a?a==="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(xn,{value:e,onChange:t}):null,n==="date"?r.jsx(b.DatePicker,{showTime:!0,value:mt(e),onChange:a=>{t(a?a.toDate():null)}}):null]})}var ge=function(){return ge=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var a in t=arguments[o])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},ge.apply(this,arguments)};function bn(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 a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(o[n[a]]=e[n[a]])}return o}function At(e,t,o){if(o||arguments.length===2)for(var n,a=0,i=t.length;a<i;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}var Wl=[{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 * * * *"}],Ue=[{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"]}],Z={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 vn(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function It(e){return e.sort(function(t,o){return t-o}),e}function wn(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function Se(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 Cn(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||Z.errorInvalidCron})}function Ft(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function kn(e,t,o,n,a,i,l,c,d,u,p,f,y,h){o&&o(void 0),t(!1);var g=!1;if(!e){if(n==="always"||i&&n==="for-default-value")return;g=!0}if(!g){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var w=Wl.find(function(S){return S.name===e});w&&(e=w.value)}try{var C=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var I=S.replace(/\s+/g," ").trim().split(" ");if(I.length===5)return I.map(function(M,E){return function(N,V){if(N==="*"||N==="*/1")return[];var K=It(wn(Fn(function(G,j,X){if(X){G=G.toUpperCase();for(var B=0;B<X.length;B++)G=G.replace(X[B],"".concat(B+j))}return G}(N,V.min,V.alt).split(",").map(function(G){var j,X=G.split("/");if(X.length>2)throw new Error('Invalid value "'.concat(N,' for "').concat(V.type,'"'));var B=X[0],L=X[1];j=B==="*"?vn(V.min,V.max):function(J,_,R){var z=J.split("-");if(z.length===1){var de=Ft(z[0]);if(isNaN(de))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));return[de]}if(z.length===2){var te=Ft(z[0]),$e=Ft(z[1]);if(isNaN(te)||isNaN($e))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));if($e<te)throw new Error('Max range is less than min range in "'.concat(J,'" for ').concat(R.type));return vn(te,$e)}throw new Error('Invalid value "'.concat(J,'" for ').concat(R.type))}(B,N,V);var $=function(J,_){if(J!==void 0){var R=Ft(J);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(J,'" for ').concat(_.type));return R}}(L,V),U=function(J,_){if(_){var R=J[0];J=J.filter(function(z){return z%_==R%_||z===R})}return J}(j,$);return U}).flat(),V))),q=Tn(K,V);if(q!==void 0)throw new Error('Value "'.concat(q,'" out of range for ').concat(V.type));return K.length===V.total?[]:K}(M,Ue[E])});throw new Error("Invalid cron string format")}(e),D=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"}(C);h(D),d(C[0]),u(C[1]),p(C[2]),f(C[3]),y(C[4])}catch(S){g=!0}}g&&(a.current=e,t(!0),Cn(o,l))}function Sn(e,t,o,n,a,i,l){if(e==="reboot")return"@reboot";var c=function(d,u){return d.map(function(p,f){var y=Ue[f];return An(In(p,y),y,u)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&a?a:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function An(e,t,o,n,a){var i="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)i="*";else{var l=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);i=l&&function(c,d){for(var u=1;u<c.length;u++){var p=c[u-1];if(c[u]-p!==d)return!1}return!0}(e,l)?function(c,d,u){var p=Nn(c),f=Dn(c),y=c.length===(f-p)/u+1;return!!(p===d.min&&f+u>d.max&&y)}(e,t,l)?"*/".concat(l):"".concat(Ze(Nn(e),t,o,n,a),"-").concat(Ze(Dn(e),t,o,n,a),"/").concat(l):function(c){var d=[],u=null;return c.forEach(function(p,f,y){p!==y[f+1]-1?u!==null?(d.push([u,p]),u=null):d.push(p):u===null&&(u=p)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ze(c[0],t,o,n,a),"-").concat(Ze(c[1],t,o,n,a)):Ze(c,t,o,n,a)}).join(",")}return i}function Ze(e,t,o,n,a){var i=e.toString(),l=t.type,c=t.alt,d=t.min,u=n&&(n===!0||n.includes(l)),p=a==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?i=c[e-d]:e<10&&(u||p)&&(i=i.padStart(2,"0")),l==="hours"&&a==="12-hour-clock"){var f=e>=12?"PM":"AM",y=e%12||12;y<10&&u&&(y=y.toString().padStart(2,"0")),i="".concat(y).concat(f)}return i}function In(e,t){var o=It(wn(Fn(e,t)));if(o.length===0)return o;var n=Tn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function Fn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function Tn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function Nn(e){return e[0]}function Dn(e){return e[e.length-1]}function ct(e){var t=e.value,o=e.grid,n=o===void 0||o,a=e.optionsList,i=e.setValue,l=e.locale,c=e.className,d=e.humanizeLabels,u=e.disabled,p=e.readOnly,f=e.leadingZero,y=e.clockFormat,h=e.period,g=e.unit,w=e.periodicityOnDoubleClick,C=e.mode,D=bn(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=x.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(B){return B.toString()})},[t]),I=x.useMemo(function(){return a?a.map(function(B,L){return{value:(g.min===0?L:L+1).toString(),label:B}}):At([],Array(g.total),!0).map(function(B,L){var $=g.min===0?L:L+1;return{value:$.toString(),label:Ze($,g,d,f,y)}})},[a,f,d,y]),M=JSON.stringify(l),E=x.useCallback(function(B){var L=B.value;if(!t||t[0]!==Number(L))return r.jsx(r.Fragment,{});var $=An(In(t,g),g,d,f,y),U=$.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:U[1]?"".concat(l.everyText||Z.everyText," ").concat(U[1]):$})},[t,M,d,f,y]),N=x.useCallback(function(B){var L=Array.isArray(B)?It(B):[B],$=L;t&&($=C==="single"?[]:At([],t,!0),L.forEach(function(U){var J=Number(U);$=t.some(function(_){return _===J})?$.filter(function(_){return _!==J}):It(At(At([],$,!0),[J],!1))})),$.length===g.total?i([]):i($)},[i,t]),V=x.useCallback(function(B){if(B!==0&&B!==1){for(var L=g.total+g.min,$=[],U=g.min;U<L;U++)U%B==0&&$.push(U);var J=t&&$&&t.length===$.length&&t.every(function(R,z){return R===$[z]}),_=$.length===I.length;i(_||J?[]:$)}else i([])},[t,I,i]),K=x.useRef([]),q=x.useCallback(function(B){if(!p){var L=K.current;L.push({time:new Date().getTime(),value:Number(B)});var $=window.setTimeout(function(){w&&L.length>1&&L[L.length-1].time-L[L.length-2].time<300?L[L.length-1].value===L[L.length-2].value?V(Number(B)):N([L[L.length-2].value,L[L.length-1].value]):N(Number(B)),K.current=[]},300);return function(){window.clearTimeout($)}}},[K,N,V,p,w]),G=x.useCallback(function(){p||i([])},[i,p]),j=x.useMemo(function(){var B;return Se(((B={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,B))},[c]),X=x.useMemo(function(){var B;return Se(((B={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(g.type)]=!0,B["react-js-cron-custom-select-dropdown"]=!0,B["react-js-cron-custom-select-dropdown-".concat(g.type)]=!0,B["react-js-cron-custom-select-dropdown-minutes-large"]=g.type==="minutes"&&h!=="hour"&&h!=="day",B["react-js-cron-custom-select-dropdown-minutes-medium"]=g.type==="minutes"&&(h==="day"||h==="hour"),B["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=g.type==="hours"&&y==="12-hour-clock",B["react-js-cron-custom-select-dropdown-grid"]=!!n,B["".concat(c,"-select-dropdown")]=!!c,B["".concat(c,"-select-dropdown-").concat(g.type)]=!!c,B))},[c,n,y,h]);return r.jsx(b.Select,ge({mode:C!=="single"||w?"multiple":void 0,allowClear:!p,virtual:!1,open:!p&&void 0,value:S,onClear:G,tagRender:E,className:j,popupClassName:X,options:I,showSearch:!1,showArrow:!p,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:q,onDeselect:q,disabled:u,dropdownAlign:g.type!=="minutes"&&g.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(g.type)},D))}function jl(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=x.useMemo(function(){var h;return Se(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(a,"-field")]=!!a,h["".concat(a,"-hours")]=!!a,h))},[a]);return r.jsxs("div",ge({className:y},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||Z.prefixHours}),r.jsx(ct,{placeholder:n.emptyHours||Z.emptyHours,value:t,unit:Ue[1],setValue:o,locale:n,className:a,disabled:i,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:p,mode:f})]}))}function Ll(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=x.useMemo(function(){var h;return Se(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(a,"-field")]=!!a,h["".concat(a,"-minutes")]=!!a,h))},[a]);return r.jsxs("div",ge({className:y},{children:[u==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||Z.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||Z.prefixMinutes}),r.jsx(ct,{placeholder:u==="hour"?n.emptyMinutesForHourPeriod||Z.emptyMinutesForHourPeriod:n.emptyMinutes||Z.emptyMinutes,value:t,unit:Ue[0],setValue:o,locale:n,className:a,disabled:i,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:p,mode:f}),u==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||Z.suffixMinutesForHourPeriod})]}))}function zl(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.weekDays,l=e.disabled,c=e.readOnly,d=e.leadingZero,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=!i||i.length===0,h=x.useMemo(function(){var C;return Se(((C={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!y})["".concat(a,"-field")]=!!a,C["".concat(a,"-month-days")]=!!a,C))},[a,y]),g=JSON.stringify(n),w=x.useMemo(function(){return y?n.emptyMonthDays||Z.emptyMonthDays:n.emptyMonthDaysShort||Z.emptyMonthDaysShort},[y,g]);return!c||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0)?r.jsxs("div",ge({className:h},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||Z.prefixMonthDays}),r.jsx(ct,{placeholder:w,value:t,setValue:o,unit:Ue[2],locale:n,className:a,disabled:l,readOnly:c,leadingZero:d,period:u,periodicityOnDoubleClick:p,mode:f})]})):null}function ql(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.humanizeLabels,l=e.disabled,c=e.readOnly,d=e.period,u=e.periodicityOnDoubleClick,p=e.mode,f=n.months||Z.months,y=x.useMemo(function(){var h;return Se(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(a,"-field")]=!!a,h["".concat(a,"-months")]=!!a,h))},[a]);return r.jsxs("div",ge({className:y},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||Z.prefixMonths}),r.jsx(ct,{placeholder:n.emptyMonths||Z.emptyMonths,optionsList:f,grid:!1,value:t,unit:ge(ge({},Ue[3]),{alt:n.altMonths||Z.altMonths}),setValue:o,locale:n,className:a,humanizeLabels:i,disabled:l,readOnly:c,period:d,periodicityOnDoubleClick:u,mode:p})]}))}function Ul(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,u=[];d.includes("year")&&u.push({value:"year",label:n.yearOption||Z.yearOption}),d.includes("month")&&u.push({value:"month",label:n.monthOption||Z.monthOption}),d.includes("week")&&u.push({value:"week",label:n.weekOption||Z.weekOption}),d.includes("day")&&u.push({value:"day",label:n.dayOption||Z.dayOption}),d.includes("hour")&&u.push({value:"hour",label:n.hourOption||Z.hourOption}),d.includes("minute")&&u.push({value:"minute",label:n.minuteOption||Z.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&u.push({value:"reboot",label:n.rebootOption||Z.rebootOption});var p=x.useCallback(function(g){l||o(g)},[o,l]),f=x.useMemo(function(){var g;return Se(((g={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(a,"-field")]=!!a,g["".concat(a,"-period")]=!!a,g))},[a]),y=x.useMemo(function(){var g;return Se(((g={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(a,"-select")]=!!a,g))},[a,n.prefixPeriod]),h=x.useMemo(function(){var g;return Se(((g={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(a,"-select-dropdown")]=!!a,g["".concat(a,"-select-dropdown-period")]=!!a,g))},[a]);return r.jsxs("div",ge({className:f},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||Z.prefixPeriod}),r.jsx(b.Select,{defaultValue:t,value:t,onChange:p,options:u,className:y,popupClassName:h,disabled:i,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Kl(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.humanizeLabels,l=e.monthDays,c=e.disabled,d=e.readOnly,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=n.weekDays||Z.weekDays,h=u==="week"||!l||l.length===0,g=x.useMemo(function(){var I;return Se(((I={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(a,"-field")]=!!a,I["".concat(a,"-week-days")]=!!a,I))},[a,h]),w=JSON.stringify(n),C=x.useMemo(function(){return h?n.emptyWeekDays||Z.emptyWeekDays:n.emptyWeekDaysShort||Z.emptyWeekDaysShort},[h,w]),D=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 D?r.jsxs("div",ge({className:g},{children:[n.prefixWeekDays!==""&&(u==="week"||!S)&&r.jsx("span",{children:n.prefixWeekDays||Z.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&u!=="week"&&S&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||Z.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(ct,{placeholder:C,optionsList:y,grid:!1,value:t,unit:ge(ge({},Ue[4]),{alt:n.altWeekDays||Z.altWeekDays}),setValue:o,locale:n,className:a,humanizeLabels:i,disabled:c,readOnly:d,period:u,periodicityOnDoubleClick:p,mode:f})]})):null}function _l(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,a=n===void 0?{}:n,i=e.clearButtonAction,l=i===void 0?"fill-with-every":i,c=e.locale,d=c===void 0?Z:c,u=e.value,p=u===void 0?"":u,f=e.setValue,y=e.displayError,h=y===void 0||y,g=e.onError,w=e.className,C=e.defaultPeriod,D=C===void 0?"day":C,S=e.allowEmpty,I=S===void 0?"for-default-value":S,M=e.humanizeLabels,E=M===void 0||M,N=e.humanizeValue,V=N!==void 0&&N,K=e.disabled,q=K!==void 0&&K,G=e.readOnly,j=G!==void 0&&G,X=e.leadingZero,B=X!==void 0&&X,L=e.shortcuts,$=L===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:L,U=e.clockFormat,J=e.periodicityOnDoubleClick,_=J===void 0||J,R=e.mode,z=R===void 0?"multiple":R,de=e.allowedDropdowns,te=de===void 0?["period","months","month-days","week-days","hours","minutes"]:de,$e=e.allowedPeriods,Cc=$e===void 0?["year","month","week","day","hour","minute","reboot"]:$e,Xe=x.useRef(p),uo=x.useRef(D),Gn=x.useState(),Oe=Gn[0],Tt=Gn[1],Hn=x.useState(),dt=Hn[0],Nt=Hn[1],Jn=x.useState(),Dt=Jn[0],Ot=Jn[1],Yn=x.useState(),ut=Yn[0],Pt=Yn[1],Qn=x.useState(),Et=Qn[0],Mt=Qn[1],Zn=x.useState(),$t=Zn[0],Bt=Zn[1],Xn=x.useState(!1),po=Xn[0],pt=Xn[1],Rn=x.useState(!1),Vt=Rn[0],er=Rn[1],kc=function(ie){var Fe=x.useRef(ie);return x.useEffect(function(){Fe.current=ie},[ie]),Fe.current}(Vt),tr=JSON.stringify(d);x.useEffect(function(){kn(p,pt,g,I,Xe,!0,d,$,Bt,Mt,Nt,Ot,Pt,Tt)},[]),x.useEffect(function(){p!==Xe.current&&kn(p,pt,g,I,Xe,!1,d,$,Bt,Mt,Nt,Ot,Pt,Tt)},[p,Xe,tr,I,$]),x.useEffect(function(){if(!(Oe||$t||Dt||dt||ut||Et)||Vt||kc)Vt&&er(!1);else{var ie=Oe||uo.current,Fe=Sn(ie,Dt,dt,ut,Et,$t,V);f(Fe,{selectedPeriod:ie}),Xe.current=Fe,g&&g(void 0),pt(!1)}},[Oe,dt,Dt,ut,Et,$t,V,Vt]);var or=x.useCallback(function(){Nt(void 0),Ot(void 0),Pt(void 0),Mt(void 0),Bt(void 0);var ie="",Fe=Oe!=="reboot"&&Oe?Oe:uo.current;Fe!==Oe&&Tt(Fe),l==="fill-with-every"&&(ie=Sn(Fe,void 0,void 0,void 0,void 0,void 0)),f(ie,{selectedPeriod:Fe}),Xe.current=ie,er(!0),I==="never"&&l==="empty"?(pt(!0),Cn(g,d)):(g&&g(void 0),pt(!1))},[Oe,f,g,l]),Sc=x.useMemo(function(){var ie;return Se(((ie={"react-js-cron":!0,"react-js-cron-error":po&&h,"react-js-cron-disabled":q,"react-js-cron-read-only":j})["".concat(w)]=!!w,ie["".concat(w,"-error")]=po&&h&&!!w,ie["".concat(w,"-disabled")]=q&&!!w,ie["".concat(w,"-read-only")]=j&&!!w,ie))},[w,po,h,q,j]),mo=a.className,nr=bn(a,["className"]),rr=x.useMemo(function(){var ie;return Se(((ie={"react-js-cron-clear-button":!0})["".concat(w,"-clear-button")]=!!w,ie["".concat(mo)]=!!mo,ie))},[w,mo]),Ac=JSON.stringify(nr),sr=x.useMemo(function(){return o&&!j?r.jsx(b.Button,ge({className:rr,danger:!0,type:"primary",disabled:q},nr,{onClick:or},{children:d.clearButtonText||Z.clearButtonText})):null},[o,j,tr,rr,q,Ac,or]),pe=Oe||uo.current;return r.jsxs("div",ge({className:Sc},{children:[te.includes("period")&&r.jsx(Ul,{value:pe,setValue:Tt,locale:d,className:w,disabled:q,readOnly:j,shortcuts:$,allowedPeriods:Cc}),pe==="reboot"?sr:r.jsxs(r.Fragment,{children:[pe==="year"&&te.includes("months")&&r.jsx(ql,{value:Dt,setValue:Ot,locale:d,className:w,humanizeLabels:E,disabled:q,readOnly:j,period:pe,periodicityOnDoubleClick:_,mode:z}),(pe==="year"||pe==="month")&&te.includes("month-days")&&r.jsx(zl,{value:dt,setValue:Nt,locale:d,className:w,weekDays:ut,disabled:q,readOnly:j,leadingZero:B,period:pe,periodicityOnDoubleClick:_,mode:z}),(pe==="year"||pe==="month"||pe==="week")&&te.includes("week-days")&&r.jsx(Kl,{value:ut,setValue:Pt,locale:d,className:w,humanizeLabels:E,monthDays:dt,disabled:q,readOnly:j,period:pe,periodicityOnDoubleClick:_,mode:z}),r.jsxs("div",{children:[pe!=="minute"&&pe!=="hour"&&te.includes("hours")&&r.jsx(jl,{value:Et,setValue:Mt,locale:d,className:w,disabled:q,readOnly:j,leadingZero:B,clockFormat:U,period:pe,periodicityOnDoubleClick:_,mode:z}),pe!=="minute"&&te.includes("minutes")&&r.jsx(Ll,{value:$t,setValue:Bt,locale:d,period:pe,className:w,disabled:q,readOnly:j,leadingZero:B,clockFormat:U,periodicityOnDoubleClick:_,mode:z}),sr]})]})]}))}const Gl={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},On=[{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 Pn(e){return On.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Hl(e){let t;switch(typeof e){case"number":return t=Pn(e),t?t.value:"none";case"string":return"cron"}return"none"}function Jl({value:e,onChange:t}){const{t:o}=ve(),n=Pn(e);return r.jsx(b.InputNumber,{value:e/n.value,onChange:a=>t(a*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Yl({value:e=null,onChange:t}){const{t:o}=ve(),n=Hl(e);function a(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const i=Gl[localStorage.getItem("TACHYBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:s.css`
865
865
  display: flex;
866
866
  flex-direction: ${n==="cron"?"column":"row"};
867
867
  align-items: flex-start;
@@ -890,7 +890,7 @@ export default async function (
890
890
  }
891
891
  }
892
892
  }
893
- `,children:[r.jsx(b.Select,{value:n,onChange:a,className:"auto-width",children:On.map(l=>r.jsx(b.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Gl,{value:e,onChange:t}):null,n==="cron"?r.jsx(Ul,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:i}):null]})}const Jl={[qe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}}},[qe.DATE_FIELD]:{collection:F(v({},ue),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...ue["x-reactions"],{target:"startsOn",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${m}" })}}`,"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: "${m}" })}}`,"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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}},appends:F(v({},lt),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${qe.DATE_FIELD} && $deps[1]}}`}}}]})}},Yl=[{value:qe.STATIC,label:`{{t("Based on certain date", { ns: "${m}" })}}`},{value:qe.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${m}" })}}`}],Ql=()=>{const{values:e={},clearFormGraph:t}=A.useForm(),[o,n]=x.useState(e.mode);return A.useFormEffects(()=>{A.onFieldValueChange("mode",a=>{n(a.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${m}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Yl},required:!0,default:qe.STATIC}}),r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
893
+ `,children:[r.jsx(b.Select,{value:n,onChange:a,className:"auto-width",children:On.map(l=>r.jsx(b.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Jl,{value:e,onChange:t}):null,n==="cron"?r.jsx(_l,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:i}):null]})}const Ql={[qe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}}},[qe.DATE_FIELD]:{collection:F(v({},ue),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...ue["x-reactions"],{target:"startsOn",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${m}" })}}`,"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: "${m}" })}}`,"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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}},appends:F(v({},lt),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${qe.DATE_FIELD} && $deps[1]}}`}}}]})}},Zl=[{value:qe.STATIC,label:`{{t("Based on certain date", { ns: "${m}" })}}`},{value:qe.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${m}" })}}`}],Xl=()=>{const{values:e={},clearFormGraph:t}=A.useForm(),[o,n]=x.useState(e.mode);return A.useFormEffects(()=>{A.onFieldValueChange("mode",a=>{n(a.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${m}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Zl},required:!0,default:qe.STATIC}}),r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
894
894
  .ant-input-number {
895
895
  width: auto;
896
896
  min-width: 6em;
@@ -899,4 +899,4 @@ export default async function (
899
899
  .ant-picker {
900
900
  width: auto;
901
901
  }
902
- `},properties:Jl[o]}}},components:{OnField:xn,RepeatField:Hl,EndsByField:$l}})]})};class Zl extends Re{constructor(){super(...arguments),this.sync=!1,this.title=`{{t("Schedule event", { ns: "${m}" })}}`,this.description=`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`,this.fieldset={config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={ScheduleConfig:Ql}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&i.push({key:"date",value:"date",label:O("Trigger time")}),t.mode===qe.DATE_FIELD){const[c]=fe(F(v({appends:["data",...((l=t.appends)==null?void 0:l.map(d=>`data.${d}`))||[]]},o),{fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:O("Trigger data")}}],compile:n,getCollectionFields:a}));c&&i.push(c)}return i}useInitializers(t){return t.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const ao={name:"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: "${m}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"bigInt",type:"bigInt",name:"executionCost",uiSchema:{type:"bigInt",title:`{{t("Execution time", { ns: "${m}" })}}`,"x-component":({value:e})=>{const t=s.useCollectionRecordData(),o=Wr(e,t);return r.jsx(s.Input,{type:"text",value:o})},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${m}" })}}`,"x-component"({value:e}){const{setVisible:t}=s.useActionContext();return r.jsx(se.Link,{to:Le(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:gt}}]},En=e=>{const{isShowActionClear:t=!0}=e||{};return{type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${m}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:ao,dataSource:"main",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{isShow:t,useAction(){const{t:o}=ve(),{refresh:n,params:a}=s.useDataBlockRequest(),i=s.useDataBlockResource(),{setVisible:l}=s.useActionContext();return{run(){return P(this,null,function*(){yield i.destroy({filter:a==null?void 0:a.filter}),b.message.success(o("Operation succeeded")),n(),l(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${m}" })}}`,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: "${m}" })}}`}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{width:50},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},retry:{type:"void",title:`{{t("Retry", { ns: "${m}" })}}`,"x-component":"Action.Link","x-use-component-props":"ExecutionRetryAction"}}}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},executionCost:{type:"void",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{executionCost:{type:"bigInt","x-component":"CollectionField","x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}}},io=En();function Xl(n){var a=n,{params:e,filter:t={}}=a,o=Q(a,["params","filter"]);const{workflow:i}=Y(),l=F(v({},o),{params:F(v({},e),{filter:F(v({},e==null?void 0:e.filter),{key:i.key})})});return r.jsx(s.TableBlockProvider,v({},l))}function Rl(){var J,_;const e=se.useNavigate(),{t}=ee.useTranslation(),o=s.useApp(),{data:n,refresh:a,loading:i}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:c}=s.useDocumentTitle(),[d,u]=x.useState(!1),[p,f]=x.useState(!1),[y,h]=x.useState(null),{styles:g}=we(),{modal:w}=b.App.useApp(),D=(J=window.location.pathname.split("business-components/")[1])==null?void 0:J.split("/")[0],S=o.systemSettingsManager.get(`business-components.${D}`)||{},I=s.useCompile();if(x.useEffect(()=>{var de;const{title:z}=(de=n==null?void 0:n.data)!=null?de:{};c==null||c(`${O("Workflow")}${z?`: ${z}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return i?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const R=(_=n==null?void 0:n.data)!=null?_:{},{nodes:M=[],revisions:E=[]}=R,N=Q(R,["nodes","revisions"]);xt(M);const V=M.find(z=>!z.upstream);function K({key:z}){z!==N.id&&e(Le(z,D))}function q(z){return P(this,null,function*(){yield l.update({filterByTk:N.id,values:{enabled:z}}),a()})}function G(){return P(this,null,function*(){const{data:{data:z}}=yield l.retry({filterByTk:N.id,filter:{key:N.key}});e(He(z.id,D))})}function j(){return P(this,null,function*(){var z,de;try{const{data:{data:te}}=yield l.test({filterByTk:N.id,filter:{key:N.key},values:{data:{}}});if(!te||!te.id){b.message.error(O("Failed to create execution"));return}e(He(te.id,D))}catch(te){console.error("Test execution failed:",te),b.message.error(((de=(z=te==null?void 0:te.response)==null?void 0:z.data)==null?void 0:de.message)||(te==null?void 0:te.message)||O("Test execution failed"))}})}function X(){return P(this,null,function*(){const{data:{data:z}}=yield l.revision({filterByTk:N.id,filter:{key:N.key},values:{color:N.color}});b.message.success(t("Operation succeeded")),e(Le(z.id,D))})}function B(){return P(this,null,function*(){const z=N.current?O("Delete a main version will cause all other revisions to be deleted too."):"";w.confirm({title:t("Are you sure you want to delete it?"),content:z,onOk(){return P(this,null,function*(){var te;yield l.destroy({filterByTk:N.id}),b.message.success(t("Operation succeeded")),e(N.current?o.systemSettingsManager.getRoutePath("workflow"):Le((te=E.find($e=>$e.current))==null?void 0:te.id,D))})}})})}const L=()=>P(null,null,function*(){y?(yield l.moveWorkflow({id:N.id,targetKey:y}),b.message.success(O("Move success")),f(!1),N.key=y,a()):b.message.error(O("Select target workflow"))});function $(de){return P(this,arguments,function*({key:z}){switch(z){case"history":u(!0);return;case"test":return j();case"Retry":return G();case"revision":return X();case"delete":return B();case"move":h(null),f(!0);return}})}const U=N.executed&&!E.find(z=>!z.executed&&new Date(z.createdAt)>new Date(N.createdAt));return r.jsxs(Ve.Provider,{value:{workflow:N,nodes:M,refresh:a},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(To,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(se.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${D}`),children:I(S.label)})},{title:r.jsx("strong",{children:N.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:K,defaultSelectedKeys:[`${N.id}`],className:s.cx(g.dropdownClass,g.workflowVersionDropdownClass),items:E.sort((z,de)=>de.id-z.id).map((z,de)=>({role:"button","aria-label":`version-${de}`,key:`${z.id}`,icon:z.current?r.jsx(H.RightOutlined,{}):null,className:s.cx({executed:z.executed,unexecuted:!z.executed,enabled:z.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${z.id}`}),r.jsx("time",{children:W.str2moment(z.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:O("Version")}),r.jsx("span",{children:N!=null&&N.id?`#${N.id}`:null}),r.jsx(H.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:N.enabled,onChange:q,checkedChildren:O("On"),unCheckedChildren:O("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:O("Show execution history"),disabled:!N.allExecuted},{role:"button","aria-label":"test",key:"test",label:O("Execute empty test")},{role:"button","aria-label":"Retry",key:"Retry",label:O("Retry"),disabled:!N.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:O("Copy to new version"),disabled:!U},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")},{role:"button","aria-label":"move",key:"move",label:O("Move"),disabled:N.current}],onClick:$},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(H.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:d,setVisible:u},children:r.jsx(s.SchemaComponent,{schema:io,components:{ExecutionResourceProvider:Xl,ExecutionLink:Zt,ExecutionStatusColumn:Yt},scope:{ExecutionRetryAction:Xt}})})]})]}),r.jsx(Fo,{entry:V}),r.jsxs(b.Modal,{title:O("Move workflow"),visible:p,onOk:L,onCancel:()=>{f(!1)},children:[r.jsx("p",{children:O("Move current version to another workflow")}),r.jsx(s.WorkflowSelect,{buttonAction:"submit",noCollection:!0,label:"title",actionType:"update",value:y,filterType:N.type,filterSync:N.sync,filterKey:{$ne:N.key},onChange:z=>h(z)})]})]})}const lo=()=>{const e=se.useParams(),{styles:t}=we();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.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:["createdBy","nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:Rl}})})},Mn=x.createContext({data:[],refresh:()=>{},activeKey:"",setActiveKey:()=>{},categoriesLoaded:!1}),co=()=>x.useContext(Mn),ec=A.observer(e=>{const{value:t}=e,o=s.useCompile();return r.jsx(r.Fragment,{children:t==null?void 0:t.map(n=>r.jsx(b.Tag,{color:n.color,children:o(n==null?void 0:n.name)},n.name))})},{displayName:"WorkflowCategory"}),tc=()=>{const e=A.useForm(),t=s.useActionContext(),{refresh:o}=co(),n=s.useAPIClient();return{run(){return P(this,null,function*(){yield e.submit();const i=ae.cloneDeep(e.values);yield n.resource("workflowCategories").create({values:F(v({},i),{type:t==null?void 0:t.categoryType})}),t.setVisible(!1),yield e.reset(),o()})}}},oc=e=>r.jsx($n,v({},e)),$n=e=>{const{scope:t,getContainer:o,children:n,categoryType:a}=e,[i,l]=x.useState(!1),{t:c}=ve(),d=nc(a),u={visible:i,setVisible:l,categoryType:a};return r.jsxs(s.ActionContextProvider,{value:u,children:[r.jsx("div",{onClick:()=>l(!0),title:c("Add category"),children:n||r.jsx(H.PlusOutlined,{})}),r.jsx(s.SchemaComponent,{schema:d,components:{CollectionCategory:ec},scope:v({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useCreateworkflowCategry:tc},t)})]})},nc=e=>({type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",categoryType:e,useAction:"{{ useCreateworkflowCategry }}",style:{marginLeft:"8px"}}}}}}}}}),rc=()=>{var i;const e=s.useCollectionRecordData(),t=s.useCollectionManager(),o=(i=e.config)==null?void 0:i.collection,n=t.getCollection(o),a=o?`${n==null?void 0:n.options.title}(${o})`:"-";return r.jsx("div",{style:{textAlign:"center"},children:a})},sc=()=>{const t=s.useCollectionRecordData().eventSourceName||"-";return r.jsx("div",{style:{textAlign:"left"},children:t})},ac=()=>{const e=s.useCollectionRecordData(),t=s.useCompile(),n=s.usePlugin("workflow").getTriggersOptions(),{type:a,title:i}=e,l=n.find(c=>c.value===a);return r.jsx(b.Tooltip,{title:t(l.label),placement:"right",color:"cyan",style:{},children:r.jsx("span",{style:{display:"inline-block",maxWidth:300,textAlign:"left",cursor:"pointer",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})})},ic=()=>{const e=A.useForm(),t=s.useActionContext(),{refresh:o}=co(),n=s.useAPIClient(),{id:a}=s.useRecord();return{run(){return P(this,null,function*(){yield e.submit();const l=ae.cloneDeep(e.values);yield n.resource("workflowCategories").update({filter:{id:a},values:v({},l)}),t.setVisible(!1),yield e.reset(),o()})}}},lc=e=>{const t=s.useRecord(),o=s.useRequest(()=>Promise.resolve({data:ae.cloneDeep(t)}),F(v({},e),{manual:!0})),n=s.useActionContext();return x.useEffect(()=>{n.visible&&o.run()},[n.visible]),o},cc=e=>r.jsx(Bn,v({},e)),Bn=e=>{const{scope:t,getContainer:o,item:n,children:a}=e,[i,l]=x.useState(!1),c=s.useCompile();return r.jsx(s.RecordProvider,{record:n,children:r.jsxs(s.ActionContextProvider,{value:{visible:i,setVisible:l},children:[r.jsx(r.Fragment,{children:a||r.jsx("span",{onClick:()=>l(!0),children:c('{{ t("Edit category") }}')})}),r.jsx(s.SchemaComponent,{schema:dc,scope:v({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useEditCategry:ic,useValuesFromRecord:lc},t)})]})})},dc={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},uc=n=>{var a=n,{params:e,filter:t={}}=a,o=Q(a,["params","filter"]);const i=s.useCollectionRecordData(),l=F(v({},o),{params:F(v({},e),{filter:F(v({},e==null?void 0:e.filter),{key:i.key})})});return r.jsx(s.TableBlockProvider,v({},l))},le=A.observable({value:"",item:{}}),Ke={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: "${m}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"belongsToMany",name:"category",target:"workflowCategories",sourceKey:"key",foreignKey:"workflowKey",otherKey:"categoryId",targetKey:"id",sortBy:"sort",through:"workflowCategory",collectionName:"workflows",interface:"m2m",uiSchema:{title:`{{t("Category", { ns: "${m}" })}}`,type:"array","x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"name"}}}},{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: "${m}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${m}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${m}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${m}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:T("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"workflows",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{value:"id",label:"nickname"}}}}]},Vn={name:"workflowCategories",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"input",uiSchema:{title:'{{t("Type")}}',type:"string","x-component":"Input"}}]},be={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem",default:"general-action","x-hidden":!0},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect",default:!0,"x-component-props":{options:[{label:`{{ t("Queue Mode", { ns: "${m}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${m}" }) }}`},{label:`{{ t("Transactional Mode", { ns: "${m}" }) }}`,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: "${m}" }) }}`}]}},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0,service:{params:{filter:{$and:[{type:{$ne:"approval"}}]}}}}},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: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Wn=()=>{const{form:e}=s.useFormBlockProps();return le.value&&(e.values.category=[le.item]),{form:e}},jn={type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":`${Ke.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:Ke},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},title:be.title,category:be.category,type:be.type,sync:be.sync,description:be.description,options:be.options}}}}}}}},Ln={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":`${Ke.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:Ke,params:{appends:["category"]}},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"},"x-action-settings":{isDeltaChanged:!0}}}},title:be.title,category:be.category,type:be.type,enabled:be.enabled,sync:be.sync,description:be.description,options:be.options}}}}}}}},pc={type:"void",title:`{{t("Duplicate", { ns: "${m}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0,service:{params:{filter:{$and:[{type:{$ne:"approval"}}]}}}}},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useRevisionAction }}"}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},mc={type:"void",title:`{{t("Test", { ns: "${m}" })}}`,"x-component":"Action.Link",properties:{modal:{type:"void",title:`{{t("Test workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{params:{type:"string",title:'{{t("Input")}}',description:`{{t("Data is the trigger variable, it can be { data: 0 }, or { data: { id: 0 }}", { ns: "${m}" })}}`,"x-decorator":"FormItem",default:'{ "data":{} }',"x-component":"CodeMirror","x-component-props":{height:"50vh",defaultLanguage:"json"}},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}=ee.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),a=s.useFilterByTk(),{values:i}=A.useForm();return{run(){return P(this,null,function*(){try{const c=JSON.parse(i.params);yield o.test({filterByTk:a,values:c}),t(),n(!1)}catch(c){console.error(c)}})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}};function fc(e){const{isOver:t,setNodeRef:o}=Be.useDroppable({id:e.id,data:e.data}),n=t?{color:"green"}:void 0;return r.jsx("div",{ref:o,style:n,children:e.children})}function gc(e){const{attributes:t,listeners:o,setNodeRef:n}=Be.useDraggable({id:e.id,data:e.data});return r.jsx("div",F(v(v({ref:n},o),t),{children:r.jsx("div",{children:e.children})}))}const hc=A.observer(({item:e})=>r.jsx(fc,{id:e.id.toString(),data:e,children:r.jsx("div",{children:r.jsx(gc,{id:e.id.toString(),data:e,children:r.jsx(zn,{item:e})})})}),{displayName:"TabTitle"}),zn=({item:e})=>{const{t}=ee.useTranslation(),o=s.useCompile();return r.jsxs(b.Space,{children:[r.jsx(b.Badge,{color:e.color}),t(o(e.name))]})},yc=A.observer(e=>{const[t,o]=x.useState(null),{refresh:n}=co(),a=s.useAPIClient(),i=u=>P(null,null,function*(){const{active:p,over:f}=u;setTimeout(()=>{o(null)}),f&&f.id!==p.id&&(yield a.resource("workflowCategories").move({sourceId:p.id,targetId:f.id}),n())});function l(u){var p;o((p=u.active)==null?void 0:p.data.current)}const c=Be.useSensor(Be.MouseSensor,{activationConstraint:{distance:10}}),d=Be.useSensors(c);return r.jsxs(Be.DndContext,{sensors:d,onDragEnd:i,onDragStart:l,children:[e.children,r.jsx(Be.DragOverlay,{children:t?r.jsx("span",{style:{whiteSpace:"nowrap"},children:r.jsx(zn,{item:t})}):null})]})},{displayName:"DndProvider"}),qn=e=>{const{children:t,params:o,type:n}=e,a=s.useAPIClient(),[i,l]=x.useState([]),[c,d]=x.useState(!1),[u,p]=x.useState({tab:le.value,item:le.item}),f=s.useCompile(),{modal:y}=b.App.useApp(),h=x.useCallback(()=>P(null,null,function*(){const{data:C}=yield a.request({url:"workflowCategories:list",params:o});l(C.data),le.value&&!C.data.find(D=>D.id===le.value)&&(le.value="",le.item={},p({tab:"",item:{}})),d(!0)}),[a,o]);x.useEffect(()=>{h()},[h]);const g=C=>{y.confirm({title:f("{{t('Delete category')}}"),content:f("{{t('Are you sure you want to delete it?')}}"),onOk:()=>P(null,null,function*(){yield a.resource("workflowCategories").destroy({filter:{id:C}}),p({tab:"",item:{}}),le.value="",le.item={},h()})})},w=ae.memoize(C=>({items:[{key:"edit",label:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[A.uid()]:{"x-component":"EditWorkflowCategory","x-component-props":{item:C}}}}})},{key:"delete",label:f("{{t('Delete category')}}"),onClick:()=>g(C.id)}]}));return r.jsx(Mn.Provider,{value:{data:i,refresh:h,activeKey:u.tab,setActiveKey:C=>p({tab:C,item:i.find(D=>D.id===C)}),categoriesLoaded:c},children:r.jsx(yc,{children:r.jsx(b.Tabs,{addIcon:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddWorkflowCategory","x-component-props":{type:"primary",categoryType:n}}}}}),type:"editable-card",activeKey:u.tab,onChange:C=>{const D=i.find(S=>S.id===C);p({tab:C,item:D}),le.value=C,le.item=D,C===""&&h()},defaultActiveKey:u.tab||"",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:[{id:"",name:O("All"),closable:!1}].concat(i).filter(C=>C&&C.name!=null&&C.id!=null).map(C=>({label:C.id!==""?r.jsx("div",{"data-no-dnd":"true",children:r.jsx(hc,{item:C})}):f(C.name),key:C.id,closable:C.closable,closeIcon:r.jsx(b.Dropdown,{menu:w(C),children:r.jsx(H.MenuOutlined,{role:"button","aria-label":f(C.name),style:{padding:8,margin:"-8px"}})}),children:r.jsx(s.CardItem,{children:t})}))})})})},Un=A.observer(e=>{const{params:t={}}=e,{filter:o}=s.useParsedFilter({filterOption:t==null?void 0:t.filter}),n=x.useMemo(()=>{const c=o&&Object.keys(o).length>0?v({},o):{};return le.value?c["category.id"]=[le.value]:delete c["category.id"],{collection:Ke,action:"listExtended",params:F(v({},t),{filter:v({},c)}),rowKey:"id"}},[t,o,le.value]),a=(t==null?void 0:t.filter)&&Object.keys(t.filter).length>0,i=o&&Object.keys(o).length>0;return a&&!i||!(i||(t==null?void 0:t.filter)&&Object.keys(t.filter).length>0)?null:r.jsx(s.TableBlockProvider,v(v({},e),n))}),Kn={type:"void",properties:{provider:{type:"void","x-decorator":Un,"x-decorator-props":{params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]}},"x-component":qn,"x-component-props":{params:{paginate:!1,sort:["sort"],filter:{type:{$ne:"approval"}}},type:"workflow"},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":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},fuzzySearch:{type:"void","x-component":"FuzzySearchInput","x-align":"left"},statusFilter:{type:"void","x-component":"EnabledStatusFilter","x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},load:{type:"void",title:`{{t("Load", { ns: "${m}" })}}`,"x-component":"Action","x-component-props":{icon:"UploadOutlined",openSize:"small"},properties:{modal:{type:"void",title:`{{t("Load a workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1}},title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input","x-reactions":{dependencies:["file"],fulfill:{state:{value:'{{$deps[0]?.title || $deps[0]?.filename || ""}}'}}}},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0,service:{params:{filter:{$and:[{type:{$ne:"approval"}}]}}}}},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}=ee.useTranslation(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),a=s.useFilterByTk(),{setVisible:i}=s.useActionContext(),l=A.useForm();return le.value&&le.item&&(l.setInitialValues({category:[le.item]}),l.setValues({category:[le.item]})),{run(){return P(this,null,function*(){const{values:d}=l,{data:u}=yield t.request({url:d.file.url,baseURL:"/"});yield n.load({filterByTk:a,values:F(v({},d),{workflow:u})}),b.message.success(e("Operation succeeded")),o(),i(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},create:jn}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:100},title:'{{t("Name")}}',properties:{title:{type:"string","x-component":"ColumnShowTitle"}}},category:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},title:`{{t("Category", { ns: "${m}" })}}`,properties:{category:{type:"array","x-component":"WorkflowCategoryColumn","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},title:`{{t("Status", { ns: "${m}" })}}`,properties:{enabled:{type:"void","x-component":"EnabledToggle","x-component-props":{resource:"workflows"}}}},allExecuted:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=s.useCollectionRecordData();return x.createElement("a",v({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:io}}}},executedTime:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:T("Finally executed on"),"x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{executedTime:{type:"string","x-component":"ColumnExecutedTime"}}},showCollection:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:T("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},showEventSource:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:T("Event source"),properties:{showEventSource:{type:"string","x-component":"ColumnShowEventSource"}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"string","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"workflows.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{fixed:"right"},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:Ln,revision:pc,test:mc,delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action.Link","x-component-props":{useAction:"{{ useDumpAction }}"}}}}}}}}}}}},xc=()=>{const{t:e}=ee.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(se.Link,{"aria-label":n(),to:Le(t),onClick:()=>o(!1),children:e("Configure")})};function bc(e){const t=A.useField(),o=s.usePlugin(re);return A.useFormEffects(()=>{A.onFieldChange("type",n=>{let a=!n.value;if(n.value){const i=o.triggers.get(n.value);i.sync!=null&&(a=!0,t.setValue(i.sync))}t.setPattern(a?"disabled":"editable")})}),r.jsx(Ne,v({},e))}function _n(e){const{schema:t=Kn,components:o,scopes:n}=e,a=x.useContext(s.SchemaComponentContext),{getTriggersOptions:i}=s.usePlugin(re);return r.jsx(s.ExtendCollectionsProvider,{collections:[Ke,ao,Vn],children:r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},a),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:v({WorkflowLink:xc,ExecutionResourceProvider:uc,ExecutionLink:Zt,OpenDrawer:Vo,ExecutionStatusSelect:jo,SyncOptionSelect:bc,ExecutionStatusColumn:Yt,ColumnShowTitle:ac,ColumnShowCollection:rc,AddWorkflowCategory:oc,AddWorkflowCategoryAction:$n,EditWorkflowCategory:cc,EditWorkflowCategoryAction:Bn,ColumnShowEventSource:sc,ColumnExecutedTime:qo,WorkflowCategoryColumn:Uo,EnabledStatusFilter:_o},o),scope:v({getTriggersOptions:i,ExecutionRetryAction:Xt,useCreateFormBlockProps:Wn,useDumpAction:nn,useRevisionAction:rn},n)})})})}class re extends s.Plugin{constructor(){super(...arguments),this.triggers=new W.Registry,this.instructions=new W.Registry,this.getTriggersOptions=()=>Array.from(this.triggers.getEntities()).map(a=>{var[t,i]=a,l=i,{title:o}=l,n=Q(l,["title"]);return{value:t,label:o,color:"gold",options:n}})}isWorkflowSync(t){var o;return(o=this.triggers.get(t.type).sync)!=null?o:t.sync}registerTrigger(t,o){if(typeof o=="function")this.triggers.register(t,new o);else if(o)this.triggers.register(t,o);else throw new TypeError("invalid trigger type to register")}registerInstruction(t,o){if(typeof o=="function")this.instructions.register(t,new o);else if(o instanceof oe)this.instructions.register(t,o);else throw new TypeError("invalid instruction type to register")}afterAdd(){return P(this,null,function*(){yield this.pm.add(Ki),yield this.pm.add($i),yield this.pm.add(Ei),yield this.pm.add(Ca),yield this.pm.add(Es),yield this.pm.add(is),yield this.pm.add(Xr),yield this.pm.add(Jr),yield this.pm.add(qi),yield this.pm.add(Is),yield this.pm.add(Zi),yield this.pm.add(Vi),yield this.pm.add(Oi),yield this.pm.add(Hi),yield this.pm.add(wi),yield this.pm.add(Ds),yield this.pm.add(Ts)})}load(){return P(this,null,function*(){this.addComponents(),this.app.systemSettingsManager.add(`business-components.${m}`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:_n,aclSnippet:"pm.workflow.workflows",sort:-80}),this.app.systemSettingsManager.add(`business-components.${m}/:id`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.workflow`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:lo,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.executions`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:zt,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(Ol),this.registerTrigger("collection",El),this.registerTrigger("schedule",Zl),this.registerInstruction("calculation",Xi),this.registerInstruction("condition",vl),this.registerInstruction("end",Sl),this.registerInstruction("updateorcreate",Dl),this.registerInstruction("query",Al),this.registerInstruction("select",Il),this.registerInstruction("create",Cl),this.registerInstruction("update",Tl),this.registerInstruction("destroy",kl)})}addComponents(){this.app.addComponents({WorkflowLink:fr,WorkflowPage:lo,ExecutionPage:zt,CollectionTreeSelect:mr})}}k.AddButton=Lt,k.AdditionNotifiedPerson=ws,k.AutoResizeInput=Lo,k.BaseTypeSets=Pe,k.Branch=je,k.BuiltinGroupType=_e,k.CheckboxGroupWithTooltip=Bo,k.CollectionBlockInitializer=Te,k.ColumnExecutedTime=qo,k.ConfigButtonMessage=ks,k.DetailsBlockProvider=qt,k.EXECUTION_STATUS=ye,k.EnabledStatusFilter=_o,k.ExecutionContextProvider=dn,k.ExecutionLink=Zt,k.ExecutionPage=zt,k.ExecutionRetryAction=Xt,k.ExecutionStatusColumn=Yt,k.ExecutionStatusOptions=gt,k.ExecutionStatusOptionsMap=ht,k.ExecutionStatusSelect=jo,k.FieldsSelect=rt,k.FilterDynamicComponent=Ae,k.FlowContext=Ve,k.Instruction=oe,k.JOB_STATUS=Ce,k.JobStatusOptions=yt,k.JobStatusOptionsMap=ot,k.Node=vo,k.NodeDefaultView=it,k.OpenDrawer=Vo,k.ProviderContextNode=bo,k.ProviderContextWorkflow=yr,k.RadioWithTooltip=Ne,k.SelectNotifiedPerson=ys,k.SimpleDesigner=Jt,k.TabTableBlockProvider=Un,k.Trigger=Re,k.ValueBlock=Ie,k.WorkflowCategoryColumn=Uo,k.WorkflowPage=lo,k.WorkflowPane=_n,k.WorkflowTabCardItem=qn,k.WorkflowVariableCodeMirror=ms,k.WorkflowVariableInput=ke,k.WorkflowVariableJSON=$o,k.WorkflowVariableRawTextArea=Mo,k.WorkflowVariableTextArea=at,k.collectionWorkflowCategories=Vn,k.collectionWorkflows=Ke,k.createWorkflow=jn,k.currentFormOptions=Do,k.default=re,k.defaultFieldNames=xe,k.executionCollection=ao,k.executionSchema=io,k.getCollectionFieldOptions=fe,k.getExecutionSchema=En,k.getWorkflowDetailPath=Le,k.getWorkflowExecutionsPath=He,k.isValidFilter=nt,k.linkNodes=xt,k.nodesOptions=vt,k.scopeOptions=Ut,k.systemOptions=Oo,k.traverseSchema=bt,k.triggerOptions=wt,k.updateWorkflow=Ln,k.useAvailableUpstreams=We,k.useContextNode=he,k.useCreateFormBlockProps=Wn,k.useDumpAction=nn,k.useFlowContext=Y,k.useGetAriaLabelOfAddButton=ft,k.useRecordTriggerWorkflowsActionProps=Ta,k.useRevisionAction=rn,k.useStyles=we,k.useTrigger=et,k.useTriggerWorkflowsActionProps=Fa,k.useWorkflowAnyExecuted=zo,k.useWorkflowExecuted=Qt,k.useWorkflowVariableFormOptions=Eo,k.useWorkflowVariableOptions=me,k.workflowFieldset=be,k.workflowSchema=Kn,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
902
+ `},properties:Ql[o]}}},components:{OnField:xn,RepeatField:Yl,EndsByField:Vl}})]})};class Rl extends Re{constructor(){super(...arguments),this.sync=!1,this.title=`{{t("Schedule event", { ns: "${m}" })}}`,this.description=`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`,this.fieldset={config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={ScheduleConfig:Xl}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&i.push({key:"date",value:"date",label:O("Trigger time")}),t.mode===qe.DATE_FIELD){const[c]=fe(F(v({appends:["data",...((l=t.appends)==null?void 0:l.map(d=>`data.${d}`))||[]]},o),{fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:O("Trigger data")}}],compile:n,getCollectionFields:a}));c&&i.push(c)}return i}useInitializers(t){return t.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const ao={name:"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: "${m}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"bigInt",type:"bigInt",name:"executionCost",uiSchema:{type:"bigInt",title:`{{t("Execution time", { ns: "${m}" })}}`,"x-component":({value:e})=>{const t=s.useCollectionRecordData(),o=Wr(e,t);return r.jsx(s.Input,{type:"text",value:o})},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${m}" })}}`,"x-component"({value:e}){const{setVisible:t}=s.useActionContext();return r.jsx(se.Link,{to:Le(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:gt}}]},En=e=>{const{isShowActionClear:t=!0}=e||{};return{type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${m}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:ao,dataSource:"main",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{isShow:t,useAction(){const{t:o}=ve(),{refresh:n,params:a}=s.useDataBlockRequest(),i=s.useDataBlockResource(),{setVisible:l}=s.useActionContext();return{run(){return P(this,null,function*(){yield i.destroy({filter:a==null?void 0:a.filter}),b.message.success(o("Operation succeeded")),n(),l(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${m}" })}}`,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: "${m}" })}}`}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{width:50},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},retry:{type:"void",title:`{{t("Retry", { ns: "${m}" })}}`,"x-component":"Action.Link","x-use-component-props":"ExecutionRetryAction"}}}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},executionCost:{type:"void",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{executionCost:{type:"bigInt","x-component":"CollectionField","x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}}},io=En();function ec(n){var a=n,{params:e,filter:t={}}=a,o=Q(a,["params","filter"]);const{workflow:i}=Y(),l=F(v({},o),{params:F(v({},e),{filter:F(v({},e==null?void 0:e.filter),{key:i.key})})});return r.jsx(s.TableBlockProvider,v({},l))}function tc(){var J,_;const e=se.useNavigate(),{t}=ee.useTranslation(),o=s.useApp(),{data:n,refresh:a,loading:i}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:c}=s.useDocumentTitle(),[d,u]=x.useState(!1),[p,f]=x.useState(!1),[y,h]=x.useState(null),{styles:g}=we(),{modal:w}=b.App.useApp(),D=(J=window.location.pathname.split("business-components/")[1])==null?void 0:J.split("/")[0],S=o.systemSettingsManager.get(`business-components.${D}`)||{},I=s.useCompile();if(x.useEffect(()=>{var de;const{title:z}=(de=n==null?void 0:n.data)!=null?de:{};c==null||c(`${O("Workflow")}${z?`: ${z}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return i?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const R=(_=n==null?void 0:n.data)!=null?_:{},{nodes:M=[],revisions:E=[]}=R,N=Q(R,["nodes","revisions"]);xt(M);const V=M.find(z=>!z.upstream);function K({key:z}){z!==N.id&&e(Le(z,D))}function q(z){return P(this,null,function*(){yield l.update({filterByTk:N.id,values:{enabled:z}}),a()})}function G(){return P(this,null,function*(){const{data:{data:z}}=yield l.retry({filterByTk:N.id,filter:{key:N.key}});e(He(z.id,D))})}function j(){return P(this,null,function*(){var z,de;try{const{data:{data:te}}=yield l.test({filterByTk:N.id,filter:{key:N.key},values:{data:{}}});if(!te||!te.id){b.message.error(O("Failed to create execution"));return}e(He(te.id,D))}catch(te){console.error("Test execution failed:",te),b.message.error(((de=(z=te==null?void 0:te.response)==null?void 0:z.data)==null?void 0:de.message)||(te==null?void 0:te.message)||O("Test execution failed"))}})}function X(){return P(this,null,function*(){const{data:{data:z}}=yield l.revision({filterByTk:N.id,filter:{key:N.key},values:{color:N.color}});b.message.success(t("Operation succeeded")),e(Le(z.id,D))})}function B(){return P(this,null,function*(){const z=N.current?O("Delete a main version will cause all other revisions to be deleted too."):"";w.confirm({title:t("Are you sure you want to delete it?"),content:z,onOk(){return P(this,null,function*(){var te;yield l.destroy({filterByTk:N.id}),b.message.success(t("Operation succeeded")),e(N.current?o.systemSettingsManager.getRoutePath("workflow"):Le((te=E.find($e=>$e.current))==null?void 0:te.id,D))})}})})}const L=()=>P(null,null,function*(){y?(yield l.moveWorkflow({id:N.id,targetKey:y}),b.message.success(O("Move success")),f(!1),N.key=y,a()):b.message.error(O("Select target workflow"))});function $(de){return P(this,arguments,function*({key:z}){switch(z){case"history":u(!0);return;case"test":return j();case"Retry":return G();case"revision":return X();case"delete":return B();case"move":h(null),f(!0);return}})}const U=N.executed&&!E.find(z=>!z.executed&&new Date(z.createdAt)>new Date(N.createdAt));return r.jsxs(Ve.Provider,{value:{workflow:N,nodes:M,refresh:a},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(To,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(se.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${D}`),children:I(S.label)})},{title:r.jsx("strong",{children:N.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:K,defaultSelectedKeys:[`${N.id}`],className:s.cx(g.dropdownClass,g.workflowVersionDropdownClass),items:E.sort((z,de)=>de.id-z.id).map((z,de)=>({role:"button","aria-label":`version-${de}`,key:`${z.id}`,icon:z.current?r.jsx(H.RightOutlined,{}):null,className:s.cx({executed:z.executed,unexecuted:!z.executed,enabled:z.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${z.id}`}),r.jsx("time",{children:W.str2moment(z.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:O("Version")}),r.jsx("span",{children:N!=null&&N.id?`#${N.id}`:null}),r.jsx(H.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:N.enabled,onChange:q,checkedChildren:O("On"),unCheckedChildren:O("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:O("Show execution history"),disabled:!N.allExecuted},{role:"button","aria-label":"test",key:"test",label:O("Execute empty test")},{role:"button","aria-label":"Retry",key:"Retry",label:O("Retry"),disabled:!N.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:O("Copy to new version"),disabled:!U},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")},{role:"button","aria-label":"move",key:"move",label:O("Move"),disabled:N.current}],onClick:$},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(H.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:d,setVisible:u},children:r.jsx(s.SchemaComponent,{schema:io,components:{ExecutionResourceProvider:ec,ExecutionLink:Zt,ExecutionStatusColumn:Yt},scope:{ExecutionRetryAction:Xt}})})]})]}),r.jsx(Fo,{entry:V}),r.jsxs(b.Modal,{title:O("Move workflow"),visible:p,onOk:L,onCancel:()=>{f(!1)},children:[r.jsx("p",{children:O("Move current version to another workflow")}),r.jsx(s.WorkflowSelect,{buttonAction:"submit",noCollection:!0,label:"title",actionType:"update",value:y,filterType:N.type,filterSync:N.sync,filterKey:{$ne:N.key},onChange:z=>h(z)})]})]})}const lo=()=>{const e=se.useParams(),{styles:t}=we();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.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:["createdBy","nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:tc}})})},Mn=x.createContext({data:[],refresh:()=>{},activeKey:"",setActiveKey:()=>{},categoriesLoaded:!1}),co=()=>x.useContext(Mn),oc=A.observer(e=>{const{value:t}=e,o=s.useCompile();return r.jsx(r.Fragment,{children:t==null?void 0:t.map(n=>r.jsx(b.Tag,{color:n.color,children:o(n==null?void 0:n.name)},n.name))})},{displayName:"WorkflowCategory"}),nc=()=>{const e=A.useForm(),t=s.useActionContext(),{refresh:o}=co(),n=s.useAPIClient();return{run(){return P(this,null,function*(){yield e.submit();const i=ae.cloneDeep(e.values);yield n.resource("workflowCategories").create({values:F(v({},i),{type:t==null?void 0:t.categoryType})}),t.setVisible(!1),yield e.reset(),o()})}}},rc=e=>r.jsx($n,v({},e)),$n=e=>{const{scope:t,getContainer:o,children:n,categoryType:a}=e,[i,l]=x.useState(!1),{t:c}=ve(),d=sc(a),u={visible:i,setVisible:l,categoryType:a};return r.jsxs(s.ActionContextProvider,{value:u,children:[r.jsx("div",{onClick:()=>l(!0),title:c("Add category"),children:n||r.jsx(H.PlusOutlined,{})}),r.jsx(s.SchemaComponent,{schema:d,components:{CollectionCategory:oc},scope:v({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useCreateworkflowCategry:nc},t)})]})},sc=e=>({type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",categoryType:e,useAction:"{{ useCreateworkflowCategry }}",style:{marginLeft:"8px"}}}}}}}}}),ac=()=>{var i;const e=s.useCollectionRecordData(),t=s.useCollectionManager(),o=(i=e.config)==null?void 0:i.collection,n=t.getCollection(o),a=o?`${n==null?void 0:n.options.title}(${o})`:"-";return r.jsx("div",{style:{textAlign:"center"},children:a})},ic=()=>{const t=s.useCollectionRecordData().eventSourceName||"-";return r.jsx("div",{style:{textAlign:"left"},children:t})},lc=()=>{const e=s.useCollectionRecordData(),t=s.useCompile(),n=s.usePlugin("workflow").getTriggersOptions(),{type:a,title:i}=e,l=n.find(c=>c.value===a);return r.jsx(b.Tooltip,{title:t(l.label),placement:"right",color:"cyan",style:{},children:r.jsx("span",{style:{display:"inline-block",maxWidth:300,textAlign:"left",cursor:"pointer",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})})},cc=()=>{const e=A.useForm(),t=s.useActionContext(),{refresh:o}=co(),n=s.useAPIClient(),{id:a}=s.useRecord();return{run(){return P(this,null,function*(){yield e.submit();const l=ae.cloneDeep(e.values);yield n.resource("workflowCategories").update({filter:{id:a},values:v({},l)}),t.setVisible(!1),yield e.reset(),o()})}}},dc=e=>{const t=s.useRecord(),o=s.useRequest(()=>Promise.resolve({data:ae.cloneDeep(t)}),F(v({},e),{manual:!0})),n=s.useActionContext();return x.useEffect(()=>{n.visible&&o.run()},[n.visible]),o},uc=e=>r.jsx(Bn,v({},e)),Bn=e=>{const{scope:t,getContainer:o,item:n,children:a}=e,[i,l]=x.useState(!1),c=s.useCompile();return r.jsx(s.RecordProvider,{record:n,children:r.jsxs(s.ActionContextProvider,{value:{visible:i,setVisible:l},children:[r.jsx(r.Fragment,{children:a||r.jsx("span",{onClick:()=>l(!0),children:c('{{ t("Edit category") }}')})}),r.jsx(s.SchemaComponent,{schema:pc,scope:v({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useEditCategry:cc,useValuesFromRecord:dc},t)})]})})},pc={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},mc=n=>{var a=n,{params:e,filter:t={}}=a,o=Q(a,["params","filter"]);const i=s.useCollectionRecordData(),l=F(v({},o),{params:F(v({},e),{filter:F(v({},e==null?void 0:e.filter),{key:i.key})})});return r.jsx(s.TableBlockProvider,v({},l))},le=A.observable({value:"",item:{}}),Ke={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: "${m}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"belongsToMany",name:"category",target:"workflowCategories",sourceKey:"key",foreignKey:"workflowKey",otherKey:"categoryId",targetKey:"id",sortBy:"sort",through:"workflowCategory",collectionName:"workflows",interface:"m2m",uiSchema:{title:`{{t("Category", { ns: "${m}" })}}`,type:"array","x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"name"}}}},{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: "${m}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${m}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${m}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${m}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:T("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"workflows",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{value:"id",label:"nickname"}}}}]},Vn={name:"workflowCategories",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"input",uiSchema:{title:'{{t("Type")}}',type:"string","x-component":"Input"}}]},be={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem",default:"general-action","x-hidden":!0},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect",default:!0,"x-component-props":{options:[{label:`{{ t("Queue Mode", { ns: "${m}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${m}" }) }}`},{label:`{{ t("Transactional Mode", { ns: "${m}" }) }}`,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: "${m}" }) }}`}]}},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0,service:{params:{filter:{$and:[{type:{$ne:"approval"}}]}}}}},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: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Wn=()=>{const{form:e}=s.useFormBlockProps();return le.value&&(e.values.category=[le.item]),{form:e}},jn={type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":`${Ke.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:Ke},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},title:be.title,category:be.category,type:be.type,sync:be.sync,description:be.description,options:be.options}}}}}}}},Ln={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":`${Ke.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:Ke,params:{appends:["category"]}},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"},"x-action-settings":{isDeltaChanged:!0}}}},title:be.title,category:be.category,type:be.type,enabled:be.enabled,sync:be.sync,description:be.description,options:be.options}}}}}}}},fc={type:"void",title:`{{t("Duplicate", { ns: "${m}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0,service:{params:{filter:{$and:[{type:{$ne:"approval"}}]}}}}},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useRevisionAction }}"}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},gc={type:"void",title:`{{t("Test", { ns: "${m}" })}}`,"x-component":"Action.Link",properties:{modal:{type:"void",title:`{{t("Test workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{params:{type:"string",title:'{{t("Input")}}',description:`{{t("Data is the trigger variable, it can be { data: 0 }, or { data: { id: 0 }}", { ns: "${m}" })}}`,"x-decorator":"FormItem",default:'{ "data":{} }',"x-component":"CodeMirror","x-component-props":{height:"50vh",defaultLanguage:"json"}},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}=ee.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),a=s.useFilterByTk(),{values:i}=A.useForm();return{run(){return P(this,null,function*(){try{const c=JSON.parse(i.params);yield o.test({filterByTk:a,values:c}),t(),n(!1)}catch(c){console.error(c)}})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}};function hc(e){const{isOver:t,setNodeRef:o}=Be.useDroppable({id:e.id,data:e.data}),n=t?{color:"green"}:void 0;return r.jsx("div",{ref:o,style:n,children:e.children})}function yc(e){const{attributes:t,listeners:o,setNodeRef:n}=Be.useDraggable({id:e.id,data:e.data});return r.jsx("div",F(v(v({ref:n},o),t),{children:r.jsx("div",{children:e.children})}))}const xc=A.observer(({item:e})=>r.jsx(hc,{id:e.id.toString(),data:e,children:r.jsx("div",{children:r.jsx(yc,{id:e.id.toString(),data:e,children:r.jsx(zn,{item:e})})})}),{displayName:"TabTitle"}),zn=({item:e})=>{const{t}=ee.useTranslation(),o=s.useCompile();return r.jsxs(b.Space,{children:[r.jsx(b.Badge,{color:e.color}),t(o(e.name))]})},bc=A.observer(e=>{const[t,o]=x.useState(null),{refresh:n}=co(),a=s.useAPIClient(),i=u=>P(null,null,function*(){const{active:p,over:f}=u;setTimeout(()=>{o(null)}),f&&f.id!==p.id&&(yield a.resource("workflowCategories").move({sourceId:p.id,targetId:f.id}),n())});function l(u){var p;o((p=u.active)==null?void 0:p.data.current)}const c=Be.useSensor(Be.MouseSensor,{activationConstraint:{distance:10}}),d=Be.useSensors(c);return r.jsxs(Be.DndContext,{sensors:d,onDragEnd:i,onDragStart:l,children:[e.children,r.jsx(Be.DragOverlay,{children:t?r.jsx("span",{style:{whiteSpace:"nowrap"},children:r.jsx(zn,{item:t})}):null})]})},{displayName:"DndProvider"}),qn=e=>{const{children:t,params:o,type:n}=e,a=s.useAPIClient(),[i,l]=x.useState([]),[c,d]=x.useState(!1),[u,p]=x.useState({tab:le.value,item:le.item}),f=s.useCompile(),{modal:y}=b.App.useApp(),h=x.useCallback(()=>P(null,null,function*(){const{data:C}=yield a.request({url:"workflowCategories:list",params:o});l(C.data),le.value&&!C.data.find(D=>D.id===le.value)&&(le.value="",le.item={},p({tab:"",item:{}})),d(!0)}),[a,o]);x.useEffect(()=>{h()},[h]);const g=C=>{y.confirm({title:f("{{t('Delete category')}}"),content:f("{{t('Are you sure you want to delete it?')}}"),onOk:()=>P(null,null,function*(){yield a.resource("workflowCategories").destroy({filter:{id:C}}),p({tab:"",item:{}}),le.value="",le.item={},h()})})},w=ae.memoize(C=>({items:[{key:"edit",label:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[A.uid()]:{"x-component":"EditWorkflowCategory","x-component-props":{item:C}}}}})},{key:"delete",label:f("{{t('Delete category')}}"),onClick:()=>g(C.id)}]}));return r.jsx(Mn.Provider,{value:{data:i,refresh:h,activeKey:u.tab,setActiveKey:C=>p({tab:C,item:i.find(D=>D.id===C)}),categoriesLoaded:c},children:r.jsx(bc,{children:r.jsx(b.Tabs,{addIcon:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddWorkflowCategory","x-component-props":{type:"primary",categoryType:n}}}}}),type:"editable-card",activeKey:u.tab,onChange:C=>{const D=i.find(S=>S.id===C);p({tab:C,item:D}),le.value=C,le.item=D,C===""&&h()},defaultActiveKey:u.tab||"",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:[{id:"",name:O("All"),closable:!1}].concat(i).filter(C=>C&&C.name!=null&&C.id!=null).map(C=>({label:C.id!==""?r.jsx("div",{"data-no-dnd":"true",children:r.jsx(xc,{item:C})}):f(C.name),key:C.id,closable:C.closable,closeIcon:r.jsx(b.Dropdown,{menu:w(C),children:r.jsx(H.MenuOutlined,{role:"button","aria-label":f(C.name),style:{padding:8,margin:"-8px"}})}),children:r.jsx(s.CardItem,{children:t})}))})})})},Un=A.observer(e=>{const{params:t={}}=e,{filter:o}=s.useParsedFilter({filterOption:t==null?void 0:t.filter}),n=x.useMemo(()=>{const c=o&&Object.keys(o).length>0?v({},o):{};return le.value?c["category.id"]=[le.value]:delete c["category.id"],{collection:Ke,action:"listExtended",params:F(v({},t),{filter:v({},c)}),rowKey:"id"}},[t,o,le.value]),a=(t==null?void 0:t.filter)&&Object.keys(t.filter).length>0,i=o&&Object.keys(o).length>0;return a&&!i||!(i||(t==null?void 0:t.filter)&&Object.keys(t.filter).length>0)?null:r.jsx(s.TableBlockProvider,v(v({},e),n))}),Kn={type:"void",properties:{provider:{type:"void","x-decorator":Un,"x-decorator-props":{params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]}},"x-component":qn,"x-component-props":{params:{paginate:!1,sort:["sort"],filter:{type:{$ne:"approval"}}},type:"workflow"},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":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},fuzzySearch:{type:"void","x-component":"FuzzySearchInput","x-align":"left"},statusFilter:{type:"void","x-component":"EnabledStatusFilter","x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},load:{type:"void",title:`{{t("Load", { ns: "${m}" })}}`,"x-component":"Action","x-component-props":{icon:"UploadOutlined",openSize:"small"},properties:{modal:{type:"void",title:`{{t("Load a workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1}},title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input","x-reactions":{dependencies:["file"],fulfill:{state:{value:'{{$deps[0]?.title || $deps[0]?.filename || ""}}'}}}},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0,service:{params:{filter:{$and:[{type:{$ne:"approval"}}]}}}}},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}=ee.useTranslation(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),a=s.useFilterByTk(),{setVisible:i}=s.useActionContext(),l=A.useForm();return le.value&&le.item&&(l.setInitialValues({category:[le.item]}),l.setValues({category:[le.item]})),{run(){return P(this,null,function*(){const{values:d}=l,{data:u}=yield t.request({url:d.file.url,baseURL:"/"});yield n.load({filterByTk:a,values:F(v({},d),{workflow:u})}),b.message.success(e("Operation succeeded")),o(),i(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},create:jn}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:100},title:'{{t("Name")}}',properties:{title:{type:"string","x-component":"ColumnShowTitle"}}},category:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},title:`{{t("Category", { ns: "${m}" })}}`,properties:{category:{type:"array","x-component":"WorkflowCategoryColumn","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},title:`{{t("Status", { ns: "${m}" })}}`,properties:{enabled:{type:"void","x-component":"EnabledToggle","x-component-props":{resource:"workflows"}}}},allExecuted:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=s.useCollectionRecordData();return x.createElement("a",v({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:io}}}},executedTime:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:T("Finally executed on"),"x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{executedTime:{type:"string","x-component":"ColumnExecutedTime"}}},showCollection:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:T("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},showEventSource:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:T("Event source"),properties:{showEventSource:{type:"string","x-component":"ColumnShowEventSource"}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"string","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"workflows.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{fixed:"right"},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:Ln,revision:fc,test:gc,delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action.Link","x-component-props":{useAction:"{{ useDumpAction }}"}}}}}}}}}}}},vc=()=>{const{t:e}=ee.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(se.Link,{"aria-label":n(),to:Le(t),onClick:()=>o(!1),children:e("Configure")})};function wc(e){const t=A.useField(),o=s.usePlugin(re);return A.useFormEffects(()=>{A.onFieldChange("type",n=>{let a=!n.value;if(n.value){const i=o.triggers.get(n.value);i.sync!=null&&(a=!0,t.setValue(i.sync))}t.setPattern(a?"disabled":"editable")})}),r.jsx(Ne,v({},e))}function _n(e){const{schema:t=Kn,components:o,scopes:n}=e,a=x.useContext(s.SchemaComponentContext),{getTriggersOptions:i}=s.usePlugin(re);return r.jsx(s.ExtendCollectionsProvider,{collections:[Ke,ao,Vn],children:r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},a),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:v({WorkflowLink:vc,ExecutionResourceProvider:mc,ExecutionLink:Zt,OpenDrawer:Vo,ExecutionStatusSelect:jo,SyncOptionSelect:wc,ExecutionStatusColumn:Yt,ColumnShowTitle:lc,ColumnShowCollection:ac,AddWorkflowCategory:rc,AddWorkflowCategoryAction:$n,EditWorkflowCategory:uc,EditWorkflowCategoryAction:Bn,ColumnShowEventSource:ic,ColumnExecutedTime:qo,WorkflowCategoryColumn:Uo,EnabledStatusFilter:_o},o),scope:v({getTriggersOptions:i,ExecutionRetryAction:Xt,useCreateFormBlockProps:Wn,useDumpAction:nn,useRevisionAction:rn},n)})})})}class re extends s.Plugin{constructor(){super(...arguments),this.triggers=new W.Registry,this.instructions=new W.Registry,this.getTriggersOptions=()=>Array.from(this.triggers.getEntities()).map(a=>{var[t,i]=a,l=i,{title:o}=l,n=Q(l,["title"]);return{value:t,label:o,color:"gold",options:n}})}isWorkflowSync(t){var o;return(o=this.triggers.get(t.type).sync)!=null?o:t.sync}registerTrigger(t,o){if(typeof o=="function")this.triggers.register(t,new o);else if(o)this.triggers.register(t,o);else throw new TypeError("invalid trigger type to register")}registerInstruction(t,o){if(typeof o=="function")this.instructions.register(t,new o);else if(o instanceof oe)this.instructions.register(t,o);else throw new TypeError("invalid instruction type to register")}afterAdd(){return P(this,null,function*(){yield this.pm.add(Gi),yield this.pm.add(Vi),yield this.pm.add($i),yield this.pm.add(Sa),yield this.pm.add($s),yield this.pm.add(is),yield this.pm.add(Xr),yield this.pm.add(Jr),yield this.pm.add(Ki),yield this.pm.add(Ts),yield this.pm.add(Ri),yield this.pm.add(ji),yield this.pm.add(Ei),yield this.pm.add(Yi),yield this.pm.add(cs),yield this.pm.add(ki),yield this.pm.add(Ps),yield this.pm.add(Ds)})}load(){return P(this,null,function*(){this.addComponents(),this.app.systemSettingsManager.add(`business-components.${m}`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:_n,aclSnippet:"pm.workflow.workflows",sort:-80}),this.app.systemSettingsManager.add(`business-components.${m}/:id`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.workflow`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:lo,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.executions`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:zt,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(El),this.registerTrigger("collection",$l),this.registerTrigger("schedule",Rl),this.registerInstruction("calculation",el),this.registerInstruction("condition",Cl),this.registerInstruction("end",Il),this.registerInstruction("updateorcreate",Pl),this.registerInstruction("query",Fl),this.registerInstruction("select",Tl),this.registerInstruction("create",Sl),this.registerInstruction("update",Dl),this.registerInstruction("destroy",Al)})}addComponents(){this.app.addComponents({WorkflowLink:fr,WorkflowPage:lo,ExecutionPage:zt,CollectionTreeSelect:mr})}}k.AddButton=Lt,k.AdditionNotifiedPerson=ks,k.AutoResizeInput=Lo,k.BaseTypeSets=Pe,k.Branch=je,k.BuiltinGroupType=_e,k.CheckboxGroupWithTooltip=Bo,k.CollectionBlockInitializer=Te,k.ColumnExecutedTime=qo,k.ConfigButtonMessage=As,k.DetailsBlockProvider=qt,k.EXECUTION_STATUS=ye,k.EnabledStatusFilter=_o,k.ExecutionContextProvider=dn,k.ExecutionLink=Zt,k.ExecutionPage=zt,k.ExecutionRetryAction=Xt,k.ExecutionStatusColumn=Yt,k.ExecutionStatusOptions=gt,k.ExecutionStatusOptionsMap=ht,k.ExecutionStatusSelect=jo,k.FieldsSelect=rt,k.FilterDynamicComponent=Ae,k.FlowContext=Ve,k.Instruction=oe,k.JOB_STATUS=Ce,k.JobStatusOptions=yt,k.JobStatusOptionsMap=ot,k.Node=vo,k.NodeDefaultView=it,k.OpenDrawer=Vo,k.ProviderContextNode=bo,k.ProviderContextWorkflow=yr,k.RadioWithTooltip=Ne,k.SelectNotifiedPerson=bs,k.SimpleDesigner=Jt,k.TabTableBlockProvider=Un,k.Trigger=Re,k.ValueBlock=Ie,k.WorkflowCategoryColumn=Uo,k.WorkflowPage=lo,k.WorkflowPane=_n,k.WorkflowTabCardItem=qn,k.WorkflowVariableCodeMirror=gs,k.WorkflowVariableInput=ke,k.WorkflowVariableJSON=$o,k.WorkflowVariableRawTextArea=Mo,k.WorkflowVariableTextArea=at,k.collectionWorkflowCategories=Vn,k.collectionWorkflows=Ke,k.createWorkflow=jn,k.currentFormOptions=Do,k.default=re,k.defaultFieldNames=xe,k.executionCollection=ao,k.executionSchema=io,k.getCollectionFieldOptions=fe,k.getExecutionSchema=En,k.getWorkflowDetailPath=Le,k.getWorkflowExecutionsPath=He,k.isValidFilter=nt,k.linkNodes=xt,k.nodesOptions=vt,k.scopeOptions=Ut,k.systemOptions=Oo,k.traverseSchema=bt,k.triggerOptions=wt,k.updateWorkflow=Ln,k.useAvailableUpstreams=We,k.useContextNode=he,k.useCreateFormBlockProps=Wn,k.useDumpAction=nn,k.useFlowContext=Y,k.useGetAriaLabelOfAddButton=ft,k.useRecordTriggerWorkflowsActionProps=Da,k.useRevisionAction=rn,k.useStyles=we,k.useTrigger=et,k.useTriggerWorkflowsActionProps=Na,k.useWorkflowAnyExecuted=zo,k.useWorkflowExecuted=Qt,k.useWorkflowVariableFormOptions=Eo,k.useWorkflowVariableOptions=me,k.workflowFieldset=be,k.workflowSchema=Kn,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});