@w6w/ui 0.2.56 → 0.2.57

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 (41) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/CallTargetForm.d.ts +10 -0
  3. package/dist/{CodeBlock-CymlfyeA.cjs → CodeBlock-BSX1pi6W.cjs} +2 -2
  4. package/dist/{CodeBlock-CymlfyeA.cjs.map → CodeBlock-BSX1pi6W.cjs.map} +1 -1
  5. package/dist/{CodeBlock-C-oIIYfC.js → CodeBlock-CPKXSNEs.js} +7 -3
  6. package/dist/{CodeBlock-C-oIIYfC.js.map → CodeBlock-CPKXSNEs.js.map} +1 -1
  7. package/dist/CodeEditor.d.ts +2 -0
  8. package/dist/JsonEditor.d.ts +1 -3
  9. package/dist/Markdown.d.ts +3 -1
  10. package/dist/StepBuilderModal.d.ts +2 -3
  11. package/dist/TriggerSampleButton.d.ts +11 -0
  12. package/dist/WorkflowFlowEditor.d.ts +48 -0
  13. package/dist/YamlEditor.d.ts +1 -2
  14. package/dist/callable-fields.d.ts +4 -0
  15. package/dist/code.cjs +1 -1
  16. package/dist/code.mjs +1 -1
  17. package/dist/components/ConfirmModal.d.ts +7 -1
  18. package/dist/components/DataEntryList.d.ts +2 -0
  19. package/dist/components/ResultViewer.d.ts +1 -2
  20. package/dist/connection-app-meta-BeYDm-cs.cjs +24 -0
  21. package/dist/connection-app-meta-BeYDm-cs.cjs.map +1 -0
  22. package/dist/{connection-app-meta-ZCPakGjD.js → connection-app-meta-aURFNTx_.js} +6115 -5806
  23. package/dist/connection-app-meta-aURFNTx_.js.map +1 -0
  24. package/dist/flow.cjs +4 -3
  25. package/dist/flow.cjs.map +1 -1
  26. package/dist/flow.mjs +1820 -1753
  27. package/dist/flow.mjs.map +1 -1
  28. package/dist/index.cjs +2 -2
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.mjs +306 -305
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/provider.d.ts +3 -0
  33. package/package.json +2 -1
  34. package/src/code.css +24 -0
  35. package/src/styles/_code-editor.scss +16 -0
  36. package/src/styles/_copyable.scss +22 -0
  37. package/src/styles/_data-vars.scss +11 -0
  38. package/src/styles.css +54 -0
  39. package/dist/connection-app-meta-BEXlKBgV.cjs +0 -22
  40. package/dist/connection-app-meta-BEXlKBgV.cjs.map +0 -1
  41. package/dist/connection-app-meta-ZCPakGjD.js.map +0 -1
@@ -0,0 +1,24 @@
1
+ "use strict";const n=require("react/jsx-runtime"),m=require("react"),ae=require("@w6w/expr"),Un=require("@codemirror/lang-javascript"),Mi=require("@codemirror/lang-python"),ds=require("@codemirror/view"),Vo=require("@uiw/react-codemirror"),le=require("./CodeBlock-BSX1pi6W.cjs"),zo=require("@codemirror/lang-json"),ao=require("@codemirror/lint"),pn=require("react-dom"),Vn=require("@xyflow/react"),Di=require("react-markdown");var Fn=typeof document<"u"?document.currentScript:null;const Hi={ai:"AI",cms:"CMS",crm:"CRM",hr:"HR",devops:"DevOps"};function Wi(e){if(typeof e!="string"||e.trim()==="")return"";const t=Hi[e];return t||e.split(/[-_\s]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")}function qi(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:Wi(s),count:o})).sort((s,o)=>o.count-s.count||s.label.localeCompare(o.label,void 0,{sensitivity:"base"}))}function Bi(e,t){if(t.length===0)return!0;const s=e.categories??[];return t.some(o=>s.includes(o))}function Jt(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 ps="out-error",gn="out-each",jt="done",Jo="each";function fs(e){return e==="error"?ps:e==="each"?gn:void 0}function Ui(e){return e===ps?"error":e===gn?"each":"success"}const Vi="@w6w/",Oe="@w6w/control",Ko="@w6w/script",Dt="@w6w/data",Ct="@w6w/trigger",zi="@w6w/http",Fe="@w6w/webhook",hs="@w6w/scheduler",Ji="@w6w/respond",yn="@w6w/call",ws="@w6w/document",Ln="@w6w/model",Ki="@w6w/template",Xt="@w6w/regex",De="@w6w/store",ms="@w6w/stop",We="@w6w/router",Kt="@w6w/race",Go="Continue once with the first arriving path’s output. Later arrivals are ignored for this run. Other paths keep running.";function bs(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 At=e=>`route:${e}`,Gi=e=>e!=null&&e.startsWith("route:")?e.slice(6):void 0,Yi=3,Xi=16;function Zi(e){const t=e.find(r=>r.default),s=r=>({id:r.id,handleId:At(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>Yi?{minHeight:o.length*Xi}:{}}}const fn="false";function gs(e){return e.uses.app===Oe&&e.uses.action==="if"}function Qi(){return{right:[{id:"true",label:"True",top:"50%"}],bottom:{id:fn,handleId:At(fn),label:"False"}}}function Ge(e){return e.startsWith(Vi)}function It(e){return e===Oe||e===Kt}function hn(e){return e===Ct||e===Fe||e===hs}function ea(e){return hn(e.app)||e.trigger===!0}const lo={in:1,out:Number.POSITIVE_INFINITY};function co(e){return e==="many"?Number.POSITIVE_INFINITY:typeof e=="number"?e:void 0}function ta(...e){let t,s;for(const o of e)t??(t=co(o==null?void 0:o.in)),s??(s=co(o==null?void 0:o.out));return{in:t??lo.in,out:s??lo.out}}function Ht(e,t){var i;if(e.uses.app===We)return{in:1,out:bs(e).length};const{app:s,action:o}=e.uses,r=e.uses.trigger?{in:0,out:1}:void 0;return ta(e.ports,t==null?void 0:t(s,o),((i=at(s,o))==null?void 0:i.ports)??r)}const na='<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" />',uo='<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" />',sa='<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" />',oa='<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" />',ra='<circle cx="12" cy="12" r="9" /><polyline points="12 7 12 12 15 14" />',ia='<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" />',aa='<polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" />',po='<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" />',la='<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" />',ca='<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" />',ua='<polyline points="9 17 4 12 9 7" /><path d="M20 18v-2a4 4 0 0 0-4-4H4" />',fo='<polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" />',da='<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" />',pa='<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" />',Mn='<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" />',fa='<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" />',rt='<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" />',ha=[{app:Xt,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:Xt,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:Xt,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:Xt,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"}]}],dt=[...ha,{app:Kt,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:uo,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:Ct,action:"manual",label:"Manual trigger",displayName:"Manual trigger",group:"trigger",icon:na,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:Fe,action:"webhook",label:"Webhook",displayName:"Webhook",group:"trigger",icon:ca,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:hs,action:"schedule",label:"Schedule",displayName:"Scheduler",group:"trigger",icon:ia,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:Oe,action:"if",label:"If",displayName:"If",group:"control",icon:uo,params:[{key:"condition",type:"json",label:"Condition",required:!0,default:!0,hint:"A boolean, or an expression like {{ nodes.x.output.ok }}."}]},{app:Oe,action:"foreach",label:"For each",displayName:"For each",group:"control",icon:sa,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:Oe,action:"parallel",label:"Parallel",displayName:"Parallel",group:"control",icon:oa,params:[]},{app:Oe,action:"wait",label:"Wait",displayName:"Wait",group:"control",icon:ra,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:Ko,action:"run",label:"Run script",displayName:"Run script",group:"compute",icon:aa,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:Ki,action:"render",label:"Render template",displayName:"Template",group:"compute",icon:fa,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:Dt,action:"set",label:"Data",displayName:"Data set",group:"compute",icon:po,params:[{key:"vars",type:"vars",label:"Variables",required:!0,default:[],hint:"Set values for downstream steps using individual fields or a JSON object."}]},{app:Dt,action:"update",label:"Update object",displayName:"Update object",group:"compute",icon:po,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:zi,action:"request",label:"HTTP request",displayName:"HTTP",group:"request",icon:la,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:Ji,action:"respond",label:"Respond to Webhook",displayName:"Respond to Webhook",group:"request",icon:ua,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:Oe,action:"aggregate",label:"Aggregate",displayName:"Aggregate",group:"control",icon:fo,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:Oe,action:"merge",label:"Merge",displayName:"Merge",group:"control",icon:fo,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:yn,action:"call",label:"Call workflow",displayName:"Call",group:"compute",icon:da,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:"entry",label:"Trigger node",type:"string",hint:"The manual trigger node to start at in the called workflow."},{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:ws,action:"get",label:"Get document",displayName:"Document",group:"compute",icon:pa,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:Mn,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:Mn,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:Mn,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:rt,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:rt,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:rt,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:rt,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:rt,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:rt,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:rt,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 at(e,t){return dt.find(s=>s.app===e&&s.action===t)}function wa(e,t){var s;return((s=at(e,t))==null?void 0:s.label)??t}function ma(e,t){var s;return((s=at(e,t))==null?void 0:s.icon)??""}function Yo(e,t){var s;return((s=at(e,t))==null?void 0:s.params)??[]}function wn(e,t){const s={};for(const o of Yo(e,t))o.default!==void 0&&(s[o.key]=o.default);return s}function ba(e,t){return e.q===t.q&&(e.category??"")===(t.category??"")&&(e.ids??[]).join(",")===(t.ids??[]).join(",")}function Xo(e,t=0){return{query:e,generation:t,status:"loading",apps:[],hasMore:!1}}function ga(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 ya(e,t){switch(t.type){case"query-changed":return t.generation===e.generation&&ba(t.query,e.query)?e:Xo(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=ga(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 xa(e){return e.filter(t=>!Ge(t.id))}function Dn(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 va(e,t){const s=[];for(const o of e){const r=t.get(o);r&&s.push(r)}return s}const Zo=m.createContext(void 0);function ho(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 xn(e){const t=m.useContext(Zo),[s,o]=m.useState(()=>ho(e,t));return m.useEffect(()=>{if(e){o(e);return}if(t){o(t);return}if(typeof window>"u")return;const r=()=>o(ho(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 pt({src:e,srcDark:t,brandColor:s,name:o,size:r=32,theme:i}){const l=xn(i)==="dark"?t??e:e,[u,c]=m.useState(void 0);if(l&&l!==u)return n.jsx("img",{src:l,width:r,height:r,alt:"",onError:()=>c(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(p=>{var f;return((f=p[0])==null?void 0:f.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 ys=m.createContext(null);function ja({api:e,theme:t,children:s}){const o=n.jsx(ys.Provider,{value:e,children:n.jsx(Zo.Provider,{value:t,children:s})});return t?n.jsx("div",{"data-theme":t,style:{display:"contents"},children:o}):o}function xe(){const e=m.useContext(ys);if(!e)throw new Error("useW6WApi must be used inside <W6WUIProvider>. Wrap your app root with <W6WUIProvider api={api}>...</W6WUIProvider>.");return e}function nn(){return m.useContext(ys)??void 0}const Qo=m.createContext(void 0),er=m.createContext(void 0);function Na({project:e,workflowId:t,children:s}){return n.jsx(Qo.Provider,{value:e,children:n.jsx(er.Provider,{value:t,children:s})})}function xs(){return m.useContext(Qo)}function ka(){return m.useContext(er)}const Hn=8,Sa=60,Ca=300;function wo(e){const t=e.modelProvider;return!t||typeof t!="object"?null:t}function Aa(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 lt({onSelectApp:e,theme:t,filter:s,searchPlaceholder:o,emptyMessage:r,search:i=!0,searchValue:a,onSearchChange:l,emptyAction:u,apps:c,categoryFilter:d=!1,providerFilter:p=!1,bridgeSupport:f,category:h,hasTriggers:b,ids:w,pageLimit:x=Sa,loadPage:g}){const y=xe(),k=c!==void 0,A=w&&w.length>0?w.join(","):"",S=!k&&(g!==void 0||typeof y.listAppsPage=="function"),j=m.useRef(g);j.current=g;const[v,E]=m.useState(null),[T,D]=m.useState(null);m.useEffect(()=>{if(k||S)return;const q=y.listApps;if(typeof q!="function"){E([]);return}let ie=!1;return q().then(oe=>!ie&&E(oe)).catch(oe=>!ie&&D(oe.message)),()=>{ie=!0}},[y,k,S]);const[I,R]=m.useReducer(ya,Xo({q:"",category:h,ids:w},0)),[O,L]=m.useState(""),H=a??O,B=q=>{a===void 0&&L(q),l==null||l(q)},[z,P]=m.useState(H.trim()),$=m.useRef(0),Z=m.useRef(null),Q=m.useCallback((q,ie,oe)=>{var gt;const Ve=j.current,ze=y.listAppsPage;if(!Ve&&!ze)return;(gt=Z.current)==null||gt.abort();const Te=new AbortController;Z.current=Te;let Ie;try{Ie=Ve?Ve({q:q.q||void 0,cursor:oe,limit:x,...q.ids?{ids:q.ids}:{},signal:Te.signal}):ze({q:q.q||void 0,category:q.category,...b?{hasTriggers:!0}:{},...q.ids?{ids:q.ids}:{},cursor:oe,limit:x,compact:!0,signal:Te.signal})}catch(ye){Ie=Promise.reject(ye)}Ie.then(ye=>{if($.current===ie){if(!ye||!Array.isArray(ye.apps)){R({type:"page-failed",generation:ie,error:"The server returned a malformed apps page."});return}R({type:"page-loaded",generation:ie,apps:ye.apps,nextCursor:ye.nextCursor,requestedCursor:oe,total:typeof ye.total=="number"?ye.total:void 0})}}).catch(ye=>{if($.current!==ie||ye instanceof Error&&ye.name==="AbortError")return;const Tt=ye==null?void 0:ye.code;if(oe!==void 0&&(Tt==="snapshot_expired"||Tt==="unknown_snapshot")){const N=++$.current;R({type:"query-changed",query:q,generation:N}),Q(q,N,void 0);return}R({type:"page-failed",generation:ie,error:ye.message})})},[y,x,b]);m.useEffect(()=>{if(!S)return;const q=setTimeout(()=>P(H.trim()),Ca);return()=>clearTimeout(q)},[H,S]),m.useEffect(()=>{if(!S)return;const q=++$.current,ie={q:z,category:h,...A?{ids:A.split(",")}:{}};return R({type:"query-changed",query:ie,generation:q}),Q(ie,q,void 0),()=>{var oe;(oe=Z.current)==null||oe.abort()}},[S,z,h,A,Q]),m.useEffect(()=>{if(S)return()=>{var q;return(q=Z.current)==null?void 0:q.abort()}},[S]);const ee=()=>{if(!S||I.status!=="ready"||!I.hasMore)return;const q=$.current;R({type:"load-more"}),Q(I.query,q,I.cursor)},F=()=>{!S||I.status!=="error"||(R({type:"retry"}),Q(I.query,$.current,I.cursor))},[X,Y]=m.useState([]),[U,G]=m.useState(!1),[te,C]=m.useState(!1),V=q=>n.jsx("div",{className:"w6w-apppicker-host",children:q});let J,_=null,W=!1,ue=!1,pe=null,he=!1;if(k?J=c??null:S?(J=I.apps,he=I.status==="loading",W=I.status==="loading-more",ue=I.hasMore,I.status==="error"&&(I.apps.length===0?_=I.error??"Failed to load apps.":pe=I.error??"Failed to load apps.")):(J=v,_=T),!S&&_)return V(n.jsx("div",{className:"w6w-result w6w-error",children:_}));if(!S&&J===null)return V(n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading apps…"}));J??(J=[]);const ge=xa(J),ke=s?ge.filter(s):ge;if(!S&&ke.length===0)return V(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."}),u]}));const ve=d?qi(ke):[],Be=ve.slice(0,Hn),ce=ve.slice(Hn).filter(q=>X.includes(q.slug)),Ee=[...Be,...ce],Ue=ve.length-Ee.length,tt=U?ve:Ee,wt=q=>Y(ie=>ie.includes(q)?ie.filter(oe=>oe!==q):[...ie,q]),nt=()=>Y([]),mt=ke.filter(q=>wo(q)!==null).length,Le=p&&mt>0,st=Le&&te,we=st?ke.filter(q=>wo(q)!==null):ke,Re=d&&X.length>0?we.filter(q=>Bi(q,X)):we,ot=S?Re:[...Re].sort((q,ie)=>q.displayName.localeCompare(ie.displayName,void 0,{sensitivity:"base"})),_e=S?"":H.trim().toLowerCase(),me=H.trim().length>0,Ae=_e?ot.filter(q=>q.displayName.toLowerCase().includes(_e)||q.id.toLowerCase().includes(_e)):ot,Se=s!==void 0&&ke.length!==ge.length||st&&we.length!==ke.length||d&&X.length>0&&Re.length!==we.length,bt=(d&&X.length>0||st)&&Ae.length===0,Rt=st&&X.length===0,ne=()=>{Y([]),C(!1),B("")};return V(n.jsxs("div",{className:"w6w-stepbuilder-apps",children:[i&&n.jsx("input",{type:"text",className:"w6w-stepbuilder-search",placeholder:o??"Search apps…",value:H,onChange:q=>B(q.target.value),"aria-label":"Search apps"}),(Le||d&&ve.length>0)&&n.jsxs("div",{className:"w6w-apppicker-cats",children:[Le&&n.jsxs("button",{type:"button",className:"w6w-apppicker-chip w6w-apppicker-provider-toggle","aria-pressed":te,"aria-label":"Filter to model providers",onClick:()=>C(q=>!q),children:["Model providers ",n.jsxs("span",{className:"w6w-muted",children:["(",mt,")"]})]}),d&&ve.length>0&&n.jsxs(n.Fragment,{children:[tt.map(q=>n.jsxs("button",{type:"button",className:"w6w-apppicker-chip","aria-pressed":X.includes(q.slug),"aria-label":`Filter by ${q.label}`,onClick:()=>wt(q.slug),children:[q.label," ",n.jsxs("span",{className:"w6w-muted",children:["(",q.count,")"]})]},q.slug)),!U&&Ue>0&&n.jsxs("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>G(!0),children:["+",Ue," more"]}),U&&ve.length>Hn&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>G(!1),children:"Show less"}),X.length>0&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:nt,children:"Clear"})]})]}),S&&he?n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading apps…"}):S&&_?n.jsxs("div",{className:"w6w-result w6w-error",children:[_," ",n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:F,children:"Retry"})]}):Ae.length===0&&!ue?bt?n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:Rt?me?`No model providers match “${H}”.`:"No apps declare a model provider.":me?`No apps match “${H}” 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:ne,children:"Clear filters"})]}):S?n.jsxs("div",{className:"w6w-stack",children:[n.jsx("p",{className:"w6w-muted w6w-small",children:me?`No apps match “${H}”.`:r??"No apps registered yet. Register one from the Apps page first."}),!me&&u]}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["No apps match “",H,"”."]}):n.jsxs(n.Fragment,{children:[Ae.length===0&&ue?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:Ae.map(q=>{const ie=f==null?void 0:f.get(q.id),oe=Aa(ie);return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item w6w-apppicker-card",onClick:()=>e(q),children:[n.jsx(pt,{src:q.iconSvg,srcDark:q.iconSvgDark,brandColor:q.brandColor,name:q.displayName,theme:t,size:24}),n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:q.displayName}),n.jsx("code",{className:"w6w-apppicker-card-id",children:q.id}),q.version&&n.jsxs("span",{className:"w6w-apppicker-card-version",children:["v",q.version]}),oe&&n.jsx("span",{className:ie!=null&&ie.supported?"w6w-chip w6w-apppicker-card-bridge":"w6w-chip w6w-apppicker-card-bridge w6w-apppicker-card-bridge-unsupported",title:oe.title,children:oe.text})]})]},q.id)})}),S&&typeof I.total=="number"&&n.jsx("div",{className:"w6w-small w6w-apppicker-count",children:Se?`${Ae.length} ${Ae.length===1?"app":"apps"}`:`${I.apps.length} of ${I.total}`}),S&&pe&&n.jsxs("div",{className:"w6w-result w6w-error w6w-small",children:[pe," ",n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:F,children:"Retry"})]}),S&&ue&&!pe&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-apppicker-load-more",onClick:ee,disabled:W,children:W?"Loading more…":"Load more"})]})]}))}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 Ea(){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:Fn&&Fn.tagName.toUpperCase()==="SCRIPT"&&Fn.src||new URL("connection-app-meta-BeYDm-cs.cjs",document.baseURI).href),{type:"module"}),e.onmessage=c=>{var d;(d=o.get(c.data.id))==null||d(c.data.options),o.delete(c.data.id)},e.onerror=r);const u=await new Promise(c=>{const d=++t;o.set(d,c),a.addEventListener("abort",()=>{o.delete(d),c([])},{onDocChange:!0}),e==null||e.postMessage({id:d,code:a.state.doc.toString(),position:a.pos})});return a.aborted||!u.length?null:{from:l.from,options:u}};return[Un.javascriptLanguage.data.of({autocomplete:i}),ds.ViewPlugin.define(()=>(s=!1,{destroy(){s=!0,r()}}))]}function Ra(e){switch(e){case"javascript":return Un.javascript();case"typescript":return Un.javascript({typescript:!0});case"python":return Mi.python()}}function js(e){const t=xn(e.theme),{copied:s,copy:o}=le.useCopyToClipboard(e.value),r=m.useMemo(()=>[...e.language?[Ra(e.language)]:[],...e.language==="javascript"||e.language==="typescript"?[Ea()]:[],ds.EditorView.theme(vs)],[e.language]);return n.jsxs("div",{className:"w6w-code-editor","aria-label":e["aria-label"]??"Code editor",children:[n.jsx(Vo,{value:e.value,onChange:e.onChange,extensions:r,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}}),e.copyable!==!1&&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(le.CheckGlyph,{}):n.jsx(le.CopyGlyph,{})}),n.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:s?"Copied":""})]})]})}function Ta(){const e=zo.jsonParseLinter();return t=>t.state.doc.toString().trim()===""?[]:e(t)}function Ye(e){const t=xn(e.theme),{copied:s,copy:o}=le.useCopyToClipboard(e.value),r=m.useMemo(()=>[zo.json(),...e.showDiagnostics===!1?[]:[ao.linter(Ta()),ao.lintGutter()],ds.EditorView.theme(vs)],[e.showDiagnostics]);function i(a){var l,u,c,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 p=JSON.parse(a);(u=e.onValidChange)==null||u.call(e,p),(c=e.onValidityChange)==null||c.call(e,{valid:!0})}catch(p){(d=e.onValidityChange)==null||d.call(e,{valid:!1,error:p.message})}}}return n.jsxs("div",{className:"w6w-json-editor","aria-label":e["aria-label"]??"JSON editor",children:[n.jsx(Vo,{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!==!1&&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(le.CheckGlyph,{}):n.jsx(le.CopyGlyph,{})}),n.jsx("span",{className:"w6w-copyable-status","aria-live":"polite",children:s?"Copied":""})]})]})}function tr(e,t,s){return e*t>.6*s}function nr(e,t){const s=t.trim().toLowerCase();return s?e.filter(o=>o.label.toLowerCase().includes(s)||o.value.toLowerCase().includes(s)):e}const Ia=240,Oa={display:"block",fontSize:"0.85em",opacity:.65,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},$a={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 ft({options:e,value:t,onChange:s,placeholder:o,disabled:r,"aria-label":i,mode:a="auto",forceSelection:l=!0,optionHeight:u=32,listMaxHeight:c=Ia,className:d,onInputChange:p,emptyText:f="No matches",footer:h}){var z;const b=a==="combobox"||a==="auto"&&tr(e.length,u,typeof window>"u"?0:window.innerHeight),w=m.useId(),x=((z=e.find(P=>P.value===t))==null?void 0:z.label)??(l?"":t),[g,y]=m.useState(x),[k,A]=m.useState(!1),[S,j]=m.useState(!1),[v,E]=m.useState(0),T=m.useRef(null);m.useEffect(()=>{y(x)},[x]);const D=m.useMemo(()=>S?nr(e,g):e,[e,g,S]),I=m.useMemo(()=>({...$a,maxHeight:c}),[c]);if(!b)return n.jsxs("select",{className:d,value:t,disabled:r,"aria-label":i,onChange:P=>s(P.target.value),children:[o!==void 0&&t===""&&n.jsx("option",{value:"",disabled:!0,children:o}),e.map(P=>n.jsx("option",{value:P.value,children:P.label},P.value))]});const R=P=>`${w}-opt-${P}`,O=()=>{A(!1),j(!1)},L=P=>{y(P.label),s(P.value),O()},H=P=>{P.key==="ArrowDown"?(P.preventDefault(),k?E($=>Math.min($+1,D.length-1)):A(!0)):P.key==="ArrowUp"?(P.preventDefault(),k?E($=>Math.max($-1,0)):A(!0)):P.key==="Enter"?k&&D[v]?(P.preventDefault(),L(D[v])):l||(g!==x&&s(g),O()):P.key==="Escape"&&(k&&P.stopPropagation(),y(x),O())},B=()=>{l?y(x):g!==x&&s(g),O()};return n.jsxs("div",{ref:T,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":k,"aria-controls":`${w}-list`,"aria-autocomplete":"list","aria-activedescendant":k&&D[v]?R(v):void 0,autoComplete:"off",onFocus:()=>A(!0),onChange:P=>{y(P.target.value),p==null||p(P.target.value),j(!0),E(0),A(!0)},onKeyDown:H,onBlur:B}),k&&n.jsxs("div",{id:`${w}-list`,role:"listbox",tabIndex:-1,"aria-label":i,style:I,children:[D.map((P,$)=>n.jsxs("div",{id:R($),role:"option",tabIndex:-1,"aria-selected":P.value===t,style:{padding:"6px 8px",cursor:"pointer",borderRadius:4,background:$===v?"var(--w6w-panel-2)":void 0},onMouseDown:Z=>{Z.preventDefault(),L(P)},onMouseEnter:()=>E($),children:[P.label,P.detail!==void 0&&n.jsx("span",{className:"w6w-combobox-detail",style:Oa,children:P.detail})]},P.value)),D.length===0&&n.jsx("div",{role:"presentation",style:{padding:"6px 8px",opacity:.6},children:f}),h!==void 0&&n.jsx("div",{role:"presentation",className:"w6w-combobox-footer",style:{padding:"6px 8px",opacity:.6,fontSize:"0.85em"},children:h})]})]})}function vn(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 Qe(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 sn(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}Pa(s)%2===1&&(s+="\\"),s+=ae.serializeTemplate([mo(o)])}return s}function Pa(e){let t=0;for(;t<e.length&&e[e.length-1-t]==="\\";)t+=1;return t}const sr={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(sr));const bo=e=>Object.prototype.hasOwnProperty.call(sr,e),go=["state","var","vars"];function or(e){for(const t of go)if(e===t||e.startsWith(`${t}.`)){const s=e.slice(t.length);return[...new Set([e,...go.map(o=>o+s)])]}return[e]}function yo(e){const t=e.indexOf(".");return t===-1?e:e.slice(0,t)}function Xe(e){const t=ae.parseTemplate(e,"editor",_a);return t.every(jn)?t:[{kind:"text",value:e}]}function jn(e){if(e.kind==="var"){const t=e.ref??"";return!ae.hasRefusedChainToken(t)&&bo(yo(t))}if(e.kind==="expr"){const t=ae.coalesceOperandRefs(e.expr);return t===null?!0:t.every(s=>bo(yo(s)))}return!0}const _a={isOurs:jn,backslash:"keep"},rr={isOurs:jn,backslash:"strip"};function Ze(e){return qe(e)?!0:typeof e=="string"&&e.includes("{{")&&Xe(e).some(t=>t.kind!=="text")}function Nn(e){if(!e.includes("{{"))return null;const t=ae.parseTemplate(e,"editor",rr);return t.every(jn)&&(t.some(s=>s.kind!=="text")||t.map(s=>s.value??"").join("")!==e)?t:null}function Fa(e){return e.includes("{{")?ae.parseTemplate(e,"editor",rr).map(t=>t.kind==="text"?t.value??"":ae.serializeTemplate([t])).join(""):e}function zn(e){if(Qe(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 La(e,t){let s="";for(const o of e)switch(o.kind){case"text":s+=Fa(o.value??"");break;case"var":case"render":{const r=or(o.ref??"").find(i=>i in t);s+=r===void 0?"":t[r];break}case"secret":s+="•••";break;case"expr":s+=ae.serializeTemplate([o]);break}return s}const Nt="var.",xo="vars.",Jn="documents.",Kn="const.",Gn="state.";function ir(e){return e==="state"||e==="vars"?"var":e.startsWith(xo)?Nt+e.slice(xo.length):e.startsWith(Gn)?Nt+e.slice(Gn.length):e}function Ma(e){return e.startsWith(Gn)?3:e.startsWith(Nt)?2:1}function ar(e){return e.rank>0?e.value:Object.fromEntries(Array.from(e.children,([t,s])=>[t,ar(s)]))}function Ns(e,t,s,o){const r={children:new Map,rank:0},i={},a={};for(const[b,w]of Object.entries(e??{})){const x=ir(b);if(x.startsWith(Nt)){const g=x.slice(Nt.length),y=Ma(b);let k=r;for(const A of g.split(".")){let S=k.children.get(A);S||(S={children:new Map,rank:0},k.children.set(A,S)),k=S}y>=k.rank&&(k.value=w,k.rank=y)}else x.startsWith(Jn)?i[x.slice(Jn.length)]=w:x.startsWith(Kn)&&(a[x.slice(Kn.length)]=w)}const l=ar(r),u=(t==null?void 0:t.steps)??{},c=e??{},d=Object.hasOwn(c,"foreach.item"),p=typeof c["foreach.index"]=="number",f=t==null?void 0:t.foreach,h=f?{...f}:d||p?{...d?{item:c["foreach.item"]}:{},...p?{index:c["foreach.index"]}:{}}:void 0;return{...h?{foreach:h}:{},vars:l,state:l,documents:i,constants:a,steps:u,nodes:u,trigger:(t==null?void 0:t.trigger)??{},flat:e??{},...s?{config:s}:{},...o?{meta:o}:{}}}function Da(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 Ha=/^(?:nodes|steps)\.[^.]+\.(?:meta\.)?config(?:\.|$)/,Wa=/^(?:nodes|steps)\.([^.]+)\.meta(?:\.|$)/;function qa(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 lr(e,t){var f;const s=ir(e);if(t.flat&&(s.startsWith(Nt)||s.startsWith(Jn)||s.startsWith(Kn))){const h=or(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,u=qa(t.nodes??t.steps,i,a),c={...l,var:o,...r?{const:r}:{},nodes:u,steps:u},d=Da(c,s);if(d.present)return{status:"resolved",ref:e,value:d.value};if(Ha.test(s))return{status:"at-run",ref:e};const p=(f=Wa.exec(s))==null?void 0:f[1];return p!==void 0&&(a!=null&&a[p])?{status:"at-run",ref:e}:{status:"unresolved",ref:e}}function vo(e,t){switch(e.kind){case"text":return{status:"resolved",value:e.value??""};case"var":return lr(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(Qe(e))return[{status:"masked"}];if(qe(e))return e.parts.map(s=>vo(s,t));if(typeof e=="string"){const s=Nn(e);if(s)return s.map(o=>vo(o,t))}return ks(e)?[lr(String(e.$),t)]:Ss(e)?[{status:"not-evaluated"}]:[{status:"resolved",value:e}]}function Yn(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 u=e,c=t;return u.length===c.length&&u.every((d,p)=>Yn(d,c[p]))}const r=e,i=t,a=Object.keys(r),l=Object.keys(i);return a.length===l.length&&a.every(u=>u in i&&Yn(r[u],i[u]))}function cr(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 Ba(e){return e.status==="resolved"&&e.value!==void 0?typeof e.value=="string"?e.value:JSON.stringify(e.value):String(cr(e))}function Ua(e){return e.length===1?cr(e[0]):e.map(Ba).join("")}function Wt(e,t){return Ua(Cs(e,t))}function Va(e,t){const s={};for(const o of e)s[o.key||"(no key)"]=Wt(o.value,t);return s}const kn=m.forwardRef(function(t,s){const{label:o,children:r,icon:i,iconSize:a,title:l,onClick:u,disabled:c,className:d,danger:p,...f}=t,h=r??(i?n.jsx(le.Icon,{name:i,size:a??16}):null);return n.jsx("button",{ref:s,type:"button",className:["w6w-icon-button",p?"w6w-icon-button-danger":"",d??""].filter(Boolean).join(" "),title:l??o,"aria-label":o,"aria-pressed":f["aria-pressed"],"aria-expanded":f["aria-expanded"],"aria-controls":f["aria-controls"],disabled:c,onClick:u,"data-testid":f["data-testid"],children:h})});kn.displayName="IconButton";const za={default:"",wide:" w6w-modal-wide",xl:" w6w-modal-xl",full:" w6w-modal-full",fullscreen:" w6w-modal-fullscreen"};function je({title:e,ariaLabel:t,onClose:s,children:o,size:r="default",titleIcon:i,subtitle:a,headerRight:l}){const u=m.useRef(null),c=m.useRef(null);return m.useEffect(()=>()=>{var d;(d=c.current)!=null&&d.isConnected&&c.current.focus({preventScroll:!0})},[]),m.useEffect(()=>{const d=u.current;if(!d)return;d.open||(c.current=document.activeElement,d.showModal());const p=h=>{h.preventDefault(),s()},f=h=>{if(h.target!==d)return;const b=d.getBoundingClientRect();(h.clientX<b.left||h.clientX>b.right||h.clientY<b.top||h.clientY>b.bottom)&&s()};return d.addEventListener("cancel",p),d.addEventListener("click",f),()=>{d.removeEventListener("cancel",p),d.removeEventListener("click",f)}},[s]),n.jsx("div",{className:"w6w-modal-backdrop",children:n.jsxs("dialog",{ref:u,className:`w6w-modal${za[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"]),Ja=/[=<>]|!=|&&|\|\||\?\?/,on=e=>Ja.test(e)||/^\s*\(*\s*!/.test(e),jo=e=>ae.expressionReferences(e).some(on);function Ka(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(u=>u.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 Ot(e,t){var c,d,p,f,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"&&!jo(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(jo(b.expr)){const x=ae.serializeTemplate([b]);if(!x.startsWith("{{ ="))return`(${x.slice(2,-2).trim()})`}const w=ae.formatReadableExpression(b.expr);return w===null?ae.serializeTemplate([b]):`(${w})`}return on(b.ref??"")?b.ref??"":`{{ ${b.ref??""} }}`}).join("").trim();if(!on(r))return s;const i=/^\{\{([^{}]+)\}\}$/.exec(r);i&&on(i[1])&&(r=i[1].trim());const a=r.replace(/^[\s(!]+/,""),l=(c=/^(?:\{\{\s*)?([A-Za-z_$][\w$-]*)/.exec(a))==null?void 0:c[1],u=a.startsWith("{{")||l!==void 0&&(As.has(l)||l==="secrets"||((d=t.steps)==null?void 0:d.some(b=>b.id===l))||((p=t.vars)==null?void 0:p.includes(l))||((f=t.constants)==null?void 0:f.includes(l)));if(!u&&!/^(?:["']|-?\d|true\b|false\b|null\b)/.test(a))return s;if(u&&!/^\s*\(*\s*!/.test(r)){const b=(h=/^(?:\{\{[^{}]+\}\}|[A-Za-z_$][\w$-]*(?:\.[\w$-]+)*)/.exec(a))==null?void 0:h[0];if(b){const w=a.slice(b.length).replace(/^[\s)]+/,"");if(!/^(?:[=<>(]|!=|&&|\|\||\?\?)/.test(w)||/^<\/?[A-Za-z][^>]*>/.test(w))return s}}try{return{parts:[{kind:"expr",expr:ae.parseReadableExpression(r,w=>Ka(w,t))}],error:null}}catch(b){return{parts:o,error:b instanceof Error?b.message:"Check the expression."}}}function Ga(e){return[...new Set(e.flatMap(t=>t.kind==="expr"?ae.expressionReferences(t.expr):(t.kind==="var"||t.kind==="render")&&t.ref?[t.ref]:[]))]}function Ya(e){return e.replace(/^(?:vars|state)(?=\.|$)/,"var").replace(/^steps(?=\.|$)/,"nodes")}function Xa(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=Ya(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],u=l&&typeof l=="object"?{...l}:{};i[a]=u,i=u}i[r[r.length-1]]=o}return t.steps=t.nodes,t.vars=t.var,t.state=t.var,t}function Za(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=Xa(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"||ae.formatReadableExpression(a.expr)===null)return La([a],i);if(ae.expressionReferences(a.expr).some(c=>!c||c.split(".")[0]==="secrets"))return"••••";const u=ae.evaluate(a.expr,r);return typeof u=="string"?u:JSON.stringify(u)??""}).join("")}const Qa=/^(?:nodes|steps)\.([^.]+)\.output(?:\.(.+))?$/,el=/^(?:nodes|steps)\.([^.]+)\.meta\.(app|version|action|connectionId)$/,Ke=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=Qa.exec(e);if(t)return t[2]?`${t[1]}.${t[2]}`:t[1];const s=el.exec(e);return s?`${s[1]} meta · ${s[2]}`:e};function tl(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 nl(e){const t=e.op==="or"?"||":"??",s=e.operands.map(o=>{const r=tl(o);return r!==void 0?Ke(r):JSON.stringify(o)}).join(` ${t} `);return s.length>40?`${s.slice(0,40)}…`:s}const sl=/[.{}]/;function yt(e){return e===""||e!==e.trim()?!1:!sl.test(e)}function Zt(e){return e.split(".").every(yt)}function No(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 _t(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=Ke(t.ref??""),o.title=`Variable: ${t.ref??""}`;else if(t.kind==="render")o.setAttribute("data-ref",t.ref??""),r.textContent="▤",i.textContent=Ke(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 u=ae.parseCoalesceChain(t.expr);if(u)i.textContent=nl(u),o.title=`Expression: ${ae.serializeTemplate([t])}`;else{const c=ae.formatReadableExpression(t.expr,Ke);i.textContent=c??(l.length>24?`${l.slice(0,24)}…`:l||"expr"),o.title=`Expression: ${c??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 u=t.kind==="render"?"Stop rendering as a template":"Render this as a template";l.setAttribute("aria-label",u),l.title=u,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 ur=new Set(["div","p"]);function dr(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 $t(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,u=dr(l);if(u){t.push(u);return}const c=(l.tagName??"").toLowerCase();if(c==="br"){a||s(`
3
+ `);return}const d=ur.has(c);d&&t.length>0&&s(`
4
+ `),r(l,d)},r=(i,a)=>{const l=Array.from(i.childNodes);l.forEach((u,c)=>o(u,a&&c===l.length-1))};return r(e,!0),t}const pr=e=>!!e&&(e.tagName??"").toLowerCase()==="br";function fr(e){pr(e.lastChild)||e.appendChild(e.ownerDocument.createElement("br"))}function ol(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(ur.has((r.tagName??"").toLowerCase()))return r}o=o.parentNode}return e}function hr(e){fr(ol(e))}const rl=e=>e.getAttribute("aria-multiline")!=="false";function wr(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(_t(o,a,s));const r=t[t.length-1];(r==null?void 0:r.kind)==="text"&&((i=r.value)!=null&&i.endsWith(`
5
+ `))&&rl(e)&&fr(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 Pt(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 pr(e.lastChild)?e.insertBefore(t,e.lastChild):e.appendChild(t),Es(e);e.focus()}function mr(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 u=l.lastIndexOf("{{",a-2);if(u===-1)return!1;const c=l.slice(u,a),d=Xe(c);if(d.length!==1||d[0].kind==="text")return!1;let p=0;for(;u-1-p>=0&&l[u-1-p]==="\\";)p+=1;if(p%2===1)return!1;const f=s.createRange();f.setStart(i,u),f.setEnd(i,a),f.deleteContents();const h=_t(s,d[0],t);f.insertNode(h);const b=s.createRange();return b.setStartAfter(h),b.collapse(!0),o.removeAllRanges(),o.addRange(b),!0}function br(e){const t=dr(e);if(!t)return null;const s=t.kind==="expr"&&!ae.parseCoalesceChain(t.expr)?ae.formatReadableExpression(t.expr):null,o=e.ownerDocument.createTextNode(s??ae.serializeTemplate([t]));return e.replaceWith(o),o}function il(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 al(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 ll(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 cl(e,t){if(!e||!Object.hasOwn(e,t))return t;let s=2;for(;Object.hasOwn(e,`${t}_${s}`);)s++;return`${t}_${s}`}function ko(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(il(e,t))return l(t,i);let u,c=!0;try{u=JSON.parse(e)}catch{c=!1}const d=c&&u!==null&&typeof u=="object"&&!Array.isArray(u)?u:null,p=()=>`${JSON.stringify(cl(d,al(s)))}: ${a}`,f=e.slice(0,t).trimEnd(),h=f[f.length-1],b=e.slice(t).trimStart()[0],w=ll(e,t);if(h===":"||h==="["||h===","&&w==="[")return l(t,a+(h!==":"&&b!==void 0&&b!=="]"?", ":""));if(h==="{"||h===","&&w==="{"){const g=b!==void 0&&b!=="}"?", ":"";return l(t,(h===","?" ":"")+p()+g)}if(c&&(d||Array.isArray(u))){const g=e.lastIndexOf(d?"}":"]"),y=e.slice(0,g).trimEnd(),k=y.endsWith(d?"{":"["),A=d?p():a,S=e.slice(y.length,g);if(S.includes(`
6
+ `)){const E=k?`${S.slice(S.lastIndexOf(`
7
+ `)+1)} `:((x=/^\s*/.exec(y.slice(y.lastIndexOf(`
8
+ `)+1)))==null?void 0:x[0])??"",T=`${k?"":","}
9
+ ${E}${A}`;return{text:y+T+e.slice(y.length),caret:y.length+T.length}}const j=`${k?"":","} ${A} `,v=y.length;return{text:e.slice(0,v)+j+e.slice(g),caret:v+j.length-1}}return l(t,a)}const ul=/^\{\{\s*((?:var|vars|const|steps|nodes|trigger|foreach|inputs|output|documents)(?:\.[^\s{}]+)?)\s*\}\}$/;function dl(e){const t=ul.exec(e.trim());return t?`{{ ${t[1]} }}`:null}function et(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 pl(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 Xn(e,t){if(typeof e=="string"){const s=Nn(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=>Xn(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,Xn(r,t)]))}return e}function Gt({value:e,masked:t,multiline:s,options:o,fieldLabel:r,onSave:i,onClose:a,mode:l,jsonValue:u,onSaveJson:c,whole:d,startingState:p,jsonProblem:f,title:h}){var Tt;const b=l==="json-binding",w=b&&p===!0,[x,g]=m.useState("ref"),[y,k]=m.useState(()=>u===void 0?"":JSON.stringify(u,null,2)),A=m.useRef(null),S=m.useRef(!1),j=m.useMemo(()=>{if(y.trim()==="")return{ok:!1};try{return{ok:!0,value:JSON.parse(y)}}catch{return{ok:!1}}},[y]),v=w?(f==null?void 0:f(y))??null:null,E=w?(y.trim()===""||j.ok)&&v===null:j.ok,T=()=>Ns(o.sampleValues,pl(o.sampleValues),o.nodeConfig,o.nodeMeta),D=b?j.ok?JSON.stringify(Xn(j.value,N=>Wt(N,T())),null,2):y.trim()===""?"":"Invalid JSON":"",I=N=>{const M=A.current,K=M?M.state.doc.toString():y;if(w){const Me=x==="value"?{value:Wt(`{{ ${N} }}`,T())??null}:void 0,io=K.trim()===""?"{}":K,Li=S.current&&M?M.state.selection.main.head:io.length,_n=ko(io,Li,N,Me);if(!M){k(_n.text);return}M.dispatch({changes:{from:0,to:K.length,insert:_n.text},selection:{anchor:_n.caret}}),M.focus();return}let se=null;try{se=K.trim()===""?null:et(JSON.parse(K))}catch{se=null}let fe=!1;if(d)try{const Me=JSON.parse(K);fe=Array.isArray(Me)?Me.length===0:typeof Me=="object"&&Me!==null&&Object.keys(Me).length===0}catch{fe=!1}if(K.trim()===""||se!==null||fe){c==null||c(`{{ ${N} }}`),a();return}if(!M)return;const de=S.current?M.state.selection.main.head:K.length,re=ko(K,de,N);M.dispatch({changes:{from:0,to:K.length,insert:re.text},selection:{anchor:re.caret}}),M.focus()},[R,O]=m.useState(()=>Ot(zn(e).parts,o).parts),L=m.useMemo(()=>Ot(R,o),[R,o]),[H,B]=m.useState(0),z=m.useRef(null),P=m.useRef(!1),[$,Z]=m.useState({}),[Q,ee]=m.useState(null),[F,X]=m.useState(()=>new Set),Y=N=>{X(M=>{const K=new Set(M);return K.has(N)?K.delete(N):K.add(N),K})},[U,G]=m.useState("auto");m.useLayoutEffect(()=>{const N=z.current;N&&(wr(N,R,{renderToggle:!0}),P.current&&(P.current=!1,Es(N),N.focus()))},[H]);const te=()=>{const N=z.current;N&&O($t(N))},C=N=>{const M=z.current;M&&(Pt(M,_t(M.ownerDocument,N,{renderToggle:!0})),O($t(M)))},V=R.some(N=>N.kind==="render"),J=(N,{restoreFocus:M})=>{O(Ot(Xe(N),o).parts),B(K=>K+1)},_=()=>{const N=z.current,M=Ot(N?$t(N):R,o);M.error||(i==null||i(sn(M.parts)),a())},W=()=>{ee(null),P.current=!0,B(N=>N+1)},ue=o.vars??[],pe=o.constants??[],he=o.secrets??[],ge=o.inputs??[],ke=o.documents??[],ve=o.steps??[],Be=o.nodeConfigs??[],ce=o.loop,Ee=new Map(Be.map(N=>[N.id,N.keys.filter(yt)]).filter(([,N])=>N.length>0)),Ue=o.nodeMeta??{},tt=N=>fl.filter(([M])=>hl.has(M)?nt(N):Object.hasOwn(Ue[N]??{},M)),wt=ve.filter(N=>N.hasMeta===!0).map(N=>N.id),nt=N=>{var K;if(wt.includes(N))return!0;const M=(K=Ue[N])==null?void 0:K.app;return typeof M=="string"&&!Ge(M)},mt=N=>tt(N).map(([M,K])=>oe(K,{kind:"var",ref:`nodes.${N}.meta.${M}`},"w6w-exprmodal-field",null)),Le=[...new Set([...Object.keys(Ue),...wt,...Ee.keys()])],st=ve.length>0||!!o.hasTrigger,we=!w&&(st||!!ce),Re=w?[]:(((Tt=o.stateShape)==null?void 0:Tt.fields)??[]).filter(N=>Zt(N.key)),ot=[...we?["state"]:[],...Re.length>0?["runstate"]:[],...Le.length>0?["meta"]:[],...o.inputs!==void 0?["inputs"]:[],"vars",...pe.length>0?["consts"]:[],...!b||w?["docs"]:[],...b?[]:["secrets"]],_e=U==="auto"||U!==null&&!ot.includes(U)?ot.find(N=>N!=="meta")??null:U,me=N=>({open:_e===N,onToggle:()=>G(_e===N?null:N)}),Ae=((ce==null?void 0:ce.itemOutputs)??[]).filter(N=>N.path?Zt(N.key):yt(N.key)),Se=(o.eventOutputs??[]).filter(N=>N.path?Zt(N.key):yt(N.key)),bt=ae.serializeTemplate(L.parts),Rt=m.useMemo(()=>{const N={};for(const[M,K]of Object.entries(o.sampleValues??{}))N[M]=typeof K=="string"?K:JSON.stringify(K);return{...N,...$}},[o.sampleValues,$]),ne=m.useMemo(()=>Ga(L.parts),[L.parts]),q=m.useMemo(()=>{if(L.error)return"";try{return Za(L.parts,o.sampleValues,$)}catch{return bt}},[L,o.sampleValues,$,bt]),ie=m.useMemo(()=>{var M;const N=new Set;for(const K of ne){if($[K]!==void 0)continue;const se=(M=o.valueSources)==null?void 0:M[K];se==="sample"?N.add("example from the app"):se==="persisted"&&N.add("from last test")}return[...N]},[ne,$,o.valueSources]),oe=(N,M,K,se,fe=!1,de,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)??N}`,"aria-label":de,onClick:()=>b?M.kind==="var"&&I(M.ref??""):C(M),children:[se!==null&&n.jsx("span",{className:"w6w-expr-chip-sigil",children:se}),n.jsx("span",{className:"w6w-exprmodal-source-label",children:N}),(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(kn,{icon:"copy",iconSize:14,label:"Copy to expression editor","data-testid":"expr-copy-to-editor",onClick:()=>C(M)})]},`${M.kind}:${M.ref??N}`),Ve=F.has("loop:item"),ze=oe("Current item",{kind:"var",ref:"foreach.item"},"w6w-expr-chip-var","↻"),Te=(N,M)=>{if(M.length===0)return null;const K=F.has(`mcfg:${N}`);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:()=>Y(`mcfg:${N}`),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:M.map(se=>oe(se,{kind:"var",ref:`nodes.${N}.meta.config.${se}`},"w6w-exprmodal-field",null))})]})},Ie=(N,M,K=`nodes.${N}.output`)=>No(M).map(({field:se,depth:fe,name:de})=>{const re=`${K}.${se.key}`;return oe(de,{kind:"var",ref:re},"w6w-exprmodal-field",null,!1,void 0,{name:Ke(re),depth:fe,declaredOnly:se.declaredOnly===!0})}),gt=N=>N==="fresh"||N==="persisted"?n.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":"expr-fields-from-test",children:N==="fresh"?"Fields from the last test run":"Fields from last test"}):N==="declared"||N==="sample"?n.jsx("span",{className:"w6w-exprmodal-shape-note","data-testid":`expr-fields-from-${N}`,children:N==="declared"?"declared by the app":"example from the app"}):null,ye=N=>{const M=`mnode:${N}`,K=F.has(M);return n.jsxs(m.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 ${N} metadata`:`Show ${N} metadata`,title:K?"Hide metadata":"Show metadata",onClick:()=>Y(M),children:K?"▾":"▸"}),oe(N,{kind:"var",ref:`nodes.${N}.meta`},"w6w-expr-chip-var w6w-exprmodal-node",null,!0)]}),K&&n.jsxs("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-metadata-fields",children:[mt(N),Te(N,Ee.get(N)??[])]})]},M)};return n.jsxs(je,{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&&(c==null||c(j.ok?j.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:V,title:V?"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(ae.serializeTemplate(R)),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:_,"data-testid":"expr-save",disabled:L.error!==null,children:"Save"})]}),children:[n.jsxs("div",{className:"w6w-exprmodal",children:[n.jsxs("aside",{className:"w6w-exprmodal-sources",children:[w&&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(([N,M,K])=>n.jsx("button",{type:"button","aria-pressed":x===N,"data-testid":`expr-insert-as-${N}`,title:K,className:`w6w-btn w6w-btn-sm${x===N?"":" w6w-btn-ghost"}`,onClick:()=>g(N),children:M},N))]}),b&&!w&&!we&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No upstream steps"}),we&&n.jsxs(Je,{label:"Previous steps",...me("state"),children:[ce&&n.jsxs("div",{className:"w6w-exprmodal-subgroup","data-testid":"expr-loop-group",children:[n.jsx("span",{className:"w6w-exprmodal-shape-note",children:"Loop"}),Ae.length>0?n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[ze,n.jsx(Qt,{count:Ae.length,open:Ve,onToggle:()=>Y("loop:item")})]}):ze,Ae.length>0&&Ve&&n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-loop-fields",children:Ae.map(N=>{const M=`foreach.item.${N.key}`;return oe(N.key,{kind:"var",ref:M},"w6w-exprmodal-field",null)})}),oe("Index",{kind:"var",ref:"foreach.index"},"w6w-expr-chip-var","#")]}),o.hasTrigger&&(Se.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":F.has("event"),"aria-label":F.has("event")?"Hide fields":"Show fields",title:F.has("event")?"Hide fields":"Show fields",onClick:()=>Y("event"),children:F.has("event")?"▾":"▸"}),oe("trigger.event",{kind:"var",ref:"trigger.event"},"w6w-expr-chip-var w6w-exprmodal-node","⚡",!0)]}),F.has("event")&&n.jsxs("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-event-fields",children:[gt(o.eventOutputsFrom),Ie("",Se,"trigger.event")]})]}):n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[n.jsx("span",{className:"w6w-exprmodal-caret-spacer","aria-hidden":"true"}),oe("trigger.event",{kind:"var",ref:"trigger.event"},"w6w-expr-chip-var w6w-exprmodal-node","⚡")]})),ve.map(N=>{const M=(N.outputs??[]).filter(de=>de.path?Zt(de.key):yt(de.key)),K=`step:${N.id}`,se=F.has(K),fe=oe(N.label??N.id,{kind:"var",ref:`nodes.${N.id}.output`},"w6w-expr-chip-var w6w-exprmodal-node",null,M.length>0);return b?n.jsxs(m.Fragment,{children:[n.jsx("span",{className:"w6w-exprmodal-shape-note",children:N.label??N.id}),oe("Entire output",{kind:"var",ref:`nodes.${N.id}.output`},"w6w-expr-chip-var",null,!1,`Entire output of ${N.label??N.id}`),N.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"})}),M.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:()=>Y(K),children:se?"▾":"▸"}),n.jsx(Qt,{count:M.length,open:se,onToggle:()=>Y(K)})]}),se&&n.jsxs("div",{className:"w6w-exprmodal-subsources",children:[gt(N.outputsFrom),Ie(N.id,M)]})]})]},N.id):n.jsxs(m.Fragment,{children:[M.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:()=>Y(K),children:se?"▾":"▸"}),fe,n.jsx(Qt,{count:M.length,open:se,onToggle:()=>Y(K)})]}):n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[n.jsx("span",{className:"w6w-exprmodal-caret-spacer","aria-hidden":"true"}),fe]}),N.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"})}),M.length>0&&se&&n.jsxs("div",{className:"w6w-exprmodal-subsources",children:[gt(N.outputsFrom),Ie(N.id,M)]})]},N.id)})]}),Re.length>0&&n.jsxs(Je,{label:"State",testId:"expr-state-group",...me("runstate"),children:[oe("state",{kind:"var",ref:"state"},"w6w-expr-chip-var","◇",!0),n.jsx("div",{className:"w6w-exprmodal-subsources","data-testid":"expr-state-fields",children:No(Re).map(({field:N,depth:M,name:K})=>{const se=`state.${N.key}`;return oe(K,{kind:"var",ref:se},"w6w-exprmodal-field",null,!1,void 0,{name:Ke(se),depth:M,somePaths:N.paths==="some"})})})]}),Le.length>0&&n.jsx(Je,{label:"Metadata",testId:"expr-metadata-group",...me("meta"),children:Le.map(N=>ye(N))}),n.jsxs(n.Fragment,{children:[o.inputs!==void 0&&n.jsxs(Je,{label:"Inputs",...me("inputs"),children:[ge.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No inputs"}),ge.map(N=>oe(N,{kind:"var",ref:`inputs.${N}`},"w6w-expr-chip-var","⇥"))]}),n.jsxs(Je,{label:"Variables",...me("vars"),action:o.createVar&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm","data-testid":"expr-add-var",onClick:()=>ee("var"),children:"+ Add"}),children:[ue.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No variables"}),ue.map(N=>oe(N,{kind:"var",ref:`var.${N}`},"w6w-expr-chip-var","◆"))]}),pe.length>0&&n.jsx(Je,{label:"Constants",testId:"expr-constants-group",...me("consts"),children:pe.map(N=>oe(N,{kind:"var",ref:`const.${N}`},"w6w-expr-chip-var","◈"))})]}),(!b||w)&&n.jsxs(Je,{label:"Documents",...me("docs"),children:[ke.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No documents"}),ke.map(N=>{const M=(N.fields??[]).filter(de=>yt(de.key)),K=`doc:${N.key}`,se=F.has(K),fe=oe(N.key,{kind:"var",ref:`documents.${N.key}`},"w6w-expr-chip-var","▦",M.length>0);return n.jsxs(m.Fragment,{children:[M.length>0?n.jsxs("div",{className:"w6w-exprmodal-source-row",children:[fe,n.jsx(Qt,{count:M.length,open:se,onToggle:()=>Y(K)})]}):fe,M.length>0&&se&&n.jsx("div",{className:"w6w-exprmodal-subsources",children:M.map(de=>{const re=`documents.${N.key}.${de.key}`;return n.jsxs("div",{className:"w6w-exprmodal-subsource-row",children:[oe(de.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:()=>C({kind:"render",ref:re}),children:"▤"})]},re)})})]},N.key)})]}),!b&&n.jsxs(Je,{label:"Secrets",...me("secrets"),action:o.createSecret&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm","data-testid":"expr-add-secret",onClick:()=>ee("secret"),children:"+ Add"}),children:[he.length===0&&n.jsx("span",{className:"w6w-expr-menu-empty",children:"No secrets"}),he.map(N=>oe(N,{kind:"secret",ref:N},"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:()=>{S.current=!0},children:n.jsx(Ye,{value:y,onChange:k,height:"100%",minHeight:"0px","aria-label":"Compose JSON",placeholder:w?'{ "region": "us", "template": "{{ documents.welcome }}" }':'{ "key": "{{ nodes.step_1.output }}" }',onCreateEditor:N=>{A.current=N}})})]}),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:[" ",w?" — 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(le.Copyable,{value:D??"",label:"Copy result",children:n.jsx("pre",{className:"w6w-exprmodal-result","data-testid":"expr-json-result",children:D})})]})]}),!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:z,className:`w6w-exprmodal-chips${t?" is-masked":""}${R.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":L.error!==null,"aria-describedby":L.error?"expression-problem":void 0,spellCheck:!1,onInput:()=>{const N=z.current;N&&mr(N,{renderToggle:!0}),te()},onDoubleClick:N=>{const M=N.target;if(M.closest("[data-x]")||M.closest("[data-render-toggle]"))return;const K=M.closest(".w6w-expr-chip");if(!K)return;N.preventDefault();const se=br(K);if(se){const fe=se.ownerDocument,de=fe.createRange();de.setStartAfter(se),de.collapse(!0);const re=fe.getSelection();re==null||re.removeAllRanges(),re==null||re.addRange(de)}te()},onBlur:()=>{const N=z.current;N&&J(ae.serializeTemplate($t(N)),{restoreFocus:!1})},onPaste:N=>{var se;N.preventDefault();const M=z.current;if(!M)return;const K=((se=N.clipboardData)==null?void 0:se.getData("text/plain"))??"";for(const fe of Xe(K))fe.kind==="text"?Pt(M,M.ownerDocument.createTextNode(fe.value??"")):Pt(M,_t(M.ownerDocument,fe,{renderToggle:!0}));te()},onClick:N=>{var fe;const M=N.target,K=M.closest("[data-x]");if(K){N.preventDefault(),(fe=K.closest(".w6w-expr-chip"))==null||fe.remove(),te();return}const se=M.closest("[data-render-toggle]");if(se){N.preventDefault();const de=se.closest(".w6w-expr-chip");if(de){const re=de.getAttribute("data-ref")??"",Me=de.getAttribute("data-kind")==="render"?"var":"render";de.replaceWith(_t(de.ownerDocument,{kind:Me,ref:re},{renderToggle:!0}))}te()}},onKeyDown:N=>{if(N.key!=="Enter"||(N.preventDefault(),!s))return;const M=z.current;M&&(Pt(M,M.ownerDocument.createTextNode(`
10
+ `)),hr(M),te())}}),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."]}),L.error&&n.jsx("span",{id:"expression-problem",role:"alert",className:"w6w-error",children:L.error})]}),ne.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"]})]}),ne.map(N=>n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:N}),n.jsx("input",{type:"text",value:$[N]??Rt[N]??"",placeholder:"sample value",onChange:M=>Z(K=>({...K,[N]:M.target.value}))})]},N))]}),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(le.Copyable,{value:q,readOnly:!0,children:n.jsx("pre",{className:"w6w-exprmodal-result",children:q||" "})}),ie.length>0&&n.jsx("span",{className:"w6w-muted w6w-small","data-testid":"expr-result-source",children:ie.join(" · ")})]})]})]}),Q==="var"&&o.createVar&&n.jsx(So,{kind:"var",onCreate:o.createVar,onClose:W}),Q==="secret"&&o.createSecret&&n.jsx(So,{kind:"secret",onCreate:o.createSecret,onClose:W})]})}function Je({label:e,open:t,onToggle:s,action:o,testId:r,children:i}){const a=m.useId(),l=m.useRef(null);return m.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 Qt({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 fl=[["app","App"],["version","App version"],["action","Action"],["connectionId","Connection ID"],["subscriptionId","Subscription ID"],["url","Webhook URL"]],hl=new Set(["app","version","action","connectionId"]);function So({kind:e,onCreate:t,onClose:s}){const[o,r]=m.useState(""),[i,a]=m.useState(""),[l,u]=m.useState(""),[c,d]=m.useState(null),[p,f]=m.useState(!1),h=e==="var"?"variable":"secret";async function b(){d(null),f(!0);try{await t({name:o,value:i,description:l||void 0}),s()}catch(w){d(w.message)}finally{f(!1)}}return n.jsxs(je,{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:w=>r(w.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:w=>a(w.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:w=>u(w.target.value),placeholder:"Optional",autoComplete:"off"})]}),c&&n.jsx("div",{className:"w6w-result w6w-error",children:c})]})}),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||p,onClick:b,children:p?"Saving…":"Save"})]})]})}function wl(e,t){return t?e.filter(s=>s.id!==t):e}const Zn=m.createContext({});function ml({value:e,children:t}){const s=m.useContext(Zn),o=m.useMemo(()=>({...s,...e}),[s,e]);return n.jsx(Zn.Provider,{value:o,children:t})}function ht(){return m.useContext(Zn)}function qt({value:e,onChange:t,placeholder:s,masked:o,multiline:r,readOnly:i,options:a,"aria-label":l}){const[u,c]=m.useState(()=>zn(e)),{parts:d,sealed:p}=u,[f,h]=m.useState(0),[b,w]=m.useState(!1),[x,g]=m.useState(!1),y=m.useRef(!1),k=m.useRef(null),A=m.useRef(null),S=ht(),j={...S,...a??{}},v=S.sealSecret;m.useLayoutEffect(()=>{const R=k.current;!R||p||(wr(R,d),(y.current||R.ownerDocument.activeElement===R)&&(R.focus(),Es(R),y.current=!1))},[f,p]);const E=()=>{const R=k.current;if(!R)return;const O=$t(R);c(H=>({...H,parts:O}));const L=Ot(O,j);t(sn(L.parts))},T=async R=>{if(!v)return!1;w(!0);try{const O=await v(R);return y.current=!1,c({parts:[],sealed:O}),h(L=>L+1),t(O),!0}catch{return!1}finally{w(!1)}},D=R=>{var H;if(x||!o||i||b)return;const O=R.relatedTarget;if(O&&((H=A.current)!=null&&H.contains(O)))return;const L=sn(d);typeof L=="string"&&L!==""&&!Ze(L)&&T(L)},I=R=>{if(o&&typeof R=="string"&&R.trim()!==""&&!Ze(R)){T(R);return}y.current=!1,c(zn(R)),h(O=>O+1),t(R)};return p?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,c({parts:[],sealed:null}),h(R=>R+1),t("")},children:"Replace"})]}):n.jsxs("div",{className:"w6w-expr",ref:A,onBlur:D,children:[n.jsxs("div",{className:"w6w-expr-field",children:[n.jsx("div",{ref:k,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 R=k.current;R&&mr(R),E()},onClick:R=>{var L;const O=R.target.closest("[data-x]");O&&(R.preventDefault(),(L=O.closest(".w6w-expr-chip"))==null||L.remove(),E())},onDoubleClick:R=>{const O=R.target;if(O.closest("[data-x]"))return;const L=O.closest(".w6w-expr-chip");if(!L)return;R.preventDefault();const H=br(L);if(H){const B=H.ownerDocument,z=B.createRange();z.setStartAfter(H),z.collapse(!0);const P=B.getSelection();P==null||P.removeAllRanges(),P==null||P.addRange(z)}E()},onKeyDown:R=>{if(R.key!=="Enter"||(R.preventDefault(),!r))return;const O=k.current;O&&(Pt(O,O.ownerDocument.createTextNode(`
11
+ `)),hr(O),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(Gt,{value:sn(d),masked:o,multiline:r,options:j,fieldLabel:l,onSave:I,onClose:()=>g(!1)})]})}const bl=/\{\{\s*([^{}]*?)\s*\}\}/g;function gr(e,t="javascript"){const s=t==="python",o=[],r=[];let i=0;for(;i<e.length;){const l=e[i],u=e.slice(i,i+2),c=e.slice(i,i+3);if(s&&l==="#"||!s&&u==="//"){const d=e.indexOf(`
12
+ `,i),p=d===-1?e.length:d;r.push({start:i,end:p}),i=p}else if(!s&&u==="/*"){const d=e.indexOf("*/",i+2),p=d===-1?e.length:d+2;r.push({start:i,end:p}),i=p}else if(s&&(c==='"""'||c==="'''")){const d=e.indexOf(c,i+3),p=d===-1?e.length:d+3;o.push({start:i,end:p,quote:c}),i=p}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]===`
13
+ `)break;d++}const p=Math.min(d+1,e.length);o.push({start:i,end:p,quote:l}),i=p}else i++}const a=[];for(const l of e.matchAll(bl)){const u=l.index??0,c=u+l[0].length;if(r.some(p=>u>=p.start&&u<p.end))continue;const d=o.find(p=>u>p.start&&u<p.end);a.push({start:u,end:c,ref:l[1],context:d?{kind:"string",...d}:{kind:"code"}})}return a}const gl=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$-]*|\[\d+\]|\["[^"\\]*"\]|\['[^'\\]*'\])*$/,yl=/\.([A-Za-z_$][\w$-]*)|\[(\d+)\]|\["([^"\\]*)"\]|\['([^'\\]*)'\]/g,xl={nodes:["run","nodes"],steps:["run","nodes"],trigger:["run","trigger"],foreach:["run","foreach"],state:["state"],var:["state"],vars:["state"],const:["consts"],consts:["consts"]};function rn(e,t="javascript"){var u;const s=e.trim();if(!gl.test(s))return null;const o=((u=/^[A-Za-z_$][\w$]*/.exec(s))==null?void 0:u[0])??"",r=xl[o];if(!r)return null;const i=[...r.slice(1)];for(const c of s.slice(o.length).matchAll(yl))i.push(c[2]!==void 0?Number(c[2]):c[1]??c[3]??c[4]);const a=r[0]==="run"?i.shift():r[0];return`${t==="python"?"ctx":"$"}.get(${[a,...i].map(c=>JSON.stringify(c)).join(", ")})`}function vl(e,t="javascript"){const s=t==="python";let o="",r=0,i=0,a=0;for(const l of gr(e,t)){const u=rn(l.ref,t);if(u===null){a++;continue}const c=l.context;if(c.kind==="code"){o+=e.slice(r,l.start)+u,r=l.end,i++;continue}const d=c.quote,p=l.start===c.start+d.length,f=l.end===c.end-d.length;if(p&&f)o+=e.slice(r,c.start)+u,r=c.end,i++;else if(!s&&d==="`")o+=`${e.slice(r,l.start)}\${${u}}`,r=l.end,i++;else if(d.length===1&&!(s&&/[A-Za-z]/.test(e[c.start-1]??""))){const h=s?`str(${u})`:u;o+=p?`${e.slice(r,c.start)}${h} + ${d}`:`${e.slice(r,l.start)}${d} + ${h}`,f?r=c.end:(p||(o+=` + ${d}`),r=l.end),i++}else a++}return o+=e.slice(r),{code:o,converted:i,left:a}}function jl({param:e,value:t,language:s,label:o,req:r,readOnly:i,onChange:a}){var A;const l=m.useRef(null),[u,c]=m.useState(!1),d=ht(),p=d.steps??[],f=s==="python",h=S=>{const j=l.current;if(!j){a(t+S);return}j.dispatch(j.state.replaceSelection(S)),j.focus()},b=S=>{const j=et(S);if(j!==null){const v=rn(j,s);v&&h(v);return}S===void 0||S===""||h(JSON.stringify(S,null,2).replace(/"\{\{\s*([^{}"]*?)\s*\}\}"/g,(v,E)=>rn(E,s)??v))},w=((A=p[0])==null?void 0:A.id)??"<step-id>",x=f?"ctx":"$",g=[[`${x}.get("nodes", ${JSON.stringify(w)}, "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(([S])=>S.length)),k=f?"#":"//";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:S=>{l.current=S}}),!i&&n.jsxs("div",{className:"w6w-seed-chips w6w-script-insert",children:[n.jsx("span",{className:"w6w-muted w6w-small",children:"Insert"}),p.map(S=>{const j=rn(`nodes[${JSON.stringify(S.id)}].output`,s)??"";return n.jsx("button",{type:"button",className:"w6w-chip w6w-seed-chip",title:`Insert ${j}`,onClick:()=>h(j),children:n.jsx("code",{children:S.id})},S.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:()=>c(!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(([S,j])=>`${S.padEnd(y)} ${k} ${j}`).join(`
14
+ `)}),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:f?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."]})})]}),u&&n.jsx(Gt,{mode:"json-binding",value:void 0,jsonValue:void 0,options:d,fieldLabel:o,whole:!0,onSaveJson:b,onClose:()=>c(!1)})]})}function Sn(e){const t=[];for(const s of e)t.push(s),s.type==="section"&&s.children&&t.push(...Sn(s.children));return t}function yr(e){return Ze(e)||Qe(e)?!0:typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,"$")}function mn(e){var t;return((t=e.config)==null?void 0:t.allowCustom)===!0}function Qn(e){return Sn(e).filter(t=>vn(t.options))}function Rs(e){return vn(e.options)?e.options.refreshOn??[]:[]}function es(e,t){const s={},o=[];for(const r of Sn(e)){if(r.type==="section")continue;const i=t[r.key]!==void 0?t[r.key]:r.default;i!==void 0&&(yr(i)?o.push(r.key):s[r.key]=i)}return{form:s,unresolved:o}}function Nl(e,t,s,o,r){const{form:i,unresolved:a}=es(e,t),l=new Set(a),u=Qn(e).filter(d=>{const p=Rs(d);return s==="change"&&!(o??[]).some(f=>p.includes(f))?!1:p.every(f=>!l.has(f))}).map(d=>d.key);if(u.length===0)return null;const c={reason:s,form:i,fields:u,unresolved:a};return s==="change"&&(c.changed=[...o??[]],c.previous=es(e,r??{}).form),c}function Co(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 Ao(e){return!(vn(e.options)&&e.options.cache==="none")}function kl(e,t){return e.some(s=>t.includes(s))}function Sl(e,t,s,o){var l;if(!o.connectionId)return{reason:"no-connection",hint:"Connect an account to load choices"};const r=new Set(es(t,s).unresolved),i=Rs(e).find(u=>r.has(u));return i===void 0?null:{reason:"unresolved-dependency",hint:`Options unavailable while ${((l=Sn(t).find(u=>u.key===i))==null?void 0:l.label)??i} is an expression`}}function Eo(e,t,s){return e==null||e===""?{action:"keep"}:yr(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 Cl(e,t,s,o){var k;const r=(k=nn())==null?void 0:k.resolveActionFields,i=!!(s&&r),[a,l]=m.useState({}),u=m.useRef({params:e,values:t,dynamic:s,onChange:o,resolve:r});u.current={params:e,values:t,dynamic:s,onChange:o,resolve:r};const c=m.useRef(new Map),d=m.useRef([]),p=m.useCallback((A,S,j,v,E)=>{const{params:T,values:D,dynamic:I,resolve:R}=u.current,O=E??D;if(!I||!R||!I.connectionId)return;const L=Nl(T,O,A,S,j);if(!L)return;const H=new Map(Qn(T).map(U=>[U.key,U])),B=[],z={},P=[],$=I.appName??I.appId,Z=(U,G)=>{const te=H.get(U);if(!te)return;Eo(O[U],G,{allowCustom:mn(te),reason:A,appLabel:$}).action==="clear"&&B.push(U)};for(const U of L.fields){if(v!==void 0&&U!==v)continue;const G=H.get(U);if(!G)continue;const te=v===void 0&&Ao(G)?c.current.get(Co(I,G,L.form)):void 0;te?(z[U]={options:te,loading:!1},Z(U,te)):P.push(U)}const Q=(U=!1)=>{if(B.length===0)return;const G={...U?O:u.current.values};for(const te of B)delete G[te];u.current.onChange(G)};if(Object.keys(z).length>0&&l(U=>({...U,...z})),P.length===0){Q(!0);return}for(const U of d.current)kl(U.fields,P)&&U.controller.abort();const ee=new AbortController,F={fields:P,controller:ee};d.current=[...d.current.filter(U=>!U.controller.signal.aborted),F],l(U=>{var te;const G={...U};for(const C of P)G[C]={options:(te=U[C])==null?void 0:te.options,loading:!0};return G});const X={...L,fields:P,connectionId:I.connectionId,...I.version!==void 0?{version:I.version}:{}},Y=U=>{d.current=d.current.filter(G=>G!==F),l(G=>({...G,...U}))};Promise.resolve().then(()=>R(I.appId,I.actionKey,X,{signal:ee.signal})).then(U=>{var te;if(ee.signal.aborted)return;const G={};for(const C of P){const V=(te=U==null?void 0:U.fields)==null?void 0:te[C],J=H.get(C);if(!V||!J)G[C]={loading:!1};else if(V.error)G[C]={loading:!1,error:V.error};else{const _=Array.isArray(V.options)?V.options:[];G[C]={loading:!1,options:_},Ao(J)&&c.current.set(Co(I,J,L.form),_),Z(C,_)}}Y(G),Q()}).catch(U=>{if(ee.signal.aborted)return;const G=U instanceof Error?U.message:String(U),te={};for(const C of P)te[C]={loading:!1,error:G||"Request failed"};Y(te)})},[]),f=s?JSON.stringify([s.appId,s.actionKey,s.version,s.connectionId]):"";m.useEffect(()=>{if(i)return l({}),p("init"),()=>{for(const A of d.current)A.controller.abort();d.current=[]}},[f,i,p]);const h=m.useRef(new Map),b=m.useCallback((A,S)=>{const j=h.current.get(A)??u.current.values;h.current.delete(A),p("change",[A],j,void 0,{...u.current.values,[A]:S})},[p]),w=m.useCallback(A=>{h.current.has(A)||h.current.set(A,u.current.values)},[]),x=m.useCallback(A=>{const S=h.current.get(A);if(h.current.delete(A),!S)return;const j=u.current.values;JSON.stringify(S[A])!==JSON.stringify(j[A])&&p("change",[A],S)},[p]),g=m.useCallback(A=>p("init",void 0,void 0,A),[p]);return{fields:m.useMemo(()=>{const A={};if(!i||!s)return A;const S=s.appName??s.appId;for(const j of Qn(e)){const v=Sl(j,e,t,s);if(v){A[j.key]={loading:!1,hint:v.hint};continue}const E=a[j.key]??{loading:!0},T={...E};if(E.options){const D=Eo(t[j.key],E.options,{allowCustom:mn(j),reason:"init",appLabel:S});D.action==="flag"&&(T.notInList=D.message)}A[j.key]=T}return A},[i,s,e,t,a]),commit:b,focus:w,blur:x,retry:g}}function Yt(e,t){return e.hidden===!0?!1:e.showIf?ae.matchesParamCondition(e.showIf,t):!0}function kt(e){const t=[];for(const s of e)t.push(s),s.type==="section"&&s.children&&t.push(...kt(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 xr(e,t,s,o){const r=i=>i.type==="section"?n.jsx(Al,{param:i,effective:s,renderOne:r},i.key):i.repeat&&i.type!=="array"?n.jsx(Il,{param:i,value:e[i.key],onChange:t,readOnly:o},i.key):i.type==="group"&&i.children&&i.children.length>0?n.jsx(Tl,{param:i,value:e[i.key],onChange:t,effective:s,readOnly:o},i.key):n.jsx($l,{param:i,value:e[i.key],onChange:t,effective:s,readOnly:o},i.key);return r}const Cn=m.createContext(null);function Pe({params:e,values:t,onChange:s,readOnly:o,dynamic:r}){const i=Cl(e,t,r,s),a=kt(e),l=h=>{var b;return t[h]!==void 0?t[h]:(b=a.find(w=>w.key===h))==null?void 0:b.default},u=e.filter(h=>Yt(h,l)).map(h=>ae.effectiveParam(h,l)),c=u.filter(h=>h.required||!h.advanced),d=u.filter(h=>!h.required&&h.advanced),p=(h,b)=>{if(h==="language"){const w={...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===ts||Ol.includes(g))&&(w[x.key]=b==="python"?ts:x.default)}s(w);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 f=xr(t,p,l,o);return n.jsx(Cn.Provider,{value:i,children:n.jsxs("div",{className:"w6w-stack",children:[Bt(c,f),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,f)})]})]})})}function Al({param:e,effective:t,renderOne:s}){const o=(e.children??[]).filter(r=>Yt(r,t)).map(r=>ae.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 El=new Set(["string","text","number","boolean","select"]);function Rl(e){return e.length>0&&e.every(t=>El.has(t.type)&&!t.children)}function Tl({param:e,value:t,onChange:s,effective:o,readOnly:r}){const i=e.children??[],a=t??{},l=(f,h)=>s(e.key,{...a,[f]:h}),u=kt(i),c=f=>{const h=u.find(b=>b.key===f);return h?a[f]!==void 0?a[f]:h.default:o(f)},d=i.filter(f=>Yt(f,c)).map(f=>ae.effectiveParam(f,c)),p=xr(a,l,c,r);return n.jsx(Cn.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,p)})]})})}function Il({param:e,value:t,onChange:s,readOnly:o}){if(e.type==="group"){const i=e.children??[];if(!Rl(i))return n.jsx(Ts,{param:e,value:t,onChange:s,readOnly:o});const a={...e,item:{type:"object",fields:i}};return n.jsx(ns,{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(ns,{param:r,value:t,onChange:s,readOnly:o})}const ts=`# Runs as a function body. Return the step's output.
15
+ return input`,Ol=["// 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 $l(e){const t=m.useContext(Cn),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(Pl,{...e})})}function Pl({param:e,value:t,onChange:s,effective:o,readOnly:r}){var A,S,j,v,E;const i=(A=nn())==null?void 0:A.listModelRoutes,a=(S=nn())==null?void 0:S.listDataStores,l=(j=nn())==null?void 0:j.listDataStoreEntries,u=xs(),c=m.useContext(Cn),d=c==null?void 0:c.fields[e.key],p=(T,D)=>{s(T,D),c==null||c.commit(T,D)},f=s,h=e.label??e.key,b=e.required&&e.type!=="boolean"?" *":"",w=m.useId();if(e.type==="boolean"){const T=!!(t??e.default??!1);return n.jsx($e,{param:e,value:t,onChange:f,readOnly:r,label:h,req:b,variant:"inline",controlId:w,children:n.jsx("input",{id:w,type:"checkbox",checked:T,disabled:r,onChange:D=>p(e.key,D.target.checked)})})}if(e.type==="json"||e.type==="group")return n.jsx(Ts,{param:e,value:t,onChange:f,readOnly:r});if(e.type==="code"){const T=o==null?void 0:o("language"),D=T==="python"||T==="javascript"||T==="typescript"?T:void 0,I=D==="python"?ts:e.default,R=t??I??"";return e.scriptReads?n.jsx(jl,{param:e,value:String(R),language:T==="python"?"python":"javascript",label:h,req:b,readOnly:r,onChange:O=>f(e.key,O)}):n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{children:[h,b]}),n.jsx(js,{value:String(R),readOnly:r,minHeight:"180px",language:D,"aria-label":`${e.key} code`,onChange:O=>f(e.key,O)}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}if(e.type==="model-route"&&i)return n.jsx(_l,{param:e,value:t,onChange:f,readOnly:r,label:h,req:b,listModelRoutes:i,project:u});if(e.type==="data-store"&&a)return n.jsx(Fl,{param:e,value:t,onChange:f,readOnly:r,label:h,req:b,listDataStores:a,project:u});const x=o==null?void 0:o("store");if(e.type==="data-store-key"&&l&&typeof x=="string"&&x.trim()!=="")return n.jsx(Hl,{param:e,value:t,onChange:f,readOnly:r,label:h,req:b,store:x,listDataStoreEntries:l,project:u});if(e.type==="vars")return n.jsx(Jl,{param:e,value:t,onChange:f,readOnly:r});if(e.type==="text"||(v=e.config)!=null&&v.multiline){const T=t??e.default??"";return n.jsx($e,{param:e,value:t,onChange:f,readOnly:r,label:h,req:b,children:n.jsx("textarea",{rows:3,value:String(T),readOnly:r,"aria-label":h,onChange:D=>f(e.key,D.target.value)})})}if(e.type==="multiselect")return n.jsx(Wl,{param:e,value:t,onChange:p,readOnly:r});if(e.type==="array")return n.jsx(ns,{param:e,value:t,onChange:f,readOnly:r});if(c&&d&&!d.hint)return n.jsx(Ro,{param:e,value:t,onChange:p,readOnly:r,label:h,req:b,state:d,retry:()=>c.retry(e.key)});if(Array.isArray(e.options)&&e.options.length>0&&mn(e))return n.jsx(Ro,{param:e,value:t,onChange:p,readOnly:r,label:h,req:b,state:{loading:!1,options:e.options}});if(Array.isArray(e.options)&&e.options.length>0){const T=!e.required&&e.default===void 0&&typeof e.placeholder=="string"&&e.placeholder?e.placeholder:void 0,D=t??e.default??(T!==void 0?"":(E=e.options[0])==null?void 0:E.value)??"",I=e.type==="number";return n.jsx($e,{param:e,value:t,onChange:f,readOnly:r,label:h,req:b,children:n.jsxs("select",{value:String(D),disabled:r,"aria-label":h,onChange:R=>{const O=R.target.value;T!==void 0&&O===""?p(e.key,void 0):p(e.key,I?Number(O):O)},children:[T!==void 0&&n.jsx("option",{value:"",children:T}),e.options.map(R=>n.jsx("option",{value:String(R.value),children:R.label},String(R.value)))]})})}if(e.type==="secret"){const T=t??e.default;return n.jsxs("div",{className:"w6w-field",children:[n.jsxs("span",{children:[h,b]}),n.jsx(qt,{value:T,masked:!0,readOnly:r,"aria-label":h,onChange:D=>f(e.key,D)}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}const g=e.type==="number"?"number":"text",y=t??e.default??"",k=typeof y=="object"&&y!==null?JSON.stringify(y):String(y??"");return n.jsxs($e,{param:e,value:t,onChange:f,readOnly:r,label:h,req:b,children:[n.jsx("input",{type:g,value:k,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:T=>f(e.key,e.type==="number"?Number(T.target.value):T.target.value)}),(d==null?void 0:d.hint)&&n.jsx("span",{className:"w6w-hint",children:d.hint})]})}function Ro({param:e,value:t,onChange:s,readOnly:o,label:r,req:i,state:a,retry:l}){const u=t??e.default??"",c=typeof u=="string"||typeof u=="number"?String(u):"";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(ft,{mode:"combobox",forceSelection:!mn(e),"aria-label":r,disabled:o,value:c,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 _l({param:e,value:t,onChange:s,readOnly:o,label:r,req:i,listModelRoutes:a,project:l}){const[u,c]=m.useState([]);m.useEffect(()=>{let f=!0;return Promise.resolve().then(()=>a(l)).then(h=>f&&c(Array.isArray(h)?h:[])).catch(()=>f&&c([])),()=>{f=!1}},[a,l]);const d=t??e.default??"",p=typeof d=="string"?d:"";return n.jsx($e,{param:e,value:t,onChange:s,readOnly:o,label:r,req:i,children:n.jsx(ft,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:p,placeholder:"Select a route…",options:u.map(f=>({value:f.name,label:f.status==="broken"?`${f.name} (broken)`:f.name})),onChange:f=>s(e.key,f)})})}function Fl({param:e,value:t,onChange:s,readOnly:o,label:r,req:i,listDataStores:a,project:l}){const[u,c]=m.useState([]);m.useEffect(()=>{let f=!0;return Promise.resolve().then(()=>a(l)).then(h=>f&&c(Array.isArray(h)?h:[])).catch(()=>f&&c([])),()=>{f=!1}},[a,l]);const d=t??e.default??"",p=typeof d=="string"?d:"";return n.jsx($e,{param:e,value:t,onChange:s,readOnly:o,label:r,req:i,children:n.jsx(ft,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:p,placeholder:"Select a store…",options:u.map(f=>({value:f.name,label:`${f.name} (${f.kind})`})),onChange:f=>s(e.key,f)})})}const Ll=25,Ml=200,To=60;function Dl(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>To&&(t=`${t.slice(0,To-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 Hl({param:e,value:t,onChange:s,readOnly:o,label:r,req:i,store:a,listDataStoreEntries:l,project:u}){const[c,d]=m.useState(""),[p,f]=m.useState({items:[]}),[h,b]=m.useState(!0);m.useEffect(()=>{const y=new AbortController;b(!0);const k=c.trim(),A=setTimeout(()=>{Promise.resolve().then(()=>l(a,{project:u,prefix:k===""?void 0:k,limit:Ll,signal:y.signal})).then(S=>{y.signal.aborted||(f(S&&Array.isArray(S.items)?S:{items:[]}),b(!1))}).catch(()=>{y.signal.aborted||(f({items:[]}),b(!1))})},k===""?0:Ml);return()=>{clearTimeout(A),y.abort()}},[l,a,u,c]);const w=t??e.default??"",x=typeof w=="string"?w:"",g=c.trim();return n.jsx($e,{param:e,value:t,onChange:s,readOnly:o,label:r,req:i,children:n.jsx(ft,{mode:"combobox",forceSelection:!1,"aria-label":r,disabled:o,value:x,placeholder:"Search entries or type a key…",options:p.items.map(y=>({value:y.key,label:y.key,detail:Dl(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:p.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:u,children:c}){var g;const d=Ze(t),p=e.type==="text"||!!((g=e.config)!=null&&g.multiline),[f,h]=m.useState(!1),b=ht(),w=l==="inline"&&!d,x=n.jsxs(n.Fragment,{children:[n.jsx("div",{className:w?"w6w-fx-inline":`w6w-fx-wrap${d?" is-fx":""}`,children:d?n.jsx(qt,{value:t,multiline:p,readOnly:o,"aria-label":r,onChange:y=>s(e.key,y)}):n.jsxs(n.Fragment,{children:[c,!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"}),w&&n.jsxs("label",{className:"w6w-fx-inline-label",htmlFor:u,children:[r,i]})]})}),f&&n.jsx(Gt,{value:t,multiline:p,options:b,fieldLabel:r,onSave:y=>s(e.key,y),onClose:()=>h(!1)})]});return a?x:n.jsxs("div",{className:"w6w-field",children:[!w&&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=et(t)??"",l=a!=="",u=t??e.default,[c,d]=m.useState(()=>l||u===void 0?"":JSON.stringify(u,null,2)),[p,f]=m.useState(!1),[h,b]=m.useState(!1),[w,x]=m.useState(!1),g=ht(),y=g.steps??[];m.useEffect(()=>{if(l)return;let T;try{T=c.trim()===""?void 0:JSON.parse(c)}catch{T=void 0}JSON.stringify(T)!==JSON.stringify(u)&&(d(u===void 0?"":JSON.stringify(u,null,2)),f(!1))},[u,e.key,l]);const k=T=>{d(T)},A=T=>{f(!1),i==null||i(!0),s(e.key,T)},S=({valid:T,error:D})=>{if(i==null||i(T||D==="Empty"),!T&&D==="Empty"){f(!1),s(e.key,void 0);return}f(!T)},j=()=>{const T=dl(c);T&&(f(!1),s(e.key,T))},v=e.label??e.key,E=()=>{let T;try{T=c.trim()===""?void 0:JSON.parse(c)}catch{T=void 0}s(e.key,T)};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(le.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:Ke(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(Ye,{value:c,onChange:k,onBlur:j,readOnly:o,minHeight:"34px",maxHeight:"260px","aria-label":`${e.key} JSON`,onValidChange:A,onValidityChange:S,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"})}),w&&n.jsx(Gt,{mode:"json-binding",value:void 0,jsonValue:t,options:g,fieldLabel:v,whole:e.whole,onSaveJson:T=>s(e.key,T),onClose:()=>x(!1)}),!l&&p&&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(T=>n.jsx("button",{type:"button",className:"w6w-chip w6w-seed-chip",title:`Bind ${v} to {{ nodes.${T.id}.output }}`,onClick:()=>s(e.key,`{{ nodes.${T.id}.output }}`),children:n.jsx("code",{children:T.id})},T.id))]}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint}),h&&!l&&n.jsxs(je,{title:v,subtitle:n.jsx("code",{children:"JSON"}),size:"wide",onClose:()=>b(!1),children:[n.jsx("div",{className:"w6w-json-fullview",children:n.jsx(Ye,{value:c,onChange:k,readOnly:o,height:"100%",minHeight:"360px","aria-label":`${e.key} JSON (full view)`,onValidChange:A,onValidityChange:S})}),p&&n.jsx("span",{className:"w6w-hint",style:{color:"var(--w6w-danger)"},children:"Invalid JSON"})]})]})}function Wl({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):[],u=new Set(l.map(String)),c=r.filter(y=>!u.has(String(y.value))),d=y=>{var k;return((k=r.find(A=>String(A.value)===String(y)))==null?void 0:k.label)??String(y)},p=y=>s(e.key,i?y.join(","):y),f=y=>{if(!y||u.has(y))return;const k=r.find(A=>String(A.value)===y);p([...l,k?k.value:y])},h=y=>p(l.filter(k=>String(k)!==String(y))),b=typeof e.placeholder=="string"&&e.placeholder?e.placeholder:"Select…",w=e.label??e.key,x=e.required?" *":"";return n.jsx($e,{param:e,value:t,onChange:s,readOnly:o,label:w,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:c.length===0,onClick:()=>p([...l,...c.map(y=>y.value)]),children:"Select all"}),n.jsx("button",{type:"button",className:"w6w-linkbtn",disabled:l.length===0,onClick:()=>p([]),children:"Clear"})]})]}),n.jsx("fieldset",{className:"w6w-multiselect-checks-options","aria-label":w,children:[...r,...l.filter(y=>!r.some(k=>String(k.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:u.has(String(y.value)),disabled:o,onChange:k=>k.target.checked?f(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:c.length===0,"aria-label":`Add to ${e.label??e.key}`,onChange:y=>f(y.target.value),children:[n.jsx("option",{value:"",children:c.length>0?l.length?"Add more…":b:"All selected"}),c.map(y=>n.jsx("option",{value:String(y.value),children:y.label},String(y.value)))]})]})})})}function ql({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 ns({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),u=()=>i?Object.fromEntries((r.fields??[]).map(d=>[d.key,d.default??""])):r.type==="number"?0:"",c=(d,p)=>l(a.map((f,h)=>h===d?p:f));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,p)=>n.jsxs("div",{className:"w6w-array-row",children:[i?n.jsx("div",{className:"w6w-array-cells",children:(r.fields??[]).map(f=>n.jsx(ql,{field:f,value:d==null?void 0:d[f.key],readOnly:o,onChange:h=>c(p,{...d??{},[f.key]:h})},f.key))}):n.jsx("input",{className:"w6w-array-input",type:r.type==="number"?"number":"text",value:String(d??""),placeholder:r.placeholder,readOnly:o,onChange:f=>c(p,r.type==="number"?Number(f.target.value):f.target.value)}),!o&&n.jsx("button",{type:"button",className:"w6w-array-x","aria-label":"Remove item",title:"Remove",onClick:()=>l(a.filter((f,h)=>h!==p)),children:"×"})]},p)),!o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm w6w-array-add",onClick:()=>l([...a,u()]),children:"+ Add"})]}),e.hint&&n.jsx("span",{className:"w6w-hint",children:e.hint})]})}const Bl=["string","number","boolean","json"],Ul=[];function bn(e,t=[]){return Array.isArray(e)?e.every(s=>s&&typeof s=="object"&&typeof s.key=="string")?e:null:!e||typeof e!="object"||Ze(e)||et(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 Vl(e){const t=Array.isArray(e)?bn(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 Io(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 $o(e,t=!1){if(typeof e=="string"&&/^[\[{]/.test(e.trim()))try{JSON.parse(e)}catch{return e}return e===void 0?"":JSON.stringify(e,null,t?2:void 0)}function zl({param:e,value:t,label:s,onChange:o,readOnly:r}){const[i,a]=m.useState(null),l=()=>a($o(t,!0));let u=!1,c;if(i!==null)try{c=JSON.parse(i),u=!0}catch{}return n.jsxs(n.Fragment,{children:[n.jsxs($e,{bare:!0,param:e,value:t,onChange:(d,p)=>o(p),readOnly:r,label:s,req:"",children:[n.jsx("input",{type:"text",className:"w6w-datavar-json-preview",value:$o(t).replace(/\r?\n\s*/g," "),placeholder:"JSON value","aria-label":`${s} JSON preview`,readOnly:!0,onClick:l,onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),l())}}),n.jsx("button",{type:"button",className:"w6w-expr-fx",title:"Open JSON editor","aria-label":`Open ${s} JSON editor`,onClick:l,children:n.jsx(le.Icon,{name:"maximize",size:14})})]}),i!==null&&n.jsxs(je,{title:s,subtitle:n.jsx("code",{children:"JSON"}),size:"wide",onClose:()=>a(null),children:[n.jsx("div",{className:"w6w-json-fullview",children:n.jsx(Ye,{value:i,onChange:a,height:"100%",minHeight:"360px",readOnly:r,"aria-label":`${s} JSON editor`})}),!u&&i.trim()&&n.jsx("p",{className:"w6w-field-error",role:"alert",children:"Invalid JSON"}),n.jsxs("div",{className:"w6w-modal-actions",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>a(null),children:r?"Close":"Cancel"}),!r&&n.jsx("button",{type:"button",className:"w6w-btn",disabled:!u,onClick:()=>{u&&(o(c),a(null))},children:"Apply"})]})]})]})}function Jl({param:e,value:t,onChange:s,readOnly:o}){const r=t??e.default??Ul,i=m.useMemo(()=>Vl(r),[r]),[a,l]=m.useState(()=>Array.isArray(r)?"fields":"json"),u=m.useRef([]),[c,d]=m.useState(!1),[p,f]=m.useState(null),h=bn(r,u.current),b=h??[],w=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${w?"":" active"}`,"aria-label":`Edit ${x} as fields`,"aria-pressed":!w,disabled:c||!!p||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${w?" active":""}`,"aria-label":`Edit ${x} as JSON`,"aria-pressed":w,onClick:()=>{u.current=b,l("json")},children:"JSON"})]});if(w)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,S)=>{if(S!==void 0&&bn(S)===null&&!et(S)&&!Ze(S)&&!(S&&typeof S=="object"&&"$expr"in S)){f("Use a JSON object, a typed key/value array, or an object binding.");return}f(null),d(!1),s(A,S)}}),p&&n.jsx("span",{className:"w6w-hint w6w-datavar-error","aria-live":"polite",children:p})]});const y=A=>s(e.key,A),k=(A,S)=>y(b.map((j,v)=>v===A?{...j,...S}:j));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,S)=>n.jsxs("div",{className:"w6w-datavar-row",children:[n.jsx("input",{type:"text",placeholder:"key",value:A.key,readOnly:o,onChange:j=>k(S,{key:j.target.value})}),n.jsx("select",{value:A.type,disabled:o,onChange:j=>{const v=j.target.value;k(S,{type:v,value:Io(v,Oo(A.value))})},children:Bl.map(j=>n.jsx("option",{value:j,children:j},j))}),A.type==="json"?n.jsx(zl,{param:e,value:A.value,label:A.key||"value",onChange:j=>k(S,{value:j}),readOnly:o}):n.jsx($e,{bare:!0,param:e,value:A.value,onChange:(j,v)=>k(S,{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:j=>k(S,{value:j.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:j=>k(S,{value:Io(A.type,j.target.value)})})}),!o&&n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost","aria-label":`Remove variable ${A.key||S+1}`,title:"Remove",onClick:()=>y(b.filter((j,v)=>v!==S)),children:"×"})]},S)),!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})]})}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 an({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",u=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:!!u,onChange:p=>i(a.key,p.target.checked),...o}),a.label,a.required?" *":""]}),a.hint&&n.jsx("span",{className:"w6w-hint",children:a.hint})]},a.key);const c=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:c?"w6w-secret-input":void 0,rows:a.type==="json"?6:3,value:String(u??""),placeholder:l&&c?"•••••• (unchanged)":void 0,onChange:p=>i(a.key,p.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:c?"w6w-secret-input":void 0,value:String(u??""),placeholder:l&&c?"•••••• (unchanged)":void 0,onChange:p=>i(a.key,a.type==="number"&&!(l&&p.target.value==="")?Number(p.target.value):p.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 vr({credentials:e,mode:t,onModeChange:s,selectedId:o,onSelect:r,canUseExisting:i=!0,contract:a}){const l=u=>{const c=Object.values(u.display??{}).filter(Boolean);return c.length>0?`${u.name} (${c.join(", ")})`:u.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:u=>r(u.target.value),children:e.map(u=>n.jsx("option",{value:u.id,children:l(u)},u.id))})]})]})}function jr(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 Nr(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 Kl="width=560,height=720,menubar=no,toolbar=no,location=no";function kr(e){return new Promise((t,s)=>{const o=window.open(e,"w6w-oauth",Kl);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=u=>{const c=u.data;if((c==null?void 0:c.w6w)==="oauth-result"){i();try{o.close()}catch{}c.ok&&typeof c.connectionId=="string"?t({connectionId:c.connectionId}):s(new Error(c.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 Gl=new Set(["checkbox","radio","button","submit","reset","file","range","color","image","hidden","date","datetime-local","month","week","time"]);function Yl(e){return e.closest('[contenteditable]:not([contenteditable="false"])')!==null}function Sr(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"&&(Yl(o)||o.tagName==="INPUT"&&Gl.has(o.type)||(s.preventDefault(),e()))}}}function Is(e){const t=xe(),[s,o]=m.useState(null),[r,i]=m.useState(!!e.initialAppId);return m.useEffect(()=>{const a=e.initialAppId;if(!a)return;let l=!1;const u=p=>{l||(o(p),i(!1))},c=t.listAppsByIds;if(c)return c([a]).then(p=>u(p.find(f=>f.id===a)??null)).catch(()=>u(null)),()=>{l=!0};const d=t.listApps;return typeof d=="function"?d().then(p=>u(p.find(f=>f.id===a)??null)).catch(()=>u(null)):u(null),()=>{l=!0}},[t,e.initialAppId]),s?n.jsx(je,{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(pt,{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(Xl,{app:s,onCreated:e.onCreated,onClose:e.onClose})}):r?n.jsx(je,{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(je,{title:"Add connection",onClose:e.onClose,size:"xl",children:n.jsx("div",{className:"w6w-stepbuilder-content",children:n.jsx(lt,{onSelectApp:o,theme:e.theme,searchPlaceholder:"Search apps to connect…",categoryFilter:!0})})})}function Xl({app:e,onCreated:t,onClose:s}){var V,J;const o=xe(),[r,i]=m.useState(null),[a,l]=m.useState(""),[u,c]=m.useState(""),[d,p]=m.useState({}),[f,h]=m.useState(null),[b,w]=m.useState(!1),[x,g]=m.useState(null),[y,k]=m.useState(null),[A,S]=m.useState(""),[j,v]=m.useState(""),[E,T]=m.useState({}),D=m.useRef(null);m.useEffect(()=>{let _=!1;return i(null),o.getAppAuth(e.id).then(W=>!_&&i(W.filter(ue=>ue.available!==!1))).catch(W=>!_&&h(W.message)),()=>{_=!0}},[o,e.id]);const I=r??[],R=I.find(_=>_.key===a)??I.find(_=>_.default===!0)??I[0],O=(R==null?void 0:R.fields)??[],L=(R==null?void 0:R.type)==="oauth2",H=R==null?void 0:R.serviceAccount,B=o.listCredentials,z=o.createCredential,P=!L&&!!H&&typeof B=="function"&&typeof z=="function",$=((V=H==null?void 0:H.accepts)==null?void 0:V[0])??"",Z=(x??[]).filter(_=>_.contract===$&&_.status==="active"),Q=Z.length===0?"new":y??"existing",ee=Z.some(_=>_.id===A)?A:((J=Z[0])==null?void 0:J.id)??"",F=P&&H?jr(H):[];m.useEffect(()=>{if(!P||!B)return;let _=!1;return g(null),k(null),D.current=null,B.call(o,{contract:$}).then(W=>!_&&g(W)).catch(()=>!_&&g([])),()=>{_=!0}},[o,P,$,B]);const X=(R==null?void 0:R.key)==="zero-credential",Y=_=>_===void 0||_==="",U=!L&&!X&&(P?x===null||F.some(_=>_.required&&Y(E[_.key]))||(Q==="existing"?ee==="":j.trim()===""||O.some(_=>_.required&&Y(d[_.key]))):O.some(_=>_.required&&Y(d[_.key]))),G=!R||!L&&!X&&U||b;async function te(){if(R){h(null),w(!0);try{if(X)t({connectionId:`zerocred:${e.id}`});else if(L){const{authorizationUrl:_}=await o.startAppOAuthFlow(e.id,R.key,{displayName:u||void 0}),{connectionId:W}=await kr(_);t({connectionId:W})}else if(P&&z){let _=Q==="existing"?ee:D.current;if(_===null){const he=ss(O,d);if("error"in he){h(he.error);return}const ge=await z.call(o,{name:j.trim(),contract:$,source:he.values});D.current=ge.id,_=ge.id}const W=Nr(F,E),ue={authKey:R.key,credentialId:_,...W?{binding:W}:{},...u?{displayName:u}:{}},pe=await o.createConnection(e.id,ue);t({connectionId:pe.id})}else{const _=ss(O,d);if("error"in _){h(_.error);return}const W=await o.createConnection(e.id,{authKey:R.key,credential:_.values,displayName:u||void 0});t({connectionId:W.id})}}catch(_){h(_.message)}finally{w(!1)}}}const C=Sr(te,{enabled:!G});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&&I.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."}),I.length>1&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Auth method"}),n.jsx("select",{value:(R==null?void 0:R.key)??"",onChange:_=>{l(_.target.value),p({}),T({}),D.current=null,h(null)},children:I.map(_=>n.jsxs("option",{value:_.key,children:[_.displayName??_.key," (",_.type,")"]},_.key))})]}),R&&n.jsxs(n.Fragment,{children:[!X&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Display name"}),n.jsx("input",{type:"text",value:u,onChange:_=>c(_.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",...C})]}),R.description&&n.jsx("p",{className:"w6w-muted w6w-small",children:R.description}),X?null:L?n.jsxs("p",{className:"w6w-muted w6w-small",children:["You'll be redirected to ",n.jsx("strong",{children:R.displayName??R.key})," to authorize this connection."]}):P&&H?n.jsxs(n.Fragment,{children:[n.jsx(vr,{credentials:Z,mode:Q,onModeChange:_=>{k(_),D.current=null},selectedId:ee,onSelect:S,canUseExisting:Z.length>0,contract:$}),H.scopes.length>0&&n.jsxs("p",{className:"w6w-muted w6w-small",children:["Scopes: ",n.jsx("code",{children:H.scopes.join(" ")})]}),F.length>0&&n.jsx(an,{fields:F,values:E,onChange:T,enterSubmitProps:C}),Q==="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:j,onChange:_=>v(_.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",...C})]}),n.jsx(an,{fields:O,values:d,onChange:p,enterSubmitProps:C})]})]}):n.jsx(an,{fields:O,values:d,onChange:p,enterSubmitProps:C})]}),f&&n.jsx("div",{className:"w6w-result w6w-error",children:f})]})}),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:G,onClick:te,children:b?X?"Saving…":L?"Waiting for authorization…":"Saving…":X?"Use this":L?`Sign in with ${(R==null?void 0:R.displayName)??(R==null?void 0:R.key)??"provider"}`:"Save connection"})]})]})}const Ut=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)"]],en={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."},Zl=new Set(Os.map(([e])=>e)),Po={...Object.fromEntries(Os),"==":"equals","!=":"does not equal",in:"is in"};function Ql(e){return e.startsWith("not:")?`Not (${Po[e.slice(4)]??e.slice(4)})`:Po[e]??e}const Cr=[["and","All of (AND)"],["or","Any of (OR)"],["xor","Exactly one of (XOR)"]],Ar=Object.fromEntries(Cr);function ec(e){return Ar[e]??e}function $s(e,t=!0){if(!Ut(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=$s(r[0],!1);return!i||i.negated?void 0:{...i,negated:!0}}if(!(!Zl.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 tc(e){if(!(!Ut(e)||Object.keys(e).length!==1))return $s(e.$expr)}function nc(e){const t=tc(e);if(t)return{combinator:"and",rows:[t]};if(!Ut(e)||Object.keys(e).length!==1||!Ut(e.$expr))return;const s=Object.entries(e.$expr);if(s.length!==1)return;const[o,r]=s[0];if(!Object.hasOwn(Ar,o)||!Array.isArray(r)||r.length===0)return;const i=r.map(a=>$s(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 os(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"?Nn(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 Fo(e){return typeof e=="string"?os(e)===e?e:JSON.stringify(e):Ut(e)?Object.keys(e).length===1&&typeof e.var=="string"?ae.serializeTemplate([{kind:"var",ref:e.var}]):ae.serializeTemplate([{kind:"expr",expr:e}]):JSON.stringify(e)??""}const Er={left:"",operator:"is-true",right:!0},Lo={combinator:"and",rows:[Er]},sc=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function An({values:e,onChange:t,readOnly:s,purpose:o="if"}){const r=ht(),i=e.condition===void 0?!0:e.condition,a=nc(i),[l,u]=m.useState(!1),[c,d]=m.useState(a??Lo),p=m.useRef(0),[f,h]=m.useState(()=>c.rows.map(()=>p.current++)),b=a!==void 0||typeof i=="boolean",w=sc(_o(c),i)?c:a??Lo,x=w.rows.map((j,v)=>f[v]??-1-v),g=(j,v=x)=>{d(j),h(v),t({...e,condition:_o(j)})},y=(j,v)=>g({...w,rows:w.rows.map((E,T)=>T===j?{...E,...v}:E)}),k=()=>g({...w,rows:[...w.rows,Er]},[...x,p.current++]),A=j=>g({...w,rows:w.rows.filter((v,E)=>E!==j)},x.filter((v,E)=>E!==j)),S=w.rows.length>1;return n.jsxs("div",{className:"w6w-condition-editor",children:[l||!b?n.jsx(Pe,{params:[{key:"condition",label:"Condition",type:"json",required:!0}],values:e,onChange:t,readOnly:s}):n.jsxs("div",{className:"w6w-condition-rows",children:[S&&n.jsx("select",{className:"w6w-condition-comparison w6w-condition-combinator","aria-label":"Combine conditions",disabled:s,value:w.combinator,onChange:j=>g({...w,combinator:j.target.value}),children:Cr.map(([j,v])=>n.jsx("option",{value:j,children:v},j))}),w.rows.map((j,v)=>{const E=j.operator==="is-true"||j.operator==="is-false";return n.jsxs("div",{className:`w6w-condition-row${S?" 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:j.negated??!1,disabled:s,onChange:T=>y(v,{negated:T.target.checked})}),"Not"]}),n.jsx(qt,{value:Fo(j.left),"aria-label":"Condition field",placeholder:"Field or expression",readOnly:s,onChange:T=>y(v,{left:os(T)})}),n.jsx("select",{className:"w6w-condition-comparison","aria-label":"Condition comparison",title:en[j.operator],disabled:s,value:j.operator,onChange:T=>y(v,{operator:T.target.value,right:T.target.value==="is-true"?!0:T.target.value==="is-false"?!1:E?"":j.right}),children:Os.map(([T,D])=>n.jsx("option",{value:T,title:en[T],children:D},T))}),!E&&n.jsx(qt,{value:Fo(j.right),"aria-label":"Condition value",placeholder:"Value or expression",readOnly:s,onChange:T=>y(v,{right:os(T)})}),S&&!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(le.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:k,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(w.rows.map(j=>j.operator))].map(j=>en[j]?n.jsx("p",{className:"w6w-muted w6w-small",children:en[j]},j):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:()=>u(!l),children:n.jsx(le.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 oc={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 Rr({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",u=c=>t({maxAttempts:i,delayMs:a,backoff:l,...e,...c});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:c=>t(c.target.checked?{maxAttempts:i,delayMs:a,backoff:l}:void 0)})," ","Retry on failure"]}),n.jsx("span",{className:"w6w-hint",children:oc[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:c=>u({maxAttempts:Math.max(1,Number(c.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:c=>u({delayMs:Math.max(0,Number(c.target.value)||0)})})]}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Backoff"}),n.jsxs("select",{value:l,disabled:s,onChange:c=>u({backoff:c.target.value}),children:[n.jsx("option",{value:"fixed",children:"Fixed"}),n.jsx("option",{value:"exponential",children:"Exponential"})]})]})]})]})}function Ps({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(Rr,{value:e.retry,onChange:u=>t({...e,retry:u}),readOnly:s}),n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"On error"}),n.jsxs("select",{value:l,disabled:s,onChange:u=>{const c=u.target.value;t({...e,onError:c==="fail"?void 0:c})},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:u=>t({...e,notes:u.target.value||void 0})})]})]})}function En(e){return e.$merge!==void 0}function Tr(e){const t=e.$merge;if(t===void 0)return e;if(!(et(t)||qe(t)||Ss(t)||typeof t=="string"&&Nn(t)))return t&&typeof t=="object"&&!Array.isArray(t)&&!Qe(t)&&!("$merge"in t)?{...e,...t}:null}function Ir(e,t,s=[]){if(qe(e)||Qe(e)||ks(e)||Ss(e)||e===null||typeof e!="object")return Wt(e,t);const o=r=>Ir(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 _s({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(Pe,{params:[{key:"$merge",label:"JSON customization",type:"json",required:!0,default:{},whole:!0}],values:e,onChange:t,readOnly:s}),Tr(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&&En(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 Or(e){const{label:t,onClick:s,disabled:o,className:r,...i}=e;return n.jsx(kn,{label:t,onClick:s,disabled:o,className:r,danger:!0,icon:"delete","data-testid":i["data-testid"]})}function $r({values:e,onChange:t,readOnly:s}){const o=Array.isArray(e.routes)?e.routes:wn(We,"route").routes,r=o.filter(g=>!g.default),[i,a]=m.useState(null),[l,u]=m.useState(null),[c,d]=m.useState(null),[p,f]=m.useState(""),h=g=>t({...e,routes:[...g,...o.filter(y=>y.default)]}),b=(g,y)=>h(r.map(k=>k.id===g?{...k,...y}:k)),w=(g,y)=>{const k=r.findIndex(j=>j.id===g);if(k<0||y<0||y>=r.length||k===y)return;const A=[...r],[S]=A.splice(k,1);A.splice(y,0,S),h(A)},x=g=>{p.trim()&&b(g.id,{label:p.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:k=>{s||!i||i===g.id||(k.preventDefault(),k.dataTransfer.dropEffect="move",u(g.id))},onDrop:k=>{k.preventDefault(),!s&&i&&w(i,y),a(null),u(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:k=>{k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("text/plain",g.id);const A=k.currentTarget.closest(".w6w-router-route");A&&k.dataTransfer.setDragImage(A,16,16),a(g.id)},onDragEnd:()=>{a(null),u(null)},onKeyDown:k=>{k.key!=="ArrowUp"&&k.key!=="ArrowDown"||(k.preventDefault(),w(g.id,y+(k.key==="ArrowUp"?-1:1)))},children:n.jsx(le.Icon,{name:"grip",size:14})}),n.jsx("span",{className:"w6w-step-rename",children:c===g.id&&!s?n.jsx("input",{autoFocus:!0,"aria-label":"Route name",value:p,onChange:k=>f(k.target.value),onBlur:()=>x(g),onKeyDown:k=>{k.key==="Enter"&&x(g),k.key==="Escape"&&d(null)}}):n.jsxs("button",{type:"button",className:"w6w-router-route-name",disabled:s,"aria-label":`Rename ${g.label||g.id}`,onClick:()=>{f(g.label||g.id),d(g.id)},children:[g.label||g.id,!s&&n.jsx(le.Icon,{name:"edit",size:12})]})}),n.jsx(Or,{label:`Remove ${g.label||g.id}`,disabled:s,onClick:()=>h(r.filter(k=>k.id!==g.id))})]}),n.jsx(An,{values:{condition:g.condition??!1},onChange:k=>b(g.id,{condition:k.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 Pr({value:e,onCommit:t,readOnly:s}){const[o,r]=m.useState(!1),[i,a]=m.useState(e),[l,u]=m.useState(null),c=()=>{const d=i.trim(),p=d&&d!==e?t(d):null;if(p){u(p);return}u(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),u(null)},onBlur:c,onKeyDown:d=>{d.key==="Enter"&&c(),d.key==="Escape"&&(a(e),u(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(le.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(An,{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 rc=["props","code"];function ic(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Fr({params:e,values:t,onChange:s,onValidityChange:o,readOnly:r,initialView:i="props"}){const a=e.length>0,[l,u]=m.useState(i),c=!a||l==="code",[d,p]=m.useState(()=>Mo(t)),[f,h]=m.useState(!0),b=m.useRef(!0),w=y=>{y!==b.current&&(b.current=y,h(y),o==null||o(y))},x=y=>{y==="code"&&p(Mo(t)),w(!0),u(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:[...rc],onChange:y=>x(y)})}),c?n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:g}),n.jsx(Ye,{value:d,onChange:p,readOnly:r,minHeight:"140px","aria-label":`${g} JSON`,onValidChange:y=>{const k=ic(y);w(k),k&&s(y)},onValidityChange:y=>{y.valid||w(!1)}}),!f&&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(Pe,{params:e,values:t,onChange:s,readOnly:r})]})}function Mo(e){return JSON.stringify(e??{},null,2)}const ac=new Set(["http:","https:","mailto:"]);function lc(e){try{return ac.has(new URL(e).protocol)?e:""}catch{return""}}const cc=["img"];function uc({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 Lr(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 dc({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 Fs({content:e,className:t,copyable:s=!0}){const{frontmatter:o,body:r}=Lr(e),i=n.jsxs("div",{className:t,children:[(o==null?void 0:o.trim())&&n.jsx(dc,{yaml:o}),n.jsx(Di,{skipHtml:!0,urlTransform:lc,disallowedElements:cc,unwrapDisallowed:!0,components:{a:uc},children:r})]});return s?n.jsx(le.Copyable,{value:e,label:"Copy Markdown",className:"w6w-copyable--document",children:i}):i}const Mr="default-src 'none'; style-src 'unsafe-inline'; img-src data:; base-uri 'none'; form-action 'none'";function Dr(e){return`<!doctype html><meta http-equiv="Content-Security-Policy" content="${Mr}">${e}`}function Hr({html:e}){return n.jsx("iframe",{title:"HTML preview",className:"w6w-html-preview",sandbox:"",referrerPolicy:"no-referrer",srcDoc:Dr(e)})}function Wr(e){return typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":"null"}function pc(e){return Wr(e)==="string"?JSON.stringify(e):String(e)}function fc(e){return typeof e=="object"&&e!==null}function hc(e,t){return`${t} ${e?"item":"key"}${t===1?"":"s"}`}function wc({value:e,expandDepth:t=2}){return n.jsx(qr,{label:void 0,value:e,depth:0,expandDepth:t})}function qr(e){const{label:t,value:s,depth:o,expandDepth:r}=e,i=fc(s),a=Array.isArray(s),l=i?a?s.map((c,d)=>[d,c]):Object.entries(s):[],u=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:[u,a?"[…]":"{…}"," ",n.jsx("span",{className:"w6w-json-count",children:hc(a,l.length)})]}),n.jsx("div",{className:"w6w-json-children",children:l.map(([c,d])=>n.jsx(qr,{label:c,value:d,depth:o+1,expandDepth:r},String(c)))})]}):n.jsxs("div",{className:"w6w-json-leaf",children:[u,u===null?null:": ",n.jsx("span",{className:`w6w-json-${i?"null":Wr(s)}`,children:i?a?"[]":"{}":pc(s)})]})}const Br=262144,mc=/^#{1,6}\s+\S/,bc=/^```/,gc=/^\s*(?:[-*+]|\d+\.)\s+\S/,yc=/\[[^\]\n]+\]\(https?:\/\/[^)\s]+\)/;function Ur(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(`
16
+ `);return s.some(o=>mc.test(o)||bc.test(o))||s.filter(o=>gc.test(o)).length>=2||yc.test(t)?{format:"markdown",text:e}:{format:"text",text:e}}function Vr(e){return e.format==="json"?JSON.stringify(e.data,null,2)??"":e.text}const xc=65536;function Wn(e,t){return e.length>xc?n.jsx("pre",{className:"w6w-result-viewer-text",children:e}):n.jsx(le.CodeBlock,{code:e,language:t,copyable:!1,wrap:!0})}function Ne(e){const{value:t,format:s="auto",maxHeight:o=320,className:r}=e,i=m.useMemo(()=>s==="json"?{format:"json",data:t}:Ur(t),[t,s]),[a,l]=m.useState("rendered"),[u,c]=m.useState(2),[d,p]=m.useState(0),f=i.format==="json"?"":i.text,h=i.format==="html"||i.format==="markdown",b=h&&f.length>Br,w=m.useMemo(()=>{try{return Vr(i)}catch{return typeof t=="string"?t:String(t)}},[i,t]);let x;if(i.format==="json")x=n.jsx(wc,{value:i.data,expandDepth:u},d);else if(i.format==="xml")x=Wn(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."}),Wn(i.text,y)]}):a==="source"?x=Wn(i.text,y):i.format==="html"?x=n.jsx(Hr,{html:i.text}):x=n.jsx(Fs,{content:i.text,copyable:!1})}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:()=>{c(Number.POSITIVE_INFINITY),p(y=>y+1)},children:"Expand all"}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>{c(1),p(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(le.Copyable,{value:w,label:"Copy result",className:"w6w-copyable--overlay",children:n.jsx("div",{className:"w6w-result-viewer-body",style:{maxHeight:o,overflow:"auto"},children:x})})]})}function zr(e,t){const s=e.filter(o=>o.appId===Fe);return s.find(o=>o.nodeId===t)??s.find(o=>!o.nodeId)??s[0]??null}const vc=/auth|token|secret|passw|cookie|api[-_]?key|signature|session/i,jc="••••••";function Nc(e){const t={};for(const[s,o]of Object.entries(e))t[s]=vc.test(s)?jc:o;return t}const kc=20;function Sc({workflowId:e,stepId:t,stepWith:s,readOnly:o,onUse:r,using:i}){const a=xe(),[l,u]=m.useState(void 0),[c,d]=m.useState(!1),[p,f]=m.useState({phase:"idle"}),[h,b]=m.useState(()=>Date.now()),w=m.useRef(null);m.useEffect(()=>{const j=a.listSubscriptionsForWorkflow;if(!j)return;let v=!1;return j(e).then(E=>!v&&u(zr(E,t))).catch(E=>!v&&f({phase:"error",message:E.message})),()=>{v=!0}},[a,e,t]);const x=m.useCallback(j=>{var E;const v=w.current;w.current=null,v&&(v.abort.abort(),j&&((E=a.stopWebhookListen)==null||E.call(a,v.subId,v.sessionId).catch(()=>{})))},[a]);m.useEffect(()=>()=>x(!0),[x]),m.useEffect(()=>{if(p.phase!=="waiting")return;const j=setInterval(()=>b(Date.now()),1e3);return()=>clearInterval(j)},[p.phase]);const g=()=>{const j=a.createSubscription;j&&(d(!0),j(Fe,"webhook",{workflowId:e,connectionId:null,params:s??{}}).then(v=>u(v)).catch(v=>f({phase:"error",message:v.message})).finally(()=>d(!1)))},y=async()=>{var I;const j=a.startWebhookListen,v=a.pollWebhookListen;if(!l||!j||!v)return;x(!0),f({phase:"starting"});let E;try{E=(await j(l.id)).session}catch(R){f({phase:"error",message:R.message});return}const T=new AbortController,D={subId:l.id,sessionId:E.id,abort:T};for(w.current=D,b(Date.now()),f({phase:"waiting",session:E});;){let R;try{R=await v(l.id,E.id,{waitSeconds:kc,signal:T.signal})}catch(O){if(w.current!==D)return;w.current=null,f({phase:"error",message:O.message});return}if(w.current!==D)return;if(R.status==="captured"&&R.request){w.current=null,f({phase:"captured",session:R,request:R.request});return}if(R.status==="expired"){w.current=null,(I=a.stopWebhookListen)==null||I.call(a,l.id,E.id).catch(()=>{}),f({phase:"expired"});return}}},k=()=>{x(!0),f({phase:"idle"})};if(!a.startWebhookListen||!a.pollWebhookListen)return null;const A=l==null?void 0:l.webhookUrl,S=p.phase==="waiting"?Math.max(0,Math.ceil((Date.parse(p.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(le.Copyable,{value:A,readOnly:!0,children:n.jsx("input",{type:"text",readOnly:!0,value:A,"aria-label":"Webhook URL"})}),p.phase==="waiting"||p.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}),"…",p.phase==="waiting"&&n.jsxs("span",{className:"w6w-muted",children:[" ",Cc(S)," left"]})]}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:k,children:"Stop"})]}):n.jsxs("div",{className:"w6w-steptest-bar",children:[n.jsx("button",{type:"button",className:"w6w-btn",disabled:o,onClick:()=>void y(),children:p.phase==="captured"?"Listen again":"Listen for test event"}),p.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:c,onClick:g,children:c?"Creating…":"Create webhook URL"})]}),p.phase==="expired"&&n.jsx("p",{className:"w6w-muted w6w-small",children:"No request arrived in time. Listen again, then send the request."}),p.phase==="error"&&n.jsx("div",{className:"w6w-result w6w-error",children:p.message}),p.phase==="captured"&&n.jsx(Ac,{request:p.request,receivedAt:p.session.receivedAt,readOnly:o,using:i,onUse:()=>r(p.request),stepId:t})]})}function Cc(e){const t=Math.floor(e/60);return t>0?`${t}:${String(e%60).padStart(2,"0")}`:`${e}s`}function Ac({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(Ne,{value:e.query,maxHeight:120})]}),n.jsx("div",{className:"w6w-testout-label",children:"Headers"}),n.jsx(Ne,{value:Nc(e.headers??{}),maxHeight:160}),n.jsx("div",{className:"w6w-testout-label",children:"Body"}),n.jsx(Ne,{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 Ms(e){return e==="object"||e==="array"?"json":e==="number"||e==="boolean"||e==="json"?e:"string"}function Ds(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 Hs(e){return e.filter(t=>typeof t.key=="string"&&t.key.trim()!=="").map(t=>({key:t.key,label:t.key,type:Ms(t.type),required:!!t.required}))}function rs(e){const t={};for(const s of e){if(typeof s.key!="string"||s.key.trim()==="")continue;const o=Ds(s.type,s.default);o!==void 0&&(t[s.key]=o)}return t}function Jr(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 Ec(e){return qe(e)||typeof e=="string"&&e.includes("{{")}function Ws(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||Qe(i)||s.has(r)&&!Ec(i)||(o[r]=i);return o}const is=new Set;function Kr(e){const t=e.then(()=>{},()=>{});return is.add(t),t.then(()=>is.delete(t)),e}async function Gr(){await Promise.all([...is])}function Yr(e,t){const s=xe(),o=typeof s.loadTestInputs=="function"&&!!e&&!!t,[r,i]=m.useState(!o),[a,l]=m.useState(void 0);m.useEffect(()=>{if(!o||!e||!t||!s.loadTestInputs){i(!0);return}let p=!1;return i(!1),Gr().then(()=>{var f;return((f=s.loadTestInputs)==null?void 0:f.call(s,e))??[]}).then(f=>{p||(l(Jr(f,t)),i(!0))}).catch(()=>{p||i(!0)}),()=>{p=!0}},[s,o,e,t]);const u=m.useCallback(p=>{l(p),!(!e||!t||typeof s.saveTestInput!="function")&&Kr(s.saveTestInput(e,t,p)).catch(f=>{console.error("test input save failed",f)})},[s,e,t]),c=m.useCallback((p,f)=>u(Ws(p,f)),[u]),d=m.useCallback(()=>u({}),[u]);return{loaded:r,supported:o,input:a,save:c,clear:d}}function Xr({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 Rc=600;function Zr({app:e,action:t,fields:s,persist:o,listen:r}){const i=xe(),a=xs(),l=m.useMemo(()=>Ls(s),[s]),u=m.useMemo(()=>Hs(l),[l]),c=u.length>0,[d,p]=m.useState(()=>rs(l)),[f,h]=m.useState(null),b=o==null?void 0:o.workflowId,w=o==null?void 0:o.stepId,x=Yr(b,w),[g,y]=m.useState(!1),[k,A]=m.useState(!1),[S,j]=m.useState(!b||!w);m.useEffect(()=>{if(!b||!w){j(!0);return}if(!x.loaded)return;if(x.input!==void 0){const X=x.input;Object.keys(X).length>0&&(p(Y=>({...Y,...X})),y(!0),A(!0)),j(!0);return}let F=!1;return i.listStepTests(b,w).then(X=>{if(F)return;const Y=X.length?X[X.length-1]:null;Y!=null&&Y.with&&(p(U=>({...U,...Y.with})),Object.keys(Y.with).length>0&&A(!0)),j(!0)}).catch(()=>{F||j(!0)}),()=>{F=!0}},[i,b,w,x.loaded]);const[v,E]=m.useState(0),T=()=>{clearTimeout(I.current),D.current=null,x.clear(),y(!1),p(rs(l)),E(F=>F+1)},D=m.useRef(null),I=m.useRef(void 0),R=m.useRef(()=>{});R.current=()=>{clearTimeout(I.current);const F=D.current;D.current=null,F&&x.save(F,u)},m.useEffect(()=>()=>R.current(),[]);const O=F=>{p(F),!(!b||!w||!S)&&(D.current=F,clearTimeout(I.current),I.current=setTimeout(()=>R.current(),Rc))},[L,H]=m.useState(!0),B=L&&St(u,d),z=async F=>{const X=F??d;clearTimeout(I.current),D.current=null,o&&x.save(X,u),h({status:"running"});let Y;try{const U=await i.invokeAction(e,t,{input:X},{project:a});Y={status:"done",value:U.value,logs:U.logs}}catch(U){const G=U;Y={status:"error",error:G.message??String(U),errorCode:G.code,logs:G.logs}}if(h(Y),o)try{const U=await i.saveStepTest(o.workflowId,o.stepId,{input:o.input,with:X});await i.recordStepTestRun(o.workflowId,o.stepId,{stepTestId:U.id,status:Y.status==="done"?"succeeded":"failed",input:o.input,output:Y.status==="done"?Y.value:void 0,error:Y.status==="error"?Y.error:void 0})}catch(U){console.error("step test persist failed",U)}},P=f&&f.status!=="running"?f.logs:void 0,$=F=>{const X={...F};p(X),z(X)},Z=r&&o&&n.jsx(Sc,{workflowId:o.workflowId,stepId:o.stepId,stepWith:r.stepWith,readOnly:r.readOnly,onUse:$,using:(f==null?void 0:f.status)==="running"});return n.jsxs("div",{className:"w6w-stack",children:[Z,Z?n.jsxs("details",{className:"w6w-listen-manual","data-testid":"trigger-sample-payload",open:k,onToggle:F=>A(F.currentTarget.open),children:[n.jsx("summary",{className:"w6w-small",children:"Or test with a sample payload"}),Q()]}):Q(),ee()]});function Q(){return n.jsxs("div",{className:"w6w-stack",children:[S?n.jsxs(n.Fragment,{children:[g&&n.jsx(Xr,{onClear:T}),n.jsx(Fr,{params:u,values:d,onChange:O,onValidityChange:H},v),!c&&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:!S||!B||(f==null?void 0:f.status)==="running",onClick:()=>void z(),children:(f==null?void 0:f.status)==="running"?"Running…":"▶ Test run"}),S&&!B&&n.jsx("span",{className:"w6w-muted w6w-small",children:L?"Fill the required fields to test.":"The payload must be a JSON object to test."})]})})]})}function ee(){return n.jsxs("div",{className:"w6w-steptest",children:[(f==null?void 0:f.status)==="error"&&n.jsxs("div",{className:"w6w-result w6w-error",children:[f.errorCode&&n.jsx("div",{className:"w6w-small",style:{opacity:.75,marginBottom:4},children:n.jsx("code",{children:f.errorCode})}),f.error]}),(f==null?void 0:f.status)==="done"&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Output state (filled values)"}),n.jsx(Ne,{value:f.value,maxHeight:220})]}),P&&P.length>0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Console output"}),n.jsx(le.Copyable,{value:P.join(`
17
+ `),label:"Copy console output",children:n.jsx("pre",{className:"w6w-result w6w-testout-console",style:{whiteSpace:"pre-wrap",maxHeight:160,overflow:"auto",margin:0},children:P.join(`
18
+ `)})})]})]})}}const Tc=[["s","Seconds"],["m","Minutes"],["h","Hours"],["d","Days"],["w","Weeks"]],Ic=/^(?=\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 Qr({values:e,onChange:t,readOnly:s}){const o=e.duration??"1s",r=typeof o=="string"?o.match(/^(\d+(?:\.\d+)?)([smhdw])$/i):null,[i,a]=m.useState("s"),[l,u]=m.useState("text"),[c,d]=m.useState(e.until?"until":"duration"),p=typeof o=="string"&&(!Ic.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:c,onChange:f=>{const h=f.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"})]})]}),c==="until"?n.jsx(Pe,{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:f=>{r&&a((r==null?void 0:r[2].toLowerCase())??i),u(f.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:f=>t({...e,duration:`${f.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:f=>{a(f.target.value),t({...e,duration:`${(r==null?void 0:r[1])??""}${f.target.value}`})},children:Tc.map(([f,h])=>n.jsx("option",{value:f,children:h},f))})]})]}):n.jsx(Pe,{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}),p&&n.jsx("p",{role:"alert",children:"Enter a duration such as 30s or 1h30m30s, using units w, d, h, m, s in order."})]})]})}function ei({anchorRef:e,onClose:t,children:s}){const o=m.useRef(null),[r,i]=m.useState(null),[a,l]=m.useState(null);return m.useEffect(()=>{const u=e.current;if(!u)return;const c=u.getBoundingClientRect();i({top:c.bottom+6,left:c.left,width:c.width}),l(u.closest("dialog")??document.body)},[e]),m.useEffect(()=>{function u(d){var f,h;const p=d.target;(f=o.current)!=null&&f.contains(p)||(h=e.current)!=null&&h.contains(p)||t()}function c(d){d.key==="Escape"&&t()}return document.addEventListener("mousedown",u),document.addEventListener("keydown",c),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",c)}},[t,e]),!r||!a?null:pn.createPortal(n.jsx("div",{ref:o,className:"w6w-flyout",style:{top:r.top,left:r.left,width:r.width},children:s}),a)}function ti(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)&&ti(e[r],t[r]))}function Oc(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&&ti(r,o)?s:{...s,data:{...s.data,stepProblems:structuredClone(o)}}})}const $c={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 Pc(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=$c[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 _c(e,t){return(t==null?void 0:t.some(s=>s.code==="unknown_connection"&&e.uses.connection===s.connection))??!1}function Do(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 ln(e,t,s){if(s.type==="update"){const r=ln(e,t,{type:"rename",ref:s.ref,name:s.name}),i=s.name.trim(),a=ln(r.nodes,r.connections,{type:"replace",ref:i,connection:s.connection});return s.nodeIds?ln(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?Vt(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)?Vt(i,s.ref):i)}}}}function Et(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 qs(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 ni(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:qs(r.uses.app,t);return t={...t,[a]:{app:r.uses.app,connection:r.uses.connection}},s=!0,Vt(r,a)});return s?{...e,nodes:o,connections:t}:e}function Vt(e,t){const{connection:s,...o}=e.uses;return{...e,uses:{...o,connectionRef:t}}}function Fc(e,t,s,o){if(!t){const{connection:l,connectionRef:u,...c}=e.uses;return{step:{...e,uses:c},connections:o}}const r=e.uses.connectionRef,i=r&&s.some(l=>l.id!==e.id&&l.uses.connectionRef===r),a=r&&!i?r:qs(e.uses.app,o);return{step:Vt(e,a),connections:{...o,[a]:{app:e.uses.app,connection:t}}}}function cn(e,t,s,o){return t?s.filter(r=>r.uses.app===e&&Et(r,o)===t):[]}function si(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 u=Et(l,o);if(!(!u||!t.some(c=>c.id===u&&c.appId===e.uses.app)))return l.uses.connectionRef?{connectionRef:l.uses.connectionRef}:{connection:u}}for(const[l,u]of Object.entries(o))if(u.app===e.uses.app&&t.some(c=>c.appId===u.app&&c.id===u.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 Ho(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 Lc(e,t,s,o,r){const i=new Set(cn(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 oi=m.createContext(null);function Bs(){return m.useContext(oi)}function ri({step:e,conns:t,failed:s=!1,readOnly:o,open:r,onOpenChange:i,anchorRef:a,onChangeConnection:l,onChangeConnectionRef:u,onConnectionCreated:c}){var E,T,D;const d=Bs(),p=o||(d==null?void 0:d.readOnly),f=(d==null?void 0:d.connections)??{},h=(d==null?void 0:d.nodes)??[],b=(t??[]).map(I=>({conn:I,users:cn(e.uses.app,I.id,h,f)})).sort((I,R)=>+(R.users.length>0)-+(I.users.length>0)),w=Et(e,f)??(e.uses.connectionRef===void 0?(E=t==null?void 0:t.find(I=>I.builtIn&&I.appId===e.uses.app))==null?void 0:E.id:void 0),x=cn(e.uses.app,w,h,f).filter(I=>I.id!==e.id),[g,y]=m.useState(null),[k,A]=m.useState(!1),S=g||k?((D=(T=a.current)==null?void 0:T.closest("dialog"))==null?void 0:D.parentElement)??document.body:null,j=(I,R)=>{if(!p){if(R&&d&&w){d.setConnections(Lc(e.uses.app,w,I,h,f));const O=h.find(L=>L.id===e.id)??e;O.uses.connectionRef?u(O.uses.connectionRef):l(I)}else{const O=cn(e.uses.app,I,h,f).filter(H=>H.id!==e.id&&H.uses.connectionRef).at(-1),L=Object.entries(f).find(([,H])=>H.app===e.uses.app&&H.connection===I);O!=null&&O.uses.connectionRef?u(O.uses.connectionRef):L?u(L[0]):l(I)}y(null),i(!1)}},v=I=>{p||(i(!1),I!==w&&(x.length>0&&h.some(R=>R.id===e.id)?y(I):j(I,!1)))};return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"w6w-app-conn-btn","aria-label":"Connection","aria-expanded":r,disabled:p||t===null&&!s,onClick:()=>i(!r),children:n.jsx("span",{className:"w6w-conn-label-name",children:t===null&&!s&&!w?"Loading connections…":Do(w,t,s)})}),r&&n.jsx(ei,{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(f).some(([,I])=>I.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(f).filter(([,I])=>I.app===e.uses.app).map(([I,R])=>n.jsx("button",{type:"button",className:"w6w-stepbuilder-item",disabled:p||!R.connection||!(t!=null&&t.some(O=>O.id===R.connection)),"aria-pressed":e.uses.connectionRef===I,"data-connection-ref":I,onClick:()=>{u(I),i(!1)},children:n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:I}),n.jsx("span",{className:"w6w-muted w6w-small",children:Do(R.connection??void 0,t,s)})]})},I))})]}),n.jsx("div",{className:"w6w-stepbuilder-list",children:b.map(({conn:I,users:R})=>n.jsx("button",{type:"button",className:"w6w-stepbuilder-item",disabled:p,"aria-pressed":I.id===w,"data-connection-id":I.id,onClick:()=>v(I.id),children:n.jsxs("span",{className:"w6w-stepbuilder-item-main",children:[n.jsx("strong",{children:I.builtIn?"Built-in":I.displayName||I.id}),n.jsx("span",{className:"w6w-muted w6w-small",children:R.length>0?`In use in this workflow · ${R.map(O=>O.id).join(", ")}`:I.builtIn?"Built-in connection":I.state})]})},I.id))}),n.jsx("button",{type:"button",className:"w6w-btn",disabled:p,onClick:()=>{i(!1),A(!0)},children:"+ New connection"})]})}),k&&S&&pn.createPortal(n.jsx(Is,{initialAppId:e.uses.app,onClose:()=>A(!1),onCreated:({connectionId:I})=>{A(!1),c(),v(I)}}),S),g&&S&&pn.createPortal(n.jsxs(je,{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(I=>n.jsx("li",{children:I.id},I.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:p,onClick:()=>j(g,!0),children:["All ",x.length+1," nodes"]}),n.jsx("button",{type:"button",className:"w6w-btn",disabled:p,onClick:()=>j(g,!1),children:"Only this node"})]})]}),S)]})}function Mc(e,t){return`${e.method}-${e.url??e.host}-${t}`}function ii({calls:e,defaultOpen:t,keyOf:s,title:o}){if(e.length===0)return null;const r=s??Mc;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(Ne,{value:i.requestHeaders??{},maxHeight:240}),i.requestBody&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-muted w6w-small",children:"Request body"}),n.jsx(Ne,{value:i.requestBody,maxHeight:240})]}),n.jsx("div",{className:"w6w-muted w6w-small",children:"Response headers"}),n.jsx(Ne,{value:i.responseHeaders??{},maxHeight:240}),i.responseBody&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-muted w6w-small",children:"Response body"}),n.jsx(Ne,{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 ai({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(u=>u!==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 Rn({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 li(e,t,s,o){var u;if(e!=="io.w6w.eventbrite")return null;const r=t==null?void 0:t.find(c=>c.key==="activity"),i=(u=r==null?void 0:r.params)==null?void 0:u.find(c=>c.key==="actions"&&c.type==="multiselect");if(!r||!Array.isArray(i==null?void 0:i.options)||!i.options.length)return null;const a=i.options.map(c=>{var f;const d=String(c.value),p=d.replace(/[._]/g,"-");return{value:d,label:((f=t==null?void 0:t.find(h=>h.key===p))==null?void 0:f.title)??c.label,triggerKey:p}}),l=a.find(c=>c.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((c,d)=>c.label.localeCompare(d.label)),selected:l?[l.value]:Array.isArray(o.actions)?o.actions.filter(c=>typeof c=="string"):[]}}function Ce(e){var t;return((t=e==null?void 0:e.uses)==null?void 0:t.app)===Oe&&e.uses.action==="foreach"}function ci(e){var t;return((t=e==null?void 0:e.uses)==null?void 0:t.app)===Oe}function as(e){var t,s;return(e==null?void 0:e.uses.app)===We?!0:!ci(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 Us(e){if(!ci(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 Dc(e){const t=new Set;for(const s of e)for(const o of Us(s))t.add(o);return t}function un(e,t,s,o){return{id:ct(e,t,"each",o),source:e,target:t,sourceHandle:o!==void 0?At(o):s?gn:void 0,animated:!1,data:{when:"each",...o===void 0?{}:{route:o}},...Jt("each",void 0)}}const Vs=e=>{var t;return typeof((t=e.data)==null?void 0:t.route)=="string"?e.data.route:void 0};function Tn(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=[],u=[e];for(let b=0;b<u.length;b++)for(const w of i)w.source===u[b]&&(!r.has(w.target)||a.has(w.target)||o!=null&&o.has(w.target)||(a.add(w.target),l.push(w.target),u.push(w.target)));const c=new Map(l.map((b,w)=>[b,w])),d=i.filter(b=>b.source!==e&&c.has(b.source)&&c.has(b.target)),p=new Map(l.map(b=>[b,0]));for(const b of d)p.set(b.target,(p.get(b.target)??0)+1);const f=[],h=new Set;for(;;){const b=l.find(w=>!h.has(w)&&p.get(w)===0);if(b===void 0)break;h.add(b),f.push(b);for(const w of d)w.source===b&&p.set(w.target,(p.get(w.target)??0)-1)}for(const b of l)h.has(b)||f.push(b);return f}function ui(e,t){const s=new Set(e);return t.filter(o=>be(o)==="each"&&s.has(o.source)&&s.has(o.target))}function Hc(e,t){const s=ui(e,t),o=new Set;for(const r of s){if(Vs(r)!==void 0||o.has(r.source))return!1;o.add(r.source)}return!0}function Wc(e,t){const s=[];for(const o of In(e,t).values())if(!Hc(o,t))for(const r of ui(o,t)){const i=Vs(r);s.push({from:r.source,to:r.target,...i===void 0?{}:{route:i}})}return s}function In(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=Tn(i.id,e,t,o);for(const l of a)o.add(l);s.set(i.id,a)}return s}function He(e,t){const s={};for(const[o,r]of In(e,t))for(const i of r)s[i]=o;return s}function qc(e,t,s){const o=p=>p.source===e||p.target===e,r=s.filter(p=>!o(p));if(Ce((p=>{var f,h;return(h=(f=t.find(b=>b.id===p))==null?void 0:f.data)==null?void 0:h.step})(e))){const p=Tn(e,t,s),f=new Set(p);return r.filter(h=>!(be(h)==="each"&&(h.source===e||f.has(h.source))&&f.has(h.target)))}const a=He(t,s)[e];if(a===void 0)return r;const l=s.filter(p=>p.target===e&&be(p)==="each"),u=s.filter(p=>p.source===e&&be(p)==="each");if(l.length!==1||u.length!==1)return r;const c=l[0].source,d=u[0].target;return r.some(p=>p.source===c&&p.target===d&&be(p)==="each")?r:[...r,un(c,d,c===a,Vs(l[0]))]}function zs(e){if(!Ce(e)||!e.with||!("body"in e.with))return e;const{body:t,...s}=e.with;return{...e,with:s}}function di(e,t,s,o,r){const i=He(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=c=>{var d,p;return(p=(d=o.find(f=>f.id===c))==null?void 0:d.data)==null?void 0:p.step},l=Ce(a(e))?e:i[e];if(l===void 0)return null;if(t===l)return"loop_cycle";const u=()=>e!==l||!r.some(c=>c.source===e&&be(c)==="each");return i[t]===l?e===l||Bc(t,e,r)?"loop_cycle":u()?null:"body_branch":i[t]!==void 0?"already_in_loop":as(a(t))?u()?r.some(c=>c.source===t||c.target===t)?"body_exit":null:"body_branch":"control_in_body"}function Bc(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 Uc={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 Vc(e){return Uc[e]}function zc(e,t){const s=He(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,...u}=i.data;return{...i,data:u}}return{...i,data:{...i.data,loopOf:a}}});return o?r:e}function Jc(e,t,s){var a,l;const o=`Delete node "${e}"? Its connections are removed too.`,r=(l=(a=t.find(u=>u.id===e))==null?void 0:a.data)==null?void 0:l.step;if(!Ce(r))return o;const i=Tn(e,t,s);return i.length===0?o:`${o} Its loop body steps ${i.map(u=>`"${u}"`).join(", ")} stay as standalone steps.`}function Js(e){if(e.edges)return e.edges;const t=Dc(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 dn=e=>(e.when??"success")==="success",Ks=e=>e.route===Jo&&dn(e);function Gs(e){const t=new Map(e.nodes.map(u=>[u.id,u])),s=new Map;for(const u of e.nodes)for(const c of Us(u)){const d=s.get(c)??new Set;d.add(u.id),s.set(c,d)}const o=Js(e),r=e.edges??[],i={};for(const u of e.nodes){if(!Ce(u))continue;const c=u.with??{};if("body"in c){i[u.id]=a(u.id,c.body);continue}i[u.id]=l(u.id)}return i;function a(u,c){const d=(w,x)=>({invalid:x===void 0?{reason:w}:{reason:w,stepId:x}});if(!Array.isArray(c)||c.some(w=>typeof w!="string"))return d("body_not_literal");const p=c,f=new Set(p),h=new Set;for(const w of p){if(!t.has(w))return d("body_unknown_step",w);if(w===u)return d("body_self",w);if(h.has(w))return d("body_duplicate",w);if(h.add(w),!as(t.get(w)))return d("body_contains_control",w);const x=s.get(w);if(x&&[...x].some(g=>g!==u))return d("body_claimed_twice",w)}const b=[];for(const w of r){if(Ks(w)&&w.from===u&&w.to===p[0]||!(f.has(w.from)||f.has(w.to)))continue;if(!(f.has(w.from)&&f.has(w.to)&&dn(w)&&w.to!==p[0]))return d("body_step_has_edges",f.has(w.from)?w.from:w.to);b.push(w)}return b.length>0?{body:p,source:"body",edges:b}:{body:p,source:"body"}}function l(u){var w;const c=o.filter(x=>x.from===u&&dn(x)&&x.route===void 0);if(c.length===0)return{body:[],source:"body"};const d=x=>({invalid:{reason:"legacy_not_linear",stepId:x}});if(c.length>1)return d(u);const p=[],f=new Set([u]);let h=u,b=c[0].to;for(;b!==void 0;){const x=b,g=t.get(x);if(!g||f.has(x)||!as(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 k=o.filter(A=>A.from===x);if(k.length>1||k.length===1&&!dn(k[0]))return d(x);f.add(x),p.push(x),h=x,b=(w=k[0])==null?void 0:w.to}return{body:p,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 pi(e,t){var s;return((s=e.find(o=>o.id===t))==null?void 0:s.id)??null}function fi(e,t,s,o,r,i){var d,p;if(!e||!t||e===t||o.some(f=>{var h;return f.source===e&&f.target===t&&((h=f.data)==null?void 0:h.route)===i}))return!1;const a=(d=s.find(f=>f.id===e))==null?void 0:d.data.step,l=(p=s.find(f=>f.id===t))==null?void 0:p.data.step;if(!a||!l)return!1;const u=Ht(a,r),c=Ht(l,r);return u.out>=1&&c.in>=1}function Ys(e,t,s,o,r,i,a){var S,j,v;const l=r==="success"&&Ce((S=s.find(E=>E.id===e))==null?void 0:S.data.step),u=l&&a===void 0?jt:a;if(!fi(e,t,s,o,i,u)||!e||!t)return null;const c=(j=s.find(E=>E.id===e))==null?void 0:j.data.step,d=(v=s.find(E=>E.id===t))==null?void 0:v.data.step;if(!c||!d)return null;const p=gs(c);if(l){if(u!==jt)return null}else if(c.uses.app===We&&r==="success"){if(!bs(c).some(E=>E.id===u))return null}else if(p&&r==="success"){if(u!==void 0&&u!==fn)return null}else if(u!==void 0)return null;const f=He(s,o)[e]!==void 0,h=r==="success"&&f?"each":r;if(h==="each"&&!f&&!Ce(c))return null;const b=di(e,t,h,s,o);if(b)return{next:o,conflict:null,refusal:{refused:"loop",reason:b}};const w=Ht(c,i),x=o,g=x.filter(E=>{var T;return E.source===e&&be(E)===h&&((T=E.data)==null?void 0:T.route)===u}),y=u===void 0||p||l?w.out:1;if(g.length>=y)return{next:o,conflict:null,refusal:{refused:"out_cap",cap:y}};const k=ct(e,t,h,u),A=h==="each"&&f?void 0:fs(h);return{next:Vn.addEdge({source:e,target:t,id:k,sourceHandle:u===void 0?A:At(u),data:{when:h,...u===void 0?{}:{route:u}},...Jt(h,void 0)},x),conflict:pi(x,k),refusal:null}}function Kc(e,t,s,o,r="success",i,a){const l=Ys(e,t,s,o,r,i,a);return!l||l.conflict||l.refusal?null:l.next}function Gc(e,t,s,o,r="success",i,a){var l;return((l=Ys(e,t,s,o,r,i,a))==null?void 0:l.conflict)??null}function Yc(e,t,s,o,r="success",i,a){var l;return((l=Ys(e,t,s,o,r,i,a))==null?void 0:l.refusal)??null}function Xs(e,t,s,o,r){var y;const i=e.filter(k=>k.id===t);if(i.length!==1)return null;const a=i[0];if(be(a)==="each")return null;const l=(y=o.find(k=>k.id===a.source))==null?void 0:y.data.step;if(!l||l.uses.app===We||l.uses.app===Kt)return null;const u=Ht(l,r).out,c=e.filter(k=>k.id!==t);if((be(a)===s?[]:c.filter(k=>k.source===a.source&&be(k)===s)).length>=u)return{next:e,conflict:null,refusal:{refused:"out_cap",cap:u}};const p=Jt(s,void 0),f=Ce(l),h=f&&s==="success"?jt:void 0,{route:b,...w}=a.data??{},x={...a,id:ct(a.source,a.target,s,h),data:f?{...w,when:s,...h?{route:h}:{}}:{...a.data,when:s},className:p.className,label:p.label,sourceHandle:h?At(h):fs(s)},g=pi(c,x.id);return{next:e.map(k=>k.id===t?x:k),conflict:g,refusal:null}}function Xc(e,t,s,o,r){const i=Xs(e,t,s,o,r);return!i||i.conflict||i.refusal?null:i.next}function Zc(e,t,s,o,r){var i;return((i=Xs(e,t,s,o,r))==null?void 0:i.conflict)??null}function Qc(e,t,s,o,r){var i;return((i=Xs(e,t,s,o,r))==null?void 0:i.refusal)??null}function eu(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:ct(r,i,be(o),typeof((a=o.data)==null?void 0:a.route)=="string"?o.data.route:void 0)}})}function ct(e,t,s,o){const r=s==="error"?`${e}->${t}:error`:`${e}->${t}`;return o===void 0?r:`${r}:route:${encodeURIComponent(o)}`}function tu(e){return e.includes(".")?"A step id can't contain a dot (.).":null}function hi(e,t){const s=tu(e);if(s)return s;for(const o of t)if(o===e)return`A step named "${e}" already exists.`;return null}function nu(e,t,s){const o=(p,f)=>!p||!f?void 0:ct(p,f)===t?"success":ct(p,f,"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,u=r==="success"?s[1]:s[3],c=a?s.find(p=>!!p&&p.includes("->")):l&&(u!=null&&u.endsWith(":error"))?u:void 0,d=c===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 “${c}”, 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 “${c}”, then try again.`;return`${e}: the id “${t}” is already taken by another edge. ${d}`}const su=240,ou=100,ru=40,iu=40;function Zs(e,t){return{x:ru+e*su,y:iu+t*ou}}function au(e,t){var l;const s=new Map,o=new Map;for(const u of e)s.set(u.id,0),o.set(u.id,[]);for(const u of t)(l=o.get(u.to))==null||l.push(u.from);const r=e.length+1;let i=0,a=!0;for(;a&&i<r;){i++,a=!1;for(const u of e){const c=o.get(u.id)??[];if(c.length===0)continue;const d=c.reduce((p,f)=>Math.max(p,(s.get(f)??0)+1),0);(s.get(u.id)??0)<d&&(s.set(u.id,d),a=!0)}}if(a){const u=Math.max(0,e.length-1);for(const[c,d]of s)d>u&&s.set(c,u)}return s}function wi(e,t){var u;const s=au(e,t),o=new Map(e.map((c,d)=>[c.id,d])),r=new Map;for(const{from:c,to:d}of t){const p=s.get(c),f=s.get(d);if(p===void 0||f===void 0||p>=f)continue;const h=r.get(d);(h===void 0||p<(s.get(h)??0)||p===s.get(h)&&(o.get(c)??0)<(o.get(h)??0))&&r.set(d,c)}const i=new Map(e.map(c=>[c.id,[]]));for(const[c,d]of r)(u=i.get(d))==null||u.push(c);for(const c of i.values())c.sort((d,p)=>(s.get(p)??0)-(s.get(d)??0)||(o.get(d)??0)-(o.get(p)??0));const a=new Map;let l=0;for(const c of e.filter(d=>!r.has(d.id))){const d=[c.id];for(;d.length;){const p=d.pop();if(p===void 0)continue;a.set(p,Zs(s.get(p)??0,l));const f=i.get(p)??[];if(f.length===0)l++;else for(let h=f.length-1;h>=0;h--)d.push(f[h])}}return a}function lu(e){const t=e.position;if(!(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y)))return{x:t.x,y:t.y}}function Qs(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 cu(e){const t=Qs(e),s=t.nodes;let o=Js(t);const r=[],i=new Map,a=new Set,l=new Set;for(const[h,b]of Object.entries(Gs(t))){if("invalid"in b)continue;let w=h;if(b.edges&&b.body.length>0){r.push(un(h,b.body[0],!0));for(const x of b.edges)l.add(x),r.push(un(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===w&&y.to===x&&(y.when??"success")==="success");g&&l.add(g)}r.push(un(w,x,w===h)),i.set(x,h),w=x}b.source==="legacy"&&a.add(h)}const u=new Set(s.filter(Ce).map(h=>h.id));for(const h of o)u.has(h.from)&&Ks(h)&&l.add(h);l.size>0&&(o=o.filter(h=>!l.has(h)));const c=wi(s,[...o,...r.map(h=>({from:h.source,to:h.target}))]),d=s.map(h=>{const b=Ge(h.uses.app);return{id:h.id,type:b?"control":"step",position:lu(h)??c.get(h.id)??Zs(0,0),data:{step:h,isInternal:b,...i.has(h.id)?{loopOf:i.get(h.id)}:{},...a.has(h.id)?{legacyLoop:!0}:{}}}}),p=new Set(s.filter(gs).map(h=>h.id)),f=o.map(h=>{const b=h.when==="error"&&h.route===void 0&&p.has(h.from)?{from:h.from,to:h.to,route:fn}:u.has(h.from)&&h.route===void 0&&h.when!=="error"?{...h,route:jt}:h,w=b.when??"success";return{id:ct(b.from,b.to,w,b.route),source:b.from,target:b.to,sourceHandle:b.route===void 0?fs(w):`route:${b.route}`,animated:!1,data:{when:w,...b.route===void 0?{}:{route:b.route}},...Jt(w,void 0)}});return{nodes:d,edges:[...f,...r]}}function uu(e,t){const s=e.map(r=>({...r.data.step,id:r.id})),o=wi(s,t.map(r=>({from:r.source,to:r.target})));return e.map(r=>({...r,position:o.get(r.id)??Zs(0,0)}))}function du(e,t,s){var S,j;const o=Qs(e),r=((S=o.settings)==null?void 0:S.savePosition)!==!1,i=new Map(t.map(v=>[v.id,v])),a=v=>{var T;if(!r)return v;const E=(T=i.get(v.id))==null?void 0:T.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)(j=v.data)!=null&&j.step&&l.set(v.id,v.data.step);const u=In(t,s),c=Gs(o),d=new Map(o.nodes.map(v=>[v.id,v])),p=new Set;for(const v of s)be(v)==="success"&&p.add(v.source);const f=v=>{if(!Ce(v))return v;const E=u.get(v.id)??[],T=d.get(v.id),D=c[v.id];let I;E.length>0?I={value:E}:D&&"invalid"in D&&D.invalid.reason!=="legacy_not_linear"?I=T!=null&&T.with&&"body"in T.with?{value:T.with.body}:null:D&&"invalid"in D?I=null:p.has(v.id)||T!=null&&T.with&&"body"in T.with?I={value:[]}:I=null;const R=v.with??{};return I===null?"body"in R?zs(v):v:{...v,with:{...R,body:I.value}}},h=v=>a(f(v)),b=[],w=new Set;for(const v of o.nodes){const E=l.get(v.id);E&&t.some(T=>T.id===v.id)&&(b.push(h(E)),w.add(v.id))}for(const v of t){if(w.has(v.id))continue;const E=l.get(v.id);E&&b.push(h(E))}const x=new Set;for(const v of u.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 T;const E=typeof((T=v.data)==null?void 0:T.route)=="string"?v.data.route:g.has(v.source)&&be(v)==="success"?jt:void 0;return{from:v.source,to:v.target,...be(v)==="error"?{when:"error"}:{},...E===void 0?{}:{route:E}}}),k=[];for(const[v,E]of u)E.length>0&&k.push({from:v,to:E[0],route:Jo});const A=[...y,...k,...Wc(t,s)];return ni({...o,nodes:b,edges:A})}function mi(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 pu(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=mi(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 fu(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"step"}function hu(e,t){const s=new Set(t.map(o=>o.target));return e.find(o=>!s.has(o.id))}function wu(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 mu(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 eo(e){return JSON.stringify(zs(e),null,2)}const bu=3,gu=100;function ut(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bi(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(!ut(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(!ut(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 yu(e,t){var o;if(!Array.isArray(e))return;const s=e.find(r=>ut(r)&&r.key===t);if(!(!ut(s)||!Array.isArray(s.items)))return(o=bi([{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 it(e){if(!ut(e))return;const t=[],s=(o,r,i)=>{for(const[a,l]of Object.entries(o)){if(t.length>=gu)return;const u=r?`${r}.${a}`:a;t.push({key:u,path:!0}),ut(l)&&i<bu&&s(l,u,i+1)}};return s(e,"",1),t.length>0?t:void 0}function Ft(e,t){let s=e;for(const o of t.split(".")){if(!ut(s)||!(o in s))return;s=s[o]}return s}function xt(e,t,s){const o=bi(e==null?void 0:e.output),r=it(t),i=r??it(s);if(i){const l=new Map((o??[]).map(d=>[d.key,d])),u=new Set(i.map(d=>d.key)),c=i.map(d=>{const p=l.get(d.key);return p!=null&&p.label?{...d,label:p.label}:d});for(const d of o??[])u.has(d.key)||c.push({...d,declaredOnly:!0});return{fields:c,from:r?"fresh":"persisted"}}if(o)return{fields:o,from:"declared"};const a=it(e==null?void 0:e.sample);if(a)return{fields:a,from:"sample"}}function to(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 gi(e,t,s={}){var a,l,u,c,d,p,f;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 w=((a=at(b.uses.app,b.uses.action))==null?void 0:a.group)==="trigger",x=(l=s.testOutputs)==null?void 0:l[b.id],g=(u=s.persistedOutputs)==null?void 0:u[b.id];if(b.uses.trigger===!0){r=!0;const E=xt((c=s.triggerDef)==null?void 0:c.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}}w&&(r=!0);const y=w&&b.uses.app===Ct,k=y?Hs(Ls((d=b.with)==null?void 0:d.fields)).map(E=>({key:E.key,label:E.label})):((p=at(b.uses.app,b.uses.action))==null?void 0:p.output)??[],A={id:b.id,label:b.id};if(k.length>0){o.push({...A,outputs:k});continue}if(w){const E=xt(void 0,x,g);E&&!y&&(i??(i=E)),o.push(E?{...A,outputs:E.fields,outputsFrom:E.from}:A);continue}if(Ge(b.uses.app)){const E=xt(void 0,x,g);o.push(E?{...A,outputs:E.fields,outputsFrom:E.from}:A);continue}const S=(f=s.actionDef)==null?void 0:f.call(s,b.uses.app,b.uses.action),j=xt(S,x,g),v=b.uses.app.trim()!==""?{hasMeta:!0}:{};j?o.push({...A,outputs:j.fields,outputsFrom:j.from,...v}):o.push(S?{...A,needsTest:!0,...v}:{...A,...v})}return{steps:o,hasTrigger:r,...i?{eventOutputs:i.fields,eventOutputsFrom:i.from}:{}}}function xu(e,t){const s={};for(const[o,r]of Object.entries(t))s[o]={output:r};return yi(e,{steps:s})}function yi(e,t){if(et(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 vu=10;function ju(e,t){return{input:t,with:{items:e.slice(0,vu),itemCount:e.length}}}function Nu(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 xi(e,t,s,o,r={}){const i=He(s,o),a=new Set;for(const p of e){if(p===t)continue;const f=i[p];f!==void 0&&f!==t||a.add(p)}const l=gi(a,s,r),u=In(s,o),c=[];return{steps:l.steps.map(p=>{var y,k,A;const f=u.get(p.id);if(!f||f.length===0)return p;const h=f[f.length-1],b=(y=s.find(S=>S.id===h))==null?void 0:y.data.step,w=r.testOutputs??{},x=b?xt((k=r.actionDef)==null?void 0:k.call(r,b.uses.app,b.uses.action),w[h],(A=r.persistedOutputs)==null?void 0:A[h]):void 0;c.includes(h)||c.push(h);const g=((x==null?void 0:x.fields)??[]).map(S=>({key:`items.0.${S.key}`,path:!0,...S.declaredOnly?{declaredOnly:!0}:{}}));return{id:p.id,label:p.label,outputs:[{key:"items",path:!0},...g],...x?{outputsFrom:x.from}:{}}}),hasTrigger:l.hasTrigger,extraSampleIds:c,...l.eventOutputs?{eventOutputs:l.eventOutputs,eventOutputsFrom:l.eventOutputsFrom}:{}}}function ku(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 Su(e,t,s){var p,f;const o=et(e),r=o?ku(o):void 0,i=r?(p=t.find(h=>h.id===r.id))==null?void 0:p.data.step:void 0;if(!r||!i)return;const a=(f=s.actionDef)==null?void 0:f.call(s,i.uses.app,i.uses.action),l=Ft(a==null?void 0:a.sample,r.path),u=Array.isArray(l)&&l.length>0?l[0]:void 0,d=yu(a==null?void 0:a.output,r.path)??it(u);if(!(u===void 0&&!d))return{...u!==void 0?{itemSample:u}:{},...d?{itemOutputs:d}:{}}}function vi(e,t,s={}){var c,d,p;const o={foreachId:e},r=(d=(c=t.find(f=>f.id===e))==null?void 0:c.data.step.with)==null?void 0:d.items,i={...s.persistedOutputs??{},...s.testOutputs??{}},a=xu(r,i),l=a&&a.length>0?a:(p=s.loopSamples)==null?void 0:p[e];if(l&&l.length>0){o.itemSample=l[0];const f=it(l[0]);return f&&(o.itemOutputs=f),o}const u=Su(r,t,s);return(u==null?void 0:u.itemSample)!==void 0&&(o.itemSample=u.itemSample),u!=null&&u.itemOutputs&&(o.itemOutputs=u.itemOutputs),o}function Cu(e,t,s,o,r){let i=e;if(!i&&r&&(s.some(u=>u.target===r)||He(t,s)[r]!==void 0)&&(i=r),!i)return gi(new Set(t.map(u=>u.id)),t,o);const a=He(t,s)[i],l=xi(to(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:vi(a,t,o)}:{},...l.extraSampleIds.length>0?{extraSampleIds:l.extraSampleIds}:{}}}function Au(e,t,s,o){if(!e||e.handleType==="target")return[];const r=to(e.nodeId,s);r.add(e.nodeId);const i=ji(e,t,s);return xi(r,i,t,s,o).steps}function ji(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:He(t,s)[e.nodeId]}function Eu(e,t,s,o){if(!e||e.handleType==="target")return;const r=ji(e,t,s);return r?vi(r,t,o):void 0}async function Ru(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 no(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 Ni(e){if(e)return{..."itemSample"in e?{item:e.itemSample}:{},index:0}}function Tu(e){return!e||!("itemSample"in e)?"":JSON.stringify(e.itemSample,null,2)??""}function Iu(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 Ou(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 $u(e,t,s,o,r){return ki(e,t,s,o,r).values}function Pu(e,t,s,o,r){return ki(e,t,s,o,r).sources}function _u(e,t){var r,i,a,l;const s={};let o;for(const u of e){const c=u.data.step.uses;if(c.trigger===!0){const p=(i=(r=t.triggerDef)==null?void 0:r.call(t,c.app,c.action))==null?void 0:i.sample;o===void 0&&p!==void 0&&(o=p);continue}if(Ge(c.app))continue;const d=(l=(a=t.actionDef)==null?void 0:a.call(t,c.app,c.action))==null?void 0:l.sample;d!==void 0&&(s[u.id]=d)}return{samples:s,...o!==void 0?{event:o}:{}}}function ki(e,t,s,o,r={}){var l,u;const i={},a={};for(const c of e){Object.assign(i,Ou(c.id,s[c.id]));const d=[["sample",(l=r.samples)==null?void 0:l[c.id]],["persisted",(u=r.persisted)==null?void 0:u[c.id]],["fresh",t[c.id]]];for(const[p,f]of d){if(f===void 0)continue;const h=(b,w)=>{for(const x of["nodes","steps"])i[`${x}.${b}`]=w,a[`${x}.${b}`]=p};if(h(`${c.id}.output`,f),typeof f=="object"&&f!==null&&!Array.isArray(f))for(const[b,w]of Object.entries(f))h(`${c.id}.output.${b}`,w);for(const b of c.outputs??[]){if(!b.path||!b.key.includes("."))continue;const w=Ft(f,b.key);w!==void 0&&h(`${c.id}.output.${b.key}`,w)}}}if(r.event!==void 0){const c=(d,p)=>{i[d]=p,a[d]="sample"};if(c("trigger.event",r.event),typeof r.event=="object"&&r.event!==null&&!Array.isArray(r.event))for(const[d,p]of Object.entries(r.event))c(`trigger.event.${d}`,p);for(const d of it(r.event)??[]){const p=Ft(r.event,d.key);p!==void 0&&c(`trigger.event.${d.key}`,p)}}if(o&&"itemSample"in o){i["foreach.item"]=o.itemSample;for(const c of o.itemOutputs??[]){const d=Ft(o.itemSample,c.key);d!==void 0&&(i[`foreach.item.${c.key}`]=d)}i["foreach.index"]=0}return{values:i,sources:a}}function Fu(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 Lu(e){const t=[];for(const s of e){const o=s.data.step,r=Object.entries(o.with??{}).filter(([,a])=>a!==void 0&&!Fu(a)).map(([a])=>a);(o.uses.app===Fe||o.uses.trigger===!0)&&!r.includes("url")&&r.unshift("url"),r.length>0&&t.push({id:o.id,keys:r})}return t}function ls(e){if(!(qe(e)||Qe(e))){if(Array.isArray(e))return e.map(ls).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=ls(i);a!==void 0&&(o[r]=a)}return o}return e}}function Mu(e,t){const s={};for(const o of e){const r=o.data.step,i={...ls(r.with??{})??{}},a=Si(r,t);a!=null&&a.webhookUrl&&(i.url=a.webhookUrl),Object.keys(i).length>0&&(s[r.id]=i)}return s}function Si(e,t){if(!(e.uses.app!==Fe&&e.uses.trigger!==!0))return t.find(s=>s.nodeId===e.id)??(e.uses.app===Fe?t.find(s=>s.appId===Fe):void 0)}function Du(e,t,s,o){var i;const r={};for(const a of e){const l=a.data.step;if(!l.uses.app)continue;const u={app:l.uses.app,action:l.uses.action,connectionId:Et(l,o)??null},c=(i=s==null?void 0:s.get(l.uses.app))==null?void 0:i.version;c&&(u.version=c);const d=Si(l,t);d&&(u.subscriptionId=d.id),d!=null&&d.webhookUrl&&(u.url=d.webhookUrl),r[l.id]=u}return r}function Hu(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 so(e,t,s){const o=xe(),[r,i]=m.useState([]),a=JSON.stringify(t.map(l=>[l.id,l.label]));return m.useEffect(()=>{const l=JSON.parse(a);if(!s||l.length===0){i([]);return}let u=!1;return Ru(c=>o.listStepTests(e,c),l.map(([c,d])=>({id:c,label:d}))).then(c=>{u||i(c)}),()=>{u=!0}},[o,e,a,s]),r}function Ci(e){return(e.nodes??e.steps??[]).filter(t=>t.uses.app===Ct&&t.uses.action==="manual")}function Wu(e,t){var i;const s=Ci(e),o=t?s.find(a=>a.id===t):s[0],r=(i=o==null?void 0:o.with)==null?void 0:i.fields;return Array.isArray(r)?r.flatMap(a=>!a||typeof a!="object"||typeof a.key!="string"||!a.key.trim()?[]:[{key:a.key,label:a.key,type:Ms(a.type),default:Ds(a.type,a.default),required:!!a.required}]):[]}const qu=["function","workflow"],Bu={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"/>'},qn={props:{label:"Form",icon:"form"},code:{label:"JSON",icon:"code"},"params-code":{label:"Params JSON",icon:"braces"},config:{label:"Node settings",icon:"settings-2"}},Uu=["props","code","params-code","config"];function On({view:e,onChange:t,disabled:s,views:o=Uu,customized:r=!1}){const i=a=>n.jsx("button",{type:"button",title:qn[a].label,"aria-label":qn[a].label,"aria-pressed":e===a,disabled:s,className:`w6w-icon-btn${e===a&&!s?" active":""}`,onClick:()=>t(a),children:n.jsx(le.Icon,{name:qn[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 Vu({onClose:e,onAdd:t,onDraftChange:s,theme:o,appsOnly:r,callables:i=qu,initialTab:a,title:l,workflowId:u,stepId:c,upstreamSteps:d=[],loop:p,initialApp:f,initialAction:h,initialConnection:b,initialWith:w,appsFilter:x,appsIds:g,connectionOnly:y,onConnected:k,excludeCallableIds:A,onOpenStep:S,stepIds:j=[]}){const[v,E]=m.useState(null),[T,D]=m.useState(null),I=m.useRef(null),R=_=>{const W=t(_);return typeof W=="string"&&(I.current=_,E(W),D(null)),W},O=s?(_,W)=>{I.current=W,s(_,W)}:void 0,L=()=>{v&&T&&T!==v&&O&&I.current&&O(v,{...I.current,id:T}),e()},H=_=>v&&s?n.jsxs("span",{className:"w6w-stepbuilder-title",children:[_,n.jsx(Pr,{value:T??v,onCommit:W=>{const ue=hi(W,j.filter(pe=>pe!==v));return ue||D(W),ue}})]}):_,[B,z]=m.useState(a??"connected"),[P,$]=m.useState(""),[Z,Q]=m.useState(f??null),[ee,F]=m.useState(null),[X,Y]=m.useState(null),[U,G]=m.useState(null),te=!!g&&g.length>0,C=Ti(i,x,A,g),V=C.state!=="empty";if(m.useEffect(()=>{!V&&B==="connected"&&z("apps")},[V,B]),U)return n.jsx(je,{title:H(U.label),ariaLabel:U.label,subtitle:n.jsx("code",{children:U.id}),onClose:e,size:"xl",headerRight:n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>G(null),children:"← Back"}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:n.jsx(Xu,{family:U.family,targetId:U.id,targetLabel:U.label,onAdd:R,onClose:e,onDone:L,onDraftChange:O})})});if(ee)return n.jsx(je,{title:H(ee.groupActions?ee.displayName:ee.label),ariaLabel:ee.groupActions?ee.displayName:ee.label,titleIcon:n.jsx(Rn,{icon:ee.icon,size:22}),subtitle:n.jsxs("code",{children:[ee.app,!ee.groupActions&&` · ${ee.action}`]}),onClose:e,size:"xl",headerRight:n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost",onClick:()=>F(null),children:"← Back"}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:n.jsx(Yu,{node:ee,onAdd:R,onClose:e,onDone:L,onDraftChange:O,onOpenStep:S,workflowId:u,upstreamSteps:d,loop:p})})});const J=X??Z;if(J){const _=X?"trigger":"action",W=()=>{Q(null),Y(null)};return n.jsx(je,{title:H(J.displayName),ariaLabel:J.displayName,subtitle:n.jsxs(n.Fragment,{children:[n.jsx("code",{children:J.id}),J.version&&` · v${J.version}`]}),onClose:e,size:"xl",titleIcon:n.jsx(pt,{src:J.iconSvg,srcDark:J.iconSvgDark,brandColor:J.brandColor,name:J.displayName,theme:o,size:22}),children:n.jsx("div",{className:"w6w-stepbuilder-config",children:y&&_==="action"?n.jsx(id,{appId:J.id,app:J,onClose:e,onChangeApp:W,theme:o,initialConnection:b,onConnected:(ue,pe)=>k==null?void 0:k(ue,pe)}):n.jsx(rd,{kind:_,onOpenStep:S,appId:J.id,app:J,onAdd:R,onClose:e,onDone:L,onDraftChange:O,onChangeApp:W,theme:o,workflowId:u,stepId:c,upstreamSteps:d,loop:p,..._==="action"?{initialAction:h,initialConnection:b,initialWith:w}:{}})})})}return n.jsx(je,{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:P,onChange:_=>$(_.target.value)}),n.jsxs("div",{className:"w6w-stepbuilder",children:[n.jsxs("nav",{className:"w6w-stepbuilder-sidebar",children:[V&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${B==="connected"?" active":""}`,onClick:()=>z("connected"),children:"Ready to use"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${B==="apps"?" active":""}`,onClick:()=>z("apps"),children:"Apps"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${B==="ai"?" active":""}`,onClick:()=>z("ai"),children:"AI"}),i.includes("workflow")&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${B==="workflows"?" active":""}`,onClick:()=>z("workflows"),children:"Workflows"}),i.includes("function")&&n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${B==="functions"?" active":""}`,onClick:()=>z("functions"),children:"Functions"}),!r&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${B==="triggers"?" active":""}`,onClick:()=>z("triggers"),children:"Triggers"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${B==="controls"?" active":""}`,onClick:()=>z("controls"),children:"Controls"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${B==="utilities"?" active":""}`,onClick:()=>z("utilities"),children:"Utilities"}),n.jsx("button",{type:"button",className:`w6w-stepbuilder-tab${B==="data"?" active":""}`,onClick:()=>z("data"),children:"Data"})]})]}),n.jsx("div",{className:"w6w-stepbuilder-content",children:B==="connected"?n.jsx(od,{data:C,query:P,appsFilter:x,onSelectApp:Q,onSelectCallable:G,theme:o}):B==="functions"?n.jsx(Wo,{family:"function",query:P,excludeIds:A,onSelect:_=>G({family:"function",..._})}):B==="workflows"?n.jsx(Wo,{family:"workflow",query:P,excludeIds:A,onSelect:_=>G({family:"workflow",..._})}):B==="apps"?n.jsx(lt,{search:!1,searchValue:P,onSelectApp:Q,theme:o,filter:x,ids:g}):B==="ai"?n.jsx(lt,{search:!1,searchValue:P,onSelectApp:Q,theme:o,category:te?void 0:"ai",ids:g,filter:_=>{var W;return((x==null?void 0:x(_))??!0)&&(te||(((W=_.categories)==null?void 0:W.includes("ai"))??!1))},emptyMessage:"No AI apps registered yet."}):B==="triggers"?n.jsx(zu,{query:P,onSelect:F,onSelectApp:Y,theme:o,appsFilter:x,appsIds:g}):B==="controls"?n.jsx(Ju,{query:P,onSelect:F}):B==="data"?n.jsx(Gu,{query:P,onSelect:F}):n.jsx(Ku,{query:P,onSelect:F})})]})]})})}function Lt(e,...t){const s=t.filter(Boolean).join(" ").toLowerCase();return e.trim().toLowerCase().split(/\s+/).every(o=>s.includes(o))}function Ai(e,t){return Lt(t,e.label,e.displayName,e.app,e.action)}function oo({nodes:e,onSelect:t,query:s}){const o=new Set,r=e.filter(i=>Ai(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(Ei,{node:i,onSelect:t},`${i.app}:${i.action}`))}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["No nodes match “",s,"”."]})}function Ei({node:e,onSelect:t}){return n.jsxs("button",{type:"button",className:"w6w-stepbuilder-item",onClick:()=>t(e),children:[n.jsx(Rn,{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 zu({query:e,onSelect:t,onSelectApp:s,theme:o,appsFilter:r,appsIds:i}){var b;const a=xe(),l=dt.filter(w=>w.group==="trigger"&&Ai(w,e)),[u,c]=m.useState(!1),d=Ti([],r,void 0,i,{resolveInline:!0});if(u)return n.jsxs("div",{className:"w6w-stack",children:[n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>c(!1),children:"← Back"}),n.jsx(lt,{onSelectApp:s,theme:o,filter:r,ids:i?[...i]:void 0,hasTriggers:!0,search:!1,searchValue:e,emptyMessage:"No apps declare triggers yet."})]});const f=d.apps.filter(w=>(w.triggerCount??0)>0&&Lt(e,w.displayName,w.id)).sort(Mt(w=>w.displayName)).map(w=>n.jsx(Ii,{app:w,theme:o,onSelect:s},w.id));d.moreApps&&f.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(lt,{search:!1,searchValue:e,ids:d.appIds,hasTriggers:!0,filter:r,onSelectApp:s,theme:o}):f.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:()=>c(!0),children:"Search all apps"})]}):h=n.jsx("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:f}),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(w=>n.jsx(Ei,{node:w,onSelect:t},`${w.app}:${w.action}`))]})]})})]}),n.jsx("div",{className:"w6w-readytouse-footer",children:n.jsx("button",{type:"button",className:"w6w-btn",onClick:()=>c(!0),children:"Search all apps"})})]})}function Ju({onSelect:e,query:t}){const s=dt.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(oo,{nodes:s,onSelect:e,query:t})]})}function Ku({onSelect:e,query:t}){const s=dt.filter(o=>o.group!=="control"&&o.group!=="trigger"&&o.app!==Dt&&o.app!==ws&&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(oo,{nodes:s,onSelect:e,query:t})]})}function Gu({onSelect:e,query:t}){const s=dt.filter(o=>(o.app===Dt||o.app===De||o.app===ws)&&!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(oo,{nodes:s,onSelect:e,query:t})]})}function Yu({node:e,onAdd:t,onClose:s,onDone:o,onDraftChange:r,onOpenStep:i,workflowId:a,upstreamSteps:l=[],loop:u}){const[c,d]=m.useState(e),p=e.groupActions?dt.filter(H=>H.app===e.app&&!H.hidden):[],[f,h]=m.useState(()=>wn(c.app,c.action)),b=!It(c.app),w=so(a??"",l,b&&!!a),x=no(w,Ni(u)),[g,y]=m.useState("configure"),[k,A]=m.useState("props"),[S,j]=m.useState("{}"),[v,E]=m.useState({}),T=St(c.params,f),[D,I]=m.useState(null),R=()=>({uses:{app:c.app,action:c.action},with:f,...v});m.useEffect(()=>{if(!r)return;const H=t(R());H&&I(H),H&&c.app===Fe&&(i==null||i(H))},[]),m.useEffect(()=>{!r||D===null||r(D,R())},[D,f,v,c]);const O=H=>{H==="code"&&j(eo(R())),A(H)},L=()=>t(R());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:!T,title:T?void 0:"Fill the required fields first",className:`w6w-subtab${g==="test"?" active":""}`,onClick:()=>T&&y("test"),children:"Test"})]}),n.jsx(On,{view:k,customized:En(f),onChange:O,disabled:g!=="configure"})]}),n.jsxs("div",{className:"w6w-stepconfig-body",children:[g==="configure"&&k==="props"&&p.length>1&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Action"}),n.jsx("select",{className:"w6w-input","aria-label":"Action",value:c.action,onChange:H=>{const B=p.find(P=>P.action===H.target.value);if(!B)return;const z=wn(B.app,B.action);h(Object.fromEntries(B.params.flatMap(P=>P.key in f?[[P.key,f[P.key]]]:P.key in z?[[P.key,z[P.key]]]:[]))),d(B)},children:p.map(H=>n.jsx("option",{value:H.action,children:H.label},H.action))})]}),g==="configure"&&(k==="props"?c.app===Kt?n.jsx("p",{className:"w6w-muted w6w-small",children:Go}):c.action==="wait"&&It(c.app)?n.jsx(Qr,{values:f,onChange:h}):c.action==="if"&&It(c.app)?n.jsx(An,{values:f,onChange:h}):c.app===ms?n.jsx(_r,{values:f,onChange:h}):c.app===We?n.jsx($r,{values:f,onChange:h}):n.jsx(Pe,{params:c.params,values:f,onChange:h}):k==="code"?n.jsx(Ye,{value:S,onChange:()=>{},readOnly:!0,minHeight:"240px",height:"100%","aria-label":"Node JSON",copyable:!0}):k==="params-code"?n.jsx(_s,{values:f,onChange:h}):n.jsx(Ps,{config:v,onChange:E,failureHandling:!hn(c.app),retryControls:!It(c.app)&&c.app!==yn})),g==="test"&&b&&(hn(c.app)?n.jsx(Zr,{app:c.app,action:c.action,fields:f.fields}):n.jsx(ro,{app:c.app,action:c.action,values:f,canRun:T,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:!T,onClick:()=>y("test"),children:"Next →"}):n.jsx("button",{type:"button",className:"w6w-btn",onClick:D!==null?o??s:L,children:D!==null?"Done":"Add node"})]})]})}function Wo({family:e,query:t,excludeIds:s,onSelect:o}){const r=xe(),[i,a]=m.useState(null),[l,u]=m.useState(null),c=e==="function"?"Functions":"Workflows";m.useEffect(()=>{let w=!1;return(e==="function"?r.listFunctions():r.listWorkflows()).then(g=>!w&&a(g)).catch(g=>!w&&u(g.message)),()=>{w=!0}},[r,e]);const d=w=>n.jsx("div",{className:"w6w-apppicker-host",children:w});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 ",c.toLowerCase(),"…"]}));if(i.length===0)return d(n.jsxs("p",{className:"w6w-muted w6w-small",children:["No ",c.toLowerCase()," registered yet."]}));const p=vt,f=t.trim().toLowerCase(),h=cs(i,s).sort(Mt(p)),b=f?h.filter(w=>p(w).toLowerCase().includes(f)||w.id.toLowerCase().includes(f)):h;return d(n.jsx("div",{className:"w6w-stepbuilder-apps",children:b.length===0?n.jsxs("p",{className:"w6w-muted w6w-small",children:["No ",c.toLowerCase()," match “",t,"”."]}):n.jsx("div",{className:"w6w-stepbuilder-list w6w-stepbuilder-scroll",children:b.map(w=>n.jsx(us,{family:e,item:w,onSelect:o},w.id))})}))}function Xu({family:e,targetId:t,targetLabel:s,onAdd:o,onClose:r,onDone:i,onDraftChange:a}){const[l,u]=m.useState({targetKind:e,targetId:t,inputs:{},wait:!0}),[c,d]=m.useState(!1),[p,f]=m.useState("configure"),[h,b]=m.useState(null),w=()=>({uses:{app:yn,action:"call"},with:l});m.useEffect(()=>{if(!a)return;const g=o(w());g&&b(g)},[]),m.useEffect(()=>{!a||h===null||a(h,w())},[h,l]);const x=()=>o(w());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${p==="configure"?" active":""}`,onClick:()=>f("configure"),children:"Configure"}),n.jsx("button",{type:"button",disabled:!c,title:c?void 0:"Fill the required fields first",className:`w6w-subtab${p==="test"?" active":""}`,onClick:()=>c&&f("test"),children:"Test"})]})}),n.jsx("div",{className:"w6w-stepconfig-body",children:p==="configure"?n.jsx(Pi,{fixedTarget:!0,values:l,onChange:u,onValidityChange:d,targetLabel:s}):n.jsx(Zu,{family:l.targetKind==="function"?"function":"workflow",targetId:String(l.targetId),inputs:l.inputs,entry:typeof l.entry=="string"?l.entry:void 0,canRun:c})}),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"}),p==="configure"?n.jsx("button",{type:"button",className:"w6w-btn",disabled:!c,onClick:()=>f("test"),children:"Next →"}):n.jsx("button",{type:"button",className:"w6w-btn",onClick:h!==null?i??r:x,children:h!==null?"Done":"Add node"})]})]})}function Zu({family:e,targetId:t,inputs:s,entry:o,canRun:r}){const i=xe(),[a,l]=m.useState(null),u=async()=>{if(!(!r||(a==null?void 0:a.status)==="running")){l({status:"running"});try{if(e==="function"){const c=await i.invokeFunction(t,s);l({status:"done",output:c,terminal:!0})}else{const c=await i.runWorkflow(t,{input:s,variables:s,entry:o});l({status:"done",output:c.output,runId:c.runId,terminal:c.terminal,error:c.error})}}catch(c){l({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:!r||(a==null?void 0:a.status)==="running",onClick:u,children:(a==null?void 0:a.status)==="running"?"Running…":"▶ Test run"}),!r&&n.jsx("span",{className:"w6w-muted w6w-small",children:"Fill the required fields to test."})]}),(a==null?void 0:a.status)==="error"&&n.jsx("div",{className:"w6w-result w6w-error",children:a.error}),(a==null?void 0:a.status)==="done"&&!a.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:a.runId})," has not finished yet — check its status from the workflow's run history."]})]}),(a==null?void 0:a.status)==="done"&&a.terminal&&a.error!==void 0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Run failed"}),n.jsx(le.Copyable,{value:JSON.stringify(a.error,null,2),label:"Copy error",children:n.jsx("pre",{className:"w6w-result w6w-error",style:{whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto",margin:0},children:JSON.stringify(a.error,null,2)})})]}),(a==null?void 0:a.status)==="done"&&a.terminal&&a.error===void 0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Result"}),n.jsx(Ne,{value:a.output,maxHeight:220})]})]})}function Qu(e){const t={};for(const s of e)Ze(s.default)&&(t[s.key]=s.default);return t}function St(e,t){const s=Tr(t);if(s===null)return!1;if(s===void 0)return!0;const o=kt(e),r=a=>{var l;return s[a]!==void 0?s[a]:(l=o.find(u=>u.key===a))==null?void 0:l.default},i=(a,l,u)=>a.every(c=>{const d=ae.effectiveParam(c,u);if(d.type==="section")return i(d.children??[],l,u);if(d.type==="group"){const f=d.children??[],h=kt(f),b=x=>g=>{const y=h.find(k=>k.key===g);return y?x[g]!==void 0?x[g]:y.default:u(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(f,y,b(y))})}const w=l[d.key]??{};return i(f,w,b(w))}if(!d.required||!Yt(c,u))return!0;const p=l[d.key]??d.default;return p==null?!1:typeof p=="string"?p.trim()!=="":!0});return i(e,s,r)}function Ri(e){const t=e==null?void 0:e.testRequired;return typeof t=="boolean"?t:!0}function ed(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 td(e){const t=e==null?void 0:e.apiCalls;return Array.isArray(t)?t:[]}function nd({log:e,onClose:t}){return n.jsx(je,{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(Ne,{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(Ne,{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(ii,{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 ro=m.forwardRef(function({app:t,action:s,connectionId:o,values:r,canRun:i,hideRunButton:a,persist:l,state:u,onBusyChange:c,onResult:d},p){const f=xe(),h=xs(),b=ka(),[w,x]=m.useState(null),[g,y]=m.useState(null),[k,A]=m.useState(!1),S=m.useRef(!1),[j,v]=m.useState(null),E=l==null?void 0:l.workflowId,T=l==null?void 0:l.stepId,D=ht().nodeMeta,I=T?D==null?void 0:D[T]:void 0;m.useEffect(()=>{if(!E||!T)return;let L=!1;return f.listStepTests(E,T).then(H=>{let B;for(const z of H)!z.lastRunAt||!z.lastRunStatus||(!B||Date.parse(z.lastRunAt)>Date.parse(B.lastRunAt))&&(B=z);!B||!B.lastRunAt||L||S.current||(B.lastRunStatus==="succeeded"?x({status:"done",value:B.lastRunOutput,...B.lastRunMeta?{meta:B.lastRunMeta}:{}}):x({status:"error",error:typeof B.lastRunError=="string"?B.lastRunError:B.lastRunError==null?"Test failed":JSON.stringify(B.lastRunError)}),v(B.lastRunAt))}).catch(()=>{}),()=>{L=!0}},[f,E,T]);const R=async()=>{var P;if(!i||(w==null?void 0:w.status)==="running")return;S.current=!0,v(null),x({status:"running"}),c==null||c(!0);let L;const H=new Date,B={method:"POST",path:`/apps/${encodeURIComponent(t)}/actions/${encodeURIComponent(s)}/invoke`,body:{params:r,...o?{connectionId:o}:{},...h?{project:h}:{},...u?{state:u}:{},...b?{workflowId:b}:{}}},z=$=>y({startedAt:H.toLocaleString(),durationMs:Date.now()-H.getTime(),request:B,response:$,apiCalls:td($.body)});try{const $=await f.invokeAction(t,s,r,{...o?{connectionId:o}:{},project:h,...u?{state:u}:{},...b?{workflowId:b}:{}});z({ok:!0,body:$}),L={status:"done",value:$.value,logs:$.logs,...$.meta?{meta:$.meta}:{}}}catch($){const Z=$;z({ok:!1,...typeof Z.status=="number"?{status:Z.status}:{},body:ed($)}),L={status:"error",error:Z.message??String($),errorCode:Z.code,logs:Z.logs}}if(x(L),d==null||d(L.status==="done"),l){(P=f.saveTestInput)==null||P.call(f,l.workflowId,l.stepId,Ws(l.input)).catch($=>console.error("test input save failed",$));try{const $=await f.saveStepTest(l.workflowId,l.stepId,{input:l.input,with:r});await f.recordStepTestRun(l.workflowId,l.stepId,{stepTestId:$.id,status:L.status==="done"?"succeeded":"failed",input:l.input,output:L.status==="done"?L.value:void 0,error:L.status==="error"?L.error:void 0,...L.status==="done"&&L.meta?{meta:L.meta}:{}})}catch($){console.error("step test persist failed",$)}}c==null||c(!1)};m.useImperativeHandle(p,()=>({run:R}));const O=w&&w.status!=="running"?w.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||(w==null?void 0:w.status)==="running",onClick:R,children:(w==null?void 0:w.status)==="running"?"Running…":"▶ Test run"}),g&&(w==null?void 0:w.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."})]}),k&&g&&n.jsx(nd,{log:g,onClose:()=>A(!1)}),j&&((w==null?void 0:w.status)==="done"||(w==null?void 0:w.status)==="error")&&n.jsxs("div",{className:"w6w-muted w6w-small w6w-testout-restored",children:["Last run · ",new Date(j).toLocaleString()]}),(w==null?void 0:w.status)==="error"&&n.jsxs("div",{className:"w6w-result w6w-error",children:[w.errorCode&&n.jsx("div",{className:"w6w-small",style:{opacity:.75,marginBottom:4},children:n.jsx("code",{children:w.errorCode})}),w.error]}),(w==null?void 0:w.status)==="done"&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Result (return value)"}),n.jsx(Ne,{value:w.value,maxHeight:220}),(w.meta||I)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w6w-testout-label",children:"Metadata"}),n.jsx(Ne,{value:{...I,...w.meta},maxHeight:220})]})]}),(w==null?void 0:w.status)!=="done"&&(w==null?void 0:w.status)!=="running"&&I&&n.jsxs("div",{className:"w6w-testout","data-testid":"steptest-static-meta",children:[n.jsx("div",{className:"w6w-testout-label",children:"Metadata"}),n.jsx(Ne,{value:I,maxHeight:220})]}),O&&O.length>0&&n.jsxs("div",{className:"w6w-testout",children:[n.jsx("div",{className:"w6w-testout-label",children:"Console output"}),n.jsx(le.Copyable,{value:O.join(`
19
+ `),label:"Copy console output",children:n.jsx("pre",{className:"w6w-result w6w-testout-console",style:{whiteSpace:"pre-wrap",maxHeight:160,overflow:"auto",margin:0},children:O.join(`
20
+ `)})})]})]})}),qo=12,tn=new Set;function Ti(e,t,s,o,r){const i=o&&o.length>0?new Set(o):null,a=F=>(i?i.has(F.id):!0)&&((t==null?void 0:t(F))??!0),l=xe(),[u,c]=m.useState(null),[d,p]=m.useState(null),[f,h]=m.useState(null),[b,w]=m.useState(null),[x,g]=m.useState(null),[y,k]=m.useState(()=>new Map),[A,S]=m.useState(()=>new Set),[j,v]=m.useState(tn),E=m.useRef(tn),T=m.useCallback(F=>{E.current=F,v(F)},[]),D=m.useRef(tn),I=e.includes("function"),R=e.includes("workflow"),O=typeof l.listAppsByIds=="function";m.useEffect(()=>{let F=!1;const X=Y=>!F&&g(Y.message);return l.listConnections().then(Y=>{if(F)return;const U=[],G=new Set,te=new Map;for(const C of Y)Ge(C.appId)||(O&&!(r!=null&&r.resolveInline)&&C.app&&!te.has(C.appId)&&te.set(C.appId,{...C.app,id:C.appId}),!G.has(C.appId)&&(G.add(C.appId),U.push(C.appId)));te.size>0&&(D.current=new Set(te.keys()),k(C=>new Map([...C,...te])),S(C=>new Set([...C,...te.keys()]))),c(U)}).catch(X),I?l.listFunctions().then(Y=>!F&&h(Y)).catch(X):h([]),R?l.listWorkflows().then(Y=>!F&&w(Y)).catch(X):w([]),()=>{F=!0}},[l,O,I,R,r==null?void 0:r.resolveInline]),m.useEffect(()=>{if(O)return;const F=l.listApps;if(typeof F!="function"){p([]);return}let X=!1;return F().then(Y=>!X&&p(Y)).catch(Y=>!X&&g(Y.message)),()=>{X=!0}},[l,O]);const L=m.useRef(!0);m.useEffect(()=>(L.current=!0,()=>{L.current=!1}),[]);const H=m.useCallback(F=>{const X=l.listAppsByIds;!X||F.length===0||E.current.size>0||(T(new Set(F)),X(F).then(Y=>{L.current&&(T(tn),k(U=>{const G=new Map(U);for(const te of Y)G.set(te.id,te);return G}),S(U=>new Set([...U,...F])))}).catch(Y=>L.current&&g(Y.message)))},[l,T]),B=m.useRef(!1);m.useEffect(()=>{if(!O||u===null||B.current)return;const F=Dn(u,D.current,qo);F.length!==0&&(B.current=!0,H(F))},[O,u,H]);const z=()=>{if(!O||u===null||E.current.size>0)return;const F=new Set([...A,...E.current]);H(Dn(u,F,qo))};if(x)return{state:"error",error:x,apps:[],fns:[],wfs:[],moreApps:!1,loadMoreApps:z};if(f===null||b===null)return{state:"loading",apps:[],fns:[],wfs:[],moreApps:!1,loadMoreApps:z};const P=cs(f,s),$=cs(b,s);if(O){if(u===null)return{state:"loading",apps:[],fns:P,wfs:$,moreApps:!1,loadMoreApps:z};if(u.length>0&&A.size===0)return{state:"loading",apps:[],fns:P,wfs:$,moreApps:!1,loadMoreApps:z};const F=va(u,y).filter(a),X=j.size===0&&Dn(u,new Set([...A,...j]),1).length>0;return{state:F.length===0&&P.length===0&&$.length===0&&!X?"empty":"ready",apps:F,appIds:u.filter(U=>!i||i.has(U)),fns:P,wfs:$,moreApps:X,loadMoreApps:z}}if(d===null)return{state:"loading",apps:[],fns:P,wfs:$,moreApps:!1,loadMoreApps:z};const Z=new Set(u??[]),Q=d.filter(F=>!Ge(F.id)&&a(F)&&(Z.has(F.id)||F.zeroCredential===!0));return{state:Q.length===0&&P.length===0&&$.length===0?"empty":"ready",apps:Q,fns:P,wfs:$,moreApps:!1,loadMoreApps:z}}function cs(e,t){return t&&t.length>0?e.filter(s=>!t.includes(s.id)):[...e]}function Mt(e){return(t,s)=>e(t).localeCompare(e(s),void 0,{sensitivity:"base"})}function vt(e){const t=e.displayName;return t!=null&&t.trim()?t:"name"in e?e.name:e.id}function us({family:e,item:t,onSelect:s}){const o=vt(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(Rn,{icon:Bu[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 sd(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 Ii({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(pt,{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 od({data:e,query:t,appsFilter:s,onSelectApp:o,onSelectCallable:r,theme:i}){var x;const a=xe(),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 u=e.apps.filter(g=>Lt(t,g.displayName,g.id)).sort(Mt(g=>g.displayName)),c=e.fns.filter(g=>Lt(t,vt(g),g.id)).sort(Mt(vt)),d=e.wfs.filter(g=>Lt(t,vt(g),g.id)).sort(Mt(vt)),p=sd,f=u.map(g=>n.jsx(Ii,{app:g,theme:i,onSelect:o},g.id));e.moreApps&&f.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(lt,{search:!1,searchValue:t,ids:e.appIds,filter:s,onSelectApp:o,theme:i})]}):p("Connected apps",f),b=[p("Functions",c.map(g=>n.jsx(us,{family:"function",item:g,onSelect:y=>r({family:"function",...y})},g.id))),p("Workflows",d.map(g=>n.jsx(us,{family:"workflow",item:g,onSelect:y=>r({family:"workflow",...y})},g.id)))].filter(Boolean),w=(h?1:0)+(b.length>0?1:0);return l(w?n.jsxs("div",{className:"w6w-readytouse","data-cols":w,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 Oi(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 $i({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 rd({kind:e="action",onOpenStep:t,appId:s,app:o,onAdd:r,onClose:i,onDone:a,onDraftChange:l,onChangeApp:u,theme:c,workflowId:d,stepId:p,upstreamSteps:f=[],loop:h,initialAction:b,initialConnection:w,initialWith:x}){const g=xe(),y=e==="trigger",k=y?"a trigger":"an action",[A,S]=m.useState(null),[j,v]=m.useState(null),[E,T]=m.useState(null),[D,I]=m.useState(null),[R,O]=m.useState(w??""),[L,H]=m.useState(),B=Bs(),z=m.useRef(B);z.current=B;const P=L?Et({uses:{app:s,action:"",connectionRef:L}},B==null?void 0:B.connections)??"":R,$=m.useCallback(ne=>{H(void 0),O(ne)},[]),[Z,Q]=m.useState(b??""),[ee,F]=m.useState(x??{}),X=m.useRef(null),[Y,U]=m.useState(!1),[G,te]=m.useState(b&&x?"configure":"setup"),[C,V]=m.useState("props"),[J,_]=m.useState("{}"),[W,ue]=m.useState({});m.useEffect(()=>{let ne=!1;I(null);const q=y?Oi(g,s):g.getAppActions(s);return Promise.all([g.getAppAuth(s),g.listConnectionsForApp(s),q]).then(([ie,oe,Ve])=>{if(ne)return;const ze=Ho(s,ie,oe);S(ie),v(ze),T(Ve);const Te=z.current,Ie=si({id:p??"",uses:{app:s,action:""}},ze,(Te==null?void 0:Te.nodes)??[],(Te==null?void 0:Te.connections)??{},w);Ie.connectionRef?H(Ie.connectionRef):$(Ie.connection??"")}).catch(ie=>!ne&&I(ie.message)),()=>{ne=!0}},[g,s,y,$,w,p]);const pe=async()=>{const ne=await g.listConnectionsForApp(s);v(Ho(s,A??[],ne))},he=(A??[]).filter(ne=>ne.available!==!1),ge=he.some(ne=>ne.autoSatisfied===!0&&(ne.type==="tenantAuth"||ne.type==="jit")),ke=ge&&!he.some(ne=>ne.autoSatisfied===!0&&ne.type==="tenantAuth"),ve=he.length>0&&!ge,Be=(j??[]).length>0,ce=(E??[]).find(ne=>ne.key===Z),Ee=y?li(s,E,Z,ee):null,Ue=[...E??[]].sort((ne,q)=>(ne.title??ne.key).localeCompare(q.title??q.key,void 0,{sensitivity:"base"})),tt=Ri(o),[wt,nt]=m.useState(!1);m.useEffect(()=>{if(!tt||!d||!p)return;let ne=!1;return g.listStepTests(d,p).then(q=>{!ne&&q.some(ie=>ie.lastRunStatus==="succeeded")&&nt(!0)}).catch(()=>{}),()=>{ne=!0}},[g,tt,d,p]);const mt=so(d??"",f,!!d),Le=no(mt,Ni(h)),we=!!Z&&(!ve||Be&&!!P)&&(!Ee||Ee.selected.length>0),Re=we&&!!ce&&St(ce.params??[],ee),ot=we,_e=(j??[]).find(ne=>ne.id===P);function me(){return{uses:{app:s,action:(ce==null?void 0:ce.key)??Z,...L?{connectionRef:L}:P?{connection:P}:{},...y?{trigger:!0}:{}},with:ee,...W}}function Ae(){ce&&r(me())}const[Se,bt]=m.useState(null);m.useEffect(()=>{if(!l||Se!==null||!we||Ee&&G==="setup")return;const ne=r(me());ne&&bt(ne),ne&&y&&(t==null||t(ne))},[l,Se,we,G]),m.useEffect(()=>{!l||Se===null||l(Se,me())},[Se,ee,W,P,L]);const Rt=ne=>{ne==="code"&&_(eo(me())),V(ne)};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==="setup"?" active":""}`,onClick:()=>te("setup"),children:"Setup"}),n.jsx("button",{type:"button",disabled:!we,title:we?void 0:"Complete Setup first",className:`w6w-subtab${G==="configure"?" active":""}`,onClick:()=>we&&te("configure"),children:"Configure"}),n.jsx("button",{type:"button",disabled:!Re,title:Re?void 0:"Fill the required fields first",className:`w6w-subtab${G==="test"?" active":""}`,onClick:()=>Re&&te("test"),children:"Test"})]}),n.jsx(On,{view:C,customized:En(ee),onChange:Rt,disabled:G!=="configure"})]}),n.jsxs("div",{className:"w6w-stepconfig-body",children:[G==="setup"&&n.jsxs("div",{className:"w6w-stack",children:[D&&n.jsx("div",{className:"w6w-result w6w-error",children:D}),A===null&&!D&&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:X,children:[n.jsxs("button",{type:"button",className:"w6w-app-conn-btn","aria-label":"App",onClick:u,disabled:!u,children:[o&&n.jsx(pt,{src:o.iconSvg,srcDark:o.iconSvgDark,brandColor:o.brandColor,name:o.displayName,theme:c,size:20}),n.jsx("span",{className:"w6w-conn-label-name",children:(o==null?void 0:o.displayName)??s})]}),n.jsx(ri,{step:{id:Se??p??"",uses:{app:s,action:Z,...L?{connectionRef:L}:{connection:P||void 0}}},conns:j,failed:!!D,open:Y,onOpenChange:U,anchorRef:X,onChangeConnection:$,onChangeConnectionRef:H,onConnectionCreated:()=>{pe()}})]}),ke&&(_e==null?void 0:_e.builtIn)&&n.jsx("span",{className:"w6w-hint",children:"Scheduled or queued runs need a stored connection. Choose one from the connection menu."}),A!==null&&ve&&!Be&&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(ai,{choices:Ee,onChange:ne=>{Q(Ee.triggerKey),F(q=>({...q,actions:ne}))}}):n.jsxs("label",{className:"w6w-field",children:[n.jsxs("span",{children:[y?"Trigger":"Action",Z?"":" *"]}),n.jsx(ft,{value:Z,placeholder:`— pick ${k} —`,mode:"combobox",listMaxHeight:200,onChange:ne=>{var q;Q(ne),F(Qu(((q=(E??[]).find(ie=>ie.key===ne))==null?void 0:q.params)??[])),nt(!1)},options:Ue.map(ne=>({value:ne.key,label:`${ne.title??ne.key} (${ne.key})`}))}),(ce==null?void 0:ce.description)&&n.jsx("span",{className:"w6w-hint",children:ce.description})]}))]}),G==="configure"&&(ce?C==="props"?n.jsx(Pe,{params:ce.params??[],values:ee,onChange:F,dynamic:{appId:s,actionKey:ce.key,connectionId:P||void 0,appName:o==null?void 0:o.displayName}}):C==="code"?n.jsx(Ye,{value:J,onChange:()=>{},readOnly:!0,minHeight:"240px",height:"100%","aria-label":"Node JSON",copyable:!0}):C==="params-code"?n.jsx(_s,{values:ee,onChange:F}):n.jsx(Ps,{config:W,onChange:ue,failureHandling:!y}):n.jsxs("p",{className:"w6w-muted w6w-small",children:["Pick ",k," in Setup first."]})),G==="test"&&(ce&&y?n.jsx($i,{title:ce.title??ce.key,app:(o==null?void 0:o.displayName)??s}):ce?n.jsx(ro,{app:s,action:ce.key,connectionId:P||void 0,values:ee,canRun:we&&St(ce.params??[],ee),state:Le,onResult:nt}):n.jsx("p",{className:"w6w-muted w6w-small",children:"Pick an action in Setup first."}))]}),G==="test"&&n.jsx("div",{className:"w6w-stepconfig-testnote",children:tt&&!wt&&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"}),G==="test"?n.jsx("button",{type:"button",className:"w6w-btn",disabled:Se===null&&!ot,onClick:Se!==null?a??i:Ae,children:Se!==null?"Done":"Add node"}):n.jsx("button",{type:"button",className:"w6w-btn",disabled:G==="setup"?!we:!Re,onClick:()=>te(G==="setup"?"configure":"test"),children:"Next →"})]})]})}function id({appId:e,app:t,onClose:s,onChangeApp:o,theme:r,initialConnection:i,onConnected:a}){const l=xe(),[u,c]=m.useState(null),[d,p]=m.useState(null),[f,h]=m.useState(null),[b,w]=m.useState(i??""),[x,g]=m.useState(!1),[y,k]=m.useState(!1);m.useEffect(()=>{let O=!1;return h(null),Promise.all([l.getAppAuth(e),l.listConnectionsForApp(e)]).then(([L,H])=>{if(O)return;c(L),p(H),!(L??[]).some(z=>z.autoSatisfied===!0)&&H.length>0&&w(H[0].id)}).catch(L=>!O&&h(L.message)),()=>{O=!0}},[l,e]);const A=async()=>{const O=await l.listConnectionsForApp(e);p(O),O.length>0&&w(L=>L||O[0].id)},S=(u??[]).filter(O=>O.available!==!1),j=S.some(O=>O.autoSatisfied===!0&&(O.type==="tenantAuth"||O.type==="jit")),v=j&&!S.some(O=>O.autoSatisfied===!0&&O.type==="tenantAuth"),E=S.length>0&&!j,T=(d??[]).length>0,D=!E||T&&!!b,I=(d??[]).find(O=>O.id===b),R=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:[f&&n.jsx("div",{className:"w6w-result w6w-error",children:f}),u===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-conn-label",children:[t&&n.jsx(pt,{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"})]})]}),u!==null&&j&&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.'})]}),u!==null&&E&&(T?R?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:O=>{w(O.target.value),k(!1)},style:{flex:1},children:(d??[]).map(O=>n.jsxs("option",{value:O.id,children:[O.displayName||O.id," ",O.state?`(${O.state})`:""]},O.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:[(I==null?void 0:I.displayName)||(I==null?void 0:I.id)||b,I!=null&&I.state?` (${I.state})`:""]}),n.jsx("button",{type:"button",className:"w6w-btn w6w-btn-ghost w6w-btn-sm",onClick:()=>k(!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:!D||!t,onClick:()=>t&&a(b,t),children:"Next →"})]}),x&&n.jsx(Is,{theme:r,initialAppId:e,onClose:()=>g(!1),onCreated:async({connectionId:O})=>{g(!1),w(O),k(!1),await A()}})]})}function Pi({values:e,onChange:t,readOnly:s,setupOnly:o,onValidityChange:r,targetLabel:i,fixedTarget:a}){var z,P;const l=xe(),u=e.targetKind==="function"?"function":"workflow",c=typeof e.targetId=="string"?e.targetId:"",d=typeof e.entry=="string"?e.entry:void 0,p=e.inputs&&typeof e.inputs=="object"&&!Array.isArray(e.inputs)?e.inputs:{},f=Ze(e.inputs)||typeof p.$=="string",[h,b]=m.useState([]),[w,x]=m.useState(),[g,y]=m.useState(),[k,A]=m.useState(),S=`${u}:${c}`;m.useEffect(()=>{if(a)return;let $=!1;return b([]),x(void 0),(u==="workflow"?l.listWorkflows():l.listFunctions()).then(Z=>{$||b(Z)}).catch(Z=>{$||x(String(Z.message??Z))}),()=>{$=!0}},[l,u,a]),m.useEffect(()=>{let $=!1;return y(void 0),A(void 0),c?((u==="workflow"?l.getWorkflow(c).then(Q=>({key:S,workflow:Q,fields:[],label:Q.displayName||Q.name||c})):l.getFunction(c).then(Q=>({key:S,fields:Q.inputs,label:Q.displayName||Q.id}))).then(Q=>{$||y(Q)}).catch(Q=>{$||A(String(Q.message??Q))}),()=>{$=!0}):void 0},[l,c,u,S]);const j=(g==null?void 0:g.key)===S?g:void 0,v=j!=null&&j.workflow?Ci(j.workflow):[],E=d??((z=v[0])==null?void 0:z.id),T=j!=null&&j.workflow?Wu(j.workflow,E):(j==null?void 0:j.fields)??[],I={...Object.fromEntries(T.filter($=>$.default!==void 0).map($=>[$.key,$.default])),...p},R=u==="function"||!d||v.some($=>$.id===d),O=!!j&&R&&(f||St(T,I));m.useEffect(()=>{r==null||r(O)},[O,r]),m.useEffect(()=>{if(!j||s||o)return;const $=!f&&T.some(Z=>Z.default!==void 0&&!(Z.key in p));(!d&&E||$)&&t({...e,...E?{entry:E}:{},inputs:f?e.inputs:I})});const L=h.map($=>({value:$.id,label:$.displayName||("name"in $?$.name:$.id)||$.id})).sort(($,Z)=>$.label.localeCompare(Z.label));c&&!L.some($=>$.value===c)&&L.unshift({value:c,label:(j==null?void 0:j.label)||i||c});const H=c?(P=l.callableHref)==null?void 0:P.call(l,u,c):void 0,B=($,Z)=>{const{target:Q,entry:ee,...F}=e;t({...F,targetKind:$,targetId:Z,inputs:{}})};return n.jsxs("div",{className:"w6w-stack",children:[!a&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Target kind"}),n.jsxs("select",{className:"w6w-input",value:u,disabled:s,onChange:$=>B($.target.value,""),children:[n.jsx("option",{value:"workflow",children:"Workflow"}),n.jsx("option",{value:"function",children:"Function"})]})]}),n.jsxs("div",{className:"w6w-field",children:[n.jsx("span",{children:u==="workflow"?"Workflow":"Function"}),a?n.jsx("span",{children:(j==null?void 0:j.label)||i||c}):n.jsx(ft,{"aria-label":u==="workflow"?"Workflow":"Function",options:L,value:c,disabled:s,placeholder:`Choose a ${u}…`,onChange:$=>B(u,$)}),H&&n.jsxs("a",{className:"w6w-btn w6w-btn-ghost",href:H,target:"_blank",rel:"noopener noreferrer",children:["Open ",u," in new tab ↗"]})]}),w&&n.jsx("div",{className:"w6w-result w6w-error",children:w}),!o&&c&&n.jsxs(n.Fragment,{children:[k?n.jsx("div",{className:"w6w-result w6w-error",children:k}):j?n.jsxs(n.Fragment,{children:[u==="workflow"&&v.length>0&&n.jsxs("label",{className:"w6w-field",children:[n.jsx("span",{children:"Trigger"}),n.jsxs("select",{className:"w6w-input","aria-label":"Trigger",value:E,disabled:s,onChange:$=>t({...e,entry:$.target.value,inputs:{}}),children:[d&&!R&&n.jsxs("option",{value:d,children:[d," (unavailable)"]}),v.map($=>n.jsxs("option",{value:$.id,children:[$.id," (",$.uses.app===Ct?"Manual":$.uses.action,")"]},$.id))]})]}),!R&&n.jsx("div",{className:"w6w-result w6w-error",children:"The selected trigger is unavailable. Choose another trigger."}),u==="workflow"&&v.length===0&&n.jsxs("p",{className:"w6w-muted w6w-small",children:[j.label," has no manual trigger. Add a manual trigger to that workflow to define its input fields."]}),n.jsx("span",{className:"w6w-small",children:"Inputs"}),T.length>0&&!f?n.jsx(Pe,{params:T,values:I,readOnly:s,onChange:$=>t({...e,inputs:$})}):n.jsx(Pe,{params:[{key:"inputs",label:"Input payload",type:"json"}],values:{inputs:e.inputs??{}},readOnly:s,onChange:$=>t({...e,inputs:$.inputs})})]}):n.jsx("p",{className:"w6w-muted w6w-small",children:"Loading inputs…"}),n.jsx(Pe,{params:[{key:"wait",label:"Wait for completion",type:"boolean",default:!0,hint:"On: wait for the workflow or function to finish and return its output. Off: return a run handle and continue."}],values:e,readOnly:s,onChange:t})]})]})}const ad=/^(#{1,6})\s+(.*)$/,ld=new RegExp("\\*\\*(?=\\S)(.+?)(?<=\\S)\\*\\*","g");function cd(e,t){const s=e.ownerDocument;e.replaceChildren();for(const o of t.split(`
21
+ `)){const r=ad.exec(o),i=s.createElement(r?`h${r[1].length}`:"div"),a=r?r[2]:o;let l=0;for(const u of a.matchAll(ld)){u.index>l&&i.append(s.createTextNode(a.slice(l,u.index)));const c=s.createElement("strong");c.textContent=u[1],i.append(c),l=u.index+u[0].length}l<a.length&&i.append(s.createTextNode(a.slice(l))),i.firstChild||i.append(s.createElement("br")),e.append(i)}}function ud(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 dd(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 pd(e){const t=[];let s=null;const o=a=>(s={level:a,runs:[]},t.push(s),s),r=(a,l,u)=>{if(a.nodeType===3){const w=(a.textContent??"").replace(/ /g," ").replace(/\n/g,"");w&&(s??o(l)).runs.push({text:w,bold:u});return}if(a.nodeType!==1)return;const c=a,d=c.tagName.toLowerCase();if(d==="br"){s||o(l),s=null;return}const p=/^h([1-6])$/.exec(d),f=p||["div","p","li","ul","ol","blockquote","pre"].includes(d);f&&(s=null);const h=p?Number(p[1]):l,b=d==="b"||d==="strong"?!0:ud(c)??u;for(const w of c.childNodes)r(w,h,b);f&&(s=null)};for(const a of e.childNodes)r(a,0,!1);const i=t.map(a=>{const l=dd(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(`
22
+ `)}function fd(e){return e.replace(/([^\n])\n(?=[^\n])/g,`$1
23
+ `)}const hd=-2,wd=-1,Bo=1e3,md=["#facc15","#fb923c","#f87171","#f472b6","#a78bfa","#60a5fa","#2dd4bf","#4ade80","#9ca3af"],bd=[{level:1,label:"Title"},{level:2,label:"Heading"},{level:3,label:"Subheading"},{level:0,label:"Body"}],gd=80,yd=48,Uo=10,xd=4,Bn=e=>e.stopPropagation();function vd(e){const t=e.ownerDocument.getSelection();if(!t)return;const s=e.ownerDocument.createRange();s.selectNodeContents(e),t.removeAllRanges(),t.addRange(s)}function jd(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 _i({canvas:e,className:t,viewport:s,readOnly:o,zoom:r=1,onChange:i,onSectionDrop:a,onRequestDelete:l}){const[u,c]=m.useState({}),[d,p]=m.useState(null),[f,h]=m.useState(null),[b,w]=m.useState(null),[x,g]=m.useState(null),y=m.useRef(null),k=m.useRef(null),A=m.useRef(null);if(m.useEffect(()=>{if(!d&&!f)return;const C=d?`[data-note-id="${d}"], [data-note-toolbar="${d}"]`:`[data-section-label="${f}"], [data-section-toolbar="${f}"]`,V=J=>{var ue,pe;const _=J.target;if((ue=_==null?void 0:_.closest)!=null&&ue.call(_,C))return;const W=document.activeElement;(pe=W==null?void 0:W.closest)!=null&&pe.call(W,"[data-section-toolbar]")&&W.blur(),p(null),h(null),g(null)};return window.addEventListener("pointerdown",V,!0),()=>window.removeEventListener("pointerdown",V,!0)},[d,f]),!s)return null;const S=!o&&!!i,j=e.sections??[],v=e.notes??[],E=C=>u[C.id]??{x:C.position.x,y:C.position.y,w:C.size.width,h:C.size.height},T=C=>{const V=E(C);return{left:V.x,top:V.y,width:V.w,height:V.h,"--w6w-canvas-color":C.color}},D=(C,V)=>i==null?void 0:i({...e,notes:v.map(J=>J.id===C?{...J,...V}:J)}),I=(C,V)=>i==null?void 0:i({...e,sections:j.map(J=>J.id===C?{...J,...V}:J)}),R=C=>{const V=k.current,J=v.find(W=>W.id===C);if(!(V!=null&&V.isConnected)||!J)return;const _=pd(V);_!==J.content&&D(C,{content:_})},O=C=>{h(null),p(C)},L=C=>{p(null),h(C)},H=(C,V)=>{A.current=V??null,O(C),w(C),g(null)},B=C=>V=>{if(!V||V.dataset.ready==="1")return;V.dataset.ready="1",k.current=V,cd(V,C.content),V.focus();const J=A.current;A.current=null,J?(vd(V),J(),R(C.id)):jd(V)},z=(C,V,J)=>{var W;g(null);const _=()=>document.execCommand(V,!1,J);b===C&&((W=k.current)!=null&&W.isConnected)?(_(),R(C)):H(C,_)},P=C=>C.mode==="move"?{...C.base,x:C.base.x+C.dx,y:C.base.y+C.dy}:{...C.base,w:Math.max(gd,C.base.w+C.dx),h:Math.max(yd,C.base.h+C.dy)},$=(C,V,J,_)=>{if(!S||C.button!==0)return;C.stopPropagation(),C.preventDefault();const W={kind:J,id:V.id,mode:_,sx:C.clientX,sy:C.clientY,base:E(V),dx:0,dy:0};y.current=W;const ue=he=>{W.dx=(he.clientX-W.sx)/(r||1),W.dy=(he.clientY-W.sy)/(r||1),c(ge=>({...ge,[W.id]:P(W)}))},pe=()=>{if(window.removeEventListener("pointermove",ue),window.removeEventListener("pointerup",pe),y.current=null,c(ke=>{const{[W.id]:ve,...Be}=ke;return Be}),W.dx===0&&W.dy===0)return;const he=P(W),ge={position:{x:he.x,y:he.y},size:{width:he.w,height:he.h}};W.kind==="section"&&W.mode==="move"&&a?a(W.id,{dx:W.dx,dy:W.dy}):W.kind==="note"?D(W.id,ge):I(W.id,ge)};window.addEventListener("pointermove",ue),window.addEventListener("pointerup",pe)},Z=t?` ${t}`:"",Q="nopan nodrag nowheel",ee=S?v.find(C=>C.id===d):void 0,F=S?j.find(C=>C.id===f):void 0,X=r||1,Y=C=>{const V=E(C);return{left:V.x+V.w/2,top:V.y,transform:`translate(-50%, calc(-100% - ${Uo/X}px)) scale(${1/X})`,transformOrigin:"50% 100%","--w6w-canvas-color":C.color}},U=(C,V)=>{const J=E(C);return{left:J.x,top:J.y,transform:`translate(0, calc(-100% - ${V/X}px)) scale(${1/X})`,transformOrigin:"0 100%","--w6w-canvas-color":C.color}},G=(C,V,J,_)=>n.jsxs("div",{className:"w6w-note-menu w6w-note-menu-colors",role:"menu",children:[md.map(W=>n.jsx("button",{type:"button",role:"menuitemradio","aria-checked":W===C,"aria-label":`Colour ${W}`,title:W,className:`w6w-note-swatch-btn${W===C?" active":""}`,style:{"--w6w-canvas-color":W},"data-testid":`${J}-option`,"data-color":W,onClick:()=>{g(null),W!==C&&_(W)}},W)),n.jsx("label",{className:"w6w-note-swatch-btn w6w-note-swatch-custom",title:"Custom",children:n.jsx("input",{type:"color","aria-label":`Custom ${V} colour`,"data-testid":`${J}-input`,value:C,onChange:W=>_(W.currentTarget.value)})})]}),te=C=>{C.target.closest("input")||C.preventDefault()};return pn.createPortal(n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:`w6w-canvas-layer w6w-canvas-sections${Z}`,style:{zIndex:hd},"data-testid":"w6w-canvas-sections",children:[j.map(C=>n.jsx("div",{className:`w6w-canvas-section${f===C.id?" selected":""}`,style:T(C),"data-section-id":C.id,"data-testid":"section",children:S&&n.jsx("div",{className:`w6w-note-resize ${Q}`,"data-testid":"section-resize",onPointerDown:V=>$(V,C,"section","resize")})},C.id)),j.map(C=>(F==null?void 0:F.id)===C.id?null:n.jsx("div",{className:`w6w-canvas-section-title${S?` editable ${Q}`:""}`,style:U(C,xd),"data-section-label":C.id,"data-testid":"section-label",title:S?"Click to edit · drag to move":void 0,onPointerDown:S?V=>{L(C.id),$(V,C,"section","move")}:void 0,children:C.title||(S?"Untitled section":"")},C.id))]}),n.jsx("div",{className:`w6w-canvas-layer w6w-canvas-notes${Z}`,style:{zIndex:wd},"data-testid":"w6w-canvas-notes",children:v.map(C=>{const V=S&&b===C.id;return n.jsxs("div",{className:`w6w-canvas-note${d===C.id?" selected":""}`,style:T(C),"data-note-id":C.id,"data-testid":"note",children:[V?n.jsx("div",{ref:B(C),className:`w6w-canvas-note-body w6w-canvas-note-editor ${Q}`,contentEditable:!0,suppressContentEditableWarning:!0,role:"textbox",tabIndex:0,"aria-multiline":"true","aria-label":"Note content","data-testid":"note-content",onPointerDown:Bn,onBlur:()=>{R(C.id),k.current=null,w(null)},onKeyDown:J=>{J.key==="Escape"&&J.currentTarget.blur()},onPaste:J=>{J.preventDefault(),document.execCommand("insertText",!1,J.clipboardData.getData("text/plain"))}},"editor"):n.jsx("div",{className:`w6w-canvas-note-body ${Q}`,"data-testid":"note-view",style:S?{cursor:"grab",touchAction:"none"}:void 0,onPointerDown:S?J=>{O(C.id),$(J,C,"note","move")}:void 0,onDoubleClick:S?()=>H(C.id):void 0,children:C.content.trim()?n.jsx(Fs,{content:fd(C.content)}):S&&n.jsx("span",{className:"w6w-canvas-note-empty",children:"Double-click to write"})},"view"),S&&n.jsx("div",{className:`w6w-note-resize ${Q}`,"data-testid":"note-resize",onPointerDown:J=>$(J,C,"note","resize")})]},C.id)})}),F&&n.jsx("div",{className:`w6w-canvas-layer${Z}`,style:{zIndex:Bo},"data-testid":"w6w-canvas-overlay",children:n.jsxs("div",{className:`w6w-note-toolbar w6w-section-toolbar ${Q}`,role:"toolbar","aria-label":"Section","data-testid":"section-toolbar","data-section-toolbar":F.id,style:U(F,Uo),onPointerDown:Bn,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:C=>$(C,F,"section","move"),children:n.jsx(le.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:F.title,size:Math.max(8,Math.min(32,F.title.length+1)),onBlur:C=>{const V=C.currentTarget.value;V!==F.title&&I(F.id,{title:V})},onKeyDown:C=>{(C.key==="Enter"||C.key==="Escape")&&C.currentTarget.blur()}},`${F.id}:${F.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(le.Icon,{name:"chevron-down",size:12})]}),x==="color"&&G(F.color,"section","section-color",C=>I(F.id,{color:C}))]}),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",F.id)},children:n.jsx(le.Icon,{name:"trash"})})]})}),ee&&n.jsx("div",{className:`w6w-canvas-layer${Z}`,style:{zIndex:Bo},"data-testid":"w6w-canvas-overlay",children:n.jsxs("div",{className:`w6w-note-toolbar ${Q}`,role:"toolbar","aria-label":"Note","data-testid":"note-toolbar","data-note-toolbar":ee.id,style:Y(ee),onPointerDown:Bn,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:C=>$(C,ee,"note","move"),children:n.jsx(le.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(le.Icon,{name:"chevron-down",size:12})]}),x==="color"&&G(ee.color,"note","note-color",C=>D(ee.id,{color:C}))]}),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(le.Icon,{name:"chevron-down",size:12})]}),x==="size"&&n.jsx("div",{className:"w6w-note-menu w6w-note-menu-sizes",role:"menu",children:bd.map(C=>n.jsx("button",{type:"button",role:"menuitem",className:`w6w-note-menu-item w6w-note-size-${C.level}`,"data-testid":`note-size-${C.level}`,onClick:()=>z(ee.id,"formatBlock",C.level?`<h${C.level}>`:"<div>"),children:C.label},C.level))})]}),n.jsx("button",{type:"button",className:"w6w-icon-btn","aria-label":"Bold",title:"Bold","data-testid":"note-bold",onClick:()=>z(ee.id,"bold"),children:n.jsx(le.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",ee.id)},children:n.jsx(le.Icon,{name:"trash"})})]})})]}),s)}function Nd(e){const t=Vn.useStore(o=>{var r;return((r=o.domNode)==null?void 0:r.querySelector(".react-flow__viewport"))??null}),s=Vn.useStore(o=>o.transform[2]);return n.jsx(_i,{...e,zoom:e.zoom??s,viewport:t})}function kd(e){return e.viewport!==void 0?n.jsx(_i,{...e,viewport:e.viewport}):n.jsx(Nd,{...e})}function Sd({title:e,message:t,onConfirm:s,onClose:o,confirmLabel:r="Confirm",cancelLabel:i="Cancel",destructive:a=!0,pending:l=!1,autoFocusConfirm:u=!1,children:c}){const d=m.useRef(null);return m.useEffect(()=>{var p;u&&((p=d.current)==null||p.focus())},[u]),n.jsxs(je,{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",{ref:d,type:"button",className:a?"w6w-btn w6w-btn-danger":"w6w-btn",onClick:s,disabled:l,children:r})]})]})}function zt(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]=zt(o);return t}case"array":return e.items?[zt(e.items)]:[];default:return null}}function Cd(e){const t={};for(const s of e??[])s&&typeof s.nodeId=="string"&&s.nodeId!==""&&(t[s.nodeId]=s);return t}function $n(e){return e.sampleOmitted!==!0&&"sample"in e&&e.sample!==void 0}function Pn(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 Fi(e,t,s,o){const r=t[e],i=s[e];return r!==void 0&&(!i||!Pn(i,o==null?void 0:o[e]))||!i?r:$n(i)?i.sample:zt(i.shape)}function Ad(e,t,s){const o={};for(const r of new Set([...Object.keys(e),...Object.keys(t)])){const i=Fi(r,e,t,s);i!==void 0&&(o[r]=i)}return o}function Ed(e,t,s){const o={...e};for(const[r,i]of Object.entries(t))$n(i)&&(e[r]===void 0||Pn(i,s==null?void 0:s[r]))&&(o[r]=i.sample);return o}function Rd(e,t,s){const o={...e},r={};for(const[i,a]of Object.entries(t))e[i]!==void 0&&!Pn(a,s==null?void 0:s[i])||(delete o[i],r[i]=$n(a)?a.sample:zt(a.shape));return{fresh:o,persisted:r}}function Td(e,t,s){const o={...e},r={};for(const[i,a]of Object.entries(t))$n(a)&&(e[i]===void 0||Pn(a,s==null?void 0:s[i]))&&(delete o[i],r[i]=a.sample);return{fresh:o,persisted:r}}function Id(e,t){if(e.app)return e.app;if(e.app!==null)return t.get(e.appId)}function Od(e){const t=new Set;for(const s of e)s.app===void 0&&t.add(s.appId);return[...t]}exports.AddConnectionModal=Is;exports.AnchoredFlyout=ei;exports.ApiCallsPanel=ii;exports.AppIcon=pt;exports.AppPicker=lt;exports.AppTriggerTestNote=$i;exports.AuthFieldsForm=an;exports.CALL_APP=yn;exports.CONTROL_APP=Oe;exports.CallTargetForm=Pi;exports.CanvasLayer=kd;exports.CodeEditor=js;exports.Combobox=ft;exports.ConditionEditor=An;exports.ConfigViewToggle=On;exports.ConfirmModal=Sd;exports.CredentialPicker=vr;exports.DATA_APP=Dt;exports.DeleteButton=Or;exports.EACH_SOURCE_HANDLE=gn;exports.EDITOR_THEME_SPEC=vs;exports.ERROR_SOURCE_HANDLE=ps;exports.EventbriteTriggerPicker=ai;exports.ExpressionEditorModal=Gt;exports.ExpressionInput=qt;exports.ExpressionOptionsProvider=ml;exports.FOREACH_DONE_ROUTE=jt;exports.HTML_PREVIEW_CSP=Mr;exports.HtmlPreview=Hr;exports.INTERNAL_NODES=dt;exports.IconButton=kn;exports.InternalIcon=Rn;exports.JsonEditor=Ye;exports.LastUsedNote=Xr;exports.Markdown=Fs;exports.Modal=je;exports.NodeConfigForm=Ps;exports.ParamCustomization=_s;exports.ParamsForm=Pe;exports.PropertyEntryForm=Fr;exports.RACE_APP=Kt;exports.RACE_DESCRIPTION=Go;exports.RESULT_RENDER_MAX_CHARS=Br;exports.ROUTER_APP=We;exports.ResultViewer=Ne;exports.RetryPolicyFields=Rr;exports.RouterEditor=$r;exports.SCHEDULER_APP=hs;exports.SCRIPT_APP=Ko;exports.StepBuilderModal=Vu;exports.StepNameEditor=Pr;exports.StepTestRun=ro;exports.StopEditor=_r;exports.TRIGGER_APP=Ct;exports.TriggerFillForm=Zr;exports.W6WUIProvider=ja;exports.WEBHOOK_APP=Fe;exports.WaitEditor=Qr;exports.WorkflowConnectionPicker=ri;exports.WorkflowConnectionsContext=oi;exports.WorkflowProjectProvider=Na;exports.ancestorIds=to;exports.applyConnect=Kc;exports.applyStepProblems=Oc;exports.asFieldDefs=Ls;exports.bindingFieldsFor=jr;exports.bridgeDeletedBodyStep=qc;exports.buildBinding=Nr;exports.buildResolveScope=Ns;exports.canConnect=fi;exports.centralizeConnections=ni;exports.coerceDefault=Ds;exports.conditionCombinatorLabel=ec;exports.conditionOperatorLabel=Ql;exports.connectConflict=Gc;exports.connectRefusal=Yc;exports.connectionAppIdsToLookUp=Od;exports.connectionIdFor=Et;exports.controlOwnedIds=Us;exports.convertCodeBindingsToReads=vl;exports.dataVarRows=bn;exports.declaredSamples=_u;exports.deepEqual=Yn;exports.defaultConnectionFor=si;exports.definitionLoops=Gs;exports.deleteStepMessage=Jc;exports.detectResultFormat=Ur;exports.edgeLane=be;exports.edgeVisuals=Jt;exports.edgeWhenConflict=Zc;exports.editConnectionResources=ln;exports.effectiveEdges=Js;exports.effectiveNodeOutput=Fi;exports.effectiveNodeOutputs=Ad;exports.eventbriteTriggerChoices=li;exports.excludeSelfStep=wl;exports.fieldWidget=Ms;exports.fieldsToParams=Hs;exports.filterOptions=nr;exports.findChainRoot=hu;exports.findChainTail=wu;exports.findCodeBindings=gr;exports.findTestInput=Jr;exports.flattenParams=kt;exports.flowToWorkflow=du;exports.foreachTestFixture=ju;exports.foreachTestSample=Nu;exports.getTriggerDefs=Oi;exports.hasParamCustomization=En;exports.htmlPreviewSrcDoc=Dr;exports.idClashMessage=nu;exports.ifPortLayout=Qi;exports.indexNodeSamples=Cd;exports.inferOutputFields=it;exports.internalNodeDef=at;exports.internalNodeDefaults=wn;exports.internalNodeIcon=ma;exports.internalNodeLabel=wa;exports.internalNodeParams=Yo;exports.isConnectionBlocked=_c;exports.isControlApp=It;exports.isDollarPath=ks;exports.isEachLink=Ks;exports.isExprValue=qe;exports.isForeachStep=Ce;exports.isFormResolvedOptions=vn;exports.isIfStep=gs;exports.isInternalApp=Ge;exports.isParamVisible=Yt;exports.isSecretValue=Qe;exports.isTestRequired=Ri;exports.isTriggerApp=hn;exports.isTriggerStep=ea;exports.laneForSourceHandle=Ui;exports.loopBody=Tn;exports.loopItemText=Tu;exports.loopMembership=He;exports.loopRefusal=di;exports.loopRefusalMessage=Vc;exports.nextWorkflowConnectionName=qs;exports.nodeConfigSources=Lu;exports.nodeConfigValues=Mu;exports.nodeMetaSampleValues=Hu;exports.nodeMetaValues=Du;exports.nodePortsForStep=Ht;exports.normalizeInput=Qs;exports.parseJsonFields=ss;exports.parseLoopSeed=Iu;exports.parseRootAnchoredTemplate=Xe;exports.pickWebhookSubscription=zr;exports.previewCustomization=Ir;exports.previewNodeOutputs=Ed;exports.relaneRefusal=Qc;exports.relayoutNodes=uu;exports.rememberableInput=Ws;exports.renameStepInEdges=eu;exports.requiredParamsFilled=St;exports.resolveConnectionAppMeta=Id;exports.resolveLoopItemsInState=yi;exports.resolveOutputShape=xt;exports.resolveParamJson=Wt;exports.resolveParamValue=Cs;exports.resolveVarsJson=Va;exports.resultCopyText=Vr;exports.routeFromHandle=Gi;exports.routeHandle=At;exports.routerPortLayout=Zi;exports.routesForStep=bs;exports.seedValues=rs;exports.selectNodeConnection=Fc;exports.setEdgeWhen=Xc;exports.shapeToSkeleton=zt;exports.shouldUseCombobox=tr;exports.slugifyLabel=fu;exports.splitFrontmatter=Lr;exports.splitNodeOutputs=Rd;exports.splitPreviewOutputs=Td;exports.stampLoopOf=zc;exports.startOAuthPopup=kr;exports.startStateFromSeeds=no;exports.stepBuilderLoop=Eu;exports.stepBuilderUpstreamSteps=Au;exports.stepNameError=hi;exports.stepProblemTooltip=Pc;exports.stepToJson=eo;exports.storedViewport=mi;exports.stripBody=zs;exports.suggestStepId=mu;exports.testInputSavesSettled=Gr;exports.trackTestInputSave=Kr;exports.upstreamSampleValueSources=Pu;exports.upstreamSampleValues=$u;exports.upstreamStateSources=Cu;exports.useEffectiveTheme=xn;exports.useEnterSubmit=Sr;exports.useExpressionOptions=ht;exports.useRememberedTestInput=Yr;exports.useSeedSources=so;exports.useW6WApi=xe;exports.useWorkflowConnections=Bs;exports.valueAtPath=Ft;exports.varLabel=Ke;exports.withConnectionRef=Vt;exports.withViewport=pu;exports.workflowToFlow=cu;
24
+ //# sourceMappingURL=connection-app-meta-BeYDm-cs.cjs.map