easy_flow 0.47.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a64183f5e338cb3950e9f77d3165834a939dee76067f5cf4cd567e4ca2e40144
4
- data.tar.gz: b5878c5007128011c23d43bc3aeaeeee8b13e79856f7c061ab01de7a61894745
3
+ metadata.gz: c8982c5b8d1ce99325e551defd3fe3cd5dc1c6fe47b30c9577acd0eb4963cfb5
4
+ data.tar.gz: cacca6d87e4cd17cecd3ca9c8f421222bdb9f9e5b1190db60d5d7768065c2843
5
5
  SHA512:
6
- metadata.gz: 4a68b07005457be0dc468f418ae95cda4bf89f87951cb7ac2b9b3c086f42baa2fd390fcae62f3882e8678428952634c9448e471883ad582e76c001591d95ec20
7
- data.tar.gz: 738d0e6babe2dfd388381d0224615a3deefa630b2a2dd6084793184f7e1b9a1095c97963afaeac8dbb9139bc66eb0f93019832b49067b7e858ec5662f3077cc7
6
+ metadata.gz: 7ea8fb69a242f0ac1e6b62032b55fadead54cf95c4c41a28d223dfce56089ab25d088969520a1ff1a6a221d95e669fd722fba87aff5f3ba0d1cf5ef53b1701be
7
+ data.tar.gz: eb0eae28d9d3c148eabe860b39b379c89471b4a16c4ef396af9a78a930d8b7adb50ad92859a4df83036c46c849b5797562f504743978d8bb42fb17b2c4ca85a3
@@ -1 +1 @@
1
- (()=>{var ze=globalThis.ReactDOM;var{createPortal:eo,createRoot:ft,flushSync:ro,hydrateRoot:oo,preconnect:no,prefetchDNS:so,preinit:ao,preinitModule:io,preload:lo,preloadModule:co,requestFormReset:po,unstable_batchedUpdates:uo,useFormState:mo,useFormStatus:fo,version:go}=ze;var gt=globalThis.React,e=gt,{Children:yo,Component:xo,Fragment:bo,PureComponent:vo,StrictMode:wo,Suspense:ko,cloneElement:Co,createContext:So,createElement:No,createRef:zo,forwardRef:Bo,isValidElement:_o,lazy:To,memo:Eo,startTransition:Do,useCallback:Ao,useContext:Oo,useDebugValue:Po,useDeferredValue:$o,useEffect:L,useId:Lo,useImperativeHandle:Io,useLayoutEffect:ht,useMemo:j,useReducer:Mo,useRef:et,useState:C,useSyncExternalStore:jo,useTransition:Ho}=gt;var yt=new Map,V=new Map,rt=(t,r)=>yt.set(t,r),xt=()=>{V.forEach(t=>t.unmount()),V.clear()},bt=(t,r)=>t.querySelectorAll("[data-react-ui]").forEach(n=>{if(V.has(n))return;let o=yt.get(n.dataset.reactUi),a=r(n);V.set(n,a),a.render(e.createElement(o,JSON.parse(n.dataset.props)))});var vt=(t,r)=>{let n=()=>bt(t,r);t.addEventListener("turbo:load",n),t.addEventListener("turbo:frame-load",n),t.addEventListener("turbo:before-cache",xt),t.readyState==="loading"?t.addEventListener("DOMContentLoaded",n):n()};var T=(...t)=>t.filter(Boolean).join(" ");var Be={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},_e={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Te=({variant:t="primary",size:r="md",className:n,children:o,...a})=>{let i=a.href?"a":"button";return e.createElement(i,{...a,className:T("ks-button",Be[t],_e[r],n)},o)},v=Te;var Ee="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",De="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Ae="border border-accent-600 bg-accent-600 text-white",Oe=({name:t,connected:r,armed:n,onArm:o,connecting:a})=>e.createElement("button",{onClick:i=>{a||(i.stopPropagation(),o(i))},title:n?"Now choose a step to connect to":"Connect this branch",className:n?Ae:r?De:Ee,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},t||"next"),wt=Oe;var Pe={width:240,boxSizing:"border-box",borderRadius:8},$e={minWidth:120,boxSizing:"border-box",borderRadius:6},Le={padding:"8px 14px",textAlign:"center",fontWeight:600},Ie={fontWeight:600,lineHeight:1.3},Me={fontSize:12,fontWeight:500,lineHeight:1.3},je=(t,r,n)=>{let o=n?"ring-4 ring-accent-600/15":"shadow-sm";return t||n&&!r?`border-accent-600 ${o}`:r?`border-red-600 ${o}`:"border-gray-300 shadow-sm dark:border-zinc-700"},He=(t,r)=>r&&t.label===t.id&&t.type_name||t.label,We=(t,r,n)=>n?r===t.type_name?null:t.type_name:t.type,Fe=({node:t,selected:r,armed:n,connecting:o,onSelect:a,onOpen:i,onArm:c,onDragEnd:d,onDragStart:l,hideStepTypeCodes:y,branches:h=[],compact:m=!1,typeAbove:g=m})=>{let f=t.begins_here||t.ends_here,u=t.begins_here,k=t.ends_here?[]:t.ports,w=o&&!u,S=He(t,y),_=We(t,S,y);return e.createElement("div",{ref:t.ref,"data-step":t.id,draggable:!u,onDragStart:b=>{b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("text/plain",t.id),l()},onDragEnd:d,onClick:t.opens&&!o?()=>i(t.opens):a,className:`bg-white ${m&&!r?"border":"border-2"} dark:bg-zinc-900 ${je(w,t.violations.length>0,r)}`,style:{...m?$e:Pe,padding:f?0:m?"8px 10px":"12px 14px",cursor:u?"default":o?"crosshair":"grab"}},!f&&g&&_&&e.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},_),f&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:Le},S),!f&&e.createElement("div",{style:m?Me:Ie},S),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"}`),!f&&t.summary&&t.violations.length===0&&e.createElement("div",{className:r?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},t.summary),!f&&!g&&_&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},_),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(v,{variant:"secondary",size:"sm",className:"mt-2",onClick:b=>{b.stopPropagation(),a()}},"Settings"),h.map(b=>e.createElement("div",{key:b,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},b)),k.length>0&&e.createElement("div",{style:{padding:t.begins_here?"0 14px 8px":"10px 0 0"}},k.map(b=>e.createElement(wt,{key:b,name:b,connected:t.connected.includes(b),connecting:o,armed:n===b,onArm:x=>c(b,x)}))))},ot=Fe;var kt={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},Ve={...kt,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},Ye=({node:t,header:r,onSelect:n,compact:o=!1})=>e.createElement("div",{ref:t.ref,"data-group-header":t.id,onClick:n,className:"font-mono text-gray-500 dark:text-gray-400",style:{...o?Ve:kt,...n?{}:{cursor:"default"}}},r),Y=Ye;var Ue=({id:t,bounds:r,onDrop:n})=>e.createElement("div",{"data-group-box":t,onDragOver:o=>{o.preventDefault(),o.dataTransfer.dropEffect="move"},onDrop:o=>{o.preventDefault(),n()},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",...r}}),Ct=Ue;var Ge=t=>t!=null&&t!==""&&typeof t!="object",Xe=["integer","float"],qe=(t,r,n)=>n&&r.labels?.[t]||t,U=(t,r,n)=>{let o=Object.keys(r?.fields||{}).filter(a=>Ge(t.config[a])).map(a=>`${qe(a,r,n)}${Xe.includes(r.fields[a])?"":":"} ${t.config[a]}`);return[n&&t.type_name||t.type,...o].join(" \xB7 ")};var St=(t,r,n)=>{let o=Math.min(...t.map(d=>d.left))-r.left+n.scrollLeft-12,a=Math.min(...t.map(d=>d.top))-r.top+n.scrollTop-10,i=Math.max(...t.map(d=>d.left+d.width))-r.left+n.scrollLeft+12,c=Math.max(...t.map(d=>d.top+d.height))-r.top+n.scrollTop+10;return{left:o,top:a,width:i-o,height:c-a}},Je=({left:t,top:r,width:n,height:o},a)=>a.x>=t&&a.x<=t+n&&a.y>=r&&a.y<=r+o,Nt=(t,r)=>t.find(n=>Je(n.bounds,r))?.id||null,zt=(t,r)=>t.filter(n=>!r.some(o=>o.id===n.source&&o.holds?.includes(n.target))),Bt=(t,r)=>r.some(n=>n.holds?.includes(t.id)&&!n.loose&&n.row===t.row-1);var nt=(t,r)=>t.includes(r)?t.filter(n=>n!==r):[...t,r],_t=(t,r)=>({...r?.choices||{},...t?.choices||{}});var Ke=({as:t="input",disabled:r,className:n,...o})=>e.createElement(t,{...o,disabled:r,className:T("ks-input",r&&"ks-input-disabled",n)}),A=Ke;var Qe=t=>e.createElement(A,{...t,as:"select"}),Tt=Qe;var Ze=({className:t,...r})=>e.createElement("input",{type:"checkbox",...r,className:T("ks-checkbox",t)}),G=Ze;var Re=({name:t,value:r,label:n,hint:o,...a})=>e.createElement("label",{className:"inline-block cursor-pointer relative"},e.createElement("input",{type:"radio",name:t,value:r,...a,className:"peer sr-only"}),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"},n)),o!=null&&e.createElement("span",{className:"ks-radio-card-hint block text-sm"},o))),Et=Re;var tr=({name:t,options:r,value:n,onChange:o})=>e.createElement("div",{className:"flex flex-wrap ks-grid-gap-sm"},r.map(a=>e.createElement(Et,{key:a.value,name:t,...a,checked:a.value===n,onChange:o}))),Dt=tr;var At=t=>(t||[]).map(r=>typeof r=="object"?r:{value:r,label:r}),er=({name:t,type:r,value:n,choices:o,onChange:a,onSettle:i,onPick:c,pictureUrl:d})=>{if(r==="picture")return e.createElement("div",{className:"mb-3"},n&&d&&e.createElement("img",{src:d,alt:"The step's picture",style:{maxWidth:"100%"}}),n&&e.createElement("button",{type:"button","data-remove-picture":!0,className:"ks-button ks-button-secondary ks-button-sm",onClick:()=>i("")},"Remove picture"),e.createElement("input",{type:"file",accept:"image/*",onChange:l=>l.target.files[0]&&c(l.target.files[0])}));if(r==="boolean")return e.createElement(G,{checked:!!n,onChange:l=>i(l.target.checked)});if(r==="select"||r==="previous_step"||r==="from_step"||r==="flow")return e.createElement(Tt,{className:"mb-3",value:n??"",onChange:l=>i(l.target.value)},e.createElement("option",{value:""}),At(o).map(l=>e.createElement("option",{key:l.value,value:l.value},l.label)));if(r==="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(Dt,{name:t,value:n,options:o||[],onChange:l=>i(l.target.value)}));if(r==="multi_select"){let l=Array.isArray(n)?n:[],y=h=>i(nt(l,h));return e.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(o||[]).map(h=>e.createElement("label",{key:h,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(G,{checked:l.includes(h),onChange:()=>y(h)}),e.createElement("span",null,h))))}if(r==="flows"){let l=Array.isArray(n)?n:[];return e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},At(o).map(y=>e.createElement("label",{key:y.value,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(G,{checked:l.includes(y.value),onChange:()=>i(nt(l,y.value))}),e.createElement("span",null,y.label))))}return r==="integer"||r==="float"?e.createElement(A,{className:"mb-3",type:"number",step:r==="integer"?"1":"any",value:n??"",onChange:l=>a(l.target.value),onBlur:l=>i(l.target.value)}):e.createElement(A,{className:"mb-3",type:"text",value:n??"",onChange:l=>a(l.target.value),onBlur:l=>i(l.target.value)})},X=er;var Ot=(t,r,n,o)=>t.map((a,i)=>i===r?{...a,[n]:o}:a);var rr=({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),q=rr;var or=(t,r,n,o)=>{let a=(t||{})[n],i=(r||{})[n];return i?(a||{})[o[i]]:a},nr=({holds:t,labels:r,explanations:n,rows:o,choices:a,outputsOf:i,onChange:c,onSettle:d})=>{let l=Array.isArray(o)?o:[],y=(h,m,g,f)=>{let u=Ot(l,h,m,g);f?d(u):c(u)};return e.createElement("div",{style:{marginBottom:12}},l.map((h,m)=>e.createElement("div",{key:m,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(t).map(([g,f])=>e.createElement("label",{key:g,style:{display:"block"}},e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(r||{})[g]||g),e.createElement(X,{type:f,value:h[g],choices:or(a,i,g,h),onChange:u=>y(m,g,u,!1),onSettle:u=>y(m,g,u,!0)}),(n||{})[g]&&e.createElement(q,{text:n[g]}))),e.createElement(v,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>d(l.filter((g,f)=>f!==m))},"Remove"))),e.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>d([...l,{}])},"Add"))},Pt=nr;var sr=({as:t="div",className:r,children:n,...o})=>e.createElement(t,{...o,className:T("ks-panel",r)},n),$=sr;var J=(t,r)=>({className:n,children:o,...a})=>e.createElement(t,{...a,className:T(r,n)},o),W=J("label","ks-label"),Xn=J("p","ks-hint"),qn=J("p","ks-error"),Jn=J("span","ks-required");var ar={width:280,padding:20,overflowY:"auto"},ir=({node:t,fields:r,holds:n,labels:o,explanations:a,recordLabels:i,recordExplanations:c,recordChoices:d,recordOutputsOf:l,choices:y,onSave:h,onDelete:m,onClose:g,onPickPicture:f,refusal:u})=>{let[k,w]=C(t.config),[S,_]=C(t.picture_url);L(()=>_(t.picture_url),[t.id,t.picture_url]),L(()=>w(t.config),[t.id,t.config]);let b=x=>{w(x),JSON.stringify(x)!==JSON.stringify(t.config)&&h(x)};return e.createElement($,{as:"aside",style:ar,"data-inspector":!0},e.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},e.createElement("h2",{style:{fontWeight:600,marginBottom:2}},t.label),e.createElement("button",{title:"Close",onClick:g,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:16}},t.id," \xB7 ",t.type),u&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},u),Object.entries(r).map(([x,O])=>e.createElement(W,{key:x},e.createElement("span",{style:{display:"block",marginBottom:3}},o[x]||x),O==="list"?e.createElement(Pt,{holds:n[x]||{},labels:i[x]||{},explanations:(c||{})[x],rows:k[x],choices:{...(d||{})[x],...(t.record_choices||{})[x]},outputsOf:(l||{})[x],onChange:z=>w({...k,[x]:z}),onSettle:z=>b({...k,[x]:z})}):e.createElement(X,{name:x,type:O,value:k[x],choices:y[x],pictureUrl:S,onChange:z=>w({...k,[x]:z}),onSettle:z=>b({...k,[x]:z}),onPick:async z=>{let B=await f(z);B&&(_(B.url),b({...k,[x]:B.reference}))}}),(a||{})[x]&&e.createElement(q,{text:a[x]}))),e.createElement(v,{variant:"danger",size:"sm",className:"w-full",onClick:m},"Delete step"))},$t=ir;var lr={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},dr={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},cr="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",pr="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",ur=({node:t,dragging:r,onFill:n,onDrop:o,compact:a=!1})=>e.createElement("div",{ref:t.ref,"data-placeholder":t.id,title:`Choose the step \u201C${t.label}\u201D should lead to`,onClick:n,onDragOver:i=>{r&&(i.preventDefault(),i.dataTransfer.dropEffect="move")},onDrop:i=>{i.preventDefault(),o()},className:r?pr:cr,style:a?dr:lr},e.createElement("div",{style:{fontWeight:600}},t.label),e.createElement("div",{style:{fontSize:11}},r?"drop a step here":"leads nowhere yet \u2014 click to choose")),Lt=ur;var mr=({entries:t,at:r,onPick:n,onConnect:o,onDismiss:a,hideStepTypeCodes:i})=>e.createElement($,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:r.y,left:r.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(c=>e.createElement(v,{key:c.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>n(c)},c.label,!i&&e.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},c.type))),o&&e.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:o},"Connect to a step already here"),e.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:a},"Cancel")),It=mr;var fr=t=>r=>r.label.toLowerCase().includes(t.trim().toLowerCase()),gr=(t,r,n="")=>{let o=Object.values(r).flat(),a=Object.entries(r).map(([i,c])=>({heading:i,entries:c.map(d=>t.find(l=>l.type===d)).filter(Boolean)}));return[{heading:null,entries:t.filter(i=>!o.includes(i.type))},...a].map(i=>({...i,entries:i.entries.filter(fr(n))})).filter(i=>i.entries.length>0)},hr={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},yr={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},xr={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},br=({entries:t,groups:r,onPick:n,onCarry:o,onDrop:a})=>{let[i,c]=C("");return e.createElement($,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:hr},e.createElement(A,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:i,onChange:d=>c(d.target.value),style:{marginBottom:6,fontSize:12}}),gr(t,r,i).map(d=>e.createElement(e.Fragment,{key:d.heading||""},d.heading&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:yr},d.heading),d.entries.map(l=>e.createElement($,{as:"button",type:"button",key:l.type,"data-step-type":l.type,className:"bg-surface-50 dark:bg-surface-950",style:xr,draggable:!0,onClick:()=>n(l),onDragStart:y=>{y.dataTransfer.effectAllowed="copyMove",y.dataTransfer.setData("text/plain",l.type),o(l)},onDragEnd:a},l.label)))))},Mt=br;var vr={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},jt=({label:t,title:r,idle:n,enabled:o,onUse:a})=>e.createElement(v,{variant:"secondary",size:"sm",title:o?r:n,disabled:!o,onClick:a,style:{opacity:o?1:.4,cursor:o?"pointer":"default"}},t),wr=({undoable:t,redoable:r,onAdd:n,onUndo:o,onRedo:a})=>e.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},e.createElement(v,{variant:"secondary",className:"rounded-full",style:vr,title:"Add a step",onClick:n},"+"),e.createElement(jt,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:t,onUse:o}),e.createElement(jt,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:r,onUse:a})),Ht=wr;var kr=({type:t="info",title:r,message:n,onDismiss:o,className:a})=>e.createElement("div",{className:T("ks-alert",`ks-alert-${t}`,a),role:"alert"},e.createElement("div",{className:"ks-alert-body"},e.createElement("div",{className:"ks-alert-content"},r&&e.createElement("p",{className:"ks-alert-title"},r),e.createElement("p",{className:r?"ks-alert-message-titled":"ks-alert-message"},n)),o&&e.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:o},"\xD7"))),Wt=kr;var Ft=t=>{let r=t.map(n=>`\u201C${n.name}\u201D`).join(", ");return t.length===1?`${r} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${r} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var Vt=({version:t,published:r})=>t?r?r===t?`Version ${t} \xB7 live`:`Version ${t} \xB7 visitors still on ${r}`:`Version ${t} \xB7 never published`:"No version yet";var Cr={width:280,padding:20,overflowY:"auto"},st={fontWeight:600,marginBottom:6,marginTop:14},K={fontSize:12,marginBottom:4,lineHeight:1.4},Yt={display:"block",marginBottom:3},Ut=(t,r,n)=>o=>{o.target.value!==(t[r]??"")&&n({[r]:o.target.value})},Sr=({flow:t,changes:r,problems:n,refusal:o,notice:a,publishNote:i,warning:c,onCreate:d,onPublish:l,onAccept:y,onDecline:h,onSaveDetails:m,onClose:g})=>e.createElement($,{as:"aside",style:Cr,"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:g,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},Vt(t)),c?e.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},e.createElement(Wt,{type:"warning",className:"mb-1.5",message:Ft(c.steps)}),e.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:y,"data-accept-removal":!0},c.path==="/publish"?"Remove and publish":"Remove and create version"),e.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:h,"data-decline-removal":!0},"Cancel")):e.createElement("div",{style:{marginTop:14}},e.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:d,"data-create-version":!0},"Create version"),e.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:l,"data-publish":!0},"Publish"),i&&e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},i)),e.createElement("h2",{style:st},"Problems"),o&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...K,fontWeight:600},"data-refusal":!0},o),a&&!o&&e.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...K,fontWeight:600},"data-notice":!0},a),n.length===0&&!o?e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing wrong with this flow."):n.map(f=>e.createElement("p",{key:`${f.node}-${f.problem}`,className:"text-amber-700 dark:text-amber-400",style:K,"data-problem":!0},"\u26A0 ",f.sentence)),e.createElement("h2",{style:st},"Changes since the last version"),r.length===0?e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):r.map((f,u)=>e.createElement("p",{key:u,style:K,"data-change":!0},f)),e.createElement("h2",{style:st},"Details"),e.createElement(W,null,e.createElement("span",{style:Yt},"Title"),e.createElement(A,{className:"mb-3",defaultValue:t.title??"",onBlur:Ut(t,"title",m),"data-flow-title":!0})),e.createElement(W,null,e.createElement("span",{style:Yt},"Start label"),e.createElement(A,{className:"mb-3",defaultValue:t.start_label??"",onBlur:Ut(t,"start_label",m),"data-flow-start-label":!0})),e.createElement("div",{style:{marginTop:16}},e.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.definition_url,"data-definition":!0},"Definition"),e.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.details_url,"data-details":!0},"Edit details"))),Gt=Sr;var Xt={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},qt=t=>({opacity:t?1:0,transition:"opacity .12s"}),Nr=({link:t,onInsert:r,onRemove:n,onDrop:o,dragging:a,alwaysShowInsertButtons:i})=>{let[c,d]=C(!1),l=c||a;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:()=>d(!0),onMouseLeave:()=>d(!1),onDragEnter:()=>d(!0),onDragLeave:()=>d(!1),onDragOver:y=>{y.preventDefault(),y.dataTransfer.dropEffect="move"},onDrop:y=>{y.preventDefault(),d(!1),o()}},e.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},e.createElement(v,{variant:"secondary",title:a?"Move the step here":"Insert a step here",onClick:r,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(a&&c),style:{...Xt,...qt(l||i)}},"+"),!a&&e.createElement(v,{variant:"danger",title:"Remove this connection",onClick:n,className:"rounded-full",style:{...Xt,...qt(l)}},"\xD7")))},Jt=Nr;var zr=({links:t,extent:r,dragging:n,onInsert:o,onRemove:a,onDrop:i,alwaysShowInsertButtons:c})=>e.createElement(e.Fragment,null,e.createElement("svg",{width:r.width,height:r.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(d=>e.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}))),t.filter(d=>d.label).map(d=>e.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+(c?2:-10),top:d.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},d.label)),t.filter(d=>!d.placeholder).map(d=>e.createElement(Jt,{key:d.id,link:d,dragging:!!n,alwaysShowInsertButtons:c,onInsert:()=>o(d),onRemove:()=>a(d),onDrop:()=>i(d)}))),Kt=zr;var at={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Qt="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Br=({link:t,onInsert:r,onRemove:n,onDrop:o,alwaysShowInsertButtons:a,dragging:i})=>e.createElement("div",{"data-joint":t?.id,className:"group relative h-7 w-full sm:h-auto sm:w-7 sm:self-stretch",onMouseEnter:c=>{c.currentTarget.dataset.over="true"},onMouseLeave:c=>{delete c.currentTarget.dataset.over},onDragOver:c=>{t&&o&&(c.preventDefault(),c.dataTransfer.dropEffect="move")},onDrop:c=>{t&&(c.preventDefault(),o(t))}},t&&e.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"}),t&&r&&e.createElement("div",{className:"absolute inset-0 flex items-center justify-center gap-1 sm:flex-col",style:{zIndex:4}},e.createElement(v,{variant:"secondary",title:"Insert a step here",onClick:c=>r(t,c),className:`rounded-full ${a?"opacity-100":Qt}`,style:i?{...at,opacity:1}:at},"+"),e.createElement(v,{variant:"danger",title:"Remove this connection",onClick:()=>n(t),className:`rounded-full ${Qt}`,style:at},"\xD7"))),Zt=Br;var _r=(t,r)=>t.row-r.row||t.column-r.column,Rt=t=>{let r=[...t].sort(_r),n=r.filter(o=>t.some(a=>a.holds?.includes(o.id)));return r.filter(o=>!n.includes(o)).flatMap(o=>[o,...n.filter(a=>o.holds?.includes(a.id))])},te=t=>{let r=Rt(t),n=o=>r.some(a=>a.holds?.includes(o.id));return r.filter(o=>!n(o)).reduce((o,a)=>{if(a.holds)return[...o,{group:a,steps:r.filter(c=>a.holds.includes(c.id))}];let i=o[o.length-1];return i&&!i.group?[...o.slice(0,-1),{steps:[...i.steps,a]}]:[...o,{steps:[a]}]},[])},Tr=(t,r)=>t[t.findIndex(n=>n.id===r.id)+1]?.id,ee=(t,r,n)=>{let o=Tr(Rt(n),t);return r.filter(a=>a.source===t.id&&(a.label||a.target!==o))},Er=t=>t?.placeholder?"nowhere yet":t?.label,re=(t,r)=>[t.label,"\u2192",Er(r.find(n=>n.id===t.target))].filter(Boolean).join(" "),oe=(t,r,n)=>t.find(o=>o.source===r.id&&o.target===n.id);var Dr={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},ne=({steps:t,edges:r,draw:n,joints:o})=>e.createElement("div",{"data-flow-row":!0,className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5"},t.map((a,i)=>e.createElement("div",{key:a.id,className:"flex flex-col sm:flex-row sm:items-center"},i>0&&e.createElement(Zt,{link:oe(r,t[i-1],a),...o}),n(a)))),Ar={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},Or=({group:t,steps:r,edges:n,draw:o,joints:a})=>e.createElement("div",{"data-group-box":t.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:Ar},o(t),e.createElement(ne,{steps:r,edges:n,draw:o,joints:a})),Pr=({nodes:t,edges:r,draw:n,joints:o,children:a,style:i})=>e.createElement("div",{"data-flow-rows":!0,style:{...Dr,...i}},a,te(t).map(c=>c.group?e.createElement(Or,{key:c.group.id,group:c.group,steps:c.steps,edges:r,draw:n,joints:o}):e.createElement(ne,{key:c.steps[0].id,steps:c.steps,edges:r,draw:n,joints:o}))),Q=Pr;var se="Your change was not saved because the server could not be reached.",ae=({base:t,token:r,fetch:n,onFlow:o,onError:a,onNotice:i,onWarning:c=()=>{}})=>async(d,l,y)=>{let h=await n(t+d,{method:l,headers:{"Content-Type":"application/json","X-CSRF-Token":r},body:y&&JSON.stringify(y)}).catch(()=>null);if(!h)return i(null),a(se);let m=await h.json().catch(()=>({}));if(m.unconnected)return i(null),a(null),c({path:d,steps:m.unconnected}),o(await(await n(t+".json",{headers:{Accept:"application/json"}})).json());if(c(null),!h.ok)return i(null),a(m.error||"That change was refused");a(null),i(m.notice||null),o(await(await n(t+".json",{headers:{Accept:"application/json"}})).json())},ie=({base:t,token:r,fetch:n,onError:o})=>async a=>{let i=new FormData;i.append("picture",a);let c=await n(t+"/pictures",{method:"POST",headers:{"X-CSRF-Token":r},body:i}).catch(()=>null);if(!c)return o(se),null;let d=await c.json().catch(()=>({}));return c.ok?(o(null),d):(o(d.error||"That picture was refused"),null)};var $r=(t,r,n)=>{let[o,a]=C(n),[i,c]=C(null),[d,l]=C(null),[y,h]=C(null),m=j(()=>ae({base:t,token:r,fetch:(...f)=>window.fetch(...f),onFlow:a,onError:c,onNotice:l,onWarning:h}),[t,r]),g=j(()=>ie({base:t,token:r,fetch:(...f)=>window.fetch(...f),onError:c}),[t,r]);return{flow:o,error:i,notice:d,warning:y,setWarning:h,send:m,pickPicture:g}},le=$r;var Z=(t,r,n,o)=>{let a=t.left-n.left+o.scrollLeft,i=t.top-n.top+o.scrollTop;return r==="left"?{x:a,y:i+t.height/2}:r==="right"?{x:a+t.width,y:i+t.height/2}:r==="top"?{x:a+t.width/2,y:i}:{x:a+t.width/2,y:i+t.height}},Lr=(t,r,n)=>n&&r==="top"?{x:t.x,y:n.top}:t,Ir=(t,r)=>r==="top"?{x:t.x,y:t.y-3}:r==="left"?{x:t.x-3,y:t.y}:r==="right"?{x:t.x+3,y:t.y}:{x:t.x,y:t.y+3},Mr=(t,r,n,o,a)=>{let i={straight:`M ${r.x} ${r.y} L ${n.x} ${n.y}`,turn:`M ${r.x} ${r.y} H ${n.x} V ${n.y}`,lane:`M ${r.x} ${r.y} V ${o} H ${n.x} V ${n.y}`,detour:`M ${r.x} ${r.y} H ${a} V ${n.y} H ${n.x}`}[t.route];return{...t,path:i,midX:t.route==="detour"?a:(r.x+n.x)/2,midY:t.route==="lane"?o:(r.y+n.y)/2}},jr=(t,r,n,o)=>{let[a,i]=C([]),[c,d]=C({width:"100%",height:"100%"}),[l,y]=C([]);return ht(()=>{let h=()=>{let g=r.current?.getBoundingClientRect();if(!g)return;d({width:r.current.scrollWidth,height:r.current.scrollHeight});let f=t.nodes.filter(u=>u.holds&&!u.loose&&n.current[u.id]).map(u=>{let k=n.current[u.id],w=k.getBoundingClientRect(),S=u.holds.flatMap(b=>n.current[b]?[n.current[b].getBoundingClientRect()]:[]),_=[{left:w.left,top:w.top,width:Math.max(w.width,k.scrollWidth),height:w.height},...S];return{id:u.id,bounds:St(_,g,r.current)}});y(f),i(t.edges.flatMap(u=>{let k=n.current[u.source]?.getBoundingClientRect(),w=n.current[u.target]?.getBoundingClientRect();if(!k||!w)return[];let S=Z(k,u.leaves,g,r.current),_=f.find(z=>z.id===u.target)?.bounds,b=Ir(Lr(Z(w,u.enters,g,r.current),u.enters,_),u.enters),x=(Z(k,"bottom",g,r.current).y+Z(w,"top",g,r.current).y)/2,O=u.leaves==="left"?Math.min(S.x,b.x)-28:Math.max(S.x,b.x)+28;return[Mr(u,S,b,x,O)]}))};h(),window.addEventListener("resize",h);let m=new ResizeObserver(h);return r.current&&m.observe(r.current),()=>{window.removeEventListener("resize",h),m.disconnect()}},o),{links:a,extent:c,boxes:l}},de=jr;var ce=(t,r)=>{let n=new Set(r),o=t,a=2;for(;n.has(o);)o=`${t}_${a++}`;return o};var Wr=8,Fr={display:"flex",height:"100%",minHeight:0,fontSize:13},Vr={flex:1,overflow:"auto",position:"relative"},ue={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},Yr={...ue,position:"static",alignSelf:"flex-start"},Ur={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Gr={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Xr=({port:t,onCancel:r})=>e.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Gr},"Choose the step \u201C",t||"next","\u201D should lead to \u2014 ",e.createElement("button",{onClick:r,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),qr=({base:t,token:r,initial:n})=>{let{flow:o,error:a,notice:i,warning:c,setWarning:d,send:l,pickPicture:y}=le(t,r,n),[h,m]=C(null),[g,f]=C(null),[u,k]=C(null),[w,S]=C(null),[_,b]=C(null),[x,O]=C(!1),z=et({}),B=et(null);L(()=>{let s={open:null,publish:"/publish",save_draft:"/versions"},p=N=>{let D=N.target.closest?.("[data-bar-action]");if(!D||!(D.dataset.barAction in s))return;D.closest("details")?.removeAttribute("open"),m(null),O(!0);let F=s[D.dataset.barAction];F&&l(F,"POST")};return document.addEventListener("click",p),()=>document.removeEventListener("click",p)},[l]),L(()=>{if(!x){d(null);return}let s=p=>{p.target.isConnected&&!p.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&O(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[x]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:o.flow?.title||o.flow?.slug}))},[o.flow?.title,o.flow?.slug]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:o.flow?.status,publishes:o.flow?.publishes}}))},[o.flow?.status,o.flow?.publishes]);let xe=j(()=>Object.fromEntries(o.nodes.map(s=>[s.id,s])),[o.nodes]),{links:be,extent:ve,boxes:it}=de(o,B,z,[o,h,xe]),lt=j(()=>{let s={};return o.violations.forEach(p=>{var N;return(s[N=p.node]||(s[N]=[])).push(p)}),s},[o.violations]),E=o.direction==="left_to_right",H=o.nodes.filter(s=>!s.loose),dt=o.nodes.filter(s=>s.loose),we=Math.max(0,...H.map(s=>s.row))+1,ke=Math.max(0,...H.map(s=>s.column))+1,R=s=>{if(!u)return;let[p,N]=u;k(null),p!==s&&l("/edges","POST",{from:p,to:s,on:N||null})},Ce=s=>{if(s.isDefaultPrevented()||!w)return;s.preventDefault();let p=w;S(null);let N=B.current.getBoundingClientRect(),D=Nt(it,{x:s.clientX-N.left+B.current.scrollLeft,y:s.clientY-N.top+B.current.scrollTop}),F=o.nodes.find(Ne=>Ne.holds?.includes(p))?.id||null;D!==F&&l(`/steps/${p}/group`,"PATCH",{group:D})},ct=s=>[...o.palette,...o.unoffered||[]].find(p=>p.type===s?.type),M=o.nodes.find(s=>s.id===h),P=ct(M),tt=(s,p={})=>l("/steps","POST",{id:ce(s.type,o.nodes.map(N=>N.id)),type:s.type,from:p.from,to:p.to,on:p.on}),pt=s=>{let[p,N]=[_,w];b(null),S(null),p?tt(p,{from:s.source,to:s.target}):N&&l("/steps/"+N+"/move","PATCH",{from:s.source,to:s.target})},Se=s=>{let p=B.current.getBoundingClientRect();return{x:s.clientX-p.left+B.current.scrollLeft+8,y:s.clientY-p.top+B.current.scrollTop+8}},ut=s=>e.createElement(e.Fragment,null,s.placeholder&&e.createElement(Lt,{node:{...s,ref:p=>{z.current[s.id]=p}},dragging:!!w,compact:E,onFill:()=>f({from:s.from,on:s.on,at:{x:16,y:52}}),onDrop:()=>{let p=w;S(null),p&&l("/edges","POST",{from:s.from,to:p,on:s.on})}}),s.holds&&e.createElement(Y,{node:{...s,ref:p=>{z.current[s.id]=p}},header:U(s,ct(s),o.hide_step_type_codes),compact:E,onSelect:()=>u?R(s.id):m(s.id)}),!s.placeholder&&!s.holds&&e.createElement(ot,{node:{...s,ref:p=>{z.current[s.id]=p},violations:lt[s.id]||[],connected:o.edges.filter(p=>p.source===s.id).map(p=>p.label||null)},selected:s.id===h,armed:u&&u[0]===s.id?u[1]:null,connecting:!!u&&u[0]!==s.id,onSelect:()=>u?R(s.id):m(s.id),onOpen:p=>window.location.assign(p),onArm:(p,N)=>{let D=B.current.getBoundingClientRect();f({from:s.id,on:p,at:{x:N.clientX-D.left+B.current.scrollLeft+8,y:N.clientY-D.top+B.current.scrollTop+8}})},onDragEnd:()=>S(null),onDragStart:()=>S(s.id),hideStepTypeCodes:o.hide_step_type_codes,compact:E,branches:E?ee(s,o.edges,H).map(p=>re(p,o.nodes)):[]})),mt=dt.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:E?Yr:ue},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"),dt.map(s=>e.createElement("div",{key:s.id,style:{marginBottom:8}},e.createElement(ot,{node:{...s,ref:p=>{z.current[s.id]=p},violations:lt[s.id]||[],connected:[]},selected:h===s.id,armed:u&&u[0]===s.id?u[1]:null,connecting:!!u,onSelect:()=>u?R(s.id):m(s.id),onOpen:p=>window.location.assign(p),onArm:(p,N)=>{N.stopPropagation(),k([s.id,p])},onDragStart:()=>S(s.id),onDragEnd:()=>S(null),hideStepTypeCodes:o.hide_step_type_codes}))));return e.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:Fr,onMouseUp:()=>S(null),onKeyDown:s=>{s.key==="Escape"&&(m(null),k(null),f(null))},tabIndex:-1},e.createElement(Mt,{entries:o.palette,groups:o.step_groups||{},onPick:s=>tt(s),onCarry:b,onDrop:()=>b(null)}),e.createElement("div",{ref:B,className:"bg-surface-50 dark:bg-surface-950",style:Vr,onClick:s=>{s.target===B.current&&(m(null),k(null),O(!1))},onDragOver:s=>{w&&s.preventDefault()},onDrop:Ce},u&&e.createElement(Xr,{port:u[1],onCancel:()=>k(null)}),e.createElement(Ht,{undoable:o.undoable,redoable:o.redoable,onAdd:()=>f({at:{x:16,y:52}}),onUndo:()=>{m(null),l("/undo","POST")},onRedo:()=>{m(null),l("/redo","POST")}}),!E&&it.map(s=>e.createElement(Ct,{key:s.id,id:s.id,bounds:s.bounds,onDrop:()=>{let p=w;S(null),p&&l(`/steps/${p}/group`,"PATCH",{group:s.id})}})),!E&&e.createElement(Kt,{links:zt(be,o.nodes),extent:ve,dragging:w||_,alwaysShowInsertButtons:o.always_show_insert_buttons,onInsert:s=>f({from:s.source,to:s.target,at:{x:s.midX+30,y:s.midY}}),onRemove:s=>{m(null),l("/edges","DELETE",{from:s.source,to:s.target})},onDrop:pt}),!E&&mt,E&&e.createElement(Q,{nodes:H,edges:o.edges,draw:ut,joints:{alwaysShowInsertButtons:o.always_show_insert_buttons,dragging:!!(w||_),onInsert:(s,p)=>f({from:s.source,to:s.target,at:Se(p)}),onRemove:s=>{m(null),l("/edges","DELETE",{from:s.source,to:s.target})},onDrop:pt}},mt),!E&&e.createElement("div",{style:{...Ur,gridTemplateColumns:`repeat(${ke+1}, ${280/2}px)`,gridTemplateRows:`repeat(${we}, auto)`}},H.map(s=>e.createElement("div",{key:s.id,style:{gridRow:s.row+1,gridColumn:`${s.column+1} / span 2`,zIndex:2,marginTop:Bt(s,o.nodes)?Wr-64:0}},ut(s)))),g&&e.createElement(It,{entries:o.palette,at:g.at,onDismiss:()=>f(null),hideStepTypeCodes:o.hide_step_type_codes,onConnect:g.on!==void 0?()=>{k([g.from,g.on]),f(null)}:null,onPick:s=>{let p=g;f(null),tt(s,p)}})),x&&!M&&e.createElement(Gt,{flow:o.flow||{},changes:o.changes||[],problems:o.violations,refusal:a,notice:i,publishNote:o.publish_note,warning:c,onClose:()=>O(!1),onCreate:()=>l("/versions","POST"),onPublish:()=>l("/publish","POST"),onAccept:()=>l(c.path,"POST",{remove_unconnected:c.steps.map(s=>s.id)}),onDecline:()=>d(null),onSaveDetails:s=>l("/details","PATCH",{flow:s})}),M&&e.createElement($t,{node:M,fields:P?.fields||{},holds:P?.records||{},labels:P?.labels||{},explanations:P?.explanations||{},recordLabels:P?.record_labels||{},recordExplanations:P?.record_explanations||{},recordChoices:P?.record_choices||{},recordOutputsOf:P?.record_outputs_of||{},choices:_t(M,P),onClose:()=>m(null),onSave:s=>l(`/steps/${M.id}`,"PATCH",{config:s}),onPickPicture:y,refusal:a,onDelete:()=>{m(null),l(`/steps/${M.id}`,"DELETE")}}))},me=qr;var Jr={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Kr={fontSize:12,fontWeight:500,lineHeight:1.3},fe={done:"border-green-600 bg-green-50 dark:border-green-500 dark:bg-green-950",paused:"border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-950",pending:"border-gray-300 bg-white text-gray-500 dark:border-zinc-700 dark:bg-zinc-900 dark:text-gray-400",failed:"border-red-600 bg-red-50 dark:border-red-500 dark:bg-red-950"},ge={done:"text-green-700 dark:text-green-400",paused:"text-amber-800 dark:text-amber-300",pending:"text-gray-500 dark:text-gray-400",failed:"text-red-700 dark:text-red-400"},Qr="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Zr=({node:t,selected:r=!1})=>{let n=t.address?"a":"div";return e.createElement(n,{"data-step":t.id,href:t.address||void 0,className:`${t.state==="paused"?"border-2":"border"} ${fe[t.state]||fe.pending}${r?` ${Qr}`:""}`,style:Jr},e.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.type),e.createElement("div",{style:Kr},t.label,t.version&&e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},t.version)),t.status&&e.createElement("div",{className:ge[t.state]||ge.pending,style:{fontSize:11}},t.status))},he=Zr;var Rr={gap:12,padding:0},to=({nodes:t,edges:r,selected:n})=>e.createElement(Q,{nodes:t,edges:r,joints:{},style:Rr,draw:o=>o.holds?e.createElement(Y,{node:o,header:U(o,o,!1),compact:!0}):e.createElement(he,{node:o,selected:o.id===n})}),ye=to;rt("easy_flow/flow-editor",me);rt("easy_flow/run-view",ye);document.addEventListener("easy_flow:flow-named",t=>{let r=document.querySelector("[data-flow-heading]");r&&(r.textContent=t.detail)});document.addEventListener("easy_flow:flow-status",({detail:t})=>{t.status&&document.querySelectorAll("[data-version-status]").forEach(r=>{r.textContent=t.status}),t.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(r=>{r.textContent=`Publish v${t.publishes}`})});vt(document,ft);})();
1
+ (()=>{var jt=globalThis.ReactDOM;var{createPortal:Yr,createRoot:fe,flushSync:Xr,hydrateRoot:qr,preconnect:Jr,prefetchDNS:Kr,preinit:Zr,preinitModule:Qr,preload:Rr,preloadModule:es,requestFormReset:ts,unstable_batchedUpdates:os,useFormState:rs,useFormStatus:ss,version:ns}=jt;var ge=globalThis.React,t=ge,{Children:is,Component:ls,Fragment:ds,PureComponent:cs,StrictMode:ps,Suspense:ms,cloneElement:us,createContext:fs,createElement:gs,createRef:xs,forwardRef:hs,isValidElement:ys,lazy:bs,memo:vs,startTransition:ks,useCallback:ws,useContext:Ss,useDebugValue:Cs,useDeferredValue:Ns,useEffect:P,useId:_s,useImperativeHandle:zs,useLayoutEffect:xe,useMemo:j,useReducer:Es,useRef:ee,useState:w,useSyncExternalStore:Bs,useTransition:Ts}=ge;var he=new Map,F=new Map,te=(e,o)=>he.set(e,o),ye=()=>{F.forEach(e=>e.unmount()),F.clear()},be=(e,o)=>e.querySelectorAll("[data-react-ui]").forEach(s=>{if(F.has(s))return;let r=he.get(s.dataset.reactUi),n=o(s);F.set(s,n),n.render(t.createElement(r,JSON.parse(s.dataset.props)))});var ve=(e,o)=>{let s=()=>be(e,o);e.addEventListener("turbo:load",s),e.addEventListener("turbo:frame-load",s),e.addEventListener("turbo:before-cache",ye),e.readyState==="loading"?e.addEventListener("DOMContentLoaded",s):s()};var _=(...e)=>e.filter(Boolean).join(" ");var Ht={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},Wt={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Vt=({variant:e="primary",size:o="md",className:s,children:r,...n})=>{let i=n.href?"a":"button";return t.createElement(i,{...n,className:_("ks-button",Ht[e],Wt[o],s)},r)},v=Vt;var Ft="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Ut="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Gt="border border-accent-600 bg-accent-600 text-white",Yt=({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?Gt:o?Ut:Ft,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},e||"next"),ke=Yt;var Xt={width:240,boxSizing:"border-box",borderRadius:8},qt={minWidth:120,boxSizing:"border-box",borderRadius:6},Jt={padding:"8px 14px",textAlign:"center",fontWeight:600},Kt={fontWeight:600,lineHeight:1.3},Zt={fontSize:12,fontWeight:500,lineHeight:1.3},Qt=(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"},Rt=(e,o)=>o&&e.label===e.id&&e.type_name||e.label,eo=(e,o,s)=>s?o===e.type_name?null:e.type_name:e.type,to=({node:e,selected:o,armed:s,connecting:r,onSelect:n,onOpen:i,onArm:d,onDragEnd:c,onDragStart:l,hideStepTypeCodes:h,branches:g=[],compact:u=!1,typeAbove:x=u})=>{let y=e.begins_here||e.ends_here,m=e.begins_here,S=e.ends_here?[]:e.ports,k=r&&!m,C=Rt(e,h),B=eo(e,C,h);return t.createElement("div",{ref:e.ref,"data-step":e.id,draggable:!m,onDragStart:b=>{b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("text/plain",e.id),l()},onDragEnd:c,onClick:e.opens&&!r?()=>i(e.opens):n,className:`bg-white ${u&&!o?"border":"border-2"} dark:bg-zinc-900 ${Qt(k,e.violations.length>0,o)}`,style:{...u?qt:Xt,padding:y?0:u?"8px 10px":"12px 14px",cursor:m?"default":r?"crosshair":"grab"}},!y&&x&&B&&t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},B),y&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:Jt},C),!y&&t.createElement("div",{style:u?Zt:Kt},C),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&&!x&&B&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},B),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(v,{variant:"secondary",size:"sm",className:"mt-2",onClick:b=>{b.stopPropagation(),n()}},"Settings"),g.map(b=>t.createElement("div",{key:b,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},b)),S.length>0&&t.createElement("div",{style:{padding:e.begins_here?"0 14px 8px":"10px 0 0"}},S.map(b=>t.createElement(ke,{key:b,name:b,connected:e.connected.includes(b),connecting:r,armed:s===b,onArm:f=>d(b,f)}))))},oe=to;var we={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},oo={...we,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},ro=({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?oo:we,...s?{}:{cursor:"default"}}},o),U=ro;var so=({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}}),Se=so;var no=e=>e!=null&&e!==""&&typeof e!="object",ao=["integer","float"],io=(e,o,s)=>s&&o.labels?.[e]||e,G=(e,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>no(e.config[n])).map(n=>`${io(n,o,s)}${ao.includes(o.fields[n])?"":":"} ${e.config[n]}`);return[s&&e.type_name||e.type,...r].join(" \xB7 ")};var Ce=(e,o,s)=>{let r=Math.min(...e.map(c=>c.left))-o.left+s.scrollLeft-12,n=Math.min(...e.map(c=>c.top))-o.top+s.scrollTop-10,i=Math.max(...e.map(c=>c.left+c.width))-o.left+s.scrollLeft+12,d=Math.max(...e.map(c=>c.top+c.height))-o.top+s.scrollTop+10;return{left:r,top:n,width:i-r,height:d-n}},lo=({left:e,top:o,width:s,height:r},n)=>n.x>=e&&n.x<=e+s&&n.y>=o&&n.y<=o+r,Ne=(e,o)=>e.find(s=>lo(s.bounds,o))?.id||null,_e=(e,o)=>e.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),ze=(e,o)=>o.some(s=>s.holds?.includes(e.id)&&!s.loose&&s.row===e.row-1);var re=(e,o)=>e.includes(o)?e.filter(s=>s!==o):[...e,o],Ee=(e,o)=>({...o?.choices||{},...e?.choices||{}});var co=({as:e="input",disabled:o,className:s,...r})=>t.createElement(e,{...r,disabled:o,className:_("ks-input",o&&"ks-input-disabled",s)}),L=co;var po=e=>t.createElement(L,{...e,as:"select"}),Be=po;var mo=({className:e,...o})=>t.createElement("input",{type:"checkbox",...o,className:_("ks-checkbox",e)}),Y=mo;var uo=({name:e,value:o,label:s,hint:r,...n})=>t.createElement("label",{className:"inline-block cursor-pointer relative"},t.createElement("input",{type:"radio",name:e,value:o,...n,className:"peer sr-only"}),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))),Te=uo;var fo=({name:e,options:o,value:s,onChange:r})=>t.createElement("div",{className:"flex flex-wrap ks-grid-gap-sm"},o.map(n=>t.createElement(Te,{key:n.value,name:e,...n,checked:n.value===s,onChange:r}))),Ae=fo;var De=e=>(e||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),go=({name:e,type:o,value:s,choices:r,onChange:n,onSettle:i,onPick:d,pictureUrl:c})=>{if(o==="picture")return t.createElement("div",{className:"mb-3"},s&&c&&t.createElement("img",{src:c,alt:"The step's picture",style:{maxWidth:"100%"}}),s&&t.createElement("button",{type:"button","data-remove-picture":!0,className:"ks-button ks-button-secondary ks-button-sm",onClick:()=>i("")},"Remove picture"),t.createElement("input",{type:"file",accept:"image/*",onChange:l=>l.target.files[0]&&d(l.target.files[0])}));if(o==="boolean")return t.createElement(Y,{checked:!!s,onChange:l=>i(l.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return t.createElement(Be,{className:"mb-3",value:s??"",onChange:l=>i(l.target.value)},t.createElement("option",{value:""}),De(r).map(l=>t.createElement("option",{key:l.value,value:l.value},l.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(Ae,{name:e,value:s,options:r||[],onChange:l=>i(l.target.value)}));if(o==="multi_select"){let l=Array.isArray(s)?s:[],h=g=>i(re(l,g));return t.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(r||[]).map(g=>t.createElement("label",{key:g,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(Y,{checked:l.includes(g),onChange:()=>h(g)}),t.createElement("span",null,g))))}if(o==="flows"){let l=Array.isArray(s)?s:[];return t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},De(r).map(h=>t.createElement("label",{key:h.value,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(Y,{checked:l.includes(h.value),onChange:()=>i(re(l,h.value))}),t.createElement("span",null,h.label))))}return o==="integer"||o==="float"?t.createElement(L,{className:"mb-3",type:"number",step:o==="integer"?"1":"any",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>i(l.target.value)}):t.createElement(L,{className:"mb-3",type:"text",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>i(l.target.value)})},X=go;var Le=(e,o,s,r)=>e.map((n,i)=>i===o?{...n,[s]:r}:n);var xo=({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),q=xo;var ho=(e,o,s,r)=>{let n=(e||{})[s],i=(o||{})[s];return i?(n||{})[r[i]]:n},yo=({holds:e,labels:o,explanations:s,rows:r,choices:n,outputsOf:i,onChange:d,onSettle:c})=>{let l=Array.isArray(r)?r:[],h=(g,u,x,y)=>{let m=Le(l,g,u,x);y?c(m):d(m)};return t.createElement("div",{style:{marginBottom:12}},l.map((g,u)=>t.createElement("div",{key:u,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(e).map(([x,y])=>t.createElement("label",{key:x,style:{display:"block"}},t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[x]||x),t.createElement(X,{type:y,value:g[x],choices:ho(n,i,x,g),onChange:m=>h(u,x,m,!1),onSettle:m=>h(u,x,m,!0)}),(s||{})[x]&&t.createElement(q,{text:s[x]}))),t.createElement(v,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>c(l.filter((x,y)=>y!==u))},"Remove"))),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>c([...l,{}])},"Add"))},Oe=yo;var bo={start:null,end:"ks-value-list-end"},vo="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",ko="flex flex-col min-w-0",wo="ks-value-list-label basis-auto text-xs",So=()=>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"})),Co=({value:e,fallback:o})=>String(e??"")===""?o:e,No=({rows:e,align:o="start",columns:s=!1})=>t.createElement("dl",{className:_("ks-value-list",bo[o],s&&vo)},e.map((r,n)=>t.createElement("div",{key:n,className:_(s?ko:"ks-value-list-row",r.total&&"ks-value-list-total")},t.createElement("dt",{className:s?wo:"ks-value-list-label"},r.label,r.note!=null&&t.createElement(t.Fragment,null," ",t.createElement("span",{className:"ks-value-list-note"},r.note))),t.createElement("dd",{className:"ks-value-list-value"},Co(r),r.right&&t.createElement(t.Fragment,null," ",t.createElement(So,null)))))),$e=No;var _o=()=>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"})),zo=({summary:e,open:o=!1,children:s})=>t.createElement("details",{className:"ks-disclosure group",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(_o,null))),t.createElement("div",{className:"ks-disclosure-body text-sm"},s)),Pe=zo;var Eo=({language:e,caption:o,children:s})=>t.createElement("div",{className:"ks-code overflow-hidden"},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}`},s))),Me=Eo;var se="flex flex-col gap-1 mb-3",Ie="[&_dd]:font-mono",Bo="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",To="[&_.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]",Ao="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]",Do=e=>e.values?e.columns?`${se} ${Ie} ${Bo}`:`${se} ${Ie} ${To}`:`${se} ${Ao}`,Lo=({details:e})=>t.createElement(t.Fragment,null,e.map((o,s)=>t.createElement("section",{key:s,className:Do(o)},o.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400"},o.heading),o.values&&t.createElement($e,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>t.createElement(Pe,{key:r.summary,summary:r.summary},t.createElement(Me,null,r.code)))))),je=Lo;var Oo=({as:e="div",className:o,children:s,...r})=>t.createElement(e,{...r,className:_("ks-panel",o)},s),T=Oo;var J=(e,o)=>({className:s,children:r,...n})=>t.createElement(e,{...n,className:_(o,s)},r),W=J("label","ks-label"),Jn=J("p","ks-hint"),Kn=J("p","ks-error"),Zn=J("span","ks-required");var $o={width:320,padding:"14px 16px",overflowY:"auto",display:"flex",flexDirection:"column",fontSize:12},Po={marginTop:"auto",paddingTop:12,display:"flex",flexDirection:"column",gap:8},Mo=({node:e,fields:o,holds:s,labels:r,explanations:n,recordLabels:i,recordExplanations:d,recordChoices:c,recordOutputsOf:l,choices:h,onSave:g,onDelete:u,onClose:x,onPickPicture:y,refusal:m})=>{let[S,k]=w(e.config),[C,B]=w(e.picture_url);P(()=>B(e.picture_url),[e.id,e.picture_url]),P(()=>k(e.config),[e.id,e.config]);let b=f=>{k(f),JSON.stringify(f)!==JSON.stringify(e.config)&&g(f)};return t.createElement(T,{as:"aside",style:$o,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:x,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(([f,O])=>t.createElement(W,{key:f},t.createElement("span",{style:{display:"block",marginBottom:3}},r[f]||f),O==="list"?t.createElement(Oe,{holds:s[f]||{},labels:i[f]||{},explanations:(d||{})[f],rows:S[f],choices:{...(c||{})[f],...(e.record_choices||{})[f]},outputsOf:(l||{})[f],onChange:z=>k({...S,[f]:z}),onSettle:z=>b({...S,[f]:z})}):t.createElement(X,{name:f,type:O,value:S[f],choices:h[f],pictureUrl:C,onChange:z=>k({...S,[f]:z}),onSettle:z=>b({...S,[f]:z}),onPick:async z=>{let E=await y(z);E&&(B(E.url),b({...S,[f]:E.reference}))}}),(n||{})[f]&&t.createElement(q,{text:n[f]}))),t.createElement(je,{details:e.details||[]}),t.createElement("div",{style:Po},(e.links||[]).length>0&&t.createElement("div",{style:{display:"flex",gap:8}},e.links.map(f=>t.createElement(v,{key:f.address,variant:"secondary",size:"sm",className:"flex-1",href:f.address},f.label))),t.createElement(v,{variant:"danger",size:"sm",className:"w-full",onClick:u},"Delete step")))},He=Mo;var Io={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},jo={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},Ho="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",Wo="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Vo=({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?Wo:Ho,style:n?jo:Io},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")),We=Vo;var Fo=({entries:e,at:o,onPick:s,onConnect:r,onDismiss:n,hideStepTypeCodes:i})=>t.createElement(T,{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(d=>t.createElement(v,{key:d.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>s(d)},d.label,!i&&t.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},d.type))),r&&t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:n},"Cancel")),Ve=Fo;var Uo=e=>o=>o.label.toLowerCase().includes(e.trim().toLowerCase()),Go=(e,o,s="")=>{let r=Object.values(o).flat(),n=Object.entries(o).map(([i,d])=>({heading:i,entries:d.map(c=>e.find(l=>l.type===c)).filter(Boolean)}));return[{heading:null,entries:e.filter(i=>!r.includes(i.type))},...n].map(i=>({...i,entries:i.entries.filter(Uo(s))})).filter(i=>i.entries.length>0)},Yo={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},Xo={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},qo={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},Jo=({entries:e,groups:o,onPick:s,onCarry:r,onDrop:n})=>{let[i,d]=w("");return t.createElement(T,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:Yo},t.createElement(L,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:i,onChange:c=>d(c.target.value),style:{marginBottom:6,fontSize:12}}),Go(e,o,i).map(c=>t.createElement(t.Fragment,{key:c.heading||""},c.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:Xo},c.heading),c.entries.map(l=>t.createElement(T,{as:"button",type:"button",key:l.type,"data-step-type":l.type,className:"bg-surface-50 dark:bg-surface-950",style:qo,draggable:!0,onClick:()=>s(l),onDragStart:h=>{h.dataTransfer.effectAllowed="copyMove",h.dataTransfer.setData("text/plain",l.type),r(l)},onDragEnd:n},l.label)))))},Fe=Jo;var Ko={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Ue=({label:e,title:o,idle:s,enabled:r,onUse:n})=>t.createElement(v,{variant:"secondary",size:"sm",title:r?o:s,disabled:!r,onClick:n,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},e),Zo=({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(v,{variant:"secondary",className:"rounded-full",style:Ko,title:"Add a step",onClick:s},"+"),t.createElement(Ue,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:e,onUse:r}),t.createElement(Ue,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),Ge=Zo;var Qo=({type:e="info",title:o,message:s,onDismiss:r,className:n})=>t.createElement("div",{className:_("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"))),Ye=Qo;var Xe=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 qe=({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 Ro={width:280,padding:20,overflowY:"auto"},Je={fontWeight:600,marginBottom:6,marginTop:14},ne={fontSize:12,marginBottom:4,lineHeight:1.4},Ke={display:"block",marginBottom:3},Ze=(e,o,s)=>r=>{r.target.value!==(e[o]??"")&&s({[o]:r.target.value})},er=({flow:e,changes:o,refusal:s,notice:r,publishNote:n,warning:i,onCreate:d,onPublish:c,onAccept:l,onDecline:h,onSaveDetails:g,onClose:u})=>t.createElement(T,{as:"aside",style:Ro,"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:u,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},qe(e)),i?t.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},t.createElement(Ye,{type:"warning",className:"mb-1.5",message:Xe(i.steps)}),t.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:l,"data-accept-removal":!0},i.path==="/publish"?"Remove and publish":"Remove and create version"),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:h,"data-decline-removal":!0},"Cancel")):t.createElement("div",{style:{marginTop:14}},t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:d,"data-create-version":!0},"Create version"),t.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:c,"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:{...ne,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&t.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...ne,fontWeight:600,marginTop:8},"data-notice":!0},r),t.createElement("h2",{style:Je},"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((x,y)=>t.createElement("p",{key:y,style:ne,"data-change":!0},x)),t.createElement("h2",{style:Je},"Details"),t.createElement(W,null,t.createElement("span",{style:Ke},"Title"),t.createElement(L,{className:"mb-3",defaultValue:e.title??"",onBlur:Ze(e,"title",g),"data-flow-title":!0})),t.createElement(W,null,t.createElement("span",{style:Ke},"Start label"),t.createElement(L,{className:"mb-3",defaultValue:e.start_label??"",onBlur:Ze(e,"start_label",g),"data-flow-start-label":!0})),t.createElement("div",{style:{marginTop:16}},t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.definition_url,"data-definition":!0},"Definition"),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.details_url,"data-details":!0},"Edit details"))),Qe=er;var tr=({variant:e="neutral",className:o,children:s,...r})=>t.createElement("span",{...r,className:_("ks-badge",`ks-badge-${e}`,o)},s),Re=tr;var or={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"},rr={pills:"ks-tab-bar-pills",underline:"ks-tab-bar-underline"},sr="ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",nr="ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",ar=({shape:e,count:o})=>e?t.createElement("span",{className:"ks-tab-count"},o):t.createElement(Re,{variant:"info"},o),ir=e=>typeof e=="string"?e!=="":e>0,lr=({tabs:e,value:o,onChange:s,align:r="center",shape:n})=>t.createElement("div",null,t.createElement("div",{className:_(or[r],rr[n])},e.map(i=>t.createElement("button",{key:i.value,type:"button",className:n?nr:sr,"data-active":i.value===o?"":void 0,onClick:()=>s(i.value)},i.label,ir(i.count)&&t.createElement(t.Fragment,null," ",t.createElement(ar,{shape:n,count:i.count}))))),e.find(i=>i.value===o)?.content),et=lr;var dr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},tt="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",cr="max-sm:absolute max-sm:inset-0 max-sm:z-20",st={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},ot={display:"flex",gap:8,textAlign:"left"},rt={flexShrink:0,whiteSpace:"nowrap"},pr=({check:e,onSelect:o})=>{let s=t.createElement(t.Fragment,null,t.createElement("span",{className:dr[e.level],style:{...rt,fontWeight:500}},e.level),e.node&&t.createElement("span",{className:"font-mono",style:rt},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:{...ot,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:ot},s)},mr=({checks:e,onSelect:o})=>t.createElement("div",{style:st},e.map((s,r)=>t.createElement(pr,{key:r,check:s,onSelect:o}))),ur=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,fr=({checks:e,tabs:o,onSelect:s,opened:r=ur()?null:"validation"})=>{let[n,i]=w(r);return t.createElement(T,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${tt} ${cr}`:tt},t.createElement(et,{align:"start",shape:"underline",value:n,onChange:d=>i(d===n?null:d),tabs:[{value:"validation",label:"Validation",count:e.filter(d=>d.level==="error").length,content:t.createElement(mr,{checks:e,onSelect:s})},...o.map(d=>({value:d.label,label:d.label,count:d.count??"",content:t.createElement("div",{"data-drawer-content":!0,style:st,dangerouslySetInnerHTML:{__html:d.content}})}))]}))},nt=fr;var at={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},it=e=>({opacity:e?1:0,transition:"opacity .12s"}),gr=({link:e,onInsert:o,onRemove:s,onDrop:r,dragging:n,alwaysShowInsertButtons:i})=>{let[d,c]=w(!1),l=d||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:()=>c(!0),onMouseLeave:()=>c(!1),onDragEnter:()=>c(!0),onDragLeave:()=>c(!1),onDragOver:h=>{h.preventDefault(),h.dataTransfer.dropEffect="move"},onDrop:h=>{h.preventDefault(),c(!1),r()}},t.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},t.createElement(v,{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&&d),style:{...at,...it(l||i)}},"+"),!n&&t.createElement(v,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...at,...it(l)}},"\xD7")))},lt=gr;var xr=({links:e,extent:o,dragging:s,onInsert:r,onRemove:n,onDrop:i,alwaysShowInsertButtons:d})=>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(c=>t.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}))),e.filter(c=>c.label).map(c=>t.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+(d?2:-10),top:c.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},c.label)),e.filter(c=>!c.placeholder).map(c=>t.createElement(lt,{key:c.id,link:c,dragging:!!s,alwaysShowInsertButtons:d,onInsert:()=>r(c),onRemove:()=>n(c),onDrop:()=>i(c)}))),dt=xr;var ae={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},ct="opacity-0 transition-opacity group-data-[over=true]:opacity-100",hr=({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:d=>{d.currentTarget.dataset.over="true"},onMouseLeave:d=>{delete d.currentTarget.dataset.over},onDragOver:d=>{e&&r&&(d.preventDefault(),d.dataTransfer.dropEffect="move")},onDrop:d=>{e&&(d.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(v,{variant:"secondary",title:"Insert a step here",onClick:d=>o(e,d),className:`rounded-full ${n?"opacity-100":ct}`,style:i?{...ae,opacity:1}:ae},"+"),t.createElement(v,{variant:"danger",title:"Remove this connection",onClick:()=>s(e),className:`rounded-full ${ct}`,style:ae},"\xD7"))),pt=hr;var yr=(e,o)=>e.row-o.row||e.column-o.column,mt=e=>{let o=[...e].sort(yr),s=o.filter(r=>e.some(n=>n.holds?.includes(r.id)));return o.filter(r=>!s.includes(r)).flatMap(r=>[r,...s.filter(n=>r.holds?.includes(n.id))])},ut=e=>{let o=mt(e),s=r=>o.some(n=>n.holds?.includes(r.id));return o.filter(r=>!s(r)).reduce((r,n)=>{if(n.holds)return[...r,{group:n,steps:o.filter(d=>n.holds.includes(d.id))}];let i=r[r.length-1];return i&&!i.group?[...r.slice(0,-1),{steps:[...i.steps,n]}]:[...r,{steps:[n]}]},[])},br=(e,o)=>e[e.findIndex(s=>s.id===o.id)+1]?.id,ft=(e,o,s)=>{let r=br(mt(s),e);return o.filter(n=>n.source===e.id&&(n.label||n.target!==r))},vr=e=>e?.placeholder?"nowhere yet":e?.label,gt=(e,o)=>[e.label,"\u2192",vr(o.find(s=>s.id===e.target))].filter(Boolean).join(" "),xt=(e,o,s)=>e.find(r=>r.source===o.id&&r.target===s.id);var kr={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},ht=({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(pt,{link:xt(o,e[i-1],n),...r}),s(n)))),wr={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},Sr=({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:wr},r(e),t.createElement(ht,{steps:o,edges:s,draw:r,joints:n})),Cr=({nodes:e,edges:o,draw:s,joints:r,children:n,style:i})=>t.createElement("div",{"data-flow-rows":!0,style:{...kr,...i}},n,ut(e).map(d=>d.group?t.createElement(Sr,{key:d.group.id,group:d.group,steps:d.steps,edges:o,draw:s,joints:r}):t.createElement(ht,{key:d.steps[0].id,steps:d.steps,edges:o,draw:s,joints:r}))),K=Cr;var yt="Your change was not saved because the server could not be reached.",bt=({base:e,token:o,fetch:s,onFlow:r,onError:n,onNotice:i,onWarning:d=()=>{}})=>async(c,l,h)=>{let g=await s(e+c,{method:l,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:h&&JSON.stringify(h)}).catch(()=>null);if(!g)return i(null),n(yt);let u=await g.json().catch(()=>({}));if(u.unconnected)return i(null),n(null),d({path:c,steps:u.unconnected}),r(await(await s(e+".json",{headers:{Accept:"application/json"}})).json());if(d(null),!g.ok)return i(null),n(u.error||"That change was refused");n(null),i(u.notice||null),r(await(await s(e+".json",{headers:{Accept:"application/json"}})).json())},vt=({base:e,token:o,fetch:s,onError:r})=>async n=>{let i=new FormData;i.append("picture",n);let d=await s(e+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:i}).catch(()=>null);if(!d)return r(yt),null;let c=await d.json().catch(()=>({}));return d.ok?(r(null),c):(r(c.error||"That picture was refused"),null)};var Nr=(e,o,s)=>{let[r,n]=w(s),[i,d]=w(null),[c,l]=w(null),[h,g]=w(null),u=j(()=>bt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onFlow:n,onError:d,onNotice:l,onWarning:g}),[e,o]),x=j(()=>vt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onError:d}),[e,o]);return{flow:r,error:i,notice:c,warning:h,setWarning:g,send:u,pickPicture:x}},kt=Nr;var Z=(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}},_r=(e,o,s)=>s&&o==="top"?{x:e.x,y:s.top}:e,zr=(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},Er=(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}},Br=(e,o,s,r)=>{let[n,i]=w([]),[d,c]=w({width:"100%",height:"100%"}),[l,h]=w([]);return xe(()=>{let g=()=>{let x=o.current?.getBoundingClientRect();if(!x)return;c({width:o.current.scrollWidth,height:o.current.scrollHeight});let y=e.nodes.filter(m=>m.holds&&!m.loose&&s.current[m.id]).map(m=>{let S=s.current[m.id],k=S.getBoundingClientRect(),C=m.holds.flatMap(b=>s.current[b]?[s.current[b].getBoundingClientRect()]:[]),B=[{left:k.left,top:k.top,width:Math.max(k.width,S.scrollWidth),height:k.height},...C];return{id:m.id,bounds:Ce(B,x,o.current)}});h(y),i(e.edges.flatMap(m=>{let S=s.current[m.source]?.getBoundingClientRect(),k=s.current[m.target]?.getBoundingClientRect();if(!S||!k)return[];let C=Z(S,m.leaves,x,o.current),B=y.find(z=>z.id===m.target)?.bounds,b=zr(_r(Z(k,m.enters,x,o.current),m.enters,B),m.enters),f=(Z(S,"bottom",x,o.current).y+Z(k,"top",x,o.current).y)/2,O=m.leaves==="left"?Math.min(C.x,b.x)-28:Math.max(C.x,b.x)+28;return[Er(m,C,b,f,O)]}))};g(),window.addEventListener("resize",g);let u=new ResizeObserver(g);return o.current&&u.observe(o.current),()=>{window.removeEventListener("resize",g),u.disconnect()}},r),{links:n,extent:d,boxes:l}},wt=Br;var St=(e,o)=>{let s=new Set(o),r=e,n=2;for(;s.has(r);)r=`${e}_${n++}`;return r};var Ar=8,Dr={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},Lr={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},Or={flex:1,minHeight:0,overflow:"auto",position:"relative"},Nt={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},$r={...Nt,position:"static",alignSelf:"flex-start"},Pr={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Mr={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Ir=({port:e,onCancel:o})=>t.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Mr},"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")),jr=({base:e,token:o,initial:s})=>{let{flow:r,error:n,notice:i,warning:d,setWarning:c,send:l,pickPicture:h}=kt(e,o,s),[g,u]=w(null),[x,y]=w(null),[m,S]=w(null),[k,C]=w(null),[B,b]=w(null),[f,O]=w(!1),z=ee({}),E=ee(null);P(()=>{let a={open:null,publish:"/publish",save_draft:"/versions"},p=N=>{let D=N.target.closest?.("[data-bar-action]");if(!D||!(D.dataset.barAction in a))return;D.closest("details")?.removeAttribute("open"),u(null),O(!0);let V=a[D.dataset.barAction];V&&l(V,"POST")};return document.addEventListener("click",p),()=>document.removeEventListener("click",p)},[l]),P(()=>{if(!f){c(null);return}let a=p=>{p.target.isConnected&&!p.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&O(!1)};return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[f]),P(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),P(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let At=j(()=>Object.fromEntries(r.nodes.map(a=>[a.id,a])),[r.nodes]),{links:Dt,extent:Lt,boxes:ie}=wt(r,E,z,[r,g,At]),le=j(()=>{let a={};return r.violations.forEach(p=>{var N;return(a[N=p.node]||(a[N]=[])).push(p)}),a},[r.violations]),A=r.direction==="left_to_right",H=r.nodes.filter(a=>!a.loose),de=r.nodes.filter(a=>a.loose),Ot=Math.max(0,...H.map(a=>a.row))+1,$t=Math.max(0,...H.map(a=>a.column))+1,Q=a=>{if(!m)return;let[p,N]=m;S(null),p!==a&&l("/edges","POST",{from:p,to:a,on:N||null})},Pt=a=>{if(a.isDefaultPrevented()||!k)return;a.preventDefault();let p=k;C(null);let N=E.current.getBoundingClientRect(),D=Ne(ie,{x:a.clientX-N.left+E.current.scrollLeft,y:a.clientY-N.top+E.current.scrollTop}),V=r.nodes.find(It=>It.holds?.includes(p))?.id||null;D!==V&&l(`/steps/${p}/group`,"PATCH",{group:D})},ce=a=>[...r.palette,...r.unoffered||[]].find(p=>p.type===a?.type),I=r.nodes.find(a=>a.id===g),$=ce(I),R=(a,p={})=>l("/steps","POST",{id:St(a.type,r.nodes.map(N=>N.id)),type:a.type,from:p.from,to:p.to,on:p.on}),pe=a=>{let[p,N]=[B,k];b(null),C(null),p?R(p,{from:a.source,to:a.target}):N&&l("/steps/"+N+"/move","PATCH",{from:a.source,to:a.target})},Mt=a=>{let p=E.current.getBoundingClientRect();return{x:a.clientX-p.left+E.current.scrollLeft+8,y:a.clientY-p.top+E.current.scrollTop+8}},me=a=>t.createElement(t.Fragment,null,a.placeholder&&t.createElement(We,{node:{...a,ref:p=>{z.current[a.id]=p}},dragging:!!k,compact:A,onFill:()=>y({from:a.from,on:a.on,at:{x:16,y:52}}),onDrop:()=>{let p=k;C(null),p&&l("/edges","POST",{from:a.from,to:p,on:a.on})}}),a.holds&&t.createElement(U,{node:{...a,ref:p=>{z.current[a.id]=p}},header:G(a,ce(a),r.hide_step_type_codes),compact:A,onSelect:()=>m?Q(a.id):u(a.id)}),!a.placeholder&&!a.holds&&t.createElement(oe,{node:{...a,ref:p=>{z.current[a.id]=p},violations:le[a.id]||[],connected:r.edges.filter(p=>p.source===a.id).map(p=>p.label||null)},selected:a.id===g,armed:m&&m[0]===a.id?m[1]:null,connecting:!!m&&m[0]!==a.id,onSelect:()=>m?Q(a.id):u(a.id),onOpen:p=>window.location.assign(p),onArm:(p,N)=>{let D=E.current.getBoundingClientRect();y({from:a.id,on:p,at:{x:N.clientX-D.left+E.current.scrollLeft+8,y:N.clientY-D.top+E.current.scrollTop+8}})},onDragEnd:()=>C(null),onDragStart:()=>C(a.id),hideStepTypeCodes:r.hide_step_type_codes,compact:A,branches:A?ft(a,r.edges,H).map(p=>gt(p,r.nodes)):[]})),ue=de.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:A?$r:Nt},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"),de.map(a=>t.createElement("div",{key:a.id,style:{marginBottom:8}},t.createElement(oe,{node:{...a,ref:p=>{z.current[a.id]=p},violations:le[a.id]||[],connected:[]},selected:g===a.id,armed:m&&m[0]===a.id?m[1]:null,connecting:!!m,onSelect:()=>m?Q(a.id):u(a.id),onOpen:p=>window.location.assign(p),onArm:(p,N)=>{N.stopPropagation(),S([a.id,p])},onDragStart:()=>C(a.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes}))));return t.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:Dr,onMouseUp:()=>C(null),onKeyDown:a=>{a.key==="Escape"&&(u(null),S(null),y(null))},tabIndex:-1},t.createElement(Fe,{entries:r.palette,groups:r.step_groups||{},onPick:a=>R(a),onCarry:b,onDrop:()=>b(null)}),t.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:Lr},t.createElement("div",{ref:E,style:Or,onClick:a=>{a.target===E.current&&(u(null),S(null),O(!1))},onDragOver:a=>{k&&a.preventDefault()},onDrop:Pt},m&&t.createElement(Ir,{port:m[1],onCancel:()=>S(null)}),t.createElement(Ge,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>y({at:{x:16,y:52}}),onUndo:()=>{u(null),l("/undo","POST")},onRedo:()=>{u(null),l("/redo","POST")}}),!A&&ie.map(a=>t.createElement(Se,{key:a.id,id:a.id,bounds:a.bounds,onDrop:()=>{let p=k;C(null),p&&l(`/steps/${p}/group`,"PATCH",{group:a.id})}})),!A&&t.createElement(dt,{links:_e(Dt,r.nodes),extent:Lt,dragging:k||B,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=>{u(null),l("/edges","DELETE",{from:a.source,to:a.target})},onDrop:pe}),!A&&ue,A&&t.createElement(K,{nodes:H,edges:r.edges,draw:me,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(k||B),onInsert:(a,p)=>y({from:a.source,to:a.target,at:Mt(p)}),onRemove:a=>{u(null),l("/edges","DELETE",{from:a.source,to:a.target})},onDrop:pe}},ue),!A&&t.createElement("div",{style:{...Pr,gridTemplateColumns:`repeat(${$t+1}, ${280/2}px)`,gridTemplateRows:`repeat(${Ot}, auto)`}},H.map(a=>t.createElement("div",{key:a.id,style:{gridRow:a.row+1,gridColumn:`${a.column+1} / span 2`,zIndex:2,marginTop:ze(a,r.nodes)?Ar-64:0}},me(a)))),x&&t.createElement(Ve,{entries:r.palette,at:x.at,onDismiss:()=>y(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:x.on!==void 0?()=>{S([x.from,x.on]),y(null)}:null,onPick:a=>{let p=x;y(null),R(a,p)}})),t.createElement(nt,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:u})),f&&!I&&t.createElement(Qe,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:i,publishNote:r.publish_note,warning:d,onClose:()=>O(!1),onCreate:()=>l("/versions","POST"),onPublish:()=>l("/publish","POST"),onAccept:()=>l(d.path,"POST",{remove_unconnected:d.steps.map(a=>a.id)}),onDecline:()=>c(null),onSaveDetails:a=>l("/details","PATCH",{flow:a})}),I&&t.createElement(He,{node:I,fields:$?.fields||{},holds:$?.records||{},labels:$?.labels||{},explanations:$?.explanations||{},recordLabels:$?.record_labels||{},recordExplanations:$?.record_explanations||{},recordChoices:$?.record_choices||{},recordOutputsOf:$?.record_outputs_of||{},choices:Ee(I,$),onClose:()=>u(null),onSave:a=>l(`/steps/${I.id}`,"PATCH",{config:a}),onPickPicture:h,refusal:n,onDelete:()=>{u(null),l(`/steps/${I.id}`,"DELETE")}}))},_t=jr;var Hr={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Wr={fontSize:12,fontWeight:500,lineHeight:1.3},zt={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"},Et={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"},Vr="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Fr=({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"} ${zt[e.state]||zt.pending}${o?` ${Vr}`:""}`,style:Hr},t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.type),t.createElement("div",{style:Wr},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:Et[e.state]||Et.pending,style:{fontSize:11}},e.status))},Bt=Fr;var Ur={gap:12,padding:0},Gr=({nodes:e,edges:o,selected:s})=>t.createElement(K,{nodes:e,edges:o,joints:{},style:Ur,draw:r=>r.holds?t.createElement(U,{node:r,header:G(r,r,!1),compact:!0}):t.createElement(Bt,{node:r,selected:r.id===s})}),Tt=Gr;te("easy_flow/flow-editor",_t);te("easy_flow/run-view",Tt);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}`})});ve(document,fe);})();
@@ -13,7 +13,8 @@ module EasyFlow
13
13
  "hide_step_type_codes" => flow_host.hide_step_type_codes?,
14
14
  "direction" => flow_host.canvas_direction.to_s,
15
15
  "step_groups" => flow_host.step_groups,
16
- "publish_note" => flow_host.publish_note)
16
+ "publish_note" => flow_host.publish_note,
17
+ "drawer_tabs" => flow_host.drawer_tabs_for(flow).map(&:to_h))
17
18
  end
18
19
 
19
20
  def canvas_document(flow)
@@ -10,6 +10,7 @@ import TypePicker from "./TypePicker"
10
10
  import StepList from "./StepList"
11
11
  import Toolbar from "./Toolbar"
12
12
  import Panel from "./Panel"
13
+ import Drawer from "./Drawer"
13
14
  import ConnectorLayer from "./ConnectorLayer"
14
15
  import LeftToRight from "./LeftToRight"
15
16
  import useFlow from "./useFlow"
@@ -20,8 +21,9 @@ import { branchLine, branchesOf } from "./reading"
20
21
 
21
22
  const HEADER_GAP = 8
22
23
 
23
- const page = { display: "flex", height: "100%", minHeight: 0, fontSize: 13 }
24
- const scroll = { flex: 1, overflow: "auto", position: "relative" }
24
+ const page = { display: "flex", height: "100%", minHeight: 0, fontSize: 13, position: "relative" }
25
+ const column = { flex: 1, minWidth: 0, display: "flex", flexDirection: "column", position: "relative" }
26
+ const scroll = { flex: 1, minHeight: 0, overflow: "auto", position: "relative" }
25
27
  const waiting = { position: "absolute", top: 56, left: 16, zIndex: 5, width: CARD + 24, padding: 12, borderRadius: 8 }
26
28
 
27
29
  const waitingInRows = { ...waiting, position: "static", alignSelf: "flex-start" }
@@ -215,59 +217,62 @@ const Canvas = ({ base, token, initial }) => {
215
217
  tabIndex={-1}>
216
218
  <StepList entries={flow.palette} groups={flow.step_groups || {}}
217
219
  onPick={(entry) => addStep(entry)} onCarry={setCarrying} onDrop={() => setCarrying(null)} />
218
- <div ref={surface} className="bg-surface-50 dark:bg-surface-950" style={scroll}
219
- onClick={(event) => { if (event.target === surface.current) { setSelected(null); setArmed(null); setShowing(false) } }}
220
- onDragOver={(event) => { if (dragging) event.preventDefault() }}
221
- onDrop={regroup}>
222
- {armed && (
223
- <Choosing port={armed[1]} onCancel={() => setArmed(null)} />
224
- )}
225
- <Toolbar undoable={flow.undoable} redoable={flow.redoable}
226
- onAdd={() => setAdding({ at: { x: 16, y: 52 } })}
227
- onUndo={() => { setSelected(null); send("/undo", "POST") }}
228
- onRedo={() => { setSelected(null); send("/redo", "POST") }} />
229
-
230
- {!leftToRight && boxes.map((box) => (
231
- <GroupBox key={box.id} id={box.id} bounds={box.bounds}
232
- onDrop={() => { const held = dragging; setDragging(null); if (held) send(`/steps/${held}/group`, "PATCH", { group: box.id }) }} />
233
- ))}
234
-
235
- {!leftToRight && <ConnectorLayer links={linksOutside(links, flow.nodes)} extent={extent} dragging={dragging || carrying} alwaysShowInsertButtons={flow.always_show_insert_buttons}
236
- onInsert={(link) => setAdding({ from: link.source, to: link.target, at: { x: link.midX + 30, y: link.midY } })}
237
- onRemove={(link) => { setSelected(null); send("/edges", "DELETE", { from: link.source, to: link.target }) }}
238
- onDrop={dropOnLink} />}
239
-
240
- {!leftToRight && waitingSteps}
241
-
242
- {leftToRight && <LeftToRight nodes={attached} edges={flow.edges} draw={draw} joints={{
243
- alwaysShowInsertButtons: flow.always_show_insert_buttons,
244
- dragging: Boolean(dragging || carrying),
245
- onInsert: (link, event) => setAdding({ from: link.source, to: link.target, at: pointed(event) }),
246
- onRemove: (link) => { setSelected(null); send("/edges", "DELETE", { from: link.source, to: link.target }) },
247
- onDrop: dropOnLink
248
- }}>{waitingSteps}</LeftToRight>}
249
-
250
- {!leftToRight && <div style={{ ...grid, gridTemplateColumns: `repeat(${columns + 1}, ${(CARD + GAP_X) / 2}px)`, gridTemplateRows: `repeat(${rows}, auto)` }}>
251
- {attached.map((node) => (
252
- <div key={node.id} style={{ gridRow: node.row + 1, gridColumn: `${node.column + 1} / span 2`, zIndex: 2, marginTop: underHeader(node, flow.nodes) ? HEADER_GAP - GAP_Y : 0 }}>
253
- {draw(node)}
254
- </div>
220
+ <div className="bg-surface-50 dark:bg-surface-950" style={column}>
221
+ <div ref={surface} style={scroll}
222
+ onClick={(event) => { if (event.target === surface.current) { setSelected(null); setArmed(null); setShowing(false) } }}
223
+ onDragOver={(event) => { if (dragging) event.preventDefault() }}
224
+ onDrop={regroup}>
225
+ {armed && (
226
+ <Choosing port={armed[1]} onCancel={() => setArmed(null)} />
227
+ )}
228
+ <Toolbar undoable={flow.undoable} redoable={flow.redoable}
229
+ onAdd={() => setAdding({ at: { x: 16, y: 52 } })}
230
+ onUndo={() => { setSelected(null); send("/undo", "POST") }}
231
+ onRedo={() => { setSelected(null); send("/redo", "POST") }} />
232
+
233
+ {!leftToRight && boxes.map((box) => (
234
+ <GroupBox key={box.id} id={box.id} bounds={box.bounds}
235
+ onDrop={() => { const held = dragging; setDragging(null); if (held) send(`/steps/${held}/group`, "PATCH", { group: box.id }) }} />
255
236
  ))}
256
- </div>}
257
-
258
- {adding && (
259
- <TypePicker entries={flow.palette} at={adding.at} onDismiss={() => setAdding(null)} hideStepTypeCodes={flow.hide_step_type_codes}
260
- onConnect={adding.on !== undefined ? () => { setArmed([ adding.from, adding.on ]); setAdding(null) } : null}
261
- onPick={(entry) => {
262
- const where = adding
263
- setAdding(null)
264
- addStep(entry, where)
265
- }} />
266
- )}
237
+
238
+ {!leftToRight && <ConnectorLayer links={linksOutside(links, flow.nodes)} extent={extent} dragging={dragging || carrying} alwaysShowInsertButtons={flow.always_show_insert_buttons}
239
+ onInsert={(link) => setAdding({ from: link.source, to: link.target, at: { x: link.midX + 30, y: link.midY } })}
240
+ onRemove={(link) => { setSelected(null); send("/edges", "DELETE", { from: link.source, to: link.target }) }}
241
+ onDrop={dropOnLink} />}
242
+
243
+ {!leftToRight && waitingSteps}
244
+
245
+ {leftToRight && <LeftToRight nodes={attached} edges={flow.edges} draw={draw} joints={{
246
+ alwaysShowInsertButtons: flow.always_show_insert_buttons,
247
+ dragging: Boolean(dragging || carrying),
248
+ onInsert: (link, event) => setAdding({ from: link.source, to: link.target, at: pointed(event) }),
249
+ onRemove: (link) => { setSelected(null); send("/edges", "DELETE", { from: link.source, to: link.target }) },
250
+ onDrop: dropOnLink
251
+ }}>{waitingSteps}</LeftToRight>}
252
+
253
+ {!leftToRight && <div style={{ ...grid, gridTemplateColumns: `repeat(${columns + 1}, ${(CARD + GAP_X) / 2}px)`, gridTemplateRows: `repeat(${rows}, auto)` }}>
254
+ {attached.map((node) => (
255
+ <div key={node.id} style={{ gridRow: node.row + 1, gridColumn: `${node.column + 1} / span 2`, zIndex: 2, marginTop: underHeader(node, flow.nodes) ? HEADER_GAP - GAP_Y : 0 }}>
256
+ {draw(node)}
257
+ </div>
258
+ ))}
259
+ </div>}
260
+
261
+ {adding && (
262
+ <TypePicker entries={flow.palette} at={adding.at} onDismiss={() => setAdding(null)} hideStepTypeCodes={flow.hide_step_type_codes}
263
+ onConnect={adding.on !== undefined ? () => { setArmed([ adding.from, adding.on ]); setAdding(null) } : null}
264
+ onPick={(entry) => {
265
+ const where = adding
266
+ setAdding(null)
267
+ addStep(entry, where)
268
+ }} />
269
+ )}
270
+ </div>
271
+ <Drawer checks={flow.checks || []} tabs={flow.drawer_tabs || []} onSelect={setSelected} />
267
272
  </div>
268
273
 
269
274
  {showing && !selectedNode && (
270
- <Panel flow={flow.flow || {}} changes={flow.changes || []} problems={flow.violations} refusal={error} notice={notice} publishNote={flow.publish_note} warning={warning}
275
+ <Panel flow={flow.flow || {}} changes={flow.changes || []} refusal={error} notice={notice} publishNote={flow.publish_note} warning={warning}
271
276
  onClose={() => setShowing(false)}
272
277
  onCreate={() => send("/versions", "POST")}
273
278
  onPublish={() => send("/publish", "POST")}
@@ -0,0 +1,37 @@
1
+ import React from "react"
2
+ import ValueList from "keystone_ui-react/src/ValueList.jsx"
3
+ import Disclosure from "keystone_ui-react/src/Disclosure.jsx"
4
+ import Code from "keystone_ui-react/src/Code.jsx"
5
+
6
+ const SECTION = "flex flex-col gap-1 mb-3"
7
+
8
+ const VALUES = "[&_dd]:font-mono"
9
+
10
+ const COLUMNS = "[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2"
11
+
12
+ const ROWS = "[&_.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]"
13
+
14
+ const CODE = "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]"
15
+
16
+ const looks = (section) => {
17
+ if (!section.values) return `${SECTION} ${CODE}`
18
+ return section.columns ? `${SECTION} ${VALUES} ${COLUMNS}` : `${SECTION} ${VALUES} ${ROWS}`
19
+ }
20
+
21
+ const Details = ({ details }) => (
22
+ <>
23
+ {details.map((section, at) => (
24
+ <section key={at} className={looks(section)}>
25
+ {section.heading && <div className="text-gray-500 dark:text-gray-400">{section.heading}</div>}
26
+ {section.values && <ValueList rows={section.values} columns={section.columns} />}
27
+ {section.code && section.code.map((block) => (
28
+ <Disclosure key={block.summary} summary={block.summary}>
29
+ <Code>{block.code}</Code>
30
+ </Disclosure>
31
+ ))}
32
+ </section>
33
+ ))}
34
+ </>
35
+ )
36
+
37
+ export default Details
@@ -0,0 +1,49 @@
1
+ import React, { useState } from "react"
2
+ import Panel from "keystone_ui-react/src/Panel.jsx"
3
+ import Tabs from "keystone_ui-react/src/Tabs.jsx"
4
+
5
+ const LEVELS = { error: "text-red-800 dark:text-red-400", ok: "text-emerald-800 dark:text-emerald-400" }
6
+
7
+ const LOOK = "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"
8
+
9
+ const COVERING = "max-sm:absolute max-sm:inset-0 max-sm:z-20"
10
+
11
+ const body = { padding: "10px 14px", fontSize: 12, display: "flex", flexDirection: "column", gap: 6 }
12
+
13
+ const row = { display: "flex", gap: 8, textAlign: "left" }
14
+
15
+ const whole = { flexShrink: 0, whiteSpace: "nowrap" }
16
+
17
+ const Row = ({ check, onSelect }) => {
18
+ const shown = <>
19
+ <span className={LEVELS[check.level]} style={{ ...whole, fontWeight: 500 }}>{check.level}</span>
20
+ {check.node && <span className="font-mono" style={whole}>{check.node}</span>}
21
+ <span>{check.sentence}</span>
22
+ </>
23
+
24
+ return check.node
25
+ ? <button type="button" data-check-row data-step-id={check.node} style={{ ...row, border: "none", background: "none", padding: 0, cursor: "pointer", font: "inherit", color: "inherit" }} onClick={() => onSelect(check.node)}>{shown}</button>
26
+ : <div data-check-row style={row}>{shown}</div>
27
+ }
28
+
29
+ const Rows = ({ checks, onSelect }) => (
30
+ <div style={body}>
31
+ {checks.map((check, at) => <Row key={at} check={check} onSelect={onSelect} />)}
32
+ </div>
33
+ )
34
+
35
+ const onAPhone = () => typeof window !== "undefined" && Boolean(window.matchMedia?.("(max-width: 639px)").matches)
36
+
37
+ const Drawer = ({ checks, tabs, onSelect, opened = onAPhone() ? null : "validation" }) => {
38
+ const [ open, setOpen ] = useState(opened)
39
+
40
+ return (
41
+ <Panel as="section" aria-label="Validation and tests" data-drawer className={open ? `${LOOK} ${COVERING}` : LOOK}>
42
+ <Tabs align="start" shape="underline" value={open} onChange={(chosen) => setOpen(chosen === open ? null : chosen)}
43
+ tabs={[ { value: "validation", label: "Validation", count: checks.filter((check) => check.level === "error").length, content: <Rows checks={checks} onSelect={onSelect} /> },
44
+ ...tabs.map((tab) => ({ value: tab.label, label: tab.label, count: tab.count ?? "", content: <div data-drawer-content style={body} dangerouslySetInnerHTML={{ __html: tab.content }} /> })) ]} />
45
+ </Panel>
46
+ )
47
+ }
48
+
49
+ export default Drawer
@@ -2,11 +2,14 @@ import React, { useEffect, useState } from "react"
2
2
  import Control from "./Control"
3
3
  import Records from "./Records"
4
4
  import Explanation from "./Explanation"
5
+ import Details from "./Details"
5
6
  import Panel from "keystone_ui-react/src/Panel.jsx"
6
7
  import Button from "keystone_ui-react/src/Button.jsx"
7
8
  import { Label } from "keystone_ui-react/src/FieldText.jsx"
8
9
 
9
- const panel = { width: 280, padding: 20, overflowY: "auto" }
10
+ const panel = { width: 320, padding: "14px 16px", overflowY: "auto", display: "flex", flexDirection: "column", fontSize: 12 }
11
+
12
+ const foot = { marginTop: "auto", paddingTop: 12, display: "flex", flexDirection: "column", gap: 8 }
10
13
 
11
14
  const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, recordExplanations, recordChoices, recordOutputsOf, choices, onSave, onDelete, onClose, onPickPicture, refusal }) => {
12
15
  const [ draft, setDraft ] = useState(node.config)
@@ -20,13 +23,15 @@ const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, re
20
23
  }
21
24
 
22
25
  return (
23
- <Panel as="aside" style={panel} data-inspector>
24
- <div style={{ display: "flex", alignItems: "start", justifyContent: "space-between", gap: 8 }}>
25
- <h2 style={{ fontWeight: 600, marginBottom: 2 }}>{node.label}</h2>
26
+ <Panel as="aside" style={panel} className="max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto" data-inspector>
27
+ <div style={{ display: "flex", alignItems: "start", justifyContent: "space-between", gap: 8, marginBottom: 12 }}>
28
+ <div>
29
+ <p className="font-mono text-gray-500 dark:text-gray-400" style={{ fontSize: 11 }}>{node.id} · {node.type}</p>
30
+ <h2 style={{ fontSize: 15, fontWeight: 600 }}>{node.label}</h2>
31
+ </div>
26
32
  <button title="Close" onClick={onClose} className="text-gray-500 dark:text-gray-400"
27
33
  style={{ border: "none", background: "none", cursor: "pointer", fontSize: 18, lineHeight: 1 }}>×</button>
28
34
  </div>
29
- <p className="text-gray-500 dark:text-gray-400" style={{ fontSize: 11, marginBottom: 16 }}>{node.id} · {node.type}</p>
30
35
  {refusal && <p className="text-red-800 dark:text-red-400" style={{ fontWeight: 600, marginBottom: 12 }} data-refusal>{refusal}</p>}
31
36
  {Object.entries(fields).map(([ name, type ]) => (
32
37
  <Label key={name}>
@@ -49,7 +54,17 @@ const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, re
49
54
  {(explanations || {})[name] && <Explanation text={explanations[name]} />}
50
55
  </Label>
51
56
  ))}
52
- <Button variant="danger" size="sm" className="w-full" onClick={onDelete}>Delete step</Button>
57
+ <Details details={node.details || []} />
58
+ <div style={foot}>
59
+ {(node.links || []).length > 0 && (
60
+ <div style={{ display: "flex", gap: 8 }}>
61
+ {node.links.map((link) => (
62
+ <Button key={link.address} variant="secondary" size="sm" className="flex-1" href={link.address}>{link.label}</Button>
63
+ ))}
64
+ </div>
65
+ )}
66
+ <Button variant="danger" size="sm" className="w-full" onClick={onDelete}>Delete step</Button>
67
+ </div>
53
68
  </Panel>
54
69
  )
55
70
  }
@@ -16,7 +16,7 @@ const settling = (flow, name, onSaveDetails) => (event) => {
16
16
  if (event.target.value !== (flow[name] ?? "")) onSaveDetails({ [name]: event.target.value })
17
17
  }
18
18
 
19
- const Panel = ({ flow, changes, problems, refusal, notice, publishNote, warning, onCreate, onPublish, onAccept, onDecline, onSaveDetails, onClose }) => (
19
+ const Panel = ({ flow, changes, refusal, notice, publishNote, warning, onCreate, onPublish, onAccept, onDecline, onSaveDetails, onClose }) => (
20
20
  <KeystonePanel as="aside" style={sheet} data-builder-panel>
21
21
  <div style={{ display: "flex", alignItems: "start", justifyContent: "space-between", gap: 8 }}>
22
22
  <h2 style={{ fontWeight: 600 }} data-flow-name>{flow.title || flow.slug}</h2>
@@ -41,14 +41,8 @@ const Panel = ({ flow, changes, problems, refusal, notice, publishNote, warning,
41
41
  </div>
42
42
  )}
43
43
 
44
- <h2 style={heading}>Problems</h2>
45
- {refusal && <p className="text-red-800 dark:text-red-400" style={{ ...item, fontWeight: 600 }} data-refusal>{refusal}</p>}
46
- {notice && !refusal && <p className="text-emerald-800 dark:text-emerald-400" style={{ ...item, fontWeight: 600 }} data-notice>{notice}</p>}
47
- {problems.length === 0 && !refusal
48
- ? <p className="text-gray-500 dark:text-gray-400" style={{ fontSize: 12 }}>Nothing wrong with this flow.</p>
49
- : problems.map((problem) => (
50
- <p key={`${problem.node}-${problem.problem}`} className="text-amber-700 dark:text-amber-400" style={item} data-problem>⚠ {problem.sentence}</p>
51
- ))}
44
+ {refusal && <p className="text-red-800 dark:text-red-400" style={{ ...item, fontWeight: 600, marginTop: 8 }} data-refusal>{refusal}</p>}
45
+ {notice && !refusal && <p className="text-emerald-800 dark:text-emerald-400" style={{ ...item, fontWeight: 600, marginTop: 8 }} data-notice>{notice}</p>}
52
46
 
53
47
  <h2 style={heading}>Changes since the last version</h2>
54
48
  {changes.length === 0
@@ -10,7 +10,7 @@ module EasyFlow
10
10
  end
11
11
 
12
12
  def to_h
13
- { "nodes" => nodes, "edges" => edges, "palette" => palette, "unoffered" => unoffered, "violations" => violations }
13
+ { "nodes" => nodes, "edges" => edges, "palette" => palette, "unoffered" => unoffered, "violations" => violations, "checks" => CheckList.new(violations).rows }
14
14
  end
15
15
 
16
16
  private
@@ -20,7 +20,7 @@ module EasyFlow
20
20
  end
21
21
 
22
22
  def drawn_step(node)
23
- { "id" => node.id, "type" => node.type, "type_name" => step_type_for(node)&.step_name, "label" => label_for(node), "summary" => step_type_for(node)&.summary_of(node),
23
+ { "id" => node.id, "type" => node.type, "type_name" => step_type_for(node)&.step_name, "label" => label_for(node), "summary" => step_type_for(node)&.summary_of(node), "details" => step_type_for(node)&.details_of(node).to_a, "links" => step_type_for(node)&.links_of(node).to_a,
24
24
  "config" => node.config.merge(kept_values(node)), "ports" => [], "ends_here" => ends_here?(node), "begins_here" => begins_here?(node),
25
25
  "starts_a_flow" => starts_a_flow?(node), "holds" => holds(node), "opens" => opens(node), "loose" => loose?(node), "choices" => choices_for(node), "record_choices" => record_choices_for(node), "placeholder" => false, "picture_url" => picture_url(node), **placed[node.id] }
26
26
  end
@@ -112,7 +112,14 @@ module EasyFlow
112
112
  "record_outputs_of" => step_type.settings.record_outputs_of.to_h { |name, sources| [ name.to_s, sources.to_h { |field, source| [ field.to_s, source.to_s ] } ] },
113
113
  "record_labels" => step_type.settings.record_labels.to_h { |name, held| [ name.to_s, held.transform_keys(&:to_s) ] },
114
114
  "record_explanations" => record_explanations_of(step_type),
115
- "awaits_input" => step_type.awaits_input? }
115
+ "awaits_input" => step_type.awaits_input?,
116
+ "outputs" => step_type.outputs.map { |output| palette_output(output) },
117
+ "outputs_named_by" => step_type.outputs_named_by&.to_s }
118
+ end
119
+
120
+ def palette_output(output)
121
+ { "name" => output.name.to_s, "label" => output.label, "type" => output.type.to_s,
122
+ "values" => output.values.respond_to?(:call) ? nil : output.values }
116
123
  end
117
124
 
118
125
  def hidden_settings_of(step_type)
@@ -138,7 +145,7 @@ module EasyFlow
138
145
  end
139
146
 
140
147
  def violations
141
- Validator.new(@document, registry: @registry, flow: @flow).violations.map do |violation|
148
+ @violations ||= Validator.new(@document, registry: @registry, flow: @flow).violations.map do |violation|
142
149
  { "node" => violation.node, "problem" => violation.problem.to_s, "detail" => violation.detail, "sentence" => sentences.of(violation) }
143
150
  end
144
151
  end
@@ -0,0 +1,47 @@
1
+ module EasyFlow
2
+ class CheckList
3
+ ALWAYS = {
4
+ "Every connection joins two steps that exist." => %w[missing_edge_target missing_edge_source],
5
+ "Every step has an id of its own that a flow can use." => %w[duplicate_id reserved_id],
6
+ "The flow has one start step, and nothing leads into it." => %w[no_beginning many_beginnings before_the_beginning],
7
+ "Every step can be reached from the start." => %w[unreachable],
8
+ "Every step comes after the steps it reads." => %w[unmet_requirement reading_an_unconnected_step],
9
+ "Every step has the settings it needs." => %w[missing_setting missing_value],
10
+ "Every flow a step starts can run and does not lead back here." => %w[missing_flow unrunnable_version owned_by_another_owner circular]
11
+ }.freeze
12
+
13
+ OPTIONAL = {
14
+ unrouted_value: { "Every answer leads to a next step." => %w[unrouted_value] },
15
+ unfollowed_path: { "Every path out of a step is connected." => %w[unfollowed_path] },
16
+ dead_end: { "Every path ends at an End step." => %w[dead_end past_the_end] }
17
+ }.freeze
18
+
19
+ def initialize(violations, checks: EasyFlow.checks)
20
+ @violations = violations
21
+ @checks = checks
22
+ end
23
+
24
+ def rows
25
+ errors + passed
26
+ end
27
+
28
+ private
29
+
30
+ def errors
31
+ @violations.map { |violation| { "level" => "error", "node" => violation["node"], "sentence" => violation["sentence"] } }
32
+ end
33
+
34
+ def passed
35
+ made.reject { |_sentence, problems| problems.intersect?(found) }.keys
36
+ .map { |sentence| { "level" => "ok", "node" => nil, "sentence" => sentence } }
37
+ end
38
+
39
+ def made
40
+ ALWAYS.merge(*@checks.map { |name| OPTIONAL.fetch(name) })
41
+ end
42
+
43
+ def found
44
+ @violations.map { |violation| violation["problem"] }
45
+ end
46
+ end
47
+ end
@@ -20,6 +20,7 @@ module EasyFlow
20
20
  @outputs_of = {}
21
21
  @kept = {}
22
22
  @declared_outputs = []
23
+ @details = []
23
24
  @required = []
24
25
  @optional = []
25
26
  @awaits_input = false
@@ -119,6 +120,18 @@ module EasyFlow
119
120
  @summarizing = summarizing
120
121
  end
121
122
 
123
+ def shows_values(heading = nil, columns: false, &values)
124
+ @details += [ ShownValues.new(heading: heading, columns: columns, values: values) ]
125
+ end
126
+
127
+ def shows_code(heading = nil, &code)
128
+ @details += [ ShownCode.new(heading: heading, code: code) ]
129
+ end
130
+
131
+ def links_to(&linking)
132
+ @linking = linking
133
+ end
134
+
122
135
  def setting(name, type: nil, from: nil, outputs_of: nil, label: nil, explanation: nil, options: nil, limit: nil, check: nil, required: false, optional: false, kept_on: nil, attribute: nil, &entries)
123
136
  type ||= :from_step if from
124
137
  type ||= :from_step if outputs_of
@@ -167,7 +180,7 @@ module EasyFlow
167
180
  def to_step_type
168
181
  StepType.new(id: @id, step_name: @step_name, settings: settings, awaits_input: @awaits_input,
169
182
  ends_here: @ends_here, begins_here: @begins_here, starts_a_flow: @starts_a_flow, plays_the_picked_flow: @plays_the_picked_flow, holds_steps: @holds_steps, flow_chooser: @flow_chooser, run_chooser: @run_chooser, behaviour: @behaviour, routing: @routing,
170
- display: @display, drawn_by: @drawn_by, naming_field: @naming_field, naming: @naming, summarizing: @summarizing,
183
+ display: @display, drawn_by: @drawn_by, naming_field: @naming_field, naming: @naming, summarizing: @summarizing, details: @details, linking: @linking,
171
184
  outputs: @declared_outputs, outputs_named_by: @outputs_named_by, answer_check: @answer_check, answer_labelling: @answer_labelling, readiness: @readiness, return_rule: @return_rule, unsaved_refusal: @unsaved_refusal)
172
185
  end
173
186
 
@@ -0,0 +1,9 @@
1
+ module EasyFlow
2
+ class StepType
3
+ ShownCode = Data.define(:heading, :code) do
4
+ def drawn(node)
5
+ { "heading" => heading, "code" => code.call(node).to_h.map { |summary, text| { "summary" => summary.to_s, "code" => text.to_s } } }
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module EasyFlow
2
+ class StepType
3
+ ShownValues = Data.define(:heading, :columns, :values) do
4
+ def drawn(node)
5
+ { "heading" => heading, "columns" => columns,
6
+ "values" => values.call(node).to_h.map { |label, value| { "label" => label.to_s, "value" => value.to_s } } }
7
+ end
8
+ end
9
+ end
10
+ end
@@ -8,11 +8,11 @@ module EasyFlow
8
8
  behaviour.present? && behaviour.parameters.include?([ :key, :run ])
9
9
  end
10
10
 
11
- attr_reader :id, :step_name, :settings, :naming_field, :naming, :outputs, :drawn_by, :unsaved_refusal
11
+ attr_reader :id, :step_name, :settings, :naming_field, :naming, :outputs, :outputs_named_by, :drawn_by, :unsaved_refusal
12
12
 
13
13
  def initialize(id:, step_name:, settings:, awaits_input:, behaviour:, routing:,
14
14
  ends_here: false, begins_here: false, starts_a_flow: false, plays_the_picked_flow: false, holds_steps: false, flow_chooser: nil, run_chooser: nil, display: nil, drawn_by: nil,
15
- naming_field: nil, naming: nil, summarizing: nil, outputs: [], outputs_named_by: nil, answer_check: nil, answer_labelling: nil, readiness: nil, return_rule: nil, unsaved_refusal: nil)
15
+ naming_field: nil, naming: nil, summarizing: nil, details: [], linking: nil, outputs: [], outputs_named_by: nil, answer_check: nil, answer_labelling: nil, readiness: nil, return_rule: nil, unsaved_refusal: nil)
16
16
  @id = id
17
17
  @step_name = step_name
18
18
  @settings = settings
@@ -31,6 +31,8 @@ module EasyFlow
31
31
  @naming_field = naming_field
32
32
  @naming = naming
33
33
  @summarizing = summarizing
34
+ @details = details
35
+ @linking = linking
34
36
  @outputs = outputs
35
37
  @outputs_named_by = outputs_named_by
36
38
  @answer_check = answer_check
@@ -84,6 +86,14 @@ module EasyFlow
84
86
  @summarizing&.call(node).presence
85
87
  end
86
88
 
89
+ def details_of(node)
90
+ @details.map { |detail| detail.drawn(node) }
91
+ end
92
+
93
+ def links_of(node)
94
+ Array(@linking&.call(node)).map { |link| link.to_h.symbolize_keys.then { |given| { "label" => given[:label].to_s, "address" => given[:address].to_s } } }
95
+ end
96
+
87
97
  def acts?
88
98
  @behaviour.present?
89
99
  end
@@ -2,9 +2,14 @@ module EasyFlow
2
2
  class Host
3
3
  BackLink = Data.define(:label, :address)
4
4
  Button = Data.define(:label, :address)
5
+ Tab = Data.define(:label, :count, :content) do
6
+ def initialize(label:, content:, count: nil)
7
+ super
8
+ end
9
+ end
5
10
 
6
11
  attr_reader :name, :back_link
7
- attr_writer :layout, :admin_layout, :offers, :allowed_answers, :always_show_insert_buttons, :hide_step_type_codes, :marks_ends, :on_publish, :canvas_direction, :editor_buttons
12
+ attr_writer :layout, :admin_layout, :offers, :allowed_answers, :always_show_insert_buttons, :hide_step_type_codes, :marks_ends, :on_publish, :canvas_direction, :editor_buttons, :drawer_tabs
8
13
  attr_accessor :admin_authentication_method, :visitor_authorization_method, :refusal_method, :owner_method, :finds_flows_across_owners, :publish_note
9
14
 
10
15
  def initialize(name)
@@ -24,6 +29,11 @@ module EasyFlow
24
29
  Array(listed).map { |button| Button.new(**button) }
25
30
  end
26
31
 
32
+ def drawer_tabs_for(flow)
33
+ listed = @drawer_tabs.respond_to?(:call) ? @drawer_tabs.call(flow) : @drawer_tabs
34
+ Array(listed).map { |tab| Tab.new(**tab) }
35
+ end
36
+
27
37
  def setting_explanations=(explanations)
28
38
  explained = explanations.to_h.deep_stringify_keys
29
39
  raise ArgumentError, "an explanation must be text, and a list entry's setting is named like answers.weight" unless explained.values.flat_map(&:values).all? { |text| text.nil? || text.is_a?(String) }
@@ -1,3 +1,3 @@
1
1
  module EasyFlow
2
- VERSION = "0.47.0"
2
+ VERSION = "0.49.0"
3
3
  end
@@ -106,6 +106,10 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
106
106
  Here `CheckResult.for` is the app's own lookup.
107
107
  - `names_by :setting` or `names_by { |node| ... }` — what the step is called on the canvas, from a setting or computed.
108
108
  - `summarizes_by { |node| ... }` — the one line the step's card shows under its name on the canvas, worked out from the step's settings, such as `summarizes_by { |node| "role: #{node.config['role']} · #{node.config['hours']}h" }`. Return a short phrase, or `nil` or `""` to show no line. Without it the card shows no summary, and a step with problems shows its error count in the summary's place. The block is called every time the canvas is drawn, so it must not be slow and must not change anything, and like `names_by` its `node.config` holds no kept setting. Ask the developer what an admin should read about a step of this type without opening it.
109
+ - `shows_values(heading = nil, columns: false) { |node| ... }` — a read-only section of the step settings panel, shown under the step's editable settings. The block returns a hash of labels to values, such as `shows_values("Inputs") { |node| { "brief" => "load_brief.out.brief" } }`, and each value is shown as text in a monospace font. Without `columns:` each label sits beside its value with the labels in one column. With `columns: true` the pairs sit two to a row, each label above its value, such as `shows_values(columns: true) { |node| { "Timeout" => "90s", "Retry" => "3" } }`. Declare it several times for several sections, which are shown in the order declared. Nothing in a section can be edited from the panel.
110
+ - `shows_code(heading = nil) { |node| ... }` — a read-only section of the step settings panel holding code blocks. The block returns a hash of summary lines to code, such as `shows_code("Schemas") { |node| { "input_schema" => node.config["input_schema"].to_s } }`. Each block is closed until its summary line is clicked, and a line wider than the panel scrolls sideways inside its block.
111
+ - `links_to { |node| ... }` — buttons at the foot of the step settings panel, side by side above Delete step. The block returns a list of hashes each with a `label` and an `address`, such as `links_to { |node| [ { label: "Open agent", address: "/agents/#{node.config['agent']}" } ] }`. Each address is used as written.
112
+ - The blocks of `shows_values`, `shows_code` and `links_to` are called every time the canvas is drawn, so they must not be slow and must not change anything. Ask the developer what an admin should read about a step of this type in its settings without being able to change it, and which pages it should link to.
109
113
  - `awaits_input` — the visitor is shown this step and submits an answer to it.
110
114
  - `waits_until { |node, state| ... }` or `waits_until { |node, state, times| ... }` — the run stops at this step until the block returns a truthy value. See step 8.
111
115
  - `answer_check { |node, value| ... }` — checks a submitted answer before it is recorded. `value` is the submitted string, an array of strings when the input submits several values, or `nil` or `""` when the input sent nothing. An array may hold blank strings. Return a message to refuse the answer, or `nil` to accept it. Without it every answer is accepted, including a blank one. For a file input, see step 7.
@@ -102,7 +102,7 @@ easy_flow declares no commands of its own for this local. Its surface is split b
102
102
  - **Offered step types** — the list of step types a host names for its admins to add. A host that names no list offers every registered step type. The list only narrows the palette.
103
103
  - **Allowed answers** — a rule a host may carry that looks at a step and the answers given so far in a run and names the answer values that step allows. When it names nothing for a step, the step offers every answer. When it names several, a question or checklist offers only those. When it names exactly one, the step records that answer without being shown, and when it names none, the step is passed over and records a blank answer. This holds in a stored run, a run moved on outside a visitor's request, a flow that carries its answers in the page, and an admin's preview. Going back skips the steps the host filled in and returns to the last step the visitor was shown.
104
104
  - **Always-visible insert buttons** — a setting a host may turn on, `always_show_insert_buttons`, that shows each connection's button for inserting a step on its canvas without the pointer over the connection, with the connection's label moved to the right of the line. It is off by default, and with it off the button shows only with the pointer over the connection.
105
- - **Step card** — the box that draws one step on the canvas. It shows the step's name, the one-line summary the step's type works out from its settings under the name when the type declares one, and the step's type code under those, or above the name on a left-to-right canvas. A step with problems is bordered in red and its card counts them under the name, such as "1 error" or "2 errors", in place of the summary, and the sentence for each problem is in the flow panel's list of problems rather than on the card.
105
+ - **Step card** — the box that draws one step on the canvas. It shows the step's name, the one-line summary the step's type works out from its settings under the name when the type declares one, and the step's type code under those, or above the name on a left-to-right canvas. A step with problems is bordered in red and its card counts them under the name, such as "1 error" or "2 errors", in place of the summary, and the sentence for each problem is in the Validation tab of the drawer under the canvas rather than on the card.
106
106
  - **Hidden step type codes** — a setting a host may turn on, `hide_step_type_codes`, that hides step type code names on its canvas. The add menu lists each step type by its name alone, and a step's box shows its step type's name in place of the code name, with a step that has no name of its own headed by its step type's name. It is off by default, and with it off the add menu and step boxes show the code names. The settings panel shows a step's id and code name either way.
107
107
  - **Canvas direction** — a setting a host may set, `canvas_direction`, to `:left_to_right` to lay its canvas out left to right in place of top to bottom. Steps sit as compact cards in rows joined by short lines, a row that reaches the edge of the canvas goes on in a new row, each branch or loop that leads anywhere but the step beside it is written on its step's card with the step it leads to, a group step's box takes a row of its own, and a phone-width screen shows one step per row. Top to bottom is the default.
108
108
  - **Step list** — a list beside the editing canvas, on screens 640 pixels and wider, of every step type the host offers, with a search field that keeps only the types whose name holds what was typed. A host may set `step_groups`, a hash of headings each with the step types listed under it, in the host's order, and the types it puts in no group are listed above the first heading. Clicking a type adds the step unconnected, as the add menu does, and dragging a type onto a connection inserts the step on that connection. On a phone the list is hidden and the add menu is the way to add steps.
@@ -113,7 +113,9 @@ easy_flow declares no commands of its own for this local. Its surface is split b
113
113
  - **Editor buttons** — a setting a host may set, `editor_buttons`, holding a list of buttons each with a label and an address, or a callable that takes the flow being shown and returns that list, whose buttons the top bar shows before `Save draft`, such as Run tests and Dry-run. The app decides what each address does. With none set, the bar shows no extra buttons.
114
114
  - **On publish** — a setting a host may set, `on_publish`, holding a callable that takes a flow. easy_flow calls it each time a new version of one of that host's flows goes live, from the canvas's Publish button or from the app calling publish. Publishing a version that is already live does not call it. With none set, nothing is called.
115
115
  - **Host setting explanations** — a setting a host may set, `setting_explanations`, giving its own explanation for one setting of one step type, including a setting inside a list. It shows in place of the step type's own. A setting it gives none for shows the step type's own, and with none set nothing changes.
116
- - **Flow panel** — the panel the top bar's `This flow`, `Save draft` and `Publish` buttons open on the canvas, on every host. It shows Create version and Publish above its lists of problems and changes. Each problem is a sentence naming the step by its name, or by its step type's name when it has none, never by its id, and saying what to do to clear it. Several saves to the same step in a row show as one line in the changes list, named by the step's latest name. A save, a move and any other change each keep their own line, and the history of versions still lists every change a version captured.
116
+ - **Flow panel** — the panel the top bar's `This flow`, `Save draft` and `Publish` buttons open on the canvas, on every host. It shows Create version and Publish, the message saying what the last of them did or why it was refused, and the list of changes since the last version. Several saves to the same step in a row show as one line in the changes list, named by the step's latest name. A save, a move and any other change each keep their own line, and the history of versions still lists every change a version captured.
117
+ - **Drawer** — the panel under the editing canvas, on every host, with a row of tabs. Its first tab is Validation, followed by the number of problems the flow has when it has any. Validation lists one row per check: an `error` row for each problem with the step's id and a sentence naming the step by its name, or by its step type's name when it has none, and saying what to do to clear it, then an `ok` row for each check that found nothing. Clicking a row that names a step selects that step and opens its settings. A host may set `drawer_tabs` to add its own tabs after Validation, each with a label, an optional count such as `12/12` and its own content. On a phone the drawer shows only its tabs until one is tapped, an open drawer covers the canvas, and tapping the open tab again closes it.
118
+ - **Step settings panel** — the panel on the right of the canvas that opens when a step is selected. It is 320 pixels wide and shows the step's id and type, its name, its editable settings, then the read-only sections its step type declares with `shows_values` and `shows_code`, and at its foot the buttons the type declares with `links_to` above Delete step. On a phone it covers the canvas from edge to edge.
117
119
  - **Picture mark** — the words `Has a picture` on the box of a step with a picture on the canvas, on every host.
118
120
  - **Palette** — the step types an admin can add on a host's canvas. It never holds the start step, always holds the end step, and otherwise holds the step types the host offers. A step already in a flow whose type the host does not offer is still drawn and run, and still opens with all its settings and can be saved.
119
121
  - **Run** — one visitor's pass through a flow. A run may belong to one of the app's own records, its owner, which the app sets. A run is pinned to the version it started on, so publishing a new version does not change a run already under way. A run starts on the live version unless the app chooses another of the flow's published versions. A run is refused when the chosen version is a draft, is retired or withdrawn, or belongs to another flow. It records each visit, and going back discards the last visit on the path.
@@ -66,6 +66,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
66
66
  - `publish_note` — a sentence shown directly under the Publish button in this host's flow panel. It is shown as plain text. With none set, the panel shows no note.
67
67
  - `back_link` — a hash with a `label` and an `address`, such as `{ label: "Games", address: "/admin/games" }`, that shows a link with that label and address at the start of this host's editor top bar in place of `All flows`. The bar then has no `All flows` link. A hash missing either key raises `ArgumentError` when the host is declared, and a blank value is not refused. The address is used as written and is not checked, so it comes from the app's own configuration and never from a request. It may instead be a callable that takes the flow being shown and returns that hash, such as `->(flow) { { label: "Funnel", address: "/funnels/#{flow.owner_id}" } }`, so each flow's canvas links to a page of its own, such as its owner record's page. A returned hash missing either key raises `ArgumentError` when that flow's canvas is opened. With none set, the bar shows `All flows`.
68
68
  - `editor_buttons` — a list of hashes each with a `label` and an `address`, such as `[ { label: "Run tests", address: "/admin/flow_tests" }, { label: "Dry-run", address: "/admin/dry_runs" } ]`, shown as buttons in this host's editor top bar before `Save draft`, on the canvas and on the definition text page. On a phone they are reached from the bar's actions menu. It may instead be a callable that takes the flow being shown and returns that list, such as `->(flow) { [ { label: "Run tests", address: "/admin/flow_tests/#{flow.slug}" } ] }`, so each flow's buttons lead to pages of its own. A hash missing either key raises `ArgumentError` when the canvas is opened. Each address is used as written, so it comes from the app's own configuration and never from a request. The app decides what each address does. With none set, the bar shows no extra buttons. Ask the developer which buttons each host's editor needs.
69
+ - `drawer_tabs` — a list of hashes each with a `label`, an optional `count` and its `content` as HTML, such as `[ { label: "Fixtures", count: "12/12", content: "<p>12 of 12 fixtures pass.</p>" }, { label: "Dry-run", content: "<p>No dry-run yet.</p>" } ]`, shown as tabs after Validation in the drawer under this host's canvas. The count is written after the label, and a tab with no count shows only its label. It may instead be a callable that takes the flow being edited and returns that list, such as `->(flow) { [ { label: "Fixtures", count: FixtureRun.score(flow), content: ApplicationController.render(partial: "flows/fixtures", locals: { flow: flow }) } ] }`. The content is put on the page as given, so it is built by the app and any value from a record in it is escaped. The list is worked out each time the canvas is drawn, so a slow lookup slows the canvas. A hash missing `label` or `content` raises `ArgumentError` when the canvas is opened. With none set, the drawer shows only Validation. Ask the developer which tabs each host's drawer needs and what each shows.
69
70
  - `on_publish` — a callable that takes a flow, such as `->(flow) { RecountJob.perform_later(flow.id) }`, that easy_flow calls each time a new version of one of this host's flows goes live, whether an admin pressed Publish on the canvas or the app called `publish` on the flow. It runs inside the publish request, so slow work belongs in a job it starts. Publishing a version that is already live does not call it. With none set, nothing is called. Ask the developer what the app must do when a flow goes live.
70
71
  - `setting_explanations` — this host's own explanations for step type settings, as a hash of step type name to setting name to a sentence, such as `{ multiple_select: { category: "The round this question counts toward.", "answers.weight" => "Points this answer adds to the score." } }`. A setting inside a list is named by the list and the setting joined with a dot, and a list setting's own explanation is named by the list alone. The sentence is shown as plain text under the setting in the step's settings, in place of the step type's own. A setting with none, or with a blank one, shows the step type's own, if it has one. A step type or setting name that matches nothing is ignored. A value that is not text, such as a nested hash, raises `ArgumentError` when the host is declared. With none set, every setting shows the step type's own explanation.
71
72
 
@@ -169,6 +170,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
169
170
  - A page of the app that calls `easy_flow_run_view` needs the `keystone_ui/react` and `easy_flow/canvas` scripts in its head, the same two the canvas page loads. The helper needs no setting in the initializer, and it is available in every view of the app. After adding one, check that the page shows each step's card with the state and status line the app supplied, and that a phone-width screen shows one card per row.
170
171
  - After setting `step_groups` on a host, check that its canvas shows the step list beside the canvas with each step type under its heading, that typing in its search field narrows the list, that clicking a type adds an unconnected step, that dragging a type onto a connection inserts it there, and that a phone-width screen shows no step list.
171
172
  - After setting `editor_buttons` on a host, check that its canvas's top bar shows each button between `Try it` and `Save draft` with the label given, that each opens its address, and that on a phone-width screen the buttons are listed in the bar's actions menu.
173
+ - After setting `drawer_tabs` on a host, check that the drawer under its canvas shows each tab after Validation with its count, that choosing a tab shows its content, and that on a phone-width screen the drawer shows only its tabs until one is tapped.
172
174
  - Every stored run keeps each step's value together with the time the step was completed. An app upgrading from a version that kept values alone runs `bin/rails easy_flow:install:migrations` and `bin/rails db:migrate` before any stored run takes an answer. The migration wraps each value its existing runs already hold, and those values carry no completion time. Running the migration back drops every completion time.
173
175
  - After install, check that a Compare step, a Compare two values step, or a comparison of an All of or Any of step, once its earlier step is picked, offers "Hour completed", "Weekday completed" and "Minutes since 1970 when completed" beside that step's own outputs. They need no setting in the initializer.
174
176
  - After install, check that a Wait step placed on the canvas asks for the earlier step it counts from, minutes after it, a time of day as HH:MM and a date as YYYY-MM-DD. It needs no migration beyond the one that keeps each step's completion time with its value and no setting in the initializer beyond being listed in a host's `offers` when that host sets `offers`.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.47.0
4
+ version: 0.49.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -82,6 +82,8 @@ files:
82
82
  - app/javascript/easy_flow/canvas/Connector.jsx
83
83
  - app/javascript/easy_flow/canvas/ConnectorLayer.jsx
84
84
  - app/javascript/easy_flow/canvas/Control.jsx
85
+ - app/javascript/easy_flow/canvas/Details.jsx
86
+ - app/javascript/easy_flow/canvas/Drawer.jsx
85
87
  - app/javascript/easy_flow/canvas/Explanation.jsx
86
88
  - app/javascript/easy_flow/canvas/GroupBox.jsx
87
89
  - app/javascript/easy_flow/canvas/GroupHeader.jsx
@@ -116,6 +118,7 @@ files:
116
118
  - app/models/easy_flow/asked.rb
117
119
  - app/models/easy_flow/canvas.rb
118
120
  - app/models/easy_flow/change.rb
121
+ - app/models/easy_flow/check_list.rb
119
122
  - app/models/easy_flow/choice.rb
120
123
  - app/models/easy_flow/chosen_flow.rb
121
124
  - app/models/easy_flow/compare.rb
@@ -152,6 +155,8 @@ files:
152
155
  - app/models/easy_flow/step.rb
153
156
  - app/models/easy_flow/step_type.rb
154
157
  - app/models/easy_flow/step_type/declaration.rb
158
+ - app/models/easy_flow/step_type/shown_code.rb
159
+ - app/models/easy_flow/step_type/shown_values.rb
155
160
  - app/models/easy_flow/steps/checklist.rb
156
161
  - app/models/easy_flow/steps/file_upload.rb
157
162
  - app/models/easy_flow/steps/fill_in_the_blank.rb