@baasix/baasix 0.1.61 → 0.1.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/app/404/index.html +1 -1
  2. package/dist/app/404.html +1 -1
  3. package/dist/app/_next/static/chunks/2667-7993936698bf75a9.js +1 -0
  4. package/dist/app/_next/static/chunks/3233-ae028c73c510ebea.js +1 -0
  5. package/dist/app/_next/static/chunks/4033-ea89dd457b87cead.js +1 -0
  6. package/dist/app/_next/static/chunks/799-d4372ad380b0dec6.js +1 -0
  7. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/all-activity/{page-a7e9f0b39624b489.js → page-8e1f084e807ff5ee.js} +1 -1
  8. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/email-log/{page-40f2b9ecf73e74b5.js → page-4e08df2865fe9d0f.js} +1 -1
  9. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/notifications/{page-21fcdd2f0b3549db.js → page-3a5070a5088835ae.js} +1 -1
  10. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/sessions/{page-82662735f1ec476a.js → page-edfa379cab0d3ccb.js} +1 -1
  11. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/workflow-executions/{page-4a781c95e5fb25f0.js → page-d007890f17b60862.js} +1 -1
  12. package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/workflow-logs/{page-70bf8d31074dcba0.js → page-976e9829706ac8f2.js} +1 -1
  13. package/dist/app/_next/static/chunks/app/(authenticated)/dashboard/page-6bff6e8911fc5036.js +1 -0
  14. package/dist/app/_next/static/chunks/app/(authenticated)/data-browser/{page-d5715b9743d8dba4.js → page-fbb7a4d4f2a4353d.js} +1 -1
  15. package/dist/app/_next/static/chunks/app/(authenticated)/file-manager/{page-c008de2bcf6811b9.js → page-cea6a2c1670d4ef5.js} +1 -1
  16. package/dist/app/_next/static/chunks/app/(authenticated)/layout-b7f18737e4c308a4.js +1 -0
  17. package/dist/app/_next/static/chunks/app/(authenticated)/settings/migrations/page-505c3389890685b9.js +1 -0
  18. package/dist/app/_next/static/chunks/app/(authenticated)/settings/permissions/{page-2d3043500adcdb12.js → page-ed80f4bd5d81df95.js} +1 -1
  19. package/dist/app/_next/static/chunks/app/(authenticated)/settings/project/{page-6a58f15efb013e17.js → page-310b8ce72d0516ea.js} +1 -1
  20. package/dist/app/_next/static/chunks/app/(authenticated)/settings/roles/{page-00cf3e4483986407.js → page-fd62dc19ac88dd64.js} +1 -1
  21. package/dist/app/_next/static/chunks/app/(authenticated)/settings/schema/page-3d91124704c2e853.js +1 -0
  22. package/dist/app/_next/static/chunks/app/(authenticated)/settings/schema-diff/page-cae8772a7ae93b9a.js +1 -0
  23. package/dist/app/_next/static/chunks/app/(authenticated)/settings/tasks/{page-fa3c401992a2fb8f.js → page-1479604bbfc53a83.js} +1 -1
  24. package/dist/app/_next/static/chunks/app/(authenticated)/settings/templates/edit/{page-4ce715d527c717a8.js → page-a611195661ce22bd.js} +1 -1
  25. package/dist/app/_next/static/chunks/app/(authenticated)/settings/templates/{page-aafbfd4f12875738.js → page-6787b62a4960304f.js} +1 -1
  26. package/dist/app/_next/static/chunks/app/(authenticated)/settings/tenants/{page-f34d97ce6f68183b.js → page-856d4af5fbd76c8e.js} +1 -1
  27. package/dist/app/_next/static/chunks/app/(authenticated)/users/invites/{page-20dd05a8745b6283.js → page-ed5493d55f6c1db8.js} +1 -1
  28. package/dist/app/_next/static/chunks/app/(authenticated)/users/list/{page-479a164304f4de3f.js → page-02e6ef533bdc3bbc.js} +1 -1
  29. package/dist/app/_next/static/chunks/app/(authenticated)/users/{page-909d7be1b8d9800c.js → page-faf321b61a6fdeef.js} +1 -1
  30. package/dist/app/_next/static/chunks/app/(authenticated)/users/preferences/{page-e3fbcc425e1710e5.js → page-2116015e962a2ecc.js} +1 -1
  31. package/dist/app/_next/static/chunks/app/(authenticated)/users/user-roles/{page-3f654c69d79269f7.js → page-7d1bcbbfc8f0694b.js} +1 -1
  32. package/dist/app/_next/static/chunks/app/(authenticated)/workflows/edit/{page-753cf274fd329860.js → page-45c465caaa5679bd.js} +1 -1
  33. package/dist/app/_next/static/chunks/app/(authenticated)/workflows/{page-33c1c69678122839.js → page-7f9cb24aaa798f42.js} +1 -1
  34. package/dist/app/_next/static/chunks/{main-324e91f5a430cddf.js → main-8ffa7219a08e42cf.js} +1 -1
  35. package/dist/app/_next/static/chunks/{webpack-b29732cfe967a5f5.js → webpack-7a100cbf9402e7ea.js} +1 -1
  36. package/dist/app/_next/static/css/45276c37be155f45.css +3 -0
  37. package/dist/app/activity-log/all-activity/index.html +1 -1
  38. package/dist/app/activity-log/all-activity/index.txt +3 -3
  39. package/dist/app/activity-log/email-log/index.html +1 -1
  40. package/dist/app/activity-log/email-log/index.txt +3 -3
  41. package/dist/app/activity-log/index.html +1 -1
  42. package/dist/app/activity-log/index.txt +2 -2
  43. package/dist/app/activity-log/notifications/index.html +1 -1
  44. package/dist/app/activity-log/notifications/index.txt +3 -3
  45. package/dist/app/activity-log/sessions/index.html +1 -1
  46. package/dist/app/activity-log/sessions/index.txt +3 -3
  47. package/dist/app/activity-log/workflow-executions/index.html +1 -1
  48. package/dist/app/activity-log/workflow-executions/index.txt +3 -3
  49. package/dist/app/activity-log/workflow-logs/index.html +1 -1
  50. package/dist/app/activity-log/workflow-logs/index.txt +3 -3
  51. package/dist/app/change-password/index.html +1 -1
  52. package/dist/app/change-password/index.txt +2 -2
  53. package/dist/app/dashboard/index.html +1 -1
  54. package/dist/app/dashboard/index.txt +3 -3
  55. package/dist/app/data-browser/index.html +1 -1
  56. package/dist/app/data-browser/index.txt +3 -3
  57. package/dist/app/file-manager/index.html +1 -1
  58. package/dist/app/file-manager/index.txt +3 -3
  59. package/dist/app/forgot-password/index.html +1 -1
  60. package/dist/app/forgot-password/index.txt +1 -1
  61. package/dist/app/index.html +1 -1
  62. package/dist/app/index.txt +1 -1
  63. package/dist/app/login/index.html +1 -1
  64. package/dist/app/login/index.txt +1 -1
  65. package/dist/app/register/index.html +1 -1
  66. package/dist/app/register/index.txt +1 -1
  67. package/dist/app/settings/migrations/index.html +1 -1
  68. package/dist/app/settings/migrations/index.txt +3 -3
  69. package/dist/app/settings/permissions/index.html +1 -1
  70. package/dist/app/settings/permissions/index.txt +3 -3
  71. package/dist/app/settings/project/index.html +1 -1
  72. package/dist/app/settings/project/index.txt +3 -3
  73. package/dist/app/settings/roles/index.html +1 -1
  74. package/dist/app/settings/roles/index.txt +3 -3
  75. package/dist/app/settings/schema/index.html +1 -1
  76. package/dist/app/settings/schema/index.txt +3 -3
  77. package/dist/app/settings/schema-diff/index.html +1 -0
  78. package/dist/app/settings/schema-diff/index.txt +14 -0
  79. package/dist/app/settings/tasks/index.html +1 -1
  80. package/dist/app/settings/tasks/index.txt +3 -3
  81. package/dist/app/settings/templates/edit/index.html +1 -1
  82. package/dist/app/settings/templates/edit/index.txt +3 -3
  83. package/dist/app/settings/templates/index.html +1 -1
  84. package/dist/app/settings/templates/index.txt +3 -3
  85. package/dist/app/settings/tenants/index.html +1 -1
  86. package/dist/app/settings/tenants/index.txt +3 -3
  87. package/dist/app/users/index.html +1 -1
  88. package/dist/app/users/index.txt +3 -3
  89. package/dist/app/users/invites/index.html +1 -1
  90. package/dist/app/users/invites/index.txt +3 -3
  91. package/dist/app/users/list/index.html +1 -1
  92. package/dist/app/users/list/index.txt +3 -3
  93. package/dist/app/users/preferences/index.html +1 -1
  94. package/dist/app/users/preferences/index.txt +3 -3
  95. package/dist/app/users/user-roles/index.html +1 -1
  96. package/dist/app/users/user-roles/index.txt +3 -3
  97. package/dist/app/workflows/detail/index.html +1 -1
  98. package/dist/app/workflows/detail/index.txt +2 -2
  99. package/dist/app/workflows/edit/index.html +1 -1
  100. package/dist/app/workflows/edit/index.txt +3 -3
  101. package/dist/app/workflows/execution/index.html +1 -1
  102. package/dist/app/workflows/execution/index.txt +2 -2
  103. package/dist/app/workflows/index.html +1 -1
  104. package/dist/app/workflows/index.txt +3 -3
  105. package/dist/routes/mcp.route.d.ts.map +1 -1
  106. package/dist/routes/mcp.route.js +283 -2
  107. package/dist/routes/mcp.route.js.map +1 -1
  108. package/dist/routes/schema-diff.route.d.ts +7 -0
  109. package/dist/routes/schema-diff.route.d.ts.map +1 -0
  110. package/dist/routes/schema-diff.route.js +320 -0
  111. package/dist/routes/schema-diff.route.js.map +1 -0
  112. package/dist/services/ItemsService.d.ts +5 -4
  113. package/dist/services/ItemsService.d.ts.map +1 -1
  114. package/dist/services/ItemsService.js +30 -26
  115. package/dist/services/ItemsService.js.map +1 -1
  116. package/package.json +1 -1
  117. package/dist/app/_next/static/chunks/2033-8355304f13887db5.js +0 -1
  118. package/dist/app/_next/static/chunks/4952-1b97320cf61f3f21.js +0 -1
  119. package/dist/app/_next/static/chunks/6547-1aaab011e6089042.js +0 -1
  120. package/dist/app/_next/static/chunks/app/(authenticated)/dashboard/page-1ceeac9e72997a8a.js +0 -1
  121. package/dist/app/_next/static/chunks/app/(authenticated)/layout-2a4b221af5cbbade.js +0 -1
  122. package/dist/app/_next/static/chunks/app/(authenticated)/settings/migrations/page-6681c14dd478cc9a.js +0 -1
  123. package/dist/app/_next/static/chunks/app/(authenticated)/settings/schema/page-e7f836d3a7f7c5d0.js +0 -1
  124. package/dist/app/_next/static/css/17a2e01c4184b106.css +0 -3
  125. /package/dist/app/_next/static/{ORfvBD2VaKIB_8_7O9AgQ → O6PA41CeUjDJQ4sma7vMH}/_buildManifest.js +0 -0
  126. /package/dist/app/_next/static/{ORfvBD2VaKIB_8_7O9AgQ → O6PA41CeUjDJQ4sma7vMH}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9853],{24654:function(){},61514:function(e,t,o){Promise.resolve().then(o.bind(o,36303))},36303:function(e,t,o){"use strict";o.r(t),o.d(t,{default:function(){return z}});var r=o(57437),s=o(2265),n=o(99376),a=o(72135),l=o(30166),i=o(14438),d=o(51817),c=o(32660),u=o(42208),f=o(7586),m=o(83229),h=o(12381),p=o(79820),x=o(40279),g=o(75060),v=o(23675),w=o(17168),b=o(15291),j=o(18333),k=o(32489),y=o(24156),N=o(30401),_=o(69174),S=o(2596),C=o(12749),I=o(93448);function D(e){let{options:t,selected:o,onChange:n,placeholder:a="Select...",className:l}=e,[i,d]=s.useState(!1),c=e=>{n(o.filter(t=>t!==e))},u=e=>{o.includes(e)?n(o.filter(t=>t!==e)):n([...o,e])};return(0,r.jsxs)(C.J2,{open:i,onOpenChange:d,children:[(0,r.jsx)(C.xo,{asChild:!0,children:(0,r.jsxs)(h.z,{variant:"outline",role:"combobox","aria-expanded":i,className:(0,I.cn)("w-full justify-between",l),children:[(0,r.jsxs)("div",{className:"flex gap-1 flex-wrap",children:[0===o.length?(0,r.jsx)("span",{className:"text-muted-foreground",children:a}):o.slice(0,3).map(e=>{var o;return(0,r.jsxs)(_.C,{variant:"secondary",className:"mr-1",onClick:t=>{t.stopPropagation(),c(e)},children:[(null===(o=t.find(t=>t.value===e))||void 0===o?void 0:o.label)||e,(0,r.jsx)(k.Z,{className:"ml-1 h-3 w-3"})]},e)}),o.length>3&&(0,r.jsxs)(_.C,{variant:"secondary",children:["+",o.length-3," more"]})]}),(0,r.jsx)(y.Z,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,r.jsx)(C.yk,{className:"w-full p-0",align:"start",children:(0,r.jsxs)(S.mY,{children:[(0,r.jsx)(S.sZ,{placeholder:"Search..."}),(0,r.jsxs)(S.e8,{children:[(0,r.jsx)(S.rb,{children:"No option found."}),(0,r.jsx)(S.fu,{className:"max-h-64 overflow-auto",children:t.map(e=>(0,r.jsxs)(S.di,{value:e.value,onSelect:()=>u(e.value),children:[(0,r.jsx)(N.Z,{className:(0,I.cn)("mr-2 h-4 w-4",o.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},e.value))})]})]})})]})}let R=(0,l.default)(()=>Promise.all([o.e(1627),o.e(780),o.e(926),o.e(9881),o.e(3563),o.e(3834),o.e(1299)]).then(o.bind(o,81299)).then(e=>({default:e.WorkflowBuilder})),{loadableGenerated:{webpack:()=>[81299]},ssr:!1}),E=e=>{let{workflowId:t}=e,o=(0,n.useRouter)(),{startExecution:l}=(0,j.R)(),[k,y]=(0,s.useState)("manual"),[N,_]=(0,s.useState)({id:"",name:"",description:"",status:"draft",trigger_type:"manual",cron:"",webhook_path:"",webhook_method:"POST",hook_collection:"",hook_action:"",allowed_roles:[]}),{data:S,isLoading:C}=(0,a.rD)({resource:"baasix_Workflow",id:t||"",queryOptions:{enabled:!!t}}),{data:I}=(0,a.sm)({resource:"baasix_Role",pagination:{mode:"off"}}),{mutate:E}=(0,a.PQ)(),{mutate:z}=(0,a.uC)(),P=null==S?void 0:S.data,Q=(null==I?void 0:I.data)||[];(0,s.useEffect)(()=>{P&&(y(P.trigger_type),_({id:String(P.id||""),name:P.name,description:P.description||"",status:P.status,trigger_type:P.trigger_type,cron:P.trigger_cron||"",webhook_path:P.trigger_webhook_path||"",webhook_method:P.trigger_webhook_method||"POST",hook_collection:P.trigger_hook_collection||"",hook_action:P.trigger_hook_action||"",allowed_roles:P.allowed_roles||[]}))},[P]);let Y=(e,t)=>{_(o=>({...o,[e]:t})),"trigger_type"===e&&y(t)},Z=e=>{if(!t)return;let o={id:N.id,name:N.name,description:N.description,status:N.status,trigger_type:N.trigger_type,allowed_roles:N.allowed_roles||[],...e&&{flow_data:e}};"schedule"===k?(o.trigger_cron=N.cron,o.trigger_webhook_path=null,o.trigger_webhook_method=null,o.trigger_hook_collection=null,o.trigger_hook_action=null):"webhook"===k?(o.trigger_cron=null,o.trigger_webhook_path=N.webhook_path,o.trigger_webhook_method=N.webhook_method,o.trigger_hook_collection=null,o.trigger_hook_action=null):"hook"===k?(o.trigger_cron=null,o.trigger_webhook_path=null,o.trigger_webhook_method=null,o.trigger_hook_collection=N.hook_collection,o.trigger_hook_action=N.hook_action):(o.trigger_cron=null,o.trigger_webhook_path=null,o.trigger_webhook_method=null,o.trigger_hook_collection=null,o.trigger_hook_action=null),E({resource:"baasix_Workflow",id:t,values:o,successNotification:!1},{onSuccess:()=>{i.Am.success("Workflow saved")}})};return!C&&P&&t?(0,r.jsxs)("div",{className:"flex flex-col h-full overflow-hidden p-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(h.z,{variant:"ghost",size:"icon",onClick:()=>o.push("/workflows"),children:(0,r.jsx)(c.Z,{className:"h-4 w-4"})}),(0,r.jsx)("h1",{className:"text-xl font-semibold",children:P.name})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)(h.z,{variant:"outline",onClick:()=>o.push("/workflows/detail?id=".concat(t)),children:[(0,r.jsx)(u.Z,{className:"h-4 w-4 mr-2"}),"Overview"]}),(0,r.jsxs)(h.z,{variant:"outline",onClick:()=>o.push("/workflows/detail?id=".concat(t,"#executions")),children:[(0,r.jsx)(f.Z,{className:"h-4 w-4 mr-2"}),"Executions"]})]})]}),(0,r.jsxs)(w.mQ,{defaultValue:"builder",className:"flex-1 flex flex-col overflow-hidden",children:[(0,r.jsxs)(w.dr,{children:[(0,r.jsx)(w.SP,{value:"builder",children:"Workflow Builder"}),(0,r.jsx)(w.SP,{value:"settings",children:"Settings"})]}),(0,r.jsx)(w.nU,{value:"builder",className:"flex-1 overflow-hidden mt-4",children:(0,r.jsx)(R,{workflow:P,onSave:Z,onExecute:"active"===P.status?()=>{t&&z({url:"/workflows/".concat(t,"/execute"),method:"post",values:{},successNotification:!1},{onSuccess:e=>{var t,o,r;i.Am.success("Workflow execution started");let s=(null==e?void 0:null===(t=e.execution)||void 0===t?void 0:t.id)||(null==e?void 0:null===(r=e.data)||void 0===r?void 0:null===(o=r.execution)||void 0===o?void 0:o.id);s&&l(s)},onError:()=>{i.Am.error("Failed to execute workflow")}})}:void 0})}),(0,r.jsx)(w.nU,{value:"settings",className:"flex-1 overflow-auto mt-4",children:(0,r.jsxs)(p.Zb,{children:[(0,r.jsxs)(p.Ol,{children:[(0,r.jsx)(p.ll,{children:"Workflow Settings"}),(0,r.jsx)(p.SZ,{children:"Configure workflow properties and trigger settings"})]}),(0,r.jsxs)(p.aY,{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"id",children:"Workflow ID"}),(0,r.jsx)(x.I,{id:"id",value:N.id,onChange:e=>Y("id",e.target.value)}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Unique identifier for this workflow"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"name",children:"Workflow Name *"}),(0,r.jsx)(x.I,{id:"name",value:N.name,onChange:e=>Y("name",e.target.value)})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"description",children:"Description"}),(0,r.jsx)(v.g,{id:"description",rows:3,value:N.description,onChange:e=>Y("description",e.target.value)})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{children:"Status *"}),(0,r.jsxs)(b.Ph,{value:N.status,onValueChange:e=>Y("status",e),children:[(0,r.jsx)(b.i4,{children:(0,r.jsx)(b.ki,{placeholder:"Select status"})}),(0,r.jsxs)(b.Bw,{children:[(0,r.jsx)(b.Ql,{value:"draft",children:"Draft"}),(0,r.jsx)(b.Ql,{value:"active",children:"Active"}),(0,r.jsx)(b.Ql,{value:"inactive",children:"Inactive"})]})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{children:"Trigger Type *"}),(0,r.jsxs)(b.Ph,{value:N.trigger_type,onValueChange:e=>Y("trigger_type",e),children:[(0,r.jsx)(b.i4,{children:(0,r.jsx)(b.ki,{placeholder:"Select trigger type"})}),(0,r.jsxs)(b.Bw,{children:[(0,r.jsx)(b.Ql,{value:"manual",children:"Manual"}),(0,r.jsx)(b.Ql,{value:"webhook",children:"Webhook"}),(0,r.jsx)(b.Ql,{value:"schedule",children:"Schedule"}),(0,r.jsx)(b.Ql,{value:"hook",children:"Hook"})]})]})]}),"schedule"===k&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"cron",children:"Cron Expression *"}),(0,r.jsx)(x.I,{id:"cron",placeholder:"0 0 * * *",value:N.cron,onChange:e=>Y("cron",e.target.value)}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Example: 0 0 * * * (runs daily at midnight)"})]}),"webhook"===k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"webhook_path",children:"Webhook Path *"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"/webhook"}),(0,r.jsx)(x.I,{id:"webhook_path",placeholder:"/my-workflow",value:N.webhook_path,onChange:e=>Y("webhook_path",e.target.value)})]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Full URL will be: https://your-domain.com/webhook",N.webhook_path]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{children:"HTTP Method *"}),(0,r.jsxs)(b.Ph,{value:N.webhook_method,onValueChange:e=>Y("webhook_method",e),children:[(0,r.jsx)(b.i4,{children:(0,r.jsx)(b.ki,{placeholder:"Select method"})}),(0,r.jsxs)(b.Bw,{children:[(0,r.jsx)(b.Ql,{value:"GET",children:"GET"}),(0,r.jsx)(b.Ql,{value:"POST",children:"POST"}),(0,r.jsx)(b.Ql,{value:"PUT",children:"PUT"}),(0,r.jsx)(b.Ql,{value:"PATCH",children:"PATCH"}),(0,r.jsx)(b.Ql,{value:"DELETE",children:"DELETE"})]})]})]})]}),"hook"===k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"hook_collection",children:"Collection Name *"}),(0,r.jsx)(x.I,{id:"hook_collection",placeholder:"baasix_User",value:N.hook_collection,onChange:e=>Y("hook_collection",e.target.value)}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"The collection to watch for changes"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{children:"Hook Action *"}),(0,r.jsxs)(b.Ph,{value:N.hook_action,onValueChange:e=>Y("hook_action",e),children:[(0,r.jsx)(b.i4,{children:(0,r.jsx)(b.ki,{placeholder:"Select action"})}),(0,r.jsxs)(b.Bw,{children:[(0,r.jsx)(b.Ql,{value:"items.read",children:"Before Read"}),(0,r.jsx)(b.Ql,{value:"items.read.one",children:"Before Read One"}),(0,r.jsx)(b.Ql,{value:"items.create",children:"Before Create"}),(0,r.jsx)(b.Ql,{value:"items.update",children:"Before Update"}),(0,r.jsx)(b.Ql,{value:"items.delete",children:"Before Delete"}),(0,r.jsx)(b.Ql,{value:"items.read.after",children:"After Read"}),(0,r.jsx)(b.Ql,{value:"items.read.one.after",children:"After Read One"}),(0,r.jsx)(b.Ql,{value:"items.create.after",children:"After Create"}),(0,r.jsx)(b.Ql,{value:"items.update.after",children:"After Update"}),(0,r.jsx)(b.Ql,{value:"items.delete.after",children:"After Delete"})]})]})]})]}),"schedule"!==k&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{children:"Allowed Roles"}),(0,r.jsx)(D,{options:Q.map(e=>({label:e.name,value:e.id})),selected:N.allowed_roles,onChange:e=>Y("allowed_roles",e),placeholder:"Select roles (optional)"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Select roles that can execute this workflow. Leave empty to allow all authenticated users."})]}),(0,r.jsxs)(h.z,{onClick:()=>{if(t){if(!N.name){i.Am.error("Please enter workflow name");return}Z(),N.id&&N.id!==t&&o.push("/workflows/edit?id=".concat(N.id))}},children:[(0,r.jsx)(m.Z,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})})]})]}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)(d.Z,{className:"h-8 w-8 animate-spin"})})};var z=()=>{let e=(0,n.useSearchParams)(),[t,o]=(0,s.useState)(null);return((0,s.useEffect)(()=>{o(e.get("id"))},[e]),t)?(0,r.jsx)(j.S,{workflowId:t,children:(0,r.jsx)(E,{workflowId:t})}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)(d.Z,{className:"h-8 w-8 animate-spin"})})}},12438:function(e,t,o){"use strict";o.d(t,{$:function(){return s}});var r=o(68680);class s{connect(e,t){return this.socket=(0,r.io)(e,{auth:{token:t},path:"/realtime",reconnection:!0,reconnectionAttempts:5,reconnectionDelay:1e3,reconnectionDelayMax:5e3,transports:["websocket","polling"]}),this._setupListeners(),this}_setupListeners(){this.socket&&(this.socket.on("connect",()=>{console.log("Connected to socket server"),this.subscriptions.forEach(e=>{this._subscribe(e)})}),this.socket.on("connected",e=>{console.log("Socket authenticated:",e)}),this.socket.on("disconnect",e=>{console.log("Disconnected from socket server:",e)}),this.socket.on("connect_error",e=>{console.error("Socket connection error:",e)}))}_subscribe(e){this.socket&&this.socket.emit("subscribe",{collection:e})}async subscribe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((o,r)=>{if(!this.socket){r(Error("Socket not connected"));return}this.socket.emit("subscribe",{collection:e},s=>{"success"===s.status?(this.subscriptions.add(e),["create","update","delete"].forEach(o=>{let r="".concat(e,":").concat(o),s=t[o];s&&(this.eventHandlers.has(r)&&this.socket.off(r,this.eventHandlers.get(r)),this.socket.on(r,s),this.eventHandlers.set(r,s))}),o()):r(Error(s.message))})})}async unsubscribe(e){return new Promise((t,o)=>{if(!this.socket){o(Error("Socket not connected"));return}this.socket.emit("unsubscribe",{collection:e},r=>{"success"===r.status?(this.subscriptions.delete(e),["create","update","delete"].forEach(t=>{let o="".concat(e,":").concat(t);this.eventHandlers.has(o)&&(this.socket.off(o,this.eventHandlers.get(o)),this.eventHandlers.delete(o))}),t()):o(Error(r.message))})})}disconnect(){this.socket&&(this.socket.disconnect(),this.subscriptions.clear(),this.eventHandlers.clear())}constructor(){this.socket=null,this.subscriptions=new Set,this.eventHandlers=new Map}}},69174:function(e,t,o){"use strict";o.d(t,{C:function(){return l}});var r=o(57437);o(2265);var s=o(90535),n=o(93448);let a=(0,s.j)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function l(e){let{className:t,variant:o,...s}=e;return(0,r.jsx)("div",{className:(0,n.cn)(a({variant:o}),t),...s})}},12381:function(e,t,o){"use strict";o.d(t,{d:function(){return i},z:function(){return d}});var r=o(57437),s=o(2265),n=o(37053),a=o(90535),l=o(93448);let i=(0,a.j)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),d=s.forwardRef((e,t)=>{let{className:o,variant:s,size:a,asChild:d=!1,...c}=e,u=d?n.g7:"button";return(0,r.jsx)(u,{className:(0,l.cn)(i({variant:s,size:a,className:o})),ref:t,...c})});d.displayName="Button"},79820:function(e,t,o){"use strict";o.d(t,{Ol:function(){return l},SZ:function(){return d},Zb:function(){return a},aY:function(){return c},eW:function(){return u},ll:function(){return i}});var r=o(57437),s=o(2265),n=o(93448);let a=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,n.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",o),...s})});a.displayName="Card";let l=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,n.cn)("flex flex-col space-y-1 p-4",o),...s})});l.displayName="CardHeader";let i=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("h3",{ref:t,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",o),...s})});i.displayName="CardTitle";let d=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("p",{ref:t,className:(0,n.cn)("text-sm text-muted-foreground",o),...s})});d.displayName="CardDescription";let c=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,n.cn)("p-4 pt-0",o),...s})});c.displayName="CardContent";let u=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,n.cn)("flex items-center p-4 pt-0",o),...s})});u.displayName="CardFooter"},2596:function(e,t,o){"use strict";o.d(t,{di:function(){return h},e8:function(){return c},fu:function(){return f},mY:function(){return i},rb:function(){return u},sZ:function(){return d},zz:function(){return m}});var r=o(57437),s=o(2265),n=o(46343),a=o(73247),l=o(93448);o(74291);let i=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.mY,{ref:t,className:(0,l.cn)("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",o),...s})});i.displayName=n.mY.displayName;let d=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,r.jsx)(a.Z,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,r.jsx)(n.mY.Input,{ref:t,className:(0,l.cn)("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",o),...s})]})});d.displayName=n.mY.Input.displayName;let c=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.mY.List,{ref:t,className:(0,l.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",o),...s})});c.displayName=n.mY.List.displayName;let u=s.forwardRef((e,t)=>(0,r.jsx)(n.mY.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));u.displayName=n.mY.Empty.displayName;let f=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.mY.Group,{ref:t,className:(0,l.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",o),...s})});f.displayName=n.mY.Group.displayName;let m=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.mY.Separator,{ref:t,className:(0,l.cn)("-mx-1 h-px bg-border",o),...s})});m.displayName=n.mY.Separator.displayName;let h=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.mY.Item,{ref:t,className:(0,l.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",o),...s})});h.displayName=n.mY.Item.displayName},74291:function(e,t,o){"use strict";o.d(t,{$N:function(){return p},Be:function(){return x},Vq:function(){return i},cN:function(){return h},cZ:function(){return f},fK:function(){return m},hg:function(){return d}});var r=o(57437),s=o(2265),n=o(70001),a=o(32489),l=o(93448);let i=n.fC,d=n.xz,c=n.h_;n.x8;let u=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.aV,{ref:t,className:(0,l.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",o),...s})});u.displayName=n.aV.displayName;let f=s.forwardRef((e,t)=>{let{className:o,children:s,...i}=e;return(0,r.jsxs)(c,{children:[(0,r.jsx)(u,{}),(0,r.jsxs)(n.VY,{ref:t,className:(0,l.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",o),...i,children:[s,(0,r.jsxs)(n.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,r.jsx)(a.Z,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});f.displayName=n.VY.displayName;let m=e=>{let{className:t,...o}=e;return(0,r.jsx)("div",{className:(0,l.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...o})};m.displayName="DialogHeader";let h=e=>{let{className:t,...o}=e;return(0,r.jsx)("div",{className:(0,l.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...o})};h.displayName="DialogFooter";let p=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.Dx,{ref:t,className:(0,l.cn)("text-lg font-semibold leading-none tracking-tight",o),...s})});p.displayName=n.Dx.displayName;let x=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.dk,{ref:t,className:(0,l.cn)("text-sm text-muted-foreground",o),...s})});x.displayName=n.dk.displayName},40279:function(e,t,o){"use strict";o.d(t,{I:function(){return a}});var r=o(57437),s=o(2265),n=o(93448);let a=s.forwardRef((e,t)=>{let{className:o,type:s,...a}=e;return(0,r.jsx)("input",{type:s,className:(0,n.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",o),ref:t,...a})});a.displayName="Input"},75060:function(e,t,o){"use strict";o.d(t,{_:function(){return d}});var r=o(57437),s=o(2265),n=o(370),a=o(90535),l=o(93448);let i=(0,a.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.f,{ref:t,className:(0,l.cn)(i(),o),...s})});d.displayName=n.f.displayName},12749:function(e,t,o){"use strict";o.d(t,{J2:function(){return l},xo:function(){return i},yk:function(){return d}});var r=o(57437),s=o(2265),n=o(51777),a=o(93448);let l=n.fC,i=n.xz;n.ee;let d=s.forwardRef((e,t)=>{let{className:o,align:s="center",sideOffset:l=4,...i}=e;return(0,r.jsx)(n.h_,{children:(0,r.jsx)(n.VY,{ref:t,align:s,sideOffset:l,className:(0,a.cn)("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",o),...i})})});d.displayName=n.VY.displayName},15291:function(e,t,o){"use strict";o.d(t,{Bw:function(){return x},DI:function(){return u},Ph:function(){return c},Ql:function(){return v},i4:function(){return m},ki:function(){return f},n5:function(){return g}});var r=o(57437),s=o(2265),n=o(74797),a=o(40875),l=o(22135),i=o(30401),d=o(93448);let c=n.fC,u=n.ZA,f=n.B4,m=s.forwardRef((e,t)=>{let{className:o,children:s,...l}=e;return(0,r.jsxs)(n.xz,{ref:t,className:(0,d.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",o),...l,children:[s,(0,r.jsx)(n.JO,{asChild:!0,children:(0,r.jsx)(a.Z,{className:"h-4 w-4 opacity-50"})})]})});m.displayName=n.xz.displayName;let h=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.u_,{ref:t,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",o),...s,children:(0,r.jsx)(l.Z,{className:"h-4 w-4"})})});h.displayName=n.u_.displayName;let p=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.$G,{ref:t,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",o),...s,children:(0,r.jsx)(a.Z,{className:"h-4 w-4"})})});p.displayName=n.$G.displayName;let x=s.forwardRef((e,t)=>{let{className:o,children:s,position:a="popper",...l}=e;return(0,r.jsx)(n.h_,{children:(0,r.jsxs)(n.VY,{ref:t,className:(0,d.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===a&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",o),position:a,...l,children:[(0,r.jsx)(h,{}),(0,r.jsx)(n.l_,{className:(0,d.cn)("p-1 max-h-[300px] overflow-y-auto","popper"===a&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),style:{overscrollBehavior:"contain",touchAction:"pan-y",WebkitOverflowScrolling:"touch",willChange:"scroll-position",pointerEvents:"auto"},children:s}),(0,r.jsx)(p,{})]})})});x.displayName=n.VY.displayName;let g=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.__,{ref:t,className:(0,d.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",o),...s})});g.displayName=n.__.displayName;let v=s.forwardRef((e,t)=>{let{className:o,children:s,...a}=e;return(0,r.jsxs)(n.ck,{ref:t,className:(0,d.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o),...a,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(n.wU,{children:(0,r.jsx)(i.Z,{className:"h-4 w-4"})})}),(0,r.jsx)(n.eT,{children:s})]})});v.displayName=n.ck.displayName,s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.Z0,{ref:t,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",o),...s})}).displayName=n.Z0.displayName},17168:function(e,t,o){"use strict";o.d(t,{SP:function(){return d},dr:function(){return i},mQ:function(){return l},nU:function(){return c}});var r=o(57437),s=o(2265),n=o(20271),a=o(93448);let l=n.fC,i=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.aV,{ref:t,className:(0,a.cn)("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",o),...s})});i.displayName=n.aV.displayName;let d=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.xz,{ref:t,className:(0,a.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",o),...s})});d.displayName=n.xz.displayName;let c=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.VY,{ref:t,className:(0,a.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",o),...s})});c.displayName=n.VY.displayName},23675:function(e,t,o){"use strict";o.d(t,{g:function(){return a}});var r=o(57437),s=o(2265),n=o(93448);let a=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("textarea",{className:(0,n.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",o),ref:t,...s})});a.displayName="Textarea"},93448:function(e,t,o){"use strict";o.d(t,{cn:function(){return n}});var r=o(61994),s=o(53335);function n(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return(0,s.m6)((0,r.W)(t))}},18333:function(e,t,o){"use strict";o.d(t,{R:function(){return c},S:function(){return d}});var r=o(57437),s=o(2265),n=o(12438),a=o(72135);let l=(0,s.createContext)(void 0),i={executionId:null,status:"idle",currentNodeId:null,nodeStatuses:{},nodeInputs:{},nodeOutputs:{},logs:[]},d=e=>{var t,o,d;let{children:c,workflowId:u}=e,[f,m]=(0,s.useState)(i),[h,p]=(0,s.useState)(null),[x,g]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=localStorage.getItem("token"),t=new n.$;return t.connect("/",e||""),console.log("\uD83D\uDD0C Socket client created, socket instance:",!!t.socket),t.socket&&(console.log("\uD83C\uDFA7 Setting up socket event listeners..."),t.socket.on("connect",()=>{var e;console.log("✅ Socket connected successfully!"),console.log("\uD83C\uDD94 New Socket ID:",null===(e=t.socket)||void 0===e?void 0:e.id)}),t.socket.on("disconnect",e=>{console.log("❌ Socket disconnected:",e)}),t.socket.on("connect_error",e=>{console.error("❌ Socket connection error:",e)}),t.socket.on("workflow:execution:update",e=>{console.log("\uD83D\uDD04 Socket update received:",e),m(t=>{let o={...t};if(e.status&&(o.status=e.status),e.currentNodeId&&(o.currentNodeId=e.currentNodeId),e.nodeId&&e.inputData&&(o.nodeInputs[e.nodeId]=e.inputData),e.nodeId&&e.outputData&&(o.nodeOutputs[e.nodeId]=e.outputData),e.nodeId&&e.nodeStatus){let t=o.nodeStatuses[e.nodeId];"completed"===t||"failed"===t||("completed"===e.nodeStatus||"failed"===e.nodeStatus?("running"!==o.nodeStatuses[e.nodeId]&&(o.nodeStatuses[e.nodeId]="running"),setTimeout(()=>{m(t=>{let o=t.nodeStatuses[e.nodeId];return"completed"===o||"failed"===o?t:{...t,nodeStatuses:{...t.nodeStatuses,[e.nodeId]:e.nodeStatus},currentNodeId:t.currentNodeId===e.nodeId?null:t.currentNodeId}})},2e3)):o.nodeStatuses[e.nodeId]=e.nodeStatus)}return e.log&&o.logs.push(e.log),o})}),t.socket.on("workflow:execution:complete",e=>{console.log("✅ Workflow execution complete:",e),m(t=>({...t,status:e.status||"completed",currentNodeId:null}))})),p(t),()=>{t.disconnect()}},[]);let{data:v}=(0,a.EV)({url:"/workflows/".concat(u,"/executions"),method:"get",config:{query:{"sort[createdAt]":"desc",limit:1}},queryOptions:{enabled:!!u&&!x}}),w=null==v?void 0:null===(d=v.data)||void 0===d?void 0:null===(o=d.data)||void 0===o?void 0:null===(t=o[0])||void 0===t?void 0:t.id,{data:b}=(0,a.EV)({url:"/workflows/".concat(u,"/executions/").concat(w,"/logs"),method:"get",queryOptions:{enabled:!!u&&!!w&&!x}});return(0,s.useEffect)(()=>{var e;if((null==b?void 0:null===(e=b.data)||void 0===e?void 0:e.data)&&!x){let e={},t={},o={};b.data.data.forEach(r=>{r.inputData&&(e[r.nodeId]=r.inputData),r.outputData&&(t[r.nodeId]=r.outputData),"success"===r.status?o[r.nodeId]="completed":"failed"===r.status&&(o[r.nodeId]="failed")}),m(r=>({...r,nodeInputs:e,nodeOutputs:t,nodeStatuses:o})),g(!0)}},[b,x,w]),(0,r.jsx)(l.Provider,{value:{execution:f,startExecution:e=>{console.log("\uD83D\uDE80 Starting execution tracking for:",e),m({...i,executionId:e,status:"running"}),(null==h?void 0:h.socket)&&(console.log("\uD83D\uDCE1 Joining execution room:",e),h.socket.emit("workflow:execution:join",{executionId:e}))},clearExecution:()=>{m(i)},getNodeStatus:e=>f.nodeStatuses[e]||"pending",getNodeInput:e=>f.nodeInputs[e],getNodeOutput:e=>f.nodeOutputs[e]},children:c})},c=()=>{let e=(0,s.useContext)(l);if(void 0===e)throw Error("useExecution must be used within an ExecutionProvider");return e}}},function(e){e.O(0,[7999,5094,4438,6530,6241,4475,600,1509,1783,4458,7874,2971,2117,1744],function(){return e(e.s=61514)}),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9853],{24654:function(){},61514:function(e,t,o){Promise.resolve().then(o.bind(o,36303))},36303:function(e,t,o){"use strict";o.r(t),o.d(t,{default:function(){return z}});var r=o(57437),s=o(2265),n=o(99376),a=o(72135),l=o(30166),i=o(14438),d=o(51817),c=o(32660),u=o(42208),f=o(7586),m=o(83229),h=o(12381),p=o(79820),x=o(40279),g=o(75060),v=o(23675),w=o(17168),b=o(15291),j=o(18333),k=o(32489),y=o(24156),N=o(30401),_=o(69174),S=o(2596),C=o(12749),I=o(93448);function D(e){let{options:t,selected:o,onChange:n,placeholder:a="Select...",className:l}=e,[i,d]=s.useState(!1),c=e=>{n(o.filter(t=>t!==e))},u=e=>{o.includes(e)?n(o.filter(t=>t!==e)):n([...o,e])};return(0,r.jsxs)(C.J2,{open:i,onOpenChange:d,children:[(0,r.jsx)(C.xo,{asChild:!0,children:(0,r.jsxs)(h.z,{variant:"outline",role:"combobox","aria-expanded":i,className:(0,I.cn)("w-full justify-between",l),children:[(0,r.jsxs)("div",{className:"flex gap-1 flex-wrap",children:[0===o.length?(0,r.jsx)("span",{className:"text-muted-foreground",children:a}):o.slice(0,3).map(e=>{var o;return(0,r.jsxs)(_.C,{variant:"secondary",className:"mr-1",onClick:t=>{t.stopPropagation(),c(e)},children:[(null===(o=t.find(t=>t.value===e))||void 0===o?void 0:o.label)||e,(0,r.jsx)(k.Z,{className:"ml-1 h-3 w-3"})]},e)}),o.length>3&&(0,r.jsxs)(_.C,{variant:"secondary",children:["+",o.length-3," more"]})]}),(0,r.jsx)(y.Z,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,r.jsx)(C.yk,{className:"w-full p-0",align:"start",children:(0,r.jsxs)(S.mY,{children:[(0,r.jsx)(S.sZ,{placeholder:"Search..."}),(0,r.jsxs)(S.e8,{children:[(0,r.jsx)(S.rb,{children:"No option found."}),(0,r.jsx)(S.fu,{className:"max-h-64 overflow-auto",children:t.map(e=>(0,r.jsxs)(S.di,{value:e.value,onSelect:()=>u(e.value),children:[(0,r.jsx)(N.Z,{className:(0,I.cn)("mr-2 h-4 w-4",o.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},e.value))})]})]})})]})}let R=(0,l.default)(()=>Promise.all([o.e(1627),o.e(780),o.e(926),o.e(9881),o.e(3563),o.e(3834),o.e(1299)]).then(o.bind(o,81299)).then(e=>({default:e.WorkflowBuilder})),{loadableGenerated:{webpack:()=>[81299]},ssr:!1}),E=e=>{let{workflowId:t}=e,o=(0,n.useRouter)(),{startExecution:l}=(0,j.R)(),[k,y]=(0,s.useState)("manual"),[N,_]=(0,s.useState)({id:"",name:"",description:"",status:"draft",trigger_type:"manual",cron:"",webhook_path:"",webhook_method:"POST",hook_collection:"",hook_action:"",allowed_roles:[]}),{data:S,isLoading:C}=(0,a.rD)({resource:"baasix_Workflow",id:t||"",queryOptions:{enabled:!!t}}),{data:I}=(0,a.sm)({resource:"baasix_Role",pagination:{mode:"off"}}),{mutate:E}=(0,a.PQ)(),{mutate:z}=(0,a.uC)(),P=null==S?void 0:S.data,Q=(null==I?void 0:I.data)||[];(0,s.useEffect)(()=>{P&&(y(P.trigger_type),_({id:String(P.id||""),name:P.name,description:P.description||"",status:P.status,trigger_type:P.trigger_type,cron:P.trigger_cron||"",webhook_path:P.trigger_webhook_path||"",webhook_method:P.trigger_webhook_method||"POST",hook_collection:P.trigger_hook_collection||"",hook_action:P.trigger_hook_action||"",allowed_roles:P.allowed_roles||[]}))},[P]);let Y=(e,t)=>{_(o=>({...o,[e]:t})),"trigger_type"===e&&y(t)},Z=e=>{if(!t)return;let o={id:N.id,name:N.name,description:N.description,status:N.status,trigger_type:N.trigger_type,allowed_roles:N.allowed_roles||[],...e&&{flow_data:e}};"schedule"===k?(o.trigger_cron=N.cron,o.trigger_webhook_path=null,o.trigger_webhook_method=null,o.trigger_hook_collection=null,o.trigger_hook_action=null):"webhook"===k?(o.trigger_cron=null,o.trigger_webhook_path=N.webhook_path,o.trigger_webhook_method=N.webhook_method,o.trigger_hook_collection=null,o.trigger_hook_action=null):"hook"===k?(o.trigger_cron=null,o.trigger_webhook_path=null,o.trigger_webhook_method=null,o.trigger_hook_collection=N.hook_collection,o.trigger_hook_action=N.hook_action):(o.trigger_cron=null,o.trigger_webhook_path=null,o.trigger_webhook_method=null,o.trigger_hook_collection=null,o.trigger_hook_action=null),E({resource:"baasix_Workflow",id:t,values:o,successNotification:!1},{onSuccess:()=>{i.Am.success("Workflow saved")}})};return!C&&P&&t?(0,r.jsxs)("div",{className:"flex flex-col h-full overflow-hidden p-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(h.z,{variant:"ghost",size:"icon",onClick:()=>o.push("/workflows"),children:(0,r.jsx)(c.Z,{className:"h-4 w-4"})}),(0,r.jsx)("h1",{className:"text-xl font-semibold",children:P.name})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)(h.z,{variant:"outline",onClick:()=>o.push("/workflows/detail?id=".concat(t)),children:[(0,r.jsx)(u.Z,{className:"h-4 w-4 mr-2"}),"Overview"]}),(0,r.jsxs)(h.z,{variant:"outline",onClick:()=>o.push("/workflows/detail?id=".concat(t,"#executions")),children:[(0,r.jsx)(f.Z,{className:"h-4 w-4 mr-2"}),"Executions"]})]})]}),(0,r.jsxs)(w.mQ,{defaultValue:"builder",className:"flex-1 flex flex-col overflow-hidden",children:[(0,r.jsxs)(w.dr,{children:[(0,r.jsx)(w.SP,{value:"builder",children:"Workflow Builder"}),(0,r.jsx)(w.SP,{value:"settings",children:"Settings"})]}),(0,r.jsx)(w.nU,{value:"builder",className:"flex-1 overflow-hidden mt-4",children:(0,r.jsx)(R,{workflow:P,onSave:Z,onExecute:"active"===P.status?()=>{t&&z({url:"/workflows/".concat(t,"/execute"),method:"post",values:{},successNotification:!1},{onSuccess:e=>{var t,o,r;i.Am.success("Workflow execution started");let s=(null==e?void 0:null===(t=e.execution)||void 0===t?void 0:t.id)||(null==e?void 0:null===(r=e.data)||void 0===r?void 0:null===(o=r.execution)||void 0===o?void 0:o.id);s&&l(s)},onError:()=>{i.Am.error("Failed to execute workflow")}})}:void 0})}),(0,r.jsx)(w.nU,{value:"settings",className:"flex-1 overflow-auto mt-4",children:(0,r.jsxs)(p.Zb,{children:[(0,r.jsxs)(p.Ol,{children:[(0,r.jsx)(p.ll,{children:"Workflow Settings"}),(0,r.jsx)(p.SZ,{children:"Configure workflow properties and trigger settings"})]}),(0,r.jsxs)(p.aY,{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"id",children:"Workflow ID"}),(0,r.jsx)(x.I,{id:"id",value:N.id,onChange:e=>Y("id",e.target.value)}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Unique identifier for this workflow"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"name",children:"Workflow Name *"}),(0,r.jsx)(x.I,{id:"name",value:N.name,onChange:e=>Y("name",e.target.value)})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"description",children:"Description"}),(0,r.jsx)(v.g,{id:"description",rows:3,value:N.description,onChange:e=>Y("description",e.target.value)})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{children:"Status *"}),(0,r.jsxs)(b.Ph,{value:N.status,onValueChange:e=>Y("status",e),children:[(0,r.jsx)(b.i4,{children:(0,r.jsx)(b.ki,{placeholder:"Select status"})}),(0,r.jsxs)(b.Bw,{children:[(0,r.jsx)(b.Ql,{value:"draft",children:"Draft"}),(0,r.jsx)(b.Ql,{value:"active",children:"Active"}),(0,r.jsx)(b.Ql,{value:"inactive",children:"Inactive"})]})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{children:"Trigger Type *"}),(0,r.jsxs)(b.Ph,{value:N.trigger_type,onValueChange:e=>Y("trigger_type",e),children:[(0,r.jsx)(b.i4,{children:(0,r.jsx)(b.ki,{placeholder:"Select trigger type"})}),(0,r.jsxs)(b.Bw,{children:[(0,r.jsx)(b.Ql,{value:"manual",children:"Manual"}),(0,r.jsx)(b.Ql,{value:"webhook",children:"Webhook"}),(0,r.jsx)(b.Ql,{value:"schedule",children:"Schedule"}),(0,r.jsx)(b.Ql,{value:"hook",children:"Hook"})]})]})]}),"schedule"===k&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"cron",children:"Cron Expression *"}),(0,r.jsx)(x.I,{id:"cron",placeholder:"0 0 * * *",value:N.cron,onChange:e=>Y("cron",e.target.value)}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Example: 0 0 * * * (runs daily at midnight)"})]}),"webhook"===k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"webhook_path",children:"Webhook Path *"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"/webhook"}),(0,r.jsx)(x.I,{id:"webhook_path",placeholder:"/my-workflow",value:N.webhook_path,onChange:e=>Y("webhook_path",e.target.value)})]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Full URL will be: https://your-domain.com/webhook",N.webhook_path]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{children:"HTTP Method *"}),(0,r.jsxs)(b.Ph,{value:N.webhook_method,onValueChange:e=>Y("webhook_method",e),children:[(0,r.jsx)(b.i4,{children:(0,r.jsx)(b.ki,{placeholder:"Select method"})}),(0,r.jsxs)(b.Bw,{children:[(0,r.jsx)(b.Ql,{value:"GET",children:"GET"}),(0,r.jsx)(b.Ql,{value:"POST",children:"POST"}),(0,r.jsx)(b.Ql,{value:"PUT",children:"PUT"}),(0,r.jsx)(b.Ql,{value:"PATCH",children:"PATCH"}),(0,r.jsx)(b.Ql,{value:"DELETE",children:"DELETE"})]})]})]})]}),"hook"===k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{htmlFor:"hook_collection",children:"Collection Name *"}),(0,r.jsx)(x.I,{id:"hook_collection",placeholder:"baasix_User",value:N.hook_collection,onChange:e=>Y("hook_collection",e.target.value)}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"The collection to watch for changes"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{children:"Hook Action *"}),(0,r.jsxs)(b.Ph,{value:N.hook_action,onValueChange:e=>Y("hook_action",e),children:[(0,r.jsx)(b.i4,{children:(0,r.jsx)(b.ki,{placeholder:"Select action"})}),(0,r.jsxs)(b.Bw,{children:[(0,r.jsx)(b.Ql,{value:"items.read",children:"Before Read"}),(0,r.jsx)(b.Ql,{value:"items.read.one",children:"Before Read One"}),(0,r.jsx)(b.Ql,{value:"items.create",children:"Before Create"}),(0,r.jsx)(b.Ql,{value:"items.update",children:"Before Update"}),(0,r.jsx)(b.Ql,{value:"items.delete",children:"Before Delete"}),(0,r.jsx)(b.Ql,{value:"items.read.after",children:"After Read"}),(0,r.jsx)(b.Ql,{value:"items.read.one.after",children:"After Read One"}),(0,r.jsx)(b.Ql,{value:"items.create.after",children:"After Create"}),(0,r.jsx)(b.Ql,{value:"items.update.after",children:"After Update"}),(0,r.jsx)(b.Ql,{value:"items.delete.after",children:"After Delete"})]})]})]})]}),"schedule"!==k&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g._,{children:"Allowed Roles"}),(0,r.jsx)(D,{options:Q.map(e=>({label:e.name,value:e.id})),selected:N.allowed_roles,onChange:e=>Y("allowed_roles",e),placeholder:"Select roles (optional)"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Select roles that can execute this workflow. Leave empty to allow all authenticated users."})]}),(0,r.jsxs)(h.z,{onClick:()=>{if(t){if(!N.name){i.Am.error("Please enter workflow name");return}Z(),N.id&&N.id!==t&&o.push("/workflows/edit?id=".concat(N.id))}},children:[(0,r.jsx)(m.Z,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})})]})]}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)(d.Z,{className:"h-8 w-8 animate-spin"})})};var z=()=>{let e=(0,n.useSearchParams)(),[t,o]=(0,s.useState)(null);return((0,s.useEffect)(()=>{o(e.get("id"))},[e]),t)?(0,r.jsx)(j.S,{workflowId:t,children:(0,r.jsx)(E,{workflowId:t})}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)(d.Z,{className:"h-8 w-8 animate-spin"})})}},12438:function(e,t,o){"use strict";o.d(t,{$:function(){return s}});var r=o(68680);class s{connect(e,t){return this.socket=(0,r.io)(e,{auth:{token:t},path:"/realtime",reconnection:!0,reconnectionAttempts:5,reconnectionDelay:1e3,reconnectionDelayMax:5e3,transports:["websocket","polling"]}),this._setupListeners(),this}_setupListeners(){this.socket&&(this.socket.on("connect",()=>{console.log("Connected to socket server"),this.subscriptions.forEach(e=>{this._subscribe(e)})}),this.socket.on("connected",e=>{console.log("Socket authenticated:",e)}),this.socket.on("disconnect",e=>{console.log("Disconnected from socket server:",e)}),this.socket.on("connect_error",e=>{console.error("Socket connection error:",e)}))}_subscribe(e){this.socket&&this.socket.emit("subscribe",{collection:e})}async subscribe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((o,r)=>{if(!this.socket){r(Error("Socket not connected"));return}this.socket.emit("subscribe",{collection:e},s=>{"success"===s.status?(this.subscriptions.add(e),["create","update","delete"].forEach(o=>{let r="".concat(e,":").concat(o),s=t[o];s&&(this.eventHandlers.has(r)&&this.socket.off(r,this.eventHandlers.get(r)),this.socket.on(r,s),this.eventHandlers.set(r,s))}),o()):r(Error(s.message))})})}async unsubscribe(e){return new Promise((t,o)=>{if(!this.socket){o(Error("Socket not connected"));return}this.socket.emit("unsubscribe",{collection:e},r=>{"success"===r.status?(this.subscriptions.delete(e),["create","update","delete"].forEach(t=>{let o="".concat(e,":").concat(t);this.eventHandlers.has(o)&&(this.socket.off(o,this.eventHandlers.get(o)),this.eventHandlers.delete(o))}),t()):o(Error(r.message))})})}disconnect(){this.socket&&(this.socket.disconnect(),this.subscriptions.clear(),this.eventHandlers.clear())}constructor(){this.socket=null,this.subscriptions=new Set,this.eventHandlers=new Map}}},69174:function(e,t,o){"use strict";o.d(t,{C:function(){return l}});var r=o(57437);o(2265);var s=o(90535),n=o(93448);let a=(0,s.j)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function l(e){let{className:t,variant:o,...s}=e;return(0,r.jsx)("div",{className:(0,n.cn)(a({variant:o}),t),...s})}},12381:function(e,t,o){"use strict";o.d(t,{d:function(){return i},z:function(){return d}});var r=o(57437),s=o(2265),n=o(37053),a=o(90535),l=o(93448);let i=(0,a.j)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),d=s.forwardRef((e,t)=>{let{className:o,variant:s,size:a,asChild:d=!1,...c}=e,u=d?n.g7:"button";return(0,r.jsx)(u,{className:(0,l.cn)(i({variant:s,size:a,className:o})),ref:t,...c})});d.displayName="Button"},79820:function(e,t,o){"use strict";o.d(t,{Ol:function(){return l},SZ:function(){return d},Zb:function(){return a},aY:function(){return c},eW:function(){return u},ll:function(){return i}});var r=o(57437),s=o(2265),n=o(93448);let a=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,n.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",o),...s})});a.displayName="Card";let l=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,n.cn)("flex flex-col space-y-1 p-4",o),...s})});l.displayName="CardHeader";let i=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("h3",{ref:t,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",o),...s})});i.displayName="CardTitle";let d=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("p",{ref:t,className:(0,n.cn)("text-sm text-muted-foreground",o),...s})});d.displayName="CardDescription";let c=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,n.cn)("p-4 pt-0",o),...s})});c.displayName="CardContent";let u=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("div",{ref:t,className:(0,n.cn)("flex items-center p-4 pt-0",o),...s})});u.displayName="CardFooter"},2596:function(e,t,o){"use strict";o.d(t,{di:function(){return h},e8:function(){return c},fu:function(){return f},mY:function(){return i},rb:function(){return u},sZ:function(){return d},zz:function(){return m}});var r=o(57437),s=o(2265),n=o(46343),a=o(73247),l=o(93448);o(74291);let i=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.mY,{ref:t,className:(0,l.cn)("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",o),...s})});i.displayName=n.mY.displayName;let d=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,r.jsx)(a.Z,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,r.jsx)(n.mY.Input,{ref:t,className:(0,l.cn)("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",o),...s})]})});d.displayName=n.mY.Input.displayName;let c=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.mY.List,{ref:t,className:(0,l.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",o),...s})});c.displayName=n.mY.List.displayName;let u=s.forwardRef((e,t)=>(0,r.jsx)(n.mY.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));u.displayName=n.mY.Empty.displayName;let f=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.mY.Group,{ref:t,className:(0,l.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",o),...s})});f.displayName=n.mY.Group.displayName;let m=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.mY.Separator,{ref:t,className:(0,l.cn)("-mx-1 h-px bg-border",o),...s})});m.displayName=n.mY.Separator.displayName;let h=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.mY.Item,{ref:t,className:(0,l.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",o),...s})});h.displayName=n.mY.Item.displayName},74291:function(e,t,o){"use strict";o.d(t,{$N:function(){return p},Be:function(){return x},Vq:function(){return i},cN:function(){return h},cZ:function(){return f},fK:function(){return m},hg:function(){return d}});var r=o(57437),s=o(2265),n=o(70001),a=o(32489),l=o(93448);let i=n.fC,d=n.xz,c=n.h_;n.x8;let u=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.aV,{ref:t,className:(0,l.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",o),...s})});u.displayName=n.aV.displayName;let f=s.forwardRef((e,t)=>{let{className:o,children:s,...i}=e;return(0,r.jsxs)(c,{children:[(0,r.jsx)(u,{}),(0,r.jsxs)(n.VY,{ref:t,className:(0,l.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",o),...i,children:[s,(0,r.jsxs)(n.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,r.jsx)(a.Z,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});f.displayName=n.VY.displayName;let m=e=>{let{className:t,...o}=e;return(0,r.jsx)("div",{className:(0,l.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...o})};m.displayName="DialogHeader";let h=e=>{let{className:t,...o}=e;return(0,r.jsx)("div",{className:(0,l.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...o})};h.displayName="DialogFooter";let p=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.Dx,{ref:t,className:(0,l.cn)("text-lg font-semibold leading-none tracking-tight",o),...s})});p.displayName=n.Dx.displayName;let x=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.dk,{ref:t,className:(0,l.cn)("text-sm text-muted-foreground",o),...s})});x.displayName=n.dk.displayName},40279:function(e,t,o){"use strict";o.d(t,{I:function(){return a}});var r=o(57437),s=o(2265),n=o(93448);let a=s.forwardRef((e,t)=>{let{className:o,type:s,...a}=e;return(0,r.jsx)("input",{type:s,className:(0,n.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",o),ref:t,...a})});a.displayName="Input"},75060:function(e,t,o){"use strict";o.d(t,{_:function(){return d}});var r=o(57437),s=o(2265),n=o(370),a=o(90535),l=o(93448);let i=(0,a.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.f,{ref:t,className:(0,l.cn)(i(),o),...s})});d.displayName=n.f.displayName},12749:function(e,t,o){"use strict";o.d(t,{J2:function(){return l},xo:function(){return i},yk:function(){return d}});var r=o(57437),s=o(2265),n=o(51777),a=o(93448);let l=n.fC,i=n.xz;n.ee;let d=s.forwardRef((e,t)=>{let{className:o,align:s="center",sideOffset:l=4,...i}=e;return(0,r.jsx)(n.h_,{children:(0,r.jsx)(n.VY,{ref:t,align:s,sideOffset:l,className:(0,a.cn)("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",o),...i})})});d.displayName=n.VY.displayName},15291:function(e,t,o){"use strict";o.d(t,{Bw:function(){return x},DI:function(){return u},Ph:function(){return c},Ql:function(){return v},i4:function(){return m},ki:function(){return f},n5:function(){return g}});var r=o(57437),s=o(2265),n=o(74797),a=o(40875),l=o(22135),i=o(30401),d=o(93448);let c=n.fC,u=n.ZA,f=n.B4,m=s.forwardRef((e,t)=>{let{className:o,children:s,...l}=e;return(0,r.jsxs)(n.xz,{ref:t,className:(0,d.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",o),...l,children:[s,(0,r.jsx)(n.JO,{asChild:!0,children:(0,r.jsx)(a.Z,{className:"h-4 w-4 opacity-50"})})]})});m.displayName=n.xz.displayName;let h=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.u_,{ref:t,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",o),...s,children:(0,r.jsx)(l.Z,{className:"h-4 w-4"})})});h.displayName=n.u_.displayName;let p=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.$G,{ref:t,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",o),...s,children:(0,r.jsx)(a.Z,{className:"h-4 w-4"})})});p.displayName=n.$G.displayName;let x=s.forwardRef((e,t)=>{let{className:o,children:s,position:a="popper",...l}=e;return(0,r.jsx)(n.h_,{children:(0,r.jsxs)(n.VY,{ref:t,className:(0,d.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===a&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",o),position:a,...l,children:[(0,r.jsx)(h,{}),(0,r.jsx)(n.l_,{className:(0,d.cn)("p-1 max-h-[300px] overflow-y-auto","popper"===a&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),style:{overscrollBehavior:"contain",touchAction:"pan-y",WebkitOverflowScrolling:"touch",willChange:"scroll-position",pointerEvents:"auto"},children:s}),(0,r.jsx)(p,{})]})})});x.displayName=n.VY.displayName;let g=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.__,{ref:t,className:(0,d.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",o),...s})});g.displayName=n.__.displayName;let v=s.forwardRef((e,t)=>{let{className:o,children:s,...a}=e;return(0,r.jsxs)(n.ck,{ref:t,className:(0,d.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o),...a,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(n.wU,{children:(0,r.jsx)(i.Z,{className:"h-4 w-4"})})}),(0,r.jsx)(n.eT,{children:s})]})});v.displayName=n.ck.displayName,s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.Z0,{ref:t,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",o),...s})}).displayName=n.Z0.displayName},17168:function(e,t,o){"use strict";o.d(t,{SP:function(){return d},dr:function(){return i},mQ:function(){return l},nU:function(){return c}});var r=o(57437),s=o(2265),n=o(20271),a=o(93448);let l=n.fC,i=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.aV,{ref:t,className:(0,a.cn)("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",o),...s})});i.displayName=n.aV.displayName;let d=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.xz,{ref:t,className:(0,a.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",o),...s})});d.displayName=n.xz.displayName;let c=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)(n.VY,{ref:t,className:(0,a.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",o),...s})});c.displayName=n.VY.displayName},23675:function(e,t,o){"use strict";o.d(t,{g:function(){return a}});var r=o(57437),s=o(2265),n=o(93448);let a=s.forwardRef((e,t)=>{let{className:o,...s}=e;return(0,r.jsx)("textarea",{className:(0,n.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",o),ref:t,...s})});a.displayName="Textarea"},93448:function(e,t,o){"use strict";o.d(t,{cn:function(){return n}});var r=o(61994),s=o(53335);function n(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return(0,s.m6)((0,r.W)(t))}},18333:function(e,t,o){"use strict";o.d(t,{R:function(){return c},S:function(){return d}});var r=o(57437),s=o(2265),n=o(12438),a=o(72135);let l=(0,s.createContext)(void 0),i={executionId:null,status:"idle",currentNodeId:null,nodeStatuses:{},nodeInputs:{},nodeOutputs:{},logs:[]},d=e=>{var t,o,d;let{children:c,workflowId:u}=e,[f,m]=(0,s.useState)(i),[h,p]=(0,s.useState)(null),[x,g]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=localStorage.getItem("token"),t=new n.$;return t.connect("/",e||""),console.log("\uD83D\uDD0C Socket client created, socket instance:",!!t.socket),t.socket&&(console.log("\uD83C\uDFA7 Setting up socket event listeners..."),t.socket.on("connect",()=>{var e;console.log("✅ Socket connected successfully!"),console.log("\uD83C\uDD94 New Socket ID:",null===(e=t.socket)||void 0===e?void 0:e.id)}),t.socket.on("disconnect",e=>{console.log("❌ Socket disconnected:",e)}),t.socket.on("connect_error",e=>{console.error("❌ Socket connection error:",e)}),t.socket.on("workflow:execution:update",e=>{console.log("\uD83D\uDD04 Socket update received:",e),m(t=>{let o={...t};if(e.status&&(o.status=e.status),e.currentNodeId&&(o.currentNodeId=e.currentNodeId),e.nodeId&&e.inputData&&(o.nodeInputs[e.nodeId]=e.inputData),e.nodeId&&e.outputData&&(o.nodeOutputs[e.nodeId]=e.outputData),e.nodeId&&e.nodeStatus){let t=o.nodeStatuses[e.nodeId];"completed"===t||"failed"===t||("completed"===e.nodeStatus||"failed"===e.nodeStatus?("running"!==o.nodeStatuses[e.nodeId]&&(o.nodeStatuses[e.nodeId]="running"),setTimeout(()=>{m(t=>{let o=t.nodeStatuses[e.nodeId];return"completed"===o||"failed"===o?t:{...t,nodeStatuses:{...t.nodeStatuses,[e.nodeId]:e.nodeStatus},currentNodeId:t.currentNodeId===e.nodeId?null:t.currentNodeId}})},2e3)):o.nodeStatuses[e.nodeId]=e.nodeStatus)}return e.log&&o.logs.push(e.log),o})}),t.socket.on("workflow:execution:complete",e=>{console.log("✅ Workflow execution complete:",e),m(t=>({...t,status:e.status||"completed",currentNodeId:null}))})),p(t),()=>{t.disconnect()}},[]);let{data:v}=(0,a.EV)({url:"/workflows/".concat(u,"/executions"),method:"get",config:{query:{"sort[createdAt]":"desc",limit:1}},queryOptions:{enabled:!!u&&!x}}),w=null==v?void 0:null===(d=v.data)||void 0===d?void 0:null===(o=d.data)||void 0===o?void 0:null===(t=o[0])||void 0===t?void 0:t.id,{data:b}=(0,a.EV)({url:"/workflows/".concat(u,"/executions/").concat(w,"/logs"),method:"get",queryOptions:{enabled:!!u&&!!w&&!x}});return(0,s.useEffect)(()=>{var e;if((null==b?void 0:null===(e=b.data)||void 0===e?void 0:e.data)&&!x){let e={},t={},o={};b.data.data.forEach(r=>{r.inputData&&(e[r.nodeId]=r.inputData),r.outputData&&(t[r.nodeId]=r.outputData),"success"===r.status?o[r.nodeId]="completed":"failed"===r.status&&(o[r.nodeId]="failed")}),m(r=>({...r,nodeInputs:e,nodeOutputs:t,nodeStatuses:o})),g(!0)}},[b,x,w]),(0,r.jsx)(l.Provider,{value:{execution:f,startExecution:e=>{console.log("\uD83D\uDE80 Starting execution tracking for:",e),m({...i,executionId:e,status:"running"}),(null==h?void 0:h.socket)&&(console.log("\uD83D\uDCE1 Joining execution room:",e),h.socket.emit("workflow:execution:join",{executionId:e}))},clearExecution:()=>{m(i)},getNodeStatus:e=>f.nodeStatuses[e]||"pending",getNodeInput:e=>f.nodeInputs[e],getNodeOutput:e=>f.nodeOutputs[e]},children:c})},c=()=>{let e=(0,s.useContext)(l);if(void 0===e)throw Error("useExecution must be used within an ExecutionProvider");return e}}},function(e){e.O(0,[7999,5094,4438,6530,4475,6241,600,1509,1783,4458,7874,2971,2117,1744],function(){return e(e.s=61514)}),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7866],{69162:function(e,t,r){Promise.resolve().then(r.bind(r,53740))},79205:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});var s=r(2265);let l=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),o=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let a=(0,s.forwardRef)((e,t)=>{let{color:r="currentColor",size:l=24,strokeWidth:a=2,absoluteStrokeWidth:n,className:c="",children:d,iconNode:u,...h}=e;return(0,s.createElement)("svg",{ref:t,...i,width:l,height:l,stroke:r,strokeWidth:n?24*Number(a)/Number(l):a,className:o("lucide",c),...h},[...u.map(e=>{let[t,r]=e;return(0,s.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),n=(e,t)=>{let r=(0,s.forwardRef)((r,i)=>{let{className:n,...c}=r;return(0,s.createElement)(a,{ref:i,iconNode:t,className:o("lucide-".concat(l(e)),n),...c})});return r.displayName="".concat(e),r}},41671:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(79205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},78867:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(79205).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},51817:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(79205).Z)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},33276:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(79205).Z)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},76865:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(79205).Z)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},53740:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return z}});var s=r(57437),l=r(2265),o=r(99376),i=r(72135),a=r(14438),n=r(41671);let c=(0,r(79205).Z)("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);var d=r(91723),u=r(45675),h=r(33276),w=r(67782),m=r(42208),x=r(78867),f=r(18930),p=r(92735),k=r(51817),g=r(17689),j=r(99397),v=r(76865),y=r(33245),b=r(12381),N=r(69174),C=r(32060),_=r(74291),Z=r(90641),A=r(95937),S=r(72337);let E=()=>{var e,t,r;let E=(0,o.useRouter)(),[z,W]=(0,l.useState)(null),[D,O]=(0,l.useState)(!1),[I,F]=(0,l.useState)(!1),[R,L]=(0,l.useState)(null),[B,X]=(0,l.useState)(null),[T,V]=(0,l.useState)(0),M=(0,l.useRef)(null),{mutate:$}=(0,i.RO)(),{mutate:q}=(0,i.uC)(),{mutate:P}=(0,i.uC)(),{mutate:U}=(0,i.uC)(),J=(0,i.x5)(),K=(0,i.Ji)(),[G,H]=(0,l.useState)(!1),Q=e=>{W(e),O(!0)},Y=e=>{if(!B)return;let t=new FormData;t.append("file",B),t.append("overwrite",e.toString()),U({url:"/workflows/import",method:"post",values:t},{onSuccess:e=>{let t=e.data.summary;a.Am.success("Import complete: ".concat(t.created," created, ").concat(t.updated," updated, ").concat(t.skipped," skipped")),F(!1),L(null),X(null),V(e=>e+1)},onError:()=>{a.Am.error("Failed to import workflows")}})},ee=async e=>{try{let{data:t}=await J().getOne({resource:"baasix_Workflow",id:e.id});$({resource:"baasix_Workflow",values:{id:"".concat(t.id,"-copy"),name:"".concat(t.name," (Copy)"),description:t.description,status:"draft",trigger_type:t.trigger_type,trigger_cron:t.trigger_cron,trigger_webhook_path:t.trigger_webhook_path,trigger_webhook_method:t.trigger_webhook_method,trigger_hook_collection:t.trigger_hook_collection,trigger_hook_action:t.trigger_hook_action,allowed_roles:t.allowed_roles||[],flow_data:t.flow_data,variables:t.variables||{},options:t.options||{}}},{onSuccess:e=>{a.Am.success("Workflow duplicated"),E.push("/workflows/edit?id=".concat(e.data.id))},onError:()=>{a.Am.error("Failed to duplicate workflow")}})}catch(e){a.Am.error("Failed to fetch workflow data")}},et=(0,l.useCallback)(async e=>{H(!0);try{let r=localStorage.getItem("token"),s=e;if(!s||0===s.length){var t;let e=await fetch("".concat(K,"/items/baasix_Workflow?fields=id&limit=-1"),{headers:{Authorization:"Bearer ".concat(r)}});if(!e.ok)throw Error("Failed to fetch workflows");let l=await e.json();s=(null===(t=l.data)||void 0===t?void 0:t.map(e=>e.id))||[]}if(!s||0===s.length){a.Am.error("No workflows found to export");return}let l=await fetch("".concat(K,"/workflows/export"),{method:"POST",headers:{Authorization:"Bearer ".concat(r),"Content-Type":"application/json"},body:JSON.stringify({workflowIds:s})});if(!l.ok){let e=await l.json().catch(()=>({}));throw Error(e.message||"Export failed")}let o=(await l.json()).data;if(!o||!o.workflows||0===o.workflows.length){a.Am.error("No workflows found to export");return}let i=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),n=window.URL.createObjectURL(i),c=document.createElement("a");c.href=n,c.setAttribute("download","workflows-export-".concat(Date.now(),".json")),document.body.appendChild(c),c.click(),c.remove(),window.URL.revokeObjectURL(n),a.Am.success("".concat(o.workflows.length," workflow(s) exported successfully"))}catch(e){a.Am.error("Export failed: ".concat(e.message))}finally{H(!1)}},[K]),er=e=>{let t={active:{variant:"default",icon:(0,s.jsx)(n.Z,{className:"h-3 w-3 mr-1"})},inactive:{variant:"secondary",icon:(0,s.jsx)(c,{className:"h-3 w-3 mr-1"})},draft:{variant:"outline",icon:(0,s.jsx)(d.Z,{className:"h-3 w-3 mr-1"})}},r=t[e]||t.draft;return(0,s.jsxs)(N.C,{variant:r.variant,className:"capitalize",children:[r.icon,e]})},es=e=>(0,s.jsx)(N.C,{variant:"secondary",className:{manual:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300",webhook:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-300",schedule:"bg-cyan-100 text-cyan-800 dark:bg-cyan-900 dark:text-cyan-300",hook:"bg-pink-100 text-pink-800 dark:bg-pink-900 dark:text-pink-300"}[e]||"",children:e}),el=[{label:"Export Selected",icon:(0,s.jsx)(p.Z,{className:"h-4 w-4"}),variant:"outline",onClick:async e=>{let t=e.map(e=>e.id);await et(t)},disabled:G}],eo=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{ref:M,type:"file",accept:".json",onChange:e=>{var t;let r=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!r)return;let s=new FormData;s.append("file",r),P({url:"/workflows/import/preview",method:"post",values:s},{onSuccess:e=>{L(e.data),X(r),F(!0)},onError:()=>{a.Am.error("Failed to preview import file")}}),M.current&&(M.current.value="")},className:"hidden"}),(0,s.jsxs)(C.h_,{children:[(0,s.jsx)(C.$F,{asChild:!0,children:(0,s.jsx)(b.z,{variant:"outline",size:"icon",title:"More",children:(0,s.jsx)(w.Z,{className:"h-4 w-4"})})}),(0,s.jsxs)(C.AW,{align:"end",children:[(0,s.jsxs)(C.Xi,{onClick:()=>et(),disabled:G,children:[G?(0,s.jsx)(k.Z,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(p.Z,{className:"mr-2 h-4 w-4"}),"Export All Workflows"]}),(0,s.jsx)(C.VD,{}),(0,s.jsxs)(C.Xi,{onClick:()=>{var e;null===(e=M.current)||void 0===e||e.click()},children:[(0,s.jsx)(g.Z,{className:"mr-2 h-4 w-4"}),"Import Workflow"]})]})]}),(0,s.jsx)(b.z,{size:"icon",onClick:()=>{let e=new Date().toISOString().replace(/[:.]/g,"-").slice(0,-5);$({resource:"baasix_Workflow",values:{id:"workflow-".concat(e),name:"New Workflow - ".concat(e),description:"",status:"draft",trigger_type:"manual",allowed_roles:[],flow_data:{nodes:[{id:"trigger-1",type:"trigger",position:{x:250,y:50},data:{label:"Trigger"}}],edges:[]},variables:{},options:{}}},{onSuccess:e=>{a.Am.success("Workflow created"),E.push("/workflows/edit?id=".concat(e.data.id))}})},title:"Create Workflow",children:(0,s.jsx)(j.Z,{className:"h-4 w-4"})})]});return(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,s.jsx)(S.DataBrowserInner,{selectedCollection:"baasix_Workflow",title:"Workflows",enableSearch:!0,enableFilters:!0,enableCreate:!1,enableEdit:!0,enableDelete:!0,enableExport:!1,enableImport:!1,enableBulkSelect:!0,enableColumnSettings:!0,defaultSorters:[{field:"updatedAt",order:"desc"}],defaultVisibleColumns:["name","status","trigger_type","updatedAt"],headerActions:eo,renderRowActions:e=>{let{record:t,onDelete:r}=e;return(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(b.z,{variant:"ghost",size:"icon",onClick:()=>E.push("/workflows/edit?id=".concat(t.id)),children:(0,s.jsx)(u.Z,{className:"h-4 w-4"})}),(0,s.jsx)(b.z,{variant:"ghost",size:"icon",onClick:()=>Q(t),disabled:"active"!==t.status,children:(0,s.jsx)(h.Z,{className:"h-4 w-4"})}),(0,s.jsxs)(C.h_,{children:[(0,s.jsx)(C.$F,{asChild:!0,children:(0,s.jsx)(b.z,{variant:"ghost",size:"icon",children:(0,s.jsx)(w.Z,{className:"h-4 w-4"})})}),(0,s.jsxs)(C.AW,{align:"end",children:[(0,s.jsxs)(C.Xi,{onClick:()=>E.push("/workflows/edit?id=".concat(t.id)),children:[(0,s.jsx)(u.Z,{className:"h-4 w-4 mr-2"}),"Edit"]}),(0,s.jsxs)(C.Xi,{onClick:()=>E.push("/workflows/detail?id=".concat(t.id)),children:[(0,s.jsx)(m.Z,{className:"h-4 w-4 mr-2"}),"View Details"]}),(0,s.jsxs)(C.Xi,{onClick:()=>Q(t),disabled:"active"!==t.status,children:[(0,s.jsx)(h.Z,{className:"h-4 w-4 mr-2"}),"Execute"]}),(0,s.jsxs)(C.Xi,{onClick:()=>ee(t),children:[(0,s.jsx)(x.Z,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),(0,s.jsx)(C.VD,{}),(0,s.jsxs)(C.Xi,{className:"text-destructive",onClick:r,children:[(0,s.jsx)(f.Z,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})},customColumnRenderers:{name:(e,t)=>(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("button",{className:"text-primary hover:underline text-left font-medium",onClick:()=>E.push("/workflows/detail?id=".concat(t.id)),children:e}),t.description&&(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:t.description})]}),status:e=>er(e),trigger_type:e=>es(e),updatedAt:e=>(0,s.jsx)("span",{className:"text-muted-foreground",children:new Date(e).toLocaleString()})},customBulkActions:el,onRefresh:()=>V(e=>e+1)},T),(0,s.jsx)(_.Vq,{open:D,onOpenChange:O,children:(0,s.jsxs)(_.cZ,{children:[(0,s.jsxs)(_.fK,{children:[(0,s.jsx)(_.$N,{children:"Execute Workflow"}),(0,s.jsxs)(_.Be,{children:["Are you sure you want to execute the workflow"," ",(0,s.jsx)("strong",{children:null==z?void 0:z.name}),"?"]})]}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:"This will start the workflow execution immediately."}),(0,s.jsxs)(_.cN,{children:[(0,s.jsx)(b.z,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),(0,s.jsx)(b.z,{onClick:()=>{z&&q({url:"/workflows/".concat(z.id,"/execute"),method:"post",values:{}},{onSuccess:()=>{a.Am.success("Workflow execution started"),O(!1),E.push("/workflows/detail?id=".concat(z.id))},onError:()=>{a.Am.error("Failed to execute workflow")}})},children:"Execute"})]})]})}),(0,s.jsx)(_.Vq,{open:I,onOpenChange:F,children:(0,s.jsxs)(_.cZ,{className:"max-w-2xl",children:[(0,s.jsx)(_.fK,{children:(0,s.jsx)(_.$N,{children:"Import Workflows"})}),R&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-medium mb-2",children:"Import Summary:"}),(0,s.jsxs)("ul",{className:"list-disc list-inside text-sm text-muted-foreground",children:[(0,s.jsxs)("li",{children:["Total workflows: ",R.total]}),(0,s.jsxs)("li",{children:["New workflows: ",R.new]}),(0,s.jsxs)("li",{children:["Existing workflows: ",(null===(e=R.conflicts)||void 0===e?void 0:e.length)||0]})]})]}),R.conflicts&&R.conflicts.length>0&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(A.bZ,{variant:"destructive",className:"border-yellow-500 bg-yellow-50 dark:bg-yellow-900/20",children:[(0,s.jsx)(v.Z,{className:"h-4 w-4"}),(0,s.jsx)(A.Cd,{children:"Workflow Conflicts Detected"}),(0,s.jsx)(A.X,{children:"The following workflows already exist. Choose to overwrite them or import new ones only."})]}),(0,s.jsx)(Z.x,{className:"h-48 border rounded-md p-4",children:(0,s.jsx)("div",{className:"space-y-2",children:R.conflicts.map(e=>{var t,r;return(0,s.jsxs)("div",{className:"border-b pb-2 last:border-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium",children:e.name}),(null===(t=e.existing)||void 0===t?void 0:t.isDeleted)&&(0,s.jsx)(N.C,{variant:"destructive",className:"text-xs",children:"Deleted - will be restored"})]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["ID: ",e.id," | Type: ",e.trigger_type," | Status: ",null===(r=e.existing)||void 0===r?void 0:r.status]})]},e.id)})})})]}),R.new>0&&(0,s.jsxs)(A.bZ,{children:[(0,s.jsx)(y.Z,{className:"h-4 w-4"}),(0,s.jsxs)(A.X,{children:[R.new," new workflow(s) will be imported"]})]})]}),(0,s.jsxs)(_.cN,{children:[(0,s.jsx)(b.z,{variant:"outline",onClick:()=>{F(!1),L(null),X(null)},children:"Cancel"}),(null==R?void 0:null===(t=R.conflicts)||void 0===t?void 0:t.length)>0&&(0,s.jsx)(b.z,{variant:"secondary",onClick:()=>Y(!1),children:"Import New Only"}),(0,s.jsx)(b.z,{onClick:()=>Y(!0),children:(null==R?void 0:null===(r=R.conflicts)||void 0===r?void 0:r.length)>0?"Import & Overwrite":"Import"})]})]})})]})};function z(){return(0,s.jsx)(E,{})}}},function(e){e.O(0,[7999,3572,7902,5094,4438,6530,6241,4475,926,600,1668,2676,1509,6869,9487,1783,9881,7324,9124,6712,6547,2033,7304,3817,2971,2117,1744],function(){return e(e.s=69162)}),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7866],{69162:function(e,t,r){Promise.resolve().then(r.bind(r,53740))},79205:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});var s=r(2265);let l=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),o=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let a=(0,s.forwardRef)((e,t)=>{let{color:r="currentColor",size:l=24,strokeWidth:a=2,absoluteStrokeWidth:n,className:c="",children:d,iconNode:u,...h}=e;return(0,s.createElement)("svg",{ref:t,...i,width:l,height:l,stroke:r,strokeWidth:n?24*Number(a)/Number(l):a,className:o("lucide",c),...h},[...u.map(e=>{let[t,r]=e;return(0,s.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),n=(e,t)=>{let r=(0,s.forwardRef)((r,i)=>{let{className:n,...c}=r;return(0,s.createElement)(a,{ref:i,iconNode:t,className:o("lucide-".concat(l(e)),n),...c})});return r.displayName="".concat(e),r}},41671:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(79205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},78867:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(79205).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},51817:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(79205).Z)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},33276:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(79205).Z)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},76865:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});let s=(0,r(79205).Z)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},53740:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return z}});var s=r(57437),l=r(2265),o=r(99376),i=r(72135),a=r(14438),n=r(41671);let c=(0,r(79205).Z)("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);var d=r(91723),u=r(45675),h=r(33276),w=r(67782),m=r(42208),x=r(78867),f=r(18930),p=r(92735),k=r(51817),g=r(17689),j=r(99397),v=r(76865),y=r(33245),b=r(12381),N=r(69174),C=r(32060),_=r(74291),Z=r(90641),A=r(95937),S=r(72337);let E=()=>{var e,t,r;let E=(0,o.useRouter)(),[z,W]=(0,l.useState)(null),[D,O]=(0,l.useState)(!1),[I,F]=(0,l.useState)(!1),[R,L]=(0,l.useState)(null),[B,X]=(0,l.useState)(null),[T,V]=(0,l.useState)(0),M=(0,l.useRef)(null),{mutate:$}=(0,i.RO)(),{mutate:q}=(0,i.uC)(),{mutate:P}=(0,i.uC)(),{mutate:U}=(0,i.uC)(),J=(0,i.x5)(),K=(0,i.Ji)(),[G,H]=(0,l.useState)(!1),Q=e=>{W(e),O(!0)},Y=e=>{if(!B)return;let t=new FormData;t.append("file",B),t.append("overwrite",e.toString()),U({url:"/workflows/import",method:"post",values:t},{onSuccess:e=>{let t=e.data.summary;a.Am.success("Import complete: ".concat(t.created," created, ").concat(t.updated," updated, ").concat(t.skipped," skipped")),F(!1),L(null),X(null),V(e=>e+1)},onError:()=>{a.Am.error("Failed to import workflows")}})},ee=async e=>{try{let{data:t}=await J().getOne({resource:"baasix_Workflow",id:e.id});$({resource:"baasix_Workflow",values:{id:"".concat(t.id,"-copy"),name:"".concat(t.name," (Copy)"),description:t.description,status:"draft",trigger_type:t.trigger_type,trigger_cron:t.trigger_cron,trigger_webhook_path:t.trigger_webhook_path,trigger_webhook_method:t.trigger_webhook_method,trigger_hook_collection:t.trigger_hook_collection,trigger_hook_action:t.trigger_hook_action,allowed_roles:t.allowed_roles||[],flow_data:t.flow_data,variables:t.variables||{},options:t.options||{}}},{onSuccess:e=>{a.Am.success("Workflow duplicated"),E.push("/workflows/edit?id=".concat(e.data.id))},onError:()=>{a.Am.error("Failed to duplicate workflow")}})}catch(e){a.Am.error("Failed to fetch workflow data")}},et=(0,l.useCallback)(async e=>{H(!0);try{let r=localStorage.getItem("token"),s=e;if(!s||0===s.length){var t;let e=await fetch("".concat(K,"/items/baasix_Workflow?fields=id&limit=-1"),{headers:{Authorization:"Bearer ".concat(r)}});if(!e.ok)throw Error("Failed to fetch workflows");let l=await e.json();s=(null===(t=l.data)||void 0===t?void 0:t.map(e=>e.id))||[]}if(!s||0===s.length){a.Am.error("No workflows found to export");return}let l=await fetch("".concat(K,"/workflows/export"),{method:"POST",headers:{Authorization:"Bearer ".concat(r),"Content-Type":"application/json"},body:JSON.stringify({workflowIds:s})});if(!l.ok){let e=await l.json().catch(()=>({}));throw Error(e.message||"Export failed")}let o=(await l.json()).data;if(!o||!o.workflows||0===o.workflows.length){a.Am.error("No workflows found to export");return}let i=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),n=window.URL.createObjectURL(i),c=document.createElement("a");c.href=n,c.setAttribute("download","workflows-export-".concat(Date.now(),".json")),document.body.appendChild(c),c.click(),c.remove(),window.URL.revokeObjectURL(n),a.Am.success("".concat(o.workflows.length," workflow(s) exported successfully"))}catch(e){a.Am.error("Export failed: ".concat(e.message))}finally{H(!1)}},[K]),er=e=>{let t={active:{variant:"default",icon:(0,s.jsx)(n.Z,{className:"h-3 w-3 mr-1"})},inactive:{variant:"secondary",icon:(0,s.jsx)(c,{className:"h-3 w-3 mr-1"})},draft:{variant:"outline",icon:(0,s.jsx)(d.Z,{className:"h-3 w-3 mr-1"})}},r=t[e]||t.draft;return(0,s.jsxs)(N.C,{variant:r.variant,className:"capitalize",children:[r.icon,e]})},es=e=>(0,s.jsx)(N.C,{variant:"secondary",className:{manual:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300",webhook:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-300",schedule:"bg-cyan-100 text-cyan-800 dark:bg-cyan-900 dark:text-cyan-300",hook:"bg-pink-100 text-pink-800 dark:bg-pink-900 dark:text-pink-300"}[e]||"",children:e}),el=[{label:"Export Selected",icon:(0,s.jsx)(p.Z,{className:"h-4 w-4"}),variant:"outline",onClick:async e=>{let t=e.map(e=>e.id);await et(t)},disabled:G}],eo=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{ref:M,type:"file",accept:".json",onChange:e=>{var t;let r=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!r)return;let s=new FormData;s.append("file",r),P({url:"/workflows/import/preview",method:"post",values:s},{onSuccess:e=>{L(e.data),X(r),F(!0)},onError:()=>{a.Am.error("Failed to preview import file")}}),M.current&&(M.current.value="")},className:"hidden"}),(0,s.jsxs)(C.h_,{children:[(0,s.jsx)(C.$F,{asChild:!0,children:(0,s.jsx)(b.z,{variant:"outline",size:"icon",title:"More",children:(0,s.jsx)(w.Z,{className:"h-4 w-4"})})}),(0,s.jsxs)(C.AW,{align:"end",children:[(0,s.jsxs)(C.Xi,{onClick:()=>et(),disabled:G,children:[G?(0,s.jsx)(k.Z,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(p.Z,{className:"mr-2 h-4 w-4"}),"Export All Workflows"]}),(0,s.jsx)(C.VD,{}),(0,s.jsxs)(C.Xi,{onClick:()=>{var e;null===(e=M.current)||void 0===e||e.click()},children:[(0,s.jsx)(g.Z,{className:"mr-2 h-4 w-4"}),"Import Workflow"]})]})]}),(0,s.jsx)(b.z,{size:"icon",onClick:()=>{let e=new Date().toISOString().replace(/[:.]/g,"-").slice(0,-5);$({resource:"baasix_Workflow",values:{id:"workflow-".concat(e),name:"New Workflow - ".concat(e),description:"",status:"draft",trigger_type:"manual",allowed_roles:[],flow_data:{nodes:[{id:"trigger-1",type:"trigger",position:{x:250,y:50},data:{label:"Trigger"}}],edges:[]},variables:{},options:{}}},{onSuccess:e=>{a.Am.success("Workflow created"),E.push("/workflows/edit?id=".concat(e.data.id))}})},title:"Create Workflow",children:(0,s.jsx)(j.Z,{className:"h-4 w-4"})})]});return(0,s.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,s.jsx)(S.DataBrowserInner,{selectedCollection:"baasix_Workflow",title:"Workflows",enableSearch:!0,enableFilters:!0,enableCreate:!1,enableEdit:!0,enableDelete:!0,enableExport:!1,enableImport:!1,enableBulkSelect:!0,enableColumnSettings:!0,defaultSorters:[{field:"updatedAt",order:"desc"}],defaultVisibleColumns:["name","status","trigger_type","updatedAt"],headerActions:eo,renderRowActions:e=>{let{record:t,onDelete:r}=e;return(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(b.z,{variant:"ghost",size:"icon",onClick:()=>E.push("/workflows/edit?id=".concat(t.id)),children:(0,s.jsx)(u.Z,{className:"h-4 w-4"})}),(0,s.jsx)(b.z,{variant:"ghost",size:"icon",onClick:()=>Q(t),disabled:"active"!==t.status,children:(0,s.jsx)(h.Z,{className:"h-4 w-4"})}),(0,s.jsxs)(C.h_,{children:[(0,s.jsx)(C.$F,{asChild:!0,children:(0,s.jsx)(b.z,{variant:"ghost",size:"icon",children:(0,s.jsx)(w.Z,{className:"h-4 w-4"})})}),(0,s.jsxs)(C.AW,{align:"end",children:[(0,s.jsxs)(C.Xi,{onClick:()=>E.push("/workflows/edit?id=".concat(t.id)),children:[(0,s.jsx)(u.Z,{className:"h-4 w-4 mr-2"}),"Edit"]}),(0,s.jsxs)(C.Xi,{onClick:()=>E.push("/workflows/detail?id=".concat(t.id)),children:[(0,s.jsx)(m.Z,{className:"h-4 w-4 mr-2"}),"View Details"]}),(0,s.jsxs)(C.Xi,{onClick:()=>Q(t),disabled:"active"!==t.status,children:[(0,s.jsx)(h.Z,{className:"h-4 w-4 mr-2"}),"Execute"]}),(0,s.jsxs)(C.Xi,{onClick:()=>ee(t),children:[(0,s.jsx)(x.Z,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),(0,s.jsx)(C.VD,{}),(0,s.jsxs)(C.Xi,{className:"text-destructive",onClick:r,children:[(0,s.jsx)(f.Z,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})},customColumnRenderers:{name:(e,t)=>(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("button",{className:"text-primary hover:underline text-left font-medium",onClick:()=>E.push("/workflows/detail?id=".concat(t.id)),children:e}),t.description&&(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:t.description})]}),status:e=>er(e),trigger_type:e=>es(e),updatedAt:e=>(0,s.jsx)("span",{className:"text-muted-foreground",children:new Date(e).toLocaleString()})},customBulkActions:el,onRefresh:()=>V(e=>e+1)},T),(0,s.jsx)(_.Vq,{open:D,onOpenChange:O,children:(0,s.jsxs)(_.cZ,{children:[(0,s.jsxs)(_.fK,{children:[(0,s.jsx)(_.$N,{children:"Execute Workflow"}),(0,s.jsxs)(_.Be,{children:["Are you sure you want to execute the workflow"," ",(0,s.jsx)("strong",{children:null==z?void 0:z.name}),"?"]})]}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:"This will start the workflow execution immediately."}),(0,s.jsxs)(_.cN,{children:[(0,s.jsx)(b.z,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),(0,s.jsx)(b.z,{onClick:()=>{z&&q({url:"/workflows/".concat(z.id,"/execute"),method:"post",values:{}},{onSuccess:()=>{a.Am.success("Workflow execution started"),O(!1),E.push("/workflows/detail?id=".concat(z.id))},onError:()=>{a.Am.error("Failed to execute workflow")}})},children:"Execute"})]})]})}),(0,s.jsx)(_.Vq,{open:I,onOpenChange:F,children:(0,s.jsxs)(_.cZ,{className:"max-w-2xl",children:[(0,s.jsx)(_.fK,{children:(0,s.jsx)(_.$N,{children:"Import Workflows"})}),R&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-medium mb-2",children:"Import Summary:"}),(0,s.jsxs)("ul",{className:"list-disc list-inside text-sm text-muted-foreground",children:[(0,s.jsxs)("li",{children:["Total workflows: ",R.total]}),(0,s.jsxs)("li",{children:["New workflows: ",R.new]}),(0,s.jsxs)("li",{children:["Existing workflows: ",(null===(e=R.conflicts)||void 0===e?void 0:e.length)||0]})]})]}),R.conflicts&&R.conflicts.length>0&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(A.bZ,{variant:"destructive",className:"border-yellow-500 bg-yellow-50 dark:bg-yellow-900/20",children:[(0,s.jsx)(v.Z,{className:"h-4 w-4"}),(0,s.jsx)(A.Cd,{children:"Workflow Conflicts Detected"}),(0,s.jsx)(A.X,{children:"The following workflows already exist. Choose to overwrite them or import new ones only."})]}),(0,s.jsx)(Z.x,{className:"h-48 border rounded-md p-4",children:(0,s.jsx)("div",{className:"space-y-2",children:R.conflicts.map(e=>{var t,r;return(0,s.jsxs)("div",{className:"border-b pb-2 last:border-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium",children:e.name}),(null===(t=e.existing)||void 0===t?void 0:t.isDeleted)&&(0,s.jsx)(N.C,{variant:"destructive",className:"text-xs",children:"Deleted - will be restored"})]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["ID: ",e.id," | Type: ",e.trigger_type," | Status: ",null===(r=e.existing)||void 0===r?void 0:r.status]})]},e.id)})})})]}),R.new>0&&(0,s.jsxs)(A.bZ,{children:[(0,s.jsx)(y.Z,{className:"h-4 w-4"}),(0,s.jsxs)(A.X,{children:[R.new," new workflow(s) will be imported"]})]})]}),(0,s.jsxs)(_.cN,{children:[(0,s.jsx)(b.z,{variant:"outline",onClick:()=>{F(!1),L(null),X(null)},children:"Cancel"}),(null==R?void 0:null===(t=R.conflicts)||void 0===t?void 0:t.length)>0&&(0,s.jsx)(b.z,{variant:"secondary",onClick:()=>Y(!1),children:"Import New Only"}),(0,s.jsx)(b.z,{onClick:()=>Y(!0),children:(null==R?void 0:null===(r=R.conflicts)||void 0===r?void 0:r.length)>0?"Import & Overwrite":"Import"})]})]})})]})};function z(){return(0,s.jsx)(E,{})}}},function(e){e.O(0,[7999,3572,7902,5094,4438,6530,4475,6241,926,600,1668,2676,1509,6869,9487,1783,9881,7324,9124,6712,2667,4033,7304,3817,2971,2117,1744],function(){return e(e.s=69162)}),_N_E=e.O()}]);