@nocobase/plugin-workflow 0.15.0-alpha.4 → 0.15.0-alpha.5
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/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(S,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/client"),require("react-i18next"),require("antd"),require("react"),require("lodash"),require("@formily/core"),require("@formily/react"),require("@nocobase/utils/client"),require("react-router-dom"),require("dayjs"),require("@formily/antd-v5"),require("@nocobase/evaluators/client")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@ant-design/icons","@nocobase/client","react-i18next","antd","react","lodash","@formily/core","@formily/react","@nocobase/utils/client","react-router-dom","dayjs","@formily/antd-v5","@nocobase/evaluators/client"],n):(S=typeof globalThis!="undefined"?globalThis:S||self,n(S["@nocobase/plugin-workflow"]={},S.jsxRuntime,S["@ant-design/icons"],S["@nocobase/client"],S["react-i18next"],S.antd,S.react,S.lodash,S["@formily/core"],S["@formily/react"],S["@nocobase/utils"],S["react-router-dom"],S.dayjs,S["@formily/antd-v5"],S["@nocobase/evaluators"]))})(this,function(S,n,
|
|
1
|
+
(function(S,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/client"),require("react-i18next"),require("antd"),require("react"),require("lodash"),require("@formily/core"),require("@formily/react"),require("@nocobase/utils/client"),require("react-router-dom"),require("dayjs"),require("@formily/antd-v5"),require("@nocobase/evaluators/client")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@ant-design/icons","@nocobase/client","react-i18next","antd","react","lodash","@formily/core","@formily/react","@nocobase/utils/client","react-router-dom","dayjs","@formily/antd-v5","@nocobase/evaluators/client"],n):(S=typeof globalThis!="undefined"?globalThis:S||self,n(S["@nocobase/plugin-workflow"]={},S.jsxRuntime,S["@ant-design/icons"],S["@nocobase/client"],S["react-i18next"],S.antd,S.react,S.lodash,S["@formily/core"],S["@formily/react"],S["@nocobase/utils"],S["react-router-dom"],S.dayjs,S["@formily/antd-v5"],S["@nocobase/evaluators"]))})(this,function(S,n,O,i,oe,b,y,$e,se,F,X,he,No,Se,Xe){"use strict";var lv=Object.defineProperty,cv=Object.defineProperties;var uv=Object.getOwnPropertyDescriptors;var Ut=Object.getOwnPropertySymbols;var os=Object.prototype.hasOwnProperty,rs=Object.prototype.propertyIsEnumerable;var Do=(S,n,O)=>n in S?lv(S,n,{enumerable:!0,configurable:!0,writable:!0,value:O}):S[n]=O,v=(S,n)=>{for(var O in n||(n={}))os.call(n,O)&&Do(S,O,n[O]);if(Ut)for(var O of Ut(n))rs.call(n,O)&&Do(S,O,n[O]);return S},C=(S,n)=>cv(S,uv(n));var ns=S=>typeof S=="symbol"?S:S+"",W=(S,n)=>{var O={};for(var i in S)os.call(S,i)&&n.indexOf(i)<0&&(O[i]=S[i]);if(S!=null&&Ut)for(var i of Ut(S))n.indexOf(i)<0&&rs.call(S,i)&&(O[i]=S[i]);return O};var Gt=(S,n,O)=>(Do(S,typeof n!="symbol"?n+"":n,O),O);var J=(S,n,O)=>new Promise((i,oe)=>{var b=se=>{try{$e(O.next(se))}catch(F){oe(F)}},y=se=>{try{$e(O.throw(se))}catch(F){oe(F)}},$e=se=>se.done?i(se.value):Promise.resolve(se.value).then(b,y);$e((O=O.apply(S,n)).next())});const d="workflow";function N(e,t={}){return i.i18n.t(e,C(v({},t),{ns:d}))}function Ht(){return oe.useTranslation(d)}const ye={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},ft=[{value:ye.QUEUEING,label:`{{t("Queueing", { ns: "${d}" })}}`,color:"blue",icon:n.jsx(O.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:n.jsx(O.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:n.jsx(O.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${d}" })}}`},{value:ye.FAILED,label:`{{t("Failed", { ns: "${d}" })}}`,color:"red",icon:n.jsx(O.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${d}" })}}`},{value:ye.ERROR,label:`{{t("Error", { ns: "${d}" })}}`,color:"red",icon:n.jsx(O.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${d}" })}}`},{value:ye.ABORTED,label:`{{t("Aborted", { ns: "${d}" })}}`,color:"red",icon:n.jsx(O.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:n.jsx(O.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${d}" })}}`},{value:ye.REJECTED,label:`{{t("Rejected", { ns: "${d}" })}}`,color:"volcano",icon:n.jsx(O.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${d}" })}}`},{value:ye.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${d}" })}}`,color:"volcano",icon:n.jsx(O.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${d}" })}}`}],ht=ft.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),ee={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},yt=[{value:ee.PENDING,label:`{{t("Pending", { ns: "${d}" })}}`,color:"gold",icon:n.jsx(O.ClockCircleOutlined,{})},{value:ee.RESOLVED,label:`{{t("Resolved", { ns: "${d}" })}}`,color:"green",icon:n.jsx(O.CheckOutlined,{})},{value:ee.FAILED,label:`{{t("Failed", { ns: "${d}" })}}`,color:"red",icon:n.jsx(O.ExclamationOutlined,{})},{value:ee.ERROR,label:`{{t("Error", { ns: "${d}" })}}`,color:"red",icon:n.jsx(O.CloseOutlined,{})},{value:ee.ABORTED,label:`{{t("Aborted", { ns: "${d}" })}}`,color:"red",icon:n.jsx(O.MinusOutlined,{rotate:90})},{value:ee.CANCELED,label:`{{t("Canceled", { ns: "${d}" })}}`,color:"volcano",icon:n.jsx(O.MinusOutlined,{rotate:45})},{value:ee.REJECTED,label:`{{t("Rejected", { ns: "${d}" })}}`,color:"volcano",icon:n.jsx(O.MinusOutlined,{})},{value:ee.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${d}" })}}`,color:"volcano",icon:n.jsx(O.RedoOutlined,{})}],Re=yt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),et=y.createContext({});function G(){return y.useContext(et)}const ss=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,7 @@
|
|
|
23
23
|
p {
|
|
24
24
|
color: ${t.colorTextDescription};
|
|
25
25
|
}
|
|
26
|
-
`}));function
|
|
26
|
+
`}));function Po(e){const{label:t,title:o,description:r}=e,{styles:s}=ss();return n.jsxs("div",{className:i.cx(s.container,e.className),children:[n.jsxs("dl",{children:[n.jsx("dt",{children:t}),n.jsx("dd",{children:n.jsx(b.Tag,{style:{background:"none"},children:o})})]}),r?n.jsx("p",{children:r}):null]})}var gt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Eo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Mo={exports:{}};/*!
|
|
27
27
|
Copyright (c) 2018 Jed Watson.
|
|
28
28
|
Licensed under the MIT License (MIT), see
|
|
29
29
|
http://jedwatson.github.io/classnames
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
}
|
|
40
40
|
`,noStatusButtonClass:e`
|
|
41
41
|
border-width: 2px;
|
|
42
|
-
`}));function tt(e){var r;const{styles:t}=ls();let o=null;if(typeof e.status!="undefined"&&((r=e.statusMap)!=null&&r[e.status])){const{icon:s,color:a}=e.statusMap[e.status];o=n.jsx(
|
|
42
|
+
`}));function tt(e){var r;const{styles:t}=ls();let o=null;if(typeof e.status!="undefined"&&((r=e.statusMap)!=null&&r[e.status])){const{icon:s,color:a}=e.statusMap[e.status];o=n.jsx(b.Tag,{color:a,children:s})}return n.jsx(b.Button,C(v({},e),{shape:"circle",size:"small",className:is(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const Kt=(e,t)=>({getAriaLabel:y.useCallback(r=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",r].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),ae=i.createStyles(({css:e,token:t})=>({workflowPageClass:e`
|
|
43
43
|
flex-grow: 1;
|
|
44
44
|
overflow: hidden;
|
|
45
45
|
display: flex;
|
|
@@ -392,18 +392,18 @@
|
|
|
392
392
|
border-radius: 50%;
|
|
393
393
|
background-color: ${t.colorText};
|
|
394
394
|
color: ${t.colorBgContainer};
|
|
395
|
-
`}));function cs(){return!0}const qt=
|
|
395
|
+
`}));function cs(){return!0}const qt=F.observer(e=>{const c=e,{filter:t=cs}=c,o=W(c,["filter"]),r=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager(),{values:a}=F.useForm(),l=s(a==null?void 0:a.collection);return n.jsx(b.Select,C(v({popupMatchSelectWidth:!1},o),{options:l.filter(t).map(u=>{var p;return{label:r((p=u.uiSchema)==null?void 0:p.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Jt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{Jt(e.properties[o],t)})}function ke(e,t,o=!1){const r=[];return e?t(e)&&(!o||!e.properties)?(r.push(e),r):(e.properties&&Object.keys(e.properties).forEach(s=>{r.push(...ke(e.properties[s],t))}),r):r}function us(s){var a=s,{insert:e,collection:t,dataSource:o}=a,r=W(a,["insert","collection","dataSource"]);const{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager(),u=i.useRecordCollectionDataSourceItems("FormItem"),p=c(t);function f(x){return J(this,arguments,function*({item:g}){const h=g.template?yield l(g):null,m={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:r.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{useDetailsBlockProps}}"},"x-read-pretty":!0,properties:{grid:h||{type:"void","x-component":"Grid","x-initializer":"ReadPrettyFormItemInitializers",properties:{}}}}}};Jt(m,k=>{k["x-uid"]&&delete k["x-uid"]}),e(m)})}return n.jsx(i.SchemaInitializer.Item,C(v({},r),{onClick:f,items:u}))}function _e(e){return n.jsx(i.CollectionProvider,{collection:e.collection,children:n.jsx(us,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"}},_o={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:i.css`
|
|
396
396
|
flex-direction: column;
|
|
397
|
-
`},"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}" })}}`},je={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=
|
|
397
|
+
`},"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}" })}}`},je={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=F.useForm();return{options:i.useCollectionFilterOptions(e==null?void 0:e.collection),className:i.css`
|
|
398
398
|
position: relative;
|
|
399
399
|
width: 100%;
|
|
400
|
-
`}},dynamicComponent:"FilterDynamicComponent"}},ds={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"}}},ps={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},Be={type:"array",title:`{{t("Preload associations", { ns: "${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}=I.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Ve={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},ms=[{label:`{{t("After record added", { ns: "${d}" })}}`,value:Ve.CREATED},{label:`{{t("After record updated", { ns: "${d}" })}}`,value:Ve.UPDATED},{label:`{{t("After record added or updated", { ns: "${d}" })}}`,value:Ve.SAVED},{label:`{{t("After record deleted", { ns: "${d}" })}}`,value:Ve.DELETED}],jo={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:ms,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] & ${Ve.UPDATED})}}`}}}]},condition:C(v({},je),{title:`{{t("Only triggers when match conditions", { ns: "${d}" })}}`,"x-component-props":{useProps:je["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:C(v({},Be),{"x-reactions":[...Be["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ve.DELETED})}}`}}}]})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FieldsSelect:qt},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:r}=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:r}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:_e,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function fs(e,t){for(var o=-1,r=e==null?0:e.length,s=Array(r);++o<r;)s[o]=t(e[o],o,e);return s}var Bo=fs;function hs(){this.__data__=[],this.size=0}var ys=hs;function gs(e,t){return e===t||e!==e&&t!==t}var Vo=gs,vs=Vo;function bs(e,t){for(var o=e.length;o--;)if(vs(e[o][0],t))return o;return-1}var vt=bs,xs=vt,Cs=Array.prototype,ws=Cs.splice;function $s(e){var t=this.__data__,o=xs(t,e);if(o<0)return!1;var r=t.length-1;return o==r?t.pop():ws.call(t,o,1),--this.size,!0}var Ss=$s,ks=vt;function As(e){var t=this.__data__,o=ks(t,e);return o<0?void 0:t[o][1]}var Ts=As,Os=vt;function Fs(e){return Os(this.__data__,e)>-1}var Is=Fs,Ds=vt;function Ps(e,t){var o=this.__data__,r=Ds(o,e);return r<0?(++this.size,o.push([e,t])):o[r][1]=t,this}var Ns=Ps,Es=ys,Ms=Ss,_s=Ts,js=Is,Bs=Ns;function Le(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var r=e[t];this.set(r[0],r[1])}}Le.prototype.clear=Es,Le.prototype.delete=Ms,Le.prototype.get=_s,Le.prototype.has=js,Le.prototype.set=Bs;var bt=Le,Vs=bt;function Ls(){this.__data__=new Vs,this.size=0}var zs=Ls;function Ws(e){var t=this.__data__,o=t.delete(e);return this.size=t.size,o}var Us=Ws;function Gs(e){return this.__data__.get(e)}var Hs=Gs;function Ks(e){return this.__data__.has(e)}var qs=Ks,Js=typeof gt=="object"&>&>.Object===Object&>,Lo=Js,Ys=Lo,Zs=typeof self=="object"&&self&&self.Object===Object&&self,Qs=Ys||Zs||Function("return this")(),ve=Qs,Xs=ve,Rs=Xs.Symbol,ot=Rs,zo=ot,Wo=Object.prototype,ea=Wo.hasOwnProperty,ta=Wo.toString,rt=zo?zo.toStringTag:void 0;function oa(e){var t=ea.call(e,rt),o=e[rt];try{e[rt]=void 0;var r=!0}catch(a){}var s=ta.call(e);return r&&(t?e[rt]=o:delete e[rt]),s}var ra=oa,na=Object.prototype,sa=na.toString;function aa(e){return sa.call(e)}var ia=aa,Uo=ot,la=ra,ca=ia,ua="[object Null]",da="[object Undefined]",Go=Uo?Uo.toStringTag:void 0;function pa(e){return e==null?e===void 0?da:ua:Go&&Go in Object(e)?la(e):ca(e)}var ze=pa;function ma(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var nt=ma,fa=ze,ha=nt,ya="[object AsyncFunction]",ga="[object Function]",va="[object GeneratorFunction]",ba="[object Proxy]";function xa(e){if(!ha(e))return!1;var t=fa(e);return t==ga||t==va||t==ya||t==ba}var Ho=xa,Ca=ve,wa=Ca["__core-js_shared__"],$a=wa,Yt=$a,Ko=function(){var e=/[^.]+$/.exec(Yt&&Yt.keys&&Yt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Sa(e){return!!Ko&&Ko in e}var ka=Sa,Aa=Function.prototype,Ta=Aa.toString;function Oa(e){if(e!=null){try{return Ta.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var qo=Oa,Fa=Ho,Ia=ka,Da=nt,Pa=qo,Na=/[\\^$.*+?()[\]{}|]/g,Ea=/^\[object .+?Constructor\]$/,Ma=Function.prototype,_a=Object.prototype,ja=Ma.toString,Ba=_a.hasOwnProperty,Va=RegExp("^"+ja.call(Ba).replace(Na,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function La(e){if(!Da(e)||Ia(e))return!1;var t=Fa(e)?Va:Ea;return t.test(Pa(e))}var za=La;function Wa(e,t){return e==null?void 0:e[t]}var Ua=Wa,Ga=za,Ha=Ua;function Ka(e,t){var o=Ha(e,t);return Ga(o)?o:void 0}var Fe=Ka,qa=Fe,Ja=ve,Ya=qa(Ja,"Map"),Zt=Ya,Za=Fe,Qa=Za(Object,"create"),xt=Qa,Jo=xt;function Xa(){this.__data__=Jo?Jo(null):{},this.size=0}var Ra=Xa;function ei(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var ti=ei,oi=xt,ri="__lodash_hash_undefined__",ni=Object.prototype,si=ni.hasOwnProperty;function ai(e){var t=this.__data__;if(oi){var o=t[e];return o===ri?void 0:o}return si.call(t,e)?t[e]:void 0}var ii=ai,li=xt,ci=Object.prototype,ui=ci.hasOwnProperty;function di(e){var t=this.__data__;return li?t[e]!==void 0:ui.call(t,e)}var pi=di,mi=xt,fi="__lodash_hash_undefined__";function hi(e,t){var o=this.__data__;return this.size+=this.has(e)?0:1,o[e]=mi&&t===void 0?fi:t,this}var yi=hi,gi=Ra,vi=ti,bi=ii,xi=pi,Ci=yi;function We(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var r=e[t];this.set(r[0],r[1])}}We.prototype.clear=gi,We.prototype.delete=vi,We.prototype.get=bi,We.prototype.has=xi,We.prototype.set=Ci;var wi=We,Yo=wi,$i=bt,Si=Zt;function ki(){this.size=0,this.__data__={hash:new Yo,map:new(Si||$i),string:new Yo}}var Ai=ki;function Ti(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Oi=Ti,Fi=Oi;function Ii(e,t){var o=e.__data__;return Fi(t)?o[typeof t=="string"?"string":"hash"]:o.map}var Ct=Ii,Di=Ct;function Pi(e){var t=Di(this,e).delete(e);return this.size-=t?1:0,t}var Ni=Pi,Ei=Ct;function Mi(e){return Ei(this,e).get(e)}var _i=Mi,ji=Ct;function Bi(e){return ji(this,e).has(e)}var Vi=Bi,Li=Ct;function zi(e,t){var o=Li(this,e),r=o.size;return o.set(e,t),this.size+=o.size==r?0:1,this}var Wi=zi,Ui=Ai,Gi=Ni,Hi=_i,Ki=Vi,qi=Wi;function Ue(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var r=e[t];this.set(r[0],r[1])}}Ue.prototype.clear=Ui,Ue.prototype.delete=Gi,Ue.prototype.get=Hi,Ue.prototype.has=Ki,Ue.prototype.set=qi;var Zo=Ue,Ji=bt,Yi=Zt,Zi=Zo,Qi=200;function Xi(e,t){var o=this.__data__;if(o instanceof Ji){var r=o.__data__;if(!Yi||r.length<Qi-1)return r.push([e,t]),this.size=++o.size,this;o=this.__data__=new Zi(r)}return o.set(e,t),this.size=o.size,this}var Ri=Xi,el=bt,tl=zs,ol=Us,rl=Hs,nl=qs,sl=Ri;function Ge(e){var t=this.__data__=new el(e);this.size=t.size}Ge.prototype.clear=tl,Ge.prototype.delete=ol,Ge.prototype.get=rl,Ge.prototype.has=nl,Ge.prototype.set=sl;var al=Ge;function il(e,t){for(var o=-1,r=e==null?0:e.length;++o<r&&t(e[o],o,e)!==!1;);return e}var ll=il,cl=Fe,ul=function(){try{var e=cl(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),Qo=ul,Xo=Qo;function dl(e,t,o){t=="__proto__"&&Xo?Xo(e,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):e[t]=o}var Ro=dl,pl=Ro,ml=Vo,fl=Object.prototype,hl=fl.hasOwnProperty;function yl(e,t,o){var r=e[t];(!(hl.call(e,t)&&ml(r,o))||o===void 0&&!(t in e))&&pl(e,t,o)}var er=yl,gl=er,vl=Ro;function bl(e,t,o,r){var s=!o;o||(o={});for(var a=-1,l=t.length;++a<l;){var c=t[a],u=r?r(o[c],e[c],c,o,e):void 0;u===void 0&&(u=e[c]),s?vl(o,c,u):gl(o,c,u)}return o}var st=bl;function xl(e,t){for(var o=-1,r=Array(e);++o<e;)r[o]=t(o);return r}var Cl=xl;function wl(e){return e!=null&&typeof e=="object"}var Ie=wl,$l=ze,Sl=Ie,kl="[object Arguments]";function Al(e){return Sl(e)&&$l(e)==kl}var Tl=Al,tr=Tl,Ol=Ie,or=Object.prototype,Fl=or.hasOwnProperty,Il=or.propertyIsEnumerable,Dl=tr(function(){return arguments}())?tr:function(e){return Ol(e)&&Fl.call(e,"callee")&&!Il.call(e,"callee")},rr=Dl,Pl=Array.isArray,De=Pl,wt={exports:{}};function Nl(){return!1}var El=Nl;wt.exports,function(e,t){var o=ve,r=El,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||r;e.exports=p}(wt,wt.exports);var nr=wt.exports,Ml=9007199254740991,_l=/^(?:0|[1-9]\d*)$/;function jl(e,t){var o=typeof e;return t=t==null?Ml:t,!!t&&(o=="number"||o!="symbol"&&_l.test(e))&&e>-1&&e%1==0&&e<t}var Bl=jl,Vl=9007199254740991;function Ll(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Vl}var sr=Ll,zl=ze,Wl=sr,Ul=Ie,Gl="[object Arguments]",Hl="[object Array]",Kl="[object Boolean]",ql="[object Date]",Jl="[object Error]",Yl="[object Function]",Zl="[object Map]",Ql="[object Number]",Xl="[object Object]",Rl="[object RegExp]",ec="[object Set]",tc="[object String]",oc="[object WeakMap]",rc="[object ArrayBuffer]",nc="[object DataView]",sc="[object Float32Array]",ac="[object Float64Array]",ic="[object Int8Array]",lc="[object Int16Array]",cc="[object Int32Array]",uc="[object Uint8Array]",dc="[object Uint8ClampedArray]",pc="[object Uint16Array]",mc="[object Uint32Array]",q={};q[sc]=q[ac]=q[ic]=q[lc]=q[cc]=q[uc]=q[dc]=q[pc]=q[mc]=!0,q[Gl]=q[Hl]=q[rc]=q[Kl]=q[nc]=q[ql]=q[Jl]=q[Yl]=q[Zl]=q[Ql]=q[Xl]=q[Rl]=q[ec]=q[tc]=q[oc]=!1;function fc(e){return Ul(e)&&Wl(e.length)&&!!q[zl(e)]}var hc=fc;function yc(e){return function(t){return e(t)}}var Qt=yc,$t={exports:{}};$t.exports,function(e,t){var o=Lo,r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===r,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}($t,$t.exports);var Xt=$t.exports,gc=hc,vc=Qt,ar=Xt,ir=ar&&ar.isTypedArray,bc=ir?vc(ir):gc,xc=bc,Cc=Cl,wc=rr,$c=De,Sc=nr,kc=Bl,Ac=xc,Tc=Object.prototype,Oc=Tc.hasOwnProperty;function Fc(e,t){var o=$c(e),r=!o&&wc(e),s=!o&&!r&&Sc(e),a=!o&&!r&&!s&&Ac(e),l=o||r||s||a,c=l?Cc(e.length,String):[],u=c.length;for(var p in e)(t||Oc.call(e,p))&&!(l&&(p=="length"||s&&(p=="offset"||p=="parent")||a&&(p=="buffer"||p=="byteLength"||p=="byteOffset")||kc(p,u)))&&c.push(p);return c}var lr=Fc,Ic=Object.prototype;function Dc(e){var t=e&&e.constructor,o=typeof t=="function"&&t.prototype||Ic;return e===o}var Rt=Dc;function Pc(e,t){return function(o){return e(t(o))}}var cr=Pc,Nc=cr,Ec=Nc(Object.keys,Object),Mc=Ec,_c=Rt,jc=Mc,Bc=Object.prototype,Vc=Bc.hasOwnProperty;function Lc(e){if(!_c(e))return jc(e);var t=[];for(var o in Object(e))Vc.call(e,o)&&o!="constructor"&&t.push(o);return t}var zc=Lc,Wc=Ho,Uc=sr;function Gc(e){return e!=null&&Uc(e.length)&&!Wc(e)}var ur=Gc,Hc=lr,Kc=zc,qc=ur;function Jc(e){return qc(e)?Hc(e):Kc(e)}var eo=Jc,Yc=st,Zc=eo;function Qc(e,t){return e&&Yc(t,Zc(t),e)}var Xc=Qc;function Rc(e){var t=[];if(e!=null)for(var o in Object(e))t.push(o);return t}var eu=Rc,tu=nt,ou=Rt,ru=eu,nu=Object.prototype,su=nu.hasOwnProperty;function au(e){if(!tu(e))return ru(e);var t=ou(e),o=[];for(var r in e)r=="constructor"&&(t||!su.call(e,r))||o.push(r);return o}var iu=au,lu=lr,cu=iu,uu=ur;function du(e){return uu(e)?lu(e,!0):cu(e)}var to=du,pu=st,mu=to;function fu(e,t){return e&&pu(t,mu(t),e)}var hu=fu,St={exports:{}};St.exports,function(e,t){var o=ve,r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===r,l=a?o.Buffer:void 0,c=l?l.allocUnsafe:void 0;function u(p,f){if(f)return p.slice();var g=p.length,b=c?c(g):new p.constructor(g);return p.copy(b),b}e.exports=u}(St,St.exports);var yu=St.exports;function gu(e,t){var o=-1,r=e.length;for(t||(t=Array(r));++o<r;)t[o]=e[o];return t}var vu=gu;function bu(e,t){for(var o=-1,r=e==null?0:e.length,s=0,a=[];++o<r;){var l=e[o];t(l,o,e)&&(a[s++]=l)}return a}var xu=bu;function Cu(){return[]}var dr=Cu,wu=xu,$u=dr,Su=Object.prototype,ku=Su.propertyIsEnumerable,pr=Object.getOwnPropertySymbols,Au=pr?function(e){return e==null?[]:(e=Object(e),wu(pr(e),function(t){return ku.call(e,t)}))}:$u,oo=Au,Tu=st,Ou=oo;function Fu(e,t){return Tu(e,Ou(e),t)}var Iu=Fu;function Du(e,t){for(var o=-1,r=t.length,s=e.length;++o<r;)e[s+o]=t[o];return e}var ro=Du,Pu=cr,Nu=Pu(Object.getPrototypeOf,Object),no=Nu,Eu=ro,Mu=no,_u=oo,ju=dr,Bu=Object.getOwnPropertySymbols,Vu=Bu?function(e){for(var t=[];e;)Eu(t,_u(e)),e=Mu(e);return t}:ju,mr=Vu,Lu=st,zu=mr;function Wu(e,t){return Lu(e,zu(e),t)}var Uu=Wu,Gu=ro,Hu=De;function Ku(e,t,o){var r=t(e);return Hu(e)?r:Gu(r,o(e))}var fr=Ku,qu=fr,Ju=oo,Yu=eo;function Zu(e){return qu(e,Yu,Ju)}var Qu=Zu,Xu=fr,Ru=mr,ed=to;function td(e){return Xu(e,ed,Ru)}var hr=td,od=Fe,rd=ve,nd=od(rd,"DataView"),sd=nd,ad=Fe,id=ve,ld=ad(id,"Promise"),cd=ld,ud=Fe,dd=ve,pd=ud(dd,"Set"),md=pd,fd=Fe,hd=ve,yd=fd(hd,"WeakMap"),gd=yd,so=sd,ao=Zt,io=cd,lo=md,co=gd,yr=ze,He=qo,gr="[object Map]",vd="[object Object]",vr="[object Promise]",br="[object Set]",xr="[object WeakMap]",Cr="[object DataView]",bd=He(so),xd=He(ao),Cd=He(io),wd=He(lo),$d=He(co),Pe=yr;(so&&Pe(new so(new ArrayBuffer(1)))!=Cr||ao&&Pe(new ao)!=gr||io&&Pe(io.resolve())!=vr||lo&&Pe(new lo)!=br||co&&Pe(new co)!=xr)&&(Pe=function(e){var t=yr(e),o=t==vd?e.constructor:void 0,r=o?He(o):"";if(r)switch(r){case bd:return Cr;case xd:return gr;case Cd:return vr;case wd:return br;case $d:return xr}return t});var uo=Pe,Sd=Object.prototype,kd=Sd.hasOwnProperty;function Ad(e){var t=e.length,o=new e.constructor(t);return t&&typeof e[0]=="string"&&kd.call(e,"index")&&(o.index=e.index,o.input=e.input),o}var Td=Ad,Od=ve,Fd=Od.Uint8Array,Id=Fd,wr=Id;function Dd(e){var t=new e.constructor(e.byteLength);return new wr(t).set(new wr(e)),t}var po=Dd,Pd=po;function Nd(e,t){var o=t?Pd(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.byteLength)}var Ed=Nd,Md=/\w*$/;function _d(e){var t=new e.constructor(e.source,Md.exec(e));return t.lastIndex=e.lastIndex,t}var jd=_d,$r=ot,Sr=$r?$r.prototype:void 0,kr=Sr?Sr.valueOf:void 0;function Bd(e){return kr?Object(kr.call(e)):{}}var Vd=Bd,Ld=po;function zd(e,t){var o=t?Ld(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.length)}var Wd=zd,Ud=po,Gd=Ed,Hd=jd,Kd=Vd,qd=Wd,Jd="[object Boolean]",Yd="[object Date]",Zd="[object Map]",Qd="[object Number]",Xd="[object RegExp]",Rd="[object Set]",ep="[object String]",tp="[object Symbol]",op="[object ArrayBuffer]",rp="[object DataView]",np="[object Float32Array]",sp="[object Float64Array]",ap="[object Int8Array]",ip="[object Int16Array]",lp="[object Int32Array]",cp="[object Uint8Array]",up="[object Uint8ClampedArray]",dp="[object Uint16Array]",pp="[object Uint32Array]";function mp(e,t,o){var r=e.constructor;switch(t){case op:return Ud(e);case Jd:case Yd:return new r(+e);case rp:return Gd(e,o);case np:case sp:case ap:case ip:case lp:case cp:case up:case dp:case pp:return qd(e,o);case Zd:return new r;case Qd:case ep:return new r(e);case Xd:return Hd(e);case Rd:return new r;case tp:return Kd(e)}}var fp=mp,hp=nt,Ar=Object.create,yp=function(){function e(){}return function(t){if(!hp(t))return{};if(Ar)return Ar(t);e.prototype=t;var o=new e;return e.prototype=void 0,o}}(),gp=yp,vp=gp,bp=no,xp=Rt;function Cp(e){return typeof e.constructor=="function"&&!xp(e)?vp(bp(e)):{}}var wp=Cp,$p=uo,Sp=Ie,kp="[object Map]";function Ap(e){return Sp(e)&&$p(e)==kp}var Tp=Ap,Op=Tp,Fp=Qt,Tr=Xt,Or=Tr&&Tr.isMap,Ip=Or?Fp(Or):Op,Dp=Ip,Pp=uo,Np=Ie,Ep="[object Set]";function Mp(e){return Np(e)&&Pp(e)==Ep}var _p=Mp,jp=_p,Bp=Qt,Fr=Xt,Ir=Fr&&Fr.isSet,Vp=Ir?Bp(Ir):jp,Lp=Vp,zp=al,Wp=ll,Up=er,Gp=Xc,Hp=hu,Kp=yu,qp=vu,Jp=Iu,Yp=Uu,Zp=Qu,Qp=hr,Xp=uo,Rp=Td,em=fp,tm=wp,om=De,rm=nr,nm=Dp,sm=nt,am=Lp,im=eo,lm=to,cm=1,um=2,dm=4,Dr="[object Arguments]",pm="[object Array]",mm="[object Boolean]",fm="[object Date]",hm="[object Error]",Pr="[object Function]",ym="[object GeneratorFunction]",gm="[object Map]",vm="[object Number]",Nr="[object Object]",bm="[object RegExp]",xm="[object Set]",Cm="[object String]",wm="[object Symbol]",$m="[object WeakMap]",Sm="[object ArrayBuffer]",km="[object DataView]",Am="[object Float32Array]",Tm="[object Float64Array]",Om="[object Int8Array]",Fm="[object Int16Array]",Im="[object Int32Array]",Dm="[object Uint8Array]",Pm="[object Uint8ClampedArray]",Nm="[object Uint16Array]",Em="[object Uint32Array]",H={};H[Dr]=H[pm]=H[Sm]=H[km]=H[mm]=H[fm]=H[Am]=H[Tm]=H[Om]=H[Fm]=H[Im]=H[gm]=H[vm]=H[Nr]=H[bm]=H[xm]=H[Cm]=H[wm]=H[Dm]=H[Pm]=H[Nm]=H[Em]=!0,H[hm]=H[Pr]=H[$m]=!1;function kt(e,t,o,r,s,a){var l,c=t&cm,u=t&um,p=t&dm;if(o&&(l=s?o(e,r,s,a):o(e)),l!==void 0)return l;if(!sm(e))return e;var f=om(e);if(f){if(l=Rp(e),!c)return qp(e,l)}else{var g=Xp(e),b=g==Pr||g==ym;if(rm(e))return Kp(e,c);if(g==Nr||g==Dr||b&&!s){if(l=u||b?{}:tm(e),!c)return u?Yp(e,Hp(l,e)):Jp(e,Gp(l,e))}else{if(!H[g])return s?e:{};l=em(e,g,c)}}a||(a=new zp);var h=a.get(e);if(h)return h;a.set(e,l),am(e)?e.forEach(function(w){l.add(kt(w,t,o,w,e,a))}):nm(e)&&e.forEach(function(w,T){l.set(T,kt(w,t,o,T,e,a))});var m=p?u?Qp:Zp:u?lm:im,k=f?void 0:m(e);return Wp(k||e,function(w,T){k&&(T=w,w=e[T]),Up(l,T,kt(w,t,o,T,e,a))}),l}var Mm=kt,_m=ze,jm=Ie,Bm="[object Symbol]";function Vm(e){return typeof e=="symbol"||jm(e)&&_m(e)==Bm}var mo=Vm,Lm=De,zm=mo,Wm=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Um=/^\w*$/;function Gm(e,t){if(Lm(e))return!1;var o=typeof e;return o=="number"||o=="symbol"||o=="boolean"||e==null||zm(e)?!0:Um.test(e)||!Wm.test(e)||t!=null&&e in Object(t)}var Hm=Gm,Er=Zo,Km="Expected a function";function fo(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Km);var o=function(){var r=arguments,s=t?t.apply(this,r):r[0],a=o.cache;if(a.has(s))return a.get(s);var l=e.apply(this,r);return o.cache=a.set(s,l)||a,l};return o.cache=new(fo.Cache||Er),o}fo.Cache=Er;var qm=fo,Jm=qm,Ym=500;function Zm(e){var t=Jm(e,function(r){return o.size===Ym&&o.clear(),r}),o=t.cache;return t}var Qm=Zm,Xm=Qm,Rm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ef=/\\(\\)?/g,tf=Xm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Rm,function(o,r,s,a){t.push(s?a.replace(ef,"$1"):r||o)}),t}),of=tf,Mr=ot,rf=Bo,nf=De,sf=mo,af=1/0,_r=Mr?Mr.prototype:void 0,jr=_r?_r.toString:void 0;function Br(e){if(typeof e=="string")return e;if(nf(e))return rf(e,Br)+"";if(sf(e))return jr?jr.call(e):"";var t=e+"";return t=="0"&&1/e==-af?"-0":t}var lf=Br,cf=lf;function uf(e){return e==null?"":cf(e)}var df=uf,pf=De,mf=Hm,ff=of,hf=df;function yf(e,t){return pf(e)?e:mf(e,t)?[e]:ff(hf(e))}var ho=yf;function gf(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var vf=gf,bf=mo,xf=1/0;function Cf(e){if(typeof e=="string"||bf(e))return e;var t=e+"";return t=="0"&&1/e==-xf?"-0":t}var Vr=Cf,wf=ho,$f=Vr;function Sf(e,t){t=wf(t,e);for(var o=0,r=t.length;e!=null&&o<r;)e=e[$f(t[o++])];return o&&o==r?e:void 0}var kf=Sf;function Af(e,t,o){var r=-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);++r<s;)a[r]=e[r+t];return a}var Tf=Af,Of=kf,Ff=Tf;function If(e,t){return t.length<2?e:Of(e,Ff(t,0,-1))}var Df=If,Pf=ho,Nf=vf,Ef=Df,Mf=Vr;function _f(e,t){return t=Pf(t,e),e=Ef(e,t),e==null||delete e[Mf(Nf(t))]}var jf=_f,Bf=ze,Vf=no,Lf=Ie,zf="[object Object]",Wf=Function.prototype,Uf=Object.prototype,Lr=Wf.toString,Gf=Uf.hasOwnProperty,Hf=Lr.call(Object);function Kf(e){if(!Lf(e)||Bf(e)!=zf)return!1;var t=Vf(e);if(t===null)return!0;var o=Gf.call(t,"constructor")&&t.constructor;return typeof o=="function"&&o instanceof o&&Lr.call(o)==Hf}var qf=Kf,Jf=qf;function Yf(e){return Jf(e)?void 0:e}var Zf=Yf,zr=ot,Qf=rr,Xf=De,Wr=zr?zr.isConcatSpreadable:void 0;function Rf(e){return Xf(e)||Qf(e)||!!(Wr&&e&&e[Wr])}var eh=Rf,th=ro,oh=eh;function Ur(e,t,o,r,s){var a=-1,l=e.length;for(o||(o=oh),s||(s=[]);++a<l;){var c=e[a];t>0&&o(c)?t>1?Ur(c,t-1,o,r,s):th(s,c):r||(s[s.length]=c)}return s}var rh=Ur,nh=rh;function sh(e){var t=e==null?0:e.length;return t?nh(e,1):[]}var ah=sh;function ih(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 lh=ih,ch=lh,Gr=Math.max;function uh(e,t,o){return t=Gr(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=Gr(r.length-t,0),l=Array(a);++s<a;)l[s]=r[t+s];s=-1;for(var c=Array(t+1);++s<t;)c[s]=r[s];return c[t]=o(l),ch(e,this,c)}}var dh=uh;function ph(e){return function(){return e}}var mh=ph;function fh(e){return e}var hh=fh,yh=mh,Hr=Qo,gh=hh,vh=Hr?function(e,t){return Hr(e,"toString",{configurable:!0,enumerable:!1,value:yh(t),writable:!0})}:gh,bh=vh,xh=800,Ch=16,wh=Date.now;function $h(e){var t=0,o=0;return function(){var r=wh(),s=Ch-(r-o);if(o=r,s>0){if(++t>=xh)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Sh=$h,kh=bh,Ah=Sh,Th=Ah(kh),Oh=Th,Fh=ah,Ih=dh,Dh=Oh;function Ph(e){return Dh(Ih(e,void 0,Fh),e+"")}var Nh=Ph,Eh=Bo,Mh=Mm,_h=jf,jh=ho,Bh=st,Vh=Zf,Lh=Nh,zh=hr,Wh=1,Uh=2,Gh=4,Hh=Lh(function(e,t){var o={};if(e==null)return o;var r=!1;t=Eh(t,function(a){return a=jh(a,e),r||(r=a.length>1),a}),Bh(e,zh(e),o),r&&(o=Mh(o,Wh|Uh|Gh,Vh));for(var s=t.length;s--;)_h(o,t[s]);return o}),Kh=Hh;const qh=Eo(Kh),Kr={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({},Be),{title:`{{t("Associations to use", { ns: "${d}" })}}`})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:r}=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:r}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:_e,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{},useActionTriggerable:!0};function Jh({filterByTk:e,form:t,getField:o,actionFields:r}){if(e&&r){const s=Object.keys(t.values).filter(a=>{const l=o(a);return!r.includes(a)&&["hasOne","hasMany","belongsTo","belongsToMany"].includes(l==null?void 0:l.type)});return qh(v({},t.values),s)}return t.values}function Yh(){var _;const e=i.useAPIClient(),t=I.useForm(),{field:o,resource:r,__parent:s}=i.useBlockRequestContext(),{setVisible:a,fieldSchema:l}=i.useActionContext(),c=he.useNavigate(),u=I.useFieldSchema(),p=I.useField(),{fields:f,getField:g,getTreeParentField:b}=i.useCollection(),h=i.useCompile(),m=i.useFilterByTk(),k=i.useRecord(),w=i.useCurrentUserContext(),{modal:T}=x.App.useApp(),{getActiveFieldsName:$}=i.useFormActiveFields()||{},P=(_=w==null?void 0:w.data)==null?void 0:_.data,M=p.componentProps.filterKeys||[];return{onClick(){return J(this,null,function*(){var L,ie,Y,Q,R,ne;const{assignedValues:N={},onSuccess:A,overwriteValues:D,skipValidator:U,triggerWorkflows:V}=(L=u==null?void 0:u["x-action-settings"])!=null?L:{},Z=(ie=l==null?void 0:l["x-component-props"])==null?void 0:ie.addChild,E=X.parse(N)({currentTime:new Date,currentRecord:k,currentUser:P,$user:P,$nRecord:k,$nForm:t.values,$nDate:{now:new Date}});U||(yield t.submit());const j=Jh({filterByTk:m,form:t,getField:g,actionFields:($==null?void 0:$("form"))||[]});if(Z){const ue=b();j[(Y=ue==null?void 0:ue.name)!=null?Y:"parent"]=k,j[(Q=ue==null?void 0:ue.foreignKey)!=null?Q:"parentId"]=k.id}p.data=o.data||{},p.data.loading=!0;try{const ue=yield e.resource("workflows").trigger({values:v(v(v({},j),D),E),filterKeys:M,triggerWorkflows:V!=null&&V.length?V.map(me=>[me.workflowKey,me.context].filter(Boolean).join("!")).join(","):void 0});if(p.data.loading=!1,p.data.data=ue,(ne=(R=s==null?void 0:s.service)==null?void 0:R.refresh)==null||ne.call(R),a==null||a(!1),!(A!=null&&A.successMessage))return;A!=null&&A.manualClose?T.success({title:h(A==null?void 0:A.successMessage),onOk:()=>J(this,null,function*(){yield t.reset(),A!=null&&A.redirecting&&(A!=null&&A.redirectTo)&&(X.isURL(A.redirectTo)?window.location.href=A.redirectTo:c(A.redirectTo))})}):x.message.success(h(A==null?void 0:A.successMessage))}catch(ue){p.data.loading=!1}})}}}const Ne={STATIC:0,COLLECTION_FIELD:1};function Zh(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function qr({value:e,onChange:t}){const{t:o}=oe.useTranslation(),[r,s]=y.useState(e.offset?e.offset/Math.abs(e.offset):0);return n.jsxs("fieldset",{className:i.css`
|
|
400
|
+
`}},dynamicComponent:"FilterDynamicComponent"}},ds={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"}}},ps={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},Be={type:"array",title:`{{t("Preload associations", { ns: "${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}=F.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Ve={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},ms=[{label:`{{t("After record added", { ns: "${d}" })}}`,value:Ve.CREATED},{label:`{{t("After record updated", { ns: "${d}" })}}`,value:Ve.UPDATED},{label:`{{t("After record added or updated", { ns: "${d}" })}}`,value:Ve.SAVED},{label:`{{t("After record deleted", { ns: "${d}" })}}`,value:Ve.DELETED}],jo={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:ms,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] & ${Ve.UPDATED})}}`}}}]},condition:C(v({},je),{title:`{{t("Only triggers when match conditions", { ns: "${d}" })}}`,"x-component-props":{useProps:je["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:C(v({},Be),{"x-reactions":[...Be["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ve.DELETED})}}`}}}]})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FieldsSelect:qt},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:r}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:N("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:r}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:_e,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function fs(e,t){for(var o=-1,r=e==null?0:e.length,s=Array(r);++o<r;)s[o]=t(e[o],o,e);return s}var Bo=fs;function hs(){this.__data__=[],this.size=0}var ys=hs;function gs(e,t){return e===t||e!==e&&t!==t}var Vo=gs,vs=Vo;function bs(e,t){for(var o=e.length;o--;)if(vs(e[o][0],t))return o;return-1}var vt=bs,xs=vt,Cs=Array.prototype,ws=Cs.splice;function $s(e){var t=this.__data__,o=xs(t,e);if(o<0)return!1;var r=t.length-1;return o==r?t.pop():ws.call(t,o,1),--this.size,!0}var Ss=$s,ks=vt;function As(e){var t=this.__data__,o=ks(t,e);return o<0?void 0:t[o][1]}var Ts=As,Os=vt;function Fs(e){return Os(this.__data__,e)>-1}var Is=Fs,Ds=vt;function Ns(e,t){var o=this.__data__,r=Ds(o,e);return r<0?(++this.size,o.push([e,t])):o[r][1]=t,this}var Ps=Ns,Es=ys,Ms=Ss,_s=Ts,js=Is,Bs=Ps;function Le(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var r=e[t];this.set(r[0],r[1])}}Le.prototype.clear=Es,Le.prototype.delete=Ms,Le.prototype.get=_s,Le.prototype.has=js,Le.prototype.set=Bs;var bt=Le,Vs=bt;function Ls(){this.__data__=new Vs,this.size=0}var zs=Ls;function Ws(e){var t=this.__data__,o=t.delete(e);return this.size=t.size,o}var Us=Ws;function Gs(e){return this.__data__.get(e)}var Hs=Gs;function Ks(e){return this.__data__.has(e)}var qs=Ks,Js=typeof gt=="object"&>&>.Object===Object&>,Lo=Js,Ys=Lo,Zs=typeof self=="object"&&self&&self.Object===Object&&self,Qs=Ys||Zs||Function("return this")(),ve=Qs,Xs=ve,Rs=Xs.Symbol,ot=Rs,zo=ot,Wo=Object.prototype,ea=Wo.hasOwnProperty,ta=Wo.toString,rt=zo?zo.toStringTag:void 0;function oa(e){var t=ea.call(e,rt),o=e[rt];try{e[rt]=void 0;var r=!0}catch(a){}var s=ta.call(e);return r&&(t?e[rt]=o:delete e[rt]),s}var ra=oa,na=Object.prototype,sa=na.toString;function aa(e){return sa.call(e)}var ia=aa,Uo=ot,la=ra,ca=ia,ua="[object Null]",da="[object Undefined]",Go=Uo?Uo.toStringTag:void 0;function pa(e){return e==null?e===void 0?da:ua:Go&&Go in Object(e)?la(e):ca(e)}var ze=pa;function ma(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var nt=ma,fa=ze,ha=nt,ya="[object AsyncFunction]",ga="[object Function]",va="[object GeneratorFunction]",ba="[object Proxy]";function xa(e){if(!ha(e))return!1;var t=fa(e);return t==ga||t==va||t==ya||t==ba}var Ho=xa,Ca=ve,wa=Ca["__core-js_shared__"],$a=wa,Yt=$a,Ko=function(){var e=/[^.]+$/.exec(Yt&&Yt.keys&&Yt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Sa(e){return!!Ko&&Ko in e}var ka=Sa,Aa=Function.prototype,Ta=Aa.toString;function Oa(e){if(e!=null){try{return Ta.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var qo=Oa,Fa=Ho,Ia=ka,Da=nt,Na=qo,Pa=/[\\^$.*+?()[\]{}|]/g,Ea=/^\[object .+?Constructor\]$/,Ma=Function.prototype,_a=Object.prototype,ja=Ma.toString,Ba=_a.hasOwnProperty,Va=RegExp("^"+ja.call(Ba).replace(Pa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function La(e){if(!Da(e)||Ia(e))return!1;var t=Fa(e)?Va:Ea;return t.test(Na(e))}var za=La;function Wa(e,t){return e==null?void 0:e[t]}var Ua=Wa,Ga=za,Ha=Ua;function Ka(e,t){var o=Ha(e,t);return Ga(o)?o:void 0}var Fe=Ka,qa=Fe,Ja=ve,Ya=qa(Ja,"Map"),Zt=Ya,Za=Fe,Qa=Za(Object,"create"),xt=Qa,Jo=xt;function Xa(){this.__data__=Jo?Jo(null):{},this.size=0}var Ra=Xa;function ei(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var ti=ei,oi=xt,ri="__lodash_hash_undefined__",ni=Object.prototype,si=ni.hasOwnProperty;function ai(e){var t=this.__data__;if(oi){var o=t[e];return o===ri?void 0:o}return si.call(t,e)?t[e]:void 0}var ii=ai,li=xt,ci=Object.prototype,ui=ci.hasOwnProperty;function di(e){var t=this.__data__;return li?t[e]!==void 0:ui.call(t,e)}var pi=di,mi=xt,fi="__lodash_hash_undefined__";function hi(e,t){var o=this.__data__;return this.size+=this.has(e)?0:1,o[e]=mi&&t===void 0?fi:t,this}var yi=hi,gi=Ra,vi=ti,bi=ii,xi=pi,Ci=yi;function We(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var r=e[t];this.set(r[0],r[1])}}We.prototype.clear=gi,We.prototype.delete=vi,We.prototype.get=bi,We.prototype.has=xi,We.prototype.set=Ci;var wi=We,Yo=wi,$i=bt,Si=Zt;function ki(){this.size=0,this.__data__={hash:new Yo,map:new(Si||$i),string:new Yo}}var Ai=ki;function Ti(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Oi=Ti,Fi=Oi;function Ii(e,t){var o=e.__data__;return Fi(t)?o[typeof t=="string"?"string":"hash"]:o.map}var Ct=Ii,Di=Ct;function Ni(e){var t=Di(this,e).delete(e);return this.size-=t?1:0,t}var Pi=Ni,Ei=Ct;function Mi(e){return Ei(this,e).get(e)}var _i=Mi,ji=Ct;function Bi(e){return ji(this,e).has(e)}var Vi=Bi,Li=Ct;function zi(e,t){var o=Li(this,e),r=o.size;return o.set(e,t),this.size+=o.size==r?0:1,this}var Wi=zi,Ui=Ai,Gi=Pi,Hi=_i,Ki=Vi,qi=Wi;function Ue(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var r=e[t];this.set(r[0],r[1])}}Ue.prototype.clear=Ui,Ue.prototype.delete=Gi,Ue.prototype.get=Hi,Ue.prototype.has=Ki,Ue.prototype.set=qi;var Zo=Ue,Ji=bt,Yi=Zt,Zi=Zo,Qi=200;function Xi(e,t){var o=this.__data__;if(o instanceof Ji){var r=o.__data__;if(!Yi||r.length<Qi-1)return r.push([e,t]),this.size=++o.size,this;o=this.__data__=new Zi(r)}return o.set(e,t),this.size=o.size,this}var Ri=Xi,el=bt,tl=zs,ol=Us,rl=Hs,nl=qs,sl=Ri;function Ge(e){var t=this.__data__=new el(e);this.size=t.size}Ge.prototype.clear=tl,Ge.prototype.delete=ol,Ge.prototype.get=rl,Ge.prototype.has=nl,Ge.prototype.set=sl;var al=Ge;function il(e,t){for(var o=-1,r=e==null?0:e.length;++o<r&&t(e[o],o,e)!==!1;);return e}var ll=il,cl=Fe,ul=function(){try{var e=cl(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),Qo=ul,Xo=Qo;function dl(e,t,o){t=="__proto__"&&Xo?Xo(e,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):e[t]=o}var Ro=dl,pl=Ro,ml=Vo,fl=Object.prototype,hl=fl.hasOwnProperty;function yl(e,t,o){var r=e[t];(!(hl.call(e,t)&&ml(r,o))||o===void 0&&!(t in e))&&pl(e,t,o)}var er=yl,gl=er,vl=Ro;function bl(e,t,o,r){var s=!o;o||(o={});for(var a=-1,l=t.length;++a<l;){var c=t[a],u=r?r(o[c],e[c],c,o,e):void 0;u===void 0&&(u=e[c]),s?vl(o,c,u):gl(o,c,u)}return o}var st=bl;function xl(e,t){for(var o=-1,r=Array(e);++o<e;)r[o]=t(o);return r}var Cl=xl;function wl(e){return e!=null&&typeof e=="object"}var Ie=wl,$l=ze,Sl=Ie,kl="[object Arguments]";function Al(e){return Sl(e)&&$l(e)==kl}var Tl=Al,tr=Tl,Ol=Ie,or=Object.prototype,Fl=or.hasOwnProperty,Il=or.propertyIsEnumerable,Dl=tr(function(){return arguments}())?tr:function(e){return Ol(e)&&Fl.call(e,"callee")&&!Il.call(e,"callee")},rr=Dl,Nl=Array.isArray,De=Nl,wt={exports:{}};function Pl(){return!1}var El=Pl;wt.exports,function(e,t){var o=ve,r=El,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||r;e.exports=p}(wt,wt.exports);var nr=wt.exports,Ml=9007199254740991,_l=/^(?:0|[1-9]\d*)$/;function jl(e,t){var o=typeof e;return t=t==null?Ml:t,!!t&&(o=="number"||o!="symbol"&&_l.test(e))&&e>-1&&e%1==0&&e<t}var Bl=jl,Vl=9007199254740991;function Ll(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Vl}var sr=Ll,zl=ze,Wl=sr,Ul=Ie,Gl="[object Arguments]",Hl="[object Array]",Kl="[object Boolean]",ql="[object Date]",Jl="[object Error]",Yl="[object Function]",Zl="[object Map]",Ql="[object Number]",Xl="[object Object]",Rl="[object RegExp]",ec="[object Set]",tc="[object String]",oc="[object WeakMap]",rc="[object ArrayBuffer]",nc="[object DataView]",sc="[object Float32Array]",ac="[object Float64Array]",ic="[object Int8Array]",lc="[object Int16Array]",cc="[object Int32Array]",uc="[object Uint8Array]",dc="[object Uint8ClampedArray]",pc="[object Uint16Array]",mc="[object Uint32Array]",q={};q[sc]=q[ac]=q[ic]=q[lc]=q[cc]=q[uc]=q[dc]=q[pc]=q[mc]=!0,q[Gl]=q[Hl]=q[rc]=q[Kl]=q[nc]=q[ql]=q[Jl]=q[Yl]=q[Zl]=q[Ql]=q[Xl]=q[Rl]=q[ec]=q[tc]=q[oc]=!1;function fc(e){return Ul(e)&&Wl(e.length)&&!!q[zl(e)]}var hc=fc;function yc(e){return function(t){return e(t)}}var Qt=yc,$t={exports:{}};$t.exports,function(e,t){var o=Lo,r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===r,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}($t,$t.exports);var Xt=$t.exports,gc=hc,vc=Qt,ar=Xt,ir=ar&&ar.isTypedArray,bc=ir?vc(ir):gc,xc=bc,Cc=Cl,wc=rr,$c=De,Sc=nr,kc=Bl,Ac=xc,Tc=Object.prototype,Oc=Tc.hasOwnProperty;function Fc(e,t){var o=$c(e),r=!o&&wc(e),s=!o&&!r&&Sc(e),a=!o&&!r&&!s&&Ac(e),l=o||r||s||a,c=l?Cc(e.length,String):[],u=c.length;for(var p in e)(t||Oc.call(e,p))&&!(l&&(p=="length"||s&&(p=="offset"||p=="parent")||a&&(p=="buffer"||p=="byteLength"||p=="byteOffset")||kc(p,u)))&&c.push(p);return c}var lr=Fc,Ic=Object.prototype;function Dc(e){var t=e&&e.constructor,o=typeof t=="function"&&t.prototype||Ic;return e===o}var Rt=Dc;function Nc(e,t){return function(o){return e(t(o))}}var cr=Nc,Pc=cr,Ec=Pc(Object.keys,Object),Mc=Ec,_c=Rt,jc=Mc,Bc=Object.prototype,Vc=Bc.hasOwnProperty;function Lc(e){if(!_c(e))return jc(e);var t=[];for(var o in Object(e))Vc.call(e,o)&&o!="constructor"&&t.push(o);return t}var zc=Lc,Wc=Ho,Uc=sr;function Gc(e){return e!=null&&Uc(e.length)&&!Wc(e)}var ur=Gc,Hc=lr,Kc=zc,qc=ur;function Jc(e){return qc(e)?Hc(e):Kc(e)}var eo=Jc,Yc=st,Zc=eo;function Qc(e,t){return e&&Yc(t,Zc(t),e)}var Xc=Qc;function Rc(e){var t=[];if(e!=null)for(var o in Object(e))t.push(o);return t}var eu=Rc,tu=nt,ou=Rt,ru=eu,nu=Object.prototype,su=nu.hasOwnProperty;function au(e){if(!tu(e))return ru(e);var t=ou(e),o=[];for(var r in e)r=="constructor"&&(t||!su.call(e,r))||o.push(r);return o}var iu=au,lu=lr,cu=iu,uu=ur;function du(e){return uu(e)?lu(e,!0):cu(e)}var to=du,pu=st,mu=to;function fu(e,t){return e&&pu(t,mu(t),e)}var hu=fu,St={exports:{}};St.exports,function(e,t){var o=ve,r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===r,l=a?o.Buffer:void 0,c=l?l.allocUnsafe:void 0;function u(p,f){if(f)return p.slice();var g=p.length,x=c?c(g):new p.constructor(g);return p.copy(x),x}e.exports=u}(St,St.exports);var yu=St.exports;function gu(e,t){var o=-1,r=e.length;for(t||(t=Array(r));++o<r;)t[o]=e[o];return t}var vu=gu;function bu(e,t){for(var o=-1,r=e==null?0:e.length,s=0,a=[];++o<r;){var l=e[o];t(l,o,e)&&(a[s++]=l)}return a}var xu=bu;function Cu(){return[]}var dr=Cu,wu=xu,$u=dr,Su=Object.prototype,ku=Su.propertyIsEnumerable,pr=Object.getOwnPropertySymbols,Au=pr?function(e){return e==null?[]:(e=Object(e),wu(pr(e),function(t){return ku.call(e,t)}))}:$u,oo=Au,Tu=st,Ou=oo;function Fu(e,t){return Tu(e,Ou(e),t)}var Iu=Fu;function Du(e,t){for(var o=-1,r=t.length,s=e.length;++o<r;)e[s+o]=t[o];return e}var ro=Du,Nu=cr,Pu=Nu(Object.getPrototypeOf,Object),no=Pu,Eu=ro,Mu=no,_u=oo,ju=dr,Bu=Object.getOwnPropertySymbols,Vu=Bu?function(e){for(var t=[];e;)Eu(t,_u(e)),e=Mu(e);return t}:ju,mr=Vu,Lu=st,zu=mr;function Wu(e,t){return Lu(e,zu(e),t)}var Uu=Wu,Gu=ro,Hu=De;function Ku(e,t,o){var r=t(e);return Hu(e)?r:Gu(r,o(e))}var fr=Ku,qu=fr,Ju=oo,Yu=eo;function Zu(e){return qu(e,Yu,Ju)}var Qu=Zu,Xu=fr,Ru=mr,ed=to;function td(e){return Xu(e,ed,Ru)}var hr=td,od=Fe,rd=ve,nd=od(rd,"DataView"),sd=nd,ad=Fe,id=ve,ld=ad(id,"Promise"),cd=ld,ud=Fe,dd=ve,pd=ud(dd,"Set"),md=pd,fd=Fe,hd=ve,yd=fd(hd,"WeakMap"),gd=yd,so=sd,ao=Zt,io=cd,lo=md,co=gd,yr=ze,He=qo,gr="[object Map]",vd="[object Object]",vr="[object Promise]",br="[object Set]",xr="[object WeakMap]",Cr="[object DataView]",bd=He(so),xd=He(ao),Cd=He(io),wd=He(lo),$d=He(co),Ne=yr;(so&&Ne(new so(new ArrayBuffer(1)))!=Cr||ao&&Ne(new ao)!=gr||io&&Ne(io.resolve())!=vr||lo&&Ne(new lo)!=br||co&&Ne(new co)!=xr)&&(Ne=function(e){var t=yr(e),o=t==vd?e.constructor:void 0,r=o?He(o):"";if(r)switch(r){case bd:return Cr;case xd:return gr;case Cd:return vr;case wd:return br;case $d:return xr}return t});var uo=Ne,Sd=Object.prototype,kd=Sd.hasOwnProperty;function Ad(e){var t=e.length,o=new e.constructor(t);return t&&typeof e[0]=="string"&&kd.call(e,"index")&&(o.index=e.index,o.input=e.input),o}var Td=Ad,Od=ve,Fd=Od.Uint8Array,Id=Fd,wr=Id;function Dd(e){var t=new e.constructor(e.byteLength);return new wr(t).set(new wr(e)),t}var po=Dd,Nd=po;function Pd(e,t){var o=t?Nd(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.byteLength)}var Ed=Pd,Md=/\w*$/;function _d(e){var t=new e.constructor(e.source,Md.exec(e));return t.lastIndex=e.lastIndex,t}var jd=_d,$r=ot,Sr=$r?$r.prototype:void 0,kr=Sr?Sr.valueOf:void 0;function Bd(e){return kr?Object(kr.call(e)):{}}var Vd=Bd,Ld=po;function zd(e,t){var o=t?Ld(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.length)}var Wd=zd,Ud=po,Gd=Ed,Hd=jd,Kd=Vd,qd=Wd,Jd="[object Boolean]",Yd="[object Date]",Zd="[object Map]",Qd="[object Number]",Xd="[object RegExp]",Rd="[object Set]",ep="[object String]",tp="[object Symbol]",op="[object ArrayBuffer]",rp="[object DataView]",np="[object Float32Array]",sp="[object Float64Array]",ap="[object Int8Array]",ip="[object Int16Array]",lp="[object Int32Array]",cp="[object Uint8Array]",up="[object Uint8ClampedArray]",dp="[object Uint16Array]",pp="[object Uint32Array]";function mp(e,t,o){var r=e.constructor;switch(t){case op:return Ud(e);case Jd:case Yd:return new r(+e);case rp:return Gd(e,o);case np:case sp:case ap:case ip:case lp:case cp:case up:case dp:case pp:return qd(e,o);case Zd:return new r;case Qd:case ep:return new r(e);case Xd:return Hd(e);case Rd:return new r;case tp:return Kd(e)}}var fp=mp,hp=nt,Ar=Object.create,yp=function(){function e(){}return function(t){if(!hp(t))return{};if(Ar)return Ar(t);e.prototype=t;var o=new e;return e.prototype=void 0,o}}(),gp=yp,vp=gp,bp=no,xp=Rt;function Cp(e){return typeof e.constructor=="function"&&!xp(e)?vp(bp(e)):{}}var wp=Cp,$p=uo,Sp=Ie,kp="[object Map]";function Ap(e){return Sp(e)&&$p(e)==kp}var Tp=Ap,Op=Tp,Fp=Qt,Tr=Xt,Or=Tr&&Tr.isMap,Ip=Or?Fp(Or):Op,Dp=Ip,Np=uo,Pp=Ie,Ep="[object Set]";function Mp(e){return Pp(e)&&Np(e)==Ep}var _p=Mp,jp=_p,Bp=Qt,Fr=Xt,Ir=Fr&&Fr.isSet,Vp=Ir?Bp(Ir):jp,Lp=Vp,zp=al,Wp=ll,Up=er,Gp=Xc,Hp=hu,Kp=yu,qp=vu,Jp=Iu,Yp=Uu,Zp=Qu,Qp=hr,Xp=uo,Rp=Td,em=fp,tm=wp,om=De,rm=nr,nm=Dp,sm=nt,am=Lp,im=eo,lm=to,cm=1,um=2,dm=4,Dr="[object Arguments]",pm="[object Array]",mm="[object Boolean]",fm="[object Date]",hm="[object Error]",Nr="[object Function]",ym="[object GeneratorFunction]",gm="[object Map]",vm="[object Number]",Pr="[object Object]",bm="[object RegExp]",xm="[object Set]",Cm="[object String]",wm="[object Symbol]",$m="[object WeakMap]",Sm="[object ArrayBuffer]",km="[object DataView]",Am="[object Float32Array]",Tm="[object Float64Array]",Om="[object Int8Array]",Fm="[object Int16Array]",Im="[object Int32Array]",Dm="[object Uint8Array]",Nm="[object Uint8ClampedArray]",Pm="[object Uint16Array]",Em="[object Uint32Array]",H={};H[Dr]=H[pm]=H[Sm]=H[km]=H[mm]=H[fm]=H[Am]=H[Tm]=H[Om]=H[Fm]=H[Im]=H[gm]=H[vm]=H[Pr]=H[bm]=H[xm]=H[Cm]=H[wm]=H[Dm]=H[Nm]=H[Pm]=H[Em]=!0,H[hm]=H[Nr]=H[$m]=!1;function kt(e,t,o,r,s,a){var l,c=t&cm,u=t&um,p=t&dm;if(o&&(l=s?o(e,r,s,a):o(e)),l!==void 0)return l;if(!sm(e))return e;var f=om(e);if(f){if(l=Rp(e),!c)return qp(e,l)}else{var g=Xp(e),x=g==Nr||g==ym;if(rm(e))return Kp(e,c);if(g==Pr||g==Dr||x&&!s){if(l=u||x?{}:tm(e),!c)return u?Yp(e,Hp(l,e)):Jp(e,Gp(l,e))}else{if(!H[g])return s?e:{};l=em(e,g,c)}}a||(a=new zp);var h=a.get(e);if(h)return h;a.set(e,l),am(e)?e.forEach(function(w){l.add(kt(w,t,o,w,e,a))}):nm(e)&&e.forEach(function(w,T){l.set(T,kt(w,t,o,T,e,a))});var m=p?u?Qp:Zp:u?lm:im,k=f?void 0:m(e);return Wp(k||e,function(w,T){k&&(T=w,w=e[T]),Up(l,T,kt(w,t,o,T,e,a))}),l}var Mm=kt,_m=ze,jm=Ie,Bm="[object Symbol]";function Vm(e){return typeof e=="symbol"||jm(e)&&_m(e)==Bm}var mo=Vm,Lm=De,zm=mo,Wm=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Um=/^\w*$/;function Gm(e,t){if(Lm(e))return!1;var o=typeof e;return o=="number"||o=="symbol"||o=="boolean"||e==null||zm(e)?!0:Um.test(e)||!Wm.test(e)||t!=null&&e in Object(t)}var Hm=Gm,Er=Zo,Km="Expected a function";function fo(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Km);var o=function(){var r=arguments,s=t?t.apply(this,r):r[0],a=o.cache;if(a.has(s))return a.get(s);var l=e.apply(this,r);return o.cache=a.set(s,l)||a,l};return o.cache=new(fo.Cache||Er),o}fo.Cache=Er;var qm=fo,Jm=qm,Ym=500;function Zm(e){var t=Jm(e,function(r){return o.size===Ym&&o.clear(),r}),o=t.cache;return t}var Qm=Zm,Xm=Qm,Rm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ef=/\\(\\)?/g,tf=Xm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Rm,function(o,r,s,a){t.push(s?a.replace(ef,"$1"):r||o)}),t}),of=tf,Mr=ot,rf=Bo,nf=De,sf=mo,af=1/0,_r=Mr?Mr.prototype:void 0,jr=_r?_r.toString:void 0;function Br(e){if(typeof e=="string")return e;if(nf(e))return rf(e,Br)+"";if(sf(e))return jr?jr.call(e):"";var t=e+"";return t=="0"&&1/e==-af?"-0":t}var lf=Br,cf=lf;function uf(e){return e==null?"":cf(e)}var df=uf,pf=De,mf=Hm,ff=of,hf=df;function yf(e,t){return pf(e)?e:mf(e,t)?[e]:ff(hf(e))}var ho=yf;function gf(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var vf=gf,bf=mo,xf=1/0;function Cf(e){if(typeof e=="string"||bf(e))return e;var t=e+"";return t=="0"&&1/e==-xf?"-0":t}var Vr=Cf,wf=ho,$f=Vr;function Sf(e,t){t=wf(t,e);for(var o=0,r=t.length;e!=null&&o<r;)e=e[$f(t[o++])];return o&&o==r?e:void 0}var kf=Sf;function Af(e,t,o){var r=-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);++r<s;)a[r]=e[r+t];return a}var Tf=Af,Of=kf,Ff=Tf;function If(e,t){return t.length<2?e:Of(e,Ff(t,0,-1))}var Df=If,Nf=ho,Pf=vf,Ef=Df,Mf=Vr;function _f(e,t){return t=Nf(t,e),e=Ef(e,t),e==null||delete e[Mf(Pf(t))]}var jf=_f,Bf=ze,Vf=no,Lf=Ie,zf="[object Object]",Wf=Function.prototype,Uf=Object.prototype,Lr=Wf.toString,Gf=Uf.hasOwnProperty,Hf=Lr.call(Object);function Kf(e){if(!Lf(e)||Bf(e)!=zf)return!1;var t=Vf(e);if(t===null)return!0;var o=Gf.call(t,"constructor")&&t.constructor;return typeof o=="function"&&o instanceof o&&Lr.call(o)==Hf}var qf=Kf,Jf=qf;function Yf(e){return Jf(e)?void 0:e}var Zf=Yf,zr=ot,Qf=rr,Xf=De,Wr=zr?zr.isConcatSpreadable:void 0;function Rf(e){return Xf(e)||Qf(e)||!!(Wr&&e&&e[Wr])}var eh=Rf,th=ro,oh=eh;function Ur(e,t,o,r,s){var a=-1,l=e.length;for(o||(o=oh),s||(s=[]);++a<l;){var c=e[a];t>0&&o(c)?t>1?Ur(c,t-1,o,r,s):th(s,c):r||(s[s.length]=c)}return s}var rh=Ur,nh=rh;function sh(e){var t=e==null?0:e.length;return t?nh(e,1):[]}var ah=sh;function ih(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 lh=ih,ch=lh,Gr=Math.max;function uh(e,t,o){return t=Gr(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=Gr(r.length-t,0),l=Array(a);++s<a;)l[s]=r[t+s];s=-1;for(var c=Array(t+1);++s<t;)c[s]=r[s];return c[t]=o(l),ch(e,this,c)}}var dh=uh;function ph(e){return function(){return e}}var mh=ph;function fh(e){return e}var hh=fh,yh=mh,Hr=Qo,gh=hh,vh=Hr?function(e,t){return Hr(e,"toString",{configurable:!0,enumerable:!1,value:yh(t),writable:!0})}:gh,bh=vh,xh=800,Ch=16,wh=Date.now;function $h(e){var t=0,o=0;return function(){var r=wh(),s=Ch-(r-o);if(o=r,s>0){if(++t>=xh)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Sh=$h,kh=bh,Ah=Sh,Th=Ah(kh),Oh=Th,Fh=ah,Ih=dh,Dh=Oh;function Nh(e){return Dh(Ih(e,void 0,Fh),e+"")}var Ph=Nh,Eh=Bo,Mh=Mm,_h=jf,jh=ho,Bh=st,Vh=Zf,Lh=Ph,zh=hr,Wh=1,Uh=2,Gh=4,Hh=Lh(function(e,t){var o={};if(e==null)return o;var r=!1;t=Eh(t,function(a){return a=jh(a,e),r||(r=a.length>1),a}),Bh(e,zh(e),o),r&&(o=Mh(o,Wh|Uh|Gh,Vh));for(var s=t.length;s--;)_h(o,t[s]);return o}),Kh=Hh;const qh=Eo(Kh),Kr={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({},Be),{title:`{{t("Associations to use", { ns: "${d}" })}}`})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:r}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:N("Trigger data")}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:N("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:r}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:_e,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{},useActionTriggerable:!0};function Jh({filterByTk:e,form:t,getField:o,actionFields:r}){if(e&&r){const s=Object.keys(t.values).filter(a=>{const l=o(a);return!r.includes(a)&&["hasOne","hasMany","belongsTo","belongsToMany"].includes(l==null?void 0:l.type)});return qh(v({},t.values),s)}return t.values}function Yh(){var _;const e=i.useAPIClient(),t=F.useForm(),{field:o,resource:r,__parent:s}=i.useBlockRequestContext(),{setVisible:a,fieldSchema:l}=i.useActionContext(),c=he.useNavigate(),u=F.useFieldSchema(),p=F.useField(),{fields:f,getField:g,getTreeParentField:x}=i.useCollection(),h=i.useCompile(),m=i.useFilterByTk(),k=i.useRecord(),w=i.useCurrentUserContext(),{modal:T}=b.App.useApp(),{getActiveFieldsName:$}=i.useFormActiveFields()||{},D=(_=w==null?void 0:w.data)==null?void 0:_.data,M=p.componentProps.filterKeys||[];return{onClick(){return J(this,null,function*(){var L,ie,Y,Q,R,ne;const{assignedValues:P={},onSuccess:A,overwriteValues:I,skipValidator:U,triggerWorkflows:V}=(L=u==null?void 0:u["x-action-settings"])!=null?L:{},Z=(ie=l==null?void 0:l["x-component-props"])==null?void 0:ie.addChild,E=X.parse(P)({currentTime:new Date,currentRecord:k,currentUser:D,$user:D,$nRecord:k,$nForm:t.values,$nDate:{now:new Date}});U||(yield t.submit());const j=Jh({filterByTk:m,form:t,getField:g,actionFields:($==null?void 0:$("form"))||[]});if(Z){const ue=x();j[(Y=ue==null?void 0:ue.name)!=null?Y:"parent"]=k,j[(Q=ue==null?void 0:ue.foreignKey)!=null?Q:"parentId"]=k.id}p.data=o.data||{},p.data.loading=!0;try{const ue=yield e.resource("workflows").trigger({values:v(v(v({},j),I),E),filterKeys:M,triggerWorkflows:V!=null&&V.length?V.map(me=>[me.workflowKey,me.context].filter(Boolean).join("!")).join(","):void 0});if(p.data.loading=!1,p.data.data=ue,(ne=(R=s==null?void 0:s.service)==null?void 0:R.refresh)==null||ne.call(R),a==null||a(!1),!(A!=null&&A.successMessage))return;A!=null&&A.manualClose?T.success({title:h(A==null?void 0:A.successMessage),onOk:()=>J(this,null,function*(){yield t.reset(),A!=null&&A.redirecting&&(A!=null&&A.redirectTo)&&(X.isURL(A.redirectTo)?window.location.href=A.redirectTo:c(A.redirectTo))})}):b.message.success(h(A==null?void 0:A.successMessage))}catch(ue){p.data.loading=!1}})}}}const Pe={STATIC:0,COLLECTION_FIELD:1};function Zh(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function qr({value:e,onChange:t}){const{t:o}=oe.useTranslation(),[r,s]=y.useState(e.offset?e.offset/Math.abs(e.offset):0);return n.jsxs("fieldset",{className:i.css`
|
|
401
401
|
display: flex;
|
|
402
402
|
gap: 0.5em;
|
|
403
|
-
`,children:[n.jsx(qt,{value:e.field,onChange:a=>t(C(v({},e),{field:a})),filter:Zh,placeholder:o("Select field")}),e.field?n.jsx(
|
|
403
|
+
`,children:[n.jsx(qt,{value:e.field,onChange:a=>t(C(v({},e),{field:a})),filter:Zh,placeholder:o("Select field")}),e.field?n.jsx(b.Select,{value:r,onChange:a=>{s(a),t(C(v({},e),{offset:Math.abs(e.offset)*a}))},options:[{value:0,label:N("Exactly at")},{value:-1,label:o("Before")},{value:1,label:o("After")}]}):null,r?n.jsxs(n.Fragment,{children:[n.jsx(b.InputNumber,{value:Math.abs(e.offset),onChange:a=>t(C(v({},e),{offset:(a!=null?a:0)*r}))}),n.jsx(b.Select,{value:e.unit||864e5,onChange:a=>t(C(v({},e),{unit:a})),options:[{value:864e5,label:N("Days")},{value:36e5,label:N("Hours")},{value:6e4,label:N("Minutes")},{value:1e3,label:N("Seconds")}]})]}):null]})}function Qh({value:e,onChange:t}){const{t:o}=Ht(),r=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return n.jsxs("fieldset",{className:i.css`
|
|
404
404
|
display: flex;
|
|
405
405
|
gap: 0.5em;
|
|
406
|
-
`,children:[n.jsxs(x.Select,{value:r,onChange:s=>{t(s?s==="field"?{}:new Date:null)},children:[n.jsx(x.Select.Option,{value:null,children:o("No end")}),n.jsx(x.Select.Option,{value:"field",children:o("By field")}),n.jsx(x.Select.Option,{value:"date",children:o("By custom date")})]}),r==="field"?n.jsx(qr,{value:e,onChange:t}):null,r==="date"?n.jsx(x.DatePicker,{showTime:!0,value:Po(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var ce=function(){return ce=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;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 Jr(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(o[r[s]]=e[r[s]])}return o}function At(e,t,o){if(o||arguments.length===2)for(var r,s=0,a=t.length;s<a;s++)!r&&s in t||(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return e.concat(r||Array.prototype.slice.call(t))}var Xh=[{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 Yr(e,t){for(var o=[],r=e;r<=t;r++)o.push(r);return o}function Tt(e){return e.sort(function(t,o){return t-o}),e}function Zr(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],r=t[1];return o&&r}).map(function(t){return t[0]}).join(" ")}function Qr(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function Ot(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function Xr(e,t,o,r,s,a,l,c,u,p,f,g,b,h){o&&o(void 0),t(!1);var m=!1;if(!e){if(r==="always"||a&&r==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var k=Xh.find(function($){return $.name===e});k&&(e=k.value)}try{var w=function($){if(typeof $!="string")throw new Error("Invalid cron string");var P=$.replace(/\s+/g," ").trim().split(" ");if(P.length===5)return P.map(function(M,_){return function(z,N){if(z==="*"||z==="*/1")return[];var A=Tt(Zr(on(function(U,V,Z){if(Z){U=U.toUpperCase();for(var E=0;E<Z.length;E++)U=U.replace(Z[E],"".concat(E+V))}return U}(z,N.min,N.alt).split(",").map(function(U){var V,Z=U.split("/");if(Z.length>2)throw new Error('Invalid value "'.concat(z,' for "').concat(N.type,'"'));var E=Z[0],j=Z[1];V=E==="*"?Yr(N.min,N.max):function(Y,Q,R){var ne=Y.split("-");if(ne.length===1){var ue=Ot(ne[0]);if(isNaN(ue))throw new Error('Invalid value "'.concat(Q,'" for ').concat(R.type));return[ue]}if(ne.length===2){var me=Ot(ne[0]),Ze=Ot(ne[1]);if(isNaN(me)||isNaN(Ze))throw new Error('Invalid value "'.concat(Q,'" for ').concat(R.type));if(Ze<me)throw new Error('Max range is less than min range in "'.concat(Y,'" for ').concat(R.type));return Yr(me,Ze)}throw new Error('Invalid value "'.concat(Y,'" for ').concat(R.type))}(E,z,N);var L=function(Y,Q){if(Y!==void 0){var R=Ot(Y);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(Y,'" for ').concat(Q.type));return R}}(j,N),ie=function(Y,Q){if(Q){var R=Y[0];Y=Y.filter(function(ne){return ne%Q==R%Q||ne===R})}return Y}(V,L);return ie}).flat(),N))),D=rn(A,N);if(D!==void 0)throw new Error('Value "'.concat(D,'" out of range for ').concat(N.type));return A.length===N.total?[]:A}(M,Ee[_])});throw new Error("Invalid cron string format")}(e),T=function($){return $[3].length>0?"year":$[2].length>0?"month":$[4].length>0?"week":$[1].length>0?"day":$[0].length>0?"hour":"minute"}(w);h(T),u(w[0]),p(w[1]),f(w[2]),g(w[3]),b(w[4])}catch($){m=!0}}m&&(s.current=e,t(!0),Qr(o,l))}function Rr(e,t,o,r,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,p){return u.map(function(f,g){var b=Ee[g];return en(tn(f,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"||!r?[]:r],l);return c.join(" ")}function en(e,t,o,r,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 f=c[p-1];if(c[p]-f!==u)return!1}return!0}(e,l)?function(c,u,p){var f=nn(c),g=sn(c),b=c.length===(g-f)/p+1;return!!(f===u.min&&g+p>u.max&&b)}(e,t,l)?"*/".concat(l):"".concat(Ke(nn(e),t,o,r,s),"-").concat(Ke(sn(e),t,o,r,s),"/").concat(l):function(c){var u=[],p=null;return c.forEach(function(f,g,b){f!==b[g+1]-1?p!==null?(u.push([p,f]),p=null):u.push(f):p===null&&(p=f)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Ke(c[0],t,o,r,s),"-").concat(Ke(c[1],t,o,r,s)):Ke(c,t,o,r,s)}).join(",")}return a}function Ke(e,t,o,r,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,p=r&&(r===!0||r.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(p||f)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var g=e>=12?"PM":"AM",b=e%12||12;b<10&&p&&(b=b.toString().padStart(2,"0")),a="".concat(b).concat(g)}return a}function tn(e,t){var o=Tt(Zr(on(e,t)));if(o.length===0)return o;var r=rn(o,t);if(r!==void 0)throw new Error('Value "'.concat(r,'" out of range for ').concat(t.type));return o}function on(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],r=e[e.length-1];return o<t.min?o:r>t.max?r:void 0}function nn(e){return e[0]}function sn(e){return e[e.length-1]}function at(e){var t=e.value,o=e.grid,r=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,p=e.disabled,f=e.readOnly,g=e.leadingZero,b=e.clockFormat,h=e.period,m=e.unit,k=e.periodicityOnDoubleClick,w=e.mode,T=Jr(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),$=y.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(E){return E.toString()})},[t]),P=y.useMemo(function(){return s?s.map(function(E,j){return{value:(m.min===0?j:j+1).toString(),label:E}}):At([],Array(m.total),!0).map(function(E,j){var L=m.min===0?j:j+1;return{value:L.toString(),label:Ke(L,m,u,g,b)}})},[s,g,u,b]),M=JSON.stringify(l),_=y.useCallback(function(E){var j=E.value;if(!t||t[0]!==Number(j))return n.jsx(n.Fragment,{});var L=en(tn(t,m),m,u,g,b),ie=L.match(/^\*\/([0-9]+),?/)||[];return n.jsx("div",{children:ie[1]?"".concat(l.everyText||B.everyText," ").concat(ie[1]):L})},[t,M,u,g,b]),z=y.useCallback(function(E){var j=Array.isArray(E)?Tt(E):[E],L=j;t&&(L=w==="single"?[]:At([],t,!0),j.forEach(function(ie){var Y=Number(ie);L=t.some(function(Q){return Q===Y})?L.filter(function(Q){return Q!==Y}):Tt(At(At([],L,!0),[Y],!1))})),L.length===m.total?a([]):a(L)},[a,t]),N=y.useCallback(function(E){if(E!==0&&E!==1){for(var j=m.total+m.min,L=[],ie=m.min;ie<j;ie++)ie%E==0&&L.push(ie);var Y=t&&L&&t.length===L.length&&t.every(function(R,ne){return R===L[ne]}),Q=L.length===P.length;a(Q||Y?[]:L)}else a([])},[t,P,a]),A=y.useRef([]),D=y.useCallback(function(E){if(!f){var j=A.current;j.push({time:new Date().getTime(),value:Number(E)});var L=window.setTimeout(function(){k&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?N(Number(E)):z([j[j.length-2].value,j[j.length-1].value]):z(Number(E)),A.current=[]},300);return function(){window.clearTimeout(L)}}},[A,z,N,f,k]),U=y.useCallback(function(){f||a([])},[a,f]),V=y.useMemo(function(){var E;return fe(((E={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,E))},[c]),Z=y.useMemo(function(){var E;return fe(((E={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown"]=!0,E["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&h!=="hour"&&h!=="day",E["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(h==="day"||h==="hour"),E["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&b==="12-hour-clock",E["react-js-cron-custom-select-dropdown-grid"]=!!r,E["".concat(c,"-select-dropdown")]=!!c,E["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,E))},[c,r,b,h]);return n.jsx(x.Select,ce({mode:w!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:$,onClear:U,tagRender:_,className:V,popupClassName:Z,options:P,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:D,onDeselect:D,disabled:p,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},T))}function Rh(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,b=y.useMemo(function(){var h;return fe(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return n.jsxs("div",ce({className:b},{children:[r.prefixHours!==""&&n.jsx("span",{children:r.prefixHours||B.prefixHours}),n.jsx(at,{placeholder:r.emptyHours||B.emptyHours,value:t,unit:Ee[1],setValue:o,locale:r,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:f,mode:g})]}))}function ey(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,b=y.useMemo(function(){var h;return fe(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return n.jsxs("div",ce({className:b},{children:[p==="hour"?r.prefixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):r.prefixMinutes!==""&&n.jsx("span",{children:r.prefixMinutes||B.prefixMinutes}),n.jsx(at,{placeholder:p==="hour"?r.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:r.emptyMinutes||B.emptyMinutes,value:t,unit:Ee[0],setValue:o,locale:r,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:f,mode:g}),p==="hour"&&r.suffixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function ty(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,b=!a||a.length===0,h=y.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]),m=JSON.stringify(r),k=y.useMemo(function(){return b?r.emptyMonthDays||B.emptyMonthDays:r.emptyMonthDaysShort||B.emptyMonthDaysShort},[b,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?n.jsxs("div",ce({className:h},{children:[r.prefixMonthDays!==""&&n.jsx("span",{children:r.prefixMonthDays||B.prefixMonthDays}),n.jsx(at,{placeholder:k,value:t,setValue:o,unit:Ee[2],locale:r,className:s,disabled:l,readOnly:c,leadingZero:u,period:p,periodicityOnDoubleClick:f,mode:g})]})):null}function oy(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,g=r.months||B.months,b=y.useMemo(function(){var h;return fe(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return n.jsxs("div",ce({className:b},{children:[r.prefixMonths!==""&&n.jsx("span",{children:r.prefixMonths||B.prefixMonths}),n.jsx(at,{placeholder:r.emptyMonths||B.emptyMonths,optionsList:g,grid:!1,value:t,unit:ce(ce({},Ee[3]),{alt:r.altMonths||B.altMonths}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:p,mode:f})]}))}function ry(e){var t=e.value,o=e.setValue,r=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:r.yearOption||B.yearOption}),u.includes("month")&&p.push({value:"month",label:r.monthOption||B.monthOption}),u.includes("week")&&p.push({value:"week",label:r.weekOption||B.weekOption}),u.includes("day")&&p.push({value:"day",label:r.dayOption||B.dayOption}),u.includes("hour")&&p.push({value:"hour",label:r.hourOption||B.hourOption}),u.includes("minute")&&p.push({value:"minute",label:r.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:r.rebootOption||B.rebootOption});var f=y.useCallback(function(m){l||o(m)},[o,l]),g=y.useMemo(function(){var m;return fe(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),b=y.useMemo(function(){var m;return fe(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":r.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,r.prefixPeriod]),h=y.useMemo(function(){var m;return fe(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return n.jsxs("div",ce({className:g},{children:[r.prefixPeriod!==""&&n.jsx("span",{children:r.prefixPeriod||B.prefixPeriod}),n.jsx(x.Select,{defaultValue:t,value:t,onChange:f,options:p,className:b,popupClassName:h,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(r))]}))}function ny(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,b=r.weekDays||B.weekDays,h=p==="week"||!l||l.length===0,m=y.useMemo(function(){var P;return fe(((P={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,P["".concat(s,"-week-days")]=!!s,P))},[s,h]),k=JSON.stringify(r),w=y.useMemo(function(){return h?r.emptyWeekDays||B.emptyWeekDays:r.emptyWeekDaysShort||B.emptyWeekDaysShort},[h,k]),T=p==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),$=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return T?n.jsxs("div",ce({className:m},{children:[r.prefixWeekDays!==""&&(p==="week"||!$)&&n.jsx("span",{children:r.prefixWeekDays||B.prefixWeekDays}),r.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&$&&n.jsx("span",{children:r.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),n.jsx(at,{placeholder:w,optionsList:b,grid:!1,value:t,unit:ce(ce({},Ee[4]),{alt:r.altWeekDays||B.altWeekDays}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:p,periodicityOnDoubleClick:f,mode:g})]})):null}function sy(e){var t=e.clearButton,o=t===void 0||t,r=e.clearButtonProps,s=r===void 0?{}:r,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,p=e.value,f=p===void 0?"":p,g=e.setValue,b=e.displayError,h=b===void 0||b,m=e.onError,k=e.className,w=e.defaultPeriod,T=w===void 0?"day":w,$=e.allowEmpty,P=$===void 0?"for-default-value":$,M=e.humanizeLabels,_=M===void 0||M,z=e.humanizeValue,N=z!==void 0&&z,A=e.disabled,D=A!==void 0&&A,U=e.readOnly,V=U!==void 0&&U,Z=e.leadingZero,E=Z!==void 0&&Z,j=e.shortcuts,L=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ie=e.clockFormat,Y=e.periodicityOnDoubleClick,Q=Y===void 0||Y,R=e.mode,ne=R===void 0?"multiple":R,ue=e.allowedDropdowns,me=ue===void 0?["period","months","month-days","week-days","hours","minutes"]:ue,Ze=e.allowedPeriods,nv=Ze===void 0?["year","month","week","day","hour","minute","reboot"]:Ze,Qe=y.useRef(f),Oo=y.useRef(T),Wn=y.useState(),we=Wn[0],Nt=Wn[1],Un=y.useState(),dt=Un[0],Et=Un[1],Gn=y.useState(),Mt=Gn[0],_t=Gn[1],Hn=y.useState(),pt=Hn[0],jt=Hn[1],Kn=y.useState(),Bt=Kn[0],Vt=Kn[1],qn=y.useState(),Lt=qn[0],zt=qn[1],Jn=y.useState(!1),Fo=Jn[0],mt=Jn[1],Yn=y.useState(!1),Wt=Yn[0],Zn=Yn[1],sv=function(te){var xe=y.useRef(te);return y.useEffect(function(){xe.current=te},[te]),xe.current}(Wt),Qn=JSON.stringify(u);y.useEffect(function(){Xr(f,mt,m,P,Qe,!0,u,L,zt,Vt,Et,_t,jt,Nt)},[]),y.useEffect(function(){f!==Qe.current&&Xr(f,mt,m,P,Qe,!1,u,L,zt,Vt,Et,_t,jt,Nt)},[f,Qe,Qn,P,L]),y.useEffect(function(){if(!(we||Lt||Mt||dt||pt||Bt)||Wt||sv)Wt&&Zn(!1);else{var te=we||Oo.current,xe=Rr(te,Mt,dt,pt,Bt,Lt,N);g(xe,{selectedPeriod:te}),Qe.current=xe,m&&m(void 0),mt(!1)}},[we,dt,Mt,pt,Bt,Lt,N,Wt]);var Xn=y.useCallback(function(){Et(void 0),_t(void 0),jt(void 0),Vt(void 0),zt(void 0);var te="",xe=we!=="reboot"&&we?we:Oo.current;xe!==we&&Nt(xe),l==="fill-with-every"&&(te=Rr(xe,void 0,void 0,void 0,void 0,void 0)),g(te,{selectedPeriod:xe}),Qe.current=te,Zn(!0),P==="never"&&l==="empty"?(mt(!0),Qr(m,u)):(m&&m(void 0),mt(!1))},[we,g,m,l]),av=y.useMemo(function(){var te;return fe(((te={"react-js-cron":!0,"react-js-cron-error":Fo&&h,"react-js-cron-disabled":D,"react-js-cron-read-only":V})["".concat(k)]=!!k,te["".concat(k,"-error")]=Fo&&h&&!!k,te["".concat(k,"-disabled")]=D&&!!k,te["".concat(k,"-read-only")]=V&&!!k,te))},[k,Fo,h,D,V]),Io=s.className,Rn=Jr(s,["className"]),es=y.useMemo(function(){var te;return fe(((te={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,te["".concat(Io)]=!!Io,te))},[k,Io]),iv=JSON.stringify(Rn),ts=y.useMemo(function(){return o&&!V?n.jsx(x.Button,ce({className:es,danger:!0,type:"primary",disabled:D},Rn,{onClick:Xn},{children:u.clearButtonText||B.clearButtonText})):null},[o,V,Qn,es,D,iv,Xn]),le=we||Oo.current;return n.jsxs("div",ce({className:av},{children:[me.includes("period")&&n.jsx(ry,{value:le,setValue:Nt,locale:u,className:k,disabled:D,readOnly:V,shortcuts:L,allowedPeriods:nv}),le==="reboot"?ts:n.jsxs(n.Fragment,{children:[le==="year"&&me.includes("months")&&n.jsx(oy,{value:Mt,setValue:_t,locale:u,className:k,humanizeLabels:_,disabled:D,readOnly:V,period:le,periodicityOnDoubleClick:Q,mode:ne}),(le==="year"||le==="month")&&me.includes("month-days")&&n.jsx(ty,{value:dt,setValue:Et,locale:u,className:k,weekDays:pt,disabled:D,readOnly:V,leadingZero:E,period:le,periodicityOnDoubleClick:Q,mode:ne}),(le==="year"||le==="month"||le==="week")&&me.includes("week-days")&&n.jsx(ny,{value:pt,setValue:jt,locale:u,className:k,humanizeLabels:_,monthDays:dt,disabled:D,readOnly:V,period:le,periodicityOnDoubleClick:Q,mode:ne}),n.jsxs("div",{children:[le!=="minute"&&le!=="hour"&&me.includes("hours")&&n.jsx(Rh,{value:Bt,setValue:Vt,locale:u,className:k,disabled:D,readOnly:V,leadingZero:E,clockFormat:ie,period:le,periodicityOnDoubleClick:Q,mode:ne}),le!=="minute"&&me.includes("minutes")&&n.jsx(ey,{value:Lt,setValue:zt,locale:u,period:le,className:k,disabled:D,readOnly:V,leadingZero:E,clockFormat:ie,periodicityOnDoubleClick:Q,mode:ne}),ts]})]})]}))}const ay={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},an=[{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 ln(e){return an.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function iy(e){let t;switch(typeof e){case"number":return t=ln(e),t?t.value:"none";case"string":return"cron"}return"none"}function ly({value:e,onChange:t}){const{t:o}=Ht(),r=ln(e);return n.jsx(x.InputNumber,{value:e/r.value,onChange:s=>t(s*r.value),min:1,addonBefore:o("Every"),addonAfter:o(r.unitText),className:"auto-width"})}function cy({value:e=null,onChange:t}){const{t:o}=Ht(),r=iy(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=ay[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return n.jsxs("fieldset",{className:i.css`
|
|
406
|
+
`,children:[n.jsxs(b.Select,{value:r,onChange:s=>{t(s?s==="field"?{}:new Date:null)},children:[n.jsx(b.Select.Option,{value:null,children:o("No end")}),n.jsx(b.Select.Option,{value:"field",children:o("By field")}),n.jsx(b.Select.Option,{value:"date",children:o("By custom date")})]}),r==="field"?n.jsx(qr,{value:e,onChange:t}):null,r==="date"?n.jsx(b.DatePicker,{showTime:!0,value:No(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var ce=function(){return ce=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;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 Jr(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(o[r[s]]=e[r[s]])}return o}function At(e,t,o){if(o||arguments.length===2)for(var r,s=0,a=t.length;s<a;s++)!r&&s in t||(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return e.concat(r||Array.prototype.slice.call(t))}var Xh=[{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 Yr(e,t){for(var o=[],r=e;r<=t;r++)o.push(r);return o}function Tt(e){return e.sort(function(t,o){return t-o}),e}function Zr(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],r=t[1];return o&&r}).map(function(t){return t[0]}).join(" ")}function Qr(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function Ot(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function Xr(e,t,o,r,s,a,l,c,u,p,f,g,x,h){o&&o(void 0),t(!1);var m=!1;if(!e){if(r==="always"||a&&r==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var k=Xh.find(function($){return $.name===e});k&&(e=k.value)}try{var w=function($){if(typeof $!="string")throw new Error("Invalid cron string");var D=$.replace(/\s+/g," ").trim().split(" ");if(D.length===5)return D.map(function(M,_){return function(z,P){if(z==="*"||z==="*/1")return[];var A=Tt(Zr(on(function(U,V,Z){if(Z){U=U.toUpperCase();for(var E=0;E<Z.length;E++)U=U.replace(Z[E],"".concat(E+V))}return U}(z,P.min,P.alt).split(",").map(function(U){var V,Z=U.split("/");if(Z.length>2)throw new Error('Invalid value "'.concat(z,' for "').concat(P.type,'"'));var E=Z[0],j=Z[1];V=E==="*"?Yr(P.min,P.max):function(Y,Q,R){var ne=Y.split("-");if(ne.length===1){var ue=Ot(ne[0]);if(isNaN(ue))throw new Error('Invalid value "'.concat(Q,'" for ').concat(R.type));return[ue]}if(ne.length===2){var me=Ot(ne[0]),Ze=Ot(ne[1]);if(isNaN(me)||isNaN(Ze))throw new Error('Invalid value "'.concat(Q,'" for ').concat(R.type));if(Ze<me)throw new Error('Max range is less than min range in "'.concat(Y,'" for ').concat(R.type));return Yr(me,Ze)}throw new Error('Invalid value "'.concat(Y,'" for ').concat(R.type))}(E,z,P);var L=function(Y,Q){if(Y!==void 0){var R=Ot(Y);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(Y,'" for ').concat(Q.type));return R}}(j,P),ie=function(Y,Q){if(Q){var R=Y[0];Y=Y.filter(function(ne){return ne%Q==R%Q||ne===R})}return Y}(V,L);return ie}).flat(),P))),I=rn(A,P);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(P.type));return A.length===P.total?[]:A}(M,Ee[_])});throw new Error("Invalid cron string format")}(e),T=function($){return $[3].length>0?"year":$[2].length>0?"month":$[4].length>0?"week":$[1].length>0?"day":$[0].length>0?"hour":"minute"}(w);h(T),u(w[0]),p(w[1]),f(w[2]),g(w[3]),x(w[4])}catch($){m=!0}}m&&(s.current=e,t(!0),Qr(o,l))}function Rr(e,t,o,r,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,p){return u.map(function(f,g){var x=Ee[g];return en(tn(f,x),x,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"||!r?[]:r],l);return c.join(" ")}function en(e,t,o,r,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 f=c[p-1];if(c[p]-f!==u)return!1}return!0}(e,l)?function(c,u,p){var f=nn(c),g=sn(c),x=c.length===(g-f)/p+1;return!!(f===u.min&&g+p>u.max&&x)}(e,t,l)?"*/".concat(l):"".concat(Ke(nn(e),t,o,r,s),"-").concat(Ke(sn(e),t,o,r,s),"/").concat(l):function(c){var u=[],p=null;return c.forEach(function(f,g,x){f!==x[g+1]-1?p!==null?(u.push([p,f]),p=null):u.push(f):p===null&&(p=f)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Ke(c[0],t,o,r,s),"-").concat(Ke(c[1],t,o,r,s)):Ke(c,t,o,r,s)}).join(",")}return a}function Ke(e,t,o,r,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,p=r&&(r===!0||r.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(p||f)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var g=e>=12?"PM":"AM",x=e%12||12;x<10&&p&&(x=x.toString().padStart(2,"0")),a="".concat(x).concat(g)}return a}function tn(e,t){var o=Tt(Zr(on(e,t)));if(o.length===0)return o;var r=rn(o,t);if(r!==void 0)throw new Error('Value "'.concat(r,'" out of range for ').concat(t.type));return o}function on(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],r=e[e.length-1];return o<t.min?o:r>t.max?r:void 0}function nn(e){return e[0]}function sn(e){return e[e.length-1]}function at(e){var t=e.value,o=e.grid,r=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,p=e.disabled,f=e.readOnly,g=e.leadingZero,x=e.clockFormat,h=e.period,m=e.unit,k=e.periodicityOnDoubleClick,w=e.mode,T=Jr(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),$=y.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(E){return E.toString()})},[t]),D=y.useMemo(function(){return s?s.map(function(E,j){return{value:(m.min===0?j:j+1).toString(),label:E}}):At([],Array(m.total),!0).map(function(E,j){var L=m.min===0?j:j+1;return{value:L.toString(),label:Ke(L,m,u,g,x)}})},[s,g,u,x]),M=JSON.stringify(l),_=y.useCallback(function(E){var j=E.value;if(!t||t[0]!==Number(j))return n.jsx(n.Fragment,{});var L=en(tn(t,m),m,u,g,x),ie=L.match(/^\*\/([0-9]+),?/)||[];return n.jsx("div",{children:ie[1]?"".concat(l.everyText||B.everyText," ").concat(ie[1]):L})},[t,M,u,g,x]),z=y.useCallback(function(E){var j=Array.isArray(E)?Tt(E):[E],L=j;t&&(L=w==="single"?[]:At([],t,!0),j.forEach(function(ie){var Y=Number(ie);L=t.some(function(Q){return Q===Y})?L.filter(function(Q){return Q!==Y}):Tt(At(At([],L,!0),[Y],!1))})),L.length===m.total?a([]):a(L)},[a,t]),P=y.useCallback(function(E){if(E!==0&&E!==1){for(var j=m.total+m.min,L=[],ie=m.min;ie<j;ie++)ie%E==0&&L.push(ie);var Y=t&&L&&t.length===L.length&&t.every(function(R,ne){return R===L[ne]}),Q=L.length===D.length;a(Q||Y?[]:L)}else a([])},[t,D,a]),A=y.useRef([]),I=y.useCallback(function(E){if(!f){var j=A.current;j.push({time:new Date().getTime(),value:Number(E)});var L=window.setTimeout(function(){k&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?P(Number(E)):z([j[j.length-2].value,j[j.length-1].value]):z(Number(E)),A.current=[]},300);return function(){window.clearTimeout(L)}}},[A,z,P,f,k]),U=y.useCallback(function(){f||a([])},[a,f]),V=y.useMemo(function(){var E;return fe(((E={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,E))},[c]),Z=y.useMemo(function(){var E;return fe(((E={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown"]=!0,E["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&h!=="hour"&&h!=="day",E["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(h==="day"||h==="hour"),E["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&x==="12-hour-clock",E["react-js-cron-custom-select-dropdown-grid"]=!!r,E["".concat(c,"-select-dropdown")]=!!c,E["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,E))},[c,r,x,h]);return n.jsx(b.Select,ce({mode:w!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:$,onClear:U,tagRender:_,className:V,popupClassName:Z,options:D,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:p,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},T))}function Rh(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,x=y.useMemo(function(){var h;return fe(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return n.jsxs("div",ce({className:x},{children:[r.prefixHours!==""&&n.jsx("span",{children:r.prefixHours||B.prefixHours}),n.jsx(at,{placeholder:r.emptyHours||B.emptyHours,value:t,unit:Ee[1],setValue:o,locale:r,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:f,mode:g})]}))}function ey(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,x=y.useMemo(function(){var h;return fe(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return n.jsxs("div",ce({className:x},{children:[p==="hour"?r.prefixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):r.prefixMinutes!==""&&n.jsx("span",{children:r.prefixMinutes||B.prefixMinutes}),n.jsx(at,{placeholder:p==="hour"?r.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:r.emptyMinutes||B.emptyMinutes,value:t,unit:Ee[0],setValue:o,locale:r,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:f,mode:g}),p==="hour"&&r.suffixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function ty(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,x=!a||a.length===0,h=y.useMemo(function(){var w;return fe(((w={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!x})["".concat(s,"-field")]=!!s,w["".concat(s,"-month-days")]=!!s,w))},[s,x]),m=JSON.stringify(r),k=y.useMemo(function(){return x?r.emptyMonthDays||B.emptyMonthDays:r.emptyMonthDaysShort||B.emptyMonthDaysShort},[x,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?n.jsxs("div",ce({className:h},{children:[r.prefixMonthDays!==""&&n.jsx("span",{children:r.prefixMonthDays||B.prefixMonthDays}),n.jsx(at,{placeholder:k,value:t,setValue:o,unit:Ee[2],locale:r,className:s,disabled:l,readOnly:c,leadingZero:u,period:p,periodicityOnDoubleClick:f,mode:g})]})):null}function oy(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,g=r.months||B.months,x=y.useMemo(function(){var h;return fe(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return n.jsxs("div",ce({className:x},{children:[r.prefixMonths!==""&&n.jsx("span",{children:r.prefixMonths||B.prefixMonths}),n.jsx(at,{placeholder:r.emptyMonths||B.emptyMonths,optionsList:g,grid:!1,value:t,unit:ce(ce({},Ee[3]),{alt:r.altMonths||B.altMonths}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:p,mode:f})]}))}function ry(e){var t=e.value,o=e.setValue,r=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:r.yearOption||B.yearOption}),u.includes("month")&&p.push({value:"month",label:r.monthOption||B.monthOption}),u.includes("week")&&p.push({value:"week",label:r.weekOption||B.weekOption}),u.includes("day")&&p.push({value:"day",label:r.dayOption||B.dayOption}),u.includes("hour")&&p.push({value:"hour",label:r.hourOption||B.hourOption}),u.includes("minute")&&p.push({value:"minute",label:r.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:r.rebootOption||B.rebootOption});var f=y.useCallback(function(m){l||o(m)},[o,l]),g=y.useMemo(function(){var m;return fe(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),x=y.useMemo(function(){var m;return fe(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":r.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,r.prefixPeriod]),h=y.useMemo(function(){var m;return fe(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return n.jsxs("div",ce({className:g},{children:[r.prefixPeriod!==""&&n.jsx("span",{children:r.prefixPeriod||B.prefixPeriod}),n.jsx(b.Select,{defaultValue:t,value:t,onChange:f,options:p,className:x,popupClassName:h,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(r))]}))}function ny(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,x=r.weekDays||B.weekDays,h=p==="week"||!l||l.length===0,m=y.useMemo(function(){var D;return fe(((D={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,D["".concat(s,"-week-days")]=!!s,D))},[s,h]),k=JSON.stringify(r),w=y.useMemo(function(){return h?r.emptyWeekDays||B.emptyWeekDays:r.emptyWeekDaysShort||B.emptyWeekDaysShort},[h,k]),T=p==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),$=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return T?n.jsxs("div",ce({className:m},{children:[r.prefixWeekDays!==""&&(p==="week"||!$)&&n.jsx("span",{children:r.prefixWeekDays||B.prefixWeekDays}),r.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&$&&n.jsx("span",{children:r.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),n.jsx(at,{placeholder:w,optionsList:x,grid:!1,value:t,unit:ce(ce({},Ee[4]),{alt:r.altWeekDays||B.altWeekDays}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:p,periodicityOnDoubleClick:f,mode:g})]})):null}function sy(e){var t=e.clearButton,o=t===void 0||t,r=e.clearButtonProps,s=r===void 0?{}:r,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,p=e.value,f=p===void 0?"":p,g=e.setValue,x=e.displayError,h=x===void 0||x,m=e.onError,k=e.className,w=e.defaultPeriod,T=w===void 0?"day":w,$=e.allowEmpty,D=$===void 0?"for-default-value":$,M=e.humanizeLabels,_=M===void 0||M,z=e.humanizeValue,P=z!==void 0&&z,A=e.disabled,I=A!==void 0&&A,U=e.readOnly,V=U!==void 0&&U,Z=e.leadingZero,E=Z!==void 0&&Z,j=e.shortcuts,L=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ie=e.clockFormat,Y=e.periodicityOnDoubleClick,Q=Y===void 0||Y,R=e.mode,ne=R===void 0?"multiple":R,ue=e.allowedDropdowns,me=ue===void 0?["period","months","month-days","week-days","hours","minutes"]:ue,Ze=e.allowedPeriods,nv=Ze===void 0?["year","month","week","day","hour","minute","reboot"]:Ze,Qe=y.useRef(f),Oo=y.useRef(T),Wn=y.useState(),we=Wn[0],Pt=Wn[1],Un=y.useState(),dt=Un[0],Et=Un[1],Gn=y.useState(),Mt=Gn[0],_t=Gn[1],Hn=y.useState(),pt=Hn[0],jt=Hn[1],Kn=y.useState(),Bt=Kn[0],Vt=Kn[1],qn=y.useState(),Lt=qn[0],zt=qn[1],Jn=y.useState(!1),Fo=Jn[0],mt=Jn[1],Yn=y.useState(!1),Wt=Yn[0],Zn=Yn[1],sv=function(te){var xe=y.useRef(te);return y.useEffect(function(){xe.current=te},[te]),xe.current}(Wt),Qn=JSON.stringify(u);y.useEffect(function(){Xr(f,mt,m,D,Qe,!0,u,L,zt,Vt,Et,_t,jt,Pt)},[]),y.useEffect(function(){f!==Qe.current&&Xr(f,mt,m,D,Qe,!1,u,L,zt,Vt,Et,_t,jt,Pt)},[f,Qe,Qn,D,L]),y.useEffect(function(){if(!(we||Lt||Mt||dt||pt||Bt)||Wt||sv)Wt&&Zn(!1);else{var te=we||Oo.current,xe=Rr(te,Mt,dt,pt,Bt,Lt,P);g(xe,{selectedPeriod:te}),Qe.current=xe,m&&m(void 0),mt(!1)}},[we,dt,Mt,pt,Bt,Lt,P,Wt]);var Xn=y.useCallback(function(){Et(void 0),_t(void 0),jt(void 0),Vt(void 0),zt(void 0);var te="",xe=we!=="reboot"&&we?we:Oo.current;xe!==we&&Pt(xe),l==="fill-with-every"&&(te=Rr(xe,void 0,void 0,void 0,void 0,void 0)),g(te,{selectedPeriod:xe}),Qe.current=te,Zn(!0),D==="never"&&l==="empty"?(mt(!0),Qr(m,u)):(m&&m(void 0),mt(!1))},[we,g,m,l]),av=y.useMemo(function(){var te;return fe(((te={"react-js-cron":!0,"react-js-cron-error":Fo&&h,"react-js-cron-disabled":I,"react-js-cron-read-only":V})["".concat(k)]=!!k,te["".concat(k,"-error")]=Fo&&h&&!!k,te["".concat(k,"-disabled")]=I&&!!k,te["".concat(k,"-read-only")]=V&&!!k,te))},[k,Fo,h,I,V]),Io=s.className,Rn=Jr(s,["className"]),es=y.useMemo(function(){var te;return fe(((te={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,te["".concat(Io)]=!!Io,te))},[k,Io]),iv=JSON.stringify(Rn),ts=y.useMemo(function(){return o&&!V?n.jsx(b.Button,ce({className:es,danger:!0,type:"primary",disabled:I},Rn,{onClick:Xn},{children:u.clearButtonText||B.clearButtonText})):null},[o,V,Qn,es,I,iv,Xn]),le=we||Oo.current;return n.jsxs("div",ce({className:av},{children:[me.includes("period")&&n.jsx(ry,{value:le,setValue:Pt,locale:u,className:k,disabled:I,readOnly:V,shortcuts:L,allowedPeriods:nv}),le==="reboot"?ts:n.jsxs(n.Fragment,{children:[le==="year"&&me.includes("months")&&n.jsx(oy,{value:Mt,setValue:_t,locale:u,className:k,humanizeLabels:_,disabled:I,readOnly:V,period:le,periodicityOnDoubleClick:Q,mode:ne}),(le==="year"||le==="month")&&me.includes("month-days")&&n.jsx(ty,{value:dt,setValue:Et,locale:u,className:k,weekDays:pt,disabled:I,readOnly:V,leadingZero:E,period:le,periodicityOnDoubleClick:Q,mode:ne}),(le==="year"||le==="month"||le==="week")&&me.includes("week-days")&&n.jsx(ny,{value:pt,setValue:jt,locale:u,className:k,humanizeLabels:_,monthDays:dt,disabled:I,readOnly:V,period:le,periodicityOnDoubleClick:Q,mode:ne}),n.jsxs("div",{children:[le!=="minute"&&le!=="hour"&&me.includes("hours")&&n.jsx(Rh,{value:Bt,setValue:Vt,locale:u,className:k,disabled:I,readOnly:V,leadingZero:E,clockFormat:ie,period:le,periodicityOnDoubleClick:Q,mode:ne}),le!=="minute"&&me.includes("minutes")&&n.jsx(ey,{value:Lt,setValue:zt,locale:u,period:le,className:k,disabled:I,readOnly:V,leadingZero:E,clockFormat:ie,periodicityOnDoubleClick:Q,mode:ne}),ts]})]})]}))}const ay={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},an=[{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 ln(e){return an.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function iy(e){let t;switch(typeof e){case"number":return t=ln(e),t?t.value:"none";case"string":return"cron"}return"none"}function ly({value:e,onChange:t}){const{t:o}=Ht(),r=ln(e);return n.jsx(b.InputNumber,{value:e/r.value,onChange:s=>t(s*r.value),min:1,addonBefore:o("Every"),addonAfter:o(r.unitText),className:"auto-width"})}function cy({value:e=null,onChange:t}){const{t:o}=Ht(),r=iy(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=ay[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return n.jsxs("fieldset",{className:i.css`
|
|
407
407
|
display: flex;
|
|
408
408
|
flex-direction: ${r==="cron"?"column":"row"};
|
|
409
409
|
align-items: flex-start;
|
|
@@ -432,7 +432,7 @@
|
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
|
-
`,children:[n.jsx(
|
|
435
|
+
`,children:[n.jsx(b.Select,{value:r,onChange:s,className:"auto-width",children:an.map(l=>n.jsx(b.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof r=="number"?n.jsx(ly,{value:e,onChange:t}):null,r==="cron"?n.jsx(sy,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:a}):null]})}const uy={[Pe.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}}},[Pe.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({},Be),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${Pe.COLLECTION_FIELD} && $deps[1]}}`}}}]})}},dy=[{value:Pe.STATIC,label:`{{t("Based on certain date", { ns: "${d}" })}}`},{value:Pe.COLLECTION_FIELD,label:`{{t("Based on date field of collection", { ns: "${d}" })}}`}],py=()=>{const{values:e={},clearFormGraph:t}=F.useForm(),[o,r]=y.useState(e.mode);return F.useFormEffects(()=>{se.onFieldValueChange("mode",s=>{r(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),n.jsxs(n.Fragment,{children:[n.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:dy},required:!0,default:Pe.STATIC}}),n.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
436
436
|
.ant-input-number {
|
|
437
437
|
width: auto;
|
|
438
438
|
min-width: 6em;
|
|
@@ -441,37 +441,37 @@
|
|
|
441
441
|
.ant-picker {
|
|
442
442
|
width: auto;
|
|
443
443
|
}
|
|
444
|
-
`},properties:uy[o]}}},components:{OnField:qr,RepeatField:cy,EndsByField:Qh}})]})},cn={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:py},useVariables(e,t){var a;const o=i.useCompile(),{getCollectionFields:r}=i.useCollectionManager(),s=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&s.push({key:"date",value:"date",label:
|
|
444
|
+
`},properties:uy[o]}}},components:{OnField:qr,RepeatField:cy,EndsByField:Qh}})]})},cn={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:py},useVariables(e,t){var a;const o=i.useCompile(),{getCollectionFields:r}=i.useCollectionManager(),s=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&s.push({key:"date",value:"date",label:N("Trigger time")}),e.mode===Pe.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:N("Trigger data")}}],compile:o,getCollectionFields:r}));l&&s.push(l)}return s},useInitializers(e){return e.collection?{type:"item",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:_e,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function my(){var a;const e=F.useForm(),t=i.useAPIClient(),{workflow:o}=(a=G())!=null?a:{},r=i.useActionContext(),{refresh:s}=i.useResourceActionContext();return{run(){return J(this,null,function*(){var c,u;if(o.executed){b.message.error(N("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}}),r.setFormValueChanged(!1),r.setVisible(!1),s()})}}}const ge=new X.Registry;ge.register(Kr.type,Kr),ge.register(jo.type,jo),ge.register(cn.type,cn);function fy(){const e=i.useCompile(),{workflow:t,execution:o}=G(),{styles:r}=ae();if(!o)return null;const s=ge.get(t.type);return n.jsx(i.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:n.jsx(O.InfoOutlined,{}),shape:"circle",size:"small",className:r.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:n.jsxs("div",{className:i.cx(r.nodeTitleClass),children:[n.jsx(b.Tag,{children:e(s.title)}),n.jsx("strong",{children:t.title}),n.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`
|
|
445
445
|
padding: 1em;
|
|
446
446
|
background-color: #eee;
|
|
447
|
-
`},"x-read-pretty":!0}}}}}})}function hy(){return{form:
|
|
447
|
+
`},"x-read-pretty":!0}}}}}})}function hy(){return{form:F.useForm()}}const yy=()=>{const e=i.useAPIClient(),{workflow:t,refresh:o}=G(),[r,s]=y.useState(""),[a,l]=y.useState(!1),[c,u]=y.useState(!1),{styles:p}=ae(),f=i.useCompile(),{title:g,type:x,executed:h}=t,m=ge.get(x),k=f(m.title),{fieldset:w,scope:T,components:$}=m,D=h?'{{t("View")}}':'{{t("Configure")}}',M=N("Trigger");y.useEffect(()=>{var I;t&&s((I=t.title)!=null?I:k)},[t]);const _=y.useMemo(()=>{const I=$e.cloneDeep(t==null?void 0:t.config);return se.createForm({initialValues:I,disabled:t==null?void 0:t.executed})},[t]),z=y.useCallback(I=>{l(I),I||_.reset()},[_]),P=y.useCallback(function(I){return J(this,null,function*(){var V,Z;const U=I||k;s(U),U!==g&&(yield(Z=(V=e.resource("workflows")).update)==null?void 0:Z.call(V,{filterByTk:t.id,values:{title:U}}),o())})},[t]),A=y.useCallback(function(I){var V;if(I.target===I.currentTarget){l(!0);return}const U=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let Z=I.target;Z&&Z!==I.currentTarget;Z=Z.parentNode)if(Array.from((V=Z.classList)!=null?V:[]).some(E=>U.has(E))){l(!0),I.stopPropagation();return}},[]);return n.jsxs("div",{role:"button","aria-label":`${M}-${r}`,className:i.cx(p.nodeCardClass),onClick:A,children:[n.jsx("div",{className:i.cx(p.nodeMetaClass,"workflow-node-meta"),children:n.jsx(b.Tag,{color:"gold",children:M})}),n.jsx("div",{children:n.jsx(b.Input.TextArea,{role:"button","aria-label":"textarea",value:r,onChange:I=>s(I.target.value),onBlur:I=>P(I.target.value),autoSize:!0})}),n.jsx(fy,{}),n.jsx(i.ActionContextProvider,{value:{visible:a,setVisible:z,formValueChanged:c,setFormValueChanged:u},children:n.jsx(i.FormProvider,{form:_,children:n.jsx(i.SchemaComponent,{scope:C(v({},T),{useFormProviderProps:hy}),components:$,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":D,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:M,"x-component":"Action.Drawer","x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},properties:C(v({},m.description?{description:{type:"void","x-component":Po,"x-component-props":{label:N("Trigger type"),title:m.title,description:m.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
448
448
|
.ant-select.auto-width {
|
|
449
449
|
width: auto;
|
|
450
450
|
min-width: 6em;
|
|
451
451
|
}
|
|
452
|
-
`},properties:w},actions:v({},h?{}:{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:my}}}})})}}}})})})]})};function yo(){const{workflow:e}=G();return ge.get(e.type)}function go(){return Array.from(ge.getEntities()).map(r=>{var[e,s]=r,a=s,{title:t}=a,o=W(a,["title"]);return{value:e,label:t,color:"gold",options:o}})}const Ae={label:"label",value:"value",children:"children"},Ft={label:`{{t("Node result", { ns: "${d}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const t=Te(),o=ct(t),r=[];return o.forEach(s=>{var c;const a=K.get(s.type),l=(c=a.useVariables)==null?void 0:c.call(a,s,e);l&&r.push(l)}),r}},It={label:`{{t("Trigger variables", { ns: "${d}" })}}`,value:"$context",useOptions(e){var r,s;const{workflow:t}=G(),o=ge.get(t.type);return(s=(r=o==null?void 0:o.useVariables)==null?void 0:r.call(o,t.config,e))!=null?s:null}},vo={label:`{{t("Scope variables", { ns: "${d}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Ae,current:o}=e,r=Te(),s=o!=null?o:r,a=Fn(s),l=[];return a.forEach(c=>{var f,g;const u=K.get(c.type),p=(f=u.useScopeVariables)==null?void 0:f.call(u,c,e);p&&l.push({key:c.key,[t.value]:c.key,[t.label]:(g=c.title)!=null?g:`#${c.id}`,[t.children]:p})}),l}},un={label:`{{t("System variables", { ns: "${d}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=Ae}){return[...!e||e.includes("date")?[{key:"now",[t.label]:
|
|
452
|
+
`},properties:w},actions:v({},h?{}:{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:my}}}})})}}}})})})]})};function yo(){const{workflow:e}=G();return ge.get(e.type)}function go(){return Array.from(ge.getEntities()).map(r=>{var[e,s]=r,a=s,{title:t}=a,o=W(a,["title"]);return{value:e,label:t,color:"gold",options:o}})}const Ae={label:"label",value:"value",children:"children"},Ft={label:`{{t("Node result", { ns: "${d}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const t=Te(),o=ct(t),r=[];return o.forEach(s=>{var c;const a=K.get(s.type),l=(c=a.useVariables)==null?void 0:c.call(a,s,e);l&&r.push(l)}),r}},It={label:`{{t("Trigger variables", { ns: "${d}" })}}`,value:"$context",useOptions(e){var r,s;const{workflow:t}=G(),o=ge.get(t.type);return(s=(r=o==null?void 0:o.useVariables)==null?void 0:r.call(o,t.config,e))!=null?s:null}},vo={label:`{{t("Scope variables", { ns: "${d}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Ae,current:o}=e,r=Te(),s=o!=null?o:r,a=Fn(s),l=[];return a.forEach(c=>{var f,g;const u=K.get(c.type),p=(f=u.useScopeVariables)==null?void 0:f.call(u,c,e);p&&l.push({key:c.key,[t.value]:c.key,[t.label]:(g=c.title)!=null?g:`#${c.id}`,[t.children]:p})}),l}},un={label:`{{t("System variables", { ns: "${d}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=Ae}){return[...!e||e.includes("date")?[{key:"now",[t.label]:N("System time"),[t.value]:"now"}]:[]]}},qe={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function dn(e,t){var r,s,a,l,c,u;const o=typeof t;return o==="string"?(r=qe[t])==null?void 0:r.has(e.interface):o==="object"&&t.type==="reference"?bo(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 bo(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function xo(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(r=>r.startsWith(o)).map(r=>r.replace(o,""))}function Co({fields:e,types:t,appends:o,depth:r=1,compile:s,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(u=>dn(l,u)):!0;if(bo(l)){if(o===null)return r?c||Co({fields:wo(l.target,{compile:s,getCollectionFields:a}),types:t,depth:r-1,appends:o,compile:s,getCollectionFields:a}):!1;const u=xo(l,o),p=o.includes(l.name);return c?p:((u==null?void 0:u.length)||p)&&Co({fields:wo(l.target,{compile:s,getCollectionFields:a}),types:t,appends:u,compile:s,getCollectionFields:a}).length}else return c})}function Dt(e,t){var a,l;const o=i.useCompile(),r=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:r,disabled:!r||!r.length}}function pe(e={}){var s;const t=Object.assign({},Ae,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[Dt(vo,o),Dt(Ft,o),Dt(It,o),Dt(un,o)]}function wo(e,{compile:t,getCollectionFields:o}){var l,c,u,p,f,g,x;const r=o(e),s=[],a=[];r.forEach(h=>{h.isForeignKey?s.push(h):a.push(h)});for(let h=a.length-1;h>=0;h--){const m=a[h];if(m.type==="belongsTo"){const k=s.find(w=>w.name===m.foreignKey);k?a.splice(h,0,C(v(v({},m),k),{uiSchema:C(v({},m.uiSchema),{title:(l=m.uiSchema)!=null&&l.title?`${t((c=m.uiSchema)==null?void 0:c.title)} ID`:k.name})})):a.splice(h,0,C(v({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:C(v({},m.uiSchema),{title:(u=m.uiSchema)!=null&&u.title?`${t((p=m.uiSchema)==null?void 0:p.title)} ID`:m.name})}))}else if(m.type==="context"&&m.collectionName==="users"){const k=(f=a.find(w=>w.type==="belongsTo"&&w.target==="users"&&w.foreignKey===m.name))!=null?f:{};a.splice(h,0,C(v({},m),{type:m.dataType,interface:k.interface,uiSchema:C(v({},k.uiSchema),{title:(g=k.uiSchema)!=null&&g.title?`${t((x=k.uiSchema)==null?void 0:x.title)} ID`:m.name})}))}}return a.filter(h=>h.interface&&!h.hidden)}function gy(e){const t=xo(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=>dn(e.field,s))||(e.disabled=!0))}function be(e){const{fields:t,collection:o,types:r,appends:s=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:u=Ae}=e,p=wo(o,{compile:l,getCollectionFields:c}),f=t!=null?t:p,g=gy.bind({compile:l,getCollectionFields:c,fieldNames:u});return Co({fields:f,types:r,depth:a,appends:s,compile:l,getCollectionFields:c}).map(h=>{var T;const m=l(((T=h.uiSchema)==null?void 0:T.title)||h.name),k=xo(h,s),w=!bo(h)||k&&!k.length&&!s.includes(h.name)||!1;return{[u.label]:m,key:h.name,[u.value]:h.name,isLeaf:w,loadChildren:w?null:g,field:h,depth:a,appends:s,types:r}})}function it(o){var r=o,{variableOptions:e}=r,t=W(r,["variableOptions"]);const s=pe(e);return n.jsx(i.Variable.Input,v({scope:s},t))}function pn(o){var r=o,{variableOptions:e}=r,t=W(r,["variableOptions"]);const s=pe(e);return n.jsx(i.Variable.TextArea,v({scope:s},t))}function mn(o){var r=o,{variableOptions:e}=r,t=W(r,["variableOptions"]);const s=pe(e);return n.jsx(i.Variable.RawTextArea,v({scope:s},t))}function fn(o){var r=o,{variableOptions:e}=r,t=W(r,["variableOptions"]);const s=pe(e);return n.jsx(i.Variable.JSON,v({scope:s},t))}function lt({value:e,onChange:t,renderSchemaComponent:o}){const r=pe();return n.jsx(i.Variable.Input,{value:e,onChange:t,scope:r,children:o()})}const Je=()=>null;function vy(s){var a=s,{node:e,resultTitle:t,insert:o}=a,r=W(a,["node","resultTitle","insert"]);return n.jsx(i.SchemaInitializer.Item,C(v({},r),{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 by({dataSource:e}){var s;const t=F.useFieldSchema(),{execution:o}=G();if(!o)return t.title;const r=X.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeId]:l.result}),{})});return n.jsx("pre",{className:i.css`
|
|
453
453
|
margin: 0;
|
|
454
|
-
`,children:JSON.stringify(r,null,2)})}Je.Initializer=vy,Je.Result=by;function xy(e){return["hasMany","belongsToMany"].includes(e.type)}function Cy(){const e=i.useCompile();return[Ft,It].map(t=>{var r;const o=(r=t.useOptions({types:[xy],appends:null,depth:4}))==null?void 0:r.filter(Boolean);return{label:e(t.label),value:t.value,key:t.value,children:e(o),disabled:o&&!o.length}})}function wy(r){var s=r,{value:e,onChange:t}=s,o=W(s,["value","onChange"]);const{setValuesIn:a}=
|
|
454
|
+
`,children:JSON.stringify(r,null,2)})}Je.Initializer=vy,Je.Result=by;function xy(e){return["hasMany","belongsToMany"].includes(e.type)}function Cy(){const e=i.useCompile();return[Ft,It].map(t=>{var r;const o=(r=t.useOptions({types:[xy],appends:null,depth:4}))==null?void 0:r.filter(Boolean);return{label:e(t.label),value:t.value,key:t.value,children:e(o),disabled:o&&!o.length}})}function wy(r){var s=r,{value:e,onChange:t}=s,o=W(s,["value","onChange"]);const{setValuesIn:a}=F.useForm(),{getCollection:l}=i.useCollectionManager(),c=Cy(),[u,p]=y.useState(c),{associatedKey:f="",name:g}=e!=null?e:{};let x=[];const h=f.match(/^{{(.*)}}$/);h&&(x=[...h[1].trim().split(".").slice(0,-1),g]);const m=w=>J(this,null,function*(){var $;const T=w[w.length-1];!(($=T.children)!=null&&$.length)&&!T.isLeaf&&T.loadChildren&&(yield T.loadChildren(T),p(D=>[...D]))});y.useEffect(()=>{(()=>J(this,null,function*(){var $;if(!x||u.length<=1)return;let T=null;for(let D=0;D<x.length;D++){const M=x[D];try{D===0?T=u.find(_=>_.value===M):(T.loadChildren&&!(($=T.children)!=null&&$.length)&&(yield T.loadChildren(T)),T=T.children.find(_=>_.value===M))}catch(_){console.error(_)}}p([...u])}))()},[e,u.length]);const k=y.useCallback((w,T)=>{if(!(w!=null&&w.length)){a("collection",null),t({});return}const{field:$}=T.pop();if(!$||!["hasMany","belongsToMany"].includes($.type))return;const{collectionName:D,target:M,name:_}=$,P=l(D).fields.find(A=>A.primaryKey);a("collection",M),t({name:_,associatedKey:`{{${w.slice(0,-1).join(".")}.${P.name}}}`,associatedCollection:D})},[t]);return n.jsx(b.Cascader,C(v({},o),{value:x,options:u,onChange:k,loadData:m}))}const $y={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({},je),{"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]})}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{SchemaComponentContext:i.SchemaComponentContext,FilterDynamicComponent:lt,FieldsSelect:qt,ValueBlock:Je,AssociatedConfig:wy},useVariables({key:e,title:t},{types:o,fieldNames:r=Ae}){return o&&!o.some(s=>s in qe||Object.values(qe).some(a=>a.has(s)))?null:{[r.value]:e,[r.label]:t}},useInitializers(e){var t;return e.config.collection?{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:Je.Initializer,node:e,resultTitle:N("Query result")}:null}};function Nt(e){const s=e,{options:t=[]}=s,o=W(s,["options"]),r=i.useCompile();return n.jsx(b.Radio.Group,C(v({},o),{children:t.map(a=>n.jsxs(b.Radio,{value:a.value,children:[n.jsx("span",{className:i.css`
|
|
455
455
|
& + .anticon {
|
|
456
456
|
margin-left: 0.25em;
|
|
457
457
|
}
|
|
458
|
-
`,children:r(a.label)}),a.tooltip&&n.jsx(
|
|
458
|
+
`,children:r(a.label)}),a.tooltip&&n.jsx(b.Tooltip,{title:r(a.tooltip),children:n.jsx(O.QuestionCircleOutlined,{style:{color:"#666"}})})]},a.value))}))}const hn=e=>{const t=Xe.evaluators.get(e);return t&&t.link?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:i.css`
|
|
459
459
|
&:after {
|
|
460
460
|
content: ':';
|
|
461
461
|
}
|
|
462
462
|
& + a {
|
|
463
463
|
margin-left: 0.25em;
|
|
464
464
|
}
|
|
465
|
-
`,children:i.i18n.t("Syntax references")}),n.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};function Sy(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(r=>r.interface==="expression"):!1}const ky=({value:e,onChange:t})=>{const{t:o}=oe.useTranslation(),{getCollectionFields:r,getCollection:s}=i.useCollectionManager(),a=pe({types:[Sy.bind({getCollectionFields:r,getCollection:s})]});return n.jsxs(Se.FormLayout,{layout:"vertical",children:[n.jsx(Se.FormItem,{colon:!0,label:o("Expression type",{ns:d}),children:n.jsxs(
|
|
465
|
+
`,children:i.i18n.t("Syntax references")}),n.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};function Sy(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(r=>r.interface==="expression"):!1}const ky=({value:e,onChange:t})=>{const{t:o}=oe.useTranslation(),{getCollectionFields:r,getCollection:s}=i.useCollectionManager(),a=pe({types:[Sy.bind({getCollectionFields:r,getCollection:s})]});return n.jsxs(Se.FormLayout,{layout:"vertical",children:[n.jsx(Se.FormItem,{colon:!0,label:o("Expression type",{ns:d}),children:n.jsxs(b.Radio.Group,{value:e===!1?!1:e||"",onChange:l=>{t(l.target.value)},children:[n.jsx(b.Radio,{value:!1,children:o("Static",{ns:d})}),n.jsx(b.Radio,{value:e||"",children:o("Dynamic",{ns:d})})]})}),e!==!1?n.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:n.jsx(i.Variable.Input,{value:e||"",onChange:l=>t(l),scope:a})}):null]})},Ay={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:Xe.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":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(e,t,{form:o}){const{values:r}=o,{evaluate:s}=Xe.evaluators.get(r.engine),a=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(a),""}catch(l){return N("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":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}},view:{},scope:{renderEngineReference:hn},components:{WorkflowVariableInput:it,WorkflowVariableTextArea:pn,RadioWithTooltip:Nt,DynamicConfig:ky,ValueBlock:Je},useVariables({key:e,title:t},{types:o,fieldNames:r=i.defaultFieldNames}){return o&&!o.some(s=>s in qe||Object.values(qe).some(a=>a.has(s)))?null:{[r.value]:e,[r.label]:t}},useInitializers(e){var t;return{type:"item",title:(t=e.title)!=null?t:`#${e.id}`,component:Je.Initializer,node:e,resultTitle:N("Calculation result")}}},re=new X.Registry;re.register("equal",{name:"=",type:"boolean",group:"boolean"}),re.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),re.register("gt",{name:">",type:"boolean",group:"boolean"}),re.register("gte",{name:"≥",type:"boolean",group:"boolean"}),re.register("lt",{name:"<",type:"boolean",group:"boolean"}),re.register("lte",{name:"≤",type:"boolean",group:"boolean"}),re.register("add",{name:"+",type:"number",group:"number"}),re.register("minus",{name:"-",type:"number",group:"number"}),re.register("multiple",{name:"*",type:"number",group:"number"}),re.register("divide",{name:"/",type:"number",group:"number"}),re.register("mod",{name:"%",type:"number",group:"number"}),re.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),re.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),re.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),re.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),re.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),re.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),re.register("concat",{name:`{{t("concat", { ns: "${d}" })}}`,type:"string",group:"string"});const Ty=[{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 yn(e){return Array.from(re.getEntities()).filter(([t,o])=>o.group===e)}function Oy({calculator:e,operands:t=[],onChange:o}){const r=i.useCompile(),s=pe();return n.jsxs("fieldset",{className:i.css`
|
|
466
466
|
display: flex;
|
|
467
467
|
gap: 0.5em;
|
|
468
468
|
align-items: center;
|
|
469
469
|
flex-wrap: wrap;
|
|
470
|
-
`,children:[n.jsx(i.Variable.Input,{value:t[0],onChange:a=>o({calculator:e,operands:[a,t[1]]}),scope:s,useTypedConstant:!0}),n.jsx(
|
|
470
|
+
`,children:[n.jsx(i.Variable.Input,{value:t[0],onChange:a=>o({calculator:e,operands:[a,t[1]]}),scope:s,useTypedConstant:!0}),n.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:a=>o({operands:t,calculator:a}),placeholder:N("Calculator"),popupMatchSelectWidth:!1,children:Ty.filter(a=>!!yn(a.value).length).map(a=>n.jsx(b.Select.OptGroup,{label:r(a.title),children:yn(a.value).map(([l,{name:c}])=>n.jsx(b.Select.Option,{value:l,children:r(c)},l))},a.value))}),n.jsx(i.Variable.Input,{value:t[1],onChange:a=>o({calculator:e,operands:[t[0],a]}),scope:s,useTypedConstant:!0})]})}function Fy({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:r,operands:s=[]}=e;return n.jsxs("div",{className:i.css`
|
|
471
471
|
display: flex;
|
|
472
472
|
position: relative;
|
|
473
473
|
margin: 0.5em 0;
|
|
474
|
-
`,children:[e.group?n.jsx(gn,{value:e.group,onChange:a=>t(C(v({},e),{group:a}))}):n.jsx(Oy,{operands:s,calculator:r,onChange:t}),n.jsx(
|
|
474
|
+
`,children:[e.group?n.jsx(gn,{value:e.group,onChange:a=>t(C(v({},e),{group:a}))}):n.jsx(Oy,{operands:s,calculator:r,onChange:t}),n.jsx(b.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:n.jsx(O.CloseCircleOutlined,{})})]})}function gn({value:e,onChange:t}){const{t:o}=oe.useTranslation(),{type:r="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,f){s.splice(p,1,f),t(C(v({},e),{calculations:[...s]}))}return n.jsxs("div",{className:i.cx("node-type-condition-group",i.css`
|
|
475
475
|
position: relative;
|
|
476
476
|
width: 100%;
|
|
477
477
|
.node-type-condition-group {
|
|
@@ -490,14 +490,14 @@
|
|
|
490
490
|
width: auto;
|
|
491
491
|
min-width: 6em;
|
|
492
492
|
}
|
|
493
|
-
`,children:n.jsxs(oe.Trans,{children:["Meet ",n.jsxs(
|
|
493
|
+
`,children:n.jsxs(oe.Trans,{children:["Meet ",n.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:r,onChange:p=>t(C(v({},e),{type:p})),children:[n.jsx(b.Select.Option,{value:"and",children:"All"}),n.jsx(b.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),n.jsx("div",{className:"calculation-items",children:s.map((p,f)=>n.jsx(Fy,{value:p,onChange:u.bind(this,f),onRemove:()=>c(f)},`${p.calculator}_${f}`))}),n.jsxs("div",{className:i.css`
|
|
494
494
|
button {
|
|
495
495
|
padding: 0;
|
|
496
496
|
&:not(:last-child) {
|
|
497
497
|
margin-right: 1em;
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
`,children:[n.jsx(
|
|
500
|
+
`,children:[n.jsx(b.Button,{type:"link",onClick:a,children:o("Add condition")}),n.jsx(b.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function Iy({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return n.jsx(gn,{value:o.group,onChange:r=>t(C(v({},o),{group:r}))})}const Dy={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(Xe.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:r}=o,{evaluate:s}=Xe.evaluators.get(r.engine),a=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(a),""}catch(l){return N("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}=oe.useTranslation(),{nodes:r}=G(),{styles:s}=ae(),{id:a,config:{rejectOnFalse:l}}=t,c=r.find(p=>p.upstreamId===a&&p.branchIndex===1),u=r.find(p=>p.upstreamId===a&&p.branchIndex===0);return n.jsx(ut,{data:t,children:l?null:n.jsxs("div",{className:s.nodeSubtreeClass,children:[n.jsxs("div",{className:s.branchBlockClass,children:[n.jsx(Me,{from:t,entry:u,branchIndex:0}),n.jsx(Me,{from:t,entry:c,branchIndex:1})]}),n.jsxs("div",{className:s.conditionClass,children:[n.jsx("span",{style:{right:"4em"},children:o("No")}),n.jsx("span",{style:{left:"4em"},children:o("Yes")})]})]})})},scope:{renderEngineReference:hn,useWorkflowVariableOptions:pe},components:{CalculationConfig:Iy,CalculationExpression(e){const t=pe();return n.jsx(i.Variable.TextArea,v({scope:t},e))},RadioWithTooltip:Nt}};function Ny(e){const{getCollectionFields:t}=i.useCollectionManager(),{path:o}=F.useField(),r=o.segments[o.segments.length-1],{values:s}=F.useForm(),a=t(s==null?void 0:s.collection),{type:l}=a.find(p=>p.name===r),c=Array.isArray(e.value)?e.value.join(","):e.value;function u(p){const f=p.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(l)?f:f.split(/[,\s]+/))}return n.jsx(b.Input,C(v({},e),{value:c,onChange:u}))}const vn=F.observer(({value:e,disabled:t,onChange:o,filter:r})=>{const{token:s}=i.useToken(),{t:a}=oe.useTranslation(),l=i.useCompile(),c=F.useForm(),{getCollection:u,getCollectionFields:p}=i.useCollectionManager(),f=pe(),{values:g}=c,x=g==null?void 0:g.collection,h=p(x).filter($=>$.uiSchema),m=r?h.filter(r.bind(g)):h,k=y.useMemo(()=>m.filter($=>!e||!($.name in e)),[m,e]),w=t||c.disabled,T=y.useMemo(()=>({onClick:({key:$})=>{o(C(v({},e),{[$]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map($=>{var D,M;return{key:$.name,label:l((M=(D=$.uiSchema)==null?void 0:D.title)!=null?M:$.name)}})}),[o,k,e]);return n.jsx("fieldset",{className:i.css`
|
|
501
501
|
margin-top: 0.5em;
|
|
502
502
|
|
|
503
503
|
> .ant-formily-item {
|
|
@@ -507,14 +507,14 @@
|
|
|
507
507
|
line-height: 32px;
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
-
`,children:m.length?n.jsxs(i.CollectionProvider,{collection:u(
|
|
510
|
+
`,children:m.length?n.jsxs(i.CollectionProvider,{collection:u(x),children:[m.filter($=>e&&$.name in e).map($=>{var M,_;const D=["belongsTo","hasOne","hasMany","belongsToMany"].includes($.type)?Ny:i.CollectionField;return n.jsxs(b.Form.Item,{label:l((_=(M=$.uiSchema)==null?void 0:M.title)!=null?_:$.name),labelAlign:"left",className:i.css`
|
|
511
511
|
.ant-form-item-control-input-content {
|
|
512
512
|
display: flex;
|
|
513
513
|
}
|
|
514
|
-
`,children:[n.jsx(i.Variable.Input,{scope:f,value:e[$.name],changeOnSelect:!0,onChange:z=>{o(C(v({},e),{[$.name]:z}))},children:n.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[$.name]:{"x-component":
|
|
514
|
+
`,children:[n.jsx(i.Variable.Input,{scope:f,value:e[$.name],changeOnSelect:!0,onChange:z=>{o(C(v({},e),{[$.name]:z}))},children:n.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[$.name]:{"x-component":D,"x-validator"(){return""}}}}})}),w?null:n.jsx(b.Button,{"aria-label":"icon-close",type:"link",icon:n.jsx(O.CloseCircleOutlined,{}),onClick:()=>{var A;const I=e,{[A=$.name]:z}=I,P=W(I,[ns(A)]);o(P)}})]},$.name)}),k.length?n.jsx(b.Dropdown,{menu:T,children:n.jsx(b.Button,{icon:n.jsx(O.PlusOutlined,{}),children:a("Add field")})}):null]}):n.jsx("p",{style:{color:s.colorText},children:N("Please select collection first")})})},{displayName:"CollectionFieldSet"}),Py={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:_o,appends:Be}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{CollectionFieldset:vn},useVariables({key:e,title:t,config:o},r){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}`))||[]]},r),{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:_e,collection:e.config.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}:null},initializers:{}},bn=[{value:1e3,label:"Seconds"},{value:6e4,label:"Minutes"},{value:36e5,label:"Hours"},{value:864e5,label:"Days"},{value:6048e5,label:"Weeks"}];function Ey(e){return bn.slice().reverse().find(t=>!(e%t.value))}function My({value:e=6e4,onChange:t}){const o=Ey(e),r=Math.round(e/o.value);return n.jsxs("fieldset",{className:i.css`
|
|
515
515
|
display: flex;
|
|
516
516
|
gap: 0.5em;
|
|
517
|
-
`,children:[n.jsx(
|
|
517
|
+
`,children:[n.jsx(b.InputNumber,{min:1,value:r,onChange:s=>t(Math.round(s*o.value)),className:"auto-width"}),n.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:o.value,onChange:s=>t(Math.round(r*s)),className:"auto-width",children:bn.map(s=>n.jsx(b.Select.Option,{value:s.value,children:N(s.label)},s.value))})]})}const _y={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:ee.RESOLVED},{label:`{{t("Fail and exit", { ns: "${d}" })}}`,value:ee.FAILED}],required:!0,default:ee.RESOLVED}},view:{},scope:{},components:{Duration:My}};function $o(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 So(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return So(o);const[r]=Object.keys(o);if(!r||!o[r])return!1;const[s]=Object.keys(o[r]);return!(!s||typeof o[r][s]=="undefined")}):!1}const jy={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({},je),{"x-validator"(e){return So(e)?"":`{{t("Please add at least one condition", { ns: "${d}" })}}`}})}}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FilterDynamicComponent:lt}};function By(e,t){let o=e,r=null;for(let s=0;s<t.length;s++){const a=t[s],l=o.find(c=>c.value===a);if(!l)return null;r=l,!l.isLeaf&&l.loadChildren&&l.loadChildren(l),l.children&&(o=l.children)}return r}const Vy={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":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:["string","number","null"],className:i.css`
|
|
518
518
|
width: 100%;
|
|
519
519
|
|
|
520
520
|
.variable {
|
|
@@ -526,13 +526,13 @@
|
|
|
526
526
|
}
|
|
527
527
|
`},required:!0}},view:{},component:function({data:t}){var a;const{nodes:o}=G(),{styles:r}=ae(),s=o.find(l=>l.upstreamId===t.id&&l.branchIndex!=null);return n.jsx(ut,{data:t,children:n.jsx("div",{className:r.nodeSubtreeClass,children:n.jsxs("div",{className:i.cx(r.branchBlockClass,i.css`
|
|
528
528
|
padding-left: 20em;
|
|
529
|
-
`),children:[n.jsx(Me,{from:t,entry:s,branchIndex:(a=s==null?void 0:s.branchIndex)!=null?a:0}),n.jsxs("div",{className:r.branchClass,children:[n.jsx("div",{className:"workflow-branch-lines"}),n.jsx("div",{className:i.cx(r.addButtonClass,r.loopLineClass),children:n.jsx(F.ArrowUpOutlined,{})})]})]})})})},scope:{},components:{WorkflowVariableInput:it},useScopeVariables(e,t){const o=i.useCompile(),{target:r}=e.config;if(!r)return null;const{fieldNames:s=Ae}=t;let a={key:"item",[s.value]:"item",[s.label]:O("Loop target")};if(typeof r=="string"&&r.startsWith("{{")&&r.endsWith("}}")){const l=r.slice(2,-2).split(".").map(p=>p.trim()),c=[vo,Ft,It].map(p=>{const f=p.useOptions(C(v({},t),{current:e})).filter(Boolean);return{[s.label]:o(p.label),[s.value]:p.value,key:p.value,[s.children]:f,disabled:f&&!f.length}}),u=By(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 Ly(e){const{execution:t,nodes:o}=G(),r=y.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),s=y.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,{[r[u.nodeId]]:u.result}),{})}},[t]);return y.useMemo(()=>X.parse(e)(s),[t])}function xn(e){const t=I.useField(),o=y.useRef(null),{appends:r,updateAssociationValues:s}=i.useAssociationNames(),a=Ly(e.dataSource),l=y.useMemo(()=>se.createForm({values:a,readPretty:!0}),[a]),c={appends:r},u={loading:!1,data:{data:a}},f=i.useAPIClient().resource(e.collection),g=y.useContext(i.BlockRequestContext);return n.jsx(i.CollectionProvider,{collection:e.collection,children:n.jsx(i.RecordProvider,{record:a,parent:!1,children:n.jsx(i.BlockRequestContext.Provider,{value:{block:"form",field:t,service:u,resource:f,__parent:g},children:n.jsx(i.FormBlockContext.Provider,{value:{params:c,form:l,field:t,service:u,updateAssociationValues:s,formBlockRef:o},children:e.children})})})})}function Cn(e){var $,P,M;const t=i.useRecord(),o=I.useFieldSchema(),r=I.useField(),s=y.useRef(null),{appends:a,updateAssociationValues:l}=i.useAssociationNames(),[c]=Object.keys(($=o.toJSON().properties)!=null?$:{}),u=(P=t==null?void 0:t.result)==null?void 0:P[c],{findComponent:p}=i.useDesignable(),f=p((M=r.component)==null?void 0:M[0])||y.Fragment,g=y.useMemo(()=>se.createForm({initialValues:u}),[u]),b=y.useMemo(()=>v({appends:a},e.params),[a,e.params]),h=y.useMemo(()=>({loading:!1,data:{data:u}}),[u]),k=i.useAPIClient().resource(e.collection),w=y.useContext(i.BlockRequestContext),T=y.useMemo(()=>({params:b,form:g,field:r,service:h,updateAssociationValues:l,formBlockRef:s}),[r,g,b,h,l]);return!t.status||u?n.jsx(i.CollectionProvider,{collection:e.collection,children:n.jsx(i.RecordProvider,{record:u,parent:!1,children:n.jsx(i.FormActiveFieldsProvider,{name:"form",children:n.jsx(i.BlockRequestContext.Provider,{value:{block:"form",props:e,field:r,service:h,resource:k,__parent:w},children:n.jsx(i.FormBlockContext.Provider,{value:T,children:n.jsxs(f,C(v({},r.componentProps),{children:[n.jsx(i.FormV2.Templates,{style:{marginBottom:18},form:g}),n.jsx("div",{ref:s,children:n.jsx(I.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})}):null}function zy(r){var s=r,{insert:e,schema:t}=s,o=W(s,["insert","schema"]);const{getTemplateSchemaByMode:a}=i.useSchemaTemplateManager(),l=i.useRecordCollectionDataSourceItems("FormItem");function c(p){return J(this,arguments,function*({item:u}){const f=u.template?yield a(u):null,g=i.createFormBlockSchema(C(v({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:ee.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},t),{template:f}));delete g["x-acl-action-props"],delete g["x-acl-action"];const[b]=Object.keys(g.properties);g.properties[b].properties.actions["x-decorator"]="ActionBarProvider",g.properties[b].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},Jt(g,h=>{h["x-uid"]&&delete h["x-uid"]}),e(g)})}return n.jsx(i.SchemaInitializer.Item,C(v({},o),{onClick:c,items:l}))}function wn(e){var t;return n.jsx(i.CollectionProvider,{collection:(t=e.schema)==null?void 0:t.collection,children:n.jsx(zy,v({},e))})}function Wy(){const{name:e,title:t}=i.useCollection();return n.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[n.jsx(i.SchemaSettings.BlockTitleItem,{}),n.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),n.jsx(i.SchemaSettings.DataTemplates,{collectionName:e}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Uy={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:wn}))}]}},initializers:{},components:{CreateFormDesigner:Wy},parseFormOptions(e){const t={};return ke(e,r=>r["x-decorator"]==="FormBlockProvider"&&r["x-decorator-props"].formType==="create").forEach(r=>{var l;const[s]=Object.keys(r.properties),a=r.properties[s];t[s]={type:"create",title:((l=r["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:r["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function $n(e){var p,f,g,b;const[t,o]=y.useState((f=(p=e.collection)==null?void 0:p.fields)!=null?f:[]),r=i.useRecord(),s=I.useField(),a=I.useFieldSchema(),[l]=Object.keys((g=a.toJSON().properties)!=null?g:{}),c=(b=r==null?void 0:r.result)==null?void 0:b[l],u=y.useMemo(()=>se.createForm({initialValues:c}),[c]);return!r.status||c?n.jsx(i.CollectionProvider,{collection:C(v({},e.collection),{fields:t}),children:n.jsx(i.RecordProvider,{record:c,parent:!1,children:n.jsx(i.FormBlockContext.Provider,{value:{form:u,field:s,setCollectionFields:o},children:e.children})})}):null}function Gy(o){var r=o,{insert:e}=r,t=W(r,["insert"]);return n.jsx(i.SchemaInitializer.Item,C(v({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:X.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[X.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:ee.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const Sn={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 Hy(e){const t={};return Object.keys(e).forEach(o=>{const r=e[o],{group:s="others"}=r;t[s]=t[s]||{},$e.set(t,[s,o],r)}),Object.keys(Sn).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:Sn[o],children:Object.keys(t[o]||{}).map(r=>{const s=t[o][r];return v({value:r,title:s.title,name:r},t[o][r])}).sort((r,s)=>r.order-s.order)}))}function Ky(){const{interfaces:e}=i.useCollectionManager();return Hy(e).map(o=>({key:o.title,type:"itemGroup",title:o.title,children:o.children.map(r=>({key:r.name,type:"item",title:r.title,component:Jy,fieldInterface:r.name}))}))}const kn=y.createContext({});function qy(e){const{insertPosition:t="beforeEnd",component:o}=e,r=Ky(),s=y.useContext(i.CollectionContext),[a,l]=y.useState(null),[c,u]=y.useState(),{setCollectionFields:p}=y.useContext(i.FormBlockContext);return n.jsxs(kn.Provider,{value:{onAddField(f){const k=$e.cloneDeep(f),{properties:w}=k,T=w,{unique:g,type:b}=T,h=W(T,["unique","type"]),m=W(k,["properties"]);delete h.name["x-disabled"],l(C(v({},m),{properties:h}))},setCallback:u},children:[n.jsx(i.SchemaInitializer.Button,{wrap:i.gridRowColWrap,insertPosition:t,items:r,component:o,title:"{{t('Configure fields')}}"}),n.jsx(i.ActionContextProvider,{value:{visible:!!a},children:a?n.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 f=I.useForm();return{run(){return J(this,null,function*(){u(null),l(null),f.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:f,query:g}=I.useForm();return{run(){return J(this,null,function*(){var T,$,P,M;const{default:h}=a,m=X.uid();if(h.name=(T=f.name)!=null?T:m,h.uiSchema.title=(P=($=f.uiSchema)==null?void 0:$.title)!=null?P:m,h.interface=a.name,(M=s.fields)==null?void 0:M.find(_=>_.name===h.name)){g("name").take().setFeedback({type:"error",messages:[O("Field name existed in form")]});return}const w=X.merge(h,f);p([...s.fields,w]),c({name:h.name,type:h.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:w},"x-collection-field":`${s.name}.${h.name}`,"x-designer":"FormItem.Designer"}),u(null),l(null)})}}}}}}}})},components:{ArrayTable:Se.ArrayTable}}):null})]})}function Jy(e){const{item:t,insert:o}=e,{onAddField:r,setCallback:s}=y.useContext(kn),{getInterface:a}=i.useCollectionManager(),l=a(t.fieldInterface);return n.jsx(i.SchemaInitializer.Item,{onClick:()=>{s(()=>o),r(l)}},t.fieldInterface)}const An={title:`{{t("Custom form", { ns: "${d}" })}}`,config:{useInitializer(){return{key:"customForm",type:"item",title:`{{t("Custom form", { ns: "${d}" })}}`,component:Gy}},initializers:{AddCustomFormField:qy},components:{CustomFormBlockProvider:$n},parseFormOptions(e){const t={};return ke(e,r=>r["x-decorator"]==="CustomFormBlockProvider").forEach(r=>{var c;const[s]=Object.keys(r.properties),a=r.properties[s],l=ke(a.properties.grid,u=>u["x-component"]==="CollectionField",!0);r["x-decorator-props"].collection.fields=l.map(u=>{var p,f;return(f=(p=u["x-component-props"])==null?void 0:p.field)!=null?f:u["x-interface-options"]}),t[s]={type:"custom",title:((c=r["x-component-props"])==null?void 0:c.title)||s,actions:ke(a.properties.actions,u=>u["x-component"]==="Action").map(u=>{var p,f;return{status:u["x-decorator-props"].value,values:(f=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:u.name}}),collection:r["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:$n}}};function Yy(){const{name:e,title:t}=i.useCollection(),o=I.useFieldSchema(),{t:r}=oe.useTranslation(),{dn:s}=i.useDesignable();return n.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[n.jsx(i.SchemaSettings.BlockTitleItem,{}),n.jsx(i.SchemaSettings.ActionModalItem,{title:r("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()}}),n.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Zy={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:wn}))}]}},initializers:{},components:{FilterDynamicComponent:lt,UpdateFormDesigner:Yy},parseFormOptions(e){const t={};return ke(e,r=>r["x-decorator"]==="FormBlockProvider"&&r["x-decorator-props"].formType==="update").forEach(r=>{var l;const[s]=Object.keys(r.properties),a=r.properties[s];t[s]=C(v({},r["x-decorator-props"]),{type:"update",title:((l=r["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 X.Registry;Ce.register("customForm",An),Ce.register("createForm",Uy),Ce.register("updateForm",Zy);function Qy(){const{workflow:e}=G(),t=yo();return t.useInitializers?t.useInitializers(e.config):null}const Xy={customForm:An.title,record:`{{t("Data record", { ns: "${d}" })}}`};function Ry(){var r,s;const e=I.useFieldSchema(),t=(s=Xy[(r=e["x-designer-props"])==null?void 0:r.type])!=null?s:'{{t("Block")}}',o=i.useCompile();return n.jsxs(i.GeneralSchemaDesigner,{title:o(t),children:[n.jsx(i.SchemaSettings.BlockTitleItem,{}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}function eg(e){const{collections:t}=i.useCollectionManager(),o=Te(),r=ct(o),s=[Qy()].filter(Boolean),a=r.map(u=>{var f;const p=K.get(u.type);return(f=p==null?void 0:p.useInitializers)==null?void 0:f.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 n.jsx(i.SchemaInitializer.Button,C(v({},e),{wrap:i.gridRowColWrap,items:c,title:"{{t('Add block')}}"}))}function tg(){var w,T,$;const e=y.useContext(i.SchemaComponentContext),{t}=oe.useTranslation(),o=I.useFieldSchema(),r=pe(),[s,a]=y.useState(!1),[l,c]=y.useState(($=(T=(w=o==null?void 0:o["x-action-settings"])==null?void 0:w.assignedValues)==null?void 0:T.schema)!=null?$:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[u,p]=y.useState(null),{components:f}=i.useSchemaOptionsContext();y.useEffect(()=>{p(new I.Schema({properties:{grid:l}}))},[l]);const g=y.useMemo(()=>{var M,_;const P=(_=(M=o==null?void 0:o["x-action-settings"])==null?void 0:M.assignedValues)==null?void 0:_.values;return se.createForm({initialValues:X.lodash.cloneDeep(P),values:X.lodash.cloneDeep(P)})},[]),b=i.useFormActiveFields(),h=t("Assign field values");function m(){a(!1)}function k(){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=g.values,a(!1),setTimeout(()=>{var P;(P=e.refresh)==null||P.call(e)},300)}return n.jsxs(n.Fragment,{children:[n.jsx(i.SchemaSettings.Item,{title:h,onClick:()=>a(!0),children:h}),n.jsx(x.Modal,{width:"50%",title:h,open:s,onCancel:m,footer:n.jsxs(x.Space,{children:[n.jsx(x.Button,{onClick:m,children:t("Cancel")}),n.jsx(x.Button,{type:"primary",onClick:k,children:t("Submit")})]}),children:n.jsx(i.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:n.jsx(i.VariableScopeProvider,{scope:r,children:n.jsx(i.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:b==null?void 0:b.getActiveFieldsName,children:n.jsx(I.FormProvider,{form:g,children:n.jsxs(Se.FormLayout,{layout:"vertical",children:[n.jsx(x.Alert,{message:O("Values preset in this form will override user submitted ones when continue or reject.")}),n.jsx("br",{}),s&&u&&n.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{refresh(){c(X.lodash.get(u.toJSON(),"properties.grid"))}}),children:n.jsx(i.SchemaComponent,{schema:u,components:f})})]})})})})})})]})}function og(e){return n.jsxs(i.GeneralSchemaDesigner,C(v({},e),{disableInitializer:!0,children:[n.jsx(i.Action.Designer.ButtonEditor,{}),n.jsx(tg,{}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function rg(s){var a=s,{action:e,actionProps:t,insert:o}=a,r=W(a,["action","actionProps","insert"]);return n.jsx(i.SchemaInitializer.Item,C(v({},r),{onClick:()=>{o({type:"void",title:r.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 Tn(r){var s=r,{action:e,actionProps:t}=s,o=W(s,["action","actionProps"]);return n.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 ng(e){return n.jsx(i.SchemaInitializer.Button,C(v({},e),{items:[{key:ee.RESOLVED,type:"item",title:`{{t("Continue the process", { ns: "${d}" })}}`,component:rg,action:ee.RESOLVED,actionProps:{type:"primary"}},{key:ee.REJECTED,type:"item",title:`{{t("Terminate the process", { ns: "${d}" })}}`,component:Tn,action:ee.REJECTED,actionProps:{danger:!0}},{key:ee.PENDING,type:"item",title:`{{t("Save temporarily", { ns: "${d}" })}}`,component:Tn,action:ee.PENDING}],title:"{{t('Configure actions')}}"}))}function sg(){return{run(){}}}function ag({value:e,onChange:t}){const o=y.useContext(i.SchemaComponentContext),r=yo(),s=Te(),a=ct(s),l=I.useForm(),{workflow:c}=G(),u={},p={};a.forEach(b=>{const h=K.get(b.type);Object.assign(u,h.initializers),Object.assign(p,h.components)});const f=y.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:{}}}}}}}}}}),[]),g=y.useCallback(function(){const{tabs:h}=X.lodash.get(f.toJSON(),"properties.drawer.properties"),m=Array.from(Ce.getValues()).reduce((k,w)=>Object.assign(k,w.config.parseFormOptions(h)),{});l.setValuesIn("forms",m),t(h.properties)},[l,t,f]);return n.jsx(i.SchemaComponentContext.Provider,{value:C(v({},o),{designable:!c.executed,refresh:g}),children:n.jsx(i.SchemaInitializerProvider,{initializers:v(v(v({AddBlockButton:eg,AddActionButton:ng},r.initializers),u),Array.from(Ce.getValues()).reduce((b,h)=>Object.assign(b,h.config.initializers),{})),children:n.jsx(i.SchemaComponent,{schema:f,components:C(v(v({},p),Array.from(Ce.getValues()).reduce((b,h)=>Object.assign(b,h.config.components),{})),{FormBlockProvider:Cn,DetailsBlockProvider:xn,ManualActionStatusProvider(b){return b.children},ActionBarProvider(b){return b.children},SimpleDesigner:Ry,ManualActionDesigner:og}),scope:{useSubmit:sg,useDetailsBlockProps:i.useFormBlockContext}})})})}function ig(e){const{workflow:t}=G(),[o,r]=y.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(x.Button,{type:"primary",onClick:()=>r(!0),children:t.executed?O("View user interface"):O("Configure user interface")}),n.jsx(i.ActionContextProvider,{value:{visible:o,setVisible:r,formValueChanged:!1},children:e.children})]})}function lg({value:e,onChange:t}){return n.jsxs("fieldset",{className:i.css`
|
|
529
|
+
`),children:[n.jsx(Me,{from:t,entry:s,branchIndex:(a=s==null?void 0:s.branchIndex)!=null?a:0}),n.jsxs("div",{className:r.branchClass,children:[n.jsx("div",{className:"workflow-branch-lines"}),n.jsx("div",{className:i.cx(r.addButtonClass,r.loopLineClass),children:n.jsx(O.ArrowUpOutlined,{})})]})]})})})},scope:{},components:{WorkflowVariableInput:it},useScopeVariables(e,t){const o=i.useCompile(),{target:r}=e.config;if(!r)return null;const{fieldNames:s=Ae}=t;let a={key:"item",[s.value]:"item",[s.label]:N("Loop target")};if(typeof r=="string"&&r.startsWith("{{")&&r.endsWith("}}")){const l=r.slice(2,-2).split(".").map(p=>p.trim()),c=[vo,Ft,It].map(p=>{const f=p.useOptions(C(v({},t),{current:e})).filter(Boolean);return{[s.label]:o(p.label),[s.value]:p.value,key:p.value,[s.children]:f,disabled:f&&!f.length}}),u=By(c,l);a=Object.assign({},u,a)}return[a,{key:"index",[s.value]:"index",[s.label]:N("Loop index")},{key:"length",[s.value]:"length",[s.label]:N("Loop length")}]}};function Ly(e){const{execution:t,nodes:o}=G(),r=y.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),s=y.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,{[r[u.nodeId]]:u.result}),{})}},[t]);return y.useMemo(()=>X.parse(e)(s),[t])}function xn(e){const t=F.useField(),o=y.useRef(null),{appends:r,updateAssociationValues:s}=i.useAssociationNames(),a=Ly(e.dataSource),l=y.useMemo(()=>se.createForm({values:a,readPretty:!0}),[a]),c={appends:r},u={loading:!1,data:{data:a}},f=i.useAPIClient().resource(e.collection),g=y.useContext(i.BlockRequestContext);return n.jsx(i.CollectionProvider,{collection:e.collection,children:n.jsx(i.RecordProvider,{record:a,parent:!1,children:n.jsx(i.BlockRequestContext.Provider,{value:{block:"form",field:t,service:u,resource:f,__parent:g},children:n.jsx(i.FormBlockContext.Provider,{value:{params:c,form:l,field:t,service:u,updateAssociationValues:s,formBlockRef:o},children:e.children})})})})}function Cn(e){var $,D,M;const t=i.useRecord(),o=F.useFieldSchema(),r=F.useField(),s=y.useRef(null),{appends:a,updateAssociationValues:l}=i.useAssociationNames(),[c]=Object.keys(($=o.toJSON().properties)!=null?$:{}),u=(D=t==null?void 0:t.result)==null?void 0:D[c],{findComponent:p}=i.useDesignable(),f=p((M=r.component)==null?void 0:M[0])||y.Fragment,g=y.useMemo(()=>se.createForm({initialValues:u}),[u]),x=y.useMemo(()=>v({appends:a},e.params),[a,e.params]),h=y.useMemo(()=>({loading:!1,data:{data:u}}),[u]),k=i.useAPIClient().resource(e.collection),w=y.useContext(i.BlockRequestContext),T=y.useMemo(()=>({params:x,form:g,field:r,service:h,updateAssociationValues:l,formBlockRef:s}),[r,g,x,h,l]);return!t.status||u?n.jsx(i.CollectionProvider,{collection:e.collection,children:n.jsx(i.RecordProvider,{record:u,parent:!1,children:n.jsx(i.FormActiveFieldsProvider,{name:"form",children:n.jsx(i.BlockRequestContext.Provider,{value:{block:"form",props:e,field:r,service:h,resource:k,__parent:w},children:n.jsx(i.FormBlockContext.Provider,{value:T,children:n.jsxs(f,C(v({},r.componentProps),{children:[n.jsx(i.FormV2.Templates,{style:{marginBottom:18},form:g}),n.jsx("div",{ref:s,children:n.jsx(F.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})}):null}function zy(r){var s=r,{insert:e,schema:t}=s,o=W(s,["insert","schema"]);const{getTemplateSchemaByMode:a}=i.useSchemaTemplateManager(),l=i.useRecordCollectionDataSourceItems("FormItem");function c(p){return J(this,arguments,function*({item:u}){const f=u.template?yield a(u):null,g=i.createFormBlockSchema(C(v({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:ee.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},t),{template:f}));delete g["x-acl-action-props"],delete g["x-acl-action"];const[x]=Object.keys(g.properties);g.properties[x].properties.actions["x-decorator"]="ActionBarProvider",g.properties[x].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},Jt(g,h=>{h["x-uid"]&&delete h["x-uid"]}),e(g)})}return n.jsx(i.SchemaInitializer.Item,C(v({},o),{onClick:c,items:l}))}function wn(e){var t;return n.jsx(i.CollectionProvider,{collection:(t=e.schema)==null?void 0:t.collection,children:n.jsx(zy,v({},e))})}function Wy(){const{name:e,title:t}=i.useCollection();return n.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[n.jsx(i.SchemaSettings.BlockTitleItem,{}),n.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),n.jsx(i.SchemaSettings.DataTemplates,{collectionName:e}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Uy={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:wn}))}]}},initializers:{},components:{CreateFormDesigner:Wy},parseFormOptions(e){const t={};return ke(e,r=>r["x-decorator"]==="FormBlockProvider"&&r["x-decorator-props"].formType==="create").forEach(r=>{var l;const[s]=Object.keys(r.properties),a=r.properties[s];t[s]={type:"create",title:((l=r["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:r["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function $n(e){var p,f,g,x;const[t,o]=y.useState((f=(p=e.collection)==null?void 0:p.fields)!=null?f:[]),r=i.useRecord(),s=F.useField(),a=F.useFieldSchema(),[l]=Object.keys((g=a.toJSON().properties)!=null?g:{}),c=(x=r==null?void 0:r.result)==null?void 0:x[l],u=y.useMemo(()=>se.createForm({initialValues:c}),[c]);return!r.status||c?n.jsx(i.CollectionProvider,{collection:C(v({},e.collection),{fields:t}),children:n.jsx(i.RecordProvider,{record:c,parent:!1,children:n.jsx(i.FormBlockContext.Provider,{value:{form:u,field:s,setCollectionFields:o},children:e.children})})}):null}function Gy(o){var r=o,{insert:e}=r,t=W(r,["insert"]);return n.jsx(i.SchemaInitializer.Item,C(v({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:X.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[X.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:ee.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const Sn={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 Hy(e){const t={};return Object.keys(e).forEach(o=>{const r=e[o],{group:s="others"}=r;t[s]=t[s]||{},$e.set(t,[s,o],r)}),Object.keys(Sn).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:Sn[o],children:Object.keys(t[o]||{}).map(r=>{const s=t[o][r];return v({value:r,title:s.title,name:r},t[o][r])}).sort((r,s)=>r.order-s.order)}))}function Ky(){const{interfaces:e}=i.useCollectionManager();return Hy(e).map(o=>({key:o.title,type:"itemGroup",title:o.title,children:o.children.map(r=>({key:r.name,type:"item",title:r.title,component:Jy,fieldInterface:r.name}))}))}const kn=y.createContext({});function qy(e){const{insertPosition:t="beforeEnd",component:o}=e,r=Ky(),s=y.useContext(i.CollectionContext),[a,l]=y.useState(null),[c,u]=y.useState(),{setCollectionFields:p}=y.useContext(i.FormBlockContext);return n.jsxs(kn.Provider,{value:{onAddField(f){const k=$e.cloneDeep(f),{properties:w}=k,T=w,{unique:g,type:x}=T,h=W(T,["unique","type"]),m=W(k,["properties"]);delete h.name["x-disabled"],l(C(v({},m),{properties:h}))},setCallback:u},children:[n.jsx(i.SchemaInitializer.Button,{wrap:i.gridRowColWrap,insertPosition:t,items:r,component:o,title:"{{t('Configure fields')}}"}),n.jsx(i.ActionContextProvider,{value:{visible:!!a},children:a?n.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 f=F.useForm();return{run(){return J(this,null,function*(){u(null),l(null),f.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:f,query:g}=F.useForm();return{run(){return J(this,null,function*(){var T,$,D,M;const{default:h}=a,m=X.uid();if(h.name=(T=f.name)!=null?T:m,h.uiSchema.title=(D=($=f.uiSchema)==null?void 0:$.title)!=null?D:m,h.interface=a.name,(M=s.fields)==null?void 0:M.find(_=>_.name===h.name)){g("name").take().setFeedback({type:"error",messages:[N("Field name existed in form")]});return}const w=X.merge(h,f);p([...s.fields,w]),c({name:h.name,type:h.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:w},"x-collection-field":`${s.name}.${h.name}`,"x-designer":"FormItem.Designer"}),u(null),l(null)})}}}}}}}})},components:{ArrayTable:Se.ArrayTable}}):null})]})}function Jy(e){const{item:t,insert:o}=e,{onAddField:r,setCallback:s}=y.useContext(kn),{getInterface:a}=i.useCollectionManager(),l=a(t.fieldInterface);return n.jsx(i.SchemaInitializer.Item,{onClick:()=>{s(()=>o),r(l)}},t.fieldInterface)}const An={title:`{{t("Custom form", { ns: "${d}" })}}`,config:{useInitializer(){return{key:"customForm",type:"item",title:`{{t("Custom form", { ns: "${d}" })}}`,component:Gy}},initializers:{AddCustomFormField:qy},components:{CustomFormBlockProvider:$n},parseFormOptions(e){const t={};return ke(e,r=>r["x-decorator"]==="CustomFormBlockProvider").forEach(r=>{var c;const[s]=Object.keys(r.properties),a=r.properties[s],l=ke(a.properties.grid,u=>u["x-component"]==="CollectionField",!0);r["x-decorator-props"].collection.fields=l.map(u=>{var p,f;return(f=(p=u["x-component-props"])==null?void 0:p.field)!=null?f:u["x-interface-options"]}),t[s]={type:"custom",title:((c=r["x-component-props"])==null?void 0:c.title)||s,actions:ke(a.properties.actions,u=>u["x-component"]==="Action").map(u=>{var p,f;return{status:u["x-decorator-props"].value,values:(f=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:u.name}}),collection:r["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:$n}}};function Yy(){const{name:e,title:t}=i.useCollection(),o=F.useFieldSchema(),{t:r}=oe.useTranslation(),{dn:s}=i.useDesignable();return n.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[n.jsx(i.SchemaSettings.BlockTitleItem,{}),n.jsx(i.SchemaSettings.ActionModalItem,{title:r("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()}}),n.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Zy={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:wn}))}]}},initializers:{},components:{FilterDynamicComponent:lt,UpdateFormDesigner:Yy},parseFormOptions(e){const t={};return ke(e,r=>r["x-decorator"]==="FormBlockProvider"&&r["x-decorator-props"].formType==="update").forEach(r=>{var l;const[s]=Object.keys(r.properties),a=r.properties[s];t[s]=C(v({},r["x-decorator-props"]),{type:"update",title:((l=r["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 X.Registry;Ce.register("customForm",An),Ce.register("createForm",Uy),Ce.register("updateForm",Zy);function Qy(){const{workflow:e}=G(),t=yo();return t.useInitializers?t.useInitializers(e.config):null}const Xy={customForm:An.title,record:`{{t("Data record", { ns: "${d}" })}}`};function Ry(){var r,s;const e=F.useFieldSchema(),t=(s=Xy[(r=e["x-designer-props"])==null?void 0:r.type])!=null?s:'{{t("Block")}}',o=i.useCompile();return n.jsxs(i.GeneralSchemaDesigner,{title:o(t),children:[n.jsx(i.SchemaSettings.BlockTitleItem,{}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}function eg(e){const{collections:t}=i.useCollectionManager(),o=Te(),r=ct(o),s=[Qy()].filter(Boolean),a=r.map(u=>{var f;const p=K.get(u.type);return(f=p==null?void 0:p.useInitializers)==null?void 0:f.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 n.jsx(i.SchemaInitializer.Button,C(v({},e),{wrap:i.gridRowColWrap,items:c,title:"{{t('Add block')}}"}))}function tg(){var w,T,$;const e=y.useContext(i.SchemaComponentContext),{t}=oe.useTranslation(),o=F.useFieldSchema(),r=pe(),[s,a]=y.useState(!1),[l,c]=y.useState(($=(T=(w=o==null?void 0:o["x-action-settings"])==null?void 0:w.assignedValues)==null?void 0:T.schema)!=null?$:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[u,p]=y.useState(null),{components:f}=i.useSchemaOptionsContext();y.useEffect(()=>{p(new F.Schema({properties:{grid:l}}))},[l]);const g=y.useMemo(()=>{var M,_;const D=(_=(M=o==null?void 0:o["x-action-settings"])==null?void 0:M.assignedValues)==null?void 0:_.values;return se.createForm({initialValues:X.lodash.cloneDeep(D),values:X.lodash.cloneDeep(D)})},[]),x=i.useFormActiveFields(),h=t("Assign field values");function m(){a(!1)}function k(){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=g.values,a(!1),setTimeout(()=>{var D;(D=e.refresh)==null||D.call(e)},300)}return n.jsxs(n.Fragment,{children:[n.jsx(i.SchemaSettings.Item,{title:h,onClick:()=>a(!0),children:h}),n.jsx(b.Modal,{width:"50%",title:h,open:s,onCancel:m,footer:n.jsxs(b.Space,{children:[n.jsx(b.Button,{onClick:m,children:t("Cancel")}),n.jsx(b.Button,{type:"primary",onClick:k,children:t("Submit")})]}),children:n.jsx(i.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:n.jsx(i.VariableScopeProvider,{scope:r,children:n.jsx(i.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:x==null?void 0:x.getActiveFieldsName,children:n.jsx(F.FormProvider,{form:g,children:n.jsxs(Se.FormLayout,{layout:"vertical",children:[n.jsx(b.Alert,{message:N("Values preset in this form will override user submitted ones when continue or reject.")}),n.jsx("br",{}),s&&u&&n.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{refresh(){c(X.lodash.get(u.toJSON(),"properties.grid"))}}),children:n.jsx(i.SchemaComponent,{schema:u,components:f})})]})})})})})})]})}function og(e){return n.jsxs(i.GeneralSchemaDesigner,C(v({},e),{disableInitializer:!0,children:[n.jsx(i.Action.Designer.ButtonEditor,{}),n.jsx(tg,{}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function rg(s){var a=s,{action:e,actionProps:t,insert:o}=a,r=W(a,["action","actionProps","insert"]);return n.jsx(i.SchemaInitializer.Item,C(v({},r),{onClick:()=>{o({type:"void",title:r.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 Tn(r){var s=r,{action:e,actionProps:t}=s,o=W(s,["action","actionProps"]);return n.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 ng(e){return n.jsx(i.SchemaInitializer.Button,C(v({},e),{items:[{key:ee.RESOLVED,type:"item",title:`{{t("Continue the process", { ns: "${d}" })}}`,component:rg,action:ee.RESOLVED,actionProps:{type:"primary"}},{key:ee.REJECTED,type:"item",title:`{{t("Terminate the process", { ns: "${d}" })}}`,component:Tn,action:ee.REJECTED,actionProps:{danger:!0}},{key:ee.PENDING,type:"item",title:`{{t("Save temporarily", { ns: "${d}" })}}`,component:Tn,action:ee.PENDING}],title:"{{t('Configure actions')}}"}))}function sg(){return{run(){}}}function ag({value:e,onChange:t}){const o=y.useContext(i.SchemaComponentContext),r=yo(),s=Te(),a=ct(s),l=F.useForm(),{workflow:c}=G(),u={},p={};a.forEach(x=>{const h=K.get(x.type);Object.assign(u,h.initializers),Object.assign(p,h.components)});const f=y.useMemo(()=>new F.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:{}}}}}}}}}}),[]),g=y.useCallback(function(){const{tabs:h}=X.lodash.get(f.toJSON(),"properties.drawer.properties"),m=Array.from(Ce.getValues()).reduce((k,w)=>Object.assign(k,w.config.parseFormOptions(h)),{});l.setValuesIn("forms",m),t(h.properties)},[l,t,f]);return n.jsx(i.SchemaComponentContext.Provider,{value:C(v({},o),{designable:!c.executed,refresh:g}),children:n.jsx(i.SchemaInitializerProvider,{initializers:v(v(v({AddBlockButton:eg,AddActionButton:ng},r.initializers),u),Array.from(Ce.getValues()).reduce((x,h)=>Object.assign(x,h.config.initializers),{})),children:n.jsx(i.SchemaComponent,{schema:f,components:C(v(v({},p),Array.from(Ce.getValues()).reduce((x,h)=>Object.assign(x,h.config.components),{})),{FormBlockProvider:Cn,DetailsBlockProvider:xn,ManualActionStatusProvider(x){return x.children},ActionBarProvider(x){return x.children},SimpleDesigner:Ry,ManualActionDesigner:og}),scope:{useSubmit:sg,useDetailsBlockProps:i.useFormBlockContext}})})})}function ig(e){const{workflow:t}=G(),[o,r]=y.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(b.Button,{type:"primary",onClick:()=>r(!0),disabled:!1,children:t.executed?N("View user interface"):N("Configure user interface")}),n.jsx(i.ActionContextProvider,{value:{visible:o,setVisible:r,formValueChanged:!1},children:e.children})]})}function lg({value:e,onChange:t}){return n.jsxs("fieldset",{className:i.css`
|
|
530
530
|
.ant-radio-group {
|
|
531
531
|
.anticon {
|
|
532
532
|
margin-left: 0.5em;
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
|
-
`,children:[n.jsx(
|
|
535
|
+
`,children:[n.jsx(b.Form.Item,{children:n.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:o}})=>{console.log(o),t(Number(o))},children:[n.jsx(b.Radio,{value:!0,children:n.jsxs(b.Tooltip,{title:N("Each user has own task"),placement:"bottom",children:[n.jsx("span",{children:N("Separately")}),n.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})}),n.jsx(b.Radio,{value:!1,children:n.jsxs(b.Tooltip,{title:N("Everyone shares one task"),placement:"bottom",children:[n.jsx("span",{children:N("Collaboratively")}),n.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?n.jsx("fieldset",{children:n.jsx(Se.FormLayout,{layout:"vertical",children:n.jsx(i.FormItem,{label:N("Negotiation"),children:n.jsxs(b.Radio.Group,{value:e,onChange:t,children:[n.jsx(b.Radio,{value:1,children:n.jsxs(b.Tooltip,{title:N("Everyone should pass"),placement:"bottom",children:[n.jsx("span",{children:N("All pass")}),n.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})}),n.jsx(b.Radio,{value:-1,children:n.jsxs(b.Tooltip,{title:N("Anyone pass"),placement:"bottom",children:[n.jsx("span",{children:N("Any pass")}),n.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})}):null]})}function cg(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function ug({multiple:e=!1,value:t=[],onChange:o}){const r=pe({types:[cg]});return n.jsx(i.Variable.Input,{scope:r,value:t[0],onChange:s=>{o([s])},children:n.jsx(i.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:s=>{o(s!=null?[s]:[])}})})}const On=i.BlockInitializers.items.find(e=>e.key==="media");On.children.find(e=>e.key==="workflowTodos")||On.children.push({key:"workflowTodos",type:"item",title:`{{t("Workflow todos", { ns: "${d}" })}}`,component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"});const dg={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:ig,SchemaConfig:ag,ModeConfig:lg,AssigneesSelect:ug},useVariables({key:e,title:t,config:o},{types:r,fieldNames:s=Ae}){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(f=>{var m;const g=o.forms[f],x=be({fields:(m=g.collection)==null?void 0:m.fields,collection:g.collection,types:r,compile:a,getCollectionFields:l}),h=a(g.title)||f;return x.length?{key:f,value:f,label:h,title:h,children:x}: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 r=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:_e,collection:l.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}.${a}}}`}:null}).filter(Boolean);return r.length?{key:"forms",type:"subMenu",title:e.title,children:r}:null},initializers:{}},pg={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}=ae(),{id:r,config:{mode:s}}=t,{workflow:a,nodes:l}=G(),c=l.reduce((h,m)=>m.upstreamId===r&&m.branchIndex!=null?h.concat(m):h,[]).sort((h,m)=>h.branchIndex-m.branchIndex),[u,p]=y.useState(Math.max(2,c.length)),{getAriaLabel:f}=Kt(t),g=Array(Math.max(0,u-c.length)).fill(null),x=c[c.length-1];return n.jsx(ut,{data:t,children:n.jsxs("div",{className:o.nodeSubtreeClass,children:[n.jsxs("div",{className:o.branchBlockClass,children:[c.map(h=>n.jsx(Me,{from:t,entry:h,branchIndex:h.branchIndex},h.id)),g.map((h,m)=>n.jsx(Me,{from:t,branchIndex:(x?x.branchIndex:0)+m+1,controller:c.length+m>1?n.jsx("div",{className:i.css`
|
|
536
536
|
padding-top: 2em;
|
|
537
537
|
|
|
538
538
|
> button {
|
|
@@ -540,9 +540,9 @@
|
|
|
540
540
|
transform: rotate(45deg);
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
-
`,children:n.jsx(
|
|
543
|
+
`,children:n.jsx(b.Button,{shape:"circle",icon:n.jsx(O.PlusOutlined,{}),onClick:()=>p(u-1),disabled:a.executed})}):null},`temp_${c.length+m}`))]}),n.jsx(b.Tooltip,{title:N("Add branch"),className:i.css`
|
|
544
544
|
visibility: ${a.executed?"hidden":"visible"};
|
|
545
|
-
`,children:n.jsx(
|
|
545
|
+
`,children:n.jsx(b.Button,{"aria-label":f("add-branch"),icon:n.jsx(O.PlusOutlined,{}),className:i.css`
|
|
546
546
|
position: relative;
|
|
547
547
|
top: 1em;
|
|
548
548
|
transform-origin: center;
|
|
@@ -552,10 +552,10 @@
|
|
|
552
552
|
transform-origin: center;
|
|
553
553
|
transform: rotate(-45deg);
|
|
554
554
|
}
|
|
555
|
-
`,onClick:()=>p(u+1),disabled:a.executed})})]})})},components:{RadioWithTooltip:
|
|
555
|
+
`,onClick:()=>p(u+1),disabled:a.executed})})]})})},components:{RadioWithTooltip:Nt}},mg={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:je,sort:ds,pagination:ps,appends:Be},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${d}" })}}`}},view:{},scope:{useCollectionDataSource:i.useCollectionDataSource,useSortableFields(){const e=i.useCompile(),{getCollectionFields:t,getInterface:o}=i.useCollectionManager(),{values:r}=F.useForm();return t(r.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:lt,SchemaComponentContext:i.SchemaComponentContext,WorkflowVariableInput:it},useVariables({key:e,title:t,config:o},r){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}`))||[]]},r),{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:_e,collection:e.config.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}},initializers:{}},fg={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":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${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":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${d}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","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:{},components:{ArrayItems:Se.ArrayItems,WorkflowVariableInput:it,WorkflowVariableJSON:fn},useVariables({key:e,title:t},{types:o,fieldNames:r=i.defaultFieldNames}){return{[r.value]:e,[r.label]:t}}},hg={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":"WorkflowVariableRawTextArea","x-component-props":{rows:20,className:i.css`
|
|
556
556
|
font-size: 80%;
|
|
557
557
|
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
558
|
-
`}}},scope:{},components:{WorkflowVariableRawTextArea:mn},useVariables({key:e,title:t},{types:o,fieldNames:r=i.defaultFieldNames}){return{[r.value]:e,[r.label]:t}}};function yg(o){var r=o,{onChange:e}=r,t=W(r,["onChange"]);const{getCollectionFields:s}=i.useCollectionManager(),a=
|
|
558
|
+
`}}},scope:{},components:{WorkflowVariableRawTextArea:mn},useVariables({key:e,title:t},{types:o,fieldNames:r=i.defaultFieldNames}){return{[r.value]:e,[r.label]:t}}};function yg(o){var r=o,{onChange:e}=r,t=W(r,["onChange"]);const{getCollectionFields:s}=i.useCollectionManager(),a=F.useForm(),{collection:l}=a.values,c=s(l),u=F.useField();function p({target:f}){const g=u.query(".values").take();if(!g)return;const x=c.reduce((h,m)=>(m.name in g.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(m.type))&&(h[m.name]=g.value[m.name]),h),{});a.setValuesIn("params.values",x),e(f.value)}return n.jsx(Nt,C(v({},t),{onChange:p}))}const gg={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({},je),{title:`{{t("Only update records matching conditions", { ns: "${d}" })}}`,"x-validator"(e){return So(e)?"":N("Please add at least one condition")}}),values:C(v({},_o),{"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:lt,CollectionFieldset:vn,IndividualHooksRadioWithTooltip:yg}},K=new X.Registry;K.register("calculation",Ay),K.register("condition",Dy),K.register("parallel",pg),K.register("loop",Vy),K.register("delay",_y),K.register("manual",dg),K.register("query",mg),K.register("create",Py),K.register("update",gg),K.register("destroy",jy),K.register("aggregate",$y),K.register("request",fg),K.register("sql",hg);function vg(){const e=F.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:r}=i.useResourceActionContext(),s=Te(),{workflow:a}=G();return{run(){return J(this,null,function*(){var c,u;if(a.executed){b.message.error(N("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.setFormValueChanged(!1),o.setVisible(!1),r()})}}}const ko=y.createContext({});function Te(){return y.useContext(ko)}function ct(e){const t=[];if(!e)return[];for(let o=e.upstream;o;o=o.upstream)t.push(o);return t}function Fn(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 In({data:e}){const{styles:t}=ae(),{getAriaLabel:o}=Kt(e),{component:r=ut}=K.get(e.type);return n.jsx(ko.Provider,{value:e,children:n.jsxs("div",{className:i.cx(t.nodeBlockClass),children:[n.jsx(r,{data:e}),n.jsx(Pn,{"aria-label":o(),upstream:e})]})})}function Dn(){var p;const{t:e}=oe.useTranslation(),t=i.useAPIClient(),{workflow:o,nodes:r,refresh:s}=(p=G())!=null?p:{},a=Te(),{modal:l}=b.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return J(this,null,function*(){function f(){return J(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:a.id}),s()})}const g=r.filter(m=>m===a?!1:X.parse(m.config).parameters.filter(({key:T})=>T.startsWith(`$jobsMapByNodeKey.${a.key}.`)||T===`$jobsMapByNodeKey.${a.key}`).length);if(g.length){l.error({title:N("Can not delete"),content:N("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:g.map(m=>`#${m.id}`).join(", ")})});return}const h=!r.find(m=>m.upstream===a&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):N("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:h,onOk:f})})}return o.executed?null:n.jsx(b.Button,{type:"text",shape:"circle",icon:n.jsx(O.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function Nn(){var a;const{execution:e,setViewJob:t}=G(),{jobs:o}=(a=Te())!=null?a:{},{styles:r}=ae();if(!e)return null;if(!o.length)return n.jsx(tt,{className:r.nodeJobButtonClass,disabled:!0});function s({key:l}){const c=o.find(u=>u.id==l);t(c)}return o.length>1?n.jsx(b.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:n.jsxs(n.Fragment,{children:[n.jsx(tt,{statusMap:Re,status:l.status}),n.jsx("time",{children:X.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:r.dropdownClass},children:n.jsx(tt,{statusMap:Re,status:o[o.length-1].status,className:r.nodeJobButtonClass})}):n.jsx(tt,{statusMap:Re,status:o[0].status,onClick:()=>t(o[0]),className:r.nodeJobButtonClass})}function bg(){return{form:F.useForm()}}function ut(e){var _,z;const{data:t,children:o}=e,r=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(_=G())!=null?_:{},{styles:c}=ae(),u=K.get(t.type),p=a.executed?'{{t("View")}}':'{{t("Configure")}}',f=r(u.title),[g,x]=y.useState((z=t.title)!=null?z:f),[h,m]=y.useState(!1),[k,w]=y.useState(!1),T=y.useMemo(()=>{const P=$e.cloneDeep(t.config);return se.createForm({initialValues:P,disabled:a.executed})},[t,a]),$=y.useCallback(P=>{m(P),P||T.reset()},[T]),D=y.useCallback(function(P){return J(this,null,function*(){var I,U;const A=P||f;x(A),A!==t.title&&(yield(U=(I=s.resource("flow_nodes")).update)==null?void 0:U.call(I,{filterByTk:t.id,values:{title:A}}),l())})},[t]),M=y.useCallback(function(P){if(P.target===P.currentTarget){m(!0);return}const A=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=P.target;I&&I!==P.currentTarget&&I!==document.documentElement;I=I.parentNode)if(Array.from(I.classList).some(U=>A.has(U))){m(!0),P.stopPropagation();return}},[]);return n.jsxs("div",{className:i.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[n.jsxs("div",{role:"button","aria-label":`${f}-${g}`,className:i.cx(c.nodeCardClass,{configuring:h}),onClick:M,children:[n.jsxs("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:[n.jsx(b.Tag,{children:f}),n.jsx("span",{className:"workflow-node-id",children:t.id})]}),n.jsx(b.Input.TextArea,{role:"button","aria-label":"textarea",disabled:a.executed,value:g,onChange:P=>x(P.target.value),onBlur:P=>D(P.target.value),autoSize:!0}),n.jsx(Dn,{}),n.jsx(Nn,{}),n.jsx(i.ActionContextProvider,{value:{visible:h,setVisible:$,formValueChanged:k,setFormValueChanged:w},children:n.jsx(i.FormProvider,{form:T,children:n.jsx(i.SchemaComponent,{scope:C(v({},u.scope),{useFormProviderProps:bg}),components:u.components,schema:{type:"void",properties:C(v({},u.view?{view:u.view}:{}),{button:{type:"void","x-content":p,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[`${u.type}_${t.id}`]:{type:"void",title:n.jsxs("div",{className:i.css`
|
|
559
559
|
display: flex;
|
|
560
560
|
justify-content: space-between;
|
|
561
561
|
|
|
@@ -570,7 +570,7 @@
|
|
|
570
570
|
code {
|
|
571
571
|
font-weight: normal;
|
|
572
572
|
}
|
|
573
|
-
`,children:[n.jsx("strong",{children:t.title}),n.jsx(
|
|
573
|
+
`,children:[n.jsx("strong",{children:t.title}),n.jsx(b.Tooltip,{title:N("Variable key of node"),children:n.jsx(b.Tag,{children:n.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},"x-component":"Action.Drawer",properties:C(v({},u.description?{description:{type:"void","x-component":Po,"x-component-props":{label:N("Node type"),title:u.title,description:u.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
574
574
|
.ant-input,
|
|
575
575
|
.ant-select,
|
|
576
576
|
.ant-cascader-picker,
|
|
@@ -582,17 +582,17 @@
|
|
|
582
582
|
min-width: 6em;
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
|
-
`},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:vg}}}}})}})}})})})]}),o]})}function
|
|
585
|
+
`},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:vg}}}}})}})}})})})]}),o]})}function Pn(e){var h;const{upstream:t,branchIndex:o=null}=e,r=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(h=G())!=null?h:{},c=Array.from(K.getValues()),{styles:u}=ae(),p=y.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(m=>c.filter(k=>k.group===m.key).length).map(m=>{const k=c.filter(w=>w.group===m.key&&(w.isAvailable?w.isAvailable({workflow:a,upstream:t,branchIndex:o}):!0));return C(v({},m),{type:"group",children:k.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(T=>({role:"button","aria-label":T.key,key:T.key,label:T.label})):null}))})}),[o,c,t,a]),f=y.useMemo(()=>a?s.resource("workflows.nodes",a.id):null,[a==null?void 0:a.id]),g=y.useCallback(k=>J(this,[k],function*({keyPath:m}){var M,_,z;const w=m.pop(),T={},[$]=m,D=K.get(w);if($){const{value:P}=(_=(M=D.options)==null?void 0:M.find(A=>A.key===$))!=null?_:{};Object.assign(T,typeof P=="function"?P():P)}f&&(yield f.create({values:{type:w,upstreamId:(z=t==null?void 0:t.id)!=null?z:null,branchIndex:o,title:r(D.title),config:T}}),l())}),[o,f==null?void 0:f.create,t==null?void 0:t.id]),x=y.useMemo(()=>({onClick:g,items:r(p)}),[p,g]);return a?n.jsx("div",{className:u.addButtonClass,children:n.jsx(b.Dropdown,{trigger:["click"],menu:x,disabled:a.executed,overlayClassName:i.css`
|
|
586
586
|
.ant-dropdown-menu-root {
|
|
587
587
|
max-height: 30em;
|
|
588
588
|
overflow-y: auto;
|
|
589
589
|
}
|
|
590
|
-
`,children:n.jsx(
|
|
590
|
+
`,children:n.jsx(b.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:n.jsx(O.PlusOutlined,{})})})}):null}function Me({from:e=null,entry:t=null,branchIndex:o=null,controller:r=null,className:s,end:a}){const{styles:l}=ae(),{getAriaLabel:c}=Kt(e,o),u=[];for(let p=t;p;p=p.downstream)u.push(p);return n.jsxs("div",{className:i.cx("workflow-branch",l.branchClass,s),children:[n.jsx("div",{className:"workflow-branch-lines"}),r,n.jsx(Pn,{"aria-label":c(),upstream:e,branchIndex:o}),n.jsx("div",{className:"workflow-node-list",children:u.map(p=>n.jsx(In,{data:p},p.id))}),a?n.jsx("div",{className:"end-sign",children:n.jsx(O.CloseOutlined,{})}):null]})}function En({entry:e}){const{styles:t}=ae(),{workflow:o}=G(),[r,s]=y.useState(100);return n.jsxs("div",{className:"workflow-canvas-wrapper",children:[n.jsx("div",{className:"workflow-canvas",style:{zoom:r/100},children:n.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
|
|
591
591
|
margin-top: 0 !important;
|
|
592
|
-
`),children:n.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?n.jsx(
|
|
592
|
+
`),children:n.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?n.jsx(b.Alert,{type:"warning",message:N("Executed workflow cannot be modified"),showIcon:!0,className:i.css`
|
|
593
593
|
margin-bottom: 1em;
|
|
594
594
|
`}):null,n.jsx(yy,{}),n.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
|
|
595
595
|
margin-top: 0 !important;
|
|
596
|
-
`),children:n.jsx(Me,{entry:e})}),n.jsx("div",{className:t.terminalClass,children:O("End")})]})})}),n.jsx("div",{className:"workflow-canvas-zoomer",children:n.jsx(x.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:r,onChange:s})})]})}const Ye=e=>`/admin/workflow/workflows/${e}`,Ao=e=>`/admin/workflow/executions/${e}`;function xg(e,t=[]){const o=new Map;e.forEach(r=>{r.jobs=[],o.set(r.id,r)}),t.forEach(r=>{const s=o.get(r.nodeId);s.jobs.push(r),r.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(r=>{r.jobs=r.jobs.sort((s,a)=>s.id-a.id)})}function Cg(){const e=i.useCompile(),{viewJob:t,setViewJob:o}=G(),{styles:r}=ae(),{node:s={}}=t!=null?t:{},a=K.get(s.type);return n.jsx(i.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:n.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:n.jsxs("div",{className:r.nodeTitleClass,children:[n.jsx(x.Tag,{children:e(a==null?void 0:a.title)}),n.jsx("strong",{children:s.title}),n.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:yt,"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:r.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function wg(e){const{execution:t}=G(),o=i.useAPIClient(),r=he.useNavigate(),{styles:s}=ae(),[a,l]=y.useState([]),[c,u]=y.useState([]);y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{l(f.data)}).catch(()=>{})},[t]),y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{u(f.data.reverse())}).catch(()=>{})},[t]);const p=y.useCallback(({key:f})=>{f!=t.id&&r(Ao(f))},[t]);return t?n.jsx(x.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(f=>({key:f.id,label:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"id",children:`#${f.id}`}),n.jsx("time",{children:X.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:n.jsx("span",{children:n.jsx(tt,{statusMap:ht,status:f.status})})}))},children:n.jsxs(x.Space,{children:[n.jsx("strong",{children:`#${t.id}`}),n.jsx(F.DownOutlined,{})]})}):null}function $g(){var m;const e=i.useCompile(),{data:t,loading:o}=i.useResourceActionContext(),{setTitle:r}=i.useDocumentTitle(),[s,a]=y.useState(null),l=i.useApp();if(y.useEffect(()=>{var P;const{workflow:$}=(P=t==null?void 0:t.data)!=null?P:{};r==null||r(`${$!=null&&$.title?`${$.title} - `:""}${O("Execution history")}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return o?n.jsx("div",{children:O("Loading")}):n.jsx("div",{children:O("Load failed")});const k=(m=t==null?void 0:t.data)!=null?m:{},{jobs:c=[],workflow:w={}}=k,T=w,{nodes:u=[],revisions:p=[]}=T,f=W(T,["nodes","revisions"]),g=W(k,["jobs","workflow"]);$o(u),xg(u,c);const b=u.find($=>!$.upstream),h=ht[g.status];return n.jsxs(et.Provider,{value:{workflow:f.type?f:null,nodes:u,execution:g,viewJob:s,setViewJob:a},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(x.Breadcrumb,{items:[{title:n.jsx(he.Link,{to:l.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(he.Link,{to:Ye(f.id),children:f.title})},{title:n.jsx(wg,{})}]})}),n.jsxs("aside",{children:[n.jsx(x.Tag,{color:h.color,children:e(h.label)}),n.jsx("time",{children:X.str2moment(g.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),n.jsx(En,{entry:b}),n.jsx(Cg,{})]})}const Mn=()=>{const e=he.useParams(),{styles:t}=ae();return n.jsx("div",{className:i.cx(t.workflowPageClass),children:n.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:$g}})})},_n=()=>{const{t:e}=oe.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return n.jsx(he.Link,{to:Ao(t),onClick:()=>o(!1),children:e("View")})},Sg={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 n.jsx(he.Link,{to:Ye(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:ft}}]},jn={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:Sg,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}=oe.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:r}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return J(this,null,function*(){var l;yield r.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 kg(r){var s=r,{request:e,filter:t={}}=s,o=W(s,["request","filter"]);var c;const{workflow:a}=G(),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 n.jsx(i.ResourceActionProvider,v({},l))}function Ag(){var z;const e=he.useNavigate(),{t}=oe.useTranslation(),o=i.useApp(),{data:r,refresh:s,loading:a}=i.useResourceActionContext(),{resource:l}=i.useResourceContext(),{setTitle:c}=i.useDocumentTitle(),[u,p]=y.useState(!1),{styles:f}=ae(),{modal:g}=x.App.useApp();if(y.useEffect(()=>{var D;const{title:A}=(D=r==null?void 0:r.data)!=null?D:{};c==null||c(`${O("Workflow")}${A?`: ${A}`:""}`)},[r==null?void 0:r.data]),!(r!=null&&r.data))return n.jsx("div",{children:O(a?"Loading":"Load failed")});const N=(z=r==null?void 0:r.data)!=null?z:{},{nodes:b=[],revisions:h=[]}=N,m=W(N,["nodes","revisions"]);$o(b);const k=b.find(A=>!A.upstream);function w({key:A}){A!=m.id&&e(Ye(A))}function T(A){return J(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:A}}),s()})}function $(){return J(this,null,function*(){const{data:{data:A}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});x.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${A.id}`)})}function P(){return J(this,null,function*(){const A=m.current?O("Delete a main version will cause all other revisions to be deleted too."):"";g.confirm({title:t("Are you sure you want to delete it?"),content:A,onOk(){return J(this,null,function*(){var U;yield l.destroy({filterByTk:m.id}),x.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):Ye((U=h.find(V=>V.current))==null?void 0:U.id))})}})})}function M(D){return J(this,arguments,function*({key:A}){switch(A){case"history":p(!0);return;case"revision":return $();case"delete":return P()}})}const _=m.executed&&!h.find(A=>!A.executed&&new Date(A.createdAt)>new Date(m.createdAt));return n.jsxs(et.Provider,{value:{workflow:m,nodes:b,refresh:s},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(x.Breadcrumb,{items:[{title:n.jsx(he.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx("strong",{children:m.title})}]})}),n.jsxs("aside",{children:[n.jsx("div",{className:"workflow-versions",children:n.jsx(x.Dropdown,{trigger:["click"],menu:{onClick:w,defaultSelectedKeys:[`${m.id}`],className:i.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((A,D)=>D.id-A.id).map((A,D)=>({role:"button","aria-label":`version-${D}`,key:`${A.id}`,icon:A.current?n.jsx(F.RightOutlined,{}):null,className:i.cx({executed:A.executed,unexecuted:!A.executed,enabled:A.enabled}),label:n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:`#${A.id}`}),n.jsx("time",{children:X.str2moment(A.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:n.jsxs(x.Button,{type:"text","aria-label":"version",children:[n.jsx("label",{children:O("Version")}),n.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),n.jsx(F.DownOutlined,{})]})})}),n.jsx(x.Switch,{checked:m.enabled,onChange:T,checkedChildren:O("On"),unCheckedChildren:O("Off")}),n.jsx(x.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:O("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:O("Copy to new version"),disabled:!_},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:M},children:n.jsx(x.Button,{"aria-label":"more",type:"text",icon:n.jsx(F.EllipsisOutlined,{})})}),n.jsx(i.ActionContextProvider,{value:{visible:u,setVisible:p},children:n.jsx(i.SchemaComponent,{schema:jn,components:{ExecutionResourceProvider:kg,ExecutionLink:_n}})})]})]}),n.jsx(En,{entry:k})]})}const Bn=()=>{const e=he.useParams(),{styles:t}=ae();return n.jsx("div",{className:i.cx(t.workflowPageClass),children:n.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:Ag}})})},Tg=r=>{var s=r,{request:e,filter:t={}}=s,o=W(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 n.jsx(i.ResourceActionProvider,v({},l))},Og=()=>{const{t:e}=oe.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:r}=i.useGetAriaLabelOfAction("Configure");return n.jsx(he.Link,{"aria-label":r(),to:Ye(t),onClick:()=>o(!1),children:e("Configure")})};function Fg(r){var s=r,{component:e="div",children:t}=s,o=W(s,["component","children"]);const[a,l]=y.useState(!1),c=I.useFieldSchema();return n.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[y.createElement(e,C(v({},o),{onClick(){l(!0)}}),t),n.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const{defaultProps:Ig}=i.interfacesProperties,Dg={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({},Ig)},Vn={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"}]},Oe={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}}}}},Pg={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Vn,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Vn},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:Oe.title,type:Oe.type,description:Oe.description,options:Oe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=i.useRecord();return y.createElement("a",v({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:jn}}}},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:Oe.title,enabled:Oe.enabled,description:Oe.description,options:Oe.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}=oe.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:r}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[r]:a}=i.useRecord(),{values:l}=I.useForm();return{run(){return J(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 Ln(e){var a;const o=i.useCompile()(e.label),r=y.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=ht[e.value])!=null?a:{};return n.jsx(x.Tag,{color:s,onMouseDown:r,closable:e.closable,onClose:e.onClose,children:o})}function Ng(e){const t=i.useCompile();return n.jsxs(n.Fragment,{children:[n.jsx(Ln,v({},e)),e.description?n.jsx("span",{children:t(e.description)}):null]})}function Eg(t){var e=W(t,[]);const o=e.multiple?"multiple":null;return n.jsx(x.Select,C(v({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Ln,children:ft.filter(r=>!!r.value&&r.value!==ye.ABORTED).map(r=>n.jsx(x.Select.Option,C(v({},r),{children:n.jsx(Ng,v({},r))}),r.value))}))}const Mg=y.createContext({});function _g(){const e=y.useContext(i.SchemaComponentContext);return n.jsx(x.Card,{bordered:!1,children:n.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{designable:!1}),children:n.jsx(i.SchemaComponent,{schema:Pg,components:{WorkflowLink:Og,ExecutionResourceProvider:Tg,ExecutionLink:_n,OpenDrawer:Fg,ExecutionStatusSelect:Eg},scope:{getTriggersOptions:go}})})})}const jg=e=>{const t=y.useContext(i.PluginManagerContext),o=y.useContext(i.CollectionManagerContext);return n.jsx(i.PluginManagerContext.Provider,{value:{components:v({},t==null?void 0:t.components)},children:n.jsx(i.CollectionManagerContext.Provider,{value:C(v({},o),{interfaces:C(v({},o.interfaces),{expression:Dg})}),children:n.jsx(Mg.Provider,{value:{triggers:ge,instructions:K},children:e.children})})})},Bg=I.observer(e=>{const{onChange:t}=e,o=I.useField(),r=I.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=y.useState(r.getValuesIn(a)),u=i.useCompile(),{getCollectionFields:p}=i.useCollectionManager();I.useFormEffects(()=>{se.onFormInitialValuesChange(g=>{c(g.getValuesIn(a))}),se.onFieldInputValueChange(a,g=>{c(g.value),t(null)})});const f=be({collection:l,compile:u,getCollectionFields:p});return n.jsx(i.Variable.TextArea,C(v({},e),{scope:f}))},{displayName:"InternalExpression"});function Vg(e){const{t}=oe.useTranslation(),o=i.useRecord(),r=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager(),a=y.useMemo(()=>be({collection:o.sourceCollection,compile:r,getCollectionFields:s}),[o.sourceCollection,o.sourceCollection]);return e.value?n.jsx(i.Variable.TextArea,C(v({},e),{scope:a})):n.jsx(x.Tag,{children:t("Unconfigured",{ns:d})})}const Lg=I.connect(Bg,I.mapReadPretty(Vg)),zg={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"}}]},Wg={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}}]},Ug={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:yt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Gg=I.observer(()=>{var t,o,r;const e=I.useField();return(r=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?r:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"NodeColumn"}),Hg=I.observer(()=>{var t,o,r;const e=I.useField();return(r=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?r:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"WorkflowColumn"}),Kg=I.observer(()=>{var t,o,r;const e=I.useField();return(r=(t=e==null?void 0:e.value)==null?void 0:t.nickname)!=null?r:(o=e.value)==null?void 0:o.id},{displayName:"UserColumn"}),To=()=>n.jsx(i.SchemaComponent,{components:{NodeColumn:Gg,WorkflowColumn:Hg,UserColumn:Kg},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 qg(e){var p;const{data:t}=i.useCurrentUserContext(),{userJob:o}=G(),{status:r,result:s,userId:a}=o,l=I.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:u}=e;return r?s[c]||(u=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==a&&(u=null),u}const Jg=y.createContext(null);function Yg({value:e,children:t}){const{userJob:o}=G(),r=I.useField(),s=I.useFieldSchema();return y.useEffect(()=>{o.status&&(r.disabled=!0,r.visible=o.status===e&&o.result._===s.name)},[o,e,r]),n.jsx(Jg.Provider,{value:e,children:t})}function Zg(){const e=i.useAPIClient(),{setVisible:t}=i.useActionContext(),{values:o,submit:r}=I.useForm(),s=I.useFieldSchema(),{service:a}=i.useTableBlockContext(),{userJob:l}=G(),{name:c}=s,{name:u}=s.parent.parent;return{run(){return J(this,null,function*(){l.status||(yield r(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[u]:o,_:c}}}),t(!1),a.refresh())})}}}function Qg(e){var p;const t=i.useAPIClient(),{id:o}=i.useRecord(),[r,s]=y.useState(null),[a,l]=y.useState(null);y.useEffect(()=>{var f,g;o&&((g=(f=t.resource("users_jobs")).get)==null||g.call(f,{filterByTk:o,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:b})=>{var $;const P=($=b==null?void 0:b.data)!=null?$:{},{node:h,workflow:M={}}=P,_=M,{nodes:m=[]}=_,k=W(_,["nodes"]),z=P,{execution:w}=z,T=W(z,["node","workflow","execution"]);$o(m),l(h),s({userJob:T,workflow:k,nodes:m,execution:w})}))},[o]);const u=ct(r==null?void 0:r.nodes.find(f=>f.id===a.id)).reduce((f,{type:g})=>Object.assign(f,K.get(g).components),{});return a&&r?n.jsx(et.Provider,{value:r,children:n.jsx(i.SchemaComponent,{components:v(v({FormBlockProvider:Cn,DetailsBlockProvider:xn,ActionBarProvider:qg,ManualActionStatusProvider:Yg},Array.from(Ce.getValues()).reduce((f,g)=>Object.assign(f,g.block.components),{})),u),scope:v({useSubmit:Zg,useFormBlockProps:Xg,useDetailsBlockProps:Rg},Array.from(Ce.getValues()).reduce((f,g)=>Object.assign(f,g.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=a.config)==null?void 0:p.schema}})}):n.jsx(x.Spin,{})}function Xg(){var a;const{userJob:e}=G(),t=i.useRecord(),{data:o}=i.useCurrentUserContext(),{form:r}=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 y.useEffect(()=>{r==null||r.setPattern(s)},[s,r]),{form:r}}function Rg(){const{form:e}=i.useFormBlockContext();return{form:e}}function ev(){const e=i.useCompile(),{status:t,updatedAt:o}=i.useRecord(),r=Re[t];return t?n.jsxs(x.Space,{children:[n.jsx("time",{className:i.css`
|
|
596
|
+
`),children:n.jsx(Me,{entry:e})}),n.jsx("div",{className:t.terminalClass,children:N("End")})]})})}),n.jsx("div",{className:"workflow-canvas-zoomer",children:n.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:r,onChange:s})})]})}const Ye=e=>`/admin/workflow/workflows/${e}`,Ao=e=>`/admin/workflow/executions/${e}`;function xg(e,t=[]){const o=new Map;e.forEach(r=>{r.jobs=[],o.set(r.id,r)}),t.forEach(r=>{const s=o.get(r.nodeId);s.jobs.push(r),r.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(r=>{r.jobs=r.jobs.sort((s,a)=>s.id-a.id)})}function Cg(){const e=i.useCompile(),{viewJob:t,setViewJob:o}=G(),{styles:r}=ae(),{node:s={}}=t!=null?t:{},a=K.get(s.type);return n.jsx(i.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:n.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${t==null?void 0:t.id}-${t==null?void 0:t.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:t},"x-component":"Action.Modal",title:n.jsxs("div",{className:r.nodeTitleClass,children:[n.jsx(b.Tag,{children:e(a==null?void 0:a.title)}),n.jsx("strong",{children:s.title}),n.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:yt,"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:r.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function wg(e){const{execution:t}=G(),o=i.useAPIClient(),r=he.useNavigate(),{styles:s}=ae(),[a,l]=y.useState([]),[c,u]=y.useState([]);y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{l(f.data)}).catch(()=>{})},[t]),y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{u(f.data.reverse())}).catch(()=>{})},[t]);const p=y.useCallback(({key:f})=>{f!=t.id&&r(Ao(f))},[t]);return t?n.jsx(b.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(f=>({key:f.id,label:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"id",children:`#${f.id}`}),n.jsx("time",{children:X.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:n.jsx("span",{children:n.jsx(tt,{statusMap:ht,status:f.status})})}))},children:n.jsxs(b.Space,{children:[n.jsx("strong",{children:`#${t.id}`}),n.jsx(O.DownOutlined,{})]})}):null}function $g(){var m;const e=i.useCompile(),{data:t,loading:o}=i.useResourceActionContext(),{setTitle:r}=i.useDocumentTitle(),[s,a]=y.useState(null),l=i.useApp();if(y.useEffect(()=>{var D;const{workflow:$}=(D=t==null?void 0:t.data)!=null?D:{};r==null||r(`${$!=null&&$.title?`${$.title} - `:""}${N("Execution history")}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return o?n.jsx(b.Spin,{}):n.jsx(b.Result,{status:"404",title:"Not found"});const k=(m=t==null?void 0:t.data)!=null?m:{},{jobs:c=[],workflow:w={}}=k,T=w,{nodes:u=[],revisions:p=[]}=T,f=W(T,["nodes","revisions"]),g=W(k,["jobs","workflow"]);$o(u),xg(u,c);const x=u.find($=>!$.upstream),h=ht[g.status];return n.jsxs(et.Provider,{value:{workflow:f.type?f:null,nodes:u,execution:g,viewJob:s,setViewJob:a},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(b.Breadcrumb,{items:[{title:n.jsx(he.Link,{to:l.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:n.jsx(he.Link,{to:Ye(f.id),children:f.title})},{title:n.jsx(wg,{})}]})}),n.jsxs("aside",{children:[n.jsx(b.Tag,{color:h.color,children:e(h.label)}),n.jsx("time",{children:X.str2moment(g.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),n.jsx(En,{entry:x}),n.jsx(Cg,{})]})}const Mn=()=>{const e=he.useParams(),{styles:t}=ae();return n.jsx("div",{className:i.cx(t.workflowPageClass),children:n.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:$g}})})},_n=()=>{const{t:e}=oe.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return n.jsx(he.Link,{to:Ao(t),onClick:()=>o(!1),children:e("View")})},Sg={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 n.jsx(he.Link,{to:Ye(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:ft}}]},jn={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:Sg,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}=oe.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:r}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return J(this,null,function*(){var l;yield r.destroy({filter:(l=o.params)==null?void 0:l.filter}),b.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${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 kg(r){var s=r,{request:e,filter:t={}}=s,o=W(s,["request","filter"]);var c;const{workflow:a}=G(),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 n.jsx(i.ResourceActionProvider,v({},l))}function Ag(){var z;const e=he.useNavigate(),{t}=oe.useTranslation(),o=i.useApp(),{data:r,refresh:s,loading:a}=i.useResourceActionContext(),{resource:l}=i.useResourceContext(),{setTitle:c}=i.useDocumentTitle(),[u,p]=y.useState(!1),{styles:f}=ae(),{modal:g}=b.App.useApp();if(y.useEffect(()=>{var I;const{title:A}=(I=r==null?void 0:r.data)!=null?I:{};c==null||c(`${N("Workflow")}${A?`: ${A}`:""}`)},[r==null?void 0:r.data]),!(r!=null&&r.data))return a?n.jsx(b.Spin,{}):n.jsx(b.Result,{status:"404",title:"Not found"});const P=(z=r==null?void 0:r.data)!=null?z:{},{nodes:x=[],revisions:h=[]}=P,m=W(P,["nodes","revisions"]);$o(x);const k=x.find(A=>!A.upstream);function w({key:A}){A!=m.id&&e(Ye(A))}function T(A){return J(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:A}}),s()})}function $(){return J(this,null,function*(){const{data:{data:A}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});b.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${A.id}`)})}function D(){return J(this,null,function*(){const A=m.current?N("Delete a main version will cause all other revisions to be deleted too."):"";g.confirm({title:t("Are you sure you want to delete it?"),content:A,onOk(){return J(this,null,function*(){var U;yield l.destroy({filterByTk:m.id}),b.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):Ye((U=h.find(V=>V.current))==null?void 0:U.id))})}})})}function M(I){return J(this,arguments,function*({key:A}){switch(A){case"history":p(!0);return;case"revision":return $();case"delete":return D()}})}const _=m.executed&&!h.find(A=>!A.executed&&new Date(A.createdAt)>new Date(m.createdAt));return n.jsxs(et.Provider,{value:{workflow:m,nodes:x,refresh:s},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(b.Breadcrumb,{items:[{title:n.jsx(he.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:n.jsx("strong",{children:m.title})}]})}),n.jsxs("aside",{children:[n.jsx("div",{className:"workflow-versions",children:n.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:w,defaultSelectedKeys:[`${m.id}`],className:i.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((A,I)=>I.id-A.id).map((A,I)=>({role:"button","aria-label":`version-${I}`,key:`${A.id}`,icon:A.current?n.jsx(O.RightOutlined,{}):null,className:i.cx({executed:A.executed,unexecuted:!A.executed,enabled:A.enabled}),label:n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:`#${A.id}`}),n.jsx("time",{children:X.str2moment(A.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:n.jsxs(b.Button,{type:"text","aria-label":"version",children:[n.jsx("label",{children:N("Version")}),n.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),n.jsx(O.DownOutlined,{})]})})}),n.jsx(b.Switch,{checked:m.enabled,onChange:T,checkedChildren:N("On"),unCheckedChildren:N("Off")}),n.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:N("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:N("Copy to new version"),disabled:!_},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:M},children:n.jsx(b.Button,{"aria-label":"more",type:"text",icon:n.jsx(O.EllipsisOutlined,{})})}),n.jsx(i.ActionContextProvider,{value:{visible:u,setVisible:p},children:n.jsx(i.SchemaComponent,{schema:jn,components:{ExecutionResourceProvider:kg,ExecutionLink:_n}})})]})]}),n.jsx(En,{entry:k})]})}const Bn=()=>{const e=he.useParams(),{styles:t}=ae();return n.jsx("div",{className:i.cx(t.workflowPageClass),children:n.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:Ag}})})},Tg=r=>{var s=r,{request:e,filter:t={}}=s,o=W(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 n.jsx(i.ResourceActionProvider,v({},l))},Og=()=>{const{t:e}=oe.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:r}=i.useGetAriaLabelOfAction("Configure");return n.jsx(he.Link,{"aria-label":r(),to:Ye(t),onClick:()=>o(!1),children:e("Configure")})};function Fg(r){var s=r,{component:e="div",children:t}=s,o=W(s,["component","children"]);const[a,l]=y.useState(!1),c=F.useFieldSchema();return n.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[y.createElement(e,C(v({},o),{onClick(){l(!0)}}),t),n.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const{defaultProps:Ig}=i.interfacesProperties,Dg={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({},Ig)},Vn={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"}]},Oe={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}}}}},Ng={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Vn,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Vn},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:Oe.title,type:Oe.type,description:Oe.description,options:Oe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=i.useRecord();return y.createElement("a",v({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:jn}}}},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:Oe.title,enabled:Oe.enabled,description:Oe.description,options:Oe.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}=oe.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:r}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[r]:a}=i.useRecord(),{values:l}=F.useForm();return{run(){return J(this,null,function*(){yield o.revision({filterByTk:a,values:l}),b.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Ln(e){var a;const o=i.useCompile()(e.label),r=y.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=ht[e.value])!=null?a:{};return n.jsx(b.Tag,{color:s,onMouseDown:r,closable:e.closable,onClose:e.onClose,children:o})}function Pg(e){const t=i.useCompile();return n.jsxs(n.Fragment,{children:[n.jsx(Ln,v({},e)),e.description?n.jsx("span",{children:t(e.description)}):null]})}function Eg(t){var e=W(t,[]);const o=e.multiple?"multiple":null;return n.jsx(b.Select,C(v({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Ln,children:ft.filter(r=>!!r.value&&r.value!==ye.ABORTED).map(r=>n.jsx(b.Select.Option,C(v({},r),{children:n.jsx(Pg,v({},r))}),r.value))}))}const Mg=y.createContext({});function _g(){const e=y.useContext(i.SchemaComponentContext);return n.jsx(b.Card,{bordered:!1,children:n.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{designable:!1}),children:n.jsx(i.SchemaComponent,{schema:Ng,components:{WorkflowLink:Og,ExecutionResourceProvider:Tg,ExecutionLink:_n,OpenDrawer:Fg,ExecutionStatusSelect:Eg},scope:{getTriggersOptions:go}})})})}const jg=e=>{const t=y.useContext(i.PluginManagerContext),o=y.useContext(i.CollectionManagerContext);return n.jsx(i.PluginManagerContext.Provider,{value:{components:v({},t==null?void 0:t.components)},children:n.jsx(i.CollectionManagerContext.Provider,{value:C(v({},o),{interfaces:C(v({},o.interfaces),{expression:Dg})}),children:n.jsx(Mg.Provider,{value:{triggers:ge,instructions:K},children:e.children})})})},Bg=F.observer(e=>{const{onChange:t}=e,o=F.useField(),r=F.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=y.useState(r.getValuesIn(a)),u=i.useCompile(),{getCollectionFields:p}=i.useCollectionManager();F.useFormEffects(()=>{se.onFormInitialValuesChange(g=>{c(g.getValuesIn(a))}),se.onFieldInputValueChange(a,g=>{c(g.value),t(null)})});const f=be({collection:l,compile:u,getCollectionFields:p});return n.jsx(i.Variable.TextArea,C(v({},e),{scope:f}))},{displayName:"InternalExpression"});function Vg(e){const{t}=oe.useTranslation(),o=i.useRecord(),r=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager(),a=y.useMemo(()=>be({collection:o.sourceCollection,compile:r,getCollectionFields:s}),[o.sourceCollection,o.sourceCollection]);return e.value?n.jsx(i.Variable.TextArea,C(v({},e),{scope:a})):n.jsx(b.Tag,{children:t("Unconfigured",{ns:d})})}const Lg=F.connect(Bg,F.mapReadPretty(Vg)),zg={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"}}]},Wg={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}}]},Ug={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:yt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Gg=F.observer(()=>{var t,o,r;const e=F.useField();return(r=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?r:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"NodeColumn"}),Hg=F.observer(()=>{var t,o,r;const e=F.useField();return(r=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?r:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"WorkflowColumn"}),Kg=F.observer(()=>{var t,o,r;const e=F.useField();return(r=(t=e==null?void 0:e.value)==null?void 0:t.nickname)!=null?r:(o=e.value)==null?void 0:o.id},{displayName:"UserColumn"}),To=()=>n.jsx(i.SchemaComponent,{components:{NodeColumn:Gg,WorkflowColumn:Hg,UserColumn:Kg},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 qg(e){var p;const{data:t}=i.useCurrentUserContext(),{userJob:o}=G(),{status:r,result:s,userId:a}=o,l=F.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:u}=e;return r?s[c]||(u=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==a&&(u=null),u}const Jg=y.createContext(null);function Yg({value:e,children:t}){const{userJob:o}=G(),r=F.useField(),s=F.useFieldSchema();return y.useEffect(()=>{o.status&&(r.disabled=!0,r.visible=o.status===e&&o.result._===s.name)},[o,e,r]),n.jsx(Jg.Provider,{value:e,children:t})}function Zg(){const e=i.useAPIClient(),{setVisible:t}=i.useActionContext(),{values:o,submit:r}=F.useForm(),s=F.useFieldSchema(),{service:a}=i.useTableBlockContext(),{userJob:l}=G(),{name:c}=s,{name:u}=s.parent.parent;return{run(){return J(this,null,function*(){l.status||(yield r(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[u]:o,_:c}}}),t(!1),a.refresh())})}}}function Qg(e){var p;const t=i.useAPIClient(),{id:o}=i.useRecord(),[r,s]=y.useState(null),[a,l]=y.useState(null);y.useEffect(()=>{var f,g;o&&((g=(f=t.resource("users_jobs")).get)==null||g.call(f,{filterByTk:o,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:x})=>{var $;const D=($=x==null?void 0:x.data)!=null?$:{},{node:h,workflow:M={}}=D,_=M,{nodes:m=[]}=_,k=W(_,["nodes"]),z=D,{execution:w}=z,T=W(z,["node","workflow","execution"]);$o(m),l(h),s({userJob:T,workflow:k,nodes:m,execution:w})}))},[o]);const u=ct(r==null?void 0:r.nodes.find(f=>f.id===a.id)).reduce((f,{type:g})=>Object.assign(f,K.get(g).components),{});return a&&r?n.jsx(et.Provider,{value:r,children:n.jsx(i.SchemaComponent,{components:v(v({FormBlockProvider:Cn,DetailsBlockProvider:xn,ActionBarProvider:qg,ManualActionStatusProvider:Yg},Array.from(Ce.getValues()).reduce((f,g)=>Object.assign(f,g.block.components),{})),u),scope:v({useSubmit:Zg,useFormBlockProps:Xg,useDetailsBlockProps:Rg},Array.from(Ce.getValues()).reduce((f,g)=>Object.assign(f,g.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=a.config)==null?void 0:p.schema}})}):n.jsx(b.Spin,{})}function Xg(){var a;const{userJob:e}=G(),t=i.useRecord(),{data:o}=i.useCurrentUserContext(),{form:r}=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 y.useEffect(()=>{r==null||r.setPattern(s)},[s,r]),{form:r}}function Rg(){const{form:e}=i.useFormBlockContext();return{form:e}}function ev(){const e=i.useCompile(),{status:t,updatedAt:o}=i.useRecord(),r=Re[t];return t?n.jsxs(b.Space,{children:[n.jsx("time",{className:i.css`
|
|
597
597
|
margin-right: 0.5em;
|
|
598
|
-
`,children:
|
|
598
|
+
`,children:No(o).format("YYYY-MM-DD HH:mm:ss")}),n.jsx(b.Tag,{icon:r.icon,color:r.color,children:e(r.label)})]}):null}function tv(){var a;const e=y.useContext(i.SchemaComponentContext),{id:t,node:o,workflow:r,status:s}=i.useRecord();return n.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{reset(){},designable:!1}),children:n.jsx(i.SchemaComponent,{components:{FooterStatus:ev,FlowContextProvider:Qg},schema:{type:"void",name:`drawer-${t}-${s}`,"x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:`${r.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 ov({params:e={},children:t}){const a=i.useCollectionManager(),{collections:o}=a,r=W(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 n.jsx(i.CollectionManagerProvider,C(v({},r),{collections:[...o,zg,Wg,Ug],children:n.jsx(i.TableBlockProvider,C(v({name:"workflow-todo"},s),{children:t}))}))}To.Drawer=tv,To.Decorator=ov;const rv=o=>{var r=o,{insert:e}=r,t=W(r,["insert"]);return n.jsx(i.SchemaInitializer.Item,C(v({icon:n.jsx(O.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 zn extends i.Plugin{constructor(){super(...arguments);Gt(this,"triggers",ge);Gt(this,"getTriggersOptions",go);Gt(this,"instructions",K)}load(){return J(this,null,function*(){this.addRoutes(),this.addScopes(),this.addComponents(),this.app.addProvider(jg),this.app.pluginSettingsManager.add(d,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${d}" })}}`,Component:_g,aclSnippet:"pm.workflow.workflows"})})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:Yh})}addComponents(){this.app.addComponents({WorkflowPage:Bn,ExecutionPage:Mn,WorkflowTodo:To,WorkflowTodoBlockInitializer:rv,DynamicExpression:Lg})}addRoutes(){this.app.router.add("admin.workflow.workflows.id",{path:Ye(":id"),element:n.jsx(Bn,{})}),this.app.router.add("admin.workflow.executions.id",{path:Ao(":id"),element:n.jsx(Mn,{})})}}S.BaseTypeSets=qe,S.Branch=Me,S.EXECUTION_STATUS=ye,S.ExecutionStatusOptions=ft,S.ExecutionStatusOptionsMap=ht,S.FlowContext=et,S.JOB_STATUS=ee,S.JobButton=Nn,S.JobStatusOptions=yt,S.JobStatusOptionsMap=Re,S.Node=In,S.NodeContext=ko,S.NodeDefaultView=ut,S.RemoveButton=Dn,S.WorkflowPlugin=zn,S.WorkflowVariableInput=it,S.WorkflowVariableJSON=fn,S.WorkflowVariableRawTextArea=mn,S.WorkflowVariableTextArea=pn,S.default=zn,S.defaultFieldNames=Ae,S.getCollectionFieldOptions=be,S.getTriggersOptions=go,S.instructions=K,S.nodesOptions=Ft,S.scopeOptions=vo,S.systemOptions=un,S.triggerOptions=It,S.triggers=ge,S.useAvailableUpstreams=ct,S.useFlowContext=G,S.useNodeContext=Te,S.useStyles=ae,S.useTrigger=yo,S.useUpstreamScopes=Fn,S.useWorkflowVariableOptions=pe,Object.defineProperties(S,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|