easy_flow 0.49.1 → 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/controllers/easy_flow/manage/canvas_controller.rb +11 -2
- data/app/javascript/easy_flow/canvas/Canvas.jsx +2 -4
- data/app/javascript/easy_flow/canvas/Inspector.jsx +2 -1
- 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/app/models/easy_flow/all_or_any.rb +2 -0
- data/app/models/easy_flow/canvas.rb +15 -3
- data/app/models/easy_flow/compare.rb +9 -0
- data/app/models/easy_flow/compare_two_values.rb +13 -0
- data/app/models/easy_flow/condition.rb +1 -0
- data/app/models/easy_flow/count.rb +8 -0
- data/app/models/easy_flow/data_step.rb +1 -0
- data/app/models/easy_flow/flow_step.rb +6 -0
- data/app/models/easy_flow/play_flows.rb +1 -0
- data/app/models/easy_flow/settings.rb +46 -6
- data/app/models/easy_flow/steps/checklist.rb +1 -0
- data/app/models/easy_flow/steps/file_upload.rb +1 -0
- data/app/models/easy_flow/steps/fill_in_the_blank.rb +1 -0
- data/app/models/easy_flow/steps/multiple_select.rb +1 -0
- data/app/models/easy_flow/steps/question.rb +5 -0
- data/app/models/easy_flow/switch.rb +2 -0
- data/app/models/easy_flow/wait.rb +8 -0
- data/lib/easy_flow/host.rb +12 -0
- data/lib/easy_flow/version.rb +1 -1
- data/the_local/agents/easy_flow-develop.md +3 -3
- data/the_local/agents/easy_flow-info.md +6 -4
- data/the_local/agents/easy_flow-install.md +3 -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:ge,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 xe=globalThis.React,t=xe,{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:he,useMemo:$,useReducer:Ps,useRef:Z,useState:S,useSyncExternalStore:Ms,useTransition:Is}=xe;var ye=new Map,W=new Map,Q=(e,o)=>ye.set(e,o),be=()=>{W.forEach(e=>e.unmount()),W.clear()},ve=(e,o)=>e.querySelectorAll("[data-react-ui]").forEach(s=>{if(W.has(s))return;let r=ye.get(s.dataset.reactUi),n=o(s);W.set(s,n),n.render(t.createElement(r,JSON.parse(s.dataset.props)))});var ke=(e,o)=>{let s=()=>ve(e,o);e.addEventListener("turbo:load",s),e.addEventListener("turbo:frame-load",s),e.addEventListener("turbo:before-cache",be),e.readyState==="loading"?e.addEventListener("DOMContentLoaded",s):s()};var k=(...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:k("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"),we=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,C=e.ends_here?[]:e.ports,w=r&&!m,_=ao(e,x),E=io(e,_,x);return t.createElement("div",{ref:e.ref,"data-step":e.id,draggable:!m,onDragStart:v=>{v.dataTransfer.effectAllowed="move",v.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(w,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},_),!y&&t.createElement("div",{style:f?so:ro},_),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:v=>{v.stopPropagation(),n()}},"Settings"),h.map(v=>t.createElement("div",{key:v,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},v)),C.length>0&&t.createElement("div",{style:{padding:e.begins_here?"0 14px 8px":"10px 0 0"}},C.map(v=>t.createElement(we,{key:v,name:v,connected:e.connected.includes(v),connecting:r,armed:s===v,onArm:g=>l(v,g)}))))},R=lo;var Se={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},co={...Se,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:Se,...s?{}:{cursor:"default"}}},o),V=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}}),Ce=mo;var uo=e=>e!=null&&e!==""&&typeof e!="object",fo=["integer","float"],go=(e,o,s)=>s&&o.labels?.[e]||e,F=(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 Ne=(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,_e=(e,o)=>e.find(s=>xo(s.bounds,o))?.id||null,ze=(e,o)=>e.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),Ee=(e,o)=>o.some(s=>s.holds?.includes(e.id)&&!s.loose&&s.row===e.row-1);var ee=(e,o)=>e.includes(o)?e.filter(s=>s!==o):[...e,o],Be=(e,o)=>({...o?.choices||{},...e?.choices||{}});var ho=({as:e="input",disabled:o,className:s,...r})=>t.createElement(e,{...r,disabled:o,className:k("ks-input",o&&"ks-input-disabled",s)}),D=ho;var yo=e=>t.createElement(D,{...e,as:"select"}),Te=yo;var bo=({className:e,...o})=>t.createElement("input",{type:"checkbox",...o,className:k("ks-checkbox",e)}),U=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:k("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))),Ae=vo;var ko=({name:e,options:o,value:s,onChange:r,className:n})=>t.createElement("div",{className:k("flex flex-wrap ks-grid-gap-sm",n)},o.map(i=>t.createElement(Ae,{key:i.value,name:e,...i,checked:i.value===s,onChange:()=>r(i.value)}))),De=ko;var Le=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(U,{checked:!!s,onChange:c=>i(c.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return t.createElement(Te,{className:"mb-3",value:s??"",onChange:c=>i(c.target.value)},t.createElement("option",{value:""}),Le(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(De,{name:e,value:s,options:r||[],onChange:i}));if(o==="multi_select"){let c=Array.isArray(s)?s:[],x=h=>i(ee(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(U,{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"},Le(r).map(x=>t.createElement("label",{key:x.value,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(U,{checked:c.includes(x.value),onChange:()=>i(ee(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)})},G=wo;var Oe=(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),Y=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=Oe(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(G,{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(Y,{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"))},$e=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:k("ks-value-list",_o[o],s&&zo,r)},e.map((n,i)=>t.createElement("div",{key:i,className:k(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)))))),Pe=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:k("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)),Me=Oo;var $o=({language:e,caption:o,className:s,children:r})=>t.createElement("div",{className:k("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))),Ie=$o;var te="flex flex-col gap-1 mb-3",je="[&_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?`${te} ${je} ${Po}`:`${te} ${je} ${Mo}`:`${te} ${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(Pe,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>t.createElement(Me,{key:r.summary,summary:r.summary},t.createElement(Ie,null,r.code)))))),He=Ho;var Wo=({as:e="div",className:o,children:s,...r})=>t.createElement(e,{...r,className:k("ks-panel",o)},s),A=Wo;var X=(e,o)=>({className:s,children:r,...n})=>t.createElement(e,{...n,className:k(o,s)},r),H=X("label","ks-label"),la=X("p","ks-hint"),da=X("p","ks-error"),ca=X("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})=>{let[C,w]=S(e.config),[_,E]=S(e.picture_url);M(()=>E(e.picture_url),[e.id,e.picture_url]),M(()=>w(e.config),[e.id,e.config]);let v=g=>{w(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),Object.entries(o).map(([g,L])=>t.createElement(H,{key:g},t.createElement("span",{style:{display:"block",marginBottom:3}},r[g]||g),L==="list"?t.createElement($e,{holds:s[g]||{},labels:i[g]||{},explanations:(l||{})[g],rows:C[g],choices:{...(d||{})[g],...(e.record_choices||{})[g]},outputsOf:(c||{})[g],onChange:z=>w({...C,[g]:z}),onSettle:z=>v({...C,[g]:z})}):t.createElement(G,{name:g,type:L,value:C[g],choices:x[g],pictureUrl:_,onChange:z=>w({...C,[g]:z}),onSettle:z=>v({...C,[g]:z}),onPick:async z=>{let B=await y(z);B&&(E(B.url),v({...C,[g]:B.reference}))}}),(n||{})[g]&&t.createElement(Y,{text:n[g]}))),t.createElement(He,{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")))},We=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")),Ve=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")),Fe=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)))))},Ue=or;var rr={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Ge=({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(Ge,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:e,onUse:r}),t.createElement(Ge,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),Ye=sr;var nr=({type:e="info",title:o,message:s,onDismiss:r,className:n})=>t.createElement("div",{className:k("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"))),Xe=nr;var qe=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 Je=({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"},Ke={fontWeight:600,marginBottom:6,marginTop:14},oe={fontSize:12,marginBottom:4,lineHeight:1.4},Ze={display:"block",marginBottom:3},Qe=(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},Je(e)),i?t.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},t.createElement(Xe,{type:"warning",className:"mb-1.5",message:qe(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:{...oe,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&t.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...oe,fontWeight:600,marginTop:8},"data-notice":!0},r),t.createElement("h2",{style:Ke},"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:oe,"data-change":!0},u)),t.createElement("h2",{style:Ke},"Details"),t.createElement(H,null,t.createElement("span",{style:Ze},"Title"),t.createElement(D,{className:"mb-3",defaultValue:e.title??"",onBlur:Qe(e,"title",h),"data-flow-title":!0})),t.createElement(H,null,t.createElement("span",{style:Ze},"Start label"),t.createElement(D,{className:"mb-3",defaultValue:e.start_label??"",onBlur:Qe(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"))),Re=ir;var lr=({variant:e="neutral",className:o,children:s,...r})=>t.createElement("span",{...r,className:k("ks-badge",`ks-badge-${e}`,o)},s),et=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(et,{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:k(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),tt=gr;var xr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},ot="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",nt={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},rt={display:"flex",gap:8,textAlign:"left"},st={flexShrink:0,whiteSpace:"nowrap"},yr=({check:e,onSelect:o})=>{let s=t.createElement(t.Fragment,null,t.createElement("span",{className:xr[e.level],style:{...st,fontWeight:500}},e.level),e.node&&t.createElement("span",{className:"font-mono",style:st},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:{...rt,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:rt},s)},br=({checks:e,onSelect:o})=>t.createElement("div",{style:nt},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?`${ot} ${hr}`:ot},t.createElement(tt,{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:nt,dangerouslySetInnerHTML:{__html:l.content}})}))]}))},at=kr;var it={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},lt=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:{...it,...lt(c||i)}},"+"),!n&&t.createElement(b,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...it,...lt(c)}},"\xD7")))},dt=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(dt,{key:d.id,link:d,dragging:!!s,alwaysShowInsertButtons:l,onInsert:()=>r(d),onRemove:()=>n(d),onDrop:()=>i(d)}))),ct=Sr;var re={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},pt="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":pt}`,style:i?{...re,opacity:1}:re},"+"),t.createElement(b,{variant:"danger",title:"Remove this connection",onClick:()=>s(e),className:`rounded-full ${pt}`,style:re},"\xD7"))),mt=Cr;var Nr=(e,o)=>e.row-o.row||e.column-o.column,ut=e=>new Map(e.flatMap(o=>(o.holds||[]).map(s=>[s,o.id]))),ft=e=>{let o=[...e].sort(Nr),s=ut(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)||[]])},gt=e=>{let o=ut(e),s=ft(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,se=new WeakMap,zr=e=>(se.has(e)||se.set(e,new Map([...e].reverse().map(o=>[`${o.source}
|
|
2
|
-
${o.target}`,o]))),se.get(e)),xt=(e,o,s)=>zr(e).get(`${o.id}
|
|
3
|
-
${s.id}`),ht=(e,o,s)=>{let r=ft(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"},yt=({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(mt,{link:xt(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(yt,{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,gt(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(yt,{key:l.steps[0].id,steps:l.steps,edges:o,draw:s,joints:r}))),q=Ar;var vt="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.",bt=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)},kt=({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(vt);let u=await f.json().catch(()=>({}));return u.unconnected?(i(null),n(null),l({path:d,steps:u.unconnected}),bt(h)):(l(null),f.ok?(n(null),i(u.notice||null),bt(h)):(i(null),n(u.error||"That change was refused")))},wt=({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(vt),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=$(()=>kt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onFlow:n,onError:l,onNotice:c,onWarning:h}),[e,o]),u=$(()=>wt({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}},St=Lr;var J=(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 he(()=>{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 C=s.current[m.id],w=C.getBoundingClientRect(),_=m.holds.flatMap(v=>s.current[v]?[s.current[v].getBoundingClientRect()]:[]),E=[{left:w.left,top:w.top,width:Math.max(w.width,C.scrollWidth),height:w.height},..._];return{id:m.id,bounds:Ne(E,u,o.current)}});x(y),i(e.edges.flatMap(m=>{let C=s.current[m.source]?.getBoundingClientRect(),w=s.current[m.target]?.getBoundingClientRect();if(!C||!w)return[];let _=J(C,m.leaves,u,o.current),E=y.find(z=>z.id===m.target)?.bounds,v=$r(Or(J(w,m.enters,u,o.current),m.enters,E),m.enters),g=(J(C,"bottom",u,o.current).y+J(w,"top",u,o.current).y)/2,L=m.leaves==="left"?Math.min(_.x,v.x)-28:Math.max(_.x,v.x)+28;return[Pr(m,_,v,g,L)]}))};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}},Ct=Mr;var Nt=(e,o)=>{let s=new Set(o),r=e,n=2;for(;s.has(r);)r=`${e}_${n++}`;return r};var _t=({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"},Et={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},Fr={...Et,position:"static",alignSelf:"flex-start"},Ur={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Bt={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:Bt},"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:Bt},e),Xr=({base:e,token:o,initial:s})=>{let{flow:r,error:n,notice:i,warning:l,setWarning:d,send:c,pickPicture:x}=St(e,o,s),[h,f]=S(null),[u,y]=S(null),[m,C]=S(null),[w,_]=S(null),[E,v]=S(null),[g,L]=S(!1),z=Z({}),B=Z(null);M(()=>{let a=_t({send:c,onPress:()=>{f(null),L(!0)}});return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[c]),M(()=>{if(!g){d(null);return}let a=p=>{p.target.isConnected&&!p.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&L(!1)};return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[g]),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 $t=$(()=>Object.fromEntries(r.nodes.map(a=>[a.id,a])),[r.nodes]),{links:Pt,extent:Mt,boxes:ne}=Ct(r,B,z,[r,h,$t]),It=$(()=>{let a={};return r.violations.forEach(p=>{var N;return(a[N=p.node]||(a[N]=[])).push(p)}),a},[r.violations]),T=r.direction==="left_to_right",j=$(()=>r.nodes.filter(a=>!a.loose),[r.nodes]),ae=r.nodes.filter(a=>a.loose),jt=$(()=>T?ht(j,r.edges,r.nodes):{},[T,j,r.edges,r.nodes]),Ht=$(()=>{let a={};return r.edges.forEach(p=>{var N;return(a[N=p.source]||(a[N]=[])).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,ie=a=>{if(!m)return;let[p,N]=m;C(null),p!==a&&c("/edges","POST",{from:p,to:a,on:N||null})},Ft=a=>{if(a.isDefaultPrevented()||!w)return;a.preventDefault();let p=w;_(null);let N=B.current.getBoundingClientRect(),fe=_e(ne,{x:a.clientX-N.left+B.current.scrollLeft,y:a.clientY-N.top+B.current.scrollTop}),Ut=r.nodes.find(Gt=>Gt.holds?.includes(p))?.id||null;fe!==Ut&&c(`/steps/${p}/group`,"PATCH",{group:fe})},le=a=>[...r.palette,...r.unoffered||[]].find(p=>p.type===a?.type),P=r.nodes.find(a=>a.id===h),O=le(P),K=(a,p={})=>c("/steps","POST",{id:Nt(a.type,r.nodes.map(N=>N.id)),type:a.type,from:p.from,to:p.to,on:p.on}),de=a=>{let[p,N]=[E,w];v(null),_(null),p?K(p,{from:a.source,to:a.target}):N&&c("/steps/"+N+"/move","PATCH",{from:a.source,to:a.target})},ce=a=>{let p=B.current.getBoundingClientRect();return{x:a.clientX-p.left+B.current.scrollLeft+8,y:a.clientY-p.top+B.current.scrollTop+8}},pe=(a,p)=>({node:{...a,ref:N=>{z.current[a.id]=N},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?ie(a.id):f(a.id),onOpen:N=>window.location.assign(N),onDragStart:()=>_(a.id),onDragEnd:()=>_(null),hideStepTypeCodes:r.hide_step_type_codes,compact:T,branches:jt[a.id]||[]}),me=a=>t.createElement(t.Fragment,null,a.placeholder&&t.createElement(Ve,{node:{...a,ref:p=>{z.current[a.id]=p}},dragging:!!w,compact:T,onFill:()=>y({from:a.from,on:a.on,at:{x:16,y:52}}),onDrop:()=>{let p=w;_(null),p&&c("/edges","POST",{from:a.from,to:p,on:a.on})}}),a.holds&&t.createElement(V,{node:{...a,ref:p=>{z.current[a.id]=p}},header:F(a,le(a),r.hide_step_type_codes),compact:T,onSelect:()=>m?ie(a.id):f(a.id)}),!a.placeholder&&!a.holds&&t.createElement(R,{...pe(a,Ht[a.id]||[]),onArm:(p,N)=>y({from:a.id,on:p,at:ce(N)})})),ue=ae.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:Et},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"),ae.map(a=>t.createElement("div",{key:a.id,style:{marginBottom:8}},t.createElement(R,{...pe(a,[]),onArm:(p,N)=>{N.stopPropagation(),C([a.id,p])}}))));return t.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:Hr,onMouseUp:()=>_(null),onKeyDown:a=>{a.key==="Escape"&&(f(null),C(null),y(null))},tabIndex:-1},t.createElement(Ue,{entries:r.palette,groups:r.step_groups||{},onPick:a=>K(a),onCarry:v,onDrop:()=>v(null)}),t.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:Wr},t.createElement("div",{ref:B,style:Vr,onClick:a=>{a.target===B.current&&(f(null),C(null),L(!1))},onDragOver:a=>{w&&a.preventDefault()},onDrop:Ft},m&&t.createElement(Gr,{port:m[1],onCancel:()=>C(null)}),n&&!g&&!P&&t.createElement(Yr,{message:n}),t.createElement(Ye,{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&&ne.map(a=>t.createElement(Ce,{key:a.id,id:a.id,bounds:a.bounds,onDrop:()=>{let p=w;_(null),p&&c(`/steps/${p}/group`,"PATCH",{group:a.id})}})),!T&&t.createElement(ct,{links:ze(Pt,r.nodes),extent:Mt,dragging:w||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:de}),!T&&ue,T&&t.createElement(q,{nodes:j,edges:r.edges,draw:me,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(w||E),onInsert:(a,p)=>y({from:a.source,to:a.target,at:ce(p)}),onRemove:a=>{f(null),c("/edges","DELETE",{from:a.source,to:a.target})},onDrop:de}},ue),!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:Ee(a,r.nodes)?jr-64:0}},me(a)))),u&&t.createElement(Fe,{entries:r.palette,at:u.at,onDismiss:()=>y(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:u.on!==void 0?()=>{C([u.from,u.on]),y(null)}:null,onPick:a=>{let p=u;y(null),K(a,p)}})),t.createElement(at,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:f})),g&&!P&&t.createElement(Re,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:i,publishNote:r.publish_note,warning:l,onClose:()=>L(!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(We,{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:Be(P,O),onClose:()=>f(null),onSave:a=>c(`/steps/${P.id}`,"PATCH",{config:a}),onPickPicture:x,refusal:n,onDelete:()=>{f(null),c(`/steps/${P.id}`,"DELETE")}}))},Tt=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},At={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"},Dt={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"} ${At[e.state]||At.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:Dt[e.state]||Dt.pending,style:{fontSize:11}},e.status))},Lt=Zr;var Qr={gap:12,padding:0},Rr=({nodes:e,edges:o,selected:s})=>t.createElement(q,{nodes:e,edges:o,joints:{},style:Qr,draw:r=>r.holds?t.createElement(V,{node:r,header:F(r,r,!1),compact:!0}):t.createElement(Lt,{node:r,selected:r.id===s})}),Ot=Rr;Q("easy_flow/flow-editor",Tt);Q("easy_flow/run-view",Ot);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}`})});ke(document,ge);})();
|
|
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);})();
|
|
@@ -104,7 +104,7 @@ module EasyFlow
|
|
|
104
104
|
def apply(action = nil, *steps)
|
|
105
105
|
before = document.to_h
|
|
106
106
|
flow.edit_history.record(yield(document), action, steps, before)
|
|
107
|
-
|
|
107
|
+
@notice ? render(json: { notice: @notice }) : head(:no_content)
|
|
108
108
|
rescue InvalidEdit => invalid
|
|
109
109
|
render json: { error: invalid.message }, status: :unprocessable_entity
|
|
110
110
|
end
|
|
@@ -193,10 +193,15 @@ module EasyFlow
|
|
|
193
193
|
return configuration unless step_type && EasyFlow.registry.registered?(step_type)
|
|
194
194
|
|
|
195
195
|
settled(EasyFlow.registry.fetch(step_type))
|
|
196
|
+
rescue Settings::OptionsUnavailable => unavailable
|
|
197
|
+
Rails.logger.error("EasyFlow could not save step #{id}: #{unavailable.message}")
|
|
198
|
+
raise InvalidEdit, "#{unavailable.setting} could not be worked out, so the change was not saved."
|
|
196
199
|
end
|
|
197
200
|
|
|
198
201
|
def settled(step_type)
|
|
199
|
-
step_type.settings.coerce(configuration)
|
|
202
|
+
coerced = step_type.settings.coerce(configuration)
|
|
203
|
+
@notice = cleared_notice(step_type, coerced)
|
|
204
|
+
step_type.settings.cleared(coerced).tap do |values|
|
|
200
205
|
objections = step_type.settings.objections(values)
|
|
201
206
|
raise InvalidEdit, objections.join(", ") if objections.any?
|
|
202
207
|
|
|
@@ -208,6 +213,10 @@ module EasyFlow
|
|
|
208
213
|
end.then { |values| step_type.settings.unkept(values) }
|
|
209
214
|
end
|
|
210
215
|
|
|
216
|
+
def cleared_notice(step_type, values)
|
|
217
|
+
step_type.settings.strays(values).map { |name| "Cleared #{step_type.settings.labels[name.to_sym]} because #{values[name]} is not offered for the step's other settings." }.join(" ").presence
|
|
218
|
+
end
|
|
219
|
+
|
|
211
220
|
def foreign_flows(step_type, values)
|
|
212
221
|
step_type.settings.fields.select { |name, type| %i[flow flows].include?(type) && values[name.to_s].present? }
|
|
213
222
|
.reject { |name, _type| Array(values[name.to_s]).all? { |id| flow.reaches?(Definition.find_by(id: id)) } }
|
|
@@ -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) => (
|
|
@@ -269,6 +266,7 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
269
266
|
onSave={(config) => send(`/steps/${selectedNode.id}`, "PATCH", { config })}
|
|
270
267
|
onPickPicture={pickPicture}
|
|
271
268
|
refusal={error}
|
|
269
|
+
notice={notice}
|
|
272
270
|
onDelete={() => { setSelected(null); send(`/steps/${selectedNode.id}`, "DELETE") }} />
|
|
273
271
|
)}
|
|
274
272
|
</div>
|
|
@@ -11,7 +11,7 @@ const panel = { width: 320, padding: "14px 16px", overflowY: "auto", display: "f
|
|
|
11
11
|
|
|
12
12
|
const foot = { marginTop: "auto", paddingTop: 12, display: "flex", flexDirection: "column", gap: 8 }
|
|
13
13
|
|
|
14
|
-
const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, recordExplanations, recordChoices, recordOutputsOf, choices, onSave, onDelete, onClose, onPickPicture, refusal }) => {
|
|
14
|
+
const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, recordExplanations, recordChoices, recordOutputsOf, choices, onSave, onDelete, onClose, onPickPicture, refusal, notice }) => {
|
|
15
15
|
const [ draft, setDraft ] = useState(node.config)
|
|
16
16
|
const [ pictureUrl, setPictureUrl ] = useState(node.picture_url)
|
|
17
17
|
useEffect(() => setPictureUrl(node.picture_url), [ node.id, node.picture_url ])
|
|
@@ -33,6 +33,7 @@ const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, re
|
|
|
33
33
|
style={{ border: "none", background: "none", cursor: "pointer", fontSize: 18, lineHeight: 1 }}>×</button>
|
|
34
34
|
</div>
|
|
35
35
|
{refusal && <p className="text-red-800 dark:text-red-400" style={{ fontWeight: 600, marginBottom: 12 }} data-refusal>{refusal}</p>}
|
|
36
|
+
{notice && !refusal && <p className="text-emerald-800 dark:text-emerald-400" style={{ fontWeight: 600, marginBottom: 12 }} data-notice>{notice}</p>}
|
|
36
37
|
{Object.entries(fields).map(([ name, type ]) => (
|
|
37
38
|
<Label key={name}>
|
|
38
39
|
<span style={{ display: "block", marginBottom: 3 }}>{labels[name] || name}</span>
|
|
@@ -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) => (
|