easy_flow 0.52.0 → 0.53.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d7c7fe6e156649f27feced89f3bcead9bdac9fe6f39ebe8a9956e11716eefcd
4
- data.tar.gz: c7635a07ec44d41af799c51f17542b3346d8143a267630696527593d899a6091
3
+ metadata.gz: 1f5f8658d15f77b5f5ffd3b5ab85d1e90daa8a2199d20d260f6b72823bc5d09c
4
+ data.tar.gz: 4f824955ad8425066bf489b08ae48c4a60216ac5358aa96bebeaa56b8fb31647
5
5
  SHA512:
6
- metadata.gz: 8abdee407d6ce1ffc63a98484d70ea89e1a0781a797c355886c39a08f95fad0a4a2a7966272825be60f01f9f9a0758763efbea2d126c35778adc8751aca6ca17
7
- data.tar.gz: 957d60c9212f3fee557badd513bfeab88c5854df885f4cbd74042bb664bd3944cc3ac64253796da67bf14968aa554870588fbe4fc447270b44a2b3a05a8e5c4a
6
+ metadata.gz: 3f20a4149225cfe7d1142822d7b29d507ca6eb2e801df27d6ddf881f6d6c09870952fe2c8c271cdd794df4cc207a072abdb3a83c8e98d0e5c82ee746d9500560
7
+ data.tar.gz: e2efb559112c1821028b0e442e8c1050e7ba545310fc9fb48841f42db942a6be8628070ed7555ca028aaaa4ecc4db10c37601c200fc5f8f1ff8cd76b9f2294a5
@@ -1 +1 @@
1
- (()=>{var Ye=globalThis.ReactDOM;var{createPortal:xs,createRoot:At,flushSync:ys,hydrateRoot:bs,preconnect:vs,prefetchDNS:ws,preinit:ks,preinitModule:Ss,preload:Cs,preloadModule:Ns,requestFormReset:Es,unstable_batchedUpdates:_s,useFormState:As,useFormStatus:zs,version:Ts}=Ye;var zt=globalThis.React,e=zt,{Children:Os,Component:Bs,Fragment:Ds,PureComponent:Ls,StrictMode:Ps,Suspense:Is,cloneElement:$s,createContext:Hs,createElement:Ws,createRef:js,forwardRef:Gs,isValidElement:Vs,lazy:Fs,memo:Us,startTransition:Xs,useCallback:Ys,useContext:qs,useDebugValue:Js,useDeferredValue:Ks,useEffect:L,useId:Zs,useImperativeHandle:Qs,useLayoutEffect:R,useMemo:P,useReducer:Rs,useRef:Y,useState:E,useSyncExternalStore:tn,useTransition:en}=zt;var Tt=new Map,tt=new Map,ft=(t,o)=>Tt.set(t,o),Mt=()=>{tt.forEach(t=>t.unmount()),tt.clear()},Ot=(t,o)=>t.querySelectorAll("[data-react-ui]").forEach(s=>{if(tt.has(s))return;let r=Tt.get(s.dataset.reactUi),n=o(s);tt.set(s,n),n.render(e.createElement(r,JSON.parse(s.dataset.props)))});var Bt=(t,o)=>{let s=()=>Ot(t,o);t.addEventListener("turbo:load",s),t.addEventListener("turbo:frame-load",s),t.addEventListener("turbo:before-cache",Mt),t.readyState==="loading"?t.addEventListener("DOMContentLoaded",s):s()};var A=(...t)=>t.filter(Boolean).join(" ");var qe={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},Je={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Ke=({variant:t="primary",size:o="md",className:s,children:r,...n})=>{let a=n.href?"a":"button";return e.createElement(a,{...n,className:A("ks-button",qe[t],Je[o],s)},r)},w=Ke;var Ze="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Qe="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Re="border border-accent-600 bg-accent-600 text-white",to=({name:t,connected:o,armed:s,onArm:r,connecting:n})=>e.createElement("button",{onClick:a=>{n||(a.stopPropagation(),r(a))},title:s?"Now choose a step to connect to":"Connect this branch",className:s?Re:o?Qe:Ze,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},t||"next"),Dt=to;var eo={width:240,boxSizing:"border-box",borderRadius:8},oo={minWidth:120,boxSizing:"border-box",borderRadius:6},ro={padding:"8px 14px",textAlign:"center",fontWeight:600},so={fontWeight:600,lineHeight:1.3},no={fontSize:12,fontWeight:500,lineHeight:1.3},ao=(t,o,s)=>{let r=s?"ring-4 ring-accent-600/15":"shadow-sm";return t||s&&!o?`border-accent-600 ${r}`:o?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},io=(t,o)=>o&&t.label===t.id&&t.type_name||t.label,lo=(t,o,s)=>s?o===t.type_name?null:t.type_name:t.type,co=({node:t,selected:o,armed:s,connecting:r,onSelect:n,onOpen:a,onArm:p,onDragEnd:c,onDragStart:l,hideStepTypeCodes:m,compact:u=!1,typeAbove:x=u})=>{let h=t.begins_here||t.ends_here,d=t.begins_here,f=t.ends_here?[]:t.ports,_=r&&!d,v=io(t,m),C=lo(t,v,m);return e.createElement("div",{ref:t.ref,"data-step":t.id,draggable:!d,onDragStart:k=>{k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("text/plain",t.id),l()},onDragEnd:c,onClick:t.opens&&!r?()=>a(t.opens):n,className:`bg-white ${u&&!o?"border":"border-2"} dark:bg-zinc-900 ${ao(_,t.violations.length>0,o)}`,style:{...u?oo:eo,padding:h?0:u?"8px 10px":"12px 14px",cursor:d?"default":r?"crosshair":"grab"}},!h&&x&&C&&e.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},C),h&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:ro},v),!h&&e.createElement("div",{style:u?no:so},v),t.violations.length>0&&e.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${t.violations.length} error${t.violations.length===1?"":"s"}`),!h&&t.summary&&t.violations.length===0&&e.createElement("div",{className:o?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},t.summary),!h&&!x&&C&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},C),t.picture_url&&e.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),t.starts_a_flow&&e.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),t.opens&&e.createElement(w,{variant:"secondary",size:"sm",className:"mt-2",onClick:k=>{k.stopPropagation(),n()}},"Settings"),f.length>0&&e.createElement("div",{style:{padding:t.begins_here?"0 14px 8px":"10px 0 0"}},f.map(k=>e.createElement(Dt,{key:k,name:k,connected:t.connected.includes(k),connecting:r,armed:s===k,onArm:N=>p(k,N)}))))},gt=co;var Lt={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},po={...Lt,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},mo=({node:t,header:o,onSelect:s,compact:r=!1})=>e.createElement("div",{ref:t.ref,"data-group-header":t.id,onClick:s,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?po:Lt,...s?{}:{cursor:"default"}}},o),et=mo;var uo=({id:t,bounds:o,onDrop:s})=>e.createElement("div",{"data-group-box":t,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),s()},className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",zIndex:1,borderRadius:8,boxSizing:"border-box",...o}}),Pt=uo;var fo=t=>t!=null&&t!==""&&typeof t!="object",go=["integer","float"],ho=(t,o,s)=>s&&o.labels?.[t]||t,ot=(t,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>fo(t.config[n])).map(n=>`${ho(n,o,s)}${go.includes(o.fields[n])?"":":"} ${t.config[n]}`);return[s&&t.type_name||t.type,...r].join(" \xB7 ")};var It=(t,o,s)=>{let r=Math.min(...t.map(c=>c.left))-o.left+s.scrollLeft-12,n=Math.min(...t.map(c=>c.top))-o.top+s.scrollTop-10,a=Math.max(...t.map(c=>c.left+c.width))-o.left+s.scrollLeft+12,p=Math.max(...t.map(c=>c.top+c.height))-o.top+s.scrollTop+10;return{left:r,top:n,width:a-r,height:p-n}},xo=({left:t,top:o,width:s,height:r},n)=>n.x>=t&&n.x<=t+s&&n.y>=o&&n.y<=o+r,$t=(t,o)=>t.find(s=>xo(s.bounds,o))?.id||null,Ht=(t,o)=>t.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),Wt=(t,o)=>o.some(s=>s.holds?.includes(t.id)&&!s.loose&&s.row===t.row-1);var ht=(t,o)=>t.includes(o)?t.filter(s=>s!==o):[...t,o],jt=(t,o)=>({...o?.choices||{},...t?.choices||{}});var yo=({as:t="input",disabled:o,className:s,...r})=>e.createElement(t,{...r,disabled:o,className:A("ks-input",o&&"ks-input-disabled",s)}),I=yo;var bo=t=>e.createElement(I,{...t,as:"select"}),Gt=bo;var vo=({className:t,...o})=>e.createElement("input",{type:"checkbox",...o,className:A("ks-checkbox",t)}),rt=vo;var wo=({name:t,value:o,label:s,hint:r,className:n,...a})=>e.createElement("label",{className:"inline-block cursor-pointer relative"},e.createElement("input",{type:"radio",name:t,value:o,...a,className:A("peer sr-only",n)}),e.createElement("span",{className:"ks-radio-card inline-flex flex-col cursor-pointer transition ks-radio-card-highlight"},e.createElement("span",{className:"ks-radio-card-header flex items-start justify-between"},e.createElement("span",{className:"ks-radio-card-label block"},s)),r!=null&&e.createElement("span",{className:"ks-radio-card-hint block text-sm"},r))),Vt=wo;var ko=({name:t,options:o,value:s,onChange:r,className:n})=>e.createElement("div",{className:A("flex flex-wrap ks-grid-gap-sm",n)},o.map(a=>e.createElement(Vt,{key:a.value,name:t,...a,checked:a.value===s,onChange:()=>r(a.value)}))),Ft=ko;var Ut=t=>(t||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),So=({name:t,type:o,value:s,choices:r,onChange:n,onSettle:a,onPick:p,pictureUrl:c})=>{if(o==="picture")return e.createElement("div",{className:"mb-3"},s&&c&&e.createElement("img",{src:c,alt:"The step's picture",style:{maxWidth:"100%"}}),s&&e.createElement(w,{type:"button",variant:"secondary",size:"sm","data-remove-picture":!0,onClick:()=>a("")},"Remove picture"),e.createElement("input",{type:"file",accept:"image/*",onChange:l=>l.target.files[0]&&p(l.target.files[0])}));if(o==="boolean")return e.createElement(rt,{checked:!!s,onChange:l=>a(l.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return e.createElement(Gt,{className:"mb-3",value:s??"",onChange:l=>a(l.target.value)},e.createElement("option",{value:""}),Ut(r).map(l=>e.createElement("option",{key:l.value,value:l.value},l.label)));if(o==="radio_cards")return e.createElement("div",{"data-radio-cards":!0,className:"mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full"},e.createElement(Ft,{name:t,value:s,options:r||[],onChange:a}));if(o==="multi_select"){let l=Array.isArray(s)?s:[],m=u=>a(ht(l,u));return e.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(r||[]).map(u=>e.createElement("label",{key:u,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(rt,{checked:l.includes(u),onChange:()=>m(u)}),e.createElement("span",null,u))))}if(o==="flows"){let l=Array.isArray(s)?s:[];return e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},Ut(r).map(m=>e.createElement("label",{key:m.value,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(rt,{checked:l.includes(m.value),onChange:()=>a(ht(l,m.value))}),e.createElement("span",null,m.label))))}return o==="integer"||o==="float"?e.createElement(I,{className:"mb-3",type:"number",step:o==="integer"?"1":"any",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>a(l.target.value)}):e.createElement(I,{className:"mb-3",type:"text",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>a(l.target.value)})},st=So;var Xt=(t,o,s,r)=>t.map((n,a)=>a===o?{...n,[s]:r}:n);var Co=({text:t})=>e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},t),nt=Co;var No=(t,o,s,r)=>{let n=(t||{})[s],a=(o||{})[s];return a?(n||{})[r[a]]:n},Eo=({holds:t,labels:o,explanations:s,rows:r,choices:n,outputsOf:a,onChange:p,onSettle:c})=>{let l=Array.isArray(r)?r:[],m=(u,x,h,d)=>{let f=Xt(l,u,x,h);d?c(f):p(f)};return e.createElement("div",{style:{marginBottom:12}},l.map((u,x)=>e.createElement("div",{key:x,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(t).map(([h,d])=>e.createElement("label",{key:h,style:{display:"block"}},e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[h]||h),e.createElement(st,{type:d,value:u[h],choices:No(n,a,h,u),onChange:f=>m(x,h,f,!1),onSettle:f=>m(x,h,f,!0)}),(s||{})[h]&&e.createElement(nt,{text:s[h]}))),e.createElement(w,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>c(l.filter((h,d)=>d!==x))},"Remove"))),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>c([...l,{}])},"Add"))},Yt=Eo;var _o={start:null,end:"ks-value-list-end"},Ao="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",zo="flex flex-col min-w-0",To="ks-value-list-label basis-auto text-xs",Mo=()=>e.createElement("svg",{"aria-label":"Right",role:"img",className:"ks-tone-success inline size-5 align-text-bottom",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},e.createElement("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z",clipRule:"evenodd"})),Oo=({value:t,fallback:o})=>String(t??"")===""?o:t,Bo=({rows:t,align:o="start",columns:s=!1,className:r})=>e.createElement("dl",{className:A("ks-value-list",_o[o],s&&Ao,r)},t.map((n,a)=>e.createElement("div",{key:a,className:A(s?zo:"ks-value-list-row",n.total&&"ks-value-list-total")},e.createElement("dt",{className:s?To:"ks-value-list-label"},n.label,n.note!=null&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"ks-value-list-note"},n.note))),e.createElement("dd",{className:"ks-value-list-value"},Oo(n),n.right&&e.createElement(e.Fragment,null," ",e.createElement(Mo,null)))))),qt=Bo;var Do=()=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})),Lo=({summary:t,open:o=!1,className:s,children:r})=>e.createElement("details",{className:A("ks-disclosure group",s),open:o},e.createElement("summary",{className:"ks-disclosure-summary flex cursor-pointer list-none items-center justify-between [&::-webkit-details-marker]:hidden"},e.createElement("span",null,t),e.createElement("span",{className:"ks-disclosure-icon h-4 w-4 shrink-0 transition-transform group-open:rotate-180"},e.createElement(Do,null))),e.createElement("div",{className:"ks-disclosure-body text-sm"},r)),Jt=Lo;var Po=({language:t,caption:o,className:s,children:r})=>e.createElement("div",{className:A("ks-code overflow-hidden",s)},o!=null&&e.createElement("div",{className:"ks-code-caption font-mono text-xs"},o),e.createElement("pre",{className:"ks-code-block overflow-x-auto font-mono text-sm leading-relaxed"},e.createElement("code",{className:t==null?"":`language-${t}`},r))),Kt=Po;var xt="flex flex-col gap-1 mb-3",Zt="[&_dd]:font-mono",Io="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",$o="[&_.ks-value-list]:font-mono [&_.ks-value-list]:flex [&_.ks-value-list]:flex-col [&_.ks-value-list]:gap-1 [&_.ks-value-list-row]:gap-2 [&_.ks-value-list-row]:py-0 [&_.ks-value-list-row]:border-0 [&_.ks-value-list-label]:basis-[90px]",Ho="border-t border-gray-200 pt-2.5 dark:border-zinc-700 [&_.ks-disclosure]:border-0 [&_.ks-disclosure-summary]:flex-row-reverse [&_.ks-disclosure-summary]:justify-end [&_.ks-disclosure-summary]:gap-1 [&_.ks-disclosure-summary]:p-0 [&_.ks-disclosure-summary]:font-normal [&_.ks-disclosure-body]:p-0 [&_.ks-disclosure-body]:pt-1.5 [&_.ks-code-block]:p-2 [&_.ks-code-block]:text-[11px]",Wo=t=>t.values?t.columns?`${xt} ${Zt} ${Io}`:`${xt} ${Zt} ${$o}`:`${xt} ${Ho}`,jo=({details:t})=>e.createElement(e.Fragment,null,t.map((o,s)=>e.createElement("section",{key:s,className:Wo(o)},o.heading&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400"},o.heading),o.values&&e.createElement(qt,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>e.createElement(Jt,{key:r.summary,summary:r.summary},e.createElement(Kt,null,r.code)))))),Qt=jo;var Go=({as:t="div",className:o,children:s,...r})=>e.createElement(t,{...r,className:A("ks-panel",o)},s),D=Go;var at=(t,o)=>({className:s,children:r,...n})=>e.createElement(t,{...n,className:A(o,s)},r),q=at("label","ks-label"),Na=at("p","ks-hint"),Ea=at("p","ks-error"),_a=at("span","ks-required");var Vo={width:320,padding:"14px 16px",overflowY:"auto",display:"flex",flexDirection:"column",fontSize:12},Fo={marginTop:"auto",paddingTop:12,display:"flex",flexDirection:"column",gap:8},Uo=({node:t,fields:o,holds:s,labels:r,explanations:n,recordLabels:a,recordExplanations:p,recordChoices:c,recordOutputsOf:l,choices:m,onSave:u,onDelete:x,onClose:h,onPickPicture:d,refusal:f,notice:_})=>{let[v,C]=E(t.config),[k,N]=E(t.picture_url);L(()=>N(t.picture_url),[t.id,t.picture_url]),L(()=>C(t.config),[t.id,t.config]);let O=b=>{C(b),JSON.stringify(b)!==JSON.stringify(t.config)&&u(b)};return e.createElement(D,{as:"aside",style:Vo,className:"max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto","data-inspector":!0},e.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8,marginBottom:12}},e.createElement("div",null,e.createElement("p",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.id," \xB7 ",t.type),e.createElement("h2",{style:{fontSize:15,fontWeight:600}},t.label)),e.createElement("button",{title:"Close",onClick:h,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),f&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},f),_&&!f&&e.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{fontWeight:600,marginBottom:12},"data-notice":!0},_),Object.entries(o).map(([b,B])=>e.createElement(q,{key:b},e.createElement("span",{style:{display:"block",marginBottom:3}},r[b]||b),B==="list"?e.createElement(Yt,{holds:s[b]||{},labels:a[b]||{},explanations:(p||{})[b],rows:v[b],choices:{...(c||{})[b],...(t.record_choices||{})[b]},outputsOf:(l||{})[b],onChange:T=>C({...v,[b]:T}),onSettle:T=>O({...v,[b]:T})}):e.createElement(st,{name:b,type:B,value:v[b],choices:m[b],pictureUrl:k,onChange:T=>C({...v,[b]:T}),onSettle:T=>O({...v,[b]:T}),onPick:async T=>{let H=await d(T);H&&(N(H.url),O({...v,[b]:H.reference}))}}),(n||{})[b]&&e.createElement(nt,{text:n[b]}))),e.createElement(Qt,{details:t.details||[]}),e.createElement("div",{style:Fo},(t.links||[]).length>0&&e.createElement("div",{style:{display:"flex",gap:8}},t.links.map(b=>e.createElement(w,{key:b.address,variant:"secondary",size:"sm",className:"flex-1",href:b.address},b.label))),e.createElement(w,{variant:"danger",size:"sm",className:"w-full",onClick:x},"Delete step")))},Rt=Uo;var Xo={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},Yo={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},qo="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",Jo="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Ko=({node:t,dragging:o,onFill:s,onDrop:r,compact:n=!1})=>e.createElement("div",{ref:t.ref,"data-placeholder":t.id,title:`Choose the step \u201C${t.label}\u201D should lead to`,onClick:s,onDragOver:a=>{o&&(a.preventDefault(),a.dataTransfer.dropEffect="move")},onDrop:a=>{a.preventDefault(),r()},className:o?Jo:qo,style:n?Yo:Xo},e.createElement("div",{style:{fontWeight:600}},t.label),e.createElement("div",{style:{fontSize:11}},o?"drop a step here":"leads nowhere yet \u2014 click to choose")),te=Ko;var Zo=({entries:t,at:o,onPick:s,onConnect:r,onDismiss:n,hideStepTypeCodes:a})=>e.createElement(D,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:o.y,left:o.x,width:210,padding:8,borderRadius:8}},e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),t.map(p=>e.createElement(w,{key:p.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>s(p)},p.label,!a&&e.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},p.type))),r&&e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:n},"Cancel")),ee=Zo;var Qo=t=>o=>o.label.toLowerCase().includes(t.trim().toLowerCase()),Ro=(t,o,s="")=>{let r=Object.values(o).flat(),n=Object.entries(o).map(([a,p])=>({heading:a,entries:p.map(c=>t.find(l=>l.type===c)).filter(Boolean)}));return[{heading:null,entries:t.filter(a=>!r.includes(a.type))},...n].map(a=>({...a,entries:a.entries.filter(Qo(s))})).filter(a=>a.entries.length>0)},tr={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},er={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},or={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},rr=({entries:t,groups:o,onPick:s,onCarry:r,onDrop:n})=>{let[a,p]=E("");return e.createElement(D,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:tr},e.createElement(I,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:a,onChange:c=>p(c.target.value),style:{marginBottom:6,fontSize:12}}),Ro(t,o,a).map(c=>e.createElement(e.Fragment,{key:c.heading||""},c.heading&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:er},c.heading),c.entries.map(l=>e.createElement(D,{as:"button",type:"button",key:l.type,"data-step-type":l.type,className:"bg-surface-50 dark:bg-surface-950",style:or,draggable:!0,onClick:()=>s(l),onDragStart:m=>{m.dataTransfer.effectAllowed="copyMove",m.dataTransfer.setData("text/plain",l.type),r(l)},onDragEnd:n},l.label)))))},oe=rr;var sr={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},re=({label:t,title:o,idle:s,enabled:r,onUse:n})=>e.createElement(w,{variant:"secondary",size:"sm",title:r?o:s,disabled:!r,onClick:n,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},t),nr=({undoable:t,redoable:o,onAdd:s,onUndo:r,onRedo:n})=>e.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},e.createElement(w,{variant:"secondary",className:"rounded-full",style:sr,title:"Add a step",onClick:s},"+"),e.createElement(re,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:t,onUse:r}),e.createElement(re,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),se=nr;var ar=({type:t="info",title:o,message:s,onDismiss:r,className:n})=>e.createElement("div",{className:A("ks-alert",`ks-alert-${t}`,n),role:"alert"},e.createElement("div",{className:"ks-alert-body"},e.createElement("div",{className:"ks-alert-content"},o&&e.createElement("p",{className:"ks-alert-title"},o),e.createElement("p",{className:o?"ks-alert-message-titled":"ks-alert-message"},s)),r&&e.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),ne=ar;var ae=t=>{let o=t.map(s=>`\u201C${s.name}\u201D`).join(", ");return t.length===1?`${o} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${o} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var ie=({version:t,published:o})=>t?o?o===t?`Version ${t} \xB7 live`:`Version ${t} \xB7 visitors still on ${o}`:`Version ${t} \xB7 never published`:"No version yet";var ir={width:280,padding:20,overflowY:"auto"},le={fontWeight:600,marginBottom:6,marginTop:14},yt={fontSize:12,marginBottom:4,lineHeight:1.4},de={display:"block",marginBottom:3},ce=(t,o,s)=>r=>{r.target.value!==(t[o]??"")&&s({[o]:r.target.value})},lr=({flow:t,changes:o,refusal:s,notice:r,publishNote:n,warning:a,onCreate:p,onPublish:c,onAccept:l,onDecline:m,onSaveDetails:u,onClose:x})=>e.createElement(D,{as:"aside",style:ir,"data-builder-panel":!0},e.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},e.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},t.title||t.slug),e.createElement("button",{title:"Close",onClick:x,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),e.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:t.history_url,"data-history":!0},ie(t)),a?e.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},e.createElement(ne,{type:"warning",className:"mb-1.5",message:ae(a.steps)}),e.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:l,"data-accept-removal":!0},a.path==="/publish"?"Remove and publish":"Remove and create version"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:m,"data-decline-removal":!0},"Cancel")):e.createElement("div",{style:{marginTop:14}},e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:p,"data-create-version":!0},"Create version"),e.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:c,"data-publish":!0},"Publish"),n&&e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},n)),s&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...yt,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&e.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...yt,fontWeight:600,marginTop:8},"data-notice":!0},r),e.createElement("h2",{style:le},"Changes since the last version"),o.length===0?e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):o.map((h,d)=>e.createElement("p",{key:d,style:yt,"data-change":!0},h)),e.createElement("h2",{style:le},"Details"),e.createElement(q,null,e.createElement("span",{style:de},"Title"),e.createElement(I,{className:"mb-3",defaultValue:t.title??"",onBlur:ce(t,"title",u),"data-flow-title":!0})),e.createElement(q,null,e.createElement("span",{style:de},"Start label"),e.createElement(I,{className:"mb-3",defaultValue:t.start_label??"",onBlur:ce(t,"start_label",u),"data-flow-start-label":!0})),e.createElement("div",{style:{marginTop:16}},e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.definition_url,"data-definition":!0},"Definition"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.details_url,"data-details":!0},"Edit details"))),pe=lr;var dr=({variant:t="neutral",className:o,children:s,...r})=>e.createElement("span",{...r,className:A("ks-badge",`ks-badge-${t}`,o)},s),me=dr;var cr={center:"ks-tab-bar flex flex-wrap justify-center max-sm:flex-nowrap max-sm:overflow-x-auto max-sm:justify-start",start:"ks-tab-bar flex flex-wrap justify-start max-sm:flex-nowrap max-sm:overflow-x-auto"},pr={pills:"ks-tab-bar-pills",underline:"ks-tab-bar-underline"},mr="ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",ur="ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",fr=({shape:t,count:o})=>t?e.createElement("span",{className:"ks-tab-count"},o):e.createElement(me,{variant:"info"},o),gr=t=>typeof t=="string"?t!=="":t>0,hr=({tabs:t,value:o,onChange:s,align:r="center",shape:n,className:a})=>e.createElement("div",{className:a},e.createElement("div",{className:A(cr[r],pr[n])},t.map(p=>e.createElement("button",{key:p.value,type:"button",className:n?ur:mr,"data-active":p.value===o?"":void 0,onClick:()=>s(p.value)},p.label,gr(p.count)&&e.createElement(e.Fragment,null," ",e.createElement(fr,{shape:n,count:p.count}))))),t.find(p=>p.value===o)?.content),ue=hr;var xr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},fe="mx-6 mb-6 flex max-h-[45%] flex-none flex-col overflow-y-auto rounded-lg max-sm:m-0 max-sm:max-h-none max-sm:rounded-none [&_.ks-tab-bar]:mb-0 [&_.ks-tab-bar]:px-2",yr="max-sm:absolute max-sm:inset-0 max-sm:z-20",xe={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},ge={display:"flex",gap:8,textAlign:"left"},he={flexShrink:0,whiteSpace:"nowrap"},br=({check:t,onSelect:o})=>{let s=e.createElement(e.Fragment,null,e.createElement("span",{className:xr[t.level],style:{...he,fontWeight:500}},t.level),t.node&&e.createElement("span",{className:"font-mono",style:he},t.node),e.createElement("span",null,t.sentence));return t.node?e.createElement("button",{type:"button","data-check-row":!0,"data-step-id":t.node,style:{...ge,border:"none",background:"none",padding:0,cursor:"pointer",font:"inherit",color:"inherit"},onClick:()=>o(t.node)},s):e.createElement("div",{"data-check-row":!0,style:ge},s)},vr=({checks:t,onSelect:o})=>e.createElement("div",{style:xe},t.map((s,r)=>e.createElement(br,{key:r,check:s,onSelect:o}))),wr=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,kr=({checks:t,tabs:o,onSelect:s,opened:r=wr()?null:"validation"})=>{let[n,a]=E(r);return e.createElement(D,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${fe} ${yr}`:fe},e.createElement(ue,{align:"start",shape:"underline",value:n,onChange:p=>a(p===n?null:p),tabs:[{value:"validation",label:"Validation",count:t.filter(p=>p.level==="error").length,content:e.createElement(vr,{checks:t,onSelect:s})},...o.map(p=>({value:p.label,label:p.label,count:p.count??"",content:e.createElement("div",{"data-drawer-content":!0,style:xe,dangerouslySetInnerHTML:{__html:p.content}})}))]}))},ye=kr;var be={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},ve=t=>({opacity:t?1:0,transition:"opacity .12s"}),Sr=({link:t,onInsert:o,onRemove:s,onDrop:r,dragging:n,alwaysShowInsertButtons:a})=>{let[p,c]=E(!1),l=p||n;return e.createElement("div",{"data-connector":`${t.source}-${t.target}`,style:{position:"absolute",left:t.midX-34,top:t.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onDragEnter:()=>c(!0),onDragLeave:()=>c(!1),onDragOver:m=>{m.preventDefault(),m.dataTransfer.dropEffect="move"},onDrop:m=>{m.preventDefault(),c(!1),r()}},e.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},e.createElement(w,{variant:"secondary",title:n?"Move the step here":"Insert a step here",onClick:o,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(n&&p),style:{...be,...ve(l||a)}},"+"),!n&&e.createElement(w,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...be,...ve(l)}},"\xD7")))},we=Sr;var Cr=({links:t,extent:o,dragging:s,onInsert:r,onRemove:n,onDrop:a,alwaysShowInsertButtons:p})=>e.createElement(e.Fragment,null,e.createElement("svg",{width:o.width,height:o.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},e.createElement("defs",null,e.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},e.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),t.map(c=>e.createElement("path",{key:c.id,"data-link":c.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:c.path}))),t.filter(c=>c.label).map(c=>e.createElement("div",{key:`${c.id}-label`,"data-link-label":c.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:c.midX+(p?2:-10),top:c.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},c.label)),t.filter(c=>!c.placeholder).map(c=>e.createElement(we,{key:c.id,link:c,dragging:!!s,alwaysShowInsertButtons:p,onInsert:()=>r(c),onRemove:()=>n(c),onDrop:()=>a(c)}))),ke=Cr;var bt={width:22,height:22,padding:0,fontSize:14,lineHeight:"14px"},Se="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Nr={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:2,height:"100%"},Er=({link:t,onInsert:o,onRemove:s,onDrop:r,alwaysShowInsertButtons:n,dragging:a,shown:p=!1,className:c="",style:l,children:m})=>e.createElement("div",{"data-joint":t?.id,className:`group ${c}`.trim(),style:l,onMouseEnter:u=>{u.currentTarget.dataset.over="true"},onMouseLeave:u=>{delete u.currentTarget.dataset.over},onDragOver:u=>{t&&r&&(u.preventDefault(),u.dataTransfer.dropEffect="move")},onDrop:u=>{t&&(u.preventDefault(),r(t))}},m,t&&o&&e.createElement("div",{style:Nr},e.createElement(w,{variant:"secondary",title:"Insert a step here",onClick:u=>o(t,u),className:`rounded-full ${n?"opacity-100":Se}`,style:a?{...bt,opacity:1}:bt},"+"),e.createElement(w,{variant:"danger",title:"Remove this connection",onClick:()=>s(t),className:`rounded-full ${p?"opacity-100":Se}`,style:bt},"\xD7"))),it=Er;var _r=(t,o)=>{let s=new Map(t.map(p=>[p,0])),r=new Map(t.map(p=>[p,[]])),n=new Map(t.map(p=>[p,0]));o.forEach(p=>{r.get(p.source).push(p.target),n.set(p.target,n.get(p.target)+1)});let a=t.filter(p=>n.get(p)===0);for(let p=0;p<a.length;p++){let c=a[p];r.get(c).forEach(l=>{s.set(l,Math.max(s.get(l),s.get(c)+1)),n.set(l,n.get(l)-1),n.get(l)===0&&a.push(l)})}return s},wt=(t,o)=>{let s=new Map(t.map(r=>[r,[]]));return o.forEach(r=>s.get(r.source).push(r)),s},Ar=(t,o)=>{let s=wt(t,o),r=new Set(o.map(c=>c.target)),n=new Map,a=new Set,p=c=>{let l=[[c,0]];for(n.set(c,"open");l.length>0;){let m=l[l.length-1],u=s.get(m[0])[m[1]++];u?n.get(u.target)==="open"?a.add(u):n.has(u.target)||(n.set(u.target,"open"),l.push([u.target,0])):(n.set(m[0],"done"),l.pop())}};return t.filter(c=>!r.has(c)).forEach(p),t.forEach(c=>{n.has(c)||p(c)}),a},zr=(t,o,s)=>{let r=[];t.forEach(l=>{var m;return(r[m=s.get(l)]||(r[m]=[])).push(l)});let n=wt(t,o),a=new Map;n.forEach(l=>l.forEach((m,u)=>a.set(m,(u+1)/(l.length+1))));let p=new Map(t.map(l=>[l,[]]));o.forEach(l=>p.get(l.target).push(l));let c=new Map;return r.forEach(l=>{let m=new Map(l.map(u=>{let x=p.get(u),h=x.reduce((d,f)=>d+c.get(f.source)+a.get(f),0);return[u,x.length>0?h/x.length:1/0]}));l.sort((u,x)=>m.get(u)===m.get(x)?0:m.get(u)<m.get(x)?-1:1),l.forEach((u,x)=>c.set(u,x))}),c};var vt=(t,o,s)=>{let r=[];return t.forEach((n,a)=>{r[a]=a===0?s:r[a-1]+t[a-1]+o}),r},Tr=(t,o)=>t.length>0?t[t.length-1]+o[o.length-1]:0,Mr=t=>{let o=[t];for(let s=1;s*2<=t.length;s*=2){let r=o[o.length-1];o.push(r.slice(0,t.length-s*2+1).map((n,a)=>Math.max(n,r[a+s])))}return(s,r)=>{let n=Math.floor(Math.log2(r-s+1));return Math.max(o[n][s],o[n][r-(1<<n)+1])}},Ce=(t,o,s,r)=>{let n=Ar(t,o),a=o.filter(g=>!n.has(g)),p=_r(t,a),c=zr(t,a,p),l=[],m=[];t.forEach(g=>{var S;l[p.get(g)]=Math.max(l[p.get(g)]||0,s(g).width),(m[S=p.get(g)]||(m[S]=[]))[c.get(g)]=g});let u=g=>p.get(g.target)>p.get(g.source)+1,x=g=>{let S=new Map;return g.forEach(M=>{S.has(M.target)||S.set(M.target,S.size)}),S},h=x(o.filter(g=>n.has(g))),d=x(a.filter(u)),f=vt(l,64,r.left),_=r.top+h.size*14,v=new Map,C=m.map(g=>{let S=g.map(M=>s(M).height);return vt(S,24,_).forEach((M,W)=>v.set(g[W],M)),Tr(vt(S,24,_),S)}),k=Mr(C),N=Object.fromEntries(t.map(g=>[g,{column:p.get(g),row:c.get(g),x:f[p.get(g)],y:v.get(g),width:s(g).width,height:s(g).height}])),O=new Map;a.filter(u).forEach(g=>O.set(g.target,Math.max(O.get(g.target)||0,k(p.get(g.source)+1,p.get(g.target)-1))));let b=g=>n.has(g)?r.top+(h.size-1-h.get(g.target))*14:u(g)?O.get(g.target)+(d.get(g.target)+1)*14:null,B=g=>N[g].y+(s(g).arrives??N[g].height/2),T=g=>b(g)??B(g.target),H=new Map;wt(t,o).forEach(g=>[...g].sort((S,M)=>T(S)-T(M)).forEach((S,M)=>H.set(S,(M+1)/(g.length+1))));let pt=g=>{let S=N[g.source],M=N[g.target],W=S.y+S.height*H.get(g),U=B(g.target),X=f[S.column]+l[S.column]+40,V=b(g),Q=[[S.x+S.width,W],[X,W]],F=[[M.x-64+40,U],[M.x,U]];return{...g.drawn,points:V===null?[...Q,[X,U],F[1]]:[...Q,[X,V],[F[0][0],V],...F]}},K=o.map(pt),Z=[...Object.values(N).map(g=>[g.x+g.width,g.y+g.height]),...K.flatMap(g=>g.points)].reduce(([g,S],[M,W])=>[Math.max(g,M),Math.max(S,W)],[0,0]);return{places:N,links:K,width:Z[0]+r.right,height:Z[1]+r.bottom}},J="\0entry";var Or={left:44,top:40,right:20,bottom:40},Br={left:0,top:8,right:16,bottom:12},lt=(t,o,{heights:s={}}={})=>{let r=new Set(t.map(d=>d.id)),n=new Map(t.flatMap(d=>(d.holds||[]).filter(f=>r.has(f)).map(f=>[f,d.id]))),a=new Map([[null,{ids:[],edges:[]}]]);t.filter(d=>d.holds).forEach(d=>a.set(d.id,{ids:[J],edges:[]})),t.forEach(d=>a.get(n.get(d.id)??null).ids.push(d.id)),o.filter(d=>r.has(d.source)&&r.has(d.target)).forEach(d=>{let f=n.get(d.target);f&&f===d.source?a.get(f).edges.push({source:J,target:d.target,drawn:d}):f&&f===n.get(d.source)?a.get(f).edges.push({source:d.source,target:d.target,drawn:d}):a.get(null).edges.push({source:n.get(d.source)??d.source,target:f??d.target,drawn:d})});let p=d=>({width:184,height:s[d]||64}),c=new Map([...a].filter(([d])=>d).map(([d,f])=>[d,Ce(f.ids,f.edges,_=>_===J?{width:0,height:64}:p(_),Br)])),l=d=>s[d]||24,m=d=>{let f=c.get(d);return f?{width:f.width,height:l(d)+f.height,arrives:l(d)+f.places[J].y+64/2}:p(d)},u=Ce(a.get(null).ids,a.get(null).edges,m,Or),x={...u.places},h=[...u.links];return c.forEach((d,f)=>{let _=u.places[f],[v,C]=[_.x,_.y+l(f)];Object.entries(d.places).filter(([k])=>k!==J).forEach(([k,N])=>{x[k]={...N,x:N.x+v,y:N.y+C}}),d.links.forEach(k=>h.push({...k,points:k.points.map(([N,O])=>[N+v,O+C])}))}),{places:x,links:h,width:u.width,height:u.height}};var Dr={display:"flex",flexDirection:"column",gap:14,padding:"64px 16px 24px"},Lr={display:"flex",flexDirection:"column",gap:10,padding:"8px 10px",borderRadius:8},Pr={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,minHeight:26,paddingLeft:12,fontSize:11},Ir=t=>(o,s)=>t[o.id].column-t[s.id].column||t[o.id].row-t[s.id].row,$r=t=>t?.placeholder?"nowhere yet":t?.label,Hr=({node:t,leaving:o,named:s,draw:r,joints:n})=>e.createElement("div",{"data-step-row":t.id},r(t),o.map(a=>e.createElement(it,{key:a.id,link:a,...n,alwaysShowInsertButtons:!0,shown:!0,className:"border-l border-gray-300 text-gray-500 dark:border-zinc-600 dark:text-gray-400",style:Pr},e.createElement("span",null,[a.label,"\u2192",s.get(a.target)].filter(Boolean).join(" "))))),Wr=({nodes:t,edges:o,draw:s,joints:r,children:n,style:a})=>{let{places:p}=lt(t,o),c=new Map(t.map(d=>[d.id,$r(d)])),l=new Map(t.map(d=>[d.id,[]]));o.forEach(d=>{l.has(d.source)&&c.has(d.target)&&l.get(d.source).push(d)});let m=new Map(t.flatMap(d=>(d.holds||[]).map(f=>[f,d.id]))),u=[...t].sort(Ir(p)),x=new Map;u.filter(d=>m.has(d.id)).forEach(d=>{x.has(m.get(d.id))||x.set(m.get(d.id),[]),x.get(m.get(d.id)).push(d)});let h=d=>e.createElement(Hr,{key:d.id,node:d,leaving:l.get(d.id),named:c,draw:s,joints:r});return e.createElement("div",{"data-flow-rows":!0,style:{...Dr,...a}},n,u.filter(d=>!m.has(d.id)).map(d=>d.holds?e.createElement("div",{key:d.id,"data-group-box":d.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:Lr},h(d),(x.get(d.id)||[]).map(h)):h(d)))},Ne=Wr;var jr={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:14,padding:"64px 0 0"},Gr={position:"absolute",zIndex:3,maxWidth:56,fontSize:10,lineHeight:"13px",pointerEvents:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Vr=t=>t.map(([o,s],r)=>`${r===0?"M":"L"} ${o} ${s}`).join(" "),Fr=t=>Object.fromEntries(Object.entries(t).filter(([,o])=>o?.firstElementChild).map(([o,s])=>[o,s.firstElementChild.offsetHeight])),Ur=(t,o)=>Object.keys(o).some(s=>t[s]!==o[s]),Xr=({nodes:t,edges:o,draw:s,joints:r})=>{let[n,a]=E({}),p=Y({}),c=P(()=>lt(t,o,{heights:n}),[t,o,n]);R(()=>{let m=Fr(p.current);Ur(n,m)&&a({...n,...m})});let l=m=>u=>{p.current[m]=u};return e.createElement("div",{"data-flow-graph":!0,style:{position:"relative",flex:"none",width:c.width,height:c.height}},e.createElement("svg",{width:c.width,height:c.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("defs",null,e.createElement("marker",{id:"easy_flow-graph-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},e.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),c.links.map(m=>e.createElement("path",{key:m.id,"data-link":m.id,d:Vr(m.points),fill:"none",strokeWidth:"1.5",className:"stroke-gray-400 dark:stroke-zinc-500",markerEnd:"url(#easy_flow-graph-arrow)"}))),t.map(m=>{let u=c.places[m.id];return m.holds?e.createElement("div",{key:m.id,ref:l(m.id),"data-group-box":m.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",left:u.x,top:u.y,width:u.width,height:u.height,boxSizing:"border-box",borderRadius:8}},e.createElement("div",{style:{padding:"4px 10px"}},s(m))):e.createElement("div",{key:m.id,ref:l(m.id),style:{position:"absolute",left:u.x,top:u.y,width:u.width,zIndex:2}},s(m))}),c.links.filter(m=>m.label).map(m=>e.createElement("div",{key:`${m.id}-label`,"data-link-label":m.id,title:m.label,className:"text-gray-500 dark:text-gray-400",style:{...Gr,left:m.points[0][0]+6,top:m.points[0][1]-14}},m.label)),r.onInsert&&c.links.filter(m=>!m.placeholder).map(m=>e.createElement(it,{key:m.id,link:m,...r,style:{position:"absolute",left:m.points[0][0],top:m.points[0][1]-12,width:62,height:24,zIndex:3}})))},_e="(min-width: 640px)",Yr=()=>typeof window>"u"||!window.matchMedia||window.matchMedia(_e).matches,qr=()=>{let[t,o]=E(Yr);return L(()=>{if(!window.matchMedia)return;let s=window.matchMedia(_e),r=()=>o(s.matches);return s.addEventListener("change",r),()=>s.removeEventListener("change",r)},[]),t},Jr=({nodes:t,edges:o,draw:s,joints:r,children:n,style:a})=>qr()?e.createElement("div",{"data-flow-rows":!0,style:{...jr,...a}},n,e.createElement(Xr,{nodes:t,edges:o,draw:s,joints:r})):e.createElement(Ne,{nodes:t,edges:o,draw:s,joints:r,style:a},n),dt=Jr;var ze="Your change was not saved because the server could not be reached.",Kr="Your change was saved, but the canvas could not be refreshed. Reload the page to see it.",Ae=async({base:t,fetch:o,onFlow:s,onError:r})=>{let n=await o(t+".json",{headers:{Accept:"application/json"}}).catch(()=>null),a=n?.ok?await n.json().catch(()=>null):null;return a?s(a):r(Kr)},Te=({base:t,token:o,fetch:s,onFlow:r,onError:n,onNotice:a,onWarning:p=()=>{}})=>async(c,l,m)=>{let u={base:t,fetch:s,onFlow:r,onError:n},x=await s(t+c,{method:l,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:m&&JSON.stringify(m)}).catch(()=>null);if(!x)return a(null),n(ze);let h=await x.json().catch(()=>({}));return h.unconnected?(a(null),n(null),p({path:c,steps:h.unconnected}),Ae(u)):(p(null),x.ok?(n(null),a(h.notice||null),Ae(u)):(a(null),n(h.error||"That change was refused")))},Me=({base:t,token:o,fetch:s,onError:r})=>async n=>{let a=new FormData;a.append("picture",n);let p=await s(t+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:a}).catch(()=>null);if(!p)return r(ze),null;let c=await p.json().catch(()=>({}));return p.ok?(r(null),c):(r(c.error||"That picture was refused"),null)};var Zr=(t,o,s)=>{let[r,n]=E(s),[a,p]=E(null),[c,l]=E(null),[m,u]=E(null),x=P(()=>Te({base:t,token:o,fetch:(...d)=>window.fetch(...d),onFlow:n,onError:p,onNotice:l,onWarning:u}),[t,o]),h=P(()=>Me({base:t,token:o,fetch:(...d)=>window.fetch(...d),onError:p}),[t,o]);return{flow:r,error:a,notice:c,warning:m,setWarning:u,send:x,pickPicture:h}},Oe=Zr;var ct=(t,o,s,r)=>{let n=t.left-s.left+r.scrollLeft,a=t.top-s.top+r.scrollTop;return o==="left"?{x:n,y:a+t.height/2}:o==="right"?{x:n+t.width,y:a+t.height/2}:o==="top"?{x:n+t.width/2,y:a}:{x:n+t.width/2,y:a+t.height}},Qr=(t,o,s)=>s&&o==="top"?{x:t.x,y:s.top}:t,Rr=(t,o)=>o==="top"?{x:t.x,y:t.y-3}:o==="left"?{x:t.x-3,y:t.y}:o==="right"?{x:t.x+3,y:t.y}:{x:t.x,y:t.y+3},ts=(t,o,s,r,n)=>{let a={straight:`M ${o.x} ${o.y} L ${s.x} ${s.y}`,turn:`M ${o.x} ${o.y} H ${s.x} V ${s.y}`,lane:`M ${o.x} ${o.y} V ${r} H ${s.x} V ${s.y}`,detour:`M ${o.x} ${o.y} H ${n} V ${s.y} H ${s.x}`}[t.route];return{...t,path:a,midX:t.route==="detour"?n:(o.x+s.x)/2,midY:t.route==="lane"?r:(o.y+s.y)/2}},es=(t,o,s,r)=>{let[n,a]=E([]),[p,c]=E({width:"100%",height:"100%"}),[l,m]=E([]);return R(()=>{let u=()=>{let h=o.current?.getBoundingClientRect();if(!h)return;c({width:o.current.scrollWidth,height:o.current.scrollHeight});let d=t.nodes.filter(f=>f.holds&&!f.loose&&s.current[f.id]).map(f=>{let _=s.current[f.id],v=_.getBoundingClientRect(),C=f.holds.flatMap(N=>s.current[N]?[s.current[N].getBoundingClientRect()]:[]),k=[{left:v.left,top:v.top,width:Math.max(v.width,_.scrollWidth),height:v.height},...C];return{id:f.id,bounds:It(k,h,o.current)}});m(d),a(t.edges.flatMap(f=>{let _=s.current[f.source]?.getBoundingClientRect(),v=s.current[f.target]?.getBoundingClientRect();if(!_||!v)return[];let C=ct(_,f.leaves,h,o.current),k=d.find(B=>B.id===f.target)?.bounds,N=Rr(Qr(ct(v,f.enters,h,o.current),f.enters,k),f.enters),O=(ct(_,"bottom",h,o.current).y+ct(v,"top",h,o.current).y)/2,b=f.leaves==="left"?Math.min(C.x,N.x)-28:Math.max(C.x,N.x)+28;return[ts(f,C,N,O,b)]}))};u(),window.addEventListener("resize",u);let x=new ResizeObserver(u);return o.current&&x.observe(o.current),()=>{window.removeEventListener("resize",u),x.disconnect()}},r),{links:n,extent:p,boxes:l}},Be=es;var De=(t,o)=>{let s=new Set(o),r=t,n=2;for(;s.has(r);)r=`${t}_${n++}`;return r};var Le=({send:t,onPress:o})=>s=>{let r=s.target.closest?.("[data-bar-action]");r&&(r.closest("details")?.removeAttribute("open"),o(),r.dataset.barPath&&t(r.dataset.barPath,"POST"))};var rs=8,ss={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},ns={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},as={flex:1,minHeight:0,overflow:"auto",position:"relative"},Ie={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},is={...Ie,position:"static",alignSelf:"flex-start"},ls={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},$e={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},ds=({port:t,onCancel:o})=>e.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:$e},"Choose the step \u201C",t||"next","\u201D should lead to \u2014 ",e.createElement("button",{onClick:o,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),cs=({message:t})=>e.createElement("p",{"data-canvas-error":!0,className:"bg-red-50 text-red-800 dark:bg-red-950 dark:text-red-200",style:$e},t),ps=({base:t,token:o,initial:s})=>{let{flow:r,error:n,notice:a,warning:p,setWarning:c,send:l,pickPicture:m}=Oe(t,o,s),[u,x]=E(null),[h,d]=E(null),[f,_]=E(null),[v,C]=E(null),[k,N]=E(null),[O,b]=E(!1),B=Y({}),T=Y(null);L(()=>{let i=Le({send:l,onPress:()=>{x(null),b(!0)}});return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[l]),L(()=>{if(!O){c(null);return}let i=y=>{y.target.isConnected&&!y.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&b(!1)};return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[O]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let H=P(()=>Object.fromEntries(r.nodes.map(i=>[i.id,i])),[r.nodes]),{links:pt,extent:K,boxes:mt}=Be(r,T,B,[r,u,H]),Z=P(()=>{let i={};return r.violations.forEach(y=>{var z;return(i[z=y.node]||(i[z]=[])).push(y)}),i},[r.violations]),g=r.direction==="left_to_right",S=P(()=>r.nodes.filter(i=>!i.loose),[r.nodes]),M=r.nodes.filter(i=>i.loose),W=P(()=>{let i={};return r.edges.forEach(y=>{var z;return(i[z=y.source]||(i[z]=[])).push(y.label||null)}),i},[r.edges]),U=Math.max(0,...S.map(i=>i.row))+1,X=Math.max(0,...S.map(i=>i.column))+1,V=i=>{if(!f)return;let[y,z]=f;_(null),y!==i&&l("/edges","POST",{from:y,to:i,on:z||null})},Q=i=>{if(i.isDefaultPrevented()||!v)return;i.preventDefault();let y=v;C(null);let z=T.current.getBoundingClientRect(),_t=$t(mt,{x:i.clientX-z.left+T.current.scrollLeft,y:i.clientY-z.top+T.current.scrollTop}),Ue=r.nodes.find(Xe=>Xe.holds?.includes(y))?.id||null;_t!==Ue&&l(`/steps/${y}/group`,"PATCH",{group:_t})},F=i=>[...r.palette,...r.unoffered||[]].find(y=>y.type===i?.type),j=r.nodes.find(i=>i.id===u),$=F(j),ut=(i,y={})=>l("/steps","POST",{id:De(i.type,r.nodes.map(z=>z.id)),type:i.type,from:y.from,to:y.to,on:y.on}),kt=i=>{let[y,z]=[k,v];N(null),C(null),y?ut(y,{from:i.source,to:i.target}):z&&l("/steps/"+z+"/move","PATCH",{from:i.source,to:i.target})},St=i=>{let y=T.current.getBoundingClientRect();return{x:i.clientX-y.left+T.current.scrollLeft+8,y:i.clientY-y.top+T.current.scrollTop+8}},Ct=(i,y)=>({node:{...i,ref:z=>{B.current[i.id]=z},violations:Z[i.id]||[],connected:y},selected:i.id===u,armed:f&&f[0]===i.id?f[1]:null,connecting:!!f&&f[0]!==i.id,onSelect:()=>f?V(i.id):x(i.id),onOpen:z=>window.location.assign(z),onDragStart:()=>C(i.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes,compact:g}),Nt=i=>e.createElement(e.Fragment,null,i.placeholder&&e.createElement(te,{node:{...i,ref:y=>{B.current[i.id]=y}},dragging:!!v,compact:g,onFill:()=>d({from:i.from,on:i.on,at:{x:16,y:52}}),onDrop:()=>{let y=v;C(null),y&&l("/edges","POST",{from:i.from,to:y,on:i.on})}}),i.holds&&e.createElement(et,{node:{...i,ref:y=>{B.current[i.id]=y}},header:ot(i,F(i),r.hide_step_type_codes),compact:g,onSelect:()=>f?V(i.id):x(i.id)}),!i.placeholder&&!i.holds&&e.createElement(gt,{...Ct(i,W[i.id]||[]),onArm:(y,z)=>d({from:i.id,on:y,at:St(z)})})),Et=M.length>0&&e.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:g?is:Ie},e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:6}},"Not in the flow yet \u2014 drag one onto a connection"),M.map(i=>e.createElement("div",{key:i.id,style:{marginBottom:8}},e.createElement(gt,{...Ct(i,[]),onArm:(y,z)=>{z.stopPropagation(),_([i.id,y])}}))));return e.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:ss,onMouseUp:()=>C(null),onKeyDown:i=>{i.key==="Escape"&&(x(null),_(null),d(null))},tabIndex:-1},e.createElement(oe,{entries:r.palette,groups:r.step_groups||{},onPick:i=>ut(i),onCarry:N,onDrop:()=>N(null)}),e.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:ns},e.createElement("div",{ref:T,style:as,onClick:i=>{i.target===T.current&&(x(null),_(null),b(!1))},onDragOver:i=>{v&&i.preventDefault()},onDrop:Q},f&&e.createElement(ds,{port:f[1],onCancel:()=>_(null)}),n&&!O&&!j&&e.createElement(cs,{message:n}),e.createElement(se,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>d({at:{x:16,y:52}}),onUndo:()=>{x(null),l("/undo","POST")},onRedo:()=>{x(null),l("/redo","POST")}}),!g&&mt.map(i=>e.createElement(Pt,{key:i.id,id:i.id,bounds:i.bounds,onDrop:()=>{let y=v;C(null),y&&l(`/steps/${y}/group`,"PATCH",{group:i.id})}})),!g&&e.createElement(ke,{links:Ht(pt,r.nodes),extent:K,dragging:v||k,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:i=>d({from:i.source,to:i.target,at:{x:i.midX+30,y:i.midY}}),onRemove:i=>{x(null),l("/edges","DELETE",{from:i.source,to:i.target})},onDrop:kt}),!g&&Et,g&&e.createElement(dt,{nodes:S,edges:r.edges,draw:Nt,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(v||k),onInsert:(i,y)=>d({from:i.source,to:i.target,at:St(y)}),onRemove:i=>{x(null),l("/edges","DELETE",{from:i.source,to:i.target})},onDrop:kt}},Et),!g&&e.createElement("div",{style:{...ls,gridTemplateColumns:`repeat(${X+1}, ${280/2}px)`,gridTemplateRows:`repeat(${U}, auto)`}},S.map(i=>e.createElement("div",{key:i.id,style:{gridRow:i.row+1,gridColumn:`${i.column+1} / span 2`,zIndex:2,marginTop:Wt(i,r.nodes)?rs-64:0}},Nt(i)))),h&&e.createElement(ee,{entries:r.palette,at:h.at,onDismiss:()=>d(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:h.on!==void 0?()=>{_([h.from,h.on]),d(null)}:null,onPick:i=>{let y=h;d(null),ut(i,y)}})),e.createElement(ye,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:x})),O&&!j&&e.createElement(pe,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:a,publishNote:r.publish_note,warning:p,onClose:()=>b(!1),onCreate:()=>l("/versions","POST"),onPublish:()=>l("/publish","POST"),onAccept:()=>l(p.path,"POST",{remove_unconnected:p.steps.map(i=>i.id)}),onDecline:()=>c(null),onSaveDetails:i=>l("/details","PATCH",{flow:i})}),j&&e.createElement(Rt,{node:j,fields:$?.fields||{},holds:$?.records||{},labels:$?.labels||{},explanations:$?.explanations||{},recordLabels:$?.record_labels||{},recordExplanations:$?.record_explanations||{},recordChoices:$?.record_choices||{},recordOutputsOf:$?.record_outputs_of||{},choices:jt(j,$),onClose:()=>x(null),onSave:i=>l(`/steps/${j.id}`,"PATCH",{config:i}),onPickPicture:m,refusal:n,notice:a,onDelete:()=>{x(null),l(`/steps/${j.id}`,"DELETE")}}))},He=ps;var ms={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},We={fontSize:12,fontWeight:500,lineHeight:1.3},je={done:"border-green-600 bg-green-50 dark:border-green-500 dark:bg-green-950",paused:"border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-950",pending:"border-gray-300 bg-white text-gray-500 dark:border-zinc-700 dark:bg-zinc-900 dark:text-gray-400",failed:"border-red-600 bg-red-50 dark:border-red-500 dark:bg-red-950"},Ge={done:"text-green-700 dark:text-green-400",paused:"text-amber-800 dark:text-amber-300",pending:"text-gray-500 dark:text-gray-400",failed:"text-red-700 dark:text-red-400"},us="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",fs=({node:t,selected:o=!1})=>{let s=t.address?"a":"div",r=t.begins_here||t.ends_here;return e.createElement(s,{"data-step":t.id,href:t.address||void 0,className:`${t.state==="paused"?"border-2":"border"} ${je[t.state]||je.pending}${o?` ${us}`:""}`,style:ms},!r&&e.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.type),e.createElement("div",{style:r?{...We,textAlign:"center"}:We},t.label,t.version&&e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},t.version)),t.status&&e.createElement("div",{className:Ge[t.state]||Ge.pending,style:{fontSize:11}},t.status))},Ve=fs;var gs={gap:12,padding:0,maxWidth:"100%",overflowX:"auto"},hs=({nodes:t,edges:o,selected:s})=>e.createElement(dt,{nodes:t,edges:o,joints:{},style:gs,draw:r=>r.holds?e.createElement(et,{node:r,header:ot(r,r,!1),compact:!0}):e.createElement(Ve,{node:r,selected:r.id===s})}),Fe=hs;ft("easy_flow/flow-editor",He);ft("easy_flow/run-view",Fe);document.addEventListener("easy_flow:flow-named",t=>{let o=document.querySelector("[data-flow-heading]");o&&(o.textContent=t.detail)});document.addEventListener("easy_flow:flow-status",({detail:t})=>{t.status&&document.querySelectorAll("[data-version-status]").forEach(o=>{o.textContent=t.status}),t.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(o=>{o.textContent=`Publish v${t.publishes}`})});Bt(document,At);})();
1
+ (()=>{var Ye=globalThis.ReactDOM;var{createPortal:vs,createRoot:At,flushSync:ws,hydrateRoot:ks,preconnect:Ss,prefetchDNS:Cs,preinit:Ns,preinitModule:Es,preload:_s,preloadModule:As,requestFormReset:zs,unstable_batchedUpdates:Os,useFormState:Ts,useFormStatus:Ms,version:Bs}=Ye;var zt=globalThis.React,e=zt,{Children:Ls,Component:Ps,Fragment:Is,PureComponent:$s,StrictMode:Hs,Suspense:Ws,cloneElement:js,createContext:Gs,createElement:Vs,createRef:Fs,forwardRef:Us,isValidElement:Xs,lazy:Ys,memo:qs,startTransition:Js,useCallback:Ks,useContext:Zs,useDebugValue:Qs,useDeferredValue:Rs,useEffect:L,useId:tn,useImperativeHandle:en,useLayoutEffect:R,useMemo:P,useReducer:on,useRef:Y,useState:E,useSyncExternalStore:rn,useTransition:sn}=zt;var Ot=new Map,tt=new Map,ft=(t,o)=>Ot.set(t,o),Tt=()=>{tt.forEach(t=>t.unmount()),tt.clear()},Mt=(t,o)=>t.querySelectorAll("[data-react-ui]").forEach(s=>{if(tt.has(s))return;let r=Ot.get(s.dataset.reactUi),n=o(s);tt.set(s,n),n.render(e.createElement(r,JSON.parse(s.dataset.props)))});var Bt=(t,o)=>{let s=()=>Mt(t,o);t.addEventListener("turbo:load",s),t.addEventListener("turbo:frame-load",s),t.addEventListener("turbo:before-cache",Tt),t.readyState==="loading"?t.addEventListener("DOMContentLoaded",s):s()};var A=(...t)=>t.filter(Boolean).join(" ");var qe={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},Je={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Ke=({variant:t="primary",size:o="md",className:s,children:r,...n})=>{let a=n.href?"a":"button";return e.createElement(a,{...n,className:A("ks-button",qe[t],Je[o],s)},r)},w=Ke;var Ze="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Qe="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Re="border border-accent-600 bg-accent-600 text-white",to=({name:t,connected:o,armed:s,onArm:r,connecting:n})=>e.createElement("button",{onClick:a=>{n||(a.stopPropagation(),r(a))},title:s?"Now choose a step to connect to":"Connect this branch",className:s?Re:o?Qe:Ze,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},t||"next"),Dt=to;var eo={width:240,boxSizing:"border-box",borderRadius:8},oo={minWidth:120,boxSizing:"border-box",borderRadius:6},ro={padding:"8px 14px",textAlign:"center",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},so={fontWeight:600,lineHeight:1.3},no={fontSize:12,fontWeight:500,lineHeight:1.3},ao=(t,o,s)=>{let r=s?"ring-4 ring-accent-600/15":"shadow-sm";return t||s&&!o?`border-accent-600 ${r}`:o?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},io=(t,o)=>o&&t.label===t.id&&t.type_name||t.label,lo=(t,o)=>[o,t.ends_here&&t.mark].filter(Boolean).join(" \xB7 "),co=(t,o,s)=>s?o===t.type_name?null:t.type_name:t.type,po=({node:t,selected:o,armed:s,connecting:r,onSelect:n,onOpen:a,onArm:p,onDragEnd:c,onDragStart:l,hideStepTypeCodes:m,compact:u=!1,typeAbove:x=u})=>{let h=t.begins_here||t.ends_here,d=t.begins_here,f=t.ends_here?[]:t.ports,_=r&&!d,v=io(t,m),C=co(t,v,m);return e.createElement("div",{ref:t.ref,"data-step":t.id,draggable:!d,onDragStart:k=>{k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("text/plain",t.id),l()},onDragEnd:c,onClick:t.opens&&!r?()=>a(t.opens):n,className:`bg-white ${u&&!o?"border":"border-2"} dark:bg-zinc-900 ${ao(_,t.violations.length>0,o)}`,style:{...u?oo:eo,padding:h?0:u?"8px 10px":"12px 14px",cursor:d?"default":r?"crosshair":"grab"}},!h&&x&&C&&e.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},C),h&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:ro},lo(t,v)),!h&&e.createElement("div",{style:u?no:so},v),t.violations.length>0&&e.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${t.violations.length} error${t.violations.length===1?"":"s"}`),!h&&t.summary&&t.violations.length===0&&e.createElement("div",{className:o?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},t.summary),!h&&!x&&C&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},C),t.picture_url&&e.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),t.starts_a_flow&&e.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),t.opens&&e.createElement(w,{variant:"secondary",size:"sm",className:"mt-2",onClick:k=>{k.stopPropagation(),n()}},"Settings"),f.length>0&&e.createElement("div",{style:{padding:t.begins_here?"0 14px 8px":"10px 0 0"}},f.map(k=>e.createElement(Dt,{key:k,name:k,connected:t.connected.includes(k),connecting:r,armed:s===k,onArm:N=>p(k,N)}))))},gt=po;var Lt={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},mo={...Lt,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},uo=({node:t,header:o,onSelect:s,compact:r=!1})=>e.createElement("div",{ref:t.ref,"data-group-header":t.id,onClick:s,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?mo:Lt,...s?{}:{cursor:"default"}}},o),et=uo;var fo=({id:t,bounds:o,onDrop:s})=>e.createElement("div",{"data-group-box":t,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),s()},className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",zIndex:1,borderRadius:8,boxSizing:"border-box",...o}}),Pt=fo;var go=t=>t!=null&&t!==""&&typeof t!="object",ho=["integer","float"],xo=(t,o,s)=>s&&o.labels?.[t]||t,ot=(t,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>go(t.config[n])).map(n=>`${xo(n,o,s)}${ho.includes(o.fields[n])?"":":"} ${t.config[n]}`);return[s&&t.type_name||t.type,...r].join(" \xB7 ")};var It=(t,o,s)=>{let r=Math.min(...t.map(c=>c.left))-o.left+s.scrollLeft-12,n=Math.min(...t.map(c=>c.top))-o.top+s.scrollTop-10,a=Math.max(...t.map(c=>c.left+c.width))-o.left+s.scrollLeft+12,p=Math.max(...t.map(c=>c.top+c.height))-o.top+s.scrollTop+10;return{left:r,top:n,width:a-r,height:p-n}},yo=({left:t,top:o,width:s,height:r},n)=>n.x>=t&&n.x<=t+s&&n.y>=o&&n.y<=o+r,$t=(t,o)=>t.find(s=>yo(s.bounds,o))?.id||null,Ht=(t,o)=>t.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),Wt=(t,o)=>o.some(s=>s.holds?.includes(t.id)&&!s.loose&&s.row===t.row-1);var ht=(t,o)=>t.includes(o)?t.filter(s=>s!==o):[...t,o],jt=(t,o)=>({...o?.choices||{},...t?.choices||{}});var bo=({as:t="input",disabled:o,className:s,...r})=>e.createElement(t,{...r,disabled:o,className:A("ks-input",o&&"ks-input-disabled",s)}),I=bo;var vo=t=>e.createElement(I,{...t,as:"select"}),Gt=vo;var wo=({className:t,...o})=>e.createElement("input",{type:"checkbox",...o,className:A("ks-checkbox",t)}),rt=wo;var ko=({name:t,value:o,label:s,hint:r,className:n,...a})=>e.createElement("label",{className:"inline-block cursor-pointer relative"},e.createElement("input",{type:"radio",name:t,value:o,...a,className:A("peer sr-only",n)}),e.createElement("span",{className:"ks-radio-card inline-flex flex-col cursor-pointer transition ks-radio-card-highlight"},e.createElement("span",{className:"ks-radio-card-header flex items-start justify-between"},e.createElement("span",{className:"ks-radio-card-label block"},s)),r!=null&&e.createElement("span",{className:"ks-radio-card-hint block text-sm"},r))),Vt=ko;var So=({name:t,options:o,value:s,onChange:r,className:n})=>e.createElement("div",{className:A("flex flex-wrap ks-grid-gap-sm",n)},o.map(a=>e.createElement(Vt,{key:a.value,name:t,...a,checked:a.value===s,onChange:()=>r(a.value)}))),Ft=So;var Ut=t=>(t||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),Co=({name:t,type:o,value:s,choices:r,onChange:n,onSettle:a,onPick:p,pictureUrl:c})=>{if(o==="picture")return e.createElement("div",{className:"mb-3"},s&&c&&e.createElement("img",{src:c,alt:"The step's picture",style:{maxWidth:"100%"}}),s&&e.createElement(w,{type:"button",variant:"secondary",size:"sm","data-remove-picture":!0,onClick:()=>a("")},"Remove picture"),e.createElement("input",{type:"file",accept:"image/*",onChange:l=>l.target.files[0]&&p(l.target.files[0])}));if(o==="boolean")return e.createElement(rt,{checked:!!s,onChange:l=>a(l.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return e.createElement(Gt,{className:"mb-3",value:s??"",onChange:l=>a(l.target.value)},e.createElement("option",{value:""}),Ut(r).map(l=>e.createElement("option",{key:l.value,value:l.value},l.label)));if(o==="radio_cards")return e.createElement("div",{"data-radio-cards":!0,className:"mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full"},e.createElement(Ft,{name:t,value:s,options:r||[],onChange:a}));if(o==="multi_select"){let l=Array.isArray(s)?s:[],m=u=>a(ht(l,u));return e.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(r||[]).map(u=>e.createElement("label",{key:u,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(rt,{checked:l.includes(u),onChange:()=>m(u)}),e.createElement("span",null,u))))}if(o==="flows"){let l=Array.isArray(s)?s:[];return e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},Ut(r).map(m=>e.createElement("label",{key:m.value,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(rt,{checked:l.includes(m.value),onChange:()=>a(ht(l,m.value))}),e.createElement("span",null,m.label))))}return o==="integer"||o==="float"?e.createElement(I,{className:"mb-3",type:"number",step:o==="integer"?"1":"any",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>a(l.target.value)}):e.createElement(I,{className:"mb-3",type:"text",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>a(l.target.value)})},st=Co;var Xt=(t,o,s,r)=>t.map((n,a)=>a===o?{...n,[s]:r}:n);var No=({text:t})=>e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},t),nt=No;var Eo=(t,o,s,r)=>{let n=(t||{})[s],a=(o||{})[s];return a?(n||{})[r[a]]:n},_o=({holds:t,labels:o,explanations:s,rows:r,choices:n,outputsOf:a,onChange:p,onSettle:c})=>{let l=Array.isArray(r)?r:[],m=(u,x,h,d)=>{let f=Xt(l,u,x,h);d?c(f):p(f)};return e.createElement("div",{style:{marginBottom:12}},l.map((u,x)=>e.createElement("div",{key:x,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(t).map(([h,d])=>e.createElement("label",{key:h,style:{display:"block"}},e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[h]||h),e.createElement(st,{type:d,value:u[h],choices:Eo(n,a,h,u),onChange:f=>m(x,h,f,!1),onSettle:f=>m(x,h,f,!0)}),(s||{})[h]&&e.createElement(nt,{text:s[h]}))),e.createElement(w,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>c(l.filter((h,d)=>d!==x))},"Remove"))),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>c([...l,{}])},"Add"))},Yt=_o;var Ao={start:null,end:"ks-value-list-end"},zo="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",Oo="flex flex-col min-w-0",To="ks-value-list-label basis-auto text-xs",Mo=()=>e.createElement("svg",{"aria-label":"Right",role:"img",className:"ks-tone-success inline size-5 align-text-bottom",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},e.createElement("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z",clipRule:"evenodd"})),Bo=({value:t,fallback:o})=>String(t??"")===""?o:t,Do=({rows:t,align:o="start",columns:s=!1,className:r})=>e.createElement("dl",{className:A("ks-value-list",Ao[o],s&&zo,r)},t.map((n,a)=>e.createElement("div",{key:a,className:A(s?Oo:"ks-value-list-row",n.total&&"ks-value-list-total")},e.createElement("dt",{className:s?To:"ks-value-list-label"},n.label,n.note!=null&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"ks-value-list-note"},n.note))),e.createElement("dd",{className:"ks-value-list-value"},Bo(n),n.right&&e.createElement(e.Fragment,null," ",e.createElement(Mo,null)))))),qt=Do;var Lo=()=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})),Po=({summary:t,open:o=!1,className:s,children:r})=>e.createElement("details",{className:A("ks-disclosure group",s),open:o},e.createElement("summary",{className:"ks-disclosure-summary flex cursor-pointer list-none items-center justify-between [&::-webkit-details-marker]:hidden"},e.createElement("span",null,t),e.createElement("span",{className:"ks-disclosure-icon h-4 w-4 shrink-0 transition-transform group-open:rotate-180"},e.createElement(Lo,null))),e.createElement("div",{className:"ks-disclosure-body text-sm"},r)),Jt=Po;var Io=({language:t,caption:o,className:s,children:r})=>e.createElement("div",{className:A("ks-code overflow-hidden",s)},o!=null&&e.createElement("div",{className:"ks-code-caption font-mono text-xs"},o),e.createElement("pre",{className:"ks-code-block overflow-x-auto font-mono text-sm leading-relaxed"},e.createElement("code",{className:t==null?"":`language-${t}`},r))),Kt=Io;var xt="flex flex-col gap-1 mb-3",Zt="[&_dd]:font-mono",$o="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",Ho="[&_.ks-value-list]:font-mono [&_.ks-value-list]:flex [&_.ks-value-list]:flex-col [&_.ks-value-list]:gap-1 [&_.ks-value-list-row]:gap-2 [&_.ks-value-list-row]:py-0 [&_.ks-value-list-row]:border-0 [&_.ks-value-list-label]:basis-[90px]",Wo="border-t border-gray-200 pt-2.5 dark:border-zinc-700 [&_.ks-disclosure]:border-0 [&_.ks-disclosure-summary]:flex-row-reverse [&_.ks-disclosure-summary]:justify-end [&_.ks-disclosure-summary]:gap-1 [&_.ks-disclosure-summary]:p-0 [&_.ks-disclosure-summary]:font-normal [&_.ks-disclosure-body]:p-0 [&_.ks-disclosure-body]:pt-1.5 [&_.ks-code-block]:p-2 [&_.ks-code-block]:text-[11px]",jo=t=>t.values?t.columns?`${xt} ${Zt} ${$o}`:`${xt} ${Zt} ${Ho}`:`${xt} ${Wo}`,Go=({details:t})=>e.createElement(e.Fragment,null,t.map((o,s)=>e.createElement("section",{key:s,className:jo(o)},o.heading&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400"},o.heading),o.values&&e.createElement(qt,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>e.createElement(Jt,{key:r.summary,summary:r.summary},e.createElement(Kt,null,r.code)))))),Qt=Go;var Vo=({as:t="div",className:o,children:s,...r})=>e.createElement(t,{...r,className:A("ks-panel",o)},s),D=Vo;var at=(t,o)=>({className:s,children:r,...n})=>e.createElement(t,{...n,className:A(o,s)},r),q=at("label","ks-label"),Aa=at("p","ks-hint"),za=at("p","ks-error"),Oa=at("span","ks-required");var Fo={width:320,padding:"14px 16px",overflowY:"auto",display:"flex",flexDirection:"column",fontSize:12},Uo={marginTop:"auto",paddingTop:12,display:"flex",flexDirection:"column",gap:8},Xo=({node:t,fields:o,holds:s,labels:r,explanations:n,recordLabels:a,recordExplanations:p,recordChoices:c,recordOutputsOf:l,choices:m,onSave:u,onDelete:x,onClose:h,onPickPicture:d,refusal:f,notice:_})=>{let[v,C]=E(t.config),[k,N]=E(t.picture_url);L(()=>N(t.picture_url),[t.id,t.picture_url]),L(()=>C(t.config),[t.id,t.config]);let M=b=>{C(b),JSON.stringify(b)!==JSON.stringify(t.config)&&u(b)};return e.createElement(D,{as:"aside",style:Fo,className:"max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto","data-inspector":!0},e.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8,marginBottom:12}},e.createElement("div",null,e.createElement("p",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.id," \xB7 ",t.type),e.createElement("h2",{style:{fontSize:15,fontWeight:600}},t.label)),e.createElement("button",{title:"Close",onClick:h,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),f&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},f),_&&!f&&e.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{fontWeight:600,marginBottom:12},"data-notice":!0},_),Object.entries(o).map(([b,B])=>e.createElement(q,{key:b},e.createElement("span",{style:{display:"block",marginBottom:3}},r[b]||b),B==="list"?e.createElement(Yt,{holds:s[b]||{},labels:a[b]||{},explanations:(p||{})[b],rows:v[b],choices:{...(c||{})[b],...(t.record_choices||{})[b]},outputsOf:(l||{})[b],onChange:O=>C({...v,[b]:O}),onSettle:O=>M({...v,[b]:O})}):e.createElement(st,{name:b,type:B,value:v[b],choices:m[b],pictureUrl:k,onChange:O=>C({...v,[b]:O}),onSettle:O=>M({...v,[b]:O}),onPick:async O=>{let H=await d(O);H&&(N(H.url),M({...v,[b]:H.reference}))}}),(n||{})[b]&&e.createElement(nt,{text:n[b]}))),e.createElement(Qt,{details:t.details||[]}),e.createElement("div",{style:Uo},(t.links||[]).length>0&&e.createElement("div",{style:{display:"flex",gap:8}},t.links.map(b=>e.createElement(w,{key:b.address,variant:"secondary",size:"sm",className:"flex-1",href:b.address},b.label))),e.createElement(w,{variant:"danger",size:"sm",className:"w-full",onClick:x},"Delete step")))},Rt=Xo;var Yo={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},qo={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},Jo="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",Ko="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Zo=({node:t,dragging:o,onFill:s,onDrop:r,compact:n=!1})=>e.createElement("div",{ref:t.ref,"data-placeholder":t.id,title:`Choose the step \u201C${t.label}\u201D should lead to`,onClick:s,onDragOver:a=>{o&&(a.preventDefault(),a.dataTransfer.dropEffect="move")},onDrop:a=>{a.preventDefault(),r()},className:o?Ko:Jo,style:n?qo:Yo},e.createElement("div",{style:{fontWeight:600}},t.label),e.createElement("div",{style:{fontSize:11}},o?"drop a step here":"leads nowhere yet \u2014 click to choose")),te=Zo;var Qo=({entries:t,at:o,onPick:s,onConnect:r,onDismiss:n,hideStepTypeCodes:a})=>e.createElement(D,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:o.y,left:o.x,width:210,padding:8,borderRadius:8}},e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),t.map(p=>e.createElement(w,{key:p.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>s(p)},p.label,!a&&e.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},p.type))),r&&e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:n},"Cancel")),ee=Qo;var Ro=t=>o=>o.label.toLowerCase().includes(t.trim().toLowerCase()),tr=(t,o,s="")=>{let r=Object.values(o).flat(),n=Object.entries(o).map(([a,p])=>({heading:a,entries:p.map(c=>t.find(l=>l.type===c)).filter(Boolean)}));return[{heading:null,entries:t.filter(a=>!r.includes(a.type))},...n].map(a=>({...a,entries:a.entries.filter(Ro(s))})).filter(a=>a.entries.length>0)},er={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},or={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},rr={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},sr=({entries:t,groups:o,onPick:s,onCarry:r,onDrop:n})=>{let[a,p]=E("");return e.createElement(D,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:er},e.createElement(I,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:a,onChange:c=>p(c.target.value),style:{marginBottom:6,fontSize:12}}),tr(t,o,a).map(c=>e.createElement(e.Fragment,{key:c.heading||""},c.heading&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:or},c.heading),c.entries.map(l=>e.createElement(D,{as:"button",type:"button",key:l.type,"data-step-type":l.type,className:"bg-surface-50 dark:bg-surface-950",style:rr,draggable:!0,onClick:()=>s(l),onDragStart:m=>{m.dataTransfer.effectAllowed="copyMove",m.dataTransfer.setData("text/plain",l.type),r(l)},onDragEnd:n},l.label)))))},oe=sr;var nr={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},re=({label:t,title:o,idle:s,enabled:r,onUse:n})=>e.createElement(w,{variant:"secondary",size:"sm",title:r?o:s,disabled:!r,onClick:n,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},t),ar=({undoable:t,redoable:o,onAdd:s,onUndo:r,onRedo:n})=>e.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},e.createElement(w,{variant:"secondary",className:"rounded-full",style:nr,title:"Add a step",onClick:s},"+"),e.createElement(re,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:t,onUse:r}),e.createElement(re,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),se=ar;var ir=({type:t="info",title:o,message:s,onDismiss:r,className:n})=>e.createElement("div",{className:A("ks-alert",`ks-alert-${t}`,n),role:"alert"},e.createElement("div",{className:"ks-alert-body"},e.createElement("div",{className:"ks-alert-content"},o&&e.createElement("p",{className:"ks-alert-title"},o),e.createElement("p",{className:o?"ks-alert-message-titled":"ks-alert-message"},s)),r&&e.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),ne=ir;var ae=t=>{let o=t.map(s=>`\u201C${s.name}\u201D`).join(", ");return t.length===1?`${o} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${o} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var ie=({version:t,published:o})=>t?o?o===t?`Version ${t} \xB7 live`:`Version ${t} \xB7 visitors still on ${o}`:`Version ${t} \xB7 never published`:"No version yet";var lr={width:280,padding:20,overflowY:"auto"},le={fontWeight:600,marginBottom:6,marginTop:14},yt={fontSize:12,marginBottom:4,lineHeight:1.4},de={display:"block",marginBottom:3},ce=(t,o,s)=>r=>{r.target.value!==(t[o]??"")&&s({[o]:r.target.value})},dr=({flow:t,changes:o,refusal:s,notice:r,publishNote:n,warning:a,onCreate:p,onPublish:c,onAccept:l,onDecline:m,onSaveDetails:u,onClose:x})=>e.createElement(D,{as:"aside",style:lr,"data-builder-panel":!0},e.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},e.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},t.title||t.slug),e.createElement("button",{title:"Close",onClick:x,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),e.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:t.history_url,"data-history":!0},ie(t)),a?e.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},e.createElement(ne,{type:"warning",className:"mb-1.5",message:ae(a.steps)}),e.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:l,"data-accept-removal":!0},a.path==="/publish"?"Remove and publish":"Remove and create version"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:m,"data-decline-removal":!0},"Cancel")):e.createElement("div",{style:{marginTop:14}},e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:p,"data-create-version":!0},"Create version"),e.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:c,"data-publish":!0},"Publish"),n&&e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},n)),s&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...yt,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&e.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...yt,fontWeight:600,marginTop:8},"data-notice":!0},r),e.createElement("h2",{style:le},"Changes since the last version"),o.length===0?e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):o.map((h,d)=>e.createElement("p",{key:d,style:yt,"data-change":!0},h)),e.createElement("h2",{style:le},"Details"),e.createElement(q,null,e.createElement("span",{style:de},"Title"),e.createElement(I,{className:"mb-3",defaultValue:t.title??"",onBlur:ce(t,"title",u),"data-flow-title":!0})),e.createElement(q,null,e.createElement("span",{style:de},"Start label"),e.createElement(I,{className:"mb-3",defaultValue:t.start_label??"",onBlur:ce(t,"start_label",u),"data-flow-start-label":!0})),e.createElement("div",{style:{marginTop:16}},e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.definition_url,"data-definition":!0},"Definition"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.details_url,"data-details":!0},"Edit details"))),pe=dr;var cr=({variant:t="neutral",className:o,children:s,...r})=>e.createElement("span",{...r,className:A("ks-badge",`ks-badge-${t}`,o)},s),me=cr;var pr={center:"ks-tab-bar flex flex-wrap justify-center max-sm:flex-nowrap max-sm:overflow-x-auto max-sm:justify-start",start:"ks-tab-bar flex flex-wrap justify-start max-sm:flex-nowrap max-sm:overflow-x-auto"},mr={pills:"ks-tab-bar-pills",underline:"ks-tab-bar-underline"},ur="ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",fr="ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",gr=({shape:t,count:o})=>t?e.createElement("span",{className:"ks-tab-count"},o):e.createElement(me,{variant:"info"},o),hr=t=>typeof t=="string"?t!=="":t>0,xr=({tabs:t,value:o,onChange:s,align:r="center",shape:n,className:a})=>e.createElement("div",{className:a},e.createElement("div",{className:A(pr[r],mr[n])},t.map(p=>e.createElement("button",{key:p.value,type:"button",className:n?fr:ur,"data-active":p.value===o?"":void 0,onClick:()=>s(p.value)},p.label,hr(p.count)&&e.createElement(e.Fragment,null," ",e.createElement(gr,{shape:n,count:p.count}))))),t.find(p=>p.value===o)?.content),ue=xr;var yr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},fe="mx-6 mb-6 flex max-h-[45%] flex-none flex-col overflow-y-auto rounded-lg max-sm:m-0 max-sm:max-h-none max-sm:rounded-none [&_.ks-tab-bar]:mb-0 [&_.ks-tab-bar]:px-2",br="max-sm:absolute max-sm:inset-0 max-sm:z-20",xe={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},ge={display:"flex",gap:8,textAlign:"left"},he={flexShrink:0,whiteSpace:"nowrap"},vr=({check:t,onSelect:o})=>{let s=e.createElement(e.Fragment,null,e.createElement("span",{className:yr[t.level],style:{...he,fontWeight:500}},t.level),t.node&&e.createElement("span",{className:"font-mono",style:he},t.node),e.createElement("span",null,t.sentence));return t.node?e.createElement("button",{type:"button","data-check-row":!0,"data-step-id":t.node,style:{...ge,border:"none",background:"none",padding:0,cursor:"pointer",font:"inherit",color:"inherit"},onClick:()=>o(t.node)},s):e.createElement("div",{"data-check-row":!0,style:ge},s)},wr=({checks:t,onSelect:o})=>e.createElement("div",{style:xe},t.map((s,r)=>e.createElement(vr,{key:r,check:s,onSelect:o}))),kr=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,Sr=({checks:t,tabs:o,onSelect:s,opened:r=kr()?null:"validation"})=>{let[n,a]=E(r);return e.createElement(D,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${fe} ${br}`:fe},e.createElement(ue,{align:"start",shape:"underline",value:n,onChange:p=>a(p===n?null:p),tabs:[{value:"validation",label:"Validation",count:t.filter(p=>p.level==="error").length,content:e.createElement(wr,{checks:t,onSelect:s})},...o.map(p=>({value:p.label,label:p.label,count:p.count??"",content:e.createElement("div",{"data-drawer-content":!0,style:xe,dangerouslySetInnerHTML:{__html:p.content}})}))]}))},ye=Sr;var be={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},ve=t=>({opacity:t?1:0,transition:"opacity .12s"}),Cr=({link:t,onInsert:o,onRemove:s,onDrop:r,dragging:n,alwaysShowInsertButtons:a})=>{let[p,c]=E(!1),l=p||n;return e.createElement("div",{"data-connector":`${t.source}-${t.target}`,style:{position:"absolute",left:t.midX-34,top:t.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onDragEnter:()=>c(!0),onDragLeave:()=>c(!1),onDragOver:m=>{m.preventDefault(),m.dataTransfer.dropEffect="move"},onDrop:m=>{m.preventDefault(),c(!1),r()}},e.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},e.createElement(w,{variant:"secondary",title:n?"Move the step here":"Insert a step here",onClick:o,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(n&&p),style:{...be,...ve(l||a)}},"+"),!n&&e.createElement(w,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...be,...ve(l)}},"\xD7")))},we=Cr;var Nr=({links:t,extent:o,dragging:s,onInsert:r,onRemove:n,onDrop:a,alwaysShowInsertButtons:p})=>e.createElement(e.Fragment,null,e.createElement("svg",{width:o.width,height:o.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},e.createElement("defs",null,e.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},e.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),t.map(c=>e.createElement("path",{key:c.id,"data-link":c.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:c.path}))),t.filter(c=>c.label).map(c=>e.createElement("div",{key:`${c.id}-label`,"data-link-label":c.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:c.midX+(p?2:-10),top:c.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},c.label)),t.filter(c=>!c.placeholder).map(c=>e.createElement(we,{key:c.id,link:c,dragging:!!s,alwaysShowInsertButtons:p,onInsert:()=>r(c),onRemove:()=>n(c),onDrop:()=>a(c)}))),ke=Nr;var bt={width:22,height:22,padding:0,fontSize:14,lineHeight:"14px"},Se="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Er={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:2,height:"100%"},_r=({link:t,onInsert:o,onRemove:s,onDrop:r,alwaysShowInsertButtons:n,dragging:a,shown:p=!1,className:c="",style:l,children:m})=>e.createElement("div",{"data-joint":t?.id,className:`group ${c}`.trim(),style:l,onMouseEnter:u=>{u.currentTarget.dataset.over="true"},onMouseLeave:u=>{delete u.currentTarget.dataset.over},onDragOver:u=>{t&&r&&(u.preventDefault(),u.dataTransfer.dropEffect="move")},onDrop:u=>{t&&(u.preventDefault(),r(t))}},m,t&&o&&e.createElement("div",{style:Er},e.createElement(w,{variant:"secondary",title:"Insert a step here",onClick:u=>o(t,u),className:`rounded-full ${n?"opacity-100":Se}`,style:a?{...bt,opacity:1}:bt},"+"),e.createElement(w,{variant:"danger",title:"Remove this connection",onClick:()=>s(t),className:`rounded-full ${p?"opacity-100":Se}`,style:bt},"\xD7"))),it=_r;var Ar=(t,o)=>{let s=new Map(t.map(p=>[p,0])),r=new Map(t.map(p=>[p,[]])),n=new Map(t.map(p=>[p,0]));o.forEach(p=>{r.get(p.source).push(p.target),n.set(p.target,n.get(p.target)+1)});let a=t.filter(p=>n.get(p)===0);for(let p=0;p<a.length;p++){let c=a[p];r.get(c).forEach(l=>{s.set(l,Math.max(s.get(l),s.get(c)+1)),n.set(l,n.get(l)-1),n.get(l)===0&&a.push(l)})}return s},wt=(t,o)=>{let s=new Map(t.map(r=>[r,[]]));return o.forEach(r=>s.get(r.source).push(r)),s},zr=(t,o)=>{let s=wt(t,o),r=new Set(o.map(c=>c.target)),n=new Map,a=new Set,p=c=>{let l=[[c,0]];for(n.set(c,"open");l.length>0;){let m=l[l.length-1],u=s.get(m[0])[m[1]++];u?n.get(u.target)==="open"?a.add(u):n.has(u.target)||(n.set(u.target,"open"),l.push([u.target,0])):(n.set(m[0],"done"),l.pop())}};return t.filter(c=>!r.has(c)).forEach(p),t.forEach(c=>{n.has(c)||p(c)}),a},Or=(t,o,s)=>{let r=[];t.forEach(l=>{var m;return(r[m=s.get(l)]||(r[m]=[])).push(l)});let n=wt(t,o),a=new Map;n.forEach(l=>l.forEach((m,u)=>a.set(m,(u+1)/(l.length+1))));let p=new Map(t.map(l=>[l,[]]));o.forEach(l=>p.get(l.target).push(l));let c=new Map;return r.forEach(l=>{let m=new Map(l.map(u=>{let x=p.get(u),h=x.reduce((d,f)=>d+c.get(f.source)+a.get(f),0);return[u,x.length>0?h/x.length:1/0]}));l.sort((u,x)=>m.get(u)===m.get(x)?0:m.get(u)<m.get(x)?-1:1),l.forEach((u,x)=>c.set(u,x))}),c};var vt=(t,o,s)=>{let r=[];return t.forEach((n,a)=>{r[a]=a===0?s:r[a-1]+t[a-1]+o}),r},Tr=(t,o)=>t.length>0?t[t.length-1]+o[o.length-1]:0,Mr=t=>{let o=[t];for(let s=1;s*2<=t.length;s*=2){let r=o[o.length-1];o.push(r.slice(0,t.length-s*2+1).map((n,a)=>Math.max(n,r[a+s])))}return(s,r)=>{let n=Math.floor(Math.log2(r-s+1));return Math.max(o[n][s],o[n][r-(1<<n)+1])}},Ce=(t,o,s,r)=>{let n=zr(t,o),a=o.filter(g=>!n.has(g)),p=Ar(t,a),c=Or(t,a,p),l=[],m=[];t.forEach(g=>{var S;l[p.get(g)]=Math.max(l[p.get(g)]||0,s(g).width),(m[S=p.get(g)]||(m[S]=[]))[c.get(g)]=g});let u=g=>p.get(g.target)>p.get(g.source)+1,x=g=>{let S=new Map;return g.forEach(T=>{S.has(T.target)||S.set(T.target,S.size)}),S},h=x(o.filter(g=>n.has(g))),d=x(a.filter(u)),f=vt(l,64,r.left),_=r.top+h.size*14,v=new Map,C=m.map(g=>{let S=g.map(T=>s(T).height);return vt(S,24,_).forEach((T,W)=>v.set(g[W],T)),Tr(vt(S,24,_),S)}),k=Mr(C),N=Object.fromEntries(t.map(g=>[g,{column:p.get(g),row:c.get(g),x:f[p.get(g)],y:v.get(g),width:s(g).width,height:s(g).height}])),M=new Map;a.filter(u).forEach(g=>M.set(g.target,Math.max(M.get(g.target)||0,k(p.get(g.source)+1,p.get(g.target)-1))));let b=g=>n.has(g)?r.top+(h.size-1-h.get(g.target))*14:u(g)?M.get(g.target)+(d.get(g.target)+1)*14:null,B=g=>N[g].y+(s(g).arrives??N[g].height/2),O=g=>b(g)??B(g.target),H=new Map;wt(t,o).forEach(g=>[...g].sort((S,T)=>O(S)-O(T)).forEach((S,T)=>H.set(S,(T+1)/(g.length+1))));let pt=g=>{let S=N[g.source],T=N[g.target],W=S.y+S.height*H.get(g),U=B(g.target),X=f[S.column]+l[S.column]+40,V=b(g),Q=[[S.x+S.width,W],[X,W]],F=[[T.x-64+40,U],[T.x,U]];return{...g.drawn,points:V===null?[...Q,[X,U],F[1]]:[...Q,[X,V],[F[0][0],V],...F]}},K=o.map(pt),Z=[...Object.values(N).map(g=>[g.x+g.width,g.y+g.height]),...K.flatMap(g=>g.points)].reduce(([g,S],[T,W])=>[Math.max(g,T),Math.max(S,W)],[0,0]);return{places:N,links:K,width:Z[0]+r.right,height:Z[1]+r.bottom}},J="\0entry";var Br={left:44,top:40,right:20,bottom:40},Dr={left:0,top:8,right:16,bottom:12},lt=(t,o,{heights:s={}}={})=>{let r=new Set(t.map(d=>d.id)),n=new Map(t.flatMap(d=>(d.holds||[]).filter(f=>r.has(f)).map(f=>[f,d.id]))),a=new Map([[null,{ids:[],edges:[]}]]);t.filter(d=>d.holds).forEach(d=>a.set(d.id,{ids:[J],edges:[]})),t.forEach(d=>a.get(n.get(d.id)??null).ids.push(d.id)),o.filter(d=>r.has(d.source)&&r.has(d.target)).forEach(d=>{let f=n.get(d.target);f&&f===d.source?a.get(f).edges.push({source:J,target:d.target,drawn:d}):f&&f===n.get(d.source)?a.get(f).edges.push({source:d.source,target:d.target,drawn:d}):a.get(null).edges.push({source:n.get(d.source)??d.source,target:f??d.target,drawn:d})});let p=d=>({width:184,height:s[d]||64}),c=new Map([...a].filter(([d])=>d).map(([d,f])=>[d,Ce(f.ids,f.edges,_=>_===J?{width:0,height:64}:p(_),Dr)])),l=d=>s[d]||24,m=d=>{let f=c.get(d);return f?{width:f.width,height:l(d)+f.height,arrives:l(d)+f.places[J].y+64/2}:p(d)},u=Ce(a.get(null).ids,a.get(null).edges,m,Br),x={...u.places},h=[...u.links];return c.forEach((d,f)=>{let _=u.places[f],[v,C]=[_.x,_.y+l(f)];Object.entries(d.places).filter(([k])=>k!==J).forEach(([k,N])=>{x[k]={...N,x:N.x+v,y:N.y+C}}),d.links.forEach(k=>h.push({...k,points:k.points.map(([N,M])=>[N+v,M+C])}))}),{places:x,links:h,width:u.width,height:u.height}};var Lr={display:"flex",flexDirection:"column",gap:14,padding:"64px 16px 24px"},Pr={display:"flex",flexDirection:"column",gap:10,padding:"8px 10px",borderRadius:8},Ir={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,minHeight:26,paddingLeft:12,fontSize:11},$r=t=>(o,s)=>t[o.id].column-t[s.id].column||t[o.id].row-t[s.id].row,Hr=t=>t?.placeholder?"nowhere yet":t?.label,Wr=({node:t,leaving:o,named:s,draw:r,joints:n})=>e.createElement("div",{"data-step-row":t.id},r(t),o.map(a=>e.createElement(it,{key:a.id,link:a,...n,alwaysShowInsertButtons:!0,shown:!0,className:"border-l border-gray-300 text-gray-500 dark:border-zinc-600 dark:text-gray-400",style:Ir},e.createElement("span",null,[a.label,"\u2192",s.get(a.target)].filter(Boolean).join(" "))))),jr=({nodes:t,edges:o,draw:s,joints:r,children:n,style:a})=>{let{places:p}=lt(t,o),c=new Map(t.map(d=>[d.id,Hr(d)])),l=new Map(t.map(d=>[d.id,[]]));o.forEach(d=>{l.has(d.source)&&c.has(d.target)&&l.get(d.source).push(d)});let m=new Map(t.flatMap(d=>(d.holds||[]).map(f=>[f,d.id]))),u=[...t].sort($r(p)),x=new Map;u.filter(d=>m.has(d.id)).forEach(d=>{x.has(m.get(d.id))||x.set(m.get(d.id),[]),x.get(m.get(d.id)).push(d)});let h=d=>e.createElement(Wr,{key:d.id,node:d,leaving:l.get(d.id),named:c,draw:s,joints:r});return e.createElement("div",{"data-flow-rows":!0,style:{...Lr,...a}},n,u.filter(d=>!m.has(d.id)).map(d=>d.holds?e.createElement("div",{key:d.id,"data-group-box":d.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:Pr},h(d),(x.get(d.id)||[]).map(h)):h(d)))},Ne=jr;var Gr={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:14,padding:"64px 0 0"},Vr={position:"absolute",zIndex:3,maxWidth:56,fontSize:10,lineHeight:"13px",pointerEvents:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Fr=t=>t.map(([o,s],r)=>`${r===0?"M":"L"} ${o} ${s}`).join(" "),Ur=t=>Object.fromEntries(Object.entries(t).filter(([,o])=>o?.firstElementChild).map(([o,s])=>[o,s.firstElementChild.offsetHeight])),Xr=(t,o)=>Object.keys(o).some(s=>t[s]!==o[s]),Yr=({nodes:t,edges:o,draw:s,joints:r})=>{let[n,a]=E({}),p=Y({}),c=P(()=>lt(t,o,{heights:n}),[t,o,n]);R(()=>{let m=Ur(p.current);Xr(n,m)&&a({...n,...m})});let l=m=>u=>{p.current[m]=u};return e.createElement("div",{"data-flow-graph":!0,style:{position:"relative",flex:"none",width:c.width,height:c.height}},e.createElement("svg",{width:c.width,height:c.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("defs",null,e.createElement("marker",{id:"easy_flow-graph-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},e.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),c.links.map(m=>e.createElement("path",{key:m.id,"data-link":m.id,d:Fr(m.points),fill:"none",strokeWidth:"1.5",className:"stroke-gray-400 dark:stroke-zinc-500",markerEnd:"url(#easy_flow-graph-arrow)"}))),t.map(m=>{let u=c.places[m.id];return m.holds?e.createElement("div",{key:m.id,ref:l(m.id),"data-group-box":m.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",left:u.x,top:u.y,width:u.width,height:u.height,boxSizing:"border-box",borderRadius:8}},e.createElement("div",{style:{padding:"4px 10px"}},s(m))):e.createElement("div",{key:m.id,ref:l(m.id),style:{position:"absolute",left:u.x,top:u.y,width:u.width,zIndex:2}},s(m))}),c.links.filter(m=>m.label).map(m=>e.createElement("div",{key:`${m.id}-label`,"data-link-label":m.id,title:m.label,className:"text-gray-500 dark:text-gray-400",style:{...Vr,left:m.points[0][0]+6,top:m.points[0][1]-14}},m.label)),r.onInsert&&c.links.filter(m=>!m.placeholder).map(m=>e.createElement(it,{key:m.id,link:m,...r,style:{position:"absolute",left:m.points[0][0],top:m.points[0][1]-12,width:62,height:24,zIndex:3}})))},_e="(min-width: 640px)",qr=()=>typeof window>"u"||!window.matchMedia||window.matchMedia(_e).matches,Jr=()=>{let[t,o]=E(qr);return L(()=>{if(!window.matchMedia)return;let s=window.matchMedia(_e),r=()=>o(s.matches);return s.addEventListener("change",r),()=>s.removeEventListener("change",r)},[]),t},Kr=({nodes:t,edges:o,draw:s,joints:r,children:n,style:a})=>Jr()?e.createElement("div",{"data-flow-rows":!0,style:{...Gr,...a}},n,e.createElement(Yr,{nodes:t,edges:o,draw:s,joints:r})):e.createElement(Ne,{nodes:t,edges:o,draw:s,joints:r,style:a},n),dt=Kr;var ze="Your change was not saved because the server could not be reached.",Zr="Your change was saved, but the canvas could not be refreshed. Reload the page to see it.",Ae=async({base:t,fetch:o,onFlow:s,onError:r})=>{let n=await o(t+".json",{headers:{Accept:"application/json"}}).catch(()=>null),a=n?.ok?await n.json().catch(()=>null):null;return a?s(a):r(Zr)},Oe=({base:t,token:o,fetch:s,onFlow:r,onError:n,onNotice:a,onWarning:p=()=>{}})=>async(c,l,m)=>{let u={base:t,fetch:s,onFlow:r,onError:n},x=await s(t+c,{method:l,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:m&&JSON.stringify(m)}).catch(()=>null);if(!x)return a(null),n(ze);let h=await x.json().catch(()=>({}));return h.unconnected?(a(null),n(null),p({path:c,steps:h.unconnected}),Ae(u)):(p(null),x.ok?(n(null),a(h.notice||null),Ae(u)):(a(null),n(h.error||"That change was refused")))},Te=({base:t,token:o,fetch:s,onError:r})=>async n=>{let a=new FormData;a.append("picture",n);let p=await s(t+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:a}).catch(()=>null);if(!p)return r(ze),null;let c=await p.json().catch(()=>({}));return p.ok?(r(null),c):(r(c.error||"That picture was refused"),null)};var Qr=(t,o,s)=>{let[r,n]=E(s),[a,p]=E(null),[c,l]=E(null),[m,u]=E(null),x=P(()=>Oe({base:t,token:o,fetch:(...d)=>window.fetch(...d),onFlow:n,onError:p,onNotice:l,onWarning:u}),[t,o]),h=P(()=>Te({base:t,token:o,fetch:(...d)=>window.fetch(...d),onError:p}),[t,o]);return{flow:r,error:a,notice:c,warning:m,setWarning:u,send:x,pickPicture:h}},Me=Qr;var ct=(t,o,s,r)=>{let n=t.left-s.left+r.scrollLeft,a=t.top-s.top+r.scrollTop;return o==="left"?{x:n,y:a+t.height/2}:o==="right"?{x:n+t.width,y:a+t.height/2}:o==="top"?{x:n+t.width/2,y:a}:{x:n+t.width/2,y:a+t.height}},Rr=(t,o,s)=>s&&o==="top"?{x:t.x,y:s.top}:t,ts=(t,o)=>o==="top"?{x:t.x,y:t.y-3}:o==="left"?{x:t.x-3,y:t.y}:o==="right"?{x:t.x+3,y:t.y}:{x:t.x,y:t.y+3},es=(t,o,s,r,n)=>{let a={straight:`M ${o.x} ${o.y} L ${s.x} ${s.y}`,turn:`M ${o.x} ${o.y} H ${s.x} V ${s.y}`,lane:`M ${o.x} ${o.y} V ${r} H ${s.x} V ${s.y}`,detour:`M ${o.x} ${o.y} H ${n} V ${s.y} H ${s.x}`}[t.route];return{...t,path:a,midX:t.route==="detour"?n:(o.x+s.x)/2,midY:t.route==="lane"?r:(o.y+s.y)/2}},os=(t,o,s,r)=>{let[n,a]=E([]),[p,c]=E({width:"100%",height:"100%"}),[l,m]=E([]);return R(()=>{let u=()=>{let h=o.current?.getBoundingClientRect();if(!h)return;c({width:o.current.scrollWidth,height:o.current.scrollHeight});let d=t.nodes.filter(f=>f.holds&&!f.loose&&s.current[f.id]).map(f=>{let _=s.current[f.id],v=_.getBoundingClientRect(),C=f.holds.flatMap(N=>s.current[N]?[s.current[N].getBoundingClientRect()]:[]),k=[{left:v.left,top:v.top,width:Math.max(v.width,_.scrollWidth),height:v.height},...C];return{id:f.id,bounds:It(k,h,o.current)}});m(d),a(t.edges.flatMap(f=>{let _=s.current[f.source]?.getBoundingClientRect(),v=s.current[f.target]?.getBoundingClientRect();if(!_||!v)return[];let C=ct(_,f.leaves,h,o.current),k=d.find(B=>B.id===f.target)?.bounds,N=ts(Rr(ct(v,f.enters,h,o.current),f.enters,k),f.enters),M=(ct(_,"bottom",h,o.current).y+ct(v,"top",h,o.current).y)/2,b=f.leaves==="left"?Math.min(C.x,N.x)-28:Math.max(C.x,N.x)+28;return[es(f,C,N,M,b)]}))};u(),window.addEventListener("resize",u);let x=new ResizeObserver(u);return o.current&&x.observe(o.current),()=>{window.removeEventListener("resize",u),x.disconnect()}},r),{links:n,extent:p,boxes:l}},Be=os;var De=(t,o)=>{let s=new Set(o),r=t,n=2;for(;s.has(r);)r=`${t}_${n++}`;return r};var Le=({send:t,onPress:o})=>s=>{let r=s.target.closest?.("[data-bar-action]");r&&(r.closest("details")?.removeAttribute("open"),o(),r.dataset.barPath&&t(r.dataset.barPath,"POST"))};var ss=8,ns={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},as={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},is={flex:1,minHeight:0,overflow:"auto",position:"relative"},Ie={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},ls={...Ie,position:"static",alignSelf:"flex-start"},ds={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},$e={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},cs=({port:t,onCancel:o})=>e.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:$e},"Choose the step \u201C",t||"next","\u201D should lead to \u2014 ",e.createElement("button",{onClick:o,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),ps=({message:t})=>e.createElement("p",{"data-canvas-error":!0,className:"bg-red-50 text-red-800 dark:bg-red-950 dark:text-red-200",style:$e},t),ms=({base:t,token:o,initial:s})=>{let{flow:r,error:n,notice:a,warning:p,setWarning:c,send:l,pickPicture:m}=Me(t,o,s),[u,x]=E(null),[h,d]=E(null),[f,_]=E(null),[v,C]=E(null),[k,N]=E(null),[M,b]=E(!1),B=Y({}),O=Y(null);L(()=>{let i=Le({send:l,onPress:()=>{x(null),b(!0)}});return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[l]),L(()=>{if(!M){c(null);return}let i=y=>{y.target.isConnected&&!y.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&b(!1)};return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[M]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let H=P(()=>Object.fromEntries(r.nodes.map(i=>[i.id,i])),[r.nodes]),{links:pt,extent:K,boxes:mt}=Be(r,O,B,[r,u,H]),Z=P(()=>{let i={};return r.violations.forEach(y=>{var z;return(i[z=y.node]||(i[z]=[])).push(y)}),i},[r.violations]),g=r.direction==="left_to_right",S=P(()=>r.nodes.filter(i=>!i.loose),[r.nodes]),T=r.nodes.filter(i=>i.loose),W=P(()=>{let i={};return r.edges.forEach(y=>{var z;return(i[z=y.source]||(i[z]=[])).push(y.label||null)}),i},[r.edges]),U=Math.max(0,...S.map(i=>i.row))+1,X=Math.max(0,...S.map(i=>i.column))+1,V=i=>{if(!f)return;let[y,z]=f;_(null),y!==i&&l("/edges","POST",{from:y,to:i,on:z||null})},Q=i=>{if(i.isDefaultPrevented()||!v)return;i.preventDefault();let y=v;C(null);let z=O.current.getBoundingClientRect(),_t=$t(mt,{x:i.clientX-z.left+O.current.scrollLeft,y:i.clientY-z.top+O.current.scrollTop}),Ue=r.nodes.find(Xe=>Xe.holds?.includes(y))?.id||null;_t!==Ue&&l(`/steps/${y}/group`,"PATCH",{group:_t})},F=i=>[...r.palette,...r.unoffered||[]].find(y=>y.type===i?.type),j=r.nodes.find(i=>i.id===u),$=F(j),ut=(i,y={})=>l("/steps","POST",{id:De(i.type,r.nodes.map(z=>z.id)),type:i.type,from:y.from,to:y.to,on:y.on}),kt=i=>{let[y,z]=[k,v];N(null),C(null),y?ut(y,{from:i.source,to:i.target}):z&&l("/steps/"+z+"/move","PATCH",{from:i.source,to:i.target})},St=i=>{let y=O.current.getBoundingClientRect();return{x:i.clientX-y.left+O.current.scrollLeft+8,y:i.clientY-y.top+O.current.scrollTop+8}},Ct=(i,y)=>({node:{...i,ref:z=>{B.current[i.id]=z},violations:Z[i.id]||[],connected:y},selected:i.id===u,armed:f&&f[0]===i.id?f[1]:null,connecting:!!f&&f[0]!==i.id,onSelect:()=>f?V(i.id):x(i.id),onOpen:z=>window.location.assign(z),onDragStart:()=>C(i.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes,compact:g}),Nt=i=>e.createElement(e.Fragment,null,i.placeholder&&e.createElement(te,{node:{...i,ref:y=>{B.current[i.id]=y}},dragging:!!v,compact:g,onFill:()=>d({from:i.from,on:i.on,at:{x:16,y:52}}),onDrop:()=>{let y=v;C(null),y&&l("/edges","POST",{from:i.from,to:y,on:i.on})}}),i.holds&&e.createElement(et,{node:{...i,ref:y=>{B.current[i.id]=y}},header:ot(i,F(i),r.hide_step_type_codes),compact:g,onSelect:()=>f?V(i.id):x(i.id)}),!i.placeholder&&!i.holds&&e.createElement(gt,{...Ct(i,W[i.id]||[]),onArm:(y,z)=>d({from:i.id,on:y,at:St(z)})})),Et=T.length>0&&e.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:g?ls:Ie},e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:6}},"Not in the flow yet \u2014 drag one onto a connection"),T.map(i=>e.createElement("div",{key:i.id,style:{marginBottom:8}},e.createElement(gt,{...Ct(i,[]),onArm:(y,z)=>{z.stopPropagation(),_([i.id,y])}}))));return e.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:ns,onMouseUp:()=>C(null),onKeyDown:i=>{i.key==="Escape"&&(x(null),_(null),d(null))},tabIndex:-1},e.createElement(oe,{entries:r.palette,groups:r.step_groups||{},onPick:i=>ut(i),onCarry:N,onDrop:()=>N(null)}),e.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:as},e.createElement("div",{ref:O,style:is,onClick:i=>{i.target===O.current&&(x(null),_(null),b(!1))},onDragOver:i=>{v&&i.preventDefault()},onDrop:Q},f&&e.createElement(cs,{port:f[1],onCancel:()=>_(null)}),n&&!M&&!j&&e.createElement(ps,{message:n}),e.createElement(se,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>d({at:{x:16,y:52}}),onUndo:()=>{x(null),l("/undo","POST")},onRedo:()=>{x(null),l("/redo","POST")}}),!g&&mt.map(i=>e.createElement(Pt,{key:i.id,id:i.id,bounds:i.bounds,onDrop:()=>{let y=v;C(null),y&&l(`/steps/${y}/group`,"PATCH",{group:i.id})}})),!g&&e.createElement(ke,{links:Ht(pt,r.nodes),extent:K,dragging:v||k,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:i=>d({from:i.source,to:i.target,at:{x:i.midX+30,y:i.midY}}),onRemove:i=>{x(null),l("/edges","DELETE",{from:i.source,to:i.target})},onDrop:kt}),!g&&Et,g&&e.createElement(dt,{nodes:S,edges:r.edges,draw:Nt,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(v||k),onInsert:(i,y)=>d({from:i.source,to:i.target,at:St(y)}),onRemove:i=>{x(null),l("/edges","DELETE",{from:i.source,to:i.target})},onDrop:kt}},Et),!g&&e.createElement("div",{style:{...ds,gridTemplateColumns:`repeat(${X+1}, ${280/2}px)`,gridTemplateRows:`repeat(${U}, auto)`}},S.map(i=>e.createElement("div",{key:i.id,style:{gridRow:i.row+1,gridColumn:`${i.column+1} / span 2`,zIndex:2,marginTop:Wt(i,r.nodes)?ss-64:0}},Nt(i)))),h&&e.createElement(ee,{entries:r.palette,at:h.at,onDismiss:()=>d(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:h.on!==void 0?()=>{_([h.from,h.on]),d(null)}:null,onPick:i=>{let y=h;d(null),ut(i,y)}})),e.createElement(ye,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:x})),M&&!j&&e.createElement(pe,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:a,publishNote:r.publish_note,warning:p,onClose:()=>b(!1),onCreate:()=>l("/versions","POST"),onPublish:()=>l("/publish","POST"),onAccept:()=>l(p.path,"POST",{remove_unconnected:p.steps.map(i=>i.id)}),onDecline:()=>c(null),onSaveDetails:i=>l("/details","PATCH",{flow:i})}),j&&e.createElement(Rt,{node:j,fields:$?.fields||{},holds:$?.records||{},labels:$?.labels||{},explanations:$?.explanations||{},recordLabels:$?.record_labels||{},recordExplanations:$?.record_explanations||{},recordChoices:$?.record_choices||{},recordOutputsOf:$?.record_outputs_of||{},choices:jt(j,$),onClose:()=>x(null),onSave:i=>l(`/steps/${j.id}`,"PATCH",{config:i}),onPickPicture:m,refusal:n,notice:a,onDelete:()=>{x(null),l(`/steps/${j.id}`,"DELETE")}}))},He=ms;var us={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Ge={fontSize:12,fontWeight:500,lineHeight:1.3},fs={...Ge,textAlign:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},We={done:"border-green-600 bg-green-50 dark:border-green-500 dark:bg-green-950",paused:"border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-950",pending:"border-gray-300 bg-white text-gray-500 dark:border-zinc-700 dark:bg-zinc-900 dark:text-gray-400",failed:"border-red-600 bg-red-50 dark:border-red-500 dark:bg-red-950"},je={done:"text-green-700 dark:text-green-400",paused:"text-amber-800 dark:text-amber-300",pending:"text-gray-500 dark:text-gray-400",failed:"text-red-700 dark:text-red-400"},gs=t=>[t.label,t.ends_here&&t.mark].filter(Boolean).join(" \xB7 "),hs="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",xs=({node:t,selected:o=!1})=>{let s=t.address?"a":"div",r=t.begins_here||t.ends_here;return e.createElement(s,{"data-step":t.id,href:t.address||void 0,className:`${t.state==="paused"?"border-2":"border"} ${We[t.state]||We.pending}${o?` ${hs}`:""}`,style:us},!r&&e.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.type),e.createElement("div",{style:r?fs:Ge},gs(t),t.version&&e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},t.version)),t.status&&e.createElement("div",{className:je[t.state]||je.pending,style:{fontSize:11}},t.status))},Ve=xs;var ys={gap:12,padding:0,maxWidth:"100%",overflowX:"auto"},bs=({nodes:t,edges:o,selected:s})=>e.createElement(dt,{nodes:t,edges:o,joints:{},style:ys,draw:r=>r.holds?e.createElement(et,{node:r,header:ot(r,r,!1),compact:!0}):e.createElement(Ve,{node:r,selected:r.id===s})}),Fe=bs;ft("easy_flow/flow-editor",He);ft("easy_flow/run-view",Fe);document.addEventListener("easy_flow:flow-named",t=>{let o=document.querySelector("[data-flow-heading]");o&&(o.textContent=t.detail)});document.addEventListener("easy_flow:flow-status",({detail:t})=>{t.status&&document.querySelectorAll("[data-version-status]").forEach(o=>{o.textContent=t.status}),t.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(o=>{o.textContent=`Publish v${t.publishes}`})});Bt(document,At);})();
@@ -4,6 +4,8 @@ const card = { display: "block", minWidth: 118, boxSizing: "border-box", borderR
4
4
 
5
5
  const named = { fontSize: 12, fontWeight: 500, lineHeight: 1.3 }
6
6
 
7
+ const bookendName = { ...named, textAlign: "center", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }
8
+
7
9
  const STATES = {
8
10
  done: "border-green-600 bg-green-50 dark:border-green-500 dark:bg-green-950",
9
11
  paused: "border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-950",
@@ -18,6 +20,8 @@ const STATUS_LINES = {
18
20
  failed: "text-red-700 dark:text-red-400"
19
21
  }
20
22
 
23
+ const markedOf = (node) => [ node.label, node.ends_here && node.mark ].filter(Boolean).join(" · ")
24
+
21
25
  const marked = "ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950"
22
26
 
23
27
  const RunCard = ({ node, selected = false }) => {
@@ -27,7 +31,7 @@ const RunCard = ({ node, selected = false }) => {
27
31
  return (
28
32
  <Card data-step={node.id} href={node.address || undefined} className={`${node.state === "paused" ? "border-2" : "border"} ${STATES[node.state] || STATES.pending}${selected ? ` ${marked}` : ""}`} style={card}>
29
33
  {!bookend && <div className="font-mono text-gray-500 dark:text-gray-400" style={{ fontSize: 11 }}>{node.type}</div>}
30
- <div style={bookend ? { ...named, textAlign: "center" } : named}>{node.label}{node.version && <span className="text-gray-500 dark:text-gray-400" style={{ fontWeight: 400, marginLeft: 4 }}>{node.version}</span>}</div>
34
+ <div style={bookend ? bookendName : named}>{markedOf(node)}{node.version && <span className="text-gray-500 dark:text-gray-400" style={{ fontWeight: 400, marginLeft: 4 }}>{node.version}</span>}</div>
31
35
  {node.status && <div className={STATUS_LINES[node.state] || STATUS_LINES.pending} style={{ fontSize: 11 }}>{node.status}</div>}
32
36
  </Card>
33
37
  )
@@ -7,7 +7,7 @@ const card = { width: CARD, boxSizing: "border-box", borderRadius: 8 }
7
7
 
8
8
  const compactCard = { minWidth: 120, boxSizing: "border-box", borderRadius: 6 }
9
9
 
10
- const bookendCard = { padding: "8px 14px", textAlign: "center", fontWeight: 600 }
10
+ const bookendCard = { padding: "8px 14px", textAlign: "center", fontWeight: 600, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }
11
11
 
12
12
  const named = { fontWeight: 600, lineHeight: 1.3 }
13
13
 
@@ -23,6 +23,8 @@ const edge = (target, troubled, selected) => {
23
23
  const headingOf = (node, hideStepTypeCodes) =>
24
24
  hideStepTypeCodes && node.label === node.id ? node.type_name || node.label : node.label
25
25
 
26
+ const markedOf = (node, heading) => [ heading, node.ends_here && node.mark ].filter(Boolean).join(" · ")
27
+
26
28
  const typeLineOf = (node, heading, hideStepTypeCodes) => {
27
29
  if (!hideStepTypeCodes) return node.type
28
30
  return heading === node.type_name ? null : node.type_name
@@ -50,7 +52,7 @@ const StepCard = ({ node, selected, armed, connecting, onSelect, onOpen, onArm,
50
52
  cursor: pinned ? "default" : connecting ? "crosshair" : "grab"
51
53
  }}>
52
54
  {!bookend && typeAbove && typeLine && <div className="font-mono text-gray-500 dark:text-gray-400" style={{ fontSize: 11 }}>{typeLine}</div>}
53
- {bookend && <div className="text-gray-500 dark:text-gray-400" style={bookendCard}>{heading}</div>}
55
+ {bookend && <div className="text-gray-500 dark:text-gray-400" style={bookendCard}>{markedOf(node, heading)}</div>}
54
56
  {!bookend && <div style={compact ? compactName : named}>{heading}</div>}
55
57
  {node.violations.length > 0 && <div data-error-count className="text-red-600 dark:text-red-400" style={{ fontSize: 10 }}>{`${node.violations.length} error${node.violations.length === 1 ? "" : "s"}`}</div>}
56
58
  {!bookend && node.summary && node.violations.length === 0 && <div className={selected ? "text-accent-600 dark:text-accent-400" : "text-gray-500 dark:text-gray-400"} style={{ fontSize: 10 }}>{node.summary}</div>}
@@ -21,7 +21,7 @@ module EasyFlow
21
21
 
22
22
  def drawn_step(node)
23
23
  { "id" => node.id, "type" => node.type, "type_name" => step_type_for(node)&.step_name, "label" => label_for(node), "summary" => summary_of(node), "details" => drawn_by_type(node, :details_of).to_a, "links" => drawn_by_type(node, :links_of).to_a,
24
- "config" => node.config.merge(kept_values(node)), "ports" => [], "ends_here" => ends_here?(node), "begins_here" => begins_here?(node),
24
+ "config" => node.config.merge(kept_values(node)), "ports" => [], "ends_here" => ends_here?(node), "mark" => mark_of(node), "begins_here" => begins_here?(node),
25
25
  "starts_a_flow" => starts_a_flow?(node), "holds" => holds(node), "opens" => opens(node), "loose" => loose?(node), "choices" => choices_for(node), "record_choices" => record_choices_for(node), "placeholder" => false, "picture_url" => picture_url(node), **placed[node.id] }
26
26
  end
27
27
 
@@ -241,6 +241,10 @@ module EasyFlow
241
241
  step_type_for(node)&.ends_here? || false
242
242
  end
243
243
 
244
+ def mark_of(node)
245
+ node.config["mark"].presence if ends_here?(node)
246
+ end
247
+
244
248
  def loose?(node)
245
249
  @document.entry.present? && @document.reachable.exclude?(node.id)
246
250
  end
@@ -41,7 +41,11 @@ module EasyFlow
41
41
  shown = @steps.fetch(node.id, {}).to_h.symbolize_keys
42
42
 
43
43
  { "id" => node.id, "type" => node.type, "label" => Name.of(node, @registry), "state" => state_of(node, shown), "status" => shown[:status], "address" => (shown[:address] unless bookend?(node)), "version" => shown[:version],
44
- "begins_here" => step_type_for(node)&.begins_here? || false, "ends_here" => step_type_for(node)&.ends_here? || false, "holds" => holds(node), **header_of(node), **placed.fetch(node.id, {}) }
44
+ "begins_here" => step_type_for(node)&.begins_here? || false, "ends_here" => step_type_for(node)&.ends_here? || false, "mark" => mark_of(node), "holds" => holds(node), **header_of(node), **placed.fetch(node.id, {}) }
45
+ end
46
+
47
+ def mark_of(node)
48
+ node.config["mark"].presence if step_type_for(node)&.ends_here?
45
49
  end
46
50
 
47
51
  def hidden?(node)
@@ -1,3 +1,3 @@
1
1
  module EasyFlow
2
- VERSION = "0.52.0"
2
+ VERSION = "0.53.0"
3
3
  end
@@ -60,7 +60,7 @@ easy_flow declares no commands of its own for this local. Its surface is split b
60
60
  - **Output** — a value a step records into the run, with a type and a label. Later steps read outputs, and a setting that points at an earlier step offers that step's known values on the canvas. A step type may also take further outputs from a list setting, one for each entry the admin gives a name, labelled with that name written as a phrase, such as "First reading" for `first_reading`. An entry left without a name adds no output. Those outputs are offered wherever the step's declared outputs are, such as when a Condition, Compare, Compare two values, All of or Any of or Count step picks which output to read.
61
61
  - **Chosen output** — which of an earlier step's outputs a step reads. Every built-in step that names an earlier step and then reads one of its outputs asks the admin to pick that output, as does a step type of the app's own whose output setting points at a step setting. Once the earlier step is named, a step with no output picked is reported as missing that setting, and the same holds for each comparison in an All of or Any of list, for its first step and for its second step. A step that names no earlier step, such as a Compare two values step with its second step left empty, is not asked for that step's output.
62
62
  - **Start** and **End** — the built-in step types that begin and finish a flow. An End step has one setting, its output, and a second, its mark, in a host that sets `marks_ends`.
63
- - **End mark** — success or failure, chosen by an admin on each End step of a host that sets `marks_ends`, so a run that ended says whether it ended well. Publishing such a flow with an End left unmarked is refused. A stored run gives the mark of the End it reached, and gives none when it has not reached one or reached one left unmarked.
63
+ - **End mark** — success or failure, chosen by an admin on each End step of a host that sets `marks_ends`, so a run that ended says whether it ended well. Publishing such a flow with an End left unmarked is refused. A stored run gives the mark of the End it reached, and gives none when it has not reached one or reached one left unmarked. An End card on the canvas and in the run view shows its mark after the word End, such as "End · success", on one line cut short when the mark is too long for the card, and an unmarked End card reads "End".
64
64
  - **Flow output** — the text an admin writes into the output setting of an End step, given as the result of a stored run that has reached that step. A flow may hold several End steps with a different output on each, so the output says which way the flow ended. A run that has not reached an End step, or that ended on one whose output was left blank, gives no output.
65
65
  - **Question** — the built-in step type that asks the visitor: a question text, an optional category, a yes-or-no required setting, and a list of answers, each with a value, a label, a weight, a hint and an info. The visitor picks one answer, and that answer's value is recorded.
66
66
  - **Checklist** — the built-in step type that asks the visitor to tick any number of answers: a question text, a yes-or-no required setting, and a list of answers, each with a value, a label and an info. The list of ticked values is recorded, and a checklist left with nothing ticked records an empty list.
@@ -106,7 +106,7 @@ easy_flow declares no commands of its own for this local. Its surface is split b
106
106
  - **Hidden step type codes** — a setting a host may turn on, `hide_step_type_codes`, that hides step type code names on its canvas. The add menu lists each step type by its name alone, and a step's box shows its step type's name in place of the code name, with a step that has no name of its own headed by its step type's name. It is off by default, and with it off the add menu and step boxes show the code names. The settings panel shows a step's id and code name either way.
107
107
  - **Canvas direction** — a setting a host may set, `canvas_direction`, to `:left_to_right` to lay its canvas out left to right in place of top to bottom. Steps sit as compact cards in columns by stage, every connection is drawn as a line labelled with the answer it is taken on, a loop back runs above the steps, a group step's box holds its steps as their own small graph, a flow wider than the canvas scrolls sideways, and a phone-width screen shows one step per row with its connections listed under it. Top to bottom is the default.
108
108
  - **Step list** — a list beside the editing canvas, on screens 640 pixels and wider, of every step type the host offers, with a search field that keeps only the types whose name holds what was typed. A host may set `step_groups`, a hash of headings each with the step types listed under it, in the host's order, and the types it puts in no group are listed above the first heading. Clicking a type adds the step unconnected, as the add menu does, and dragging a type onto a connection inserts the step on that connection. On a phone the list is hidden and the add menu is the way to add steps.
109
- - **Run view** — a read-only view of one flow version that an app draws on its own page with `easy_flow_run_view`, showing each step as a compact card with its type code, name, the version and status line the app supplies, and an edge coloured by the state the app supplies, done, paused, pending or failed. A paused step's edge is thicker, the step the app names as selected is ringed, a card the app gives an address is a link to it, and steps sit in the same graph a left-to-right canvas draws, with every connection drawn as a line, a group step's box holding its steps, and one card per row with its connections listed on a phone. The Start and End steps are drawn as cards with their name alone and never link anywhere, Start shows as done once any step has left pending, and an End shows as done when the app names it as the step the run ended at and as pending otherwise. An app can hide Start and End. It has no editing controls.
109
+ - **Run view** — a read-only view of one flow version that an app draws on its own page with `easy_flow_run_view`, showing each step as a compact card with its type code, name, the version and status line the app supplies, and an edge coloured by the state the app supplies, done, paused, pending or failed. A paused step's edge is thicker, the step the app names as selected is ringed, a card the app gives an address is a link to it, and steps sit in the same graph a left-to-right canvas draws, with every connection drawn as a line, a group step's box holding its steps, and one card per row with its connections listed on a phone. The Start and End steps are drawn as cards with their name alone, an End followed by its mark when it has one, and never link anywhere, Start shows as done once any step has left pending, and an End shows as done when the app names it as the step the run ended at and as pending otherwise. An app can hide Start and End. It has no editing controls.
110
110
  - **Publish note** — a setting a host may set, `publish_note`, whose sentence is shown directly under the Publish button in its flow panel. With none set, the panel shows no note.
111
111
  - **Back link** — a setting a host may set, `back_link`, holding a label and an address, or a callable that takes the flow being shown and returns them, that shows a link with that label and address at the start of the editor's top bar in place of `All flows`. With a callable, each flow's canvas shows the back link worked out for that flow. With none set, the bar shows `All flows`.
112
112
  - **Top bar** — the bar across the top of the canvas and of the definition text page. From left to right it shows the back link, the flow's name, the draft's status, such as `draft from v14 · unsaved 2 changes` or `new draft · unsaved 0 changes` for a flow with no version yet, and a Canvas / Text switch between the canvas and the definition text. On the canvas its buttons are `This flow`, `Try it`, the host's editor buttons, `Save draft` and a `Publish` button naming the version it will create, such as `Publish v15`. `Save draft` creates a version as the panel's Create version does, and both open the flow panel with the result. The status and the Publish label follow each change made on the canvas. The definition text page's bar shows `Try it` and the host's editor buttons, and the page keeps its own Save button. On a screen narrower than 640 pixels the back link, name, status and switch wrap onto more lines, and the buttons are reached from an actions menu in the bar.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.52.0
4
+ version: 0.53.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider