@nocobase/client-v2 2.1.25 → 2.1.26

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/es/index.mjs CHANGED
@@ -280,7 +280,7 @@ ${n}`,u)}}let o=T(e.issues.filter(e=>"runtime"===e.type)),n=o?`Key runtime issue
280
280
  .ant-pagination-item-link {
281
281
  min-width: ${l}px;
282
282
  }
283
- `},i,a.default.createElement("div",{style:o},t)):i},h=(e,t)=>t?{...e,showTotal:!1,showSizeChanger:!1,showLessItems:!0,className:p(e.className,c())}:e},5703(e,t,l){l.d(t,{n:()=>n});var o=l(504);let n=()=>(0,o.useFlowEngineContext)().app},2202(e,t,l){l.d(t,{g:()=>i});var o=l(504),n=l(1649);function i(){let e=(0,o.useFlowEngineContext)(),[t,l]=(0,n.useState)();return(0,n.useEffect)(()=>{let t=!0;return Promise.resolve(e.appInfo).then(e=>{t&&l(e||{})}).catch(e=>{console.error(e)}),()=>{t=!1}},[e]),t}},6625(e,t,l){l.d(t,{n:()=>n});var o=l(5703);function n(e){return(0,o.n)().pm.get(e)}},6553(e,t,l){l.d(t,{A:()=>o});let o={"ar-EG":{label:"العربية"},"az-AZ":{label:"Azərbaycan dili"},"bg-BG":{label:"Български"},"bn-BD":{label:"Bengali"},"by-BY":{label:"Беларускі"},"ca-ES":{label:"Сatal\xe0/Espanya"},"cs-CZ":{label:"Česky"},"da-DK":{label:"Dansk"},"de-DE":{label:"Deutsch"},"el-GR":{label:"Ελληνικά"},"en-GB":{label:"English(GB)"},"en-US":{label:"English"},"es-ES":{label:"Espa\xf1ol"},"et-EE":{label:"Estonian (Eesti)"},"fa-IR":{label:"فارسی"},"fi-FI":{label:"Suomi"},"fr-BE":{label:"Fran\xe7ais(BE)"},"fr-CA":{label:"Fran\xe7ais(CA)"},"fr-FR":{label:"Fran\xe7ais"},"ga-IE":{label:"Gaeilge"},"gl-ES":{label:"Galego"},"he-IL":{label:"עברית"},"hi-IN":{label:"हिन्दी"},"hr-HR":{label:"Hrvatski jezik"},"hu-HU":{label:"Magyar"},"hy-AM":{label:"Հայերեն"},"id-ID":{label:"Bahasa Indonesia"},"is-IS":{label:"\xcdslenska"},"it-IT":{label:"Italiano"},"ja-JP":{label:"日本語"},"ka-GE":{label:"ქართული"},"kk-KZ":{label:"Қазақ тілі"},"km-KH":{label:"ភាសាខ្មែរ"},"kn-IN":{label:"ಕನ್ನಡ"},"ko-KR":{label:"한국어"},"ku-IQ":{label:"کوردی"},"lt-LT":{label:"lietuvių"},"lv-LV":{label:"Latviešu valoda"},"mk-MK":{label:"македонски јазик"},"ml-IN":{label:"മലയാളം"},"mn-MN":{label:"Монгол хэл"},"ms-MY":{label:"بهاس ملايو"},"nb-NO":{label:"Norsk bokm\xe5l"},"ne-NP":{label:"नेपाली"},"nl-BE":{label:"Vlaams"},"nl-NL":{label:"Nederlands"},"pl-PL":{label:"Polski"},"pt-BR":{label:"Portugu\xeas brasileiro"},"pt-PT":{label:"Portugu\xeas"},"ro-RO":{label:"Rom\xe2nia"},"ru-RU":{label:"Русский"},"si-LK":{label:"සිංහල"},"sk-SK":{label:"Slovenčina"},"sl-SI":{label:"Slovenščina"},"sr-RS":{label:"српски језик"},"sv-SE":{label:"Svenska"},"ta-IN":{label:"Tamil"},"th-TH":{label:"ภาษาไทย"},"tk-TK":{label:"Turkmen"},"tr-TR":{label:"T\xfcrk\xe7e"},"uk-UA":{label:"Українська"},"ur-PK":{label:"Oʻzbekcha"},"vi-VN":{label:"Tiếng Việt"},"zh-CN":{label:"简体中文"},"zh-HK":{label:"繁體中文(香港)"},"zh-TW":{label:"繁體中文(台湾)"}}},9652(e,t,l){l.r(t),l.d(t,{AdminSettingsLayout:()=>_,InternalAdminSettingsLayout:()=>y,default:()=>b});var o=l(1178),n=l(2113),i=l(4829),r=l(691),a=l(504),s=l(2793),d=l(1649),u=l(7843),c=l(8356),p=l(3589),m=l(3939),h=l(5703),f=l(6681),g=l(6431);function v(e){let{type:t}=e,{t:l}=(0,u.useTranslation)();return"route"===t?(0,o.jsx)(s.Result,{status:"warning",title:l("Current settings page is unavailable"),subTitle:l("The requested settings page does not exist or you do not have permission to access it.")}):(0,o.jsx)(s.Result,{status:"info",title:l("No settings pages available"),subTitle:l("No settings pages are currently available in Client V2. Settings registered by migrated plugins will appear here automatically.")})}let y=()=>{var e,t,l;let r=(0,h.n)(),a=(0,c.useNavigate)(),f=(0,c.useLocation)(),y=(0,c.useParams)(),{token:_}=s.theme.useToken(),{t:b}=(0,u.useTranslation)(),{snippets:x=[]}=(0,p.v6)(),M=(0,d.useMemo)(()=>(0,g.Ui)(r.pluginSettingsManager.getList(!1)),[r.pluginSettingsManager]),w=(0,d.useMemo)(()=>(0,g.eD)((0,g.Ui)(r.pluginSettingsManager.getList(!0))),[r.pluginSettingsManager]),S=(0,d.useMemo)(()=>w.find(e=>e.name===g.Bm)||null,[w]),k=(0,d.useMemo)(()=>(0,g.p$)(w.filter(e=>e.name!==g.Bm)),[w]),F=(0,d.useMemo)(()=>S?[S,...k]:k,[k,S]),C=(0,d.useMemo)(()=>(0,g.nC)(M),[M]),A=(0,d.useMemo)(()=>(0,g.nC)(F),[F]),P=(0,d.useMemo)(()=>(0,g.CM)(C,f.pathname),[f.pathname,C]),T=(0,d.useMemo)(()=>(0,g.CM)(A,f.pathname),[f.pathname,A]),j=(0,d.useMemo)(()=>P?M.find(e=>e.name===P.topLevelName)||P:null,[M,P]),I=(0,d.useMemo)(()=>P&&F.find(e=>e.name===P.topLevelName)||null,[F,P]),L=(0,d.useMemo)(()=>(0,g.C9)(F),[F]),D=(0,d.useMemo)(()=>((null==I?void 0:I.children)||[]).filter(e=>!e.hidden),[null==I?void 0:I.children]),R=D.length>1&&(null==I?void 0:I.showTabs)!==!1;(0,d.useEffect)(()=>{let e=j&&"string"==typeof j.title?j.title:null==j?void 0:j.topLevelName;e&&(document.title=e)},[j]);let E=(0,d.useMemo)(()=>{let e=[];return S&&x.includes("pm")&&e.push({key:S.name,icon:S.icon||(0,o.jsx)(n.ApiOutlined,{}),label:S.label||b("Plugin manager")}),e.length&&k.length&&e.push({type:"divider"}),e.push(...(0,g.gL)(k.map(e=>({...e,children:void 0})))||[]),e},[k,S,x,b]),Y=f.pathname===m.wq||f.pathname===m.wq.replace(/\/$/,"")||f.pathname===`${m.wq}index`;if(Y&&L)return(0,o.jsx)(c.Navigate,{replace:!0,to:L});if(Y&&!L)return(0,o.jsx)(v,{type:"home"});if(!P||!T&&!1===P.isAllow)return(0,o.jsx)(v,{type:"route"});if(P.link)return(0,o.jsx)(c.Navigate,{replace:!0,to:P.link});if(f.pathname===(null==j?void 0:j.path)&&(null==j||null==(e=j.children)?void 0:e.length)){let e=null==I||null==(l=I.children)||null==(t=l.find(e=>"index"===e.pageKey))?void 0:t.path,n=(0,g.C9)(null==I?void 0:I.children),i=e||n;if(i&&i!==f.pathname)return(0,o.jsx)(c.Navigate,{replace:!0,to:i})}return(0,o.jsxs)(s.Layout,{style:{height:"100%",minHeight:"100%",background:_.colorBgLayout,borderRadius:_.borderRadiusLG,overflow:"hidden"},children:[(0,o.jsx)(s.Layout.Sider,{width:200,style:{background:_.colorBgContainer,borderInlineEnd:`${_.lineWidth}px solid ${_.colorBorderSecondary}`},children:(0,o.jsx)(s.Menu,{selectedKeys:(null==I?void 0:I.name)?[I.name]:[],style:{height:"100%",borderInlineEnd:"none"},onClick:e=>{var t;let{key:l}=e,o=F.find(e=>e.name===l);if(!o)return;if(o.link)return void window.open(o.link,"_blank","noopener,noreferrer");let n=(null==(t=o.children)?void 0:t.length)?(0,g.C9)(o.children):o.path;n&&a(n)},items:E})}),(0,o.jsxs)(s.Layout.Content,{style:{background:_.colorBgLayout,display:"flex",flexDirection:"column",minWidth:0,overflowY:"auto",overflowX:"hidden"},children:[(0,o.jsx)(i.PageHeader,{ghost:!1,title:null==j?void 0:j.title,style:{background:_.colorBgContainer,borderBlockEnd:`${_.lineWidth}px solid ${_.colorBorderSecondary}`,paddingBottom:R?0:_.padding},footer:R?(0,o.jsx)(s.Menu,{mode:"horizontal",selectedKeys:[(null==T?void 0:T.name)||(null==P?void 0:P.name)],items:(0,g.gL)(D),onClick:e=>{let{key:t}=e,l=(0,g.uT)(r.pluginSettingsManager.getRoutePath(String(t)),y);f.pathname!==l&&a(l)},style:{marginLeft:-_.marginSM,borderBottom:"none"}}):null}),(0,o.jsx)("div",{style:{padding:_.paddingLG},children:(0,o.jsx)(c.Outlet,{})})]})]})},_=e=>{let t=(0,a.useFlowEngine)(),l=(0,d.useRef)(null),n=(0,d.useMemo)(()=>(0,o.jsx)(y,{...e}),[e]),i=(0,r.css)`
283
+ `},i,a.default.createElement("div",{style:o},t)):i},h=(e,t)=>t?{...e,showTotal:!1,showSizeChanger:!1,showLessItems:!0,className:p(e.className,c())}:e},5703(e,t,l){l.d(t,{n:()=>n});var o=l(504);let n=()=>(0,o.useFlowEngineContext)().app},2202(e,t,l){l.d(t,{g:()=>i});var o=l(504),n=l(1649);function i(){let e=(0,o.useFlowEngineContext)(),[t,l]=(0,n.useState)();return(0,n.useEffect)(()=>{let t=!0;return Promise.resolve(e.appInfo).then(e=>{t&&l(e||{})}).catch(e=>{console.error(e)}),()=>{t=!1}},[e]),t}},6625(e,t,l){l.d(t,{n:()=>n});var o=l(5703);function n(e){return(0,o.n)().pm.get(e)}},6553(e,t,l){l.d(t,{A:()=>o});let o={"ar-EG":{label:"العربية"},"az-AZ":{label:"Azərbaycan dili"},"bg-BG":{label:"Български"},"bn-BD":{label:"Bengali"},"by-BY":{label:"Беларускі"},"ca-ES":{label:"Сatal\xe0/Espanya"},"cs-CZ":{label:"Česky"},"da-DK":{label:"Dansk"},"de-DE":{label:"Deutsch"},"el-GR":{label:"Ελληνικά"},"en-GB":{label:"English(GB)"},"en-US":{label:"English"},"es-ES":{label:"Espa\xf1ol"},"et-EE":{label:"Estonian (Eesti)"},"fa-IR":{label:"فارسی"},"fi-FI":{label:"Suomi"},"fr-BE":{label:"Fran\xe7ais(BE)"},"fr-CA":{label:"Fran\xe7ais(CA)"},"fr-FR":{label:"Fran\xe7ais"},"ga-IE":{label:"Gaeilge"},"gl-ES":{label:"Galego"},"he-IL":{label:"עברית"},"hi-IN":{label:"हिन्दी"},"hr-HR":{label:"Hrvatski jezik"},"hu-HU":{label:"Magyar"},"hy-AM":{label:"Հայերեն"},"id-ID":{label:"Bahasa Indonesia"},"is-IS":{label:"\xcdslenska"},"it-IT":{label:"Italiano"},"ja-JP":{label:"日本語"},"ka-GE":{label:"ქართული"},"kk-KZ":{label:"Қазақ тілі"},"km-KH":{label:"ភាសាខ្មែរ"},"kn-IN":{label:"ಕನ್ನಡ"},"ko-KR":{label:"한국어"},"ku-IQ":{label:"کوردی"},"lt-LT":{label:"lietuvių"},"lv-LV":{label:"Latviešu valoda"},"mk-MK":{label:"македонски јазик"},"ml-IN":{label:"മലയാളം"},"mn-MN":{label:"Монгол хэл"},"ms-MY":{label:"بهاس ملايو"},"nb-NO":{label:"Norsk bokm\xe5l"},"ne-NP":{label:"नेपाली"},"nl-BE":{label:"Vlaams"},"nl-NL":{label:"Nederlands"},"pl-PL":{label:"Polski"},"pt-BR":{label:"Portugu\xeas brasileiro"},"pt-PT":{label:"Portugu\xeas"},"ro-RO":{label:"Rom\xe2nia"},"ru-RU":{label:"Русский"},"si-LK":{label:"සිංහල"},"sk-SK":{label:"Slovenčina"},"sl-SI":{label:"Slovenščina"},"sr-RS":{label:"српски језик"},"sv-SE":{label:"Svenska"},"ta-IN":{label:"Tamil"},"th-TH":{label:"ภาษาไทย"},"tk-TK":{label:"Turkmen"},"tr-TR":{label:"T\xfcrk\xe7e"},"uk-UA":{label:"Українська"},"ur-PK":{label:"اردو"},"uz-UZ":{label:"Oʻzbekcha"},"vi-VN":{label:"Tiếng Việt"},"zh-CN":{label:"简体中文"},"zh-HK":{label:"繁體中文(香港)"},"zh-TW":{label:"繁體中文(台湾)"}}},9652(e,t,l){l.r(t),l.d(t,{AdminSettingsLayout:()=>_,InternalAdminSettingsLayout:()=>y,default:()=>b});var o=l(1178),n=l(2113),i=l(4829),r=l(691),a=l(504),s=l(2793),d=l(1649),u=l(7843),c=l(8356),p=l(3589),m=l(3939),h=l(5703),f=l(6681),g=l(6431);function v(e){let{type:t}=e,{t:l}=(0,u.useTranslation)();return"route"===t?(0,o.jsx)(s.Result,{status:"warning",title:l("Current settings page is unavailable"),subTitle:l("The requested settings page does not exist or you do not have permission to access it.")}):(0,o.jsx)(s.Result,{status:"info",title:l("No settings pages available"),subTitle:l("No settings pages are currently available in Client V2. Settings registered by migrated plugins will appear here automatically.")})}let y=()=>{var e,t,l;let r=(0,h.n)(),a=(0,c.useNavigate)(),f=(0,c.useLocation)(),y=(0,c.useParams)(),{token:_}=s.theme.useToken(),{t:b}=(0,u.useTranslation)(),{snippets:x=[]}=(0,p.v6)(),M=(0,d.useMemo)(()=>(0,g.Ui)(r.pluginSettingsManager.getList(!1)),[r.pluginSettingsManager]),w=(0,d.useMemo)(()=>(0,g.eD)((0,g.Ui)(r.pluginSettingsManager.getList(!0))),[r.pluginSettingsManager]),S=(0,d.useMemo)(()=>w.find(e=>e.name===g.Bm)||null,[w]),k=(0,d.useMemo)(()=>(0,g.p$)(w.filter(e=>e.name!==g.Bm)),[w]),F=(0,d.useMemo)(()=>S?[S,...k]:k,[k,S]),C=(0,d.useMemo)(()=>(0,g.nC)(M),[M]),A=(0,d.useMemo)(()=>(0,g.nC)(F),[F]),P=(0,d.useMemo)(()=>(0,g.CM)(C,f.pathname),[f.pathname,C]),T=(0,d.useMemo)(()=>(0,g.CM)(A,f.pathname),[f.pathname,A]),j=(0,d.useMemo)(()=>P?M.find(e=>e.name===P.topLevelName)||P:null,[M,P]),I=(0,d.useMemo)(()=>P&&F.find(e=>e.name===P.topLevelName)||null,[F,P]),L=(0,d.useMemo)(()=>(0,g.C9)(F),[F]),D=(0,d.useMemo)(()=>((null==I?void 0:I.children)||[]).filter(e=>!e.hidden),[null==I?void 0:I.children]),R=D.length>1&&(null==I?void 0:I.showTabs)!==!1;(0,d.useEffect)(()=>{let e=j&&"string"==typeof j.title?j.title:null==j?void 0:j.topLevelName;e&&(document.title=e)},[j]);let E=(0,d.useMemo)(()=>{let e=[];return S&&x.includes("pm")&&e.push({key:S.name,icon:S.icon||(0,o.jsx)(n.ApiOutlined,{}),label:S.label||b("Plugin manager")}),e.length&&k.length&&e.push({type:"divider"}),e.push(...(0,g.gL)(k.map(e=>({...e,children:void 0})))||[]),e},[k,S,x,b]),Y=f.pathname===m.wq||f.pathname===m.wq.replace(/\/$/,"")||f.pathname===`${m.wq}index`;if(Y&&L)return(0,o.jsx)(c.Navigate,{replace:!0,to:L});if(Y&&!L)return(0,o.jsx)(v,{type:"home"});if(!P||!T&&!1===P.isAllow)return(0,o.jsx)(v,{type:"route"});if(P.link)return(0,o.jsx)(c.Navigate,{replace:!0,to:P.link});if(f.pathname===(null==j?void 0:j.path)&&(null==j||null==(e=j.children)?void 0:e.length)){let e=null==I||null==(l=I.children)||null==(t=l.find(e=>"index"===e.pageKey))?void 0:t.path,n=(0,g.C9)(null==I?void 0:I.children),i=e||n;if(i&&i!==f.pathname)return(0,o.jsx)(c.Navigate,{replace:!0,to:i})}return(0,o.jsxs)(s.Layout,{style:{height:"100%",minHeight:"100%",background:_.colorBgLayout,borderRadius:_.borderRadiusLG,overflow:"hidden"},children:[(0,o.jsx)(s.Layout.Sider,{width:200,style:{background:_.colorBgContainer,borderInlineEnd:`${_.lineWidth}px solid ${_.colorBorderSecondary}`},children:(0,o.jsx)(s.Menu,{selectedKeys:(null==I?void 0:I.name)?[I.name]:[],style:{height:"100%",borderInlineEnd:"none"},onClick:e=>{var t;let{key:l}=e,o=F.find(e=>e.name===l);if(!o)return;if(o.link)return void window.open(o.link,"_blank","noopener,noreferrer");let n=(null==(t=o.children)?void 0:t.length)?(0,g.C9)(o.children):o.path;n&&a(n)},items:E})}),(0,o.jsxs)(s.Layout.Content,{style:{background:_.colorBgLayout,display:"flex",flexDirection:"column",minWidth:0,overflowY:"auto",overflowX:"hidden"},children:[(0,o.jsx)(i.PageHeader,{ghost:!1,title:null==j?void 0:j.title,style:{background:_.colorBgContainer,borderBlockEnd:`${_.lineWidth}px solid ${_.colorBorderSecondary}`,paddingBottom:R?0:_.padding},footer:R?(0,o.jsx)(s.Menu,{mode:"horizontal",selectedKeys:[(null==T?void 0:T.name)||(null==P?void 0:P.name)],items:(0,g.gL)(D),onClick:e=>{let{key:t}=e,l=(0,g.uT)(r.pluginSettingsManager.getRoutePath(String(t)),y);f.pathname!==l&&a(l)},style:{marginLeft:-_.marginSM,borderBottom:"none"}}):null}),(0,o.jsx)("div",{style:{padding:_.paddingLG},children:(0,o.jsx)(c.Outlet,{})})]})]})},_=e=>{let t=(0,a.useFlowEngine)(),l=(0,d.useRef)(null),n=(0,d.useMemo)(()=>(0,o.jsx)(y,{...e}),[e]),i=(0,r.css)`
284
284
  height: 100%;
285
285
  > div {
286
286
  height: 100%;
@@ -1316,7 +1316,7 @@ ctx.render(<JsItem />);
1316
1316
  > .ant-tabs-content-holder > .ant-tabs-content > .ant-tabs-tabpane {
1317
1317
  height: 100%;
1318
1318
  }
1319
- `,bM={display:"flex",alignItems:"center",marginBottom:16,paddingBottom:8,borderBottom:"1px solid #f0f0f0"},bw={width:"4px",height:"16px",borderRadius:"2px",marginRight:8},bS={margin:0,fontSize:14,fontWeight:500,color:"#262626"},bk={marginBottom:8,fontSize:14,fontWeight:500,color:"#262626"},bF={marginInlineStart:4,color:"#ff4d4f"},bC={marginInlineStart:2,marginInlineEnd:8},bA={display:"flex",justifyContent:"flex-end",gap:8,padding:"8px 16px",borderTop:"1px solid #f0f0f0",backgroundColor:"#fff",flexShrink:0},bP=e=>{let{color:t,children:l}=e;return(0,s.jsxs)("div",{style:bM,children:[(0,s.jsx)("div",{style:{...bw,backgroundColor:t}}),(0,s.jsx)("h4",{style:bS,children:l})]})},bT=e=>{let{children:t,required:l,style:o}=e;return(0,s.jsxs)("div",{style:{...bk,...o},children:[t,l&&(0,s.jsx)("span",{style:bF,children:"*"}),(0,s.jsx)("span",{style:bC,children:":"})]})},bj=(0,u.observer)(e=>{var t;let{flow:l,model:o,flowEngine:n,flowRegistry:i}=e,r=(0,u.useFlowContext)(),a=o.translate.bind(o),d=(0,o8.useUpdate)(),[m,h]=p.default.useState([]),f=bh(l.on),v=bm(l.on)?l.on:void 0,y=f?null==(t=o.getEvent(f))?void 0:t.uiSchema:void 0,_="function"==typeof y?y(r):y,b=null==v?void 0:v.defaultParams,x=p.default.useCallback(()=>{if(bm(l.on))return l.on;if(!f)return;let e={eventName:f};return l.on=e,e},[f,l]),M=(null==v?void 0:v.phase)?String(v.phase):"beforeAllFlows",w=(null==v?void 0:v.flowKey)?String(v.flowKey):void 0,S=(null==v?void 0:v.stepKey)?String(v.stepKey):void 0,k=p.default.useMemo(()=>[...o.getEvents().values()],[o]);p.default.useEffect(()=>{let e=!1;return(async()=>{let t=[];for(let e of k)await (0,u.shouldHideEventInSettings)(o,l,e)||t.push({label:o.translate(e.title),value:e.name});e||h(e=>c.default.isEqual(e,t)?e:t)})(),()=>{e=!0}},[l,o,k]);let F=p.default.useMemo(()=>f?Array.from(o.constructor.globalFlowRegistry.getFlows().values()).filter(e=>"beforeRender"===f?!0!==e.manual&&(!e.on||"beforeRender"===bh(e.on)):bh(e.on)===f):[],[f,o]),C=p.default.useMemo(()=>new Map(F.map(e=>[e.key,e])),[F]),A=p.default.useCallback((e,t)=>{if(!t)return e;let l=a(String(t));return`${e} (${l})`},[a]),P=p.default.useMemo(()=>F.map(e=>({value:e.key,label:A(String(e.key),e.title),disabled:i.hasFlow(e.key)})),[i,A,F]),T=p.default.useMemo(()=>{if(!w)return[];let e=C.get(w);return e?e.mapSteps(e=>{let t=e.use?o.getAction(e.use):void 0,l=e.title||(null==t?void 0:t.title);return{value:e.key,label:A(String(e.key),l)}}):[]},[w,A,o,C]),j=p.default.useMemo(()=>[{value:"beforeAllFlows",label:a("Before all flows")},{value:"afterAllFlows",label:a("After built-in flows")},{value:"beforeFlow",label:a("Before built-in flow")},{value:"afterFlow",label:a("After built-in flow")},{value:"beforeStep",label:a("Before built-in flow step")},{value:"afterStep",label:a("After built-in flow step")}],[a]),I=["beforeFlow","afterFlow","beforeStep","afterStep"].includes(M),L=["beforeStep","afterStep"].includes(M),D=v?bg(v):void 0,R="flowKey"===D,E="stepKey"===D,Y=e=>{let t=bm(l.on)?l.on:{eventName:e};l.on=t,t.eventName=e,delete t.phase,delete t.flowKey,delete t.stepKey,d()};return(0,s.jsxs)("div",{style:{marginBottom:32},children:[(0,s.jsx)(bP,{color:"#1890ff",children:a("Event")}),(0,s.jsxs)("div",{style:{paddingLeft:12},children:[(0,s.jsxs)("div",{style:{marginBottom:16},children:[(0,s.jsx)(bT,{children:a("Trigger event")}),(0,s.jsx)(g.Select,{placeholder:a("Select trigger event"),style:{width:"100%"},value:f,onChange:e=>{Y(e)},options:m})]}),(0,s.jsxs)("div",{style:{marginBottom:16},children:[(0,s.jsx)(bT,{children:a("Execution timing")}),(0,s.jsx)(g.Select,{style:{width:"100%"},disabled:!f,value:M,onChange:e=>{let t=x();t&&(t.phase=e,bf(t),d())},options:j}),I&&(0,s.jsxs)("div",{style:{marginTop:12,display:"flex",flexDirection:"column",gap:12},children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(bT,{required:I,style:{marginBottom:6},children:a("Built-in flow")}),(0,s.jsx)(g.Select,{style:{width:"100%"},disabled:!f||0===P.length,placeholder:a("Select a built-in flow"),value:w,status:R?"error":void 0,options:P,onChange:e=>{let t=x();t&&(e?t.flowKey=e:delete t.flowKey,delete t.stepKey,d())}}),R&&(0,s.jsx)("div",{style:{marginTop:4,fontSize:12,color:"#ff4d4f"},children:a("Please select a built-in flow")})]}),L&&(0,s.jsxs)("div",{children:[(0,s.jsx)(bT,{required:L,style:{marginBottom:6},children:a("Built-in flow step")}),(0,s.jsx)(g.Select,{style:{width:"100%"},disabled:!f||!w||0===T.length,placeholder:a("Select a built-in flow step"),value:S,status:E?"error":void 0,options:T,onChange:e=>{let t=x();t&&(e?t.stepKey=e:delete t.stepKey,d())}}),E&&(0,s.jsx)("div",{style:{marginTop:4,fontSize:12,color:"#ff4d4f"},children:a("Please select a built-in flow step")})]}),0===P.length&&(0,s.jsx)("div",{style:{marginTop:4,fontSize:12,color:"#8c8c8c"},children:a("No built-in flows for this event")})]})]}),f&&n.flowSettings.renderStepForm({key:f,uiSchema:_,initialValues:b,flowEngine:n,onFormValuesChange:e=>{let t=x();t&&(t.defaultParams=e.values)}})]})]})}),bI=(0,u.observer)(e=>{var t;let{model:l}=e,o=e.active??!0,n=e.guardBeforeClose??!0,i=e.onDirtyChange,r=e.onRegisterEditor,a=e.onSaveRequest,d=(0,u.useFlowContext)(),m=l.flowEngine,h=(0,u.serializeFlowRegistry)(l.flowRegistry),f=p.default.useRef(h),[v]=p.default.useState(()=>new u.DetachedFlowRegistry(h)),[y,_]=p.default.useState(!1),b=e.submitLoading??y,x=p.default.useMemo(()=>l.translate.bind(l),[l]),M=p.default.useCallback(()=>!c.default.isEqual(f.current,(0,u.serializeFlowRegistry)(v)),[v]);p.default.useEffect(()=>{null==i||i(M())}),p.default.useEffect(()=>{c.default.isEqual(f.current,h)||M()||((0,u.replaceFlowRegistry)(v,h),f.current=h)},[v,M,h]),p.default.useEffect(()=>{if(!n)return;let e=d.view;if(!e)return;let t=e.beforeClose,l=async e=>(!M()||!!await bv(d,x))&&!1!==await (null==t?void 0:t(e));return e.beforeClose=l,()=>{e.beforeClose===l&&(e.beforeClose=t)}},[d,n,M,x]);let w=()=>{v.addFlow((0,nx.uid)(),{title:x("Event flow"),steps:{}})},S=e=>{e.remove()},k=(e,t)=>{e.title=t},F=()=>[...l.getActions().values()].filter(e=>c.default.castArray(e.scene).includes(u.ActionScene.DYNAMIC_EVENT_FLOW)).sort((e,t)=>(e.sort??0)-(t.sort??0)),C=(e,t)=>{let l={use:t.name};e.addStep((0,nx.uid)(),l)},A=e=>{e.remove()},P=(e,t)=>{e.defaultParams=t},T=e=>(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,s.jsx)("div",{style:{flex:1,marginRight:16},children:(0,s.jsx)(g.Input,{value:e.title,onChange:t=>k(e,t.target.value),onClick:e=>e.stopPropagation(),placeholder:x("Enter flow title")})}),(0,s.jsx)(g.Space,{onClick:e=>e.stopPropagation(),children:(0,s.jsx)(g.Tooltip,{title:"Delete",children:(0,s.jsx)(g.Button,{type:"text",size:"small",icon:(0,s.jsx)(e1.DeleteOutlined,{}),onClick:()=>S(e)})})})]}),j=v.mapFlows(e=>({key:e.key,label:T(e),styles:{header:{display:"flex",alignItems:"center"}},children:(0,s.jsxs)("div",{children:[(0,s.jsx)(bj,{flow:e,model:l,flowEngine:m,flowRegistry:v}),(0,s.jsxs)("div",{children:[(0,s.jsx)(bP,{color:"#52c41a",children:x("Steps")}),(0,s.jsxs)("div",{style:{paddingLeft:12},children:[(0,s.jsx)("div",{style:{marginBottom:16},children:e.mapSteps(e=>{let t=l.getAction(e.use);return t?(0,s.jsxs)("div",{style:{border:"1px solid #f0f0f0",borderRadius:"6px",padding:"12px",marginBottom:"8px"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},children:[(0,s.jsxs)("span",{style:{fontWeight:600,color:"#262626"},children:[x(t.title),(0,s.jsx)("span",{style:{marginInlineStart:2,marginInlineEnd:8},children:":"})]}),(0,s.jsx)(g.Tooltip,{title:x("Delete step"),children:(0,s.jsx)(g.Button,{type:"text",size:"small",icon:(0,s.jsx)(e1.DeleteOutlined,{}),onClick:()=>A(e)})})]}),(0,s.jsx)("div",{children:p.default.createElement(u.FlowStepContext.Provider,{value:{params:(0,u.untracked)(()=>e.defaultParams),path:`${l.uid}_${e.flowKey}_${e.key}`}},m.flowSettings.renderStepForm({uiSchema:t.uiSchema,initialValues:(0,u.untracked)(()=>e.defaultParams),flowEngine:m,onFormValuesChange:t=>P(e,t.values)}))})]},e.key):null})}),(0,s.jsx)(g.Dropdown,{menu:{items:F().map(t=>({key:t.name,label:x(t.title)||t.name,onClick:()=>C(e,t)}))},trigger:["hover"],children:(0,s.jsx)(g.Button,{type:"link",icon:(0,s.jsx)(e1.PlusOutlined,{}),style:{padding:0,height:"auto",textAlign:"left"},children:x("Add step")})})]})]})]})})),I=p.default.useCallback(async()=>{var e,t;let l=d.view;return!!l&&("function"==typeof l.close?await l.close()!==!1:!1!==await (null==(e=l.beforeClose)?void 0:e.call(l,{}))&&(null==(t=l.destroy)||t.call(l),!0))},[d.view]),L=p.default.useCallback(async()=>{var e,t,o,n,r,a,s,d,c,p,m,h;_(!0);let g=v.mapFlows(e=>{if(!bm(e.on))return;bf(e.on);let t=bg(e.on);if(t)return{type:t}}).filter(Boolean)[0];if(g){let e="flowKey"===g.type?x("Please select a built-in flow"):x("Please select a built-in flow step");return null==(a=l.context)||null==(r=a.message)||null==(n=r.error)||n.call(r,e),_(!1),!1}let y=(0,u.serializeFlowRegistry)(l.flowRegistry),b=[];try{for(let e of v.mapFlows(e=>e))for(let t of e.mapSteps(e=>e)){let o=t.serialize(),n=t.use?l.getAction(t.use):void 0,i=o.beforeParamsSave||(null==n?void 0:n.beforeParamsSave),r=o.afterParamsSave||(null==n?void 0:n.afterParamsSave);if("function"!=typeof i&&"function"!=typeof r)continue;let a=new u.FlowRuntimeContext(l,e.key,"settings");(0,u.setupRuntimeContextSteps)(a,e.steps,l,e.key),a.defineProperty("currentStep",{value:o});let s={...t.defaultParams||{}},d={...t.defaultParams||{}};"function"==typeof i&&await i(a,s,d),"function"==typeof r&&b.push(async()=>{await r(a,s,d)}),t.defaultParams=s}(0,u.replaceFlowRegistry)(l.flowRegistry,(0,u.serializeFlowRegistry)(v)),await l.flowRegistry.save()}catch(e){return(0,u.replaceFlowRegistry)(l.flowRegistry,y),_(!1),null==(c=l.context)||null==(d=c.message)||null==(s=d.error)||s.call(d,"Steps post-save hooks failed to run"),console.error(e),!1}f.current=(0,u.serializeFlowRegistry)(l.flowRegistry);try{for(let e of b)await e()}catch(e){null==(h=l.context)||null==(m=h.message)||null==(p=m.error)||p.call(m,"Steps post-save hooks failed to run"),console.error(e)}return l.flowRegistry.mapFlows(e=>{if((0,u.isBeforeRenderFlow)(e))return e}).filter(Boolean).length>0&&l.rerender(),_(!1),null==i||i(!1),null==(o=l.context)||null==(t=o.message)||null==(e=t.success)||e.call(t,x("Configuration saved")),!0},[v,l,i,x]);p.default.useEffect(()=>{if(r)return r({hasUnsavedChanges:M,save:L}),()=>{r()}},[M,r,L]);let D=(0,s.jsxs)(g.Space,{children:[(0,s.jsx)(g.Button,{onClick:I,children:x("Cancel")}),(0,s.jsx)(g.Button,{type:"primary",loading:b,onClick:async()=>{a?await a():await L()&&await I()},children:x("Save")})]}),R=null==(t=d.view)?void 0:t.Footer;return(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,s.jsxs)("div",{style:{flex:1,padding:"16px",overflow:"auto",minHeight:0},children:[j.length>0?(0,s.jsx)(g.Collapse,{items:j,size:"small",style:{marginBottom:8},defaultActiveKey:[j[0].key],accordion:!0}):(0,s.jsx)("div",{style:{border:"1px dashed #d9d9d9",borderRadius:"6px",backgroundColor:"#fafafa",marginBottom:"8px"},children:(0,s.jsx)(g.Empty,{description:x("No event flows"),style:{margin:"20px 0"}})}),(0,s.jsx)(g.Button,{type:"dashed",icon:(0,s.jsx)(e1.PlusOutlined,{}),onClick:w,style:{width:"100%"},children:x("Add event flow")})]}),o?R?(0,s.jsx)(R,{children:D}):(0,s.jsx)("div",{style:bA,children:D}):null]})});var bL=__webpack_require__(2828);let bD=()=>{let e=(0,u.useFlowContext)().app,t=e.pm.get("@nocobase/plugin-block-markdown");return t.dependencyLoaded||(t.initVditorDependency(e),t.dependencyLoaded=!0),t.getCDN(e)},bR="nb-markdown-vditor";function bE(){let{theme:e,token:t,hashId:l}=g.theme.useToken(),o=(0,__rspack_external__ant_design_cssinjs_c619260f.useStyleRegister)({theme:e,token:t,hashId:l,path:["flow-markdown",bR]},()=>({[`.${bR}`]:{".vditor-reset":{fontSize:`${t.fontSize}px !important`,color:"unset"},".vditor":{borderRadius:8},".vditor .vditor-content":{borderRadius:"0 0 8px 8px",overflow:"hidden"},".vditor .vditor-toolbar":{paddingLeft:" 16px !important",borderRadius:"8px 8px 0 0"},".vditor .vditor-content .vditor-ir .vditor-reset":{padding:"10px !important"},".vditor-ir pre.vditor-reset":{backgroundColor:`${t.colorBgContainer}!important`},".vditor-preview":{display:"none !important"},".vditor-preview__action":{display:"none"}}}));return{wrapSSR:(0,p.useMemo)(()=>o,[o,e,t,l]),hashId:l,componentCls:bR}}function bY(e){let t=new DOMParser().parseFromString(e,"text/html");t.querySelectorAll("img").forEach(e=>{let t=e.getAttribute("src");t&&e.replaceWith(document.createTextNode(` [Image: ${t}] `))});let l=t.body.textContent||t.body.innerText;return(null==l?void 0:l.replace(/\n|\r/g," "))||""}let bN=e=>{if(e){let t=document.createRange();return t.selectNodeContents(e),t.getBoundingClientRect().width}};function bO(e){let t=(0,p.useRef)(null),{wrapSSR:l,componentCls:o,hashId:n}=bE(),i=bD();return(0,p.useEffect)(()=>{e.loadImages&&(__rspack_external_vditor.default.preview(t.current,e.value??"",{mode:"light",cdn:i,markdown:{sanitize:!0},transform:bL.$P}).then(()=>(0,bL.VC)(t.current)).catch(()=>(0,bL.VC)(t.current)),setTimeout(()=>{var e,l;(0,bL.VC)(t.current),null==(e=t.current)||e.querySelectorAll("img").forEach(e=>{e.style.cursor="zoom-in",e.addEventListener("click",()=>{bB(e.src)})}),null==(l=t.current)||l.querySelectorAll("qr-code").forEach(e=>{let t=e.getAttribute("value")||"",l=document.createElement("div");e.replaceWith(l),(0,__rspack_external_react_dom_client_76b1397c.createRoot)(l).render((0,s.jsx)(g.QRCode,{value:t}))})},300))},[e.value,e.loadImages,i]),l((0,s.jsx)("span",{className:`${n} ${o}`,children:(0,s.jsx)("span",{ref:t,style:{border:"none",...(null==e?void 0:e.style)??{}}})}))}function bB(e){if(document.getElementById("custom-image-preview"))return;let t=document.createElement("span");t.id="custom-image-preview",Object.assign(t.style,{position:"fixed",inset:"0",backgroundColor:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"9999",cursor:"zoom-out"});let l=document.createElement("img");l.src=e,Object.assign(l.style,{maxWidth:"90%",maxHeight:"90%",borderRadius:"8px",boxShadow:"0 0 20px rgba(0,0,0,0.5)",transition:"transform 0.2s",cursor:"zoom-out"}),t.addEventListener("click",()=>{document.body.removeChild(t)}),t.appendChild(l),document.body.appendChild(t)}let bV=e=>{let{value:t,textOnly:l=!0}=e,o=bD(),[n,i]=(0,p.useState)(!1),[r,a]=(0,p.useState)(!1),[d,u]=(0,p.useState)(!1),[c,m]=(0,p.useState)(""),h=(0,p.useRef)();(0,p.useEffect)(()=>{e.value&&l&&__rspack_external_vditor.default.md2html(e.value,{mode:"light",cdn:o,markdown:{sanitize:!0}}).then(e=>{m(bY((0,bL.$P)(e)))}).catch(()=>m(""))},[e.value,l,o]);let f=(0,p.useCallback)(()=>{var e;return!!h.current&&bN(h.current)>(null==(e=h.current)?void 0:e.offsetWidth)},[h]),v=e=>{i(e),e&&!d&&u(!0)};return e.ellipsis?(0,s.jsx)(g.Popover,{open:n,getPopupContainer:()=>{var e;return null==(e=document.getElementsByClassName("ant-drawer-content"))?void 0:e[0]},onOpenChange:e=>{v(r&&e)},overlayStyle:{maxWidth:600},content:(0,s.jsx)("div",{style:{maxHeight:400,overflow:"auto"},children:(0,s.jsx)(bO,{value:t,loadImages:d})}),children:(0,s.jsx)("div",{ref:h,style:{overflow:"hidden",overflowWrap:"break-word",textOverflow:"ellipsis",whiteSpace:"nowrap",wordBreak:"break-all"},onMouseEnter:e=>{let t=e.target;f()&&a(t.scrollWidth>=t.clientWidth)},children:l?c:(0,s.jsx)("div",{className:(0,S.css)`
1319
+ `,bM={display:"flex",alignItems:"center",marginBottom:16,paddingBottom:8,borderBottom:"1px solid #f0f0f0"},bw={width:"4px",height:"16px",borderRadius:"2px",marginRight:8},bS={margin:0,fontSize:14,fontWeight:500,color:"#262626"},bk={marginBottom:8,fontSize:14,fontWeight:500,color:"#262626"},bF={marginInlineStart:4,color:"#ff4d4f"},bC={marginInlineStart:2,marginInlineEnd:8},bA={display:"flex",justifyContent:"flex-end",gap:8,padding:"8px 16px",borderTop:"1px solid #f0f0f0",backgroundColor:"#fff",flexShrink:0},bP=e=>{let{color:t,children:l}=e;return(0,s.jsxs)("div",{style:bM,children:[(0,s.jsx)("div",{style:{...bw,backgroundColor:t}}),(0,s.jsx)("h4",{style:bS,children:l})]})},bT=e=>{let{children:t,required:l,style:o}=e;return(0,s.jsxs)("div",{style:{...bk,...o},children:[t,l&&(0,s.jsx)("span",{style:bF,children:"*"}),(0,s.jsx)("span",{style:bC,children:":"})]})},bj=(0,u.observer)(e=>{var t;let{flow:l,model:o,flowEngine:n,flowRegistry:i}=e,r=(0,u.useFlowContext)(),a=o.translate.bind(o),d=(0,o8.useUpdate)(),[m,h]=p.default.useState([]),f=bh(l.on),v=bm(l.on)?l.on:void 0,y=f?null==(t=o.getEvent(f))?void 0:t.uiSchema:void 0,_="function"==typeof y?y(r):y,b=null==v?void 0:v.defaultParams,x=p.default.useCallback(()=>{if(bm(l.on))return l.on;if(!f)return;let e={eventName:f};return l.on=e,e},[f,l]),M=(null==v?void 0:v.phase)?String(v.phase):"beforeAllFlows",w=(null==v?void 0:v.flowKey)?String(v.flowKey):void 0,S=(null==v?void 0:v.stepKey)?String(v.stepKey):void 0,k=p.default.useMemo(()=>[...o.getEvents().values()],[o]);p.default.useEffect(()=>{let e=!1;return(async()=>{let t=[];for(let e of k)await (0,u.shouldHideEventInSettings)(o,l,e)||t.push({label:o.translate(e.title),value:e.name});e||h(e=>c.default.isEqual(e,t)?e:t)})(),()=>{e=!0}},[l,o,k]);let F=p.default.useMemo(()=>f?Array.from(o.constructor.globalFlowRegistry.getFlows().values()).filter(e=>"beforeRender"===f?!0!==e.manual&&(!e.on||"beforeRender"===bh(e.on)):bh(e.on)===f):[],[f,o]),C=p.default.useMemo(()=>new Map(F.map(e=>[e.key,e])),[F]),A=p.default.useCallback((e,t)=>{if(!t)return e;let l=a(String(t));return`${e} (${l})`},[a]),P=p.default.useMemo(()=>F.map(e=>({value:e.key,label:A(String(e.key),e.title),disabled:i.hasFlow(e.key)})),[i,A,F]),T=p.default.useMemo(()=>{if(!w)return[];let e=C.get(w);return e?e.mapSteps(e=>{let t=e.use?o.getAction(e.use):void 0,l=e.title||(null==t?void 0:t.title);return{value:e.key,label:A(String(e.key),l)}}):[]},[w,A,o,C]),j=p.default.useMemo(()=>[{value:"beforeAllFlows",label:a("Before all flows")},{value:"afterAllFlows",label:a("After built-in flows")},{value:"beforeFlow",label:a("Before built-in flow")},{value:"afterFlow",label:a("After built-in flow")},{value:"beforeStep",label:a("Before built-in flow step")},{value:"afterStep",label:a("After built-in flow step")}],[a]),I=["beforeFlow","afterFlow","beforeStep","afterStep"].includes(M),L=["beforeStep","afterStep"].includes(M),D=v?bg(v):void 0,R="flowKey"===D,E="stepKey"===D,Y=e=>{let t=bm(l.on)?l.on:{eventName:e};l.on=t,t.eventName=e,delete t.phase,delete t.flowKey,delete t.stepKey,d()};return(0,s.jsxs)("div",{style:{marginBottom:32},children:[(0,s.jsx)(bP,{color:"#1890ff",children:a("Event")}),(0,s.jsxs)("div",{style:{paddingLeft:12},children:[(0,s.jsxs)("div",{style:{marginBottom:16},children:[(0,s.jsx)(bT,{children:a("Trigger event")}),(0,s.jsx)(g.Select,{placeholder:a("Select trigger event"),style:{width:"100%"},value:f,onChange:e=>{Y(e)},options:m})]}),(0,s.jsxs)("div",{style:{marginBottom:16},children:[(0,s.jsx)(bT,{children:a("Execution timing")}),(0,s.jsx)(g.Select,{style:{width:"100%"},disabled:!f,value:M,onChange:e=>{let t=x();t&&(t.phase=e,bf(t),d())},options:j}),I&&(0,s.jsxs)("div",{style:{marginTop:12,display:"flex",flexDirection:"column",gap:12},children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(bT,{required:I,style:{marginBottom:6},children:a("Built-in flow")}),(0,s.jsx)(g.Select,{style:{width:"100%"},disabled:!f||0===P.length,placeholder:a("Select a built-in flow"),value:w,status:R?"error":void 0,options:P,onChange:e=>{let t=x();t&&(e?t.flowKey=e:delete t.flowKey,delete t.stepKey,d())}}),R&&(0,s.jsx)("div",{style:{marginTop:4,fontSize:12,color:"#ff4d4f"},children:a("Please select a built-in flow")})]}),L&&(0,s.jsxs)("div",{children:[(0,s.jsx)(bT,{required:L,style:{marginBottom:6},children:a("Built-in flow step")}),(0,s.jsx)(g.Select,{style:{width:"100%"},disabled:!f||!w||0===T.length,placeholder:a("Select a built-in flow step"),value:S,status:E?"error":void 0,options:T,onChange:e=>{let t=x();t&&(e?t.stepKey=e:delete t.stepKey,d())}}),E&&(0,s.jsx)("div",{style:{marginTop:4,fontSize:12,color:"#ff4d4f"},children:a("Please select a built-in flow step")})]}),0===P.length&&(0,s.jsx)("div",{style:{marginTop:4,fontSize:12,color:"#8c8c8c"},children:a("No built-in flows for this event")})]})]}),f&&n.flowSettings.renderStepForm({key:f,uiSchema:_,initialValues:b,flowEngine:n,onFormValuesChange:e=>{let t=x();t&&(t.defaultParams=e.values)}})]})]})}),bI=(0,u.observer)(e=>{var t;let{model:l}=e,o=e.active??!0,n=e.guardBeforeClose??!0,i=e.onDirtyChange,r=e.onRegisterEditor,a=e.onSaveRequest,d=(0,u.useFlowContext)(),m=l.flowEngine,h=(0,u.serializeFlowRegistry)(l.flowRegistry),f=p.default.useRef(h),[v]=p.default.useState(()=>new u.DetachedFlowRegistry(h)),[y,_]=p.default.useState(!1),b=e.submitLoading??y,x=p.default.useMemo(()=>l.translate.bind(l),[l]),M=p.default.useCallback(()=>!c.default.isEqual(f.current,(0,u.serializeFlowRegistry)(v)),[v]);p.default.useEffect(()=>{null==i||i(M())}),p.default.useEffect(()=>{c.default.isEqual(f.current,h)||M()||((0,u.replaceFlowRegistry)(v,h),f.current=h)},[v,M,h]),p.default.useEffect(()=>{if(!n)return;let e=d.view;if(!e)return;let t=e.beforeClose,l=async e=>(!M()||!!await bv(d,x))&&!1!==await (null==t?void 0:t(e));return e.beforeClose=l,()=>{e.beforeClose===l&&(e.beforeClose=t)}},[d,n,M,x]);let w=()=>{v.addFlow((0,nx.uid)(),{title:x("Event flow"),steps:{}})},S=e=>{e.remove()},k=(e,t)=>{e.title=t},F=()=>[...l.getActions().values()].filter(e=>c.default.castArray(e.scene).includes(u.ActionScene.DYNAMIC_EVENT_FLOW)).sort((e,t)=>(e.sort??0)-(t.sort??0)),C=(e,t)=>{let l={use:t.name};e.addStep((0,nx.uid)(),l)},A=e=>{e.remove()},P=(e,t)=>{e.defaultParams=t},T=e=>(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,s.jsx)("div",{style:{flex:1,marginRight:16},children:(0,s.jsx)(g.Input,{value:e.title,onChange:t=>k(e,t.target.value),onClick:e=>e.stopPropagation(),placeholder:x("Enter flow title")})}),(0,s.jsx)(g.Space,{onClick:e=>e.stopPropagation(),children:(0,s.jsx)(g.Tooltip,{title:"Delete",children:(0,s.jsx)(g.Button,{type:"text",size:"small",icon:(0,s.jsx)(e1.DeleteOutlined,{}),onClick:()=>S(e)})})})]}),j=v.mapFlows(e=>({key:e.key,label:T(e),styles:{header:{display:"flex",alignItems:"center"}},children:(0,s.jsxs)("div",{children:[(0,s.jsx)(bj,{flow:e,model:l,flowEngine:m,flowRegistry:v}),(0,s.jsxs)("div",{children:[(0,s.jsx)(bP,{color:"#52c41a",children:x("Steps")}),(0,s.jsxs)("div",{style:{paddingLeft:12},children:[(0,s.jsx)("div",{style:{marginBottom:16},children:e.mapSteps(e=>{let t=l.getAction(e.use);return t?(0,s.jsxs)("div",{style:{border:"1px solid #f0f0f0",borderRadius:"6px",padding:"12px",marginBottom:"8px"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},children:[(0,s.jsxs)("span",{style:{fontWeight:600,color:"#262626"},children:[x(t.title),(0,s.jsx)("span",{style:{marginInlineStart:2,marginInlineEnd:8},children:":"})]}),(0,s.jsx)(g.Tooltip,{title:x("Delete step"),children:(0,s.jsx)(g.Button,{type:"text",size:"small",icon:(0,s.jsx)(e1.DeleteOutlined,{}),onClick:()=>A(e)})})]}),(0,s.jsx)("div",{children:p.default.createElement(u.FlowStepContext.Provider,{value:{params:(0,u.untracked)(()=>e.defaultParams),path:`${l.uid}_${e.flowKey}_${e.key}`}},m.flowSettings.renderStepForm({uiSchema:t.uiSchema,initialValues:(0,u.untracked)(()=>e.defaultParams),flowEngine:m,onFormValuesChange:t=>P(e,t.values)}))})]},e.key):null})}),(0,s.jsx)(g.Dropdown,{menu:{items:F().map(t=>({key:t.name,label:x(t.title)||t.name,onClick:()=>C(e,t)}))},trigger:["hover"],children:(0,s.jsx)(g.Button,{type:"link",icon:(0,s.jsx)(e1.PlusOutlined,{}),style:{padding:0,height:"auto",textAlign:"left"},children:x("Add step")})})]})]})]})})),I=p.default.useCallback(async()=>{var e,t;let l=d.view;return!!l&&("function"==typeof l.close?await l.close()!==!1:!1!==await (null==(e=l.beforeClose)?void 0:e.call(l,{}))&&(null==(t=l.destroy)||t.call(l),!0))},[d.view]),L=p.default.useCallback(async()=>{var e,t,o,n,r,a,s,d,c,p,m,h;_(!0);let g=v.mapFlows(e=>{if(!bm(e.on))return;bf(e.on);let t=bg(e.on);if(t)return{type:t}}).filter(Boolean)[0];if(g){let e="flowKey"===g.type?x("Please select a built-in flow"):x("Please select a built-in flow step");return null==(a=l.context)||null==(r=a.message)||null==(n=r.error)||n.call(r,e),_(!1),!1}let y=(0,u.serializeFlowRegistry)(l.flowRegistry),b=[];try{for(let e of v.mapFlows(e=>e))for(let t of e.mapSteps(e=>e)){let o=t.serialize(),n=t.use?l.getAction(t.use):void 0,i=o.beforeParamsSave||(null==n?void 0:n.beforeParamsSave),r=o.afterParamsSave||(null==n?void 0:n.afterParamsSave);if("function"!=typeof i&&"function"!=typeof r)continue;let a=new u.FlowRuntimeContext(l,e.key,"settings");(0,u.setupRuntimeContextSteps)(a,e.steps,l,e.key),a.defineProperty("currentStep",{value:o});let s={...t.defaultParams||{}},d={...t.defaultParams||{}};"function"==typeof i&&await i(a,s,d),"function"==typeof r&&b.push(async()=>{await r(a,s,d)}),t.defaultParams=s}(0,u.replaceFlowRegistry)(l.flowRegistry,(0,u.serializeFlowRegistry)(v)),await l.flowRegistry.save()}catch(e){return(0,u.replaceFlowRegistry)(l.flowRegistry,y),_(!1),null==(c=l.context)||null==(d=c.message)||null==(s=d.error)||s.call(d,"Steps post-save hooks failed to run"),console.error(e),!1}f.current=(0,u.serializeFlowRegistry)(l.flowRegistry);try{for(let e of b)await e()}catch(e){null==(h=l.context)||null==(m=h.message)||null==(p=m.error)||p.call(m,"Steps post-save hooks failed to run"),console.error(e)}return l.flowRegistry.mapFlows(e=>{if((0,u.isBeforeRenderFlow)(e))return e}).filter(Boolean).length>0&&l.rerender(),_(!1),null==i||i(!1),null==(o=l.context)||null==(t=o.message)||null==(e=t.success)||e.call(t,x("Configuration saved")),!0},[v,l,i,x]);p.default.useEffect(()=>{if(r)return r({hasUnsavedChanges:M,save:L}),()=>{r()}},[M,r,L]);let D=(0,s.jsxs)(g.Space,{children:[(0,s.jsx)(g.Button,{onClick:I,children:x("Cancel")}),(0,s.jsx)(g.Button,{type:"primary",loading:b,onClick:async()=>{a?await a():await L()&&await I()},children:x("Save")})]}),R=null==(t=d.view)?void 0:t.Footer;return(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,s.jsxs)("div",{style:{flex:1,padding:"16px",overflow:"auto",minHeight:0},children:[j.length>0?(0,s.jsx)(g.Collapse,{items:j,size:"small",style:{marginBottom:8},defaultActiveKey:[j[0].key],accordion:!0}):(0,s.jsx)("div",{style:{border:"1px dashed #d9d9d9",borderRadius:"6px",backgroundColor:"#fafafa",marginBottom:"8px"},children:(0,s.jsx)(g.Empty,{description:x("No event flows"),style:{margin:"20px 0"}})}),(0,s.jsx)(g.Button,{type:"dashed",icon:(0,s.jsx)(e1.PlusOutlined,{}),onClick:w,style:{width:"100%"},children:x("Add event flow")})]}),o?R?(0,s.jsx)(R,{children:D}):(0,s.jsx)("div",{style:bA,children:D}):null]})});var bL=__webpack_require__(2828);let bD=()=>{let e=(0,u.useFlowContext)().app,t=e.pm.get("@nocobase/plugin-block-markdown");return t.dependencyLoaded||(t.initVditorDependency(e),t.dependencyLoaded=!0),t.getCDN(e)},bR="nb-markdown-vditor";function bE(){let{theme:e,token:t,hashId:l}=g.theme.useToken(),o=(0,__rspack_external__ant_design_cssinjs_c619260f.useStyleRegister)({theme:e,token:t,hashId:l,path:["flow-markdown",bR]},()=>({[`.${bR}`]:{".vditor-reset":{fontSize:`${t.fontSize}px !important`,color:"unset"},".vditor-reset h2":{borderBottom:"none !important",boxShadow:"none !important"},".vditor":{borderRadius:8},".vditor .vditor-content":{borderRadius:"0 0 8px 8px",overflow:"hidden"},".vditor .vditor-toolbar":{paddingLeft:" 16px !important",borderRadius:"8px 8px 0 0"},".vditor .vditor-content .vditor-ir .vditor-reset":{padding:"10px !important"},".vditor-ir pre.vditor-reset":{backgroundColor:`${t.colorBgContainer}!important`},".vditor-preview":{display:"none !important"},".vditor-preview__action":{display:"none"}}}));return{wrapSSR:(0,p.useMemo)(()=>o,[o,e,t,l]),hashId:l,componentCls:bR}}function bY(e){let t=new DOMParser().parseFromString(e,"text/html");t.querySelectorAll("img").forEach(e=>{let t=e.getAttribute("src");t&&e.replaceWith(document.createTextNode(` [Image: ${t}] `))});let l=t.body.textContent||t.body.innerText;return(null==l?void 0:l.replace(/\n|\r/g," "))||""}let bN=e=>{if(e){let t=document.createRange();return t.selectNodeContents(e),t.getBoundingClientRect().width}};function bO(e){let t=(0,p.useRef)(null),{wrapSSR:l,componentCls:o,hashId:n}=bE(),i=bD();return(0,p.useEffect)(()=>{e.loadImages&&(__rspack_external_vditor.default.preview(t.current,e.value??"",{mode:"light",cdn:i,markdown:{sanitize:!0},transform:bL.$P}).then(()=>(0,bL.VC)(t.current)).catch(()=>(0,bL.VC)(t.current)),setTimeout(()=>{var e,l;(0,bL.VC)(t.current),null==(e=t.current)||e.querySelectorAll("img").forEach(e=>{e.style.cursor="zoom-in",e.addEventListener("click",()=>{bB(e.src)})}),null==(l=t.current)||l.querySelectorAll("qr-code").forEach(e=>{let t=e.getAttribute("value")||"",l=document.createElement("div");e.replaceWith(l),(0,__rspack_external_react_dom_client_76b1397c.createRoot)(l).render((0,s.jsx)(g.QRCode,{value:t}))})},300))},[e.value,e.loadImages,i]),l((0,s.jsx)("span",{className:`${n} ${o}`,children:(0,s.jsx)("span",{ref:t,style:{border:"none",...(null==e?void 0:e.style)??{}}})}))}function bB(e){if(document.getElementById("custom-image-preview"))return;let t=document.createElement("span");t.id="custom-image-preview",Object.assign(t.style,{position:"fixed",inset:"0",backgroundColor:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"9999",cursor:"zoom-out"});let l=document.createElement("img");l.src=e,Object.assign(l.style,{maxWidth:"90%",maxHeight:"90%",borderRadius:"8px",boxShadow:"0 0 20px rgba(0,0,0,0.5)",transition:"transform 0.2s",cursor:"zoom-out"}),t.addEventListener("click",()=>{document.body.removeChild(t)}),t.appendChild(l),document.body.appendChild(t)}let bV=e=>{let{value:t,textOnly:l=!0}=e,o=bD(),[n,i]=(0,p.useState)(!1),[r,a]=(0,p.useState)(!1),[d,u]=(0,p.useState)(!1),[c,m]=(0,p.useState)(""),h=(0,p.useRef)();(0,p.useEffect)(()=>{e.value&&l&&__rspack_external_vditor.default.md2html(e.value,{mode:"light",cdn:o,markdown:{sanitize:!0}}).then(e=>{m(bY((0,bL.$P)(e)))}).catch(()=>m(""))},[e.value,l,o]);let f=(0,p.useCallback)(()=>{var e;return!!h.current&&bN(h.current)>(null==(e=h.current)?void 0:e.offsetWidth)},[h]),v=e=>{i(e),e&&!d&&u(!0)};return e.ellipsis?(0,s.jsx)(g.Popover,{open:n,getPopupContainer:()=>{var e;return null==(e=document.getElementsByClassName("ant-drawer-content"))?void 0:e[0]},onOpenChange:e=>{v(r&&e)},overlayStyle:{maxWidth:600},content:(0,s.jsx)("div",{style:{maxHeight:400,overflow:"auto"},children:(0,s.jsx)(bO,{value:t,loadImages:d})}),children:(0,s.jsx)("div",{ref:h,style:{overflow:"hidden",overflowWrap:"break-word",textOverflow:"ellipsis",whiteSpace:"nowrap",wordBreak:"break-all"},onMouseEnter:e=>{let t=e.target;f()&&a(t.scrollWidth>=t.clientWidth)},children:l?c:(0,s.jsx)("div",{className:(0,S.css)`
1320
1320
  .vditor-reset {
1321
1321
  white-space: nowrap;
1322
1322
  display: -webkit-box;