@w6w/ui 0.2.11 → 0.2.55

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 (138) hide show
  1. package/CHANGELOG.md +139 -2
  2. package/README.md +28 -10
  3. package/dist/AppPicker.d.ts +12 -1
  4. package/dist/CanvasContextMenu.d.ts +19 -0
  5. package/dist/{CodeBlock-BqXDA35P.js → CodeBlock-C-oIIYfC.js} +1436 -555
  6. package/dist/CodeBlock-C-oIIYfC.js.map +1 -0
  7. package/dist/CodeBlock-CymlfyeA.cjs +15 -0
  8. package/dist/CodeBlock-CymlfyeA.cjs.map +1 -0
  9. package/dist/CodeEditor.d.ts +4 -1
  10. package/dist/ConditionEditor.d.ts +11 -0
  11. package/dist/JsonEditor.d.ts +12 -0
  12. package/dist/ParamCustomization.d.ts +5 -0
  13. package/dist/ParamsForm.d.ts +11 -3
  14. package/dist/RouterEditor.d.ts +5 -0
  15. package/dist/StepBuilderModal.d.ts +83 -13
  16. package/dist/StepNameEditor.d.ts +11 -0
  17. package/dist/StopEditor.d.ts +5 -0
  18. package/dist/TriggerFillForm.d.ts +14 -1
  19. package/dist/WebhookListenPanel.d.ts +28 -0
  20. package/dist/WorkflowConnections.d.ts +29 -0
  21. package/dist/WorkflowConnectionsPanel.d.ts +5 -0
  22. package/dist/WorkflowFlowEditor.d.ts +67 -8
  23. package/dist/assets/script-completion.worker-DDJKkj5M.js +8290 -0
  24. package/dist/assets/script-completion.worker-DDJKkj5M.js.map +1 -0
  25. package/dist/canvas-context-menu.d.ts +27 -0
  26. package/dist/code.cjs +1 -1
  27. package/dist/code.mjs +3 -4
  28. package/dist/code.mjs.map +1 -1
  29. package/dist/components/AnchoredFlyout.d.ts +7 -0
  30. package/dist/components/ColumnsEditor.d.ts +27 -0
  31. package/dist/components/Combobox.d.ts +12 -1
  32. package/dist/components/ConfirmModal.d.ts +3 -1
  33. package/dist/components/CsvPanel.d.ts +21 -0
  34. package/dist/components/DataEntryEditor.d.ts +38 -0
  35. package/dist/components/DataEntryList.d.ts +33 -0
  36. package/dist/components/DataStoreList.d.ts +33 -0
  37. package/dist/components/DataTableGrid.d.ts +46 -0
  38. package/dist/components/EventbriteTriggerPicker.d.ts +7 -0
  39. package/dist/components/ExecutionDetail.d.ts +17 -1
  40. package/dist/components/ExecutionList.d.ts +19 -1
  41. package/dist/components/ExecutionLogPanel.d.ts +61 -3
  42. package/dist/components/ExpressionEditorModal.d.ts +33 -10
  43. package/dist/components/ExpressionOptions.d.ts +101 -15
  44. package/dist/components/HtmlPreview.d.ts +7 -0
  45. package/dist/components/JsonTree.d.ts +32 -0
  46. package/dist/components/ResolvedParams.d.ts +6 -1
  47. package/dist/components/ResultViewer.d.ts +46 -0
  48. package/dist/components/ScriptBindingsNotice.d.ts +31 -0
  49. package/dist/components/ScriptCodeField.d.ts +13 -0
  50. package/dist/components/StepStatusPill.d.ts +7 -0
  51. package/dist/components/expression-authoring.d.ts +13 -0
  52. package/dist/components/expression-dom.d.ts +17 -2
  53. package/dist/components/expression-template.d.ts +25 -3
  54. package/dist/components/icons.d.ts +1 -1
  55. package/dist/components/json-compose.d.ts +53 -0
  56. package/dist/components/result-format.d.ts +13 -0
  57. package/dist/condition-editor.d.ts +44 -0
  58. package/dist/connection-app-meta-BEXlKBgV.cjs +22 -0
  59. package/dist/connection-app-meta-BEXlKBgV.cjs.map +1 -0
  60. package/dist/connection-app-meta-ZCPakGjD.js +12422 -0
  61. package/dist/connection-app-meta-ZCPakGjD.js.map +1 -0
  62. package/dist/data-stores/data-store-view.d.ts +371 -0
  63. package/dist/eventbrite-trigger-selection.d.ts +13 -0
  64. package/dist/flow-connect.d.ts +22 -16
  65. package/dist/flow-delete.d.ts +16 -0
  66. package/dist/flow-history.d.ts +75 -0
  67. package/dist/flow-layout.d.ts +13 -0
  68. package/dist/flow-loop-colors.d.ts +39 -0
  69. package/dist/flow-loop.d.ts +98 -0
  70. package/dist/flow-node-flags.d.ts +14 -0
  71. package/dist/flow-problems.d.ts +69 -0
  72. package/dist/flow-state.d.ts +20 -0
  73. package/dist/flow-types.d.ts +137 -9
  74. package/dist/flow-utils.d.ts +27 -13
  75. package/dist/flow.cjs +4 -2
  76. package/dist/flow.cjs.map +1 -1
  77. package/dist/flow.d.ts +9 -3
  78. package/dist/flow.mjs +4028 -1585
  79. package/dist/flow.mjs.map +1 -1
  80. package/dist/index.cjs +2 -1
  81. package/dist/index.cjs.map +1 -1
  82. package/dist/index.d.ts +30 -4
  83. package/dist/index.mjs +2559 -1287
  84. package/dist/index.mjs.map +1 -1
  85. package/dist/node-samples.d.ts +80 -0
  86. package/dist/output-shape.d.ts +30 -14
  87. package/dist/param-customization.d.ts +7 -0
  88. package/dist/provider.d.ts +119 -7
  89. package/dist/resolve-params.d.ts +45 -11
  90. package/dist/run-visuals.d.ts +14 -21
  91. package/dist/script-bindings.d.ts +63 -0
  92. package/dist/script-completion-service.d.ts +9 -0
  93. package/dist/script-completion.worker.d.ts +1 -0
  94. package/dist/script-completions.d.ts +2 -0
  95. package/dist/state-shape.d.ts +38 -0
  96. package/dist/step-preview-state.d.ts +155 -6
  97. package/dist/step-problems.d.ts +42 -12
  98. package/dist/test-inputs.d.ts +25 -0
  99. package/dist/trigger-registration.d.ts +28 -0
  100. package/dist/types.d.ts +70 -8
  101. package/dist/use-app-action-defs.d.ts +9 -1
  102. package/dist/use-test-input.d.ts +18 -0
  103. package/dist/workflow-connections.d.ts +78 -0
  104. package/package.json +16 -7
  105. package/src/code.css +60 -6
  106. package/src/styles/_canvas.scss +35 -0
  107. package/src/styles/_code-editor.scss +35 -0
  108. package/src/styles/_code.scss +6 -5
  109. package/src/styles/_connections.scss +64 -0
  110. package/src/styles/_copyable.scss +24 -0
  111. package/src/styles/_data-stores.scss +138 -0
  112. package/src/styles/_data-vars.scss +17 -6
  113. package/src/styles/_execution-history.scss +73 -0
  114. package/src/styles/_execution-log.scss +145 -1
  115. package/src/styles/_expression-modal.scss +106 -16
  116. package/src/styles/_fields.scss +11 -0
  117. package/src/styles/_flow.scss +166 -0
  118. package/src/styles/_fx.scss +3 -1
  119. package/src/styles/_incoming-state.scss +33 -0
  120. package/src/styles/_modal.scss +12 -0
  121. package/src/styles/_multiselect.scss +35 -0
  122. package/src/styles/_sections.scss +36 -0
  123. package/src/styles/_step-builder.scss +145 -0
  124. package/src/styles/_tester.scss +56 -0
  125. package/src/styles/_tokens.scss +27 -1
  126. package/src/styles.css +1347 -41
  127. package/src/styles.scss +2 -0
  128. package/dist/CodeBlock-BqXDA35P.js.map +0 -1
  129. package/dist/CodeBlock-CulfbnZD.cjs +0 -15
  130. package/dist/CodeBlock-CulfbnZD.cjs.map +0 -1
  131. package/dist/ConfirmModal-Ln99S9NT.js +0 -7919
  132. package/dist/ConfirmModal-Ln99S9NT.js.map +0 -1
  133. package/dist/ConfirmModal-fjHW5rN-.cjs +0 -14
  134. package/dist/ConfirmModal-fjHW5rN-.cjs.map +0 -1
  135. package/dist/Copyable-DA6eiU7w.cjs +0 -2
  136. package/dist/Copyable-DA6eiU7w.cjs.map +0 -1
  137. package/dist/Copyable-F4NTaG77.js +0 -847
  138. package/dist/Copyable-F4NTaG77.js.map +0 -1
@@ -0,0 +1,22 @@
1
+ "use strict";const n=require("react/jsx-runtime"),qn=require("@xyflow/react"),w=require("react"),dn=require("react-dom"),ue=require("./CodeBlock-CymlfyeA.cjs"),Bo=require("@codemirror/lang-json"),oo=require("@codemirror/lint"),us=require("@codemirror/view"),Wo=require("@uiw/react-codemirror"),ie=require("@w6w/expr"),Un=require("@codemirror/lang-javascript"),Pi=require("@codemirror/lang-python"),_i=require("react-markdown");var _n=typeof document<"u"?document.currentScript:null;const Li={ai:"AI",cms:"CMS",crm:"CRM",hr:"HR",devops:"DevOps"};function Fi(e){if(typeof e!="string"||e.trim()==="")return"";const t=Li[e];return t||e.split(/[-_\s]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")}function Mi(e){const t=new Map;for(const s of e)for(const o of s.categories??[])t.set(o,(t.get(o)??0)+1);return[...t.entries()].map(([s,o])=>({slug:s,label:Fi(s),count:o})).sort((s,o)=>o.count-s.count||s.label.localeCompare(o.label,void 0,{sensitivity:"base"}))}function Di(e,t){if(t.length===0)return!0;const s=e.categories??[];return t.some(o=>s.includes(o))}function Vt(e,t){const s=e==="error"?{className:"w6w-edge-error",label:"on error"}:e==="each"?{className:"w6w-edge-each"}:{};if(!t)return s;const o=t==="taken"?"w6w-edge-taken":"w6w-edge-skipped";return{className:s.className?`${s.className} ${o}`:o,...s.label?{label:s.label}:{}}}const ds="out-error",wn="out-each",yt="done",qo="each";function ps(e){return e==="error"?ds:e==="each"?wn:void 0}function Hi(e){return e===ds?"error":e===wn?"each":"success"}const Bi="@w6w/",Pe="@w6w/control",Uo="@w6w/script",Lt="@w6w/data",bn="@w6w/trigger",Wi="@w6w/http",Le="@w6w/webhook",fs="@w6w/scheduler",qi="@w6w/respond",gn="@w6w/call",hs="@w6w/document",Ln="@w6w/model",Ui="@w6w/template",Yt="@w6w/regex",De="@w6w/store",ms="@w6w/stop",We="@w6w/router",zt="@w6w/race",Vo="Continue once with the first arriving path’s output. Later arrivals are ignored for this run. Other paths keep running.";function ws(e){var t;return e.uses.app!==We||!Array.isArray((t=e.with)==null?void 0:t.routes)?[]:e.with.routes.filter(s=>!!s&&typeof s=="object"&&typeof s.id=="string")}const Nt=e=>`route:${e}`,Vi=e=>e!=null&&e.startsWith("route:")?e.slice(6):void 0,zi=3,Ji=16;function Ki(e){const t=e.find(r=>r.default),s=r=>({id:r.id,handleId:Nt(r.id),label:r.default?"Fallback":r.label||r.id}),o=e.filter(r=>r!==t);return{right:o.map((r,i)=>({...s(r),top:`${(i+.5)/o.length*100}%`})),...t?{bottom:s(t)}:{},...o.length>zi?{minHeight:o.length*Ji}:{}}}const pn="false";function bs(e){return e.uses.app===Pe&&e.uses.action==="if"}function Gi(){return{right:[{id:"true",label:"True",top:"50%"}],bottom:{id:pn,handleId:Nt(pn),label:"False"}}}function Ye(e){return e.startsWith(Bi)}function Et(e){return e===Pe||e===zt}function Ft(e){return e===bn||e===Le||e===fs}function Yi(e){return Ft(e.app)||e.trigger===!0}const ro={in:1,out:Number.POSITIVE_INFINITY};function io(e){return e==="many"?Number.POSITIVE_INFINITY:typeof e=="number"?e:void 0}function Xi(...e){let t,s;for(const o of e)t??(t=io(o==null?void 0:o.in)),s??(s=io(o==null?void 0:o.out));return{in:t??ro.in,out:s??ro.out}}function Mt(e,t){var i;if(e.uses.app===We)return{in:1,out:ws(e).length};const{app:s,action:o}=e.uses,r=e.uses.trigger?{in:0,out:1}:void 0;return Xi(e.ports,t==null?void 0:t(s,o),((i=it(s,o))==null?void 0:i.ports)??r)}const Zi='<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" />',ao='<line x1="6" y1="3" x2="6" y2="15" /><circle cx="18" cy="6" r="3" /><circle cx="6" cy="18" r="3" /><path d="M18 9a9 9 0 0 1-9 9" />',Qi='<polyline points="17 1 21 5 17 9" /><path d="M3 11V9a4 4 0 0 1 4-4h14" /><polyline points="7 23 3 19 7 15" /><path d="M21 13v2a4 4 0 0 1-4 4H3" />',ea='<line x1="6" y1="4" x2="6" y2="20" /><line x1="12" y1="4" x2="12" y2="20" /><line x1="18" y1="4" x2="18" y2="20" />',ta='<circle cx="12" cy="12" r="9" /><polyline points="12 7 12 12 15 14" />',na='<rect x="3" y="4" width="18" height="18" rx="2" /><line x1="16" y1="2" x2="16" y2="6" /><line x1="8" y1="2" x2="8" y2="6" /><line x1="3" y1="10" x2="21" y2="10" /><polyline points="12 13 12 16 14 17" />',sa='<polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" />',lo='<ellipse cx="12" cy="5" rx="9" ry="3" /><path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3" /><path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5" />',oa='<circle cx="12" cy="12" r="10" /><line x1="2" y1="12" x2="22" y2="12" /><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />',ra='<circle cx="18" cy="5" r="3" /><circle cx="6" cy="12" r="3" /><circle cx="18" cy="19" r="3" /><line x1="8.59" y1="13.51" x2="15.42" y2="17.49" /><line x1="15.41" y1="6.51" x2="8.59" y2="10.49" />',ia='<polyline points="9 17 4 12 9 7" /><path d="M20 18v-2a4 4 0 0 0-4-4H4" />',co='<polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" />',aa='<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /><polyline points="15 3 21 3 21 9" /><line x1="10" y1="14" x2="21" y2="3" />',la='<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><polyline points="14 2 14 8 20 8" /><line x1="16" y1="13" x2="8" y2="13" /><line x1="16" y1="17" x2="8" y2="17" /><polyline points="10 9 9 9 8 9" />',Fn='<rect x="4" y="4" width="16" height="16" rx="2" /><rect x="9" y="9" width="6" height="6" /><line x1="9" y1="1" x2="9" y2="4" /><line x1="15" y1="1" x2="15" y2="4" /><line x1="9" y1="20" x2="9" y2="23" /><line x1="15" y1="20" x2="15" y2="23" /><line x1="20" y1="9" x2="23" y2="9" /><line x1="20" y1="14" x2="23" y2="14" /><line x1="1" y1="9" x2="4" y2="9" /><line x1="1" y1="14" x2="4" y2="14" />',ca='<path d="M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2h1" /><path d="M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2h-1" />',ot='<ellipse cx="12" cy="5" rx="9" ry="3" /><path d="M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5" /><path d="M3 12c0 1.66 4.03 3 9 3s9-1.34 9-3" />',ua=[{app:Yt,action:"match",label:"Extract",displayName:"Regex",groupActions:!0,group:"compute",icon:'<circle cx="6" cy="17" r="1"/><path d="M16 4v12M11 7l10 6M11 13l10-6"/>',params:[{key:"text",label:"Text",type:"string",config:{multiline:!0},default:"",hint:"Text to process. Empty text is allowed."},{key:"pattern",label:"Pattern",type:"string",default:"",hint:"Enter a regular expression without enclosing / delimiters. The extracted value is the first capture group, or the full match if there are no capture groups."},{key:"flags",label:"Flags",type:"string",default:"",hint:"Optional flags: d, g, i, m, s, u, v, y. Use g for all matches or replacements; u and v cannot be combined."}],output:[{key:"value",label:"Extracted value"},{key:"matched",label:"Matched"},{key:"matches",label:"Matches"}]},{app:Yt,action:"test",label:"Test",displayName:"Regex",groupActions:!0,group:"compute",icon:'<circle cx="6" cy="17" r="1"/><path d="M16 4v12M11 7l10 6M11 13l10-6"/>',params:[{key:"text",label:"Text",type:"string",config:{multiline:!0},default:"",hint:"Text to process. Empty text is allowed."},{key:"pattern",label:"Pattern",type:"string",default:"",hint:"JavaScript regular expression without / delimiters. An empty pattern matches an empty string."},{key:"flags",label:"Flags",type:"string",default:"",hint:"Optional flags: d, g, i, m, s, u, v, y. Use g for all matches or replacements; u and v cannot be combined."}],output:[{key:"matched",label:"Matched"}]},{app:Yt,action:"replace",label:"Replace",displayName:"Regex",groupActions:!0,group:"compute",icon:'<circle cx="6" cy="17" r="1"/><path d="M16 4v12M11 7l10 6M11 13l10-6"/>',params:[{key:"text",label:"Text",type:"string",config:{multiline:!0},default:"",hint:"Text to process. Empty text is allowed."},{key:"pattern",label:"Pattern",type:"string",default:"",hint:"JavaScript regular expression without / delimiters. An empty pattern matches an empty string."},{key:"flags",label:"Flags",type:"string",default:"",hint:"Optional flags: d, g, i, m, s, u, v, y. Use g for all matches or replacements; u and v cannot be combined."},{key:"replacement",label:"Replacement",type:"string",config:{multiline:!0},default:"",hint:"Replacement text; supports $1, $<name>, $&, $$, $` and $'. Leave empty to remove matches."}],output:[{key:"result",label:"Result"}]},{app:Yt,action:"split",label:"Split",displayName:"Regex",groupActions:!0,group:"compute",icon:'<circle cx="6" cy="17" r="1"/><path d="M16 4v12M11 7l10 6M11 13l10-6"/>',params:[{key:"text",label:"Text",type:"string",config:{multiline:!0},default:"",hint:"Text to process. Empty text is allowed."},{key:"pattern",label:"Pattern",type:"string",default:"",hint:"JavaScript regular expression without / delimiters. An empty pattern matches an empty string."},{key:"flags",label:"Flags",type:"string",default:"",hint:"Optional flags: d, g, i, m, s, u, v, y. Use g for all matches or replacements; u and v cannot be combined."}],output:[{key:"parts",label:"Parts"}]}],pt=[...ua,{app:zt,action:"race",label:"Race",displayName:"Race",group:"control",icon:'<path d="M3 5h4l5 7h9M3 19h4l5-7" /><polyline points="17 8 21 12 17 16" />',ports:{in:"many",out:1},params:[]},{app:We,action:"route",label:"Router",displayName:"Router",group:"control",icon:ao,params:[{key:"routes",label:"Routes",type:"json",required:!0,default:[{id:"route_1",label:"Route 1",condition:!1},{id:"default",label:"Default",default:!0}]}],output:[{key:"route",label:"Selected route"}]},{app:ms,action:"stop",label:"Stop workflow",displayName:"Stop workflow",group:"control",icon:'<rect x="5" y="5" width="14" height="14" rx="2" />',params:[{key:"condition",label:"Condition",type:"json",default:!0,hint:"Stop when this condition is true. Omit it to always stop."}],output:[{key:"stopped",label:"Stopped"}]},{app:bn,action:"manual",label:"Manual trigger",displayName:"Manual trigger",group:"trigger",icon:Zi,ports:{in:0,out:1},params:[{key:"fields",label:"Fields",type:"array",default:[],hint:"The fields this trigger emits into the run. Reference them downstream as {{ nodes.<trigger>.output.<key> }}.",item:{type:"object",fields:[{key:"key",label:"Key",type:"string",placeholder:"e.g. email"},{key:"type",label:"Type",type:"select",default:"string",options:[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"boolean",label:"Boolean"},{value:"json",label:"JSON"}]},{key:"default",label:"Default",type:"string",placeholder:"optional"},{key:"required",label:"Required",type:"boolean",default:!1}]}}]},{app:Le,action:"webhook",label:"Webhook",displayName:"Webhook",group:"trigger",icon:ra,ports:{in:0,out:1},params:[{key:"methods",label:"HTTP Methods",type:"multiselect",required:!0,default:["POST"],hint:"Which HTTP methods this webhook accepts.",options:[{value:"GET",label:"GET"},{value:"POST",label:"POST"},{value:"PUT",label:"PUT"},{value:"PATCH",label:"PATCH"},{value:"DELETE",label:"DELETE"},{value:"HEAD",label:"HEAD"}]},{key:"auth",label:"Authentication",type:"select",default:"none",hint:"How incoming requests are authenticated.",options:[{value:"none",label:"None"},{value:"basic",label:"Basic auth"},{value:"header",label:"Header auth"},{value:"jwt",label:"JWT (HMAC)"}]},{key:"basicUser",label:"Username",type:"string",row:"basic-auth",showIf:{field:"auth",equals:"basic"}},{key:"basicPassword",label:"Password",type:"secret",row:"basic-auth",showIf:{field:"auth",equals:"basic"}},{key:"headerName",label:"Header name",type:"string",row:"header-auth",placeholder:"e.g. X-Api-Key",showIf:{field:"auth",equals:"header"}},{key:"headerValue",label:"Header value",type:"secret",row:"header-auth",showIf:{field:"auth",equals:"header"}},{key:"jwtSecret",label:"JWT secret",type:"secret",showIf:{field:"auth",equals:"jwt"}},{key:"responseMode",label:"Respond",type:"select",default:"onReceived",hint:"When and how to respond to the caller.",options:[{value:"onReceived",label:"Immediately (ASAP)"},{value:"lastNode",label:"When the run finishes"},{value:"responseNode",label:"Using a Response node"},{value:"streaming",label:"Streaming"}]},{key:"responseCode",label:"Response status code",type:"number",default:200,showIf:{field:"responseMode",notIn:["responseNode"]}},{key:"responseData",label:"Response body (immediate)",type:"text",hint:'Body for "Immediately" responses. Empty = { "runId": "run_…", "status": "started" }. Write {{ runId }} to include the run id.',showIf:{field:"responseMode",equals:"onReceived"}},{key:"rawBody",label:"Raw body",type:"boolean",default:!1,advanced:!0},{key:"ignoreBots",label:"Ignore bots",type:"boolean",default:!1,advanced:!0},{key:"ipAllowList",label:"IP allow list",type:"array",advanced:!0,item:{type:"string",placeholder:"e.g. 203.0.113.4"},hint:"Client IPs allowed to call this webhook. Empty = allow all."},{key:"binaryPropertyName",label:"Binary field name",type:"string",advanced:!0},{key:"cors",label:"CORS allowed origin",type:"string",advanced:!0},{key:"responseHeaders",label:"Response headers",type:"array",default:[],advanced:!0,item:{type:"object",fields:[{key:"name",label:"Name",type:"string"},{key:"value",label:"Value",type:"string"}]}}]},{app:fs,action:"schedule",label:"Schedule",displayName:"Scheduler",group:"trigger",icon:na,ports:{in:0,out:1},params:[{key:"mode",label:"Mode",type:"select",required:!0,default:"cron",hint:"How the schedule fires.",options:[{value:"once",label:"Once"},{value:"cron",label:"Cron"},{value:"interval",label:"Interval"}]},{key:"cron",label:"Cron expression",type:"string",placeholder:"e.g. 0 9 * * 1-5",showIf:{field:"mode",equals:"cron"}},{key:"runAt",label:"Run at",type:"string",placeholder:"e.g. 2026-01-01T09:00:00Z",showIf:{field:"mode",equals:"once"}},{key:"intervalSeconds",label:"Interval (seconds)",type:"number",showIf:{field:"mode",equals:"interval"}},{key:"timezone",label:"Timezone",type:"string",default:"UTC",advanced:!0}]},{app:Pe,action:"if",label:"If",displayName:"If",group:"control",icon:ao,params:[{key:"condition",type:"json",label:"Condition",required:!0,default:!0,hint:"A boolean, or an expression like {{ nodes.x.output.ok }}."}]},{app:Pe,action:"foreach",label:"For each",displayName:"For each",group:"control",icon:Qi,params:[{key:"items",type:"json",label:"Items",required:!0,whole:!0,hint:"An array to iterate, or an expression binding to one."},{key:"body",type:"json",label:"Body",hidden:!0,hint:"Step ids run per item. The canvas owns it; the engine requires it at run time."},{key:"parallelism",type:"number",label:"Parallelism",hidden:!0,hint:"Concurrent iterations. The engine clamps it to 1."}]},{app:Pe,action:"parallel",label:"Parallel",displayName:"Parallel",group:"control",icon:ea,params:[]},{app:Pe,action:"wait",label:"Wait",displayName:"Wait",group:"control",icon:ta,params:[{key:"duration",type:"string",label:"Duration",default:"1s",hint:"Use 30s, 1h30m30s, or 3d30s. Units: w, d, h, m, s; uppercase also works."}]},{app:Uo,action:"run",label:"Run script",displayName:"Run script",group:"compute",icon:sa,params:[{key:"language",label:"Language",type:"select",default:"javascript",options:[{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"python",label:"Python"}],hint:"Execution language for this step's code. TypeScript types are erased before it runs, not checked. Python runs CPython-on-WASM with no network."},{key:"code",type:"code",label:"Script",required:!0,scriptReads:!0,default:`// Runs as a function body. Return the step's output.
2
+ return input;`,hint:"Return the step's output. Read data from state, vars and consts; {{ }} isn't substituted in code. digest(value) returns a stable SHA-256 hex (await it in JavaScript or TypeScript)."},{key:"custom_input",type:"section",section:"collapsible",title:"Custom input (advanced)",openWhenSet:!0,children:[{key:"input",type:"json",label:"Input",whole:!0,hint:"Replaces what the script reads as `input` (by default, the run state). Each bound value keeps its type; a secret goes here, since state never holds one."}]}]},{app:Ui,action:"render",label:"Render template",displayName:"Template",group:"compute",icon:ca,output:[{key:"result"}],params:[{key:"template",label:"Template",type:"json",required:!0,whole:!0,hint:'Enter a JSON string ("Hello {{name}}") or object, or bind one with ƒx. String values render recursively; other values stay unchanged. {{name}} is HTML-escaped; use {{{name}}} for raw output.'},{key:"values",label:"Values",type:"vars",required:!0,whole:!0,default:{},hint:"Enter a JSON object, or use ƒx to bind data from workflow state or variables. Each key becomes a top-level placeholder root."}]},{app:Lt,action:"set",label:"Data",displayName:"Data set",group:"compute",icon:lo,params:[{key:"vars",type:"vars",label:"Variables",required:!0,default:[],hint:"Set values for downstream steps using individual fields or a JSON object."}]},{app:Lt,action:"update",label:"Update object",displayName:"Update object",group:"compute",icon:lo,params:[{key:"object",type:"json",label:"Starting object",required:!0,whole:!0,hint:"Use ƒx to choose an object from state or a previous step. The original stays unchanged."},{key:"vars",type:"vars",label:"Fields to set",required:!0,default:[],hint:"Set one or more fields. Use dot paths for nested fields, such as address.city."}]},{app:Wi,action:"request",label:"HTTP request",displayName:"HTTP",group:"request",icon:oa,output:[{key:"status"},{key:"statusText"},{key:"ok"},{key:"headers"},{key:"body"}],params:[{key:"method",type:"string",label:"Method",required:!0,default:"GET",options:[{value:"GET",label:"GET"},{value:"POST",label:"POST"},{value:"PUT",label:"PUT"},{value:"PATCH",label:"PATCH"},{value:"DELETE",label:"DELETE"}],hint:"HTTP method for the request."},{key:"url",type:"string",label:"URL",required:!0,default:"",hint:"Full request URL, e.g. https://api.example.com/v1/things."},{key:"headers",type:"json",label:"Headers",default:{},hint:"Object of header name → value."},{key:"query",type:"json",label:"Query params",default:{},hint:"Object of query-string name → value, appended to the URL."},{key:"body",type:"text",label:"Body",default:"",hint:"Request body (raw text or a JSON string). Ignored for GET/HEAD."}]},{app:qi,action:"respond",label:"Respond to Webhook",displayName:"Respond to Webhook",group:"request",icon:ia,params:[{key:"respondWith",label:"Respond with",type:"select",default:"json",hint:"Shape of the response returned to the webhook caller.",options:[{value:"json",label:"JSON"},{value:"text",label:"Text"},{value:"noData",label:"No body"}]},{key:"responseCode",label:"Response status code",type:"number",default:200},{key:"responseBody",label:"Response body",type:"json",default:{},hint:"Body to return (object for JSON, string for Text)."},{key:"responseHeaders",label:"Response headers",type:"array",default:[],item:{type:"object",fields:[{key:"name",label:"Name",type:"string"},{key:"value",label:"Value",type:"string"}]}}]},{app:Pe,action:"aggregate",label:"Aggregate",displayName:"Aggregate",group:"control",icon:co,hidden:!0,ports:{in:10,out:1},params:[{key:"mode",label:"Mode",type:"select",default:"array",hint:"How to combine the inbound branch outputs: an array of results, or an object keyed by source step.",options:[{value:"array",label:"Array"},{value:"object",label:"Object"}]}]},{app:Pe,action:"merge",label:"Merge",displayName:"Merge",group:"control",icon:co,ports:{in:"many",out:1},params:[{key:"mode",label:"Mode",type:"select",default:"array",hint:"Combine the entries into an array, or into an object keyed by each entry's key.",options:[{value:"array",label:"Array"},{value:"object",label:"Object"}]},{key:"entries",label:"Entries",type:"array",default:[],hint:"Each entry's value may be an expression (ƒx) over the inbound branches' outputs.",item:{type:"object",fields:[{key:"key",label:"Key",type:"string"},{key:"value",label:"Value",type:"string"}]}}]},{app:gn,action:"call",label:"Call workflow",displayName:"Call",group:"compute",icon:aa,ports:{in:1,out:1},params:[{key:"targetKind",label:"Target kind",type:"select",required:!0,default:"workflow",hint:"Whether this node calls another Workflow or a Function.",options:[{value:"workflow",label:"Workflow"},{value:"function",label:"Function"}]},{key:"targetId",label:"Target id",type:"string",required:!0,default:"",placeholder:"e.g. wf_… or fn_…",hint:"Id of the Workflow (wf_…) or Function (fn_…) to call, within this project."},{key:"inputs",label:"Inputs",type:"json",default:{},hint:"Payload passed to the target — an object keyed by the callee's declared inputs. Values may be expressions."},{key:"wait",label:"Wait for completion",type:"boolean",default:!0,hint:"On: block until the sub-run finishes and expose its output. Off: return a run handle and continue."}]},{app:hs,action:"get",label:"Get document",displayName:"Document",group:"compute",icon:la,ports:{in:1,out:1},params:[{key:"key",label:"Key",type:"string",required:!0,default:"",hint:"Document key to read — may be an expression, e.g. a step output."}]},{app:Ln,action:"complete",label:"Complete with model",displayName:"Model",group:"compute",icon:Fn,ports:{in:1,out:1},params:[{key:"route",label:"Route",type:"model-route",hint:"Name of a model route (Models → Routes). Use this, or the model + connection pair below — never both."},{key:"model",label:"Model",type:"string",advanced:!0,hint:"Catalog id of a model (`mdl_…`, Models → Catalog), called through `connection`. Ignored when `route` is set."},{key:"connection",label:"Connection",type:"string",advanced:!0,hint:"Id of a model-provider connection on this account. Required by `model`; ignored when `route` is set."},{key:"input",label:"Input",type:"json",required:!0,default:{},hint:`The request body handed to the provider — e.g. { "messages": [{ "role": "user", "content": "hi" }] }, or the provider's native payload.`},{key:"dialect",label:"Dialect",type:"select",advanced:!0,hint:"Rewrite the result into this wire dialect; bridge keeps the baseline unprojected. Leave unset to keep the provider's own.",placeholder:"Provider native",options:[{value:"bridge",label:"Bridge (unprojected)"},{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"ollama",label:"Ollama"}]},{key:"response",label:"Response",type:"select",advanced:!0,hint:"Output: the dialect-shaped result. Raw: the provider's own response. Leave unset to carry both.",placeholder:"Both",options:[{value:"output",label:"Output"},{value:"raw",label:"Raw"}]}]},{app:Ln,action:"list-models",label:"List models",displayName:"Model",group:"compute",icon:Fn,ports:{in:1,out:1},params:[{key:"connection",label:"Connection",type:"string",required:!0,hint:"Connection id of the provider to list models for."}]},{app:Ln,action:"allowance",label:"Model allowance",displayName:"Model",group:"compute",icon:Fn,ports:{in:1,out:1},params:[{key:"connection",label:"Connection",type:"string",required:!0,hint:"Connection id of the provider to read the allowance of."}]},{app:De,action:"get",label:"Get entry",displayName:"Store",group:"compute",icon:ot,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"key",label:"Key",type:"data-store-key",required:!0,hint:"Entry key — search the store's entries, type a key, or bind an expression."},{key:"required",label:"Required",type:"boolean",default:!1,hint:"Fail the step when the key is missing instead of returning found: false."}],output:[{key:"found"},{key:"key"},{key:"value"},{key:"version"},{key:"expiresAt"}]},{app:De,action:"set",label:"Set entry",displayName:"Store",group:"compute",icon:ot,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"key",label:"Key",type:"data-store-key",required:!0,hint:"Entry key — search the store's entries, type a key, or bind an expression."},{key:"value",label:"Value",type:"json",required:!0,hint:"The JSON value to store."},{key:"ifVersion",label:"If version",type:"number",hint:"Write only when the stored version equals this number."},{key:"ttlSeconds",label:"TTL (seconds)",type:"number",hint:"Expire the entry after this many seconds. Omit to keep it."}],output:[{key:"key"},{key:"value"},{key:"version"},{key:"expiresAt"}]},{app:De,action:"delete",label:"Delete entry",displayName:"Store",group:"compute",icon:ot,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"key",label:"Key",type:"data-store-key",required:!0,hint:"Entry key — search the store's entries, type a key, or bind an expression."}],output:[{key:"key"},{key:"deleted"}]},{app:De,action:"increment",label:"Increment counter",displayName:"Store",group:"compute",icon:ot,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"key",label:"Key",type:"data-store-key",required:!0,hint:"Entry key — search the store's entries, type a key, or bind an expression."},{key:"by",label:"By",type:"number",default:1,hint:"Amount to add; may be negative."}],output:[{key:"key"},{key:"value"},{key:"version"}]},{app:De,action:"list",label:"List entries",displayName:"Store",group:"compute",icon:ot,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"prefix",label:"Prefix",type:"string",hint:"Only entries whose key starts with this."},{key:"cursor",label:"Cursor",type:"string",hint:"The nextCursor of a previous page."},{key:"limit",label:"Limit",type:"number",default:50,hint:"Page size, at most 200."}],output:[{key:"items"},{key:"nextCursor"}]},{app:De,action:"query",label:"Query rows",displayName:"Store",group:"compute",icon:ot,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"where",label:"Where",type:"json",hint:"Column equality filter."},{key:"order",label:"Order",type:"string",hint:"Column to order by; prefix with - for descending."},{key:"limit",label:"Limit",type:"number",hint:"Maximum rows to return."}],output:[{key:"items"}]},{app:De,action:"insert",label:"Insert row",displayName:"Store",group:"compute",icon:ot,ports:{in:1,out:1},params:[{key:"store",label:"Store",type:"data-store",required:!0,hint:"Name of a data store in this account and project."},{key:"row",label:"Row",type:"json",required:!0,hint:"The row, keyed by column name."},{key:"ttlSeconds",label:"TTL (seconds)",type:"number",hint:"Expire the entry after this many seconds. Omit to keep it."}],output:[{key:"key"},{key:"value"},{key:"version"}]}];function it(e,t){return pt.find(s=>s.app===e&&s.action===t)}function da(e,t){var s;return((s=it(e,t))==null?void 0:s.label)??t}function pa(e,t){var s;return((s=it(e,t))==null?void 0:s.icon)??""}function zo(e,t){var s;return((s=it(e,t))==null?void 0:s.params)??[]}function fn(e,t){const s={};for(const o of zo(e,t))o.default!==void 0&&(s[o.key]=o.default);return s}function fa(e,t){return e.q===t.q&&(e.category??"")===(t.category??"")&&(e.ids??[]).join(",")===(t.ids??[]).join(",")}function Jo(e,t=0){return{query:e,generation:t,status:"loading",apps:[],hasMore:!1}}function ha(e,t){const s=new Set(e.map(r=>r.id)),o=[];for(const r of t)s.has(r.id)||(s.add(r.id),o.push(r));return o.length===0?e:[...e,...o]}function ma(e,t){switch(t.type){case"query-changed":return t.generation===e.generation&&fa(t.query,e.query)?e:Jo(t.query,t.generation);case"load-more":return e.status!=="ready"||!e.hasMore?e:{...e,status:"loading-more"};case"retry":return e.status!=="error"?e:{...e,status:e.apps.length===0?"loading":"loading-more"};case"page-loaded":{if(t.generation!==e.generation)return e;const s=ha(e.apps,t.apps),o=t.nextCursor!==void 0&&t.nextCursor===t.requestedCursor,r=!!t.nextCursor&&!o;return{...e,status:"ready",apps:s,cursor:r?t.nextCursor:void 0,hasMore:r,total:typeof t.total=="number"?t.total:e.total,error:void 0}}case"page-failed":return t.generation!==e.generation?e:{...e,status:"error",error:t.error};default:return e}}function wa(e){return e.filter(t=>!Ye(t.id))}function Mn(e,t,s){if(s<=0)return[];const o=[];for(const r of e)if(!t.has(r)&&(o.push(r),o.length>=s))break;return o}function ba(e,t){const s=[];for(const o of e){const r=t.get(o);r&&s.push(r)}return s}const Ko=w.createContext(void 0);function uo(e,t){var o;if(e)return e;if(t)return t;if(typeof document>"u")return"light";const s=document.documentElement.getAttribute("data-theme");return s==="dark"||s==="light"?s:(o=window.matchMedia)!=null&&o.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function yn(e){const t=w.useContext(Ko),[s,o]=w.useState(()=>uo(e,t));return w.useEffect(()=>{if(e){o(e);return}if(t){o(t);return}if(typeof window>"u")return;const r=()=>o(uo(void 0,t)),i=window.matchMedia("(prefers-color-scheme: dark)");i.addEventListener("change",r);const a=new MutationObserver(r);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),r(),()=>{i.removeEventListener("change",r),a.disconnect()}},[e,t]),s}function ft({src:e,srcDark:t,brandColor:s,name:o,size:r=32,theme:i}){const l=yn(i)==="dark"?t??e:e,[c,u]=w.useState(void 0);if(l&&l!==c)return n.jsx("img",{src:l,width:r,height:r,alt:"",onError:()=>u(l),style:{width:r,height:r,borderRadius:6,flexShrink:0,objectFit:"contain",padding:Math.max(1,Math.round(r*.06)),boxSizing:"border-box",background:"var(--w6w-icon-swatch, var(--w6w-panel-2))"}});const d=(o??"?").split(/\s+/).slice(0,2).map(f=>{var p;return((p=f[0])==null?void 0:p.toUpperCase())??""}).join("");return n.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:r,height:r,borderRadius:6,background:s??"var(--w6w-accent)",color:"#fff",fontWeight:700,fontSize:Math.round(r*.42),flexShrink:0},children:d})}const gs=w.createContext(null);function ga({api:e,theme:t,children:s}){const o=n.jsx(gs.Provider,{value:e,children:n.jsx(Ko.Provider,{value:t,children:s})});return t?n.jsx("div",{"data-theme":t,style:{display:"contents"},children:o}):o}function ye(){const e=w.useContext(gs);if(!e)throw new Error("useW6WApi must be used inside <W6WUIProvider>. Wrap your app root with <W6WUIProvider api={api}>...</W6WUIProvider>.");return e}function tn(){return w.useContext(gs)??void 0}const Go=w.createContext(void 0),Yo=w.createContext(void 0);function ya({project:e,workflowId:t,children:s}){return n.jsx(Go.Provider,{value:e,children:n.jsx(Yo.Provider,{value:t,children:s})})}function ys(){return w.useContext(Go)}function xa(){return w.useContext(Yo)}const Dn=8,va=60,ja=300;function po(e){const t=e.modelProvider;return!t||typeof t!="object"?null:t}function Na(e){if(!e)return null;if(e.supported)return{text:"Bridge supported",title:"Bridge supported"};const t=typeof e.reason=="string"?e.reason.trim():"";return{text:t===""?"unsupported":`unsupported — ${t}`,title:t===""?"Bridge not supported":t}}function at({onSelectApp:e,theme:t,filter:s,searchPlaceholder:o,emptyMessage:r,search:i=!0,searchValue:a,onSearchChange:l,emptyAction:c,apps:u,categoryFilter:d=!1,providerFilter:f=!1,bridgeSupport:p,category:h,hasTriggers:b,ids:m,pageLimit:x=va,loadPage:g}){const y=ye(),N=u!==void 0,A=m&&m.length>0?m.join(","):"",k=!N&&(g!==void 0||typeof y.listAppsPage=="function"),C=w.useRef(g);C.current=g;const[v,E]=w.useState(null),[R,F]=w.useState(null);w.useEffect(()=>{if(N||k)return;const W=y.listApps;if(typeof W!="function"){E([]);return}let Q=!1;return W().then(de=>!Q&&E(de)).catch(de=>!Q&&F(de.message)),()=>{Q=!0}},[y,N,k]);const[T,O]=w.useReducer(ma,Jo({q:"",category:h,ids:m},0)),[I,M]=w.useState(""),D=a??I,H=W=>{a===void 0&&M(W),l==null||l(W)},[Y,$]=w.useState(D.trim()),G=w.useRef(0),ne=w.useRef(null),oe=w.useCallback((W,Q,de)=>{var Gt;const Je=C.current,st=y.listAppsPage;if(!Je&&!st)return;(Gt=ne.current)==null||Gt.abort();const ke=new AbortController;ne.current=ke;let $e;try{$e=Je?Je({q:W.q||void 0,cursor:de,limit:x,...W.ids?{ids:W.ids}:{},signal:ke.signal}):st({q:W.q||void 0,category:W.category,...b?{hasTriggers:!0}:{},...W.ids?{ids:W.ids}:{},cursor:de,limit:x,compact:!0,signal:ke.signal})}catch(we){$e=Promise.reject(we)}$e.then(we=>{if(G.current===Q){if(!we||!Array.isArray(we.apps)){O({type:"page-failed",generation:Q,error:"The server returned a malformed apps page."});return}O({type:"page-loaded",generation:Q,apps:we.apps,nextCursor:we.nextCursor,requestedCursor:de,total:typeof we.total=="number"?we.total:void 0})}}).catch(we=>{if(G.current!==Q||we instanceof Error&&we.name==="AbortError")return;const j=we==null?void 0:we.code;if(de!==void 0&&(j==="snapshot_expired"||j==="unknown_snapshot")){const _=++G.current;O({type:"query-changed",query:W,generation:_}),oe(W,_,void 0);return}O({type:"page-failed",generation:Q,error:we.message})})},[y,x,b]);w.useEffect(()=>{if(!k)return;const W=setTimeout(()=>$(D.trim()),ja);return()=>clearTimeout(W)},[D,k]),w.useEffect(()=>{if(!k)return;const W=++G.current,Q={q:Y,category:h,...A?{ids:A.split(",")}:{}};return O({type:"query-changed",query:Q,generation:W}),oe(Q,W,void 0),()=>{var de;(de=ne.current)==null||de.abort()}},[k,Y,h,A,oe]),w.useEffect(()=>{if(k)return()=>{var W;return(W=ne.current)==null?void 0:W.abort()}},[k]);const X=()=>{if(!k||T.status!=="ready"||!T.hasMore)return;const W=G.current;O({type:"load-more"}),oe(T.query,W,T.cursor)},L=()=>{!k||T.status!=="error"||(O({type:"retry"}),oe(T.query,G.current,T.cursor))},[z,Z]=w.useState([]),[q,J]=w.useState(!1),[te,S]=w.useState(!1),U=W=>n.jsx("div",{className:"w6w-apppicker-host",children:W});let V,P=null,B=!1,ae=!1,fe=null,he=!1;if(N?V=u??null:k?(V=T.apps,he=T.status==="loading",B=T.status==="loading-more",ae=T.hasMore,T.status==="error"&&(T.apps.length===0?P=T.error??"Failed to load apps.":fe=T.error??"Failed to load apps.")):(V=v,P=R),!k&&P)return U(n.jsx("div",{className:"w6w-result w6w-error",children:P}));if(!k&&V===null)return U(n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading apps…"}));V??(V=[]);const ge=wa(V),ve=s?ge.filter(s):ge;if(!k&&ve.length===0)return U(n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:r??"No apps registered yet. Register one from the Apps page first."}),c]}));const Ae=d?Mi(ve):[],Te=Ae.slice(0,Dn),le=Ae.slice(Dn).filter(W=>z.includes(W.slug)),Ee=[...Te,...le],mt=Ae.length-Ee.length,Ue=q?Ae:Ee,Ct=W=>Z(Q=>Q.includes(W)?Q.filter(de=>de!==W):[...Q,W]),et=()=>Z([]),Ve=ve.filter(W=>po(W)!==null).length,tt=f&&Ve>0,Fe=tt&&te,me=Fe?ve.filter(W=>po(W)!==null):ve,Oe=d&&z.length>0?me.filter(W=>Di(W,z)):me,nt=k?Oe:[...Oe].sort((W,Q)=>W.displayName.localeCompare(Q.displayName,void 0,{sensitivity:"base"})),xe=k?"":D.trim().toLowerCase(),je=D.trim().length>0,Ie=xe?nt.filter(W=>W.displayName.toLowerCase().includes(xe)||W.id.toLowerCase().includes(xe)):nt,Ne=s!==void 0&&ve.length!==ge.length||Fe&&me.length!==ve.length||d&&z.length>0&&Oe.length!==me.length,At=(d&&z.length>0||Fe)&&Ie.length===0,ze=Fe&&z.length===0,ee=()=>{Z([]),S(!1),H("")};return U(n.jsxs("div",{className:"w6w-stepbuilder-apps",children:[i&&n.jsx("input",{type:"text",className:"w6w-stepbuilder-search",placeholder:o??"Search apps…",value:D,onChange:W=>H(W.target.value),"aria-label":"Search apps"}),(tt||d&&Ae.length>0)&&n.jsxs("div",{className:"w6w-apppicker-cats",children:[tt&&n.jsxs("button",{type:"button",className:"w6w-apppicker-chip w6w-apppicker-provider-toggle","aria-pressed":te,"aria-label":"Filter to model providers",onClick:()=>S(W=>!W),children:["Model providers ",n.jsxs("span",{className:"w6w-muted",children:["(",Ve,")"]})]}),d&&Ae.length>0&&n.jsxs(n.Fragment,{children:[Ue.map(W=>n.jsxs("button",{type:"button",className:"w6w-apppicker-chip","aria-pressed":z.includes(W.slug),"aria-label":`Filter by ${W.label}`,onClick:()=>Ct(W.slug),children:[W.label," ",n.jsxs("span",{className:"w6w-muted",children:["(",W.count,")"]})]},W.slug)),!q&&mt>0&&n.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>J(!0),children:["+",mt," more"]}),q&&Ae.length>Dn&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>J(!1),children:"Show less"}),z.length>0&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:et,children:"Clear"})]})]}),k&&he?n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading apps…"}):k&&P?n.jsxs("div",{className:"w6w-result w6w-error",children:[P," ",n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:L,children:"Retry"})]}):Ie.length===0&&!ae?At?n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:ze?je?`No model providers match “${D}”.`:"No apps declare a model provider.":je?`No apps match “${D}” in the selected categories.`:"No apps match the selected categories."}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:ee,children:"Clear filters"})]}):k?n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:je?`No apps match “${D}”.`:r??"No apps registered yet. Register one from the Apps page first."}),!je&&c]}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["No apps match “",D,"”."]}):n.jsxs(n.Fragment,{children:[Ie.length===0&&ae?n.jsx("p",{className:"w6w-muted w6w-small",children:"No matching apps on this page yet — try “Load more”."}):n.jsx("div",{className:"w6w-stepbuilder-list w6w-apppicker-grid w6w-stepbuilder-scroll",children:Ie.map(W=>{const Q=p==null?void 0:p.get(W.id),de=Na(Q);return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item w6w-apppicker-card",onClick:()=>e(W),children:[n.jsx(ft,{src:W.iconSvg,srcDark:W.iconSvgDark,brandColor:W.brandColor,name:W.displayName,theme:t,size:24}),n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:W.displayName}),n.jsx("code",{className:"w6w-apppicker-card-id",children:W.id}),W.version&&n.jsxs("span",{className:"w6w-apppicker-card-version",children:["v",W.version]}),de&&n.jsx("span",{className:Q!=null&&Q.supported?"w6w-chip w6w-apppicker-card-bridge":"w6w-chip w6w-apppicker-card-bridge w6w-apppicker-card-bridge-unsupported",title:de.title,children:de.text})]})]},W.id)})}),k&&typeof T.total=="number"&&n.jsx("div",{className:"w6w-small w6w-apppicker-count",children:Ne?`${Ie.length} ${Ie.length===1?"app":"apps"}`:`${T.apps.length} of ${T.total}`}),k&&fe&&n.jsxs("div",{className:"w6w-result w6w-error w6w-small",children:[fe," ",n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:L,children:"Retry"})]}),k&&ae&&!fe&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-apppicker-load-more",onClick:X,disabled:B,children:B?"Loading more…":"Load more"})]})]}))}const ka=new Set(["http:","https:","mailto:"]);function Sa(e){try{return ka.has(new URL(e).protocol)?e:""}catch{return""}}const Ca=["img"];function Aa({node:e,href:t,children:s,...o}){return n.jsx("a",{...o,href:t||void 0,target:"_blank",rel:"noopener noreferrer nofollow",children:s})}function Xo(e){const t=/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(e);return t?{frontmatter:t[1],body:e.slice(t[0].length)}:{frontmatter:null,body:e}}function Ea({yaml:e}){return n.jsxs("details",{className:"w6w-md-frontmatter","data-testid":"md-frontmatter",children:[n.jsx("summary",{children:"Frontmatter"}),n.jsx("pre",{children:n.jsx("code",{children:e})})]})}function xs({content:e,className:t}){const{frontmatter:s,body:o}=Xo(e);return n.jsxs("div",{className:t,children:[(s==null?void 0:s.trim())&&n.jsx(Ea,{yaml:s}),n.jsx(_i,{skipHtml:!0,urlTransform:Sa,disallowedElements:Ca,unwrapDisallowed:!0,components:{a:Aa},children:o})]})}const Ra=/^(#{1,6})\s+(.*)$/,Ta=new RegExp("\\*\\*(?=\\S)(.+?)(?<=\\S)\\*\\*","g");function Oa(e,t){const s=e.ownerDocument;e.replaceChildren();for(const o of t.split(`
3
+ `)){const r=Ra.exec(o),i=s.createElement(r?`h${r[1].length}`:"div"),a=r?r[2]:o;let l=0;for(const c of a.matchAll(Ta)){c.index>l&&i.append(s.createTextNode(a.slice(l,c.index)));const u=s.createElement("strong");u.textContent=c[1],i.append(u),l=c.index+c[0].length}l<a.length&&i.append(s.createTextNode(a.slice(l))),i.firstChild||i.append(s.createElement("br")),e.append(i)}}function Ia(e){var o;const t=(o=e.style)==null?void 0:o.fontWeight;if(!t)return;if(t==="bold"||t==="bolder")return!0;const s=Number(t);return Number.isFinite(s)?s>=600:!1}function $a(e){const t=[];for(const s of e){const o=t[t.length-1];o&&o.bold===s.bold?o.text+=s.text:t.push({...s})}return t.map(({text:s,bold:o})=>{const r=s.trim();if(!o||!r)return s;const i=s.slice(0,s.indexOf(r)),a=s.slice(i.length+r.length);return`${i}**${r}**${a}`}).join("")}function Pa(e){const t=[];let s=null;const o=a=>(s={level:a,runs:[]},t.push(s),s),r=(a,l,c)=>{if(a.nodeType===3){const m=(a.textContent??"").replace(/ /g," ").replace(/\n/g,"");m&&(s??o(l)).runs.push({text:m,bold:c});return}if(a.nodeType!==1)return;const u=a,d=u.tagName.toLowerCase();if(d==="br"){s||o(l),s=null;return}const f=/^h([1-6])$/.exec(d),p=f||["div","p","li","ul","ol","blockquote","pre"].includes(d);p&&(s=null);const h=f?Number(f[1]):l,b=d==="b"||d==="strong"?!0:Ia(u)??c;for(const m of u.childNodes)r(m,h,b);p&&(s=null)};for(const a of e.childNodes)r(a,0,!1);const i=t.map(a=>{const l=$a(a.runs);return a.level>0?`${"#".repeat(a.level)} ${l.trimStart()}`:l});for(;i.length&&i[i.length-1].trim()==="";)i.pop();return i.join(`
4
+ `)}function _a(e){return e.replace(/([^\n])\n(?=[^\n])/g,`$1
5
+ `)}const La=-2,Fa=-1,fo=1e3,Ma=["#facc15","#fb923c","#f87171","#f472b6","#a78bfa","#60a5fa","#2dd4bf","#4ade80","#9ca3af"],Da=[{level:1,label:"Title"},{level:2,label:"Heading"},{level:3,label:"Subheading"},{level:0,label:"Body"}],Ha=80,Ba=48,ho=10,Wa=4,Hn=e=>e.stopPropagation();function qa(e){const t=e.ownerDocument.getSelection();if(!t)return;const s=e.ownerDocument.createRange();s.selectNodeContents(e),t.removeAllRanges(),t.addRange(s)}function Ua(e){const t=e.ownerDocument.getSelection();if(!t)return;const s=e.ownerDocument.createRange();s.selectNodeContents(e),s.collapse(!1),t.removeAllRanges(),t.addRange(s)}function Zo({canvas:e,className:t,viewport:s,readOnly:o,zoom:r=1,onChange:i,onSectionDrop:a,onRequestDelete:l}){const[c,u]=w.useState({}),[d,f]=w.useState(null),[p,h]=w.useState(null),[b,m]=w.useState(null),[x,g]=w.useState(null),y=w.useRef(null),N=w.useRef(null),A=w.useRef(null);if(w.useEffect(()=>{if(!d&&!p)return;const S=d?`[data-note-id="${d}"], [data-note-toolbar="${d}"]`:`[data-section-label="${p}"], [data-section-toolbar="${p}"]`,U=V=>{var ae,fe;const P=V.target;if((ae=P==null?void 0:P.closest)!=null&&ae.call(P,S))return;const B=document.activeElement;(fe=B==null?void 0:B.closest)!=null&&fe.call(B,"[data-section-toolbar]")&&B.blur(),f(null),h(null),g(null)};return window.addEventListener("pointerdown",U,!0),()=>window.removeEventListener("pointerdown",U,!0)},[d,p]),!s)return null;const k=!o&&!!i,C=e.sections??[],v=e.notes??[],E=S=>c[S.id]??{x:S.position.x,y:S.position.y,w:S.size.width,h:S.size.height},R=S=>{const U=E(S);return{left:U.x,top:U.y,width:U.w,height:U.h,"--w6w-canvas-color":S.color}},F=(S,U)=>i==null?void 0:i({...e,notes:v.map(V=>V.id===S?{...V,...U}:V)}),T=(S,U)=>i==null?void 0:i({...e,sections:C.map(V=>V.id===S?{...V,...U}:V)}),O=S=>{const U=N.current,V=v.find(B=>B.id===S);if(!(U!=null&&U.isConnected)||!V)return;const P=Pa(U);P!==V.content&&F(S,{content:P})},I=S=>{h(null),f(S)},M=S=>{f(null),h(S)},D=(S,U)=>{A.current=U??null,I(S),m(S),g(null)},H=S=>U=>{if(!U||U.dataset.ready==="1")return;U.dataset.ready="1",N.current=U,Oa(U,S.content),U.focus();const V=A.current;A.current=null,V?(qa(U),V(),O(S.id)):Ua(U)},Y=(S,U,V)=>{var B;g(null);const P=()=>document.execCommand(U,!1,V);b===S&&((B=N.current)!=null&&B.isConnected)?(P(),O(S)):D(S,P)},$=S=>S.mode==="move"?{...S.base,x:S.base.x+S.dx,y:S.base.y+S.dy}:{...S.base,w:Math.max(Ha,S.base.w+S.dx),h:Math.max(Ba,S.base.h+S.dy)},G=(S,U,V,P)=>{if(!k||S.button!==0)return;S.stopPropagation(),S.preventDefault();const B={kind:V,id:U.id,mode:P,sx:S.clientX,sy:S.clientY,base:E(U),dx:0,dy:0};y.current=B;const ae=he=>{B.dx=(he.clientX-B.sx)/(r||1),B.dy=(he.clientY-B.sy)/(r||1),u(ge=>({...ge,[B.id]:$(B)}))},fe=()=>{if(window.removeEventListener("pointermove",ae),window.removeEventListener("pointerup",fe),y.current=null,u(ve=>{const{[B.id]:Ae,...Te}=ve;return Te}),B.dx===0&&B.dy===0)return;const he=$(B),ge={position:{x:he.x,y:he.y},size:{width:he.w,height:he.h}};B.kind==="section"&&B.mode==="move"&&a?a(B.id,{dx:B.dx,dy:B.dy}):B.kind==="note"?F(B.id,ge):T(B.id,ge)};window.addEventListener("pointermove",ae),window.addEventListener("pointerup",fe)},ne=t?` ${t}`:"",oe="nopan nodrag nowheel",X=k?v.find(S=>S.id===d):void 0,L=k?C.find(S=>S.id===p):void 0,z=r||1,Z=S=>{const U=E(S);return{left:U.x+U.w/2,top:U.y,transform:`translate(-50%, calc(-100% - ${ho/z}px)) scale(${1/z})`,transformOrigin:"50% 100%","--w6w-canvas-color":S.color}},q=(S,U)=>{const V=E(S);return{left:V.x,top:V.y,transform:`translate(0, calc(-100% - ${U/z}px)) scale(${1/z})`,transformOrigin:"0 100%","--w6w-canvas-color":S.color}},J=(S,U,V,P)=>n.jsxs("div",{className:"w6w-note-menu w6w-note-menu-colors",role:"menu",children:[Ma.map(B=>n.jsx("button",{type:"button",role:"menuitemradio","aria-checked":B===S,"aria-label":`Colour ${B}`,title:B,className:`w6w-note-swatch-btn${B===S?" active":""}`,style:{"--w6w-canvas-color":B},"data-testid":`${V}-option`,"data-color":B,onClick:()=>{g(null),B!==S&&P(B)}},B)),n.jsx("label",{className:"w6w-note-swatch-btn w6w-note-swatch-custom",title:"Custom",children:n.jsx("input",{type:"color","aria-label":`Custom ${U} colour`,"data-testid":`${V}-input`,value:S,onChange:B=>P(B.currentTarget.value)})})]}),te=S=>{S.target.closest("input")||S.preventDefault()};return dn.createPortal(n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:`w6w-canvas-layer w6w-canvas-sections${ne}`,style:{zIndex:La},"data-testid":"w6w-canvas-sections",children:[C.map(S=>n.jsx("div",{className:`w6w-canvas-section${p===S.id?" selected":""}`,style:R(S),"data-section-id":S.id,"data-testid":"section",children:k&&n.jsx("div",{className:`w6w-note-resize ${oe}`,"data-testid":"section-resize",onPointerDown:U=>G(U,S,"section","resize")})},S.id)),C.map(S=>(L==null?void 0:L.id)===S.id?null:n.jsx("div",{className:`w6w-canvas-section-title${k?` editable ${oe}`:""}`,style:q(S,Wa),"data-section-label":S.id,"data-testid":"section-label",title:k?"Click to edit · drag to move":void 0,onPointerDown:k?U=>{M(S.id),G(U,S,"section","move")}:void 0,children:S.title||(k?"Untitled section":"")},S.id))]}),n.jsx("div",{className:`w6w-canvas-layer w6w-canvas-notes${ne}`,style:{zIndex:Fa},"data-testid":"w6w-canvas-notes",children:v.map(S=>{const U=k&&b===S.id;return n.jsxs("div",{className:`w6w-canvas-note${d===S.id?" selected":""}`,style:R(S),"data-note-id":S.id,"data-testid":"note",children:[U?n.jsx("div",{ref:H(S),className:`w6w-canvas-note-body w6w-canvas-note-editor ${oe}`,contentEditable:!0,suppressContentEditableWarning:!0,role:"textbox",tabIndex:0,"aria-multiline":"true","aria-label":"Note content","data-testid":"note-content",onPointerDown:Hn,onBlur:()=>{O(S.id),N.current=null,m(null)},onKeyDown:V=>{V.key==="Escape"&&V.currentTarget.blur()},onPaste:V=>{V.preventDefault(),document.execCommand("insertText",!1,V.clipboardData.getData("text/plain"))}},"editor"):n.jsx("div",{className:`w6w-canvas-note-body ${oe}`,"data-testid":"note-view",style:k?{cursor:"grab",touchAction:"none"}:void 0,onPointerDown:k?V=>{I(S.id),G(V,S,"note","move")}:void 0,onDoubleClick:k?()=>D(S.id):void 0,children:S.content.trim()?n.jsx(xs,{content:_a(S.content)}):k&&n.jsx("span",{className:"w6w-canvas-note-empty",children:"Double-click to write"})},"view"),k&&n.jsx("div",{className:`w6w-note-resize ${oe}`,"data-testid":"note-resize",onPointerDown:V=>G(V,S,"note","resize")})]},S.id)})}),L&&n.jsx("div",{className:`w6w-canvas-layer${ne}`,style:{zIndex:fo},"data-testid":"w6w-canvas-overlay",children:n.jsxs("div",{className:`w6w-note-toolbar w6w-section-toolbar ${oe}`,role:"toolbar","aria-label":"Section","data-testid":"section-toolbar","data-section-toolbar":L.id,style:q(L,ho),onPointerDown:Hn,onMouseDown:te,children:[n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-grip","aria-label":"Move section",title:"Drag to move","data-testid":"section-drag",onPointerDown:S=>G(S,L,"section","move"),children:n.jsx(ue.Icon,{name:"grip"})}),n.jsx("input",{type:"text",className:"w6w-section-title-input","aria-label":"Section title",placeholder:"Untitled section","data-testid":"section-title",defaultValue:L.title,size:Math.max(8,Math.min(32,L.title.length+1)),onBlur:S=>{const U=S.currentTarget.value;U!==L.title&&T(L.id,{title:U})},onKeyDown:S=>{(S.key==="Enter"||S.key==="Escape")&&S.currentTarget.blur()}},`${L.id}:${L.title}`),n.jsx("span",{className:"w6w-note-toolbar-sep"}),n.jsxs("div",{className:"w6w-note-toolbar-group",children:[n.jsxs("button",{type:"button",className:`w6w-icon-btn${x==="color"?" active":""}`,"aria-label":"Section colour","aria-expanded":x==="color",title:"Colour","data-testid":"section-color",onClick:()=>g(x==="color"?null:"color"),children:[n.jsx("span",{className:"w6w-note-swatch"}),n.jsx(ue.Icon,{name:"chevron-down",size:12})]}),x==="color"&&J(L.color,"section","section-color",S=>T(L.id,{color:S}))]}),n.jsx("span",{className:"w6w-note-toolbar-sep"}),n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-delete","aria-label":"Delete section",title:"Delete section","data-testid":"section-delete",onClick:()=>{g(null),l==null||l("section",L.id)},children:n.jsx(ue.Icon,{name:"trash"})})]})}),X&&n.jsx("div",{className:`w6w-canvas-layer${ne}`,style:{zIndex:fo},"data-testid":"w6w-canvas-overlay",children:n.jsxs("div",{className:`w6w-note-toolbar ${oe}`,role:"toolbar","aria-label":"Note","data-testid":"note-toolbar","data-note-toolbar":X.id,style:Z(X),onPointerDown:Hn,onMouseDown:te,children:[n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-grip","aria-label":"Move note",title:"Drag to move","data-testid":"note-drag",onPointerDown:S=>G(S,X,"note","move"),children:n.jsx(ue.Icon,{name:"grip"})}),n.jsx("span",{className:"w6w-note-toolbar-sep"}),n.jsxs("div",{className:"w6w-note-toolbar-group",children:[n.jsxs("button",{type:"button",className:`w6w-icon-btn${x==="color"?" active":""}`,"aria-label":"Note colour","aria-expanded":x==="color",title:"Colour","data-testid":"note-color",onClick:()=>g(x==="color"?null:"color"),children:[n.jsx("span",{className:"w6w-note-swatch"}),n.jsx(ue.Icon,{name:"chevron-down",size:12})]}),x==="color"&&J(X.color,"note","note-color",S=>F(X.id,{color:S}))]}),n.jsx("span",{className:"w6w-note-toolbar-sep"}),n.jsxs("div",{className:"w6w-note-toolbar-group",children:[n.jsxs("button",{type:"button",className:`w6w-icon-btn w6w-note-size-btn${x==="size"?" active":""}`,"aria-label":"Text size","aria-expanded":x==="size",title:"Text size","data-testid":"note-size",onClick:()=>g(x==="size"?null:"size"),children:["Aa",n.jsx(ue.Icon,{name:"chevron-down",size:12})]}),x==="size"&&n.jsx("div",{className:"w6w-note-menu w6w-note-menu-sizes",role:"menu",children:Da.map(S=>n.jsx("button",{type:"button",role:"menuitem",className:`w6w-note-menu-item w6w-note-size-${S.level}`,"data-testid":`note-size-${S.level}`,onClick:()=>Y(X.id,"formatBlock",S.level?`<h${S.level}>`:"<div>"),children:S.label},S.level))})]}),n.jsx("button",{type:"button",className:"w6w-icon-btn","aria-label":"Bold",title:"Bold","data-testid":"note-bold",onClick:()=>Y(X.id,"bold"),children:n.jsx(ue.Icon,{name:"bold"})}),n.jsx("span",{className:"w6w-note-toolbar-sep"}),n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-note-delete","aria-label":"Delete note",title:"Delete note","data-testid":"note-delete",onClick:()=>{g(null),l==null||l("note",X.id)},children:n.jsx(ue.Icon,{name:"trash"})})]})})]}),s)}function Va(e){const t=qn.useStore(o=>{var r;return((r=o.domNode)==null?void 0:r.querySelector(".react-flow__viewport"))??null}),s=qn.useStore(o=>o.transform[2]);return n.jsx(Zo,{...e,zoom:e.zoom??s,viewport:t})}function za(e){return e.viewport!==void 0?n.jsx(Zo,{...e,viewport:e.viewport}):n.jsx(Va,{...e})}const vs={"&":{fontSize:"13px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",backgroundColor:"var(--w6w-panel-2)",color:"var(--w6w-text)",border:"1px solid var(--w6w-border)",borderRadius:"8px"},"&.cm-focused":{outline:"none",borderColor:"var(--w6w-accent)"},".cm-gutters":{backgroundColor:"var(--w6w-panel)",color:"var(--w6w-muted)",border:"none",borderRight:"1px solid var(--w6w-border)"},".cm-scroller":{overflow:"auto",borderRadius:"7px"},".cm-content":{paddingTop:"var(--w6w-sp-2)",paddingBottom:"var(--w6w-sp-2)"},".cm-line":{paddingLeft:"var(--w6w-sp-2)"}};function Ja(){let e,t=0,s=!1;const o=new Map,r=()=>{e==null||e.terminate(),e=void 0;for(const a of o.values())a([]);o.clear()},i=async a=>{const l=a.matchBefore(/[\w$]*/);if(s||!l||!a.explicit&&l.from===l.to&&a.state.sliceDoc(a.pos-1,a.pos)!==".")return null;e||(e=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/script-completion.worker-DDJKkj5M.js").href:new URL("assets/script-completion.worker-DDJKkj5M.js",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:_n&&_n.tagName.toUpperCase()==="SCRIPT"&&_n.src||new URL("connection-app-meta-BEXlKBgV.cjs",document.baseURI).href),{type:"module"}),e.onmessage=u=>{var d;(d=o.get(u.data.id))==null||d(u.data.options),o.delete(u.data.id)},e.onerror=r);const c=await new Promise(u=>{const d=++t;o.set(d,u),a.addEventListener("abort",()=>{o.delete(d),u([])},{onDocChange:!0}),e==null||e.postMessage({id:d,code:a.state.doc.toString(),position:a.pos})});return a.aborted||!c.length?null:{from:l.from,options:c}};return[Un.javascriptLanguage.data.of({autocomplete:i}),us.ViewPlugin.define(()=>(s=!1,{destroy(){s=!0,r()}}))]}function Ka(e){switch(e){case"javascript":return Un.javascript();case"typescript":return Un.javascript({typescript:!0});case"python":return Pi.python()}}function js(e){const t=yn(e.theme),s=w.useMemo(()=>[...e.language?[Ka(e.language)]:[],...e.language==="javascript"||e.language==="typescript"?[Ja()]:[],us.EditorView.theme(vs)],[e.language]);return n.jsx("div",{className:"w6w-code-editor","aria-label":e["aria-label"]??"Code editor",children:n.jsx(Wo,{value:e.value,onChange:e.onChange,extensions:s,placeholder:e.placeholder,readOnly:e.readOnly,theme:t,height:e.height,minHeight:e.minHeight??"160px",maxHeight:e.maxHeight,onCreateEditor:e.onCreateEditor,basicSetup:{lineNumbers:!0,foldGutter:!1,highlightActiveLine:!e.readOnly,bracketMatching:!0,closeBrackets:!0}})})}function Ga(){const e=Bo.jsonParseLinter();return t=>t.state.doc.toString().trim()===""?[]:e(t)}function lt(e){const t=yn(e.theme),{copied:s,copy:o}=ue.useCopyToClipboard(e.value),r=w.useMemo(()=>[Bo.json(),...e.showDiagnostics===!1?[]:[oo.linter(Ga()),oo.lintGutter()],us.EditorView.theme(vs)],[e.showDiagnostics]);function i(a){var l,c,u,d;if(e.onChange(a),!(!e.onValidChange&&!e.onValidityChange)){if(a.trim().length===0){(l=e.onValidityChange)==null||l.call(e,{valid:!1,error:"Empty"});return}try{const f=JSON.parse(a);(c=e.onValidChange)==null||c.call(e,f),(u=e.onValidityChange)==null||u.call(e,{valid:!0})}catch(f){(d=e.onValidityChange)==null||d.call(e,{valid:!1,error:f.message})}}}return n.jsxs("div",{className:"w6w-json-editor","aria-label":e["aria-label"]??"JSON editor",children:[n.jsx(Wo,{value:e.value,onChange:i,extensions:r,placeholder:e.placeholder,readOnly:e.readOnly,editable:!e.readOnly,theme:t,height:e.height,minHeight:e.minHeight??"240px",maxHeight:e.maxHeight,onCreateEditor:e.onCreateEditor,onBlur:e.onBlur,onFocus:e.onFocus,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!e.readOnly,autocompletion:!0,bracketMatching:!0,closeBrackets:!0}}),e.overlay,e.copyable&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:`w6w-icon-btn w6w-copyable-btn${s?" is-copied":""}`,"aria-label":"Copy",onClick:()=>void o(),children:s?n.jsx(ue.CheckGlyph,{}):n.jsx(ue.CopyGlyph,{})}),n.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:s?"Copied":""})]})]})}function Qo(e,t,s){return e*t>.6*s}function er(e,t){const s=t.trim().toLowerCase();return s?e.filter(o=>o.label.toLowerCase().includes(s)||o.value.toLowerCase().includes(s)):e}const Ya=240,Xa={display:"block",fontSize:"0.85em",opacity:.65,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Za={position:"absolute",zIndex:50,left:0,right:0,top:"100%",overflowY:"auto",overscrollBehavior:"contain",margin:0,padding:4,listStyle:"none",background:"var(--w6w-panel)",color:"var(--w6w-text)",border:"1px solid var(--w6w-border)",borderRadius:6,boxShadow:"0 4px 12px rgba(0,0,0,0.15)"};function kt({options:e,value:t,onChange:s,placeholder:o,disabled:r,"aria-label":i,mode:a="auto",forceSelection:l=!0,optionHeight:c=32,listMaxHeight:u=Ya,className:d,onInputChange:f,emptyText:p="No matches",footer:h}){var Y;const b=a==="combobox"||a==="auto"&&Qo(e.length,c,typeof window>"u"?0:window.innerHeight),m=w.useId(),x=((Y=e.find($=>$.value===t))==null?void 0:Y.label)??(l?"":t),[g,y]=w.useState(x),[N,A]=w.useState(!1),[k,C]=w.useState(!1),[v,E]=w.useState(0),R=w.useRef(null);w.useEffect(()=>{y(x)},[x]);const F=w.useMemo(()=>k?er(e,g):e,[e,g,k]),T=w.useMemo(()=>({...Za,maxHeight:u}),[u]);if(!b)return n.jsxs("select",{className:d,value:t,disabled:r,"aria-label":i,onChange:$=>s($.target.value),children:[o!==void 0&&t===""&&n.jsx("option",{value:"",disabled:!0,children:o}),e.map($=>n.jsx("option",{value:$.value,children:$.label},$.value))]});const O=$=>`${m}-opt-${$}`,I=()=>{A(!1),C(!1)},M=$=>{y($.label),s($.value),I()},D=$=>{$.key==="ArrowDown"?($.preventDefault(),N?E(G=>Math.min(G+1,F.length-1)):A(!0)):$.key==="ArrowUp"?($.preventDefault(),N?E(G=>Math.max(G-1,0)):A(!0)):$.key==="Enter"?N&&F[v]?($.preventDefault(),M(F[v])):l||(g!==x&&s(g),I()):$.key==="Escape"&&(N&&$.stopPropagation(),y(x),I())},H=()=>{l?y(x):g!==x&&s(g),I()};return n.jsxs("div",{ref:R,className:"w6w-combobox",style:{position:"relative"},children:[n.jsx("input",{type:"text",role:"combobox",className:d,value:g,disabled:r,placeholder:o,"aria-label":i,"aria-expanded":N,"aria-controls":`${m}-list`,"aria-autocomplete":"list","aria-activedescendant":N&&F[v]?O(v):void 0,autoComplete:"off",onFocus:()=>A(!0),onChange:$=>{y($.target.value),f==null||f($.target.value),C(!0),E(0),A(!0)},onKeyDown:D,onBlur:H}),N&&n.jsxs("div",{id:`${m}-list`,role:"listbox",tabIndex:-1,"aria-label":i,style:T,children:[F.map(($,G)=>n.jsxs("div",{id:O(G),role:"option",tabIndex:-1,"aria-selected":$.value===t,style:{padding:"6px 8px",cursor:"pointer",borderRadius:4,background:G===v?"var(--w6w-panel-2)":void 0},onMouseDown:ne=>{ne.preventDefault(),M($)},onMouseEnter:()=>E(G),children:[$.label,$.detail!==void 0&&n.jsx("span",{className:"w6w-combobox-detail",style:Xa,children:$.detail})]},$.value)),F.length===0&&n.jsx("div",{role:"presentation",style:{padding:"6px 8px",opacity:.6},children:p}),h!==void 0&&n.jsx("div",{role:"presentation",className:"w6w-combobox-footer",style:{padding:"6px 8px",opacity:.6,fontSize:"0.85em"},children:h})]})]})}function xn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.source==="resolveFields"}function qe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.type==="expr"&&Array.isArray(e.parts)}function Ze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.type==="secret"&&typeof e.ciphertext=="string"&&typeof e.iv=="string"}function mo(e){return e.kind==="text"?{kind:"text",value:e.value??""}:e.kind==="expr"?{kind:"expr",expr:e.expr}:{kind:e.kind,ref:e.ref??""}}function nn(e){const t=e.filter(o=>o.kind!=="text"||(o.value??"")!=="");if(t.length===0)return"";if(t.some(o=>o.kind==="render"))return{type:"expr",parts:t.map(mo)};let s="";for(const o of t){if(o.kind==="text"){s+=o.value??"";continue}Qa(s)%2===1&&(s+="\\"),s+=ie.serializeTemplate([mo(o)])}return s}function Qa(e){let t=0;for(;t<e.length&&e[e.length-1-t]==="\\";)t+=1;return t}const tr={var:!0,vars:!0,state:!0,steps:!0,nodes:!0,trigger:!0,foreach:!0,inputs:!0,output:!0,secrets:!0,documents:!0,const:!0};Object.freeze(Object.keys(tr));const wo=e=>Object.prototype.hasOwnProperty.call(tr,e),bo=["state","var","vars"];function nr(e){for(const t of bo)if(e===t||e.startsWith(`${t}.`)){const s=e.slice(t.length);return[...new Set([e,...bo.map(o=>o+s)])]}return[e]}function go(e){const t=e.indexOf(".");return t===-1?e:e.slice(0,t)}function Xe(e){const t=ie.parseTemplate(e,"editor",el);return t.every(vn)?t:[{kind:"text",value:e}]}function vn(e){if(e.kind==="var"){const t=e.ref??"";return!ie.hasRefusedChainToken(t)&&wo(go(t))}if(e.kind==="expr"){const t=ie.coalesceOperandRefs(e.expr);return t===null?!0:t.every(s=>wo(go(s)))}return!0}const el={isOurs:vn,backslash:"keep"},sr={isOurs:vn,backslash:"strip"};function ct(e){return qe(e)?!0:typeof e=="string"&&e.includes("{{")&&Xe(e).some(t=>t.kind!=="text")}function jn(e){if(!e.includes("{{"))return null;const t=ie.parseTemplate(e,"editor",sr);return t.every(vn)&&(t.some(s=>s.kind!=="text")||t.map(s=>s.value??"").join("")!==e)?t:null}function tl(e){return e.includes("{{")?ie.parseTemplate(e,"editor",sr).map(t=>t.kind==="text"?t.value??"":ie.serializeTemplate([t])).join(""):e}function Vn(e){if(Ze(e))return{parts:[],sealed:e};if(qe(e))return{parts:e.parts.map(s=>({...s})),sealed:null};const t=typeof e=="string"?e:"";return{parts:t?Xe(t):[],sealed:null}}function nl(e,t){let s="";for(const o of e)switch(o.kind){case"text":s+=tl(o.value??"");break;case"var":case"render":{const r=nr(o.ref??"").find(i=>i in t);s+=r===void 0?"":t[r];break}case"secret":s+="•••";break;case"expr":s+=ie.serializeTemplate([o]);break}return s}const xt="var.",yo="vars.",zn="documents.",Jn="const.",Kn="state.";function or(e){return e==="state"||e==="vars"?"var":e.startsWith(yo)?xt+e.slice(yo.length):e.startsWith(Kn)?xt+e.slice(Kn.length):e}function sl(e){return e.startsWith(Kn)?3:e.startsWith(xt)?2:1}function rr(e){return e.rank>0?e.value:Object.fromEntries(Array.from(e.children,([t,s])=>[t,rr(s)]))}function Ns(e,t,s,o){const r={children:new Map,rank:0},i={},a={};for(const[b,m]of Object.entries(e??{})){const x=or(b);if(x.startsWith(xt)){const g=x.slice(xt.length),y=sl(b);let N=r;for(const A of g.split(".")){let k=N.children.get(A);k||(k={children:new Map,rank:0},N.children.set(A,k)),N=k}y>=N.rank&&(N.value=m,N.rank=y)}else x.startsWith(zn)?i[x.slice(zn.length)]=m:x.startsWith(Jn)&&(a[x.slice(Jn.length)]=m)}const l=rr(r),c=(t==null?void 0:t.steps)??{},u=e??{},d=Object.hasOwn(u,"foreach.item"),f=typeof u["foreach.index"]=="number",p=t==null?void 0:t.foreach,h=p?{...p}:d||f?{...d?{item:u["foreach.item"]}:{},...f?{index:u["foreach.index"]}:{}}:void 0;return{...h?{foreach:h}:{},vars:l,state:l,documents:i,constants:a,steps:c,nodes:c,trigger:(t==null?void 0:t.trigger)??{},flat:e??{},...s?{config:s}:{},...o?{meta:o}:{}}}function ol(e,t){const s=t.split(".");let o=e;for(const r of s){if(o===null||typeof o!="object")return{present:!1,value:void 0};if(!(r in o))return{present:!1,value:void 0};o=o[r]}return{present:!0,value:o}}const rl=/^(?:nodes|steps)\.[^.]+\.(?:meta\.)?config(?:\.|$)/,il=/^(?:nodes|steps)\.([^.]+)\.meta(?:\.|$)/;function al(e,t,s){var r;if(!t&&!s)return e;const o={...e};for(const i of new Set([...Object.keys(s??{}),...Object.keys(t??{})])){const a=t==null?void 0:t[i];o[i]={...e[i],meta:{...s==null?void 0:s[i],...(r=e[i])==null?void 0:r.meta,...a?{config:a}:{}},...a?{config:a}:{}}}return o}function ir(e,t){var p;const s=or(e);if(t.flat&&(s.startsWith(xt)||s.startsWith(zn)||s.startsWith(Jn))){const h=nr(e).find(b=>Object.hasOwn(t.flat,b));if(h!==void 0)return{status:"resolved",ref:e,value:t.flat[h]}}const{vars:o,constants:r,config:i,meta:a,...l}=t,c=al(t.nodes??t.steps,i,a),u={...l,var:o,...r?{const:r}:{},nodes:c,steps:c},d=ol(u,s);if(d.present)return{status:"resolved",ref:e,value:d.value};if(rl.test(s))return{status:"at-run",ref:e};const f=(p=il.exec(s))==null?void 0:p[1];return f!==void 0&&(a!=null&&a[f])?{status:"at-run",ref:e}:{status:"unresolved",ref:e}}function xo(e,t){switch(e.kind){case"text":return{status:"resolved",value:e.value??""};case"var":return ir(e.ref??"",t);case"secret":return{status:"masked",ref:e.ref};case"expr":return{status:"not-evaluated"};case"render":return{status:"not-evaluated"};default:return{status:"resolved",value:void 0}}}function ks(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1&&"$"in e}function Ss(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1&&"$expr"in e}function Cs(e,t){if(Ze(e))return[{status:"masked"}];if(qe(e))return e.parts.map(s=>xo(s,t));if(typeof e=="string"){const s=jn(e);if(s)return s.map(o=>xo(o,t))}return ks(e)?[ir(String(e.$),t)]:Ss(e)?[{status:"not-evaluated"}]:[{status:"resolved",value:e}]}function Gn(e,t){if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null||typeof e!="object")return!1;const s=Array.isArray(e),o=Array.isArray(t);if(s!==o)return!1;if(s){const c=e,u=t;return c.length===u.length&&c.every((d,f)=>Gn(d,u[f]))}const r=e,i=t,a=Object.keys(r),l=Object.keys(i);return a.length===l.length&&a.every(c=>c in i&&Gn(r[c],i[c]))}function ar(e){switch(e.status){case"resolved":return e.value===void 0?"<not set>":e.value;case"unresolved":return`<unresolved: ${e.ref}>`;case"at-run":return`<resolved at run: ${e.ref}>`;case"not-evaluated":return"<not evaluated>";case"masked":return e.ref?`<masked: ${e.ref}>`:"<masked>"}}function ll(e){return e.status==="resolved"&&e.value!==void 0?typeof e.value=="string"?e.value:JSON.stringify(e.value):String(ar(e))}function cl(e){return e.length===1?ar(e[0]):e.map(ll).join("")}function Dt(e,t){return cl(Cs(e,t))}function ul(e,t){const s={};for(const o of e)s[o.key||"(no key)"]=Dt(o.value,t);return s}const Nn=w.forwardRef(function(t,s){const{label:o,children:r,icon:i,iconSize:a,title:l,onClick:c,disabled:u,className:d,danger:f,...p}=t,h=r??(i?n.jsx(ue.Icon,{name:i,size:a??16}):null);return n.jsx("button",{ref:s,type:"button",className:["w6w-icon-button",f?"w6w-icon-button-danger":"",d??""].filter(Boolean).join(" "),title:l??o,"aria-label":o,"aria-pressed":p["aria-pressed"],"aria-expanded":p["aria-expanded"],"aria-controls":p["aria-controls"],disabled:u,onClick:c,"data-testid":p["data-testid"],children:h})});Nn.displayName="IconButton";const dl={default:"",wide:" w6w-modal-wide",xl:" w6w-modal-xl",full:" w6w-modal-full",fullscreen:" w6w-modal-fullscreen"};function Se({title:e,ariaLabel:t,onClose:s,children:o,size:r="default",titleIcon:i,subtitle:a,headerRight:l}){const c=w.useRef(null);return w.useEffect(()=>{const u=c.current;if(!u)return;u.open||u.showModal();const d=p=>{p.preventDefault(),s()},f=p=>{if(p.target!==u)return;const h=u.getBoundingClientRect();(p.clientX<h.left||p.clientX>h.right||p.clientY<h.top||p.clientY>h.bottom)&&s()};return u.addEventListener("cancel",d),u.addEventListener("click",f),()=>{u.removeEventListener("cancel",d),u.removeEventListener("click",f)}},[s]),n.jsx("div",{className:"w6w-modal-backdrop",children:n.jsxs("dialog",{ref:c,className:`w6w-modal${dl[r]}`,"aria-label":t??(typeof e=="string"?e:void 0),children:[n.jsxs("div",{className:"w6w-modal-header",children:[n.jsxs("h3",{className:"w6w-modal-title",children:[i,n.jsx("span",{children:e}),a&&n.jsx("span",{className:"w6w-modal-subtitle",children:a})]}),l]}),o]})})}const As=new Set(["nodes","steps","state","var","vars","const","inputs","output","trigger","foreach","documents"]),pl=/[=<>]|!=|&&|\|\||\?\?/,sn=e=>pl.test(e)||/^\s*\(*\s*!/.test(e),vo=e=>ie.expressionReferences(e).some(sn);function fl(e,t){var i,a,l;const[s,...o]=e.split(".");if(s==="secrets")throw new Error("Secrets can be inserted into text, but cannot be used in comparisons.");if(As.has(s))return e;const r=[...(i=t.steps)!=null&&i.some(c=>c.id===s)?[`nodes.${s}.output`]:[],...(a=t.vars)!=null&&a.includes(s)?[`var.${s}`]:[],...(l=t.constants)!=null&&l.includes(s)?[`const.${s}`]:[]];if(r.length>1)throw new Error(`“${s}” is ambiguous. Select the field from the sources.`);if(r.length===0)throw new Error(`Unknown field “${s}”. Select a source, or put text values in quotes.`);return[r[0],...o].join(".")}function Rt(e,t){var u,d,f,p,h;const s={parts:e,error:null},o=e.flatMap(b=>b.kind==="text"?Xe(b.value??""):[b]);if(o.some(b=>b.kind==="render"))return s;if(o.length===1&&o[0].kind==="expr"&&!vo(o[0].expr))return{parts:o,error:null};let r=o.map(b=>{if(b.kind==="text")return b.value??"";if(b.kind==="secret")return`{{ secrets.${b.ref??""} }}`;if(b.kind==="expr"){if(vo(b.expr)){const x=ie.serializeTemplate([b]);if(!x.startsWith("{{ ="))return`(${x.slice(2,-2).trim()})`}const m=ie.formatReadableExpression(b.expr);return m===null?ie.serializeTemplate([b]):`(${m})`}return sn(b.ref??"")?b.ref??"":`{{ ${b.ref??""} }}`}).join("").trim();if(!sn(r))return s;const i=/^\{\{([^{}]+)\}\}$/.exec(r);i&&sn(i[1])&&(r=i[1].trim());const a=r.replace(/^[\s(!]+/,""),l=(u=/^(?:\{\{\s*)?([A-Za-z_$][\w$-]*)/.exec(a))==null?void 0:u[1],c=a.startsWith("{{")||l!==void 0&&(As.has(l)||l==="secrets"||((d=t.steps)==null?void 0:d.some(b=>b.id===l))||((f=t.vars)==null?void 0:f.includes(l))||((p=t.constants)==null?void 0:p.includes(l)));if(!c&&!/^(?:["']|-?\d|true\b|false\b|null\b)/.test(a))return s;if(c&&!/^\s*\(*\s*!/.test(r)){const b=(h=/^(?:\{\{[^{}]+\}\}|[A-Za-z_$][\w$-]*(?:\.[\w$-]+)*)/.exec(a))==null?void 0:h[0];if(b){const m=a.slice(b.length).replace(/^[\s)]+/,"");if(!/^(?:[=<>(]|!=|&&|\|\||\?\?)/.test(m)||/^<\/?[A-Za-z][^>]*>/.test(m))return s}}try{return{parts:[{kind:"expr",expr:ie.parseReadableExpression(r,m=>fl(m,t))}],error:null}}catch(b){return{parts:o,error:b instanceof Error?b.message:"Check the expression."}}}function hl(e){return[...new Set(e.flatMap(t=>t.kind==="expr"?ie.expressionReferences(t.expr):(t.kind==="var"||t.kind==="render")&&t.ref?[t.ref]:[]))]}function ml(e){return e.replace(/^(?:vars|state)(?=\.|$)/,"var").replace(/^steps(?=\.|$)/,"nodes")}function wl(e){const t=Object.create(null);for(const[s,o]of Object.entries(e).sort(([r],[i])=>r.split(".").length-i.split(".").length)){const r=ml(s).split(".");if(!As.has(r[0])||r.some(a=>["__proto__","constructor","prototype"].includes(a)))continue;let i=t;for(const a of r.slice(0,-1)){const l=i[a],c=l&&typeof l=="object"?{...l}:{};i[a]=c,i=c}i[r[r.length-1]]=o}return t.steps=t.nodes,t.vars=t.var,t.state=t.var,t}function bl(e,t={},s={}){const o={...t};for(const[a,l]of Object.entries(s))try{o[a]=JSON.parse(l)}catch{o[a]=l}const r=wl(o),i=Object.fromEntries(Object.entries(o).map(([a,l])=>[a,typeof l=="string"?l:JSON.stringify(l)]));return e.map(a=>{if(a.kind!=="expr"||ie.formatReadableExpression(a.expr)===null)return nl([a],i);if(ie.expressionReferences(a.expr).some(u=>!u||u.split(".")[0]==="secrets"))return"••••";const c=ie.evaluate(a.expr,r);return typeof c=="string"?c:JSON.stringify(c)??""}).join("")}const gl=/^(?:nodes|steps)\.([^.]+)\.output(?:\.(.+))?$/,yl=/^(?:nodes|steps)\.([^.]+)\.meta\.(app|version|action|connectionId)$/,Ge=e=>{if(e.startsWith("var."))return e.slice(4);if(e.startsWith("vars."))return e.slice(5);if(e.startsWith("const."))return e.slice(6);const t=gl.exec(e);if(t)return t[2]?`${t[1]}.${t[2]}`:t[1];const s=yl.exec(e);return s?`${s[1]} meta · ${s[2]}`:e};function xl(e){if(e===null||typeof e!="object"||Array.isArray(e))return;const t=Object.keys(e);if(t.length!==1||t[0]!=="var")return;const s=e.var;return typeof s=="string"?s:void 0}function vl(e){const t=e.op==="or"?"||":"??",s=e.operands.map(o=>{const r=xl(o);return r!==void 0?Ge(r):JSON.stringify(o)}).join(` ${t} `);return s.length>40?`${s.slice(0,40)}…`:s}const jl=/[.{}]/;function wt(e){return e===""||e!==e.trim()?!1:!jl.test(e)}function Xt(e){return e.split(".").every(wt)}function jo(e){const t=new Set(e.filter(s=>s.path).map(s=>s.key));return e.map(s=>{if(!s.path)return{field:s,depth:0,name:s.key};const o=s.key.split(".");let r=0,i=0;for(let a=1;a<o.length;a++)t.has(o.slice(0,a).join("."))&&(r++,i=a);return{field:s,depth:r,name:o.slice(i).join(".")}})}function It(e,t,{renderToggle:s}={}){const o=e.createElement("span");o.contentEditable="false",o.className=`w6w-expr-chip w6w-expr-chip-${t.kind}`,o.setAttribute("data-kind",t.kind);const r=e.createElement("span");r.className="w6w-expr-chip-sigil";const i=e.createElement("span");if(i.className="w6w-expr-chip-label",t.kind==="var")o.setAttribute("data-ref",t.ref??""),r.textContent="◆",i.textContent=Ge(t.ref??""),o.title=`Variable: ${t.ref??""}`;else if(t.kind==="render")o.setAttribute("data-ref",t.ref??""),r.textContent="▤",i.textContent=Ge(t.ref??""),o.title=`Render as template: ${t.ref??""}`;else if(t.kind==="secret")o.setAttribute("data-ref",t.ref??""),r.textContent="🔒",i.textContent=t.ref??"",o.title=`Secret: ${t.ref??""}`;else{const l=typeof t.expr=="string"?t.expr:JSON.stringify(t.expr??"");o.setAttribute("data-expr",l),r.textContent="ƒ";const c=ie.parseCoalesceChain(t.expr);if(c)i.textContent=vl(c),o.title=`Expression: ${ie.serializeTemplate([t])}`;else{const u=ie.formatReadableExpression(t.expr,Ge);i.textContent=u??(l.length>24?`${l.slice(0,24)}…`:l||"expr"),o.title=`Expression: ${u??l}`}}if(o.append(r,i),(t.kind==="var"||t.kind==="render")&&s){const l=e.createElement("span");l.className="w6w-expr-chip-toggle",l.setAttribute("data-render-toggle","1"),l.setAttribute("role","button");const c=t.kind==="render"?"Stop rendering as a template":"Render this as a template";l.setAttribute("aria-label",c),l.title=c,l.textContent="⇄",o.append(l)}const a=e.createElement("span");return a.className="w6w-expr-chip-x",a.setAttribute("data-x","1"),a.setAttribute("role","button"),a.setAttribute("aria-label","Remove"),a.textContent="×",o.append(a),o}const lr=new Set(["div","p"]);function cr(e){const t=e.getAttribute("data-kind");if(t==="var"||t==="secret"||t==="render")return{kind:t,ref:e.getAttribute("data-ref")??""};if(t==="expr"){const s=e.getAttribute("data-expr")??"";let o=s;try{o=JSON.parse(s)}catch{o=s}return{kind:"expr",expr:o}}return null}function Tt(e){const t=[],s=i=>{if(!i)return;const a=t[t.length-1];a&&a.kind==="text"?a.value=(a.value??"")+i:t.push({kind:"text",value:i})},o=(i,a)=>{if(i.nodeType===Node.TEXT_NODE){s(i.textContent??"");return}if(i.nodeType!==Node.ELEMENT_NODE)return;const l=i,c=cr(l);if(c){t.push(c);return}const u=(l.tagName??"").toLowerCase();if(u==="br"){a||s(`
6
+ `);return}const d=lr.has(u);d&&t.length>0&&s(`
7
+ `),r(l,d)},r=(i,a)=>{const l=Array.from(i.childNodes);l.forEach((c,u)=>o(c,a&&u===l.length-1))};return r(e,!0),t}const ur=e=>!!e&&(e.tagName??"").toLowerCase()==="br";function dr(e){ur(e.lastChild)||e.appendChild(e.ownerDocument.createElement("br"))}function Nl(e){const t=e.ownerDocument.getSelection(),s=t!=null&&t.rangeCount?t.getRangeAt(0):null;if(!s||!e.contains(s.endContainer))return e;let o=s.endContainer;for(;o&&o!==e;){if(o.nodeType===Node.ELEMENT_NODE){const r=o;if(lr.has((r.tagName??"").toLowerCase()))return r}o=o.parentNode}return e}function pr(e){dr(Nl(e))}const kl=e=>e.getAttribute("aria-multiline")!=="false";function fr(e,t,s){var i;const o=e.ownerDocument;e.textContent="";for(const a of t)a.kind==="text"?a.value&&e.appendChild(o.createTextNode(a.value)):e.appendChild(It(o,a,s));const r=t[t.length-1];(r==null?void 0:r.kind)==="text"&&((i=r.value)!=null&&i.endsWith(`
8
+ `))&&kl(e)&&dr(e)}function Es(e){const t=e.ownerDocument.getSelection();if(!t)return;const s=e.ownerDocument.createRange();s.selectNodeContents(e),s.collapse(!1),t.removeAllRanges(),t.addRange(s)}function Ot(e,t){const s=e.ownerDocument,o=s.getSelection(),r=o!=null&&o.rangeCount?o.getRangeAt(0):null;if(r&&e.contains(r.commonAncestorContainer)){r.deleteContents(),r.insertNode(t);const i=s.createRange();i.setStartAfter(t),i.collapse(!0),o==null||o.removeAllRanges(),o==null||o.addRange(i)}else ur(e.lastChild)?e.insertBefore(t,e.lastChild):e.appendChild(t),Es(e);e.focus()}function hr(e,t={}){const s=e.ownerDocument,o=s.getSelection();if(!o||o.rangeCount===0||!o.isCollapsed)return!1;const r=o.getRangeAt(0),i=r.startContainer;if(i.nodeType!==Node.TEXT_NODE||!e.contains(i))return!1;const a=r.startOffset,l=i.textContent??"";if(a<2||l.slice(a-2,a)!=="}}")return!1;const c=l.lastIndexOf("{{",a-2);if(c===-1)return!1;const u=l.slice(c,a),d=Xe(u);if(d.length!==1||d[0].kind==="text")return!1;let f=0;for(;c-1-f>=0&&l[c-1-f]==="\\";)f+=1;if(f%2===1)return!1;const p=s.createRange();p.setStart(i,c),p.setEnd(i,a),p.deleteContents();const h=It(s,d[0],t);p.insertNode(h);const b=s.createRange();return b.setStartAfter(h),b.collapse(!0),o.removeAllRanges(),o.addRange(b),!0}function mr(e){const t=cr(e);if(!t)return null;const s=t.kind==="expr"&&!ie.parseCoalesceChain(t.expr)?ie.formatReadableExpression(t.expr):null,o=e.ownerDocument.createTextNode(s??ie.serializeTemplate([t]));return e.replaceWith(o),o}function Sl(e,t){let s=!1;for(let o=0;o<t&&o<e.length;o++){const r=e[o];if(s&&r==="\\"){o++;continue}r==='"'&&(s=!s)}return s}function Cl(e){const t=e.split(".").filter(o=>o!==""),s=t[t.length-1]??"value";return(s==="output"||s==="meta")&&t.length>=3?s==="meta"?`${t[t.length-2]}_meta`:t[t.length-2]:s}function Al(e,t){const s=[];let o=!1;for(let i=0;i<t&&i<e.length;i++){const a=e[i];if(o){a==="\\"?i++:a==='"'&&(o=!1);continue}a==='"'?o=!0:a==="{"||a==="["?s.push(a):(a==="}"||a==="]")&&s.pop()}const r=s[s.length-1];return r==="{"||r==="["?r:null}function El(e,t){if(!e||!Object.hasOwn(e,t))return t;let s=2;for(;Object.hasOwn(e,`${t}_${s}`);)s++;return`${t}_${s}`}function No(e,t,s,o){var x;const r=o?JSON.stringify(o.value)??"null":"",i=o?JSON.stringify(typeof o.value=="string"?o.value:r).slice(1,-1):`{{ ${s} }}`,a=o?r:JSON.stringify(i),l=(g,y)=>({text:e.slice(0,g)+y+e.slice(g),caret:g+y.length});if(Sl(e,t))return l(t,i);let c,u=!0;try{c=JSON.parse(e)}catch{u=!1}const d=u&&c!==null&&typeof c=="object"&&!Array.isArray(c)?c:null,f=()=>`${JSON.stringify(El(d,Cl(s)))}: ${a}`,p=e.slice(0,t).trimEnd(),h=p[p.length-1],b=e.slice(t).trimStart()[0],m=Al(e,t);if(h===":"||h==="["||h===","&&m==="[")return l(t,a+(h!==":"&&b!==void 0&&b!=="]"?", ":""));if(h==="{"||h===","&&m==="{"){const g=b!==void 0&&b!=="}"?", ":"";return l(t,(h===","?" ":"")+f()+g)}if(u&&(d||Array.isArray(c))){const g=e.lastIndexOf(d?"}":"]"),y=e.slice(0,g).trimEnd(),N=y.endsWith(d?"{":"["),A=d?f():a,k=e.slice(y.length,g);if(k.includes(`
9
+ `)){const E=N?`${k.slice(k.lastIndexOf(`
10
+ `)+1)} `:((x=/^\s*/.exec(y.slice(y.lastIndexOf(`
11
+ `)+1)))==null?void 0:x[0])??"",R=`${N?"":","}
12
+ ${E}${A}`;return{text:y+R+e.slice(y.length),caret:y.length+R.length}}const C=`${N?"":","} ${A} `,v=y.length;return{text:e.slice(0,v)+C+e.slice(g),caret:v+C.length-1}}return l(t,a)}const Rl=/^\{\{\s*((?:var|vars|const|steps|nodes|trigger|foreach|inputs|output|documents)(?:\.[^\s{}]+)?)\s*\}\}$/;function Tl(e){const t=Rl.exec(e.trim());return t?`{{ ${t[1]} }}`:null}function Qe(e){if(typeof e=="string"){if(!e.includes("{{"))return null;const t=Xe(e);return t.length===1&&t[0].kind==="var"?t[0].ref??null:null}return e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===1&&typeof e.$=="string"?e.$:null}function Ol(e){var s;const t={};for(const[o,r]of Object.entries(e??{})){const i=/^(?:steps|nodes)\.([^.]+)\.output$/.exec(o);if(i){t[i[1]]={...t[i[1]],output:r};continue}const a=/^(?:steps|nodes)\.([^.]+)\.meta\.([^.]+)$/.exec(o);if(a){t[s=a[1]]??(t[s]={});const l=t[a[1]];l.meta={...l.meta,[a[2]]:r}}}return{steps:t}}function Yn(e,t){if(typeof e=="string"){const s=jn(e);return s?s.length===1&&s[0].kind==="var"?t({$:s[0].ref}):t({type:"expr",parts:s}):e}if(Array.isArray(e))return e.map(s=>Yn(s,t));if(e!==null&&typeof e=="object"){const s=Object.keys(e);return s.length===1&&s[0]==="$"&&typeof e.$=="string"?t(e):Object.fromEntries(Object.entries(e).map(([o,r])=>[o,Yn(r,t)]))}return e}function Jt({value:e,masked:t,multiline:s,options:o,fieldLabel:r,onSave:i,onClose:a,mode:l,jsonValue:c,onSaveJson:u,whole:d,startingState:f,jsonProblem:p,title:h}){var we;const b=l==="json-binding",m=b&&f===!0,[x,g]=w.useState("ref"),[y,N]=w.useState(()=>c===void 0?"":JSON.stringify(c,null,2)),A=w.useRef(null),k=w.useRef(!1),C=w.useMemo(()=>{if(y.trim()==="")return{ok:!1};try{return{ok:!0,value:JSON.parse(y)}}catch{return{ok:!1}}},[y]),v=m?(p==null?void 0:p(y))??null:null,E=m?(y.trim()===""||C.ok)&&v===null:C.ok,R=()=>Ns(o.sampleValues,Ol(o.sampleValues),o.nodeConfig,o.nodeMeta),F=j=>{const _=A.current,K=_?_.state.doc.toString():y;if(m){const Me=x==="value"?{value:Dt(`{{ ${j} }}`,R())??null}:void 0,so=K.trim()===""?"{}":K,$i=k.current&&_?_.state.selection.main.head:so.length,Pn=No(so,$i,j,Me);if(!_){N(Pn.text);return}_.dispatch({changes:{from:0,to:K.length,insert:Pn.text},selection:{anchor:Pn.caret}}),_.focus();return}let se=null;try{se=K.trim()===""?null:Qe(JSON.parse(K))}catch{se=null}let pe=!1;if(d)try{const Me=JSON.parse(K);pe=Array.isArray(Me)?Me.length===0:typeof Me=="object"&&Me!==null&&Object.keys(Me).length===0}catch{pe=!1}if(K.trim()===""||se!==null||pe){u==null||u(`{{ ${j} }}`),a();return}if(!_)return;const ce=k.current?_.state.selection.main.head:K.length,re=No(K,ce,j);_.dispatch({changes:{from:0,to:K.length,insert:re.text},selection:{anchor:re.caret}}),_.focus()},[T,O]=w.useState(()=>Rt(Vn(e).parts,o).parts),I=w.useMemo(()=>Rt(T,o),[T,o]),[M,D]=w.useState(0),H=w.useRef(null),Y=w.useRef(!1),[$,G]=w.useState({}),[ne,oe]=w.useState(null),[X,L]=w.useState(()=>new Set),z=j=>{L(_=>{const K=new Set(_);return K.has(j)?K.delete(j):K.add(j),K})},[Z,q]=w.useState("auto");w.useLayoutEffect(()=>{const j=H.current;j&&(fr(j,T,{renderToggle:!0}),Y.current&&(Y.current=!1,Es(j),j.focus()))},[M]);const J=()=>{const j=H.current;j&&O(Tt(j))},te=j=>{const _=H.current;_&&(Ot(_,It(_.ownerDocument,j,{renderToggle:!0})),O(Tt(_)))},S=T.some(j=>j.kind==="render"),U=(j,{restoreFocus:_})=>{O(Rt(Xe(j),o).parts),D(K=>K+1)},V=()=>{const j=H.current,_=Rt(j?Tt(j):T,o);_.error||(i==null||i(nn(_.parts)),a())},P=()=>{oe(null),Y.current=!0,D(j=>j+1)},B=o.vars??[],ae=o.constants??[],fe=o.secrets??[],he=o.inputs??[],ge=o.documents??[],ve=o.steps??[],Ae=o.nodeConfigs??[],Te=o.loop,le=new Map(Ae.map(j=>[j.id,j.keys.filter(wt)]).filter(([,j])=>j.length>0)),Ee=o.nodeMeta??{},mt=j=>Il.filter(([_])=>$l.has(_)?Ct(j):Object.hasOwn(Ee[j]??{},_)),Ue=ve.filter(j=>j.hasMeta===!0).map(j=>j.id),Ct=j=>{var K;if(Ue.includes(j))return!0;const _=(K=Ee[j])==null?void 0:K.app;return typeof _=="string"&&!Ye(_)},et=j=>mt(j).map(([_,K])=>Q(K,{kind:"var",ref:`nodes.${j}.meta.${_}`},"w6w-exprmodal-field",null)),Ve=[...new Set([...Object.keys(Ee),...Ue,...le.keys()])],tt=ve.length>0||!!o.hasTrigger,Fe=!m&&(tt||!!Te),me=m?[]:(((we=o.stateShape)==null?void 0:we.fields)??[]).filter(j=>Xt(j.key)),Oe=[...Fe?["state"]:[],...me.length>0?["runstate"]:[],...Ve.length>0?["meta"]:[],...o.inputs!==void 0?["inputs"]:[],"vars",...ae.length>0?["consts"]:[],...!b||m?["docs"]:[],...b?[]:["secrets"]],nt=Z==="auto"||Z!==null&&!Oe.includes(Z)?Oe.find(j=>j!=="meta")??null:Z,xe=j=>({open:nt===j,onToggle:()=>q(nt===j?null:j)}),je=((Te==null?void 0:Te.itemOutputs)??[]).filter(j=>j.path?Xt(j.key):wt(j.key)),Ie=(o.eventOutputs??[]).filter(j=>j.path?Xt(j.key):wt(j.key)),Ne=ie.serializeTemplate(I.parts),At=w.useMemo(()=>{const j={};for(const[_,K]of Object.entries(o.sampleValues??{}))j[_]=typeof K=="string"?K:JSON.stringify(K);return{...j,...$}},[o.sampleValues,$]),ze=w.useMemo(()=>hl(I.parts),[I.parts]),ee=w.useMemo(()=>{if(I.error)return"";try{return bl(I.parts,o.sampleValues,$)}catch{return Ne}},[I,o.sampleValues,$,Ne]),W=w.useMemo(()=>{var _;const j=new Set;for(const K of ze){if($[K]!==void 0)continue;const se=(_=o.valueSources)==null?void 0:_[K];se==="sample"?j.add("example from the app"):se==="persisted"&&j.add("from last test")}return[...j]},[ze,$,o.valueSources]),Q=(j,_,K,se,pe=!1,ce,re)=>n.jsxs("div",{className:"w6w-exprmodal-item",style:{display:"flex",alignItems:"center",gap:4,minWidth:0,...re&&re.depth>0?{paddingLeft:re.depth*14}:{}},children:[n.jsxs("button",{type:"button",className:`w6w-exprmodal-source ${K}${re!=null&&re.declaredOnly?" is-declared-only":""}`,style:{flex:1,minWidth:0,...re!=null&&re.declaredOnly?{opacity:.6}:{}},title:`Insert ${(re==null?void 0:re.name)??j}`,"aria-label":ce,onClick:()=>b?_.kind==="var"&&F(_.ref??""):te(_),children:[se!==null&&n.jsx("span",{className:"w6w-expr-chip-sigil",children:se}),n.jsx("span",{className:"w6w-exprmodal-source-label",children:j}),(re==null?void 0:re.declaredOnly)&&n.jsx("span",{className:"w6w-muted w6w-small","data-testid":"expr-declared-only",style:{marginLeft:6},children:"declared by the app"}),(re==null?void 0:re.somePaths)&&n.jsx("span",{className:"w6w-muted w6w-small","data-testid":"expr-state-some-paths",title:"Set on some paths into this step, not all",style:{marginLeft:6},children:"some paths"})]}),!b&&n.jsx(Nn,{icon:"copy",iconSize:14,label:"Copy to expression editor","data-testid":"expr-copy-to-editor",onClick:()=>te(_)})]},`${_.kind}:${_.ref??j}`),de=X.has("loop:item"),Je=Q("Current item",{kind:"var",ref:"foreach.item"},"w6w-expr-chip-var","↻"),st=(j,_)=>{if(_.length===0)return null;const K=X.has(`mcfg:${j}`);return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-exprmodal-source-row",children:n.jsxs("button",{type:"button",className:"w6w-exprmodal-tree-toggle","data-testid":"expr-config-toggle","aria-expanded":K,title:K?"Hide config":"Show config",onClick:()=>z(`mcfg:${j}`),children:[n.jsx("span",{className:"w6w-exprmodal-tree-caret","aria-hidden":"true",children:K?"▾":"▸"}),"config"]})}),K&&n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-config-fields",children:_.map(se=>Q(se,{kind:"var",ref:`nodes.${j}.meta.config.${se}`},"w6w-exprmodal-field",null))})]})},ke=(j,_,K=`nodes.${j}.output`)=>jo(_).map(({field:se,depth:pe,name:ce})=>{const re=`${K}.${se.key}`;return Q(ce,{kind:"var",ref:re},"w6w-exprmodal-field",null,!1,void 0,{name:Ge(re),depth:pe,declaredOnly:se.declaredOnly===!0})}),$e=j=>j==="fresh"||j==="persisted"?n.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":"expr-fields-from-test",children:j==="fresh"?"Fields from the last test run":"Fields from last test"}):j==="declared"||j==="sample"?n.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":`expr-fields-from-${j}`,children:j==="declared"?"declared by the app":"example from the app"}):null,Gt=j=>{const _=`mnode:${j}`,K=X.has(_);return n.jsxs(w.Fragment,{children:[n.jsxs("div",{className:"w6w-exprmodal-source-row","data-testid":"expr-metadata-node",children:[n.jsx("button",{type:"button",className:"w6w-exprmodal-caret-btn","data-testid":"expr-metadata-node-toggle","aria-expanded":K,"aria-label":K?`Hide ${j} metadata`:`Show ${j} metadata`,title:K?"Hide metadata":"Show metadata",onClick:()=>z(_),children:K?"▾":"▸"}),Q(j,{kind:"var",ref:`nodes.${j}.meta`},"w6w-expr-chip-var w6w-exprmodal-node",null,!0)]}),K&&n.jsxs("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-metadata-fields",children:[et(j),st(j,le.get(j)??[])]})]},_)};return n.jsxs(Se,{title:h??(b?"Edit JSON value":"Edit expression"),subtitle:r?n.jsx("code",{children:r}):void 0,onClose:a,size:"full",headerRight:b?n.jsxs("div",{className:"w6w-exprmodal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:a,children:"Cancel"}),n.jsx("button",{type:"button",className:"w6w-btn","data-testid":"expr-json-save",disabled:!E,title:E?"Save the composed JSON":v??"Compose valid JSON to save",onClick:()=>{E&&(u==null||u(C.ok?C.value:void 0),a())},children:"Save"})]}):n.jsxs("div",{className:"w6w-exprmodal-actions",children:[!t&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:S,title:S?"Unavailable — a render part has no plain-text form. Flip it back to a variable first.":"Close the expression and keep the text as a literal value",onClick:()=>{i==null||i(ie.serializeTemplate(T)),a()},children:"Use a plain value"}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:a,children:"Cancel"}),n.jsx("button",{type:"button",className:"w6w-btn",onClick:V,"data-testid":"expr-save",disabled:I.error!==null,children:"Save"})]}),children:[n.jsxs("div",{className:"w6w-exprmodal",children:[n.jsxs("aside",{className:"w6w-exprmodal-sources",children:[m&&n.jsxs("fieldset",{className:"w6w-exprmodal-insert-as","aria-label":"Insert as",style:{display:"flex",gap:4,alignItems:"center",marginBottom:8},children:[n.jsx("span",{className:"w6w-muted w6w-small",children:"Insert as"}),[["ref","Reference","Insert {{ ref }}: resolved when each run starts"],["value","Value","Insert the current value, copied in as it is now"]].map(([j,_,K])=>n.jsx("button",{type:"button","aria-pressed":x===j,"data-testid":`expr-insert-as-${j}`,title:K,className:`w6w-btn w6w-btn-sm${x===j?"":" w6w-btn-ghost"}`,onClick:()=>g(j),children:_},j))]}),b&&!m&&!Fe&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No upstream steps"}),Fe&&n.jsxs(Ke,{label:"Previous steps",...xe("state"),children:[Te&&n.jsxs("div",{className:"w6w-exprmodal-subgroup","data-testid":"expr-loop-group",children:[n.jsx("span",{className:"w6w-exprmodal-shape-note",children:"Loop"}),je.length>0?n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[Je,n.jsx(Zt,{count:je.length,open:de,onToggle:()=>z("loop:item")})]}):Je,je.length>0&&de&&n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-loop-fields",children:je.map(j=>{const _=`foreach.item.${j.key}`;return Q(j.key,{kind:"var",ref:_},"w6w-exprmodal-field",null)})}),Q("Index",{kind:"var",ref:"foreach.index"},"w6w-expr-chip-var","#")]}),o.hasTrigger&&(Ie.length>0?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[n.jsx("button",{type:"button",className:"w6w-exprmodal-caret-btn","data-testid":"expr-caret-event","aria-expanded":X.has("event"),"aria-label":X.has("event")?"Hide fields":"Show fields",title:X.has("event")?"Hide fields":"Show fields",onClick:()=>z("event"),children:X.has("event")?"▾":"▸"}),Q("trigger.event",{kind:"var",ref:"trigger.event"},"w6w-expr-chip-var w6w-exprmodal-node","⚡",!0)]}),X.has("event")&&n.jsxs("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-event-fields",children:[$e(o.eventOutputsFrom),ke("",Ie,"trigger.event")]})]}):n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[n.jsx("span",{className:"w6w-exprmodal-caret-spacer","aria-hidden":"true"}),Q("trigger.event",{kind:"var",ref:"trigger.event"},"w6w-expr-chip-var w6w-exprmodal-node","⚡")]})),ve.map(j=>{const _=(j.outputs??[]).filter(ce=>ce.path?Xt(ce.key):wt(ce.key)),K=`step:${j.id}`,se=X.has(K),pe=Q(j.label??j.id,{kind:"var",ref:`nodes.${j.id}.output`},"w6w-expr-chip-var w6w-exprmodal-node",null,_.length>0);return b?n.jsxs(w.Fragment,{children:[n.jsx("span",{className:"w6w-exprmodal-shape-note",children:j.label??j.id}),Q("Entire output",{kind:"var",ref:`nodes.${j.id}.output`},"w6w-expr-chip-var",null,!1,`Entire output of ${j.label??j.id}`),j.needsTest&&n.jsx("div",{className:"w6w-exprmodal-subsources",children:n.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":"expr-needs-test",children:"Run a test of this step to see its fields"})}),_.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[n.jsx("button",{type:"button",className:"w6w-exprmodal-caret-btn","data-testid":"expr-caret-fields","aria-expanded":se,"aria-label":se?"Hide fields":"Show fields",title:se?"Hide fields":"Show fields",onClick:()=>z(K),children:se?"▾":"▸"}),n.jsx(Zt,{count:_.length,open:se,onToggle:()=>z(K)})]}),se&&n.jsxs("div",{className:"w6w-exprmodal-subsources",children:[$e(j.outputsFrom),ke(j.id,_)]})]})]},j.id):n.jsxs(w.Fragment,{children:[_.length>0?n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[n.jsx("button",{type:"button",className:"w6w-exprmodal-caret-btn","data-testid":"expr-caret-fields","aria-expanded":se,"aria-label":se?"Hide fields":"Show fields",title:se?"Hide fields":"Show fields",onClick:()=>z(K),children:se?"▾":"▸"}),pe,n.jsx(Zt,{count:_.length,open:se,onToggle:()=>z(K)})]}):n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[n.jsx("span",{className:"w6w-exprmodal-caret-spacer","aria-hidden":"true"}),pe]}),j.needsTest&&n.jsx("div",{className:"w6w-exprmodal-subsources",children:n.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":"expr-needs-test",children:"Run a test of this step to see its fields"})}),_.length>0&&se&&n.jsxs("div",{className:"w6w-exprmodal-subsources",children:[$e(j.outputsFrom),ke(j.id,_)]})]},j.id)})]}),me.length>0&&n.jsxs(Ke,{label:"State",testId:"expr-state-group",...xe("runstate"),children:[Q("state",{kind:"var",ref:"state"},"w6w-expr-chip-var","◇",!0),n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-state-fields",children:jo(me).map(({field:j,depth:_,name:K})=>{const se=`state.${j.key}`;return Q(K,{kind:"var",ref:se},"w6w-exprmodal-field",null,!1,void 0,{name:Ge(se),depth:_,somePaths:j.paths==="some"})})})]}),Ve.length>0&&n.jsx(Ke,{label:"Metadata",testId:"expr-metadata-group",...xe("meta"),children:Ve.map(j=>Gt(j))}),n.jsxs(n.Fragment,{children:[o.inputs!==void 0&&n.jsxs(Ke,{label:"Inputs",...xe("inputs"),children:[he.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No inputs"}),he.map(j=>Q(j,{kind:"var",ref:`inputs.${j}`},"w6w-expr-chip-var","⇥"))]}),n.jsxs(Ke,{label:"Variables",...xe("vars"),action:o.createVar&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm","data-testid":"expr-add-var",onClick:()=>oe("var"),children:"+ Add"}),children:[B.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No variables"}),B.map(j=>Q(j,{kind:"var",ref:`var.${j}`},"w6w-expr-chip-var","◆"))]}),ae.length>0&&n.jsx(Ke,{label:"Constants",testId:"expr-constants-group",...xe("consts"),children:ae.map(j=>Q(j,{kind:"var",ref:`const.${j}`},"w6w-expr-chip-var","◈"))})]}),(!b||m)&&n.jsxs(Ke,{label:"Documents",...xe("docs"),children:[ge.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No documents"}),ge.map(j=>{const _=(j.fields??[]).filter(ce=>wt(ce.key)),K=`doc:${j.key}`,se=X.has(K),pe=Q(j.key,{kind:"var",ref:`documents.${j.key}`},"w6w-expr-chip-var","▦",_.length>0);return n.jsxs(w.Fragment,{children:[_.length>0?n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[pe,n.jsx(Zt,{count:_.length,open:se,onToggle:()=>z(K)})]}):pe,_.length>0&&se&&n.jsx("div",{className:"w6w-exprmodal-subsources",children:_.map(ce=>{const re=`documents.${j.key}.${ce.key}`;return n.jsxs("div",{className:"w6w-exprmodal-subsource-row",children:[Q(ce.key,{kind:"var",ref:re},"w6w-expr-chip-var","·"),!b&&n.jsx("button",{type:"button",className:"w6w-exprmodal-render-btn","data-testid":"expr-insert-render",title:`Insert ${re} and render its {{ }} placeholders`,"aria-label":`Insert ${re} and render its {{ }} placeholders`,onClick:()=>te({kind:"render",ref:re}),children:"▤"})]},re)})})]},j.key)})]}),!b&&n.jsxs(Ke,{label:"Secrets",...xe("secrets"),action:o.createSecret&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm","data-testid":"expr-add-secret",onClick:()=>oe("secret"),children:"+ Add"}),children:[fe.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No secrets"}),fe.map(j=>Q(j,{kind:"secret",ref:j},"w6w-expr-chip-secret","🔒"))]})]}),b&&n.jsxs("div",{className:"w6w-exprmodal-main",children:[n.jsxs("div",{className:"w6w-exprmodal-editor",children:[n.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["JSON",n.jsxs("span",{className:"w6w-muted w6w-small",children:[" ","— type JSON, or click a source on the left to insert it at the cursor"]})]}),n.jsx("div",{className:"w6w-exprmodal-json",onFocus:()=>{k.current=!0},children:n.jsx(lt,{value:y,onChange:N,height:"100%",minHeight:"0px","aria-label":"Compose JSON",placeholder:m?'{ "region": "us", "template": "{{ documents.welcome }}" }':'{ "key": "{{ nodes.step_1.output }}" }',onCreateEditor:j=>{A.current=j}})})]}),n.jsxs("div",{className:"w6w-exprmodal-preview w6w-exprmodal-result-pane",children:[n.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["Result",n.jsxs("span",{className:"w6w-muted w6w-small",children:[" ",m?" — the state each run starts with, against the sample values":" — live preview against the sample values"]})]}),v&&n.jsx("span",{className:"w6w-muted w6w-small",role:"alert","data-testid":"expr-json-problem",children:v}),n.jsx("pre",{className:"w6w-exprmodal-result","data-testid":"expr-json-result",children:C.ok?JSON.stringify(Yn(C.value,j=>Dt(j,R())),null,2):y.trim()===""?"":"Invalid JSON"})]})]}),!b&&n.jsxs("div",{className:"w6w-exprmodal-main",children:[n.jsxs("div",{className:"w6w-exprmodal-editor",children:[n.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["Expression",n.jsx("span",{className:"w6w-muted w6w-small",children:" — click a source on the left, or type"})]}),n.jsx("div",{ref:H,className:`w6w-exprmodal-chips${t?" is-masked":""}${T.length===0?" is-empty":""}`,contentEditable:!0,suppressContentEditableWarning:!0,role:"textbox",tabIndex:0,"aria-multiline":s?"true":"false","aria-label":"Expression","data-placeholder":'Pick a field, then type == "value"',"aria-invalid":I.error!==null,"aria-describedby":I.error?"expression-problem":void 0,spellCheck:!1,onInput:()=>{const j=H.current;j&&hr(j,{renderToggle:!0}),J()},onDoubleClick:j=>{const _=j.target;if(_.closest("[data-x]")||_.closest("[data-render-toggle]"))return;const K=_.closest(".w6w-expr-chip");if(!K)return;j.preventDefault();const se=mr(K);if(se){const pe=se.ownerDocument,ce=pe.createRange();ce.setStartAfter(se),ce.collapse(!0);const re=pe.getSelection();re==null||re.removeAllRanges(),re==null||re.addRange(ce)}J()},onBlur:()=>{const j=H.current;j&&U(ie.serializeTemplate(Tt(j)),{restoreFocus:!1})},onPaste:j=>{var se;j.preventDefault();const _=H.current;if(!_)return;const K=((se=j.clipboardData)==null?void 0:se.getData("text/plain"))??"";for(const pe of Xe(K))pe.kind==="text"?Ot(_,_.ownerDocument.createTextNode(pe.value??"")):Ot(_,It(_.ownerDocument,pe,{renderToggle:!0}));J()},onClick:j=>{var pe;const _=j.target,K=_.closest("[data-x]");if(K){j.preventDefault(),(pe=K.closest(".w6w-expr-chip"))==null||pe.remove(),J();return}const se=_.closest("[data-render-toggle]");if(se){j.preventDefault();const ce=se.closest(".w6w-expr-chip");if(ce){const re=ce.getAttribute("data-ref")??"",Me=ce.getAttribute("data-kind")==="render"?"var":"render";ce.replaceWith(It(ce.ownerDocument,{kind:Me,ref:re},{renderToggle:!0}))}J()}},onKeyDown:j=>{if(j.key!=="Enter"||(j.preventDefault(),!s))return;const _=H.current;_&&(Ot(_,_.ownerDocument.createTextNode(`
13
+ `)),pr(_),J())}}),n.jsxs("span",{className:"w6w-muted w6w-small",children:["Pick a field, then type ",n.jsx("code",{children:'== "value"'}),". Combine conditions with"," ",n.jsx("code",{children:"&&"})," or ",n.jsx("code",{children:"||"}),". Double-click a chip to edit it."]}),I.error&&n.jsx("span",{id:"expression-problem",role:"alert",className:"w6w-error",children:I.error})]}),ze.length>0&&n.jsxs("div",{className:"w6w-exprmodal-preview",children:[n.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["Sample values",n.jsxs("span",{className:"w6w-muted w6w-small",children:[" ","— try the expression against example data"]})]}),ze.map(j=>n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:j}),n.jsx("input",{type:"text",value:$[j]??At[j]??"",placeholder:"sample value",onChange:_=>G(K=>({...K,[j]:_.target.value}))})]},j))]}),n.jsxs("div",{className:"w6w-exprmodal-preview w6w-exprmodal-result-pane",children:[n.jsxs("span",{className:"w6w-exprmodal-pane-label",children:["Result",n.jsxs("span",{className:"w6w-muted w6w-small",children:[" ","— live preview against the sample values"]})]}),n.jsx(ue.Copyable,{value:ee,readOnly:!0,children:n.jsx("pre",{className:"w6w-exprmodal-result",children:ee||" "})}),W.length>0&&n.jsx("span",{className:"w6w-muted w6w-small","data-testid":"expr-result-source",children:W.join(" · ")})]})]})]}),ne==="var"&&o.createVar&&n.jsx(ko,{kind:"var",onCreate:o.createVar,onClose:P}),ne==="secret"&&o.createSecret&&n.jsx(ko,{kind:"secret",onCreate:o.createSecret,onClose:P})]})}function Ke({label:e,open:t,onToggle:s,action:o,testId:r,children:i}){const a=w.useId(),l=w.useRef(null);return w.useLayoutEffect(()=>{l.current&&(l.current.inert=!t)},[t]),n.jsxs("div",{className:`w6w-exprmodal-group${t?" is-open":""}`,"data-testid":r,"data-section-open":t?"true":"false",children:[n.jsxs("div",{className:"w6w-exprmodal-group-head",children:[n.jsxs("button",{type:"button",className:"w6w-exprmodal-group-toggle","data-testid":"expr-section-toggle","aria-expanded":t,"aria-controls":a,onClick:s,children:[n.jsx("span",{className:"w6w-exprmodal-group-label",children:e}),n.jsx("span",{className:"w6w-exprmodal-group-caret","aria-hidden":"true",children:"›"})]}),o]}),n.jsx("div",{id:a,ref:l,className:"w6w-exprmodal-group-body","aria-hidden":!t,children:n.jsx("div",{className:"w6w-exprmodal-group-inner",children:i})})]})}function Zt({count:e,open:t,onToggle:s}){return n.jsxs("button",{type:"button",className:"w6w-exprmodal-toggle-btn","data-testid":"expr-toggle-fields","aria-expanded":t,title:t?"Hide fields":"Show fields",onClick:s,children:[e," ",e===1?"field":"fields"," ",t?"⌄":"›"]})}const Il=[["app","App"],["version","App version"],["action","Action"],["connectionId","Connection ID"],["subscriptionId","Subscription ID"],["url","Webhook URL"]],$l=new Set(["app","version","action","connectionId"]);function ko({kind:e,onCreate:t,onClose:s}){const[o,r]=w.useState(""),[i,a]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(null),[f,p]=w.useState(!1),h=e==="var"?"variable":"secret";async function b(){d(null),p(!0);try{await t({name:o,value:i,description:l||void 0}),s()}catch(m){d(m.message)}finally{p(!1)}}return n.jsxs(Se,{title:`Add ${h}`,onClose:s,children:[n.jsx("div",{className:"w6w-modal-body",children:n.jsxs("div",{className:"w6w-stack",children:[n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Name"}),n.jsx("input",{type:"text",value:o,onChange:m=>r(m.target.value),placeholder:e==="var"?"e.g. api_base_url":"e.g. openai_api_key",autoComplete:"off","data-testid":"expr-add-value-name",autoFocus:!0}),n.jsx("span",{className:"w6w-muted w6w-small",children:"Letters, digits, and underscores. Must start with a letter or underscore. Case-sensitive."})]}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Value"}),n.jsx("input",{type:e==="secret"?"password":"text",value:i,onChange:m=>a(m.target.value),autoComplete:"off","data-testid":"expr-add-value-value"}),e==="secret"&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Stored encrypted at rest. Once saved, it is not readable through the UI."})]}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Description"}),n.jsx("input",{type:"text",value:l,onChange:m=>c(m.target.value),placeholder:"Optional",autoComplete:"off"})]}),u&&n.jsx("div",{className:"w6w-result w6w-error",children:u})]})}),n.jsxs("div",{className:"w6w-modal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","data-testid":"expr-add-value-cancel",onClick:s,children:"Cancel"}),n.jsx("button",{type:"button",className:"w6w-btn","data-testid":"expr-add-value-save",disabled:!o||!i||f,onClick:b,children:f?"Saving…":"Save"})]})]})}function Pl(e,t){return t?e.filter(s=>s.id!==t):e}const Xn=w.createContext({});function _l({value:e,children:t}){const s=w.useContext(Xn),o=w.useMemo(()=>({...s,...e}),[s,e]);return n.jsx(Xn.Provider,{value:o,children:t})}function ht(){return w.useContext(Xn)}function Ht({value:e,onChange:t,placeholder:s,masked:o,multiline:r,readOnly:i,options:a,"aria-label":l}){const[c,u]=w.useState(()=>Vn(e)),{parts:d,sealed:f}=c,[p,h]=w.useState(0),[b,m]=w.useState(!1),[x,g]=w.useState(!1),y=w.useRef(!1),N=w.useRef(null),A=w.useRef(null),k=ht(),C={...k,...a??{}},v=k.sealSecret;w.useLayoutEffect(()=>{const O=N.current;!O||f||(fr(O,d),(y.current||O.ownerDocument.activeElement===O)&&(O.focus(),Es(O),y.current=!1))},[p,f]);const E=()=>{const O=N.current;if(!O)return;const I=Tt(O);u(D=>({...D,parts:I}));const M=Rt(I,C);t(nn(M.parts))},R=async O=>{if(!v)return!1;m(!0);try{const I=await v(O);return y.current=!1,u({parts:[],sealed:I}),h(M=>M+1),t(I),!0}catch{return!1}finally{m(!1)}},F=O=>{var D;if(x||!o||i||b)return;const I=O.relatedTarget;if(I&&((D=A.current)!=null&&D.contains(I)))return;const M=nn(d);typeof M=="string"&&M!==""&&!ct(M)&&R(M)},T=O=>{if(o&&typeof O=="string"&&O.trim()!==""&&!ct(O)){R(O);return}y.current=!1,u(Vn(O)),h(I=>I+1),t(O)};return f?n.jsxs("div",{className:`w6w-expr-sealed${i?" is-readonly":""}`,"aria-label":l,children:[n.jsxs("span",{className:"w6w-expr-chip w6w-expr-chip-secret",title:"Encrypted secret",children:[n.jsx("span",{className:"w6w-expr-chip-sigil",children:"🔒"}),n.jsx("span",{className:"w6w-expr-chip-label",children:"••••••"})]}),!i&&n.jsx("button",{type:"button",className:"w6w-expr-replace",onClick:()=>{y.current=!0,u({parts:[],sealed:null}),h(O=>O+1),t("")},children:"Replace"})]}):n.jsxs("div",{className:"w6w-expr",ref:A,onBlur:F,children:[n.jsxs("div",{className:"w6w-expr-field",children:[n.jsx("div",{ref:N,className:`w6w-expr-editor${o?" is-masked":""}${d.length===0?" is-empty":""}${i?" is-readonly":""}`,contentEditable:!i,suppressContentEditableWarning:!0,role:"textbox",tabIndex:i?-1:0,"aria-multiline":r?"true":"false","aria-label":l,"data-placeholder":s??"",spellCheck:!1,onInput:()=>{const O=N.current;O&&hr(O),E()},onClick:O=>{var M;const I=O.target.closest("[data-x]");I&&(O.preventDefault(),(M=I.closest(".w6w-expr-chip"))==null||M.remove(),E())},onDoubleClick:O=>{const I=O.target;if(I.closest("[data-x]"))return;const M=I.closest(".w6w-expr-chip");if(!M)return;O.preventDefault();const D=mr(M);if(D){const H=D.ownerDocument,Y=H.createRange();Y.setStartAfter(D),Y.collapse(!0);const $=H.getSelection();$==null||$.removeAllRanges(),$==null||$.addRange(Y)}E()},onKeyDown:O=>{if(O.key!=="Enter"||(O.preventDefault(),!r))return;const I=N.current;I&&(Ot(I,I.ownerDocument.createTextNode(`
14
+ `)),pr(I),E())}}),!i&&n.jsx("button",{type:"button",className:"w6w-expr-edit",title:"Edit expression — browse variables, secrets & step outputs","aria-label":"Edit expression",onClick:()=>g(!0),children:"ƒx"})]}),x&&n.jsx(Jt,{value:nn(d),masked:o,multiline:r,options:C,fieldLabel:l,onSave:T,onClose:()=>g(!1)})]})}const Ll=/\{\{\s*([^{}]*?)\s*\}\}/g;function wr(e,t="javascript"){const s=t==="python",o=[],r=[];let i=0;for(;i<e.length;){const l=e[i],c=e.slice(i,i+2),u=e.slice(i,i+3);if(s&&l==="#"||!s&&c==="//"){const d=e.indexOf(`
15
+ `,i),f=d===-1?e.length:d;r.push({start:i,end:f}),i=f}else if(!s&&c==="/*"){const d=e.indexOf("*/",i+2),f=d===-1?e.length:d+2;r.push({start:i,end:f}),i=f}else if(s&&(u==='"""'||u==="'''")){const d=e.indexOf(u,i+3),f=d===-1?e.length:d+3;o.push({start:i,end:f,quote:u}),i=f}else if(l==="'"||l==='"'||!s&&l==="`"){let d=i+1;for(;d<e.length&&e[d]!==l;){if(e[d]==="\\")d++;else if(l!=="`"&&e[d]===`
16
+ `)break;d++}const f=Math.min(d+1,e.length);o.push({start:i,end:f,quote:l}),i=f}else i++}const a=[];for(const l of e.matchAll(Ll)){const c=l.index??0,u=c+l[0].length;if(r.some(f=>c>=f.start&&c<f.end))continue;const d=o.find(f=>c>f.start&&c<f.end);a.push({start:c,end:u,ref:l[1],context:d?{kind:"string",...d}:{kind:"code"}})}return a}const Fl=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$-]*|\[\d+\]|\["[^"\\]*"\]|\['[^'\\]*'\])*$/,Ml=/\.([A-Za-z_$][\w$-]*)|\[(\d+)\]|\["([^"\\]*)"\]|\['([^'\\]*)'\]/g,Dl={nodes:["run","nodes"],steps:["run","nodes"],trigger:["run","trigger"],foreach:["run","foreach"],state:["state"],var:["state"],vars:["state"],const:["consts"],consts:["consts"]};function on(e,t="javascript"){var c;const s=e.trim();if(!Fl.test(s))return null;const o=((c=/^[A-Za-z_$][\w$]*/.exec(s))==null?void 0:c[0])??"",r=Dl[o];if(!r)return null;const i=[...r.slice(1)];for(const u of s.slice(o.length).matchAll(Ml))i.push(u[2]!==void 0?Number(u[2]):u[1]??u[3]??u[4]);const a=r[0]==="run"?i.shift():r[0];return`${t==="python"?"ctx":"$"}.get(${[a,...i].map(u=>JSON.stringify(u)).join(", ")})`}function Hl(e,t="javascript"){const s=t==="python";let o="",r=0,i=0,a=0;for(const l of wr(e,t)){const c=on(l.ref,t);if(c===null){a++;continue}const u=l.context;if(u.kind==="code"){o+=e.slice(r,l.start)+c,r=l.end,i++;continue}const d=u.quote,f=l.start===u.start+d.length,p=l.end===u.end-d.length;if(f&&p)o+=e.slice(r,u.start)+c,r=u.end,i++;else if(!s&&d==="`")o+=`${e.slice(r,l.start)}\${${c}}`,r=l.end,i++;else if(d.length===1&&!(s&&/[A-Za-z]/.test(e[u.start-1]??""))){const h=s?`str(${c})`:c;o+=f?`${e.slice(r,u.start)}${h} + ${d}`:`${e.slice(r,l.start)}${d} + ${h}`,p?r=u.end:(f||(o+=` + ${d}`),r=l.end),i++}else a++}return o+=e.slice(r),{code:o,converted:i,left:a}}function Bl({param:e,value:t,language:s,label:o,req:r,readOnly:i,onChange:a}){var A;const l=w.useRef(null),[c,u]=w.useState(!1),d=ht(),f=d.steps??[],p=s==="python",h=k=>{const C=l.current;if(!C){a(t+k);return}C.dispatch(C.state.replaceSelection(k)),C.focus()},b=k=>{const C=Qe(k);if(C!==null){const v=on(C,s);v&&h(v);return}k===void 0||k===""||h(JSON.stringify(k,null,2).replace(/"\{\{\s*([^{}"]*?)\s*\}\}"/g,(v,E)=>on(E,s)??v))},m=((A=f[0])==null?void 0:A.id)??"<step-id>",x=p?"ctx":"$",g=[[`${x}.get("nodes", ${JSON.stringify(m)}, "output")`,"a step's output"],[`${x}.get("state", "region")`,"a workflow state value"],[`${x}.get("consts", "api_base")`,"a constant"]],y=Math.max(...g.map(([k])=>k.length)),N=p?"#":"//";return n.jsxs("div",{className:"w6w-field w6w-script-code",children:[n.jsxs("span",{children:[o,r]}),n.jsx(js,{value:t,readOnly:i,minHeight:"180px",language:s,"aria-label":`${e.key} code`,onChange:a,onCreateEditor:k=>{l.current=k}}),!i&&n.jsxs("div",{className:"w6w-seed-chips w6w-script-insert",children:[n.jsx("span",{className:"w6w-muted w6w-small",children:"Insert"}),f.map(k=>{const C=on(`nodes[${JSON.stringify(k.id)}].output`,s)??"";return n.jsx("button",{type:"button",className:"w6w-chip w6w-seed-chip",title:`Insert ${C}`,onClick:()=>h(C),children:n.jsx("code",{children:k.id})},k.id)}),n.jsx("button",{type:"button",className:"w6w-chip w6w-seed-chip",title:"Pick a step field, variable or constant to insert as code","aria-label":`Insert a value into ${o}`,onClick:()=>u(!0),children:"ƒx"})]}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint}),n.jsxs("details",{className:"w6w-script-help",children:[n.jsx("summary",{className:"w6w-muted w6w-small",children:"How to read data"}),n.jsx("pre",{className:"w6w-script-help-examples",children:g.map(([k,C])=>`${k.padEnd(y)} ${N} ${C}`).join(`
17
+ `)}),n.jsxs("span",{className:"w6w-hint",children:[n.jsx("code",{children:"input"})," is the same as ",n.jsx("code",{children:"run"})," unless you set Custom input."]}),n.jsx("span",{className:"w6w-hint",children:p?n.jsxs(n.Fragment,{children:["Use ",n.jsx("code",{children:"ctx.state"})," and ",n.jsx("code",{children:"ctx.nodes"})," directly, or"," ",n.jsx("code",{children:"ctx.get(root, *keys)"})," for literal keys. Missing paths return"," ",n.jsx("code",{children:"None"}),". Existing globals still work."]}):n.jsxs(n.Fragment,{children:["Use ",n.jsx("code",{children:"$.state"})," and ",n.jsx("code",{children:"$.nodes"})," directly, or"," ",n.jsx("code",{children:"$.get(root, ...keys)"})," for literal keys. Existing ",n.jsx("code",{children:"run"}),","," ",n.jsx("code",{children:"state"}),", ",n.jsx("code",{children:"vars"})," and ",n.jsx("code",{children:"consts"})," reads still work. Type a dot for suggestions, or press Ctrl+Space."]})})]}),c&&n.jsx(Jt,{mode:"json-binding",value:void 0,jsonValue:void 0,options:d,fieldLabel:o,whole:!0,onSaveJson:b,onClose:()=>u(!1)})]})}function kn(e){const t=[];for(const s of e)t.push(s),s.type==="section"&&s.children&&t.push(...kn(s.children));return t}function br(e){return ct(e)||Ze(e)?!0:typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,"$")}function hn(e){var t;return((t=e.config)==null?void 0:t.allowCustom)===!0}function Zn(e){return kn(e).filter(t=>xn(t.options))}function Rs(e){return xn(e.options)?e.options.refreshOn??[]:[]}function Qn(e,t){const s={},o=[];for(const r of kn(e)){if(r.type==="section")continue;const i=t[r.key]!==void 0?t[r.key]:r.default;i!==void 0&&(br(i)?o.push(r.key):s[r.key]=i)}return{form:s,unresolved:o}}function Wl(e,t,s,o,r){const{form:i,unresolved:a}=Qn(e,t),l=new Set(a),c=Zn(e).filter(d=>{const f=Rs(d);return s==="change"&&!(o??[]).some(p=>f.includes(p))?!1:f.every(p=>!l.has(p))}).map(d=>d.key);if(c.length===0)return null;const u={reason:s,form:i,fields:c,unresolved:a};return s==="change"&&(u.changed=[...o??[]],u.previous=Qn(e,r??{}).form),u}function So(e,t,s){return JSON.stringify([e.appId,e.version??null,e.actionKey,e.connectionId??null,t.key,Rs(t).map(o=>s[o]??null)])}function Co(e){return!(xn(e.options)&&e.options.cache==="none")}function ql(e,t){return e.some(s=>t.includes(s))}function Ul(e,t,s,o){var l;if(!o.connectionId)return{reason:"no-connection",hint:"Connect an account to load choices"};const r=new Set(Qn(t,s).unresolved),i=Rs(e).find(c=>r.has(c));return i===void 0?null:{reason:"unresolved-dependency",hint:`Options unavailable while ${((l=kn(t).find(c=>c.key===i))==null?void 0:l.label)??i} is an expression`}}function Ao(e,t,s){return e==null||e===""?{action:"keep"}:br(e)?{action:"keep"}:t.some(o=>o.value===e||String(o.value)===String(e))?{action:"keep"}:s.reason==="change"&&!s.allowCustom?{action:"clear"}:{action:"flag",message:`Not in the list returned by ${s.appLabel}`}}function Vl(e,t,s,o){var N;const r=(N=tn())==null?void 0:N.resolveActionFields,i=!!(s&&r),[a,l]=w.useState({}),c=w.useRef({params:e,values:t,dynamic:s,onChange:o,resolve:r});c.current={params:e,values:t,dynamic:s,onChange:o,resolve:r};const u=w.useRef(new Map),d=w.useRef([]),f=w.useCallback((A,k,C,v,E)=>{const{params:R,values:F,dynamic:T,resolve:O}=c.current,I=E??F;if(!T||!O||!T.connectionId)return;const M=Wl(R,I,A,k,C);if(!M)return;const D=new Map(Zn(R).map(q=>[q.key,q])),H=[],Y={},$=[],G=T.appName??T.appId,ne=(q,J)=>{const te=D.get(q);if(!te)return;Ao(I[q],J,{allowCustom:hn(te),reason:A,appLabel:G}).action==="clear"&&H.push(q)};for(const q of M.fields){if(v!==void 0&&q!==v)continue;const J=D.get(q);if(!J)continue;const te=v===void 0&&Co(J)?u.current.get(So(T,J,M.form)):void 0;te?(Y[q]={options:te,loading:!1},ne(q,te)):$.push(q)}const oe=(q=!1)=>{if(H.length===0)return;const J={...q?I:c.current.values};for(const te of H)delete J[te];c.current.onChange(J)};if(Object.keys(Y).length>0&&l(q=>({...q,...Y})),$.length===0){oe(!0);return}for(const q of d.current)ql(q.fields,$)&&q.controller.abort();const X=new AbortController,L={fields:$,controller:X};d.current=[...d.current.filter(q=>!q.controller.signal.aborted),L],l(q=>{var te;const J={...q};for(const S of $)J[S]={options:(te=q[S])==null?void 0:te.options,loading:!0};return J});const z={...M,fields:$,connectionId:T.connectionId,...T.version!==void 0?{version:T.version}:{}},Z=q=>{d.current=d.current.filter(J=>J!==L),l(J=>({...J,...q}))};Promise.resolve().then(()=>O(T.appId,T.actionKey,z,{signal:X.signal})).then(q=>{var te;if(X.signal.aborted)return;const J={};for(const S of $){const U=(te=q==null?void 0:q.fields)==null?void 0:te[S],V=D.get(S);if(!U||!V)J[S]={loading:!1};else if(U.error)J[S]={loading:!1,error:U.error};else{const P=Array.isArray(U.options)?U.options:[];J[S]={loading:!1,options:P},Co(V)&&u.current.set(So(T,V,M.form),P),ne(S,P)}}Z(J),oe()}).catch(q=>{if(X.signal.aborted)return;const J=q instanceof Error?q.message:String(q),te={};for(const S of $)te[S]={loading:!1,error:J||"Request failed"};Z(te)})},[]),p=s?JSON.stringify([s.appId,s.actionKey,s.version,s.connectionId]):"";w.useEffect(()=>{if(i)return l({}),f("init"),()=>{for(const A of d.current)A.controller.abort();d.current=[]}},[p,i,f]);const h=w.useRef(new Map),b=w.useCallback((A,k)=>{const C=h.current.get(A)??c.current.values;h.current.delete(A),f("change",[A],C,void 0,{...c.current.values,[A]:k})},[f]),m=w.useCallback(A=>{h.current.has(A)||h.current.set(A,c.current.values)},[]),x=w.useCallback(A=>{const k=h.current.get(A);if(h.current.delete(A),!k)return;const C=c.current.values;JSON.stringify(k[A])!==JSON.stringify(C[A])&&f("change",[A],k)},[f]),g=w.useCallback(A=>f("init",void 0,void 0,A),[f]);return{fields:w.useMemo(()=>{const A={};if(!i||!s)return A;const k=s.appName??s.appId;for(const C of Zn(e)){const v=Ul(C,e,t,s);if(v){A[C.key]={loading:!1,hint:v.hint};continue}const E=a[C.key]??{loading:!0},R={...E};if(E.options){const F=Ao(t[C.key],E.options,{allowCustom:hn(C),reason:"init",appLabel:k});F.action==="flag"&&(R.notInList=F.message)}A[C.key]=R}return A},[i,s,e,t,a]),commit:b,focus:m,blur:x,retry:g}}function Kt(e,t){return e.hidden===!0?!1:e.showIf?ie.matchesParamCondition(e.showIf,t):!0}function vt(e){const t=[];for(const s of e)t.push(s),s.type==="section"&&s.children&&t.push(...vt(s.children));return t}function Bt(e,t){const s=[];for(let o=0;o<e.length;){const r=e[o].row;if(r){const i=[];for(;o<e.length&&e[o].row===r;)i.push(e[o++]);s.push(n.jsx("div",{className:"w6w-field-row",children:i.map(t)},`row:${r}`))}else s.push(t(e[o])),o++}return s}function gr(e,t,s,o){const r=i=>i.type==="section"?n.jsx(zl,{param:i,effective:s,renderOne:r},i.key):i.repeat&&i.type!=="array"?n.jsx(Yl,{param:i,value:e[i.key],onChange:t,readOnly:o},i.key):i.type==="group"&&i.children&&i.children.length>0?n.jsx(Gl,{param:i,value:e[i.key],onChange:t,effective:s,readOnly:o},i.key):n.jsx(Zl,{param:i,value:e[i.key],onChange:t,effective:s,readOnly:o},i.key);return r}const Sn=w.createContext(null);function He({params:e,values:t,onChange:s,readOnly:o,dynamic:r}){const i=Vl(e,t,r,s),a=vt(e),l=h=>{var b;return t[h]!==void 0?t[h]:(b=a.find(m=>m.key===h))==null?void 0:b.default},c=e.filter(h=>Kt(h,l)).map(h=>ie.effectiveParam(h,l)),u=c.filter(h=>h.required||!h.advanced),d=c.filter(h=>!h.required&&h.advanced),f=(h,b)=>{if(h==="language"){const m={...t,[h]:b};for(const x of a){if(x.type!=="code")continue;const g=t[x.key];(g===void 0||g===x.default||g===es||Xl.includes(g))&&(m[x.key]=b==="python"?es:x.default)}s(m);return}s({...t,[h]:b})};if(e.length===0)return n.jsx("p",{className:"w6w-muted w6w-small",children:"This action takes no parameters."});const p=gr(t,f,l,o);return n.jsx(Sn.Provider,{value:i,children:n.jsxs("div",{className:"w6w-stack",children:[Bt(u,p),d.length>0&&n.jsxs("details",{className:"w6w-params-optional",children:[n.jsxs("summary",{className:"w6w-muted w6w-small",children:["Additional parameters (",d.length,")"]}),n.jsx("div",{className:"w6w-stack",style:{marginTop:8},children:Bt(d,p)})]})]})})}function zl({param:e,effective:t,renderOne:s}){const o=(e.children??[]).filter(r=>Kt(r,t)).map(r=>ie.effectiveParam(r,t));return e.section==="collapsible"?n.jsxs("details",{className:"w6w-section",open:e.collapsed===!1||e.openWhenSet===!0&&o.some(r=>{const i=t(r.key);return i!=null&&i!==""}),children:[n.jsxs("summary",{className:"w6w-section-summary",children:[n.jsx("span",{className:"w6w-section-title",children:e.title??e.label??e.key}),e.subtitle&&n.jsx("span",{className:"w6w-section-subtitle",children:e.subtitle})]}),n.jsx("div",{className:"w6w-stack w6w-section-body",children:Bt(o,s)})]}):e.layout==="row"?n.jsx("div",{className:"w6w-field-row",children:o.map(s)}):n.jsx("div",{className:"w6w-stack",children:Bt(o,s)})}const Jl=new Set(["string","text","number","boolean","select"]);function Kl(e){return e.length>0&&e.every(t=>Jl.has(t.type)&&!t.children)}function Gl({param:e,value:t,onChange:s,effective:o,readOnly:r}){const i=e.children??[],a=t??{},l=(p,h)=>s(e.key,{...a,[p]:h}),c=vt(i),u=p=>{const h=c.find(b=>b.key===p);return h?a[p]!==void 0?a[p]:h.default:o(p)},d=i.filter(p=>Kt(p,u)).map(p=>ie.effectiveParam(p,u)),f=gr(a,l,u,r);return n.jsx(Sn.Provider,{value:null,children:n.jsxs("div",{className:"w6w-stack",children:[n.jsx("span",{className:"w6w-section-title",children:e.label??e.key}),n.jsx("div",{className:"w6w-stack w6w-section-body",children:Bt(d,f)})]})})}function Yl({param:e,value:t,onChange:s,readOnly:o}){if(e.type==="group"){const i=e.children??[];if(!Kl(i))return n.jsx(Ts,{param:e,value:t,onChange:s,readOnly:o});const a={...e,item:{type:"object",fields:i}};return n.jsx(ts,{param:a,value:t,onChange:s,readOnly:o})}const r={...e,item:{type:e.type,options:Array.isArray(e.options)?e.options:void 0}};return n.jsx(ts,{param:r,value:t,onChange:s,readOnly:o})}const es=`# Runs as a function body. Return the step's output.
18
+ return input`,Xl=["// Read `input` (bound under Input), plus `vars`, `consts` and `state.nodes.<step-id>.output`.\n// Runs as a function body. Return the step's output.\nreturn input;",'# Read `input` (bound under Input), plus `vars`, `consts` and `state["nodes"][<step-id>]["output"]`.\n# Runs as a function body. Return the step\'s output.\nreturn input',"// `input` holds the data bound under Input (e.g. an upstream step's output).\n// Runs as a function body. Return the step's output.\nreturn input;","# `input` holds the data bound under Input (e.g. an upstream step's output).\n# Runs as a function body. Return the step's output.\nreturn input"];function Zl(e){const t=w.useContext(Sn),s=e.param.key;return n.jsx("div",{style:{display:"contents"},onFocusCapture:t?()=>t.focus(s):void 0,onBlurCapture:t?()=>t.blur(s):void 0,children:n.jsx(Ql,{...e})})}function Ql({param:e,value:t,onChange:s,effective:o,readOnly:r}){var A,k,C,v,E;const i=(A=tn())==null?void 0:A.listModelRoutes,a=(k=tn())==null?void 0:k.listDataStores,l=(C=tn())==null?void 0:C.listDataStoreEntries,c=ys(),u=w.useContext(Sn),d=u==null?void 0:u.fields[e.key],f=(R,F)=>{s(R,F),u==null||u.commit(R,F)},p=s,h=e.label??e.key,b=e.required&&e.type!=="boolean"?" *":"",m=w.useId();if(e.type==="boolean"){const R=!!(t??e.default??!1);return n.jsx(_e,{param:e,value:t,onChange:p,readOnly:r,label:h,req:b,variant:"inline",controlId:m,children:n.jsx("input",{id:m,type:"checkbox",checked:R,disabled:r,onChange:F=>f(e.key,F.target.checked)})})}if(e.type==="json"||e.type==="group")return n.jsx(Ts,{param:e,value:t,onChange:p,readOnly:r});if(e.type==="code"){const R=o==null?void 0:o("language"),F=R==="python"||R==="javascript"||R==="typescript"?R:void 0,T=F==="python"?es:e.default,O=t??T??"";return e.scriptReads?n.jsx(Bl,{param:e,value:String(O),language:R==="python"?"python":"javascript",label:h,req:b,readOnly:r,onChange:I=>p(e.key,I)}):n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{children:[h,b]}),n.jsx(js,{value:String(O),readOnly:r,minHeight:"180px",language:F,"aria-label":`${e.key} code`,onChange:I=>p(e.key,I)}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}if(e.type==="model-route"&&i)return n.jsx(ec,{param:e,value:t,onChange:p,readOnly:r,label:h,req:b,listModelRoutes:i,project:c});if(e.type==="data-store"&&a)return n.jsx(tc,{param:e,value:t,onChange:p,readOnly:r,label:h,req:b,listDataStores:a,project:c});const x=o==null?void 0:o("store");if(e.type==="data-store-key"&&l&&typeof x=="string"&&x.trim()!=="")return n.jsx(rc,{param:e,value:t,onChange:p,readOnly:r,label:h,req:b,store:x,listDataStoreEntries:l,project:c});if(e.type==="vars")return n.jsx(dc,{param:e,value:t,onChange:p,readOnly:r});if(e.type==="text"||(v=e.config)!=null&&v.multiline){const R=t??e.default??"";return n.jsx(_e,{param:e,value:t,onChange:p,readOnly:r,label:h,req:b,children:n.jsx("textarea",{rows:3,value:String(R),readOnly:r,"aria-label":h,onChange:F=>p(e.key,F.target.value)})})}if(e.type==="multiselect")return n.jsx(ic,{param:e,value:t,onChange:f,readOnly:r});if(e.type==="array")return n.jsx(ts,{param:e,value:t,onChange:p,readOnly:r});if(u&&d&&!d.hint)return n.jsx(Eo,{param:e,value:t,onChange:f,readOnly:r,label:h,req:b,state:d,retry:()=>u.retry(e.key)});if(Array.isArray(e.options)&&e.options.length>0&&hn(e))return n.jsx(Eo,{param:e,value:t,onChange:f,readOnly:r,label:h,req:b,state:{loading:!1,options:e.options}});if(Array.isArray(e.options)&&e.options.length>0){const R=!e.required&&e.default===void 0&&typeof e.placeholder=="string"&&e.placeholder?e.placeholder:void 0,F=t??e.default??(R!==void 0?"":(E=e.options[0])==null?void 0:E.value)??"",T=e.type==="number";return n.jsx(_e,{param:e,value:t,onChange:p,readOnly:r,label:h,req:b,children:n.jsxs("select",{value:String(F),disabled:r,"aria-label":h,onChange:O=>{const I=O.target.value;R!==void 0&&I===""?f(e.key,void 0):f(e.key,T?Number(I):I)},children:[R!==void 0&&n.jsx("option",{value:"",children:R}),e.options.map(O=>n.jsx("option",{value:String(O.value),children:O.label},String(O.value)))]})})}if(e.type==="secret"){const R=t??e.default;return n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{children:[h,b]}),n.jsx(Ht,{value:R,masked:!0,readOnly:r,"aria-label":h,onChange:F=>p(e.key,F)}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}const g=e.type==="number"?"number":"text",y=t??e.default??"",N=typeof y=="object"&&y!==null?JSON.stringify(y):String(y??"");return n.jsxs(_e,{param:e,value:t,onChange:p,readOnly:r,label:h,req:b,children:[n.jsx("input",{type:g,value:N,readOnly:r,"aria-label":h,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,"data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",onChange:R=>p(e.key,e.type==="number"?Number(R.target.value):R.target.value)}),(d==null?void 0:d.hint)&&n.jsx("span",{className:"w6w-hint",children:d.hint})]})}function Eo({param:e,value:t,onChange:s,readOnly:o,label:r,req:i,state:a,retry:l}){const c=t??e.default??"",u=typeof c=="string"||typeof c=="number"?String(c):"";return n.jsxs(_e,{param:e,value:t,onChange:s,readOnly:o,label:r,req:i,children:[n.jsx("div",{className:"w6w-fx-grow","aria-busy":a.loading?"true":"false",children:n.jsx(kt,{mode:"combobox",forceSelection:!hn(e),"aria-label":r,disabled:o,value:u,placeholder:a.loading?"Loading…":e.placeholder,options:(a.options??[]).map(d=>({value:String(d.value),label:d.label})),onChange:d=>s(e.key,d)})}),a.notInList&&n.jsx("span",{className:"w6w-hint",children:a.notInList}),a.error&&n.jsxs("span",{role:"alert",className:"w6w-hint",children:[a.error,l&&n.jsx("button",{type:"button",onClick:l,children:"Retry"})]})]})}function ec({param:e,value:t,onChange:s,readOnly:o,label:r,req:i,listModelRoutes:a,project:l}){const[c,u]=w.useState([]);w.useEffect(()=>{let p=!0;return Promise.resolve().then(()=>a(l)).then(h=>p&&u(Array.isArray(h)?h:[])).catch(()=>p&&u([])),()=>{p=!1}},[a,l]);const d=t??e.default??"",f=typeof d=="string"?d:"";return n.jsx(_e,{param:e,value:t,onChange:s,readOnly:o,label:r,req:i,children:n.jsx(kt,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:f,placeholder:"Select a route…",options:c.map(p=>({value:p.name,label:p.status==="broken"?`${p.name} (broken)`:p.name})),onChange:p=>s(e.key,p)})})}function tc({param:e,value:t,onChange:s,readOnly:o,label:r,req:i,listDataStores:a,project:l}){const[c,u]=w.useState([]);w.useEffect(()=>{let p=!0;return Promise.resolve().then(()=>a(l)).then(h=>p&&u(Array.isArray(h)?h:[])).catch(()=>p&&u([])),()=>{p=!1}},[a,l]);const d=t??e.default??"",f=typeof d=="string"?d:"";return n.jsx(_e,{param:e,value:t,onChange:s,readOnly:o,label:r,req:i,children:n.jsx(kt,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:f,placeholder:"Select a store…",options:c.map(p=>({value:p.name,label:`${p.name} (${p.kind})`})),onChange:p=>s(e.key,p)})})}const nc=25,sc=200,Ro=60;function oc(e){let t="";if(e.value!==void 0){try{t=typeof e.value=="string"?e.value:JSON.stringify(e.value)}catch{t=String(e.value)}t=t.replace(/\s+/g," "),t.length>Ro&&(t=`${t.slice(0,Ro-1)}…`)}const s=typeof e.updatedAt=="string"&&e.updatedAt.length>=16?`updated ${e.updatedAt.slice(0,16).replace("T"," ")}`:"";return[t,s].filter(Boolean).join(" · ")}function rc({param:e,value:t,onChange:s,readOnly:o,label:r,req:i,store:a,listDataStoreEntries:l,project:c}){const[u,d]=w.useState(""),[f,p]=w.useState({items:[]}),[h,b]=w.useState(!0);w.useEffect(()=>{const y=new AbortController;b(!0);const N=u.trim(),A=setTimeout(()=>{Promise.resolve().then(()=>l(a,{project:c,prefix:N===""?void 0:N,limit:nc,signal:y.signal})).then(k=>{y.signal.aborted||(p(k&&Array.isArray(k.items)?k:{items:[]}),b(!1))}).catch(()=>{y.signal.aborted||(p({items:[]}),b(!1))})},N===""?0:sc);return()=>{clearTimeout(A),y.abort()}},[l,a,c,u]);const m=t??e.default??"",x=typeof m=="string"?m:"",g=u.trim();return n.jsx(_e,{param:e,value:t,onChange:s,readOnly:o,label:r,req:i,children:n.jsx(kt,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:x,placeholder:"Search entries or type a key…",options:f.items.map(y=>({value:y.key,label:y.key,detail:oc(y)||void 0})),onInputChange:d,emptyText:h?"Searching…":g!==""?`No key starts with "${g}" — Enter keeps it as typed`:"No entries in this store",footer:f.more?"More entries — type to narrow by key":void 0,onChange:y=>s(e.key,y)})})}function _e({param:e,value:t,onChange:s,readOnly:o,label:r,req:i,bare:a,variant:l="boxed",controlId:c,children:u}){var g;const d=ct(t),f=e.type==="text"||!!((g=e.config)!=null&&g.multiline),[p,h]=w.useState(!1),b=ht(),m=l==="inline"&&!d,x=n.jsxs(n.Fragment,{children:[n.jsx("div",{className:m?"w6w-fx-inline":`w6w-fx-wrap${d?" is-fx":""}`,children:d?n.jsx(Ht,{value:t,multiline:f,readOnly:o,"aria-label":r,onChange:y=>s(e.key,y)}):n.jsxs(n.Fragment,{children:[u,!o&&n.jsx("button",{type:"button",className:"w6w-expr-fx",title:"Use an expression","aria-label":`Use an expression for ${r}`,onClick:()=>h(!0),children:"ƒx"}),m&&n.jsxs("label",{className:"w6w-fx-inline-label",htmlFor:c,children:[r,i]})]})}),p&&n.jsx(Jt,{value:t,multiline:f,options:b,fieldLabel:r,onSave:y=>s(e.key,y),onClose:()=>h(!1)})]});return a?x:n.jsxs("div",{className:"w6w-field",children:[!m&&n.jsxs("span",{children:[r,i]}),x,e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}function Ts({param:e,value:t,onChange:s,readOnly:o,headerActions:r,onValidityChange:i}){const a=Qe(t)??"",l=a!=="",c=t??e.default,[u,d]=w.useState(()=>l||c===void 0?"":JSON.stringify(c,null,2)),[f,p]=w.useState(!1),[h,b]=w.useState(!1),[m,x]=w.useState(!1),g=ht(),y=g.steps??[];w.useEffect(()=>{if(l)return;let R;try{R=u.trim()===""?void 0:JSON.parse(u)}catch{R=void 0}JSON.stringify(R)!==JSON.stringify(c)&&(d(c===void 0?"":JSON.stringify(c,null,2)),p(!1))},[c,e.key,l]);const N=R=>{d(R)},A=R=>{p(!1),i==null||i(!0),s(e.key,R)},k=({valid:R,error:F})=>{if(i==null||i(R||F==="Empty"),!R&&F==="Empty"){p(!1),s(e.key,void 0);return}p(!R)},C=()=>{const R=Tl(u);R&&(p(!1),s(e.key,R))},v=e.label??e.key,E=()=>{let R;try{R=u.trim()===""?void 0:JSON.parse(u)}catch{R=void 0}s(e.key,R)};return n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{className:"w6w-field-labelrow",children:[n.jsxs("span",{children:[v,e.required?" *":""]}),r,!l&&n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-btn-sm",title:"Open in full view","aria-label":`Open ${v} in full view`,onClick:()=>b(!0),children:n.jsx(ue.Icon,{name:"maximize",size:14})})]}),l?n.jsx("div",{className:"w6w-fx-wrap is-fx w6w-json-binding",children:n.jsx("div",{className:"w6w-expr",children:n.jsxs("div",{className:"w6w-expr-field",children:[n.jsx("div",{className:`w6w-expr-editor${o?" is-readonly":""}`,"data-testid":"json-binding-ref",children:n.jsxs("span",{className:"w6w-expr-chip w6w-expr-chip-var","data-kind":"var","data-ref":a,title:`Variable: ${a}`,children:[n.jsx("span",{className:"w6w-expr-chip-sigil",children:"◆"}),n.jsx("span",{className:"w6w-expr-chip-label",children:Ge(a)}),!o&&n.jsx("button",{type:"button",className:"w6w-expr-chip-x","aria-label":`Remove the reference from ${v}`,style:{border:0,padding:0,font:"inherit"},onClick:E,children:"×"})]})}),!o&&n.jsx("button",{type:"button",className:"w6w-expr-edit",title:"Edit expression — browse step outputs, metadata & variables","aria-label":`Edit expression for ${v}`,onClick:()=>x(!0),children:"ƒx"})]})})}):n.jsx(lt,{value:u,onChange:N,onBlur:C,readOnly:o,minHeight:"34px",maxHeight:"260px","aria-label":`${e.key} JSON`,onValidChange:A,onValidityChange:k,overlay:o?void 0:n.jsx("button",{type:"button",className:"w6w-expr-fx",title:"Use an expression","aria-label":`Use an expression for ${v}`,onClick:()=>x(!0),children:"ƒx"})}),m&&n.jsx(Jt,{mode:"json-binding",value:void 0,jsonValue:t,options:g,fieldLabel:v,whole:e.whole,onSaveJson:R=>s(e.key,R),onClose:()=>x(!1)}),!l&&f&&n.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"}),e.whole&&!l&&!o&&y.length>0&&n.jsxs("div",{className:"w6w-seed-chips w6w-json-quickbind",children:[n.jsx("span",{className:"w6w-muted w6w-small",children:"Use the output of"}),y.map(R=>n.jsx("button",{type:"button",className:"w6w-chip w6w-seed-chip",title:`Bind ${v} to {{ nodes.${R.id}.output }}`,onClick:()=>s(e.key,`{{ nodes.${R.id}.output }}`),children:n.jsx("code",{children:R.id})},R.id))]}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint}),h&&!l&&n.jsxs(Se,{title:v,subtitle:n.jsx("code",{children:"JSON"}),size:"wide",onClose:()=>b(!1),children:[n.jsx("div",{className:"w6w-json-fullview",children:n.jsx(lt,{value:u,onChange:N,readOnly:o,height:"100%",minHeight:"360px","aria-label":`${e.key} JSON (full view)`,onValidChange:A,onValidityChange:k})}),f&&n.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]})]})}function ic({param:e,value:t,onChange:s,readOnly:o}){var g;const r=Array.isArray(e.options)?e.options:[],i=((g=e.config)==null?void 0:g.valueFormat)==="csv",a=t??e.default,l=Array.isArray(a)?a:i&&typeof a=="string"?a.split(",").map(y=>y.trim()).filter(Boolean):[],c=new Set(l.map(String)),u=r.filter(y=>!c.has(String(y.value))),d=y=>{var N;return((N=r.find(A=>String(A.value)===String(y)))==null?void 0:N.label)??String(y)},f=y=>s(e.key,i?y.join(","):y),p=y=>{if(!y||c.has(y))return;const N=r.find(A=>String(A.value)===y);f([...l,N?N.value:y])},h=y=>f(l.filter(N=>String(N)!==String(y))),b=typeof e.placeholder=="string"&&e.placeholder?e.placeholder:"Select…",m=e.label??e.key,x=e.required?" *":"";return n.jsx(_e,{param:e,value:t,onChange:s,readOnly:o,label:m,req:x,children:e.ui==="checkboxes"?n.jsxs("div",{className:"w6w-multiselect-checks w6w-fx-grow",children:[n.jsxs("div",{className:"w6w-multiselect-checks-toolbar",children:[n.jsxs("span",{className:"w6w-muted w6w-small",children:[l.length," selected"]}),!o&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"w6w-linkbtn",disabled:u.length===0,onClick:()=>f([...l,...u.map(y=>y.value)]),children:"Select all"}),n.jsx("button",{type:"button",className:"w6w-linkbtn",disabled:l.length===0,onClick:()=>f([]),children:"Clear"})]})]}),n.jsx("fieldset",{className:"w6w-multiselect-checks-options","aria-label":m,children:[...r,...l.filter(y=>!r.some(N=>String(N.value)===String(y))).map(y=>({value:y,label:String(y)}))].map(y=>n.jsxs("label",{className:"w6w-multiselect-check",children:[n.jsx("input",{type:"checkbox",checked:c.has(String(y.value)),disabled:o,onChange:N=>N.target.checked?p(String(y.value)):h(y.value)}),n.jsx("span",{children:y.label})]},String(y.value)))})]}):n.jsx(n.Fragment,{children:n.jsxs("div",{className:`w6w-multiselect${o?" is-readonly":""}`,children:[l.map(y=>n.jsxs("span",{className:"w6w-chip",children:[d(y),!o&&n.jsx("button",{type:"button",className:"w6w-chip-x","aria-label":`Remove ${d(y)}`,title:"Remove",onClick:()=>h(y),children:"×"})]},String(y))),!o&&n.jsxs("select",{className:"w6w-multiselect-add",value:"",disabled:u.length===0,"aria-label":`Add to ${e.label??e.key}`,onChange:y=>p(y.target.value),children:[n.jsx("option",{value:"",children:u.length>0?l.length?"Add more…":b:"All selected"}),u.map(y=>n.jsx("option",{value:String(y.value),children:y.label},String(y.value)))]})]})})})}function ac({field:e,value:t,onChange:s,readOnly:o}){var a;const r=e.placeholder??e.label??e.key;if(Array.isArray(e.options)&&e.options.length>0)return n.jsx("select",{className:"w6w-array-input",value:String(t??e.default??((a=e.options[0])==null?void 0:a.value)??""),disabled:o,"aria-label":e.label??e.key,onChange:l=>s(l.target.value),children:e.options.map(l=>n.jsx("option",{value:String(l.value),children:l.label},String(l.value)))});if(e.type==="boolean")return n.jsxs("label",{className:"w6w-array-check",title:e.label??e.key,children:[n.jsx("input",{type:"checkbox",checked:!!(t??e.default??!1),disabled:o,"aria-label":e.label??e.key,onChange:l=>s(l.target.checked)}),n.jsx("span",{children:e.label??e.key})]});const i=e.type==="number";return n.jsx("input",{className:"w6w-array-input",type:i?"number":"text",value:String(t??e.default??""),placeholder:r,"aria-label":e.label??e.key,readOnly:o,onChange:l=>s(i?Number(l.target.value):l.target.value)})}function ts({param:e,value:t,onChange:s,readOnly:o}){const r=e.item??{type:"string"},i=r.type==="object",a=Array.isArray(t)?t:Array.isArray(e.default)?e.default:[],l=d=>s(e.key,d),c=()=>i?Object.fromEntries((r.fields??[]).map(d=>[d.key,d.default??""])):r.type==="number"?0:"",u=(d,f)=>l(a.map((p,h)=>h===d?f:p));return n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{children:[e.label??e.key,e.required?" *":""]}),n.jsxs("div",{className:"w6w-array",children:[a.length===0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"None yet — add one below."}),a.map((d,f)=>n.jsxs("div",{className:"w6w-array-row",children:[i?n.jsx("div",{className:"w6w-array-cells",children:(r.fields??[]).map(p=>n.jsx(ac,{field:p,value:d==null?void 0:d[p.key],readOnly:o,onChange:h=>u(f,{...d??{},[p.key]:h})},p.key))}):n.jsx("input",{className:"w6w-array-input",type:r.type==="number"?"number":"text",value:String(d??""),placeholder:r.placeholder,readOnly:o,onChange:p=>u(f,r.type==="number"?Number(p.target.value):p.target.value)}),!o&&n.jsx("button",{type:"button",className:"w6w-array-x","aria-label":"Remove item",title:"Remove",onClick:()=>l(a.filter((p,h)=>h!==f)),children:"×"})]},f)),!o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-array-add",onClick:()=>l([...a,c()]),children:"+ Add"})]}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}const lc=["string","number","boolean","json"],cc=[];function mn(e,t=[]){return Array.isArray(e)?e.every(s=>s&&typeof s=="object"&&typeof s.key=="string")?e:null:!e||typeof e!="object"||ct(e)||Qe(e)||"$expr"in e?null:Object.entries(e).map(([s,o])=>{const r=t.find(a=>a.key===s),i=typeof o;return{key:s,type:r&&JSON.stringify(r.value)===JSON.stringify(o)?r.type:i==="string"||i==="number"||i==="boolean"?i:"json",value:o}})}function uc(e){const t=Array.isArray(e)?mn(e):null;return!t||t.some(s=>!s.key)||new Set(t.map(s=>s.key)).size!==t.length?e:Object.fromEntries(t.map(s=>[s.key,s.value]))}function To(e,t){if(e==="number"){if(t.trim()==="")return"";const s=Number(t);return Number.isNaN(s)?t:s}if(e==="boolean")return t==="true";if(e==="json")try{return JSON.parse(t)}catch{return t}return t}function Oo(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function dc({param:e,value:t,onChange:s,readOnly:o}){const r=t??e.default??cc,i=w.useMemo(()=>uc(r),[r]),[a,l]=w.useState(()=>Array.isArray(r)?"fields":"json"),c=w.useRef([]),[u,d]=w.useState(!1),[f,p]=w.useState(null),h=mn(r,c.current),b=h??[],m=a==="json"||h===null,x=e.label??e.key,g=n.jsxs("div",{className:"w6w-view-toggle w6w-datavar-modes",children:[n.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${m?"":" active"}`,"aria-label":`Edit ${x} as fields`,"aria-pressed":!m,disabled:u||!!f||h===null,title:h===null?"Use a literal JSON object to edit individual fields":"Edit individual fields",onClick:()=>{!o&&!Array.isArray(r)&&s(e.key,b),l("fields")},children:"Fields"}),n.jsx("button",{type:"button",className:`w6w-btn w6w-btn-sm w6w-btn-ghost${m?" active":""}`,"aria-label":`Edit ${x} as JSON`,"aria-pressed":m,onClick:()=>{c.current=b,l("json")},children:"JSON"})]});if(m)return n.jsxs("div",{className:"w6w-datavar-json",children:[n.jsx(Ts,{param:{...e,type:"json",whole:!0,default:{},hint:"Enter a JSON object or use ƒx to bind one. Switch to Fields to edit individual values."},value:i,readOnly:o,headerActions:g,onValidityChange:A=>d(!A),onChange:(A,k)=>{if(k!==void 0&&mn(k)===null&&!Qe(k)&&!ct(k)&&!(k&&typeof k=="object"&&"$expr"in k)){p("Use a JSON object, a typed key/value array, or an object binding.");return}p(null),d(!1),s(A,k)}}),f&&n.jsx("span",{className:"w6w-hint w6w-datavar-error","aria-live":"polite",children:f})]});const y=A=>s(e.key,A),N=(A,k)=>y(b.map((C,v)=>v===A?{...C,...k}:C));return n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{className:"w6w-field-labelrow",children:[n.jsxs("span",{children:[x,e.required?" *":""]}),g]}),n.jsxs("div",{className:"w6w-stack",children:[b.length===0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"No variables yet — add one below."}),b.map((A,k)=>n.jsxs("div",{className:"w6w-datavar-row",children:[n.jsx("input",{type:"text",placeholder:"key",value:A.key,readOnly:o,onChange:C=>N(k,{key:C.target.value})}),n.jsx("select",{value:A.type,disabled:o,onChange:C=>{const v=C.target.value;N(k,{type:v,value:To(v,Oo(A.value))})},children:lc.map(C=>n.jsx("option",{value:C,children:C},C))}),n.jsx(_e,{bare:!0,param:e,value:A.value,onChange:(C,v)=>N(k,{value:v}),readOnly:o,label:A.key||"value",req:"",children:A.type==="boolean"?n.jsxs("select",{value:A.value===!0?"true":"false",disabled:o,onChange:C=>N(k,{value:C.target.value==="true"}),children:[n.jsx("option",{value:"true",children:"true"}),n.jsx("option",{value:"false",children:"false"})]}):n.jsx("input",{type:A.type==="number"?"number":"text",placeholder:"value",value:Oo(A.value),readOnly:o,onChange:C=>N(k,{value:To(A.type,C.target.value)})})}),!o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","aria-label":`Remove variable ${A.key||k+1}`,title:"Remove",onClick:()=>y(b.filter((C,v)=>v!==k)),children:"×"})]},k)),!o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>y([...b,{key:"",type:"string",value:""}]),children:"+ Add variable"})]}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}const Wt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Os=[["is-true","is true"],["is-false","is false"],["===","equals"],["!==","does not equal"],[">","greater than"],[">=","at least"],["<","less than"],["<=","at most"],["in","in"],["includes","includes value"],["include-any","includes any of (list)"],["include-all","includes all of (list)"]],Qt={in:"The right array contains the left value.",includes:"Check whether a list contains one value, or text contains a substring.","include-any":"Compare two lists for any shared value. For one value on the right, use includes value.","include-all":"Compare two lists: every value in the right list must be in the left list."},pc=new Set(Os.map(([e])=>e)),Io={...Object.fromEntries(Os),"==":"equals","!=":"does not equal",in:"is in"};function fc(e){return e.startsWith("not:")?`Not (${Io[e.slice(4)]??e.slice(4)})`:Io[e]??e}const yr=[["and","All of (AND)"],["or","Any of (OR)"],["xor","Exactly one of (XOR)"]],xr=Object.fromEntries(yr);function hc(e){return xr[e]??e}function Is(e,t=!0){if(!Wt(e))return;const s=Object.entries(e);if(s.length!==1)return;const[o,r]=s[0];if(t&&o==="!"&&Array.isArray(r)&&r.length===1){const i=Is(r[0],!1);return!i||i.negated?void 0:{...i,negated:!0}}if(!(!pc.has(o)||!Array.isArray(r)||r.length!==2)){if(o==="==="&&typeof r[1]=="boolean")return{left:r[0],operator:r[1]?"is-true":"is-false",right:r[1]};if(!(o==="is-true"||o==="is-false"))return{left:r[0],operator:o,right:r[1]}}}function mc(e){if(!(!Wt(e)||Object.keys(e).length!==1))return Is(e.$expr)}function wc(e){const t=mc(e);if(t)return{combinator:"and",rows:[t]};if(!Wt(e)||Object.keys(e).length!==1||!Wt(e.$expr))return;const s=Object.entries(e.$expr);if(s.length!==1)return;const[o,r]=s[0];if(!Object.hasOwn(xr,o)||!Array.isArray(r)||r.length===0)return;const i=r.map(a=>Is(a));if(!i.some(a=>a===void 0))return{combinator:o,rows:i}}function $o(e){const t=e.rows.filter(s=>s.left!=="").map(s=>{const o=s.operator==="is-true"||s.operator==="is-false"?{"===":[s.left,s.operator==="is-true"]}:{[s.operator]:[s.left,s.right]};return s.negated?{"!":[o]}:o});return t.length===0?!1:{$expr:t.length===1?t[0]:{[e.combinator]:t}}}function ns(e){if(typeof e=="string")try{const s=JSON.parse(e);if(s===null||Array.isArray(s)||["string","number","boolean"].includes(typeof s))return s}catch{}const t=typeof e=="string"?jn(e):qe(e)?e.parts:null;if(t){const s=t.map(o=>o.kind==="expr"?o.expr:o.kind==="var"?{var:o.ref}:o.kind==="secret"?{var:`secrets.${o.ref}`}:o.value??"");return s.length===1?s[0]:{cat:s}}return e}function Po(e){return typeof e=="string"?ns(e)===e?e:JSON.stringify(e):Wt(e)?Object.keys(e).length===1&&typeof e.var=="string"?ie.serializeTemplate([{kind:"var",ref:e.var}]):ie.serializeTemplate([{kind:"expr",expr:e}]):JSON.stringify(e)??""}const vr={left:"",operator:"is-true",right:!0},_o={combinator:"and",rows:[vr]},bc=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Cn({values:e,onChange:t,readOnly:s,purpose:o="if"}){const r=ht(),i=e.condition===void 0?!0:e.condition,a=wc(i),[l,c]=w.useState(!1),[u,d]=w.useState(a??_o),f=w.useRef(0),[p,h]=w.useState(()=>u.rows.map(()=>f.current++)),b=a!==void 0||typeof i=="boolean",m=bc($o(u),i)?u:a??_o,x=m.rows.map((C,v)=>p[v]??-1-v),g=(C,v=x)=>{d(C),h(v),t({...e,condition:$o(C)})},y=(C,v)=>g({...m,rows:m.rows.map((E,R)=>R===C?{...E,...v}:E)}),N=()=>g({...m,rows:[...m.rows,vr]},[...x,f.current++]),A=C=>g({...m,rows:m.rows.filter((v,E)=>E!==C)},x.filter((v,E)=>E!==C)),k=m.rows.length>1;return n.jsxs("div",{className:"w6w-condition-editor",children:[l||!b?n.jsx(He,{params:[{key:"condition",label:"Condition",type:"json",required:!0}],values:e,onChange:t,readOnly:s}):n.jsxs("div",{className:"w6w-condition-rows",children:[k&&n.jsx("select",{className:"w6w-condition-comparison w6w-condition-combinator","aria-label":"Combine conditions",disabled:s,value:m.combinator,onChange:C=>g({...m,combinator:C.target.value}),children:yr.map(([C,v])=>n.jsx("option",{value:C,children:v},C))}),m.rows.map((C,v)=>{const E=C.operator==="is-true"||C.operator==="is-false";return n.jsxs("div",{className:`w6w-condition-row${k?" w6w-condition-row-removable":""}${E?" w6w-condition-row-boolean":""}`,children:[n.jsxs("label",{className:"w6w-condition-negate",title:"Reverse this condition's result",children:[n.jsx("input",{type:"checkbox","aria-label":`Negate condition ${v+1}`,checked:C.negated??!1,disabled:s,onChange:R=>y(v,{negated:R.target.checked})}),"Not"]}),n.jsx(Ht,{value:Po(C.left),"aria-label":"Condition field",placeholder:"Field or expression",readOnly:s,onChange:R=>y(v,{left:ns(R)})}),n.jsx("select",{className:"w6w-condition-comparison","aria-label":"Condition comparison",title:Qt[C.operator],disabled:s,value:C.operator,onChange:R=>y(v,{operator:R.target.value,right:R.target.value==="is-true"?!0:R.target.value==="is-false"?!1:E?"":C.right}),children:Os.map(([R,F])=>n.jsx("option",{value:R,title:Qt[R],children:F},R))}),!E&&n.jsx(Ht,{value:Po(C.right),"aria-label":"Condition value",placeholder:"Value or expression",readOnly:s,onChange:R=>y(v,{right:ns(R)})}),k&&!s&&n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-condition-remove",title:"Remove condition","aria-label":`Remove condition ${v+1}`,onClick:()=>A(v),children:n.jsx(ue.Icon,{name:"trash",size:14})})]},x[v])}),!s&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-condition-add",onClick:N,children:"+ Add condition"}),n.jsx("p",{className:"w6w-muted w6w-small",children:"Not reverses a condition. Type true or false without quotes for booleans; use quotes for text."}),[...new Set(m.rows.map(C=>C.operator))].map(C=>Qt[C]?n.jsx("p",{className:"w6w-muted w6w-small",children:Qt[C]},C):null)]}),b&&n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-condition-mode",title:l?"Use comparison fields":"Edit condition expression","aria-label":l?"Use comparison fields":"Edit condition expression",onClick:()=>c(!l),children:n.jsx(ue.Icon,{name:l?"form":"code",size:14})}),o!=="router"&&n.jsx("p",{className:"w6w-muted w6w-small",children:o==="stop"?"End the workflow when this condition is true.":r.loop?"When false, skip the remaining steps for this item.":"Continue when this condition is true."})]})}const gc={step:"Re-run this step if it fails, up to N attempts.",function:"Re-run this function call if it fails, up to N attempts.",endpoint:"Re-run this endpoint call if it fails, up to N attempts.",workflow:"Re-run the whole workflow run if it fails, up to N attempts."};function jr({value:e,onChange:t,readOnly:s,target:o="step"}){const r=!!e,i=(e==null?void 0:e.maxAttempts)??3,a=(e==null?void 0:e.delayMs)??1e3,l=(e==null?void 0:e.backoff)??"fixed",c=u=>t({maxAttempts:i,delayMs:a,backoff:l,...e,...u});return n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[n.jsx("input",{type:"checkbox",checked:r,disabled:s,onChange:u=>t(u.target.checked?{maxAttempts:i,delayMs:a,backoff:l}:void 0)})," ","Retry on failure"]}),n.jsx("span",{className:"w6w-hint",children:gc[o]})]}),r&&n.jsxs("div",{className:"w6w-field-row",children:[n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Attempts"}),n.jsx("input",{type:"number",min:1,value:i,readOnly:s,onChange:u=>c({maxAttempts:Math.max(1,Number(u.target.value)||1)})})]}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Delay (ms)"}),n.jsx("input",{type:"number",min:0,value:a,readOnly:s,onChange:u=>c({delayMs:Math.max(0,Number(u.target.value)||0)})})]}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Backoff"}),n.jsxs("select",{value:l,disabled:s,onChange:u=>c({backoff:u.target.value}),children:[n.jsx("option",{value:"fixed",children:"Fixed"}),n.jsx("option",{value:"exponential",children:"Exponential"})]})]})]})]})}function $s({config:e,onChange:t,readOnly:s,hasGraph:o=!0,failureHandling:r=!0,retryControls:i=!0,reroute:a}){const l=e.onError??"fail";return n.jsxs("div",{className:"w6w-stack",children:[r&&n.jsxs(n.Fragment,{children:[i&&n.jsx(jr,{value:e.retry,onChange:c=>t({...e,retry:c}),readOnly:s}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"On error"}),n.jsxs("select",{value:l,disabled:s,onChange:c=>{const u=c.target.value;t({...e,onError:u==="fail"?void 0:u})},children:[n.jsx("option",{value:"fail",children:"Stop the run (default)"}),n.jsx("option",{value:"continue",children:"Continue to the next step"}),o&&n.jsx("option",{value:"continue-record",children:"Continue to the next step & record the error"})]}),o?n.jsxs("span",{className:"w6w-muted w6w-small",children:["Retries run first: this policy is reached only once this step's retry attempts (if any) are exhausted — a run that succeeds on a later attempt continues down the normal path instead. Once reached, ",n.jsx("strong",{children:"Continue"})," and"," ",n.jsx("strong",{children:"Continue & record the error"})," both carry on down this step's ordinary outgoing edges despite the failure. If this step has an outgoing"," ",n.jsx("strong",{children:"error"})," edge on the canvas, that edge decides what happens instead and this policy is not consulted — drawn by dragging from the step's error exit port."]}):n.jsxs("span",{className:"w6w-muted w6w-small",children:["Retries run first: this policy (and reroute, below) is only reached once this step's retry attempts (if any) are exhausted — a run that succeeds on a later attempt continues normally. This step has no canvas of its own, so it can't carry an error edge. Set a ",n.jsx("strong",{children:"reroute"})," target below to send a failure somewhere else instead of stopping."]})]})]}),a&&n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"Reroute on failure"}),n.jsxs("div",{className:"w6w-field-row",children:[a.picker,a.value&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:s,onClick:()=>a.onChange(void 0),children:"Clear"})]}),n.jsx("span",{className:"w6w-hint",children:"Invoked once, after retry is exhausted, if this step still fails; its output becomes this step's output."})]}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Notes"}),n.jsx("textarea",{rows:3,value:e.notes??"",readOnly:s,placeholder:"A short description — shown under this step on the canvas. Not executed.",onChange:c=>t({...e,notes:c.target.value||void 0})})]})]})}function An(e){return e.$merge!==void 0}function Nr(e){const t=e.$merge;if(t===void 0)return e;if(!(Qe(t)||qe(t)||Ss(t)||typeof t=="string"&&jn(t)))return t&&typeof t=="object"&&!Array.isArray(t)&&!Ze(t)&&!("$merge"in t)?{...e,...t}:null}function kr(e,t,s=[]){if(qe(e)||Ze(e)||ks(e)||Ss(e)||e===null||typeof e!="object")return Dt(e,t);const o=r=>kr(r,t);return Array.isArray(e)?e.map(o):Object.fromEntries(Object.entries(e).map(([r,i])=>[r,s.includes(r)?i:o(i)]))}function Ps({values:e,onChange:t,readOnly:s}){return n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"Form values are applied first. This object adds or replaces top-level fields, including nested objects. Use ƒx to reuse an object from state or a previous step. You can still edit the form."}),n.jsx(He,{params:[{key:"$merge",label:"JSON customization",type:"json",required:!0,default:{},whole:!0}],values:e,onChange:t,readOnly:s}),Nr(e)===null&&n.jsx("p",{role:"alert",className:"w6w-field-error",children:"JSON customization must be an object or an expression that returns an object."}),!s&&An(e)&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>{const{$merge:o,...r}=e;t(r)},children:"Remove JSON customization"})]})}function ss(e,t){const s={...t};for(const o of e){const r=t[o.key];if(!(o.type!=="json"||typeof r!="string"||r.trim()===""))try{s[o.key]=JSON.parse(r)}catch{return{error:`${o.label} is not valid JSON. Check it and try again.`}}}return{values:s}}function rn({fields:e,values:t,onChange:s,enterSubmitProps:o,mode:r="create"}){const i=(a,l)=>s({...t,[a]:l});return n.jsxs("div",{className:"w6w-stack",children:[e.length===0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"This auth method declares no fields — nothing to fill in. The credential will be an empty object."}),e.map(a=>{const l=r==="edit",c=t[a.key]??(l?void 0:a.default)??"";if(a.type==="boolean")return n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[n.jsx("input",{type:"checkbox",checked:!!c,onChange:f=>i(a.key,f.target.checked),...o}),a.label,a.required?" *":""]}),a.hint&&n.jsx("span",{className:"w6w-hint",children:a.hint})]},a.key);const u=a.type==="secret"||a.secret===!0;if(a.type==="json"||a.type==="text")return n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[a.label,a.required?" *":""]}),n.jsx("textarea",{className:u?"w6w-secret-input":void 0,rows:a.type==="json"?6:3,value:String(c??""),placeholder:l&&u?"•••••• (unchanged)":void 0,onChange:f=>i(a.key,f.target.value),name:`w6w-cred-${a.key}`,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,"data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other"}),a.hint&&n.jsx("span",{className:"w6w-hint",children:a.hint})]},a.key);const d=a.type==="number"?"number":"text";return n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[a.label,a.required?" *":""]}),n.jsx("input",{type:d,className:u?"w6w-secret-input":void 0,value:String(c??""),placeholder:l&&u?"•••••• (unchanged)":void 0,onChange:f=>i(a.key,a.type==="number"&&!(l&&f.target.value==="")?Number(f.target.value):f.target.value),name:`w6w-cred-${a.key}`,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,"data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",...o}),a.hint&&n.jsx("span",{className:"w6w-hint",children:a.hint})]},a.key)})]})}function Sr({credentials:e,mode:t,onModeChange:s,selectedId:o,onSelect:r,canUseExisting:i=!0,contract:a}){const l=c=>{const u=Object.values(c.display??{}).filter(Boolean);return u.length>0?`${c.name} (${u.join(", ")})`:c.name};return n.jsxs("div",{className:"w6w-stack",children:[i&&n.jsxs("div",{className:"w6w-field",role:"radiogroup","aria-label":"Credential",children:[n.jsxs("span",{children:["Credential",a?` (${a})`:""]}),n.jsxs("label",{children:[n.jsx("input",{type:"radio",name:"w6w-credential-mode",checked:t==="existing",onChange:()=>s("existing")})," ","Use existing"]}),n.jsxs("label",{children:[n.jsx("input",{type:"radio",name:"w6w-credential-mode",checked:t==="new",onChange:()=>s("new")})," ","Create new"]})]}),i&&t==="existing"&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Stored credential"}),n.jsx("select",{name:"w6w-credential-id",value:o,onChange:c=>r(c.target.value),children:e.map(c=>n.jsx("option",{value:c.id,children:l(c)},c.id))})]})]})}function Cr(e){const t=(e.bindingFields??[]).filter(r=>r.key!=="delegatedUser");return e.impersonation==="none"?t:[{...(e.bindingFields??[]).find(r=>r.key==="delegatedUser")??{type:"string"},key:"delegatedUser",label:"Impersonated user",type:"string",required:e.impersonation==="required"},...t]}function Ar(e,t){const s={},o={};for(const r of e){const i=t[r.key];i==null||i===""||(r.key==="delegatedUser"?s.delegatedUser=String(i):o[r.key]=i)}return Object.keys(o).length>0&&(s.settings=o),Object.keys(s).length>0?s:void 0}const yc="width=560,height=720,menubar=no,toolbar=no,location=no";function Er(e){return new Promise((t,s)=>{const o=window.open(e,"w6w-oauth",yc);if(!o){s(new Error("Popup blocked — allow popups for this site and try again."));return}let r=!1;const i=()=>{r=!0,window.removeEventListener("message",a),window.clearInterval(l)},a=c=>{const u=c.data;if((u==null?void 0:u.w6w)==="oauth-result"){i();try{o.close()}catch{}u.ok&&typeof u.connectionId=="string"?t({connectionId:u.connectionId}):s(new Error(u.error??"OAuth flow failed."))}};window.addEventListener("message",a);const l=window.setInterval(()=>{r||o.closed&&(i(),s(new Error("OAuth popup was closed before the flow completed.")))},500)})}const xc=new Set(["checkbox","radio","button","submit","reset","file","range","color","image","hidden","date","datetime-local","month","week","time"]);function vc(e){return e.closest('[contenteditable]:not([contenteditable="false"])')!==null}function Rr(e,t){return{onKeyDown:s=>{if((t==null?void 0:t.enabled)===!1||s.key!=="Enter"||s.shiftKey||s.altKey||s.ctrlKey||s.metaKey||s.nativeEvent.isComposing)return;const o=s.target;o.tagName!=="TEXTAREA"&&(vc(o)||o.tagName==="INPUT"&&xc.has(o.type)||(s.preventDefault(),e()))}}}function _s(e){const t=ye(),[s,o]=w.useState(null),[r,i]=w.useState(!!e.initialAppId);return w.useEffect(()=>{const a=e.initialAppId;if(!a)return;let l=!1;const c=f=>{l||(o(f),i(!1))},u=t.listAppsByIds;if(u)return u([a]).then(f=>c(f.find(p=>p.id===a)??null)).catch(()=>c(null)),()=>{l=!0};const d=t.listApps;return typeof d=="function"?d().then(f=>c(f.find(p=>p.id===a)??null)).catch(()=>c(null)):c(null),()=>{l=!0}},[t,e.initialAppId]),s?n.jsx(Se,{title:s.displayName,subtitle:n.jsxs(n.Fragment,{children:[n.jsx("code",{children:s.id}),s.version&&` · v${s.version}`]}),onClose:e.onClose,size:"xl",titleIcon:n.jsx(ft,{src:s.iconSvg,srcDark:s.iconSvgDark,brandColor:s.brandColor,name:s.displayName,theme:e.theme,size:22}),headerRight:e.initialAppId?void 0:n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>o(null),children:"← Apps"}),children:n.jsx(jc,{app:s,onCreated:e.onCreated,onClose:e.onClose})}):r?n.jsx(Se,{title:"Add connection",onClose:e.onClose,size:"xl",children:n.jsx("div",{className:"w6w-stepbuilder-content",children:n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"})})}):n.jsx(Se,{title:"Add connection",onClose:e.onClose,size:"xl",children:n.jsx("div",{className:"w6w-stepbuilder-content",children:n.jsx(at,{onSelectApp:o,theme:e.theme,searchPlaceholder:"Search apps to connect…",categoryFilter:!0})})})}function jc({app:e,onCreated:t,onClose:s}){var U,V;const o=ye(),[r,i]=w.useState(null),[a,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState({}),[p,h]=w.useState(null),[b,m]=w.useState(!1),[x,g]=w.useState(null),[y,N]=w.useState(null),[A,k]=w.useState(""),[C,v]=w.useState(""),[E,R]=w.useState({}),F=w.useRef(null);w.useEffect(()=>{let P=!1;return i(null),o.getAppAuth(e.id).then(B=>!P&&i(B.filter(ae=>ae.available!==!1))).catch(B=>!P&&h(B.message)),()=>{P=!0}},[o,e.id]);const T=r??[],O=T.find(P=>P.key===a)??T.find(P=>P.default===!0)??T[0],I=(O==null?void 0:O.fields)??[],M=(O==null?void 0:O.type)==="oauth2",D=O==null?void 0:O.serviceAccount,H=o.listCredentials,Y=o.createCredential,$=!M&&!!D&&typeof H=="function"&&typeof Y=="function",G=((U=D==null?void 0:D.accepts)==null?void 0:U[0])??"",ne=(x??[]).filter(P=>P.contract===G&&P.status==="active"),oe=ne.length===0?"new":y??"existing",X=ne.some(P=>P.id===A)?A:((V=ne[0])==null?void 0:V.id)??"",L=$&&D?Cr(D):[];w.useEffect(()=>{if(!$||!H)return;let P=!1;return g(null),N(null),F.current=null,H.call(o,{contract:G}).then(B=>!P&&g(B)).catch(()=>!P&&g([])),()=>{P=!0}},[o,$,G,H]);const z=(O==null?void 0:O.key)==="zero-credential",Z=P=>P===void 0||P==="",q=!M&&!z&&($?x===null||L.some(P=>P.required&&Z(E[P.key]))||(oe==="existing"?X==="":C.trim()===""||I.some(P=>P.required&&Z(d[P.key]))):I.some(P=>P.required&&Z(d[P.key]))),J=!O||!M&&!z&&q||b;async function te(){if(O){h(null),m(!0);try{if(z)t({connectionId:`zerocred:${e.id}`});else if(M){const{authorizationUrl:P}=await o.startAppOAuthFlow(e.id,O.key,{displayName:c||void 0}),{connectionId:B}=await Er(P);t({connectionId:B})}else if($&&Y){let P=oe==="existing"?X:F.current;if(P===null){const he=ss(I,d);if("error"in he){h(he.error);return}const ge=await Y.call(o,{name:C.trim(),contract:G,source:he.values});F.current=ge.id,P=ge.id}const B=Ar(L,E),ae={authKey:O.key,credentialId:P,...B?{binding:B}:{},...c?{displayName:c}:{}},fe=await o.createConnection(e.id,ae);t({connectionId:fe.id})}else{const P=ss(I,d);if("error"in P){h(P.error);return}const B=await o.createConnection(e.id,{authKey:O.key,credential:P.values,displayName:c||void 0});t({connectionId:B.id})}}catch(P){h(P.message)}finally{m(!1)}}}const S=Rr(te,{enabled:!J});return n.jsxs("div",{className:"w6w-stepconfig",children:[n.jsx("div",{className:"w6w-modal-body",children:n.jsxs("div",{className:"w6w-stack",children:[r===null&&n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading auth methods…"}),r!==null&&T.length===0&&n.jsx("p",{className:"w6w-muted w6w-small",children:"This app has no available auth methods. If it uses OAuth, its client credentials may not be configured on the server yet."}),T.length>1&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Auth method"}),n.jsx("select",{value:(O==null?void 0:O.key)??"",onChange:P=>{l(P.target.value),f({}),R({}),F.current=null,h(null)},children:T.map(P=>n.jsxs("option",{value:P.key,children:[P.displayName??P.key," (",P.type,")"]},P.key))})]}),O&&n.jsxs(n.Fragment,{children:[!z&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Display name"}),n.jsx("input",{type:"text",value:c,onChange:P=>u(P.target.value),placeholder:"e.g. Production API key",maxLength:80,name:"w6w-connection-label",autoComplete:"off","data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",...S})]}),O.description&&n.jsx("p",{className:"w6w-muted w6w-small",children:O.description}),z?null:M?n.jsxs("p",{className:"w6w-muted w6w-small",children:["You'll be redirected to ",n.jsx("strong",{children:O.displayName??O.key})," to authorize this connection."]}):$&&D?n.jsxs(n.Fragment,{children:[n.jsx(Sr,{credentials:ne,mode:oe,onModeChange:P=>{N(P),F.current=null},selectedId:X,onSelect:k,canUseExisting:ne.length>0,contract:G}),D.scopes.length>0&&n.jsxs("p",{className:"w6w-muted w6w-small",children:["Scopes: ",n.jsx("code",{children:D.scopes.join(" ")})]}),L.length>0&&n.jsx(rn,{fields:L,values:E,onChange:R,enterSubmitProps:S}),oe==="new"&&n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Credential name *"}),n.jsx("input",{type:"text",value:C,onChange:P=>v(P.target.value),placeholder:"e.g. Workspace automation",maxLength:80,name:"w6w-credential-name",autoComplete:"off","data-1p-ignore":"true","data-lpignore":"true","data-bwignore":"true","data-form-type":"other",...S})]}),n.jsx(rn,{fields:I,values:d,onChange:f,enterSubmitProps:S})]})]}):n.jsx(rn,{fields:I,values:d,onChange:f,enterSubmitProps:S})]}),p&&n.jsx("div",{className:"w6w-result w6w-error",children:p})]})}),n.jsxs("div",{className:"w6w-modal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),n.jsx("button",{type:"button",className:"w6w-btn",disabled:J,onClick:te,children:b?z?"Saving…":M?"Waiting for authorization…":"Saving…":z?"Use this":M?`Sign in with ${(O==null?void 0:O.displayName)??(O==null?void 0:O.key)??"provider"}`:"Save connection"})]})]})}function Tr(e){const{label:t,onClick:s,disabled:o,className:r,...i}=e;return n.jsx(Nn,{label:t,onClick:s,disabled:o,className:r,danger:!0,icon:"delete","data-testid":i["data-testid"]})}function Or({values:e,onChange:t,readOnly:s}){const o=Array.isArray(e.routes)?e.routes:fn(We,"route").routes,r=o.filter(g=>!g.default),[i,a]=w.useState(null),[l,c]=w.useState(null),[u,d]=w.useState(null),[f,p]=w.useState(""),h=g=>t({...e,routes:[...g,...o.filter(y=>y.default)]}),b=(g,y)=>h(r.map(N=>N.id===g?{...N,...y}:N)),m=(g,y)=>{const N=r.findIndex(C=>C.id===g);if(N<0||y<0||y>=r.length||N===y)return;const A=[...r],[k]=A.splice(N,1);A.splice(y,0,k),h(A)},x=g=>{f.trim()&&b(g.id,{label:f.trim()}),d(null)};return n.jsxs("div",{className:"w6w-router-editor",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"First match wins. Drag routes to change their order."}),n.jsx("div",{className:"w6w-router-routes",children:r.map((g,y)=>n.jsxs("div",{className:`w6w-router-route${i===g.id?" is-dragging":""}${l===g.id?" is-drop-target":""}`,"data-route-id":g.id,onDragOver:N=>{s||!i||i===g.id||(N.preventDefault(),N.dataTransfer.dropEffect="move",c(g.id))},onDrop:N=>{N.preventDefault(),!s&&i&&m(i,y),a(null),c(null)},children:[n.jsxs("div",{className:"w6w-router-route-heading",children:[n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-router-grip",draggable:!s,disabled:s,"aria-label":`Reorder ${g.label||g.id}`,title:"Drag to reorder · arrow keys to move",onDragStart:N=>{N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",g.id);const A=N.currentTarget.closest(".w6w-router-route");A&&N.dataTransfer.setDragImage(A,16,16),a(g.id)},onDragEnd:()=>{a(null),c(null)},onKeyDown:N=>{N.key!=="ArrowUp"&&N.key!=="ArrowDown"||(N.preventDefault(),m(g.id,y+(N.key==="ArrowUp"?-1:1)))},children:n.jsx(ue.Icon,{name:"grip",size:14})}),n.jsx("span",{className:"w6w-step-rename",children:u===g.id&&!s?n.jsx("input",{autoFocus:!0,"aria-label":"Route name",value:f,onChange:N=>p(N.target.value),onBlur:()=>x(g),onKeyDown:N=>{N.key==="Enter"&&x(g),N.key==="Escape"&&d(null)}}):n.jsxs("button",{type:"button",className:"w6w-router-route-name",disabled:s,"aria-label":`Rename ${g.label||g.id}`,onClick:()=>{p(g.label||g.id),d(g.id)},children:[g.label||g.id,!s&&n.jsx(ue.Icon,{name:"edit",size:12})]})}),n.jsx(Tr,{label:`Remove ${g.label||g.id}`,disabled:s,onClick:()=>h(r.filter(N=>N.id!==g.id))})]}),n.jsx(Cn,{values:{condition:g.condition??!1},onChange:N=>b(g.id,{condition:N.condition}),readOnly:s,purpose:"router"})]},g.id))}),n.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-router-add",disabled:s,onClick:()=>{let g=1;for(;o.some(y=>y.id===`route_${g}`);)g++;h([...r,{id:`route_${g}`,label:`Route ${g}`,condition:!1}])},children:[n.jsx("span",{"aria-hidden":"true",children:"+"})," Add route"]})]})}function Ir({value:e,onCommit:t,readOnly:s}){const[o,r]=w.useState(!1),[i,a]=w.useState(e),[l,c]=w.useState(null),u=()=>{const d=i.trim(),f=d&&d!==e?t(d):null;if(f){c(f);return}c(null),r(!1)};return n.jsxs("span",{className:"w6w-step-rename",children:[o&&!s?n.jsx("input",{autoFocus:!0,"aria-label":"Node name",value:i,onChange:d=>{a(d.target.value),c(null)},onBlur:u,onKeyDown:d=>{d.key==="Enter"&&u(),d.key==="Escape"&&(a(e),c(null),r(!1))}}):n.jsxs(n.Fragment,{children:[n.jsx("code",{children:e}),!s&&n.jsx("button",{type:"button",className:"w6w-icon-btn w6w-btn-sm",title:"Rename node","aria-label":"Rename node",onClick:()=>{a(e),r(!0)},children:n.jsx(ue.Icon,{name:"edit",size:15})})]}),l&&n.jsx("span",{className:"w6w-hint",role:"alert",style:{color:"var(--w6w-danger)"},children:l})]})}function $r({values:e,onChange:t,readOnly:s}){const o=e.condition!==void 0&&e.condition!==!0;return n.jsxs("div",{className:"w6w-stack",children:[n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Stop when"}),n.jsxs("select",{"aria-label":"Stop when",disabled:s,value:o?"condition":"always",onChange:r=>{const i=r.target.value==="condition";t({...e,condition:!i})},children:[n.jsx("option",{value:"always",children:"Always"}),n.jsx("option",{value:"condition",children:"A condition matches"})]})]}),o?n.jsx(Cn,{values:e,onChange:t,readOnly:s,purpose:"stop"}):n.jsx("p",{className:"w6w-muted w6w-small",children:"End the whole workflow successfully here, including any remaining loop iterations."})]})}const Pr="default-src 'none'; style-src 'unsafe-inline'; img-src data:; base-uri 'none'; form-action 'none'";function _r(e){return`<!doctype html><meta http-equiv="Content-Security-Policy" content="${Pr}">${e}`}function Lr({html:e}){return n.jsx("iframe",{title:"HTML preview",className:"w6w-html-preview",sandbox:"",referrerPolicy:"no-referrer",srcDoc:_r(e)})}function Fr(e){return typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":"null"}function Nc(e){return Fr(e)==="string"?JSON.stringify(e):String(e)}function kc(e){return typeof e=="object"&&e!==null}function Sc(e,t){return`${t} ${e?"item":"key"}${t===1?"":"s"}`}function Cc({value:e,expandDepth:t=2}){return n.jsx(Mr,{label:void 0,value:e,depth:0,expandDepth:t})}function Mr(e){const{label:t,value:s,depth:o,expandDepth:r}=e,i=kc(s),a=Array.isArray(s),l=i?a?s.map((u,d)=>[d,u]):Object.entries(s):[],c=t===void 0?null:n.jsx("span",{className:"w6w-json-key",children:t});return i&&l.length>0?n.jsxs("details",{className:"w6w-json-node",open:o<r,children:[n.jsxs("summary",{children:[c,a?"[…]":"{…}"," ",n.jsx("span",{className:"w6w-json-count",children:Sc(a,l.length)})]}),n.jsx("div",{className:"w6w-json-children",children:l.map(([u,d])=>n.jsx(Mr,{label:u,value:d,depth:o+1,expandDepth:r},String(u)))})]}):n.jsxs("div",{className:"w6w-json-leaf",children:[c,c===null?null:": ",n.jsx("span",{className:`w6w-json-${i?"null":Fr(s)}`,children:i?a?"[]":"{}":Nc(s)})]})}const Dr=262144,Ac=/^#{1,6}\s+\S/,Ec=/^```/,Rc=/^\s*(?:[-*+]|\d+\.)\s+\S/,Tc=/\[[^\]\n]+\]\(https?:\/\/[^)\s]+\)/;function Hr(e){if(e===void 0)return{format:"text",text:""};if(typeof e!="string")return{format:"json",data:e};const t=e.trim();if(t.startsWith("{")||t.startsWith("["))try{const o=JSON.parse(t);if(o!==null&&typeof o=="object")return{format:"json",data:o}}catch{}if(/^<!doctype html/i.test(t)||/^<html[\s>]/i.test(t))return{format:"html",text:e};if(t.startsWith("<")&&t.endsWith(">"))return{format:"xml",text:e};const s=t.split(`
19
+ `);return s.some(o=>Ac.test(o)||Ec.test(o))||s.filter(o=>Rc.test(o)).length>=2||Tc.test(t)?{format:"markdown",text:e}:{format:"text",text:e}}function Br(e){return e.format==="json"?JSON.stringify(e.data,null,2)??"":e.text}const Oc=65536;function Bn(e,t){return e.length>Oc?n.jsx("pre",{className:"w6w-result-viewer-text",children:e}):n.jsx(ue.CodeBlock,{code:e,language:t,copyable:!1,wrap:!0})}function Re(e){const{value:t,format:s="auto",maxHeight:o=320,className:r}=e,i=w.useMemo(()=>s==="json"?{format:"json",data:t}:Hr(t),[t,s]),[a,l]=w.useState("rendered"),[c,u]=w.useState(2),[d,f]=w.useState(0),p=i.format==="json"?"":i.text,h=i.format==="html"||i.format==="markdown",b=h&&p.length>Dr,m=w.useMemo(()=>{try{return Br(i)}catch{return typeof t=="string"?t:String(t)}},[i,t]);let x;if(i.format==="json")x=n.jsx(Cc,{value:i.data,expandDepth:c},d);else if(i.format==="xml")x=Bn(i.text,"markup");else if(i.format==="text")x=n.jsx("pre",{className:"w6w-result-viewer-text",children:i.text});else{const y=i.format==="html"?"markup":"markdown";b?x=n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-muted w6w-small w6w-result-viewer-note",children:"Too large to render — showing source."}),Bn(i.text,y)]}):a==="source"?x=Bn(i.text,y):i.format==="html"?x=n.jsx(Lr,{html:i.text}):x=n.jsx(xs,{content:i.text})}let g=null;return i.format==="json"?g=n.jsxs("div",{className:"w6w-result-viewer-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>{u(Number.POSITIVE_INFINITY),f(y=>y+1)},children:"Expand all"}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>{u(1),f(y=>y+1)},children:"Collapse all"})]}):h&&!b&&(g=n.jsxs("div",{className:"w6w-result-viewer-bar",children:[n.jsx("button",{type:"button",className:`w6w-btn w6w-btn-ghost${a==="rendered"?" active":""}`,"data-mode":"rendered","aria-pressed":a==="rendered",onClick:()=>l("rendered"),children:"Rendered"}),n.jsx("button",{type:"button",className:`w6w-btn w6w-btn-ghost${a==="source"?" active":""}`,"data-mode":"source","aria-pressed":a==="source",onClick:()=>l("source"),children:"Source"})]})),n.jsxs("div",{className:["w6w-result-viewer",r??""].filter(Boolean).join(" "),"data-format":i.format,children:[g,n.jsx(ue.Copyable,{value:m,label:"Copy result",className:"w6w-copyable--hover",children:n.jsx("div",{className:"w6w-result-viewer-body",style:{maxHeight:o,overflow:"auto"},children:x})})]})}function Wr(e,t){const s=e.filter(o=>o.appId===Le);return s.find(o=>o.nodeId===t)??s.find(o=>!o.nodeId)??s[0]??null}const Ic=/auth|token|secret|passw|cookie|api[-_]?key|signature|session/i,$c="••••••";function Pc(e){const t={};for(const[s,o]of Object.entries(e))t[s]=Ic.test(s)?$c:o;return t}const _c=20;function Lc({workflowId:e,stepId:t,stepWith:s,readOnly:o,onUse:r,using:i}){const a=ye(),[l,c]=w.useState(void 0),[u,d]=w.useState(!1),[f,p]=w.useState({phase:"idle"}),[h,b]=w.useState(()=>Date.now()),m=w.useRef(null);w.useEffect(()=>{const C=a.listSubscriptionsForWorkflow;if(!C)return;let v=!1;return C(e).then(E=>!v&&c(Wr(E,t))).catch(E=>!v&&p({phase:"error",message:E.message})),()=>{v=!0}},[a,e,t]);const x=w.useCallback(C=>{var E;const v=m.current;m.current=null,v&&(v.abort.abort(),C&&((E=a.stopWebhookListen)==null||E.call(a,v.subId,v.sessionId).catch(()=>{})))},[a]);w.useEffect(()=>()=>x(!0),[x]),w.useEffect(()=>{if(f.phase!=="waiting")return;const C=setInterval(()=>b(Date.now()),1e3);return()=>clearInterval(C)},[f.phase]);const g=()=>{const C=a.createSubscription;C&&(d(!0),C(Le,"webhook",{workflowId:e,connectionId:null,params:s??{}}).then(v=>c(v)).catch(v=>p({phase:"error",message:v.message})).finally(()=>d(!1)))},y=async()=>{var T;const C=a.startWebhookListen,v=a.pollWebhookListen;if(!l||!C||!v)return;x(!0),p({phase:"starting"});let E;try{E=(await C(l.id)).session}catch(O){p({phase:"error",message:O.message});return}const R=new AbortController,F={subId:l.id,sessionId:E.id,abort:R};for(m.current=F,b(Date.now()),p({phase:"waiting",session:E});;){let O;try{O=await v(l.id,E.id,{waitSeconds:_c,signal:R.signal})}catch(I){if(m.current!==F)return;m.current=null,p({phase:"error",message:I.message});return}if(m.current!==F)return;if(O.status==="captured"&&O.request){m.current=null,p({phase:"captured",session:O,request:O.request});return}if(O.status==="expired"){m.current=null,(T=a.stopWebhookListen)==null||T.call(a,l.id,E.id).catch(()=>{}),p({phase:"expired"});return}}},N=()=>{x(!0),p({phase:"idle"})};if(!a.startWebhookListen||!a.pollWebhookListen)return null;const A=l==null?void 0:l.webhookUrl,k=f.phase==="waiting"?Math.max(0,Math.ceil((Date.parse(f.session.expiresAt)-h)/1e3)):0;return n.jsxs("div",{className:"w6w-stack w6w-listen","data-testid":"webhook-listen",children:[l===void 0?n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}):A?n.jsxs(n.Fragment,{children:[n.jsx(ue.Copyable,{value:A,readOnly:!0,children:n.jsx("input",{type:"text",readOnly:!0,value:A,"aria-label":"Webhook URL"})}),f.phase==="waiting"||f.phase==="starting"?n.jsxs("div",{className:"w6w-listen-waiting",children:[n.jsx("span",{className:"w6w-listen-pulse","aria-hidden":"true"}),n.jsxs("output",{className:"w6w-small",children:["Waiting for a request to ",n.jsx("code",{children:A}),"…",f.phase==="waiting"&&n.jsxs("span",{className:"w6w-muted",children:[" ",Fc(k)," left"]})]}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:N,children:"Stop"})]}):n.jsxs("div",{className:"w6w-steptest-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn",disabled:o,onClick:()=>void y(),children:f.phase==="captured"?"Listen again":"Listen for test event"}),f.phase==="idle"&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Send a request to this URL — it works before you publish, and starts no run."})]})]}):n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"This webhook has no URL yet. Create one, then listen for a test request."}),!o&&a.createSubscription&&n.jsx("button",{type:"button",className:"w6w-btn",disabled:u,onClick:g,children:u?"Creating…":"Create webhook URL"})]}),f.phase==="expired"&&n.jsx("p",{className:"w6w-muted w6w-small",children:"No request arrived in time. Listen again, then send the request."}),f.phase==="error"&&n.jsx("div",{className:"w6w-result w6w-error",children:f.message}),f.phase==="captured"&&n.jsx(Mc,{request:f.request,receivedAt:f.session.receivedAt,readOnly:o,using:i,onUse:()=>r(f.request),stepId:t})]})}function Fc(e){const t=Math.floor(e/60);return t>0?`${t}:${String(e%60).padStart(2,"0")}`:`${e}s`}function Mc({request:e,receivedAt:t,readOnly:s,using:o,onUse:r,stepId:i}){const a=Object.keys(e.query??{}).length>0;return n.jsxs("div",{className:"w6w-testout w6w-listen-captured","data-testid":"webhook-captured",children:[n.jsxs("div",{className:"w6w-testout-label",children:["Request received",t&&n.jsxs("span",{className:"w6w-muted",children:[" · ",new Date(t).toLocaleTimeString()]})]}),n.jsxs("div",{className:"w6w-small",children:[n.jsx("code",{children:e.method})," ",n.jsx("code",{children:e.path})]}),a&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-testout-label",children:"Query"}),n.jsx(Re,{value:e.query,maxHeight:120})]}),n.jsx("div",{className:"w6w-testout-label",children:"Headers"}),n.jsx(Re,{value:Pc(e.headers??{}),maxHeight:160}),n.jsx("div",{className:"w6w-testout-label",children:"Body"}),n.jsx(Re,{value:e.body,maxHeight:240}),!s&&n.jsxs("div",{className:"w6w-steptest-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn",disabled:o,onClick:r,children:o?"Saving…":"Use as test data"}),n.jsxs("span",{className:"w6w-muted w6w-small",children:["Becomes this trigger's output, so later steps can use"," ",n.jsx("code",{children:`{{ nodes.${i}.output.body… }}`}),"."]})]})]})}function Ls(e){return Array.isArray(e)?e:[]}function qr(e){return e==="object"||e==="array"?"json":e==="number"||e==="boolean"||e==="json"?e:"string"}function Ur(e,t){if(!(t==null||t==="")){if(typeof t=="object")return t;if(e==="number"){const s=Number(t);return Number.isFinite(s)?s:void 0}if(e==="boolean")return t===!0||t==="true";if(e==="json")try{return JSON.parse(String(t))}catch{return}return String(t)}}function Fs(e){return e.filter(t=>typeof t.key=="string"&&t.key.trim()!=="").map(t=>({key:t.key,label:t.key,type:qr(t.type),required:!!t.required}))}function os(e){const t={};for(const s of e){if(typeof s.key!="string"||s.key.trim()==="")continue;const o=Ur(s.type,s.default);o!==void 0&&(t[s.key]=o)}return t}function Vr(e,t){const s=(e??[]).find(r=>r&&r.nodeId===t);if(!s)return;const o=s.input;return o&&typeof o=="object"&&!Array.isArray(o)?o:{}}function Dc(e){return qe(e)||typeof e=="string"&&e.includes("{{")}function Ms(e,t=[]){const s=new Set(t.filter(r=>r.type==="secret").map(r=>r.key)),o={};for(const[r,i]of Object.entries(e))i===void 0||Ze(i)||s.has(r)&&!Dc(i)||(o[r]=i);return o}const rs=new Set;function zr(e){const t=e.then(()=>{},()=>{});return rs.add(t),t.then(()=>rs.delete(t)),e}async function Jr(){await Promise.all([...rs])}function Kr(e,t){const s=ye(),o=typeof s.loadTestInputs=="function"&&!!e&&!!t,[r,i]=w.useState(!o),[a,l]=w.useState(void 0);w.useEffect(()=>{if(!o||!e||!t||!s.loadTestInputs){i(!0);return}let f=!1;return i(!1),Jr().then(()=>{var p;return((p=s.loadTestInputs)==null?void 0:p.call(s,e))??[]}).then(p=>{f||(l(Vr(p,t)),i(!0))}).catch(()=>{f||i(!0)}),()=>{f=!0}},[s,o,e,t]);const c=w.useCallback(f=>{l(f),!(!e||!t||typeof s.saveTestInput!="function")&&zr(s.saveTestInput(e,t,f)).catch(p=>{console.error("test input save failed",p)})},[s,e,t]),u=w.useCallback((f,p)=>c(Ms(f,p)),[c]),d=w.useCallback(()=>c({}),[c]);return{loaded:r,supported:o,input:a,save:u,clear:d}}function Gr({onClear:e}){return n.jsxs("p",{className:"w6w-muted w6w-small","data-testid":"last-used-note",children:["last used values ·"," ",n.jsx("button",{type:"button",className:"w6w-linkbtn",onClick:e,children:"Clear"})]})}const Hc=600;function Yr({app:e,action:t,fields:s,persist:o,listen:r}){const i=ye(),a=ys(),l=w.useMemo(()=>Ls(s),[s]),c=w.useMemo(()=>Fs(l),[l]),u=c.length>0,[d,f]=w.useState(()=>os(l)),[p,h]=w.useState(null),b=o==null?void 0:o.workflowId,m=o==null?void 0:o.stepId,x=Kr(b,m),[g,y]=w.useState(!1),[N,A]=w.useState(!1),[k,C]=w.useState(!b||!m);w.useEffect(()=>{if(!b||!m){C(!0);return}if(!x.loaded)return;if(x.input!==void 0){const z=x.input;Object.keys(z).length>0&&(f(Z=>({...Z,...z})),y(!0),A(!0)),C(!0);return}let L=!1;return i.listStepTests(b,m).then(z=>{if(L)return;const Z=z.length?z[z.length-1]:null;Z!=null&&Z.with&&(f(q=>({...q,...Z.with})),Object.keys(Z.with).length>0&&A(!0)),C(!0)}).catch(()=>{L||C(!0)}),()=>{L=!0}},[i,b,m,x.loaded]);const[v,E]=w.useState(0),R=()=>{clearTimeout(T.current),F.current=null,x.clear(),y(!1),f(os(l)),E(L=>L+1)},F=w.useRef(null),T=w.useRef(void 0),O=w.useRef(()=>{});O.current=()=>{clearTimeout(T.current);const L=F.current;F.current=null,L&&x.save(L,c)},w.useEffect(()=>()=>O.current(),[]);const I=L=>{f(L),!(!b||!m||!k)&&(F.current=L,clearTimeout(T.current),T.current=setTimeout(()=>O.current(),Hc))},[M,D]=w.useState(!0),H=M&&jt(c,d),Y=async L=>{const z=L??d;clearTimeout(T.current),F.current=null,o&&x.save(z,c),h({status:"running"});let Z;try{const q=await i.invokeAction(e,t,{input:z},{project:a});Z={status:"done",value:q.value,logs:q.logs}}catch(q){const J=q;Z={status:"error",error:J.message??String(q),errorCode:J.code,logs:J.logs}}if(h(Z),o)try{const q=await i.saveStepTest(o.workflowId,o.stepId,{input:o.input,with:z});await i.recordStepTestRun(o.workflowId,o.stepId,{stepTestId:q.id,status:Z.status==="done"?"succeeded":"failed",input:o.input,output:Z.status==="done"?Z.value:void 0,error:Z.status==="error"?Z.error:void 0})}catch(q){console.error("step test persist failed",q)}},$=p&&p.status!=="running"?p.logs:void 0,G=L=>{const z={...L};f(z),Y(z)},ne=r&&o&&n.jsx(Lc,{workflowId:o.workflowId,stepId:o.stepId,stepWith:r.stepWith,readOnly:r.readOnly,onUse:G,using:(p==null?void 0:p.status)==="running"});return n.jsxs("div",{className:"w6w-stack",children:[ne,ne?n.jsxs("details",{className:"w6w-listen-manual","data-testid":"trigger-sample-payload",open:N,onToggle:L=>A(L.currentTarget.open),children:[n.jsx("summary",{className:"w6w-small",children:"Or test with a sample payload"}),oe()]}):oe(),X()]});function oe(){return n.jsxs("div",{className:"w6w-stack",children:[k?n.jsxs(n.Fragment,{children:[g&&n.jsx(Gr,{onClear:R}),n.jsx(Oi,{params:c,values:d,onChange:I,onValidityChange:D},v),!u&&n.jsxs("span",{className:"w6w-hint",children:["This trigger declares no fields — provide a sample payload to test with. It becomes the trigger's output state (",n.jsx("code",{children:"input"}),")."]})]}):n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading saved values…"}),n.jsx("div",{className:"w6w-steptest",children:n.jsxs("div",{className:"w6w-steptest-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:!k||!H||(p==null?void 0:p.status)==="running",onClick:()=>void Y(),children:(p==null?void 0:p.status)==="running"?"Running…":"▶ Test run"}),k&&!H&&n.jsx("span",{className:"w6w-muted w6w-small",children:M?"Fill the required fields to test.":"The payload must be a JSON object to test."})]})})]})}function X(){return n.jsxs("div",{className:"w6w-steptest",children:[(p==null?void 0:p.status)==="error"&&n.jsxs("div",{className:"w6w-result w6w-error",children:[p.errorCode&&n.jsx("div",{className:"w6w-small",style:{opacity:.75,marginBottom:4},children:n.jsx("code",{children:p.errorCode})}),p.error]}),(p==null?void 0:p.status)==="done"&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Output state (filled values)"}),n.jsx(Re,{value:p.value,maxHeight:220})]}),$&&$.length>0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Console output"}),n.jsx("pre",{className:"w6w-result w6w-testout-console",style:{whiteSpace:"pre-wrap",maxHeight:160,overflow:"auto",margin:0},children:$.join(`
20
+ `)})]})]})}}const Bc=[["s","Seconds"],["m","Minutes"],["h","Hours"],["d","Days"],["w","Weeks"]],Wc=/^(?=\d)(?:\d+w)?(?:\d+d)?(?:\d+h)?(?:\d+m)?(?:\d+(?:\.\d+)?s)?$|^P(?:\d+W)?(?:\d+D)?(?:T(?=\d)(?:\d+H)?(?:\d+M)?(?:\d+(?:\.\d+)?S)?)?$/i;function Xr({values:e,onChange:t,readOnly:s}){const o=e.duration??"1s",r=typeof o=="string"?o.match(/^(\d+(?:\.\d+)?)([smhdw])$/i):null,[i,a]=w.useState("s"),[l,c]=w.useState("text"),[u,d]=w.useState(e.until?"until":"duration"),f=typeof o=="string"&&(!Wc.test(o.trim())||/^P$/i.test(o.trim()));return n.jsxs("div",{className:"w6w-params-form",children:[n.jsxs("label",{children:["Wait for",n.jsxs("select",{"aria-label":"Wait for",disabled:s,value:u,onChange:p=>{const h=p.target.value;d(h),t({...e,duration:h==="duration"?"1s":"",until:""})},children:[n.jsx("option",{value:"duration",children:"A duration"}),n.jsx("option",{value:"until",children:"Until a timestamp"})]})]}),u==="until"?n.jsx(He,{params:[{key:"until",label:"Until",type:"string",hint:"ISO-8601 timestamp, e.g. 2026-10-08T09:00:00Z."}],values:e,onChange:t,readOnly:s}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{children:["Duration input",n.jsxs("select",{"aria-label":"Duration input",disabled:s,value:l,onChange:p=>{r&&a((r==null?void 0:r[2].toLowerCase())??i),c(p.target.value)},children:[n.jsx("option",{value:"text",children:"Shorthand"}),n.jsx("option",{value:"value",disabled:!r,children:"Value and unit"})]})]}),l==="value"?n.jsxs("div",{className:"w6w-field-row",children:[n.jsxs("label",{children:["Value",n.jsx("input",{"aria-label":"Duration value",type:"number",min:"0",step:((r==null?void 0:r[2].toLowerCase())??i)==="s"?"any":"1",disabled:s,value:(r==null?void 0:r[1])??"",onChange:p=>t({...e,duration:`${p.target.value}${(r==null?void 0:r[2].toLowerCase())??i}`})})]}),n.jsxs("label",{children:["Unit",n.jsx("select",{"aria-label":"Duration unit",disabled:s,value:(r==null?void 0:r[2].toLowerCase())??i,onChange:p=>{a(p.target.value),t({...e,duration:`${(r==null?void 0:r[1])??""}${p.target.value}`})},children:Bc.map(([p,h])=>n.jsx("option",{value:p,children:h},p))})]})]}):n.jsx(He,{params:[{key:"duration",label:"Duration",type:"string",default:"1s",hint:"Use 30s, 1h30m30s, or 3d30s. Units: w, d, h, m, s, in that order. Uppercase and ISO-8601 also work. Value and unit is available for single-unit durations."}],values:e,onChange:t,readOnly:s}),f&&n.jsx("p",{role:"alert",children:"Enter a duration such as 30s or 1h30m30s, using units w, d, h, m, s in order."})]})]})}function Zr({anchorRef:e,onClose:t,children:s}){const o=w.useRef(null),[r,i]=w.useState(null),[a,l]=w.useState(null);return w.useEffect(()=>{const c=e.current;if(!c)return;const u=c.getBoundingClientRect();i({top:u.bottom+6,left:u.left,width:u.width}),l(c.closest("dialog")??document.body)},[e]),w.useEffect(()=>{function c(d){var p,h;const f=d.target;(p=o.current)!=null&&p.contains(f)||(h=e.current)!=null&&h.contains(f)||t()}function u(d){d.key==="Escape"&&t()}return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u)}},[t,e]),!r||!a?null:dn.createPortal(n.jsx("div",{ref:o,className:"w6w-flyout",style:{top:r.top,left:r.left,width:r.width},children:s}),a)}function Qr(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const s=Object.keys(e),o=Object.keys(t);return s.length!==o.length?!1:s.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&Qr(e[r],t[r]))}function qc(e,t){return e.map(s=>{const o=t&&Object.hasOwn(t,s.id)?t[s.id]:void 0,r=s.data.stepProblems;if(o===void 0||o.length===0){if(r===void 0&&!("stepProblems"in s.data))return s;const{stepProblems:i,...a}=s.data;return{...s,data:a}}return r&&Qr(r,o)?s:{...s,data:{...s.data,stepProblems:structuredClone(o)}}})}const Uc={body_not_literal:"This loop's body is not a list of step ids",body_unknown_step:"This loop's body names a step that doesn't exist",body_self:"This loop's body contains the For each itself",body_duplicate:"This loop's body lists a step twice",body_claimed_twice:"A step in this loop's body is also owned by another control step",body_contains_control:"This loop's body contains a control step (If, For each, Parallel…)",body_step_has_edges:"A step in this loop's body also has its own connections",legacy_not_linear:"The steps after this For each aren't one straight line, so they can't be read as its loop body"};function Vc(e){switch(e.code){case"unknown_connection":return`Connection ${e.connection} no longer exists — open the step and choose another on the Setup tab`;case"foreach_wrapped_items":return"Items wraps a list in another list — this loops once";case"foreach_body_refs_output":return`Refers to the For each's output (${e.refs.join(", ")}) from inside its loop — use Current item instead`;case"loop_body_invalid":{const t=Uc[e.reason.reason]??"This loop's body is not valid";return e.reason.stepId?`${t} (${e.reason.stepId})`:t}case"state_parallel_write":return`Writes ${`state${e.path.length?`.${e.path.join(".")}`:""}`} at the same time as ${e.with.join(", ")} — parallel branches don't see each other's writes; the final value follows the workflow's step order`;case"setup_incomplete":return`Setup incomplete — ${e.items.join(", ")}`}}function zc(e,t){return(t==null?void 0:t.some(s=>s.code==="unknown_connection"&&e.uses.connection===s.connection))??!1}function Lo(e,t,s){if(!e)return"No connection";if(s)return"Couldn't load connections";if(t===null)return e;const o=t.find(r=>r.id===e);return o?o.builtIn?"Built-in":o.displayName??e:"Missing connection — choose another"}function an(e,t,s){if(s.type==="update"){const r=an(e,t,{type:"rename",ref:s.ref,name:s.name}),i=s.name.trim(),a=an(r.nodes,r.connections,{type:"replace",ref:i,connection:s.connection});return s.nodeIds?an(a.nodes,a.connections,{type:"assign",ref:i,nodeIds:s.nodeIds}):a}if(s.type==="add"||s.type==="rename"){const r=s.name.trim();if(!r)throw new Error("Give the workflow connection a name.");if(Object.hasOwn(t,r)&&(s.type==="add"||r!==s.ref))throw new Error("A workflow connection already uses that name.");if(s.type==="add")return{nodes:e,connections:{...t,[r]:{app:s.app,connection:s.connection}}}}if(!Object.hasOwn(t,s.ref))throw new Error("This workflow connection no longer exists.");const o=t[s.ref];switch(s.type){case"replace":return{nodes:e,connections:{...t,[s.ref]:{...o,connection:s.connection}}};case"rename":{const r=s.name.trim();return{connections:Object.fromEntries(Object.entries(t).map(([i,a])=>[i===s.ref?r:i,a])),nodes:e.map(i=>i.uses.connectionRef===s.ref?qt(i,r):i)}}case"remove":{if(e.some(a=>a.uses.connectionRef===s.ref))throw new Error("Choose another connection for its nodes before removing this resource.");const{[s.ref]:r,...i}=t;return{nodes:e,connections:i}}case"assign":{const r=new Set(s.nodeIds);if(e.some(i=>r.has(i.id)&&i.uses.app!==o.app))throw new Error("A connection can only be assigned to nodes for the same app.");return{connections:t,nodes:e.map(i=>r.has(i.id)?qt(i,s.ref):i)}}}}function St(e,t){const{connectionRef:s,connection:o,app:r}=e.uses;if(s===void 0)return o??void 0;const i=t&&Object.hasOwn(t,s)?t[s]:void 0;return(i==null?void 0:i.app)===r?i.connection??void 0:void 0}function Ds(e,t){const o=(e.split(/[./]/).filter(Boolean).at(-1)??"connection").toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"connection";let r=1;for(;Object.hasOwn(t,`${o}_${r}`);)r++;return`${o}_${r}`}function ei(e){let t=e.connections??{},s=!1;const o=(e.nodes??[]).map(r=>{if(!r.uses.connection||r.uses.connectionRef!==void 0)return r;const i=Object.hasOwn(t,r.id)?t[r.id]:void 0,a=(i==null?void 0:i.app)===r.uses.app&&i.connection===r.uses.connection?r.id:Ds(r.uses.app,t);return t={...t,[a]:{app:r.uses.app,connection:r.uses.connection}},s=!0,qt(r,a)});return s?{...e,nodes:o,connections:t}:e}function qt(e,t){const{connection:s,...o}=e.uses;return{...e,uses:{...o,connectionRef:t}}}function Jc(e,t,s,o){if(!t){const{connection:l,connectionRef:c,...u}=e.uses;return{step:{...e,uses:u},connections:o}}const r=e.uses.connectionRef,i=r&&s.some(l=>l.id!==e.id&&l.uses.connectionRef===r),a=r&&!i?r:Ds(e.uses.app,o);return{step:qt(e,a),connections:{...o,[a]:{app:e.uses.app,connection:t}}}}function ln(e,t,s,o){return t?s.filter(r=>r.uses.app===e&&St(r,o)===t):[]}function ti(e,t,s,o,r){if(r)return{connection:r};for(const l of[...s].reverse()){if(l.id===e.id||l.uses.app!==e.uses.app)continue;const c=St(l,o);if(!(!c||!t.some(u=>u.id===c&&u.appId===e.uses.app)))return l.uses.connectionRef?{connectionRef:l.uses.connectionRef}:{connection:c}}for(const[l,c]of Object.entries(o))if(c.app===e.uses.app&&t.some(u=>u.appId===c.app&&u.id===c.connection))return{connectionRef:l};const i=t.filter(l=>l.appId===e.uses.app),a=i.find(l=>l.builtIn)??i[0];return a?{connection:a.id}:{}}function Fo(e,t,s){return s.some(r=>r.builtIn)||!t.some(r=>r.available!==!1&&(r.key==="zero-credential"||r.autoSatisfied===!0&&(r.type==="tenantAuth"||r.type==="jit")))?s:[...s,{id:`zerocred:${e}`,appId:e,authKey:"zero-credential",displayName:"Built-in",builtIn:!0,state:"connected"}]}function Kc(e,t,s,o,r){const i=new Set(ln(e,t,o,r).map(a=>a.uses.connectionRef));return Object.fromEntries(Object.entries(r).map(([a,l])=>[a,i.has(a)?{...l,connection:s}:l]))}const ni=w.createContext(null);function Hs(){return w.useContext(ni)}function si({step:e,conns:t,failed:s=!1,readOnly:o,open:r,onOpenChange:i,anchorRef:a,onChangeConnection:l,onChangeConnectionRef:c,onConnectionCreated:u}){var E,R,F;const d=Hs(),f=o||(d==null?void 0:d.readOnly),p=(d==null?void 0:d.connections)??{},h=(d==null?void 0:d.nodes)??[],b=(t??[]).map(T=>({conn:T,users:ln(e.uses.app,T.id,h,p)})).sort((T,O)=>+(O.users.length>0)-+(T.users.length>0)),m=St(e,p)??(e.uses.connectionRef===void 0?(E=t==null?void 0:t.find(T=>T.builtIn&&T.appId===e.uses.app))==null?void 0:E.id:void 0),x=ln(e.uses.app,m,h,p).filter(T=>T.id!==e.id),[g,y]=w.useState(null),[N,A]=w.useState(!1),k=g||N?((F=(R=a.current)==null?void 0:R.closest("dialog"))==null?void 0:F.parentElement)??document.body:null,C=(T,O)=>{if(!f){if(O&&d&&m){d.setConnections(Kc(e.uses.app,m,T,h,p));const I=h.find(M=>M.id===e.id)??e;I.uses.connectionRef?c(I.uses.connectionRef):l(T)}else{const I=ln(e.uses.app,T,h,p).filter(D=>D.id!==e.id&&D.uses.connectionRef).at(-1),M=Object.entries(p).find(([,D])=>D.app===e.uses.app&&D.connection===T);I!=null&&I.uses.connectionRef?c(I.uses.connectionRef):M?c(M[0]):l(T)}y(null),i(!1)}},v=T=>{f||(i(!1),T!==m&&(x.length>0&&h.some(O=>O.id===e.id)?y(T):C(T,!1)))};return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"w6w-app-conn-btn","aria-label":"Connection","aria-expanded":r,disabled:f||t===null&&!s,onClick:()=>i(!r),children:n.jsx("span",{className:"w6w-conn-label-name",children:t===null&&!s&&!m?"Loading connections…":Lo(m,t,s)})}),r&&n.jsx(Zr,{anchorRef:a,onClose:()=>i(!1),children:n.jsxs("div",{className:"w6w-stack",children:[s&&n.jsx("p",{role:"alert",className:"w6w-field-error",children:"Couldn’t load connections."}),Object.entries(p).some(([,T])=>T.app===e.uses.app)&&n.jsxs("div",{className:"w6w-stack",children:[n.jsx("strong",{className:"w6w-small",children:"Workflow connections"}),n.jsx("div",{className:"w6w-stepbuilder-list",children:Object.entries(p).filter(([,T])=>T.app===e.uses.app).map(([T,O])=>n.jsx("button",{type:"button",className:"w6w-stepbuilder-item",disabled:f||!O.connection||!(t!=null&&t.some(I=>I.id===O.connection)),"aria-pressed":e.uses.connectionRef===T,"data-connection-ref":T,onClick:()=>{c(T),i(!1)},children:n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:T}),n.jsx("span",{className:"w6w-muted w6w-small",children:Lo(O.connection??void 0,t,s)})]})},T))})]}),n.jsx("div",{className:"w6w-stepbuilder-list",children:b.map(({conn:T,users:O})=>n.jsx("button",{type:"button",className:"w6w-stepbuilder-item",disabled:f,"aria-pressed":T.id===m,"data-connection-id":T.id,onClick:()=>v(T.id),children:n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:T.builtIn?"Built-in":T.displayName||T.id}),n.jsx("span",{className:"w6w-muted w6w-small",children:O.length>0?`In use in this workflow · ${O.map(I=>I.id).join(", ")}`:T.builtIn?"Built-in connection":T.state})]})},T.id))}),n.jsx("button",{type:"button",className:"w6w-btn",disabled:f,onClick:()=>{i(!1),A(!0)},children:"+ New connection"})]})}),N&&k&&dn.createPortal(n.jsx(_s,{initialAppId:e.uses.app,onClose:()=>A(!1),onCreated:({connectionId:T})=>{A(!1),u(),v(T)}}),k),g&&k&&dn.createPortal(n.jsxs(Se,{title:"Change connection",onClose:()=>y(null),children:[n.jsxs("div",{className:"w6w-modal-body",children:[n.jsx("p",{children:"Change the connection for all these nodes, or only this node?"}),n.jsxs("ul",{children:[n.jsx("li",{children:e.id||"New node"}),x.map(T=>n.jsx("li",{children:T.id},T.id))]})]}),n.jsxs("div",{className:"w6w-modal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>y(null),children:"Cancel"}),n.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:f,onClick:()=>C(g,!0),children:["All ",x.length+1," nodes"]}),n.jsx("button",{type:"button",className:"w6w-btn",disabled:f,onClick:()=>C(g,!1),children:"Only this node"})]})]}),k)]})}function Gc(e,t){return`${e.method}-${e.url??e.host}-${t}`}function oi({calls:e,defaultOpen:t,keyOf:s,title:o}){if(e.length===0)return null;const r=s??Gc;return n.jsxs("div",{className:"w6w-stack",style:{gap:4},children:[o!==!1&&n.jsx("strong",{className:"w6w-small",children:o??n.jsxs(n.Fragment,{children:["API ",e.length===1?"call":"calls"," (",e.length,")"]})}),e.map((i,a)=>n.jsxs("details",{open:t,className:"w6w-result",style:{padding:8},children:[n.jsx("summary",{style:{cursor:"pointer"},children:n.jsxs("span",{className:"w6w-small",children:[i.method," ",i.url??i.host," →"," ",n.jsx("strong",{children:i.error?"failed":i.status}),i.durationMs!==void 0&&n.jsxs("span",{className:"w6w-muted",children:[" · ",i.durationMs,"ms"]})]})}),n.jsxs("div",{className:"w6w-stack",style:{gap:6,marginTop:8},children:[i.error&&n.jsx("div",{className:"w6w-error w6w-small",children:i.error}),n.jsx("div",{className:"w6w-muted w6w-small",children:"Request headers"}),n.jsx("pre",{className:"w6w-result",children:JSON.stringify(i.requestHeaders??{},null,2)}),i.requestBody&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-muted w6w-small",children:"Request body"}),n.jsx(Re,{value:i.requestBody,maxHeight:240})]}),n.jsx("div",{className:"w6w-muted w6w-small",children:"Response headers"}),n.jsx("pre",{className:"w6w-result",children:JSON.stringify(i.responseHeaders??{},null,2)}),i.responseBody&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-muted w6w-small",children:"Response body"}),n.jsx(Re,{value:i.responseBody,maxHeight:240})]}),i.truncated&&n.jsx("div",{className:"w6w-muted w6w-small",children:"A captured body exceeded the size cap and was truncated."})]})]},r(i,a)))]})}function ri({choices:e,onChange:t,readOnly:s}){const o=new Set(e.selected),r=e.options.every(a=>o.has(a.value)),i=[...e.options,...e.selected.filter(a=>!e.options.some(l=>l.value===a)).map(a=>({value:a,label:a}))];return n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"Triggers *"}),n.jsxs("div",{className:"w6w-multiselect-checks",children:[n.jsxs("div",{className:"w6w-multiselect-checks-toolbar",children:[n.jsxs("label",{className:"w6w-multiselect-check",children:[n.jsx("input",{type:"checkbox",checked:r,ref:a=>{a&&(a.indeterminate=!r&&o.size>0)},disabled:s,onChange:a=>t(a.target.checked?e.options.map(l=>l.value):[])}),n.jsx("span",{children:"All events"})]}),n.jsxs("span",{className:"w6w-muted w6w-small",children:[o.size," selected"]})]}),n.jsx("fieldset",{className:"w6w-multiselect-checks-options","aria-label":"Eventbrite events",children:i.map(a=>n.jsxs("label",{className:"w6w-multiselect-check",children:[n.jsx("input",{type:"checkbox",checked:o.has(a.value),disabled:s,onChange:l=>t(l.target.checked?[...e.selected,a.value]:e.selected.filter(c=>c!==a.value))}),n.jsx("span",{children:a.label})]},a.value))})]}),n.jsx("span",{className:"w6w-hint",children:"Start this workflow when any selected event occurs."})]})}function En({icon:e,size:t=28}){return n.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:t,height:t,borderRadius:6,flexShrink:0,background:"var(--w6w-icon-swatch, var(--w6w-panel-2))",color:"var(--w6w-accent)"},children:n.jsx("svg",{width:Math.round(t*.6),height:Math.round(t*.6),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",dangerouslySetInnerHTML:{__html:e}})})}function ii(e,t,s,o){var c;if(e!=="io.w6w.eventbrite")return null;const r=t==null?void 0:t.find(u=>u.key==="activity"),i=(c=r==null?void 0:r.params)==null?void 0:c.find(u=>u.key==="actions"&&u.type==="multiselect");if(!r||!Array.isArray(i==null?void 0:i.options)||!i.options.length)return null;const a=i.options.map(u=>{var p;const d=String(u.value),f=d.replace(/[._]/g,"-");return{value:d,label:((p=t==null?void 0:t.find(h=>h.key===f))==null?void 0:p.title)??u.label,triggerKey:f}}),l=a.find(u=>u.triggerKey===s);return s&&s!==r.key&&!l||s===r.key&&o.actions!=null&&!Array.isArray(o.actions)?null:{triggerKey:r.key,options:a.sort((u,d)=>u.label.localeCompare(d.label)),selected:l?[l.value]:Array.isArray(o.actions)?o.actions.filter(u=>typeof u=="string"):[]}}function Ce(e){var t;return((t=e==null?void 0:e.uses)==null?void 0:t.app)===Pe&&e.uses.action==="foreach"}function ai(e){var t;return((t=e==null?void 0:e.uses)==null?void 0:t.app)===Pe}function is(e){var t,s;return(e==null?void 0:e.uses.app)===We?!0:!ai(e)||(e==null?void 0:e.uses.action)==="if"&&((t=e.with)==null?void 0:t.then)===void 0&&((s=e.with)==null?void 0:s.else)===void 0}function Bs(e){if(!ai(e))return[];const t=e.with??{},s=[],o=r=>{if(typeof r=="string")s.push(r);else if(Array.isArray(r))for(const i of r)o(i)};return o(t.body),o(t.branches),o(t.then),o(t.else),s}function Yc(e){const t=new Set;for(const s of e)for(const o of Bs(s))t.add(o);return t}function cn(e,t,s,o){return{id:ut(e,t,"each",o),source:e,target:t,sourceHandle:o!==void 0?Nt(o):s?wn:void 0,animated:!1,data:{when:"each",...o===void 0?{}:{route:o}},...Vt("each",void 0)}}const Ws=e=>{var t;return typeof((t=e.data)==null?void 0:t.route)=="string"?e.data.route:void 0};function Rn(e,t,s,o){const r=new Set(t.map(b=>b.id)),i=s.filter(b=>be(b)==="each"),a=new Set([e]),l=[],c=[e];for(let b=0;b<c.length;b++)for(const m of i)m.source===c[b]&&(!r.has(m.target)||a.has(m.target)||o!=null&&o.has(m.target)||(a.add(m.target),l.push(m.target),c.push(m.target)));const u=new Map(l.map((b,m)=>[b,m])),d=i.filter(b=>b.source!==e&&u.has(b.source)&&u.has(b.target)),f=new Map(l.map(b=>[b,0]));for(const b of d)f.set(b.target,(f.get(b.target)??0)+1);const p=[],h=new Set;for(;;){const b=l.find(m=>!h.has(m)&&f.get(m)===0);if(b===void 0)break;h.add(b),p.push(b);for(const m of d)m.source===b&&f.set(m.target,(f.get(m.target)??0)-1)}for(const b of l)h.has(b)||p.push(b);return p}function li(e,t){const s=new Set(e);return t.filter(o=>be(o)==="each"&&s.has(o.source)&&s.has(o.target))}function Xc(e,t){const s=li(e,t),o=new Set;for(const r of s){if(Ws(r)!==void 0||o.has(r.source))return!1;o.add(r.source)}return!0}function Zc(e,t){const s=[];for(const o of Tn(e,t).values())if(!Xc(o,t))for(const r of li(o,t)){const i=Ws(r);s.push({from:r.source,to:r.target,...i===void 0?{}:{route:i}})}return s}function Tn(e,t){var r;const s=new Map,o=new Set;for(const i of e){if(!Ce((r=i.data)==null?void 0:r.step))continue;const a=Rn(i.id,e,t,o);for(const l of a)o.add(l);s.set(i.id,a)}return s}function Be(e,t){const s={};for(const[o,r]of Tn(e,t))for(const i of r)s[i]=o;return s}function Qc(e,t,s){const o=f=>f.source===e||f.target===e,r=s.filter(f=>!o(f));if(Ce((f=>{var p,h;return(h=(p=t.find(b=>b.id===f))==null?void 0:p.data)==null?void 0:h.step})(e))){const f=Rn(e,t,s),p=new Set(f);return r.filter(h=>!(be(h)==="each"&&(h.source===e||p.has(h.source))&&p.has(h.target)))}const a=Be(t,s)[e];if(a===void 0)return r;const l=s.filter(f=>f.target===e&&be(f)==="each"),c=s.filter(f=>f.source===e&&be(f)==="each");if(l.length!==1||c.length!==1)return r;const u=l[0].source,d=c[0].target;return r.some(f=>f.source===u&&f.target===d&&be(f)==="each")?r:[...r,cn(u,d,u===a,Ws(l[0]))]}function qs(e){if(!Ce(e)||!e.with||!("body"in e.with))return e;const{body:t,...s}=e.with;return{...e,with:s}}function ci(e,t,s,o,r){const i=Be(o,r);if(s==="error")return i[e]!==void 0||i[t]!==void 0?"error_lane_in_body":null;if(s==="success")return i[t]!==void 0?"outside_inbound":null;const a=u=>{var d,f;return(f=(d=o.find(p=>p.id===u))==null?void 0:d.data)==null?void 0:f.step},l=Ce(a(e))?e:i[e];if(l===void 0)return null;if(t===l)return"loop_cycle";const c=()=>e!==l||!r.some(u=>u.source===e&&be(u)==="each");return i[t]===l?e===l||eu(t,e,r)?"loop_cycle":c()?null:"body_branch":i[t]!==void 0?"already_in_loop":is(a(t))?c()?r.some(u=>u.source===t||u.target===t)?"body_exit":null:"body_branch":"control_in_body"}function eu(e,t,s){const o=new Set([e]),r=[e];for(;r.length>0;){const i=r.pop();if(i===t)return!0;for(const a of s)a.source!==i||be(a)!=="each"||o.has(a.target)||(o.add(a.target),r.push(a.target))}return!1}const tu={error_lane_in_body:"A step inside a loop can't have an error connection. Handle the failure outside the loop.",outside_inbound:"This step is inside a loop, so nothing outside it can connect into it. Connect from the loop's Each item side instead.",loop_cycle:"A loop body can't connect back to its own For each.",already_in_loop:"That step is already inside another loop.",control_in_body:"A loop body supports plain steps, If conditions and Routers. Nested control blocks aren't supported here yet.",body_branch:"A For each's Each item port connects to one first step. Branch inside the loop from that step onward.",body_exit:"That step is already connected elsewhere in the workflow. Use a step with no connections, or disconnect it first."};function nu(e){return tu[e]}function su(e,t){const s=Be(e,t);let o=!1;const r=e.map(i=>{const a=s[i.id];if(i.data.loopOf===a)return i;if(o=!0,a===void 0){const{loopOf:l,...c}=i.data;return{...i,data:c}}return{...i,data:{...i.data,loopOf:a}}});return o?r:e}function ou(e,t,s){var a,l;const o=`Delete node "${e}"? Its connections are removed too.`,r=(l=(a=t.find(c=>c.id===e))==null?void 0:a.data)==null?void 0:l.step;if(!Ce(r))return o;const i=Rn(e,t,s);return i.length===0?o:`${o} Its loop body steps ${i.map(c=>`"${c}"`).join(", ")} stay as standalone steps.`}function Us(e){if(e.edges)return e.edges;const t=Yc(e.nodes),s=e.nodes.filter(r=>!t.has(r.id)),o=[];for(let r=0;r<s.length-1;r++)o.push({from:s[r].id,to:s[r+1].id});return o}const un=e=>(e.when??"success")==="success",Vs=e=>e.route===qo&&un(e);function zs(e){const t=new Map(e.nodes.map(c=>[c.id,c])),s=new Map;for(const c of e.nodes)for(const u of Bs(c)){const d=s.get(u)??new Set;d.add(c.id),s.set(u,d)}const o=Us(e),r=e.edges??[],i={};for(const c of e.nodes){if(!Ce(c))continue;const u=c.with??{};if("body"in u){i[c.id]=a(c.id,u.body);continue}i[c.id]=l(c.id)}return i;function a(c,u){const d=(m,x)=>({invalid:x===void 0?{reason:m}:{reason:m,stepId:x}});if(!Array.isArray(u)||u.some(m=>typeof m!="string"))return d("body_not_literal");const f=u,p=new Set(f),h=new Set;for(const m of f){if(!t.has(m))return d("body_unknown_step",m);if(m===c)return d("body_self",m);if(h.has(m))return d("body_duplicate",m);if(h.add(m),!is(t.get(m)))return d("body_contains_control",m);const x=s.get(m);if(x&&[...x].some(g=>g!==c))return d("body_claimed_twice",m)}const b=[];for(const m of r){if(Vs(m)&&m.from===c&&m.to===f[0]||!(p.has(m.from)||p.has(m.to)))continue;if(!(p.has(m.from)&&p.has(m.to)&&un(m)&&m.to!==f[0]))return d("body_step_has_edges",p.has(m.from)?m.from:m.to);b.push(m)}return b.length>0?{body:f,source:"body",edges:b}:{body:f,source:"body"}}function l(c){var m;const u=o.filter(x=>x.from===c&&un(x)&&x.route===void 0);if(u.length===0)return{body:[],source:"body"};const d=x=>({invalid:{reason:"legacy_not_linear",stepId:x}});if(u.length>1)return d(c);const f=[],p=new Set([c]);let h=c,b=u[0].to;for(;b!==void 0;){const x=b,g=t.get(x);if(!g||p.has(x)||!is(g)||s.has(x))return d(x);const y=o.filter(A=>A.to===x);if(y.length!==1||y[0].from!==h)return d(x);const N=o.filter(A=>A.from===x);if(N.length>1||N.length===1&&!un(N[0]))return d(x);p.add(x),f.push(x),h=x,b=(m=N[0])==null?void 0:m.to}return{body:f,source:"legacy"}}}function be(e){var s;const t=(s=e.data)==null?void 0:s.when;return t==="error"?"error":t==="each"?"each":"success"}function ui(e,t){var s;return((s=e.find(o=>o.id===t))==null?void 0:s.id)??null}function di(e,t,s,o,r,i){var d,f;if(!e||!t||e===t||o.some(p=>{var h;return p.source===e&&p.target===t&&((h=p.data)==null?void 0:h.route)===i}))return!1;const a=(d=s.find(p=>p.id===e))==null?void 0:d.data.step,l=(f=s.find(p=>p.id===t))==null?void 0:f.data.step;if(!a||!l)return!1;const c=Mt(a,r),u=Mt(l,r);return c.out>=1&&u.in>=1}function Js(e,t,s,o,r,i,a){var k,C,v;const l=r==="success"&&Ce((k=s.find(E=>E.id===e))==null?void 0:k.data.step),c=l&&a===void 0?yt:a;if(!di(e,t,s,o,i,c)||!e||!t)return null;const u=(C=s.find(E=>E.id===e))==null?void 0:C.data.step,d=(v=s.find(E=>E.id===t))==null?void 0:v.data.step;if(!u||!d)return null;const f=bs(u);if(l){if(c!==yt)return null}else if(u.uses.app===We&&r==="success"){if(!ws(u).some(E=>E.id===c))return null}else if(f&&r==="success"){if(c!==void 0&&c!==pn)return null}else if(c!==void 0)return null;const p=Be(s,o)[e]!==void 0,h=r==="success"&&p?"each":r;if(h==="each"&&!p&&!Ce(u))return null;const b=ci(e,t,h,s,o);if(b)return{next:o,conflict:null,refusal:{refused:"loop",reason:b}};const m=Mt(u,i),x=o,g=x.filter(E=>{var R;return E.source===e&&be(E)===h&&((R=E.data)==null?void 0:R.route)===c}),y=c===void 0||f||l?m.out:1;if(g.length>=y)return{next:o,conflict:null,refusal:{refused:"out_cap",cap:y}};const N=ut(e,t,h,c),A=h==="each"&&p?void 0:ps(h);return{next:qn.addEdge({source:e,target:t,id:N,sourceHandle:c===void 0?A:Nt(c),data:{when:h,...c===void 0?{}:{route:c}},...Vt(h,void 0)},x),conflict:ui(x,N),refusal:null}}function ru(e,t,s,o,r="success",i,a){const l=Js(e,t,s,o,r,i,a);return!l||l.conflict||l.refusal?null:l.next}function iu(e,t,s,o,r="success",i,a){var l;return((l=Js(e,t,s,o,r,i,a))==null?void 0:l.conflict)??null}function au(e,t,s,o,r="success",i,a){var l;return((l=Js(e,t,s,o,r,i,a))==null?void 0:l.refusal)??null}function Ks(e,t,s,o,r){var y;const i=e.filter(N=>N.id===t);if(i.length!==1)return null;const a=i[0];if(be(a)==="each")return null;const l=(y=o.find(N=>N.id===a.source))==null?void 0:y.data.step;if(!l||l.uses.app===We||l.uses.app===zt)return null;const c=Mt(l,r).out,u=e.filter(N=>N.id!==t);if((be(a)===s?[]:u.filter(N=>N.source===a.source&&be(N)===s)).length>=c)return{next:e,conflict:null,refusal:{refused:"out_cap",cap:c}};const f=Vt(s,void 0),p=Ce(l),h=p&&s==="success"?yt:void 0,{route:b,...m}=a.data??{},x={...a,id:ut(a.source,a.target,s,h),data:p?{...m,when:s,...h?{route:h}:{}}:{...a.data,when:s},className:f.className,label:f.label,sourceHandle:h?Nt(h):ps(s)},g=ui(u,x.id);return{next:e.map(N=>N.id===t?x:N),conflict:g,refusal:null}}function lu(e,t,s,o,r){const i=Ks(e,t,s,o,r);return!i||i.conflict||i.refusal?null:i.next}function cu(e,t,s,o,r){var i;return((i=Ks(e,t,s,o,r))==null?void 0:i.conflict)??null}function uu(e,t,s,o,r){var i;return((i=Ks(e,t,s,o,r))==null?void 0:i.refusal)??null}function du(e,t,s){return e.map(o=>{var a;const r=o.source===t?s:o.source,i=o.target===t?s:o.target;return{...o,source:r,target:i,id:ut(r,i,be(o),typeof((a=o.data)==null?void 0:a.route)=="string"?o.data.route:void 0)}})}function ut(e,t,s,o){const r=s==="error"?`${e}->${t}:error`:`${e}->${t}`;return o===void 0?r:`${r}:route:${encodeURIComponent(o)}`}function pu(e){return e.includes(".")?"A step id can't contain a dot (.).":null}function pi(e,t){const s=pu(e);if(s)return s;for(const o of t)if(o===e)return`A step named "${e}" already exists.`;return null}function fu(e,t,s){const o=(f,p)=>!f||!p?void 0:ut(f,p)===t?"success":ut(f,p,"error")===t?"error":void 0,r=o(s[0],s[1]),i=o(s[2],s[3]),a=r!==void 0&&r===i,l=r!==void 0&&i!==void 0&&r!==i,c=r==="success"?s[1]:s[3],u=a?s.find(f=>!!f&&f.includes("->")):l&&(c!=null&&c.endsWith(":error"))?c:void 0,d=u===void 0?"Rename one of the steps it connects, then try again.":a?`A step id containing “->” collides with the edge-id separator, so two different edges mint one id — rename the step “${u}”, then try again.`:`A step id ending in “:error” collides with the error-lane marker, so two different edges mint one id — rename the step “${u}”, then try again.`;return`${e}: the id “${t}” is already taken by another edge. ${d}`}const hu=240,mu=100,wu=40,bu=40;function Gs(e,t){return{x:wu+e*hu,y:bu+t*mu}}function gu(e,t){var l;const s=new Map,o=new Map;for(const c of e)s.set(c.id,0),o.set(c.id,[]);for(const c of t)(l=o.get(c.to))==null||l.push(c.from);const r=e.length+1;let i=0,a=!0;for(;a&&i<r;){i++,a=!1;for(const c of e){const u=o.get(c.id)??[];if(u.length===0)continue;const d=u.reduce((f,p)=>Math.max(f,(s.get(p)??0)+1),0);(s.get(c.id)??0)<d&&(s.set(c.id,d),a=!0)}}if(a){const c=Math.max(0,e.length-1);for(const[u,d]of s)d>c&&s.set(u,c)}return s}function fi(e,t){var c;const s=gu(e,t),o=new Map(e.map((u,d)=>[u.id,d])),r=new Map;for(const{from:u,to:d}of t){const f=s.get(u),p=s.get(d);if(f===void 0||p===void 0||f>=p)continue;const h=r.get(d);(h===void 0||f<(s.get(h)??0)||f===s.get(h)&&(o.get(u)??0)<(o.get(h)??0))&&r.set(d,u)}const i=new Map(e.map(u=>[u.id,[]]));for(const[u,d]of r)(c=i.get(d))==null||c.push(u);for(const u of i.values())u.sort((d,f)=>(s.get(f)??0)-(s.get(d)??0)||(o.get(d)??0)-(o.get(f)??0));const a=new Map;let l=0;for(const u of e.filter(d=>!r.has(d.id))){const d=[u.id];for(;d.length;){const f=d.pop();if(f===void 0)continue;a.set(f,Gs(s.get(f)??0,l));const p=i.get(f)??[];if(p.length===0)l++;else for(let h=p.length-1;h>=0;h--)d.push(p[h])}}return a}function yu(e){const t=e.position;if(!(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y)))return{x:t.x,y:t.y}}function Ys(e){const t=e;if(t.nodes!==void 0&&t.steps!==void 0)throw new Error("workflow carries both nodes and steps");const{steps:s,...o}=e;return{...o,nodes:t.nodes??t.steps??[]}}function xu(e){const t=Ys(e),s=t.nodes;let o=Us(t);const r=[],i=new Map,a=new Set,l=new Set;for(const[h,b]of Object.entries(zs(t))){if("invalid"in b)continue;let m=h;if(b.edges&&b.body.length>0){r.push(cn(h,b.body[0],!0));for(const x of b.edges)l.add(x),r.push(cn(x.from,x.to,!1,x.route));for(const x of b.body)i.set(x,h);continue}for(const x of b.body){if(b.source==="legacy"){const g=o.find(y=>y.from===m&&y.to===x&&(y.when??"success")==="success");g&&l.add(g)}r.push(cn(m,x,m===h)),i.set(x,h),m=x}b.source==="legacy"&&a.add(h)}const c=new Set(s.filter(Ce).map(h=>h.id));for(const h of o)c.has(h.from)&&Vs(h)&&l.add(h);l.size>0&&(o=o.filter(h=>!l.has(h)));const u=fi(s,[...o,...r.map(h=>({from:h.source,to:h.target}))]),d=s.map(h=>{const b=Ye(h.uses.app);return{id:h.id,type:b?"control":"step",position:yu(h)??u.get(h.id)??Gs(0,0),data:{step:h,isInternal:b,...i.has(h.id)?{loopOf:i.get(h.id)}:{},...a.has(h.id)?{legacyLoop:!0}:{}}}}),f=new Set(s.filter(bs).map(h=>h.id)),p=o.map(h=>{const b=h.when==="error"&&h.route===void 0&&f.has(h.from)?{from:h.from,to:h.to,route:pn}:c.has(h.from)&&h.route===void 0&&h.when!=="error"?{...h,route:yt}:h,m=b.when??"success";return{id:ut(b.from,b.to,m,b.route),source:b.from,target:b.to,sourceHandle:b.route===void 0?ps(m):`route:${b.route}`,animated:!1,data:{when:m,...b.route===void 0?{}:{route:b.route}},...Vt(m,void 0)}});return{nodes:d,edges:[...p,...r]}}function vu(e,t){const s=e.map(r=>({...r.data.step,id:r.id})),o=fi(s,t.map(r=>({from:r.source,to:r.target})));return e.map(r=>({...r,position:o.get(r.id)??Gs(0,0)}))}function ju(e,t,s){var k,C;const o=Ys(e),r=((k=o.settings)==null?void 0:k.savePosition)!==!1,i=new Map(t.map(v=>[v.id,v])),a=v=>{var R;if(!r)return v;const E=(R=i.get(v.id))==null?void 0:R.position;return!E||!Number.isFinite(E.x)||!Number.isFinite(E.y)?v:{...v,position:{x:Math.round(E.x),y:Math.round(E.y)}}},l=new Map;for(const v of o.nodes)l.set(v.id,v);for(const v of t)(C=v.data)!=null&&C.step&&l.set(v.id,v.data.step);const c=Tn(t,s),u=zs(o),d=new Map(o.nodes.map(v=>[v.id,v])),f=new Set;for(const v of s)be(v)==="success"&&f.add(v.source);const p=v=>{if(!Ce(v))return v;const E=c.get(v.id)??[],R=d.get(v.id),F=u[v.id];let T;E.length>0?T={value:E}:F&&"invalid"in F&&F.invalid.reason!=="legacy_not_linear"?T=R!=null&&R.with&&"body"in R.with?{value:R.with.body}:null:F&&"invalid"in F?T=null:f.has(v.id)||R!=null&&R.with&&"body"in R.with?T={value:[]}:T=null;const O=v.with??{};return T===null?"body"in O?qs(v):v:{...v,with:{...O,body:T.value}}},h=v=>a(p(v)),b=[],m=new Set;for(const v of o.nodes){const E=l.get(v.id);E&&t.some(R=>R.id===v.id)&&(b.push(h(E)),m.add(v.id))}for(const v of t){if(m.has(v.id))continue;const E=l.get(v.id);E&&b.push(h(E))}const x=new Set;for(const v of c.values())for(const E of v)x.add(E);const g=new Set(t.filter(v=>{var E;return Ce((E=v.data)==null?void 0:E.step)}).map(v=>v.id)),y=s.filter(v=>be(v)!=="each"&&!x.has(v.source)&&!x.has(v.target)).map(v=>{var R;const E=typeof((R=v.data)==null?void 0:R.route)=="string"?v.data.route:g.has(v.source)&&be(v)==="success"?yt:void 0;return{from:v.source,to:v.target,...be(v)==="error"?{when:"error"}:{},...E===void 0?{}:{route:E}}}),N=[];for(const[v,E]of c)E.length>0&&N.push({from:v,to:E[0],route:qo});const A=[...y,...N,...Zc(t,s)];return ei({...o,nodes:b,edges:A})}function hi(e){var s;const t=(s=e.settings)==null?void 0:s.viewport;if(!(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.zoom)))return{x:t.x,y:t.y,zoom:t.zoom}}function Nu(e,t){var a;if(!(((a=e.settings)==null?void 0:a.savePosition)!==!1)||!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.zoom))return e;const o={x:Math.round(t.x),y:Math.round(t.y),zoom:Math.round(t.zoom*1e3)/1e3},r=hi(e);if(r&&r.x===o.x&&r.y===o.y&&r.zoom===o.zoom)return e;const i=typeof e.settings=="object"&&e.settings!==null&&!Array.isArray(e.settings)?e.settings:void 0;return{...e,settings:{...i,viewport:o}}}function ku(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"step"}function Su(e,t){const s=new Set(t.map(o=>o.target));return e.find(o=>!s.has(o.id))}function Cu(e,t){const s=new Set(t.map(o=>o.source));for(let o=e.length-1;o>=0;o--)if(!s.has(e[o].id))return e[o]}function Au(e,t="step"){const s=new Set(e);for(let o=1;o<1e3;o++){const r=`${t}_${o}`;if(!s.has(r))return r}return`${t}_${crypto.randomUUID().slice(0,8)}`}function Xs(e){return JSON.stringify(qs(e),null,2)}const Eu=3,Ru=100;function dt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function mi(e){if(!Array.isArray(e))return;const t=[],s=new Set,o=r=>{s.has(r.key)||(s.add(r.key),t.push(r))};for(const r of e){if(!dt(r)||typeof r.key!="string"||r.key==="")continue;const i=typeof r.label=="string"&&r.label!==""?r.label:void 0;if(o({key:r.key,...i?{label:i}:{},path:!0}),r.type==="array"&&Array.isArray(r.items))for(const a of r.items){if(!dt(a)||typeof a.key!="string"||a.key==="")continue;const l=typeof a.label=="string"&&a.label!==""?a.label:void 0;o({key:`${r.key}.0.${a.key}`,...l?{label:l}:{},path:!0})}}return t.length>0?t:void 0}function Tu(e,t){var o;if(!Array.isArray(e))return;const s=e.find(r=>dt(r)&&r.key===t);if(!(!dt(s)||!Array.isArray(s.items)))return(o=mi([{key:t,type:"array",items:s.items}]))==null?void 0:o.filter(r=>r.key!==t).map(r=>({...r,key:r.key.slice(t.length+3)}))}function rt(e){if(!dt(e))return;const t=[],s=(o,r,i)=>{for(const[a,l]of Object.entries(o)){if(t.length>=Ru)return;const c=r?`${r}.${a}`:a;t.push({key:c,path:!0}),dt(l)&&i<Eu&&s(l,c,i+1)}};return s(e,"",1),t.length>0?t:void 0}function $t(e,t){let s=e;for(const o of t.split(".")){if(!dt(s)||!(o in s))return;s=s[o]}return s}function bt(e,t,s){const o=mi(e==null?void 0:e.output),r=rt(t),i=r??rt(s);if(i){const l=new Map((o??[]).map(d=>[d.key,d])),c=new Set(i.map(d=>d.key)),u=i.map(d=>{const f=l.get(d.key);return f!=null&&f.label?{...d,label:f.label}:d});for(const d of o??[])c.has(d.key)||u.push({...d,declaredOnly:!0});return{fields:u,from:r?"fresh":"persisted"}}if(o)return{fields:o,from:"declared"};const a=rt(e==null?void 0:e.sample);if(a)return{fields:a,from:"sample"}}function Zs(e,t){const s=new Map;for(const i of t){const a=s.get(i.target)??[];a.push(i.source),s.set(i.target,a)}const o=new Set,r=[e];for(;r.length;){const i=r.pop();for(const a of s.get(i)??[])o.has(a)||(o.add(a),r.push(a))}return o}function wi(e,t,s={}){var a,l,c,u,d,f,p;const o=[];let r=!1,i;for(const h of t){if(!e.has(h.id))continue;const b=h.data.step;if(b.uses.app===ms)continue;const m=((a=it(b.uses.app,b.uses.action))==null?void 0:a.group)==="trigger",x=(l=s.testOutputs)==null?void 0:l[b.id],g=(c=s.persistedOutputs)==null?void 0:c[b.id];if(b.uses.trigger===!0){r=!0;const E=bt((u=s.triggerDef)==null?void 0:u.call(s,b.uses.app,b.uses.action),x,g);if(i??(i=E),E&&(E.from==="fresh"||E.from==="persisted")){o.push({id:b.id,label:b.id,outputs:E.fields,outputsFrom:E.from});continue}}m&&(r=!0);const y=m&&b.uses.app===bn,N=y?Fs(Ls((d=b.with)==null?void 0:d.fields)).map(E=>({key:E.key,label:E.label})):((f=it(b.uses.app,b.uses.action))==null?void 0:f.output)??[],A={id:b.id,label:b.id};if(N.length>0){o.push({...A,outputs:N});continue}if(m){const E=bt(void 0,x,g);E&&!y&&(i??(i=E)),o.push(E?{...A,outputs:E.fields,outputsFrom:E.from}:A);continue}if(Ye(b.uses.app)){const E=bt(void 0,x,g);o.push(E?{...A,outputs:E.fields,outputsFrom:E.from}:A);continue}const k=(p=s.actionDef)==null?void 0:p.call(s,b.uses.app,b.uses.action),C=bt(k,x,g),v=b.uses.app.trim()!==""?{hasMeta:!0}:{};C?o.push({...A,outputs:C.fields,outputsFrom:C.from,...v}):o.push(k?{...A,needsTest:!0,...v}:{...A,...v})}return{steps:o,hasTrigger:r,...i?{eventOutputs:i.fields,eventOutputsFrom:i.from}:{}}}function Ou(e,t){const s={};for(const[o,r]of Object.entries(t))s[o]={output:r};return bi(e,{steps:s})}function bi(e,t){if(Qe(e)!==null){const s=Cs(e,Ns(void 0,t)),o=s.length===1?s[0]:void 0;return(o==null?void 0:o.status)==="resolved"&&Array.isArray(o.value)?o.value:void 0}return Array.isArray(e)?e:void 0}const Iu=10;function $u(e,t){return{input:t,with:{items:e.slice(0,Iu),itemCount:e.length}}}function Pu(e){var s;const t=(s=e==null?void 0:e.with)==null?void 0:s.items;return Array.isArray(t)&&t.length>0?t:void 0}function gi(e,t,s,o,r={}){const i=Be(s,o),a=new Set;for(const f of e){if(f===t)continue;const p=i[f];p!==void 0&&p!==t||a.add(f)}const l=wi(a,s,r),c=Tn(s,o),u=[];return{steps:l.steps.map(f=>{var y,N,A;const p=c.get(f.id);if(!p||p.length===0)return f;const h=p[p.length-1],b=(y=s.find(k=>k.id===h))==null?void 0:y.data.step,m=r.testOutputs??{},x=b?bt((N=r.actionDef)==null?void 0:N.call(r,b.uses.app,b.uses.action),m[h],(A=r.persistedOutputs)==null?void 0:A[h]):void 0;u.includes(h)||u.push(h);const g=((x==null?void 0:x.fields)??[]).map(k=>({key:`items.0.${k.key}`,path:!0,...k.declaredOnly?{declaredOnly:!0}:{}}));return{id:f.id,label:f.label,outputs:[{key:"items",path:!0},...g],...x?{outputsFrom:x.from}:{}}}),hasTrigger:l.hasTrigger,extraSampleIds:u,...l.eventOutputs?{eventOutputs:l.eventOutputs,eventOutputsFrom:l.eventOutputsFrom}:{}}}function _u(e){const t=e.trim().split(".");if(!(t[0]!=="nodes"&&t[0]!=="steps"||t.length<4||t[2]!=="output"))return{id:t[1],path:t.slice(3).join(".")}}function Lu(e,t,s){var f,p;const o=Qe(e),r=o?_u(o):void 0,i=r?(f=t.find(h=>h.id===r.id))==null?void 0:f.data.step:void 0;if(!r||!i)return;const a=(p=s.actionDef)==null?void 0:p.call(s,i.uses.app,i.uses.action),l=$t(a==null?void 0:a.sample,r.path),c=Array.isArray(l)&&l.length>0?l[0]:void 0,d=Tu(a==null?void 0:a.output,r.path)??rt(c);if(!(c===void 0&&!d))return{...c!==void 0?{itemSample:c}:{},...d?{itemOutputs:d}:{}}}function yi(e,t,s={}){var u,d,f;const o={foreachId:e},r=(d=(u=t.find(p=>p.id===e))==null?void 0:u.data.step.with)==null?void 0:d.items,i={...s.persistedOutputs??{},...s.testOutputs??{}},a=Ou(r,i),l=a&&a.length>0?a:(f=s.loopSamples)==null?void 0:f[e];if(l&&l.length>0){o.itemSample=l[0];const p=rt(l[0]);return p&&(o.itemOutputs=p),o}const c=Lu(r,t,s);return(c==null?void 0:c.itemSample)!==void 0&&(o.itemSample=c.itemSample),c!=null&&c.itemOutputs&&(o.itemOutputs=c.itemOutputs),o}function Fu(e,t,s,o,r){let i=e;if(!i&&r&&(s.some(c=>c.target===r)||Be(t,s)[r]!==void 0)&&(i=r),!i)return wi(new Set(t.map(c=>c.id)),t,o);const a=Be(t,s)[i],l=gi(Zs(i,s),a,t,s,o);return a&&!l.extraSampleIds.includes(a)&&l.extraSampleIds.push(a),{steps:l.steps,hasTrigger:l.hasTrigger,...l.eventOutputs?{eventOutputs:l.eventOutputs,eventOutputsFrom:l.eventOutputsFrom}:{},...a?{loop:yi(a,t,o)}:{},...l.extraSampleIds.length>0?{extraSampleIds:l.extraSampleIds}:{}}}function Mu(e,t,s,o){if(!e||e.handleType==="target")return[];const r=Zs(e.nodeId,s);r.add(e.nodeId);const i=xi(e,t,s);return gi(r,i,t,s,o).steps}function xi(e,t,s){const o=t.find(r=>r.id===e.nodeId);return e.lane==="each"&&Ce(o==null?void 0:o.data.step)?e.nodeId:Be(t,s)[e.nodeId]}function Du(e,t,s,o){if(!e||e.handleType==="target")return;const r=xi(e,t,s);return r?yi(r,t,o):void 0}async function Hu(e,t){return(await Promise.all(t.map(async o=>{try{const r=await e(o.id),i=r.length?r[r.length-1]:null;return i?{stepId:o.id,label:o.label??o.id,test:i}:null}catch{return null}}))).filter(o=>o!==null)}function Qs(e,t){const s={};for(const r of e){const i=r.test.lastRunOutput,a=i!=null;if(!a&&r.test.lastRunStatus!=="succeeded")continue;const l=r.test.lastRunMeta;s[r.stepId]={output:a?i:null,...l?{meta:l}:{}}}const o=Object.keys(s).length>0;return t?{...o?{steps:s}:{},foreach:{...t.item!==void 0?{item:t.item}:{},index:t.index??0}}:o?{steps:s}:void 0}function vi(e){if(e)return{..."itemSample"in e?{item:e.itemSample}:{},index:0}}function Bu(e){return!e||!("itemSample"in e)?"":JSON.stringify(e.itemSample,null,2)??""}function Wu(e,t){let s;if(e.trim()!=="")try{s=JSON.parse(e)}catch{return{ok:!1,error:"The current item must be valid JSON."}}const o=t.trim()===""?0:Number(t.trim());return!Number.isInteger(o)||o<0?{ok:!1,error:"The index must be a whole number, 0 or more."}:{ok:!0,value:{...s!==void 0?{item:s}:{},index:o}}}function qu(e,t){if(!t)return{};const s={};for(const o of["nodes","steps"]){const r=`${o}.${e}.meta`;s[`${r}.app`]=t.app,s[`${r}.version`]=t.version,s[`${r}.action`]=t.action,s[`${r}.connectionId`]=t.connectionId}return s}function Uu(e,t,s,o,r){return ji(e,t,s,o,r).values}function Vu(e,t,s,o,r){return ji(e,t,s,o,r).sources}function zu(e,t){var r,i,a,l;const s={};let o;for(const c of e){const u=c.data.step.uses;if(u.trigger===!0){const f=(i=(r=t.triggerDef)==null?void 0:r.call(t,u.app,u.action))==null?void 0:i.sample;o===void 0&&f!==void 0&&(o=f);continue}if(Ye(u.app))continue;const d=(l=(a=t.actionDef)==null?void 0:a.call(t,u.app,u.action))==null?void 0:l.sample;d!==void 0&&(s[c.id]=d)}return{samples:s,...o!==void 0?{event:o}:{}}}function ji(e,t,s,o,r={}){var l,c;const i={},a={};for(const u of e){Object.assign(i,qu(u.id,s[u.id]));const d=[["sample",(l=r.samples)==null?void 0:l[u.id]],["persisted",(c=r.persisted)==null?void 0:c[u.id]],["fresh",t[u.id]]];for(const[f,p]of d){if(p===void 0)continue;const h=(b,m)=>{for(const x of["nodes","steps"])i[`${x}.${b}`]=m,a[`${x}.${b}`]=f};if(h(`${u.id}.output`,p),typeof p=="object"&&p!==null&&!Array.isArray(p))for(const[b,m]of Object.entries(p))h(`${u.id}.output.${b}`,m);for(const b of u.outputs??[]){if(!b.path||!b.key.includes("."))continue;const m=$t(p,b.key);m!==void 0&&h(`${u.id}.output.${b.key}`,m)}}}if(r.event!==void 0){const u=(d,f)=>{i[d]=f,a[d]="sample"};if(u("trigger.event",r.event),typeof r.event=="object"&&r.event!==null&&!Array.isArray(r.event))for(const[d,f]of Object.entries(r.event))u(`trigger.event.${d}`,f);for(const d of rt(r.event)??[]){const f=$t(r.event,d.key);f!==void 0&&u(`trigger.event.${d.key}`,f)}}if(o&&"itemSample"in o){i["foreach.item"]=o.itemSample;for(const u of o.itemOutputs??[]){const d=$t(o.itemSample,u.key);d!==void 0&&(i[`foreach.item.${u.key}`]=d)}i["foreach.index"]=0}return{values:i,sources:a}}function Ju(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;const t=e;if(t.type==="secret"||t.type==="expr")return!0;const s=Object.keys(t);return s.length===1&&s[0]==="$"}function Ku(e){const t=[];for(const s of e){const o=s.data.step,r=Object.entries(o.with??{}).filter(([,a])=>a!==void 0&&!Ju(a)).map(([a])=>a);(o.uses.app===Le||o.uses.trigger===!0)&&!r.includes("url")&&r.unshift("url"),r.length>0&&t.push({id:o.id,keys:r})}return t}function as(e){if(!(qe(e)||Ze(e))){if(Array.isArray(e))return e.map(as).filter(t=>t!==void 0);if(typeof e=="object"&&e!==null){const t=e,s=Object.keys(t);if(s.length===1&&s[0]==="$"&&typeof t.$=="string")return;const o={};for(const[r,i]of Object.entries(t)){const a=as(i);a!==void 0&&(o[r]=a)}return o}return e}}function Gu(e,t){const s={};for(const o of e){const r=o.data.step,i={...as(r.with??{})??{}},a=Ni(r,t);a!=null&&a.webhookUrl&&(i.url=a.webhookUrl),Object.keys(i).length>0&&(s[r.id]=i)}return s}function Ni(e,t){if(!(e.uses.app!==Le&&e.uses.trigger!==!0))return t.find(s=>s.nodeId===e.id)??(e.uses.app===Le?t.find(s=>s.appId===Le):void 0)}function Yu(e,t,s,o){var i;const r={};for(const a of e){const l=a.data.step;if(!l.uses.app)continue;const c={app:l.uses.app,action:l.uses.action,connectionId:St(l,o)??null},u=(i=s==null?void 0:s.get(l.uses.app))==null?void 0:i.version;u&&(c.version=u);const d=Ni(l,t);d&&(c.subscriptionId=d.id),d!=null&&d.webhookUrl&&(c.url=d.webhookUrl),r[l.id]=c}return r}function Xu(e){const t={};for(const[s,o]of Object.entries(e))for(const[r,i]of Object.entries(o))t[`nodes.${s}.meta.${r}`]=i,t[`steps.${s}.meta.${r}`]=i;return t}function eo(e,t,s){const o=ye(),[r,i]=w.useState([]),a=JSON.stringify(t.map(l=>[l.id,l.label]));return w.useEffect(()=>{const l=JSON.parse(a);if(!s||l.length===0){i([]);return}let c=!1;return Hu(u=>o.listStepTests(e,u),l.map(([u,d])=>({id:u,label:d}))).then(u=>{c||i(u)}),()=>{c=!0}},[o,e,a,s]),r}const Zu=["function","workflow"],Qu={workflow:'<line x1="6" y1="3" x2="6" y2="15"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M18 9a9 9 0 0 1-9 9"/>',function:'<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/>'},Wn={props:{label:"Form",icon:"form"},code:{label:"JSON",icon:"code"},"params-code":{label:"Params JSON",icon:"braces"},config:{label:"Node settings",icon:"settings-2"}},ed=["props","code","params-code","config"];function On({view:e,onChange:t,disabled:s,views:o=ed,customized:r=!1}){const i=a=>n.jsx("button",{type:"button",title:Wn[a].label,"aria-label":Wn[a].label,"aria-pressed":e===a,disabled:s,className:`w6w-icon-btn${e===a&&!s?" active":""}`,onClick:()=>t(a),children:n.jsx(ue.Icon,{name:Wn[a].icon,size:15})},a);return n.jsxs("div",{className:"w6w-view-toggle",children:[r&&n.jsx("button",{type:"button",className:"w6w-json-customized",disabled:s,onClick:()=>t("params-code"),title:"JSON customization adds or overrides form values",children:"JSON customized"}),o.map(i)]})}function td({onClose:e,onAdd:t,onDraftChange:s,theme:o,appsOnly:r,callables:i=Zu,initialTab:a,title:l,workflowId:c,stepId:u,upstreamSteps:d=[],loop:f,initialApp:p,initialAction:h,initialConnection:b,initialWith:m,appsFilter:x,appsIds:g,connectionOnly:y,onConnected:N,excludeCallableIds:A,onOpenStep:k,stepIds:C=[]}){const[v,E]=w.useState(null),[R,F]=w.useState(null),T=w.useRef(null),O=P=>{const B=t(P);return typeof B=="string"&&(T.current=P,E(B),F(null)),B},I=s?(P,B)=>{T.current=B,s(P,B)}:void 0,M=()=>{v&&R&&R!==v&&I&&T.current&&I(v,{...T.current,id:R}),e()},D=P=>v&&s?n.jsxs("span",{className:"w6w-stepbuilder-title",children:[P,n.jsx(Ir,{value:R??v,onCommit:B=>{const ae=pi(B,C.filter(fe=>fe!==v));return ae||F(B),ae}})]}):P,[H,Y]=w.useState(a??"connected"),[$,G]=w.useState(""),[ne,oe]=w.useState(p??null),[X,L]=w.useState(null),[z,Z]=w.useState(null),[q,J]=w.useState(null),te=!!g&&g.length>0,S=Ai(i,x,A,g),U=S.state!=="empty";if(w.useEffect(()=>{!U&&H==="connected"&&Y("apps")},[U,H]),q)return n.jsx(Se,{title:D(q.label),ariaLabel:q.label,subtitle:n.jsx("code",{children:q.id}),onClose:e,size:"xl",headerRight:n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>J(null),children:"← Back"}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:n.jsx(cd,{family:q.family,targetId:q.id,targetLabel:q.label,onAdd:O,onClose:e,onDone:M,onDraftChange:I})})});if(X)return n.jsx(Se,{title:D(X.groupActions?X.displayName:X.label),ariaLabel:X.groupActions?X.displayName:X.label,titleIcon:n.jsx(En,{icon:X.icon,size:22}),subtitle:n.jsxs("code",{children:[X.app,!X.groupActions&&` · ${X.action}`]}),onClose:e,size:"xl",headerRight:n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>L(null),children:"← Back"}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:n.jsx(id,{node:X,onAdd:O,onClose:e,onDone:M,onDraftChange:I,onOpenStep:k,workflowId:c,upstreamSteps:d,loop:f})})});const V=z??ne;if(V){const P=z?"trigger":"action",B=()=>{oe(null),Z(null)};return n.jsx(Se,{title:D(V.displayName),ariaLabel:V.displayName,subtitle:n.jsxs(n.Fragment,{children:[n.jsx("code",{children:V.id}),V.version&&` · v${V.version}`]}),onClose:e,size:"xl",titleIcon:n.jsx(ft,{src:V.iconSvg,srcDark:V.iconSvgDark,brandColor:V.brandColor,name:V.displayName,theme:o,size:22}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:y&&P==="action"?n.jsx(gd,{appId:V.id,app:V,onClose:e,onChangeApp:B,theme:o,initialConnection:b,onConnected:(ae,fe)=>N==null?void 0:N(ae,fe)}):n.jsx(bd,{kind:P,onOpenStep:k,appId:V.id,app:V,onAdd:O,onClose:e,onDone:M,onDraftChange:I,onChangeApp:B,theme:o,workflowId:c,stepId:u,upstreamSteps:d,loop:f,...P==="action"?{initialAction:h,initialConnection:b,initialWith:m}:{}})})})}return n.jsx(Se,{title:l??"Add a node",onClose:e,size:"xl",children:n.jsxs("div",{className:"w6w-stepbuilder-picker",children:[n.jsx("input",{type:"search",className:"w6w-stepbuilder-search","aria-label":"Search nodes and apps",placeholder:"Search this tab…",value:$,onChange:P=>G(P.target.value)}),n.jsxs("div",{className:"w6w-stepbuilder",children:[n.jsxs("nav",{className:"w6w-stepbuilder-sidebar",children:[U&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${H==="connected"?" active":""}`,onClick:()=>Y("connected"),children:"Ready to use"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${H==="apps"?" active":""}`,onClick:()=>Y("apps"),children:"Apps"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${H==="ai"?" active":""}`,onClick:()=>Y("ai"),children:"AI"}),i.includes("workflow")&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${H==="workflows"?" active":""}`,onClick:()=>Y("workflows"),children:"Workflows"}),i.includes("function")&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${H==="functions"?" active":""}`,onClick:()=>Y("functions"),children:"Functions"}),!r&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${H==="triggers"?" active":""}`,onClick:()=>Y("triggers"),children:"Triggers"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${H==="controls"?" active":""}`,onClick:()=>Y("controls"),children:"Controls"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${H==="utilities"?" active":""}`,onClick:()=>Y("utilities"),children:"Utilities"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${H==="data"?" active":""}`,onClick:()=>Y("data"),children:"Data"})]})]}),n.jsx("div",{className:"w6w-stepbuilder-content",children:H==="connected"?n.jsx(wd,{data:S,query:$,appsFilter:x,onSelectApp:oe,onSelectCallable:J,theme:o}):H==="functions"?n.jsx(Mo,{family:"function",query:$,excludeIds:A,onSelect:P=>J({family:"function",...P})}):H==="workflows"?n.jsx(Mo,{family:"workflow",query:$,excludeIds:A,onSelect:P=>J({family:"workflow",...P})}):H==="apps"?n.jsx(at,{search:!1,searchValue:$,onSelectApp:oe,theme:o,filter:x,ids:g}):H==="ai"?n.jsx(at,{search:!1,searchValue:$,onSelectApp:oe,theme:o,category:te?void 0:"ai",ids:g,filter:P=>{var B;return((x==null?void 0:x(P))??!0)&&(te||(((B=P.categories)==null?void 0:B.includes("ai"))??!1))},emptyMessage:"No AI apps registered yet."}):H==="triggers"?n.jsx(nd,{query:$,onSelect:L,onSelectApp:Z,theme:o,appsFilter:x,appsIds:g}):H==="controls"?n.jsx(sd,{query:$,onSelect:L}):H==="data"?n.jsx(rd,{query:$,onSelect:L}):n.jsx(od,{query:$,onSelect:L})})]})]})})}function Pt(e,...t){const s=t.filter(Boolean).join(" ").toLowerCase();return e.trim().toLowerCase().split(/\s+/).every(o=>s.includes(o))}function ki(e,t){return Pt(t,e.label,e.displayName,e.app,e.action)}function to({nodes:e,onSelect:t,query:s}){const o=new Set,r=e.filter(i=>ki(i,s)?i.groupActions?o.has(i.app)?!1:(o.add(i.app),!0):!0:!1);return r.length?n.jsx("div",{className:"w6w-stepbuilder-list",children:r.map(i=>n.jsx(Si,{node:i,onSelect:t},`${i.app}:${i.action}`))}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["No nodes match “",s,"”."]})}function Si({node:e,onSelect:t}){return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item",onClick:()=>t(e),children:[n.jsx(En,{icon:e.icon,size:24}),n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:e.groupActions?e.displayName:e.label}),n.jsxs("code",{className:"w6w-muted w6w-small",children:[e.app,!e.groupActions&&` · ${e.action}`]})]})]})}function nd({query:e,onSelect:t,onSelectApp:s,theme:o,appsFilter:r,appsIds:i}){var b;const a=ye(),l=pt.filter(m=>m.group==="trigger"&&ki(m,e)),[c,u]=w.useState(!1),d=Ai([],r,void 0,i,{resolveInline:!0});if(c)return n.jsxs("div",{className:"w6w-stack",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>u(!1),children:"← Back"}),n.jsx(at,{onSelectApp:s,theme:o,filter:r,ids:i?[...i]:void 0,hasTriggers:!0,search:!1,searchValue:e,emptyMessage:"No apps declare triggers yet."})]});const p=d.apps.filter(m=>(m.triggerCount??0)>0&&Pt(e,m.displayName,m.id)).sort(_t(m=>m.displayName)).map(m=>n.jsx(Ei,{app:m,theme:o,onSelect:s},m.id));d.moreApps&&p.push(n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:d.loadMoreApps,children:"Load more"},"__load_more_apps"));let h;return d.state==="error"?h=n.jsx("div",{className:"w6w-result w6w-error",children:d.error}):d.state==="loading"?h=n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}):e.trim()&&((b=d.appIds)!=null&&b.length)&&typeof a.listAppsPage=="function"?h=n.jsx(at,{search:!1,searchValue:e,ids:d.appIds,hasTriggers:!0,filter:r,onSelectApp:s,theme:o}):p.length===0?h=n.jsxs("p",{className:"w6w-muted w6w-small w6w-readytouse-empty",children:[e.trim()?`No connected apps match “${e}”.`:"No connected apps with triggers yet"," ","·"," ",n.jsx("button",{type:"button",className:"w6w-linkbtn",onClick:()=>u(!0),children:"Search all apps"})]}):h=n.jsx("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:p}),n.jsxs("div",{className:"w6w-apppicker-host",children:[n.jsxs("div",{className:"w6w-readytouse","data-cols":2,children:[n.jsxs("section",{className:"w6w-readytouse-col","data-col":"your-apps",children:[n.jsx("h4",{className:"w6w-readytouse-heading",children:"Your apps"}),h]}),n.jsx("div",{className:"w6w-readytouse-stack",children:n.jsxs("section",{className:"w6w-readytouse-col","data-col":"built-in",children:[n.jsx("h4",{className:"w6w-readytouse-heading",children:"Built-in"}),n.jsxs("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:[l.length===0&&n.jsxs("p",{className:"w6w-muted w6w-small",children:["No built-in triggers match “",e,"”."]}),l.map(m=>n.jsx(Si,{node:m,onSelect:t},`${m.app}:${m.action}`))]})]})})]}),n.jsx("div",{className:"w6w-readytouse-footer",children:n.jsx("button",{type:"button",className:"w6w-btn",onClick:()=>u(!0),children:"Search all apps"})})]})}function sd({onSelect:e,query:t}){const s=pt.filter(o=>o.group==="control"&&!o.hidden);return n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"Flow-control nodes branch, route, join paths, loop, parallelize, pause, or stop the run."}),n.jsx(to,{nodes:s,onSelect:e,query:t})]})}function od({onSelect:e,query:t}){const s=pt.filter(o=>o.group!=="control"&&o.group!=="trigger"&&o.app!==Lt&&o.app!==hs&&o.app!==De&&!o.hidden);return n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"Run scripts, work with regular expressions, render templates, call models, or make HTTP requests."}),n.jsx(to,{nodes:s,onSelect:e,query:t})]})}function rd({onSelect:e,query:t}){const s=pt.filter(o=>(o.app===Lt||o.app===De||o.app===hs)&&!o.hidden);return n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:"Set data, read documents, read and write store entries, or query stored rows."}),n.jsx(to,{nodes:s,onSelect:e,query:t})]})}function id({node:e,onAdd:t,onClose:s,onDone:o,onDraftChange:r,onOpenStep:i,workflowId:a,upstreamSteps:l=[],loop:c}){const[u,d]=w.useState(e),f=e.groupActions?pt.filter(D=>D.app===e.app&&!D.hidden):[],[p,h]=w.useState(()=>fn(u.app,u.action)),b=!Et(u.app),m=eo(a??"",l,b&&!!a),x=Qs(m,vi(c)),[g,y]=w.useState("configure"),[N,A]=w.useState("props"),[k,C]=w.useState("{}"),[v,E]=w.useState({}),R=jt(u.params,p),[F,T]=w.useState(null),O=()=>({uses:{app:u.app,action:u.action},with:p,...v});w.useEffect(()=>{if(!r)return;const D=t(O());D&&T(D),D&&u.app===Le&&(i==null||i(D))},[]),w.useEffect(()=>{!r||F===null||r(F,O())},[F,p,v,u]);const I=D=>{D==="code"&&C(Xs(O())),A(D)},M=()=>t(O());return n.jsxs("div",{className:"w6w-stepconfig",children:[n.jsxs("div",{className:"w6w-tabsbar",children:[n.jsxs("div",{className:"w6w-subtabs",children:[n.jsx("button",{type:"button",className:`w6w-subtab${g==="configure"?" active":""}`,onClick:()=>y("configure"),children:"Configure"}),b&&n.jsx("button",{type:"button",disabled:!R,title:R?void 0:"Fill the required fields first",className:`w6w-subtab${g==="test"?" active":""}`,onClick:()=>R&&y("test"),children:"Test"})]}),n.jsx(On,{view:N,customized:An(p),onChange:I,disabled:g!=="configure"})]}),n.jsxs("div",{className:"w6w-stepconfig-body",children:[g==="configure"&&N==="props"&&f.length>1&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Action"}),n.jsx("select",{className:"w6w-input","aria-label":"Action",value:u.action,onChange:D=>{const H=f.find($=>$.action===D.target.value);if(!H)return;const Y=fn(H.app,H.action);h(Object.fromEntries(H.params.flatMap($=>$.key in p?[[$.key,p[$.key]]]:$.key in Y?[[$.key,Y[$.key]]]:[]))),d(H)},children:f.map(D=>n.jsx("option",{value:D.action,children:D.label},D.action))})]}),g==="configure"&&(N==="props"?u.app===zt?n.jsx("p",{className:"w6w-muted w6w-small",children:Vo}):u.action==="wait"&&Et(u.app)?n.jsx(Xr,{values:p,onChange:h}):u.action==="if"&&Et(u.app)?n.jsx(Cn,{values:p,onChange:h}):u.app===ms?n.jsx($r,{values:p,onChange:h}):u.app===We?n.jsx(Or,{values:p,onChange:h}):n.jsx(He,{params:u.params,values:p,onChange:h}):N==="code"?n.jsx(lt,{value:k,onChange:()=>{},readOnly:!0,minHeight:"240px",height:"100%","aria-label":"Node JSON",copyable:!0}):N==="params-code"?n.jsx(Ps,{values:p,onChange:h}):n.jsx($s,{config:v,onChange:E,failureHandling:!Ft(u.app),retryControls:!Et(u.app)&&u.app!==gn})),g==="test"&&b&&(Ft(u.app)?n.jsx(Yr,{app:u.app,action:u.action,fields:p.fields}):n.jsx(no,{app:u.app,action:u.action,values:p,canRun:R,state:x}))]}),n.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),g==="configure"&&b?n.jsx("button",{type:"button",className:"w6w-btn",disabled:!R,onClick:()=>y("test"),children:"Next →"}):n.jsx("button",{type:"button",className:"w6w-btn",onClick:F!==null?o??s:M,children:F!==null?"Done":"Add node"})]})]})}function Mo({family:e,query:t,excludeIds:s,onSelect:o}){const r=ye(),[i,a]=w.useState(null),[l,c]=w.useState(null),u=e==="function"?"Functions":"Workflows";w.useEffect(()=>{let m=!1;return(e==="function"?r.listFunctions():r.listWorkflows()).then(g=>!m&&a(g)).catch(g=>!m&&c(g.message)),()=>{m=!0}},[r,e]);const d=m=>n.jsx("div",{className:"w6w-apppicker-host",children:m});if(l)return d(n.jsx("div",{className:"w6w-result w6w-error",children:l}));if(i===null)return d(n.jsxs("p",{className:"w6w-muted w6w-small",children:["Loading ",u.toLowerCase(),"…"]}));if(i.length===0)return d(n.jsxs("p",{className:"w6w-muted w6w-small",children:["No ",u.toLowerCase()," registered yet."]}));const f=gt,p=t.trim().toLowerCase(),h=ls(i,s).sort(_t(f)),b=p?h.filter(m=>f(m).toLowerCase().includes(p)||m.id.toLowerCase().includes(p)):h;return d(n.jsx("div",{className:"w6w-stepbuilder-apps",children:b.length===0?n.jsxs("p",{className:"w6w-muted w6w-small",children:["No ",u.toLowerCase()," match “",t,"”."]}):n.jsx("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:b.map(m=>n.jsx(cs,{family:e,item:m,onSelect:o},m.id))})}))}const ad=["string","number","boolean","json"];function ld(e){var r;const t=(e.nodes??e.steps??[]).find(i=>Ft(i.uses.app)),s=(r=t==null?void 0:t.with)==null?void 0:r.fields;if(!Array.isArray(s))return[];const o=[];for(const i of s){if(typeof i!="object"||i===null)continue;const a=i,l=typeof a.key=="string"?a.key:"";if(!l)continue;const c=typeof a.type=="string"?a.type:"string";o.push({key:l,label:l,type:ad.includes(c)?c:"string",default:a.default,required:!!a.required})}return o}function cd({family:e,targetId:t,targetLabel:s,onAdd:o,onClose:r,onDone:i,onDraftChange:a}){const l=ye(),[c,u]=w.useState(null),[d,f]=w.useState(null),[p,h]=w.useState({}),[b,m]=w.useState(!0),[x,g]=w.useState("configure"),[y,N]=w.useState(null);w.useEffect(()=>{let v=!1;return u(null),f(null),(e==="function"?l.getFunction(t).then(R=>R.inputs):l.getWorkflow(t).then(ld)).then(R=>!v&&u(R)).catch(R=>!v&&f(R.message)),()=>{v=!0}},[l,e,t]);const A=c!==null&&jt(c,p),k=()=>({uses:{app:gn,action:"call"},with:{targetKind:e,targetId:t,inputs:p,wait:b}});w.useEffect(()=>{if(!a)return;const v=o(k());v&&N(v)},[]),w.useEffect(()=>{!a||y===null||a(y,k())},[y,p,b]);const C=()=>o(k());return n.jsxs("div",{className:"w6w-stepconfig",children:[n.jsx("div",{className:"w6w-tabsbar",children:n.jsxs("div",{className:"w6w-subtabs",children:[n.jsx("button",{type:"button",className:`w6w-subtab${x==="configure"?" active":""}`,onClick:()=>g("configure"),children:"Configure"}),n.jsx("button",{type:"button",disabled:!A,title:A?void 0:"Fill the required fields first",className:`w6w-subtab${x==="test"?" active":""}`,onClick:()=>A&&g("test"),children:"Test"})]})}),n.jsx("div",{className:"w6w-stepconfig-body",children:x==="configure"?n.jsxs("div",{className:"w6w-stack",children:[d?n.jsx("div",{className:"w6w-result w6w-error",children:d}):c===null?n.jsxs("p",{className:"w6w-muted w6w-small",children:["Loading ",s,"’s inputs…"]}):c.length===0?n.jsxs("p",{className:"w6w-muted w6w-small",children:[s," declares no inputs — it can be called as-is."]}):n.jsx(He,{params:c,values:p,onChange:h}),n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[n.jsx("input",{type:"checkbox",checked:b,onChange:v=>m(v.target.checked)})," ","Wait for completion"]}),n.jsx("span",{className:"w6w-hint",children:"On: block until the sub-run finishes and expose its output. Off: return a run handle and continue."})]})]}):n.jsx(ud,{family:e,targetId:t,inputs:p,canRun:A})}),n.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:r,children:"Cancel"}),x==="configure"?n.jsx("button",{type:"button",className:"w6w-btn",disabled:!A,onClick:()=>g("test"),children:"Next →"}):n.jsx("button",{type:"button",className:"w6w-btn",onClick:y!==null?i??r:C,children:y!==null?"Done":"Add node"})]})]})}function ud({family:e,targetId:t,inputs:s,canRun:o}){const r=ye(),[i,a]=w.useState(null),l=async()=>{if(!(!o||(i==null?void 0:i.status)==="running")){a({status:"running"});try{if(e==="function"){const c=await r.invokeFunction(t,s);a({status:"done",output:c,terminal:!0})}else{const c=await r.runWorkflow(t,{input:s});a({status:"done",output:c.output,runId:c.runId,terminal:c.terminal,error:c.error})}}catch(c){a({status:"error",error:c.message??String(c)})}}};return n.jsxs("div",{className:"w6w-steptest",children:[n.jsxs("div",{className:"w6w-steptest-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:!o||(i==null?void 0:i.status)==="running",onClick:l,children:(i==null?void 0:i.status)==="running"?"Running…":"▶ Test run"}),!o&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Fill the required fields to test."})]}),(i==null?void 0:i.status)==="error"&&n.jsx("div",{className:"w6w-result w6w-error",children:i.error}),(i==null?void 0:i.status)==="done"&&!i.terminal&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Still running"}),n.jsxs("div",{className:"w6w-result",children:["Run ",n.jsx("code",{children:i.runId})," has not finished yet — check its status from the workflow's run history."]})]}),(i==null?void 0:i.status)==="done"&&i.terminal&&i.error!==void 0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Run failed"}),n.jsx("pre",{className:"w6w-result w6w-error",style:{whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto",margin:0},children:JSON.stringify(i.error,null,2)})]}),(i==null?void 0:i.status)==="done"&&i.terminal&&i.error===void 0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Result"}),n.jsx(Re,{value:i.output,maxHeight:220})]})]})}function dd(e){const t={};for(const s of e)ct(s.default)&&(t[s.key]=s.default);return t}function jt(e,t){const s=Nr(t);if(s===null)return!1;if(s===void 0)return!0;const o=vt(e),r=a=>{var l;return s[a]!==void 0?s[a]:(l=o.find(c=>c.key===a))==null?void 0:l.default},i=(a,l,c)=>a.every(u=>{const d=ie.effectiveParam(u,c);if(d.type==="section")return i(d.children??[],l,c);if(d.type==="group"){const p=d.children??[],h=vt(p),b=x=>g=>{const y=h.find(N=>N.key===g);return y?x[g]!==void 0?x[g]:y.default:c(g)};if(d.repeat){const x=Array.isArray(l[d.key])?l[d.key]:[];return x.length===0?!d.required:x.every(g=>{const y=g??{};return i(p,y,b(y))})}const m=l[d.key]??{};return i(p,m,b(m))}if(!d.required||!Kt(u,c))return!0;const f=l[d.key]??d.default;return f==null?!1:typeof f=="string"?f.trim()!=="":!0});return i(e,s,r)}function Ci(e){const t=e==null?void 0:e.testRequired;return typeof t=="boolean"?t:!0}function pd(e){const t=e;return(t==null?void 0:t.body)??(t==null?void 0:t.raw)??{error:t==null?void 0:t.code,message:(t==null?void 0:t.message)??String(e)}}function fd(e){const t=e==null?void 0:e.apiCalls;return Array.isArray(t)?t:[]}function hd({log:e,onClose:t}){return n.jsx(Se,{title:"Test run log",subtitle:e.startedAt,size:"wide",onClose:t,children:n.jsxs("div",{className:"w6w-modal-body w6w-stack",style:{gap:12},children:[n.jsxs("div",{className:"w6w-testout",children:[n.jsxs("div",{className:"w6w-testout-label",children:["Request to w6w · ",e.request.method," ",e.request.path]}),n.jsx(Re,{value:e.request.body,maxHeight:320})]}),n.jsxs("div",{className:"w6w-testout",children:[n.jsxs("div",{className:"w6w-testout-label",children:["Response from w6w ·"," ",e.response.ok?"ok":`failed${e.response.status?` (HTTP ${e.response.status})`:""}`," ","· ",e.durationMs,"ms"]}),n.jsx(Re,{value:e.response.body,maxHeight:320})]}),n.jsxs("div",{className:"w6w-testout",children:[n.jsxs("div",{className:"w6w-testout-label",children:["Outbound API calls (",e.apiCalls.length,")"]}),e.apiCalls.length>0?n.jsx(oi,{calls:e.apiCalls,title:!1,defaultOpen:!0}):n.jsxs("div",{className:"w6w-muted w6w-small",children:["No HTTP request reached the vendor API — the action",e.response.ok?" made no outbound call":" failed before sending one","."]})]})]})})}const no=w.forwardRef(function({app:t,action:s,connectionId:o,values:r,canRun:i,hideRunButton:a,persist:l,state:c,onBusyChange:u,onResult:d},f){const p=ye(),h=ys(),b=xa(),[m,x]=w.useState(null),[g,y]=w.useState(null),[N,A]=w.useState(!1),k=w.useRef(!1),[C,v]=w.useState(null),E=l==null?void 0:l.workflowId,R=l==null?void 0:l.stepId,F=ht().nodeMeta,T=R?F==null?void 0:F[R]:void 0;w.useEffect(()=>{if(!E||!R)return;let M=!1;return p.listStepTests(E,R).then(D=>{let H;for(const Y of D)!Y.lastRunAt||!Y.lastRunStatus||(!H||Date.parse(Y.lastRunAt)>Date.parse(H.lastRunAt))&&(H=Y);!H||!H.lastRunAt||M||k.current||(H.lastRunStatus==="succeeded"?x({status:"done",value:H.lastRunOutput,...H.lastRunMeta?{meta:H.lastRunMeta}:{}}):x({status:"error",error:typeof H.lastRunError=="string"?H.lastRunError:H.lastRunError==null?"Test failed":JSON.stringify(H.lastRunError)}),v(H.lastRunAt))}).catch(()=>{}),()=>{M=!0}},[p,E,R]);const O=async()=>{var $;if(!i||(m==null?void 0:m.status)==="running")return;k.current=!0,v(null),x({status:"running"}),u==null||u(!0);let M;const D=new Date,H={method:"POST",path:`/apps/${encodeURIComponent(t)}/actions/${encodeURIComponent(s)}/invoke`,body:{params:r,...o?{connectionId:o}:{},...h?{project:h}:{},...c?{state:c}:{},...b?{workflowId:b}:{}}},Y=G=>y({startedAt:D.toLocaleString(),durationMs:Date.now()-D.getTime(),request:H,response:G,apiCalls:fd(G.body)});try{const G=await p.invokeAction(t,s,r,{...o?{connectionId:o}:{},project:h,...c?{state:c}:{},...b?{workflowId:b}:{}});Y({ok:!0,body:G}),M={status:"done",value:G.value,logs:G.logs,...G.meta?{meta:G.meta}:{}}}catch(G){const ne=G;Y({ok:!1,...typeof ne.status=="number"?{status:ne.status}:{},body:pd(G)}),M={status:"error",error:ne.message??String(G),errorCode:ne.code,logs:ne.logs}}if(x(M),d==null||d(M.status==="done"),l){($=p.saveTestInput)==null||$.call(p,l.workflowId,l.stepId,Ms(l.input)).catch(G=>console.error("test input save failed",G));try{const G=await p.saveStepTest(l.workflowId,l.stepId,{input:l.input,with:r});await p.recordStepTestRun(l.workflowId,l.stepId,{stepTestId:G.id,status:M.status==="done"?"succeeded":"failed",input:l.input,output:M.status==="done"?M.value:void 0,error:M.status==="error"?M.error:void 0,...M.status==="done"&&M.meta?{meta:M.meta}:{}})}catch(G){console.error("step test persist failed",G)}}u==null||u(!1)};w.useImperativeHandle(f,()=>({run:O}));const I=m&&m.status!=="running"?m.logs:void 0;return n.jsxs("div",{className:"w6w-steptest",children:[(!a||g)&&n.jsxs("div",{className:"w6w-steptest-bar",children:[!a&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",disabled:!i||(m==null?void 0:m.status)==="running",onClick:O,children:(m==null?void 0:m.status)==="running"?"Running…":"▶ Test run"}),g&&(m==null?void 0:m.status)!=="running"&&n.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>A(!0),title:"The full request and response of the last test run",children:["Log",g.apiCalls.length>0?` (${g.apiCalls.length})`:""]}),!a&&!i&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Fill the required fields to test."})]}),N&&g&&n.jsx(hd,{log:g,onClose:()=>A(!1)}),C&&((m==null?void 0:m.status)==="done"||(m==null?void 0:m.status)==="error")&&n.jsxs("div",{className:"w6w-muted w6w-small w6w-testout-restored",children:["Last run · ",new Date(C).toLocaleString()]}),(m==null?void 0:m.status)==="error"&&n.jsxs("div",{className:"w6w-result w6w-error",children:[m.errorCode&&n.jsx("div",{className:"w6w-small",style:{opacity:.75,marginBottom:4},children:n.jsx("code",{children:m.errorCode})}),m.error]}),(m==null?void 0:m.status)==="done"&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Result (return value)"}),n.jsx(Re,{value:m.value,maxHeight:220}),(m.meta||T)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-testout-label",children:"Metadata"}),n.jsx(Re,{value:{...T,...m.meta},maxHeight:220})]})]}),(m==null?void 0:m.status)!=="done"&&(m==null?void 0:m.status)!=="running"&&T&&n.jsxs("div",{className:"w6w-testout","data-testid":"steptest-static-meta",children:[n.jsx("div",{className:"w6w-testout-label",children:"Metadata"}),n.jsx(Re,{value:T,maxHeight:220})]}),I&&I.length>0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Console output"}),n.jsx("pre",{className:"w6w-result w6w-testout-console",style:{whiteSpace:"pre-wrap",maxHeight:160,overflow:"auto",margin:0},children:I.join(`
21
+ `)})]})]})}),Do=12,en=new Set;function Ai(e,t,s,o,r){const i=o&&o.length>0?new Set(o):null,a=L=>(i?i.has(L.id):!0)&&((t==null?void 0:t(L))??!0),l=ye(),[c,u]=w.useState(null),[d,f]=w.useState(null),[p,h]=w.useState(null),[b,m]=w.useState(null),[x,g]=w.useState(null),[y,N]=w.useState(()=>new Map),[A,k]=w.useState(()=>new Set),[C,v]=w.useState(en),E=w.useRef(en),R=w.useCallback(L=>{E.current=L,v(L)},[]),F=w.useRef(en),T=e.includes("function"),O=e.includes("workflow"),I=typeof l.listAppsByIds=="function";w.useEffect(()=>{let L=!1;const z=Z=>!L&&g(Z.message);return l.listConnections().then(Z=>{if(L)return;const q=[],J=new Set,te=new Map;for(const S of Z)Ye(S.appId)||(I&&!(r!=null&&r.resolveInline)&&S.app&&!te.has(S.appId)&&te.set(S.appId,{...S.app,id:S.appId}),!J.has(S.appId)&&(J.add(S.appId),q.push(S.appId)));te.size>0&&(F.current=new Set(te.keys()),N(S=>new Map([...S,...te])),k(S=>new Set([...S,...te.keys()]))),u(q)}).catch(z),T?l.listFunctions().then(Z=>!L&&h(Z)).catch(z):h([]),O?l.listWorkflows().then(Z=>!L&&m(Z)).catch(z):m([]),()=>{L=!0}},[l,I,T,O,r==null?void 0:r.resolveInline]),w.useEffect(()=>{if(I)return;const L=l.listApps;if(typeof L!="function"){f([]);return}let z=!1;return L().then(Z=>!z&&f(Z)).catch(Z=>!z&&g(Z.message)),()=>{z=!0}},[l,I]);const M=w.useRef(!0);w.useEffect(()=>(M.current=!0,()=>{M.current=!1}),[]);const D=w.useCallback(L=>{const z=l.listAppsByIds;!z||L.length===0||E.current.size>0||(R(new Set(L)),z(L).then(Z=>{M.current&&(R(en),N(q=>{const J=new Map(q);for(const te of Z)J.set(te.id,te);return J}),k(q=>new Set([...q,...L])))}).catch(Z=>M.current&&g(Z.message)))},[l,R]),H=w.useRef(!1);w.useEffect(()=>{if(!I||c===null||H.current)return;const L=Mn(c,F.current,Do);L.length!==0&&(H.current=!0,D(L))},[I,c,D]);const Y=()=>{if(!I||c===null||E.current.size>0)return;const L=new Set([...A,...E.current]);D(Mn(c,L,Do))};if(x)return{state:"error",error:x,apps:[],fns:[],wfs:[],moreApps:!1,loadMoreApps:Y};if(p===null||b===null)return{state:"loading",apps:[],fns:[],wfs:[],moreApps:!1,loadMoreApps:Y};const $=ls(p,s),G=ls(b,s);if(I){if(c===null)return{state:"loading",apps:[],fns:$,wfs:G,moreApps:!1,loadMoreApps:Y};if(c.length>0&&A.size===0)return{state:"loading",apps:[],fns:$,wfs:G,moreApps:!1,loadMoreApps:Y};const L=ba(c,y).filter(a),z=C.size===0&&Mn(c,new Set([...A,...C]),1).length>0;return{state:L.length===0&&$.length===0&&G.length===0&&!z?"empty":"ready",apps:L,appIds:c.filter(q=>!i||i.has(q)),fns:$,wfs:G,moreApps:z,loadMoreApps:Y}}if(d===null)return{state:"loading",apps:[],fns:$,wfs:G,moreApps:!1,loadMoreApps:Y};const ne=new Set(c??[]),oe=d.filter(L=>!Ye(L.id)&&a(L)&&(ne.has(L.id)||L.zeroCredential===!0));return{state:oe.length===0&&$.length===0&&G.length===0?"empty":"ready",apps:oe,fns:$,wfs:G,moreApps:!1,loadMoreApps:Y}}function ls(e,t){return t&&t.length>0?e.filter(s=>!t.includes(s.id)):[...e]}function _t(e){return(t,s)=>e(t).localeCompare(e(s),void 0,{sensitivity:"base"})}function gt(e){const t=e.displayName;return t!=null&&t.trim()?t:"name"in e?e.name:e.id}function cs({family:e,item:t,onSelect:s}){const o=gt(t);return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item w6w-stepbuilder-item--callable","data-kind":e,onClick:()=>s({id:t.id,label:o}),children:[n.jsx(En,{icon:Qu[e],size:24}),n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:o}),n.jsx("code",{className:"w6w-muted w6w-small",children:t.id})]})]})}function md(e,t){return t.length===0?null:n.jsxs("section",{className:"w6w-readytouse-col",children:[n.jsx("h4",{className:"w6w-readytouse-heading",children:e}),n.jsx("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:t})]},e)}function Ei({app:e,theme:t,onSelect:s}){return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item","data-kind":"app",onClick:()=>s(e),children:[n.jsx(ft,{src:e.iconSvg,srcDark:e.iconSvgDark,brandColor:e.brandColor,name:e.displayName,theme:t,size:24}),n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:e.displayName}),n.jsx("code",{className:"w6w-muted w6w-small",children:e.id})]})]})}function wd({data:e,query:t,appsFilter:s,onSelectApp:o,onSelectCallable:r,theme:i}){var x;const a=ye(),l=g=>n.jsx("div",{className:"w6w-apppicker-host",children:g});if(e.state==="error")return l(n.jsx("div",{className:"w6w-result w6w-error",children:e.error}));if(e.state==="loading")return l(n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}));const c=e.apps.filter(g=>Pt(t,g.displayName,g.id)).sort(_t(g=>g.displayName)),u=e.fns.filter(g=>Pt(t,gt(g),g.id)).sort(_t(gt)),d=e.wfs.filter(g=>Pt(t,gt(g),g.id)).sort(_t(gt)),f=md,p=c.map(g=>n.jsx(Ei,{app:g,theme:i,onSelect:o},g.id));e.moreApps&&p.push(n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:e.loadMoreApps,children:"Load more"},"__load_more_apps"));const h=t.trim()&&((x=e.appIds)!=null&&x.length)&&typeof a.listAppsPage=="function"?n.jsxs("section",{className:"w6w-readytouse-col",children:[n.jsx("h4",{className:"w6w-readytouse-heading",children:"Connected apps"}),n.jsx(at,{search:!1,searchValue:t,ids:e.appIds,filter:s,onSelectApp:o,theme:i})]}):f("Connected apps",p),b=[f("Functions",u.map(g=>n.jsx(cs,{family:"function",item:g,onSelect:y=>r({family:"function",...y})},g.id))),f("Workflows",d.map(g=>n.jsx(cs,{family:"workflow",item:g,onSelect:y=>r({family:"workflow",...y})},g.id)))].filter(Boolean),m=(h?1:0)+(b.length>0?1:0);return l(m?n.jsxs("div",{className:"w6w-readytouse","data-cols":m,children:[h,b.length>0&&n.jsx("div",{className:"w6w-readytouse-stack",children:b})]}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["Nothing ready to use matches “",t,"”."]}))}function Ri(e,t){var s;return(((s=e.getAppTriggers)==null?void 0:s.call(e,t))??Promise.resolve([])).then(o=>o.map(r=>({key:r.key,title:r.title,description:r.description,params:r.params??[]})))}function Ti({title:e,app:t}){return n.jsxs("p",{className:"w6w-muted w6w-small",children:[n.jsx("strong",{children:e})," runs when ",t," reports it, so there is nothing to run by hand. Publish the workflow to start listening."]})}function bd({kind:e="action",onOpenStep:t,appId:s,app:o,onAdd:r,onClose:i,onDone:a,onDraftChange:l,onChangeApp:c,theme:u,workflowId:d,stepId:f,upstreamSteps:p=[],loop:h,initialAction:b,initialConnection:m,initialWith:x}){const g=ye(),y=e==="trigger",N=y?"a trigger":"an action",[A,k]=w.useState(null),[C,v]=w.useState(null),[E,R]=w.useState(null),[F,T]=w.useState(null),[O,I]=w.useState(m??""),[M,D]=w.useState(),H=Hs(),Y=w.useRef(H);Y.current=H;const $=M?St({uses:{app:s,action:"",connectionRef:M}},H==null?void 0:H.connections)??"":O,G=w.useCallback(ee=>{D(void 0),I(ee)},[]),[ne,oe]=w.useState(b??""),[X,L]=w.useState(x??{}),z=w.useRef(null),[Z,q]=w.useState(!1),[J,te]=w.useState(b&&x?"configure":"setup"),[S,U]=w.useState("props"),[V,P]=w.useState("{}"),[B,ae]=w.useState({});w.useEffect(()=>{let ee=!1;T(null);const W=y?Ri(g,s):g.getAppActions(s);return Promise.all([g.getAppAuth(s),g.listConnectionsForApp(s),W]).then(([Q,de,Je])=>{if(ee)return;const st=Fo(s,Q,de);k(Q),v(st),R(Je);const ke=Y.current,$e=ti({id:f??"",uses:{app:s,action:""}},st,(ke==null?void 0:ke.nodes)??[],(ke==null?void 0:ke.connections)??{},m);$e.connectionRef?D($e.connectionRef):G($e.connection??"")}).catch(Q=>!ee&&T(Q.message)),()=>{ee=!0}},[g,s,y,G,m,f]);const fe=async()=>{const ee=await g.listConnectionsForApp(s);v(Fo(s,A??[],ee))},he=(A??[]).filter(ee=>ee.available!==!1),ge=he.some(ee=>ee.autoSatisfied===!0&&(ee.type==="tenantAuth"||ee.type==="jit")),ve=ge&&!he.some(ee=>ee.autoSatisfied===!0&&ee.type==="tenantAuth"),Ae=he.length>0&&!ge,Te=(C??[]).length>0,le=(E??[]).find(ee=>ee.key===ne),Ee=y?ii(s,E,ne,X):null,mt=[...E??[]].sort((ee,W)=>(ee.title??ee.key).localeCompare(W.title??W.key,void 0,{sensitivity:"base"})),Ue=Ci(o),[Ct,et]=w.useState(!1);w.useEffect(()=>{if(!Ue||!d||!f)return;let ee=!1;return g.listStepTests(d,f).then(W=>{!ee&&W.some(Q=>Q.lastRunStatus==="succeeded")&&et(!0)}).catch(()=>{}),()=>{ee=!0}},[g,Ue,d,f]);const Ve=eo(d??"",p,!!d),tt=Qs(Ve,vi(h)),me=!!ne&&(!Ae||Te&&!!$)&&(!Ee||Ee.selected.length>0),Oe=me&&!!le&&jt(le.params??[],X),nt=me,xe=(C??[]).find(ee=>ee.id===$);function je(){return{uses:{app:s,action:(le==null?void 0:le.key)??ne,...M?{connectionRef:M}:$?{connection:$}:{},...y?{trigger:!0}:{}},with:X,...B}}function Ie(){le&&r(je())}const[Ne,At]=w.useState(null);w.useEffect(()=>{if(!l||Ne!==null||!me||Ee&&J==="setup")return;const ee=r(je());ee&&At(ee),ee&&y&&(t==null||t(ee))},[l,Ne,me,J]),w.useEffect(()=>{!l||Ne===null||l(Ne,je())},[Ne,X,B,$,M]);const ze=ee=>{ee==="code"&&P(Xs(je())),U(ee)};return n.jsxs("div",{className:"w6w-stepconfig",children:[n.jsxs("div",{className:"w6w-tabsbar",children:[n.jsxs("div",{className:"w6w-subtabs",children:[n.jsx("button",{type:"button",className:`w6w-subtab${J==="setup"?" active":""}`,onClick:()=>te("setup"),children:"Setup"}),n.jsx("button",{type:"button",disabled:!me,title:me?void 0:"Complete Setup first",className:`w6w-subtab${J==="configure"?" active":""}`,onClick:()=>me&&te("configure"),children:"Configure"}),n.jsx("button",{type:"button",disabled:!Oe,title:Oe?void 0:"Fill the required fields first",className:`w6w-subtab${J==="test"?" active":""}`,onClick:()=>Oe&&te("test"),children:"Test"})]}),n.jsx(On,{view:S,customized:An(X),onChange:ze,disabled:J!=="configure"})]}),n.jsxs("div",{className:"w6w-stepconfig-body",children:[J==="setup"&&n.jsxs("div",{className:"w6w-stack",children:[F&&n.jsx("div",{className:"w6w-result w6w-error",children:F}),A===null&&!F&&n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}),n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"App"}),n.jsxs("div",{className:"w6w-app-conn-row",ref:z,children:[n.jsxs("button",{type:"button",className:"w6w-app-conn-btn","aria-label":"App",onClick:c,disabled:!c,children:[o&&n.jsx(ft,{src:o.iconSvg,srcDark:o.iconSvgDark,brandColor:o.brandColor,name:o.displayName,theme:u,size:20}),n.jsx("span",{className:"w6w-conn-label-name",children:(o==null?void 0:o.displayName)??s})]}),n.jsx(si,{step:{id:Ne??f??"",uses:{app:s,action:ne,...M?{connectionRef:M}:{connection:$||void 0}}},conns:C,failed:!!F,open:Z,onOpenChange:q,anchorRef:z,onChangeConnection:G,onChangeConnectionRef:D,onConnectionCreated:()=>{fe()}})]}),ve&&(xe==null?void 0:xe.builtIn)&&n.jsx("span",{className:"w6w-hint",children:"Scheduled or queued runs need a stored connection. Choose one from the connection menu."}),A!==null&&Ae&&!Te&&n.jsx("span",{className:"w6w-hint",children:"This app needs a connection before its actions can run."})]}),E!==null&&(E.length===0?n.jsx("p",{className:"w6w-muted w6w-small",children:y?"This app declares no triggers.":"This app exposes no actions."}):Ee?n.jsx(ri,{choices:Ee,onChange:ee=>{oe(Ee.triggerKey),L(W=>({...W,actions:ee}))}}):n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[y?"Trigger":"Action",ne?"":" *"]}),n.jsx(kt,{value:ne,placeholder:`— pick ${N} —`,mode:"combobox",listMaxHeight:200,onChange:ee=>{var W;oe(ee),L(dd(((W=(E??[]).find(Q=>Q.key===ee))==null?void 0:W.params)??[])),et(!1)},options:mt.map(ee=>({value:ee.key,label:`${ee.title??ee.key} (${ee.key})`}))}),(le==null?void 0:le.description)&&n.jsx("span",{className:"w6w-hint",children:le.description})]}))]}),J==="configure"&&(le?S==="props"?n.jsx(He,{params:le.params??[],values:X,onChange:L,dynamic:{appId:s,actionKey:le.key,connectionId:$||void 0,appName:o==null?void 0:o.displayName}}):S==="code"?n.jsx(lt,{value:V,onChange:()=>{},readOnly:!0,minHeight:"240px",height:"100%","aria-label":"Node JSON",copyable:!0}):S==="params-code"?n.jsx(Ps,{values:X,onChange:L}):n.jsx($s,{config:B,onChange:ae,failureHandling:!y}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["Pick ",N," in Setup first."]})),J==="test"&&(le&&y?n.jsx(Ti,{title:le.title??le.key,app:(o==null?void 0:o.displayName)??s}):le?n.jsx(no,{app:s,action:le.key,connectionId:$||void 0,values:X,canRun:me&&jt(le.params??[],X),state:tt,onResult:et}):n.jsx("p",{className:"w6w-muted w6w-small",children:"Pick an action in Setup first."}))]}),J==="test"&&n.jsx("div",{className:"w6w-stepconfig-testnote",children:Ue&&!Ct&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Not yet tested. You can publish without running a test."})}),n.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:i,children:"Cancel"}),J==="test"?n.jsx("button",{type:"button",className:"w6w-btn",disabled:Ne===null&&!nt,onClick:Ne!==null?a??i:Ie,children:Ne!==null?"Done":"Add node"}):n.jsx("button",{type:"button",className:"w6w-btn",disabled:J==="setup"?!me:!Oe,onClick:()=>te(J==="setup"?"configure":"test"),children:"Next →"})]})]})}function gd({appId:e,app:t,onClose:s,onChangeApp:o,theme:r,initialConnection:i,onConnected:a}){const l=ye(),[c,u]=w.useState(null),[d,f]=w.useState(null),[p,h]=w.useState(null),[b,m]=w.useState(i??""),[x,g]=w.useState(!1),[y,N]=w.useState(!1);w.useEffect(()=>{let I=!1;return h(null),Promise.all([l.getAppAuth(e),l.listConnectionsForApp(e)]).then(([M,D])=>{if(I)return;u(M),f(D),!(M??[]).some(Y=>Y.autoSatisfied===!0)&&D.length>0&&m(D[0].id)}).catch(M=>!I&&h(M.message)),()=>{I=!0}},[l,e]);const A=async()=>{const I=await l.listConnectionsForApp(e);f(I),I.length>0&&m(M=>M||I[0].id)},k=(c??[]).filter(I=>I.available!==!1),C=k.some(I=>I.autoSatisfied===!0&&(I.type==="tenantAuth"||I.type==="jit")),v=C&&!k.some(I=>I.autoSatisfied===!0&&I.type==="tenantAuth"),E=k.length>0&&!C,R=(d??[]).length>0,F=!E||R&&!!b,T=(d??[]).find(I=>I.id===b),O=y||!b;return n.jsxs("div",{className:"w6w-stepconfig",children:[n.jsx("div",{className:"w6w-stepconfig-body",children:n.jsxs("div",{className:"w6w-stack",children:[p&&n.jsx("div",{className:"w6w-result w6w-error",children:p}),c===null&&!p&&n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading…"}),n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"App"}),n.jsxs("div",{className:"w6w-conn-label",children:[t&&n.jsx(ft,{src:t.iconSvg,srcDark:t.iconSvgDark,brandColor:t.brandColor,name:t.displayName,theme:r,size:20}),n.jsx("span",{className:"w6w-conn-label-name",children:(t==null?void 0:t.displayName)??e}),o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:o,children:"Change"})]})]}),c!==null&&C&&n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"Connection"}),n.jsxs("div",{className:"w6w-conn-label",children:[n.jsx("span",{className:"w6w-conn-label-name",children:"Connected automatically — this app needs no connection for your organization."}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>g(!0),children:"Create connection"})]}),v&&n.jsx("span",{className:"w6w-hint",children:'A scheduled or queued run of this workflow still needs a connection configured on this step — use "Create connection" if this step will run on a schedule.'})]}),c!==null&&E&&(R?O?n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Connection"}),n.jsxs("div",{style:{display:"flex",gap:6},children:[n.jsx("select",{value:b,onChange:I=>{m(I.target.value),N(!1)},style:{flex:1},children:(d??[]).map(I=>n.jsxs("option",{value:I.id,children:[I.displayName||I.id," ",I.state?`(${I.state})`:""]},I.id))}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>g(!0),children:"+ New"})]})]}):n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:"Connection"}),n.jsxs("div",{className:"w6w-conn-label",children:[n.jsxs("span",{className:"w6w-conn-label-name",children:[(T==null?void 0:T.displayName)||(T==null?void 0:T.id)||b,T!=null&&T.state?` (${T.state})`:""]}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>N(!0),children:"Change"}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>g(!0),children:"+ New"})]})]}):n.jsxs("div",{className:"w6w-result w6w-stepconfig-conn-empty",children:[n.jsx("div",{style:{marginBottom:8},children:"This app needs a connection before its actions can run."}),n.jsx("button",{type:"button",className:"w6w-btn",onClick:()=>g(!0),children:"Create connection"})]}))]})}),n.jsxs("div",{className:"w6w-modal-actions w6w-stepconfig-footer",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:s,children:"Cancel"}),n.jsx("button",{type:"button",className:"w6w-btn",disabled:!F||!t,onClick:()=>t&&a(b,t),children:"Next →"})]}),x&&n.jsx(_s,{theme:r,initialAppId:e,onClose:()=>g(!1),onCreated:async({connectionId:I})=>{g(!1),m(I),N(!1),await A()}})]})}const yd=["props","code"];function xd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Oi({params:e,values:t,onChange:s,onValidityChange:o,readOnly:r,initialView:i="props"}){const a=e.length>0,[l,c]=w.useState(i),u=!a||l==="code",[d,f]=w.useState(()=>Ho(t)),[p,h]=w.useState(!0),b=w.useRef(!0),m=y=>{y!==b.current&&(b.current=y,h(y),o==null||o(y))},x=y=>{y==="code"&&f(Ho(t)),m(!0),c(y)},g=a?"Values (JSON)":"Payload";return n.jsxs("div",{className:"w6w-stack",children:[a&&n.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:n.jsx(On,{view:l,views:[...yd],onChange:y=>x(y)})}),u?n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:g}),n.jsx(lt,{value:d,onChange:f,readOnly:r,minHeight:"140px","aria-label":`${g} JSON`,onValidChange:y=>{const N=xd(y);m(N),N&&s(y)},onValidityChange:y=>{y.valid||m(!1)}}),!p&&n.jsx("span",{className:"w6w-hint",children:"This draft isn’t a JSON object yet — the collected values are unchanged until it is."})]}):n.jsx(He,{params:e,values:t,onChange:s,readOnly:r})]})}function Ho(e){return JSON.stringify(e??{},null,2)}function vd({title:e,message:t,onConfirm:s,onClose:o,confirmLabel:r="Confirm",cancelLabel:i="Cancel",destructive:a=!0,pending:l=!1,children:c}){return n.jsxs(Se,{title:e,onClose:()=>{l||o()},children:[n.jsxs("div",{className:"w6w-modal-body",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:t}),c]}),n.jsxs("div",{className:"w6w-modal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:o,disabled:l,children:i}),n.jsx("button",{type:"button",className:a?"w6w-btn w6w-btn-danger":"w6w-btn",onClick:s,disabled:l,children:r})]})]})}function Ut(e){if(!e||typeof e!="object")return null;switch(e.type){case"string":return"";case"number":return 0;case"boolean":return!1;case"object":{const t={};for(const[s,o]of Object.entries(e.fields??{}))t[s]=Ut(o);return t}case"array":return e.items?[Ut(e.items)]:[];default:return null}}function jd(e){const t={};for(const s of e??[])s&&typeof s.nodeId=="string"&&s.nodeId!==""&&(t[s.nodeId]=s);return t}function In(e){return e.sampleOmitted!==!0&&"sample"in e&&e.sample!==void 0}function $n(e,t){if(!t)return!1;const s=Date.parse(e.updatedAt),o=Date.parse(t);return Number.isFinite(s)&&Number.isFinite(o)&&s>o}function Ii(e,t,s,o){const r=t[e],i=s[e];return r!==void 0&&(!i||!$n(i,o==null?void 0:o[e]))||!i?r:In(i)?i.sample:Ut(i.shape)}function Nd(e,t,s){const o={};for(const r of new Set([...Object.keys(e),...Object.keys(t)])){const i=Ii(r,e,t,s);i!==void 0&&(o[r]=i)}return o}function kd(e,t,s){const o={...e};for(const[r,i]of Object.entries(t))In(i)&&(e[r]===void 0||$n(i,s==null?void 0:s[r]))&&(o[r]=i.sample);return o}function Sd(e,t,s){const o={...e},r={};for(const[i,a]of Object.entries(t))e[i]!==void 0&&!$n(a,s==null?void 0:s[i])||(delete o[i],r[i]=In(a)?a.sample:Ut(a.shape));return{fresh:o,persisted:r}}function Cd(e,t,s){const o={...e},r={};for(const[i,a]of Object.entries(t))In(a)&&(e[i]===void 0||$n(a,s==null?void 0:s[i]))&&(delete o[i],r[i]=a.sample);return{fresh:o,persisted:r}}function Ad(e,t){if(e.app)return e.app;if(e.app!==null)return t.get(e.appId)}function Ed(e){const t=new Set;for(const s of e)s.app===void 0&&t.add(s.appId);return[...t]}exports.AddConnectionModal=_s;exports.AnchoredFlyout=Zr;exports.ApiCallsPanel=oi;exports.AppIcon=ft;exports.AppPicker=at;exports.AppTriggerTestNote=Ti;exports.AuthFieldsForm=rn;exports.CALL_APP=gn;exports.CONTROL_APP=Pe;exports.CanvasLayer=za;exports.CodeEditor=js;exports.Combobox=kt;exports.ConditionEditor=Cn;exports.ConfigViewToggle=On;exports.ConfirmModal=vd;exports.CredentialPicker=Sr;exports.DATA_APP=Lt;exports.DeleteButton=Tr;exports.EACH_SOURCE_HANDLE=wn;exports.EDITOR_THEME_SPEC=vs;exports.ERROR_SOURCE_HANDLE=ds;exports.EventbriteTriggerPicker=ri;exports.ExpressionEditorModal=Jt;exports.ExpressionInput=Ht;exports.ExpressionOptionsProvider=_l;exports.FOREACH_DONE_ROUTE=yt;exports.HTML_PREVIEW_CSP=Pr;exports.HtmlPreview=Lr;exports.INTERNAL_NODES=pt;exports.IconButton=Nn;exports.InternalIcon=En;exports.JsonEditor=lt;exports.LastUsedNote=Gr;exports.Markdown=xs;exports.Modal=Se;exports.NodeConfigForm=$s;exports.ParamCustomization=Ps;exports.ParamsForm=He;exports.PropertyEntryForm=Oi;exports.RACE_APP=zt;exports.RACE_DESCRIPTION=Vo;exports.RESULT_RENDER_MAX_CHARS=Dr;exports.ROUTER_APP=We;exports.ResultViewer=Re;exports.RetryPolicyFields=jr;exports.RouterEditor=Or;exports.SCHEDULER_APP=fs;exports.SCRIPT_APP=Uo;exports.StepBuilderModal=td;exports.StepNameEditor=Ir;exports.StepTestRun=no;exports.StopEditor=$r;exports.TRIGGER_APP=bn;exports.TriggerFillForm=Yr;exports.W6WUIProvider=ga;exports.WEBHOOK_APP=Le;exports.WaitEditor=Xr;exports.WorkflowConnectionPicker=si;exports.WorkflowConnectionsContext=ni;exports.WorkflowProjectProvider=ya;exports.ancestorIds=Zs;exports.applyConnect=ru;exports.applyStepProblems=qc;exports.asFieldDefs=Ls;exports.bindingFieldsFor=Cr;exports.bridgeDeletedBodyStep=Qc;exports.buildBinding=Ar;exports.buildResolveScope=Ns;exports.canConnect=di;exports.centralizeConnections=ei;exports.coerceDefault=Ur;exports.conditionCombinatorLabel=hc;exports.conditionOperatorLabel=fc;exports.connectConflict=iu;exports.connectRefusal=au;exports.connectionAppIdsToLookUp=Ed;exports.connectionIdFor=St;exports.controlOwnedIds=Bs;exports.convertCodeBindingsToReads=Hl;exports.dataVarRows=mn;exports.declaredSamples=zu;exports.deepEqual=Gn;exports.defaultConnectionFor=ti;exports.definitionLoops=zs;exports.deleteStepMessage=ou;exports.detectResultFormat=Hr;exports.edgeLane=be;exports.edgeVisuals=Vt;exports.edgeWhenConflict=cu;exports.editConnectionResources=an;exports.effectiveEdges=Us;exports.effectiveNodeOutput=Ii;exports.effectiveNodeOutputs=Nd;exports.eventbriteTriggerChoices=ii;exports.excludeSelfStep=Pl;exports.fieldWidget=qr;exports.fieldsToParams=Fs;exports.filterOptions=er;exports.findChainRoot=Su;exports.findChainTail=Cu;exports.findCodeBindings=wr;exports.findTestInput=Vr;exports.flattenParams=vt;exports.flowToWorkflow=ju;exports.foreachTestFixture=$u;exports.foreachTestSample=Pu;exports.getTriggerDefs=Ri;exports.hasParamCustomization=An;exports.htmlPreviewSrcDoc=_r;exports.idClashMessage=fu;exports.ifPortLayout=Gi;exports.indexNodeSamples=jd;exports.inferOutputFields=rt;exports.internalNodeDef=it;exports.internalNodeDefaults=fn;exports.internalNodeIcon=pa;exports.internalNodeLabel=da;exports.internalNodeParams=zo;exports.isConnectionBlocked=zc;exports.isControlApp=Et;exports.isDollarPath=ks;exports.isEachLink=Vs;exports.isExprValue=qe;exports.isForeachStep=Ce;exports.isFormResolvedOptions=xn;exports.isIfStep=bs;exports.isInternalApp=Ye;exports.isParamVisible=Kt;exports.isSecretValue=Ze;exports.isTestRequired=Ci;exports.isTriggerApp=Ft;exports.isTriggerStep=Yi;exports.laneForSourceHandle=Hi;exports.loopBody=Rn;exports.loopItemText=Bu;exports.loopMembership=Be;exports.loopRefusal=ci;exports.loopRefusalMessage=nu;exports.nextWorkflowConnectionName=Ds;exports.nodeConfigSources=Ku;exports.nodeConfigValues=Gu;exports.nodeMetaSampleValues=Xu;exports.nodeMetaValues=Yu;exports.nodePortsForStep=Mt;exports.normalizeInput=Ys;exports.parseJsonFields=ss;exports.parseLoopSeed=Wu;exports.parseRootAnchoredTemplate=Xe;exports.pickWebhookSubscription=Wr;exports.previewCustomization=kr;exports.previewNodeOutputs=kd;exports.relaneRefusal=uu;exports.relayoutNodes=vu;exports.rememberableInput=Ms;exports.renameStepInEdges=du;exports.requiredParamsFilled=jt;exports.resolveConnectionAppMeta=Ad;exports.resolveLoopItemsInState=bi;exports.resolveOutputShape=bt;exports.resolveParamJson=Dt;exports.resolveParamValue=Cs;exports.resolveVarsJson=ul;exports.resultCopyText=Br;exports.routeFromHandle=Vi;exports.routeHandle=Nt;exports.routerPortLayout=Ki;exports.routesForStep=ws;exports.seedValues=os;exports.selectNodeConnection=Jc;exports.setEdgeWhen=lu;exports.shapeToSkeleton=Ut;exports.shouldUseCombobox=Qo;exports.slugifyLabel=ku;exports.splitFrontmatter=Xo;exports.splitNodeOutputs=Sd;exports.splitPreviewOutputs=Cd;exports.stampLoopOf=su;exports.startOAuthPopup=Er;exports.startStateFromSeeds=Qs;exports.stepBuilderLoop=Du;exports.stepBuilderUpstreamSteps=Mu;exports.stepNameError=pi;exports.stepProblemTooltip=Vc;exports.stepToJson=Xs;exports.storedViewport=hi;exports.stripBody=qs;exports.suggestStepId=Au;exports.testInputSavesSettled=Jr;exports.trackTestInputSave=zr;exports.upstreamSampleValueSources=Vu;exports.upstreamSampleValues=Uu;exports.upstreamStateSources=Fu;exports.useEffectiveTheme=yn;exports.useEnterSubmit=Rr;exports.useExpressionOptions=ht;exports.useRememberedTestInput=Kr;exports.useSeedSources=eo;exports.useW6WApi=ye;exports.useWorkflowConnections=Hs;exports.valueAtPath=$t;exports.varLabel=Ge;exports.withConnectionRef=qt;exports.withViewport=Nu;exports.workflowToFlow=xu;
22
+ //# sourceMappingURL=connection-app-meta-BEXlKBgV.cjs.map