@nocobase/plugin-workflow 0.14.0-alpha.6 → 0.14.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/AddButton.d.ts +2 -1
- package/dist/client/Branch.d.ts +4 -2
- package/dist/client/constants.d.ts +2 -0
- package/dist/client/hooks/useGetAriaLabelOfAddButton.d.ts +6 -0
- package/dist/client/index.d.ts +8 -2
- package/dist/client/index.js +101 -98
- package/dist/client/nodes/aggregate.d.ts +6 -3
- package/dist/client/nodes/calculation.d.ts +6 -5
- package/dist/client/nodes/create.d.ts +3 -2
- package/dist/client/nodes/index.d.ts +1 -1
- package/dist/client/nodes/manual/SchemaConfig.d.ts +4 -2
- package/dist/client/nodes/manual/index.d.ts +3 -3
- package/dist/client/nodes/query.d.ts +3 -2
- package/dist/client/schemas/collection.d.ts +1 -0
- package/dist/client/triggers/collection.d.ts +1 -0
- package/dist/client/triggers/form.d.ts +2 -0
- package/dist/client/triggers/index.d.ts +4 -0
- package/dist/client/variable.d.ts +2 -0
- package/dist/externalVersion.js +9 -10
- package/dist/locale/zh-CN.d.ts +5 -3
- package/dist/locale/zh-CN.js +5 -3
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.js +4 -1
- package/dist/server/Processor.d.ts +5 -5
- package/dist/server/Processor.js +20 -10
- package/dist/server/actions/workflows.d.ts +1 -0
- package/dist/server/actions/workflows.js +13 -52
- package/dist/server/collections/flow_nodes.js +4 -0
- package/dist/server/constants.d.ts +2 -0
- package/dist/server/constants.js +4 -2
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +2 -0
- package/dist/server/instructions/index.d.ts +6 -4
- package/dist/server/instructions/manual/actions.js +9 -1
- package/dist/server/instructions/parallel.js +1 -1
- package/dist/server/migrations/20230221162902-jsonb-to-json.js +0 -16
- package/dist/server/migrations/20230809113132-workflow-options.js +5 -2
- package/dist/server/migrations/20231024172342-add-node-key.d.ts +4 -0
- package/dist/server/migrations/20231024172342-add-node-key.js +80 -0
- package/dist/server/triggers/form.d.ts +3 -3
- package/dist/server/triggers/form.js +17 -12
- package/dist/server/triggers/index.d.ts +2 -0
- package/dist/server/triggers/index.js +1 -1
- package/dist/server/triggers/schedule.js +1 -1
- package/dist/server/utils.js +5 -4
- package/package.json +2 -3
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(A,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/client"),require("react-i18next"),require("antd"),require("react"),require("@formily/react"),require("@nocobase/utils/client"),require("@formily/core"),require("react-router-dom"),require("dayjs"),require("@formily/antd-v5"),require("@nocobase/evaluators/client"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@ant-design/icons","@nocobase/client","react-i18next","antd","react","@formily/react","@nocobase/utils/client","@formily/core","react-router-dom","dayjs","@formily/antd-v5","@nocobase/evaluators/client","lodash"],r):(A=typeof globalThis!="undefined"?globalThis:A||self,r(A["@nocobase/plugin-workflow"]={},A.jsxRuntime,A["@ant-design/icons"],A["@nocobase/client"],A["react-i18next"],A.antd,A.react,A["@formily/react"],A["@nocobase/utils"],A["@formily/core"],A["react-router-dom"],A.dayjs,A["@formily/antd-v5"],A["@nocobase/evaluators"],A.lodash))})(this,function(A,r,F,i,ee,x,g,E,L,me,he,Ao,Se,Ye,To){"use strict";var Rg=Object.defineProperty,ev=Object.defineProperties;var tv=Object.getOwnPropertyDescriptors;var jt=Object.getOwnPropertySymbols;var qr=Object.prototype.hasOwnProperty,Jr=Object.prototype.propertyIsEnumerable;var ko=(A,r,F)=>r in A?Rg(A,r,{enumerable:!0,configurable:!0,writable:!0,value:F}):A[r]=F,v=(A,r)=>{for(var F in r||(r={}))qr.call(r,F)&&ko(A,F,r[F]);if(jt)for(var F of jt(r))Jr.call(r,F)&&ko(A,F,r[F]);return A},C=(A,r)=>ev(A,tv(r));var Yr=A=>typeof A=="symbol"?A:A+"",H=(A,r)=>{var F={};for(var i in A)qr.call(A,i)&&r.indexOf(i)<0&&(F[i]=A[i]);if(A!=null&&jt)for(var i of jt(A))r.indexOf(i)<0&&Jr.call(A,i)&&(F[i]=A[i]);return F};var Bt=(A,r,F)=>(ko(A,typeof r!="symbol"?r+"":r,F),F);var q=(A,r,F)=>new Promise((i,ee)=>{var x=L=>{try{E(F.next(L))}catch(me){ee(me)}},g=L=>{try{E(F.throw(L))}catch(me){ee(me)}},E=L=>L.done?i(L.value):Promise.resolve(L.value).then(x,g);E((F=F.apply(A,r)).next())});const d="workflow";function O(e,t={}){return i.i18n.t(e,C(v({},t),{ns:d}))}function Vt(){return ee.useTranslation(d)}const ye={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},dt=[{value:ye.QUEUEING,label:`{{t("Queueing", { ns: "${d}" })}}`,color:"blue",icon:r.jsx(F.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${d}" })}}`},{value:ye.STARTED,label:`{{t("On going", { ns: "${d}" })}}`,color:"gold",icon:r.jsx(F.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${d}" })}}`},{value:ye.RESOLVED,label:`{{t("Resolved", { ns: "${d}" })}}`,color:"green",icon:r.jsx(F.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${d}" })}}`},{value:ye.FAILED,label:`{{t("Failed", { ns: "${d}" })}}`,color:"red",icon:r.jsx(F.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${d}" })}}`},{value:ye.ERROR,label:`{{t("Error", { ns: "${d}" })}}`,color:"red",icon:r.jsx(F.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${d}" })}}`},{value:ye.ABORTED,label:`{{t("Aborted", { ns: "${d}" })}}`,color:"red",icon:r.jsx(F.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${d}" })}}`},{value:ye.CANCELED,label:`{{t("Canceled", { ns: "${d}" })}}`,color:"volcano",icon:r.jsx(F.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${d}" })}}`},{value:ye.REJECTED,label:`{{t("Rejected", { ns: "${d}" })}}`,color:"volcano",icon:r.jsx(F.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${d}" })}}`},{value:ye.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${d}" })}}`,color:"volcano",icon:r.jsx(F.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${d}" })}}`}],pt=dt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),X={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},mt=[{value:X.PENDING,label:`{{t("Pending", { ns: "${d}" })}}`,color:"gold",icon:r.jsx(F.ClockCircleOutlined,{})},{value:X.RESOLVED,label:`{{t("Resolved", { ns: "${d}" })}}`,color:"green",icon:r.jsx(F.CheckOutlined,{})},{value:X.FAILED,label:`{{t("Failed", { ns: "${d}" })}}`,color:"red",icon:r.jsx(F.ExclamationOutlined,{})},{value:X.ERROR,label:`{{t("Error", { ns: "${d}" })}}`,color:"red",icon:r.jsx(F.CloseOutlined,{})},{value:X.ABORTED,label:`{{t("Aborted", { ns: "${d}" })}}`,color:"red",icon:r.jsx(F.MinusOutlined,{rotate:90})},{value:X.CANCELED,label:`{{t("Canceled", { ns: "${d}" })}}`,color:"volcano",icon:r.jsx(F.MinusOutlined,{rotate:45})},{value:X.REJECTED,label:`{{t("Rejected", { ns: "${d}" })}}`,color:"volcano",icon:r.jsx(F.MinusOutlined,{})},{value:X.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${d}" })}}`,color:"volcano",icon:r.jsx(F.RedoOutlined,{})}],Ze=mt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),Qe=g.createContext({});function z(){return g.useContext(Qe)}const Zr=i.createStyles(({css:e,token:t})=>({container:e`
|
|
2
2
|
margin-bottom: 1.5em;
|
|
3
3
|
padding: 1em;
|
|
4
4
|
background-color: ${t.colorFillAlter};
|
|
@@ -23,7 +23,23 @@
|
|
|
23
23
|
p {
|
|
24
24
|
color: ${t.colorTextDescription};
|
|
25
25
|
}
|
|
26
|
-
`}));function
|
|
26
|
+
`}));function Oo(e){const{label:t,title:o,description:n}=e,{styles:s}=Zr();return r.jsxs("div",{className:i.cx(s.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:t}),r.jsx("dd",{children:r.jsx(x.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]})}var ft=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Fo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Io={exports:{}};/*!
|
|
27
|
+
Copyright (c) 2018 Jed Watson.
|
|
28
|
+
Licensed under the MIT License (MIT), see
|
|
29
|
+
http://jedwatson.github.io/classnames
|
|
30
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var n=[],s=0;s<arguments.length;s++){var a=arguments[s];if(a){var l=typeof a;if(l==="string"||l==="number")n.push(a);else if(Array.isArray(a)){if(a.length){var c=o.apply(null,a);c&&n.push(c)}}else if(l==="object"){if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]")){n.push(a.toString());continue}for(var u in a)t.call(a,u)&&a[u]&&n.push(u)}}}return n.join(" ")}e.exports?(o.default=o,e.exports=o):window.classNames=o})()})(Io);var Qr=Io.exports;const Xr=Fo(Qr),Rr=i.createStyles(({css:e,token:t})=>({statusButtonClass:e`
|
|
31
|
+
border: none;
|
|
32
|
+
.ant-tag {
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: 100%;
|
|
35
|
+
padding: 0;
|
|
36
|
+
margin-right: 0;
|
|
37
|
+
border-radius: 50%;
|
|
38
|
+
text-align: center;
|
|
39
|
+
}
|
|
40
|
+
`,noStatusButtonClass:e`
|
|
41
|
+
border-width: 2px;
|
|
42
|
+
`}));function Xe(e){var n;const{styles:t}=Rr();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:a}=e.statusMap[e.status];o=r.jsx(x.Tag,{color:a,children:s})}return r.jsx(x.Button,C(v({},e),{shape:"circle",size:"small",className:Xr(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const Lt=(e,t)=>({getAriaLabel:g.useCallback(n=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",n].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),ne=i.createStyles(({css:e,token:t})=>({workflowPageClass:e`
|
|
27
43
|
flex-grow: 1;
|
|
28
44
|
overflow: hidden;
|
|
29
45
|
display: flex;
|
|
@@ -65,6 +81,11 @@
|
|
|
65
81
|
align-items: center;
|
|
66
82
|
padding: 2em;
|
|
67
83
|
|
|
84
|
+
> .ant-alert {
|
|
85
|
+
margin-bottom: 2em;
|
|
86
|
+
font-size: 85%;
|
|
87
|
+
}
|
|
88
|
+
|
|
68
89
|
.end {
|
|
69
90
|
cursor: default;
|
|
70
91
|
|
|
@@ -118,6 +139,7 @@
|
|
|
118
139
|
`,branchBlockClass:e`
|
|
119
140
|
display: flex;
|
|
120
141
|
position: relative;
|
|
142
|
+
margin-top: 2em;
|
|
121
143
|
|
|
122
144
|
:before {
|
|
123
145
|
content: '';
|
|
@@ -187,6 +209,23 @@
|
|
|
187
209
|
width: 50%;
|
|
188
210
|
}
|
|
189
211
|
}
|
|
212
|
+
|
|
213
|
+
.end-sign {
|
|
214
|
+
position: relative;
|
|
215
|
+
display: flex;
|
|
216
|
+
flex-direction: column;
|
|
217
|
+
align-items: center;
|
|
218
|
+
justify-content: center;
|
|
219
|
+
width: 0;
|
|
220
|
+
height: 4em;
|
|
221
|
+
padding: 1em 0;
|
|
222
|
+
border-left: 1px dashed ${t.colorBgLayout};
|
|
223
|
+
|
|
224
|
+
.anticon {
|
|
225
|
+
font-size: 1.5em;
|
|
226
|
+
line-height: 100%;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
190
229
|
`,nodeBlockClass:e`
|
|
191
230
|
flex-grow: 1;
|
|
192
231
|
flex-shrink: 0;
|
|
@@ -213,7 +252,7 @@
|
|
|
213
252
|
box-shadow: ${t.boxShadow};
|
|
214
253
|
|
|
215
254
|
.workflow-node-remove-button {
|
|
216
|
-
|
|
255
|
+
display: block;
|
|
217
256
|
}
|
|
218
257
|
}
|
|
219
258
|
|
|
@@ -222,12 +261,11 @@
|
|
|
222
261
|
}
|
|
223
262
|
|
|
224
263
|
.workflow-node-remove-button {
|
|
264
|
+
display: none;
|
|
225
265
|
position: absolute;
|
|
226
266
|
right: 0.5em;
|
|
227
267
|
top: 0.5em;
|
|
228
268
|
color: ${t.colorText};
|
|
229
|
-
opacity: 0;
|
|
230
|
-
transition: opacity 0.3s ease;
|
|
231
269
|
|
|
232
270
|
&[disabled] {
|
|
233
271
|
display: none;
|
|
@@ -266,7 +304,7 @@
|
|
|
266
304
|
box-shadow: 0 0.25em 0.5em rgba(0, 0, 0, 0.25);
|
|
267
305
|
|
|
268
306
|
.workflow-node-remove-button {
|
|
269
|
-
|
|
307
|
+
display: block;
|
|
270
308
|
}
|
|
271
309
|
}
|
|
272
310
|
`,nodeJobButtonClass:e`
|
|
@@ -314,7 +352,6 @@
|
|
|
314
352
|
}
|
|
315
353
|
`,conditionClass:e`
|
|
316
354
|
position: relative;
|
|
317
|
-
height: 2em;
|
|
318
355
|
overflow: visible;
|
|
319
356
|
|
|
320
357
|
> span {
|
|
@@ -344,18 +381,18 @@
|
|
|
344
381
|
border-radius: 50%;
|
|
345
382
|
background-color: ${t.colorText};
|
|
346
383
|
color: ${t.colorBgContainer};
|
|
347
|
-
`}));function
|
|
384
|
+
`}));function es(){return!0}const zt=E.observer(e=>{const c=e,{filter:t=es}=c,o=H(c,["filter"]),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager(),{values:a}=E.useForm(),l=s(a==null?void 0:a.collection);return r.jsx(x.Select,C(v({popupMatchSelectWidth:!1},o),{options:l.filter(t).map(u=>{var p;return{label:n((p=u.uiSchema)==null?void 0:p.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Ut(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{Ut(e.properties[o],t)})}function ke(e,t,o=!1){const n=[];return e?t(e)&&(!o||!e.properties)?(n.push(e),n):(e.properties&&Object.keys(e.properties).forEach(s=>{n.push(...ke(e.properties[s],t))}),n):n}function ts(s){var a=s,{insert:e,collection:t,dataSource:o}=a,n=H(a,["insert","collection","dataSource"]);const{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager(),u=i.useRecordCollectionDataSourceItems("FormItem"),p=c(t);function m(b){return q(this,arguments,function*({item:y}){const f=y.template?yield l(y):null,h={type:"void",name:p.name,title:p.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:t,dataSource:o},"x-component":"CardItem","x-component-props":{title:n.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{useDetailsBlockProps}}"},"x-read-pretty":!0,properties:{grid:f||{type:"void","x-component":"Grid","x-initializer":"ReadPrettyFormItemInitializers",properties:{}}}}}};Ut(h,$=>{$["x-uid"]&&delete $["x-uid"]}),e(h)})}return r.jsx(i.SchemaInitializer.Item,C(v({},n),{onClick:m,items:u}))}function Me(e){return r.jsx(i.CollectionProvider,{collection:e.collection,children:r.jsx(ts,v({},e))})}const de={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},Do={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:i.css`
|
|
348
385
|
flex-direction: column;
|
|
349
|
-
`},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${d}" })}}`},_e={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=
|
|
386
|
+
`},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${d}" })}}`},_e={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=E.useForm();return{options:i.useCollectionFilterOptions(e==null?void 0:e.collection),className:i.css`
|
|
350
387
|
position: relative;
|
|
351
388
|
width: 100%;
|
|
352
|
-
`}},dynamicComponent:"FilterDynamicComponent"}},Xr={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"}}},Rr={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",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}}}}}}},je={type:"array",title:`{{t("Preload associations", { ns: "${d}" })}}`,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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){const{values:e}=I.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Be={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},es=[{label:`{{t("After record added", { ns: "${d}" })}}`,value:Be.CREATED},{label:`{{t("After record updated", { ns: "${d}" })}}`,value:Be.UPDATED},{label:`{{t("After record added or updated", { ns: "${d}" })}}`,value:Be.SAVED},{label:`{{t("After record deleted", { ns: "${d}" })}}`,value:Be.DELETED}],$o={title:`{{t("Collection event", { ns: "${d}" })}}`,type:"collection",description:`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${d}" })}}`,fieldset:{collection:C(v({},de),{"x-reactions":[...de["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${d}" })}}`,className:"auto-width"},enum:es,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${d}" })}}`,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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(e){return!e.hidden&&(e.uiSchema?!e.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Be.UPDATED})}}`}}}]},condition:C(v({},_e),{title:`{{t("Only triggers when match conditions", { ns: "${d}" })}}`,"x-component-props":{useProps:_e["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:C(v({},je),{"x-reactions":[...je["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Be.DELETED})}}`}}}]})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FieldsSelect:Vt},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:n}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:T("Trigger data")}}];return xe(C(v({},t),{fields:s,appends:["data",...((l=e.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],compile:o,getCollectionFields:n}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:Me,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};var dt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function So(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ts(e,t){for(var o=-1,n=e==null?0:e.length,s=Array(n);++o<n;)s[o]=t(e[o],o,e);return s}var ko=ts;function os(){this.__data__=[],this.size=0}var ns=os;function rs(e,t){return e===t||e!==e&&t!==t}var Ao=rs,ss=Ao;function as(e,t){for(var o=e.length;o--;)if(ss(e[o][0],t))return o;return-1}var pt=as,is=pt,ls=Array.prototype,cs=ls.splice;function us(e){var t=this.__data__,o=is(t,e);if(o<0)return!1;var n=t.length-1;return o==n?t.pop():cs.call(t,o,1),--this.size,!0}var ds=us,ps=pt;function ms(e){var t=this.__data__,o=ps(t,e);return o<0?void 0:t[o][1]}var fs=ms,hs=pt;function ys(e){return hs(this.__data__,e)>-1}var gs=ys,vs=pt;function bs(e,t){var o=this.__data__,n=vs(o,e);return n<0?(++this.size,o.push([e,t])):o[n][1]=t,this}var xs=bs,Cs=ns,ws=ds,$s=fs,Ss=gs,ks=xs;function Ve(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}Ve.prototype.clear=Cs,Ve.prototype.delete=ws,Ve.prototype.get=$s,Ve.prototype.has=Ss,Ve.prototype.set=ks;var mt=Ve,As=mt;function Ts(){this.__data__=new As,this.size=0}var Os=Ts;function Fs(e){var t=this.__data__,o=t.delete(e);return this.size=t.size,o}var Is=Fs;function Ds(e){return this.__data__.get(e)}var Ns=Ds;function Ps(e){return this.__data__.has(e)}var Es=Ps,Ms=typeof dt=="object"&&dt&&dt.Object===Object&&dt,To=Ms,_s=To,js=typeof self=="object"&&self&&self.Object===Object&&self,Bs=_s||js||Function("return this")(),ye=Bs,Vs=ye,Ls=Vs.Symbol,Ze=Ls,Oo=Ze,Fo=Object.prototype,zs=Fo.hasOwnProperty,Us=Fo.toString,Qe=Oo?Oo.toStringTag:void 0;function Gs(e){var t=zs.call(e,Qe),o=e[Qe];try{e[Qe]=void 0;var n=!0}catch(a){}var s=Us.call(e);return n&&(t?e[Qe]=o:delete e[Qe]),s}var Ws=Gs,Hs=Object.prototype,qs=Hs.toString;function Ks(e){return qs.call(e)}var Js=Ks,Io=Ze,Ys=Ws,Zs=Js,Qs="[object Null]",Xs="[object Undefined]",Do=Io?Io.toStringTag:void 0;function Rs(e){return e==null?e===void 0?Xs:Qs:Do&&Do in Object(e)?Ys(e):Zs(e)}var Le=Rs;function ea(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Xe=ea,ta=Le,oa=Xe,na="[object AsyncFunction]",ra="[object Function]",sa="[object GeneratorFunction]",aa="[object Proxy]";function ia(e){if(!oa(e))return!1;var t=ta(e);return t==ra||t==sa||t==na||t==aa}var No=ia,la=ye,ca=la["__core-js_shared__"],ua=ca,zt=ua,Po=function(){var e=/[^.]+$/.exec(zt&&zt.keys&&zt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function da(e){return!!Po&&Po in e}var pa=da,ma=Function.prototype,fa=ma.toString;function ha(e){if(e!=null){try{return fa.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var Eo=ha,ya=No,ga=pa,va=Xe,ba=Eo,xa=/[\\^$.*+?()[\]{}|]/g,Ca=/^\[object .+?Constructor\]$/,wa=Function.prototype,$a=Object.prototype,Sa=wa.toString,ka=$a.hasOwnProperty,Aa=RegExp("^"+Sa.call(ka).replace(xa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ta(e){if(!va(e)||ga(e))return!1;var t=ya(e)?Aa:Ca;return t.test(ba(e))}var Oa=Ta;function Fa(e,t){return e==null?void 0:e[t]}var Ia=Fa,Da=Oa,Na=Ia;function Pa(e,t){var o=Na(e,t);return Da(o)?o:void 0}var Te=Pa,Ea=Te,Ma=ye,_a=Ea(Ma,"Map"),Ut=_a,ja=Te,Ba=ja(Object,"create"),ft=Ba,Mo=ft;function Va(){this.__data__=Mo?Mo(null):{},this.size=0}var La=Va;function za(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ua=za,Ga=ft,Wa="__lodash_hash_undefined__",Ha=Object.prototype,qa=Ha.hasOwnProperty;function Ka(e){var t=this.__data__;if(Ga){var o=t[e];return o===Wa?void 0:o}return qa.call(t,e)?t[e]:void 0}var Ja=Ka,Ya=ft,Za=Object.prototype,Qa=Za.hasOwnProperty;function Xa(e){var t=this.__data__;return Ya?t[e]!==void 0:Qa.call(t,e)}var Ra=Xa,ei=ft,ti="__lodash_hash_undefined__";function oi(e,t){var o=this.__data__;return this.size+=this.has(e)?0:1,o[e]=ei&&t===void 0?ti:t,this}var ni=oi,ri=La,si=Ua,ai=Ja,ii=Ra,li=ni;function ze(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}ze.prototype.clear=ri,ze.prototype.delete=si,ze.prototype.get=ai,ze.prototype.has=ii,ze.prototype.set=li;var ci=ze,_o=ci,ui=mt,di=Ut;function pi(){this.size=0,this.__data__={hash:new _o,map:new(di||ui),string:new _o}}var mi=pi;function fi(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var hi=fi,yi=hi;function gi(e,t){var o=e.__data__;return yi(t)?o[typeof t=="string"?"string":"hash"]:o.map}var ht=gi,vi=ht;function bi(e){var t=vi(this,e).delete(e);return this.size-=t?1:0,t}var xi=bi,Ci=ht;function wi(e){return Ci(this,e).get(e)}var $i=wi,Si=ht;function ki(e){return Si(this,e).has(e)}var Ai=ki,Ti=ht;function Oi(e,t){var o=Ti(this,e),n=o.size;return o.set(e,t),this.size+=o.size==n?0:1,this}var Fi=Oi,Ii=mi,Di=xi,Ni=$i,Pi=Ai,Ei=Fi;function Ue(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}Ue.prototype.clear=Ii,Ue.prototype.delete=Di,Ue.prototype.get=Ni,Ue.prototype.has=Pi,Ue.prototype.set=Ei;var jo=Ue,Mi=mt,_i=Ut,ji=jo,Bi=200;function Vi(e,t){var o=this.__data__;if(o instanceof Mi){var n=o.__data__;if(!_i||n.length<Bi-1)return n.push([e,t]),this.size=++o.size,this;o=this.__data__=new ji(n)}return o.set(e,t),this.size=o.size,this}var Li=Vi,zi=mt,Ui=Os,Gi=Is,Wi=Ns,Hi=Es,qi=Li;function Ge(e){var t=this.__data__=new zi(e);this.size=t.size}Ge.prototype.clear=Ui,Ge.prototype.delete=Gi,Ge.prototype.get=Wi,Ge.prototype.has=Hi,Ge.prototype.set=qi;var Ki=Ge;function Ji(e,t){for(var o=-1,n=e==null?0:e.length;++o<n&&t(e[o],o,e)!==!1;);return e}var Yi=Ji,Zi=Te,Qi=function(){try{var e=Zi(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),Bo=Qi,Vo=Bo;function Xi(e,t,o){t=="__proto__"&&Vo?Vo(e,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):e[t]=o}var Lo=Xi,Ri=Lo,el=Ao,tl=Object.prototype,ol=tl.hasOwnProperty;function nl(e,t,o){var n=e[t];(!(ol.call(e,t)&&el(n,o))||o===void 0&&!(t in e))&&Ri(e,t,o)}var zo=nl,rl=zo,sl=Lo;function al(e,t,o,n){var s=!o;o||(o={});for(var a=-1,l=t.length;++a<l;){var c=t[a],u=n?n(o[c],e[c],c,o,e):void 0;u===void 0&&(u=e[c]),s?sl(o,c,u):rl(o,c,u)}return o}var Re=al;function il(e,t){for(var o=-1,n=Array(e);++o<e;)n[o]=t(o);return n}var ll=il;function cl(e){return e!=null&&typeof e=="object"}var Oe=cl,ul=Le,dl=Oe,pl="[object Arguments]";function ml(e){return dl(e)&&ul(e)==pl}var fl=ml,Uo=fl,hl=Oe,Go=Object.prototype,yl=Go.hasOwnProperty,gl=Go.propertyIsEnumerable,vl=Uo(function(){return arguments}())?Uo:function(e){return hl(e)&&yl.call(e,"callee")&&!gl.call(e,"callee")},Wo=vl,bl=Array.isArray,Fe=bl,yt={exports:{}};function xl(){return!1}var Cl=xl;yt.exports,function(e,t){var o=ye,n=Cl,s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l?o.Buffer:void 0,u=c?c.isBuffer:void 0,p=u||n;e.exports=p}(yt,yt.exports);var Ho=yt.exports,wl=9007199254740991,$l=/^(?:0|[1-9]\d*)$/;function Sl(e,t){var o=typeof e;return t=t==null?wl:t,!!t&&(o=="number"||o!="symbol"&&$l.test(e))&&e>-1&&e%1==0&&e<t}var kl=Sl,Al=9007199254740991;function Tl(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Al}var qo=Tl,Ol=Le,Fl=qo,Il=Oe,Dl="[object Arguments]",Nl="[object Array]",Pl="[object Boolean]",El="[object Date]",Ml="[object Error]",_l="[object Function]",jl="[object Map]",Bl="[object Number]",Vl="[object Object]",Ll="[object RegExp]",zl="[object Set]",Ul="[object String]",Gl="[object WeakMap]",Wl="[object ArrayBuffer]",Hl="[object DataView]",ql="[object Float32Array]",Kl="[object Float64Array]",Jl="[object Int8Array]",Yl="[object Int16Array]",Zl="[object Int32Array]",Ql="[object Uint8Array]",Xl="[object Uint8ClampedArray]",Rl="[object Uint16Array]",ec="[object Uint32Array]",W={};W[ql]=W[Kl]=W[Jl]=W[Yl]=W[Zl]=W[Ql]=W[Xl]=W[Rl]=W[ec]=!0,W[Dl]=W[Nl]=W[Wl]=W[Pl]=W[Hl]=W[El]=W[Ml]=W[_l]=W[jl]=W[Bl]=W[Vl]=W[Ll]=W[zl]=W[Ul]=W[Gl]=!1;function tc(e){return Il(e)&&Fl(e.length)&&!!W[Ol(e)]}var oc=tc;function nc(e){return function(t){return e(t)}}var Gt=nc,gt={exports:{}};gt.exports,function(e,t){var o=To,n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,l=a&&o.process,c=function(){try{var u=s&&s.require&&s.require("util").types;return u||l&&l.binding&&l.binding("util")}catch(p){}}();e.exports=c}(gt,gt.exports);var Wt=gt.exports,rc=oc,sc=Gt,Ko=Wt,Jo=Ko&&Ko.isTypedArray,ac=Jo?sc(Jo):rc,ic=ac,lc=ll,cc=Wo,uc=Fe,dc=Ho,pc=kl,mc=ic,fc=Object.prototype,hc=fc.hasOwnProperty;function yc(e,t){var o=uc(e),n=!o&&cc(e),s=!o&&!n&&dc(e),a=!o&&!n&&!s&&mc(e),l=o||n||s||a,c=l?lc(e.length,String):[],u=c.length;for(var p in e)(t||hc.call(e,p))&&!(l&&(p=="length"||s&&(p=="offset"||p=="parent")||a&&(p=="buffer"||p=="byteLength"||p=="byteOffset")||pc(p,u)))&&c.push(p);return c}var Yo=yc,gc=Object.prototype;function vc(e){var t=e&&e.constructor,o=typeof t=="function"&&t.prototype||gc;return e===o}var Ht=vc;function bc(e,t){return function(o){return e(t(o))}}var Zo=bc,xc=Zo,Cc=xc(Object.keys,Object),wc=Cc,$c=Ht,Sc=wc,kc=Object.prototype,Ac=kc.hasOwnProperty;function Tc(e){if(!$c(e))return Sc(e);var t=[];for(var o in Object(e))Ac.call(e,o)&&o!="constructor"&&t.push(o);return t}var Oc=Tc,Fc=No,Ic=qo;function Dc(e){return e!=null&&Ic(e.length)&&!Fc(e)}var Qo=Dc,Nc=Yo,Pc=Oc,Ec=Qo;function Mc(e){return Ec(e)?Nc(e):Pc(e)}var qt=Mc,_c=Re,jc=qt;function Bc(e,t){return e&&_c(t,jc(t),e)}var Vc=Bc;function Lc(e){var t=[];if(e!=null)for(var o in Object(e))t.push(o);return t}var zc=Lc,Uc=Xe,Gc=Ht,Wc=zc,Hc=Object.prototype,qc=Hc.hasOwnProperty;function Kc(e){if(!Uc(e))return Wc(e);var t=Gc(e),o=[];for(var n in e)n=="constructor"&&(t||!qc.call(e,n))||o.push(n);return o}var Jc=Kc,Yc=Yo,Zc=Jc,Qc=Qo;function Xc(e){return Qc(e)?Yc(e,!0):Zc(e)}var Kt=Xc,Rc=Re,eu=Kt;function tu(e,t){return e&&Rc(t,eu(t),e)}var ou=tu,vt={exports:{}};vt.exports,function(e,t){var o=ye,n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,l=a?o.Buffer:void 0,c=l?l.allocUnsafe:void 0;function u(p,m){if(m)return p.slice();var h=p.length,g=c?c(h):new p.constructor(h);return p.copy(g),g}e.exports=u}(vt,vt.exports);var nu=vt.exports;function ru(e,t){var o=-1,n=e.length;for(t||(t=Array(n));++o<n;)t[o]=e[o];return t}var su=ru;function au(e,t){for(var o=-1,n=e==null?0:e.length,s=0,a=[];++o<n;){var l=e[o];t(l,o,e)&&(a[s++]=l)}return a}var iu=au;function lu(){return[]}var Xo=lu,cu=iu,uu=Xo,du=Object.prototype,pu=du.propertyIsEnumerable,Ro=Object.getOwnPropertySymbols,mu=Ro?function(e){return e==null?[]:(e=Object(e),cu(Ro(e),function(t){return pu.call(e,t)}))}:uu,Jt=mu,fu=Re,hu=Jt;function yu(e,t){return fu(e,hu(e),t)}var gu=yu;function vu(e,t){for(var o=-1,n=t.length,s=e.length;++o<n;)e[s+o]=t[o];return e}var Yt=vu,bu=Zo,xu=bu(Object.getPrototypeOf,Object),Zt=xu,Cu=Yt,wu=Zt,$u=Jt,Su=Xo,ku=Object.getOwnPropertySymbols,Au=ku?function(e){for(var t=[];e;)Cu(t,$u(e)),e=wu(e);return t}:Su,en=Au,Tu=Re,Ou=en;function Fu(e,t){return Tu(e,Ou(e),t)}var Iu=Fu,Du=Yt,Nu=Fe;function Pu(e,t,o){var n=t(e);return Nu(e)?n:Du(n,o(e))}var tn=Pu,Eu=tn,Mu=Jt,_u=qt;function ju(e){return Eu(e,_u,Mu)}var Bu=ju,Vu=tn,Lu=en,zu=Kt;function Uu(e){return Vu(e,zu,Lu)}var on=Uu,Gu=Te,Wu=ye,Hu=Gu(Wu,"DataView"),qu=Hu,Ku=Te,Ju=ye,Yu=Ku(Ju,"Promise"),Zu=Yu,Qu=Te,Xu=ye,Ru=Qu(Xu,"Set"),ed=Ru,td=Te,od=ye,nd=td(od,"WeakMap"),rd=nd,Qt=qu,Xt=Ut,Rt=Zu,eo=ed,to=rd,nn=Le,We=Eo,rn="[object Map]",sd="[object Object]",sn="[object Promise]",an="[object Set]",ln="[object WeakMap]",cn="[object DataView]",ad=We(Qt),id=We(Xt),ld=We(Rt),cd=We(eo),ud=We(to),Ie=nn;(Qt&&Ie(new Qt(new ArrayBuffer(1)))!=cn||Xt&&Ie(new Xt)!=rn||Rt&&Ie(Rt.resolve())!=sn||eo&&Ie(new eo)!=an||to&&Ie(new to)!=ln)&&(Ie=function(e){var t=nn(e),o=t==sd?e.constructor:void 0,n=o?We(o):"";if(n)switch(n){case ad:return cn;case id:return rn;case ld:return sn;case cd:return an;case ud:return ln}return t});var oo=Ie,dd=Object.prototype,pd=dd.hasOwnProperty;function md(e){var t=e.length,o=new e.constructor(t);return t&&typeof e[0]=="string"&&pd.call(e,"index")&&(o.index=e.index,o.input=e.input),o}var fd=md,hd=ye,yd=hd.Uint8Array,gd=yd,un=gd;function vd(e){var t=new e.constructor(e.byteLength);return new un(t).set(new un(e)),t}var no=vd,bd=no;function xd(e,t){var o=t?bd(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.byteLength)}var Cd=xd,wd=/\w*$/;function $d(e){var t=new e.constructor(e.source,wd.exec(e));return t.lastIndex=e.lastIndex,t}var Sd=$d,dn=Ze,pn=dn?dn.prototype:void 0,mn=pn?pn.valueOf:void 0;function kd(e){return mn?Object(mn.call(e)):{}}var Ad=kd,Td=no;function Od(e,t){var o=t?Td(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.length)}var Fd=Od,Id=no,Dd=Cd,Nd=Sd,Pd=Ad,Ed=Fd,Md="[object Boolean]",_d="[object Date]",jd="[object Map]",Bd="[object Number]",Vd="[object RegExp]",Ld="[object Set]",zd="[object String]",Ud="[object Symbol]",Gd="[object ArrayBuffer]",Wd="[object DataView]",Hd="[object Float32Array]",qd="[object Float64Array]",Kd="[object Int8Array]",Jd="[object Int16Array]",Yd="[object Int32Array]",Zd="[object Uint8Array]",Qd="[object Uint8ClampedArray]",Xd="[object Uint16Array]",Rd="[object Uint32Array]";function ep(e,t,o){var n=e.constructor;switch(t){case Gd:return Id(e);case Md:case _d:return new n(+e);case Wd:return Dd(e,o);case Hd:case qd:case Kd:case Jd:case Yd:case Zd:case Qd:case Xd:case Rd:return Ed(e,o);case jd:return new n;case Bd:case zd:return new n(e);case Vd:return Nd(e);case Ld:return new n;case Ud:return Pd(e)}}var tp=ep,op=Xe,fn=Object.create,np=function(){function e(){}return function(t){if(!op(t))return{};if(fn)return fn(t);e.prototype=t;var o=new e;return e.prototype=void 0,o}}(),rp=np,sp=rp,ap=Zt,ip=Ht;function lp(e){return typeof e.constructor=="function"&&!ip(e)?sp(ap(e)):{}}var cp=lp,up=oo,dp=Oe,pp="[object Map]";function mp(e){return dp(e)&&up(e)==pp}var fp=mp,hp=fp,yp=Gt,hn=Wt,yn=hn&&hn.isMap,gp=yn?yp(yn):hp,vp=gp,bp=oo,xp=Oe,Cp="[object Set]";function wp(e){return xp(e)&&bp(e)==Cp}var $p=wp,Sp=$p,kp=Gt,gn=Wt,vn=gn&&gn.isSet,Ap=vn?kp(vn):Sp,Tp=Ap,Op=Ki,Fp=Yi,Ip=zo,Dp=Vc,Np=ou,Pp=nu,Ep=su,Mp=gu,_p=Iu,jp=Bu,Bp=on,Vp=oo,Lp=fd,zp=tp,Up=cp,Gp=Fe,Wp=Ho,Hp=vp,qp=Xe,Kp=Tp,Jp=qt,Yp=Kt,Zp=1,Qp=2,Xp=4,bn="[object Arguments]",Rp="[object Array]",em="[object Boolean]",tm="[object Date]",om="[object Error]",xn="[object Function]",nm="[object GeneratorFunction]",rm="[object Map]",sm="[object Number]",Cn="[object Object]",am="[object RegExp]",im="[object Set]",lm="[object String]",cm="[object Symbol]",um="[object WeakMap]",dm="[object ArrayBuffer]",pm="[object DataView]",mm="[object Float32Array]",fm="[object Float64Array]",hm="[object Int8Array]",ym="[object Int16Array]",gm="[object Int32Array]",vm="[object Uint8Array]",bm="[object Uint8ClampedArray]",xm="[object Uint16Array]",Cm="[object Uint32Array]",G={};G[bn]=G[Rp]=G[dm]=G[pm]=G[em]=G[tm]=G[mm]=G[fm]=G[hm]=G[ym]=G[gm]=G[rm]=G[sm]=G[Cn]=G[am]=G[im]=G[lm]=G[cm]=G[vm]=G[bm]=G[xm]=G[Cm]=!0,G[om]=G[xn]=G[um]=!1;function bt(e,t,o,n,s,a){var l,c=t&Zp,u=t&Qp,p=t&Xp;if(o&&(l=s?o(e,n,s,a):o(e)),l!==void 0)return l;if(!qp(e))return e;var m=Gp(e);if(m){if(l=Lp(e),!c)return Ep(e,l)}else{var h=Vp(e),g=h==xn||h==nm;if(Wp(e))return Pp(e,c);if(h==Cn||h==bn||g&&!s){if(l=u||g?{}:Up(e),!c)return u?_p(e,Np(l,e)):Mp(e,Dp(l,e))}else{if(!G[h])return s?e:{};l=zp(e,h,c)}}a||(a=new Op);var f=a.get(e);if(f)return f;a.set(e,l),Kp(e)?e.forEach(function($){l.add(bt($,t,o,$,e,a))}):Hp(e)&&e.forEach(function($,k){l.set(k,bt($,t,o,k,e,a))});var y=p?u?Bp:jp:u?Yp:Jp,w=m?void 0:y(e);return Fp(w||e,function($,k){w&&(k=$,$=e[k]),Ip(l,k,bt($,t,o,k,e,a))}),l}var wm=bt,$m=Le,Sm=Oe,km="[object Symbol]";function Am(e){return typeof e=="symbol"||Sm(e)&&$m(e)==km}var ro=Am,Tm=Fe,Om=ro,Fm=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Im=/^\w*$/;function Dm(e,t){if(Tm(e))return!1;var o=typeof e;return o=="number"||o=="symbol"||o=="boolean"||e==null||Om(e)?!0:Im.test(e)||!Fm.test(e)||t!=null&&e in Object(t)}var Nm=Dm,wn=jo,Pm="Expected a function";function so(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Pm);var o=function(){var n=arguments,s=t?t.apply(this,n):n[0],a=o.cache;if(a.has(s))return a.get(s);var l=e.apply(this,n);return o.cache=a.set(s,l)||a,l};return o.cache=new(so.Cache||wn),o}so.Cache=wn;var Em=so,Mm=Em,_m=500;function jm(e){var t=Mm(e,function(n){return o.size===_m&&o.clear(),n}),o=t.cache;return t}var Bm=jm,Vm=Bm,Lm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,zm=/\\(\\)?/g,Um=Vm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Lm,function(o,n,s,a){t.push(s?a.replace(zm,"$1"):n||o)}),t}),Gm=Um,$n=Ze,Wm=ko,Hm=Fe,qm=ro,Km=1/0,Sn=$n?$n.prototype:void 0,kn=Sn?Sn.toString:void 0;function An(e){if(typeof e=="string")return e;if(Hm(e))return Wm(e,An)+"";if(qm(e))return kn?kn.call(e):"";var t=e+"";return t=="0"&&1/e==-Km?"-0":t}var Jm=An,Ym=Jm;function Zm(e){return e==null?"":Ym(e)}var Qm=Zm,Xm=Fe,Rm=Nm,ef=Gm,tf=Qm;function of(e,t){return Xm(e)?e:Rm(e,t)?[e]:ef(tf(e))}var ao=of;function nf(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var rf=nf,sf=ro,af=1/0;function lf(e){if(typeof e=="string"||sf(e))return e;var t=e+"";return t=="0"&&1/e==-af?"-0":t}var Tn=lf,cf=ao,uf=Tn;function df(e,t){t=cf(t,e);for(var o=0,n=t.length;e!=null&&o<n;)e=e[uf(t[o++])];return o&&o==n?e:void 0}var pf=df;function mf(e,t,o){var n=-1,s=e.length;t<0&&(t=-t>s?0:s+t),o=o>s?s:o,o<0&&(o+=s),s=t>o?0:o-t>>>0,t>>>=0;for(var a=Array(s);++n<s;)a[n]=e[n+t];return a}var ff=mf,hf=pf,yf=ff;function gf(e,t){return t.length<2?e:hf(e,yf(t,0,-1))}var vf=gf,bf=ao,xf=rf,Cf=vf,wf=Tn;function $f(e,t){return t=bf(t,e),e=Cf(e,t),e==null||delete e[wf(xf(t))]}var Sf=$f,kf=Le,Af=Zt,Tf=Oe,Of="[object Object]",Ff=Function.prototype,If=Object.prototype,On=Ff.toString,Df=If.hasOwnProperty,Nf=On.call(Object);function Pf(e){if(!Tf(e)||kf(e)!=Of)return!1;var t=Af(e);if(t===null)return!0;var o=Df.call(t,"constructor")&&t.constructor;return typeof o=="function"&&o instanceof o&&On.call(o)==Nf}var Ef=Pf,Mf=Ef;function _f(e){return Mf(e)?void 0:e}var jf=_f,Fn=Ze,Bf=Wo,Vf=Fe,In=Fn?Fn.isConcatSpreadable:void 0;function Lf(e){return Vf(e)||Bf(e)||!!(In&&e&&e[In])}var zf=Lf,Uf=Yt,Gf=zf;function Dn(e,t,o,n,s){var a=-1,l=e.length;for(o||(o=Gf),s||(s=[]);++a<l;){var c=e[a];t>0&&o(c)?t>1?Dn(c,t-1,o,n,s):Uf(s,c):n||(s[s.length]=c)}return s}var Wf=Dn,Hf=Wf;function qf(e){var t=e==null?0:e.length;return t?Hf(e,1):[]}var Kf=qf;function Jf(e,t,o){switch(o.length){case 0:return e.call(t);case 1:return e.call(t,o[0]);case 2:return e.call(t,o[0],o[1]);case 3:return e.call(t,o[0],o[1],o[2])}return e.apply(t,o)}var Yf=Jf,Zf=Yf,Nn=Math.max;function Qf(e,t,o){return t=Nn(t===void 0?e.length-1:t,0),function(){for(var n=arguments,s=-1,a=Nn(n.length-t,0),l=Array(a);++s<a;)l[s]=n[t+s];s=-1;for(var c=Array(t+1);++s<t;)c[s]=n[s];return c[t]=o(l),Zf(e,this,c)}}var Xf=Qf;function Rf(e){return function(){return e}}var eh=Rf;function th(e){return e}var oh=th,nh=eh,Pn=Bo,rh=oh,sh=Pn?function(e,t){return Pn(e,"toString",{configurable:!0,enumerable:!1,value:nh(t),writable:!0})}:rh,ah=sh,ih=800,lh=16,ch=Date.now;function uh(e){var t=0,o=0;return function(){var n=ch(),s=lh-(n-o);if(o=n,s>0){if(++t>=ih)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var dh=uh,ph=ah,mh=dh,fh=mh(ph),hh=fh,yh=Kf,gh=Xf,vh=hh;function bh(e){return vh(gh(e,void 0,yh),e+"")}var xh=bh,Ch=ko,wh=wm,$h=Sf,Sh=ao,kh=Re,Ah=jf,Th=xh,Oh=on,Fh=1,Ih=2,Dh=4,Nh=Th(function(e,t){var o={};if(e==null)return o;var n=!1;t=Ch(t,function(a){return a=Sh(a,e),n||(n=a.length>1),a}),kh(e,Oh(e),o),n&&(o=wh(o,Fh|Ih|Dh,Ah));for(var s=t.length;s--;)$h(o,t[s]);return o}),Ph=Nh;const Eh=So(Ph),En={title:`{{t("Form event", { ns: "${d}" })}}`,type:"form",description:`{{t("Event triggers when submitted a workflow bound form action.", { ns: "${d}" })}}`,fieldset:{collection:C(v({},de),{title:`{{t("Form data model", { ns: "${d}" })}}`,description:`{{t("Use a collection to match form data.", { ns: "${d}" })}}`,"x-reactions":[...de["x-reactions"],{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),appends:C(v({},je),{title:`{{t("Associations to use", { ns: "${d}" })}}`})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:n}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:T("Trigger data")}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:T("User submitted form")}}];return xe(C(v({},t),{fields:s,appends:["data","user",...((l=e.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],compile:o,getCollectionFields:n}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:Me,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function Mh(e,t,o,n,s,a){var l;if(e){const c=(l=t==null?void 0:t.data)==null?void 0:l.activeFields;if(c){const u=Object.keys(o.values).filter(p=>{const m=s(p);return!c.has(p)&&["hasOne","hasMany","belongsTo","belongsToMany"].includes(m==null?void 0:m.type)});return Eh(v({},o.values),u)}}return o.values}function _h(){var M;const e=i.useAPIClient(),t=I.useForm(),{field:o,resource:n,__parent:s}=i.useBlockRequestContext(),{setVisible:a,fieldSchema:l}=i.useActionContext(),c=he.useNavigate(),u=I.useFieldSchema(),p=I.useField(),{fields:m,getField:h,getTreeParentField:g}=i.useCollection(),f=i.useCompile(),y=i.useFilterByTk(),w=i.useRecord(),$=i.useCurrentUserContext(),{modal:k}=x.App.useApp(),S=(M=$==null?void 0:$.data)==null?void 0:M.data,A=p.componentProps.filterKeys||[];return{onClick(){return K(this,null,function*(){var V,ne,J,Z,Q,ee;const _=m.map(re=>re.name),{assignedValues:F={},onSuccess:N,overwriteValues:U,skipValidator:ie,triggerWorkflows:Y}=(V=u==null?void 0:u["x-action-settings"])!=null?V:{},ue=(ne=l==null?void 0:l["x-component-props"])==null?void 0:ne.addChild,E=L.parse(F)({currentTime:new Date,currentRecord:w,currentUser:S});ie||(yield t.submit());const j=Mh(y,o,t,_,h);if(ue){const re=g();j[(J=re==null?void 0:re.name)!=null?J:"parent"]=w,j[(Z=re==null?void 0:re.foreignKey)!=null?Z:"parentId"]=w.id}p.data=o.data||{},p.data.loading=!0;try{const re=yield e.resource("workflows").trigger({values:v(v(v({},j),U),E),filterKeys:A,triggerWorkflows:Y!=null&&Y.length?Y.map(pe=>[pe.workflowKey,pe.context].filter(Boolean).join("!")).join(","):void 0});if(p.data.loading=!1,p.data.data=re,(ee=(Q=s==null?void 0:s.service)==null?void 0:Q.refresh)==null||ee.call(Q),a==null||a(!1),!(N!=null&&N.successMessage))return;N!=null&&N.manualClose?k.success({title:f(N==null?void 0:N.successMessage),onOk:()=>K(this,null,function*(){yield t.reset(),N!=null&&N.redirecting&&(N!=null&&N.redirectTo)&&(L.isURL(N.redirectTo)?window.location.href=N.redirectTo:c(N.redirectTo))})}):x.message.success(f(N==null?void 0:N.successMessage))}catch(re){p.data.loading=!1}})}}}const De={STATIC:0,COLLECTION_FIELD:1};function jh(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function Mn({value:e,onChange:t}){const{t:o}=te.useTranslation(),[n,s]=b.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:i.css`
|
|
389
|
+
`}},dynamicComponent:"FilterDynamicComponent"}},os={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"}}},ns={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",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}}}}}}},je={type:"array",title:`{{t("Preload associations", { ns: "${d}" })}}`,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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=E.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Be={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},rs=[{label:`{{t("After record added", { ns: "${d}" })}}`,value:Be.CREATED},{label:`{{t("After record updated", { ns: "${d}" })}}`,value:Be.UPDATED},{label:`{{t("After record added or updated", { ns: "${d}" })}}`,value:Be.SAVED},{label:`{{t("After record deleted", { ns: "${d}" })}}`,value:Be.DELETED}],Eo={title:`{{t("Collection event", { ns: "${d}" })}}`,type:"collection",description:`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${d}" })}}`,fieldset:{collection:C(v({},de),{"x-reactions":[...de["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${d}" })}}`,className:"auto-width"},enum:rs,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${d}" })}}`,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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(e){return!e.hidden&&(e.uiSchema?!e.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Be.UPDATED})}}`}}}]},condition:C(v({},_e),{title:`{{t("Only triggers when match conditions", { ns: "${d}" })}}`,"x-component-props":{useProps:_e["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:C(v({},je),{"x-reactions":[...je["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Be.DELETED})}}`}}}]})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FieldsSelect:zt},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:n}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:O("Trigger data")}}];return be(C(v({appends:["data",...((l=e.appends)==null?void 0:l.map(c=>`data.${c}`))||[]]},t),{fields:s,compile:o,getCollectionFields:n}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:Me,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function ss(e,t){for(var o=-1,n=e==null?0:e.length,s=Array(n);++o<n;)s[o]=t(e[o],o,e);return s}var No=ss;function as(){this.__data__=[],this.size=0}var is=as;function ls(e,t){return e===t||e!==e&&t!==t}var Po=ls,cs=Po;function us(e,t){for(var o=e.length;o--;)if(cs(e[o][0],t))return o;return-1}var ht=us,ds=ht,ps=Array.prototype,ms=ps.splice;function fs(e){var t=this.__data__,o=ds(t,e);if(o<0)return!1;var n=t.length-1;return o==n?t.pop():ms.call(t,o,1),--this.size,!0}var hs=fs,ys=ht;function gs(e){var t=this.__data__,o=ys(t,e);return o<0?void 0:t[o][1]}var vs=gs,bs=ht;function xs(e){return bs(this.__data__,e)>-1}var Cs=xs,ws=ht;function $s(e,t){var o=this.__data__,n=ws(o,e);return n<0?(++this.size,o.push([e,t])):o[n][1]=t,this}var Ss=$s,ks=is,As=hs,Ts=vs,Os=Cs,Fs=Ss;function Ve(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}Ve.prototype.clear=ks,Ve.prototype.delete=As,Ve.prototype.get=Ts,Ve.prototype.has=Os,Ve.prototype.set=Fs;var yt=Ve,Is=yt;function Ds(){this.__data__=new Is,this.size=0}var Es=Ds;function Ns(e){var t=this.__data__,o=t.delete(e);return this.size=t.size,o}var Ps=Ns;function Ms(e){return this.__data__.get(e)}var _s=Ms;function js(e){return this.__data__.has(e)}var Bs=js,Vs=typeof ft=="object"&&ft&&ft.Object===Object&&ft,Mo=Vs,Ls=Mo,zs=typeof self=="object"&&self&&self.Object===Object&&self,Us=Ls||zs||Function("return this")(),ve=Us,Gs=ve,Ws=Gs.Symbol,Re=Ws,_o=Re,jo=Object.prototype,Hs=jo.hasOwnProperty,Ks=jo.toString,et=_o?_o.toStringTag:void 0;function qs(e){var t=Hs.call(e,et),o=e[et];try{e[et]=void 0;var n=!0}catch(a){}var s=Ks.call(e);return n&&(t?e[et]=o:delete e[et]),s}var Js=qs,Ys=Object.prototype,Zs=Ys.toString;function Qs(e){return Zs.call(e)}var Xs=Qs,Bo=Re,Rs=Js,ea=Xs,ta="[object Null]",oa="[object Undefined]",Vo=Bo?Bo.toStringTag:void 0;function na(e){return e==null?e===void 0?oa:ta:Vo&&Vo in Object(e)?Rs(e):ea(e)}var Le=na;function ra(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var tt=ra,sa=Le,aa=tt,ia="[object AsyncFunction]",la="[object Function]",ca="[object GeneratorFunction]",ua="[object Proxy]";function da(e){if(!aa(e))return!1;var t=sa(e);return t==la||t==ca||t==ia||t==ua}var Lo=da,pa=ve,ma=pa["__core-js_shared__"],fa=ma,Gt=fa,zo=function(){var e=/[^.]+$/.exec(Gt&&Gt.keys&&Gt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ha(e){return!!zo&&zo in e}var ya=ha,ga=Function.prototype,va=ga.toString;function ba(e){if(e!=null){try{return va.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var Uo=ba,xa=Lo,Ca=ya,wa=tt,$a=Uo,Sa=/[\\^$.*+?()[\]{}|]/g,ka=/^\[object .+?Constructor\]$/,Aa=Function.prototype,Ta=Object.prototype,Oa=Aa.toString,Fa=Ta.hasOwnProperty,Ia=RegExp("^"+Oa.call(Fa).replace(Sa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Da(e){if(!wa(e)||Ca(e))return!1;var t=xa(e)?Ia:ka;return t.test($a(e))}var Ea=Da;function Na(e,t){return e==null?void 0:e[t]}var Pa=Na,Ma=Ea,_a=Pa;function ja(e,t){var o=_a(e,t);return Ma(o)?o:void 0}var Te=ja,Ba=Te,Va=ve,La=Ba(Va,"Map"),Wt=La,za=Te,Ua=za(Object,"create"),gt=Ua,Go=gt;function Ga(){this.__data__=Go?Go(null):{},this.size=0}var Wa=Ga;function Ha(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ka=Ha,qa=gt,Ja="__lodash_hash_undefined__",Ya=Object.prototype,Za=Ya.hasOwnProperty;function Qa(e){var t=this.__data__;if(qa){var o=t[e];return o===Ja?void 0:o}return Za.call(t,e)?t[e]:void 0}var Xa=Qa,Ra=gt,ei=Object.prototype,ti=ei.hasOwnProperty;function oi(e){var t=this.__data__;return Ra?t[e]!==void 0:ti.call(t,e)}var ni=oi,ri=gt,si="__lodash_hash_undefined__";function ai(e,t){var o=this.__data__;return this.size+=this.has(e)?0:1,o[e]=ri&&t===void 0?si:t,this}var ii=ai,li=Wa,ci=Ka,ui=Xa,di=ni,pi=ii;function ze(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}ze.prototype.clear=li,ze.prototype.delete=ci,ze.prototype.get=ui,ze.prototype.has=di,ze.prototype.set=pi;var mi=ze,Wo=mi,fi=yt,hi=Wt;function yi(){this.size=0,this.__data__={hash:new Wo,map:new(hi||fi),string:new Wo}}var gi=yi;function vi(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var bi=vi,xi=bi;function Ci(e,t){var o=e.__data__;return xi(t)?o[typeof t=="string"?"string":"hash"]:o.map}var vt=Ci,wi=vt;function $i(e){var t=wi(this,e).delete(e);return this.size-=t?1:0,t}var Si=$i,ki=vt;function Ai(e){return ki(this,e).get(e)}var Ti=Ai,Oi=vt;function Fi(e){return Oi(this,e).has(e)}var Ii=Fi,Di=vt;function Ei(e,t){var o=Di(this,e),n=o.size;return o.set(e,t),this.size+=o.size==n?0:1,this}var Ni=Ei,Pi=gi,Mi=Si,_i=Ti,ji=Ii,Bi=Ni;function Ue(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var n=e[t];this.set(n[0],n[1])}}Ue.prototype.clear=Pi,Ue.prototype.delete=Mi,Ue.prototype.get=_i,Ue.prototype.has=ji,Ue.prototype.set=Bi;var Ho=Ue,Vi=yt,Li=Wt,zi=Ho,Ui=200;function Gi(e,t){var o=this.__data__;if(o instanceof Vi){var n=o.__data__;if(!Li||n.length<Ui-1)return n.push([e,t]),this.size=++o.size,this;o=this.__data__=new zi(n)}return o.set(e,t),this.size=o.size,this}var Wi=Gi,Hi=yt,Ki=Es,qi=Ps,Ji=_s,Yi=Bs,Zi=Wi;function Ge(e){var t=this.__data__=new Hi(e);this.size=t.size}Ge.prototype.clear=Ki,Ge.prototype.delete=qi,Ge.prototype.get=Ji,Ge.prototype.has=Yi,Ge.prototype.set=Zi;var Qi=Ge;function Xi(e,t){for(var o=-1,n=e==null?0:e.length;++o<n&&t(e[o],o,e)!==!1;);return e}var Ri=Xi,el=Te,tl=function(){try{var e=el(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),Ko=tl,qo=Ko;function ol(e,t,o){t=="__proto__"&&qo?qo(e,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):e[t]=o}var Jo=ol,nl=Jo,rl=Po,sl=Object.prototype,al=sl.hasOwnProperty;function il(e,t,o){var n=e[t];(!(al.call(e,t)&&rl(n,o))||o===void 0&&!(t in e))&&nl(e,t,o)}var Yo=il,ll=Yo,cl=Jo;function ul(e,t,o,n){var s=!o;o||(o={});for(var a=-1,l=t.length;++a<l;){var c=t[a],u=n?n(o[c],e[c],c,o,e):void 0;u===void 0&&(u=e[c]),s?cl(o,c,u):ll(o,c,u)}return o}var ot=ul;function dl(e,t){for(var o=-1,n=Array(e);++o<e;)n[o]=t(o);return n}var pl=dl;function ml(e){return e!=null&&typeof e=="object"}var Oe=ml,fl=Le,hl=Oe,yl="[object Arguments]";function gl(e){return hl(e)&&fl(e)==yl}var vl=gl,Zo=vl,bl=Oe,Qo=Object.prototype,xl=Qo.hasOwnProperty,Cl=Qo.propertyIsEnumerable,wl=Zo(function(){return arguments}())?Zo:function(e){return bl(e)&&xl.call(e,"callee")&&!Cl.call(e,"callee")},Xo=wl,$l=Array.isArray,Fe=$l,bt={exports:{}};function Sl(){return!1}var kl=Sl;bt.exports,function(e,t){var o=ve,n=kl,s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l?o.Buffer:void 0,u=c?c.isBuffer:void 0,p=u||n;e.exports=p}(bt,bt.exports);var Ro=bt.exports,Al=9007199254740991,Tl=/^(?:0|[1-9]\d*)$/;function Ol(e,t){var o=typeof e;return t=t==null?Al:t,!!t&&(o=="number"||o!="symbol"&&Tl.test(e))&&e>-1&&e%1==0&&e<t}var Fl=Ol,Il=9007199254740991;function Dl(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Il}var en=Dl,El=Le,Nl=en,Pl=Oe,Ml="[object Arguments]",_l="[object Array]",jl="[object Boolean]",Bl="[object Date]",Vl="[object Error]",Ll="[object Function]",zl="[object Map]",Ul="[object Number]",Gl="[object Object]",Wl="[object RegExp]",Hl="[object Set]",Kl="[object String]",ql="[object WeakMap]",Jl="[object ArrayBuffer]",Yl="[object DataView]",Zl="[object Float32Array]",Ql="[object Float64Array]",Xl="[object Int8Array]",Rl="[object Int16Array]",ec="[object Int32Array]",tc="[object Uint8Array]",oc="[object Uint8ClampedArray]",nc="[object Uint16Array]",rc="[object Uint32Array]",K={};K[Zl]=K[Ql]=K[Xl]=K[Rl]=K[ec]=K[tc]=K[oc]=K[nc]=K[rc]=!0,K[Ml]=K[_l]=K[Jl]=K[jl]=K[Yl]=K[Bl]=K[Vl]=K[Ll]=K[zl]=K[Ul]=K[Gl]=K[Wl]=K[Hl]=K[Kl]=K[ql]=!1;function sc(e){return Pl(e)&&Nl(e.length)&&!!K[El(e)]}var ac=sc;function ic(e){return function(t){return e(t)}}var Ht=ic,xt={exports:{}};xt.exports,function(e,t){var o=Mo,n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,l=a&&o.process,c=function(){try{var u=s&&s.require&&s.require("util").types;return u||l&&l.binding&&l.binding("util")}catch(p){}}();e.exports=c}(xt,xt.exports);var Kt=xt.exports,lc=ac,cc=Ht,tn=Kt,on=tn&&tn.isTypedArray,uc=on?cc(on):lc,dc=uc,pc=pl,mc=Xo,fc=Fe,hc=Ro,yc=Fl,gc=dc,vc=Object.prototype,bc=vc.hasOwnProperty;function xc(e,t){var o=fc(e),n=!o&&mc(e),s=!o&&!n&&hc(e),a=!o&&!n&&!s&&gc(e),l=o||n||s||a,c=l?pc(e.length,String):[],u=c.length;for(var p in e)(t||bc.call(e,p))&&!(l&&(p=="length"||s&&(p=="offset"||p=="parent")||a&&(p=="buffer"||p=="byteLength"||p=="byteOffset")||yc(p,u)))&&c.push(p);return c}var nn=xc,Cc=Object.prototype;function wc(e){var t=e&&e.constructor,o=typeof t=="function"&&t.prototype||Cc;return e===o}var qt=wc;function $c(e,t){return function(o){return e(t(o))}}var rn=$c,Sc=rn,kc=Sc(Object.keys,Object),Ac=kc,Tc=qt,Oc=Ac,Fc=Object.prototype,Ic=Fc.hasOwnProperty;function Dc(e){if(!Tc(e))return Oc(e);var t=[];for(var o in Object(e))Ic.call(e,o)&&o!="constructor"&&t.push(o);return t}var Ec=Dc,Nc=Lo,Pc=en;function Mc(e){return e!=null&&Pc(e.length)&&!Nc(e)}var sn=Mc,_c=nn,jc=Ec,Bc=sn;function Vc(e){return Bc(e)?_c(e):jc(e)}var Jt=Vc,Lc=ot,zc=Jt;function Uc(e,t){return e&&Lc(t,zc(t),e)}var Gc=Uc;function Wc(e){var t=[];if(e!=null)for(var o in Object(e))t.push(o);return t}var Hc=Wc,Kc=tt,qc=qt,Jc=Hc,Yc=Object.prototype,Zc=Yc.hasOwnProperty;function Qc(e){if(!Kc(e))return Jc(e);var t=qc(e),o=[];for(var n in e)n=="constructor"&&(t||!Zc.call(e,n))||o.push(n);return o}var Xc=Qc,Rc=nn,eu=Xc,tu=sn;function ou(e){return tu(e)?Rc(e,!0):eu(e)}var Yt=ou,nu=ot,ru=Yt;function su(e,t){return e&&nu(t,ru(t),e)}var au=su,Ct={exports:{}};Ct.exports,function(e,t){var o=ve,n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,l=a?o.Buffer:void 0,c=l?l.allocUnsafe:void 0;function u(p,m){if(m)return p.slice();var y=p.length,b=c?c(y):new p.constructor(y);return p.copy(b),b}e.exports=u}(Ct,Ct.exports);var iu=Ct.exports;function lu(e,t){var o=-1,n=e.length;for(t||(t=Array(n));++o<n;)t[o]=e[o];return t}var cu=lu;function uu(e,t){for(var o=-1,n=e==null?0:e.length,s=0,a=[];++o<n;){var l=e[o];t(l,o,e)&&(a[s++]=l)}return a}var du=uu;function pu(){return[]}var an=pu,mu=du,fu=an,hu=Object.prototype,yu=hu.propertyIsEnumerable,ln=Object.getOwnPropertySymbols,gu=ln?function(e){return e==null?[]:(e=Object(e),mu(ln(e),function(t){return yu.call(e,t)}))}:fu,Zt=gu,vu=ot,bu=Zt;function xu(e,t){return vu(e,bu(e),t)}var Cu=xu;function wu(e,t){for(var o=-1,n=t.length,s=e.length;++o<n;)e[s+o]=t[o];return e}var Qt=wu,$u=rn,Su=$u(Object.getPrototypeOf,Object),Xt=Su,ku=Qt,Au=Xt,Tu=Zt,Ou=an,Fu=Object.getOwnPropertySymbols,Iu=Fu?function(e){for(var t=[];e;)ku(t,Tu(e)),e=Au(e);return t}:Ou,cn=Iu,Du=ot,Eu=cn;function Nu(e,t){return Du(e,Eu(e),t)}var Pu=Nu,Mu=Qt,_u=Fe;function ju(e,t,o){var n=t(e);return _u(e)?n:Mu(n,o(e))}var un=ju,Bu=un,Vu=Zt,Lu=Jt;function zu(e){return Bu(e,Lu,Vu)}var Uu=zu,Gu=un,Wu=cn,Hu=Yt;function Ku(e){return Gu(e,Hu,Wu)}var dn=Ku,qu=Te,Ju=ve,Yu=qu(Ju,"DataView"),Zu=Yu,Qu=Te,Xu=ve,Ru=Qu(Xu,"Promise"),ed=Ru,td=Te,od=ve,nd=td(od,"Set"),rd=nd,sd=Te,ad=ve,id=sd(ad,"WeakMap"),ld=id,Rt=Zu,eo=Wt,to=ed,oo=rd,no=ld,pn=Le,We=Uo,mn="[object Map]",cd="[object Object]",fn="[object Promise]",hn="[object Set]",yn="[object WeakMap]",gn="[object DataView]",ud=We(Rt),dd=We(eo),pd=We(to),md=We(oo),fd=We(no),Ie=pn;(Rt&&Ie(new Rt(new ArrayBuffer(1)))!=gn||eo&&Ie(new eo)!=mn||to&&Ie(to.resolve())!=fn||oo&&Ie(new oo)!=hn||no&&Ie(new no)!=yn)&&(Ie=function(e){var t=pn(e),o=t==cd?e.constructor:void 0,n=o?We(o):"";if(n)switch(n){case ud:return gn;case dd:return mn;case pd:return fn;case md:return hn;case fd:return yn}return t});var ro=Ie,hd=Object.prototype,yd=hd.hasOwnProperty;function gd(e){var t=e.length,o=new e.constructor(t);return t&&typeof e[0]=="string"&&yd.call(e,"index")&&(o.index=e.index,o.input=e.input),o}var vd=gd,bd=ve,xd=bd.Uint8Array,Cd=xd,vn=Cd;function wd(e){var t=new e.constructor(e.byteLength);return new vn(t).set(new vn(e)),t}var so=wd,$d=so;function Sd(e,t){var o=t?$d(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.byteLength)}var kd=Sd,Ad=/\w*$/;function Td(e){var t=new e.constructor(e.source,Ad.exec(e));return t.lastIndex=e.lastIndex,t}var Od=Td,bn=Re,xn=bn?bn.prototype:void 0,Cn=xn?xn.valueOf:void 0;function Fd(e){return Cn?Object(Cn.call(e)):{}}var Id=Fd,Dd=so;function Ed(e,t){var o=t?Dd(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.length)}var Nd=Ed,Pd=so,Md=kd,_d=Od,jd=Id,Bd=Nd,Vd="[object Boolean]",Ld="[object Date]",zd="[object Map]",Ud="[object Number]",Gd="[object RegExp]",Wd="[object Set]",Hd="[object String]",Kd="[object Symbol]",qd="[object ArrayBuffer]",Jd="[object DataView]",Yd="[object Float32Array]",Zd="[object Float64Array]",Qd="[object Int8Array]",Xd="[object Int16Array]",Rd="[object Int32Array]",ep="[object Uint8Array]",tp="[object Uint8ClampedArray]",op="[object Uint16Array]",np="[object Uint32Array]";function rp(e,t,o){var n=e.constructor;switch(t){case qd:return Pd(e);case Vd:case Ld:return new n(+e);case Jd:return Md(e,o);case Yd:case Zd:case Qd:case Xd:case Rd:case ep:case tp:case op:case np:return Bd(e,o);case zd:return new n;case Ud:case Hd:return new n(e);case Gd:return _d(e);case Wd:return new n;case Kd:return jd(e)}}var sp=rp,ap=tt,wn=Object.create,ip=function(){function e(){}return function(t){if(!ap(t))return{};if(wn)return wn(t);e.prototype=t;var o=new e;return e.prototype=void 0,o}}(),lp=ip,cp=lp,up=Xt,dp=qt;function pp(e){return typeof e.constructor=="function"&&!dp(e)?cp(up(e)):{}}var mp=pp,fp=ro,hp=Oe,yp="[object Map]";function gp(e){return hp(e)&&fp(e)==yp}var vp=gp,bp=vp,xp=Ht,$n=Kt,Sn=$n&&$n.isMap,Cp=Sn?xp(Sn):bp,wp=Cp,$p=ro,Sp=Oe,kp="[object Set]";function Ap(e){return Sp(e)&&$p(e)==kp}var Tp=Ap,Op=Tp,Fp=Ht,kn=Kt,An=kn&&kn.isSet,Ip=An?Fp(An):Op,Dp=Ip,Ep=Qi,Np=Ri,Pp=Yo,Mp=Gc,_p=au,jp=iu,Bp=cu,Vp=Cu,Lp=Pu,zp=Uu,Up=dn,Gp=ro,Wp=vd,Hp=sp,Kp=mp,qp=Fe,Jp=Ro,Yp=wp,Zp=tt,Qp=Dp,Xp=Jt,Rp=Yt,em=1,tm=2,om=4,Tn="[object Arguments]",nm="[object Array]",rm="[object Boolean]",sm="[object Date]",am="[object Error]",On="[object Function]",im="[object GeneratorFunction]",lm="[object Map]",cm="[object Number]",Fn="[object Object]",um="[object RegExp]",dm="[object Set]",pm="[object String]",mm="[object Symbol]",fm="[object WeakMap]",hm="[object ArrayBuffer]",ym="[object DataView]",gm="[object Float32Array]",vm="[object Float64Array]",bm="[object Int8Array]",xm="[object Int16Array]",Cm="[object Int32Array]",wm="[object Uint8Array]",$m="[object Uint8ClampedArray]",Sm="[object Uint16Array]",km="[object Uint32Array]",G={};G[Tn]=G[nm]=G[hm]=G[ym]=G[rm]=G[sm]=G[gm]=G[vm]=G[bm]=G[xm]=G[Cm]=G[lm]=G[cm]=G[Fn]=G[um]=G[dm]=G[pm]=G[mm]=G[wm]=G[$m]=G[Sm]=G[km]=!0,G[am]=G[On]=G[fm]=!1;function wt(e,t,o,n,s,a){var l,c=t&em,u=t&tm,p=t&om;if(o&&(l=s?o(e,n,s,a):o(e)),l!==void 0)return l;if(!Zp(e))return e;var m=qp(e);if(m){if(l=Wp(e),!c)return Bp(e,l)}else{var y=Gp(e),b=y==On||y==im;if(Jp(e))return jp(e,c);if(y==Fn||y==Tn||b&&!s){if(l=u||b?{}:Kp(e),!c)return u?Lp(e,_p(l,e)):Vp(e,Mp(l,e))}else{if(!G[y])return s?e:{};l=Hp(e,y,c)}}a||(a=new Ep);var f=a.get(e);if(f)return f;a.set(e,l),Qp(e)?e.forEach(function(w){l.add(wt(w,t,o,w,e,a))}):Yp(e)&&e.forEach(function(w,k){l.set(k,wt(w,t,o,k,e,a))});var h=p?u?Up:zp:u?Rp:Xp,$=m?void 0:h(e);return Np($||e,function(w,k){$&&(k=w,w=e[k]),Pp(l,k,wt(w,t,o,k,e,a))}),l}var Am=wt,Tm=Le,Om=Oe,Fm="[object Symbol]";function Im(e){return typeof e=="symbol"||Om(e)&&Tm(e)==Fm}var ao=Im,Dm=Fe,Em=ao,Nm=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pm=/^\w*$/;function Mm(e,t){if(Dm(e))return!1;var o=typeof e;return o=="number"||o=="symbol"||o=="boolean"||e==null||Em(e)?!0:Pm.test(e)||!Nm.test(e)||t!=null&&e in Object(t)}var _m=Mm,In=Ho,jm="Expected a function";function io(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(jm);var o=function(){var n=arguments,s=t?t.apply(this,n):n[0],a=o.cache;if(a.has(s))return a.get(s);var l=e.apply(this,n);return o.cache=a.set(s,l)||a,l};return o.cache=new(io.Cache||In),o}io.Cache=In;var Bm=io,Vm=Bm,Lm=500;function zm(e){var t=Vm(e,function(n){return o.size===Lm&&o.clear(),n}),o=t.cache;return t}var Um=zm,Gm=Um,Wm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Hm=/\\(\\)?/g,Km=Gm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Wm,function(o,n,s,a){t.push(s?a.replace(Hm,"$1"):n||o)}),t}),qm=Km,Dn=Re,Jm=No,Ym=Fe,Zm=ao,Qm=1/0,En=Dn?Dn.prototype:void 0,Nn=En?En.toString:void 0;function Pn(e){if(typeof e=="string")return e;if(Ym(e))return Jm(e,Pn)+"";if(Zm(e))return Nn?Nn.call(e):"";var t=e+"";return t=="0"&&1/e==-Qm?"-0":t}var Xm=Pn,Rm=Xm;function ef(e){return e==null?"":Rm(e)}var tf=ef,of=Fe,nf=_m,rf=qm,sf=tf;function af(e,t){return of(e)?e:nf(e,t)?[e]:rf(sf(e))}var lo=af;function lf(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var cf=lf,uf=ao,df=1/0;function pf(e){if(typeof e=="string"||uf(e))return e;var t=e+"";return t=="0"&&1/e==-df?"-0":t}var Mn=pf,mf=lo,ff=Mn;function hf(e,t){t=mf(t,e);for(var o=0,n=t.length;e!=null&&o<n;)e=e[ff(t[o++])];return o&&o==n?e:void 0}var yf=hf;function gf(e,t,o){var n=-1,s=e.length;t<0&&(t=-t>s?0:s+t),o=o>s?s:o,o<0&&(o+=s),s=t>o?0:o-t>>>0,t>>>=0;for(var a=Array(s);++n<s;)a[n]=e[n+t];return a}var vf=gf,bf=yf,xf=vf;function Cf(e,t){return t.length<2?e:bf(e,xf(t,0,-1))}var wf=Cf,$f=lo,Sf=cf,kf=wf,Af=Mn;function Tf(e,t){return t=$f(t,e),e=kf(e,t),e==null||delete e[Af(Sf(t))]}var Of=Tf,Ff=Le,If=Xt,Df=Oe,Ef="[object Object]",Nf=Function.prototype,Pf=Object.prototype,_n=Nf.toString,Mf=Pf.hasOwnProperty,_f=_n.call(Object);function jf(e){if(!Df(e)||Ff(e)!=Ef)return!1;var t=If(e);if(t===null)return!0;var o=Mf.call(t,"constructor")&&t.constructor;return typeof o=="function"&&o instanceof o&&_n.call(o)==_f}var Bf=jf,Vf=Bf;function Lf(e){return Vf(e)?void 0:e}var zf=Lf,jn=Re,Uf=Xo,Gf=Fe,Bn=jn?jn.isConcatSpreadable:void 0;function Wf(e){return Gf(e)||Uf(e)||!!(Bn&&e&&e[Bn])}var Hf=Wf,Kf=Qt,qf=Hf;function Vn(e,t,o,n,s){var a=-1,l=e.length;for(o||(o=qf),s||(s=[]);++a<l;){var c=e[a];t>0&&o(c)?t>1?Vn(c,t-1,o,n,s):Kf(s,c):n||(s[s.length]=c)}return s}var Jf=Vn,Yf=Jf;function Zf(e){var t=e==null?0:e.length;return t?Yf(e,1):[]}var Qf=Zf;function Xf(e,t,o){switch(o.length){case 0:return e.call(t);case 1:return e.call(t,o[0]);case 2:return e.call(t,o[0],o[1]);case 3:return e.call(t,o[0],o[1],o[2])}return e.apply(t,o)}var Rf=Xf,eh=Rf,Ln=Math.max;function th(e,t,o){return t=Ln(t===void 0?e.length-1:t,0),function(){for(var n=arguments,s=-1,a=Ln(n.length-t,0),l=Array(a);++s<a;)l[s]=n[t+s];s=-1;for(var c=Array(t+1);++s<t;)c[s]=n[s];return c[t]=o(l),eh(e,this,c)}}var oh=th;function nh(e){return function(){return e}}var rh=nh;function sh(e){return e}var ah=sh,ih=rh,zn=Ko,lh=ah,ch=zn?function(e,t){return zn(e,"toString",{configurable:!0,enumerable:!1,value:ih(t),writable:!0})}:lh,uh=ch,dh=800,ph=16,mh=Date.now;function fh(e){var t=0,o=0;return function(){var n=mh(),s=ph-(n-o);if(o=n,s>0){if(++t>=dh)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var hh=fh,yh=uh,gh=hh,vh=gh(yh),bh=vh,xh=Qf,Ch=oh,wh=bh;function $h(e){return wh(Ch(e,void 0,xh),e+"")}var Sh=$h,kh=No,Ah=Am,Th=Of,Oh=lo,Fh=ot,Ih=zf,Dh=Sh,Eh=dn,Nh=1,Ph=2,Mh=4,_h=Dh(function(e,t){var o={};if(e==null)return o;var n=!1;t=kh(t,function(a){return a=Oh(a,e),n||(n=a.length>1),a}),Fh(e,Eh(e),o),n&&(o=Ah(o,Nh|Ph|Mh,Ih));for(var s=t.length;s--;)Th(o,t[s]);return o}),jh=_h;const Bh=Fo(jh),Un={title:`{{t("Form event", { ns: "${d}" })}}`,type:"form",description:`{{t("Event triggers when submitted a workflow bound form action.", { ns: "${d}" })}}`,fieldset:{collection:C(v({},de),{title:`{{t("Form data model", { ns: "${d}" })}}`,description:`{{t("Use a collection to match form data.", { ns: "${d}" })}}`,"x-reactions":[...de["x-reactions"],{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),appends:C(v({},je),{title:`{{t("Associations to use", { ns: "${d}" })}}`})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:n}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:O("Trigger data")}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:O("User submitted form")}}];return be(C(v({appends:["data","user",...((l=e.appends)==null?void 0:l.map(c=>`data.${c}`))||[]]},t),{fields:s,compile:o,getCollectionFields:n}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:Me,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{},actionTriggerable:!0};function Vh({filterByTk:e,form:t,getField:o,actionFields:n}){if(e&&n){const s=Object.keys(t.values).filter(a=>{const l=o(a);return!n.includes(a)&&["hasOne","hasMany","belongsTo","belongsToMany"].includes(l==null?void 0:l.type)});return Bh(v({},t.values),s)}return t.values}function Lh(){var I;const e=i.useAPIClient(),t=E.useForm(),{field:o,resource:n,__parent:s}=i.useBlockRequestContext(),{setVisible:a,fieldSchema:l}=i.useActionContext(),c=he.useNavigate(),u=E.useFieldSchema(),p=E.useField(),{fields:m,getField:y,getTreeParentField:b}=i.useCollection(),f=i.useCompile(),h=i.useFilterByTk(),$=i.useRecord(),w=i.useCurrentUserContext(),{modal:k}=x.App.useApp(),{getActiveFieldsName:S}=i.useFormActiveFields()||{},T=(I=w==null?void 0:w.data)==null?void 0:I.data,M=p.componentProps.filterKeys||[];return{onClick(){return q(this,null,function*(){var V,re,J,Z,Q,oe;const{assignedValues:D={},onSuccess:N,overwriteValues:U,skipValidator:ae,triggerWorkflows:Y}=(V=u==null?void 0:u["x-action-settings"])!=null?V:{},ue=(re=l==null?void 0:l["x-component-props"])==null?void 0:re.addChild,P=L.parse(D)({currentTime:new Date,currentRecord:$,currentUser:T,$user:T,$nRecord:$,$nForm:t.values,$nDate:{now:new Date}});ae||(yield t.submit());const j=Vh({filterByTk:h,form:t,getField:y,actionFields:(S==null?void 0:S("form"))||[]});if(ue){const ce=b();j[(J=ce==null?void 0:ce.name)!=null?J:"parent"]=$,j[(Z=ce==null?void 0:ce.foreignKey)!=null?Z:"parentId"]=$.id}p.data=o.data||{},p.data.loading=!0;try{const ce=yield e.resource("workflows").trigger({values:v(v(v({},j),U),P),filterKeys:M,triggerWorkflows:Y!=null&&Y.length?Y.map(pe=>[pe.workflowKey,pe.context].filter(Boolean).join("!")).join(","):void 0});if(p.data.loading=!1,p.data.data=ce,(oe=(Q=s==null?void 0:s.service)==null?void 0:Q.refresh)==null||oe.call(Q),a==null||a(!1),!(N!=null&&N.successMessage))return;N!=null&&N.manualClose?k.success({title:f(N==null?void 0:N.successMessage),onOk:()=>q(this,null,function*(){yield t.reset(),N!=null&&N.redirecting&&(N!=null&&N.redirectTo)&&(L.isURL(N.redirectTo)?window.location.href=N.redirectTo:c(N.redirectTo))})}):x.message.success(f(N==null?void 0:N.successMessage))}catch(ce){p.data.loading=!1}})}}}const De={STATIC:0,COLLECTION_FIELD:1};function zh(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function Gn({value:e,onChange:t}){const{t:o}=ee.useTranslation(),[n,s]=g.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:i.css`
|
|
353
390
|
display: flex;
|
|
354
391
|
gap: 0.5em;
|
|
355
|
-
`,children:[r.jsx(
|
|
392
|
+
`,children:[r.jsx(zt,{value:e.field,onChange:a=>t(C(v({},e),{field:a})),filter:zh,placeholder:o("Select field")}),e.field?r.jsx(x.Select,{value:n,onChange:a=>{s(a),t(C(v({},e),{offset:Math.abs(e.offset)*a}))},options:[{value:0,label:O("Exactly at")},{value:-1,label:o("Before")},{value:1,label:o("After")}]}):null,n?r.jsxs(r.Fragment,{children:[r.jsx(x.InputNumber,{value:Math.abs(e.offset),onChange:a=>t(C(v({},e),{offset:(a!=null?a:0)*n}))}),r.jsx(x.Select,{value:e.unit||864e5,onChange:a=>t(C(v({},e),{unit:a})),options:[{value:864e5,label:O("Days")},{value:36e5,label:O("Hours")},{value:6e4,label:O("Minutes")},{value:1e3,label:O("Seconds")}]})]}):null]})}function Uh({value:e,onChange:t}){const{t:o}=Vt(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:i.css`
|
|
356
393
|
display: flex;
|
|
357
394
|
gap: 0.5em;
|
|
358
|
-
`,children:[r.jsxs(x.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},children:[r.jsx(x.Select.Option,{value:null,children:o("No end")}),r.jsx(x.Select.Option,{value:"field",children:o("By field")}),r.jsx(x.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(Mn,{value:e,onChange:t}):null,n==="date"?r.jsx(x.DatePicker,{showTime:!0,value:bo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var ce=function(){return ce=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},ce.apply(this,arguments)};function _n(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function xt(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var Vh=[{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 * * * *"}],Ne=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],B={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function jn(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Ct(e){return e.sort(function(t,o){return t-o}),e}function Bn(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function fe(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 Vn(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function wt(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function Ln(e,t,o,n,s,a,l,c,u,p,m,h,g,f){o&&o(void 0),t(!1);var y=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;y=!0}if(!y){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void f("reboot");var w=Vh.find(function(S){return S.name===e});w&&(e=w.value)}try{var $=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var A=S.replace(/\s+/g," ").trim().split(" ");if(A.length===5)return A.map(function(M,D){return function(_,F){if(_==="*"||_==="*/1")return[];var N=Ct(Bn(Wn(function(ie,Y,ue){if(ue){ie=ie.toUpperCase();for(var E=0;E<ue.length;E++)ie=ie.replace(ue[E],"".concat(E+Y))}return ie}(_,F.min,F.alt).split(",").map(function(ie){var Y,ue=ie.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(_,' for "').concat(F.type,'"'));var E=ue[0],j=ue[1];Y=E==="*"?jn(F.min,F.max):function(J,Z,Q){var ee=J.split("-");if(ee.length===1){var re=wt(ee[0]);if(isNaN(re))throw new Error('Invalid value "'.concat(Z,'" for ').concat(Q.type));return[re]}if(ee.length===2){var pe=wt(ee[0]),qe=wt(ee[1]);if(isNaN(pe)||isNaN(qe))throw new Error('Invalid value "'.concat(Z,'" for ').concat(Q.type));if(qe<pe)throw new Error('Max range is less than min range in "'.concat(J,'" for ').concat(Q.type));return jn(pe,qe)}throw new Error('Invalid value "'.concat(J,'" for ').concat(Q.type))}(E,_,F);var V=function(J,Z){if(J!==void 0){var Q=wt(J);if(isNaN(Q)||Q<1)throw new Error('Invalid interval step value "'.concat(J,'" for ').concat(Z.type));return Q}}(j,F),ne=function(J,Z){if(Z){var Q=J[0];J=J.filter(function(ee){return ee%Z==Q%Z||ee===Q})}return J}(Y,V);return ne}).flat(),F))),U=Hn(N,F);if(U!==void 0)throw new Error('Value "'.concat(U,'" out of range for ').concat(F.type));return N.length===F.total?[]:N}(M,Ne[D])});throw new Error("Invalid cron string format")}(e),k=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}($);f(k),u($[0]),p($[1]),m($[2]),h($[3]),g($[4])}catch(S){y=!0}}y&&(s.current=e,t(!0),Vn(o,l))}function zn(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,p){return u.map(function(m,h){var g=Ne[h];return Un(Gn(m,g),g,p)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function Un(e,t,o,n,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=l&&function(c,u){for(var p=1;p<c.length;p++){var m=c[p-1];if(c[p]-m!==u)return!1}return!0}(e,l)?function(c,u,p){var m=qn(c),h=Kn(c),g=c.length===(h-m)/p+1;return!!(m===u.min&&h+p>u.max&&g)}(e,t,l)?"*/".concat(l):"".concat(He(qn(e),t,o,n,s),"-").concat(He(Kn(e),t,o,n,s),"/").concat(l):function(c){var u=[],p=null;return c.forEach(function(m,h,g){m!==g[h+1]-1?p!==null?(u.push([p,m]),p=null):u.push(m):p===null&&(p=m)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(He(c[0],t,o,n,s),"-").concat(He(c[1],t,o,n,s)):He(c,t,o,n,s)}).join(",")}return a}function He(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,p=n&&(n===!0||n.includes(l)),m=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(p||m)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",g=e%12||12;g<10&&p&&(g=g.toString().padStart(2,"0")),a="".concat(g).concat(h)}return a}function Gn(e,t){var o=Ct(Bn(Wn(e,t)));if(o.length===0)return o;var n=Hn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function Wn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function Hn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function qn(e){return e[0]}function Kn(e){return e[e.length-1]}function et(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,p=e.disabled,m=e.readOnly,h=e.leadingZero,g=e.clockFormat,f=e.period,y=e.unit,w=e.periodicityOnDoubleClick,$=e.mode,k=_n(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(E){return E.toString()})},[t]),A=b.useMemo(function(){return s?s.map(function(E,j){return{value:(y.min===0?j:j+1).toString(),label:E}}):xt([],Array(y.total),!0).map(function(E,j){var V=y.min===0?j:j+1;return{value:V.toString(),label:He(V,y,u,h,g)}})},[s,h,u,g]),M=JSON.stringify(l),D=b.useCallback(function(E){var j=E.value;if(!t||t[0]!==Number(j))return r.jsx(r.Fragment,{});var V=Un(Gn(t,y),y,u,h,g),ne=V.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ne[1]?"".concat(l.everyText||B.everyText," ").concat(ne[1]):V})},[t,M,u,h,g]),_=b.useCallback(function(E){var j=Array.isArray(E)?Ct(E):[E],V=j;t&&(V=$==="single"?[]:xt([],t,!0),j.forEach(function(ne){var J=Number(ne);V=t.some(function(Z){return Z===J})?V.filter(function(Z){return Z!==J}):Ct(xt(xt([],V,!0),[J],!1))})),V.length===y.total?a([]):a(V)},[a,t]),F=b.useCallback(function(E){if(E!==0&&E!==1){for(var j=y.total+y.min,V=[],ne=y.min;ne<j;ne++)ne%E==0&&V.push(ne);var J=t&&V&&t.length===V.length&&t.every(function(Q,ee){return Q===V[ee]}),Z=V.length===A.length;a(Z||J?[]:V)}else a([])},[t,A,a]),N=b.useRef([]),U=b.useCallback(function(E){if(!m){var j=N.current;j.push({time:new Date().getTime(),value:Number(E)});var V=window.setTimeout(function(){w&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?F(Number(E)):_([j[j.length-2].value,j[j.length-1].value]):_(Number(E)),N.current=[]},300);return function(){window.clearTimeout(V)}}},[N,_,F,m,w]),ie=b.useCallback(function(){m||a([])},[a,m]),Y=b.useMemo(function(){var E;return fe(((E={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,E))},[c]),ue=b.useMemo(function(){var E;return fe(((E={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(y.type)]=!0,E["react-js-cron-custom-select-dropdown"]=!0,E["react-js-cron-custom-select-dropdown-".concat(y.type)]=!0,E["react-js-cron-custom-select-dropdown-minutes-large"]=y.type==="minutes"&&f!=="hour"&&f!=="day",E["react-js-cron-custom-select-dropdown-minutes-medium"]=y.type==="minutes"&&(f==="day"||f==="hour"),E["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=y.type==="hours"&&g==="12-hour-clock",E["react-js-cron-custom-select-dropdown-grid"]=!!n,E["".concat(c,"-select-dropdown")]=!!c,E["".concat(c,"-select-dropdown-").concat(y.type)]=!!c,E))},[c,n,g,f]);return r.jsx(x.Select,ce({mode:$!=="single"||w?"multiple":void 0,allowClear:!m,virtual:!1,open:!m&&void 0,value:S,onClear:ie,tagRender:D,className:Y,popupClassName:ue,options:A,showSearch:!1,showArrow:!m,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:U,onDeselect:U,disabled:p,dropdownAlign:y.type!=="minutes"&&y.type!=="hours"||f==="day"||f==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(y.type)},k))}function Lh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=b.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-hours")]=!!s,f))},[s]);return r.jsxs("div",ce({className:g},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(et,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:Ne[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:m,mode:h})]}))}function zh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=b.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-minutes")]=!!s,f))},[s]);return r.jsxs("div",ce({className:g},{children:[p==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(et,{placeholder:p==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:Ne[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:m,mode:h}),p==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function Uh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=!a||a.length===0,f=b.useMemo(function(){var $;return fe((($={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!g})["".concat(s,"-field")]=!!s,$["".concat(s,"-month-days")]=!!s,$))},[s,g]),y=JSON.stringify(n),w=b.useMemo(function(){return g?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[g,y]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",ce({className:f},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(et,{placeholder:w,value:t,setValue:o,unit:Ne[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:u,period:p,periodicityOnDoubleClick:m,mode:h})]})):null}function Gh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,p=e.periodicityOnDoubleClick,m=e.mode,h=n.months||B.months,g=b.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-months")]=!!s,f))},[s]);return r.jsxs("div",ce({className:g},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(et,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:h,grid:!1,value:t,unit:ce(ce({},Ne[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:p,mode:m})]}))}function Wh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,p=[];u.includes("year")&&p.push({value:"year",label:n.yearOption||B.yearOption}),u.includes("month")&&p.push({value:"month",label:n.monthOption||B.monthOption}),u.includes("week")&&p.push({value:"week",label:n.weekOption||B.weekOption}),u.includes("day")&&p.push({value:"day",label:n.dayOption||B.dayOption}),u.includes("hour")&&p.push({value:"hour",label:n.hourOption||B.hourOption}),u.includes("minute")&&p.push({value:"minute",label:n.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:n.rebootOption||B.rebootOption});var m=b.useCallback(function(y){l||o(y)},[o,l]),h=b.useMemo(function(){var y;return fe(((y={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,y["".concat(s,"-period")]=!!s,y))},[s]),g=b.useMemo(function(){var y;return fe(((y={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,y))},[s,n.prefixPeriod]),f=b.useMemo(function(){var y;return fe(((y={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,y["".concat(s,"-select-dropdown-period")]=!!s,y))},[s]);return r.jsxs("div",ce({className:h},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(x.Select,{defaultValue:t,value:t,onChange:m,options:p,className:g,popupClassName:f,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Hh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,p=e.period,m=e.periodicityOnDoubleClick,h=e.mode,g=n.weekDays||B.weekDays,f=p==="week"||!l||l.length===0,y=b.useMemo(function(){var A;return fe(((A={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!f})["".concat(s,"-field")]=!!s,A["".concat(s,"-week-days")]=!!s,A))},[s,f]),w=JSON.stringify(n),$=b.useMemo(function(){return f?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[f,w]),k=p==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),S=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return k?r.jsxs("div",ce({className:y},{children:[n.prefixWeekDays!==""&&(p==="week"||!S)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&S&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(et,{placeholder:$,optionsList:g,grid:!1,value:t,unit:ce(ce({},Ne[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:p,periodicityOnDoubleClick:m,mode:h})]})):null}function qh(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,p=e.value,m=p===void 0?"":p,h=e.setValue,g=e.displayError,f=g===void 0||g,y=e.onError,w=e.className,$=e.defaultPeriod,k=$===void 0?"day":$,S=e.allowEmpty,A=S===void 0?"for-default-value":S,M=e.humanizeLabels,D=M===void 0||M,_=e.humanizeValue,F=_!==void 0&&_,N=e.disabled,U=N!==void 0&&N,ie=e.readOnly,Y=ie!==void 0&&ie,ue=e.leadingZero,E=ue!==void 0&&ue,j=e.shortcuts,V=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ne=e.clockFormat,J=e.periodicityOnDoubleClick,Z=J===void 0||J,Q=e.mode,ee=Q===void 0?"multiple":Q,re=e.allowedDropdowns,pe=re===void 0?["period","months","month-days","week-days","hours","minutes"]:re,qe=e.allowedPeriods,Jg=qe===void 0?["year","month","week","day","hour","minute","reboot"]:qe,Ke=b.useRef(m),yo=b.useRef(k),Ir=b.useState(),$e=Ir[0],St=Ir[1],Dr=b.useState(),it=Dr[0],kt=Dr[1],Nr=b.useState(),At=Nr[0],Tt=Nr[1],Pr=b.useState(),lt=Pr[0],Ot=Pr[1],Er=b.useState(),Ft=Er[0],It=Er[1],Mr=b.useState(),Dt=Mr[0],Nt=Mr[1],_r=b.useState(!1),go=_r[0],ct=_r[1],jr=b.useState(!1),Pt=jr[0],Br=jr[1],Yg=function(X){var ve=b.useRef(X);return b.useEffect(function(){ve.current=X},[X]),ve.current}(Pt),Vr=JSON.stringify(u);b.useEffect(function(){Ln(m,ct,y,A,Ke,!0,u,V,Nt,It,kt,Tt,Ot,St)},[]),b.useEffect(function(){m!==Ke.current&&Ln(m,ct,y,A,Ke,!1,u,V,Nt,It,kt,Tt,Ot,St)},[m,Ke,Vr,A,V]),b.useEffect(function(){if(!($e||Dt||At||it||lt||Ft)||Pt||Yg)Pt&&Br(!1);else{var X=$e||yo.current,ve=zn(X,At,it,lt,Ft,Dt,F);h(ve,{selectedPeriod:X}),Ke.current=ve,y&&y(void 0),ct(!1)}},[$e,it,At,lt,Ft,Dt,F,Pt]);var Lr=b.useCallback(function(){kt(void 0),Tt(void 0),Ot(void 0),It(void 0),Nt(void 0);var X="",ve=$e!=="reboot"&&$e?$e:yo.current;ve!==$e&&St(ve),l==="fill-with-every"&&(X=zn(ve,void 0,void 0,void 0,void 0,void 0)),h(X,{selectedPeriod:ve}),Ke.current=X,Br(!0),A==="never"&&l==="empty"?(ct(!0),Vn(y,u)):(y&&y(void 0),ct(!1))},[$e,h,y,l]),Zg=b.useMemo(function(){var X;return fe(((X={"react-js-cron":!0,"react-js-cron-error":go&&f,"react-js-cron-disabled":U,"react-js-cron-read-only":Y})["".concat(w)]=!!w,X["".concat(w,"-error")]=go&&f&&!!w,X["".concat(w,"-disabled")]=U&&!!w,X["".concat(w,"-read-only")]=Y&&!!w,X))},[w,go,f,U,Y]),vo=s.className,zr=_n(s,["className"]),Ur=b.useMemo(function(){var X;return fe(((X={"react-js-cron-clear-button":!0})["".concat(w,"-clear-button")]=!!w,X["".concat(vo)]=!!vo,X))},[w,vo]),Qg=JSON.stringify(zr),Gr=b.useMemo(function(){return o&&!Y?r.jsx(x.Button,ce({className:Ur,danger:!0,type:"primary",disabled:U},zr,{onClick:Lr},{children:u.clearButtonText||B.clearButtonText})):null},[o,Y,Vr,Ur,U,Qg,Lr]),le=$e||yo.current;return r.jsxs("div",ce({className:Zg},{children:[pe.includes("period")&&r.jsx(Wh,{value:le,setValue:St,locale:u,className:w,disabled:U,readOnly:Y,shortcuts:V,allowedPeriods:Jg}),le==="reboot"?Gr:r.jsxs(r.Fragment,{children:[le==="year"&&pe.includes("months")&&r.jsx(Gh,{value:At,setValue:Tt,locale:u,className:w,humanizeLabels:D,disabled:U,readOnly:Y,period:le,periodicityOnDoubleClick:Z,mode:ee}),(le==="year"||le==="month")&&pe.includes("month-days")&&r.jsx(Uh,{value:it,setValue:kt,locale:u,className:w,weekDays:lt,disabled:U,readOnly:Y,leadingZero:E,period:le,periodicityOnDoubleClick:Z,mode:ee}),(le==="year"||le==="month"||le==="week")&&pe.includes("week-days")&&r.jsx(Hh,{value:lt,setValue:Ot,locale:u,className:w,humanizeLabels:D,monthDays:it,disabled:U,readOnly:Y,period:le,periodicityOnDoubleClick:Z,mode:ee}),r.jsxs("div",{children:[le!=="minute"&&le!=="hour"&&pe.includes("hours")&&r.jsx(Lh,{value:Ft,setValue:It,locale:u,className:w,disabled:U,readOnly:Y,leadingZero:E,clockFormat:ne,period:le,periodicityOnDoubleClick:Z,mode:ee}),le!=="minute"&&pe.includes("minutes")&&r.jsx(zh,{value:Dt,setValue:Nt,locale:u,period:le,className:w,disabled:U,readOnly:Y,leadingZero:E,clockFormat:ne,periodicityOnDoubleClick:Z,mode:ee}),Gr]})]})]}))}const Kh={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},Jn=[{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 Yn(e){return Jn.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Jh(e){let t;switch(typeof e){case"number":return t=Yn(e),t?t.value:"none";case"string":return"cron"}return"none"}function Yh({value:e,onChange:t}){const{t:o}=Mt(),n=Yn(e);return r.jsx(x.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Zh({value:e=null,onChange:t}){const{t:o}=Mt(),n=Jh(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=Kh[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:i.css`
|
|
395
|
+
`,children:[r.jsxs(x.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},children:[r.jsx(x.Select.Option,{value:null,children:o("No end")}),r.jsx(x.Select.Option,{value:"field",children:o("By field")}),r.jsx(x.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(Gn,{value:e,onChange:t}):null,n==="date"?r.jsx(x.DatePicker,{showTime:!0,value:Ao(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var le=function(){return le=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},le.apply(this,arguments)};function Wn(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function $t(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var Gh=[{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 * * * *"}],Ee=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],B={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function Hn(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function St(e){return e.sort(function(t,o){return t-o}),e}function Kn(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function fe(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 qn(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function kt(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function Jn(e,t,o,n,s,a,l,c,u,p,m,y,b,f){o&&o(void 0),t(!1);var h=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;h=!0}if(!h){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void f("reboot");var $=Gh.find(function(S){return S.name===e});$&&(e=$.value)}try{var w=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var T=S.replace(/\s+/g," ").trim().split(" ");if(T.length===5)return T.map(function(M,I){return function(_,D){if(_==="*"||_==="*/1")return[];var N=St(Kn(Xn(function(ae,Y,ue){if(ue){ae=ae.toUpperCase();for(var P=0;P<ue.length;P++)ae=ae.replace(ue[P],"".concat(P+Y))}return ae}(_,D.min,D.alt).split(",").map(function(ae){var Y,ue=ae.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(_,' for "').concat(D.type,'"'));var P=ue[0],j=ue[1];Y=P==="*"?Hn(D.min,D.max):function(J,Z,Q){var oe=J.split("-");if(oe.length===1){var ce=kt(oe[0]);if(isNaN(ce))throw new Error('Invalid value "'.concat(Z,'" for ').concat(Q.type));return[ce]}if(oe.length===2){var pe=kt(oe[0]),qe=kt(oe[1]);if(isNaN(pe)||isNaN(qe))throw new Error('Invalid value "'.concat(Z,'" for ').concat(Q.type));if(qe<pe)throw new Error('Max range is less than min range in "'.concat(J,'" for ').concat(Q.type));return Hn(pe,qe)}throw new Error('Invalid value "'.concat(J,'" for ').concat(Q.type))}(P,_,D);var V=function(J,Z){if(J!==void 0){var Q=kt(J);if(isNaN(Q)||Q<1)throw new Error('Invalid interval step value "'.concat(J,'" for ').concat(Z.type));return Q}}(j,D),re=function(J,Z){if(Z){var Q=J[0];J=J.filter(function(oe){return oe%Z==Q%Z||oe===Q})}return J}(Y,V);return re}).flat(),D))),U=Rn(N,D);if(U!==void 0)throw new Error('Value "'.concat(U,'" out of range for ').concat(D.type));return N.length===D.total?[]:N}(M,Ee[I])});throw new Error("Invalid cron string format")}(e),k=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"}(w);f(k),u(w[0]),p(w[1]),m(w[2]),y(w[3]),b(w[4])}catch(S){h=!0}}h&&(s.current=e,t(!0),qn(o,l))}function Yn(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,p){return u.map(function(m,y){var b=Ee[y];return Zn(Qn(m,b),b,p)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function Zn(e,t,o,n,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=l&&function(c,u){for(var p=1;p<c.length;p++){var m=c[p-1];if(c[p]-m!==u)return!1}return!0}(e,l)?function(c,u,p){var m=er(c),y=tr(c),b=c.length===(y-m)/p+1;return!!(m===u.min&&y+p>u.max&&b)}(e,t,l)?"*/".concat(l):"".concat(He(er(e),t,o,n,s),"-").concat(He(tr(e),t,o,n,s),"/").concat(l):function(c){var u=[],p=null;return c.forEach(function(m,y,b){m!==b[y+1]-1?p!==null?(u.push([p,m]),p=null):u.push(m):p===null&&(p=m)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(He(c[0],t,o,n,s),"-").concat(He(c[1],t,o,n,s)):He(c,t,o,n,s)}).join(",")}return a}function He(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,p=n&&(n===!0||n.includes(l)),m=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(p||m)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var y=e>=12?"PM":"AM",b=e%12||12;b<10&&p&&(b=b.toString().padStart(2,"0")),a="".concat(b).concat(y)}return a}function Qn(e,t){var o=St(Kn(Xn(e,t)));if(o.length===0)return o;var n=Rn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function Xn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function Rn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function er(e){return e[0]}function tr(e){return e[e.length-1]}function nt(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,p=e.disabled,m=e.readOnly,y=e.leadingZero,b=e.clockFormat,f=e.period,h=e.unit,$=e.periodicityOnDoubleClick,w=e.mode,k=Wn(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=g.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(P){return P.toString()})},[t]),T=g.useMemo(function(){return s?s.map(function(P,j){return{value:(h.min===0?j:j+1).toString(),label:P}}):$t([],Array(h.total),!0).map(function(P,j){var V=h.min===0?j:j+1;return{value:V.toString(),label:He(V,h,u,y,b)}})},[s,y,u,b]),M=JSON.stringify(l),I=g.useCallback(function(P){var j=P.value;if(!t||t[0]!==Number(j))return r.jsx(r.Fragment,{});var V=Zn(Qn(t,h),h,u,y,b),re=V.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:re[1]?"".concat(l.everyText||B.everyText," ").concat(re[1]):V})},[t,M,u,y,b]),_=g.useCallback(function(P){var j=Array.isArray(P)?St(P):[P],V=j;t&&(V=w==="single"?[]:$t([],t,!0),j.forEach(function(re){var J=Number(re);V=t.some(function(Z){return Z===J})?V.filter(function(Z){return Z!==J}):St($t($t([],V,!0),[J],!1))})),V.length===h.total?a([]):a(V)},[a,t]),D=g.useCallback(function(P){if(P!==0&&P!==1){for(var j=h.total+h.min,V=[],re=h.min;re<j;re++)re%P==0&&V.push(re);var J=t&&V&&t.length===V.length&&t.every(function(Q,oe){return Q===V[oe]}),Z=V.length===T.length;a(Z||J?[]:V)}else a([])},[t,T,a]),N=g.useRef([]),U=g.useCallback(function(P){if(!m){var j=N.current;j.push({time:new Date().getTime(),value:Number(P)});var V=window.setTimeout(function(){$&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?D(Number(P)):_([j[j.length-2].value,j[j.length-1].value]):_(Number(P)),N.current=[]},300);return function(){window.clearTimeout(V)}}},[N,_,D,m,$]),ae=g.useCallback(function(){m||a([])},[a,m]),Y=g.useMemo(function(){var P;return fe(((P={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,P))},[c]),ue=g.useMemo(function(){var P;return fe(((P={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(h.type)]=!0,P["react-js-cron-custom-select-dropdown"]=!0,P["react-js-cron-custom-select-dropdown-".concat(h.type)]=!0,P["react-js-cron-custom-select-dropdown-minutes-large"]=h.type==="minutes"&&f!=="hour"&&f!=="day",P["react-js-cron-custom-select-dropdown-minutes-medium"]=h.type==="minutes"&&(f==="day"||f==="hour"),P["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=h.type==="hours"&&b==="12-hour-clock",P["react-js-cron-custom-select-dropdown-grid"]=!!n,P["".concat(c,"-select-dropdown")]=!!c,P["".concat(c,"-select-dropdown-").concat(h.type)]=!!c,P))},[c,n,b,f]);return r.jsx(x.Select,le({mode:w!=="single"||$?"multiple":void 0,allowClear:!m,virtual:!1,open:!m&&void 0,value:S,onClear:ae,tagRender:I,className:Y,popupClassName:ue,options:T,showSearch:!1,showArrow:!m,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:U,onDeselect:U,disabled:p,dropdownAlign:h.type!=="minutes"&&h.type!=="hours"||f==="day"||f==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(h.type)},k))}function Wh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,m=e.periodicityOnDoubleClick,y=e.mode,b=g.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-hours")]=!!s,f))},[s]);return r.jsxs("div",le({className:b},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(nt,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:Ee[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:m,mode:y})]}))}function Hh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,m=e.periodicityOnDoubleClick,y=e.mode,b=g.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-minutes")]=!!s,f))},[s]);return r.jsxs("div",le({className:b},{children:[p==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(nt,{placeholder:p==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:Ee[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:m,mode:y}),p==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function Kh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,p=e.period,m=e.periodicityOnDoubleClick,y=e.mode,b=!a||a.length===0,f=g.useMemo(function(){var w;return fe(((w={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!b})["".concat(s,"-field")]=!!s,w["".concat(s,"-month-days")]=!!s,w))},[s,b]),h=JSON.stringify(n),$=g.useMemo(function(){return b?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[b,h]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",le({className:f},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(nt,{placeholder:$,value:t,setValue:o,unit:Ee[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:u,period:p,periodicityOnDoubleClick:m,mode:y})]})):null}function qh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,p=e.periodicityOnDoubleClick,m=e.mode,y=n.months||B.months,b=g.useMemo(function(){var f;return fe(((f={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-months")]=!!s,f))},[s]);return r.jsxs("div",le({className:b},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(nt,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:y,grid:!1,value:t,unit:le(le({},Ee[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:p,mode:m})]}))}function Jh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,p=[];u.includes("year")&&p.push({value:"year",label:n.yearOption||B.yearOption}),u.includes("month")&&p.push({value:"month",label:n.monthOption||B.monthOption}),u.includes("week")&&p.push({value:"week",label:n.weekOption||B.weekOption}),u.includes("day")&&p.push({value:"day",label:n.dayOption||B.dayOption}),u.includes("hour")&&p.push({value:"hour",label:n.hourOption||B.hourOption}),u.includes("minute")&&p.push({value:"minute",label:n.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:n.rebootOption||B.rebootOption});var m=g.useCallback(function(h){l||o(h)},[o,l]),y=g.useMemo(function(){var h;return fe(((h={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-period")]=!!s,h))},[s]),b=g.useMemo(function(){var h;return fe(((h={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,h))},[s,n.prefixPeriod]),f=g.useMemo(function(){var h;return fe(((h={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,h["".concat(s,"-select-dropdown-period")]=!!s,h))},[s]);return r.jsxs("div",le({className:y},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(x.Select,{defaultValue:t,value:t,onChange:m,options:p,className:b,popupClassName:f,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Yh(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,p=e.period,m=e.periodicityOnDoubleClick,y=e.mode,b=n.weekDays||B.weekDays,f=p==="week"||!l||l.length===0,h=g.useMemo(function(){var T;return fe(((T={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!f})["".concat(s,"-field")]=!!s,T["".concat(s,"-week-days")]=!!s,T))},[s,f]),$=JSON.stringify(n),w=g.useMemo(function(){return f?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[f,$]),k=p==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),S=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return k?r.jsxs("div",le({className:h},{children:[n.prefixWeekDays!==""&&(p==="week"||!S)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&S&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(nt,{placeholder:w,optionsList:b,grid:!1,value:t,unit:le(le({},Ee[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:p,periodicityOnDoubleClick:m,mode:y})]})):null}function Zh(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,p=e.value,m=p===void 0?"":p,y=e.setValue,b=e.displayError,f=b===void 0||b,h=e.onError,$=e.className,w=e.defaultPeriod,k=w===void 0?"day":w,S=e.allowEmpty,T=S===void 0?"for-default-value":S,M=e.humanizeLabels,I=M===void 0||M,_=e.humanizeValue,D=_!==void 0&&_,N=e.disabled,U=N!==void 0&&N,ae=e.readOnly,Y=ae!==void 0&&ae,ue=e.leadingZero,P=ue!==void 0&&ue,j=e.shortcuts,V=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,re=e.clockFormat,J=e.periodicityOnDoubleClick,Z=J===void 0||J,Q=e.mode,oe=Q===void 0?"multiple":Q,ce=e.allowedDropdowns,pe=ce===void 0?["period","months","month-days","week-days","hours","minutes"]:ce,qe=e.allowedPeriods,Yg=qe===void 0?["year","month","week","day","hour","minute","reboot"]:qe,Je=g.useRef(m),wo=g.useRef(k),Nr=g.useState(),$e=Nr[0],Tt=Nr[1],Pr=g.useState(),lt=Pr[0],Ot=Pr[1],Mr=g.useState(),Ft=Mr[0],It=Mr[1],_r=g.useState(),ct=_r[0],Dt=_r[1],jr=g.useState(),Et=jr[0],Nt=jr[1],Br=g.useState(),Pt=Br[0],Mt=Br[1],Vr=g.useState(!1),$o=Vr[0],ut=Vr[1],Lr=g.useState(!1),_t=Lr[0],zr=Lr[1],Zg=function(R){var xe=g.useRef(R);return g.useEffect(function(){xe.current=R},[R]),xe.current}(_t),Ur=JSON.stringify(u);g.useEffect(function(){Jn(m,ut,h,T,Je,!0,u,V,Mt,Nt,Ot,It,Dt,Tt)},[]),g.useEffect(function(){m!==Je.current&&Jn(m,ut,h,T,Je,!1,u,V,Mt,Nt,Ot,It,Dt,Tt)},[m,Je,Ur,T,V]),g.useEffect(function(){if(!($e||Pt||Ft||lt||ct||Et)||_t||Zg)_t&&zr(!1);else{var R=$e||wo.current,xe=Yn(R,Ft,lt,ct,Et,Pt,D);y(xe,{selectedPeriod:R}),Je.current=xe,h&&h(void 0),ut(!1)}},[$e,lt,Ft,ct,Et,Pt,D,_t]);var Gr=g.useCallback(function(){Ot(void 0),It(void 0),Dt(void 0),Nt(void 0),Mt(void 0);var R="",xe=$e!=="reboot"&&$e?$e:wo.current;xe!==$e&&Tt(xe),l==="fill-with-every"&&(R=Yn(xe,void 0,void 0,void 0,void 0,void 0)),y(R,{selectedPeriod:xe}),Je.current=R,zr(!0),T==="never"&&l==="empty"?(ut(!0),qn(h,u)):(h&&h(void 0),ut(!1))},[$e,y,h,l]),Qg=g.useMemo(function(){var R;return fe(((R={"react-js-cron":!0,"react-js-cron-error":$o&&f,"react-js-cron-disabled":U,"react-js-cron-read-only":Y})["".concat($)]=!!$,R["".concat($,"-error")]=$o&&f&&!!$,R["".concat($,"-disabled")]=U&&!!$,R["".concat($,"-read-only")]=Y&&!!$,R))},[$,$o,f,U,Y]),So=s.className,Wr=Wn(s,["className"]),Hr=g.useMemo(function(){var R;return fe(((R={"react-js-cron-clear-button":!0})["".concat($,"-clear-button")]=!!$,R["".concat(So)]=!!So,R))},[$,So]),Xg=JSON.stringify(Wr),Kr=g.useMemo(function(){return o&&!Y?r.jsx(x.Button,le({className:Hr,danger:!0,type:"primary",disabled:U},Wr,{onClick:Gr},{children:u.clearButtonText||B.clearButtonText})):null},[o,Y,Ur,Hr,U,Xg,Gr]),ie=$e||wo.current;return r.jsxs("div",le({className:Qg},{children:[pe.includes("period")&&r.jsx(Jh,{value:ie,setValue:Tt,locale:u,className:$,disabled:U,readOnly:Y,shortcuts:V,allowedPeriods:Yg}),ie==="reboot"?Kr:r.jsxs(r.Fragment,{children:[ie==="year"&&pe.includes("months")&&r.jsx(qh,{value:Ft,setValue:It,locale:u,className:$,humanizeLabels:I,disabled:U,readOnly:Y,period:ie,periodicityOnDoubleClick:Z,mode:oe}),(ie==="year"||ie==="month")&&pe.includes("month-days")&&r.jsx(Kh,{value:lt,setValue:Ot,locale:u,className:$,weekDays:ct,disabled:U,readOnly:Y,leadingZero:P,period:ie,periodicityOnDoubleClick:Z,mode:oe}),(ie==="year"||ie==="month"||ie==="week")&&pe.includes("week-days")&&r.jsx(Yh,{value:ct,setValue:Dt,locale:u,className:$,humanizeLabels:I,monthDays:lt,disabled:U,readOnly:Y,period:ie,periodicityOnDoubleClick:Z,mode:oe}),r.jsxs("div",{children:[ie!=="minute"&&ie!=="hour"&&pe.includes("hours")&&r.jsx(Wh,{value:Et,setValue:Nt,locale:u,className:$,disabled:U,readOnly:Y,leadingZero:P,clockFormat:re,period:ie,periodicityOnDoubleClick:Z,mode:oe}),ie!=="minute"&&pe.includes("minutes")&&r.jsx(Hh,{value:Pt,setValue:Mt,locale:u,period:ie,className:$,disabled:U,readOnly:Y,leadingZero:P,clockFormat:re,periodicityOnDoubleClick:Z,mode:oe}),Kr]})]})]}))}const Qh={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},or=[{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 nr(e){return or.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Xh(e){let t;switch(typeof e){case"number":return t=nr(e),t?t.value:"none";case"string":return"cron"}return"none"}function Rh({value:e,onChange:t}){const{t:o}=Vt(),n=nr(e);return r.jsx(x.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function ey({value:e=null,onChange:t}){const{t:o}=Vt(),n=Xh(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=Qh[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:i.css`
|
|
359
396
|
display: flex;
|
|
360
397
|
flex-direction: ${n==="cron"?"column":"row"};
|
|
361
398
|
align-items: flex-start;
|
|
@@ -384,7 +421,7 @@
|
|
|
384
421
|
}
|
|
385
422
|
}
|
|
386
423
|
}
|
|
387
|
-
`,children:[r.jsx(x.Select,{value:n,onChange:s,className:"auto-width",children:
|
|
424
|
+
`,children:[r.jsx(x.Select,{value:n,onChange:s,className:"auto-width",children:or.map(l=>r.jsx(x.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Rh,{value:e,onChange:t}):null,n==="cron"?r.jsx(Zh,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:a}):null]})}const ty={[De.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${d}" })}}`,min:0}}},[De.COLLECTION_FIELD]:{collection:C(v({},de),{"x-reactions":[...de["x-reactions"],{target:"startsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${d}" })}}`,"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: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${d}" })}}`,min:0}},appends:C(v({},je),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${De.COLLECTION_FIELD} && $deps[1]}}`}}}]})}},oy=[{value:De.STATIC,label:`{{t("Based on certain date", { ns: "${d}" })}}`},{value:De.COLLECTION_FIELD,label:`{{t("Based on date field of collection", { ns: "${d}" })}}`}],ny=()=>{const{values:e={},clearFormGraph:t}=E.useForm(),[o,n]=g.useState(e.mode);return E.useFormEffects(()=>{me.onFieldValueChange("mode",s=>{n(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(i.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${d}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:oy},required:!0,default:De.STATIC}}),r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
388
425
|
.ant-input-number {
|
|
389
426
|
width: auto;
|
|
390
427
|
min-width: 6em;
|
|
@@ -393,43 +430,37 @@
|
|
|
393
430
|
.ant-picker {
|
|
394
431
|
width: auto;
|
|
395
432
|
}
|
|
396
|
-
`},properties:
|
|
433
|
+
`},properties:ty[o]}}},components:{OnField:Gn,RepeatField:ey,EndsByField:Uh}})]})},rr={title:`{{t("Schedule event", { ns: "${d}" })}}`,type:"schedule",description:`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${d}" })}}`,fieldset:{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{ScheduleConfig:ny},useVariables(e,t){var a;const o=i.useCompile(),{getCollectionFields:n}=i.useCollectionManager(),s=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&s.push({key:"date",value:"date",label:O("Trigger time")}),e.mode===De.COLLECTION_FIELD){const[l]=be(C(v({appends:["data",...((a=e.appends)==null?void 0:a.map(c=>`data.${c}`))||[]]},t),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:O("Trigger data")}}],compile:o,getCollectionFields:n}));l&&s.push(l)}return s},useInitializers(e){return e.collection?{type:"item",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:Me,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function ry(){var a;const e=E.useForm(),t=i.useAPIClient(),{workflow:o}=(a=z())!=null?a:{},n=i.useActionContext(),{refresh:s}=i.useResourceActionContext();return{run(){return q(this,null,function*(){var c,u;if(o.executed){x.message.error(O("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("workflows")).update)==null?void 0:u.call(c,{filterByTk:o.id,values:{config:e.values}}),n.setVisible(!1),s()})}}}const ge=new L.Registry;ge.register(Un.type,Un),ge.register(Eo.type,Eo),ge.register(rr.type,rr);function sy(){const e=i.useCompile(),{workflow:t,execution:o}=z(),{styles:n}=ne();if(!o)return null;const s=ge.get(t.type);return r.jsx(i.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(F.InfoOutlined,{}),shape:"circle",size:"small",className:n.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.cx(n.nodeTitleClass),children:[r.jsx(x.Tag,{children:e(s.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:i.css`
|
|
397
434
|
padding: 1em;
|
|
398
435
|
background-color: #eee;
|
|
399
|
-
`},"x-read-pretty":!0}}}}}})}const
|
|
400
|
-
width: 100%;
|
|
401
|
-
font-size: 85%;
|
|
402
|
-
margin-bottom: 2em;
|
|
403
|
-
`}}}:f.description?{description:{type:"void","x-component":Co,"x-component-props":{label:T("Trigger type"),title:f.title,description:f.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
436
|
+
`},"x-read-pretty":!0}}}}}})}const ay=()=>{const e=i.useAPIClient(),{workflow:t,refresh:o}=z(),[n,s]=g.useState(""),[a,l]=g.useState(!1),{styles:c}=ne();let u="";g.useEffect(()=>{var I;t&&s((I=t.title)!=null?I:u)},[t]);const p=g.useMemo(()=>me.createForm({initialValues:t==null?void 0:t.config,values:t==null?void 0:t.config,disabled:t==null?void 0:t.executed}),[t]);if(!t||!t.type)return null;const{title:m,type:y,executed:b}=t,f=ge.get(y),{fieldset:h,scope:$,components:w}=f;u=f.title;const k=b?'{{t("View")}}':'{{t("Configure")}}',S=O("Trigger");function T(I){return q(this,null,function*(){var D,N;const _=I||u;s(_),_!==m&&(yield(N=(D=e.resource("workflows")).update)==null?void 0:N.call(D,{filterByTk:t.id,values:{title:_}}),o())})}function M(I){var D;if(I.target===I.currentTarget){l(!0);return}const _=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let N=I.target;N&&N!==I.currentTarget;N=N.parentNode)if(Array.from((D=N.classList)!=null?D:[]).some(U=>_.has(U))){l(!0),I.stopPropagation();return}}return r.jsxs("div",{role:"button","aria-label":`${S}-${n}`,className:i.cx(c.nodeCardClass),onClick:M,children:[r.jsx("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:r.jsx(x.Tag,{color:"gold",children:S})}),r.jsx("div",{children:r.jsx(x.Input.TextArea,{role:"button","aria-label":"textarea",value:n,onChange:I=>s(I.target.value),onBlur:I=>T(I.target.value),autoSize:!0})}),r.jsx(sy,{}),r.jsx(i.ActionContextProvider,{value:{visible:a,setVisible:l},children:r.jsx(i.SchemaComponent,{schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":k,"x-component":x.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:S,"x-component":"Action.Drawer","x-decorator":"FormV2","x-decorator-props":{form:p},properties:C(v({},f.description?{description:{type:"void","x-component":Oo,"x-component-props":{label:O("Trigger type"),title:f.title,description:f.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
404
437
|
.ant-select.auto-width {
|
|
405
438
|
width: auto;
|
|
406
439
|
min-width: 6em;
|
|
407
440
|
}
|
|
408
|
-
`},properties:
|
|
441
|
+
`},properties:h},actions:v({},b?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:ry}}}})})}}},scope:$,components:w})})]})};function co(){const{workflow:e}=z();return ge.get(e.type)}function uo(){return Array.from(ge.getEntities()).map(n=>{var[e,s]=n,a=s,{title:t}=a,o=H(a,["title"]);return{value:e,label:t,color:"gold",options:o}})}const Ne={label:"label",value:"value",children:"children"},po={label:`{{t("Node result", { ns: "${d}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const t=we(),o=at(t),n=[];return o.forEach(s=>{var c;const a=W.get(s.type),l=(c=a.useVariables)==null?void 0:c.call(a,s,e);l&&n.push(l)}),n}},mo={label:`{{t("Trigger variables", { ns: "${d}" })}}`,value:"$context",useOptions(e){var n,s;const{workflow:t}=z(),o=ge.get(t.type);return(s=(n=o==null?void 0:o.useVariables)==null?void 0:n.call(o,t.config,e))!=null?s:null}},iy={label:`{{t("Scope variables", { ns: "${d}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Ne}=e,o=we(),n=xr(o),s=[];return n.forEach(a=>{var u,p;const l=W.get(a.type),c=(u=l.useScopeVariables)==null?void 0:u.call(l,a,e);c&&s.push({key:a.key,[t.value]:a.key,[t.label]:(p=a.title)!=null?p:`#${a.id}`,[t.children]:c})}),s}},ly={label:`{{t("System variables", { ns: "${d}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=Ne}){return[...!e||e.includes("date")?[{key:"now",[t.label]:O("System time"),[t.value]:"now"}]:[]]}},rt={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 sr(e,t){var n,s,a,l,c,u;const o=typeof t;return o==="string"?(n=rt[t])==null?void 0:n.has(e.interface):o==="object"&&t.type==="reference"?fo(e)?((s=t.options)==null?void 0:s.entity)&&(e.collectionName===((a=t.options)==null?void 0:a.collection)||((l=t.options)==null?void 0:l.collection)==="*"):e.isForeignKey?e.collectionName===((c=t.options)==null?void 0:c.collection)&&e.name==="id"||e.target===((u=t.options)==null?void 0:u.collection):!1:o==="function"?t(e):!1}function fo(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function ho(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function yo({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(u=>sr(l,u)):!0;if(fo(l)){if(o===null)return n?c||yo({fields:go(l.target,{compile:s,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:a}):!1;const u=ho(l,o),p=o.includes(l.name);return c?p:((u==null?void 0:u.length)||p)&&yo({fields:go(l.target,{compile:s,getCollectionFields:a}),types:t,appends:u,compile:s,getCollectionFields:a}).length}else return c})}function se(e={}){var a;const t=Object.assign({},Ne,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t}),n=i.useCompile();return[iy,po,mo,ly].map(l=>{var u,p;const c=(p=(u=l.useOptions)==null?void 0:u.call(l,o))==null?void 0:p.filter(Boolean);return{[t.label]:n(l.label),[t.value]:l.value,key:l[t.value],[t.children]:c,disabled:!c||!c.length}})}function go(e,{compile:t,getCollectionFields:o}){var l,c,u,p,m,y,b;const n=o(e),s=[],a=[];n.forEach(f=>{f.isForeignKey?s.push(f):a.push(f)});for(let f=a.length-1;f>=0;f--){const h=a[f];if(h.type==="belongsTo"){const $=s.find(w=>w.name===h.foreignKey);$?a.splice(f,0,C(v(v({},h),$),{uiSchema:C(v({},h.uiSchema),{title:(l=h.uiSchema)!=null&&l.title?`${t((c=h.uiSchema)==null?void 0:c.title)} ID`:$.name})})):a.splice(f,0,C(v({},h),{name:h.foreignKey,type:"bigInt",isForeignKey:!0,interface:h.interface,uiSchema:C(v({},h.uiSchema),{title:(u=h.uiSchema)!=null&&u.title?`${t((p=h.uiSchema)==null?void 0:p.title)} ID`:h.name})}))}else if(h.type==="context"&&h.collectionName==="users"){const $=(m=a.find(w=>w.type==="belongsTo"&&w.target==="users"&&w.foreignKey===h.name))!=null?m:{};a.splice(f,0,C(v({},h),{type:h.dataType,interface:$.interface,uiSchema:C(v({},$.uiSchema),{title:(y=$.uiSchema)!=null&&y.title?`${t((b=$.uiSchema)==null?void 0:b.title)} ID`:h.name})}))}}return a.filter(f=>f.interface&&!f.hidden)}function cy(e){const t=ho(e.field,e.appends),o=be(v({collection:e.field.target,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(s=>sr(e.field,s))||(e.disabled=!0))}function be(e){const{fields:t,collection:o,types:n,appends:s=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:u=Ne}=e,p=go(o,{compile:l,getCollectionFields:c}),m=t!=null?t:p,y=cy.bind({compile:l,getCollectionFields:c,fieldNames:u});return yo({fields:m,types:n,depth:a,appends:s,compile:l,getCollectionFields:c}).map(f=>{var k;const h=l(((k=f.uiSchema)==null?void 0:k.title)||f.name),$=ho(f,s),w=!fo(f)||$&&!$.length&&!s.includes(f.name)||!1;return{[u.label]:h,key:f.name,[u.value]:f.name,isLeaf:w,loadChildren:w?null:y,field:f,depth:a,appends:s,types:n}})}function st({value:e,onChange:t,renderSchemaComponent:o}){const n=se();return r.jsx(i.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}const Ke=()=>null;function uy(s){var a=s,{node:e,resultTitle:t,insert:o}=a,n=H(a,["node","resultTitle","insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({},n),{onClick:()=>{var l;o({type:"void",name:e.id,title:e.title,"x-component":"CardItem","x-component-props":{title:(l=e.title)!=null?l:`#${e.id}`},"x-designer":"SimpleDesigner",properties:{result:{type:"void",title:t,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}}}})}}))}function dy({dataSource:e}){var s;const t=E.useFieldSchema(),{execution:o}=z();if(!o)return t.title;const n=L.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeId]:l.result}),{})});return r.jsx("pre",{className:i.css`
|
|
409
442
|
margin: 0;
|
|
410
|
-
`,children:JSON.stringify(n,null,2)})}
|
|
443
|
+
`,children:JSON.stringify(n,null,2)})}Ke.Initializer=uy,Ke.Result=dy;function py(e){return["hasMany","belongsToMany"].includes(e.type)}function my(){const e=i.useCompile();return[po,mo].map(t=>{var n;const o=(n=t.useOptions({types:[py],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 fy(n){var s=n,{value:e,onChange:t}=s,o=H(s,["value","onChange"]);const{setValuesIn:a}=E.useForm(),{getCollection:l}=i.useCollectionManager(),c=my(),[u,p]=g.useState(c),{associatedKey:m="",name:y}=e!=null?e:{};let b=[];const f=m.match(/^{{(.*)}}$/);f&&(b=[...f[1].trim().split(".").slice(0,-1),y]);const h=w=>q(this,null,function*(){var S;const k=w[w.length-1];!((S=k.children)!=null&&S.length)&&!k.isLeaf&&k.loadChildren&&(yield k.loadChildren(k),p(T=>[...T]))});g.useEffect(()=>{(()=>q(this,null,function*(){var S;if(!b||u.length<=1)return;let k=null;for(let T=0;T<b.length;T++){const M=b[T];try{T===0?k=u.find(I=>I.value===M):(k.loadChildren&&!((S=k.children)!=null&&S.length)&&(yield k.loadChildren(k)),k=k.children.find(I=>I.value===M))}catch(I){console.error(I)}}p([...u])}))()},[e,u.length]);const $=g.useCallback((w,k)=>{if(!(w!=null&&w.length)){a("collection",null),t({});return}const{field:S}=k.pop();if(!S||!["hasMany","belongsToMany"].includes(S.type))return;const{collectionName:T,target:M,name:I}=S,D=l(T).fields.find(N=>N.primaryKey);a("collection",M),t({name:I,associatedKey:`{{${w.slice(0,-1).join(".")}.${D.name}}}`,associatedCollection:T})},[t]);return r.jsx(x.Cascader,C(v({},o),{value:b,options:u,onChange:$,loadData:h}))}const hy={title:`{{t("Aggregate", { ns: "${d}" })}}`,type:"aggregate",group:"collection",description:`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${d}" })}}`,fieldset:{aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${d}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${d}" })}}`,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:C(v({},de),{title:`{{t("Data of collection", { ns: "${d}" })}}`,"x-component-props":C(v({},de["x-component-props"]),{className:null}),"x-reactions":[...de["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: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(e){return!e.hidden&&e.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:C(v({},_e),{"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]})}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{SchemaComponentContext:i.SchemaComponentContext,FilterDynamicComponent:st,FieldsSelect:zt,ValueBlock:Ke,AssociatedConfig:fy},useVariables({key:e,title:t},{types:o,fieldNames:n=Ne}){return o&&!o.some(s=>s in rt||Object.values(rt).some(a=>a.has(s)))?null:{[n.value]:e,[n.label]:t}},useInitializers(e){var t;return e.config.collection?{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:Ke.Initializer,node:e,resultTitle:O("Query result")}:null}};function At(e){const s=e,{options:t=[]}=s,o=H(s,["options"]),n=i.useCompile();return r.jsx(x.Radio.Group,C(v({},o),{children:t.map(a=>r.jsxs(x.Radio,{value:a.value,children:[r.jsx("span",{className:i.css`
|
|
411
444
|
& + .anticon {
|
|
412
445
|
margin-left: 0.25em;
|
|
413
446
|
}
|
|
414
|
-
`,children:n(a.label)}),a.tooltip&&r.jsx(x.Tooltip,{title:n(a.tooltip),children:r.jsx(
|
|
447
|
+
`,children:n(a.label)}),a.tooltip&&r.jsx(x.Tooltip,{title:n(a.tooltip),children:r.jsx(F.QuestionCircleOutlined,{style:{color:"#666"}})})]},a.value))}))}const ar=e=>{const t=Ye.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:i.css`
|
|
415
448
|
&:after {
|
|
416
449
|
content: ':';
|
|
417
450
|
}
|
|
418
451
|
& + a {
|
|
419
452
|
margin-left: 0.25em;
|
|
420
453
|
}
|
|
421
|
-
`,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};function
|
|
422
|
-
margin: 0;
|
|
423
|
-
`,children:JSON.stringify(o,null,2)})},RadioWithTooltip:$t,DynamicConfig:my},useVariables({id:e,title:t},{types:o,fieldNames:n=i.defaultFieldNames}){return o&&!o.some(s=>s in tt||Object.values(tt).some(a=>a.has(s)))?null:{[n.value]:`${e}`,[n.label]:t}},useInitializers(e){var t;return{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:nt.Initializer,node:e,resultTitle:T("Calculation result")}}},R=new L.Registry;R.register("equal",{name:"=",type:"boolean",group:"boolean"}),R.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),R.register("gt",{name:">",type:"boolean",group:"boolean"}),R.register("gte",{name:"≥",type:"boolean",group:"boolean"}),R.register("lt",{name:"<",type:"boolean",group:"boolean"}),R.register("lte",{name:"≤",type:"boolean",group:"boolean"}),R.register("add",{name:"+",type:"number",group:"number"}),R.register("minus",{name:"-",type:"number",group:"number"}),R.register("multiple",{name:"*",type:"number",group:"number"}),R.register("divide",{name:"/",type:"number",group:"number"}),R.register("mod",{name:"%",type:"number",group:"number"}),R.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),R.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),R.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),R.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),R.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),R.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),R.register("concat",{name:`{{t("concat", { ns: "${d}" })}}`,type:"string",group:"string"});const hy=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${d}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${d}" })}}`},{value:"date",title:`{{t("Date", { ns: "${d}" })}}`}];function nr(e){return Array.from(R.getEntities()).filter(([t,o])=>o.group===e)}function yy({calculator:e,operands:t=[],onChange:o}){const n=i.useCompile(),s=ae();return r.jsxs("fieldset",{className:i.css`
|
|
454
|
+
`,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};function yy(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}const gy=({value:e,onChange:t})=>{const{t:o}=ee.useTranslation(),{getCollectionFields:n,getCollection:s}=i.useCollectionManager(),a=se({types:[yy.bind({getCollectionFields:n,getCollection:s})]});return r.jsxs(Se.FormLayout,{layout:"vertical",children:[r.jsx(Se.FormItem,{colon:!0,label:o("Expression type",{ns:d}),children:r.jsxs(x.Radio.Group,{value:e===!1?!1:e||"",onChange:l=>{t(l.target.value)},children:[r.jsx(x.Radio,{value:!1,children:o("Static",{ns:d})}),r.jsx(x.Radio,{value:e||"",children:o("Dynamic",{ns:d})})]})}),e!==!1?r.jsx(Se.FormItem,{label:o("Select dynamic expression",{ns:d}),extra:o("Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.",{ns:d}),children:r.jsx(i.Variable.Input,{value:e||"",onChange:l=>t(l),scope:a})}):null]})},vy={title:`{{t("Calculation", { ns: "${d}" })}}`,type:"calculation",group:"control",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 can be static or dynamic one from an expression collections.", { ns: "${d}" })}}`,fieldset:{dynamic:{type:"string","x-component":"DynamicConfig",default:!1},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Ye.getOptions()},required:!0,default:"math.js","x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}}},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"CalculationExpression","x-validator"(e,t,{form:o}){const{values:n}=o,{evaluate:s}=Ye.evaluators.get(n.engine),a=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(a),""}catch(l){return O("Expression syntax error")}},"x-reactions":[{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}},{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"ScopeSelect","x-component-props":{changeOnSelect:!0},"x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}},view:{},scope:{renderEngineReference:ar},components:{CalculationExpression(e){const t=se();return r.jsx(i.Variable.TextArea,v({scope:t,changeOnSelect:!0},e))},ScopeSelect(e){const t=se({types:[{type:"reference",options:{collection:"*",entity:!0}}]});return r.jsx(i.Variable.Input,v({scope:t},e))},RadioWithTooltip:At,DynamicConfig:gy,ValueBlock:Ke},useVariables({key:e,title:t},{types:o,fieldNames:n=i.defaultFieldNames}){return o&&!o.some(s=>s in rt||Object.values(rt).some(a=>a.has(s)))?null:{[n.value]:e,[n.label]:t}},useInitializers(e){var t;return{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:Ke.Initializer,node:e,resultTitle:O("Calculation result")}}},te=new L.Registry;te.register("equal",{name:"=",type:"boolean",group:"boolean"}),te.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),te.register("gt",{name:">",type:"boolean",group:"boolean"}),te.register("gte",{name:"≥",type:"boolean",group:"boolean"}),te.register("lt",{name:"<",type:"boolean",group:"boolean"}),te.register("lte",{name:"≤",type:"boolean",group:"boolean"}),te.register("add",{name:"+",type:"number",group:"number"}),te.register("minus",{name:"-",type:"number",group:"number"}),te.register("multiple",{name:"*",type:"number",group:"number"}),te.register("divide",{name:"/",type:"number",group:"number"}),te.register("mod",{name:"%",type:"number",group:"number"}),te.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),te.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),te.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),te.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),te.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),te.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),te.register("concat",{name:`{{t("concat", { ns: "${d}" })}}`,type:"string",group:"string"});const by=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${d}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${d}" })}}`},{value:"date",title:`{{t("Date", { ns: "${d}" })}}`}];function ir(e){return Array.from(te.getEntities()).filter(([t,o])=>o.group===e)}function xy({calculator:e,operands:t=[],onChange:o}){const n=i.useCompile(),s=se();return r.jsxs("fieldset",{className:i.css`
|
|
424
455
|
display: flex;
|
|
425
456
|
gap: 0.5em;
|
|
426
457
|
align-items: center;
|
|
427
458
|
flex-wrap: wrap;
|
|
428
|
-
`,children:[r.jsx(i.Variable.Input,{value:t[0],onChange:a=>o({calculator:e,operands:[a,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(x.Select,{value:e,onChange:a=>o({operands:t,calculator:a}),placeholder:
|
|
459
|
+
`,children:[r.jsx(i.Variable.Input,{value:t[0],onChange:a=>o({calculator:e,operands:[a,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(x.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:a=>o({operands:t,calculator:a}),placeholder:O("Calculator"),popupMatchSelectWidth:!1,children:by.filter(a=>!!ir(a.value).length).map(a=>r.jsx(x.Select.OptGroup,{label:n(a.title),children:ir(a.value).map(([l,{name:c}])=>r.jsx(x.Select.Option,{value:l,children:n(c)},l))},a.value))}),r.jsx(i.Variable.Input,{value:t[1],onChange:a=>o({calculator:e,operands:[t[0],a]}),scope:s,useTypedConstant:!0})]})}function Cy({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:i.css`
|
|
429
460
|
display: flex;
|
|
430
461
|
position: relative;
|
|
431
462
|
margin: 0.5em 0;
|
|
432
|
-
`,children:[e.group?r.jsx(
|
|
463
|
+
`,children:[e.group?r.jsx(lr,{value:e.group,onChange:a=>t(C(v({},e),{group:a}))}):r.jsx(xy,{operands:s,calculator:n,onChange:t}),r.jsx(x.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(F.CloseCircleOutlined,{})})]})}function lr({value:e,onChange:t}){const{t:o}=ee.useTranslation(),{type:n="and",calculations:s=[]}=e;function a(){t(C(v({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function l(){t(C(v({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(p){s.splice(p,1),t(C(v({},e),{calculations:[...s]}))}function u(p,m){s.splice(p,1,m),t(C(v({},e),{calculations:[...s]}))}return r.jsxs("div",{className:i.cx("node-type-condition-group",i.css`
|
|
433
464
|
position: relative;
|
|
434
465
|
width: 100%;
|
|
435
466
|
.node-type-condition-group {
|
|
@@ -448,20 +479,14 @@
|
|
|
448
479
|
width: auto;
|
|
449
480
|
min-width: 6em;
|
|
450
481
|
}
|
|
451
|
-
`,children:r.jsxs(
|
|
482
|
+
`,children:r.jsxs(ee.Trans,{children:["Meet ",r.jsxs(x.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:p=>t(C(v({},e),{type:p})),children:[r.jsx(x.Select.Option,{value:"and",children:"All"}),r.jsx(x.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:s.map((p,m)=>r.jsx(Cy,{value:p,onChange:u.bind(this,m),onRemove:()=>c(m)},`${p.calculator}_${m}`))}),r.jsxs("div",{className:i.css`
|
|
452
483
|
button {
|
|
453
484
|
padding: 0;
|
|
454
485
|
&:not(:last-child) {
|
|
455
486
|
margin-right: 1em;
|
|
456
487
|
}
|
|
457
488
|
}
|
|
458
|
-
`,children:[r.jsx(x.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(x.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function
|
|
459
|
-
> * > .workflow-branch-lines {
|
|
460
|
-
> button {
|
|
461
|
-
display: none;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
`),children:[r.jsx(Ee,{from:t,entry:u,branchIndex:0}),r.jsx(Ee,{from:t,entry:c,branchIndex:1})]}),r.jsxs("div",{className:s.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:o("No")}),r.jsx("span",{style:{left:"4em"},children:o("Yes")})]})]})})},scope:{renderEngineReference:or,useWorkflowVariableOptions:ae},components:{CalculationConfig:vy,CalculationExpression(e){const t=ae();return r.jsx(i.Variable.TextArea,v({scope:t},e))},RadioWithTooltip:$t}};function xy(e){const{getCollectionFields:t}=i.useCollectionManager(),{path:o}=I.useField(),n=o.segments[o.segments.length-1],{values:s}=I.useForm(),a=t(s==null?void 0:s.collection),{type:l}=a.find(p=>p.name===n),c=Array.isArray(e.value)?e.value.join(","):e.value;function u(p){const m=p.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(l)?m:m.split(/[,\s]+/))}return r.jsx(x.Input,C(v({},e),{value:c,onChange:u}))}const sr=I.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=i.useToken(),{t:a}=te.useTranslation(),l=i.useCompile(),c=I.useForm(),{getCollection:u,getCollectionFields:p}=i.useCollectionManager(),m=ae(),{values:h}=c,g=h==null?void 0:h.collection,f=p(g).filter(S=>S.uiSchema),y=n?f.filter(n.bind(h)):f,w=b.useMemo(()=>y.filter(S=>!e||!(S.name in e)),[y,e]),$=t||c.disabled,k=b.useMemo(()=>({onClick:({key:S})=>{o(C(v({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:w.map(S=>{var A,M;return{key:S.name,label:l((M=(A=S.uiSchema)==null?void 0:A.title)!=null?M:S.name)}})}),[o,w,e]);return r.jsx("fieldset",{className:i.css`
|
|
489
|
+
`,children:[r.jsx(x.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(x.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function wy({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(lr,{value:o.group,onChange:n=>t(C(v({},o),{group:n}))})}const $y={title:`{{t("Condition", { ns: "${d}" })}}`,type:"condition",group:"control",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: "${d}" })}}`,fieldset:{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${d}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${d}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${d}" })}}`}],...Array.from(Ye.evaluators.getEntities())].reduce((e,[t,o])=>e.concat(v({value:t},o)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"CalculationExpression","x-validator"(e,t,{form:o}){const{values:n}=o,{evaluate:s}=Ye.evaluators.get(n.engine),a=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(a),""}catch(l){return O("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}},view:{},options:[{label:`{{t('Continue when "Yes"', { ns: "${d}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${d}" })}}`,key:"branch",value:{rejectOnFalse:!1}}],component:function({data:t}){const{t:o}=ee.useTranslation(),{nodes:n}=z(),{styles:s}=ne(),{id:a,config:{rejectOnFalse:l}}=t,c=n.find(p=>p.upstreamId===a&&p.branchIndex===1),u=n.find(p=>p.upstreamId===a&&p.branchIndex===0);return r.jsx(it,{data:t,children:l?null:r.jsxs("div",{className:s.nodeSubtreeClass,children:[r.jsxs("div",{className:s.branchBlockClass,children:[r.jsx(Pe,{from:t,entry:u,branchIndex:0}),r.jsx(Pe,{from:t,entry:c,branchIndex:1})]}),r.jsxs("div",{className:s.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:o("No")}),r.jsx("span",{style:{left:"4em"},children:o("Yes")})]})]})})},scope:{renderEngineReference:ar,useWorkflowVariableOptions:se},components:{CalculationConfig:wy,CalculationExpression(e){const t=se();return r.jsx(i.Variable.TextArea,v({scope:t},e))},RadioWithTooltip:At}};function Sy(e){const{getCollectionFields:t}=i.useCollectionManager(),{path:o}=E.useField(),n=o.segments[o.segments.length-1],{values:s}=E.useForm(),a=t(s==null?void 0:s.collection),{type:l}=a.find(p=>p.name===n),c=Array.isArray(e.value)?e.value.join(","):e.value;function u(p){const m=p.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(l)?m:m.split(/[,\s]+/))}return r.jsx(x.Input,C(v({},e),{value:c,onChange:u}))}const cr=E.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=i.useToken(),{t:a}=ee.useTranslation(),l=i.useCompile(),c=E.useForm(),{getCollection:u,getCollectionFields:p}=i.useCollectionManager(),m=se(),{values:y}=c,b=y==null?void 0:y.collection,f=p(b).filter(S=>S.uiSchema),h=n?f.filter(n.bind(y)):f,$=g.useMemo(()=>h.filter(S=>!e||!(S.name in e)),[h,e]),w=t||c.disabled,k=g.useMemo(()=>({onClick:({key:S})=>{o(C(v({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:$.map(S=>{var T,M;return{key:S.name,label:l((M=(T=S.uiSchema)==null?void 0:T.title)!=null?M:S.name)}})}),[o,$,e]);return r.jsx("fieldset",{className:i.css`
|
|
465
490
|
margin-top: 0.5em;
|
|
466
491
|
|
|
467
492
|
> .ant-formily-item {
|
|
@@ -471,14 +496,14 @@
|
|
|
471
496
|
line-height: 32px;
|
|
472
497
|
}
|
|
473
498
|
}
|
|
474
|
-
`,children:
|
|
499
|
+
`,children:h.length?r.jsxs(i.CollectionProvider,{collection:u(b),children:[h.filter(S=>e&&S.name in e).map(S=>{var M,I;const T=["belongsTo","hasOne","hasMany","belongsToMany"].includes(S.type)?Sy:i.CollectionField;return r.jsxs(x.Form.Item,{label:l((I=(M=S.uiSchema)==null?void 0:M.title)!=null?I:S.name),labelAlign:"left",className:i.css`
|
|
475
500
|
.ant-form-item-control-input-content {
|
|
476
501
|
display: flex;
|
|
477
502
|
}
|
|
478
|
-
`,children:[r.jsx(i.Variable.Input,{scope:m,value:e[S.name],changeOnSelect:!0,onChange:_=>{o(C(v({},e),{[S.name]:_}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":
|
|
503
|
+
`,children:[r.jsx(i.Variable.Input,{scope:m,value:e[S.name],changeOnSelect:!0,onChange:_=>{o(C(v({},e),{[S.name]:_}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":T,"x-validator"(){return""}}}}})}),w?null:r.jsx(x.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(F.CloseCircleOutlined,{}),onClick:()=>{var N;const U=e,{[N=S.name]:_}=U,D=H(U,[Yr(N)]);o(D)}})]},S.name)}),$.length?r.jsx(x.Dropdown,{menu:k,children:r.jsx(x.Button,{icon:r.jsx(F.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:O("Please select collection first")})})},{displayName:"CollectionFieldSet"}),ky={title:`{{t("Create record", { ns: "${d}" })}}`,type:"create",group:"collection",description:`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${d}" })}}`,fieldset:{collection:de,params:{type:"object",properties:{values:Do,appends:je}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{CollectionFieldset:cr},useVariables({key:e,title:t,config:o},n){var c,u;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager(),[l]=be(C(v({appends:[e,...((u=(c=o.params)==null?void 0:c.appends)==null?void 0:u.map(p=>`${e}.${p}`))||[]]},n),{fields:[{collectionName:o.collection,name:e,type:"hasOne",target:o.collection,uiSchema:{title:t}}],compile:s,getCollectionFields:a}));return l},useInitializers(e){var t;return e.config.collection?{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:Me,collection:e.config.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}:null},initializers:{}},ur=[{value:1e3,label:"Seconds"},{value:6e4,label:"Minutes"},{value:36e5,label:"Hours"},{value:864e5,label:"Days"},{value:6048e5,label:"Weeks"}];function Ay(e){return ur.slice().reverse().find(t=>!(e%t.value))}function Ty({value:e=6e4,onChange:t}){const o=Ay(e),n=Math.round(e/o.value);return r.jsxs("fieldset",{className:i.css`
|
|
479
504
|
display: flex;
|
|
480
505
|
gap: 0.5em;
|
|
481
|
-
`,children:[r.jsx(x.InputNumber,{min:1,value:n,onChange:s=>t(Math.round(s*o.value)),className:"auto-width"}),r.jsx(x.Select,{popupMatchSelectWidth:!1,value:o.value,onChange:s=>t(Math.round(n*s)),className:"auto-width",children:
|
|
506
|
+
`,children:[r.jsx(x.InputNumber,{min:1,value:n,onChange:s=>t(Math.round(s*o.value)),className:"auto-width"}),r.jsx(x.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:o.value,onChange:s=>t(Math.round(n*s)),className:"auto-width",children:ur.map(s=>r.jsx(x.Select.Option,{value:s.value,children:O(s.label)},s.value))})]})}const Oy={title:`{{t("Delay", { ns: "${d}" })}}`,type:"delay",group:"control",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: "${d}" })}}`,fieldset:{duration:{type:"number",title:`{{t("Duration", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End Status", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${d}" })}}`,value:X.RESOLVED},{label:`{{t("Fail and exit", { ns: "${d}" })}}`,value:X.FAILED}],required:!0,default:X.RESOLVED}},view:{},scope:{},components:{Duration:Ty}};function vo(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 bo(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return bo(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[s]=Object.keys(o[n]);return!(!s||typeof o[n][s]=="undefined")}):!1}const Fy={title:'{{t("Delete record")}}',type:"destroy",group:"collection",description:`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${d}" })}}`,fieldset:{collection:de,params:{type:"object",properties:{filter:C(v({},_e),{"x-validator"(e){return bo(e)?"":`{{t("Please add at least one condition", { ns: "${d}" })}}`}})}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FilterDynamicComponent:st}};function Iy(e,t){let o=e,n=null;for(let s=0;s<t.length;s++){const a=t[s],l=o.find(c=>c.value===a);if(!l)return null;n=l,!l.isLeaf&&l.loadChildren&&l.loadChildren(l),l.children&&(o=l.children)}return n}const Dy={title:`{{t("Loop", { ns: "${d}" })}}`,type:"loop",group:"control",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: "${d}" })}}`,fieldset:{target:{type:"string",title:`{{t("Loop target", { ns: "${d}" })}}`,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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",changeOnSelect:!0,useTypedConstant:["string","number","null"],className:i.css`
|
|
482
507
|
width: 100%;
|
|
483
508
|
|
|
484
509
|
.variable {
|
|
@@ -488,18 +513,15 @@
|
|
|
488
513
|
.ant-input.null-value {
|
|
489
514
|
width: 100%;
|
|
490
515
|
}
|
|
491
|
-
`},required:!0}},view:{},component:function({data:t}){var a;const{nodes:o}=z(),{styles:n}=
|
|
516
|
+
`},required:!0}},view:{},component:function({data:t}){var a;const{nodes:o}=z(),{styles:n}=ne(),s=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:i.cx(n.branchBlockClass,i.css`
|
|
492
517
|
padding-left: 20em;
|
|
493
|
-
`),children:[r.jsx(Ee,{from:t,entry:s,branchIndex:(a=s==null?void 0:s.branchIndex)!=null?a:0}),r.jsxs("div",{className:n.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:i.cx(n.addButtonClass,n.loopLineClass),children:r.jsx(P.ArrowUpOutlined,{})})]})]}),r.jsx("div",{className:i.css`
|
|
494
|
-
position: relative;
|
|
495
|
-
height: 2em;
|
|
496
|
-
`})]})})},scope:{useWorkflowVariableOptions:ae},components:{},useScopeVariables(e,t){const o=i.useCompile(),{target:n}=e.config;if(!n)return null;const{fieldNames:s=Pe}=t;let a={key:"item",[s.value]:"item",[s.label]:T("Loop target")};if(typeof n=="string"&&n.startsWith("{{")&&n.endsWith("}}")){const l=n.slice(2,-2).split(".").map(p=>p.trim()),c=[io,lo].map(p=>{const m=p.useOptions(t).filter(Boolean);return{[s.label]:o(p.label),[s.value]:p.value,key:p.value,[s.children]:m,disabled:m&&!m.length}}),u=Ay(c,l);a=Object.assign({},u,a)}return[a,{key:"index",[s.value]:"index",[s.label]:T("Loop index")},{key:"length",[s.value]:"length",[s.label]:T("Loop length")}]}};function Oy(e){const{execution:t}=z(),o=b.useMemo(()=>{var s;return{$context:t==null?void 0:t.context,$jobsMapByNodeId:((s=t==null?void 0:t.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeId]:l.result}),{})}},[t]);return b.useMemo(()=>L.parse(e)(o),[t])}function ir(e){const t=I.useField(),o=b.useRef(null),{appends:n,updateAssociationValues:s}=i.useAssociationNames(),a=Oy(e.dataSource),l=b.useMemo(()=>me.createForm({values:a,readPretty:!0}),[a]),c={appends:n},u={loading:!1,data:{data:a}},m=i.useAPIClient().resource(e.collection),h=b.useContext(i.BlockRequestContext);return r.jsx(i.CollectionProvider,{collection:e.collection,children:r.jsx(i.RecordProvider,{record:a,parent:!1,children:r.jsx(i.BlockRequestContext.Provider,{value:{block:"form",field:t,service:u,resource:m,__parent:h},children:r.jsx(i.FormBlockContext.Provider,{value:{params:c,form:l,field:t,service:u,updateAssociationValues:s,formBlockRef:o},children:e.children})})})})}function lr(e){var k,S,A;const t=i.useRecord(),o=I.useFieldSchema(),n=I.useField(),s=b.useRef(null),{appends:a,updateAssociationValues:l}=i.useAssociationNames(),[c]=Object.keys((k=o.toJSON().properties)!=null?k:{}),u=(S=t==null?void 0:t.result)==null?void 0:S[c],{findComponent:p}=i.useDesignable(),m=p((A=n.component)==null?void 0:A[0])||b.Fragment,h=b.useMemo(()=>me.createForm({initialValues:u}),[u]),g=v({appends:a},e.params),f={loading:!1,data:{data:u}},w=i.useAPIClient().resource(e.collection),$=b.useContext(i.BlockRequestContext);return!t.status||u?r.jsx(i.CollectionProvider,{collection:e.collection,children:r.jsx(i.RecordProvider,{record:u,parent:!1,children:r.jsx(i.BlockRequestContext.Provider,{value:{block:"form",props:e,field:n,service:f,resource:w,__parent:$},children:r.jsx(i.FormBlockContext.Provider,{value:{params:g,form:h,field:n,service:f,updateAssociationValues:l,formBlockRef:s},children:r.jsxs(m,C(v({},n.componentProps),{children:[r.jsx(i.FormV2.Templates,{style:{marginBottom:18},form:h}),r.jsx("div",{ref:s,children:r.jsx(I.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})}):null}function Fy(n){var s=n,{insert:e,schema:t}=s,o=q(s,["insert","schema"]);const{getTemplateSchemaByMode:a}=i.useSchemaTemplateManager(),l=i.useRecordCollectionDataSourceItems("FormItem");function c(p){return K(this,arguments,function*({item:u}){const m=u.template?yield a(u):null,h=i.createFormBlockSchema(C(v({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:oe.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},t),{template:m}));delete h["x-acl-action-props"],delete h["x-acl-action"];const[g]=Object.keys(h.properties);h.properties[g].properties.actions["x-decorator"]="ActionBarProvider",h.properties[g].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},Lt(h,f=>{f["x-uid"]&&delete f["x-uid"]}),e(h)})}return r.jsx(i.SchemaInitializer.Item,C(v({},o),{onClick:c,items:l}))}function cr(e){var t;return r.jsx(i.CollectionProvider,{collection:(t=e.schema)==null?void 0:t.collection,children:r.jsx(Fy,v({},e))})}function Iy(){const{name:e,title:t}=i.useCollection();return r.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(i.SchemaSettings.DataTemplates,{collectionName:e}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Dy={title:`{{t("Create record form", { ns: "${d}" })}}`,config:{useInitializer(){const{collections:e}=i.useCollectionManager();return{key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${d}" })}}`,children:e.filter(t=>!t.hidden).map(t=>({key:`createForm-${t.name}`,type:"item",title:t.title,schema:{collection:t.name,title:`{{t("Create record", { ns: "${d}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},component:cr}))}},initializers:{},components:{CreateFormDesigner:Iy},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var l;const[s]=Object.keys(n.properties),a=n.properties[s];t[s]={type:"create",title:((l=n["x-component-props"])==null?void 0:l.title)||s,actions:ke(a.properties.actions,c=>c["x-component"]==="Action").map(c=>{var u,p;return{status:c["x-decorator-props"].value,values:(p=(u=c["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:p.values,key:c.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function ur(e){var p,m,h,g;const[t,o]=b.useState((m=(p=e.collection)==null?void 0:p.fields)!=null?m:[]),n=i.useRecord(),s=I.useField(),a=I.useFieldSchema(),[l]=Object.keys((h=a.toJSON().properties)!=null?h:{}),c=(g=n==null?void 0:n.result)==null?void 0:g[l],u=b.useMemo(()=>me.createForm({initialValues:c}),[c]);return!n.status||c?r.jsx(i.CollectionProvider,{collection:C(v({},e.collection),{fields:t}),children:r.jsx(i.RecordProvider,{record:c,parent:!1,children:r.jsx(i.FormBlockContext.Provider,{value:{form:u,field:s,setCollectionFields:o},children:e.children})})}):null}function Ny(o){var n=o,{insert:e}=n,t=q(n,["insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:L.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[L.uid()]:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddCustomFormField"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"AddActionButton",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:oe.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const dr={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 Py(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:s="others"}=n;t[s]=t[s]||{},xo.set(t,[s,o],n)}),Object.keys(dr).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:dr[o],children:Object.keys(t[o]||{}).map(n=>{const s=t[o][n];return v({value:n,title:s.title,name:n},t[o][n])}).sort((n,s)=>n.order-s.order)}))}function Ey(){const{interfaces:e}=i.useCollectionManager();return Py(e).map(o=>({key:o.title,type:"itemGroup",title:o.title,children:o.children.map(n=>({key:n.name,type:"item",title:n.title,component:_y,fieldInterface:n.name}))}))}const pr=b.createContext({});function My(e){const{insertPosition:t="beforeEnd",component:o}=e,n=Ey(),s=b.useContext(i.CollectionContext),[a,l]=b.useState(null),[c,u]=b.useState(),{setCollectionFields:p}=b.useContext(i.FormBlockContext);return r.jsxs(pr.Provider,{value:{onAddField(m){const w=xo.cloneDeep(m),{properties:$}=w,k=$,{unique:h,type:g}=k,f=q(k,["unique","type"]),y=q(w,["properties"]);delete f.name["x-disabled"],l(C(v({},y),{properties:f}))},setCallback:u},children:[r.jsx(i.SchemaInitializer.Button,{wrap:i.gridRowColWrap,insertPosition:t,items:n,component:o,title:"{{t('Configure fields')}}"}),r.jsx(i.ActionContextProvider,{value:{visible:!!a},children:a?r.jsx(i.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"Form","x-component":"Action.Drawer",properties:C(v({},a.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const m=I.useForm();return{run(){return K(this,null,function*(){u(null),l(null),m.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:m,query:h}=I.useForm();return{run(){return K(this,null,function*(){var k,S,A,M;const{default:f}=a,y=L.uid();if(f.name=(k=m.name)!=null?k:y,f.uiSchema.title=(A=(S=m.uiSchema)==null?void 0:S.title)!=null?A:y,f.interface=a.name,(M=s.fields)==null?void 0:M.find(D=>D.name===f.name)){h("name").take().setFeedback({type:"error",messages:[T("Field name existed in form")]});return}const $=L.merge(f,m);p([...s.fields,$]),c({name:f.name,type:f.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:$},"x-collection-field":`${s.name}.${f.name}`,"x-designer":"FormItem.Designer"}),u(null),l(null)})}}}}}}}})},components:{ArrayTable:Se.ArrayTable}}):null})]})}function _y(e){const{item:t,insert:o}=e,{onAddField:n,setCallback:s}=b.useContext(pr),{getInterface:a}=i.useCollectionManager(),l=a(t.fieldInterface);return r.jsx(i.SchemaInitializer.Item,{onClick:()=>{s(()=>o),n(l)}},t.fieldInterface)}const mr={title:`{{t("Custom form", { ns: "${d}" })}}`,config:{useInitializer(){return{key:"customForm",type:"item",title:`{{t("Custom form", { ns: "${d}" })}}`,component:Ny}},initializers:{AddCustomFormField:My},components:{CustomFormBlockProvider:ur},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var c;const[s]=Object.keys(n.properties),a=n.properties[s],l=ke(a.properties.grid,u=>u["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(u=>{var p,m;return(m=(p=u["x-component-props"])==null?void 0:p.field)!=null?m:u["x-interface-options"]}),t[s]={type:"custom",title:((c=n["x-component-props"])==null?void 0:c.title)||s,actions:ke(a.properties.actions,u=>u["x-component"]==="Action").map(u=>{var p,m;return{status:u["x-decorator-props"].value,values:(m=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:m.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:ur}}};function jy(){const{name:e,title:t}=i.useCollection(),o=I.useFieldSchema(),{t:n}=te.useTranslation(),{dn:s}=i.useDesignable();return r.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.ActionModalItem,{title:n("Filter settings",{ns:d}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-component-props":{useProps(){var l;return{options:i.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:a})=>{o["x-decorator-props"].filter=a,s.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),s.refresh()}}),r.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const By={title:`{{t("Update record form", { ns: "${d}" })}}`,config:{useInitializer(){const{collections:e}=i.useCollectionManager();return{key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${d}" })}}`,children:e.filter(t=>!t.hidden).map(t=>({key:`updateForm-${t.name}`,type:"item",title:t.title,schema:{collection:t.name,title:`{{t("Update record", { ns: "${d}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},component:cr}))}},initializers:{},components:{FilterDynamicComponent:ot,UpdateFormDesigner:jy},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var l;const[s]=Object.keys(n.properties),a=n.properties[s];t[s]=C(v({},n["x-decorator-props"]),{type:"update",title:((l=n["x-component-props"])==null?void 0:l.title)||s,actions:ke(a.properties.actions,c=>c["x-component"]==="Action").map(c=>{var u,p;return{status:c["x-decorator-props"].value,values:(p=(u=c["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:p.values,key:c.name}})})}),t}},block:{scope:{},components:{}}},Ce=new L.Registry;Ce.register("customForm",mr),Ce.register("createForm",Dy),Ce.register("updateForm",By);function Vy(){const{workflow:e}=z(),t=Qn();return t.useInitializers?t.useInitializers(e.config):null}const Ly={customForm:mr.title,record:`{{t("Data record", { ns: "${d}" })}}`};function zy(){var n,s;const e=I.useFieldSchema(),t=(s=Ly[(n=e["x-designer-props"])==null?void 0:n.type])!=null?s:'{{t("Block")}}',o=i.useCompile();return r.jsxs(i.GeneralSchemaDesigner,{title:o(t),children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}function Uy(e){const t=we(),o=st(t),n=[Vy()].filter(Boolean),s=o.map(c=>{var p;const u=H.get(c.type);return(p=u==null?void 0:u.useInitializers)==null?void 0:p.call(u,c)}).filter(Boolean),a=[...n,...s.length?[{key:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${d}" })}}`,children:s}]:[]].filter(Boolean),l=[...a.length?[{type:"itemGroup",title:'{{t("Data blocks")}}',children:a}]:[],{type:"itemGroup",title:'{{t("Form")}}',children:Array.from(Ce.getValues()).map(c=>{const{useInitializer:u}=c.config;return u()})},{type:"itemGroup",title:'{{t("Other blocks")}}',children:[{type:"item",title:'{{t("Markdown")}}',component:"MarkdownBlockInitializer"}]}];return r.jsx(i.SchemaInitializer.Button,C(v({},e),{wrap:i.gridRowColWrap,items:l,title:"{{t('Add block')}}"}))}function Gy(){var w,$,k;const e=b.useContext(i.SchemaComponentContext),{t}=te.useTranslation(),o=I.useFieldSchema(),n=ae({fieldNames:{label:"title",value:"name"}}),[s,a]=b.useState(!1),[l,c]=b.useState((k=($=(w=o==null?void 0:o["x-action-settings"])==null?void 0:w.assignedValues)==null?void 0:$.schema)!=null?k:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[u,p]=b.useState(null),{components:m}=i.useSchemaOptionsContext();b.useEffect(()=>{p(new I.Schema({properties:{grid:l}}))},[l]);const h=b.useMemo(()=>{var A,M;const S=(M=(A=o==null?void 0:o["x-action-settings"])==null?void 0:A.assignedValues)==null?void 0:M.values;return me.createForm({initialValues:L.lodash.cloneDeep(S),values:L.lodash.cloneDeep(S)})},[]),g=t("Assign field values");function f(){a(!1)}function y(){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=h.values,a(!1),setTimeout(()=>{var S;(S=e.refresh)==null||S.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(i.SchemaSettings.Item,{onClick:()=>a(!0),children:g}),r.jsx(x.Modal,{width:"50%",title:g,open:s,onCancel:f,footer:r.jsxs(x.Space,{children:[r.jsx(x.Button,{onClick:f,children:t("Cancel")}),r.jsx(x.Button,{type:"primary",onClick:y,children:t("Submit")})]}),children:r.jsx(i.VariableScopeProvider,{scope:n,children:r.jsx(I.FormProvider,{form:h,children:r.jsxs(Se.FormLayout,{layout:"vertical",children:[r.jsx(x.Alert,{message:T("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),s&&u&&r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{refresh(){c(L.lodash.get(u.toJSON(),"properties.grid"))}}),children:r.jsx(i.SchemaComponent,{schema:u,components:m})})]})})})})]})}function Wy(e){return r.jsxs(i.GeneralSchemaDesigner,C(v({},e),{disableInitializer:!0,children:[r.jsx(i.Action.Designer.ButtonEditor,{}),r.jsx(Gy,{}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Hy(s){var a=s,{action:e,actionProps:t,insert:o}=a,n=q(a,["action","actionProps","insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({},n),{onClick:()=>{o({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(v({},t),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function fr(n){var s=n,{action:e,actionProps:t}=s,o=q(s,["action","actionProps"]);return r.jsx(i.InitializerWithSwitch,C(v({},o),{schema:{type:"void",title:o.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(v({},t),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${e}`},type:"x-action"}))}function qy(e){return r.jsx(i.SchemaInitializer.Button,C(v({},e),{items:[{key:oe.RESOLVED,type:"item",title:`{{t("Continue the process", { ns: "${d}" })}}`,component:Hy,action:oe.RESOLVED,actionProps:{type:"primary"}},{key:oe.REJECTED,type:"item",title:`{{t("Terminate the process", { ns: "${d}" })}}`,component:fr,action:oe.REJECTED,actionProps:{danger:!0}},{key:oe.PENDING,type:"item",title:`{{t("Save temporarily", { ns: "${d}" })}}`,component:fr,action:oe.PENDING}],title:"{{t('Configure actions')}}"}))}function Ky(){return{run(){}}}function Jy({value:e,onChange:t}){const o=b.useContext(i.SchemaComponentContext),n=Qn(),s=we(),a=st(s),l=I.useForm(),{workflow:c}=z(),u={},p={};a.forEach(h=>{const g=H.get(h.type);Object.assign(u,g.initializers),Object.assign(p,g.components)});const m=b.useMemo(()=>new I.Schema({properties:{drawer:{type:"void",title:'{{t("Configure form")}}',"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"AddBlockButton"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${d}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddBlockButton",properties:{}}}}}}}}}}),[]);return r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},o),{designable:!c.executed,refresh(){var f;(f=o.refresh)==null||f.call(o);const{tabs:h}=L.lodash.get(m.toJSON(),"properties.drawer.properties"),g=Array.from(Ce.getValues()).reduce((y,w)=>Object.assign(y,w.config.parseFormOptions(h)),{});l.setValuesIn("forms",g),t(h.properties)}}),children:r.jsx(i.SchemaInitializerProvider,{initializers:v(v(v({AddBlockButton:Uy,AddActionButton:qy},n.initializers),u),Array.from(Ce.getValues()).reduce((h,g)=>Object.assign(h,g.config.initializers),{})),children:r.jsx(i.SchemaComponent,{schema:m,components:C(v(v({},p),Array.from(Ce.getValues()).reduce((h,g)=>Object.assign(h,g.config.components),{})),{FormBlockProvider:lr,DetailsBlockProvider:ir,ManualActionStatusProvider(h){return h.children},ActionBarProvider(h){return h.children},SimpleDesigner:zy,ManualActionDesigner:Wy}),scope:{useSubmit:Ky,useDetailsBlockProps:i.useFormBlockContext}})})})}function Yy(e){const{workflow:t}=z(),[o,n]=b.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(x.Button,{type:"primary",onClick:()=>n(!0),children:t.executed?T("View user interface"):T("Configure user interface")}),r.jsx(i.ActionContextProvider,{value:{visible:o,setVisible:n},children:e.children})]})}function Zy({value:e,onChange:t}){return r.jsxs("fieldset",{className:i.css`
|
|
518
|
+
`),children:[r.jsx(Pe,{from:t,entry:s,branchIndex:(a=s==null?void 0:s.branchIndex)!=null?a:0}),r.jsxs("div",{className:n.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:i.cx(n.addButtonClass,n.loopLineClass),children:r.jsx(F.ArrowUpOutlined,{})})]})]})})})},scope:{useWorkflowVariableOptions:se},components:{},useScopeVariables(e,t){const o=i.useCompile(),{target:n}=e.config;if(!n)return null;const{fieldNames:s=Ne}=t;let a={key:"item",[s.value]:"item",[s.label]:O("Loop target")};if(typeof n=="string"&&n.startsWith("{{")&&n.endsWith("}}")){const l=n.slice(2,-2).split(".").map(p=>p.trim()),c=[po,mo].map(p=>{const m=p.useOptions(t).filter(Boolean);return{[s.label]:o(p.label),[s.value]:p.value,key:p.value,[s.children]:m,disabled:m&&!m.length}}),u=Iy(c,l);a=Object.assign({},u,a)}return[a,{key:"index",[s.value]:"index",[s.label]:O("Loop index")},{key:"length",[s.value]:"length",[s.label]:O("Loop length")}]}};function Ey(e){const{execution:t,nodes:o}=z(),n=g.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),s=g.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,u)=>Object.assign(c,{[n[u.nodeId]]:u.result}),{})}},[t]);return g.useMemo(()=>L.parse(e)(s),[t])}function dr(e){const t=E.useField(),o=g.useRef(null),{appends:n,updateAssociationValues:s}=i.useAssociationNames(),a=Ey(e.dataSource),l=g.useMemo(()=>me.createForm({values:a,readPretty:!0}),[a]),c={appends:n},u={loading:!1,data:{data:a}},m=i.useAPIClient().resource(e.collection),y=g.useContext(i.BlockRequestContext);return r.jsx(i.CollectionProvider,{collection:e.collection,children:r.jsx(i.RecordProvider,{record:a,parent:!1,children:r.jsx(i.BlockRequestContext.Provider,{value:{block:"form",field:t,service:u,resource:m,__parent:y},children:r.jsx(i.FormBlockContext.Provider,{value:{params:c,form:l,field:t,service:u,updateAssociationValues:s,formBlockRef:o},children:e.children})})})})}function pr(e){var S,T,M;const t=i.useRecord(),o=E.useFieldSchema(),n=E.useField(),s=g.useRef(null),{appends:a,updateAssociationValues:l}=i.useAssociationNames(),[c]=Object.keys((S=o.toJSON().properties)!=null?S:{}),u=(T=t==null?void 0:t.result)==null?void 0:T[c],{findComponent:p}=i.useDesignable(),m=p((M=n.component)==null?void 0:M[0])||g.Fragment,y=g.useMemo(()=>me.createForm({initialValues:u}),[u]),b=g.useMemo(()=>v({appends:a},e.params),[a,e.params]),f=g.useMemo(()=>({loading:!1,data:{data:u}}),[u]),$=i.useAPIClient().resource(e.collection),w=g.useContext(i.BlockRequestContext),k=g.useMemo(()=>({params:b,form:y,field:n,service:f,updateAssociationValues:l,formBlockRef:s}),[n,y,b,f,l]);return!t.status||u?r.jsx(i.CollectionProvider,{collection:e.collection,children:r.jsx(i.RecordProvider,{record:u,parent:!1,children:r.jsx(i.FormActiveFieldsProvider,{name:"form",children:r.jsx(i.BlockRequestContext.Provider,{value:{block:"form",props:e,field:n,service:f,resource:$,__parent:w},children:r.jsx(i.FormBlockContext.Provider,{value:k,children:r.jsxs(m,C(v({},n.componentProps),{children:[r.jsx(i.FormV2.Templates,{style:{marginBottom:18},form:y}),r.jsx("div",{ref:s,children:r.jsx(E.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})}):null}function Ny(n){var s=n,{insert:e,schema:t}=s,o=H(s,["insert","schema"]);const{getTemplateSchemaByMode:a}=i.useSchemaTemplateManager(),l=i.useRecordCollectionDataSourceItems("FormItem");function c(p){return q(this,arguments,function*({item:u}){const m=u.template?yield a(u):null,y=i.createFormBlockSchema(C(v({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:X.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},t),{template:m}));delete y["x-acl-action-props"],delete y["x-acl-action"];const[b]=Object.keys(y.properties);y.properties[b].properties.actions["x-decorator"]="ActionBarProvider",y.properties[b].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},Ut(y,f=>{f["x-uid"]&&delete f["x-uid"]}),e(y)})}return r.jsx(i.SchemaInitializer.Item,C(v({},o),{onClick:c,items:l}))}function mr(e){var t;return r.jsx(i.CollectionProvider,{collection:(t=e.schema)==null?void 0:t.collection,children:r.jsx(Ny,v({},e))})}function Py(){const{name:e,title:t}=i.useCollection();return r.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(i.SchemaSettings.DataTemplates,{collectionName:e}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const My={title:`{{t("Create record form", { ns: "${d}" })}}`,config:{useInitializer({collections:e}){return{key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${d}" })}}`,children:[{key:"createRecordForm-child",type:"itemGroup",style:{maxHeight:"48vh",overflowY:"auto"},loadChildren:({searchValue:t})=>e.filter(o=>!o.hidden&&o.title.toLowerCase().includes(t.toLowerCase())).map(o=>({key:`createRecordForm-child-${o.name}`,type:"item",title:o.title,schema:{collection:o.name,title:`{{t("Create record", { ns: "${d}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},component:mr}))}]}},initializers:{},components:{CreateFormDesigner:Py},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var l;const[s]=Object.keys(n.properties),a=n.properties[s];t[s]={type:"create",title:((l=n["x-component-props"])==null?void 0:l.title)||s,actions:ke(a.properties.actions,c=>c["x-component"]==="Action").map(c=>{var u,p;return{status:c["x-decorator-props"].value,values:(p=(u=c["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:p.values,key:c.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function fr(e){var p,m,y,b;const[t,o]=g.useState((m=(p=e.collection)==null?void 0:p.fields)!=null?m:[]),n=i.useRecord(),s=E.useField(),a=E.useFieldSchema(),[l]=Object.keys((y=a.toJSON().properties)!=null?y:{}),c=(b=n==null?void 0:n.result)==null?void 0:b[l],u=g.useMemo(()=>me.createForm({initialValues:c}),[c]);return!n.status||c?r.jsx(i.CollectionProvider,{collection:C(v({},e.collection),{fields:t}),children:r.jsx(i.RecordProvider,{record:c,parent:!1,children:r.jsx(i.FormBlockContext.Provider,{value:{form:u,field:s,setCollectionFields:o},children:e.children})})}):null}function _y(o){var n=o,{insert:e}=n,t=H(n,["insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:L.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[L.uid()]:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddCustomFormField"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"AddActionButton",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:X.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const hr={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 jy(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:s="others"}=n;t[s]=t[s]||{},To.set(t,[s,o],n)}),Object.keys(hr).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:hr[o],children:Object.keys(t[o]||{}).map(n=>{const s=t[o][n];return v({value:n,title:s.title,name:n},t[o][n])}).sort((n,s)=>n.order-s.order)}))}function By(){const{interfaces:e}=i.useCollectionManager();return jy(e).map(o=>({key:o.title,type:"itemGroup",title:o.title,children:o.children.map(n=>({key:n.name,type:"item",title:n.title,component:Ly,fieldInterface:n.name}))}))}const yr=g.createContext({});function Vy(e){const{insertPosition:t="beforeEnd",component:o}=e,n=By(),s=g.useContext(i.CollectionContext),[a,l]=g.useState(null),[c,u]=g.useState(),{setCollectionFields:p}=g.useContext(i.FormBlockContext);return r.jsxs(yr.Provider,{value:{onAddField(m){const $=To.cloneDeep(m),{properties:w}=$,k=w,{unique:y,type:b}=k,f=H(k,["unique","type"]),h=H($,["properties"]);delete f.name["x-disabled"],l(C(v({},h),{properties:f}))},setCallback:u},children:[r.jsx(i.SchemaInitializer.Button,{wrap:i.gridRowColWrap,insertPosition:t,items:n,component:o,title:"{{t('Configure fields')}}"}),r.jsx(i.ActionContextProvider,{value:{visible:!!a},children:a?r.jsx(i.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"Form","x-component":"Action.Drawer",properties:C(v({},a.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const m=E.useForm();return{run(){return q(this,null,function*(){u(null),l(null),m.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:m,query:y}=E.useForm();return{run(){return q(this,null,function*(){var k,S,T,M;const{default:f}=a,h=L.uid();if(f.name=(k=m.name)!=null?k:h,f.uiSchema.title=(T=(S=m.uiSchema)==null?void 0:S.title)!=null?T:h,f.interface=a.name,(M=s.fields)==null?void 0:M.find(I=>I.name===f.name)){y("name").take().setFeedback({type:"error",messages:[O("Field name existed in form")]});return}const w=L.merge(f,m);p([...s.fields,w]),c({name:f.name,type:f.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:w},"x-collection-field":`${s.name}.${f.name}`,"x-designer":"FormItem.Designer"}),u(null),l(null)})}}}}}}}})},components:{ArrayTable:Se.ArrayTable}}):null})]})}function Ly(e){const{item:t,insert:o}=e,{onAddField:n,setCallback:s}=g.useContext(yr),{getInterface:a}=i.useCollectionManager(),l=a(t.fieldInterface);return r.jsx(i.SchemaInitializer.Item,{onClick:()=>{s(()=>o),n(l)}},t.fieldInterface)}const gr={title:`{{t("Custom form", { ns: "${d}" })}}`,config:{useInitializer(){return{key:"customForm",type:"item",title:`{{t("Custom form", { ns: "${d}" })}}`,component:_y}},initializers:{AddCustomFormField:Vy},components:{CustomFormBlockProvider:fr},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var c;const[s]=Object.keys(n.properties),a=n.properties[s],l=ke(a.properties.grid,u=>u["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(u=>{var p,m;return(m=(p=u["x-component-props"])==null?void 0:p.field)!=null?m:u["x-interface-options"]}),t[s]={type:"custom",title:((c=n["x-component-props"])==null?void 0:c.title)||s,actions:ke(a.properties.actions,u=>u["x-component"]==="Action").map(u=>{var p,m;return{status:u["x-decorator-props"].value,values:(m=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:m.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:fr}}};function zy(){const{name:e,title:t}=i.useCollection(),o=E.useFieldSchema(),{t:n}=ee.useTranslation(),{dn:s}=i.useDesignable();return r.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.ActionModalItem,{title:n("Filter settings",{ns:d}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-component-props":{useProps(){var l;return{options:i.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:a})=>{o["x-decorator-props"].filter=a,s.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),s.refresh()}}),r.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Uy={title:`{{t("Update record form", { ns: "${d}" })}}`,config:{useInitializer({collections:e}){return{key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${d}" })}}`,children:[{key:"updateRecordForm-child",type:"itemGroup",style:{maxHeight:"48vh",overflowY:"auto"},loadChildren:({searchValue:t})=>e.filter(o=>!o.hidden&&o.title.toLowerCase().includes(t.toLowerCase())).map(o=>({key:`updateRecordForm-child-${o.name}`,type:"item",title:o.title,schema:{collection:o.name,title:`{{t("Update record", { ns: "${d}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},component:mr}))}]}},initializers:{},components:{FilterDynamicComponent:st,UpdateFormDesigner:zy},parseFormOptions(e){const t={};return ke(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var l;const[s]=Object.keys(n.properties),a=n.properties[s];t[s]=C(v({},n["x-decorator-props"]),{type:"update",title:((l=n["x-component-props"])==null?void 0:l.title)||s,actions:ke(a.properties.actions,c=>c["x-component"]==="Action").map(c=>{var u,p;return{status:c["x-decorator-props"].value,values:(p=(u=c["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:p.values,key:c.name}})})}),t}},block:{scope:{},components:{}}},Ce=new L.Registry;Ce.register("customForm",gr),Ce.register("createForm",My),Ce.register("updateForm",Uy);function Gy(){const{workflow:e}=z(),t=co();return t.useInitializers?t.useInitializers(e.config):null}const Wy={customForm:gr.title,record:`{{t("Data record", { ns: "${d}" })}}`};function Hy(){var n,s;const e=E.useFieldSchema(),t=(s=Wy[(n=e["x-designer-props"])==null?void 0:n.type])!=null?s:'{{t("Block")}}',o=i.useCompile();return r.jsxs(i.GeneralSchemaDesigner,{title:o(t),children:[r.jsx(i.SchemaSettings.BlockTitleItem,{}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}function Ky(e){const{collections:t}=i.useCollectionManager(),o=we(),n=at(o),s=[Gy()].filter(Boolean),a=n.map(u=>{var m;const p=W.get(u.type);return(m=p==null?void 0:p.useInitializers)==null?void 0:m.call(p,u)}).filter(Boolean),l=[...s,...a.length?[{key:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${d}" })}}`,children:a}]:[]].filter(Boolean),c=[...l.length?[{type:"itemGroup",title:'{{t("Data blocks")}}',children:l}]:[],{type:"itemGroup",title:'{{t("Form")}}',children:Array.from(Ce.getValues()).map(u=>{const{useInitializer:p}=u.config;return p({collections:t})})},{type:"itemGroup",title:'{{t("Other blocks")}}',children:[{type:"item",title:'{{t("Markdown")}}',component:"MarkdownBlockInitializer"}]}];return r.jsx(i.SchemaInitializer.Button,C(v({},e),{wrap:i.gridRowColWrap,items:c,title:"{{t('Add block')}}"}))}function qy(){var w,k,S;const e=g.useContext(i.SchemaComponentContext),{t}=ee.useTranslation(),o=E.useFieldSchema(),n=se(),[s,a]=g.useState(!1),[l,c]=g.useState((S=(k=(w=o==null?void 0:o["x-action-settings"])==null?void 0:w.assignedValues)==null?void 0:k.schema)!=null?S:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[u,p]=g.useState(null),{components:m}=i.useSchemaOptionsContext();g.useEffect(()=>{p(new E.Schema({properties:{grid:l}}))},[l]);const y=g.useMemo(()=>{var M,I;const T=(I=(M=o==null?void 0:o["x-action-settings"])==null?void 0:M.assignedValues)==null?void 0:I.values;return me.createForm({initialValues:L.lodash.cloneDeep(T),values:L.lodash.cloneDeep(T)})},[]),b=i.useFormActiveFields(),f=t("Assign field values");function h(){a(!1)}function $(){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=y.values,a(!1),setTimeout(()=>{var T;(T=e.refresh)==null||T.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(i.SchemaSettings.Item,{title:f,onClick:()=>a(!0),children:f}),r.jsx(x.Modal,{width:"50%",title:f,open:s,onCancel:h,footer:r.jsxs(x.Space,{children:[r.jsx(x.Button,{onClick:h,children:t("Cancel")}),r.jsx(x.Button,{type:"primary",onClick:$,children:t("Submit")})]}),children:r.jsx(i.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(i.VariableScopeProvider,{scope:n,children:r.jsx(i.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:b==null?void 0:b.getActiveFieldsName,children:r.jsx(E.FormProvider,{form:y,children:r.jsxs(Se.FormLayout,{layout:"vertical",children:[r.jsx(x.Alert,{message:O("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),s&&u&&r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{refresh(){c(L.lodash.get(u.toJSON(),"properties.grid"))}}),children:r.jsx(i.SchemaComponent,{schema:u,components:m})})]})})})})})})]})}function Jy(e){return r.jsxs(i.GeneralSchemaDesigner,C(v({},e),{disableInitializer:!0,children:[r.jsx(i.Action.Designer.ButtonEditor,{}),r.jsx(qy,{}),r.jsx(i.SchemaSettings.Divider,{}),r.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Yy(s){var a=s,{action:e,actionProps:t,insert:o}=a,n=H(a,["action","actionProps","insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({},n),{onClick:()=>{o({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(v({},t),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function vr(n){var s=n,{action:e,actionProps:t}=s,o=H(s,["action","actionProps"]);return r.jsx(i.InitializerWithSwitch,C(v({},o),{schema:{type:"void",title:o.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(v({},t),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${e}`},type:"x-action"}))}function Zy(e){return r.jsx(i.SchemaInitializer.Button,C(v({},e),{items:[{key:X.RESOLVED,type:"item",title:`{{t("Continue the process", { ns: "${d}" })}}`,component:Yy,action:X.RESOLVED,actionProps:{type:"primary"}},{key:X.REJECTED,type:"item",title:`{{t("Terminate the process", { ns: "${d}" })}}`,component:vr,action:X.REJECTED,actionProps:{danger:!0}},{key:X.PENDING,type:"item",title:`{{t("Save temporarily", { ns: "${d}" })}}`,component:vr,action:X.PENDING}],title:"{{t('Configure actions')}}"}))}function Qy(){return{run(){}}}function Xy({value:e,onChange:t}){const o=g.useContext(i.SchemaComponentContext),n=co(),s=we(),a=at(s),l=E.useForm(),{workflow:c}=z(),u={},p={};a.forEach(y=>{const b=W.get(y.type);Object.assign(u,b.initializers),Object.assign(p,b.components)});const m=g.useMemo(()=>new E.Schema({properties:{drawer:{type:"void",title:'{{t("Configure form")}}',"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"AddBlockButton"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${d}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddBlockButton",properties:{}}}}}}}}}}),[]);return r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},o),{designable:!c.executed,refresh(){var f;(f=o.refresh)==null||f.call(o);const{tabs:y}=L.lodash.get(m.toJSON(),"properties.drawer.properties"),b=Array.from(Ce.getValues()).reduce((h,$)=>Object.assign(h,$.config.parseFormOptions(y)),{});l.setValuesIn("forms",b),t(y.properties)}}),children:r.jsx(i.SchemaInitializerProvider,{initializers:v(v(v({AddBlockButton:Ky,AddActionButton:Zy},n.initializers),u),Array.from(Ce.getValues()).reduce((y,b)=>Object.assign(y,b.config.initializers),{})),children:r.jsx(i.SchemaComponent,{schema:m,components:C(v(v({},p),Array.from(Ce.getValues()).reduce((y,b)=>Object.assign(y,b.config.components),{})),{FormBlockProvider:pr,DetailsBlockProvider:dr,ManualActionStatusProvider(y){return y.children},ActionBarProvider(y){return y.children},SimpleDesigner:Hy,ManualActionDesigner:Jy}),scope:{useSubmit:Qy,useDetailsBlockProps:i.useFormBlockContext}})})})}function Ry(e){const{workflow:t}=z(),[o,n]=g.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(x.Button,{type:"primary",onClick:()=>n(!0),children:t.executed?O("View user interface"):O("Configure user interface")}),r.jsx(i.ActionContextProvider,{value:{visible:o,setVisible:n},children:e.children})]})}function eg({value:e,onChange:t}){return r.jsxs("fieldset",{className:i.css`
|
|
497
519
|
.ant-radio-group {
|
|
498
520
|
.anticon {
|
|
499
521
|
margin-left: 0.5em;
|
|
500
522
|
}
|
|
501
523
|
}
|
|
502
|
-
`,children:[r.jsx(x.Form.Item,{children:r.jsxs(x.Radio.Group,{value:!!e,onChange:({target:{value:o}})=>{console.log(o),t(Number(o))},children:[r.jsx(x.Radio,{value:!0,children:r.jsxs(x.Tooltip,{title:
|
|
524
|
+
`,children:[r.jsx(x.Form.Item,{children:r.jsxs(x.Radio.Group,{value:!!e,onChange:({target:{value:o}})=>{console.log(o),t(Number(o))},children:[r.jsx(x.Radio,{value:!0,children:r.jsxs(x.Tooltip,{title:O("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:O("Separately")}),r.jsx(F.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(x.Radio,{value:!1,children:r.jsxs(x.Tooltip,{title:O("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:O("Collaboratively")}),r.jsx(F.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?r.jsx("fieldset",{children:r.jsx(Se.FormLayout,{layout:"vertical",children:r.jsx(i.FormItem,{label:O("Negotiation"),children:r.jsxs(x.Radio.Group,{value:e,onChange:t,children:[r.jsx(x.Radio,{value:1,children:r.jsxs(x.Tooltip,{title:O("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:O("All pass")}),r.jsx(F.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(x.Radio,{value:-1,children:r.jsxs(x.Tooltip,{title:O("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:O("Any pass")}),r.jsx(F.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})}):null]})}function tg(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function og({multiple:e=!1,value:t=[],onChange:o}){const n=se({types:[tg]});return r.jsx(i.Variable.Input,{scope:n,value:t[0],onChange:s=>{o([s])},children:r.jsx(i.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:s=>{o(s!=null?[s]:[])}})})}const br=i.BlockInitializers.items.find(e=>e.key==="media");br.children.find(e=>e.key==="workflowTodos")||br.children.push({key:"workflowTodos",type:"item",title:`{{t("Workflow todos", { ns: "${d}" })}}`,component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"});const ng={title:`{{t("Manual", { ns: "${d}" })}}`,type:"manual",group:"manual",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: "${d}" })}}`,fieldset:{assignees:{type:"array",title:`{{t("Assignees", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}},view:{},scope:{},components:{SchemaConfigButton:Ry,SchemaConfig:Xy,ModeConfig:eg,AssigneesSelect:og},useVariables({key:e,title:t,config:o},{types:n,fieldNames:s=Ne}){var p;const a=i.useCompile(),{getCollectionFields:l}=i.useCollectionManager(),c=Object.keys((p=o.forms)!=null?p:{});if(!c.length)return null;const u=c.map(m=>{var h;const y=o.forms[m],b=be({fields:(h=y.collection)==null?void 0:h.fields,collection:y.collection,types:n,compile:a,getCollectionFields:l}),f=a(y.title)||m;return b.length?{key:m,value:m,label:f,title:f,children:b}:null}).filter(Boolean);return u.length?{[s.value]:e,[s.label]:t,[s.children]:u}:null},useInitializers(e){var s;const{getCollection:t}=i.useCollectionManager(),o=Object.keys((s=e.config.forms)!=null?s:{});if(!o.length||e.config.mode)return null;const n=o.map(a=>{var u;const l=e.config.forms[a],{fields:c=[]}=t(l.collection);return c.length?{type:"item",title:(u=l.title)!=null?u:a,component:Me,collection:l.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}.${a}}}`}:null}).filter(Boolean);return n.length?{key:"forms",type:"subMenu",title:e.title,children:n}:null},initializers:{}},rg={title:`{{t("Parallel branch", { ns: "${d}" })}}`,type:"parallel",group:"control",description:`{{t("Run multiple branch processes in parallel.", { ns: "${d}" })}}`,fieldset:{mode:{type:"string",title:`{{t("Mode", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${d}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${d}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${d}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${d}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${d}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${d}" })}}`}]},default:"all"}},view:{},component:function({data:t}){const{styles:o}=ne(),{id:n,config:{mode:s}}=t,{workflow:a,nodes:l}=z(),c=l.reduce((f,h)=>h.upstreamId===n&&h.branchIndex!=null?f.concat(h):f,[]).sort((f,h)=>f.branchIndex-h.branchIndex),[u,p]=g.useState(Math.max(2,c.length)),{getAriaLabel:m}=Lt(t),y=Array(Math.max(0,u-c.length)).fill(null),b=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(f=>r.jsx(Pe,{from:t,entry:f,branchIndex:f.branchIndex},f.id)),y.map((f,h)=>r.jsx(Pe,{from:t,branchIndex:(b?b.branchIndex:0)+h+1,controller:c.length+h>1?r.jsx("div",{className:i.css`
|
|
503
525
|
padding-top: 2em;
|
|
504
526
|
|
|
505
527
|
> button {
|
|
@@ -507,58 +529,37 @@
|
|
|
507
529
|
transform: rotate(45deg);
|
|
508
530
|
}
|
|
509
531
|
}
|
|
510
|
-
`,children:r.jsx(x.Button,{shape:"circle",icon:r.jsx(
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
`,onClick:()=>p(u+1),disabled:a.executed})})})]})})},components:{RadioWithTooltip:$t}},tg={title:`{{t("Query record", { ns: "${d}" })}}`,type:"query",group:"collection",description:`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${d}" })}}`,fieldset:{collection:de,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${d}" })}}`,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: "${d}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:_e,sort:Xr,pagination:Rr,appends:je},"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: "${d}" })}}`}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource,useWorkflowVariableOptions:ae,useSortableFields(){const e=i.useCompile(),{getCollectionFields:t,getInterface:o}=i.useCollectionManager(),{values:n}=I.useForm();return t(n.collection).filter(a=>{if(!a.interface)return!1;const l=o(a.interface);return!!(l!=null&&l.sortable)}).map(a=>{var l,c;return{value:a.name,label:(l=a==null?void 0:a.uiSchema)!=null&&l.title?e((c=a==null?void 0:a.uiSchema)==null?void 0:c.title):a.name}})}},components:{ArrayItems:Se.ArrayItems,FilterDynamicComponent:ot,SchemaComponentContext:i.SchemaComponentContext},useVariables({id:e,title:t,config:o},n){var u,p;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager(),l=`${e}`,[c]=xe(C(v({},n),{fields:[{collectionName:o.collection,name:l,type:"hasOne",target:o.collection,uiSchema:{title:t}}],appends:[l,...((p=(u=o.params)==null?void 0:u.appends)==null?void 0:p.map(m=>`${l}.${m}`))||[]],compile:s,getCollectionFields:a}));return c},useInitializers(e){var t;return!e.config.collection||e.config.multiple?null:{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:Me,collection:e.config.collection,dataSource:`{{$jobsMapByNodeId.${e.id}}}`}},initializers:{}},og={title:`{{t("HTTP request", { ns: "${d}" })}}`,type:"request",group:"extended",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: "${d}" })}}`,fieldset:{method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Input","x-component-props":{placeholder:"https://www.nocobase.com"}},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${d}" })}}`,description:`{{t('"Content-Type" only support "application/json", and no need to specify', { ns: "${d}" })}}`,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":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${d}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${d}" })}}`,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":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${d}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"RequestBody","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${d}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${d}" })}}`},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${d}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore fail request and continue workflow", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},view:{},scope:{useWorkflowVariableOptions:ae},components:{ArrayItems:Se.ArrayItems,RequestBody(e){const t=ae();return r.jsx(i.Variable.JSON,v({scope:t},e))}}},ng={title:`{{t("SQL action", { ns: "${d}" })}}`,type:"sql",group:"extended",description:`{{t("Execute a SQL statement in database.", { ns: "${d}" })}}`,fieldset:{sql:{type:"string",required:!0,title:"SQL",description:`{{t("Usage of SQL query result is not supported yet.", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"SQLInput","x-component-props":{rows:20,className:i.css`
|
|
532
|
+
`,children:r.jsx(x.Button,{shape:"circle",icon:r.jsx(F.PlusOutlined,{}),onClick:()=>p(u-1),disabled:a.executed})}):null},`temp_${c.length+h}`))]}),r.jsx(x.Tooltip,{title:O("Add branch"),className:i.css`
|
|
533
|
+
visibility: ${a.executed?"hidden":"visible"};
|
|
534
|
+
`,children:r.jsx(x.Button,{"aria-label":m("add-branch"),icon:r.jsx(F.PlusOutlined,{}),className:i.css`
|
|
535
|
+
position: relative;
|
|
536
|
+
top: 1em;
|
|
537
|
+
transform-origin: center;
|
|
538
|
+
transform: rotate(45deg);
|
|
539
|
+
|
|
540
|
+
.anticon {
|
|
541
|
+
transform-origin: center;
|
|
542
|
+
transform: rotate(-45deg);
|
|
543
|
+
}
|
|
544
|
+
`,onClick:()=>p(u+1),disabled:a.executed})})]})})},components:{RadioWithTooltip:At}},sg={title:`{{t("Query record", { ns: "${d}" })}}`,type:"query",group:"collection",description:`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${d}" })}}`,fieldset:{collection:de,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${d}" })}}`,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: "${d}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:_e,sort:os,pagination:ns,appends:je},"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: "${d}" })}}`}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource,useWorkflowVariableOptions:se,useSortableFields(){const e=i.useCompile(),{getCollectionFields:t,getInterface:o}=i.useCollectionManager(),{values:n}=E.useForm();return t(n.collection).filter(a=>{if(!a.interface)return!1;const l=o(a.interface);return!!(l!=null&&l.sortable)}).map(a=>{var l,c;return{value:a.name,label:(l=a==null?void 0:a.uiSchema)!=null&&l.title?e((c=a==null?void 0:a.uiSchema)==null?void 0:c.title):a.name}})}},components:{ArrayItems:Se.ArrayItems,FilterDynamicComponent:st,SchemaComponentContext:i.SchemaComponentContext},useVariables({key:e,title:t,config:o},n){var c,u;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager(),[l]=be(C(v({appends:[e,...((u=(c=o.params)==null?void 0:c.appends)==null?void 0:u.map(p=>`${e}.${p}`))||[]]},n),{fields:[{collectionName:o.collection,name:e,type:"hasOne",target:o.collection,uiSchema:{title:t}}],compile:s,getCollectionFields:a}));return l},useInitializers(e){var t;return!e.config.collection||e.config.multiple?null:{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:Me,collection:e.config.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}},initializers:{}},ag={title:`{{t("HTTP request", { ns: "${d}" })}}`,type:"request",group:"extended",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: "${d}" })}}`,fieldset:{method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${d}" })}}`,"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: "${d}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Input","x-component-props":{placeholder:"https://www.nocobase.com"}},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${d}" })}}`,description:`{{t('"Content-Type" only support "application/json", and no need to specify', { ns: "${d}" })}}`,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":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${d}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${d}" })}}`,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":"Variable.Input","x-component-props":{scope:"{{useWorkflowVariableOptions()}}",useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${d}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"RequestBody","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${d}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${d}" })}}`},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${d}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},view:{},scope:{useWorkflowVariableOptions:se},components:{ArrayItems:Se.ArrayItems,RequestBody(e){const t=se();return r.jsx(i.Variable.JSON,v({scope:t},e))}}},ig={title:`{{t("SQL action", { ns: "${d}" })}}`,type:"sql",group:"collection",description:`{{t("Execute a SQL statement in database.", { ns: "${d}" })}}`,fieldset:{sql:{type:"string",required:!0,title:"SQL",description:`{{t("Usage of SQL query result is not supported yet.", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"SQLInput","x-component-props":{rows:20,className:i.css`
|
|
524
545
|
font-size: 80%;
|
|
525
546
|
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
526
|
-
`}}},scope:{},components:{SQLInput(e){const t=
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
`}));function rt(e){var n;const{styles:t}=lg();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:a}=e.statusMap[e.status];o=r.jsx(x.Tag,{color:a,children:s})}return r.jsx(x.Button,C(v({},e),{shape:"circle",size:"small",className:ig(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const H=new L.Registry;H.register("calculation",fy),H.register("condition",by),H.register("parallel",eg),H.register("loop",Ty),H.register("delay",Sy),H.register("manual",Ry),H.register("query",tg),H.register("create",Cy),H.register("update",sg),H.register("destroy",ky),H.register("aggregate",dy),H.register("request",og),H.register("sql",ng);function cg(){const e=I.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=we(),{workflow:a}=z();return{run(){return K(this,null,function*(){var c,u;if(a.executed){x.message.error(T("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),o.setVisible(!1),n()})}}}const fo=b.createContext({});function we(){return b.useContext(fo)}function st(e){const t=[];if(!e)return[];for(let o=e.upstream;o;o=o.upstream)t.push(o);return t}function gr(e){const t=[];if(!e)return[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}function vr({data:e}){const{styles:t}=se(),{component:o=at,endding:n}=H.get(e.type);return r.jsx(fo.Provider,{value:e,children:r.jsxs("div",{className:i.cx(t.nodeBlockClass),children:[r.jsx(o,{data:e}),n?r.jsx("div",{className:i.css`
|
|
543
|
-
flex-grow: 1;
|
|
544
|
-
display: flex;
|
|
545
|
-
flex-direction: column;
|
|
546
|
-
align-items: center;
|
|
547
|
-
justify-content: center;
|
|
548
|
-
width: 1px;
|
|
549
|
-
height: 6em;
|
|
550
|
-
padding: 2em 0;
|
|
551
|
-
background-color: var(--nb-box-bg);
|
|
552
|
-
|
|
553
|
-
.anticon {
|
|
554
|
-
font-size: 1.5em;
|
|
555
|
-
line-height: 100%;
|
|
556
|
-
}
|
|
557
|
-
`,children:r.jsx(P.CloseOutlined,{})}):r.jsx(Cr,{upstream:e})]})})}function br(){var p;const{t:e}=te.useTranslation(),t=i.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(p=z())!=null?p:{},a=we(),{modal:l}=x.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return K(this,null,function*(){function m(){return K(this,null,function*(){var y;yield(y=c.destroy)==null?void 0:y.call(c,{filterByTk:a.id}),s()})}const h=n.filter(y=>y===a?!1:L.parse(y.config).parameters.filter(({key:k})=>k.startsWith(`$jobsMapByNodeId.${a.id}.`)||k===`$jobsMapByNodeId.${a.id}`).length);if(h.length){l.error({title:T("Can not delete"),content:T("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:h.map(y=>`#${y.id}`).join(", ")})});return}const f=!n.find(y=>y.upstream===a&&y.branchIndex!=null)?e("Are you sure you want to delete it?"):T("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:f,onOk:m})})}return o.executed?null:r.jsx(x.Button,{type:"text",shape:"circle",icon:r.jsx(P.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function xr(){var a;const{execution:e,setViewJob:t}=z(),{jobs:o}=(a=we())!=null?a:{},{styles:n}=se();if(!e)return null;if(!o.length)return r.jsx(rt,{className:n.nodeJobButtonClass,disabled:!0});function s({key:l}){const c=o.find(u=>u.id==l);t(c)}return o.length>1?r.jsx(x.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(rt,{statusMap:ut,status:l.status}),r.jsx("time",{children:L.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(rt,{statusMap:ut,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(rt,{statusMap:ut,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function at(e){var k,S;const{data:t,children:o}=e,n=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(k=z())!=null?k:{},{styles:c}=se(),u=H.get(t.type),p=a.executed?'{{t("View")}}':'{{t("Configure")}}',m=n(u.title),[h,g]=b.useState((S=t.title)!=null?S:m),[f,y]=b.useState(!1);function w(A){return K(this,null,function*(){var D,_;const M=A||m;g(M),M!==t.title&&(yield(_=(D=s.resource("flow_nodes")).update)==null?void 0:_.call(D,{filterByTk:t.id,values:{title:M}}),l())})}function $(A){if(A.target===A.currentTarget){y(!0);return}const M=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let D=A.target;D&&D!==A.currentTarget&&D!==document.documentElement;D=D.parentNode)if(Array.from(D.classList).some(_=>M.has(_))){y(!0),A.stopPropagation();return}}return r.jsxs("div",{className:i.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{className:i.cx(c.nodeCardClass,{configuring:f}),onClick:$,children:[r.jsxs("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(x.Tag,{children:m}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx("div",{children:r.jsx(x.Input.TextArea,{disabled:a.executed,value:h,onChange:A=>g(A.target.value),onBlur:A=>w(A.target.value),autoSize:!0})}),r.jsx(br,{}),r.jsx(xr,{}),r.jsx(i.ActionContextProvider,{value:{visible:f,setVisible:y},children:r.jsx(i.SchemaComponent,{scope:u.scope,components:u.components,schema:{type:"void",properties:C(v({},u.view?{view:u.view}:{}),{button:{type:"void","x-content":p,"x-component":x.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[`${u.type}_${t.id}`]:{type:"void",title:t.title,"x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{disabled:a.executed,useValues(A){const{config:M}=we();return i.useRequest(()=>Promise.resolve({data:M}),A)}},properties:C(v({},a.executed?{alert:{type:"void","x-component":x.Alert,"x-component-props":{type:"warning",showIcon:!0,message:`{{t("Node in executed workflow cannot be modified", { ns: "${d}" })}}`,className:i.css`
|
|
558
|
-
width: 100%;
|
|
559
|
-
font-size: 85%;
|
|
560
|
-
margin-bottom: 2em;
|
|
561
|
-
`}}}:u.description?{description:{type:"void","x-component":Co,"x-component-props":{label:T("Node type"),title:u.title,description:u.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
547
|
+
`}}},scope:{},components:{SQLInput(e){const t=se();return r.jsx(i.Variable.RawTextArea,v({scope:t},e))}}};function lg(o){var n=o,{onChange:e}=n,t=H(n,["onChange"]);const{getCollectionFields:s}=i.useCollectionManager(),a=E.useForm(),{collection:l}=a.values,c=s(l),u=E.useField();function p({target:m}){const y=u.query(".values").take();if(!y)return;const b=c.reduce((f,h)=>(h.name in y.value&&(m.value||!["hasOne","hasMany","belongsToMany"].includes(h.type))&&(f[h.name]=y.value[h.name]),f),{});a.setValuesIn("params.values",b),e(m.value)}return r.jsx(At,C(v({},t),{onChange:p}))}const cg={title:`{{t("Update record", { ns: "${d}" })}}`,type:"update",group:"collection",description:`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${d}" })}}`,fieldset:{collection:de,params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${d}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${d}" })}}`},{label:`{{t("Update one by one", { ns: "${d}" })}}`,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: "${d}" })}}`}]},default:!1},filter:C(v({},_e),{title:`{{t("Only update records matching conditions", { ns: "${d}" })}}`,"x-validator"(e){return bo(e)?"":O("Please add at least one condition")}}),values:C(v({},Do),{"x-component-props":{filter(e){var t;return((t=this.params)==null?void 0:t.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(e.type)}}})}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FilterDynamicComponent:st,CollectionFieldset:cr,IndividualHooksRadioWithTooltip:lg}},W=new L.Registry;W.register("calculation",vy),W.register("condition",$y),W.register("parallel",rg),W.register("loop",Dy),W.register("delay",Oy),W.register("manual",ng),W.register("query",sg),W.register("create",ky),W.register("update",cg),W.register("destroy",Fy),W.register("aggregate",hy),W.register("request",ag),W.register("sql",ig);function ug(){const e=E.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=we(),{workflow:a}=z();return{run(){return q(this,null,function*(){var c,u;if(a.executed){x.message.error(O("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),o.setVisible(!1),n()})}}}const xo=g.createContext({});function we(){return g.useContext(xo)}function at(e){const t=[];if(!e)return[];for(let o=e.upstream;o;o=o.upstream)t.push(o);return t}function xr(e){const t=[];if(!e)return[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}function Cr({data:e}){const{styles:t}=ne(),{getAriaLabel:o}=Lt(e),{component:n=it}=W.get(e.type);return r.jsx(xo.Provider,{value:e,children:r.jsxs("div",{className:i.cx(t.nodeBlockClass),children:[r.jsx(n,{data:e}),r.jsx(Sr,{"aria-label":o(),upstream:e})]})})}function wr(){var p;const{t:e}=ee.useTranslation(),t=i.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(p=z())!=null?p:{},a=we(),{modal:l}=x.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return q(this,null,function*(){function m(){return q(this,null,function*(){var h;yield(h=c.destroy)==null?void 0:h.call(c,{filterByTk:a.id}),s()})}const y=n.filter(h=>h===a?!1:L.parse(h.config).parameters.filter(({key:k})=>k.startsWith(`$jobsMapByNodeKey.${a.key}.`)||k===`$jobsMapByNodeKey.${a.key}`).length);if(y.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:y.map(h=>`#${h.id}`).join(", ")})});return}const f=!n.find(h=>h.upstream===a&&h.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:f,onOk:m})})}return o.executed?null:r.jsx(x.Button,{type:"text",shape:"circle",icon:r.jsx(F.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function $r(){var a;const{execution:e,setViewJob:t}=z(),{jobs:o}=(a=we())!=null?a:{},{styles:n}=ne();if(!e)return null;if(!o.length)return r.jsx(Xe,{className:n.nodeJobButtonClass,disabled:!0});function s({key:l}){const c=o.find(u=>u.id==l);t(c)}return o.length>1?r.jsx(x.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Xe,{statusMap:Ze,status:l.status}),r.jsx("time",{children:L.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(Xe,{statusMap:Ze,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Xe,{statusMap:Ze,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function it(e){var k,S;const{data:t,children:o}=e,n=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(k=z())!=null?k:{},{styles:c}=ne(),u=W.get(t.type),p=a.executed?'{{t("View")}}':'{{t("Configure")}}',m=n(u.title),[y,b]=g.useState((S=t.title)!=null?S:m),[f,h]=g.useState(!1);function $(T){return q(this,null,function*(){var I,_;const M=T||m;b(M),M!==t.title&&(yield(_=(I=s.resource("flow_nodes")).update)==null?void 0:_.call(I,{filterByTk:t.id,values:{title:M}}),l())})}function w(T){if(T.target===T.currentTarget){h(!0);return}const M=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=T.target;I&&I!==T.currentTarget&&I!==document.documentElement;I=I.parentNode)if(Array.from(I.classList).some(_=>M.has(_))){h(!0),T.stopPropagation();return}}return r.jsxs("div",{className:i.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${m}-${y}`,className:i.cx(c.nodeCardClass,{configuring:f}),onClick:w,children:[r.jsxs("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(x.Tag,{children:m}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx("div",{children:r.jsx(x.Input.TextArea,{role:"button","aria-label":"textarea",disabled:a.executed,value:y,onChange:T=>b(T.target.value),onBlur:T=>$(T.target.value),autoSize:!0})}),r.jsx(wr,{}),r.jsx($r,{}),r.jsx(i.ActionContextProvider,{value:{visible:f,setVisible:h},children:r.jsx(i.SchemaComponent,{scope:u.scope,components:u.components,schema:{type:"void",properties:C(v({},u.view?{view:u.view}:{}),{button:{type:"void","x-content":p,"x-component":x.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[`${u.type}_${t.id}`]:{type:"void",title:r.jsxs("div",{className:i.css`
|
|
548
|
+
display: flex;
|
|
549
|
+
justify-content: space-between;
|
|
550
|
+
|
|
551
|
+
strong {
|
|
552
|
+
font-weight: bold;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
.ant-tag {
|
|
556
|
+
margin-inline-end: 0;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
code {
|
|
560
|
+
font-weight: normal;
|
|
561
|
+
}
|
|
562
|
+
`,children:[r.jsx("strong",{children:t.title}),r.jsx(x.Tooltip,{title:O("Variable key of node"),children:r.jsx(x.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{disabled:a.executed,useValues(T){const{config:M}=we();return i.useRequest(()=>Promise.resolve({data:M}),T)}},properties:C(v({},u.description?{description:{type:"void","x-component":Oo,"x-component-props":{label:O("Node type"),title:u.title,description:u.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
562
563
|
.ant-input,
|
|
563
564
|
.ant-select,
|
|
564
565
|
.ant-cascader-picker,
|
|
@@ -570,11 +571,13 @@
|
|
|
570
571
|
min-width: 6em;
|
|
571
572
|
}
|
|
572
573
|
}
|
|
573
|
-
`},properties:u.fieldset},actions:a.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:
|
|
574
|
-
.ant-dropdown-menu-root{
|
|
574
|
+
`},properties:u.fieldset},actions:a.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:ug}}}}})}})}})})]}),o]})}function Sr(e){var f;const{upstream:t,branchIndex:o=null}=e,n=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(f=z())!=null?f:{},c=Array.from(W.getValues()),{styles:u}=ne(),p=g.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${d}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${d}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${d}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${d}" })}}`}].filter(h=>c.filter($=>$.group===h.key).length).map(h=>{const $=c.filter(w=>w.group===h.key&&(w.isAvailable?w.isAvailable({workflow:a,upstream:t,branchIndex:o}):!0));return C(v({},h),{type:"group",children:$.map(w=>({role:"button","aria-label":w.type,key:w.type,label:w.title,type:w.options?"subMenu":null,children:w.options?w.options.map(k=>({role:"button","aria-label":k.key,key:k.key,label:k.label})):null}))})}),[o,c,t,a]),m=g.useMemo(()=>a?s.resource("workflows.nodes",a.id):null,[a==null?void 0:a.id]),y=g.useCallback($=>q(this,[$],function*({keyPath:h}){var M,I,_;const w=h.pop(),k={},[S]=h,T=W.get(w);if(S){const{value:D}=(I=(M=T.options)==null?void 0:M.find(N=>N.key===S))!=null?I:{};Object.assign(k,D)}m&&(yield m.create({values:{type:w,upstreamId:(_=t==null?void 0:t.id)!=null?_:null,branchIndex:o,title:n(T.title),config:k}}),l())}),[o,m==null?void 0:m.create,t==null?void 0:t.id]),b=g.useMemo(()=>({onClick:y,items:n(p)}),[p,y]);return a?r.jsx("div",{className:u.addButtonClass,children:r.jsx(x.Dropdown,{trigger:["click"],menu:b,disabled:a.executed,overlayClassName:i.css`
|
|
575
|
+
.ant-dropdown-menu-root {
|
|
575
576
|
max-height: 30em;
|
|
576
577
|
overflow-y: auto;
|
|
577
578
|
}
|
|
578
|
-
`,children:r.jsx(x.Button,{shape:"circle",icon:r.jsx(P.PlusOutlined,{})})})}):null}function Ee({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null}){const{styles:s}=se(),a=[];for(let l=t;l;l=l.downstream)a.push(l);return r.jsxs("div",{className:i.cx(s.branchClass),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Cr,{upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:a.map(l=>r.jsx(vr,{data:l},l.id))})]})}function wr({entry:e}){const{styles:t}=se();return r.jsxs("div",{className:"workflow-canvas",children:[r.jsx(oy,{}),r.jsx("div",{className:t.branchBlockClass,children:r.jsx(Ee,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:T("End")})]})}function ug(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function dg(){const e=i.useCompile(),{viewJob:t,setViewJob:o}=z(),{styles:n}=se(),{node:s={}}=t!=null?t:{},a=H.get(s.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${t==null?void 0:t.id}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:t},"x-component":"Action.Modal",title:r.jsxs("div",{className:n.nodeTitleClass,children:[r.jsx(x.Tag,{children:e(a==null?void 0:a.title)}),r.jsx("strong",{children:s.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",s.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:Bt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:n.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function pg(e){const{execution:t}=z(),o=i.useAPIClient(),n=he.useNavigate(),{styles:s}=se(),[a,l]=b.useState([]),[c,u]=b.useState([]);b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{l(m.data)}).catch(()=>{})},[t]),b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{u(m.data.reverse())}).catch(()=>{})},[t]);const p=b.useCallback(({key:m})=>{m!=t.id&&n(`/admin/settings/workflow/executions/${m}`)},[t]);return t?r.jsx(x.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(m=>({key:m.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${m.id}`}),r.jsx("time",{children:L.str2moment(m.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(rt,{statusMap:jt,status:m.status})})}))},children:r.jsxs(x.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(P.DownOutlined,{})]})}):null}function mg(){var f;const e=i.useCompile(),{data:t,loading:o}=i.useResourceActionContext(),{setTitle:n}=i.useDocumentTitle(),[s,a]=b.useState(null);if(b.useEffect(()=>{var S;const{workflow:k}=(S=t==null?void 0:t.data)!=null?S:{};n==null||n(`${k!=null&&k.title?`${k.title} - `:""}${T("Execution history")}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return o?r.jsx("div",{children:T("Loading")}):r.jsx("div",{children:T("Load failed")});const y=(f=t==null?void 0:t.data)!=null?f:{},{jobs:l=[],workflow:w={}}=y,$=w,{nodes:c=[],revisions:u=[]}=$,p=q($,["nodes","revisions"]),m=q(y,["jobs","workflow"]);po(c),ug(c,l);const h=c.find(k=>!k.upstream),g=jt[m.status];return r.jsxs(Ye.Provider,{value:{workflow:p.type?p:null,nodes:c,execution:m,viewJob:s,setViewJob:a},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(x.Breadcrumb,{items:[{title:r.jsx(he.Link,{to:"/admin/settings/workflow/workflows",children:T("Workflow")})},{title:r.jsx(he.Link,{to:`/admin/settings/workflow/workflows/${p.id}`,children:p.title})},{title:r.jsx(pg,{})}]})}),r.jsxs("aside",{children:[r.jsx(x.Tag,{color:g.color,children:e(g.label)}),r.jsx("time",{children:L.str2moment(m.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(wr,{entry:h}),r.jsx(dg,{})]})}const $r=()=>{const e=he.useParams(),{styles:t}=se();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:mg}})})},Sr=()=>{const{t:e}=te.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(he.Link,{to:`/admin/settings/workflow/executions/${t}`,onClick:()=>o(!1),children:e("View")})},fg={name:"executions",fields:[{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${d}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${d}" })}}`,"x-component"({value:e}){const{setVisible:t}=i.useActionContext();return r.jsx(he.Link,{to:`/admin/settings/workflow/workflows/${e}`,onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${d}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:_t}}]},kr={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${d}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:fg,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=te.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return K(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.filter}),x.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${d}" })}}`,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: "${d}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void",title:`{{t("Details", { ns: "${d}" })}}`,"x-component":"ExecutionLink"}}}}}}}}}}};function hg(n){var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const{workflow:a}=z(),l=C(v({},o),{request:C(v({},e),{params:C(v({},e==null?void 0:e.params),{filter:C(v({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,v({},l))}function yg(){var D;const e=he.useNavigate(),{t}=te.useTranslation(),{data:o,refresh:n,loading:s}=i.useResourceActionContext(),{resource:a}=i.useResourceContext(),{setTitle:l}=i.useDocumentTitle(),[c,u]=b.useState(!1),{styles:p}=se(),{modal:m}=x.App.useApp();if(b.useEffect(()=>{var N;const{title:F}=(N=o==null?void 0:o.data)!=null?N:{};l==null||l(`${T("Workflow")}${F?`: ${F}`:""}`)},[o==null?void 0:o.data]),!(o!=null&&o.data))return r.jsx("div",{children:T(s?"Loading":"Load failed")});const _=(D=o==null?void 0:o.data)!=null?D:{},{nodes:h=[],revisions:g=[]}=_,f=q(_,["nodes","revisions"]);po(h);const y=h.find(F=>!F.upstream);function w({key:F}){F!=f.id&&e(`/admin/settings/workflow/workflows/${F}`)}function $(F){return K(this,null,function*(){yield a.update({filterByTk:f.id,values:{enabled:F}}),n()})}function k(){return K(this,null,function*(){const{data:{data:F}}=yield a.revision({filterByTk:f.id,filter:{key:f.key}});x.message.success(t("Operation succeeded")),e(`/admin/settings/workflow/workflows/${F.id}`)})}function S(){return K(this,null,function*(){const F=f.current?T("Delete a main version will cause all other revisions to be deleted too."):"";m.confirm({title:t("Are you sure you want to delete it?"),content:F,onOk(){return K(this,null,function*(){var U;yield a.destroy({filterByTk:f.id}),x.message.success(t("Operation succeeded")),e(f.current?"/admin/settings/workflow/workflows":`/admin/settings/workflow/workflows/${(U=g.find(ie=>ie.current))==null?void 0:U.id}`)})}})})}function A(N){return K(this,arguments,function*({key:F}){switch(F){case"history":u(!0);return;case"revision":return k();case"delete":return S()}})}const M=f.executed&&!g.find(F=>!F.executed&&new Date(F.createdAt)>new Date(f.createdAt));return r.jsxs(Ye.Provider,{value:{workflow:f,nodes:h,refresh:n},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(x.Breadcrumb,{items:[{title:r.jsx(he.Link,{to:"/admin/settings/workflow/workflows",children:T("Workflow")})},{title:r.jsx("strong",{children:f.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(x.Dropdown,{trigger:["click"],menu:{onClick:w,defaultSelectedKeys:[`${f.id}`],className:i.cx(p.dropdownClass,p.workflowVersionDropdownClass),items:g.sort((F,N)=>N.id-F.id).map((F,N)=>({key:`${F.id}`,icon:F.current?r.jsx(P.RightOutlined,{}):null,className:i.cx({executed:F.executed,unexecuted:!F.executed,enabled:F.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${F.id}`}),r.jsx("time",{children:L.str2moment(F.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(x.Button,{type:"text",children:[r.jsx("label",{children:T("Version")}),r.jsx("span",{children:f!=null&&f.id?`#${f.id}`:null}),r.jsx(P.DownOutlined,{})]})})}),r.jsx(x.Switch,{checked:f.enabled,onChange:$,checkedChildren:T("On"),unCheckedChildren:T("Off")}),r.jsx(x.Dropdown,{menu:{items:[{key:"history",label:T("Execution history"),disabled:!f.allExecuted},{key:"revision",label:T("Copy to new version"),disabled:!M},{key:"delete",label:t("Delete")}],onClick:A},children:r.jsx(x.Button,{type:"text",icon:r.jsx(P.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:c,setVisible:u},children:r.jsx(i.SchemaComponent,{schema:kr,components:{ExecutionResourceProvider:hg,ExecutionLink:Sr}})})]})]}),r.jsx(wr,{entry:y})]})}const Ar=()=>{const e=he.useParams(),{styles:t}=se();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:yg}})})},gg=n=>{var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const a=i.useRecord(),l=C(v({},o),{request:C(v({},e),{params:C(v({},e==null?void 0:e.params),{filter:C(v({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,v({},l))},vg=()=>{const{t:e}=te.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(he.Link,{to:`/admin/settings/workflow/workflows/${t}`,onClick:()=>o(!1),children:e("View")})};function bg(n){var s=n,{component:e="div",children:t}=s,o=q(s,["component","children"]);const[a,l]=b.useState(!1),c=I.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[b.createElement(e,C(v({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const{defaultProps:xg}=i.interfacesProperties,Cg={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${d}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${d}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:v({},xg),invariable:!0},Tr={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: "${d}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${d}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${d}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${d}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${d}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},Ae={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},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: "${d}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},wg={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Tr,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Tr},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-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:Ae.title,type:Ae.type,description:Ae.description,options:Ae.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:"a"},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:kr}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:Ae.title,enabled:Ae.enabled,description:Ae.description,options:Ae.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${d}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${d}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=te.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=I.useForm();return{run(){return K(this,null,function*(){yield o.revision({filterByTk:a,values:l}),x.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Or(e){var a;const o=i.useCompile()(e.label),n=b.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=jt[e.value])!=null?a:{};return r.jsx(x.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function $g(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Or,v({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function Sg(t){var e=q(t,[]);return r.jsx(x.Select,C(v({},e),{mode:e.multiple?"multiple":null,optionLabelProp:"label",tagRender:Or,children:_t.filter(o=>!!o.value&&o.value!==be.ABORTED).map(o=>r.jsx(x.Select.Option,C(v({},o),{children:r.jsx($g,v({},o))}),o.value))}))}const kg=b.createContext({});function Ag(){const e=b.useContext(i.SchemaComponentContext);return r.jsx(x.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:wg,components:{WorkflowLink:vg,ExecutionResourceProvider:gg,ExecutionLink:Sr,OpenDrawer:bg,ExecutionStatusSelect:Sg},scope:{getTriggersOptions:Xn}})})})}const Tg=e=>{const t=b.useContext(i.PluginManagerContext),o=b.useContext(i.CollectionManagerContext);return r.jsx(i.SettingsCenterProvider,{settings:{workflow:{icon:"PartitionOutlined",title:T("Workflow"),tabs:{workflows:{isBookmark:!0,title:T("Workflow"),component:Ag}}}},children:r.jsx(i.PluginManagerContext.Provider,{value:{components:v({},t==null?void 0:t.components)},children:r.jsx(i.CollectionManagerContext.Provider,{value:C(v({},o),{interfaces:C(v({},o.interfaces),{expression:Cg})}),children:r.jsx(kg.Provider,{value:{triggers:ge,instructions:H},children:e.children})})})})},Og=I.observer(e=>{const{onChange:t}=e,o=I.useField(),n=I.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=b.useState(n.getValuesIn(a)),u=i.useCompile(),{getCollectionFields:p}=i.useCollectionManager();I.useFormEffects(()=>{me.onFormInitialValuesChange(h=>{c(h.getValuesIn(a))}),me.onFieldInputValueChange(a,h=>{c(h.value),t(null)})});const m=xe({collection:l,compile:u,getCollectionFields:p});return r.jsx(i.Variable.TextArea,C(v({},e),{scope:m}))},{displayName:"InternalExpression"});function Fg(e){const{t}=te.useTranslation(),o=i.useRecord(),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager(),a=b.useMemo(()=>xe({collection:o.sourceCollection,compile:n,getCollectionFields:s}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(i.Variable.TextArea,C(v({},e),{scope:a})):r.jsx(x.Tag,{children:t("Unconfigured",{ns:d})})}const Ig=I.connect(Og,I.mapReadPretty(Fg)),Dg={title:`{{t("Task", { ns: "${d}" })}}`,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"}}]},Ng={title:`{{t("Workflow", { ns: "${d}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},Pg={title:`{{t("Workflow todos", { ns: "${d}" })}}`,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: "${d}" })}}`,"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: "${d}" })}}`,"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: "${d}" })}}`,"x-component":"Select",enum:Bt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Eg=I.observer(()=>{var t,o,n;const e=I.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"}),Mg=I.observer(()=>{var t,o,n;const e=I.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"}),_g=I.observer(()=>{var t,o,n;const e=I.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"}),ho=()=>r.jsx(i.SchemaComponent,{components:{NodeColumn:Eg,WorkflowColumn:Mg,UserColumn:_g},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-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Task", { ns: "${d}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Workflow", { ns: "${d}" })}}`,properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Assignee", { ns: "${d}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{"x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}}}}}}});function jg(e){var p;const{data:t}=i.useCurrentUserContext(),{userJob:o}=z(),{status:n,result:s,userId:a}=o,l=I.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:u}=e;return n?s[c]||(u=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==a&&(u=null),u}const Bg=b.createContext(null);function Vg({value:e,children:t}){const{userJob:o}=z(),n=I.useField(),s=I.useFieldSchema();return b.useEffect(()=>{o.status&&(n.disabled=!0,n.visible=o.status===e&&o.result._===s.name)},[o,e,n]),r.jsx(Bg.Provider,{value:e,children:t})}function Lg(){const e=i.useAPIClient(),{setVisible:t}=i.useActionContext(),{values:o,submit:n}=I.useForm(),s=I.useFieldSchema(),{service:a}=i.useTableBlockContext(),{userJob:l}=z(),{name:c}=s,{name:u}=s.parent.parent;return{run(){return K(this,null,function*(){l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[u]:o,_:c}}}),t(!1),a.refresh())})}}}function zg(e){var p;const t=i.useAPIClient(),{id:o}=i.useRecord(),[n,s]=b.useState(null),[a,l]=b.useState(null);b.useEffect(()=>{var m,h;o&&((h=(m=t.resource("users_jobs")).get)==null||h.call(m,{filterByTk:o,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:g})=>{var S;const A=(S=g==null?void 0:g.data)!=null?S:{},{node:f,workflow:M={}}=A,D=M,{nodes:y=[]}=D,w=q(D,["nodes"]),_=A,{execution:$}=_,k=q(_,["node","workflow","execution"]);po(y),l(f),s({userJob:k,workflow:w,nodes:y,execution:$})}))},[o]);const u=st(n==null?void 0:n.nodes.find(m=>m.id===a.id)).reduce((m,{type:h})=>Object.assign(m,H.get(h).components),{});return a&&n?r.jsx(Ye.Provider,{value:n,children:r.jsx(i.SchemaComponent,{components:v(v({FormBlockProvider:lr,DetailsBlockProvider:ir,ActionBarProvider:jg,ManualActionStatusProvider:Vg},Array.from(Ce.getValues()).reduce((m,h)=>Object.assign(m,h.block.components),{})),u),scope:v({useSubmit:Lg,useFormBlockProps:Ug,useDetailsBlockProps:Gg},Array.from(Ce.getValues()).reduce((m,h)=>Object.assign(m,h.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=a.config)==null?void 0:p.schema}})}):r.jsx(x.Spin,{})}function Ug(){var a;const{userJob:e}=z(),t=i.useRecord(),{data:o}=i.useCurrentUserContext(),{form:n}=i.useFormBlockContext(),s=e.status?t?"readPretty":"disabled":((a=o==null?void 0:o.data)==null?void 0:a.id)!==e.userId?"disabled":"editable";return b.useEffect(()=>{n==null||n.setPattern(s)},[s,n]),{form:n}}function Gg(){const{form:e}=i.useFormBlockContext();return{form:e}}function Wg(){const e=i.useCompile(),{status:t,updatedAt:o}=i.useRecord(),n=ut[t];return t?r.jsxs(x.Space,{children:[r.jsx("time",{className:Jr.css`
|
|
579
|
+
`,children:r.jsx(x.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(F.PlusOutlined,{})})})}):null}function Pe({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:a}){const{styles:l}=ne(),{getAriaLabel:c}=Lt(e,o),u=[];for(let p=t;p;p=p.downstream)u.push(p);return r.jsxs("div",{className:i.cx("workflow-branch",l.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Sr,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:u.map(p=>r.jsx(Cr,{data:p},p.id))}),a?r.jsx("div",{className:"end-sign",children:r.jsx(F.CloseOutlined,{})}):null]})}function kr({entry:e}){const{styles:t}=ne(),{workflow:o}=z();return r.jsxs("div",{className:"workflow-canvas",children:[o!=null&&o.executed?r.jsx(x.Alert,{type:"warning",message:O("Executed workflow cannot be modified"),showIcon:!0}):null,r.jsx(ay,{}),r.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
|
|
580
|
+
margin-top: 0 !important;
|
|
581
|
+
`),children:r.jsx(Pe,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:O("End")})]})}function dg(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function pg(){const e=i.useCompile(),{viewJob:t,setViewJob:o}=z(),{styles:n}=ne(),{node:s={}}=t!=null?t:{},a=W.get(s.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${t==null?void 0:t.id}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:t},"x-component":"Action.Modal",title:r.jsxs("div",{className:n.nodeTitleClass,children:[r.jsx(x.Tag,{children:e(a==null?void 0:a.title)}),r.jsx("strong",{children:s.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",s.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:mt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:n.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function mg(e){const{execution:t}=z(),o=i.useAPIClient(),n=he.useNavigate(),{styles:s}=ne(),[a,l]=g.useState([]),[c,u]=g.useState([]);g.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{l(m.data)}).catch(()=>{})},[t]),g.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{u(m.data.reverse())}).catch(()=>{})},[t]);const p=g.useCallback(({key:m})=>{m!=t.id&&n(`/admin/settings/workflow/executions/${m}`)},[t]);return t?r.jsx(x.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(m=>({key:m.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${m.id}`}),r.jsx("time",{children:L.str2moment(m.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Xe,{statusMap:pt,status:m.status})})}))},children:r.jsxs(x.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(F.DownOutlined,{})]})}):null}function fg(){var f;const e=i.useCompile(),{data:t,loading:o}=i.useResourceActionContext(),{setTitle:n}=i.useDocumentTitle(),[s,a]=g.useState(null);if(g.useEffect(()=>{var S;const{workflow:k}=(S=t==null?void 0:t.data)!=null?S:{};n==null||n(`${k!=null&&k.title?`${k.title} - `:""}${O("Execution history")}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return o?r.jsx("div",{children:O("Loading")}):r.jsx("div",{children:O("Load failed")});const h=(f=t==null?void 0:t.data)!=null?f:{},{jobs:l=[],workflow:$={}}=h,w=$,{nodes:c=[],revisions:u=[]}=w,p=H(w,["nodes","revisions"]),m=H(h,["jobs","workflow"]);vo(c),dg(c,l);const y=c.find(k=>!k.upstream),b=pt[m.status];return r.jsxs(Qe.Provider,{value:{workflow:p.type?p:null,nodes:c,execution:m,viewJob:s,setViewJob:a},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(x.Breadcrumb,{items:[{title:r.jsx(he.Link,{to:"/admin/settings/workflow/workflows",children:O("Workflow")})},{title:r.jsx(he.Link,{to:`/admin/settings/workflow/workflows/${p.id}`,children:p.title})},{title:r.jsx(mg,{})}]})}),r.jsxs("aside",{children:[r.jsx(x.Tag,{color:b.color,children:e(b.label)}),r.jsx("time",{children:L.str2moment(m.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(kr,{entry:y}),r.jsx(pg,{})]})}const Ar=()=>{const e=he.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:fg}})})},Tr=()=>{const{t:e}=ee.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(he.Link,{to:`/admin/settings/workflow/executions/${t}`,onClick:()=>o(!1),children:e("View")})},hg={name:"executions",fields:[{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${d}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${d}" })}}`,"x-component"({value:e}){const{setVisible:t}=i.useActionContext();return r.jsx(he.Link,{to:`/admin/settings/workflow/workflows/${e}`,onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${d}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:dt}}]},Or={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${d}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:hg,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=ee.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return q(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.filter}),x.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${d}" })}}`,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: "${d}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void",title:`{{t("Details", { ns: "${d}" })}}`,"x-component":"ExecutionLink"}}}}}}}}}}};function yg(n){var s=n,{request:e,filter:t={}}=s,o=H(s,["request","filter"]);var c;const{workflow:a}=z(),l=C(v({},o),{request:C(v({},e),{params:C(v({},e==null?void 0:e.params),{filter:C(v({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,v({},l))}function gg(){var I;const e=he.useNavigate(),{t}=ee.useTranslation(),{data:o,refresh:n,loading:s}=i.useResourceActionContext(),{resource:a}=i.useResourceContext(),{setTitle:l}=i.useDocumentTitle(),[c,u]=g.useState(!1),{styles:p}=ne(),{modal:m}=x.App.useApp();if(g.useEffect(()=>{var N;const{title:D}=(N=o==null?void 0:o.data)!=null?N:{};l==null||l(`${O("Workflow")}${D?`: ${D}`:""}`)},[o==null?void 0:o.data]),!(o!=null&&o.data))return r.jsx("div",{children:O(s?"Loading":"Load failed")});const _=(I=o==null?void 0:o.data)!=null?I:{},{nodes:y=[],revisions:b=[]}=_,f=H(_,["nodes","revisions"]);vo(y);const h=y.find(D=>!D.upstream);function $({key:D}){D!=f.id&&e(`/admin/settings/workflow/workflows/${D}`)}function w(D){return q(this,null,function*(){yield a.update({filterByTk:f.id,values:{enabled:D}}),n()})}function k(){return q(this,null,function*(){const{data:{data:D}}=yield a.revision({filterByTk:f.id,filter:{key:f.key}});x.message.success(t("Operation succeeded")),e(`/admin/settings/workflow/workflows/${D.id}`)})}function S(){return q(this,null,function*(){const D=f.current?O("Delete a main version will cause all other revisions to be deleted too."):"";m.confirm({title:t("Are you sure you want to delete it?"),content:D,onOk(){return q(this,null,function*(){var U;yield a.destroy({filterByTk:f.id}),x.message.success(t("Operation succeeded")),e(f.current?"/admin/settings/workflow/workflows":`/admin/settings/workflow/workflows/${(U=b.find(ae=>ae.current))==null?void 0:U.id}`)})}})})}function T(N){return q(this,arguments,function*({key:D}){switch(D){case"history":u(!0);return;case"revision":return k();case"delete":return S()}})}const M=f.executed&&!b.find(D=>!D.executed&&new Date(D.createdAt)>new Date(f.createdAt));return r.jsxs(Qe.Provider,{value:{workflow:f,nodes:y,refresh:n},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(x.Breadcrumb,{items:[{title:r.jsx(he.Link,{to:"/admin/settings/workflow/workflows",children:O("Workflow")})},{title:r.jsx("strong",{children:f.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(x.Dropdown,{trigger:["click"],menu:{onClick:$,defaultSelectedKeys:[`${f.id}`],className:i.cx(p.dropdownClass,p.workflowVersionDropdownClass),items:b.sort((D,N)=>N.id-D.id).map((D,N)=>({role:"button","aria-label":`version-${N}`,key:`${D.id}`,icon:D.current?r.jsx(F.RightOutlined,{}):null,className:i.cx({executed:D.executed,unexecuted:!D.executed,enabled:D.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${D.id}`}),r.jsx("time",{children:L.str2moment(D.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(x.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:O("Version")}),r.jsx("span",{children:f!=null&&f.id?`#${f.id}`:null}),r.jsx(F.DownOutlined,{})]})})}),r.jsx(x.Switch,{checked:f.enabled,onChange:w,checkedChildren:O("On"),unCheckedChildren:O("Off")}),r.jsx(x.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:O("Execution history"),disabled:!f.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:O("Copy to new version"),disabled:!M},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:T},children:r.jsx(x.Button,{"aria-label":"more",type:"text",icon:r.jsx(F.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:c,setVisible:u},children:r.jsx(i.SchemaComponent,{schema:Or,components:{ExecutionResourceProvider:yg,ExecutionLink:Tr}})})]})]}),r.jsx(kr,{entry:h})]})}const Fr=()=>{const e=he.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:gg}})})},vg=n=>{var s=n,{request:e,filter:t={}}=s,o=H(s,["request","filter"]);var c;const a=i.useRecord(),l=C(v({},o),{request:C(v({},e),{params:C(v({},e==null?void 0:e.params),{filter:C(v({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,v({},l))},bg=()=>{const{t:e}=ee.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:n}=i.useGetAriaLabelOfAction("Configure");return r.jsx(he.Link,{"aria-label":n(),to:`/admin/settings/workflow/workflows/${t}`,onClick:()=>o(!1),children:e("Configure")})};function xg(n){var s=n,{component:e="div",children:t}=s,o=H(s,["component","children"]);const[a,l]=g.useState(!1),c=E.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[g.createElement(e,C(v({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const{defaultProps:Cg}=i.interfacesProperties,wg={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${d}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${d}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:v({},Cg)},Ir={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: "${d}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${d}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${d}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${d}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${d}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},Ae={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},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: "${d}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},$g={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Ir,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Ir},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-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:Ae.title,type:Ae.type,description:Ae.description,options:Ae.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:"a"},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Or}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:Ae.title,enabled:Ae.enabled,description:Ae.description,options:Ae.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${d}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${d}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=ee.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=E.useForm();return{run(){return q(this,null,function*(){yield o.revision({filterByTk:a,values:l}),x.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Dr(e){var a;const o=i.useCompile()(e.label),n=g.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=pt[e.value])!=null?a:{};return r.jsx(x.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function Sg(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Dr,v({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function kg(t){var e=H(t,[]);const o=e.multiple?"multiple":null;return r.jsx(x.Select,C(v({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Dr,children:dt.filter(n=>!!n.value&&n.value!==ye.ABORTED).map(n=>r.jsx(x.Select.Option,C(v({},n),{children:r.jsx(Sg,v({},n))}),n.value))}))}const Ag=g.createContext({});function Tg(){const e=g.useContext(i.SchemaComponentContext);return r.jsx(x.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:$g,components:{WorkflowLink:bg,ExecutionResourceProvider:vg,ExecutionLink:Tr,OpenDrawer:xg,ExecutionStatusSelect:kg},scope:{getTriggersOptions:uo}})})})}const Og=e=>{const t=g.useContext(i.PluginManagerContext),o=g.useContext(i.CollectionManagerContext);return r.jsx(i.SettingsCenterProvider,{settings:{workflow:{icon:"PartitionOutlined",title:O("Workflow"),tabs:{workflows:{isBookmark:!0,title:O("Workflow"),component:Tg}}}},children:r.jsx(i.PluginManagerContext.Provider,{value:{components:v({},t==null?void 0:t.components)},children:r.jsx(i.CollectionManagerContext.Provider,{value:C(v({},o),{interfaces:C(v({},o.interfaces),{expression:wg})}),children:r.jsx(Ag.Provider,{value:{triggers:ge,instructions:W},children:e.children})})})})},Fg=E.observer(e=>{const{onChange:t}=e,o=E.useField(),n=E.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=g.useState(n.getValuesIn(a)),u=i.useCompile(),{getCollectionFields:p}=i.useCollectionManager();E.useFormEffects(()=>{me.onFormInitialValuesChange(y=>{c(y.getValuesIn(a))}),me.onFieldInputValueChange(a,y=>{c(y.value),t(null)})});const m=be({collection:l,compile:u,getCollectionFields:p});return r.jsx(i.Variable.TextArea,C(v({},e),{scope:m}))},{displayName:"InternalExpression"});function Ig(e){const{t}=ee.useTranslation(),o=i.useRecord(),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager(),a=g.useMemo(()=>be({collection:o.sourceCollection,compile:n,getCollectionFields:s}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(i.Variable.TextArea,C(v({},e),{scope:a})):r.jsx(x.Tag,{children:t("Unconfigured",{ns:d})})}const Dg=E.connect(Fg,E.mapReadPretty(Ig)),Eg={title:`{{t("Task", { ns: "${d}" })}}`,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"}}]},Ng={title:`{{t("Workflow", { ns: "${d}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},Pg={title:`{{t("Workflow todos", { ns: "${d}" })}}`,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: "${d}" })}}`,"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: "${d}" })}}`,"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: "${d}" })}}`,"x-component":"Select",enum:mt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Mg=E.observer(()=>{var t,o,n;const e=E.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"}),_g=E.observer(()=>{var t,o,n;const e=E.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"}),jg=E.observer(()=>{var t,o,n;const e=E.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"}),Co=()=>r.jsx(i.SchemaComponent,{components:{NodeColumn:Mg,WorkflowColumn:_g,UserColumn:jg},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-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Task", { ns: "${d}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Workflow", { ns: "${d}" })}}`,properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Assignee", { ns: "${d}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{"x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}}}}}}});function Bg(e){var p;const{data:t}=i.useCurrentUserContext(),{userJob:o}=z(),{status:n,result:s,userId:a}=o,l=E.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:u}=e;return n?s[c]||(u=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==a&&(u=null),u}const Vg=g.createContext(null);function Lg({value:e,children:t}){const{userJob:o}=z(),n=E.useField(),s=E.useFieldSchema();return g.useEffect(()=>{o.status&&(n.disabled=!0,n.visible=o.status===e&&o.result._===s.name)},[o,e,n]),r.jsx(Vg.Provider,{value:e,children:t})}function zg(){const e=i.useAPIClient(),{setVisible:t}=i.useActionContext(),{values:o,submit:n}=E.useForm(),s=E.useFieldSchema(),{service:a}=i.useTableBlockContext(),{userJob:l}=z(),{name:c}=s,{name:u}=s.parent.parent;return{run(){return q(this,null,function*(){l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[u]:o,_:c}}}),t(!1),a.refresh())})}}}function Ug(e){var p;const t=i.useAPIClient(),{id:o}=i.useRecord(),[n,s]=g.useState(null),[a,l]=g.useState(null);g.useEffect(()=>{var m,y;o&&((y=(m=t.resource("users_jobs")).get)==null||y.call(m,{filterByTk:o,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:b})=>{var S;const T=(S=b==null?void 0:b.data)!=null?S:{},{node:f,workflow:M={}}=T,I=M,{nodes:h=[]}=I,$=H(I,["nodes"]),_=T,{execution:w}=_,k=H(_,["node","workflow","execution"]);vo(h),l(f),s({userJob:k,workflow:$,nodes:h,execution:w})}))},[o]);const u=at(n==null?void 0:n.nodes.find(m=>m.id===a.id)).reduce((m,{type:y})=>Object.assign(m,W.get(y).components),{});return a&&n?r.jsx(Qe.Provider,{value:n,children:r.jsx(i.SchemaComponent,{components:v(v({FormBlockProvider:pr,DetailsBlockProvider:dr,ActionBarProvider:Bg,ManualActionStatusProvider:Lg},Array.from(Ce.getValues()).reduce((m,y)=>Object.assign(m,y.block.components),{})),u),scope:v({useSubmit:zg,useFormBlockProps:Gg,useDetailsBlockProps:Wg},Array.from(Ce.getValues()).reduce((m,y)=>Object.assign(m,y.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=a.config)==null?void 0:p.schema}})}):r.jsx(x.Spin,{})}function Gg(){var a;const{userJob:e}=z(),t=i.useRecord(),{data:o}=i.useCurrentUserContext(),{form:n}=i.useFormBlockContext(),s=e.status?t?"readPretty":"disabled":((a=o==null?void 0:o.data)==null?void 0:a.id)!==e.userId?"disabled":"editable";return g.useEffect(()=>{n==null||n.setPattern(s)},[s,n]),{form:n}}function Wg(){const{form:e}=i.useFormBlockContext();return{form:e}}function Hg(){const e=i.useCompile(),{status:t,updatedAt:o}=i.useRecord(),n=Ze[t];return t?r.jsxs(x.Space,{children:[r.jsx("time",{className:i.css`
|
|
579
582
|
margin-right: 0.5em;
|
|
580
|
-
`,children:
|
|
583
|
+
`,children:Ao(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(x.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function Kg(){var a;const e=g.useContext(i.SchemaComponentContext),{id:t,node:o,workflow:n,status:s}=i.useRecord();return r.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{reset(){},designable:!1}),children:r.jsx(i.SchemaComponent,{components:{FooterStatus:Hg,FlowContextProvider:Ug},schema:{type:"void",name:`drawer-${t}-${s}`,"x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:`${n.title} - ${(a=o.title)!=null?a:`#${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 qg({params:e={},children:t}){const a=i.useCollectionManager(),{collections:o}=a,n=H(a,["collections"]),s={collection:"users_jobs",resource:"users_jobs",action:"list",params:C(v({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(i.CollectionManagerProvider,C(v({},n),{collections:[...o,Eg,Ng,Pg],children:r.jsx(i.TableBlockProvider,C(v({name:"workflow-todo"},s),{children:t}))}))}Co.Drawer=Kg,Co.Decorator=qg;const Jg=o=>{var n=o,{insert:e}=n,t=H(n,["insert"]);return r.jsx(i.SchemaInitializer.Item,C(v({icon:r.jsx(F.TableOutlined,{})},t),{onClick:()=>{e({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-designer":"TableBlockDesigner",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class Er extends i.Plugin{constructor(){super(...arguments);Bt(this,"triggers",ge);Bt(this,"getTriggersOptions",uo);Bt(this,"instructions",W)}load(){return q(this,null,function*(){this.addRoutes(),this.addScopes(),this.addComponents(),this.app.addProvider(Og)})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:Lh})}addComponents(){this.app.addComponents({WorkflowPage:Fr,ExecutionPage:Ar,WorkflowTodo:Co,WorkflowTodoBlockInitializer:Jg,DynamicExpression:Dg})}addRoutes(){this.app.router.add("admin.settings.workflow.workflows.id",{path:"/admin/settings/workflow/workflows/:id",element:r.jsx(Fr,{})}),this.app.router.add("admin.settings.workflow.executions.id",{path:"/admin/settings/workflow/executions/:id",element:r.jsx(Ar,{})})}}A.Branch=Pe,A.EXECUTION_STATUS=ye,A.ExecutionStatusOptions=dt,A.ExecutionStatusOptionsMap=pt,A.FlowContext=Qe,A.JOB_STATUS=X,A.JobButton=$r,A.JobStatusOptions=mt,A.JobStatusOptionsMap=Ze,A.Node=Cr,A.NodeContext=xo,A.NodeDefaultView=it,A.RemoveButton=wr,A.WorkflowPlugin=Er,A.default=Er,A.getCollectionFieldOptions=be,A.getTriggersOptions=uo,A.instructions=W,A.triggers=ge,A.useAvailableUpstreams=at,A.useFlowContext=z,A.useNodeContext=we,A.useStyles=ne,A.useTrigger=co,A.useUpstreamScopes=xr,A.useWorkflowVariableOptions=se,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|