easy_flow 0.50.0 → 0.51.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 +4 -4
- data/app/assets/builds/easy_flow/canvas.js +1 -3
- data/app/javascript/easy_flow/canvas/Canvas.jsx +1 -4
- data/app/javascript/easy_flow/canvas/Joint.jsx +8 -6
- data/app/javascript/easy_flow/canvas/LeftToRight.jsx +105 -33
- data/app/javascript/easy_flow/canvas/RunView.jsx +1 -1
- data/app/javascript/easy_flow/canvas/StepCard.jsx +1 -4
- data/app/javascript/easy_flow/canvas/StepRows.jsx +56 -0
- data/app/javascript/easy_flow/canvas/graph.js +223 -0
- data/lib/easy_flow/version.rb +1 -1
- data/the_local/agents/easy_flow-develop.md +1 -1
- data/the_local/agents/easy_flow-info.md +2 -2
- data/the_local/agents/easy_flow-install.md +2 -2
- metadata +3 -2
- data/app/javascript/easy_flow/canvas/reading.js +0 -52
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77d02cd907f2840a4791fed3dd33e5618fafc3005ee7addb574356591440ecde
|
|
4
|
+
data.tar.gz: 274741cc8c1bcd6c4a2a02eef6e0ccef0b30f6d11e2c417eb412335a2f684d56
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c9d6f4059767823106dff2370609ad97e3556c04460e7a729d7a10095905c6c97590ce3385635f85a26509b4818465662ba16d859e9a5ba98d5a8025d437913
|
|
7
|
+
data.tar.gz: ac3cd1d1c8605564a1be75478f1467a65b94293241af23569c8356bb0e2df0cdbc9ea9109d4b8984849067b7a8ddbbddb922240b88a8eb773f46b7ce9dbcdf9e
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
(()=>{var Yt=globalThis.ReactDOM;var{createPortal:es,createRoot:xe,flushSync:ts,hydrateRoot:os,preconnect:rs,prefetchDNS:ss,preinit:ns,preinitModule:as,preload:is,preloadModule:ls,requestFormReset:ds,unstable_batchedUpdates:cs,useFormState:ps,useFormStatus:ms,version:us}=Yt;var he=globalThis.React,t=he,{Children:gs,Component:xs,Fragment:hs,PureComponent:ys,StrictMode:bs,Suspense:vs,cloneElement:ks,createContext:ws,createElement:Ss,createRef:Cs,forwardRef:Ns,isValidElement:_s,lazy:zs,memo:Es,startTransition:Bs,useCallback:Ts,useContext:As,useDebugValue:Ds,useDeferredValue:Ls,useEffect:M,useId:Os,useImperativeHandle:$s,useLayoutEffect:ye,useMemo:$,useReducer:Ps,useRef:Q,useState:S,useSyncExternalStore:Ms,useTransition:Is}=he;var be=new Map,V=new Map,R=(e,o)=>be.set(e,o),ve=()=>{V.forEach(e=>e.unmount()),V.clear()},ke=(e,o)=>e.querySelectorAll("[data-react-ui]").forEach(s=>{if(V.has(s))return;let r=be.get(s.dataset.reactUi),n=o(s);V.set(s,n),n.render(t.createElement(r,JSON.parse(s.dataset.props)))});var we=(e,o)=>{let s=()=>ke(e,o);e.addEventListener("turbo:load",s),e.addEventListener("turbo:frame-load",s),e.addEventListener("turbo:before-cache",ve),e.readyState==="loading"?e.addEventListener("DOMContentLoaded",s):s()};var w=(...e)=>e.filter(Boolean).join(" ");var Xt={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},qt={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Jt=({variant:e="primary",size:o="md",className:s,children:r,...n})=>{let i=n.href?"a":"button";return t.createElement(i,{...n,className:w("ks-button",Xt[e],qt[o],s)},r)},b=Jt;var Kt="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Zt="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Qt="border border-accent-600 bg-accent-600 text-white",Rt=({name:e,connected:o,armed:s,onArm:r,connecting:n})=>t.createElement("button",{onClick:i=>{n||(i.stopPropagation(),r(i))},title:s?"Now choose a step to connect to":"Connect this branch",className:s?Qt:o?Zt:Kt,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},e||"next"),Se=Rt;var eo={width:240,boxSizing:"border-box",borderRadius:8},to={minWidth:120,boxSizing:"border-box",borderRadius:6},oo={padding:"8px 14px",textAlign:"center",fontWeight:600},ro={fontWeight:600,lineHeight:1.3},so={fontSize:12,fontWeight:500,lineHeight:1.3},no=(e,o,s)=>{let r=s?"ring-4 ring-accent-600/15":"shadow-sm";return e||s&&!o?`border-accent-600 ${r}`:o?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},ao=(e,o)=>o&&e.label===e.id&&e.type_name||e.label,io=(e,o,s)=>s?o===e.type_name?null:e.type_name:e.type,lo=({node:e,selected:o,armed:s,connecting:r,onSelect:n,onOpen:i,onArm:l,onDragEnd:d,onDragStart:c,hideStepTypeCodes:x,branches:h=[],compact:f=!1,typeAbove:u=f})=>{let y=e.begins_here||e.ends_here,m=e.begins_here,_=e.ends_here?[]:e.ports,v=r&&!m,N=ao(e,x),E=io(e,N,x);return t.createElement("div",{ref:e.ref,"data-step":e.id,draggable:!m,onDragStart:k=>{k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("text/plain",e.id),c()},onDragEnd:d,onClick:e.opens&&!r?()=>i(e.opens):n,className:`bg-white ${f&&!o?"border":"border-2"} dark:bg-zinc-900 ${no(v,e.violations.length>0,o)}`,style:{...f?to:eo,padding:y?0:f?"8px 10px":"12px 14px",cursor:m?"default":r?"crosshair":"grab"}},!y&&u&&E&&t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},E),y&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:oo},N),!y&&t.createElement("div",{style:f?so:ro},N),e.violations.length>0&&t.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${e.violations.length} error${e.violations.length===1?"":"s"}`),!y&&e.summary&&e.violations.length===0&&t.createElement("div",{className:o?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},e.summary),!y&&!u&&E&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},E),e.picture_url&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),e.starts_a_flow&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),e.opens&&t.createElement(b,{variant:"secondary",size:"sm",className:"mt-2",onClick:k=>{k.stopPropagation(),n()}},"Settings"),h.map(k=>t.createElement("div",{key:k,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},k)),_.length>0&&t.createElement("div",{style:{padding:e.begins_here?"0 14px 8px":"10px 0 0"}},_.map(k=>t.createElement(Se,{key:k,name:k,connected:e.connected.includes(k),connecting:r,armed:s===k,onArm:B=>l(k,B)}))))},ee=lo;var Ce={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},co={...Ce,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},po=({node:e,header:o,onSelect:s,compact:r=!1})=>t.createElement("div",{ref:e.ref,"data-group-header":e.id,onClick:s,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?co:Ce,...s?{}:{cursor:"default"}}},o),F=po;var mo=({id:e,bounds:o,onDrop:s})=>t.createElement("div",{"data-group-box":e,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}}),Ne=mo;var uo=e=>e!=null&&e!==""&&typeof e!="object",fo=["integer","float"],go=(e,o,s)=>s&&o.labels?.[e]||e,U=(e,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>uo(e.config[n])).map(n=>`${go(n,o,s)}${fo.includes(o.fields[n])?"":":"} ${e.config[n]}`);return[s&&e.type_name||e.type,...r].join(" \xB7 ")};var _e=(e,o,s)=>{let r=Math.min(...e.map(d=>d.left))-o.left+s.scrollLeft-12,n=Math.min(...e.map(d=>d.top))-o.top+s.scrollTop-10,i=Math.max(...e.map(d=>d.left+d.width))-o.left+s.scrollLeft+12,l=Math.max(...e.map(d=>d.top+d.height))-o.top+s.scrollTop+10;return{left:r,top:n,width:i-r,height:l-n}},xo=({left:e,top:o,width:s,height:r},n)=>n.x>=e&&n.x<=e+s&&n.y>=o&&n.y<=o+r,ze=(e,o)=>e.find(s=>xo(s.bounds,o))?.id||null,Ee=(e,o)=>e.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),Be=(e,o)=>o.some(s=>s.holds?.includes(e.id)&&!s.loose&&s.row===e.row-1);var te=(e,o)=>e.includes(o)?e.filter(s=>s!==o):[...e,o],Te=(e,o)=>({...o?.choices||{},...e?.choices||{}});var ho=({as:e="input",disabled:o,className:s,...r})=>t.createElement(e,{...r,disabled:o,className:w("ks-input",o&&"ks-input-disabled",s)}),D=ho;var yo=e=>t.createElement(D,{...e,as:"select"}),Ae=yo;var bo=({className:e,...o})=>t.createElement("input",{type:"checkbox",...o,className:w("ks-checkbox",e)}),G=bo;var vo=({name:e,value:o,label:s,hint:r,className:n,...i})=>t.createElement("label",{className:"inline-block cursor-pointer relative"},t.createElement("input",{type:"radio",name:e,value:o,...i,className:w("peer sr-only",n)}),t.createElement("span",{className:"ks-radio-card inline-flex flex-col cursor-pointer transition ks-radio-card-highlight"},t.createElement("span",{className:"ks-radio-card-header flex items-start justify-between"},t.createElement("span",{className:"ks-radio-card-label block"},s)),r!=null&&t.createElement("span",{className:"ks-radio-card-hint block text-sm"},r))),De=vo;var ko=({name:e,options:o,value:s,onChange:r,className:n})=>t.createElement("div",{className:w("flex flex-wrap ks-grid-gap-sm",n)},o.map(i=>t.createElement(De,{key:i.value,name:e,...i,checked:i.value===s,onChange:()=>r(i.value)}))),Le=ko;var Oe=e=>(e||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),wo=({name:e,type:o,value:s,choices:r,onChange:n,onSettle:i,onPick:l,pictureUrl:d})=>{if(o==="picture")return t.createElement("div",{className:"mb-3"},s&&d&&t.createElement("img",{src:d,alt:"The step's picture",style:{maxWidth:"100%"}}),s&&t.createElement(b,{type:"button",variant:"secondary",size:"sm","data-remove-picture":!0,onClick:()=>i("")},"Remove picture"),t.createElement("input",{type:"file",accept:"image/*",onChange:c=>c.target.files[0]&&l(c.target.files[0])}));if(o==="boolean")return t.createElement(G,{checked:!!s,onChange:c=>i(c.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return t.createElement(Ae,{className:"mb-3",value:s??"",onChange:c=>i(c.target.value)},t.createElement("option",{value:""}),Oe(r).map(c=>t.createElement("option",{key:c.value,value:c.value},c.label)));if(o==="radio_cards")return t.createElement("div",{"data-radio-cards":!0,className:"mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full"},t.createElement(Le,{name:e,value:s,options:r||[],onChange:i}));if(o==="multi_select"){let c=Array.isArray(s)?s:[],x=h=>i(te(c,h));return t.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(r||[]).map(h=>t.createElement("label",{key:h,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(G,{checked:c.includes(h),onChange:()=>x(h)}),t.createElement("span",null,h))))}if(o==="flows"){let c=Array.isArray(s)?s:[];return t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},Oe(r).map(x=>t.createElement("label",{key:x.value,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(G,{checked:c.includes(x.value),onChange:()=>i(te(c,x.value))}),t.createElement("span",null,x.label))))}return o==="integer"||o==="float"?t.createElement(D,{className:"mb-3",type:"number",step:o==="integer"?"1":"any",value:s??"",onChange:c=>n(c.target.value),onBlur:c=>i(c.target.value)}):t.createElement(D,{className:"mb-3",type:"text",value:s??"",onChange:c=>n(c.target.value),onBlur:c=>i(c.target.value)})},Y=wo;var $e=(e,o,s,r)=>e.map((n,i)=>i===o?{...n,[s]:r}:n);var So=({text:e})=>t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},e),X=So;var Co=(e,o,s,r)=>{let n=(e||{})[s],i=(o||{})[s];return i?(n||{})[r[i]]:n},No=({holds:e,labels:o,explanations:s,rows:r,choices:n,outputsOf:i,onChange:l,onSettle:d})=>{let c=Array.isArray(r)?r:[],x=(h,f,u,y)=>{let m=$e(c,h,f,u);y?d(m):l(m)};return t.createElement("div",{style:{marginBottom:12}},c.map((h,f)=>t.createElement("div",{key:f,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(e).map(([u,y])=>t.createElement("label",{key:u,style:{display:"block"}},t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[u]||u),t.createElement(Y,{type:y,value:h[u],choices:Co(n,i,u,h),onChange:m=>x(f,u,m,!1),onSettle:m=>x(f,u,m,!0)}),(s||{})[u]&&t.createElement(X,{text:s[u]}))),t.createElement(b,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>d(c.filter((u,y)=>y!==f))},"Remove"))),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>d([...c,{}])},"Add"))},Pe=No;var _o={start:null,end:"ks-value-list-end"},zo="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",Eo="flex flex-col min-w-0",Bo="ks-value-list-label basis-auto text-xs",To=()=>t.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"},t.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"})),Ao=({value:e,fallback:o})=>String(e??"")===""?o:e,Do=({rows:e,align:o="start",columns:s=!1,className:r})=>t.createElement("dl",{className:w("ks-value-list",_o[o],s&&zo,r)},e.map((n,i)=>t.createElement("div",{key:i,className:w(s?Eo:"ks-value-list-row",n.total&&"ks-value-list-total")},t.createElement("dt",{className:s?Bo:"ks-value-list-label"},n.label,n.note!=null&&t.createElement(t.Fragment,null," ",t.createElement("span",{className:"ks-value-list-note"},n.note))),t.createElement("dd",{className:"ks-value-list-value"},Ao(n),n.right&&t.createElement(t.Fragment,null," ",t.createElement(To,null)))))),Me=Do;var Lo=()=>t.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"},t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})),Oo=({summary:e,open:o=!1,className:s,children:r})=>t.createElement("details",{className:w("ks-disclosure group",s),open:o},t.createElement("summary",{className:"ks-disclosure-summary flex cursor-pointer list-none items-center justify-between [&::-webkit-details-marker]:hidden"},t.createElement("span",null,e),t.createElement("span",{className:"ks-disclosure-icon h-4 w-4 shrink-0 transition-transform group-open:rotate-180"},t.createElement(Lo,null))),t.createElement("div",{className:"ks-disclosure-body text-sm"},r)),Ie=Oo;var $o=({language:e,caption:o,className:s,children:r})=>t.createElement("div",{className:w("ks-code overflow-hidden",s)},o!=null&&t.createElement("div",{className:"ks-code-caption font-mono text-xs"},o),t.createElement("pre",{className:"ks-code-block overflow-x-auto font-mono text-sm leading-relaxed"},t.createElement("code",{className:e==null?"":`language-${e}`},r))),je=$o;var oe="flex flex-col gap-1 mb-3",He="[&_dd]:font-mono",Po="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",Mo="[&_.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]",Io="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=e=>e.values?e.columns?`${oe} ${He} ${Po}`:`${oe} ${He} ${Mo}`:`${oe} ${Io}`,Ho=({details:e})=>t.createElement(t.Fragment,null,e.map((o,s)=>t.createElement("section",{key:s,className:jo(o)},o.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400"},o.heading),o.values&&t.createElement(Me,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>t.createElement(Ie,{key:r.summary,summary:r.summary},t.createElement(je,null,r.code)))))),We=Ho;var Wo=({as:e="div",className:o,children:s,...r})=>t.createElement(e,{...r,className:w("ks-panel",o)},s),A=Wo;var q=(e,o)=>({className:s,children:r,...n})=>t.createElement(e,{...n,className:w(o,s)},r),W=q("label","ks-label"),la=q("p","ks-hint"),da=q("p","ks-error"),ca=q("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:e,fields:o,holds:s,labels:r,explanations:n,recordLabels:i,recordExplanations:l,recordChoices:d,recordOutputsOf:c,choices:x,onSave:h,onDelete:f,onClose:u,onPickPicture:y,refusal:m,notice:_})=>{let[v,N]=S(e.config),[E,k]=S(e.picture_url);M(()=>k(e.picture_url),[e.id,e.picture_url]),M(()=>N(e.config),[e.id,e.config]);let B=g=>{N(g),JSON.stringify(g)!==JSON.stringify(e.config)&&h(g)};return t.createElement(A,{as:"aside",style:Vo,className:"max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto","data-inspector":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8,marginBottom:12}},t.createElement("div",null,t.createElement("p",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.id," \xB7 ",e.type),t.createElement("h2",{style:{fontSize:15,fontWeight:600}},e.label)),t.createElement("button",{title:"Close",onClick:u,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),m&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},m),_&&!m&&t.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{fontWeight:600,marginBottom:12},"data-notice":!0},_),Object.entries(o).map(([g,L])=>t.createElement(W,{key:g},t.createElement("span",{style:{display:"block",marginBottom:3}},r[g]||g),L==="list"?t.createElement(Pe,{holds:s[g]||{},labels:i[g]||{},explanations:(l||{})[g],rows:v[g],choices:{...(d||{})[g],...(e.record_choices||{})[g]},outputsOf:(c||{})[g],onChange:z=>N({...v,[g]:z}),onSettle:z=>B({...v,[g]:z})}):t.createElement(Y,{name:g,type:L,value:v[g],choices:x[g],pictureUrl:E,onChange:z=>N({...v,[g]:z}),onSettle:z=>B({...v,[g]:z}),onPick:async z=>{let H=await y(z);H&&(k(H.url),B({...v,[g]:H.reference}))}}),(n||{})[g]&&t.createElement(X,{text:n[g]}))),t.createElement(We,{details:e.details||[]}),t.createElement("div",{style:Fo},(e.links||[]).length>0&&t.createElement("div",{style:{display:"flex",gap:8}},e.links.map(g=>t.createElement(b,{key:g.address,variant:"secondary",size:"sm",className:"flex-1",href:g.address},g.label))),t.createElement(b,{variant:"danger",size:"sm",className:"w-full",onClick:f},"Delete step")))},Ve=Uo;var Go={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"},Xo="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",qo="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Jo=({node:e,dragging:o,onFill:s,onDrop:r,compact:n=!1})=>t.createElement("div",{ref:e.ref,"data-placeholder":e.id,title:`Choose the step \u201C${e.label}\u201D should lead to`,onClick:s,onDragOver:i=>{o&&(i.preventDefault(),i.dataTransfer.dropEffect="move")},onDrop:i=>{i.preventDefault(),r()},className:o?qo:Xo,style:n?Yo:Go},t.createElement("div",{style:{fontWeight:600}},e.label),t.createElement("div",{style:{fontSize:11}},o?"drop a step here":"leads nowhere yet \u2014 click to choose")),Fe=Jo;var Ko=({entries:e,at:o,onPick:s,onConnect:r,onDismiss:n,hideStepTypeCodes:i})=>t.createElement(A,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:o.y,left:o.x,width:210,padding:8,borderRadius:8}},t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),e.map(l=>t.createElement(b,{key:l.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>s(l)},l.label,!i&&t.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},l.type))),r&&t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full",onClick:n},"Cancel")),Ue=Ko;var Zo=e=>o=>o.label.toLowerCase().includes(e.trim().toLowerCase()),Qo=(e,o,s="")=>{let r=Object.values(o).flat(),n=Object.entries(o).map(([i,l])=>({heading:i,entries:l.map(d=>e.find(c=>c.type===d)).filter(Boolean)}));return[{heading:null,entries:e.filter(i=>!r.includes(i.type))},...n].map(i=>({...i,entries:i.entries.filter(Zo(s))})).filter(i=>i.entries.length>0)},Ro={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"},tr={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},or=({entries:e,groups:o,onPick:s,onCarry:r,onDrop:n})=>{let[i,l]=S("");return t.createElement(A,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:Ro},t.createElement(D,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:i,onChange:d=>l(d.target.value),style:{marginBottom:6,fontSize:12}}),Qo(e,o,i).map(d=>t.createElement(t.Fragment,{key:d.heading||""},d.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:er},d.heading),d.entries.map(c=>t.createElement(A,{as:"button",type:"button",key:c.type,"data-step-type":c.type,className:"bg-surface-50 dark:bg-surface-950",style:tr,draggable:!0,onClick:()=>s(c),onDragStart:x=>{x.dataTransfer.effectAllowed="copyMove",x.dataTransfer.setData("text/plain",c.type),r(c)},onDragEnd:n},c.label)))))},Ge=or;var rr={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Ye=({label:e,title:o,idle:s,enabled:r,onUse:n})=>t.createElement(b,{variant:"secondary",size:"sm",title:r?o:s,disabled:!r,onClick:n,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},e),sr=({undoable:e,redoable:o,onAdd:s,onUndo:r,onRedo:n})=>t.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},t.createElement(b,{variant:"secondary",className:"rounded-full",style:rr,title:"Add a step",onClick:s},"+"),t.createElement(Ye,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:e,onUse:r}),t.createElement(Ye,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),Xe=sr;var nr=({type:e="info",title:o,message:s,onDismiss:r,className:n})=>t.createElement("div",{className:w("ks-alert",`ks-alert-${e}`,n),role:"alert"},t.createElement("div",{className:"ks-alert-body"},t.createElement("div",{className:"ks-alert-content"},o&&t.createElement("p",{className:"ks-alert-title"},o),t.createElement("p",{className:o?"ks-alert-message-titled":"ks-alert-message"},s)),r&&t.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),qe=nr;var Je=e=>{let o=e.map(s=>`\u201C${s.name}\u201D`).join(", ");return e.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 Ke=({version:e,published:o})=>e?o?o===e?`Version ${e} \xB7 live`:`Version ${e} \xB7 visitors still on ${o}`:`Version ${e} \xB7 never published`:"No version yet";var ar={width:280,padding:20,overflowY:"auto"},Ze={fontWeight:600,marginBottom:6,marginTop:14},re={fontSize:12,marginBottom:4,lineHeight:1.4},Qe={display:"block",marginBottom:3},Re=(e,o,s)=>r=>{r.target.value!==(e[o]??"")&&s({[o]:r.target.value})},ir=({flow:e,changes:o,refusal:s,notice:r,publishNote:n,warning:i,onCreate:l,onPublish:d,onAccept:c,onDecline:x,onSaveDetails:h,onClose:f})=>t.createElement(A,{as:"aside",style:ar,"data-builder-panel":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},t.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},e.title||e.slug),t.createElement("button",{title:"Close",onClick:f,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),t.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:e.history_url,"data-history":!0},Ke(e)),i?t.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},t.createElement(qe,{type:"warning",className:"mb-1.5",message:Je(i.steps)}),t.createElement(b,{size:"sm",className:"w-full mb-1.5",onClick:c,"data-accept-removal":!0},i.path==="/publish"?"Remove and publish":"Remove and create version"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:x,"data-decline-removal":!0},"Cancel")):t.createElement("div",{style:{marginTop:14}},t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:l,"data-create-version":!0},"Create version"),t.createElement(b,{size:"sm",className:"w-full mb-1.5",onClick:d,"data-publish":!0},"Publish"),n&&t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},n)),s&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...re,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&t.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...re,fontWeight:600,marginTop:8},"data-notice":!0},r),t.createElement("h2",{style:Ze},"Changes since the last version"),o.length===0?t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):o.map((u,y)=>t.createElement("p",{key:y,style:re,"data-change":!0},u)),t.createElement("h2",{style:Ze},"Details"),t.createElement(W,null,t.createElement("span",{style:Qe},"Title"),t.createElement(D,{className:"mb-3",defaultValue:e.title??"",onBlur:Re(e,"title",h),"data-flow-title":!0})),t.createElement(W,null,t.createElement("span",{style:Qe},"Start label"),t.createElement(D,{className:"mb-3",defaultValue:e.start_label??"",onBlur:Re(e,"start_label",h),"data-flow-start-label":!0})),t.createElement("div",{style:{marginTop:16}},t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.definition_url,"data-definition":!0},"Definition"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.details_url,"data-details":!0},"Edit details"))),et=ir;var lr=({variant:e="neutral",className:o,children:s,...r})=>t.createElement("span",{...r,className:w("ks-badge",`ks-badge-${e}`,o)},s),tt=lr;var dr={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"},cr={pills:"ks-tab-bar-pills",underline:"ks-tab-bar-underline"},pr="ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",mr="ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",ur=({shape:e,count:o})=>e?t.createElement("span",{className:"ks-tab-count"},o):t.createElement(tt,{variant:"info"},o),fr=e=>typeof e=="string"?e!=="":e>0,gr=({tabs:e,value:o,onChange:s,align:r="center",shape:n,className:i})=>t.createElement("div",{className:i},t.createElement("div",{className:w(dr[r],cr[n])},e.map(l=>t.createElement("button",{key:l.value,type:"button",className:n?mr:pr,"data-active":l.value===o?"":void 0,onClick:()=>s(l.value)},l.label,fr(l.count)&&t.createElement(t.Fragment,null," ",t.createElement(ur,{shape:n,count:l.count}))))),e.find(l=>l.value===o)?.content),ot=gr;var xr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},rt="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",hr="max-sm:absolute max-sm:inset-0 max-sm:z-20",at={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},st={display:"flex",gap:8,textAlign:"left"},nt={flexShrink:0,whiteSpace:"nowrap"},yr=({check:e,onSelect:o})=>{let s=t.createElement(t.Fragment,null,t.createElement("span",{className:xr[e.level],style:{...nt,fontWeight:500}},e.level),e.node&&t.createElement("span",{className:"font-mono",style:nt},e.node),t.createElement("span",null,e.sentence));return e.node?t.createElement("button",{type:"button","data-check-row":!0,"data-step-id":e.node,style:{...st,border:"none",background:"none",padding:0,cursor:"pointer",font:"inherit",color:"inherit"},onClick:()=>o(e.node)},s):t.createElement("div",{"data-check-row":!0,style:st},s)},br=({checks:e,onSelect:o})=>t.createElement("div",{style:at},e.map((s,r)=>t.createElement(yr,{key:r,check:s,onSelect:o}))),vr=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,kr=({checks:e,tabs:o,onSelect:s,opened:r=vr()?null:"validation"})=>{let[n,i]=S(r);return t.createElement(A,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${rt} ${hr}`:rt},t.createElement(ot,{align:"start",shape:"underline",value:n,onChange:l=>i(l===n?null:l),tabs:[{value:"validation",label:"Validation",count:e.filter(l=>l.level==="error").length,content:t.createElement(br,{checks:e,onSelect:s})},...o.map(l=>({value:l.label,label:l.label,count:l.count??"",content:t.createElement("div",{"data-drawer-content":!0,style:at,dangerouslySetInnerHTML:{__html:l.content}})}))]}))},it=kr;var lt={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},dt=e=>({opacity:e?1:0,transition:"opacity .12s"}),wr=({link:e,onInsert:o,onRemove:s,onDrop:r,dragging:n,alwaysShowInsertButtons:i})=>{let[l,d]=S(!1),c=l||n;return t.createElement("div",{"data-connector":`${e.source}-${e.target}`,style:{position:"absolute",left:e.midX-34,top:e.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onDragEnter:()=>d(!0),onDragLeave:()=>d(!1),onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},onDrop:x=>{x.preventDefault(),d(!1),r()}},t.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},t.createElement(b,{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&&l),style:{...lt,...dt(c||i)}},"+"),!n&&t.createElement(b,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...lt,...dt(c)}},"\xD7")))},ct=wr;var Sr=({links:e,extent:o,dragging:s,onInsert:r,onRemove:n,onDrop:i,alwaysShowInsertButtons:l})=>t.createElement(t.Fragment,null,t.createElement("svg",{width:o.width,height:o.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},t.createElement("defs",null,t.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},t.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),e.map(d=>t.createElement("path",{key:d.id,"data-link":d.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:d.path}))),e.filter(d=>d.label).map(d=>t.createElement("div",{key:`${d.id}-label`,"data-link-label":d.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:d.midX+(l?2:-10),top:d.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},d.label)),e.filter(d=>!d.placeholder).map(d=>t.createElement(ct,{key:d.id,link:d,dragging:!!s,alwaysShowInsertButtons:l,onInsert:()=>r(d),onRemove:()=>n(d),onDrop:()=>i(d)}))),pt=Sr;var se={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},mt="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Cr=({link:e,onInsert:o,onRemove:s,onDrop:r,alwaysShowInsertButtons:n,dragging:i})=>t.createElement("div",{"data-joint":e?.id,className:"group relative h-7 w-full sm:h-auto sm:w-7 sm:self-stretch",onMouseEnter:l=>{l.currentTarget.dataset.over="true"},onMouseLeave:l=>{delete l.currentTarget.dataset.over},onDragOver:l=>{e&&r&&(l.preventDefault(),l.dataTransfer.dropEffect="move")},onDrop:l=>{e&&(l.preventDefault(),r(e))}},e&&t.createElement("div",{className:"absolute left-1/2 top-0 h-full w-px bg-gray-400 sm:left-0 sm:top-1/2 sm:h-px sm:w-full dark:bg-zinc-500"}),e&&o&&t.createElement("div",{className:"absolute inset-0 flex items-center justify-center gap-1 sm:flex-col",style:{zIndex:4}},t.createElement(b,{variant:"secondary",title:"Insert a step here",onClick:l=>o(e,l),className:`rounded-full ${n?"opacity-100":mt}`,style:i?{...se,opacity:1}:se},"+"),t.createElement(b,{variant:"danger",title:"Remove this connection",onClick:()=>s(e),className:`rounded-full ${mt}`,style:se},"\xD7"))),ut=Cr;var Nr=(e,o)=>e.row-o.row||e.column-o.column,ft=e=>new Map(e.flatMap(o=>(o.holds||[]).map(s=>[s,o.id]))),gt=e=>{let o=[...e].sort(Nr),s=ft(e),r=new Map(e.filter(n=>n.holds).map(n=>[n.id,[]]));return o.filter(n=>s.has(n.id)).forEach(n=>r.get(s.get(n.id)).push(n)),o.filter(n=>!s.has(n.id)).flatMap(n=>[n,...r.get(n.id)||[]])},xt=e=>{let o=ft(e),s=gt(e),r=[],n=new Map;return s.filter(i=>!o.has(i.id)).forEach(i=>{let l=r[r.length-1];i.holds?n.set(i.id,r[r.push({group:i,steps:[]})-1]):l&&!l.group?l.steps.push(i):r.push({steps:[i]})}),s.filter(i=>o.has(i.id)).forEach(i=>n.get(o.get(i.id))?.steps.push(i)),r},_r=e=>e?.placeholder?"nowhere yet":e?.label,ne=new WeakMap,zr=e=>(ne.has(e)||ne.set(e,new Map([...e].reverse().map(o=>[`${o.source}
|
|
2
|
-
${o.target}`,o]))),ne.get(e)),ht=(e,o,s)=>zr(e).get(`${o.id}
|
|
3
|
-
${s.id}`),yt=(e,o,s)=>{let r=gt(e),n=new Map(r.map((d,c)=>[d.id,r[c+1]?.id])),i=new Map(s.map(d=>[d.id,_r(d)])),l=Object.fromEntries(e.map(d=>[d.id,[]]));return o.filter(d=>l[d.source]&&(d.label||d.target!==n.get(d.source))).forEach(d=>l[d.source].push([d.label,"\u2192",i.get(d.target)].filter(Boolean).join(" "))),l};var Er={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},bt=({steps:e,edges:o,draw:s,joints:r})=>t.createElement("div",{"data-flow-row":!0,className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5"},e.map((n,i)=>t.createElement("div",{key:n.id,className:"flex flex-col sm:flex-row sm:items-center"},i>0&&t.createElement(ut,{link:ht(o,e[i-1],n),...r}),s(n)))),Br={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},Tr=({group:e,steps:o,edges:s,draw:r,joints:n})=>t.createElement("div",{"data-group-box":e.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:Br},r(e),t.createElement(bt,{steps:o,edges:s,draw:r,joints:n})),Ar=({nodes:e,edges:o,draw:s,joints:r,children:n,style:i})=>t.createElement("div",{"data-flow-rows":!0,style:{...Er,...i}},n,xt(e).map(l=>l.group?t.createElement(Tr,{key:l.group.id,group:l.group,steps:l.steps,edges:o,draw:s,joints:r}):t.createElement(bt,{key:l.steps[0].id,steps:l.steps,edges:o,draw:s,joints:r}))),J=Ar;var kt="Your change was not saved because the server could not be reached.",Dr="Your change was saved, but the canvas could not be refreshed. Reload the page to see it.",vt=async({base:e,fetch:o,onFlow:s,onError:r})=>{let n=await o(e+".json",{headers:{Accept:"application/json"}}).catch(()=>null),i=n?.ok?await n.json().catch(()=>null):null;return i?s(i):r(Dr)},wt=({base:e,token:o,fetch:s,onFlow:r,onError:n,onNotice:i,onWarning:l=()=>{}})=>async(d,c,x)=>{let h={base:e,fetch:s,onFlow:r,onError:n},f=await s(e+d,{method:c,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:x&&JSON.stringify(x)}).catch(()=>null);if(!f)return i(null),n(kt);let u=await f.json().catch(()=>({}));return u.unconnected?(i(null),n(null),l({path:d,steps:u.unconnected}),vt(h)):(l(null),f.ok?(n(null),i(u.notice||null),vt(h)):(i(null),n(u.error||"That change was refused")))},St=({base:e,token:o,fetch:s,onError:r})=>async n=>{let i=new FormData;i.append("picture",n);let l=await s(e+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:i}).catch(()=>null);if(!l)return r(kt),null;let d=await l.json().catch(()=>({}));return l.ok?(r(null),d):(r(d.error||"That picture was refused"),null)};var Lr=(e,o,s)=>{let[r,n]=S(s),[i,l]=S(null),[d,c]=S(null),[x,h]=S(null),f=$(()=>wt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onFlow:n,onError:l,onNotice:c,onWarning:h}),[e,o]),u=$(()=>St({base:e,token:o,fetch:(...y)=>window.fetch(...y),onError:l}),[e,o]);return{flow:r,error:i,notice:d,warning:x,setWarning:h,send:f,pickPicture:u}},Ct=Lr;var K=(e,o,s,r)=>{let n=e.left-s.left+r.scrollLeft,i=e.top-s.top+r.scrollTop;return o==="left"?{x:n,y:i+e.height/2}:o==="right"?{x:n+e.width,y:i+e.height/2}:o==="top"?{x:n+e.width/2,y:i}:{x:n+e.width/2,y:i+e.height}},Or=(e,o,s)=>s&&o==="top"?{x:e.x,y:s.top}:e,$r=(e,o)=>o==="top"?{x:e.x,y:e.y-3}:o==="left"?{x:e.x-3,y:e.y}:o==="right"?{x:e.x+3,y:e.y}:{x:e.x,y:e.y+3},Pr=(e,o,s,r,n)=>{let i={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}`}[e.route];return{...e,path:i,midX:e.route==="detour"?n:(o.x+s.x)/2,midY:e.route==="lane"?r:(o.y+s.y)/2}},Mr=(e,o,s,r)=>{let[n,i]=S([]),[l,d]=S({width:"100%",height:"100%"}),[c,x]=S([]);return ye(()=>{let h=()=>{let u=o.current?.getBoundingClientRect();if(!u)return;d({width:o.current.scrollWidth,height:o.current.scrollHeight});let y=e.nodes.filter(m=>m.holds&&!m.loose&&s.current[m.id]).map(m=>{let _=s.current[m.id],v=_.getBoundingClientRect(),N=m.holds.flatMap(k=>s.current[k]?[s.current[k].getBoundingClientRect()]:[]),E=[{left:v.left,top:v.top,width:Math.max(v.width,_.scrollWidth),height:v.height},...N];return{id:m.id,bounds:_e(E,u,o.current)}});x(y),i(e.edges.flatMap(m=>{let _=s.current[m.source]?.getBoundingClientRect(),v=s.current[m.target]?.getBoundingClientRect();if(!_||!v)return[];let N=K(_,m.leaves,u,o.current),E=y.find(L=>L.id===m.target)?.bounds,k=$r(Or(K(v,m.enters,u,o.current),m.enters,E),m.enters),B=(K(_,"bottom",u,o.current).y+K(v,"top",u,o.current).y)/2,g=m.leaves==="left"?Math.min(N.x,k.x)-28:Math.max(N.x,k.x)+28;return[Pr(m,N,k,B,g)]}))};h(),window.addEventListener("resize",h);let f=new ResizeObserver(h);return o.current&&f.observe(o.current),()=>{window.removeEventListener("resize",h),f.disconnect()}},r),{links:n,extent:l,boxes:c}},Nt=Mr;var _t=(e,o)=>{let s=new Set(o),r=e,n=2;for(;s.has(r);)r=`${e}_${n++}`;return r};var zt=({send:e,onPress:o})=>s=>{let r=s.target.closest?.("[data-bar-action]");r&&(r.closest("details")?.removeAttribute("open"),o(),r.dataset.barPath&&e(r.dataset.barPath,"POST"))};var jr=8,Hr={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},Wr={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},Vr={flex:1,minHeight:0,overflow:"auto",position:"relative"},Bt={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},Fr={...Bt,position:"static",alignSelf:"flex-start"},Ur={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Tt={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Gr=({port:e,onCancel:o})=>t.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Tt},"Choose the step \u201C",e||"next","\u201D should lead to \u2014 ",t.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")),Yr=({message:e})=>t.createElement("p",{"data-canvas-error":!0,className:"bg-red-50 text-red-800 dark:bg-red-950 dark:text-red-200",style:Tt},e),Xr=({base:e,token:o,initial:s})=>{let{flow:r,error:n,notice:i,warning:l,setWarning:d,send:c,pickPicture:x}=Ct(e,o,s),[h,f]=S(null),[u,y]=S(null),[m,_]=S(null),[v,N]=S(null),[E,k]=S(null),[B,g]=S(!1),L=Q({}),z=Q(null);M(()=>{let a=zt({send:c,onPress:()=>{f(null),g(!0)}});return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[c]),M(()=>{if(!B){d(null);return}let a=p=>{p.target.isConnected&&!p.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&g(!1)};return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[B]),M(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),M(()=>{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=$(()=>Object.fromEntries(r.nodes.map(a=>[a.id,a])),[r.nodes]),{links:Pt,extent:Mt,boxes:ae}=Nt(r,z,L,[r,h,H]),It=$(()=>{let a={};return r.violations.forEach(p=>{var C;return(a[C=p.node]||(a[C]=[])).push(p)}),a},[r.violations]),T=r.direction==="left_to_right",j=$(()=>r.nodes.filter(a=>!a.loose),[r.nodes]),ie=r.nodes.filter(a=>a.loose),jt=$(()=>T?yt(j,r.edges,r.nodes):{},[T,j,r.edges,r.nodes]),Ht=$(()=>{let a={};return r.edges.forEach(p=>{var C;return(a[C=p.source]||(a[C]=[])).push(p.label||null)}),a},[r.edges]),Wt=Math.max(0,...j.map(a=>a.row))+1,Vt=Math.max(0,...j.map(a=>a.column))+1,le=a=>{if(!m)return;let[p,C]=m;_(null),p!==a&&c("/edges","POST",{from:p,to:a,on:C||null})},Ft=a=>{if(a.isDefaultPrevented()||!v)return;a.preventDefault();let p=v;N(null);let C=z.current.getBoundingClientRect(),ge=ze(ae,{x:a.clientX-C.left+z.current.scrollLeft,y:a.clientY-C.top+z.current.scrollTop}),Ut=r.nodes.find(Gt=>Gt.holds?.includes(p))?.id||null;ge!==Ut&&c(`/steps/${p}/group`,"PATCH",{group:ge})},de=a=>[...r.palette,...r.unoffered||[]].find(p=>p.type===a?.type),P=r.nodes.find(a=>a.id===h),O=de(P),Z=(a,p={})=>c("/steps","POST",{id:_t(a.type,r.nodes.map(C=>C.id)),type:a.type,from:p.from,to:p.to,on:p.on}),ce=a=>{let[p,C]=[E,v];k(null),N(null),p?Z(p,{from:a.source,to:a.target}):C&&c("/steps/"+C+"/move","PATCH",{from:a.source,to:a.target})},pe=a=>{let p=z.current.getBoundingClientRect();return{x:a.clientX-p.left+z.current.scrollLeft+8,y:a.clientY-p.top+z.current.scrollTop+8}},me=(a,p)=>({node:{...a,ref:C=>{L.current[a.id]=C},violations:It[a.id]||[],connected:p},selected:a.id===h,armed:m&&m[0]===a.id?m[1]:null,connecting:!!m&&m[0]!==a.id,onSelect:()=>m?le(a.id):f(a.id),onOpen:C=>window.location.assign(C),onDragStart:()=>N(a.id),onDragEnd:()=>N(null),hideStepTypeCodes:r.hide_step_type_codes,compact:T,branches:jt[a.id]||[]}),ue=a=>t.createElement(t.Fragment,null,a.placeholder&&t.createElement(Fe,{node:{...a,ref:p=>{L.current[a.id]=p}},dragging:!!v,compact:T,onFill:()=>y({from:a.from,on:a.on,at:{x:16,y:52}}),onDrop:()=>{let p=v;N(null),p&&c("/edges","POST",{from:a.from,to:p,on:a.on})}}),a.holds&&t.createElement(F,{node:{...a,ref:p=>{L.current[a.id]=p}},header:U(a,de(a),r.hide_step_type_codes),compact:T,onSelect:()=>m?le(a.id):f(a.id)}),!a.placeholder&&!a.holds&&t.createElement(ee,{...me(a,Ht[a.id]||[]),onArm:(p,C)=>y({from:a.id,on:p,at:pe(C)})})),fe=ie.length>0&&t.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:T?Fr:Bt},t.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"),ie.map(a=>t.createElement("div",{key:a.id,style:{marginBottom:8}},t.createElement(ee,{...me(a,[]),onArm:(p,C)=>{C.stopPropagation(),_([a.id,p])}}))));return t.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:Hr,onMouseUp:()=>N(null),onKeyDown:a=>{a.key==="Escape"&&(f(null),_(null),y(null))},tabIndex:-1},t.createElement(Ge,{entries:r.palette,groups:r.step_groups||{},onPick:a=>Z(a),onCarry:k,onDrop:()=>k(null)}),t.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:Wr},t.createElement("div",{ref:z,style:Vr,onClick:a=>{a.target===z.current&&(f(null),_(null),g(!1))},onDragOver:a=>{v&&a.preventDefault()},onDrop:Ft},m&&t.createElement(Gr,{port:m[1],onCancel:()=>_(null)}),n&&!B&&!P&&t.createElement(Yr,{message:n}),t.createElement(Xe,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>y({at:{x:16,y:52}}),onUndo:()=>{f(null),c("/undo","POST")},onRedo:()=>{f(null),c("/redo","POST")}}),!T&&ae.map(a=>t.createElement(Ne,{key:a.id,id:a.id,bounds:a.bounds,onDrop:()=>{let p=v;N(null),p&&c(`/steps/${p}/group`,"PATCH",{group:a.id})}})),!T&&t.createElement(pt,{links:Ee(Pt,r.nodes),extent:Mt,dragging:v||E,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:a=>y({from:a.source,to:a.target,at:{x:a.midX+30,y:a.midY}}),onRemove:a=>{f(null),c("/edges","DELETE",{from:a.source,to:a.target})},onDrop:ce}),!T&&fe,T&&t.createElement(J,{nodes:j,edges:r.edges,draw:ue,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(v||E),onInsert:(a,p)=>y({from:a.source,to:a.target,at:pe(p)}),onRemove:a=>{f(null),c("/edges","DELETE",{from:a.source,to:a.target})},onDrop:ce}},fe),!T&&t.createElement("div",{style:{...Ur,gridTemplateColumns:`repeat(${Vt+1}, ${280/2}px)`,gridTemplateRows:`repeat(${Wt}, auto)`}},j.map(a=>t.createElement("div",{key:a.id,style:{gridRow:a.row+1,gridColumn:`${a.column+1} / span 2`,zIndex:2,marginTop:Be(a,r.nodes)?jr-64:0}},ue(a)))),u&&t.createElement(Ue,{entries:r.palette,at:u.at,onDismiss:()=>y(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:u.on!==void 0?()=>{_([u.from,u.on]),y(null)}:null,onPick:a=>{let p=u;y(null),Z(a,p)}})),t.createElement(it,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:f})),B&&!P&&t.createElement(et,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:i,publishNote:r.publish_note,warning:l,onClose:()=>g(!1),onCreate:()=>c("/versions","POST"),onPublish:()=>c("/publish","POST"),onAccept:()=>c(l.path,"POST",{remove_unconnected:l.steps.map(a=>a.id)}),onDecline:()=>d(null),onSaveDetails:a=>c("/details","PATCH",{flow:a})}),P&&t.createElement(Ve,{node:P,fields:O?.fields||{},holds:O?.records||{},labels:O?.labels||{},explanations:O?.explanations||{},recordLabels:O?.record_labels||{},recordExplanations:O?.record_explanations||{},recordChoices:O?.record_choices||{},recordOutputsOf:O?.record_outputs_of||{},choices:Te(P,O),onClose:()=>f(null),onSave:a=>c(`/steps/${P.id}`,"PATCH",{config:a}),onPickPicture:x,refusal:n,notice:i,onDelete:()=>{f(null),c(`/steps/${P.id}`,"DELETE")}}))},At=Xr;var qr={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Jr={fontSize:12,fontWeight:500,lineHeight:1.3},Dt={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"},Lt={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"},Kr="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Zr=({node:e,selected:o=!1})=>{let s=e.address?"a":"div";return t.createElement(s,{"data-step":e.id,href:e.address||void 0,className:`${e.state==="paused"?"border-2":"border"} ${Dt[e.state]||Dt.pending}${o?` ${Kr}`:""}`,style:qr},t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.type),t.createElement("div",{style:Jr},e.label,e.version&&t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},e.version)),e.status&&t.createElement("div",{className:Lt[e.state]||Lt.pending,style:{fontSize:11}},e.status))},Ot=Zr;var Qr={gap:12,padding:0},Rr=({nodes:e,edges:o,selected:s})=>t.createElement(J,{nodes:e,edges:o,joints:{},style:Qr,draw:r=>r.holds?t.createElement(F,{node:r,header:U(r,r,!1),compact:!0}):t.createElement(Ot,{node:r,selected:r.id===s})}),$t=Rr;R("easy_flow/flow-editor",At);R("easy_flow/run-view",$t);document.addEventListener("easy_flow:flow-named",e=>{let o=document.querySelector("[data-flow-heading]");o&&(o.textContent=e.detail)});document.addEventListener("easy_flow:flow-status",({detail:e})=>{e.status&&document.querySelectorAll("[data-version-status]").forEach(o=>{o.textContent=e.status}),e.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(o=>{o.textContent=`Publish v${e.publishes}`})});we(document,xe);})();
|
|
1
|
+
(()=>{var Xe=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}=Xe;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 Ye={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},qe={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Je=({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",Ye[t],qe[o],s)},r)},w=Je;var Ke="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Ze="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Qe="border border-accent-600 bg-accent-600 text-white",Re=({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?Qe:o?Ze:Ke,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},t||"next"),Dt=Re;var to={width:240,boxSizing:"border-box",borderRadius:8},eo={minWidth:120,boxSizing:"border-box",borderRadius:6},oo={padding:"8px 14px",textAlign:"center",fontWeight:600},ro={fontWeight:600,lineHeight:1.3},so={fontSize:12,fontWeight:500,lineHeight:1.3},no=(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"},ao=(t,o)=>o&&t.label===t.id&&t.type_name||t.label,io=(t,o,s)=>s?o===t.type_name?null:t.type_name:t.type,lo=({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=ao(t,m),C=io(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 ${no(_,t.violations.length>0,o)}`,style:{...u?eo:to,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:oo},v),!h&&e.createElement("div",{style:u?so:ro},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=lo;var Lt={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},co={...Lt,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},po=({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?co:Lt,...s?{}:{cursor:"default"}}},o),et=po;var mo=({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=mo;var uo=t=>t!=null&&t!==""&&typeof t!="object",fo=["integer","float"],go=(t,o,s)=>s&&o.labels?.[t]||t,ot=(t,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>uo(t.config[n])).map(n=>`${go(n,o,s)}${fo.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}},ho=({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=>ho(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 xo=({as:t="input",disabled:o,className:s,...r})=>e.createElement(t,{...r,disabled:o,className:A("ks-input",o&&"ks-input-disabled",s)}),I=xo;var yo=t=>e.createElement(I,{...t,as:"select"}),Gt=yo;var bo=({className:t,...o})=>e.createElement("input",{type:"checkbox",...o,className:A("ks-checkbox",t)}),rt=bo;var vo=({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=vo;var wo=({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=wo;var Ut=t=>(t||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),ko=({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=ko;var Xt=(t,o,s,r)=>t.map((n,a)=>a===o?{...n,[s]:r}:n);var So=({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=So;var Co=(t,o,s,r)=>{let n=(t||{})[s],a=(o||{})[s];return a?(n||{})[r[a]]:n},No=({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:Co(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=No;var Eo={start:null,end:"ks-value-list-end"},_o="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",Ao="flex flex-col min-w-0",zo="ks-value-list-label basis-auto text-xs",To=()=>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"})),Mo=({value:t,fallback:o})=>String(t??"")===""?o:t,Oo=({rows:t,align:o="start",columns:s=!1,className:r})=>e.createElement("dl",{className:A("ks-value-list",Eo[o],s&&_o,r)},t.map((n,a)=>e.createElement("div",{key:a,className:A(s?Ao:"ks-value-list-row",n.total&&"ks-value-list-total")},e.createElement("dt",{className:s?zo:"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"},Mo(n),n.right&&e.createElement(e.Fragment,null," ",e.createElement(To,null)))))),qt=Oo;var Bo=()=>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"})),Do=({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(Bo,null))),e.createElement("div",{className:"ks-disclosure-body text-sm"},r)),Jt=Do;var Lo=({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=Lo;var xt="flex flex-col gap-1 mb-3",Zt="[&_dd]:font-mono",Po="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",Io="[&_.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]",$o="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]",Ho=t=>t.values?t.columns?`${xt} ${Zt} ${Po}`:`${xt} ${Zt} ${Io}`:`${xt} ${$o}`,Wo=({details:t})=>e.createElement(e.Fragment,null,t.map((o,s)=>e.createElement("section",{key:s,className:Ho(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=Wo;var jo=({as:t="div",className:o,children:s,...r})=>e.createElement(t,{...r,className:A("ks-panel",o)},s),D=jo;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 Go={width:320,padding:"14px 16px",overflowY:"auto",display:"flex",flexDirection:"column",fontSize:12},Vo={marginTop:"auto",paddingTop:12,display:"flex",flexDirection:"column",gap:8},Fo=({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:Go,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:Vo},(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=Fo;var Uo={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},Xo={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},Yo="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",qo="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Jo=({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?qo:Yo,style:n?Xo:Uo},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=Jo;var Ko=({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=Ko;var Zo=t=>o=>o.label.toLowerCase().includes(t.trim().toLowerCase()),Qo=(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(Zo(s))})).filter(a=>a.entries.length>0)},Ro={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},tr={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},er={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},or=({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:Ro},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}}),Qo(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:tr},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:er,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=or;var rr={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),sr=({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:rr,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=sr;var nr=({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=nr;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 ar={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})},ir=({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:ar,"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=ir;var lr=({variant:t="neutral",className:o,children:s,...r})=>e.createElement("span",{...r,className:A("ks-badge",`ks-badge-${t}`,o)},s),me=lr;var dr={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"},cr={pills:"ks-tab-bar-pills",underline:"ks-tab-bar-underline"},pr="ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",mr="ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",ur=({shape:t,count:o})=>t?e.createElement("span",{className:"ks-tab-count"},o):e.createElement(me,{variant:"info"},o),fr=t=>typeof t=="string"?t!=="":t>0,gr=({tabs:t,value:o,onChange:s,align:r="center",shape:n,className:a})=>e.createElement("div",{className:a},e.createElement("div",{className:A(dr[r],cr[n])},t.map(p=>e.createElement("button",{key:p.value,type:"button",className:n?mr:pr,"data-active":p.value===o?"":void 0,onClick:()=>s(p.value)},p.label,fr(p.count)&&e.createElement(e.Fragment,null," ",e.createElement(ur,{shape:n,count:p.count}))))),t.find(p=>p.value===o)?.content),ue=gr;var hr={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",xr="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"},yr=({check:t,onSelect:o})=>{let s=e.createElement(e.Fragment,null,e.createElement("span",{className:hr[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)},br=({checks:t,onSelect:o})=>e.createElement("div",{style:xe},t.map((s,r)=>e.createElement(yr,{key:r,check:s,onSelect:o}))),vr=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,wr=({checks:t,tabs:o,onSelect:s,opened:r=vr()?null:"validation"})=>{let[n,a]=E(r);return e.createElement(D,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${fe} ${xr}`: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(br,{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=wr;var be={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},ve=t=>({opacity:t?1:0,transition:"opacity .12s"}),kr=({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=kr;var Sr=({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=Sr;var bt={width:22,height:22,padding:0,fontSize:14,lineHeight:"14px"},Se="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Cr={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:2,height:"100%"},Nr=({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:Cr},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=Nr;var Er=(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},_r=(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},Ar=(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},zr=(t,o)=>t.length>0?t[t.length-1]+o[o.length-1]:0,Tr=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=_r(t,o),a=o.filter(g=>!n.has(g)),p=Er(t,a),c=Ar(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)),zr(vt(S,24,_),S)}),k=Tr(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 Mr={left:44,top:40,right:20,bottom:40},Or={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(_),Or)])),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,Mr),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 Br={display:"flex",flexDirection:"column",gap:14,padding:"64px 16px 24px"},Dr={display:"flex",flexDirection:"column",gap:10,padding:"8px 10px",borderRadius:8},Lr={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,minHeight:26,paddingLeft:12,fontSize:11},Pr=t=>(o,s)=>t[o.id].column-t[s.id].column||t[o.id].row-t[s.id].row,Ir=t=>t?.placeholder?"nowhere yet":t?.label,$r=({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:Lr},e.createElement("span",null,[a.label,"\u2192",s.get(a.target)].filter(Boolean).join(" "))))),Hr=({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,Ir(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(Pr(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($r,{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:{...Br,...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:Dr},h(d),(x.get(d.id)||[]).map(h)):h(d)))},Ne=Hr;var Wr={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:14,padding:"64px 0 0"},jr={position:"absolute",zIndex:3,maxWidth:56,fontSize:10,lineHeight:"13px",pointerEvents:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Gr=t=>t.map(([o,s],r)=>`${r===0?"M":"L"} ${o} ${s}`).join(" "),Vr=t=>Object.fromEntries(Object.entries(t).filter(([,o])=>o?.firstElementChild).map(([o,s])=>[o,s.firstElementChild.offsetHeight])),Fr=(t,o)=>Object.keys(o).some(s=>t[s]!==o[s]),Ur=({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=Vr(p.current);Fr(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:Gr(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:{...jr,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)",Xr=()=>typeof window>"u"||!window.matchMedia||window.matchMedia(_e).matches,Yr=()=>{let[t,o]=E(Xr);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},qr=({nodes:t,edges:o,draw:s,joints:r,children:n,style:a})=>Yr()?e.createElement("div",{"data-flow-rows":!0,style:{...Wr,...a}},n,e.createElement(Ur,{nodes:t,edges:o,draw:s,joints:r})):e.createElement(Ne,{nodes:t,edges:o,draw:s,joints:r,style:a},n),dt=qr;var ze="Your change was not saved because the server could not be reached.",Jr="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(Jr)},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 Kr=(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=Kr;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}},Zr=(t,o,s)=>s&&o==="top"?{x:t.x,y:s.top}:t,Qr=(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},Rr=(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}},ts=(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=Qr(Zr(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[Rr(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=ts;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 os=8,rs={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},ss={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},ns={flex:1,minHeight:0,overflow:"auto",position:"relative"},Ie={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},as={...Ie,position:"static",alignSelf:"flex-start"},is={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},ls=({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")),ds=({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),cs=({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}),Fe=r.nodes.find(Ue=>Ue.holds?.includes(y))?.id||null;_t!==Fe&&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?as: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:rs,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:ss},e.createElement("div",{ref:T,style:ns,onClick:i=>{i.target===T.current&&(x(null),_(null),b(!1))},onDragOver:i=>{v&&i.preventDefault()},onDrop:Q},f&&e.createElement(ls,{port:f[1],onCancel:()=>_(null)}),n&&!O&&!j&&e.createElement(ds,{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:{...is,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)?os-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=cs;var ps={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},ms={fontSize:12,fontWeight:500,lineHeight:1.3},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"},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";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?` ${us}`:""}`,style:ps},e.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.type),e.createElement("div",{style:ms},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:je[t.state]||je.pending,style:{fontSize:11}},t.status))},Ge=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(Ge,{node:r,selected:r.id===s})}),Ve=hs;ft("easy_flow/flow-editor",He);ft("easy_flow/run-view",Ve);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);})();
|
|
@@ -17,7 +17,6 @@ import useFlow from "./useFlow"
|
|
|
17
17
|
import useConnectors from "./useConnectors"
|
|
18
18
|
import { CARD, GAP_X, GAP_Y } from "./styles"
|
|
19
19
|
import { nextId } from "./ids"
|
|
20
|
-
import { branchLinesOf } from "./reading"
|
|
21
20
|
import { barPressed } from "./topBar"
|
|
22
21
|
|
|
23
22
|
const HEADER_GAP = 8
|
|
@@ -92,7 +91,6 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
92
91
|
const leftToRight = flow.direction === "left_to_right"
|
|
93
92
|
const attached = useMemo(() => flow.nodes.filter((node) => !node.loose), [ flow.nodes ])
|
|
94
93
|
const loose = flow.nodes.filter((node) => node.loose)
|
|
95
|
-
const branchLines = useMemo(() => (leftToRight ? branchLinesOf(attached, flow.edges, flow.nodes) : {}), [ leftToRight, attached, flow.edges, flow.nodes ])
|
|
96
94
|
const connectedFrom = useMemo(() => {
|
|
97
95
|
const ports = {}
|
|
98
96
|
flow.edges.forEach((edge) => (ports[edge.source] ||= []).push(edge.label || null))
|
|
@@ -150,8 +148,7 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
150
148
|
onDragStart: () => setDragging(node.id),
|
|
151
149
|
onDragEnd: () => setDragging(null),
|
|
152
150
|
hideStepTypeCodes: flow.hide_step_type_codes,
|
|
153
|
-
compact: leftToRight
|
|
154
|
-
branches: branchLines[node.id] || []
|
|
151
|
+
compact: leftToRight
|
|
155
152
|
})
|
|
156
153
|
|
|
157
154
|
const draw = (node) => (
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import Button from "keystone_ui-react/src/Button.jsx"
|
|
3
3
|
|
|
4
|
-
const round = { width:
|
|
4
|
+
const round = { width: 22, height: 22, padding: 0, fontSize: 14, lineHeight: "14px" }
|
|
5
5
|
|
|
6
6
|
const shownOnHover = "opacity-0 transition-opacity group-data-[over=true]:opacity-100"
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const controls = { display: "flex", alignItems: "center", justifyContent: "flex-end", gap: 2, height: "100%" }
|
|
9
|
+
|
|
10
|
+
const Joint = ({ link, onInsert, onRemove, onDrop, alwaysShowInsertButtons, dragging, shown = false, className = "", style, children }) => (
|
|
11
|
+
<div data-joint={link?.id} className={`group ${className}`.trim()} style={style}
|
|
10
12
|
onMouseEnter={(event) => { event.currentTarget.dataset.over = "true" }}
|
|
11
13
|
onMouseLeave={(event) => { delete event.currentTarget.dataset.over }}
|
|
12
14
|
onDragOver={(event) => { if (link && onDrop) { event.preventDefault(); event.dataTransfer.dropEffect = "move" } }}
|
|
13
15
|
onDrop={(event) => { if (!link) return; event.preventDefault(); onDrop(link) }}>
|
|
14
|
-
{
|
|
16
|
+
{children}
|
|
15
17
|
{link && onInsert && (
|
|
16
|
-
<div
|
|
18
|
+
<div style={controls}>
|
|
17
19
|
<Button variant="secondary" title="Insert a step here" onClick={(event) => onInsert(link, event)}
|
|
18
20
|
className={`rounded-full ${alwaysShowInsertButtons ? "opacity-100" : shownOnHover}`} style={dragging ? { ...round, opacity: 1 } : round}>+</Button>
|
|
19
|
-
<Button variant="danger" title="Remove this connection" onClick={() => onRemove(link)} className={`rounded-full ${shownOnHover}`} style={round}>×</Button>
|
|
21
|
+
<Button variant="danger" title="Remove this connection" onClick={() => onRemove(link)} className={`rounded-full ${shown ? "opacity-100" : shownOnHover}`} style={round}>×</Button>
|
|
20
22
|
</div>
|
|
21
23
|
)}
|
|
22
24
|
</div>
|
|
@@ -1,36 +1,108 @@
|
|
|
1
|
-
import React from "react"
|
|
1
|
+
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"
|
|
2
2
|
import Joint from "./Joint"
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
3
|
+
import StepRows from "./StepRows"
|
|
4
|
+
import { COLUMN_GAP, layOut } from "./graph"
|
|
5
|
+
|
|
6
|
+
const stack = { display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 14, padding: "64px 0 0" }
|
|
7
|
+
|
|
8
|
+
const label = {
|
|
9
|
+
position: "absolute", zIndex: 3, maxWidth: COLUMN_GAP - 8, fontSize: 10, lineHeight: "13px", pointerEvents: "none",
|
|
10
|
+
overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const pathOf =(points) => points.map(([ x, y ], at) => `${at === 0 ? "M" : "L"} ${x} ${y}`).join(" ")
|
|
14
|
+
|
|
15
|
+
const measuredHeights = (slots) =>
|
|
16
|
+
Object.fromEntries(Object.entries(slots).filter(([ , slot ]) => slot?.firstElementChild).map(([ id, slot ]) => [ id, slot.firstElementChild.offsetHeight ]))
|
|
17
|
+
|
|
18
|
+
const changed = (before, after) => Object.keys(after).some((id) => before[id] !== after[id])
|
|
19
|
+
|
|
20
|
+
const Graph = ({ nodes, edges, draw, joints }) => {
|
|
21
|
+
const [ heights, setHeights ] = useState({})
|
|
22
|
+
const slots = useRef({})
|
|
23
|
+
const graph = useMemo(() => layOut(nodes, edges, { heights }), [ nodes, edges, heights ])
|
|
24
|
+
|
|
25
|
+
useLayoutEffect(() => {
|
|
26
|
+
const measured = measuredHeights(slots.current)
|
|
27
|
+
if (changed(heights, measured)) setHeights({ ...heights, ...measured })
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const slotted = (id) => (slot) => { slots.current[id] = slot }
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div data-flow-graph style={{ position: "relative", flex: "none", width: graph.width, height: graph.height }}>
|
|
34
|
+
<svg width={graph.width} height={graph.height} style={{ position: "absolute", top: 0, left: 0, pointerEvents: "none" }}>
|
|
35
|
+
<defs>
|
|
36
|
+
<marker id="easy_flow-graph-arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="5" markerHeight="5" orient="auto">
|
|
37
|
+
<path d="M 0 0 L 10 5 L 0 10 z" className="fill-gray-400 dark:fill-zinc-500" />
|
|
38
|
+
</marker>
|
|
39
|
+
</defs>
|
|
40
|
+
{graph.links.map((link) => (
|
|
41
|
+
<path key={link.id} data-link={link.id} d={pathOf(link.points)} fill="none" strokeWidth="1.5"
|
|
42
|
+
className="stroke-gray-400 dark:stroke-zinc-500" markerEnd="url(#easy_flow-graph-arrow)" />
|
|
43
|
+
))}
|
|
44
|
+
</svg>
|
|
45
|
+
|
|
46
|
+
{nodes.map((node) => {
|
|
47
|
+
const place = graph.places[node.id]
|
|
48
|
+
if (node.holds) {
|
|
49
|
+
return (
|
|
50
|
+
<div key={node.id} ref={slotted(node.id)} data-group-box={node.id}
|
|
51
|
+
className="border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60"
|
|
52
|
+
style={{ position: "absolute", left: place.x, top: place.y, width: place.width, height: place.height, boxSizing: "border-box", borderRadius: 8 }}>
|
|
53
|
+
<div style={{ padding: "4px 10px" }}>{draw(node)}</div>
|
|
54
|
+
</div>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div key={node.id} ref={slotted(node.id)} style={{ position: "absolute", left: place.x, top: place.y, width: place.width, zIndex: 2 }}>
|
|
60
|
+
{draw(node)}
|
|
61
|
+
</div>
|
|
62
|
+
)
|
|
63
|
+
})}
|
|
64
|
+
|
|
65
|
+
{graph.links.filter((link) => link.label).map((link) => (
|
|
66
|
+
<div key={`${link.id}-label`} data-link-label={link.id} title={link.label} className="text-gray-500 dark:text-gray-400"
|
|
67
|
+
style={{ ...label, left: link.points[0][0] + 6, top: link.points[0][1] - 14 }}>{link.label}</div>
|
|
68
|
+
))}
|
|
69
|
+
|
|
70
|
+
{joints.onInsert && graph.links.filter((link) => !link.placeholder).map((link) => (
|
|
71
|
+
<Joint key={link.id} link={link} {...joints}
|
|
72
|
+
style={{ position: "absolute", left: link.points[0][0], top: link.points[0][1] - 12, width: COLUMN_GAP - 2, height: 24, zIndex: 3 }} />
|
|
73
|
+
))}
|
|
74
|
+
</div>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const WIDE = "(min-width: 640px)"
|
|
79
|
+
|
|
80
|
+
const screenIsWide = () => typeof window === "undefined" || !window.matchMedia || window.matchMedia(WIDE).matches
|
|
81
|
+
|
|
82
|
+
const useWide = () => {
|
|
83
|
+
const [ wide, setWide ] = useState(screenIsWide)
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (!window.matchMedia) return undefined
|
|
87
|
+
const screen = window.matchMedia(WIDE)
|
|
88
|
+
const follow = () => setWide(screen.matches)
|
|
89
|
+
screen.addEventListener("change", follow)
|
|
90
|
+
return () => screen.removeEventListener("change", follow)
|
|
91
|
+
}, [])
|
|
92
|
+
|
|
93
|
+
return wide
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const LeftToRight = ({ nodes, edges, draw, joints, children, style }) => {
|
|
97
|
+
const wide = useWide()
|
|
98
|
+
if (!wide) return <StepRows nodes={nodes} edges={edges} draw={draw} joints={joints} style={style}>{children}</StepRows>
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<div data-flow-rows style={{ ...stack, ...style }}>
|
|
102
|
+
{children}
|
|
103
|
+
<Graph nodes={nodes} edges={edges} draw={draw} joints={joints} />
|
|
104
|
+
</div>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
35
107
|
|
|
36
108
|
export default LeftToRight
|
|
@@ -4,7 +4,7 @@ import GroupHeader from "./GroupHeader"
|
|
|
4
4
|
import RunCard from "./RunCard"
|
|
5
5
|
import { headerOf } from "./group"
|
|
6
6
|
|
|
7
|
-
const rows = { gap: 12, padding: 0 }
|
|
7
|
+
const rows = { gap: 12, padding: 0, maxWidth: "100%", overflowX: "auto" }
|
|
8
8
|
|
|
9
9
|
const RunView = ({ nodes, edges, selected }) => (
|
|
10
10
|
<LeftToRight nodes={nodes} edges={edges} joints={{}} style={rows} draw={(node) => (node.holds
|
|
@@ -28,7 +28,7 @@ const typeLineOf = (node, heading, hideStepTypeCodes) => {
|
|
|
28
28
|
return heading === node.type_name ? null : node.type_name
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const StepCard = ({ node, selected, armed, connecting, onSelect, onOpen, onArm, onDragEnd, onDragStart, hideStepTypeCodes,
|
|
31
|
+
const StepCard = ({ node, selected, armed, connecting, onSelect, onOpen, onArm, onDragEnd, onDragStart, hideStepTypeCodes, compact = false, typeAbove = compact }) => {
|
|
32
32
|
const bookend = node.begins_here || node.ends_here
|
|
33
33
|
const pinned = node.begins_here
|
|
34
34
|
const ports = node.ends_here ? [] : node.ports
|
|
@@ -58,9 +58,6 @@ const StepCard = ({ node, selected, armed, connecting, onSelect, onOpen, onArm,
|
|
|
58
58
|
{node.picture_url && <div className="text-accent-600 dark:text-accent-400" style={{ fontSize: 11, marginTop: 2 }}>Has a picture</div>}
|
|
59
59
|
{node.starts_a_flow && <div className="text-accent-600 dark:text-accent-400" style={{ fontSize: 11, marginTop: 2 }}>Runs a flow</div>}
|
|
60
60
|
{node.opens && <Button variant="secondary" size="sm" className="mt-2" onClick={(event) => { event.stopPropagation(); onSelect() }}>Settings</Button>}
|
|
61
|
-
{branches.map((branch) => (
|
|
62
|
-
<div key={branch} className="text-gray-500 dark:text-gray-400" style={{ fontSize: 10 }}>{branch}</div>
|
|
63
|
-
))}
|
|
64
61
|
{ports.length > 0 && (
|
|
65
62
|
<div style={{ padding: node.begins_here ? "0 14px 8px" : "10px 0 0" }}>
|
|
66
63
|
{ports.map((port) => (
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import Joint from "./Joint"
|
|
3
|
+
import { layOut } from "./graph"
|
|
4
|
+
|
|
5
|
+
const stack = { display: "flex", flexDirection: "column", gap: 14, padding: "64px 16px 24px" }
|
|
6
|
+
|
|
7
|
+
const box = { display: "flex", flexDirection: "column", gap: 10, padding: "8px 10px", borderRadius: 8 }
|
|
8
|
+
|
|
9
|
+
const connection = { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, minHeight: 26, paddingLeft: 12, fontSize: 11 }
|
|
10
|
+
|
|
11
|
+
const byPlace = (places) => (a, b) => places[a.id].column - places[b.id].column || places[a.id].row - places[b.id].row
|
|
12
|
+
|
|
13
|
+
const nameOf = (node) => (node?.placeholder ? "nowhere yet" : node?.label)
|
|
14
|
+
|
|
15
|
+
const Row = ({ node, leaving, named, draw, joints }) => (
|
|
16
|
+
<div data-step-row={node.id}>
|
|
17
|
+
{draw(node)}
|
|
18
|
+
{leaving.map((link) => (
|
|
19
|
+
<Joint key={link.id} link={link} {...joints} alwaysShowInsertButtons shown
|
|
20
|
+
className="border-l border-gray-300 text-gray-500 dark:border-zinc-600 dark:text-gray-400" style={connection}>
|
|
21
|
+
<span>{[ link.label, "→", named.get(link.target) ].filter(Boolean).join(" ")}</span>
|
|
22
|
+
</Joint>
|
|
23
|
+
))}
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const StepRows = ({ nodes, edges, draw, joints, children, style }) => {
|
|
28
|
+
const { places } = layOut(nodes, edges)
|
|
29
|
+
const named = new Map(nodes.map((node) => [ node.id, nameOf(node) ]))
|
|
30
|
+
const leaving = new Map(nodes.map((node) => [ node.id, [] ]))
|
|
31
|
+
edges.forEach((edge) => { if (leaving.has(edge.source) && named.has(edge.target)) leaving.get(edge.source).push(edge) })
|
|
32
|
+
const holders = new Map(nodes.flatMap((group) => (group.holds || []).map((id) => [ id, group.id ])))
|
|
33
|
+
const ordered = [ ...nodes ].sort(byPlace(places))
|
|
34
|
+
const inside = new Map()
|
|
35
|
+
ordered.filter((node) => holders.has(node.id)).forEach((node) => {
|
|
36
|
+
if (!inside.has(holders.get(node.id))) inside.set(holders.get(node.id), [])
|
|
37
|
+
inside.get(holders.get(node.id)).push(node)
|
|
38
|
+
})
|
|
39
|
+
const row = (node) => <Row key={node.id} node={node} leaving={leaving.get(node.id)} named={named} draw={draw} joints={joints} />
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div data-flow-rows style={{ ...stack, ...style }}>
|
|
43
|
+
{children}
|
|
44
|
+
{ordered.filter((node) => !holders.has(node.id)).map((node) => (node.holds
|
|
45
|
+
? (
|
|
46
|
+
<div key={node.id} data-group-box={node.id} className="border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60" style={box}>
|
|
47
|
+
{row(node)}
|
|
48
|
+
{(inside.get(node.id) || []).map(row)}
|
|
49
|
+
</div>
|
|
50
|
+
)
|
|
51
|
+
: row(node)))}
|
|
52
|
+
</div>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default StepRows
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
const columnsOf = (ids, edges) => {
|
|
2
|
+
const columns = new Map(ids.map((id) => [ id, 0 ]))
|
|
3
|
+
const outgoing = new Map(ids.map((id) => [ id, [] ]))
|
|
4
|
+
const waiting = new Map(ids.map((id) => [ id, 0 ]))
|
|
5
|
+
edges.forEach((edge) => {
|
|
6
|
+
outgoing.get(edge.source).push(edge.target)
|
|
7
|
+
waiting.set(edge.target, waiting.get(edge.target) + 1)
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const ready = ids.filter((id) => waiting.get(id) === 0)
|
|
11
|
+
for (let at = 0; at < ready.length; at++) {
|
|
12
|
+
const id = ready[at]
|
|
13
|
+
outgoing.get(id).forEach((target) => {
|
|
14
|
+
columns.set(target, Math.max(columns.get(target), columns.get(id) + 1))
|
|
15
|
+
waiting.set(target, waiting.get(target) - 1)
|
|
16
|
+
if (waiting.get(target) === 0) ready.push(target)
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return columns
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const outgoingOf = (ids, edges) => {
|
|
24
|
+
const outgoing = new Map(ids.map((id) => [ id, [] ]))
|
|
25
|
+
edges.forEach((edge) => outgoing.get(edge.source).push(edge))
|
|
26
|
+
return outgoing
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const loopingBack = (ids, edges) => {
|
|
30
|
+
const outgoing = outgoingOf(ids, edges)
|
|
31
|
+
const entered = new Set(edges.map((edge) => edge.target))
|
|
32
|
+
const state = new Map()
|
|
33
|
+
const backward = new Set()
|
|
34
|
+
|
|
35
|
+
const walk = (root) => {
|
|
36
|
+
const stack = [ [ root, 0 ] ]
|
|
37
|
+
state.set(root, "open")
|
|
38
|
+
while (stack.length > 0) {
|
|
39
|
+
const top = stack[stack.length - 1]
|
|
40
|
+
const edge = outgoing.get(top[0])[top[1]++]
|
|
41
|
+
if (!edge) {
|
|
42
|
+
state.set(top[0], "done")
|
|
43
|
+
stack.pop()
|
|
44
|
+
} else if (state.get(edge.target) === "open") backward.add(edge)
|
|
45
|
+
else if (!state.has(edge.target)) {
|
|
46
|
+
state.set(edge.target, "open")
|
|
47
|
+
stack.push([ edge.target, 0 ])
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ids.filter((id) => !entered.has(id)).forEach(walk)
|
|
53
|
+
ids.forEach((id) => { if (!state.has(id)) walk(id) })
|
|
54
|
+
|
|
55
|
+
return backward
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const rowsOf = (ids, forward, columns) => {
|
|
59
|
+
const stacks = []
|
|
60
|
+
ids.forEach((id) => (stacks[columns.get(id)] ||= []).push(id))
|
|
61
|
+
const outgoing = outgoingOf(ids, forward)
|
|
62
|
+
const exits = new Map()
|
|
63
|
+
outgoing.forEach((leaving) => leaving.forEach((edge, at) => exits.set(edge, (at + 1) / (leaving.length + 1))))
|
|
64
|
+
const incoming = new Map(ids.map((id) => [ id, [] ]))
|
|
65
|
+
forward.forEach((edge) => incoming.get(edge.target).push(edge))
|
|
66
|
+
const rows = new Map()
|
|
67
|
+
|
|
68
|
+
stacks.forEach((stack) => {
|
|
69
|
+
const keyOf = new Map(stack.map((id) => {
|
|
70
|
+
const from = incoming.get(id)
|
|
71
|
+
const total = from.reduce((sum, edge) => sum + rows.get(edge.source) + exits.get(edge), 0)
|
|
72
|
+
return [ id, from.length > 0 ? total / from.length : Infinity ]
|
|
73
|
+
}))
|
|
74
|
+
stack.sort((a, b) => (keyOf.get(a) === keyOf.get(b) ? 0 : keyOf.get(a) < keyOf.get(b) ? -1 : 1))
|
|
75
|
+
stack.forEach((id, row) => rows.set(id, row))
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
return rows
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const CARD_WIDTH = 184
|
|
82
|
+
export const CARD_HEIGHT = 64
|
|
83
|
+
export const COLUMN_GAP = 64
|
|
84
|
+
export const ROW_GAP = 24
|
|
85
|
+
export const MARGIN = 40
|
|
86
|
+
export const EXIT = 40
|
|
87
|
+
export const CHANNEL_GAP = 14
|
|
88
|
+
|
|
89
|
+
const startsOf = (sizes, gap, from) => {
|
|
90
|
+
const starts = []
|
|
91
|
+
sizes.forEach((size, at) => { starts[at] = at === 0 ? from : starts[at - 1] + sizes[at - 1] + gap })
|
|
92
|
+
return starts
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const endOf = (starts, sizes) => (starts.length > 0 ? starts[starts.length - 1] + sizes[sizes.length - 1] : 0)
|
|
96
|
+
|
|
97
|
+
const deepestOf = (values) => {
|
|
98
|
+
const levels = [ values ]
|
|
99
|
+
for (let width = 1; width * 2 <= values.length; width *= 2) {
|
|
100
|
+
const below = levels[levels.length - 1]
|
|
101
|
+
levels.push(below.slice(0, values.length - width * 2 + 1).map((value, at) => Math.max(value, below[at + width])))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return (from, to) => {
|
|
105
|
+
const level = Math.floor(Math.log2(to - from + 1))
|
|
106
|
+
return Math.max(levels[level][from], levels[level][to - (1 << level) + 1])
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const arrange = (ids, edges, sizeOf, room) => {
|
|
111
|
+
const backward = loopingBack(ids, edges)
|
|
112
|
+
const forward = edges.filter((edge) => !backward.has(edge))
|
|
113
|
+
const columns = columnsOf(ids, forward)
|
|
114
|
+
const rows = rowsOf(ids, forward, columns)
|
|
115
|
+
|
|
116
|
+
const columnWidths = []
|
|
117
|
+
const stacks = []
|
|
118
|
+
ids.forEach((id) => {
|
|
119
|
+
columnWidths[columns.get(id)] = Math.max(columnWidths[columns.get(id)] || 0, sizeOf(id).width)
|
|
120
|
+
;(stacks[columns.get(id)] ||= [])[rows.get(id)] = id
|
|
121
|
+
})
|
|
122
|
+
const skipping = (edge) => columns.get(edge.target) > columns.get(edge.source) + 1
|
|
123
|
+
const channelsOf = (taken) => {
|
|
124
|
+
const channels = new Map()
|
|
125
|
+
taken.forEach((edge) => { if (!channels.has(edge.target)) channels.set(edge.target, channels.size) })
|
|
126
|
+
return channels
|
|
127
|
+
}
|
|
128
|
+
const above = channelsOf(edges.filter((edge) => backward.has(edge)))
|
|
129
|
+
const below = channelsOf(forward.filter(skipping))
|
|
130
|
+
|
|
131
|
+
const lefts = startsOf(columnWidths, COLUMN_GAP, room.left)
|
|
132
|
+
const top = room.top + above.size * CHANNEL_GAP
|
|
133
|
+
const tops = new Map()
|
|
134
|
+
const bottoms = stacks.map((stack) => {
|
|
135
|
+
const heights = stack.map((id) => sizeOf(id).height)
|
|
136
|
+
startsOf(heights, ROW_GAP, top).forEach((y, at) => tops.set(stack[at], y))
|
|
137
|
+
return endOf(startsOf(heights, ROW_GAP, top), heights)
|
|
138
|
+
})
|
|
139
|
+
const lowestBetween = deepestOf(bottoms)
|
|
140
|
+
|
|
141
|
+
const places = Object.fromEntries(ids.map((id) => [ id, {
|
|
142
|
+
column: columns.get(id), row: rows.get(id),
|
|
143
|
+
x: lefts[columns.get(id)], y: tops.get(id), width: sizeOf(id).width, height: sizeOf(id).height
|
|
144
|
+
} ]))
|
|
145
|
+
|
|
146
|
+
const floors = new Map()
|
|
147
|
+
forward.filter(skipping).forEach((edge) => floors.set(edge.target,
|
|
148
|
+
Math.max(floors.get(edge.target) || 0, lowestBetween(columns.get(edge.source) + 1, columns.get(edge.target) - 1))))
|
|
149
|
+
|
|
150
|
+
const channelOf = (edge) => {
|
|
151
|
+
if (backward.has(edge)) return room.top + (above.size - 1 - above.get(edge.target)) * CHANNEL_GAP
|
|
152
|
+
if (skipping(edge)) return floors.get(edge.target) + (below.get(edge.target) + 1) * CHANNEL_GAP
|
|
153
|
+
return null
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const arrivingAt = (id) => places[id].y + (sizeOf(id).arrives ?? places[id].height / 2)
|
|
157
|
+
const heading = (edge) => channelOf(edge) ?? arrivingAt(edge.target)
|
|
158
|
+
const leavingAt = new Map()
|
|
159
|
+
outgoingOf(ids, edges).forEach((leaving) => [ ...leaving ].sort((a, b) => heading(a) - heading(b))
|
|
160
|
+
.forEach((edge, at) => leavingAt.set(edge, (at + 1) / (leaving.length + 1))))
|
|
161
|
+
|
|
162
|
+
const routed = (edge) => {
|
|
163
|
+
const from = places[edge.source]
|
|
164
|
+
const to = places[edge.target]
|
|
165
|
+
const leaving = from.y + from.height * leavingAt.get(edge)
|
|
166
|
+
const arriving = arrivingAt(edge.target)
|
|
167
|
+
const turn = lefts[from.column] + columnWidths[from.column] + EXIT
|
|
168
|
+
const channel = channelOf(edge)
|
|
169
|
+
const start = [ [ from.x + from.width, leaving ], [ turn, leaving ] ]
|
|
170
|
+
const end = [ [ to.x - COLUMN_GAP + EXIT, arriving ], [ to.x, arriving ] ]
|
|
171
|
+
|
|
172
|
+
return { ...edge.drawn, points: channel === null ? [ ...start, [ turn, arriving ], end[1] ] : [ ...start, [ turn, channel ], [ end[0][0], channel ], ...end ] }
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const links = edges.map(routed)
|
|
176
|
+
const corners = [ ...Object.values(places).map((card) => [ card.x + card.width, card.y + card.height ]), ...links.flatMap((each) => each.points) ]
|
|
177
|
+
const farthest = corners.reduce(([ right, low ], [ x, y ]) => [ Math.max(right, x), Math.max(low, y) ], [ 0, 0 ])
|
|
178
|
+
|
|
179
|
+
return { places, links, width: farthest[0] + room.right, height: farthest[1] + room.bottom }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const ENTRY = "\u0000entry"
|
|
183
|
+
const HEADER_HEIGHT = 24
|
|
184
|
+
const OUTSIDE = { left: COLUMN_GAP - EXIT + MARGIN / 2, top: MARGIN, right: MARGIN / 2, bottom: MARGIN }
|
|
185
|
+
const INSIDE = { left: 0, top: 8, right: 16, bottom: 12 }
|
|
186
|
+
|
|
187
|
+
export const layOut = (nodes, given, { heights = {} } = {}) => {
|
|
188
|
+
const drawn = new Set(nodes.map((node) => node.id))
|
|
189
|
+
const holders = new Map(nodes.flatMap((group) => (group.holds || []).filter((id) => drawn.has(id)).map((id) => [ id, group.id ])))
|
|
190
|
+
const levels = new Map([ [ null, { ids: [], edges: [] } ] ])
|
|
191
|
+
nodes.filter((node) => node.holds).forEach((group) => levels.set(group.id, { ids: [ ENTRY ], edges: [] }))
|
|
192
|
+
nodes.forEach((node) => levels.get(holders.get(node.id) ?? null).ids.push(node.id))
|
|
193
|
+
|
|
194
|
+
given.filter((edge) => drawn.has(edge.source) && drawn.has(edge.target)).forEach((edge) => {
|
|
195
|
+
const inside = holders.get(edge.target)
|
|
196
|
+
if (inside && inside === edge.source) levels.get(inside).edges.push({ source: ENTRY, target: edge.target, drawn: edge })
|
|
197
|
+
else if (inside && inside === holders.get(edge.source)) levels.get(inside).edges.push({ source: edge.source, target: edge.target, drawn: edge })
|
|
198
|
+
else levels.get(null).edges.push({ source: holders.get(edge.source) ?? edge.source, target: inside ?? edge.target, drawn: edge })
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
const cardSize = (id) => ({ width: CARD_WIDTH, height: heights[id] || CARD_HEIGHT })
|
|
202
|
+
const insides = new Map([ ...levels ].filter(([ group ]) => group).map(([ group, level ]) =>
|
|
203
|
+
[ group, arrange(level.ids, level.edges, (id) => (id === ENTRY ? { width: 0, height: CARD_HEIGHT } : cardSize(id)), INSIDE) ]))
|
|
204
|
+
const headerOf = (id) => heights[id] || HEADER_HEIGHT
|
|
205
|
+
const sizeOf = (id) => {
|
|
206
|
+
const inside = insides.get(id)
|
|
207
|
+
if (!inside) return cardSize(id)
|
|
208
|
+
return { width: inside.width, height: headerOf(id) + inside.height, arrives: headerOf(id) + inside.places[ENTRY].y + CARD_HEIGHT / 2 }
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const outside = arrange(levels.get(null).ids, levels.get(null).edges, sizeOf, OUTSIDE)
|
|
212
|
+
const places = { ...outside.places }
|
|
213
|
+
const links = [ ...outside.links ]
|
|
214
|
+
insides.forEach((inside, group) => {
|
|
215
|
+
const box = outside.places[group]
|
|
216
|
+
const [ x, y ] = [ box.x, box.y + headerOf(group) ]
|
|
217
|
+
Object.entries(inside.places).filter(([ id ]) => id !== ENTRY)
|
|
218
|
+
.forEach(([ id, place ]) => { places[id] = { ...place, x: place.x + x, y: place.y + y } })
|
|
219
|
+
inside.links.forEach((each) => links.push({ ...each, points: each.points.map(([ px, py ]) => [ px + x, py + y ]) }))
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
return { places, links, width: outside.width, height: outside.height }
|
|
223
|
+
}
|
data/lib/easy_flow/version.rb
CHANGED
|
@@ -580,7 +580,7 @@ Use this when a visitor's run should stop until a set time has passed, such as a
|
|
|
580
580
|
- `address` — optional. A card with one is a link to it, and a card without one is not a link.
|
|
581
581
|
- `selected` — the id of one step whose card is ringed in the accent colour, such as the step whose details the page shows.
|
|
582
582
|
- Any other keyword is passed to the wrapping element, such as `class:`.
|
|
583
|
-
3. The view lays the steps out left to right whatever the host's `canvas_direction`, as compact cards in
|
|
583
|
+
3. The view lays the steps out left to right whatever the host's `canvas_direction`, as the same graph a left-to-right canvas draws: compact cards in columns by stage, every connection drawn as a line labelled with the answer it is taken on, and a group step's box holding its steps as their own small graph. A flow wider than its box scrolls sideways inside it. On a screen narrower than 640 pixels each step sits on a row of its own with its connections listed under it. The Start and End steps are left out. It has no buttons and nothing on it changes the flow.
|
|
584
584
|
4. Ask the developer what each step's status line says and where each card links. Do not pick.
|
|
585
585
|
|
|
586
586
|
### Read a run and its answers
|
|
@@ -104,9 +104,9 @@ easy_flow declares no commands of its own for this local. Its surface is split b
|
|
|
104
104
|
- **Always-visible insert buttons** — a setting a host may turn on, `always_show_insert_buttons`, that shows each connection's button for inserting a step on its canvas without the pointer over the connection, with the connection's label moved to the right of the line. It is off by default, and with it off the button shows only with the pointer over the connection.
|
|
105
105
|
- **Step card** — the box that draws one step on the canvas. It shows the step's name, the one-line summary the step's type works out from its settings under the name when the type declares one or the host replaces it, and the step's type code under those, or above the name on a left-to-right canvas. A step with problems is bordered in red and its card counts them under the name, such as "1 error" or "2 errors", in place of the summary, and the sentence for each problem is in the Validation tab of the drawer under the canvas rather than on the card.
|
|
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
|
-
- **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
|
|
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
|
|
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. 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.
|
|
@@ -60,7 +60,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
60
60
|
- `offers` — the step types this host's admins can add from the canvas palette, as a list of step type names. With none set, every registered step type is offered. The engine's own names are `question`, `checklist`, `multiple_select`, `fill_in_the_blank`, `file_upload`, `condition`, `switch`, `compare`, `compare_two_values`, `all_or_any`, `count`, `wait`, `flow_step` and `play_flows`, `file_upload` being the File upload step, which needs the file store from step 10, `compare_two_values` being the Compare two values step, which compares the outputs of two earlier steps, `all_or_any` being the All of or Any of step, which decides whether all or any of several such comparisons hold, `count` being the Count step, which counts how often an earlier step was answered, `wait` being the Wait step, which holds a run until a time counted from an earlier answer or until a date, `flow_step` being the Flow step, which names one of the same host's flows, and `play_flows` being the Play flows step, which lists several of the same host's flows for a visitor to play in the order they choose. A step type the app declares is named by the id it was declared with, or after its class when it is a step class, so `Steps::Notify` is `notify`. The End step is offered whether it is listed or not, and the Start step is never offered. Ask the developer which step types each host should offer.
|
|
61
61
|
- `always_show_insert_buttons` — set to `true` to show each connection's button for inserting a step on this host's canvas without the pointer over the connection. A connection's label then sits to the right of the line so the button does not cover it. With none set, the button shows only with the pointer over the connection.
|
|
62
62
|
- `hide_step_type_codes` — set to `true` to hide step type code names on this host's canvas. The add menu then 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 none set, the add menu and step boxes show the code names. The settings panel shows a step's id and code name either way.
|
|
63
|
-
- `canvas_direction` — set to `:left_to_right` to lay this host's canvas out left to right. Steps then sit as compact cards in
|
|
63
|
+
- `canvas_direction` — set to `:left_to_right` to lay this host's canvas out left to right. Steps then sit as compact cards in columns by stage, each step to the right of every step that leads into it apart from connections that loop back. Every connection is drawn as a line, labelled with the answer it is taken on, and branches fan out into separate rows and join again at the step they share. A connection that loops back runs above the steps and one that skips columns runs below them, so no line crosses a card. A group step's box holds its steps as their own small graph, entered from the step before it and left for the step after it. A flow wider than the canvas scrolls sideways inside it. An admin inserts or removes a connection with the buttons on its line, and drops a step or a step type onto the line to put it there. On a screen narrower than 640 pixels, each step sits on a row of its own with its connections listed under it. With none set, or with `:top_to_bottom`, the canvas is laid out top to bottom as before.
|
|
64
64
|
- `step_groups` — a hash of the headings this host's canvas step list shows, each with the step types listed under it by name, such as `{ "Agents" => [ :question, :checklist ], "Control" => [ :switch, :wait ] }`. Headings appear in the order given. Offered step types the hash leaves out are listed above the first heading, and a type the host does not offer is not listed. With none set, the list shows every offered step type under no heading. Ask the developer how each host's step types should be grouped.
|
|
65
65
|
- `marks_ends` — set to `true` to have this host's admins mark each End step as success or failure. The End step's settings then show a Mark with those two choices, and publishing one of this host's flows with an End left unmarked is refused, the refusal shown on that End's card. With none set, End steps show no mark and publish as they do. Ask the developer whether this host's runs need to say if they ended well.
|
|
66
66
|
- `publish_note` — a sentence shown directly under the Publish button in this host's flow panel. It is shown as plain text. With none set, the panel shows no note.
|
|
@@ -167,7 +167,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
167
167
|
- A step type of the app's own that holds other steps, such as a "for each" step, is drawn on the canvas as a dashed box with a header line at the top and the steps it holds inside. It needs no migration and no setting in the initializer beyond being listed in a host's `offers` when that host sets `offers`. Flows with no such step load and run as before.
|
|
168
168
|
- After adding a step type that holds other steps to a flow, check that its header line shows the step type's code followed by each filled-in setting, or the type's name and the settings' labels on a host with `hide_step_type_codes` set, and that clicking the header opens the step's settings.
|
|
169
169
|
- After adding a step type that holds other steps to a flow, check that dragging another step onto its box puts the step inside the box, that dragging it onto the canvas outside the box takes it out, and that both leave the step's connections as they were.
|
|
170
|
-
- After setting `canvas_direction` to `:left_to_right` on a host, check that its canvas shows the steps in
|
|
170
|
+
- After setting `canvas_direction` to `:left_to_right` on a host, check that its canvas shows the steps in columns with every connection drawn as a labelled line, that a flow wider than the canvas scrolls sideways inside it, and that a phone-width screen shows one step per row with its connections listed under it.
|
|
171
171
|
- A page of the app that calls `easy_flow_run_view` needs the `keystone_ui/react` and `easy_flow/canvas` scripts in its head, the same two the canvas page loads. The helper needs no setting in the initializer, and it is available in every view of the app. After adding one, check that the page shows each step's card with the state and status line the app supplied, and that a phone-width screen shows one card per row.
|
|
172
172
|
- After setting `step_groups` on a host, check that its canvas shows the step list beside the canvas with each step type under its heading, that typing in its search field narrows the list, that clicking a type adds an unconnected step, that dragging a type onto a connection inserts it there, and that a phone-width screen shows no step list.
|
|
173
173
|
- After setting `editor_buttons` on a host, check that its canvas's top bar shows each button between `Try it` and `Save draft` with the label given, that each opens its address, and that on a phone-width screen the buttons are listed in the bar's actions menu.
|
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.
|
|
4
|
+
version: 0.51.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tylercschneider
|
|
@@ -118,15 +118,16 @@ files:
|
|
|
118
118
|
- app/javascript/easy_flow/canvas/RunView.jsx
|
|
119
119
|
- app/javascript/easy_flow/canvas/StepCard.jsx
|
|
120
120
|
- app/javascript/easy_flow/canvas/StepList.jsx
|
|
121
|
+
- app/javascript/easy_flow/canvas/StepRows.jsx
|
|
121
122
|
- app/javascript/easy_flow/canvas/Toolbar.jsx
|
|
122
123
|
- app/javascript/easy_flow/canvas/TypePicker.jsx
|
|
123
124
|
- app/javascript/easy_flow/canvas/changes.js
|
|
124
125
|
- app/javascript/easy_flow/canvas/choices.js
|
|
125
126
|
- app/javascript/easy_flow/canvas/flow.js
|
|
126
127
|
- app/javascript/easy_flow/canvas/flowSender.js
|
|
128
|
+
- app/javascript/easy_flow/canvas/graph.js
|
|
127
129
|
- app/javascript/easy_flow/canvas/group.js
|
|
128
130
|
- app/javascript/easy_flow/canvas/ids.js
|
|
129
|
-
- app/javascript/easy_flow/canvas/reading.js
|
|
130
131
|
- app/javascript/easy_flow/canvas/rows.js
|
|
131
132
|
- app/javascript/easy_flow/canvas/styles.js
|
|
132
133
|
- app/javascript/easy_flow/canvas/topBar.js
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const byPlace = (a, b) => a.row - b.row || a.column - b.column
|
|
2
|
-
|
|
3
|
-
const holdersOf = (nodes) => new Map(nodes.flatMap((group) => (group.holds || []).map((id) => [ id, group.id ])))
|
|
4
|
-
|
|
5
|
-
export const readingOrder = (nodes) => {
|
|
6
|
-
const placed = [ ...nodes ].sort(byPlace)
|
|
7
|
-
const holders = holdersOf(nodes)
|
|
8
|
-
const held = new Map(nodes.filter((node) => node.holds).map((group) => [ group.id, [] ]))
|
|
9
|
-
placed.filter((node) => holders.has(node.id)).forEach((node) => held.get(holders.get(node.id)).push(node))
|
|
10
|
-
|
|
11
|
-
return placed.filter((node) => !holders.has(node.id)).flatMap((node) => [ node, ...(held.get(node.id) || []) ])
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const blocksOf = (nodes) => {
|
|
15
|
-
const holders = holdersOf(nodes)
|
|
16
|
-
const ordered = readingOrder(nodes)
|
|
17
|
-
const blocks = []
|
|
18
|
-
const boxes = new Map()
|
|
19
|
-
|
|
20
|
-
ordered.filter((node) => !holders.has(node.id)).forEach((node) => {
|
|
21
|
-
const last = blocks[blocks.length - 1]
|
|
22
|
-
if (node.holds) boxes.set(node.id, blocks[blocks.push({ group: node, steps: [] }) - 1])
|
|
23
|
-
else if (last && !last.group) last.steps.push(node)
|
|
24
|
-
else blocks.push({ steps: [ node ] })
|
|
25
|
-
})
|
|
26
|
-
ordered.filter((node) => holders.has(node.id)).forEach((node) => boxes.get(holders.get(node.id))?.steps.push(node))
|
|
27
|
-
|
|
28
|
-
return blocks
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const nameOf = (step) => (step?.placeholder ? "nowhere yet" : step?.label)
|
|
32
|
-
|
|
33
|
-
const joins = new WeakMap()
|
|
34
|
-
|
|
35
|
-
const joinsOf = (edges) => {
|
|
36
|
-
if (!joins.has(edges)) joins.set(edges, new Map([ ...edges ].reverse().map((edge) => [ `${edge.source}\n${edge.target}`, edge ])))
|
|
37
|
-
return joins.get(edges)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const joining = (edges, before, after) => joinsOf(edges).get(`${before.id}\n${after.id}`)
|
|
41
|
-
|
|
42
|
-
export const branchLinesOf = (steps, edges, nodes) => {
|
|
43
|
-
const ordered = readingOrder(steps)
|
|
44
|
-
const next = new Map(ordered.map((step, at) => [ step.id, ordered[at + 1]?.id ]))
|
|
45
|
-
const names = new Map(nodes.map((node) => [ node.id, nameOf(node) ]))
|
|
46
|
-
const lines = Object.fromEntries(steps.map((step) => [ step.id, [] ]))
|
|
47
|
-
|
|
48
|
-
edges.filter((edge) => lines[edge.source] && (edge.label || edge.target !== next.get(edge.source)))
|
|
49
|
-
.forEach((edge) => lines[edge.source].push([ edge.label, "→", names.get(edge.target) ].filter(Boolean).join(" ")))
|
|
50
|
-
|
|
51
|
-
return lines
|
|
52
|
-
}
|