@squeed/flow-sdk 2.0.44 → 2.0.45

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.
package/dist/index.cjs CHANGED
@@ -206,7 +206,7 @@
206
206
  font-size: 14px;
207
207
  margin-top: 8px;
208
208
  }
209
- `;function Ku({request:e,property:r,config:t,value:n,disabled:o}){var he,U,re,fe,we;const{callbacks:i,structured:s,references:a}=j.useContext($t),{themeColor:c}=He(),{background:l}=at(),d=j.useId(),u=r.type.kind==="object"||r.type.kind==="array"||r.type.kind==="json",h=n===void 0?"":u?JSON.stringify(n,null,2):String(n),[p,m]=j.useState(h),[g,y]=j.useState(""),[b,v]=j.useState(0),w=j.useRef(null),x=j.useRef(),[C,S]=j.useState(!1),[E,R]=j.useState(!1),[P,I]=j.useState(),M=((he=t.$options)==null?void 0:he.$source)==="callback",k=i.resolveFormOptions,{data:_,address:N,nodeAddress:O,nodeId:V}=e;j.useEffect(()=>(S(!1),R(!1),()=>{var ie;(ie=x.current)==null||ie.abort(),x.current=void 0}),[N,O,V,o,h,t.$control,(U=t.$upload)==null?void 0:U.accept,(re=t.$upload)==null?void 0:re.maxSizeBytes]);const T=j.useRef(_);T.current=_;const Z=JSON.stringify([N,V,(fe=t.$options)!=null&&fe.$dependsOn?t.$options.$dependsOn.map(ie=>Oe(_,ie)):Oe(_,O)]);j.useEffect(()=>{m(h),y("")},[h,N,V]),j.useEffect(()=>{if(!M)return;const ie=new AbortController;return Promise.resolve().then(()=>{if(!k)throw new Error("No options resolver configured");return k({address:N,nodeAddress:O,nodeId:V,data:an(T.current),signal:ie.signal})}).then(Ce=>{if(!Array.isArray(Ce)||Ce.some($e=>!$e||typeof $e.label!="string"||!["string","number","boolean"].includes(typeof $e.value)&&$e.value!==null))throw new Error("Invalid options response");ie.signal.aborted||I({key:Z,options:Ce})}).catch(Ce=>{ie.signal.aborted||I({key:Z,options:[],error:Ce instanceof Error?Ce.message:"Options unavailable"})}),()=>ie.abort()},[M,k,Z,N,O,V,b]);const ue=M&&(P==null?void 0:P.key)!==Z,K=M?(P==null?void 0:P.key)===Z?P.options:[]:r.type.kind==="null"?[{label:"Null",value:null}]:r.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:On(r.type),ee=r.type.kind==="array",H=(t.$control==="upload"?"upload":s&&u||t.$control==="checkbox"?"pills":t.$control)??(K?ee||r.type.kind==="boolean"?"pills":"select":r.type.kind==="boolean"?"checkbox":u?"textarea":"input"),ae=!r.optional||!!t.$requiredWhen&&Eo(t.$requiredWhen,_),q=ae?"Required":"Optional",D=H!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),G=g||M&&(P==null?void 0:P.key)===Z&&P.error||!D&&Jt(r.type,n,ae),B=Dt(t.$label??N.split(".").pop()),se=ie=>{var Ce;if(!(o||Object.is(ie,n)))try{(Ce=i.onFormChange)==null||Ce.call(i,{...e,previousValue:n,value:ie}),y("")}catch($e){y($e instanceof Error?$e.message:"Unable to update field")}},te=j.useRef(se);j.useLayoutEffect(()=>{te.current=se});const le=()=>{if(u){try{const Ue=p===""&&r.optional?void 0:JSON.parse(p),Ve=Jt(r.type,Ue,ae);if(Ve){y(Ve);return}se(Ue)}catch{y("Enter valid JSON")}return}const ie=r.type.kind==="number"||r.type.kind==="integer",Ce=p===""&&r.optional?void 0:ie&&p!==""?Number(p):p,$e=Jt(r.type,Ce,ae);if(ie&&$e&&p!==""){y($e);return}se(Ce)},ne=async ie=>{var $e,Ue,Ve;if(o||x.current||!ie.length)return;const Ce=new AbortController;x.current=Ce,y(""),S(!0);try{if(r.type.kind!=="string"&&!(r.type.kind==="array"&&r.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!ee&&ie.length!==1)throw new Error("Choose one file for this field.");if(!i.uploadFormFile)throw new Error("No file upload handler configured.");const tt=(Ue=($e=t.$upload)==null?void 0:$e.accept)==null?void 0:Ue.split(",").map(be=>be.trim().toLowerCase()).filter(Boolean);for(const be of ie){if(((Ve=t.$upload)==null?void 0:Ve.maxSizeBytes)!==void 0&&be.size>t.$upload.maxSizeBytes)throw new Error(`${be.name} exceeds the file size limit.`);if(tt!=null&&tt.length&&!tt.some(Xe=>Xe.startsWith(".")?be.name.toLowerCase().endsWith(Xe):Xe.endsWith("/*")?be.type.toLowerCase().startsWith(Xe.slice(0,-1)):be.type.toLowerCase()===Xe))throw new Error(`${be.name} is not an accepted file type.`)}const ye=await Promise.all(ie.map(async be=>{const Xe=await i.uploadFormFile({...e,data:an(_),file:be,signal:Ce.signal});if(typeof Xe!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let ut;try{ut=new URL(Xe)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(ut.protocol)||ut.username||ut.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return Xe}));if(Ce.signal.aborted||x.current!==Ce)return;const Ae=ee?[...Array.isArray(n)?n:[],...ye]:ye[0],Le=Jt(r.type,Ae,ae);if(Le)throw new Error(Le);te.current(Ae)}catch(tt){Ce.signal.aborted||y(tt instanceof Error?tt.message:"Unable to upload file."),Ce.abort()}finally{x.current===Ce&&(x.current=void 0,S(!1))}},ce={id:d,disabled:o,"aria-label":B,"aria-required":ae,"aria-invalid":!!G,"aria-describedby":G?`${d}-error`:void 0},xe=Te(c);return f.jsxs("div",{"data-form-field":N,"data-flow-property":N.slice(O.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:d,children:[B,ae?" *":""]}),r.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${B}`,title:`Reset ${B}`,disabled:o||C,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>se(void 0),children:f.jsx(Q.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!u&&H!=="upload"&&f.jsx(Vw,{label:B,value:n,references:a,disabled:o,onChange:se}),H==="upload"?f.jsxs("div",{"data-form-upload":ee?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":Te(l),outline:E?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:ie=>{ie.preventDefault(),ie.stopPropagation(),!o&&!C&&(ie.dataTransfer.dropEffect="copy",R(!0))},onDragLeave:ie=>{ie.currentTarget.contains(ie.relatedTarget)||R(!1)},onDrop:ie=>{ie.preventDefault(),ie.stopPropagation(),R(!1),ne(Array.from(ie.dataTransfer.files))},children:[f.jsx("input",{ref:w,type:"file",hidden:!0,"aria-label":`Upload ${B}`,accept:(we=t.$upload)==null?void 0:we.accept,multiple:ee,disabled:o||C,onChange:ie=>{const Ce=Array.from(ie.target.files??[]);ie.target.value="",ne(Ce)}}),f.jsxs("div",{"data-upload-items":"",children:[(ee?Array.isArray(n)?n:[]:n?[n]:[]).map((ie,Ce)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof ie=="string"&&wr(ie)&&f.jsxs("a",{href:ie,target:"_blank",rel:"noopener noreferrer","aria-label":`${B} file ${Ce+1}`,children:[f.jsx(Q.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(cr,{name:ie,size:120,onError:$e=>{$e.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!ee&&f.jsx(Ne,{"aria-label":`Replace ${B}`,title:`Replace ${B}`,icon:f.jsx(Q.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>{var $e;return($e=w.current)==null?void 0:$e.click()}}),f.jsx(Ne,{"aria-label":`Remove ${B} file ${Ce+1}`,title:"Remove file",icon:f.jsx(Q.PiTrash,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>se(ee&&Array.isArray(n)?n.filter(($e,Ue)=>Ue!==Ce):"")})]})]},`${Ce}:${ie}`)),(ee||!n)&&f.jsx("button",{...ce,type:"button","data-upload-drop":"",title:`Upload ${B}`,disabled:o||C,onClick:()=>{var ie;return(ie=w.current)==null?void 0:ie.click()},children:f.jsx(Q.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):D?null:H==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(It,{...ce,disabled:o||ue||!!(P!=null&&P.error),labelCase:"preserve",value:String((K==null?void 0:K.findIndex(ie=>Object.is(ie.value,n)))??-1),onValueChange:ie=>{const Ce=K==null?void 0:K[Number(ie)];Ce&&se(Ce.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):q}),K==null?void 0:K.map((ie,Ce)=>f.jsx("option",{value:Ce,...ie.description?{description:ie.description}:{},children:Dt(ie.label)||ie.label},Ce))]})}):H==="pills"?f.jsxs("div",{id:d,role:"group","aria-label":B,"aria-describedby":ce["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[K==null?void 0:K.map((ie,Ce)=>{const $e=ee?Array.isArray(n)&&n.includes(ie.value):Object.is(n,ie.value);return f.jsx("button",{type:"button",disabled:o||ue,"aria-pressed":$e,style:{padding:"8px 16px",borderRadius:24,border:0,color:$e?xe:"inherit",background:$e?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>se(ee?$e?n.filter(Ue=>Ue!==ie.value):[...Array.isArray(n)?n:[],ie.value]:ie.value),children:Dt(ie.label)||ie.label},Ce)}),ue&&f.jsx("span",{role:"status",children:"Loading..."})]}):H==="textarea"?f.jsx("textarea",{...ce,placeholder:q,value:p,onChange:ie=>m(ie.target.value),onBlur:le}):f.jsx("input",{...ce,placeholder:q,type:r.type.kind==="number"||r.type.kind==="integer"?"number":"text",step:r.type.kind==="integer"?1:"any",value:p,onChange:ie=>m(ie.target.value),onBlur:le,onKeyDown:ie=>{ie.key==="Enter"&&le(),ie.key==="Escape"&&m(n===void 0?"":String(n))}}),G&&f.jsx("div",{role:"alert",id:`${d}-error`,children:G}),M&&(P==null?void 0:P.error)&&f.jsx("button",{type:"button",disabled:o,onClick:()=>{I(void 0),v(b+1)},children:"Retry"})]})}function Vd({nodeAddress:e,structured:r=!1}){return r?f.jsx(Hw,{nodeAddress:e},e):f.jsx(Ed,{nodeAddress:e})}function Hw({nodeAddress:e}){var u,h,p;const r=j.useContext($t),[t,n]=j.useState([]),o=((u=r.structured)==null?void 0:u.sourceSchema)??r.schema,i=((h=r.structured)==null?void 0:h.sourceBindings)??r.bindings,s=j.useMemo(()=>{if(!(!r.data||!o||!i))return kb(r.data,i,o,[{data:{id:e,type:"objectView"}}])},[r.data,i,o,e]);if(!s)return f.jsx(Ed,{nodeAddress:e});const a=t.findIndex(m=>!s.containers.has(m)),c=a<0?t:t.slice(0,a),l=c.at(-1)??e,d=(p=[...s.slots.values()].find(m=>m.nodeId===l))==null?void 0:p.label;return f.jsxs($t.Provider,{value:{...r,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:l===e?r.onFieldCreate:void 0},children:[!!c.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Ne,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(Q.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(c.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:Dt(d)})]}),f.jsx(Ed,{nodeAddress:l,onOpen:m=>n([...c,m])},l)]})}function Ed({nodeAddress:e,onOpen:r}){var S,E;const{data:t,schema:n,callbacks:o,bindings:i,editable:s,renderForm:a,structured:c}=j.useContext($t),{readOnly:l,config:d,colorMode:u}=He(),h=a==null?void 0:a(e);if(h!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:l||d.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:h});if(!t)return f.jsx(no,{$colorMode:u,role:"alert",children:"Forms require a JSON document."});const p=i?Hn(i,e,n):void 0,m=i?p:n&&un(t,e,n);if(!m)return f.jsx(no,{$colorMode:u,role:"status",children:"Form schema unavailable."});const g=(p==null?void 0:p.address)??e,y=Oe(t,g),b=(S=c==null?void 0:c.containers.get(e))==null?void 0:S.scalar;if(y===void 0||typeof y!="object"&&!b)return f.jsx(no,{$colorMode:u,role:"alert",children:"Bound form state is unavailable."});const v=Object.entries(m.type.properties).filter(([R])=>{var P;return Eo((P=m.fields[R])==null?void 0:P.$visibleWhen,t)}),w=v.length>8||v.some(([R])=>{var P;return(P=m.fields[R])==null?void 0:P.$section}),x=new Map;for(const R of v){const[P,I]=R,M=w?Dt(((E=m.fields[P])==null?void 0:E.$section)??(I.type.kind==="object"||I.type.kind==="array"?P:I.optional?"Options":"General")):"";x.has(M)||x.set(M,[]),x.get(M).push(R)}const C=([R,P])=>f.jsx(Ku,{request:{data:t,address:b?g:`${g}.${R}`,nodeAddress:g,nodeId:typeof(y==null?void 0:y.id)=="string"?y.id:void 0},property:P,config:m.fields[R]??{},value:b?y:y==null?void 0:y[R],disabled:l||d.editable===!1||!(s??!!o.onJsonChange)},`${(y==null?void 0:y.id)??e}:${R}`);return f.jsxs(no,{$colorMode:u,"data-flow-form":e,onClick:R=>R.stopPropagation(),onDoubleClick:R=>R.stopPropagation(),children:[c&&f.jsx(Gw,{nodeAddress:e,onOpen:r}),!c&&p&&m.type.additionalProperties&&v.length===0&&f.jsx(Ku,{request:{data:t,address:g,nodeAddress:g},property:{type:m.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:y,disabled:l||d.editable===!1||!s}),[...x].map(([R,P])=>w&&P.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:R}),f.jsx(Q.PiCaretDown,{size:16,"aria-hidden":"true"})]}),P.map(C)]},R):P.map(C))]})}function Ab(e){const{viewData:r}=j.useContext($t),{nodeById:t,edgeById:n,parentIds:o}=Xt();if(r){const i=Oe(r,e),s=i&&typeof i=="object"&&!Array.isArray(i)&&"$"in i?i.$:i;return Array.isArray(s)?s.length>0:!!s&&typeof s=="object"&&Object.entries(s).some(([a,c])=>!a.startsWith("$")&&c!==null&&typeof c=="object")}return o.has(e)?!0:[...n.values()].some(({data:i})=>{const s=i.isInverted?i.target:i.source,a=i.isInverted?i.source:i.target;return s===e&&a!==e&&t.has(a)})}function Dn(e,r){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:r}function Wn(e,r,t,n){return{borderColor:r,borderWidth:Dn(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...gb(r==="transparent"?"currentColor":r,t,".flow-sdk-node:hover &",!t)}}function Rb({label:e,value:r,options:t,onChange:n,disabled:o}){var i;return f.jsxs(It,{"aria-label":e,title:`Animation: ${((i=t.find(s=>s.value===r))==null?void 0:i.label)??"Mixed"}`,value:r,style:{width:104},disabled:o,onValueChange:s=>{const a=t.find(c=>c.value===s);a&&n(a.value)},children:[r===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),t.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function Gd({nodeId:e,edgeId:r,value:t,open:n,onOpenChange:o}){const{callbacks:i,readOnly:s,themeColor:a,colorMode:c}=He(),{background:l,backgroundSecondary:d,border:u,colorText:h,colorInactive:p}=at(),m=c==="dark"?ln:Te(p),g=j.useRef(null),y=j.useRef(null),b=j.useRef(0),[v,w]=j.useState(!1),[x,C]=j.useState("icons"),[S,E]=j.useState([]),[R,P]=j.useState("loading"),[I,M]=j.useState(""),[k,_]=j.useState(0),[N,O]=j.useState(""),[V,T]=j.useState(""),[Z,ue]=j.useState(!1);j.useEffect(()=>()=>{b.current++},[]),j.useEffect(()=>{if(!v)return;let B=!0;return import("react-icons/pi").then(se=>{B&&(E(Object.keys(se).filter(te=>te.startsWith("Pi")).sort()),P("ready"))}).catch(()=>{B&&P("unavailable")}),()=>{B=!1}},[v]),j.useEffect(()=>{var B;s&&((B=g.current)==null||B.close())},[s]),j.useEffect(()=>{var B,se,te;if(n!==void 0){if(!n||s){(B=g.current)==null||B.close();return}(se=g.current)!=null&&se.open||(T(""),C(t==="PiFileSvg"||t&&wr(t)?"custom":"icons"),O(t&&!t.startsWith($n)&&wr(t)?t:""),w(!0),(te=g.current)==null||te.showModal())}},[n,s,t]);const K=B=>{var se,te,le;s||(r?(se=i.onEdgeIconChange)==null||se.call(i,r,B):e&&((te=i.onNodeIconChange)==null||te.call(i,e,B)),o==null||o(!1),(le=g.current)==null||le.close())},ee=S.filter(B=>B.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(I.trim().toLowerCase())),H=36,ae=Math.max(1,Math.ceil(ee.length/H)),q=Math.min(k,ae-1),D=ee.slice(q*H,(q+1)*H),G={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${Te(u)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(Ge,{label:r?"Choose edge icon":"Choose node icon",children:f.jsx(Ne,{"aria-label":r?"Choose edge icon":"Choose node icon",icon:f.jsx(Q.PiShapes,{size:20}),size:"sm",variant:"ghost",color:Te(a),disabled:s,onClick:()=>{var B;T(""),C(t&&wr(t)?"custom":"icons"),O(t&&!t.startsWith($n)&&wr(t)?t:""),w(!0),(B=g.current)==null||B.showModal()}})}),f.jsx(W.chakra.dialog,{ref:g,"aria-label":r?"Choose edge icon":"Choose node icon",css:gr(Te(l),Te(u)),onClose:()=>{w(!1),o==null||o(!1),b.current++,ue(!1)},onClick:B=>{B.stopPropagation(),B.target===B.currentTarget&&B.currentTarget.close()},onKeyDown:B=>B.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:Te(l),color:Te(h)},children:v&&f.jsxs("div",{style:{display:"grid",gap:8},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsx("strong",{children:r?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[t&&f.jsx(Ge,{label:"Remove icon",children:f.jsx(Ne,{"aria-label":r?"Remove edge icon":"Remove node icon",icon:f.jsx(Q.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||Z,onClick:()=>K("")})}),f.jsx(dn,{"aria-label":"Close icon picker",onClick:()=>{var B;return(B=g.current)==null?void 0:B.close()}})]})]}),f.jsxs(W.Tabs.Root,{value:x,onValueChange:({value:B})=>{C(B),T("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(W.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(B=>f.jsx(W.Tabs.Trigger,{value:B,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:m,"--indicator-color":m},children:B==="icons"?"React icons":"Custom SVG"},B))}),f.jsx("input",{ref:y,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:Z||s,onChange:async B=>{var le;const se=(le=B.target.files)==null?void 0:le[0];if(B.target.value="",!se)return;const te=++b.current;ue(!0),T("");try{const ne=await $w(se);te===b.current&&K(ne)}catch(ne){te===b.current&&T(ne instanceof Error?ne.message:"Unable to read SVG.")}finally{te===b.current&&ue(!1)}}}),f.jsx(W.Tabs.Content,{value:x,p:0,style:{display:"grid",gap:8},children:x==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:I,onChange:B=>{M(B.target.value),_(0)},style:G}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[D.map(B=>f.jsx("button",{type:"button","aria-label":`Choose ${B}`,"aria-pressed":t===B,title:B,onClick:()=>K(B),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${t===B?2:1}px solid ${Te(t===B?a:u)}`,background:Te(t===B?l:d),color:"inherit",cursor:"pointer"},children:f.jsx(cr,{name:B,size:24})},B)),D.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:R==="loading"?"Loading icons...":R==="unavailable"?"React icons unavailable":"No icons found"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsxs("span",{role:"status",style:{fontSize:12},children:[ee.length," icons · ",q+1," / ",ae]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(Ge,{label:"Previous icons",children:f.jsx(Ne,{"aria-label":"Previous icons",icon:f.jsx(Q.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:q===0,onClick:()=>_(q-1)})}),f.jsx(Ge,{label:"Next icons",children:f.jsx(Ne,{"aria-label":"Next icons",icon:f.jsx(Q.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:q+1>=ae,onClick:()=>_(q+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[t&&wr(t)&&f.jsx(cr,{name:t,size:64}),f.jsxs("button",{type:"button",disabled:Z||s,onClick:()=>{var B;return(B=y.current)==null?void 0:B.click()},style:{...G,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(Q.PiUploadSimple,{}),Z?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:B=>{B.preventDefault(),!(Z||s)&&(!wr(N.trim())||N.trim().startsWith($n)?T("Enter an HTTP or HTTPS image URL."):K(N.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:N,disabled:Z||s,onChange:B=>O(B.target.value),style:{...G,flex:1,minWidth:0}}),f.jsx(Ge,{label:"Apply URL",children:f.jsx(Ne,{type:"submit","aria-label":"Apply URL",icon:f.jsx(Q.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:Z||s||!N.trim(),style:{flexShrink:0}})})]})]})})]}),V&&f.jsx("div",{role:"alert",style:{fontSize:13},children:V})]})})]})}const po=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",ln],Mb=["gray.900",ln,"gray.600","gray.200","white"];function Tb(){const{config:e}=He(),r=e.selectionToolbar||{},t=new Set(r.hide||[]);return{palette:r.palette||po,show:n=>!t.has(n)}}function Tt(){const{border:e}=at();return f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:e})}function Er({value:e,placeholder:r,ariaLabel:t,width:n="140px",type:o="text",min:i,disabled:s=!1,onCommit:a}){const{colorText:c}=at(),[l,d]=j.useState(e),u=j.useRef(!1);j.useEffect(()=>d(e),[e]);const h=()=>{if(s||u.current)return;u.current=!0;const p=l.trim();if(o==="number"&&p!==""&&(!Number.isFinite(Number(p))||Number(p)<(i??0))){d(e);return}p!==e&&a(p)};return f.jsx(W.Input,{"aria-label":t,type:o,min:i,disabled:s,size:"xs",fontSize:"16px",w:n,value:l,placeholder:r,color:c,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{u.current=!1},onChange:p=>d(p.target.value),onBlur:h,onKeyDown:p=>{p.key==="Enter"&&(h(),p.target.blur()),p.key==="Escape"&&(u.current=!0,d(e),p.target.blur())}})}function Vr({colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:s,colorText:a}=at(),[c,l]=j.useState(!1),d=j.useId(),u=j.useRef(null),h=r??e[0]??"transparent",p=jo(f.jsx(Vr,{colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i}));return f.jsx(nn.Provider,{value:null,children:f.jsxs(W.HStack,{gap:1,"aria-label":t,role:"group",onClickCapture:p,onKeyDown:m=>{var g;m.key==="Escape"&&(l(!1),(g=u.current)==null||g.focus())},children:[f.jsx(Ge,{label:`${t}: ${h}`,children:f.jsx(W.chakra.button,{ref:u,type:"button","aria-label":`${t} colors`,"aria-expanded":c,"aria-controls":d,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Te(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${Te(a)}`,outlineOffset:"1px",onClick:()=>l(m=>!m)})}),c&&f.jsxs(W.HStack,{id:d,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(m=>{const g=r===m;return f.jsx(Ge,{label:`${t}: ${m}`,children:f.jsx(W.Box,{as:"button","aria-label":`${t} ${m}`,"aria-pressed":g,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Te(m),...m==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:g?`2px solid ${Te(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(m),onDoubleClick:y=>{var b;y.stopPropagation(),l(!1),(b=u.current)==null||b.focus()}})},m)}),o&&f.jsx(Ge,{label:`Reset ${t.toLowerCase()}`,children:f.jsx(Ne,{"aria-label":`Reset ${t}`,icon:f.jsx(W.Icon,{as:Q.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var m;o(),l(!1),(m=u.current)==null||m.focus()}})})]})]})})}function Ib({edgeId:e,onClose:r}){var p;const{callbacks:t,themeColor:n,config:o}=He(),{colorInactive:i}=at(),{edgeById:s}=Xt(),{palette:a,show:c}=Tb(),l=(p=s.get(e))==null?void 0:p.data,d=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...l!=null&&l.type?[l.type]:[]])],u=l!=null&&l.isEdgeAnimated?"animated":l!=null&&l.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:Q.PiLineSegment,label:"Solid"},{key:"dashed",icon:Q.PiLineSegments,label:"Dashed"},{key:"animated",icon:Q.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(dn,{onClick:r}),c("label")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Er,{ariaLabel:"Edge label",placeholder:"Edge label",value:(l==null?void 0:l.label)||"",onCommit:m=>{var g;return(g=t.onEdgeLabelChange)==null?void 0:g.call(t,e,m)}})]}),c("style")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),h.map(m=>f.jsx(Ge,{label:m.label,children:f.jsx(Ne,{"aria-label":`Edge style ${m.key}`,"aria-pressed":u===m.key,icon:f.jsx(W.Icon,{as:m.icon,boxSize:5}),size:"sm",variant:"ghost",color:u===m.key?n:i,onClick:()=>{var g;return(g=t.onEdgeStyleChange)==null?void 0:g.call(t,e,m.key)}})},m.key)),u==="animated"&&f.jsx(Rb,{label:"Edge animation",value:(l==null?void 0:l.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:m=>{var g;return(g=t.onEdgeAnimationVariantChange)==null?void 0:g.call(t,e,m)}}),f.jsxs(It,{"aria-label":"Edge shape",title:`Edge shape: ${(l==null?void 0:l.type)??"Default"}`,icon:f.jsx(Q.PiBezierCurve,{size:20}),style:{width:36},value:(l==null?void 0:l.type)??"",disabled:o.readOnly,onValueChange:m=>{var g;return(g=t.onEdgeTypeChange)==null?void 0:g.call(t,e,m||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),d.map(m=>f.jsx("option",{value:m,children:m},m))]})]}),c("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Gd,{edgeId:e,value:l==null?void 0:l.icon},e),f.jsx(Er,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(l==null?void 0:l.icon)??"",onCommit:m=>{var g;return(g=t.onEdgeIconChange)==null?void 0:g.call(t,e,m)}})]}),c("color")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Vr,{label:"Edge color",colors:a,value:l==null?void 0:l.color,onPick:m=>{var g;return(g=t.onEdgeColorChange)==null?void 0:g.call(t,e,m)},onReset:()=>{var m;return(m=t.onEdgeColorChange)==null?void 0:m.call(t,e,"")}})]}),c("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:"Delete edge",children:f.jsx(Ne,{"aria-label":"Delete edge",icon:f.jsx(W.Icon,{as:Q.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var m;(m=t.onEdgeDelete)==null||m.call(t,e,l),r()}})})]})]})}function Nb({ids:e,showDivider:r=!0}){const{callbacks:t,config:n,nodeGridOptions:o,fillRadiusEditedIds:i}=He(),{colorInactive:s}=at(),{nodeById:a}=Xt(),[c,l]=j.useState(!1),d=e.map(y=>{var b,v;return o!=null&&o.fill&&!i.has(y)?0:(v=(b=a.get(y))==null?void 0:b.data.viewProps)==null?void 0:v.borderRadius}),u=!d.every(y=>y===d[0]),h=u?"mixed":String(d[0]??""),p=["0","8","16","30","53","100"],m=c||!u&&h!==""&&!p.includes(h),g=y=>e.forEach(b=>{var v;return(v=t.onNodeBorderRadiusChange)==null?void 0:v.call(t,b,y)});return f.jsxs(f.Fragment,{children:[r&&f.jsx(Tt,{}),f.jsx(W.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsxs(It,{icon:f.jsx(W.Icon,{as:Tv.TbBorderRadius,boxSize:5,color:s,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${u?"Mixed":d[0]===void 0?"Default":`${d[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:m?"custom":h,disabled:n.readOnly,onValueChange:y=>{l(y==="custom"),y!=="custom"&&g(y===""?void 0:Number(y))},children:[f.jsx("option",{value:"",children:"Default radius"}),u&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),p.map(y=>f.jsxs("option",{value:y,children:[y,"px radius"]},y)),f.jsx("option",{value:"custom",children:"Custom radius"})]})}),m&&f.jsx(Er,{ariaLabel:"Custom border radius",placeholder:u?"Mixed":"Auto",type:"number",min:0,width:"72px",value:u?"":h,onCommit:y=>g(y===""?void 0:Number(y))})]})}function Ob({ids:e,onClose:r,afterLabel:t}){var B,se,te,le,ne,ce,xe,he;const{callbacks:n,colorMode:o,themeColor:i,config:s,setNodeViewMode:a}=He(),{colorText:c,colorInactive:l}=at(),{nodeById:d,parentIds:u}=Xt(),{palette:h,show:p}=Tb(),m=e.length===1,[g,y]=j.useState(""),b=m?(B=d.get(e[0]))==null?void 0:B.data:void 0,v=e.map(U=>{var re,fe;return((fe=(re=d.get(U))==null?void 0:re.data.config)==null?void 0:fe.typeView)??""}),w=v.some(U=>U!==v[0]),x=w?"mixed":v[0]??"",C=[{value:"text",label:"Text",view:"text",icon:Q.PiTextT},{value:"icon-label",label:"Icon Label",view:"icon-label",icon:Q.PiShapes},{value:"object",label:"Object",view:"object",icon:Q.PiBracketsCurly},{value:"grid",label:"Grid",view:"grid",icon:Q.PiGridFour},{value:"parent",label:"Parent",view:"parent",icon:Q.PiStack},{value:"media",label:"Media",view:"icon-label",icon:Q.PiFileSvg},{value:"content",label:"Content",view:"object",icon:Q.PiTextAlignLeft},{value:"prompt",label:"Prompt",view:"prompt",icon:Q.PiTextAlignLeft}].filter(U=>U.view!=="prompt"||!!n.onPromptSubmit),S=e.some(U=>{var fe,we;const re=(fe=d.get(U))==null?void 0:fe.data;return re&&(u.has(U)||((we=re.config)==null?void 0:we.parentContainer)||Object.prototype.hasOwnProperty.call(s.customViews??{},re.type))}),E=(se=b==null?void 0:b.config)==null?void 0:se.collapsed,R=Ab(e[0]),P=U=>{var re,fe,we;return(((fe=(re=d.get(U))==null?void 0:re.data.viewProps)==null?void 0:fe.outline)??(u.has(U)?(we=s.parentNodeStyle)==null?void 0:we.outline:!1))===!0},I=e.every(P),M=!I&&e.some(P),k=U=>{var re;return((re=d.get(U))==null?void 0:re.data.isNodeAnimated)===!0},_=e.every(k),N=!_&&e.some(k),O=e.map(U=>{var re;return((re=d.get(U))==null?void 0:re.data.nodeAnimationVariant)??"traveling"}),V=O.every(U=>U===O[0])?O[0]:"",T=U=>e.forEach(U),[Z,ue]=j.useState(!1),K=Z&&p("color")&&p("borderColor"),ee=U=>{var re,fe,we;return(((fe=(re=d.get(U))==null?void 0:re.data.viewProps)==null?void 0:fe.borderStyle)??(u.has(U)?(we=s.parentNodeStyle)==null?void 0:we.borderStyle:"solid"))==="dashed"},H=e.every(ee),ae=!H&&e.some(ee),q=e.map(U=>{var we,ie,Ce;const re=(we=d.get(U))==null?void 0:we.data,fe=u.has(U)?Dn((ie=s.parentNodeStyle)==null?void 0:ie.borderWidth,6):(re==null?void 0:re.type)==="objectView"?3:2;return Dn((Ce=re==null?void 0:re.viewProps)==null?void 0:Ce.borderWidth,fe)}),D=q.every(U=>U===q[0])?String(q[0]??""):"",G=U=>T(re=>{var fe,we;K?(fe=n.onNodeBorderColorChange)==null||fe.call(n,re,U):(we=n.onNodeColorChange)==null||we.call(n,re,"bg",U)});return f.jsxs(f.Fragment,{children:[f.jsx(dn,{onClick:r}),f.jsx(Tt,{}),m&&p("label")?f.jsx(Er,{ariaLabel:"Node label",placeholder:"Node label",value:(b==null?void 0:b.label)??(b==null?void 0:b.headerTitle)??"",onCommit:U=>{var re;return(re=n.onNodeLabelChange)==null?void 0:re.call(n,e[0],U)}}):f.jsxs(W.Text,{fontSize:"xs",color:c,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),t,p("typeView")&&f.jsxs(It,{"aria-label":"Type view",title:S?"Type view is managed by the custom renderer or container":`Type view: ${x||"None (default)"}`,icon:f.jsx(Q.PiCards,{size:20}),style:{width:36},value:x,disabled:s.readOnly||s.editable===!1||S,onValueChange:U=>{var fe;const re=(fe=C.find(we=>we.value===U))==null?void 0:fe.view;re&&T(we=>{var ie,Ce;(ie=n.onNodeTypeViewChange)==null||ie.call(n,we,re),a(we,"default"),(Ce=n.onNodeViewToggle)==null||Ce.call(n,we)})},children:[w&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),C.map(U=>f.jsx("option",{value:U.value,children:f.jsxs(W.HStack,{gap:"12px",children:[f.jsx(U.icon,{size:20,"aria-hidden":"true",style:{flexShrink:0}}),f.jsx("span",{children:U.label})]})},U.value))]}),p("style")&&f.jsx(Nb,{ids:e},e.join("\0")),p("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:I?"Restore node fill":"Remove node fill",children:f.jsx(Ne,{"aria-label":"Toggle node outline","aria-pressed":M?"mixed":I,icon:f.jsx(W.Icon,{as:I?Q.PiSquare:Q.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:I?i:l,onClick:()=>T(U=>{var re;return(re=n.onNodeOutlineChange)==null?void 0:re.call(n,U,!I)})})})]}),p("color")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),p("borderColor")&&f.jsx(Ge,{label:K?"Edit node colors":"Edit node border",children:f.jsx(Ne,{"aria-label":"Edit node border","aria-pressed":K,icon:f.jsx(W.Icon,{as:Q.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:K?i:l,bg:K?o==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>ue(U=>!U)})}),f.jsx(Vr,{label:K?"Border color":"Background",colors:h,value:K?((te=b==null?void 0:b.viewProps)==null?void 0:te.borderColor)??(m&&u.has(e[0])?(le=s.parentNodeStyle)==null?void 0:le.borderColor:void 0):(ne=b==null?void 0:b.viewProps)==null?void 0:ne.bgColor,onPick:G,onReset:()=>G("")}),K&&p("style")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:H?"Solid border":"Dashed border",children:f.jsx(Ne,{"aria-label":"Toggle dashed border","aria-pressed":ae?"mixed":H,icon:f.jsx(W.Icon,{as:H?Q.PiLineSegments:Q.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:H?i:l,onClick:()=>T(U=>{var re;return(re=n.onNodeBorderStyleChange)==null?void 0:re.call(n,U,H?"solid":"dashed")})})}),f.jsx(Er,{ariaLabel:"Border thickness",placeholder:m?"Auto":"Mixed",width:"64px",type:"number",min:0,value:D,onCommit:U=>T(re=>{var fe;return(fe=n.onNodeBorderWidthChange)==null?void 0:fe.call(n,re,U===""?void 0:Number(U))})})]})]}),p("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:_?"Stop border animation":"Animate node border",children:f.jsx(Ne,{"aria-label":"Toggle node animation","aria-pressed":N?"mixed":_,icon:f.jsx(W.Icon,{as:Q.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:_?i:l,onClick:()=>T(U=>{var re;return(re=n.onNodeAnimationChange)==null?void 0:re.call(n,U,!_)})})}),(_||N)&&f.jsx(Rb,{label:"Node animation",value:V,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:s.readOnly,onChange:U=>T(re=>{var fe;return(fe=n.onNodeAnimationVariantChange)==null?void 0:fe.call(n,re,U)})})]}),!K&&p("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Vr,{label:"Text color",colors:Mb,value:(ce=b==null?void 0:b.viewProps)==null?void 0:ce.textColor,onPick:U=>T(re=>{var fe;return(fe=n.onNodeColorChange)==null?void 0:fe.call(n,re,"text",U)}),onReset:()=>T(U=>{var re;return(re=n.onNodeColorChange)==null?void 0:re.call(n,U,"text","")})})]}),m&&p("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Gd,{nodeId:e[0],value:(xe=b==null?void 0:b.config)==null?void 0:xe.icon},e[0]),f.jsx(Er,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((he=b==null?void 0:b.config)==null?void 0:he.icon)||"",onCommit:U=>{var re;return(re=n.onNodeIconChange)==null?void 0:re.call(n,e[0],U)}})]}),m&&R&&p("collapse")&&E!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:E?"Expand":"Collapse",children:f.jsx(Ne,{"aria-label":E?"Expand node":"Collapse node",icon:f.jsx(W.Icon,{as:E?Q.PiArrowsOutLineVertical:Q.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:l,onClick:()=>{var U;return(U=n.onNodeCollapse)==null?void 0:U.call(n,e[0],!E)}})})]}),p("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:m?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Ne,{"aria-label":"Delete selected nodes",icon:f.jsx(W.Icon,{as:Q.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:o==="dark"?"red.300":"red.500",onClick:()=>{T(U=>{var re,fe;return(fe=n.onNodeDelete)==null?void 0:fe.call(n,U,((re=d.get(U))==null?void 0:re.data)||{id:U})}),r()}})})]}),f.jsx(Ge,{label:"Copy selection",children:f.jsx(Ne,{"aria-label":"Copy selection",icon:f.jsx(Q.PiCopy,{size:20}),size:"sm",variant:"ghost",color:l,onClick:async()=>{var U;try{await((U=n.onNodesCopy)==null?void 0:U.call(n,e)),y("")}catch(re){y(String(re))}}})}),f.jsx(Ge,{label:"Duplicate selection",children:f.jsx(Ne,{"aria-label":"Duplicate selection",icon:f.jsx(Q.PiCopySimple,{size:20}),size:"sm",variant:"ghost",color:l,disabled:s.readOnly||s.editable===!1,onClick:()=>{var U;try{(U=n.onNodesDuplicate)==null||U.call(n,e),y("")}catch(re){y(String(re))}}})}),g&&f.jsx(W.Text,{role:"alert",fontSize:"xs",children:g})]})}async function $b(e){const{toSvg:r}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const t=await r(e,{filter:o=>!(o instanceof Element)||!o.matches("button, iframe, [role=tooltip], .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-edge-hit, .flow-sdk-ghost, .flow-sdk-node-animation")}),n=new DOMParser().parseFromString(decodeURIComponent(t.slice(t.indexOf(",")+1)),"image/svg+xml");return n.querySelectorAll(".flow-sdk-edge-hit, .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-ghost").forEach(o=>o.remove()),n.querySelectorAll("[data-flow-preview-source]").forEach(o=>{o.setAttribute("style","display:block;white-space:pre-wrap;font:16px/1.5 monospace;overflow-wrap:anywhere")}),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function qb(e,r="squeed.svg"){const t=document.createElement("a");t.href=await $b(e),t.download=r.endsWith(".svg")?r:`${r}.svg`,t.click()}function Lb(){const{themeColor:e}=He(),[r,t]=j.useState(!1),[n,o]=j.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(Ge,{label:"Download SVG (current view)",children:f.jsx(Ne,{"aria-label":"Download SVG",icon:f.jsx(Q.PiDownloadSimpleFill,{size:20}),disabled:r,borderRadius:"30%",color:e,variant:"ghost",onClick:async i=>{var a;const s=(a=i.currentTarget.closest("[data-flow-diagram]"))==null?void 0:a.querySelector("[data-flow-background]");if(!s){o("Diagram not available for export.");return}t(!0),o("");try{await qb(s)}catch(c){o(c instanceof Error?c.message:"Unable to export SVG.")}finally{t(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function ko({children:e,background:r,border:t,endElement:n,startElement:o,startElementWidth:i=44,framed:s=!0}){const a=j.useRef(null),c=j.useRef(null),[l,d]=j.useState(i);j.useLayoutEffect(()=>{const g=c.current;if(!o||!g)return;const y=()=>{const v=Math.ceil(g.getBoundingClientRect().width)+18;d(w=>Math.abs(w-v)>1?v:w)};y();const b=new ResizeObserver(y);return b.observe(g),()=>b.disconnect()},[o]);const u=o?l:0,[h,p]=j.useState({left:!1,right:!1});j.useLayoutEffect(()=>{const g=a.current;let y=g.parentElement.offsetWidth;const b=()=>{const x=g.parentElement.offsetWidth;if(x>0&&x!==y){const E=y/x;y=x,E>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&g.parentElement.animate({transform:[`scaleX(${E})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const C=g.scrollLeft>1,S=g.scrollWidth-g.clientWidth-g.scrollLeft>1;p(E=>E.left===C&&E.right===S?E:{left:C,right:S})},v=x=>{const C=x.target instanceof Element?x.target:null;if((C==null?void 0:C.closest("[data-flow-toolbar-scroll]"))!==g||C.closest("[popover], [data-flow-floating-panel]")!==g.closest("[popover], [data-flow-floating-panel]")||x.defaultPrevented||x.ctrlKey||s&&x.deltaX!==0||!(x.deltaX||x.deltaY)||g.scrollWidth<=g.clientWidth)return;x.preventDefault();const S=x.deltaMode===WheelEvent.DOM_DELTA_LINE?16:x.deltaMode===WheelEvent.DOM_DELTA_PAGE?g.clientWidth:1;g.scrollLeft+=(x.deltaX||x.deltaY)*S},w=new ResizeObserver(b);return w.observe(g),g.firstElementChild&&w.observe(g.firstElementChild),g.addEventListener("scroll",b,{passive:!0}),g.addEventListener("wheel",v,{passive:!1}),b(),()=>{w.disconnect(),g.removeEventListener("scroll",b),g.removeEventListener("wheel",v)}},[]);const m=`var(--chakra-colors-${r.replace(".","-")})`;return f.jsxs(W.Box,{position:"relative",bg:s?r:"transparent",minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:s?"30px":0,css:{...s?gr(m,`var(--chakra-colors-${t.replace(".","-")})`):{},...s||o?{"--flow-toolbar-start-width":o?`${u}px`:"0px"}:{}},children:[f.jsx(W.Box,{ref:a,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,ml:o?`${u}px`:void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(g=>f.jsx(W.Box,{"data-flow-toolbar-fade":g,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",zIndex:2,borderRadius:g==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[g]:g==="right"&&n?44:g==="left"&&o?u:0,opacity:h[g]?1:0,background:`linear-gradient(to ${g==="left"?"right":"left"}, ${m}, transparent)`}},g)),n&&f.jsx(W.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",background:m,borderRadius:s?"0 30px 30px 0":void 0,zIndex:1,children:n}),o&&f.jsx(W.Box,{ref:c,position:"absolute",left:"6px",top:0,h:"50px",w:"max-content",display:"flex",alignItems:"center",justifyContent:"center",background:m,borderRadius:s?"30px 0 0 30px":void 0,zIndex:1,children:o})]})}async function Uw(e,r){const t=new Set,n=[],o=(a,c)=>{var d,u,h;if(!a||typeof a!="object")return;const l=a;n.push(c),typeof((d=l.$form)==null?void 0:d.$type)=="string"&&t.add(l.$form.$type),typeof((h=(u=l.$form)==null?void 0:u.$create)==null?void 0:h.$type)=="string"&&t.add(l.$form.$create.$type);for(const[p,m]of Object.entries(l))p==="$"?o(m,c):p.startsWith("$")||o(m,`${c}.${p}`)};if(o(r,"root"),!t.size)return{contract:await Eb(e)};const i=await Wd(e,[...t]);for(const a of t)if(!Object.prototype.hasOwnProperty.call(i,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const c=un(r,a,i);c&&(s[a]={type:c.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:s}}}function Fb({message:e,onDismiss:r}){const{background:t,colorText:n,border:o}=at();return!e||typeof document>"u"?null:Wr.createPortal(f.jsxs(W.chakra.div,{role:"alert","aria-atomic":"true",css:gr(Te(t),Te(o)),onPointerDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),style:{position:"fixed",top:20,right:20,zIndex:1e4,width:360,maxWidth:"calc(100vw - 40px)",boxSizing:"border-box",display:"flex",alignItems:"flex-start",gap:10,padding:16,borderRadius:8,background:Te(t),color:Te(n),fontSize:14,lineHeight:1.5},children:[f.jsx(Q.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),f.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[f.jsx("strong",{children:"Interface upload failed"}),f.jsx("div",{children:e})]}),f.jsx(dn,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:r,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function Hd({showDivider:e=!0,compact:r=!1}={}){const{edgeMode:t,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:s,readOnly:a,themeColor:c,colorMode:l}=He(),{edgeById:d}=Xt(),{data:u,schema:h,setSchema:p,bindings:m,structured:g}=j.useContext($t),y=(g==null?void 0:g.sourceBindings)??m,b=(g==null?void 0:g.sourceSchema)??h,{colorText:v}=at(),w=j.useRef(null),x=j.useRef(0),[C,S]=j.useState(!1),[E,R]=j.useState("");j.useEffect(()=>()=>{x.current++},[]),j.useEffect(()=>{x.current++,S(!1)},[a,u,y]);const P=o?[...d.values()].filter(k=>Dd(o,k.data)).length:0,I=o?`${o.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${P} invalid or unverified connections`:"",M=jo(f.jsx(Hd,{showDivider:!1,compact:!0}));return f.jsx(nn.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:M,children:[f.jsx(Fb,{message:E,onDismiss:()=>R("")}),e&&f.jsx(Nn,{}),f.jsxs(It,{"aria-label":"Edge mode",title:t==="auto"?"Connections: Auto":t==="properties"?"Connections: Properties":"Connections: Nodes",icon:t==="auto"?f.jsx(Q.PiGraph,{size:20}):t==="properties"?f.jsx(Q.PiTable,{size:20}):f.jsx(Q.PiTreeStructure,{size:20}),style:{width:36},value:t,disabled:a,footer:s.onWorkflowConfigurationOpen&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{style:{border:0,borderTop:"1px solid currentColor",opacity:.2,margin:"8px 0"}}),f.jsxs(W.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:ho,_hover:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:k=>{var _,N;(_=k.currentTarget.closest("[popover]"))==null||_.hidePopover(),(N=s.onWorkflowConfigurationOpen)==null||N.call(s)},children:[f.jsx(Q.PiGear,{}),"Configuration"]})]}),onValueChange:k=>{var N;const _=k==="auto"?"auto":k==="properties"?"properties":"nodes";n(_),(N=s.onEdgeModeChange)==null||N.call(s,_)},children:[f.jsx("option",{value:"auto",children:"Auto"}),f.jsx("option",{value:"nodes",children:"Nodes"}),f.jsx("option",{value:"properties",children:"Properties"})]}),f.jsxs("span",{style:{display:t==="auto"||t==="properties"?"contents":"none"},children:[f.jsx(Ge,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:f.jsx(Ne,{"aria-label":"Upload workflow interface",icon:f.jsx(Q.PiUploadSimple,{size:20}),color:Te(c),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var k;return(k=w.current)==null?void 0:k.click()}})}),f.jsx("input",{ref:w,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async k=>{var O,V;const _=(O=k.target.files)==null?void 0:O[0];if(k.target.value="",!_)return;const N=++x.current;S(!0),R("");try{const T=y?await Wd(_,[...new Set(Object.values(y).map(K=>K.schemaType??K.type))]):void 0;if(y&&T){for(const K of Object.values(y))if(!Object.prototype.hasOwnProperty.call(T,K.schemaType??K.type))throw new Error(`Missing form type: ${K.schemaType??K.type}`)}const{contract:Z,schema:ue}=y&&T?{schema:T,contract:{name:_.name,nodes:Object.fromEntries(Object.entries(y).map(([K,ee])=>[K,{type:T[ee.schemaType??ee.type],optional:!1}]))}}:await Uw(_,u);if(N!==x.current)return;p==null||p(ue),i(Z),(V=s.onWorkflowContractChange)==null||V.call(s,Z)}catch(T){N===x.current&&R(`${_.name}: ${T instanceof Error?T.message:"Unable to load interface."}`)}finally{N===x.current&&S(!1)}}}),!r&&(I||C)&&f.jsx("span",{role:"status",title:I,style:{color:Te(v),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":I}),!r&&o&&f.jsx(Ge,{label:"Remove workflow interface",children:f.jsx(Ne,{"aria-label":"Remove workflow interface",icon:f.jsx(Q.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||C,onClick:()=>{var k;p==null||p(void 0),i(void 0),(k=s.onWorkflowContractChange)==null||k.call(s,void 0),R("")}})})]})]})})}const Kw=[{value:"BT",label:"Bottom to Up",icon:Q.PiArrowUp,flowType:Sn.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Q.PiArrowDown,flowType:Sn.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Q.PiArrowRight,flowType:Sn.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Q.PiArrowLeft,flowType:Sn.RIGHT_LEFT}],zb=({nodeGridControlsTarget:e}={})=>{const{engineRef:r,themeColor:t,setThemeColor:n,edgeColor:o,setEdgeColor:i,backgroundSelected:s,setBackgroundSelected:a,direction:c,edgeMode:l,allNodesIconLabel:d,setAllNodesIconLabel:u,nodeGridOptions:h,selectedNodeIds:p,setSelectedNodeIds:m,selectedEdgeId:g,setSelectedEdgeId:y,isZoomMode:b,setIsZoomMode:v,isMultiSelectMode:w,setIsMultiSelectMode:x,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:E,setIsEdgeHandlesEnabled:R,isArrayNodeMode:P,setIsArrayNodeMode:I,isPinned:M,setIsPinned:k,callbacks:_,config:N,readOnly:O}=He(),{nodeById:V,edgeById:T,parentIds:Z}=Xt(),ue=N.colorMode==="dark",{background:K,border:ee,colorInactive:H,colorText:ae,colorActive:q}=at(),D=ue?ee:"gray.300",G=`var(--chakra-colors-${K.replace(".","-")})`,B=`var(--chakra-colors-${(ue?ee:"gray.300").replace(".","-")})`,[se,te]=j.useState(!1),[le,ne]=j.useState(!0),ce=N.bottomBarCollapsed??le,xe=j.useRef(null),he=So({edge:"bottom",enabled:!M,bounds:xe,inside:[xe]}),U=j.useCallback(Re=>{const Ke=r.current;if(!Ke)return;const lt=N.minZoom??.01,Je=N.maxZoom??1.5,mt=.02;let At=Ke.zoom();switch(Re){case"increase":At=Math.min(Je,At+mt),Ke.zoom(At),Ke.center(!1);break;case"decrease":At=Math.max(lt,At-mt),Ke.zoom(At),Ke.center(!1);break;case"reset":Ke.fit(50);break}},[r,N.minZoom,N.maxZoom]),re=N.renderSelectedNodeToolbar,fe=p.length>0&&!!re,we=j.useMemo(()=>fe?p.map(Re=>{var lt;return{...((lt=V.get(Re))==null?void 0:lt.data)??{id:Re},isParent:Z.has(Re)}}):[],[fe,p,V,Z]),ie=j.useCallback(()=>{var Re;m([]),(Re=_.onNodeDeselect)==null||Re.call(_)},[m,_]),Ce=N.renderSelectedEdgeToolbar,$e=!!g&&!!Ce,Ue=j.useMemo(()=>{var Re;return!$e||!g?null:((Re=T.get(g))==null?void 0:Re.data)??{id:g}},[$e,g,T]),Ve=j.useCallback(()=>{var Re;y(null),(Re=_.onEdgeDeselect)==null||Re.call(_)},[y,_]),tt=N.selectionToolbar!==!1&&!O,ye=tt&&!!g&&!Ce,Ae=tt&&!ye&&p.length>0&&!re,Le=ye||Ae,be=M||he||se||Le||N.bottomBarCollapsed===!1;j.useEffect(()=>{p.length||g?a(!1):O||(s&&k(!0),N.bottomBarCollapsed===void 0&&ne(!s))},[s,p.length,g,O,a,k,N.bottomBarCollapsed]);const Xe=N.renderBottomBar,ut=Iw();return Xe?f.jsxs(f.Fragment,{children:[fe&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:re({selectedNodeIds:p,selectedNodeData:we,onDeselect:ie})}),$e&&Ue&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:Ce({edgeId:g,edgeData:Ue,onDeselect:Ve})}),f.jsx(W.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:Xe({zoomIn:()=>U("increase"),zoomOut:()=>U("decrease"),resetZoom:()=>U("reset"),direction:c,isZoomMode:b,setIsZoomMode:v,isMultiSelectMode:w,setIsMultiSelectMode:x,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:E,setIsEdgeHandlesEnabled:R,isArrayNodeMode:P,setIsArrayNodeMode:I,selectedNodeIds:p,selectedNodeData:we,selectedEdgeId:g,selectedEdgeData:Ue,onNodeDeselect:ie,onEdgeDeselect:Ve,callbacks:_})})]}):f.jsxs(nn.Provider,{value:ut,children:[fe&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:re({selectedNodeIds:p,selectedNodeData:we,onDeselect:ie})}),$e&&Ue&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:Ce({edgeId:g,edgeData:Ue,onDeselect:Ve})}),f.jsx(W.Box,{ref:xe,role:"toolbar","aria-label":"Diagram controls",position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:be?"translateY(0)":"translateY(100%)",pointerEvents:be?"auto":"none",visibility:be?"visible":"hidden",opacity:be?1:0,css:{"& button > svg:not([popover] *)":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0},"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(W.Flex,{w:"100%",px:5,position:"absolute",bottom:"calc(20px + env(safe-area-inset-bottom, 0px))",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",css:{"@media (min-width: 1024px)":{"& > :first-of-type":{maxWidth:"50vw"}}},children:[f.jsx(ko,{background:K,border:ue?ee:"gray.300",children:f.jsxs(W.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[ye?f.jsx(Ib,{edgeId:g,onClose:Ve}):Ae?f.jsx(Ob,{ids:p,onClose:ie}):null,f.jsxs("div",{style:{display:ye||Ae?"none":"contents"},children:[f.jsxs("span",{style:{display:N.bottomBarNavigation===!1?"none":"contents"},children:[f.jsx(Ge,{label:M?"Unpin":"Pin",children:f.jsx(Ne,{"aria-label":"Pin",icon:f.jsx(W.Icon,{as:M?Q.PiPushPinFill:Q.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:M?t:H,onClick:()=>{k(!M),te(!1)}})}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:"Zoom Out",children:f.jsx(Ne,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(W.Icon,{as:Q.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:ae,onClick:()=>U("decrease")})}),f.jsx(Ge,{label:"Zoom In",children:f.jsx(Ne,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(W.Icon,{as:Q.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:ae,onClick:()=>U("increase")})}),f.jsx(Ge,{label:"Reset Zoom",children:f.jsx(Ne,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(W.Icon,{as:Q.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:ae,onClick:()=>U("reset")})}),ce&&f.jsx(Nw,{visibleActions:h?["Collision mode","Fill",...h.fill?["Grid adjustment"]:[]]:[],divider:f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"})})]}),f.jsxs("span",{style:{display:ce?"none":"contents"},children:[f.jsxs("span",{style:{display:N.bottomBarNavigation===!1?"none":"contents"},children:[N.edgeHandles!==!1&&f.jsx(Ge,{label:E?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Ne,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":E,icon:f.jsx(W.Icon,{as:Q.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:E?t:H,onClick:()=>R(!E)})}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:b?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Ne,{"aria-label":"Toggle zoom mode",icon:f.jsx(W.Icon,{as:b?Q.PiMagnifyingGlassPlus:Q.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:b?t:H,onClick:()=>v(!b)})}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:w?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Ne,{"aria-label":"Toggle multi-select",icon:f.jsx(W.Icon,{as:Q.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:w?t:H,onClick:()=>x(!w)})}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:C?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Ne,{"aria-label":"Toggle drag mode",icon:f.jsx(W.Icon,{as:Q.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:C?t:H,onClick:()=>S(!C)})})]}),N.bottomBarNavigation===!1&&(e===void 0?f.jsx(so,{}):e?Wr.createPortal(f.jsx(so,{}),e):null),N.bottomBarExtra&&f.jsxs(f.Fragment,{children:[N.bottomBarNavigation!==!1&&f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"}),N.bottomBarExtra]}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"}),f.jsx(wb,{})]}),f.jsx("span",{style:{display:N.bottomBarNavigation===!1||ce&&!h?"none":"contents"},children:f.jsx(so,{})}),f.jsxs("span",{style:{display:ce?"none":"contents"},children:[f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"}),f.jsx(vb,{}),l!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:P?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Ne,{"aria-label":"Toggle array mode",icon:f.jsx(W.Icon,{as:P?Q.PiBracketsSquare:Q.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:P?t:H,onClick:()=>{var Ke;const Re=!P;I(Re),(Ke=_.onArrayModeChange)==null||Ke.call(_,Re)}})})]}),f.jsx(Hd,{}),!O&&f.jsxs("span",{style:{display:s?"contents":"none"},children:[f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Vr,{label:"Graph theme",colors:po,value:t,includeTransparent:!1,onPick:Re=>{var Ke;n(Re),(Ke=_.onThemeColorChange)==null||Ke.call(_,Re)}})]}),!O&&f.jsxs(f.Fragment,{children:[f.jsx(W.Icon,{as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"}),f.jsx(Vr,{label:"Graph edge color",colors:po,value:o||(ue?"gray.500":ln),onPick:i,onReset:()=>i("")}),f.jsx(W.Icon,{as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"})]}),f.jsx(Cb,{})]}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:ce?"Expand toolbar":"Collapse toolbar",children:f.jsx(Ne,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(W.Icon,{as:ce?Q.PiCaretRight:Q.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:H,onClick:()=>{var Re;N.bottomBarCollapsed===void 0&&ne(!ce),a(ce),(Re=_.onBottomBarCollapsedChange)==null||Re.call(_,!ce)}})}),!ce&&f.jsx(Lb,{})]})]})}),!Le&&f.jsxs(W.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(W.Box,{"data-flow-direction-control":"",bg:K,borderRadius:"30px",h:50,css:gr(G,B),px:3,cursor:"pointer",onClick:()=>te(!se),children:f.jsxs(W.Flex,{align:"center",h:"100%",children:[f.jsx(Ge,{label:"Flow Direction",children:f.jsx(Ne,{"aria-label":"Direction",onClick:Re=>{Re.stopPropagation(),te(!se)},icon:f.jsx(W.Icon,{as:Q.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:H})}),f.jsx(W.Text,{fontSize:"xs",textTransform:"uppercase !important",color:ue?"whiteAlpha.600":"blackAlpha.500",ml:1,children:c.toUpperCase()})]})}),se&&f.jsx(W.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(W.Box,{bg:K,borderRadius:"30px",p:2,minW:"180px",css:gr(G,B),children:[Kw.map(Re=>f.jsxs(W.Flex,{align:"center",gap:3,px:3,py:2,css:ho,cursor:"pointer",_hover:{bg:ue?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Ke;(Ke=_.onDirectionChange)==null||Ke.call(_,Re.value),te(!1)},children:[f.jsx(W.Icon,{as:Re.icon,boxSize:5,color:ae}),f.jsx(W.Text,{fontSize:"sm",color:ae,flex:1,whiteSpace:"nowrap",children:Re.label}),c===Re.value&&f.jsx(W.Icon,{as:Q.PiCheck,boxSize:4,color:q})]},Re.value)),f.jsxs(W.Flex,{align:"center",gap:3,px:3,py:2,css:ho,cursor:"pointer",_hover:{bg:ue?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Re;(Re=_.onDirectionChange)==null||Re.call(_,"C"),te(!1)},children:[f.jsx(W.Icon,{as:Q.PiAlignCenterHorizontal,boxSize:5,color:ae}),f.jsx(W.Text,{fontSize:"sm",color:ae,flex:1,whiteSpace:"nowrap",children:"Center"}),c==="C"&&f.jsx(W.Icon,{as:Q.PiCheck,boxSize:4,color:q})]})]})})]})]})})]})};zb.displayName="BottomBar";const Bb=j.memo(zb);function Jw({checked:e,onChange:r,disabled:t,label:n="Connected nodes"}){return f.jsx(on,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:r,disabled:t,icon:f.jsx(W.Icon,{as:Q.PiGraph,boxSize:5})})}const Ju={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Db(e,r){const t=new Map,n=(i,s)=>{if(Object.is(i,s))return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const a=Object.keys(i);return a.length===Object.keys(s).length&&a.every(c=>Object.prototype.hasOwnProperty.call(s,c)&&n(i[c],s[c]))},o=(i,s,a)=>{if(i===s)return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const c=new Set([...Object.keys(i),...Object.keys(s)]);for(const l of c)if(!n(i[l],s[l])){if(Object.prototype.hasOwnProperty.call(Ju,l)){if(typeof s[l]!="string"||!s[l])return!1;t.set(a,{...t.get(a),[Ju[l]]:s[l]})}else if(l.startsWith("$")&&l!=="$"||!o(i[l],s[l],l==="$"?a:`${a}.${l}`))return!1}return!0};if(o(e,r,"root"))return t}function Zw(e,r){return Db(e,r)!==void 0}function Xw(e,r,t){if(e===r)return t;const n=Db(e,r);if(!n)return;const o=new Set(t.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!Oe(r,i))return;return{edges:t.edges,nodes:t.nodes.map(i=>{const s=n.get(i.data.id),a=Oe(e,i.data.id),c=Oe(r,i.data.id);return!s&&a===c?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(c,null,2)}:{},...s?{viewProps:{...i.data.viewProps,...s},config:{...i.data.config,...s}}:{}}}})}}function _d(e){return e.kind==="literal"?e.value:e.kind==="union"?_d(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,r])=>!r.optional).map(([r,t])=>[r,_d(t.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function Wb(e,r,t){var y,b,v;const n=(y=Oe(e,r))==null?void 0:y.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(w=>!/^[A-Za-z0-9_-]+$/.test(w)||["__proto__","constructor","prototype"].includes(w)))throw new Error("Invalid form creation address.");if(!t||!Object.prototype.hasOwnProperty.call(t,o.$type))throw new Error(`Load form type: ${o.$type}`);const s=i.pop(),a=["root",...i].join("."),c=un(e,a,t),l=(b=c==null?void 0:c.type.properties[s])==null?void 0:b.type;if((l==null?void 0:l.kind)!=="array"||l.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const d=t[o.$type],u=o.$defaults??{};for(const[w,x]of Object.entries(u))if(!Object.prototype.hasOwnProperty.call(d.properties,w)||Jt(d.properties[w].type,x,!d.properties[w].optional))throw new Error(`Invalid creation default: ${w}`);const h={..._d(d),...structuredClone(u)};((v=d.properties.id)==null?void 0:v.type.kind)==="string"&&(h.id=Td());let p=e;const m=Oe(e,o.$address);if(m===void 0)p=Pt(e,a,w=>({...w,[s]:[]}));else if(!Array.isArray(m)&&!Array.isArray(m==null?void 0:m.$))throw new Error("Form creation destination is not an array.");const g=$d(p,o.$address,{...h,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:g.address,json:qd(g.json,r,{target:g.address,label:o.$edgeLabel})}}function Yw(e,r,t){var i,s;if(Array.isArray(r)){const a=new Set(r);if(!Oe(e,t)||[...a].some(u=>u==="root"||!Oe(e,u)))throw new Error("The source or Parent no longer exists.");const c=new Set;let l=t;for(;l;){if(c.has(l)||[...a].some(h=>l===h||l.startsWith(`${h}.`)))throw new Error("A node cannot be moved inside itself or its descendants.");c.add(l);const u=(i=Oe(e,l))==null?void 0:i.$parent;l=typeof u=="string"?u:l.includes(".")?l.slice(0,l.lastIndexOf(".")):void 0}const d=(u,h)=>{let p=u;const m=(g,y)=>{p===u&&(p=Array.isArray(u)?[...u]:{...u}),p[g]=y};if(u&&typeof u=="object")for(const[g,y]of Object.entries(u)){if(g.startsWith("$")&&g!=="$")continue;const b=d(y,g==="$"?h:`${h}.${g}`);b!==y&&m(g,b)}return a.has(h)&&(p={...p&&typeof p=="object"&&!Array.isArray(p)?p:{$:p},$parent:t}),p};return uo(d(e,"root"),t,!1)}if(r=r,r==="root"||!Oe(e,r)||!Oe(e,t))throw new Error("The source or Parent no longer exists.");const n=new Set;let o=t;for(;o;){if(o===r||o.startsWith(`${r}.`)||n.has(o))throw new Error("A node cannot be moved inside itself or its descendants.");n.add(o);const a=(s=Oe(e,o))==null?void 0:s.$parent;o=typeof a=="string"?a:o.includes(".")?o.slice(0,o.lastIndexOf(".")):void 0}return uo(Pt(e,r,a=>({...a,$parent:t})),t,!1)}function Vb(e,r){const t=new Set(r.filter(a=>Oe(e,a)!==void 0)),n=[],o=(a,c)=>{if(!(!a||typeof a!="object")){n.push([c,a]);for(const[l,d]of Object.entries(a))l.startsWith("$")||o(d,`${c}.${l}`)}};o(e,"root");const i=a=>[...t].some(c=>a===c||a.startsWith(`${c}.`));let s=!0;for(;s;){s=!1;for(const[a,c]of n)!i(a)&&typeof c.$parent=="string"&&i(c.$parent)&&(t.add(a),s=!0)}return[...t].filter(a=>![...t].some(c=>c!==a&&a.startsWith(`${c}.`)))}function Ud(e,r){const t=Vb(e,r),n=new Map(t.map((a,c)=>[a,`root.node_${c+1}`])),o=a=>{const c=t.find(l=>a===l||a.startsWith(`${l}.`));return c?`${n.get(c)}${a.slice(c.length)}`:void 0},i=a=>{if(!(!a||typeof a!="object")){Array.isArray(a.$connections)&&(a.$connections=a.$connections.flatMap(c=>{const l=typeof c.target=="string"&&o(c.target);return l?[{...c,id:void 0,target:l}]:[]}));for(const c of["$parent","$target"])if(typeof a[c]=="string"){const l=o(a[c]);l?a[c]=l:delete a[c]}for(const[c,l]of Object.entries(a))c.startsWith("$")||i(l)}},s={$hideRoot:!0};return t.forEach((a,c)=>{const l=structuredClone(Oe(e,a));i(l),s[`node_${c+1}`]=l}),s}function Gb(e,r){const t=Ud(e,r),n=Object.keys(t).filter(a=>!a.startsWith("$")),o=new Map(n.map(a=>[a,`copy_${crypto.randomUUID()}`])),i=a=>{if(!a||typeof a!="object")return;const c=l=>{const d=l.split(".");return d[0]==="root"&&o.has(d[1])&&(d[1]=o.get(d[1])),d.join(".")};for(const l of a.$connections??[])l.target=c(l.target),l.id=crypto.randomUUID();for(const l of["$parent","$target"])typeof a[l]=="string"&&(a[l]=c(a[l]));for(const[l,d]of Object.entries(a))l.startsWith("$")||i(d)},s=Object.fromEntries(n.map(a=>{const c=t[a];return i(c),[o.get(a),c]}));return{json:Pt(e,"root",a=>({...a,...s})),ids:[...o.values()].map(a=>`root.${a}`)}}function Qw(e,r){const t=o=>e&&typeof e=="object"&&o in e;let n=1;for(;t(`${r}_${n}`);)n++;return`${r}_${n}`}function Hb(e,r,t,n,o){const i=(a,c)=>{var h;if(a===e)return;const l=c.type.startsWith("node")&&c.type!=="nodeDelete",d=c.nodeAddresses??(l&&c.address?[c.address]:[]),u=d.length?(h=t.getNodeEditMetadata)==null?void 0:h.call(t):void 0;for(const p of d)JSON.stringify(Oe(a,p))!==JSON.stringify(Oe(e,p))&&(a=cb(a,p,u));e=a,n==null||n(a,c)},s=a=>{var l;const c=(l=r.find(d=>d.data.id===a))==null?void 0:l.data;return c&&{source:c.source,target:c.target,isInverted:c.isInverted,sourceProperty:c.sourceProperty,targetProperty:c.targetProperty,connection:c.connection}};return{...t,onNodesCopy:async a=>{var c;await((c=t.onNodesCopy)==null?void 0:c.call(t,a))!==!0&&await navigator.clipboard.writeText(JSON.stringify(Ud(e,a),null,2))},onNodesDuplicate:a=>{var l;if(((l=t.onNodesDuplicate)==null?void 0:l.call(t,a))===!0)return;const c=Gb(e,a);i(c.json,{type:"nodeCreate",address:c.ids[0],nodeAddresses:c.ids})},onFormChange:a=>{const c=Oe(e,a.nodeAddress);if(!c||a.nodeId!==void 0&&c.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");i(_o(e,a,t.onFormChange),{type:"form",address:a.address,nodeAddresses:[a.nodeAddress],value:a.value})},onNodeLabelChange:(a,c)=>{var l;(l=t.onNodeLabelChange)==null||l.call(t,a,c),i(jt(e,a,"$label",c),{type:"nodeLabel",address:a,key:"$label",value:c})},onNodeContentChange:(a,c)=>{var l;(l=t.onNodeContentChange)==null||l.call(t,a,c),i(jt(e,a,"$content",c),{type:"nodeContent",address:a,key:"$content",value:c})},onNodeContentFormatChange:(a,c)=>{var l;["markdown","html","jsx"].includes(c)&&((l=t.onNodeContentFormatChange)==null||l.call(t,a,c),i(jt(e,a,"$contentFormat",c),{type:"nodeStyle",address:a,key:"$contentFormat",value:c}))},onNodeTypeViewChange:(a,c)=>{var l;c!==void 0&&!Ld.includes(c)||((l=t.onNodeTypeViewChange)==null||l.call(t,a,c),i(jt(e,a,"$view",c),{type:"nodeStyle",address:a,key:"$view",value:c}))},onNodeColorChange:(a,c,l)=>{var u;(u=t.onNodeColorChange)==null||u.call(t,a,c,l);const d=c==="bg"?"$bgColor":"$textColor";i(jt(e,a,d,l),{type:"nodeColor",address:a,key:d,value:l})},onNodeBorderColorChange:(a,c)=>{var l;(l=t.onNodeBorderColorChange)==null||l.call(t,a,c),i(jt(e,a,"$borderColor",c),{type:"nodeColor",address:a,key:"$borderColor",value:c})},onNodeBorderStyleChange:(a,c)=>{var l;(l=t.onNodeBorderStyleChange)==null||l.call(t,a,c),i(jt(e,a,"$borderStyle",c),{type:"nodeStyle",address:a,key:"$borderStyle",value:c})},onNodeBorderWidthChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderWidthChange)==null||l.call(t,a,c),i(jt(e,a,"$borderWidth",c),{type:"nodeStyle",address:a,key:"$borderWidth",value:c}))},onNodeBorderRadiusChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderRadiusChange)==null||l.call(t,a,c),i(jt(e,a,"$borderRadius",c),{type:"nodeStyle",address:a,key:"$borderRadius",value:c}))},onNodeIconChange:(a,c)=>{var l;(l=t.onNodeIconChange)==null||l.call(t,a,c),i(jt(e,a,"$icon",c),{type:"nodeIcon",address:a,key:"$icon",value:c})},onNodeOutlineChange:(a,c)=>{var l;(l=t.onNodeOutlineChange)==null||l.call(t,a,c),i(jt(e,a,"$outline",c),{type:"nodeOutline",address:a,key:"$outline",value:c})},onNodeAnimationChange:(a,c)=>{var l;(l=t.onNodeAnimationChange)==null||l.call(t,a,c),i(jt(e,a,"$isNodeAnimated",c),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:c})},onNodeAnimationVariantChange:(a,c)=>{var l;c!=="traveling"&&c!=="pulse"||((l=t.onNodeAnimationVariantChange)==null||l.call(t,a,c),i(jt(e,a,"$nodeAnimationVariant",c),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:c}))},onNodeCollapse:(a,c)=>{var l;(l=t.onNodeCollapse)==null||l.call(t,a,c),i(uo(e,a,c),{type:"nodeCollapse",address:a,key:"$collapsed",value:c})},onNodeCreate:a=>{var v;if(((v=t.onNodeCreate)==null?void 0:v.call(t,a))===!0)return;const c=a.sourceNodeId||"root",l=Oe(e,c),d=!!a.sourceNodeId&&a.isArrayMode&&!(l!=null&&l.$arrayDrawInitialized),u=Array.isArray(l==null?void 0:l.$)?l.$:l,h=new Set(Object.entries(u??{}).filter(([w])=>!w.startsWith("$")).map(([,w])=>w==null?void 0:w.$label));let p=1,m=e,g;const y=[];let b=a.isArrayMode?"array":"set";for(let w=0;w<(d?2:1);w++){const x=a.sourceNodeId&&Wb(m,a.sourceNodeId,o);if(x){m=x.json,g??(g=x.address),y.push(x.address),b="form";continue}for(;h.has(`Untitled ${p}`);)p++;const C=`Untitled ${p++}`,S=Qw(Oe(m,c),a.isArrayMode?"list":"node"),E=a.isArrayMode?{$bgColor:"gray.500",$label:C,$:[]}:{$bgColor:"gray.500",$label:C},R=$d(m,c,E,S);m=R.json,g??(g=R.address),y.push(R.address)}d&&(m=Pt(m,c,w=>Array.isArray(w)?{$:w,$arrayDrawInitialized:!0}:{...w,$arrayDrawInitialized:!0})),i(m,{type:"nodeCreate",address:g,nodeAddresses:y,value:b})},onNodeDelete:(a,c)=>{var l;(l=t.onNodeDelete)==null||l.call(t,a,c),i(db(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,c,l)=>{var u;(u=t.onEdgeCreate)==null||u.call(t,a,c,l);const d=l&&(l.sourceProperty!==void 0||l.targetProperty!==void 0)?{...l,target:c}:void 0;i(d?qd(e,a,d):ub(e,a,c),{type:"edgeCreate",address:a,key:d?"$connections":"$target",value:d??c})},onEdgeLabelChange:(a,c)=>{var d;(d=t.onEdgeLabelChange)==null||d.call(t,a,c);const l=s(a);l&&i(Sr(e,l,"$sourceLabel",c),{type:"edgeLabel",edge:l,key:l.connection?"$connections":"$sourceLabel",value:c})},onEdgeStyleChange:(a,c)=>{var d;(d=t.onEdgeStyleChange)==null||d.call(t,a,c);const l=s(a);l&&i(lb(e,l,c),{type:"edgeStyle",edge:l,value:c})},onEdgeAnimationVariantChange:(a,c)=>{var d;if(c!=="dashed"&&c!=="traveling")return;(d=t.onEdgeAnimationVariantChange)==null||d.call(t,a,c);const l=s(a);l&&i(Sr(e,l,"$edgeAnimationVariant",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeAnimationVariant",value:c})},onEdgeTypeChange:(a,c)=>{var d;(d=t.onEdgeTypeChange)==null||d.call(t,a,c);const l=s(a);l&&i(Sr(e,l,"$edgeType",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeType",value:c})},onEdgeIconChange:(a,c)=>{var d;(d=t.onEdgeIconChange)==null||d.call(t,a,c);const l=s(a);l&&i(Sr(e,l,"$edgeIcon",c||void 0),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeIcon",value:c})},onEdgeColorChange:(a,c)=>{var d;(d=t.onEdgeColorChange)==null||d.call(t,a,c);const l=s(a);l&&i(Sr(e,l,"$edgeColor",c),{type:"edgeColor",edge:l,key:l.connection?"$connections":"$edgeColor",value:c})},onEdgeDelete:(a,c)=>{var u;(u=t.onEdgeDelete)==null||u.call(t,a,c);const l=s(a);if(!l)return;const d=fb(e,l);d.removed&&i(d.json,{type:"edgeDelete",edge:l,key:l.connection?"$connections":"$target"})}}}const e1=".flow-sdk-edge-reveal{animation:flow-sdk-edge-reveal var(--flow-edge-reveal-duration,600ms) linear both;animation-play-state:var(--flow-edge-reveal-state,running)}.flow-sdk-edge-reveal-end{animation:flow-sdk-edge-reveal-end var(--flow-edge-reveal-duration,600ms) steps(1,end) both;animation-play-state:var(--flow-edge-reveal-state,running)}@keyframes flow-sdk-edge-reveal{from{stroke-dashoffset:var(--flow-edge-reveal-from,100)}to{stroke-dashoffset:0}}@keyframes flow-sdk-edge-reveal-end{from{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-reveal{animation:none;stroke-dashoffset:0}.flow-sdk-edge-reveal-end{animation:none;opacity:1}}";function t1({path:e,width:r,reversed:t,children:n,onComplete:o}){const i=`flow-edge-reveal-${j.useId().replace(/:/g,"")}`,s=j.useRef(null),[a,c]=j.useState({x:0,y:0,width:1,height:1});return j.useEffect(()=>{const l=matchMedia("(prefers-reduced-motion: reduce)"),d=()=>{l.matches&&(o==null||o())};return d(),l.addEventListener("change",d),()=>l.removeEventListener("change",d)},[o]),j.useLayoutEffect(()=>{var d;const l=(d=s.current)==null?void 0:d.getBBox();l&&c({x:l.x-r,y:l.y-r,width:l.width+r*2,height:l.height+r*2})},[e,r]),f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("mask",{id:i,maskUnits:"userSpaceOnUse",...a,children:f.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:l=>{l.animationName==="flow-sdk-edge-reveal"&&(o==null||o())},"data-reveal-direction":t?"reverse":"forward",style:{"--flow-edge-reveal-from":t?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:r,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${i})`,children:n})]})}const r1=".flow-sdk-edge-trace{pointer-events:none;animation:flow-sdk-edge-trace 2.4s linear infinite}.flow-sdk-edge-trace-reverse{animation-direction:reverse}@keyframes flow-sdk-edge-trace{from{stroke-dashoffset:18}to{stroke-dashoffset:-100}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-trace,.flow-sdk-edge-anim{animation:none}}";function n1({path:e,color:r,width:t,reversed:n}){return f.jsx("path",{className:`flow-sdk-edge-trace${n?" flow-sdk-edge-trace-reverse":""}`,"data-animation-variant":"traveling","aria-hidden":"true",pointerEvents:"none",d:e,fill:"none",stroke:r,strokeWidth:t,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const Ub=".flow-sdk-node-animation{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:1}.flow-sdk-node-border-animation{pointer-events:none;animation:flow-sdk-node-border 2.4s linear infinite}.flow-sdk-node-border-pulse{stroke-width:var(--flow-pulse-rest-width);animation:flow-sdk-node-pulse 1.8s ease-in-out infinite}@keyframes flow-sdk-node-border{from{stroke-dashoffset:0}to{stroke-dashoffset:-100}}@keyframes flow-sdk-node-pulse{0%,100%{stroke-width:var(--flow-pulse-rest-width)}50%{stroke-width:var(--flow-pulse-expanded-width)}}@media(prefers-reduced-motion:reduce){.flow-sdk-node-border-animation{animation:none}}";function go({x:e=0,y:r=0,width:t,height:n,radius:o,color:i,strokeWidth:s=8,path:a,variant:c="traveling"}){const l=j.useId(),d=`flow-sdk-node-border-animation${c==="pulse"?" flow-sdk-node-border-pulse":""}`;if(c==="pulse"){const u=a?"path":"rect",h=a?{d:a}:{x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2))},p=s+36,m={x:e-p,y:r-p,width:t+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:l,maskUnits:"userSpaceOnUse",...m,style:{maskType:"luminance"},children:[f.jsx("rect",{...m,fill:"white"}),f.jsx(u,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(u,{...h,className:d,"data-animation-variant":c,fill:"none",stroke:`color-mix(in srgb, ${i} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${l})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):f.jsx("rect",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2)),fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const o1=e=>{const n=1/(Math.cbrt(e)*.8);let o=Math.round(650*n),i=Math.round(350*n);return o=Math.max(40,Math.min(450,o)),i=Math.max(30,Math.min(300,i)),{edgeSep:o,rankSep:i}};function Kb(e,r=!1){return e&&!r&&typeof requestAnimationFrame<"u"&&!(typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches)}function Jb(e,r,t=()=>{},n=300){let o,i,s=!1;const a=()=>{s=!0,o!==void 0&&cancelAnimationFrame(o),clearTimeout(i)},c=()=>{s||(a(),r(1),t())};if(!Kb(e))return c(),a;const l=performance.now(),d=u=>{if(s)return;const h=Math.max(0,Math.min(1,(u-l)/n));if(h>=1)return c();r(h<.5?4*h**3:1-(-2*h+2)**3/2),s||(o=requestAnimationFrame(d))};return o=requestAnimationFrame(d),i=setTimeout(c,n+100),a}function Zu(e,r,t){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const s of r)(s.parent===i||s.id.startsWith(`${i}.`)||t.some(c=>(c.inverted?c.target:c.source)===i&&(c.inverted?c.source:c.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),o.push(s.id))}return n}function i1(e,r,t){const n=t==="downward"||t==="upward",o=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=r(s.source),c=r(s.target);if(!a||!c)continue;const l=n?c.y-a.y:c.x-a.x,d=Math.abs(l)-(n?a.h+c.h:a.w+c.w)/2;if(d<=320)continue;const u=JSON.stringify([s.source,Math.sign(l)]),h=o.get(u)??[];h.push({edge:s,gap:d,cross:n?c.x-a.x:c.y-a.y}),o.set(u,h)}const i=new Map;for(const s of o.values()){if(new Set(s.map(({edge:c})=>c.target)).size<2)continue;const a=new Map;for(const{edge:c}of s)a.set(c.target,(a.get(c.target)??0)+1);for(const c of[-1,0,1]){const l=s.filter(({cross:u})=>Math.sign(u)===c);l.sort((u,h)=>Math.abs(h.cross)-Math.abs(u.cross)||u.edge.id.localeCompare(h.edge.id));const d=Math.min(...l.map(({gap:u})=>u));l.forEach(({edge:u,gap:h,cross:p},m)=>{const g=l.length===1?d/2:120+(d-280)*m/(l.length-1),y=l.find(b=>Math.abs(b.cross)<Math.abs(p));i.set(u.id,{turn:g/h,labelAtTarget:a.get(u.target)===1,labelFraction:p?(p+((y==null?void 0:y.cross)??0))/(2*p):.5})})}}return i}const ir=e=>({x1:e.x-e.w/2,y1:e.y-e.h/2,x2:e.x+e.w/2,y2:e.y+e.h/2}),a1=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function ei(e){if(!e.length)return null;const r={...e[0]};for(let t=1;t<e.length;t++)r.x1=Math.min(r.x1,e[t].x1),r.y1=Math.min(r.y1,e[t].y1),r.x2=Math.max(r.x2,e[t].x2),r.y2=Math.max(r.y2,e[t].y2);return r}const s1=(e,r)=>e.x1<=r.x2&&e.x2>=r.x1&&e.y1<=r.y2&&e.y2>=r.y1,Xu=(e,r)=>e.x>=r.x1&&e.x<=r.x2&&e.y>=r.y1&&e.y<=r.y2,Bt=e=>(Math.round(e*10)/10).toString(),xt=e=>`${Bt(e.x)} ${Bt(e.y)}`,c1=e=>e>0?1:e<0?-1:0,Yu=(e,r)=>e>0?Math.max(e-r,0):Math.min(e+r,0);function l1(e,r,t,n,o=10){const i=r.x-e.x,s=r.y-e.y,a=Yu(i,(e.w+r.w)/2),c=Yu(s,(e.h+r.h)/2),l=t==="downward"||t==="upward",d=l?c:a,u=l?s:i,h=c1(u),p=n*d,m=v=>Math.abs(v)<o||Math.abs(v)>=Math.abs(d),g=m(p)||m(Math.abs(d)-Math.abs(p));let y;if(g)if(l)if(Math.abs(u)<=e.h/2){const v=(e.x+r.x)/2;y=[v,e.y,v,r.y]}else if(Math.abs(i)<=r.w/2){const v=(e.y+r.y)/2;y=[e.x,v,r.x,v]}else y=[e.x,r.y];else if(Math.abs(u)<=e.w/2){const v=(e.y+r.y)/2;y=[e.x,v,r.x,v]}else if(Math.abs(s)<=r.h/2){const v=(e.x+r.x)/2;y=[v,e.y,v,r.y]}else y=[r.x,e.y];else if(l){const v=e.y+p+e.h/2*h;y=[e.x,v,r.x,v]}else{const v=e.x+p+e.w/2*h;y=[v,e.y,v,r.y]}const b=[{x:e.x,y:e.y}];for(let v=0;v<y.length;v+=2)b.push({x:y[v],y:y[v+1]});return b.push({x:r.x,y:r.y}),b}function d1(e,r,t){const n=r.x-e.x,o=r.y-e.y,i=n>0?(t.x2-e.x)/n:n<0?(t.x1-e.x)/n:1/0,s=o>0?(t.y2-e.y)/o:o<0?(t.y1-e.y)/o:1/0,a=Math.min(i,s);return!Number.isFinite(a)||a>=1||a<0?null:{x:e.x+n*a,y:e.y+o*a}}function sn(e,r,t){var s;if(!((s=t.outline)!=null&&s.length))return d1(e,r,ir(t));const n=r.x-e.x,o=r.y-e.y;let i=1/0;return t.outline.forEach((a,c,l)=>{const d=l[(c+1)%l.length],u=d.x-a.x,h=d.y-a.y,p=n*h-o*u;if(Math.abs(p)<1e-9)return;const m=a.x-e.x,g=a.y-e.y,y=(m*h-g*u)/p,b=(m*o-g*n)/p;y>=0&&y<1&&b>=-1e-9&&b<=1+1e-9&&(i=Math.min(i,y))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function Zb(e,r,t=.5){const n=Number.isFinite(t)?Math.max(0,Math.min(1,t)):.5,o=r==="top"||r==="bottom",i=r==="top"||r==="left"?-1:1,s={x:o?e.x-e.w/2+e.w*n:e.x,y:o?e.y:e.y-e.h/2+e.h*n},a=Math.max(e.w,e.h)*2+1;return{...sn(s,{x:s.x+(o?0:i*a),y:s.y+(o?i*a:0)},e)??{x:o?s.x:e.x+i*e.w/2,y:o?e.y+i*e.h/2:s.y},side:r}}function Qr(e,r){return{x:e.x+(e.side==="right"?r:e.side==="left"?-r:0),y:e.y+(e.side==="bottom"?r:e.side==="top"?-r:0)}}function u1(e,r,t,n){const o=Qr(e,t.srcDist),i=Qr(r,t.tgtDist);if(n==="straight")return Yb(o,i,t);const s=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),a=e.side==="bottom"&&r.side==="top"?i.y-o.y:e.side==="top"&&r.side==="bottom"?o.y-i.y:e.side==="right"&&r.side==="left"?i.x-o.x:e.side==="left"&&r.side==="right"?o.x-i.x:void 0,c=a!==void 0&&a>0?Math.min(s,a/2):s,l=Qr({...o,side:e.side},c),d=Qr({...i,side:r.side},c),u=t.arrowAt==="source"?Et(o,l,t.arrowGap):o,h=t.arrowAt==="target"?Et(i,d,t.arrowGap):i,p=t.arrowAt==="source"?Wt(o,l,t.arrowSize,t.headShape):t.arrowAt==="target"?Wt(i,d,t.arrowSize,t.headShape):void 0;if(n==="bezier")return{d:`M${xt(u)} C${xt(l)} ${xt(d)} ${xt(h)}`,arrow:p,label:{x:(u.x+3*l.x+3*d.x+h.x)/8,y:(u.y+3*l.y+3*d.y+h.y)/8,angle:0}};const m=e.side==="left"||e.side==="right",g=r.side==="left"||r.side==="right";let y;if(m!==g){const v=m?{x:d.x,y:l.y}:{x:l.x,y:d.y},w=(v.x-l.x)*(l.x-o.x)+(v.y-l.y)*(l.y-o.y)>=0,x=(v.x-d.x)*(d.x-i.x)+(v.y-d.y)*(d.y-i.y)>=0;y=[w&&x?v:m?{x:l.x,y:d.y}:{x:d.x,y:l.y}]}else if(a!==void 0&&a<=0)if(m){const v=(l.y+d.y)/2;y=[{x:l.x,y:v},{x:d.x,y:v}]}else{const v=(l.x+d.x)/2;y=[{x:v,y:l.y},{x:v,y:d.y}]}else if(m){const v=e.side===r.side?e.side==="right"?Math.max(l.x,d.x):Math.min(l.x,d.x):(l.x+d.x)/2;y=[{x:v,y:l.y},{x:v,y:d.y}]}else{const v=e.side===r.side?e.side==="bottom"?Math.max(l.y,d.y):Math.min(l.y,d.y):(l.y+d.y)/2;y=[{x:l.x,y:v},{x:d.x,y:v}]}const b=[l,...y,d].filter((v,w,x)=>w===0||v.x!==x[w-1].x||v.y!==x[w-1].y);return Po(u,b,h,p,n==="orthogonal"?0:t.radius)}function Et(e,r,t){const n=e.x-r.x,o=e.y-r.y,i=Math.hypot(n,o);if(!i)return e;let s=(i-t)/i;return s<0&&(s=1e-5),{x:r.x+s*n,y:r.y+s*o}}function Wt(e,r,t,n="triangle"){const o=e.x-r.x,i=e.y-r.y,s=Math.hypot(o,i)||1,a=o/s,c=i/s,l=(n==="square"?.15:.3)*t,d=.15*t,u=e.x-a*l,h=e.y-c*l;if(n==="square")return`M${xt(e)} L${Bt(e.x-c*d)} ${Bt(e.y+a*d)} L${Bt(u-c*d)} ${Bt(h+a*d)} L${Bt(u+c*d)} ${Bt(h-a*d)} L${Bt(e.x+c*d)} ${Bt(e.y-a*d)} Z`;const p=[e,{x:u-c*d,y:h+a*d},{x:u+c*d,y:h-a*d}];return p.map((g,y)=>{const b=p[(y+2)%3],v=p[(y+1)%3],w=Math.hypot(b.x-g.x,b.y-g.y),x=Math.hypot(v.x-g.x,v.y-g.y),C={x:(b.x-g.x)/w,y:(b.y-g.y)/w},S={x:(v.x-g.x)/x,y:(v.y-g.y)/x},E=Math.max(-1,Math.min(1,C.x*S.x+C.y*S.y)),R=Math.sqrt((1-E)/(1+E)),P=Math.min(1/R,w/2,x/2);return{start:{x:g.x+C.x*P,y:g.y+C.y*P},end:{x:g.x+S.x*P,y:g.y+S.y*P},radius:P*R}}).map((g,y)=>`${y?"L":"M"}${xt(g.start)} A${Bt(g.radius)} ${Bt(g.radius)} 0 0 1 ${xt(g.end)}`).join(" ")+" Z"}function Cr(e,r){let t=Math.atan(r/e);return e===0&&t<0&&(t=-t),Number.isFinite(t)||(t=0),t*180/Math.PI}function f1(e,r,t,n){const o={x:r.x-e.x,y:r.y-e.y},i={x:t.x-r.x,y:t.y-r.y},s=Math.hypot(o.x,o.y),a=Math.hypot(i.x,i.y),c=o.x*i.y-o.y*i.x;if(s<1e-6||a<1e-6||Math.abs(c)<1e-6)return{p1:r,b:r,p2:r,r:0};const l=Math.min(n,s/2,a/2);return{p1:{x:r.x-o.x/s*l,y:r.y-o.y/s*l},b:r,p2:{x:r.x+i.x/a*l,y:r.y+i.y/a*l},r:l}}function Xb(e,r,t,n){let o=-1,i=null;for(let m=0;m<e.length-1;m++){const g=sn(e[m],e[m+1],r);if(g){o=m,i=g;break}}let s=-1,a=null;for(let m=e.length-1;m>0;m--){const g=sn(e[m],e[m-1],t);if(g){s=m,a=g;break}}if(!i||!a||o>=s)return null;const c=e.slice(o+1,s),l=c[0]??a,d=c[c.length-1]??i;let u,h,p;if(n.arrowAt==="source"){const m=Et(i,l,n.srcDist);u=Et(i,l,n.srcDist+n.arrowGap),p=Wt(m,l,n.arrowSize,n.headShape)}else u=Et(i,l,n.srcDist);if(n.arrowAt==="target"){const m=Et(a,d,n.tgtDist);h=Et(a,d,n.tgtDist+n.arrowGap),p=Wt(m,d,n.arrowSize,n.headShape)}else h=Et(a,d,n.tgtDist);return Po(u,c,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function Po(e,r,t,n,o,i,s){var h;const a=[e,...r,t],c=[];let l=`M${xt(e)}`;for(let p=1;p<a.length-1;p++){const m=f1(a[p-1],a[p],a[p+1],o);c.push(m),m.r===0?l+=` L${xt(m.b)}`:l+=` L${xt(m.p1)} Q${xt(m.b)} ${xt(m.p2)}`}l+=` L${xt(t)}`;let d;const u=r.length;if(u===0)d={x:(e.x+t.x)/2,y:(e.y+t.y)/2,angle:Cr(t.x-e.x,t.y-e.y)};else if(u%2===0){const p=r[u/2-1],m=r[u/2];d={x:(p.x+m.x)/2,y:(p.y+m.y)/2,angle:Cr(m.x-p.x,m.y-p.y)}}else{const p=c[(u-1)/2];if(p.r===0){const m=a[(u-1)/2+2];d={x:p.b.x,y:p.b.y,angle:Cr(m.x-p.b.x,m.y-p.b.y)}}else d={x:.25*p.p1.x+.5*p.b.x+.25*p.p2.x,y:.25*p.p1.y+.5*p.b.y+.25*p.p2.y,angle:Cr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(s!==void 0&&c.length===2){const y=c[0].p2,b=c[1].p1,v=Math.hypot(b.x-y.x,b.y-y.y),w=Math.min(.5,i/(2*v)),x=Math.max(w,Math.min(1-w,s));d={x:y.x+(b.x-y.x)*x,y:y.y+(b.y-y.y)*x,angle:Cr(b.x-y.x,b.y-y.y)}}const p=((h=c[c.length-1])==null?void 0:h.p2)??e,m=t.x-p.x,g=t.y-p.y;Math.hypot(m,g)>=i&&(d={x:(p.x+t.x)/2,y:(p.y+t.y)/2,angle:Cr(m,g)})}return{d:l,arrow:n,label:d}}function Qu(e,r,t,n,o,i,s){const a=t==="leftward"?-1:1,c={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},l={x:r.x-a*(r.w/2+s.tgtDist),y:o??r.y},d=Math.max(80,s.arrowGap+s.arrowSize*.3),u=c.x+a*d,h=l.x-a*d;let p;if(a*(h-u)>=0){const b=c.x+(l.x-c.x)*i,v=Math.max(Math.min(u,h),Math.min(Math.max(u,h),b));p=[{x:v,y:c.y},{x:v,y:l.y}]}else{const b=Math.min(e.y-e.h/2,r.y-r.h/2)-d*(1+i);p=[{x:u,y:c.y},{x:u,y:b},{x:h,y:b},{x:h,y:l.y}]}const m=s.arrowAt==="source"?Et(c,p[0],s.arrowGap):c,g=s.arrowAt==="target"?Et(l,p[p.length-1],s.arrowGap):l,y=s.arrowAt==="source"?Wt(c,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?Wt(l,p[p.length-1],s.arrowSize,s.headShape):void 0;return Po(m,p,g,y,s.radius)}function ef(e,r,t,n,o){return Xb(l1(e,r,t,n),e,r,o)}function tf(e,r,t,n,o,i){const s=n===void 0&&o===void 0&&(t==="downward"||t==="upward"),a=t==="leftward"||s&&t==="upward"?-1:1,c=(l,d,u)=>{const h={x:l.x,y:d??l.y},p=Math.max(l.w,l.h)*2+1,m=sn(h,{x:h.x+(s?0:u*p),y:h.y+(s?u*p:0)},l);return m?{x:m.x+(s?0:u*i),y:m.y+(s?u*i:0)}:s?{x:l.x,y:l.y+u*(l.h/2+i)}:{x:l.x+u*(l.w/2+i),y:d??l.y}};return{sourcePoint:c(e,n,a),targetPoint:c(r,o,-a)}}function h1(e,r,t,n){const o=t==="downward"||t==="upward",i=t==="leftward"||t==="upward"?-1:1,s=Math.max(100,Math.abs(o?r.y-e.y:r.x-e.x)/2),a={x:e.x+(o?0:i*s),y:e.y+(o?i*s:0)},c={x:r.x-(o?0:i*s),y:r.y-(o?i*s:0)},l=n.arrowAt==="source"?Et(e,a,n.arrowGap):e,d=n.arrowAt==="target"?Et(r,c,n.arrowGap):r;return{d:`M${xt(l)} C${xt(a)} ${xt(c)} ${xt(d)}`,arrow:n.arrowAt==="source"?Wt(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?Wt(r,c,n.arrowSize,n.headShape):void 0,label:{x:(l.x+3*a.x+3*c.x+d.x)/8,y:(l.y+3*a.y+3*c.y+d.y)/8,angle:Cr(d.x+c.x-a.x-l.x,d.y+c.y-a.y-l.y)}}}function Yb(e,r,t){const n=t.arrowAt==="source"?Et(e,r,t.arrowGap):e,o=t.arrowAt==="target"?Et(r,e,t.arrowGap):r,i=t.arrowAt==="source"?Wt(e,r,t.arrowSize,t.headShape):t.arrowAt==="target"?Wt(r,e,t.arrowSize,t.headShape):void 0;return Po(n,[],o,i,0)}function p1(e,r,t,n=-90,o=-60,i=350){const s=n*Math.PI/180,a=o*Math.PI/180,c=s-Math.PI/2,l=c-a/2,d=c+a/2,u=1.4*i*(r/3+1),h={x:e.x+Math.cos(l)*u,y:e.y+Math.sin(l)*u},p={x:e.x+Math.cos(d)*u,y:e.y+Math.sin(d)*u},m={x:e.x,y:e.y},g=sn(m,h,e),y=sn(m,p,e);if(!g||!y)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let v=Et(g,h,t.srcDist),w=Et(y,p,t.tgtDist),x;if(t.arrowAt==="target"){const S=w;w=Et(y,p,t.tgtDist+t.arrowGap),x=Wt(S,p,t.arrowSize,t.headShape)}else if(t.arrowAt==="source"){const S=v;v=Et(g,h,t.srcDist+t.arrowGap),x=Wt(S,h,t.arrowSize,t.headShape)}return{d:`M${xt(v)} Q${xt(h)} ${xt(b)} Q${xt(p)} ${xt(w)}`,arrow:x,label:{x:b.x,y:b.y,angle:Cr(p.x-h.x,p.y-h.y)}}}const $r=e=>Math.round(e*1e3)/1e3;function Qb(e){var h,p;const r=e.querySelector("[data-flow-node-surface]");if(!r)return;const t=e.getBoundingClientRect(),n=t.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const o=r.getBoundingClientRect();if(!o.width||!o.height)return;const i=(p=(h=r.closest("[data-flow-icon-label]"))==null?void 0:h.querySelector("[data-flow-icon-caption]"))==null?void 0:p.getBoundingClientRect(),s=r,a=typeof s.getScreenCTM=="function"?s.getScreenCTM():null,c=typeof s.getTotalLength=="function"?s.getTotalLength():0,l=s.points,d=(l==null?void 0:l.numberOfItems)||128,u=a&&c>0?Array.from({length:d},(m,g)=>{const y=l!=null&&l.numberOfItems?l.getItem(g):s.getPointAtLength(c*g/d);return{x:$r((a.a*y.x+a.c*y.y+a.e-t.left)/n),y:$r((a.b*y.x+a.d*y.y+a.f-t.top)/n)}}):void 0;return{left:$r((o.left-t.left)/n),top:$r((o.top-t.top)/n),width:r instanceof HTMLElement?r.offsetWidth:$r(o.width/n),height:r instanceof HTMLElement?r.offsetHeight:$r(o.height/n),radius:parseFloat(getComputedStyle(r).borderTopLeftRadius)||0,...i!=null&&i.height?{captionBottom:$r((i.bottom-t.top)/n)}:{},...u?{outline:u}:{}}}function qn(e,r){const t=e.x-e.w/2,n=e.y-e.h/2;return{x:t+r.left+r.width/2,y:n+r.top+r.height/2,w:r.width,h:r.height,...r.outline?{outline:r.outline.map(o=>({x:t+o.x,y:n+o.y}))}:{}}}function g1(e,r,t,n,o){var d;const i=o!=="TB"&&o!=="BT",s=i?"top":"left",a=i?"bottom":"right",c=new Map;for(const u of n)for(const[h,p,m]of[[u.source,u.sourceProperty,u.target],[u.target,u.targetProperty,u.source]]){const g=r.get(m);if(p===void 0||!g||m===h)continue;const y=t.get(m),b=JSON.stringify([h,p]),v=c.get(b)??[];v.push(y?qn(g,y):g),c.set(b,v)}const l=new Map(e);for(const[u,h]of e){const p=r.get(u);if(!p||!h.some(w=>w.placement==="config"))continue;const m=t.get(u),g=m?qn(p,m):p,y={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=m?qn(y,m):y,v=new Map;for(const w of h){if(w.placement!=="config")continue;const C=(c.get(JSON.stringify([u,w.property]))??[]).reduce((E,R)=>E+(i?R.y-g.y:R.x-g.x),0),S=((d=w.anchor)==null?void 0:d.side)===a?a:s;v.set(w,C<-.001?s:C>.001?a:S)}l.set(u,h.map(w=>{const x=v.get(w);if(!x)return w;const C=h.filter(R=>v.get(R)===x),S=(C.indexOf(w)+1)/(C.length+1),E=Zb(b,x,S);return{...w,anchor:E,top:E.y,height:0}}))}return l}function rf(e,r,t){const n=new Set(r.map(a=>a.id));if(!n.has(e))return new Set;const o=new Set([e]);let i=!0;for(;i;){i=!1;for(const a of r)!o.has(a.id)&&(o.has(a.parent??"")||a.id.startsWith(`${e}.`))&&(o.add(a.id),i=!0)}const s=new Set(o);for(const a of t)o.has(a.source)&&n.has(a.target)&&s.add(a.target),o.has(a.target)&&n.has(a.source)&&s.add(a.source);return s}const _r='"Helvetica Neue", Helvetica, sans-serif';let Cn;const oo=new Map;function Ao(e,r){const t=`${r}|${e}`,n=oo.get(t);if(n!==void 0)return n;Cn===void 0&&(Cn=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return Cn?(Cn.font=r,o=Cn.measureText(e).width):o=e.length*(parseFloat(r)||16)*.55,oo.size>5e3&&oo.clear(),oo.set(t,o),o}function y1(e,r,t){const n=[];for(const o of String(e).split(`
209
+ `;function Ku({request:e,property:r,config:t,value:n,disabled:o}){var he,U,re,fe,we;const{callbacks:i,structured:s,references:a}=j.useContext($t),{themeColor:c}=He(),{background:l}=at(),d=j.useId(),u=r.type.kind==="object"||r.type.kind==="array"||r.type.kind==="json",h=n===void 0?"":u?JSON.stringify(n,null,2):String(n),[p,m]=j.useState(h),[g,y]=j.useState(""),[b,v]=j.useState(0),w=j.useRef(null),x=j.useRef(),[C,S]=j.useState(!1),[E,R]=j.useState(!1),[P,I]=j.useState(),M=((he=t.$options)==null?void 0:he.$source)==="callback",k=i.resolveFormOptions,{data:_,address:N,nodeAddress:O,nodeId:V}=e;j.useEffect(()=>(S(!1),R(!1),()=>{var ie;(ie=x.current)==null||ie.abort(),x.current=void 0}),[N,O,V,o,h,t.$control,(U=t.$upload)==null?void 0:U.accept,(re=t.$upload)==null?void 0:re.maxSizeBytes]);const T=j.useRef(_);T.current=_;const Z=JSON.stringify([N,V,(fe=t.$options)!=null&&fe.$dependsOn?t.$options.$dependsOn.map(ie=>Oe(_,ie)):Oe(_,O)]);j.useEffect(()=>{m(h),y("")},[h,N,V]),j.useEffect(()=>{if(!M)return;const ie=new AbortController;return Promise.resolve().then(()=>{if(!k)throw new Error("No options resolver configured");return k({address:N,nodeAddress:O,nodeId:V,data:an(T.current),signal:ie.signal})}).then(Ce=>{if(!Array.isArray(Ce)||Ce.some($e=>!$e||typeof $e.label!="string"||!["string","number","boolean"].includes(typeof $e.value)&&$e.value!==null))throw new Error("Invalid options response");ie.signal.aborted||I({key:Z,options:Ce})}).catch(Ce=>{ie.signal.aborted||I({key:Z,options:[],error:Ce instanceof Error?Ce.message:"Options unavailable"})}),()=>ie.abort()},[M,k,Z,N,O,V,b]);const ue=M&&(P==null?void 0:P.key)!==Z,K=M?(P==null?void 0:P.key)===Z?P.options:[]:r.type.kind==="null"?[{label:"Null",value:null}]:r.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:On(r.type),ee=r.type.kind==="array",H=(t.$control==="upload"?"upload":s&&u||t.$control==="checkbox"?"pills":t.$control)??(K?ee||r.type.kind==="boolean"?"pills":"select":r.type.kind==="boolean"?"checkbox":u?"textarea":"input"),ae=!r.optional||!!t.$requiredWhen&&Eo(t.$requiredWhen,_),q=ae?"Required":"Optional",D=H!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),G=g||M&&(P==null?void 0:P.key)===Z&&P.error||!D&&Jt(r.type,n,ae),B=Dt(t.$label??N.split(".").pop()),se=ie=>{var Ce;if(!(o||Object.is(ie,n)))try{(Ce=i.onFormChange)==null||Ce.call(i,{...e,previousValue:n,value:ie}),y("")}catch($e){y($e instanceof Error?$e.message:"Unable to update field")}},te=j.useRef(se);j.useLayoutEffect(()=>{te.current=se});const le=()=>{if(u){try{const Ue=p===""&&r.optional?void 0:JSON.parse(p),Ve=Jt(r.type,Ue,ae);if(Ve){y(Ve);return}se(Ue)}catch{y("Enter valid JSON")}return}const ie=r.type.kind==="number"||r.type.kind==="integer",Ce=p===""&&r.optional?void 0:ie&&p!==""?Number(p):p,$e=Jt(r.type,Ce,ae);if(ie&&$e&&p!==""){y($e);return}se(Ce)},ne=async ie=>{var $e,Ue,Ve;if(o||x.current||!ie.length)return;const Ce=new AbortController;x.current=Ce,y(""),S(!0);try{if(r.type.kind!=="string"&&!(r.type.kind==="array"&&r.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!ee&&ie.length!==1)throw new Error("Choose one file for this field.");if(!i.uploadFormFile)throw new Error("No file upload handler configured.");const tt=(Ue=($e=t.$upload)==null?void 0:$e.accept)==null?void 0:Ue.split(",").map(be=>be.trim().toLowerCase()).filter(Boolean);for(const be of ie){if(((Ve=t.$upload)==null?void 0:Ve.maxSizeBytes)!==void 0&&be.size>t.$upload.maxSizeBytes)throw new Error(`${be.name} exceeds the file size limit.`);if(tt!=null&&tt.length&&!tt.some(Xe=>Xe.startsWith(".")?be.name.toLowerCase().endsWith(Xe):Xe.endsWith("/*")?be.type.toLowerCase().startsWith(Xe.slice(0,-1)):be.type.toLowerCase()===Xe))throw new Error(`${be.name} is not an accepted file type.`)}const ye=await Promise.all(ie.map(async be=>{const Xe=await i.uploadFormFile({...e,data:an(_),file:be,signal:Ce.signal});if(typeof Xe!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let ut;try{ut=new URL(Xe)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(ut.protocol)||ut.username||ut.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return Xe}));if(Ce.signal.aborted||x.current!==Ce)return;const Ae=ee?[...Array.isArray(n)?n:[],...ye]:ye[0],Le=Jt(r.type,Ae,ae);if(Le)throw new Error(Le);te.current(Ae)}catch(tt){Ce.signal.aborted||y(tt instanceof Error?tt.message:"Unable to upload file."),Ce.abort()}finally{x.current===Ce&&(x.current=void 0,S(!1))}},ce={id:d,disabled:o,"aria-label":B,"aria-required":ae,"aria-invalid":!!G,"aria-describedby":G?`${d}-error`:void 0},xe=Te(c);return f.jsxs("div",{"data-form-field":N,"data-flow-property":N.slice(O.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:d,children:[B,ae?" *":""]}),r.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${B}`,title:`Reset ${B}`,disabled:o||C,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>se(void 0),children:f.jsx(Q.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!u&&H!=="upload"&&f.jsx(Vw,{label:B,value:n,references:a,disabled:o,onChange:se}),H==="upload"?f.jsxs("div",{"data-form-upload":ee?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":Te(l),outline:E?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:ie=>{ie.preventDefault(),ie.stopPropagation(),!o&&!C&&(ie.dataTransfer.dropEffect="copy",R(!0))},onDragLeave:ie=>{ie.currentTarget.contains(ie.relatedTarget)||R(!1)},onDrop:ie=>{ie.preventDefault(),ie.stopPropagation(),R(!1),ne(Array.from(ie.dataTransfer.files))},children:[f.jsx("input",{ref:w,type:"file",hidden:!0,"aria-label":`Upload ${B}`,accept:(we=t.$upload)==null?void 0:we.accept,multiple:ee,disabled:o||C,onChange:ie=>{const Ce=Array.from(ie.target.files??[]);ie.target.value="",ne(Ce)}}),f.jsxs("div",{"data-upload-items":"",children:[(ee?Array.isArray(n)?n:[]:n?[n]:[]).map((ie,Ce)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof ie=="string"&&wr(ie)&&f.jsxs("a",{href:ie,target:"_blank",rel:"noopener noreferrer","aria-label":`${B} file ${Ce+1}`,children:[f.jsx(Q.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(cr,{name:ie,size:120,onError:$e=>{$e.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!ee&&f.jsx(Ne,{"aria-label":`Replace ${B}`,title:`Replace ${B}`,icon:f.jsx(Q.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>{var $e;return($e=w.current)==null?void 0:$e.click()}}),f.jsx(Ne,{"aria-label":`Remove ${B} file ${Ce+1}`,title:"Remove file",icon:f.jsx(Q.PiTrash,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>se(ee&&Array.isArray(n)?n.filter(($e,Ue)=>Ue!==Ce):"")})]})]},`${Ce}:${ie}`)),(ee||!n)&&f.jsx("button",{...ce,type:"button","data-upload-drop":"",title:`Upload ${B}`,disabled:o||C,onClick:()=>{var ie;return(ie=w.current)==null?void 0:ie.click()},children:f.jsx(Q.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):D?null:H==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(It,{...ce,disabled:o||ue||!!(P!=null&&P.error),labelCase:"preserve",value:String((K==null?void 0:K.findIndex(ie=>Object.is(ie.value,n)))??-1),onValueChange:ie=>{const Ce=K==null?void 0:K[Number(ie)];Ce&&se(Ce.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):q}),K==null?void 0:K.map((ie,Ce)=>f.jsx("option",{value:Ce,...ie.description?{description:ie.description}:{},children:Dt(ie.label)||ie.label},Ce))]})}):H==="pills"?f.jsxs("div",{id:d,role:"group","aria-label":B,"aria-describedby":ce["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[K==null?void 0:K.map((ie,Ce)=>{const $e=ee?Array.isArray(n)&&n.includes(ie.value):Object.is(n,ie.value);return f.jsx("button",{type:"button",disabled:o||ue,"aria-pressed":$e,style:{padding:"8px 16px",borderRadius:24,border:0,color:$e?xe:"inherit",background:$e?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>se(ee?$e?n.filter(Ue=>Ue!==ie.value):[...Array.isArray(n)?n:[],ie.value]:ie.value),children:Dt(ie.label)||ie.label},Ce)}),ue&&f.jsx("span",{role:"status",children:"Loading..."})]}):H==="textarea"?f.jsx("textarea",{...ce,placeholder:q,value:p,onChange:ie=>m(ie.target.value),onBlur:le}):f.jsx("input",{...ce,placeholder:q,type:r.type.kind==="number"||r.type.kind==="integer"?"number":"text",step:r.type.kind==="integer"?1:"any",value:p,onChange:ie=>m(ie.target.value),onBlur:le,onKeyDown:ie=>{ie.key==="Enter"&&le(),ie.key==="Escape"&&m(n===void 0?"":String(n))}}),G&&f.jsx("div",{role:"alert",id:`${d}-error`,children:G}),M&&(P==null?void 0:P.error)&&f.jsx("button",{type:"button",disabled:o,onClick:()=>{I(void 0),v(b+1)},children:"Retry"})]})}function Vd({nodeAddress:e,structured:r=!1}){return r?f.jsx(Hw,{nodeAddress:e},e):f.jsx(Ed,{nodeAddress:e})}function Hw({nodeAddress:e}){var u,h,p;const r=j.useContext($t),[t,n]=j.useState([]),o=((u=r.structured)==null?void 0:u.sourceSchema)??r.schema,i=((h=r.structured)==null?void 0:h.sourceBindings)??r.bindings,s=j.useMemo(()=>{if(!(!r.data||!o||!i))return kb(r.data,i,o,[{data:{id:e,type:"objectView"}}])},[r.data,i,o,e]);if(!s)return f.jsx(Ed,{nodeAddress:e});const a=t.findIndex(m=>!s.containers.has(m)),c=a<0?t:t.slice(0,a),l=(c==null?void 0:c.at(-1))??e,d=(p=[...s.slots.values()].find(m=>m.nodeId===l))==null?void 0:p.label;return f.jsxs($t.Provider,{value:{...r,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:l===e?r.onFieldCreate:void 0},children:[!!c.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Ne,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(Q.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(c.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:Dt(d)})]}),f.jsx(Ed,{nodeAddress:l,onOpen:m=>n([...c,m])},l)]})}function Ed({nodeAddress:e,onOpen:r}){var S,E;const{data:t,schema:n,callbacks:o,bindings:i,editable:s,renderForm:a,structured:c}=j.useContext($t),{readOnly:l,config:d,colorMode:u}=He(),h=a==null?void 0:a(e);if(h!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:l||d.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:h});if(!t)return f.jsx(no,{$colorMode:u,role:"alert",children:"Forms require a JSON document."});const p=i?Hn(i,e,n):void 0,m=i?p:n&&un(t,e,n);if(!m)return f.jsx(no,{$colorMode:u,role:"status",children:"Form schema unavailable."});const g=(p==null?void 0:p.address)??e,y=Oe(t,g),b=(S=c==null?void 0:c.containers.get(e))==null?void 0:S.scalar;if(y===void 0||typeof y!="object"&&!b)return f.jsx(no,{$colorMode:u,role:"alert",children:"Bound form state is unavailable."});const v=Object.entries(m.type.properties).filter(([R])=>{var P;return Eo((P=m.fields[R])==null?void 0:P.$visibleWhen,t)}),w=v.length>8||v.some(([R])=>{var P;return(P=m.fields[R])==null?void 0:P.$section}),x=new Map;for(const R of v){const[P,I]=R,M=w?Dt(((E=m.fields[P])==null?void 0:E.$section)??(I.type.kind==="object"||I.type.kind==="array"?P:I.optional?"Options":"General")):"";x.has(M)||x.set(M,[]),x.get(M).push(R)}const C=([R,P])=>f.jsx(Ku,{request:{data:t,address:b?g:`${g}.${R}`,nodeAddress:g,nodeId:typeof(y==null?void 0:y.id)=="string"?y.id:void 0},property:P,config:m.fields[R]??{},value:b?y:y==null?void 0:y[R],disabled:l||d.editable===!1||!(s??!!o.onJsonChange)},`${(y==null?void 0:y.id)??e}:${R}`);return f.jsxs(no,{$colorMode:u,"data-flow-form":e,onClick:R=>R.stopPropagation(),onDoubleClick:R=>R.stopPropagation(),children:[c&&f.jsx(Gw,{nodeAddress:e,onOpen:r}),!c&&p&&m.type.additionalProperties&&v.length===0&&f.jsx(Ku,{request:{data:t,address:g,nodeAddress:g},property:{type:m.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:y,disabled:l||d.editable===!1||!s}),[...x].map(([R,P])=>w&&P.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:R}),f.jsx(Q.PiCaretDown,{size:16,"aria-hidden":"true"})]}),P.map(C)]},R):P.map(C))]})}function Ab(e){const{viewData:r}=j.useContext($t),{nodeById:t,edgeById:n,parentIds:o}=Xt();if(r){const i=Oe(r,e),s=i&&typeof i=="object"&&!Array.isArray(i)&&"$"in i?i.$:i;return Array.isArray(s)?s.length>0:!!s&&typeof s=="object"&&Object.entries(s).some(([a,c])=>!a.startsWith("$")&&c!==null&&typeof c=="object")}return o.has(e)?!0:[...n.values()].some(({data:i})=>{const s=i.isInverted?i.target:i.source,a=i.isInverted?i.source:i.target;return s===e&&a!==e&&t.has(a)})}function Dn(e,r){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:r}function Wn(e,r,t,n){return{borderColor:r,borderWidth:Dn(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...gb(r==="transparent"?"currentColor":r,t,".flow-sdk-node:hover &",!t)}}function Rb({label:e,value:r,options:t,onChange:n,disabled:o}){var i;return f.jsxs(It,{"aria-label":e,title:`Animation: ${((i=t.find(s=>s.value===r))==null?void 0:i.label)??"Mixed"}`,value:r,style:{width:104},disabled:o,onValueChange:s=>{const a=t.find(c=>c.value===s);a&&n(a.value)},children:[r===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),t.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function Gd({nodeId:e,edgeId:r,value:t,open:n,onOpenChange:o}){const{callbacks:i,readOnly:s,themeColor:a,colorMode:c}=He(),{background:l,backgroundSecondary:d,border:u,colorText:h,colorInactive:p}=at(),m=c==="dark"?ln:Te(p),g=j.useRef(null),y=j.useRef(null),b=j.useRef(0),[v,w]=j.useState(!1),[x,C]=j.useState("icons"),[S,E]=j.useState([]),[R,P]=j.useState("loading"),[I,M]=j.useState(""),[k,_]=j.useState(0),[N,O]=j.useState(""),[V,T]=j.useState(""),[Z,ue]=j.useState(!1);j.useEffect(()=>()=>{b.current++},[]),j.useEffect(()=>{if(!v)return;let B=!0;return import("react-icons/pi").then(se=>{B&&(E(Object.keys(se).filter(te=>te.startsWith("Pi")).sort()),P("ready"))}).catch(()=>{B&&P("unavailable")}),()=>{B=!1}},[v]),j.useEffect(()=>{var B;s&&((B=g.current)==null||B.close())},[s]),j.useEffect(()=>{var B,se,te;if(n!==void 0){if(!n||s){(B=g.current)==null||B.close();return}(se=g.current)!=null&&se.open||(T(""),C(t==="PiFileSvg"||t&&wr(t)?"custom":"icons"),O(t&&!t.startsWith($n)&&wr(t)?t:""),w(!0),(te=g.current)==null||te.showModal())}},[n,s,t]);const K=B=>{var se,te,le;s||(r?(se=i.onEdgeIconChange)==null||se.call(i,r,B):e&&((te=i.onNodeIconChange)==null||te.call(i,e,B)),o==null||o(!1),(le=g.current)==null||le.close())},ee=S.filter(B=>B.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(I.trim().toLowerCase())),H=36,ae=Math.max(1,Math.ceil(ee.length/H)),q=Math.min(k,ae-1),D=ee.slice(q*H,(q+1)*H),G={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${Te(u)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(Ge,{label:r?"Choose edge icon":"Choose node icon",children:f.jsx(Ne,{"aria-label":r?"Choose edge icon":"Choose node icon",icon:f.jsx(Q.PiShapes,{size:20}),size:"sm",variant:"ghost",color:Te(a),disabled:s,onClick:()=>{var B;T(""),C(t&&wr(t)?"custom":"icons"),O(t&&!t.startsWith($n)&&wr(t)?t:""),w(!0),(B=g.current)==null||B.showModal()}})}),f.jsx(W.chakra.dialog,{ref:g,"aria-label":r?"Choose edge icon":"Choose node icon",css:gr(Te(l),Te(u)),onClose:()=>{w(!1),o==null||o(!1),b.current++,ue(!1)},onClick:B=>{B.stopPropagation(),B.target===B.currentTarget&&B.currentTarget.close()},onKeyDown:B=>B.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:Te(l),color:Te(h)},children:v&&f.jsxs("div",{style:{display:"grid",gap:8},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsx("strong",{children:r?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[t&&f.jsx(Ge,{label:"Remove icon",children:f.jsx(Ne,{"aria-label":r?"Remove edge icon":"Remove node icon",icon:f.jsx(Q.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||Z,onClick:()=>K("")})}),f.jsx(dn,{"aria-label":"Close icon picker",onClick:()=>{var B;return(B=g.current)==null?void 0:B.close()}})]})]}),f.jsxs(W.Tabs.Root,{value:x,onValueChange:({value:B})=>{C(B),T("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(W.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(B=>f.jsx(W.Tabs.Trigger,{value:B,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:m,"--indicator-color":m},children:B==="icons"?"React icons":"Custom SVG"},B))}),f.jsx("input",{ref:y,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:Z||s,onChange:async B=>{var le;const se=(le=B.target.files)==null?void 0:le[0];if(B.target.value="",!se)return;const te=++b.current;ue(!0),T("");try{const ne=await $w(se);te===b.current&&K(ne)}catch(ne){te===b.current&&T(ne instanceof Error?ne.message:"Unable to read SVG.")}finally{te===b.current&&ue(!1)}}}),f.jsx(W.Tabs.Content,{value:x,p:0,style:{display:"grid",gap:8},children:x==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:I,onChange:B=>{M(B.target.value),_(0)},style:G}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[D.map(B=>f.jsx("button",{type:"button","aria-label":`Choose ${B}`,"aria-pressed":t===B,title:B,onClick:()=>K(B),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${t===B?2:1}px solid ${Te(t===B?a:u)}`,background:Te(t===B?l:d),color:"inherit",cursor:"pointer"},children:f.jsx(cr,{name:B,size:24})},B)),D.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:R==="loading"?"Loading icons...":R==="unavailable"?"React icons unavailable":"No icons found"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsxs("span",{role:"status",style:{fontSize:12},children:[ee.length," icons · ",q+1," / ",ae]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(Ge,{label:"Previous icons",children:f.jsx(Ne,{"aria-label":"Previous icons",icon:f.jsx(Q.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:q===0,onClick:()=>_(q-1)})}),f.jsx(Ge,{label:"Next icons",children:f.jsx(Ne,{"aria-label":"Next icons",icon:f.jsx(Q.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:q+1>=ae,onClick:()=>_(q+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[t&&wr(t)&&f.jsx(cr,{name:t,size:64}),f.jsxs("button",{type:"button",disabled:Z||s,onClick:()=>{var B;return(B=y.current)==null?void 0:B.click()},style:{...G,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(Q.PiUploadSimple,{}),Z?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:B=>{B.preventDefault(),!(Z||s)&&(!wr(N.trim())||N.trim().startsWith($n)?T("Enter an HTTP or HTTPS image URL."):K(N.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:N,disabled:Z||s,onChange:B=>O(B.target.value),style:{...G,flex:1,minWidth:0}}),f.jsx(Ge,{label:"Apply URL",children:f.jsx(Ne,{type:"submit","aria-label":"Apply URL",icon:f.jsx(Q.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:Z||s||!N.trim(),style:{flexShrink:0}})})]})]})})]}),V&&f.jsx("div",{role:"alert",style:{fontSize:13},children:V})]})})]})}const po=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",ln],Mb=["gray.900",ln,"gray.600","gray.200","white"];function Tb(){const{config:e}=He(),r=e.selectionToolbar||{},t=new Set(r.hide||[]);return{palette:r.palette||po,show:n=>!t.has(n)}}function Tt(){const{border:e}=at();return f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:e})}function Er({value:e,placeholder:r,ariaLabel:t,width:n="140px",type:o="text",min:i,disabled:s=!1,onCommit:a}){const{colorText:c}=at(),[l,d]=j.useState(e),u=j.useRef(!1);j.useEffect(()=>d(e),[e]);const h=()=>{if(s||u.current)return;u.current=!0;const p=l.trim();if(o==="number"&&p!==""&&(!Number.isFinite(Number(p))||Number(p)<(i??0))){d(e);return}p!==e&&a(p)};return f.jsx(W.Input,{"aria-label":t,type:o,min:i,disabled:s,size:"xs",fontSize:"16px",w:n,value:l,placeholder:r,color:c,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{u.current=!1},onChange:p=>d(p.target.value),onBlur:h,onKeyDown:p=>{p.key==="Enter"&&(h(),p.target.blur()),p.key==="Escape"&&(u.current=!0,d(e),p.target.blur())}})}function Vr({colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:s,colorText:a}=at(),[c,l]=j.useState(!1),d=j.useId(),u=j.useRef(null),h=r??e[0]??"transparent",p=jo(f.jsx(Vr,{colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i}));return f.jsx(nn.Provider,{value:null,children:f.jsxs(W.HStack,{gap:1,"aria-label":t,role:"group",onClickCapture:p,onKeyDown:m=>{var g;m.key==="Escape"&&(l(!1),(g=u.current)==null||g.focus())},children:[f.jsx(Ge,{label:`${t}: ${h}`,children:f.jsx(W.chakra.button,{ref:u,type:"button","aria-label":`${t} colors`,"aria-expanded":c,"aria-controls":d,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Te(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${Te(a)}`,outlineOffset:"1px",onClick:()=>l(m=>!m)})}),c&&f.jsxs(W.HStack,{id:d,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(m=>{const g=r===m;return f.jsx(Ge,{label:`${t}: ${m}`,children:f.jsx(W.Box,{as:"button","aria-label":`${t} ${m}`,"aria-pressed":g,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Te(m),...m==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:g?`2px solid ${Te(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(m),onDoubleClick:y=>{var b;y.stopPropagation(),l(!1),(b=u.current)==null||b.focus()}})},m)}),o&&f.jsx(Ge,{label:`Reset ${t.toLowerCase()}`,children:f.jsx(Ne,{"aria-label":`Reset ${t}`,icon:f.jsx(W.Icon,{as:Q.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var m;o(),l(!1),(m=u.current)==null||m.focus()}})})]})]})})}function Ib({edgeId:e,onClose:r}){var p;const{callbacks:t,themeColor:n,config:o}=He(),{colorInactive:i}=at(),{edgeById:s}=Xt(),{palette:a,show:c}=Tb(),l=(p=s.get(e))==null?void 0:p.data,d=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...l!=null&&l.type?[l.type]:[]])],u=l!=null&&l.isEdgeAnimated?"animated":l!=null&&l.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:Q.PiLineSegment,label:"Solid"},{key:"dashed",icon:Q.PiLineSegments,label:"Dashed"},{key:"animated",icon:Q.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(dn,{onClick:r}),c("label")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Er,{ariaLabel:"Edge label",placeholder:"Edge label",value:(l==null?void 0:l.label)||"",onCommit:m=>{var g;return(g=t.onEdgeLabelChange)==null?void 0:g.call(t,e,m)}})]}),c("style")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),h.map(m=>f.jsx(Ge,{label:m.label,children:f.jsx(Ne,{"aria-label":`Edge style ${m.key}`,"aria-pressed":u===m.key,icon:f.jsx(W.Icon,{as:m.icon,boxSize:5}),size:"sm",variant:"ghost",color:u===m.key?n:i,onClick:()=>{var g;return(g=t.onEdgeStyleChange)==null?void 0:g.call(t,e,m.key)}})},m.key)),u==="animated"&&f.jsx(Rb,{label:"Edge animation",value:(l==null?void 0:l.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:m=>{var g;return(g=t.onEdgeAnimationVariantChange)==null?void 0:g.call(t,e,m)}}),f.jsxs(It,{"aria-label":"Edge shape",title:`Edge shape: ${(l==null?void 0:l.type)??"Default"}`,icon:f.jsx(Q.PiBezierCurve,{size:20}),style:{width:36},value:(l==null?void 0:l.type)??"",disabled:o.readOnly,onValueChange:m=>{var g;return(g=t.onEdgeTypeChange)==null?void 0:g.call(t,e,m||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),d.map(m=>f.jsx("option",{value:m,children:m},m))]})]}),c("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Gd,{edgeId:e,value:l==null?void 0:l.icon},e),f.jsx(Er,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(l==null?void 0:l.icon)??"",onCommit:m=>{var g;return(g=t.onEdgeIconChange)==null?void 0:g.call(t,e,m)}})]}),c("color")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Vr,{label:"Edge color",colors:a,value:l==null?void 0:l.color,onPick:m=>{var g;return(g=t.onEdgeColorChange)==null?void 0:g.call(t,e,m)},onReset:()=>{var m;return(m=t.onEdgeColorChange)==null?void 0:m.call(t,e,"")}})]}),c("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:"Delete edge",children:f.jsx(Ne,{"aria-label":"Delete edge",icon:f.jsx(W.Icon,{as:Q.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var m;(m=t.onEdgeDelete)==null||m.call(t,e,l),r()}})})]})]})}function Nb({ids:e,showDivider:r=!0}){const{callbacks:t,config:n,nodeGridOptions:o,fillRadiusEditedIds:i}=He(),{colorInactive:s}=at(),{nodeById:a}=Xt(),[c,l]=j.useState(!1),d=e.map(y=>{var b,v;return o!=null&&o.fill&&!i.has(y)?0:(v=(b=a.get(y))==null?void 0:b.data.viewProps)==null?void 0:v.borderRadius}),u=!d.every(y=>y===d[0]),h=u?"mixed":String(d[0]??""),p=["0","8","16","30","53","100"],m=c||!u&&h!==""&&!p.includes(h),g=y=>e.forEach(b=>{var v;return(v=t.onNodeBorderRadiusChange)==null?void 0:v.call(t,b,y)});return f.jsxs(f.Fragment,{children:[r&&f.jsx(Tt,{}),f.jsx(W.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsxs(It,{icon:f.jsx(W.Icon,{as:Tv.TbBorderRadius,boxSize:5,color:s,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${u?"Mixed":d[0]===void 0?"Default":`${d[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:m?"custom":h,disabled:n.readOnly,onValueChange:y=>{l(y==="custom"),y!=="custom"&&g(y===""?void 0:Number(y))},children:[f.jsx("option",{value:"",children:"Default radius"}),u&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),p.map(y=>f.jsxs("option",{value:y,children:[y,"px radius"]},y)),f.jsx("option",{value:"custom",children:"Custom radius"})]})}),m&&f.jsx(Er,{ariaLabel:"Custom border radius",placeholder:u?"Mixed":"Auto",type:"number",min:0,width:"72px",value:u?"":h,onCommit:y=>g(y===""?void 0:Number(y))})]})}function Ob({ids:e,onClose:r,afterLabel:t}){var B,se,te,le,ne,ce,xe,he;const{callbacks:n,colorMode:o,themeColor:i,config:s,setNodeViewMode:a}=He(),{colorText:c,colorInactive:l}=at(),{nodeById:d,parentIds:u}=Xt(),{palette:h,show:p}=Tb(),m=e.length===1,[g,y]=j.useState(""),b=m?(B=d.get(e[0]))==null?void 0:B.data:void 0,v=e.map(U=>{var re,fe;return((fe=(re=d.get(U))==null?void 0:re.data.config)==null?void 0:fe.typeView)??""}),w=v.some(U=>U!==v[0]),x=w?"mixed":v[0]??"",C=[{value:"text",label:"Text",view:"text",icon:Q.PiTextT},{value:"icon-label",label:"Icon Label",view:"icon-label",icon:Q.PiShapes},{value:"object",label:"Object",view:"object",icon:Q.PiBracketsCurly},{value:"grid",label:"Grid",view:"grid",icon:Q.PiGridFour},{value:"parent",label:"Parent",view:"parent",icon:Q.PiStack},{value:"media",label:"Media",view:"icon-label",icon:Q.PiFileSvg},{value:"content",label:"Content",view:"object",icon:Q.PiTextAlignLeft},{value:"prompt",label:"Prompt",view:"prompt",icon:Q.PiTextAlignLeft}].filter(U=>U.view!=="prompt"||!!n.onPromptSubmit),S=e.some(U=>{var fe,we;const re=(fe=d.get(U))==null?void 0:fe.data;return re&&(u.has(U)||((we=re.config)==null?void 0:we.parentContainer)||Object.prototype.hasOwnProperty.call(s.customViews??{},re.type))}),E=(se=b==null?void 0:b.config)==null?void 0:se.collapsed,R=Ab(e[0]),P=U=>{var re,fe,we;return(((fe=(re=d.get(U))==null?void 0:re.data.viewProps)==null?void 0:fe.outline)??(u.has(U)?(we=s.parentNodeStyle)==null?void 0:we.outline:!1))===!0},I=e.every(P),M=!I&&e.some(P),k=U=>{var re;return((re=d.get(U))==null?void 0:re.data.isNodeAnimated)===!0},_=e.every(k),N=!_&&e.some(k),O=e.map(U=>{var re;return((re=d.get(U))==null?void 0:re.data.nodeAnimationVariant)??"traveling"}),V=O.every(U=>U===O[0])?O[0]:"",T=U=>e.forEach(U),[Z,ue]=j.useState(!1),K=Z&&p("color")&&p("borderColor"),ee=U=>{var re,fe,we;return(((fe=(re=d.get(U))==null?void 0:re.data.viewProps)==null?void 0:fe.borderStyle)??(u.has(U)?(we=s.parentNodeStyle)==null?void 0:we.borderStyle:"solid"))==="dashed"},H=e.every(ee),ae=!H&&e.some(ee),q=e.map(U=>{var we,ie,Ce;const re=(we=d.get(U))==null?void 0:we.data,fe=u.has(U)?Dn((ie=s.parentNodeStyle)==null?void 0:ie.borderWidth,6):(re==null?void 0:re.type)==="objectView"?3:2;return Dn((Ce=re==null?void 0:re.viewProps)==null?void 0:Ce.borderWidth,fe)}),D=q.every(U=>U===q[0])?String(q[0]??""):"",G=U=>T(re=>{var fe,we;K?(fe=n.onNodeBorderColorChange)==null||fe.call(n,re,U):(we=n.onNodeColorChange)==null||we.call(n,re,"bg",U)});return f.jsxs(f.Fragment,{children:[f.jsx(dn,{onClick:r}),f.jsx(Tt,{}),m&&p("label")?f.jsx(Er,{ariaLabel:"Node label",placeholder:"Node label",value:(b==null?void 0:b.label)??(b==null?void 0:b.headerTitle)??"",onCommit:U=>{var re;return(re=n.onNodeLabelChange)==null?void 0:re.call(n,e[0],U)}}):f.jsxs(W.Text,{fontSize:"xs",color:c,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),t,p("typeView")&&f.jsxs(It,{"aria-label":"Type view",title:S?"Type view is managed by the custom renderer or container":`Type view: ${x||"None (default)"}`,icon:f.jsx(Q.PiCards,{size:20}),style:{width:36},value:x,disabled:s.readOnly||s.editable===!1||S,onValueChange:U=>{var fe;const re=(fe=C.find(we=>we.value===U))==null?void 0:fe.view;re&&T(we=>{var ie,Ce;(ie=n.onNodeTypeViewChange)==null||ie.call(n,we,re),a(we,"default"),(Ce=n.onNodeViewToggle)==null||Ce.call(n,we)})},children:[w&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),C.map(U=>f.jsx("option",{value:U.value,children:f.jsxs(W.HStack,{gap:"12px",children:[f.jsx(U.icon,{size:20,"aria-hidden":"true",style:{flexShrink:0}}),f.jsx("span",{children:U.label})]})},U.value))]}),p("style")&&f.jsx(Nb,{ids:e},e.join("\0")),p("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:I?"Restore node fill":"Remove node fill",children:f.jsx(Ne,{"aria-label":"Toggle node outline","aria-pressed":M?"mixed":I,icon:f.jsx(W.Icon,{as:I?Q.PiSquare:Q.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:I?i:l,onClick:()=>T(U=>{var re;return(re=n.onNodeOutlineChange)==null?void 0:re.call(n,U,!I)})})})]}),p("color")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),p("borderColor")&&f.jsx(Ge,{label:K?"Edit node colors":"Edit node border",children:f.jsx(Ne,{"aria-label":"Edit node border","aria-pressed":K,icon:f.jsx(W.Icon,{as:Q.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:K?i:l,bg:K?o==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>ue(U=>!U)})}),f.jsx(Vr,{label:K?"Border color":"Background",colors:h,value:K?((te=b==null?void 0:b.viewProps)==null?void 0:te.borderColor)??(m&&u.has(e[0])?(le=s.parentNodeStyle)==null?void 0:le.borderColor:void 0):(ne=b==null?void 0:b.viewProps)==null?void 0:ne.bgColor,onPick:G,onReset:()=>G("")}),K&&p("style")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:H?"Solid border":"Dashed border",children:f.jsx(Ne,{"aria-label":"Toggle dashed border","aria-pressed":ae?"mixed":H,icon:f.jsx(W.Icon,{as:H?Q.PiLineSegments:Q.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:H?i:l,onClick:()=>T(U=>{var re;return(re=n.onNodeBorderStyleChange)==null?void 0:re.call(n,U,H?"solid":"dashed")})})}),f.jsx(Er,{ariaLabel:"Border thickness",placeholder:m?"Auto":"Mixed",width:"64px",type:"number",min:0,value:D,onCommit:U=>T(re=>{var fe;return(fe=n.onNodeBorderWidthChange)==null?void 0:fe.call(n,re,U===""?void 0:Number(U))})})]})]}),p("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:_?"Stop border animation":"Animate node border",children:f.jsx(Ne,{"aria-label":"Toggle node animation","aria-pressed":N?"mixed":_,icon:f.jsx(W.Icon,{as:Q.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:_?i:l,onClick:()=>T(U=>{var re;return(re=n.onNodeAnimationChange)==null?void 0:re.call(n,U,!_)})})}),(_||N)&&f.jsx(Rb,{label:"Node animation",value:V,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:s.readOnly,onChange:U=>T(re=>{var fe;return(fe=n.onNodeAnimationVariantChange)==null?void 0:fe.call(n,re,U)})})]}),!K&&p("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Vr,{label:"Text color",colors:Mb,value:(ce=b==null?void 0:b.viewProps)==null?void 0:ce.textColor,onPick:U=>T(re=>{var fe;return(fe=n.onNodeColorChange)==null?void 0:fe.call(n,re,"text",U)}),onReset:()=>T(U=>{var re;return(re=n.onNodeColorChange)==null?void 0:re.call(n,U,"text","")})})]}),m&&p("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Gd,{nodeId:e[0],value:(xe=b==null?void 0:b.config)==null?void 0:xe.icon},e[0]),f.jsx(Er,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((he=b==null?void 0:b.config)==null?void 0:he.icon)||"",onCommit:U=>{var re;return(re=n.onNodeIconChange)==null?void 0:re.call(n,e[0],U)}})]}),m&&R&&p("collapse")&&E!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:E?"Expand":"Collapse",children:f.jsx(Ne,{"aria-label":E?"Expand node":"Collapse node",icon:f.jsx(W.Icon,{as:E?Q.PiArrowsOutLineVertical:Q.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:l,onClick:()=>{var U;return(U=n.onNodeCollapse)==null?void 0:U.call(n,e[0],!E)}})})]}),p("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(Tt,{}),f.jsx(Ge,{label:m?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Ne,{"aria-label":"Delete selected nodes",icon:f.jsx(W.Icon,{as:Q.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:o==="dark"?"red.300":"red.500",onClick:()=>{T(U=>{var re,fe;return(fe=n.onNodeDelete)==null?void 0:fe.call(n,U,((re=d.get(U))==null?void 0:re.data)||{id:U})}),r()}})})]}),f.jsx(Ge,{label:"Copy selection",children:f.jsx(Ne,{"aria-label":"Copy selection",icon:f.jsx(Q.PiCopy,{size:20}),size:"sm",variant:"ghost",color:l,onClick:async()=>{var U;try{await((U=n.onNodesCopy)==null?void 0:U.call(n,e)),y("")}catch(re){y(String(re))}}})}),f.jsx(Ge,{label:"Duplicate selection",children:f.jsx(Ne,{"aria-label":"Duplicate selection",icon:f.jsx(Q.PiCopySimple,{size:20}),size:"sm",variant:"ghost",color:l,disabled:s.readOnly||s.editable===!1,onClick:()=>{var U;try{(U=n.onNodesDuplicate)==null||U.call(n,e),y("")}catch(re){y(String(re))}}})}),g&&f.jsx(W.Text,{role:"alert",fontSize:"xs",children:g})]})}async function $b(e){const{toSvg:r}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const t=await r(e,{filter:o=>!(o instanceof Element)||!o.matches("button, iframe, [role=tooltip], .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-edge-hit, .flow-sdk-ghost, .flow-sdk-node-animation")}),n=new DOMParser().parseFromString(decodeURIComponent(t.slice(t.indexOf(",")+1)),"image/svg+xml");return n.querySelectorAll(".flow-sdk-edge-hit, .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-ghost").forEach(o=>o.remove()),n.querySelectorAll("[data-flow-preview-source]").forEach(o=>{o.setAttribute("style","display:block;white-space:pre-wrap;font:16px/1.5 monospace;overflow-wrap:anywhere")}),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function qb(e,r="squeed.svg"){const t=document.createElement("a");t.href=await $b(e),t.download=r.endsWith(".svg")?r:`${r}.svg`,t.click()}function Lb(){const{themeColor:e}=He(),[r,t]=j.useState(!1),[n,o]=j.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(Ge,{label:"Download SVG (current view)",children:f.jsx(Ne,{"aria-label":"Download SVG",icon:f.jsx(Q.PiDownloadSimpleFill,{size:20}),disabled:r,borderRadius:"30%",color:e,variant:"ghost",onClick:async i=>{var a;const s=(a=i.currentTarget.closest("[data-flow-diagram]"))==null?void 0:a.querySelector("[data-flow-background]");if(!s){o("Diagram not available for export.");return}t(!0),o("");try{await qb(s)}catch(c){o(c instanceof Error?c.message:"Unable to export SVG.")}finally{t(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function ko({children:e,background:r,border:t,endElement:n,startElement:o,startElementWidth:i=44,framed:s=!0}){const a=j.useRef(null),c=j.useRef(null),[l,d]=j.useState(i);j.useLayoutEffect(()=>{const g=c.current;if(!o||!g)return;const y=()=>{const v=Math.ceil(g.getBoundingClientRect().width)+18;d(w=>Math.abs(w-v)>1?v:w)};y();const b=new ResizeObserver(y);return b.observe(g),()=>b.disconnect()},[o]);const u=o?l:0,[h,p]=j.useState({left:!1,right:!1});j.useLayoutEffect(()=>{const g=a.current;let y=g.parentElement.offsetWidth;const b=()=>{const x=g.parentElement.offsetWidth;if(x>0&&x!==y){const E=y/x;y=x,E>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&g.parentElement.animate({transform:[`scaleX(${E})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const C=g.scrollLeft>1,S=g.scrollWidth-g.clientWidth-g.scrollLeft>1;p(E=>E.left===C&&E.right===S?E:{left:C,right:S})},v=x=>{const C=x.target instanceof Element?x.target:null;if((C==null?void 0:C.closest("[data-flow-toolbar-scroll]"))!==g||C.closest("[popover], [data-flow-floating-panel]")!==g.closest("[popover], [data-flow-floating-panel]")||x.defaultPrevented||x.ctrlKey||s&&x.deltaX!==0||!(x.deltaX||x.deltaY)||g.scrollWidth<=g.clientWidth)return;x.preventDefault();const S=x.deltaMode===WheelEvent.DOM_DELTA_LINE?16:x.deltaMode===WheelEvent.DOM_DELTA_PAGE?g.clientWidth:1;g.scrollLeft+=(x.deltaX||x.deltaY)*S},w=new ResizeObserver(b);return w.observe(g),g.firstElementChild&&w.observe(g.firstElementChild),g.addEventListener("scroll",b,{passive:!0}),g.addEventListener("wheel",v,{passive:!1}),b(),()=>{w.disconnect(),g.removeEventListener("scroll",b),g.removeEventListener("wheel",v)}},[]);const m=`var(--chakra-colors-${r.replace(".","-")})`;return f.jsxs(W.Box,{position:"relative",bg:s?r:"transparent",minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:s?"30px":0,css:{...s?gr(m,`var(--chakra-colors-${t.replace(".","-")})`):{},...s||o?{"--flow-toolbar-start-width":o?`${u}px`:"0px"}:{}},children:[f.jsx(W.Box,{ref:a,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,ml:o?`${u}px`:void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(g=>f.jsx(W.Box,{"data-flow-toolbar-fade":g,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",zIndex:2,borderRadius:g==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[g]:g==="right"&&n?44:g==="left"&&o?u:0,opacity:h[g]?1:0,background:`linear-gradient(to ${g==="left"?"right":"left"}, ${m}, transparent)`}},g)),n&&f.jsx(W.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",background:m,borderRadius:s?"0 30px 30px 0":void 0,zIndex:1,children:n}),o&&f.jsx(W.Box,{ref:c,position:"absolute",left:"6px",top:0,h:"50px",w:"max-content",display:"flex",alignItems:"center",justifyContent:"center",background:m,borderRadius:s?"30px 0 0 30px":void 0,zIndex:1,children:o})]})}async function Uw(e,r){const t=new Set,n=[],o=(a,c)=>{var d,u,h;if(!a||typeof a!="object")return;const l=a;n.push(c),typeof((d=l.$form)==null?void 0:d.$type)=="string"&&t.add(l.$form.$type),typeof((h=(u=l.$form)==null?void 0:u.$create)==null?void 0:h.$type)=="string"&&t.add(l.$form.$create.$type);for(const[p,m]of Object.entries(l))p==="$"?o(m,c):p.startsWith("$")||o(m,`${c}.${p}`)};if(o(r,"root"),!t.size)return{contract:await Eb(e)};const i=await Wd(e,[...t]);for(const a of t)if(!Object.prototype.hasOwnProperty.call(i,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const c=un(r,a,i);c&&(s[a]={type:c.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:s}}}function Fb({message:e,onDismiss:r}){const{background:t,colorText:n,border:o}=at();return!e||typeof document>"u"?null:Wr.createPortal(f.jsxs(W.chakra.div,{role:"alert","aria-atomic":"true",css:gr(Te(t),Te(o)),onPointerDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),style:{position:"fixed",top:20,right:20,zIndex:1e4,width:360,maxWidth:"calc(100vw - 40px)",boxSizing:"border-box",display:"flex",alignItems:"flex-start",gap:10,padding:16,borderRadius:8,background:Te(t),color:Te(n),fontSize:14,lineHeight:1.5},children:[f.jsx(Q.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),f.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[f.jsx("strong",{children:"Interface upload failed"}),f.jsx("div",{children:e})]}),f.jsx(dn,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:r,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function Hd({showDivider:e=!0,compact:r=!1}={}){const{edgeMode:t,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:s,readOnly:a,themeColor:c,colorMode:l}=He(),{edgeById:d}=Xt(),{data:u,schema:h,setSchema:p,bindings:m,structured:g}=j.useContext($t),y=(g==null?void 0:g.sourceBindings)??m,b=(g==null?void 0:g.sourceSchema)??h,{colorText:v}=at(),w=j.useRef(null),x=j.useRef(0),[C,S]=j.useState(!1),[E,R]=j.useState("");j.useEffect(()=>()=>{x.current++},[]),j.useEffect(()=>{x.current++,S(!1)},[a,u,y]);const P=o?[...d.values()].filter(k=>Dd(o,k.data)).length:0,I=o?`${o.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${P} invalid or unverified connections`:"",M=jo(f.jsx(Hd,{showDivider:!1,compact:!0}));return f.jsx(nn.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:M,children:[f.jsx(Fb,{message:E,onDismiss:()=>R("")}),e&&f.jsx(Nn,{}),f.jsxs(It,{"aria-label":"Edge mode",title:t==="auto"?"Connections: Auto":t==="properties"?"Connections: Properties":"Connections: Nodes",icon:t==="auto"?f.jsx(Q.PiGraph,{size:20}):t==="properties"?f.jsx(Q.PiTable,{size:20}):f.jsx(Q.PiTreeStructure,{size:20}),style:{width:36},value:t,disabled:a,footer:s.onWorkflowConfigurationOpen&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{style:{border:0,borderTop:"1px solid currentColor",opacity:.2,margin:"8px 0"}}),f.jsxs(W.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:ho,_hover:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:k=>{var _,N;(_=k.currentTarget.closest("[popover]"))==null||_.hidePopover(),(N=s.onWorkflowConfigurationOpen)==null||N.call(s)},children:[f.jsx(Q.PiGear,{}),"Configuration"]})]}),onValueChange:k=>{var N;const _=k==="auto"?"auto":k==="properties"?"properties":"nodes";n(_),(N=s.onEdgeModeChange)==null||N.call(s,_)},children:[f.jsx("option",{value:"auto",children:"Auto"}),f.jsx("option",{value:"nodes",children:"Nodes"}),f.jsx("option",{value:"properties",children:"Properties"})]}),f.jsxs("span",{style:{display:t==="auto"||t==="properties"?"contents":"none"},children:[f.jsx(Ge,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:f.jsx(Ne,{"aria-label":"Upload workflow interface",icon:f.jsx(Q.PiUploadSimple,{size:20}),color:Te(c),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var k;return(k=w.current)==null?void 0:k.click()}})}),f.jsx("input",{ref:w,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async k=>{var O,V;const _=(O=k.target.files)==null?void 0:O[0];if(k.target.value="",!_)return;const N=++x.current;S(!0),R("");try{const T=y?await Wd(_,[...new Set(Object.values(y).map(K=>K.schemaType??K.type))]):void 0;if(y&&T){for(const K of Object.values(y))if(!Object.prototype.hasOwnProperty.call(T,K.schemaType??K.type))throw new Error(`Missing form type: ${K.schemaType??K.type}`)}const{contract:Z,schema:ue}=y&&T?{schema:T,contract:{name:_.name,nodes:Object.fromEntries(Object.entries(y).map(([K,ee])=>[K,{type:T[ee.schemaType??ee.type],optional:!1}]))}}:await Uw(_,u);if(N!==x.current)return;p==null||p(ue),i(Z),(V=s.onWorkflowContractChange)==null||V.call(s,Z)}catch(T){N===x.current&&R(`${_.name}: ${T instanceof Error?T.message:"Unable to load interface."}`)}finally{N===x.current&&S(!1)}}}),!r&&(I||C)&&f.jsx("span",{role:"status",title:I,style:{color:Te(v),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":I}),!r&&o&&f.jsx(Ge,{label:"Remove workflow interface",children:f.jsx(Ne,{"aria-label":"Remove workflow interface",icon:f.jsx(Q.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||C,onClick:()=>{var k;p==null||p(void 0),i(void 0),(k=s.onWorkflowContractChange)==null||k.call(s,void 0),R("")}})})]})]})})}const Kw=[{value:"BT",label:"Bottom to Up",icon:Q.PiArrowUp,flowType:Sn.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Q.PiArrowDown,flowType:Sn.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Q.PiArrowRight,flowType:Sn.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Q.PiArrowLeft,flowType:Sn.RIGHT_LEFT}],zb=({nodeGridControlsTarget:e}={})=>{const{engineRef:r,themeColor:t,setThemeColor:n,edgeColor:o,setEdgeColor:i,backgroundSelected:s,setBackgroundSelected:a,direction:c,edgeMode:l,allNodesIconLabel:d,setAllNodesIconLabel:u,nodeGridOptions:h,selectedNodeIds:p,setSelectedNodeIds:m,selectedEdgeId:g,setSelectedEdgeId:y,isZoomMode:b,setIsZoomMode:v,isMultiSelectMode:w,setIsMultiSelectMode:x,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:E,setIsEdgeHandlesEnabled:R,isArrayNodeMode:P,setIsArrayNodeMode:I,isPinned:M,setIsPinned:k,callbacks:_,config:N,readOnly:O}=He(),{nodeById:V,edgeById:T,parentIds:Z}=Xt(),ue=N.colorMode==="dark",{background:K,border:ee,colorInactive:H,colorText:ae,colorActive:q}=at(),D=ue?ee:"gray.300",G=`var(--chakra-colors-${K.replace(".","-")})`,B=`var(--chakra-colors-${(ue?ee:"gray.300").replace(".","-")})`,[se,te]=j.useState(!1),[le,ne]=j.useState(!0),ce=N.bottomBarCollapsed??le,xe=j.useRef(null),he=So({edge:"bottom",enabled:!M,bounds:xe,inside:[xe]}),U=j.useCallback(Re=>{const Ke=r.current;if(!Ke)return;const lt=N.minZoom??.01,Je=N.maxZoom??1.5,mt=.02;let At=Ke.zoom();switch(Re){case"increase":At=Math.min(Je,At+mt),Ke.zoom(At),Ke.center(!1);break;case"decrease":At=Math.max(lt,At-mt),Ke.zoom(At),Ke.center(!1);break;case"reset":Ke.fit(50);break}},[r,N.minZoom,N.maxZoom]),re=N.renderSelectedNodeToolbar,fe=p.length>0&&!!re,we=j.useMemo(()=>fe?p.map(Re=>{var lt;return{...((lt=V.get(Re))==null?void 0:lt.data)??{id:Re},isParent:Z.has(Re)}}):[],[fe,p,V,Z]),ie=j.useCallback(()=>{var Re;m([]),(Re=_.onNodeDeselect)==null||Re.call(_)},[m,_]),Ce=N.renderSelectedEdgeToolbar,$e=!!g&&!!Ce,Ue=j.useMemo(()=>{var Re;return!$e||!g?null:((Re=T.get(g))==null?void 0:Re.data)??{id:g}},[$e,g,T]),Ve=j.useCallback(()=>{var Re;y(null),(Re=_.onEdgeDeselect)==null||Re.call(_)},[y,_]),tt=N.selectionToolbar!==!1&&!O,ye=tt&&!!g&&!Ce,Ae=tt&&!ye&&p.length>0&&!re,Le=ye||Ae,be=M||he||se||Le||N.bottomBarCollapsed===!1;j.useEffect(()=>{p.length||g?a(!1):O||(s&&k(!0),N.bottomBarCollapsed===void 0&&ne(!s))},[s,p.length,g,O,a,k,N.bottomBarCollapsed]);const Xe=N.renderBottomBar,ut=Iw();return Xe?f.jsxs(f.Fragment,{children:[fe&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:re({selectedNodeIds:p,selectedNodeData:we,onDeselect:ie})}),$e&&Ue&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:Ce({edgeId:g,edgeData:Ue,onDeselect:Ve})}),f.jsx(W.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:Xe({zoomIn:()=>U("increase"),zoomOut:()=>U("decrease"),resetZoom:()=>U("reset"),direction:c,isZoomMode:b,setIsZoomMode:v,isMultiSelectMode:w,setIsMultiSelectMode:x,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:E,setIsEdgeHandlesEnabled:R,isArrayNodeMode:P,setIsArrayNodeMode:I,selectedNodeIds:p,selectedNodeData:we,selectedEdgeId:g,selectedEdgeData:Ue,onNodeDeselect:ie,onEdgeDeselect:Ve,callbacks:_})})]}):f.jsxs(nn.Provider,{value:ut,children:[fe&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:re({selectedNodeIds:p,selectedNodeData:we,onDeselect:ie})}),$e&&Ue&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:Ce({edgeId:g,edgeData:Ue,onDeselect:Ve})}),f.jsx(W.Box,{ref:xe,role:"toolbar","aria-label":"Diagram controls",position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:be?"translateY(0)":"translateY(100%)",pointerEvents:be?"auto":"none",visibility:be?"visible":"hidden",opacity:be?1:0,css:{"& button > svg:not([popover] *)":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0},"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(W.Flex,{w:"100%",px:5,position:"absolute",bottom:"calc(20px + env(safe-area-inset-bottom, 0px))",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",css:{"@media (min-width: 1024px)":{"& > :first-of-type":{maxWidth:"50vw"}}},children:[f.jsx(ko,{background:K,border:ue?ee:"gray.300",children:f.jsxs(W.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[ye?f.jsx(Ib,{edgeId:g,onClose:Ve}):Ae?f.jsx(Ob,{ids:p,onClose:ie}):null,f.jsxs("div",{style:{display:ye||Ae?"none":"contents"},children:[f.jsxs("span",{style:{display:N.bottomBarNavigation===!1?"none":"contents"},children:[f.jsx(Ge,{label:M?"Unpin":"Pin",children:f.jsx(Ne,{"aria-label":"Pin",icon:f.jsx(W.Icon,{as:M?Q.PiPushPinFill:Q.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:M?t:H,onClick:()=>{k(!M),te(!1)}})}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:"Zoom Out",children:f.jsx(Ne,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(W.Icon,{as:Q.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:ae,onClick:()=>U("decrease")})}),f.jsx(Ge,{label:"Zoom In",children:f.jsx(Ne,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(W.Icon,{as:Q.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:ae,onClick:()=>U("increase")})}),f.jsx(Ge,{label:"Reset Zoom",children:f.jsx(Ne,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(W.Icon,{as:Q.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:ae,onClick:()=>U("reset")})}),ce&&f.jsx(Nw,{visibleActions:h?["Collision mode","Fill",...h.fill?["Grid adjustment"]:[]]:[],divider:f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"})})]}),f.jsxs("span",{style:{display:ce?"none":"contents"},children:[f.jsxs("span",{style:{display:N.bottomBarNavigation===!1?"none":"contents"},children:[N.edgeHandles!==!1&&f.jsx(Ge,{label:E?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Ne,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":E,icon:f.jsx(W.Icon,{as:Q.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:E?t:H,onClick:()=>R(!E)})}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:b?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Ne,{"aria-label":"Toggle zoom mode",icon:f.jsx(W.Icon,{as:b?Q.PiMagnifyingGlassPlus:Q.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:b?t:H,onClick:()=>v(!b)})}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:w?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Ne,{"aria-label":"Toggle multi-select",icon:f.jsx(W.Icon,{as:Q.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:w?t:H,onClick:()=>x(!w)})}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:C?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Ne,{"aria-label":"Toggle drag mode",icon:f.jsx(W.Icon,{as:Q.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:C?t:H,onClick:()=>S(!C)})})]}),N.bottomBarNavigation===!1&&(e===void 0?f.jsx(so,{}):e?Wr.createPortal(f.jsx(so,{}),e):null),N.bottomBarExtra&&f.jsxs(f.Fragment,{children:[N.bottomBarNavigation!==!1&&f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"}),N.bottomBarExtra]}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"}),f.jsx(wb,{})]}),f.jsx("span",{style:{display:N.bottomBarNavigation===!1||ce&&!h?"none":"contents"},children:f.jsx(so,{})}),f.jsxs("span",{style:{display:ce?"none":"contents"},children:[f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"}),f.jsx(vb,{}),l!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:P?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Ne,{"aria-label":"Toggle array mode",icon:f.jsx(W.Icon,{as:P?Q.PiBracketsSquare:Q.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:P?t:H,onClick:()=>{var Ke;const Re=!P;I(Re),(Ke=_.onArrayModeChange)==null||Ke.call(_,Re)}})})]}),f.jsx(Hd,{}),!O&&f.jsxs("span",{style:{display:s?"contents":"none"},children:[f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Vr,{label:"Graph theme",colors:po,value:t,includeTransparent:!1,onPick:Re=>{var Ke;n(Re),(Ke=_.onThemeColorChange)==null||Ke.call(_,Re)}})]}),!O&&f.jsxs(f.Fragment,{children:[f.jsx(W.Icon,{as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"}),f.jsx(Vr,{label:"Graph edge color",colors:po,value:o||(ue?"gray.500":ln),onPick:i,onReset:()=>i("")}),f.jsx(W.Icon,{as:Q.PiLineVerticalThin,boxSize:5,color:D,role:"separator","aria-orientation":"vertical"})]}),f.jsx(Cb,{})]}),f.jsx(W.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:D}),f.jsx(Ge,{label:ce?"Expand toolbar":"Collapse toolbar",children:f.jsx(Ne,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(W.Icon,{as:ce?Q.PiCaretRight:Q.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:H,onClick:()=>{var Re;N.bottomBarCollapsed===void 0&&ne(!ce),a(ce),(Re=_.onBottomBarCollapsedChange)==null||Re.call(_,!ce)}})}),!ce&&f.jsx(Lb,{})]})]})}),!Le&&f.jsxs(W.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(W.Box,{"data-flow-direction-control":"",bg:K,borderRadius:"30px",h:50,css:gr(G,B),px:3,cursor:"pointer",onClick:()=>te(!se),children:f.jsxs(W.Flex,{align:"center",h:"100%",children:[f.jsx(Ge,{label:"Flow Direction",children:f.jsx(Ne,{"aria-label":"Direction",onClick:Re=>{Re.stopPropagation(),te(!se)},icon:f.jsx(W.Icon,{as:Q.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:H})}),f.jsx(W.Text,{fontSize:"xs",textTransform:"uppercase !important",color:ue?"whiteAlpha.600":"blackAlpha.500",ml:1,children:c.toUpperCase()})]})}),se&&f.jsx(W.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(W.Box,{bg:K,borderRadius:"30px",p:2,minW:"180px",css:gr(G,B),children:[Kw.map(Re=>f.jsxs(W.Flex,{align:"center",gap:3,px:3,py:2,css:ho,cursor:"pointer",_hover:{bg:ue?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Ke;(Ke=_.onDirectionChange)==null||Ke.call(_,Re.value),te(!1)},children:[f.jsx(W.Icon,{as:Re.icon,boxSize:5,color:ae}),f.jsx(W.Text,{fontSize:"sm",color:ae,flex:1,whiteSpace:"nowrap",children:Re.label}),c===Re.value&&f.jsx(W.Icon,{as:Q.PiCheck,boxSize:4,color:q})]},Re.value)),f.jsxs(W.Flex,{align:"center",gap:3,px:3,py:2,css:ho,cursor:"pointer",_hover:{bg:ue?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Re;(Re=_.onDirectionChange)==null||Re.call(_,"C"),te(!1)},children:[f.jsx(W.Icon,{as:Q.PiAlignCenterHorizontal,boxSize:5,color:ae}),f.jsx(W.Text,{fontSize:"sm",color:ae,flex:1,whiteSpace:"nowrap",children:"Center"}),c==="C"&&f.jsx(W.Icon,{as:Q.PiCheck,boxSize:4,color:q})]})]})})]})]})})]})};zb.displayName="BottomBar";const Bb=j.memo(zb);function Jw({checked:e,onChange:r,disabled:t,label:n="Connected nodes"}){return f.jsx(on,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:r,disabled:t,icon:f.jsx(W.Icon,{as:Q.PiGraph,boxSize:5})})}const Ju={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Db(e,r){const t=new Map,n=(i,s)=>{if(Object.is(i,s))return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const a=Object.keys(i);return a.length===Object.keys(s).length&&a.every(c=>Object.prototype.hasOwnProperty.call(s,c)&&n(i[c],s[c]))},o=(i,s,a)=>{if(i===s)return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const c=new Set([...Object.keys(i),...Object.keys(s)]);for(const l of c)if(!n(i[l],s[l])){if(Object.prototype.hasOwnProperty.call(Ju,l)){if(typeof s[l]!="string"||!s[l])return!1;t.set(a,{...t.get(a),[Ju[l]]:s[l]})}else if(l.startsWith("$")&&l!=="$"||!o(i[l],s[l],l==="$"?a:`${a}.${l}`))return!1}return!0};if(o(e,r,"root"))return t}function Zw(e,r){return Db(e,r)!==void 0}function Xw(e,r,t){if(e===r)return t;const n=Db(e,r);if(!n)return;const o=new Set(t.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!Oe(r,i))return;return{edges:t.edges,nodes:t.nodes.map(i=>{const s=n.get(i.data.id),a=Oe(e,i.data.id),c=Oe(r,i.data.id);return!s&&a===c?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(c,null,2)}:{},...s?{viewProps:{...i.data.viewProps,...s},config:{...i.data.config,...s}}:{}}}})}}function _d(e){return e.kind==="literal"?e.value:e.kind==="union"?_d(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,r])=>!r.optional).map(([r,t])=>[r,_d(t.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function Wb(e,r,t){var y,b,v;const n=(y=Oe(e,r))==null?void 0:y.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(w=>!/^[A-Za-z0-9_-]+$/.test(w)||["__proto__","constructor","prototype"].includes(w)))throw new Error("Invalid form creation address.");if(!t||!Object.prototype.hasOwnProperty.call(t,o.$type))throw new Error(`Load form type: ${o.$type}`);const s=i.pop(),a=["root",...i].join("."),c=un(e,a,t),l=(b=c==null?void 0:c.type.properties[s])==null?void 0:b.type;if((l==null?void 0:l.kind)!=="array"||l.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const d=t[o.$type],u=o.$defaults??{};for(const[w,x]of Object.entries(u))if(!Object.prototype.hasOwnProperty.call(d.properties,w)||Jt(d.properties[w].type,x,!d.properties[w].optional))throw new Error(`Invalid creation default: ${w}`);const h={..._d(d),...structuredClone(u)};((v=d.properties.id)==null?void 0:v.type.kind)==="string"&&(h.id=Td());let p=e;const m=Oe(e,o.$address);if(m===void 0)p=Pt(e,a,w=>({...w,[s]:[]}));else if(!Array.isArray(m)&&!Array.isArray(m==null?void 0:m.$))throw new Error("Form creation destination is not an array.");const g=$d(p,o.$address,{...h,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:g.address,json:qd(g.json,r,{target:g.address,label:o.$edgeLabel})}}function Yw(e,r,t){var i,s;if(Array.isArray(r)){const a=new Set(r);if(!Oe(e,t)||[...a].some(u=>u==="root"||!Oe(e,u)))throw new Error("The source or Parent no longer exists.");const c=new Set;let l=t;for(;l;){if(c.has(l)||[...a].some(h=>l===h||l.startsWith(`${h}.`)))throw new Error("A node cannot be moved inside itself or its descendants.");c.add(l);const u=(i=Oe(e,l))==null?void 0:i.$parent;l=typeof u=="string"?u:l.includes(".")?l.slice(0,l.lastIndexOf(".")):void 0}const d=(u,h)=>{let p=u;const m=(g,y)=>{p===u&&(p=Array.isArray(u)?[...u]:{...u}),p[g]=y};if(u&&typeof u=="object")for(const[g,y]of Object.entries(u)){if(g.startsWith("$")&&g!=="$")continue;const b=d(y,g==="$"?h:`${h}.${g}`);b!==y&&m(g,b)}return a.has(h)&&(p={...p&&typeof p=="object"&&!Array.isArray(p)?p:{$:p},$parent:t}),p};return uo(d(e,"root"),t,!1)}if(r=r,r==="root"||!Oe(e,r)||!Oe(e,t))throw new Error("The source or Parent no longer exists.");const n=new Set;let o=t;for(;o;){if(o===r||o.startsWith(`${r}.`)||n.has(o))throw new Error("A node cannot be moved inside itself or its descendants.");n.add(o);const a=(s=Oe(e,o))==null?void 0:s.$parent;o=typeof a=="string"?a:o.includes(".")?o.slice(0,o.lastIndexOf(".")):void 0}return uo(Pt(e,r,a=>({...a,$parent:t})),t,!1)}function Vb(e,r){const t=new Set(r.filter(a=>Oe(e,a)!==void 0)),n=[],o=(a,c)=>{if(!(!a||typeof a!="object")){n.push([c,a]);for(const[l,d]of Object.entries(a))l.startsWith("$")||o(d,`${c}.${l}`)}};o(e,"root");const i=a=>[...t].some(c=>a===c||a.startsWith(`${c}.`));let s=!0;for(;s;){s=!1;for(const[a,c]of n)!i(a)&&typeof c.$parent=="string"&&i(c.$parent)&&(t.add(a),s=!0)}return[...t].filter(a=>![...t].some(c=>c!==a&&a.startsWith(`${c}.`)))}function Ud(e,r){const t=Vb(e,r),n=new Map(t.map((a,c)=>[a,`root.node_${c+1}`])),o=a=>{const c=t.find(l=>a===l||a.startsWith(`${l}.`));return c?`${n.get(c)}${a.slice(c.length)}`:void 0},i=a=>{if(!(!a||typeof a!="object")){Array.isArray(a.$connections)&&(a.$connections=a.$connections.flatMap(c=>{const l=typeof c.target=="string"&&o(c.target);return l?[{...c,id:void 0,target:l}]:[]}));for(const c of["$parent","$target"])if(typeof a[c]=="string"){const l=o(a[c]);l?a[c]=l:delete a[c]}for(const[c,l]of Object.entries(a))c.startsWith("$")||i(l)}},s={$hideRoot:!0};return t.forEach((a,c)=>{const l=structuredClone(Oe(e,a));i(l),s[`node_${c+1}`]=l}),s}function Gb(e,r){const t=Ud(e,r),n=Object.keys(t).filter(a=>!a.startsWith("$")),o=new Map(n.map(a=>[a,`copy_${crypto.randomUUID()}`])),i=a=>{if(!a||typeof a!="object")return;const c=l=>{const d=l.split(".");return d[0]==="root"&&o.has(d[1])&&(d[1]=o.get(d[1])),d.join(".")};for(const l of a.$connections??[])l.target=c(l.target),l.id=crypto.randomUUID();for(const l of["$parent","$target"])typeof a[l]=="string"&&(a[l]=c(a[l]));for(const[l,d]of Object.entries(a))l.startsWith("$")||i(d)},s=Object.fromEntries(n.map(a=>{const c=t[a];return i(c),[o.get(a),c]}));return{json:Pt(e,"root",a=>({...a,...s})),ids:[...o.values()].map(a=>`root.${a}`)}}function Qw(e,r){const t=o=>e&&typeof e=="object"&&o in e;let n=1;for(;t(`${r}_${n}`);)n++;return`${r}_${n}`}function Hb(e,r,t,n,o){const i=(a,c)=>{var h;if(a===e)return;const l=c.type.startsWith("node")&&c.type!=="nodeDelete",d=c.nodeAddresses??(l&&c.address?[c.address]:[]),u=d.length?(h=t.getNodeEditMetadata)==null?void 0:h.call(t):void 0;for(const p of d)JSON.stringify(Oe(a,p))!==JSON.stringify(Oe(e,p))&&(a=cb(a,p,u));e=a,n==null||n(a,c)},s=a=>{var l;const c=(l=r.find(d=>d.data.id===a))==null?void 0:l.data;return c&&{source:c.source,target:c.target,isInverted:c.isInverted,sourceProperty:c.sourceProperty,targetProperty:c.targetProperty,connection:c.connection}};return{...t,onNodesCopy:async a=>{var c;await((c=t.onNodesCopy)==null?void 0:c.call(t,a))!==!0&&await navigator.clipboard.writeText(JSON.stringify(Ud(e,a),null,2))},onNodesDuplicate:a=>{var l;if(((l=t.onNodesDuplicate)==null?void 0:l.call(t,a))===!0)return;const c=Gb(e,a);i(c.json,{type:"nodeCreate",address:c.ids[0],nodeAddresses:c.ids})},onFormChange:a=>{const c=Oe(e,a.nodeAddress);if(!c||a.nodeId!==void 0&&c.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");i(_o(e,a,t.onFormChange),{type:"form",address:a.address,nodeAddresses:[a.nodeAddress],value:a.value})},onNodeLabelChange:(a,c)=>{var l;(l=t.onNodeLabelChange)==null||l.call(t,a,c),i(jt(e,a,"$label",c),{type:"nodeLabel",address:a,key:"$label",value:c})},onNodeContentChange:(a,c)=>{var l;(l=t.onNodeContentChange)==null||l.call(t,a,c),i(jt(e,a,"$content",c),{type:"nodeContent",address:a,key:"$content",value:c})},onNodeContentFormatChange:(a,c)=>{var l;["markdown","html","jsx"].includes(c)&&((l=t.onNodeContentFormatChange)==null||l.call(t,a,c),i(jt(e,a,"$contentFormat",c),{type:"nodeStyle",address:a,key:"$contentFormat",value:c}))},onNodeTypeViewChange:(a,c)=>{var l;c!==void 0&&!Ld.includes(c)||((l=t.onNodeTypeViewChange)==null||l.call(t,a,c),i(jt(e,a,"$view",c),{type:"nodeStyle",address:a,key:"$view",value:c}))},onNodeColorChange:(a,c,l)=>{var u;(u=t.onNodeColorChange)==null||u.call(t,a,c,l);const d=c==="bg"?"$bgColor":"$textColor";i(jt(e,a,d,l),{type:"nodeColor",address:a,key:d,value:l})},onNodeBorderColorChange:(a,c)=>{var l;(l=t.onNodeBorderColorChange)==null||l.call(t,a,c),i(jt(e,a,"$borderColor",c),{type:"nodeColor",address:a,key:"$borderColor",value:c})},onNodeBorderStyleChange:(a,c)=>{var l;(l=t.onNodeBorderStyleChange)==null||l.call(t,a,c),i(jt(e,a,"$borderStyle",c),{type:"nodeStyle",address:a,key:"$borderStyle",value:c})},onNodeBorderWidthChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderWidthChange)==null||l.call(t,a,c),i(jt(e,a,"$borderWidth",c),{type:"nodeStyle",address:a,key:"$borderWidth",value:c}))},onNodeBorderRadiusChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderRadiusChange)==null||l.call(t,a,c),i(jt(e,a,"$borderRadius",c),{type:"nodeStyle",address:a,key:"$borderRadius",value:c}))},onNodeIconChange:(a,c)=>{var l;(l=t.onNodeIconChange)==null||l.call(t,a,c),i(jt(e,a,"$icon",c),{type:"nodeIcon",address:a,key:"$icon",value:c})},onNodeOutlineChange:(a,c)=>{var l;(l=t.onNodeOutlineChange)==null||l.call(t,a,c),i(jt(e,a,"$outline",c),{type:"nodeOutline",address:a,key:"$outline",value:c})},onNodeAnimationChange:(a,c)=>{var l;(l=t.onNodeAnimationChange)==null||l.call(t,a,c),i(jt(e,a,"$isNodeAnimated",c),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:c})},onNodeAnimationVariantChange:(a,c)=>{var l;c!=="traveling"&&c!=="pulse"||((l=t.onNodeAnimationVariantChange)==null||l.call(t,a,c),i(jt(e,a,"$nodeAnimationVariant",c),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:c}))},onNodeCollapse:(a,c)=>{var l;(l=t.onNodeCollapse)==null||l.call(t,a,c),i(uo(e,a,c),{type:"nodeCollapse",address:a,key:"$collapsed",value:c})},onNodeCreate:a=>{var v;if(((v=t.onNodeCreate)==null?void 0:v.call(t,a))===!0)return;const c=a.sourceNodeId||"root",l=Oe(e,c),d=!!a.sourceNodeId&&a.isArrayMode&&!(l!=null&&l.$arrayDrawInitialized),u=Array.isArray(l==null?void 0:l.$)?l.$:l,h=new Set(Object.entries(u??{}).filter(([w])=>!w.startsWith("$")).map(([,w])=>w==null?void 0:w.$label));let p=1,m=e,g;const y=[];let b=a.isArrayMode?"array":"set";for(let w=0;w<(d?2:1);w++){const x=a.sourceNodeId&&Wb(m,a.sourceNodeId,o);if(x){m=x.json,g??(g=x.address),y.push(x.address),b="form";continue}for(;h.has(`Untitled ${p}`);)p++;const C=`Untitled ${p++}`,S=Qw(Oe(m,c),a.isArrayMode?"list":"node"),E=a.isArrayMode?{$bgColor:"gray.500",$label:C,$:[]}:{$bgColor:"gray.500",$label:C},R=$d(m,c,E,S);m=R.json,g??(g=R.address),y.push(R.address)}d&&(m=Pt(m,c,w=>Array.isArray(w)?{$:w,$arrayDrawInitialized:!0}:{...w,$arrayDrawInitialized:!0})),i(m,{type:"nodeCreate",address:g,nodeAddresses:y,value:b})},onNodeDelete:(a,c)=>{var l;(l=t.onNodeDelete)==null||l.call(t,a,c),i(db(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,c,l)=>{var u;(u=t.onEdgeCreate)==null||u.call(t,a,c,l);const d=l&&(l.sourceProperty!==void 0||l.targetProperty!==void 0)?{...l,target:c}:void 0;i(d?qd(e,a,d):ub(e,a,c),{type:"edgeCreate",address:a,key:d?"$connections":"$target",value:d??c})},onEdgeLabelChange:(a,c)=>{var d;(d=t.onEdgeLabelChange)==null||d.call(t,a,c);const l=s(a);l&&i(Sr(e,l,"$sourceLabel",c),{type:"edgeLabel",edge:l,key:l.connection?"$connections":"$sourceLabel",value:c})},onEdgeStyleChange:(a,c)=>{var d;(d=t.onEdgeStyleChange)==null||d.call(t,a,c);const l=s(a);l&&i(lb(e,l,c),{type:"edgeStyle",edge:l,value:c})},onEdgeAnimationVariantChange:(a,c)=>{var d;if(c!=="dashed"&&c!=="traveling")return;(d=t.onEdgeAnimationVariantChange)==null||d.call(t,a,c);const l=s(a);l&&i(Sr(e,l,"$edgeAnimationVariant",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeAnimationVariant",value:c})},onEdgeTypeChange:(a,c)=>{var d;(d=t.onEdgeTypeChange)==null||d.call(t,a,c);const l=s(a);l&&i(Sr(e,l,"$edgeType",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeType",value:c})},onEdgeIconChange:(a,c)=>{var d;(d=t.onEdgeIconChange)==null||d.call(t,a,c);const l=s(a);l&&i(Sr(e,l,"$edgeIcon",c||void 0),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeIcon",value:c})},onEdgeColorChange:(a,c)=>{var d;(d=t.onEdgeColorChange)==null||d.call(t,a,c);const l=s(a);l&&i(Sr(e,l,"$edgeColor",c),{type:"edgeColor",edge:l,key:l.connection?"$connections":"$edgeColor",value:c})},onEdgeDelete:(a,c)=>{var u;(u=t.onEdgeDelete)==null||u.call(t,a,c);const l=s(a);if(!l)return;const d=fb(e,l);d.removed&&i(d.json,{type:"edgeDelete",edge:l,key:l.connection?"$connections":"$target"})}}}const e1=".flow-sdk-edge-reveal{animation:flow-sdk-edge-reveal var(--flow-edge-reveal-duration,600ms) linear both;animation-play-state:var(--flow-edge-reveal-state,running)}.flow-sdk-edge-reveal-end{animation:flow-sdk-edge-reveal-end var(--flow-edge-reveal-duration,600ms) steps(1,end) both;animation-play-state:var(--flow-edge-reveal-state,running)}@keyframes flow-sdk-edge-reveal{from{stroke-dashoffset:var(--flow-edge-reveal-from,100)}to{stroke-dashoffset:0}}@keyframes flow-sdk-edge-reveal-end{from{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-reveal{animation:none;stroke-dashoffset:0}.flow-sdk-edge-reveal-end{animation:none;opacity:1}}";function t1({path:e,width:r,reversed:t,children:n,onComplete:o}){const i=`flow-edge-reveal-${j.useId().replace(/:/g,"")}`,s=j.useRef(null),[a,c]=j.useState({x:0,y:0,width:1,height:1});return j.useEffect(()=>{const l=matchMedia("(prefers-reduced-motion: reduce)"),d=()=>{l.matches&&(o==null||o())};return d(),l.addEventListener("change",d),()=>l.removeEventListener("change",d)},[o]),j.useLayoutEffect(()=>{var d;const l=(d=s.current)==null?void 0:d.getBBox();l&&c({x:l.x-r,y:l.y-r,width:l.width+r*2,height:l.height+r*2})},[e,r]),f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("mask",{id:i,maskUnits:"userSpaceOnUse",...a,children:f.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:l=>{l.animationName==="flow-sdk-edge-reveal"&&(o==null||o())},"data-reveal-direction":t?"reverse":"forward",style:{"--flow-edge-reveal-from":t?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:r,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${i})`,children:n})]})}const r1=".flow-sdk-edge-trace{pointer-events:none;animation:flow-sdk-edge-trace 2.4s linear infinite}.flow-sdk-edge-trace-reverse{animation-direction:reverse}@keyframes flow-sdk-edge-trace{from{stroke-dashoffset:18}to{stroke-dashoffset:-100}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-trace,.flow-sdk-edge-anim{animation:none}}";function n1({path:e,color:r,width:t,reversed:n}){return f.jsx("path",{className:`flow-sdk-edge-trace${n?" flow-sdk-edge-trace-reverse":""}`,"data-animation-variant":"traveling","aria-hidden":"true",pointerEvents:"none",d:e,fill:"none",stroke:r,strokeWidth:t,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const Ub=".flow-sdk-node-animation{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:1}.flow-sdk-node-border-animation{pointer-events:none;animation:flow-sdk-node-border 2.4s linear infinite}.flow-sdk-node-border-pulse{stroke-width:var(--flow-pulse-rest-width);animation:flow-sdk-node-pulse 1.8s ease-in-out infinite}@keyframes flow-sdk-node-border{from{stroke-dashoffset:0}to{stroke-dashoffset:-100}}@keyframes flow-sdk-node-pulse{0%,100%{stroke-width:var(--flow-pulse-rest-width)}50%{stroke-width:var(--flow-pulse-expanded-width)}}@media(prefers-reduced-motion:reduce){.flow-sdk-node-border-animation{animation:none}}";function go({x:e=0,y:r=0,width:t,height:n,radius:o,color:i,strokeWidth:s=8,path:a,variant:c="traveling"}){const l=j.useId(),d=`flow-sdk-node-border-animation${c==="pulse"?" flow-sdk-node-border-pulse":""}`;if(c==="pulse"){const u=a?"path":"rect",h=a?{d:a}:{x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2))},p=s+36,m={x:e-p,y:r-p,width:t+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:l,maskUnits:"userSpaceOnUse",...m,style:{maskType:"luminance"},children:[f.jsx("rect",{...m,fill:"white"}),f.jsx(u,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(u,{...h,className:d,"data-animation-variant":c,fill:"none",stroke:`color-mix(in srgb, ${i} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${l})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):f.jsx("rect",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2)),fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const o1=e=>{const n=1/(Math.cbrt(e)*.8);let o=Math.round(650*n),i=Math.round(350*n);return o=Math.max(40,Math.min(450,o)),i=Math.max(30,Math.min(300,i)),{edgeSep:o,rankSep:i}};function Kb(e,r=!1){return e&&!r&&typeof requestAnimationFrame<"u"&&!(typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches)}function Jb(e,r,t=()=>{},n=300){let o,i,s=!1;const a=()=>{s=!0,o!==void 0&&cancelAnimationFrame(o),clearTimeout(i)},c=()=>{s||(a(),r(1),t())};if(!Kb(e))return c(),a;const l=performance.now(),d=u=>{if(s)return;const h=Math.max(0,Math.min(1,(u-l)/n));if(h>=1)return c();r(h<.5?4*h**3:1-(-2*h+2)**3/2),s||(o=requestAnimationFrame(d))};return o=requestAnimationFrame(d),i=setTimeout(c,n+100),a}function Zu(e,r,t){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const s of r)(s.parent===i||s.id.startsWith(`${i}.`)||t.some(c=>(c.inverted?c.target:c.source)===i&&(c.inverted?c.source:c.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),o.push(s.id))}return n}function i1(e,r,t){const n=t==="downward"||t==="upward",o=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=r(s.source),c=r(s.target);if(!a||!c)continue;const l=n?c.y-a.y:c.x-a.x,d=Math.abs(l)-(n?a.h+c.h:a.w+c.w)/2;if(d<=320)continue;const u=JSON.stringify([s.source,Math.sign(l)]),h=o.get(u)??[];h.push({edge:s,gap:d,cross:n?c.x-a.x:c.y-a.y}),o.set(u,h)}const i=new Map;for(const s of o.values()){if(new Set(s.map(({edge:c})=>c.target)).size<2)continue;const a=new Map;for(const{edge:c}of s)a.set(c.target,(a.get(c.target)??0)+1);for(const c of[-1,0,1]){const l=s.filter(({cross:u})=>Math.sign(u)===c);l.sort((u,h)=>Math.abs(h.cross)-Math.abs(u.cross)||u.edge.id.localeCompare(h.edge.id));const d=Math.min(...l.map(({gap:u})=>u));l.forEach(({edge:u,gap:h,cross:p},m)=>{const g=l.length===1?d/2:120+(d-280)*m/(l.length-1),y=l.find(b=>Math.abs(b.cross)<Math.abs(p));i.set(u.id,{turn:g/h,labelAtTarget:a.get(u.target)===1,labelFraction:p?(p+((y==null?void 0:y.cross)??0))/(2*p):.5})})}}return i}const ir=e=>({x1:e.x-e.w/2,y1:e.y-e.h/2,x2:e.x+e.w/2,y2:e.y+e.h/2}),a1=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function ei(e){if(!e.length)return null;const r={...e[0]};for(let t=1;t<e.length;t++)r.x1=Math.min(r.x1,e[t].x1),r.y1=Math.min(r.y1,e[t].y1),r.x2=Math.max(r.x2,e[t].x2),r.y2=Math.max(r.y2,e[t].y2);return r}const s1=(e,r)=>e.x1<=r.x2&&e.x2>=r.x1&&e.y1<=r.y2&&e.y2>=r.y1,Xu=(e,r)=>e.x>=r.x1&&e.x<=r.x2&&e.y>=r.y1&&e.y<=r.y2,Bt=e=>(Math.round(e*10)/10).toString(),xt=e=>`${Bt(e.x)} ${Bt(e.y)}`,c1=e=>e>0?1:e<0?-1:0,Yu=(e,r)=>e>0?Math.max(e-r,0):Math.min(e+r,0);function l1(e,r,t,n,o=10){const i=r.x-e.x,s=r.y-e.y,a=Yu(i,(e.w+r.w)/2),c=Yu(s,(e.h+r.h)/2),l=t==="downward"||t==="upward",d=l?c:a,u=l?s:i,h=c1(u),p=n*d,m=v=>Math.abs(v)<o||Math.abs(v)>=Math.abs(d),g=m(p)||m(Math.abs(d)-Math.abs(p));let y;if(g)if(l)if(Math.abs(u)<=e.h/2){const v=(e.x+r.x)/2;y=[v,e.y,v,r.y]}else if(Math.abs(i)<=r.w/2){const v=(e.y+r.y)/2;y=[e.x,v,r.x,v]}else y=[e.x,r.y];else if(Math.abs(u)<=e.w/2){const v=(e.y+r.y)/2;y=[e.x,v,r.x,v]}else if(Math.abs(s)<=r.h/2){const v=(e.x+r.x)/2;y=[v,e.y,v,r.y]}else y=[r.x,e.y];else if(l){const v=e.y+p+e.h/2*h;y=[e.x,v,r.x,v]}else{const v=e.x+p+e.w/2*h;y=[v,e.y,v,r.y]}const b=[{x:e.x,y:e.y}];for(let v=0;v<y.length;v+=2)b.push({x:y[v],y:y[v+1]});return b.push({x:r.x,y:r.y}),b}function d1(e,r,t){const n=r.x-e.x,o=r.y-e.y,i=n>0?(t.x2-e.x)/n:n<0?(t.x1-e.x)/n:1/0,s=o>0?(t.y2-e.y)/o:o<0?(t.y1-e.y)/o:1/0,a=Math.min(i,s);return!Number.isFinite(a)||a>=1||a<0?null:{x:e.x+n*a,y:e.y+o*a}}function sn(e,r,t){var s;if(!((s=t.outline)!=null&&s.length))return d1(e,r,ir(t));const n=r.x-e.x,o=r.y-e.y;let i=1/0;return t.outline.forEach((a,c,l)=>{const d=l[(c+1)%l.length],u=d.x-a.x,h=d.y-a.y,p=n*h-o*u;if(Math.abs(p)<1e-9)return;const m=a.x-e.x,g=a.y-e.y,y=(m*h-g*u)/p,b=(m*o-g*n)/p;y>=0&&y<1&&b>=-1e-9&&b<=1+1e-9&&(i=Math.min(i,y))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function Zb(e,r,t=.5){const n=Number.isFinite(t)?Math.max(0,Math.min(1,t)):.5,o=r==="top"||r==="bottom",i=r==="top"||r==="left"?-1:1,s={x:o?e.x-e.w/2+e.w*n:e.x,y:o?e.y:e.y-e.h/2+e.h*n},a=Math.max(e.w,e.h)*2+1;return{...sn(s,{x:s.x+(o?0:i*a),y:s.y+(o?i*a:0)},e)??{x:o?s.x:e.x+i*e.w/2,y:o?e.y+i*e.h/2:s.y},side:r}}function Qr(e,r){return{x:e.x+(e.side==="right"?r:e.side==="left"?-r:0),y:e.y+(e.side==="bottom"?r:e.side==="top"?-r:0)}}function u1(e,r,t,n){const o=Qr(e,t.srcDist),i=Qr(r,t.tgtDist);if(n==="straight")return Yb(o,i,t);const s=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),a=e.side==="bottom"&&r.side==="top"?i.y-o.y:e.side==="top"&&r.side==="bottom"?o.y-i.y:e.side==="right"&&r.side==="left"?i.x-o.x:e.side==="left"&&r.side==="right"?o.x-i.x:void 0,c=a!==void 0&&a>0?Math.min(s,a/2):s,l=Qr({...o,side:e.side},c),d=Qr({...i,side:r.side},c),u=t.arrowAt==="source"?Et(o,l,t.arrowGap):o,h=t.arrowAt==="target"?Et(i,d,t.arrowGap):i,p=t.arrowAt==="source"?Wt(o,l,t.arrowSize,t.headShape):t.arrowAt==="target"?Wt(i,d,t.arrowSize,t.headShape):void 0;if(n==="bezier")return{d:`M${xt(u)} C${xt(l)} ${xt(d)} ${xt(h)}`,arrow:p,label:{x:(u.x+3*l.x+3*d.x+h.x)/8,y:(u.y+3*l.y+3*d.y+h.y)/8,angle:0}};const m=e.side==="left"||e.side==="right",g=r.side==="left"||r.side==="right";let y;if(m!==g){const v=m?{x:d.x,y:l.y}:{x:l.x,y:d.y},w=(v.x-l.x)*(l.x-o.x)+(v.y-l.y)*(l.y-o.y)>=0,x=(v.x-d.x)*(d.x-i.x)+(v.y-d.y)*(d.y-i.y)>=0;y=[w&&x?v:m?{x:l.x,y:d.y}:{x:d.x,y:l.y}]}else if(a!==void 0&&a<=0)if(m){const v=(l.y+d.y)/2;y=[{x:l.x,y:v},{x:d.x,y:v}]}else{const v=(l.x+d.x)/2;y=[{x:v,y:l.y},{x:v,y:d.y}]}else if(m){const v=e.side===r.side?e.side==="right"?Math.max(l.x,d.x):Math.min(l.x,d.x):(l.x+d.x)/2;y=[{x:v,y:l.y},{x:v,y:d.y}]}else{const v=e.side===r.side?e.side==="bottom"?Math.max(l.y,d.y):Math.min(l.y,d.y):(l.y+d.y)/2;y=[{x:l.x,y:v},{x:d.x,y:v}]}const b=[l,...y,d].filter((v,w,x)=>w===0||v.x!==x[w-1].x||v.y!==x[w-1].y);return Po(u,b,h,p,n==="orthogonal"?0:t.radius)}function Et(e,r,t){const n=e.x-r.x,o=e.y-r.y,i=Math.hypot(n,o);if(!i)return e;let s=(i-t)/i;return s<0&&(s=1e-5),{x:r.x+s*n,y:r.y+s*o}}function Wt(e,r,t,n="triangle"){const o=e.x-r.x,i=e.y-r.y,s=Math.hypot(o,i)||1,a=o/s,c=i/s,l=(n==="square"?.15:.3)*t,d=.15*t,u=e.x-a*l,h=e.y-c*l;if(n==="square")return`M${xt(e)} L${Bt(e.x-c*d)} ${Bt(e.y+a*d)} L${Bt(u-c*d)} ${Bt(h+a*d)} L${Bt(u+c*d)} ${Bt(h-a*d)} L${Bt(e.x+c*d)} ${Bt(e.y-a*d)} Z`;const p=[e,{x:u-c*d,y:h+a*d},{x:u+c*d,y:h-a*d}];return p.map((g,y)=>{const b=p[(y+2)%3],v=p[(y+1)%3],w=Math.hypot(b.x-g.x,b.y-g.y),x=Math.hypot(v.x-g.x,v.y-g.y),C={x:(b.x-g.x)/w,y:(b.y-g.y)/w},S={x:(v.x-g.x)/x,y:(v.y-g.y)/x},E=Math.max(-1,Math.min(1,C.x*S.x+C.y*S.y)),R=Math.sqrt((1-E)/(1+E)),P=Math.min(1/R,w/2,x/2);return{start:{x:g.x+C.x*P,y:g.y+C.y*P},end:{x:g.x+S.x*P,y:g.y+S.y*P},radius:P*R}}).map((g,y)=>`${y?"L":"M"}${xt(g.start)} A${Bt(g.radius)} ${Bt(g.radius)} 0 0 1 ${xt(g.end)}`).join(" ")+" Z"}function Cr(e,r){let t=Math.atan(r/e);return e===0&&t<0&&(t=-t),Number.isFinite(t)||(t=0),t*180/Math.PI}function f1(e,r,t,n){const o={x:r.x-e.x,y:r.y-e.y},i={x:t.x-r.x,y:t.y-r.y},s=Math.hypot(o.x,o.y),a=Math.hypot(i.x,i.y),c=o.x*i.y-o.y*i.x;if(s<1e-6||a<1e-6||Math.abs(c)<1e-6)return{p1:r,b:r,p2:r,r:0};const l=Math.min(n,s/2,a/2);return{p1:{x:r.x-o.x/s*l,y:r.y-o.y/s*l},b:r,p2:{x:r.x+i.x/a*l,y:r.y+i.y/a*l},r:l}}function Xb(e,r,t,n){let o=-1,i=null;for(let m=0;m<e.length-1;m++){const g=sn(e[m],e[m+1],r);if(g){o=m,i=g;break}}let s=-1,a=null;for(let m=e.length-1;m>0;m--){const g=sn(e[m],e[m-1],t);if(g){s=m,a=g;break}}if(!i||!a||o>=s)return null;const c=e.slice(o+1,s),l=c[0]??a,d=c[c.length-1]??i;let u,h,p;if(n.arrowAt==="source"){const m=Et(i,l,n.srcDist);u=Et(i,l,n.srcDist+n.arrowGap),p=Wt(m,l,n.arrowSize,n.headShape)}else u=Et(i,l,n.srcDist);if(n.arrowAt==="target"){const m=Et(a,d,n.tgtDist);h=Et(a,d,n.tgtDist+n.arrowGap),p=Wt(m,d,n.arrowSize,n.headShape)}else h=Et(a,d,n.tgtDist);return Po(u,c,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function Po(e,r,t,n,o,i,s){var h;const a=[e,...r,t],c=[];let l=`M${xt(e)}`;for(let p=1;p<a.length-1;p++){const m=f1(a[p-1],a[p],a[p+1],o);c.push(m),m.r===0?l+=` L${xt(m.b)}`:l+=` L${xt(m.p1)} Q${xt(m.b)} ${xt(m.p2)}`}l+=` L${xt(t)}`;let d;const u=r.length;if(u===0)d={x:(e.x+t.x)/2,y:(e.y+t.y)/2,angle:Cr(t.x-e.x,t.y-e.y)};else if(u%2===0){const p=r[u/2-1],m=r[u/2];d={x:(p.x+m.x)/2,y:(p.y+m.y)/2,angle:Cr(m.x-p.x,m.y-p.y)}}else{const p=c[(u-1)/2];if(p.r===0){const m=a[(u-1)/2+2];d={x:p.b.x,y:p.b.y,angle:Cr(m.x-p.b.x,m.y-p.b.y)}}else d={x:.25*p.p1.x+.5*p.b.x+.25*p.p2.x,y:.25*p.p1.y+.5*p.b.y+.25*p.p2.y,angle:Cr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(s!==void 0&&c.length===2){const y=c[0].p2,b=c[1].p1,v=Math.hypot(b.x-y.x,b.y-y.y),w=Math.min(.5,i/(2*v)),x=Math.max(w,Math.min(1-w,s));d={x:y.x+(b.x-y.x)*x,y:y.y+(b.y-y.y)*x,angle:Cr(b.x-y.x,b.y-y.y)}}const p=((h=c[c.length-1])==null?void 0:h.p2)??e,m=t.x-p.x,g=t.y-p.y;Math.hypot(m,g)>=i&&(d={x:(p.x+t.x)/2,y:(p.y+t.y)/2,angle:Cr(m,g)})}return{d:l,arrow:n,label:d}}function Qu(e,r,t,n,o,i,s){const a=t==="leftward"?-1:1,c={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},l={x:r.x-a*(r.w/2+s.tgtDist),y:o??r.y},d=Math.max(80,s.arrowGap+s.arrowSize*.3),u=c.x+a*d,h=l.x-a*d;let p;if(a*(h-u)>=0){const b=c.x+(l.x-c.x)*i,v=Math.max(Math.min(u,h),Math.min(Math.max(u,h),b));p=[{x:v,y:c.y},{x:v,y:l.y}]}else{const b=Math.min(e.y-e.h/2,r.y-r.h/2)-d*(1+i);p=[{x:u,y:c.y},{x:u,y:b},{x:h,y:b},{x:h,y:l.y}]}const m=s.arrowAt==="source"?Et(c,p[0],s.arrowGap):c,g=s.arrowAt==="target"?Et(l,p[p.length-1],s.arrowGap):l,y=s.arrowAt==="source"?Wt(c,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?Wt(l,p[p.length-1],s.arrowSize,s.headShape):void 0;return Po(m,p,g,y,s.radius)}function ef(e,r,t,n,o){return Xb(l1(e,r,t,n),e,r,o)}function tf(e,r,t,n,o,i){const s=n===void 0&&o===void 0&&(t==="downward"||t==="upward"),a=t==="leftward"||s&&t==="upward"?-1:1,c=(l,d,u)=>{const h={x:l.x,y:d??l.y},p=Math.max(l.w,l.h)*2+1,m=sn(h,{x:h.x+(s?0:u*p),y:h.y+(s?u*p:0)},l);return m?{x:m.x+(s?0:u*i),y:m.y+(s?u*i:0)}:s?{x:l.x,y:l.y+u*(l.h/2+i)}:{x:l.x+u*(l.w/2+i),y:d??l.y}};return{sourcePoint:c(e,n,a),targetPoint:c(r,o,-a)}}function h1(e,r,t,n){const o=t==="downward"||t==="upward",i=t==="leftward"||t==="upward"?-1:1,s=Math.max(100,Math.abs(o?r.y-e.y:r.x-e.x)/2),a={x:e.x+(o?0:i*s),y:e.y+(o?i*s:0)},c={x:r.x-(o?0:i*s),y:r.y-(o?i*s:0)},l=n.arrowAt==="source"?Et(e,a,n.arrowGap):e,d=n.arrowAt==="target"?Et(r,c,n.arrowGap):r;return{d:`M${xt(l)} C${xt(a)} ${xt(c)} ${xt(d)}`,arrow:n.arrowAt==="source"?Wt(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?Wt(r,c,n.arrowSize,n.headShape):void 0,label:{x:(l.x+3*a.x+3*c.x+d.x)/8,y:(l.y+3*a.y+3*c.y+d.y)/8,angle:Cr(d.x+c.x-a.x-l.x,d.y+c.y-a.y-l.y)}}}function Yb(e,r,t){const n=t.arrowAt==="source"?Et(e,r,t.arrowGap):e,o=t.arrowAt==="target"?Et(r,e,t.arrowGap):r,i=t.arrowAt==="source"?Wt(e,r,t.arrowSize,t.headShape):t.arrowAt==="target"?Wt(r,e,t.arrowSize,t.headShape):void 0;return Po(n,[],o,i,0)}function p1(e,r,t,n=-90,o=-60,i=350){const s=n*Math.PI/180,a=o*Math.PI/180,c=s-Math.PI/2,l=c-a/2,d=c+a/2,u=1.4*i*(r/3+1),h={x:e.x+Math.cos(l)*u,y:e.y+Math.sin(l)*u},p={x:e.x+Math.cos(d)*u,y:e.y+Math.sin(d)*u},m={x:e.x,y:e.y},g=sn(m,h,e),y=sn(m,p,e);if(!g||!y)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let v=Et(g,h,t.srcDist),w=Et(y,p,t.tgtDist),x;if(t.arrowAt==="target"){const S=w;w=Et(y,p,t.tgtDist+t.arrowGap),x=Wt(S,p,t.arrowSize,t.headShape)}else if(t.arrowAt==="source"){const S=v;v=Et(g,h,t.srcDist+t.arrowGap),x=Wt(S,h,t.arrowSize,t.headShape)}return{d:`M${xt(v)} Q${xt(h)} ${xt(b)} Q${xt(p)} ${xt(w)}`,arrow:x,label:{x:b.x,y:b.y,angle:Cr(p.x-h.x,p.y-h.y)}}}const $r=e=>Math.round(e*1e3)/1e3;function Qb(e){var h,p;const r=e.querySelector("[data-flow-node-surface]");if(!r)return;const t=e.getBoundingClientRect(),n=t.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const o=r.getBoundingClientRect();if(!o.width||!o.height)return;const i=(p=(h=r.closest("[data-flow-icon-label]"))==null?void 0:h.querySelector("[data-flow-icon-caption]"))==null?void 0:p.getBoundingClientRect(),s=r,a=typeof s.getScreenCTM=="function"?s.getScreenCTM():null,c=typeof s.getTotalLength=="function"?s.getTotalLength():0,l=s.points,d=(l==null?void 0:l.numberOfItems)||128,u=a&&c>0?Array.from({length:d},(m,g)=>{const y=l!=null&&l.numberOfItems?l.getItem(g):s.getPointAtLength(c*g/d);return{x:$r((a.a*y.x+a.c*y.y+a.e-t.left)/n),y:$r((a.b*y.x+a.d*y.y+a.f-t.top)/n)}}):void 0;return{left:$r((o.left-t.left)/n),top:$r((o.top-t.top)/n),width:r instanceof HTMLElement?r.offsetWidth:$r(o.width/n),height:r instanceof HTMLElement?r.offsetHeight:$r(o.height/n),radius:parseFloat(getComputedStyle(r).borderTopLeftRadius)||0,...i!=null&&i.height?{captionBottom:$r((i.bottom-t.top)/n)}:{},...u?{outline:u}:{}}}function qn(e,r){const t=e.x-e.w/2,n=e.y-e.h/2;return{x:t+r.left+r.width/2,y:n+r.top+r.height/2,w:r.width,h:r.height,...r.outline?{outline:r.outline.map(o=>({x:t+o.x,y:n+o.y}))}:{}}}function g1(e,r,t,n,o){var d;const i=o!=="TB"&&o!=="BT",s=i?"top":"left",a=i?"bottom":"right",c=new Map;for(const u of n)for(const[h,p,m]of[[u.source,u.sourceProperty,u.target],[u.target,u.targetProperty,u.source]]){const g=r.get(m);if(p===void 0||!g||m===h)continue;const y=t.get(m),b=JSON.stringify([h,p]),v=c.get(b)??[];v.push(y?qn(g,y):g),c.set(b,v)}const l=new Map(e);for(const[u,h]of e){const p=r.get(u);if(!p||!h.some(w=>w.placement==="config"))continue;const m=t.get(u),g=m?qn(p,m):p,y={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=m?qn(y,m):y,v=new Map;for(const w of h){if(w.placement!=="config")continue;const C=(c.get(JSON.stringify([u,w.property]))??[]).reduce((E,R)=>E+(i?R.y-g.y:R.x-g.x),0),S=((d=w.anchor)==null?void 0:d.side)===a?a:s;v.set(w,C<-.001?s:C>.001?a:S)}l.set(u,h.map(w=>{const x=v.get(w);if(!x)return w;const C=h.filter(R=>v.get(R)===x),S=(C.indexOf(w)+1)/(C.length+1),E=Zb(b,x,S);return{...w,anchor:E,top:E.y,height:0}}))}return l}function rf(e,r,t){const n=new Set(r.map(a=>a.id));if(!n.has(e))return new Set;const o=new Set([e]);let i=!0;for(;i;){i=!1;for(const a of r)!o.has(a.id)&&(o.has(a.parent??"")||a.id.startsWith(`${e}.`))&&(o.add(a.id),i=!0)}const s=new Set(o);for(const a of t)o.has(a.source)&&n.has(a.target)&&s.add(a.target),o.has(a.target)&&n.has(a.source)&&s.add(a.source);return s}const _r='"Helvetica Neue", Helvetica, sans-serif';let Cn;const oo=new Map;function Ao(e,r){const t=`${r}|${e}`,n=oo.get(t);if(n!==void 0)return n;Cn===void 0&&(Cn=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return Cn?(Cn.font=r,o=Cn.measureText(e).width):o=e.length*(parseFloat(r)||16)*.55,oo.size>5e3&&oo.clear(),oo.set(t,o),o}function y1(e,r,t){const n=[];for(const o of String(e).split(`
210
210
  `)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let s="";for(const a of i){const c=s?`${s} ${a}`:a;!s||Ao(c,r)<=t?s=c:(n.push(s),s=a)}n.push(s)}return n}const nf=e=>e.stopPropagation();function m1({id:e,rect:r,label:t,labelLayer:n,labelContent:o,style:i,onSelect:s,onCollapse:a,selected:c=!1}){const l=r.x2-r.x1,d=r.y2-r.y1,u=i.borderWidth,h=i.borderStyle==="dashed"?`${u*4} ${u*2}`:i.borderStyle==="dotted"?`${u} ${u}`:void 0,p=r.x1+l/2,m=i.labelPosition==="top"?r.y1+i.labelMargin-i.fontSize/2:i.labelPosition==="bottom"?r.y2-i.labelMargin+i.fontSize/2:r.y1+d/2,g=t?Ao(t,`bold ${i.fontSize}px ${_r}`):0,y=i.fontSize/5,b=t||c&&a?f.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[c&&a&&f.jsx("foreignObject",{x:p+g/2+y+8,y:m-24,width:48,height:48,"data-flow-content-toggle":"","data-flow-collapse-control":"",style:{pointerEvents:"auto"},children:f.jsx(Ge,{label:"Show icon",children:f.jsx(Ne,{"aria-label":"Show icon",icon:f.jsx(Q.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:i.textColor},onClick:v=>{v.stopPropagation(),a(e)}})})}),o?f.jsx("foreignObject",{x:p-g/2-y,y:m-i.fontSize/2-y,width:g+2*y,height:i.fontSize+2*y,style:{overflow:"visible"},onClick:nf,children:o}):t&&f.jsxs(f.Fragment,{children:[f.jsx("rect",{x:p-g/2-y,y:m-i.fontSize/2-y,width:g+2*y,height:i.fontSize+2*y,fill:i.textColor==="transparent"?"transparent":i.labelBg}),f.jsx("text",{x:p,y:m,fill:i.textColor,fontSize:i.fontSize,fontWeight:"bold",fontFamily:_r,style:{fontSize:i.fontSize,fontWeight:"bold",fontFamily:_r},textAnchor:"middle",dominantBaseline:"central",children:t})]})]}):null;return f.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:nf,onClick:v=>{v.stopPropagation(),s==null||s(e,{shiftKey:v.shiftKey,ctrlKey:v.ctrlKey,metaKey:v.metaKey,altKey:v.altKey})},children:[f.jsx("rect",{x:r.x1,y:r.y1,width:l,height:d,rx:i.borderRadius,ry:i.borderRadius,fill:i.bgColor,fillOpacity:i.bgOpacity,stroke:i.borderColor,strokeWidth:i.borderStyle==="double"?u/3:u,strokeDasharray:h}),i.borderStyle==="double"&&f.jsx("rect",{x:r.x1+u*2/3,y:r.y1+u*2/3,width:Math.max(0,l-u*4/3),height:Math.max(0,d-u*4/3),rx:Math.max(0,i.borderRadius-u*2/3),ry:Math.max(0,i.borderRadius-u*2/3),fill:"none",stroke:i.borderColor,strokeWidth:u/3}),i.animated&&u>0&&f.jsx(go,{variant:i.animationVariant,x:r.x1,y:r.y1,width:l,height:d,radius:i.borderRadius,color:i.animationColor||i.borderColor,strokeWidth:Math.max(8,u*1.6)}),n&&b?Wr.createPortal(b,n):b]})}const b1=j.memo(m1),yo=45,ex=70,Lr=15,tx=50;function rx(e,r,t=yo){const n=`${t}px ${_r}`,o=e?y1(e,n,200*t/yo):[],i=r?48+(o.length?12:0):0,s=i+Math.max(0,...o.map(l=>Ao(l,n))),a=Math.max(o.length*t,r?48:0),c=o.length||r?2*Lr:0;return{lines:o,iconWidth:i,contentWidth:s,contentHeight:a,width:s+c,height:a+c}}const Ln=6,nx=3,Kd=.3,x1=8,Jd=Math.max(Math.pow(Ln*13.37,.9),29)*nx-x1/Kd,ox=Ln*nx*2,co=80,v1=2*co+Jd*Kd+100,w1=36+2*Math.max(80,ox+Jd*Kd);function kd(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function Pd(e,r){return r==="auto"||(r==="properties"?kd(e):!kd(e))}function ar(e,r,t){return t!=="properties"||e!=="root"||r.some(n=>(n.source===e||n.target===e)&&kd(n))}function C1(e,r,t,n=!1,o){if(!n)return{nodes:e,edges:r};const i=e.filter(a=>ar(a.id,r,t)&&(!o||o.has(a.id))),s=new Set(i.map(a=>a.id));return{nodes:i,edges:r.filter(a=>Pd(a,t)&&s.has(a.source)&&s.has(a.target))}}const S1=500,j1="32 18",E1=e=>e.stopPropagation();function _1({id:e,reveal:r,onRevealComplete:t,edgeData:n,validationIssue:o,edgeType:i="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:c,target:l,sourceProperty:d,targetProperty:u,sourceY:h,targetY:p,sourcePort:m,targetPort:g,propertyMode:y=!1,dir:b,turn:v,labelAtTarget:w,labelFraction:x,color:C,connectorColor:S,labelBg:E,labelLayer:R,label:P,dashed:I,animated:M,inverted:k,loopIndex:_=0,onSelect:N}){const O=n==null?void 0:n.icon,V=y?yo:ex,{lines:T,iconWidth:Z,contentWidth:ue,contentHeight:K}=j.useMemo(()=>rx(P,O,V),[P,O,V]),ee=j.useMemo(()=>{const xe={srcDist:co,tgtDist:co,arrowGap:ox,arrowSize:Jd,headShape:y&&(k?h!==void 0||m:p!==void 0||g)?"square":"triangle",radius:s??(w?40:S1),arrowAt:k?"source":"target",labelTargetLength:w?ue+2*Lr:void 0,labelFraction:w?x:void 0},he=h!==void 0||p!==void 0||!!m||!!g,U=tf(c,l,b,h,p,0),re=h===void 0&&p===void 0&&(b==="downward"||b==="upward"),fe=m??{...U.sourcePoint,side:re?b==="upward"?"top":"bottom":b==="leftward"?"left":"right"},we=g??{...U.targetPoint,side:re?b==="upward"?"bottom":"top":b==="leftward"?"right":"left"},ie=c.x===l.x&&c.y===l.y,Ce=m||g?u1(fe,we,{...xe,srcDist:18,tgtDist:18},i):he?Qu(c,l,b,h,p,v,{...xe,srcDist:18,tgtDist:18,radius:s??Math.min(xe.radius,40)}):ie?p1(c,_,{...xe,srcDist:0,tgtDist:0}):ef(c,l,b,v,xe);if(!Ce)return null;const $e=tf(c,l,b,h,p,he?18:co);m&&($e.sourcePoint=Qr(m,18)),g&&($e.targetPoint=Qr(g,18));const Ue=Object.prototype.hasOwnProperty.call(a??{},i)?a==null?void 0:a[i]:void 0;if(Ue){const Ve={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return Ue({edge:n??{id:e,source:"",target:""},source:{...c},target:{...l},...$e,direction:Ve[b],sourceY:h,targetY:p,inverted:!!k,defaultGeometry:Ce})??Ce}return ie||m||g?Ce:i==="straight"?he?Yb($e.sourcePoint,$e.targetPoint,xe):Xb([c,l],c,l,xe):i==="bezier"?h1($e.sourcePoint,$e.targetPoint,he?b==="leftward"?"leftward":"rightward":b,xe):i==="orthogonal"?he?Qu(c,l,b,h,p,v,{...xe,srcDist:18,tgtDist:18,radius:0}):ef(c,l,b,v,{...xe,radius:0}):Ce},[c,e,n,i,s,a,l,y,h,p,m,g,b,v,k,_,w,x,ue]);if(!ee)return null;const H=(b==="rightward"||b==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},i)&&!(y&&(h!==void 0||p!==void 0||m||g)),ae=H?`translate(${ee.label.x} ${ee.label.y-K/2-2*Lr})`:`translate(${ee.label.x} ${ee.label.y}) rotate(${ee.label.angle}) translate(${b==="downward"||b==="upward"||w||Object.prototype.hasOwnProperty.call(a??{},i)?0:tx} 0)`,q=o!=null&&o.startsWith("Unverified:")?"#b45309":"#dc2626",D=o?q:C,G=o?f.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":o,transform:`translate(${ee.label.x} ${ee.label.y-T.length*V/2-55})`,children:[f.jsx("title",{children:o}),f.jsx(cr,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:q})]}):null,B=M&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",se=!B&&(I||M)?j1:void 0,te=M&&!B?`flow-sdk-edge-anim${k?" flow-sdk-edge-anim-rev":""}`:void 0;let le=null;const ne=r?{"--flow-edge-reveal-duration":`${r.durationMs??600}ms`,"--flow-edge-reveal-state":r.paused?"paused":"running"}:void 0;if(T.length||O){const xe=ue,he=K;le=f.jsxs("g",{className:`flow-sdk-edge-label${r?" flow-sdk-edge-reveal-end":""}`,style:ne,"data-label-transform":ae,"data-label-horizontal":H||void 0,"data-edge-id":e,"data-source-property":d,"data-target-property":u,transform:ae,children:[f.jsx("rect",{x:-xe/2-Lr,y:-he/2-Lr,width:xe+2*Lr,height:he+2*Lr,fill:C==="transparent"?"transparent":E}),f.jsx("text",{fill:C,fontSize:V,style:{fontSize:V,fontFamily:_r},fontFamily:_r,textAnchor:"middle",dominantBaseline:"central",children:T.map((U,re)=>f.jsx("tspan",{x:Z/2,y:(re-(T.length-1)/2)*V,children:U},re))}),O&&f.jsxs("g",{className:"flow-sdk-edge-icon",opacity:C==="transparent"?0:1,children:[f.jsx("title",{children:P?`Edge icon: ${P}`:"Edge icon"}),f.jsx("rect",{x:-xe/2,y:-24,width:48,height:48,fill:"transparent"}),f.jsx(cr,{name:O,svg:!0,size:48,x:-xe/2,y:-24,color:C})]})]})}const ce=f.jsxs(f.Fragment,{children:[f.jsx("path",{d:ee.d,fill:"none",stroke:D,strokeWidth:Ln,strokeOpacity:B?.35:void 0,strokeDasharray:se,className:te}),B&&f.jsx(n1,{path:ee.d,color:D,width:Ln*1.6,reversed:k})]});return f.jsxs("g",{className:"flow-sdk-edge",style:ne,"data-edge-id":e,"data-source-property":d,"data-target-property":u,"data-validation":o?o.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":o,onPointerDown:E1,onClick:xe=>{xe.stopPropagation(),N==null||N(e)},children:[r?f.jsx(t1,{path:ee.d,width:Ln*4,reversed:k,onComplete:()=>t==null?void 0:t(e),children:ce}):ce,ee.arrow&&f.jsx("path",{className:r?"flow-sdk-edge-reveal-end":void 0,d:ee.arrow,fill:o?q:S??D}),R&&le?Wr.createPortal(le,R):le,R&&G?Wr.createPortal(G,R):G,f.jsx("path",{className:"flow-sdk-edge-hit",d:ee.d,fill:"none",stroke:"transparent"})]})}const of=j.memo(_1);var io=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function k1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Zd(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ti,af;function P1(){if(af)return ti;af=1;function e(){this.__data__=[],this.size=0}return ti=e,ti}var ri,sf;function fn(){if(sf)return ri;sf=1;function e(r,t){return r===t||r!==r&&t!==t}return ri=e,ri}var ni,cf;function Ro(){if(cf)return ni;cf=1;var e=fn();function r(t,n){for(var o=t.length;o--;)if(e(t[o][0],n))return o;return-1}return ni=r,ni}var oi,lf;function A1(){if(lf)return oi;lf=1;var e=Ro(),r=Array.prototype,t=r.splice;function n(o){var i=this.__data__,s=e(i,o);if(s<0)return!1;var a=i.length-1;return s==a?i.pop():t.call(i,s,1),--this.size,!0}return oi=n,oi}var ii,df;function R1(){if(df)return ii;df=1;var e=Ro();function r(t){var n=this.__data__,o=e(n,t);return o<0?void 0:n[o][1]}return ii=r,ii}var ai,uf;function M1(){if(uf)return ai;uf=1;var e=Ro();function r(t){return e(this.__data__,t)>-1}return ai=r,ai}var si,ff;function T1(){if(ff)return si;ff=1;var e=Ro();function r(t,n){var o=this.__data__,i=e(o,t);return i<0?(++this.size,o.push([t,n])):o[i][1]=n,this}return si=r,si}var ci,hf;function Mo(){if(hf)return ci;hf=1;var e=P1(),r=A1(),t=R1(),n=M1(),o=T1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,ci=i,ci}var li,pf;function I1(){if(pf)return li;pf=1;var e=Mo();function r(){this.__data__=new e,this.size=0}return li=r,li}var di,gf;function N1(){if(gf)return di;gf=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return di=e,di}var ui,yf;function O1(){if(yf)return ui;yf=1;function e(r){return this.__data__.get(r)}return ui=e,ui}var fi,mf;function $1(){if(mf)return fi;mf=1;function e(r){return this.__data__.has(r)}return fi=e,fi}var hi,bf;function ix(){if(bf)return hi;bf=1;var e=typeof io=="object"&&io&&io.Object===Object&&io;return hi=e,hi}var pi,xf;function Yt(){if(xf)return pi;xf=1;var e=ix(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return pi=t,pi}var gi,vf;function hn(){if(vf)return gi;vf=1;var e=Yt(),r=e.Symbol;return gi=r,gi}var yi,wf;function q1(){if(wf)return yi;wf=1;var e=hn(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,o=e?e.toStringTag:void 0;function i(s){var a=t.call(s,o),c=s[o];try{s[o]=void 0;var l=!0}catch{}var d=n.call(s);return l&&(a?s[o]=c:delete s[o]),d}return yi=i,yi}var mi,Cf;function L1(){if(Cf)return mi;Cf=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return mi=t,mi}var bi,Sf;function Gr(){if(Sf)return bi;Sf=1;var e=hn(),r=q1(),t=L1(),n="[object Null]",o="[object Undefined]",i=e?e.toStringTag:void 0;function s(a){return a==null?a===void 0?o:n:i&&i in Object(a)?r(a):t(a)}return bi=s,bi}var xi,jf;function Vt(){if(jf)return xi;jf=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return xi=e,xi}var vi,Ef;function Un(){if(Ef)return vi;Ef=1;var e=Gr(),r=Vt(),t="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function s(a){if(!r(a))return!1;var c=e(a);return c==n||c==o||c==t||c==i}return vi=s,vi}var wi,_f;function F1(){if(_f)return wi;_f=1;var e=Yt(),r=e["__core-js_shared__"];return wi=r,wi}var Ci,kf;function z1(){if(kf)return Ci;kf=1;var e=F1(),r=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!r&&r in n}return Ci=t,Ci}var Si,Pf;function ax(){if(Pf)return Si;Pf=1;var e=Function.prototype,r=e.toString;function t(n){if(n!=null){try{return r.call(n)}catch{}try{return n+""}catch{}}return""}return Si=t,Si}var ji,Af;function B1(){if(Af)return ji;Af=1;var e=Un(),r=z1(),t=Vt(),n=ax(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,c=s.toString,l=a.hasOwnProperty,d=RegExp("^"+c.call(l).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function u(h){if(!t(h)||r(h))return!1;var p=e(h)?d:i;return p.test(n(h))}return ji=u,ji}var Ei,Rf;function D1(){if(Rf)return Ei;Rf=1;function e(r,t){return r==null?void 0:r[t]}return Ei=e,Ei}var _i,Mf;function Hr(){if(Mf)return _i;Mf=1;var e=B1(),r=D1();function t(n,o){var i=r(n,o);return e(i)?i:void 0}return _i=t,_i}var ki,Tf;function Xd(){if(Tf)return ki;Tf=1;var e=Hr(),r=Yt(),t=e(r,"Map");return ki=t,ki}var Pi,If;function To(){if(If)return Pi;If=1;var e=Hr(),r=e(Object,"create");return Pi=r,Pi}var Ai,Nf;function W1(){if(Nf)return Ai;Nf=1;var e=To();function r(){this.__data__=e?e(null):{},this.size=0}return Ai=r,Ai}var Ri,Of;function V1(){if(Of)return Ri;Of=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return Ri=e,Ri}var Mi,$f;function G1(){if($f)return Mi;$f=1;var e=To(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function o(i){var s=this.__data__;if(e){var a=s[i];return a===r?void 0:a}return n.call(s,i)?s[i]:void 0}return Mi=o,Mi}var Ti,qf;function H1(){if(qf)return Ti;qf=1;var e=To(),r=Object.prototype,t=r.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:t.call(i,o)}return Ti=n,Ti}var Ii,Lf;function U1(){if(Lf)return Ii;Lf=1;var e=To(),r="__lodash_hash_undefined__";function t(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?r:o,this}return Ii=t,Ii}var Ni,Ff;function K1(){if(Ff)return Ni;Ff=1;var e=W1(),r=V1(),t=G1(),n=H1(),o=U1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Ni=i,Ni}var Oi,zf;function J1(){if(zf)return Oi;zf=1;var e=K1(),r=Mo(),t=Xd();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return Oi=n,Oi}var $i,Bf;function Z1(){if(Bf)return $i;Bf=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return $i=e,$i}var qi,Df;function Io(){if(Df)return qi;Df=1;var e=Z1();function r(t,n){var o=t.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return qi=r,qi}var Li,Wf;function X1(){if(Wf)return Li;Wf=1;var e=Io();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return Li=r,Li}var Fi,Vf;function Y1(){if(Vf)return Fi;Vf=1;var e=Io();function r(t){return e(this,t).get(t)}return Fi=r,Fi}var zi,Gf;function Q1(){if(Gf)return zi;Gf=1;var e=Io();function r(t){return e(this,t).has(t)}return zi=r,zi}var Bi,Hf;function eC(){if(Hf)return Bi;Hf=1;var e=Io();function r(t,n){var o=e(this,t),i=o.size;return o.set(t,n),this.size+=o.size==i?0:1,this}return Bi=r,Bi}var Di,Uf;function Yd(){if(Uf)return Di;Uf=1;var e=J1(),r=X1(),t=Y1(),n=Q1(),o=eC();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Di=i,Di}var Wi,Kf;function tC(){if(Kf)return Wi;Kf=1;var e=Mo(),r=Xd(),t=Yd(),n=200;function o(i,s){var a=this.__data__;if(a instanceof e){var c=a.__data__;if(!r||c.length<n-1)return c.push([i,s]),this.size=++a.size,this;a=this.__data__=new t(c)}return a.set(i,s),this.size=a.size,this}return Wi=o,Wi}var Vi,Jf;function No(){if(Jf)return Vi;Jf=1;var e=Mo(),r=I1(),t=N1(),n=O1(),o=$1(),i=tC();function s(a){var c=this.__data__=new e(a);this.size=c.size}return s.prototype.clear=r,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,Vi=s,Vi}var Gi,Zf;function Qd(){if(Zf)return Gi;Zf=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o&&t(r[n],n,r)!==!1;);return r}return Gi=e,Gi}var Hi,Xf;function sx(){if(Xf)return Hi;Xf=1;var e=Hr(),r=(function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Hi=r,Hi}var Ui,Yf;function Oo(){if(Yf)return Ui;Yf=1;var e=sx();function r(t,n,o){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):t[n]=o}return Ui=r,Ui}var Ki,Qf;function $o(){if(Qf)return Ki;Qf=1;var e=Oo(),r=fn(),t=Object.prototype,n=t.hasOwnProperty;function o(i,s,a){var c=i[s];(!(n.call(i,s)&&r(c,a))||a===void 0&&!(s in i))&&e(i,s,a)}return Ki=o,Ki}var Ji,eh;function Kn(){if(eh)return Ji;eh=1;var e=$o(),r=Oo();function t(n,o,i,s){var a=!i;i||(i={});for(var c=-1,l=o.length;++c<l;){var d=o[c],u=s?s(i[d],n[d],d,i,n):void 0;u===void 0&&(u=n[d]),a?r(i,d,u):e(i,d,u)}return i}return Ji=t,Ji}var Zi,th;function rC(){if(th)return Zi;th=1;function e(r,t){for(var n=-1,o=Array(r);++n<r;)o[n]=t(n);return o}return Zi=e,Zi}var Xi,rh;function lr(){if(rh)return Xi;rh=1;function e(r){return r!=null&&typeof r=="object"}return Xi=e,Xi}var Yi,nh;function nC(){if(nh)return Yi;nh=1;var e=Gr(),r=lr(),t="[object Arguments]";function n(o){return r(o)&&e(o)==t}return Yi=n,Yi}var Qi,oh;function Jn(){if(oh)return Qi;oh=1;var e=nC(),r=lr(),t=Object.prototype,n=t.hasOwnProperty,o=t.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(s){return r(s)&&n.call(s,"callee")&&!o.call(s,"callee")};return Qi=i,Qi}var ea,ih;function Ct(){if(ih)return ea;ih=1;var e=Array.isArray;return ea=e,ea}var kn={exports:{}},ta,ah;function oC(){if(ah)return ta;ah=1;function e(){return!1}return ta=e,ta}kn.exports;var sh;function pn(){return sh||(sh=1,(function(e,r){var t=Yt(),n=oC(),o=r&&!r.nodeType&&r,i=o&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===o,a=s?t.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||n;e.exports=l})(kn,kn.exports)),kn.exports}var ra,ch;function qo(){if(ch)return ra;ch=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<o}return ra=t,ra}var na,lh;function eu(){if(lh)return na;lh=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=e}return na=r,na}var oa,dh;function iC(){if(dh)return oa;dh=1;var e=Gr(),r=eu(),t=lr(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",s="[object Date]",a="[object Error]",c="[object Function]",l="[object Map]",d="[object Number]",u="[object Object]",h="[object RegExp]",p="[object Set]",m="[object String]",g="[object WeakMap]",y="[object ArrayBuffer]",b="[object DataView]",v="[object Float32Array]",w="[object Float64Array]",x="[object Int8Array]",C="[object Int16Array]",S="[object Int32Array]",E="[object Uint8Array]",R="[object Uint8ClampedArray]",P="[object Uint16Array]",I="[object Uint32Array]",M={};M[v]=M[w]=M[x]=M[C]=M[S]=M[E]=M[R]=M[P]=M[I]=!0,M[n]=M[o]=M[y]=M[i]=M[b]=M[s]=M[a]=M[c]=M[l]=M[d]=M[u]=M[h]=M[p]=M[m]=M[g]=!1;function k(_){return t(_)&&r(_.length)&&!!M[e(_)]}return oa=k,oa}var ia,uh;function Lo(){if(uh)return ia;uh=1;function e(r){return function(t){return r(t)}}return ia=e,ia}var Pn={exports:{}};Pn.exports;var fh;function tu(){return fh||(fh=1,(function(e,r){var t=ix(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i&&t.process,a=(function(){try{var c=o&&o.require&&o.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}})();e.exports=a})(Pn,Pn.exports)),Pn.exports}var aa,hh;function Zn(){if(hh)return aa;hh=1;var e=iC(),r=Lo(),t=tu(),n=t&&t.isTypedArray,o=n?r(n):e;return aa=o,aa}var sa,ph;function cx(){if(ph)return sa;ph=1;var e=rC(),r=Jn(),t=Ct(),n=pn(),o=qo(),i=Zn(),s=Object.prototype,a=s.hasOwnProperty;function c(l,d){var u=t(l),h=!u&&r(l),p=!u&&!h&&n(l),m=!u&&!h&&!p&&i(l),g=u||h||p||m,y=g?e(l.length,String):[],b=y.length;for(var v in l)(d||a.call(l,v))&&!(g&&(v=="length"||p&&(v=="offset"||v=="parent")||m&&(v=="buffer"||v=="byteLength"||v=="byteOffset")||o(v,b)))&&y.push(v);return y}return sa=c,sa}var ca,gh;function Fo(){if(gh)return ca;gh=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,o=typeof n=="function"&&n.prototype||e;return t===o}return ca=r,ca}var la,yh;function lx(){if(yh)return la;yh=1;function e(r,t){return function(n){return r(t(n))}}return la=e,la}var da,mh;function aC(){if(mh)return da;mh=1;var e=lx(),r=e(Object.keys,Object);return da=r,da}var ua,bh;function ru(){if(bh)return ua;bh=1;var e=Fo(),r=aC(),t=Object.prototype,n=t.hasOwnProperty;function o(i){if(!e(i))return r(i);var s=[];for(var a in Object(i))n.call(i,a)&&a!="constructor"&&s.push(a);return s}return ua=o,ua}var fa,xh;function yr(){if(xh)return fa;xh=1;var e=Un(),r=eu();function t(n){return n!=null&&r(n.length)&&!e(n)}return fa=t,fa}var ha,vh;function Mr(){if(vh)return ha;vh=1;var e=cx(),r=ru(),t=yr();function n(o){return t(o)?e(o):r(o)}return ha=n,ha}var pa,wh;function sC(){if(wh)return pa;wh=1;var e=Kn(),r=Mr();function t(n,o){return n&&e(o,r(o),n)}return pa=t,pa}var ga,Ch;function cC(){if(Ch)return ga;Ch=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return ga=e,ga}var ya,Sh;function lC(){if(Sh)return ya;Sh=1;var e=Vt(),r=Fo(),t=cC(),n=Object.prototype,o=n.hasOwnProperty;function i(s){if(!e(s))return t(s);var a=r(s),c=[];for(var l in s)l=="constructor"&&(a||!o.call(s,l))||c.push(l);return c}return ya=i,ya}var ma,jh;function Ur(){if(jh)return ma;jh=1;var e=cx(),r=lC(),t=yr();function n(o){return t(o)?e(o,!0):r(o)}return ma=n,ma}var ba,Eh;function dC(){if(Eh)return ba;Eh=1;var e=Kn(),r=Ur();function t(n,o){return n&&e(o,r(o),n)}return ba=t,ba}var An={exports:{}};An.exports;var _h;function dx(){return _h||(_h=1,(function(e,r){var t=Yt(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i?t.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(l,d){if(d)return l.slice();var u=l.length,h=a?a(u):new l.constructor(u);return l.copy(h),h}e.exports=c})(An,An.exports)),An.exports}var xa,kh;function ux(){if(kh)return xa;kh=1;function e(r,t){var n=-1,o=r.length;for(t||(t=Array(o));++n<o;)t[n]=r[n];return t}return xa=e,xa}var va,Ph;function fx(){if(Ph)return va;Ph=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,i=0,s=[];++n<o;){var a=r[n];t(a,n,r)&&(s[i++]=a)}return s}return va=e,va}var wa,Ah;function hx(){if(Ah)return wa;Ah=1;function e(){return[]}return wa=e,wa}var Ca,Rh;function nu(){if(Rh)return Ca;Rh=1;var e=fx(),r=hx(),t=Object.prototype,n=t.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(s){return s==null?[]:(s=Object(s),e(o(s),function(a){return n.call(s,a)}))}:r;return Ca=i,Ca}var Sa,Mh;function uC(){if(Mh)return Sa;Mh=1;var e=Kn(),r=nu();function t(n,o){return e(n,r(n),o)}return Sa=t,Sa}var ja,Th;function ou(){if(Th)return ja;Th=1;function e(r,t){for(var n=-1,o=t.length,i=r.length;++n<o;)r[i+n]=t[n];return r}return ja=e,ja}var Ea,Ih;function zo(){if(Ih)return Ea;Ih=1;var e=lx(),r=e(Object.getPrototypeOf,Object);return Ea=r,Ea}var _a,Nh;function px(){if(Nh)return _a;Nh=1;var e=ou(),r=zo(),t=nu(),n=hx(),o=Object.getOwnPropertySymbols,i=o?function(s){for(var a=[];s;)e(a,t(s)),s=r(s);return a}:n;return _a=i,_a}var ka,Oh;function fC(){if(Oh)return ka;Oh=1;var e=Kn(),r=px();function t(n,o){return e(n,r(n),o)}return ka=t,ka}var Pa,$h;function gx(){if($h)return Pa;$h=1;var e=ou(),r=Ct();function t(n,o,i){var s=o(n);return r(n)?s:e(s,i(n))}return Pa=t,Pa}var Aa,qh;function yx(){if(qh)return Aa;qh=1;var e=gx(),r=nu(),t=Mr();function n(o){return e(o,t,r)}return Aa=n,Aa}var Ra,Lh;function hC(){if(Lh)return Ra;Lh=1;var e=gx(),r=px(),t=Ur();function n(o){return e(o,t,r)}return Ra=n,Ra}var Ma,Fh;function pC(){if(Fh)return Ma;Fh=1;var e=Hr(),r=Yt(),t=e(r,"DataView");return Ma=t,Ma}var Ta,zh;function gC(){if(zh)return Ta;zh=1;var e=Hr(),r=Yt(),t=e(r,"Promise");return Ta=t,Ta}var Ia,Bh;function mx(){if(Bh)return Ia;Bh=1;var e=Hr(),r=Yt(),t=e(r,"Set");return Ia=t,Ia}var Na,Dh;function yC(){if(Dh)return Na;Dh=1;var e=Hr(),r=Yt(),t=e(r,"WeakMap");return Na=t,Na}var Oa,Wh;function gn(){if(Wh)return Oa;Wh=1;var e=pC(),r=Xd(),t=gC(),n=mx(),o=yC(),i=Gr(),s=ax(),a="[object Map]",c="[object Object]",l="[object Promise]",d="[object Set]",u="[object WeakMap]",h="[object DataView]",p=s(e),m=s(r),g=s(t),y=s(n),b=s(o),v=i;return(e&&v(new e(new ArrayBuffer(1)))!=h||r&&v(new r)!=a||t&&v(t.resolve())!=l||n&&v(new n)!=d||o&&v(new o)!=u)&&(v=function(w){var x=i(w),C=x==c?w.constructor:void 0,S=C?s(C):"";if(S)switch(S){case p:return h;case m:return a;case g:return l;case y:return d;case b:return u}return x}),Oa=v,Oa}var $a,Vh;function mC(){if(Vh)return $a;Vh=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&r.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return $a=t,$a}var qa,Gh;function bx(){if(Gh)return qa;Gh=1;var e=Yt(),r=e.Uint8Array;return qa=r,qa}var La,Hh;function iu(){if(Hh)return La;Hh=1;var e=bx();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return La=r,La}var Fa,Uh;function bC(){if(Uh)return Fa;Uh=1;var e=iu();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.byteLength)}return Fa=r,Fa}var za,Kh;function xC(){if(Kh)return za;Kh=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return za=r,za}var Ba,Jh;function vC(){if(Jh)return Ba;Jh=1;var e=hn(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(o){return t?Object(t.call(o)):{}}return Ba=n,Ba}var Da,Zh;function xx(){if(Zh)return Da;Zh=1;var e=iu();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}return Da=r,Da}var Wa,Xh;function wC(){if(Xh)return Wa;Xh=1;var e=iu(),r=bC(),t=xC(),n=vC(),o=xx(),i="[object Boolean]",s="[object Date]",a="[object Map]",c="[object Number]",l="[object RegExp]",d="[object Set]",u="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",m="[object DataView]",g="[object Float32Array]",y="[object Float64Array]",b="[object Int8Array]",v="[object Int16Array]",w="[object Int32Array]",x="[object Uint8Array]",C="[object Uint8ClampedArray]",S="[object Uint16Array]",E="[object Uint32Array]";function R(P,I,M){var k=P.constructor;switch(I){case p:return e(P);case i:case s:return new k(+P);case m:return r(P,M);case g:case y:case b:case v:case w:case x:case C:case S:case E:return o(P,M);case a:return new k;case c:case u:return new k(P);case l:return t(P);case d:return new k;case h:return n(P)}}return Wa=R,Wa}var Va,Yh;function vx(){if(Yh)return Va;Yh=1;var e=Vt(),r=Object.create,t=(function(){function n(){}return function(o){if(!e(o))return{};if(r)return r(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return Va=t,Va}var Ga,Qh;function wx(){if(Qh)return Ga;Qh=1;var e=vx(),r=zo(),t=Fo();function n(o){return typeof o.constructor=="function"&&!t(o)?e(r(o)):{}}return Ga=n,Ga}var Ha,ep;function CC(){if(ep)return Ha;ep=1;var e=gn(),r=lr(),t="[object Map]";function n(o){return r(o)&&e(o)==t}return Ha=n,Ha}var Ua,tp;function SC(){if(tp)return Ua;tp=1;var e=CC(),r=Lo(),t=tu(),n=t&&t.isMap,o=n?r(n):e;return Ua=o,Ua}var Ka,rp;function jC(){if(rp)return Ka;rp=1;var e=gn(),r=lr(),t="[object Set]";function n(o){return r(o)&&e(o)==t}return Ka=n,Ka}var Ja,np;function EC(){if(np)return Ja;np=1;var e=jC(),r=Lo(),t=tu(),n=t&&t.isSet,o=n?r(n):e;return Ja=o,Ja}var Za,op;function Cx(){if(op)return Za;op=1;var e=No(),r=Qd(),t=$o(),n=sC(),o=dC(),i=dx(),s=ux(),a=uC(),c=fC(),l=yx(),d=hC(),u=gn(),h=mC(),p=wC(),m=wx(),g=Ct(),y=pn(),b=SC(),v=Vt(),w=EC(),x=Mr(),C=Ur(),S=1,E=2,R=4,P="[object Arguments]",I="[object Array]",M="[object Boolean]",k="[object Date]",_="[object Error]",N="[object Function]",O="[object GeneratorFunction]",V="[object Map]",T="[object Number]",Z="[object Object]",ue="[object RegExp]",K="[object Set]",ee="[object String]",H="[object Symbol]",ae="[object WeakMap]",q="[object ArrayBuffer]",D="[object DataView]",G="[object Float32Array]",B="[object Float64Array]",se="[object Int8Array]",te="[object Int16Array]",le="[object Int32Array]",ne="[object Uint8Array]",ce="[object Uint8ClampedArray]",xe="[object Uint16Array]",he="[object Uint32Array]",U={};U[P]=U[I]=U[q]=U[D]=U[M]=U[k]=U[G]=U[B]=U[se]=U[te]=U[le]=U[V]=U[T]=U[Z]=U[ue]=U[K]=U[ee]=U[H]=U[ne]=U[ce]=U[xe]=U[he]=!0,U[_]=U[N]=U[ae]=!1;function re(fe,we,ie,Ce,$e,Ue){var Ve,tt=we&S,ye=we&E,Ae=we&R;if(ie&&(Ve=$e?ie(fe,Ce,$e,Ue):ie(fe)),Ve!==void 0)return Ve;if(!v(fe))return fe;var Le=g(fe);if(Le){if(Ve=h(fe),!tt)return s(fe,Ve)}else{var be=u(fe),Xe=be==N||be==O;if(y(fe))return i(fe,tt);if(be==Z||be==P||Xe&&!$e){if(Ve=ye||Xe?{}:m(fe),!tt)return ye?c(fe,o(Ve,fe)):a(fe,n(Ve,fe))}else{if(!U[be])return $e?fe:{};Ve=p(fe,be,tt)}}Ue||(Ue=new e);var ut=Ue.get(fe);if(ut)return ut;Ue.set(fe,Ve),w(fe)?fe.forEach(function(lt){Ve.add(re(lt,we,ie,lt,fe,Ue))}):b(fe)&&fe.forEach(function(lt,Je){Ve.set(Je,re(lt,we,ie,Je,fe,Ue))});var Re=Ae?ye?d:l:ye?C:x,Ke=Le?void 0:Re(fe);return r(Ke||fe,function(lt,Je){Ke&&(Je=lt,lt=fe[Je]),t(Ve,Je,re(lt,we,ie,Je,fe,Ue))}),Ve}return Za=re,Za}var Xa,ip;function _C(){if(ip)return Xa;ip=1;var e=Cx(),r=4;function t(n){return e(n,r)}return Xa=t,Xa}var Ya,ap;function au(){if(ap)return Ya;ap=1;function e(r){return function(){return r}}return Ya=e,Ya}var Qa,sp;function kC(){if(sp)return Qa;sp=1;function e(r){return function(t,n,o){for(var i=-1,s=Object(t),a=o(t),c=a.length;c--;){var l=a[r?c:++i];if(n(s[l],l,s)===!1)break}return t}}return Qa=e,Qa}var es,cp;function su(){if(cp)return es;cp=1;var e=kC(),r=e();return es=r,es}var ts,lp;function cu(){if(lp)return ts;lp=1;var e=su(),r=Mr();function t(n,o){return n&&e(n,o,r)}return ts=t,ts}var rs,dp;function PC(){if(dp)return rs;dp=1;var e=yr();function r(t,n){return function(o,i){if(o==null)return o;if(!e(o))return t(o,i);for(var s=o.length,a=n?s:-1,c=Object(o);(n?a--:++a<s)&&i(c[a],a,c)!==!1;);return o}}return rs=r,rs}var ns,up;function Bo(){if(up)return ns;up=1;var e=cu(),r=PC(),t=r(e);return ns=t,ns}var os,fp;function Kr(){if(fp)return os;fp=1;function e(r){return r}return os=e,os}var is,hp;function Sx(){if(hp)return is;hp=1;var e=Kr();function r(t){return typeof t=="function"?t:e}return is=r,is}var as,pp;function jx(){if(pp)return as;pp=1;var e=Qd(),r=Bo(),t=Sx(),n=Ct();function o(i,s){var a=n(i)?e:r;return a(i,t(s))}return as=o,as}var ss,gp;function Ex(){return gp||(gp=1,ss=jx()),ss}var cs,yp;function AC(){if(yp)return cs;yp=1;var e=Bo();function r(t,n){var o=[];return e(t,function(i,s,a){n(i,s,a)&&o.push(i)}),o}return cs=r,cs}var ls,mp;function RC(){if(mp)return ls;mp=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return ls=r,ls}var ds,bp;function MC(){if(bp)return ds;bp=1;function e(r){return this.__data__.has(r)}return ds=e,ds}var us,xp;function _x(){if(xp)return us;xp=1;var e=Yd(),r=RC(),t=MC();function n(o){var i=-1,s=o==null?0:o.length;for(this.__data__=new e;++i<s;)this.add(o[i])}return n.prototype.add=n.prototype.push=r,n.prototype.has=t,us=n,us}var fs,vp;function TC(){if(vp)return fs;vp=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o;)if(t(r[n],n,r))return!0;return!1}return fs=e,fs}var hs,wp;function kx(){if(wp)return hs;wp=1;function e(r,t){return r.has(t)}return hs=e,hs}var ps,Cp;function Px(){if(Cp)return ps;Cp=1;var e=_x(),r=TC(),t=kx(),n=1,o=2;function i(s,a,c,l,d,u){var h=c&n,p=s.length,m=a.length;if(p!=m&&!(h&&m>p))return!1;var g=u.get(s),y=u.get(a);if(g&&y)return g==a&&y==s;var b=-1,v=!0,w=c&o?new e:void 0;for(u.set(s,a),u.set(a,s);++b<p;){var x=s[b],C=a[b];if(l)var S=h?l(C,x,b,a,s,u):l(x,C,b,s,a,u);if(S!==void 0){if(S)continue;v=!1;break}if(w){if(!r(a,function(E,R){if(!t(w,R)&&(x===E||d(x,E,c,l,u)))return w.push(R)})){v=!1;break}}else if(!(x===C||d(x,C,c,l,u))){v=!1;break}}return u.delete(s),u.delete(a),v}return ps=i,ps}var gs,Sp;function IC(){if(Sp)return gs;Sp=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o,i){n[++t]=[i,o]}),n}return gs=e,gs}var ys,jp;function lu(){if(jp)return ys;jp=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o){n[++t]=o}),n}return ys=e,ys}var ms,Ep;function NC(){if(Ep)return ms;Ep=1;var e=hn(),r=bx(),t=fn(),n=Px(),o=IC(),i=lu(),s=1,a=2,c="[object Boolean]",l="[object Date]",d="[object Error]",u="[object Map]",h="[object Number]",p="[object RegExp]",m="[object Set]",g="[object String]",y="[object Symbol]",b="[object ArrayBuffer]",v="[object DataView]",w=e?e.prototype:void 0,x=w?w.valueOf:void 0;function C(S,E,R,P,I,M,k){switch(R){case v:if(S.byteLength!=E.byteLength||S.byteOffset!=E.byteOffset)return!1;S=S.buffer,E=E.buffer;case b:return!(S.byteLength!=E.byteLength||!M(new r(S),new r(E)));case c:case l:case h:return t(+S,+E);case d:return S.name==E.name&&S.message==E.message;case p:case g:return S==E+"";case u:var _=o;case m:var N=P&s;if(_||(_=i),S.size!=E.size&&!N)return!1;var O=k.get(S);if(O)return O==E;P|=a,k.set(S,E);var V=n(_(S),_(E),P,I,M,k);return k.delete(S),V;case y:if(x)return x.call(S)==x.call(E)}return!1}return ms=C,ms}var bs,_p;function OC(){if(_p)return bs;_p=1;var e=yx(),r=1,t=Object.prototype,n=t.hasOwnProperty;function o(i,s,a,c,l,d){var u=a&r,h=e(i),p=h.length,m=e(s),g=m.length;if(p!=g&&!u)return!1;for(var y=p;y--;){var b=h[y];if(!(u?b in s:n.call(s,b)))return!1}var v=d.get(i),w=d.get(s);if(v&&w)return v==s&&w==i;var x=!0;d.set(i,s),d.set(s,i);for(var C=u;++y<p;){b=h[y];var S=i[b],E=s[b];if(c)var R=u?c(E,S,b,s,i,d):c(S,E,b,i,s,d);if(!(R===void 0?S===E||l(S,E,a,c,d):R)){x=!1;break}C||(C=b=="constructor")}if(x&&!C){var P=i.constructor,I=s.constructor;P!=I&&"constructor"in i&&"constructor"in s&&!(typeof P=="function"&&P instanceof P&&typeof I=="function"&&I instanceof I)&&(x=!1)}return d.delete(i),d.delete(s),x}return bs=o,bs}var xs,kp;function $C(){if(kp)return xs;kp=1;var e=No(),r=Px(),t=NC(),n=OC(),o=gn(),i=Ct(),s=pn(),a=Zn(),c=1,l="[object Arguments]",d="[object Array]",u="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function m(g,y,b,v,w,x){var C=i(g),S=i(y),E=C?d:o(g),R=S?d:o(y);E=E==l?u:E,R=R==l?u:R;var P=E==u,I=R==u,M=E==R;if(M&&s(g)){if(!s(y))return!1;C=!0,P=!1}if(M&&!P)return x||(x=new e),C||a(g)?r(g,y,b,v,w,x):t(g,y,E,b,v,w,x);if(!(b&c)){var k=P&&p.call(g,"__wrapped__"),_=I&&p.call(y,"__wrapped__");if(k||_){var N=k?g.value():g,O=_?y.value():y;return x||(x=new e),w(N,O,b,v,x)}}return M?(x||(x=new e),n(g,y,b,v,w,x)):!1}return xs=m,xs}var vs,Pp;function Ax(){if(Pp)return vs;Pp=1;var e=$C(),r=lr();function t(n,o,i,s,a){return n===o?!0:n==null||o==null||!r(n)&&!r(o)?n!==n&&o!==o:e(n,o,i,s,t,a)}return vs=t,vs}var ws,Ap;function qC(){if(Ap)return ws;Ap=1;var e=No(),r=Ax(),t=1,n=2;function o(i,s,a,c){var l=a.length,d=l,u=!c;if(i==null)return!d;for(i=Object(i);l--;){var h=a[l];if(u&&h[2]?h[1]!==i[h[0]]:!(h[0]in i))return!1}for(;++l<d;){h=a[l];var p=h[0],m=i[p],g=h[1];if(u&&h[2]){if(m===void 0&&!(p in i))return!1}else{var y=new e;if(c)var b=c(m,g,p,i,s,y);if(!(b===void 0?r(g,m,t|n,c,y):b))return!1}}return!0}return ws=o,ws}var Cs,Rp;function Rx(){if(Rp)return Cs;Rp=1;var e=Vt();function r(t){return t===t&&!e(t)}return Cs=r,Cs}var Ss,Mp;function LC(){if(Mp)return Ss;Mp=1;var e=Rx(),r=Mr();function t(n){for(var o=r(n),i=o.length;i--;){var s=o[i],a=n[s];o[i]=[s,a,e(a)]}return o}return Ss=t,Ss}var js,Tp;function Mx(){if(Tp)return js;Tp=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return js=e,js}var Es,Ip;function FC(){if(Ip)return Es;Ip=1;var e=qC(),r=LC(),t=Mx();function n(o){var i=r(o);return i.length==1&&i[0][2]?t(i[0][0],i[0][1]):function(s){return s===o||e(s,o,i)}}return Es=n,Es}var _s,Np;function yn(){if(Np)return _s;Np=1;var e=Gr(),r=lr(),t="[object Symbol]";function n(o){return typeof o=="symbol"||r(o)&&e(o)==t}return _s=n,_s}var ks,Op;function du(){if(Op)return ks;Op=1;var e=Ct(),r=yn(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(i,s){if(e(i))return!1;var a=typeof i;return a=="number"||a=="symbol"||a=="boolean"||i==null||r(i)?!0:n.test(i)||!t.test(i)||s!=null&&i in Object(s)}return ks=o,ks}var Ps,$p;function zC(){if($p)return Ps;$p=1;var e=Yd(),r="Expected a function";function t(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(r);var i=function(){var s=arguments,a=o?o.apply(this,s):s[0],c=i.cache;if(c.has(a))return c.get(a);var l=n.apply(this,s);return i.cache=c.set(a,l)||c,l};return i.cache=new(t.Cache||e),i}return t.Cache=e,Ps=t,Ps}var As,qp;function BC(){if(qp)return As;qp=1;var e=zC(),r=500;function t(n){var o=e(n,function(s){return i.size===r&&i.clear(),s}),i=o.cache;return o}return As=t,As}var Rs,Lp;function DC(){if(Lp)return Rs;Lp=1;var e=BC(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(r,function(s,a,c,l){i.push(c?l.replace(t,"$1"):a||s)}),i});return Rs=n,Rs}var Ms,Fp;function Do(){if(Fp)return Ms;Fp=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,i=Array(o);++n<o;)i[n]=t(r[n],n,r);return i}return Ms=e,Ms}var Ts,zp;function WC(){if(zp)return Ts;zp=1;var e=hn(),r=Do(),t=Ct(),n=yn(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function s(a){if(typeof a=="string")return a;if(t(a))return r(a,s)+"";if(n(a))return i?i.call(a):"";var c=a+"";return c=="0"&&1/a==-1/0?"-0":c}return Ts=s,Ts}var Is,Bp;function Tx(){if(Bp)return Is;Bp=1;var e=WC();function r(t){return t==null?"":e(t)}return Is=r,Is}var Ns,Dp;function Wo(){if(Dp)return Ns;Dp=1;var e=Ct(),r=du(),t=DC(),n=Tx();function o(i,s){return e(i)?i:r(i,s)?[i]:t(n(i))}return Ns=o,Ns}var Os,Wp;function Xn(){if(Wp)return Os;Wp=1;var e=yn();function r(t){if(typeof t=="string"||e(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return Os=r,Os}var $s,Vp;function Vo(){if(Vp)return $s;Vp=1;var e=Wo(),r=Xn();function t(n,o){o=e(o,n);for(var i=0,s=o.length;n!=null&&i<s;)n=n[r(o[i++])];return i&&i==s?n:void 0}return $s=t,$s}var qs,Gp;function VC(){if(Gp)return qs;Gp=1;var e=Vo();function r(t,n,o){var i=t==null?void 0:e(t,n);return i===void 0?o:i}return qs=r,qs}var Ls,Hp;function GC(){if(Hp)return Ls;Hp=1;function e(r,t){return r!=null&&t in Object(r)}return Ls=e,Ls}var Fs,Up;function Ix(){if(Up)return Fs;Up=1;var e=Wo(),r=Jn(),t=Ct(),n=qo(),o=eu(),i=Xn();function s(a,c,l){c=e(c,a);for(var d=-1,u=c.length,h=!1;++d<u;){var p=i(c[d]);if(!(h=a!=null&&l(a,p)))break;a=a[p]}return h||++d!=u?h:(u=a==null?0:a.length,!!u&&o(u)&&n(p,u)&&(t(a)||r(a)))}return Fs=s,Fs}var zs,Kp;function Nx(){if(Kp)return zs;Kp=1;var e=GC(),r=Ix();function t(n,o){return n!=null&&r(n,o,e)}return zs=t,zs}var Bs,Jp;function HC(){if(Jp)return Bs;Jp=1;var e=Ax(),r=VC(),t=Nx(),n=du(),o=Rx(),i=Mx(),s=Xn(),a=1,c=2;function l(d,u){return n(d)&&o(u)?i(s(d),u):function(h){var p=r(h,d);return p===void 0&&p===u?t(h,d):e(u,p,a|c)}}return Bs=l,Bs}var Ds,Zp;function Ox(){if(Zp)return Ds;Zp=1;function e(r){return function(t){return t==null?void 0:t[r]}}return Ds=e,Ds}var Ws,Xp;function UC(){if(Xp)return Ws;Xp=1;var e=Vo();function r(t){return function(n){return e(n,t)}}return Ws=r,Ws}var Vs,Yp;function KC(){if(Yp)return Vs;Yp=1;var e=Ox(),r=UC(),t=du(),n=Xn();function o(i){return t(i)?e(n(i)):r(i)}return Vs=o,Vs}var Gs,Qp;function mr(){if(Qp)return Gs;Qp=1;var e=FC(),r=HC(),t=Kr(),n=Ct(),o=KC();function i(s){return typeof s=="function"?s:s==null?t:typeof s=="object"?n(s)?r(s[0],s[1]):e(s):o(s)}return Gs=i,Gs}var Hs,eg;function $x(){if(eg)return Hs;eg=1;var e=fx(),r=AC(),t=mr(),n=Ct();function o(i,s){var a=n(i)?e:r;return a(i,t(s,3))}return Hs=o,Hs}var Us,tg;function JC(){if(tg)return Us;tg=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,o){return n!=null&&r.call(n,o)}return Us=t,Us}var Ks,rg;function qx(){if(rg)return Ks;rg=1;var e=JC(),r=Ix();function t(n,o){return n!=null&&r(n,o,e)}return Ks=t,Ks}var Js,ng;function ZC(){if(ng)return Js;ng=1;var e=ru(),r=gn(),t=Jn(),n=Ct(),o=yr(),i=pn(),s=Fo(),a=Zn(),c="[object Map]",l="[object Set]",d=Object.prototype,u=d.hasOwnProperty;function h(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||a(p)||t(p)))return!p.length;var m=r(p);if(m==c||m==l)return!p.size;if(s(p))return!e(p).length;for(var g in p)if(u.call(p,g))return!1;return!0}return Js=h,Js}var Zs,og;function Lx(){if(og)return Zs;og=1;function e(r){return r===void 0}return Zs=e,Zs}var Xs,ig;function Fx(){if(ig)return Xs;ig=1;var e=Bo(),r=yr();function t(n,o){var i=-1,s=r(n)?Array(n.length):[];return e(n,function(a,c,l){s[++i]=o(a,c,l)}),s}return Xs=t,Xs}var Ys,ag;function zx(){if(ag)return Ys;ag=1;var e=Do(),r=mr(),t=Fx(),n=Ct();function o(i,s){var a=n(i)?e:t;return a(i,r(s,3))}return Ys=o,Ys}var Qs,sg;function XC(){if(sg)return Qs;sg=1;function e(r,t,n,o){var i=-1,s=r==null?0:r.length;for(o&&s&&(n=r[++i]);++i<s;)n=t(n,r[i],i,r);return n}return Qs=e,Qs}var ec,cg;function YC(){if(cg)return ec;cg=1;function e(r,t,n,o,i){return i(r,function(s,a,c){n=o?(o=!1,s):t(n,s,a,c)}),n}return ec=e,ec}var tc,lg;function Bx(){if(lg)return tc;lg=1;var e=XC(),r=Bo(),t=mr(),n=YC(),o=Ct();function i(s,a,c){var l=o(s)?e:n,d=arguments.length<3;return l(s,t(a,4),c,d,r)}return tc=i,tc}var rc,dg;function QC(){if(dg)return rc;dg=1;var e=Gr(),r=Ct(),t=lr(),n="[object String]";function o(i){return typeof i=="string"||!r(i)&&t(i)&&e(i)==n}return rc=o,rc}var nc,ug;function eS(){if(ug)return nc;ug=1;var e=Ox(),r=e("length");return nc=r,nc}var oc,fg;function tS(){if(fg)return oc;fg=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,i="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+o+i+"]");function c(l){return a.test(l)}return oc=c,oc}var ic,hg;function rS(){if(hg)return ic;hg=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,i="\\ufe0e\\ufe0f",s="["+e+"]",a="["+o+"]",c="\\ud83c[\\udffb-\\udfff]",l="(?:"+a+"|"+c+")",d="[^"+e+"]",u="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",m=l+"?",g="["+i+"]?",y="(?:"+p+"(?:"+[d,u,h].join("|")+")"+g+m+")*",b=g+m+y,v="(?:"+[d+a+"?",a,u,h,s].join("|")+")",w=RegExp(c+"(?="+c+")|"+v+b,"g");function x(C){for(var S=w.lastIndex=0;w.test(C);)++S;return S}return ic=x,ic}var ac,pg;function nS(){if(pg)return ac;pg=1;var e=eS(),r=tS(),t=rS();function n(o){return r(o)?t(o):e(o)}return ac=n,ac}var sc,gg;function oS(){if(gg)return sc;gg=1;var e=ru(),r=gn(),t=yr(),n=QC(),o=nS(),i="[object Map]",s="[object Set]";function a(c){if(c==null)return 0;if(t(c))return n(c)?o(c):c.length;var l=r(c);return l==i||l==s?c.size:e(c).length}return sc=a,sc}var cc,yg;function iS(){if(yg)return cc;yg=1;var e=Qd(),r=vx(),t=cu(),n=mr(),o=zo(),i=Ct(),s=pn(),a=Un(),c=Vt(),l=Zn();function d(u,h,p){var m=i(u),g=m||s(u)||l(u);if(h=n(h,4),p==null){var y=u&&u.constructor;g?p=m?new y:[]:c(u)?p=a(y)?r(o(u)):{}:p={}}return(g?e:t)(u,function(b,v,w){return h(p,b,v,w)}),p}return cc=d,cc}var lc,mg;function aS(){if(mg)return lc;mg=1;var e=hn(),r=Jn(),t=Ct(),n=e?e.isConcatSpreadable:void 0;function o(i){return t(i)||r(i)||!!(n&&i&&i[n])}return lc=o,lc}var dc,bg;function uu(){if(bg)return dc;bg=1;var e=ou(),r=aS();function t(n,o,i,s,a){var c=-1,l=n.length;for(i||(i=r),a||(a=[]);++c<l;){var d=n[c];o>0&&i(d)?o>1?t(d,o-1,i,s,a):e(a,d):s||(a[a.length]=d)}return a}return dc=t,dc}var uc,xg;function sS(){if(xg)return uc;xg=1;function e(r,t,n){switch(n.length){case 0:return r.call(t);case 1:return r.call(t,n[0]);case 2:return r.call(t,n[0],n[1]);case 3:return r.call(t,n[0],n[1],n[2])}return r.apply(t,n)}return uc=e,uc}var fc,vg;function Dx(){if(vg)return fc;vg=1;var e=sS(),r=Math.max;function t(n,o,i){return o=r(o===void 0?n.length-1:o,0),function(){for(var s=arguments,a=-1,c=r(s.length-o,0),l=Array(c);++a<c;)l[a]=s[o+a];a=-1;for(var d=Array(o+1);++a<o;)d[a]=s[a];return d[o]=i(l),e(n,this,d)}}return fc=t,fc}var hc,wg;function cS(){if(wg)return hc;wg=1;var e=au(),r=sx(),t=Kr(),n=r?function(o,i){return r(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:t;return hc=n,hc}var pc,Cg;function lS(){if(Cg)return pc;Cg=1;var e=800,r=16,t=Date.now;function n(o){var i=0,s=0;return function(){var a=t(),c=r-(a-s);if(s=a,c>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return pc=n,pc}var gc,Sg;function Wx(){if(Sg)return gc;Sg=1;var e=cS(),r=lS(),t=r(e);return gc=t,gc}var yc,jg;function Go(){if(jg)return yc;jg=1;var e=Kr(),r=Dx(),t=Wx();function n(o,i){return t(r(o,i,e),o+"")}return yc=n,yc}var mc,Eg;function Vx(){if(Eg)return mc;Eg=1;function e(r,t,n,o){for(var i=r.length,s=n+(o?1:-1);o?s--:++s<i;)if(t(r[s],s,r))return s;return-1}return mc=e,mc}var bc,_g;function dS(){if(_g)return bc;_g=1;function e(r){return r!==r}return bc=e,bc}var xc,kg;function uS(){if(kg)return xc;kg=1;function e(r,t,n){for(var o=n-1,i=r.length;++o<i;)if(r[o]===t)return o;return-1}return xc=e,xc}var vc,Pg;function fS(){if(Pg)return vc;Pg=1;var e=Vx(),r=dS(),t=uS();function n(o,i,s){return i===i?t(o,i,s):e(o,r,s)}return vc=n,vc}var wc,Ag;function hS(){if(Ag)return wc;Ag=1;var e=fS();function r(t,n){var o=t==null?0:t.length;return!!o&&e(t,n,0)>-1}return wc=r,wc}var Cc,Rg;function pS(){if(Rg)return Cc;Rg=1;function e(r,t,n){for(var o=-1,i=r==null?0:r.length;++o<i;)if(n(t,r[o]))return!0;return!1}return Cc=e,Cc}var Sc,Mg;function gS(){if(Mg)return Sc;Mg=1;function e(){}return Sc=e,Sc}var jc,Tg;function yS(){if(Tg)return jc;Tg=1;var e=mx(),r=gS(),t=lu(),n=1/0,o=e&&1/t(new e([,-0]))[1]==n?function(i){return new e(i)}:r;return jc=o,jc}var Ec,Ig;function mS(){if(Ig)return Ec;Ig=1;var e=_x(),r=hS(),t=pS(),n=kx(),o=yS(),i=lu(),s=200;function a(c,l,d){var u=-1,h=r,p=c.length,m=!0,g=[],y=g;if(d)m=!1,h=t;else if(p>=s){var b=l?null:o(c);if(b)return i(b);m=!1,h=n,y=new e}else y=l?[]:g;e:for(;++u<p;){var v=c[u],w=l?l(v):v;if(v=d||v!==0?v:0,m&&w===w){for(var x=y.length;x--;)if(y[x]===w)continue e;l&&y.push(w),g.push(v)}else h(y,w,d)||(y!==g&&y.push(w),g.push(v))}return g}return Ec=a,Ec}var _c,Ng;function Gx(){if(Ng)return _c;Ng=1;var e=yr(),r=lr();function t(n){return r(n)&&e(n)}return _c=t,_c}var kc,Og;function bS(){if(Og)return kc;Og=1;var e=uu(),r=Go(),t=mS(),n=Gx(),o=r(function(i){return t(e(i,1,n,!0))});return kc=o,kc}var Pc,$g;function xS(){if($g)return Pc;$g=1;var e=Do();function r(t,n){return e(n,function(o){return t[o]})}return Pc=r,Pc}var Ac,qg;function Hx(){if(qg)return Ac;qg=1;var e=xS(),r=Mr();function t(n){return n==null?[]:e(n,r(n))}return Ac=t,Ac}var Rc,Lg;function Gt(){if(Lg)return Rc;Lg=1;var e;if(typeof Zd=="function")try{e={clone:_C(),constant:au(),each:Ex(),filter:$x(),has:qx(),isArray:Ct(),isEmpty:ZC(),isFunction:Un(),isUndefined:Lx(),keys:Mr(),map:zx(),reduce:Bx(),size:oS(),transform:iS(),union:bS(),values:Hx()}}catch{}return e||(e=window._),Rc=e,Rc}var Mc,Fg;function fu(){if(Fg)return Mc;Fg=1;var e=Gt();Mc=o;var r="\0",t="\0",n="";function o(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(d){return this._label=d,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._in[u])})},o.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._out[u])})},o.prototype.setNodes=function(d,u){var h=arguments,p=this;return e.each(d,function(m){h.length>1?p.setNode(m,u):p.setNode(m)}),this},o.prototype.setNode=function(d,u){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=u),this):(this._nodes[d]=arguments.length>1?u:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},o.prototype.node=function(d){return this._nodes[d]},o.prototype.hasNode=function(d){return e.has(this._nodes,d)},o.prototype.removeNode=function(d){var u=this;if(e.has(this._nodes,d)){var h=function(p){u.removeEdge(u._edgeObjs[p])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(p){u.setParent(p)}),delete this._children[d]),e.each(e.keys(this._in[d]),h),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},o.prototype.setParent=function(d,u){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(u))u=t;else{u+="";for(var h=u;!e.isUndefined(h);h=this.parent(h))if(h===d)throw new Error("Setting "+u+" as parent of "+d+" would create a cycle");this.setNode(u)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=u,this._children[u][d]=!0,this},o.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},o.prototype.parent=function(d){if(this._isCompound){var u=this._parent[d];if(u!==t)return u}},o.prototype.children=function(d){if(e.isUndefined(d)&&(d=t),this._isCompound){var u=this._children[d];if(u)return e.keys(u)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}},o.prototype.predecessors=function(d){var u=this._preds[d];if(u)return e.keys(u)},o.prototype.successors=function(d){var u=this._sucs[d];if(u)return e.keys(u)},o.prototype.neighbors=function(d){var u=this.predecessors(d);if(u)return e.union(u,this.successors(d))},o.prototype.isLeaf=function(d){var u;return this.isDirected()?u=this.successors(d):u=this.neighbors(d),u.length===0},o.prototype.filterNodes=function(d){var u=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});u.setGraph(this.graph());var h=this;e.each(this._nodes,function(g,y){d(y)&&u.setNode(y,g)}),e.each(this._edgeObjs,function(g){u.hasNode(g.v)&&u.hasNode(g.w)&&u.setEdge(g,h.edge(g))});var p={};function m(g){var y=h.parent(g);return y===void 0||u.hasNode(y)?(p[g]=y,y):y in p?p[y]:m(y)}return this._isCompound&&e.each(u.nodes(),function(g){u.setParent(g,m(g))}),u},o.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(d,u){var h=this,p=arguments;return e.reduce(d,function(m,g){return p.length>1?h.setEdge(m,g,u):h.setEdge(m,g),g}),this},o.prototype.setEdge=function(){var d,u,h,p,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(d=g.v,u=g.w,h=g.name,arguments.length===2&&(p=arguments[1],m=!0)):(d=g,u=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),d=""+d,u=""+u,e.isUndefined(h)||(h=""+h);var y=a(this._isDirected,d,u,h);if(e.has(this._edgeLabels,y))return m&&(this._edgeLabels[y]=p),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(u),this._edgeLabels[y]=m?p:this._defaultEdgeLabelFn(d,u,h);var b=c(this._isDirected,d,u,h);return d=b.v,u=b.w,Object.freeze(b),this._edgeObjs[y]=b,i(this._preds[u],d),i(this._sucs[d],u),this._in[u][y]=b,this._out[d][y]=b,this._edgeCount++,this},o.prototype.edge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return this._edgeLabels[p]},o.prototype.hasEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h),m=this._edgeObjs[p];return m&&(d=m.v,u=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[u],d),s(this._sucs[d],u),delete this._in[u][p],delete this._out[d][p],this._edgeCount--),this},o.prototype.inEdges=function(d,u){var h=this._in[d];if(h){var p=e.values(h);return u?e.filter(p,function(m){return m.v===u}):p}},o.prototype.outEdges=function(d,u){var h=this._out[d];if(h){var p=e.values(h);return u?e.filter(p,function(m){return m.w===u}):p}},o.prototype.nodeEdges=function(d,u){var h=this.inEdges(d,u);if(h)return h.concat(this.outEdges(d,u))};function i(d,u){d[u]?d[u]++:d[u]=1}function s(d,u){--d[u]||delete d[u]}function a(d,u,h,p){var m=""+u,g=""+h;if(!d&&m>g){var y=m;m=g,g=y}return m+n+g+n+(e.isUndefined(p)?r:p)}function c(d,u,h,p){var m=""+u,g=""+h;if(!d&&m>g){var y=m;m=g,g=y}var b={v:m,w:g};return p&&(b.name=p),b}function l(d,u){return a(d,u.v,u.w,u.name)}return Mc}var Tc,zg;function vS(){return zg||(zg=1,Tc="2.1.8"),Tc}var Ic,Bg;function wS(){return Bg||(Bg=1,Ic={Graph:fu(),version:vS()}),Ic}var Nc,Dg;function CS(){if(Dg)return Nc;Dg=1;var e=Gt(),r=fu();Nc={write:t,read:i};function t(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:o(s)};return e.isUndefined(s.graph())||(a.value=e.clone(s.graph())),a}function n(s){return e.map(s.nodes(),function(a){var c=s.node(a),l=s.parent(a),d={v:a};return e.isUndefined(c)||(d.value=c),e.isUndefined(l)||(d.parent=l),d})}function o(s){return e.map(s.edges(),function(a){var c=s.edge(a),l={v:a.v,w:a.w};return e.isUndefined(a.name)||(l.name=a.name),e.isUndefined(c)||(l.value=c),l})}function i(s){var a=new r(s.options).setGraph(s.value);return e.each(s.nodes,function(c){a.setNode(c.v,c.value),c.parent&&a.setParent(c.v,c.parent)}),e.each(s.edges,function(c){a.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),a}return Nc}var Oc,Wg;function SS(){if(Wg)return Oc;Wg=1;var e=Gt();Oc=r;function r(t){var n={},o=[],i;function s(a){e.has(n,a)||(n[a]=!0,i.push(a),e.each(t.successors(a),s),e.each(t.predecessors(a),s))}return e.each(t.nodes(),function(a){i=[],s(a),i.length&&o.push(i)}),o}return Oc}var $c,Vg;function Ux(){if(Vg)return $c;Vg=1;var e=Gt();$c=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return e.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var o=this._keyIndices;if(t=String(t),!e.has(o,t)){var i=this._arr,s=i.length;return o[t]=s,i.push({key:t,priority:n}),this._decrease(s),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var o=this._keyIndices[t];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},r.prototype._heapify=function(t){var n=this._arr,o=2*t,i=o+1,s=t;o<n.length&&(s=n[o].priority<n[s].priority?o:s,i<n.length&&(s=n[i].priority<n[s].priority?i:s),s!==t&&(this._swap(t,s),this._heapify(s)))},r.prototype._decrease=function(t){for(var n=this._arr,o=n[t].priority,i;t!==0&&(i=t>>1,!(n[i].priority<o));)this._swap(t,i),t=i},r.prototype._swap=function(t,n){var o=this._arr,i=this._keyIndices,s=o[t],a=o[n];o[t]=a,o[n]=s,i[a.key]=t,i[s.key]=n},$c}var qc,Gg;function Kx(){if(Gg)return qc;Gg=1;var e=Gt(),r=Ux();qc=n;var t=e.constant(1);function n(i,s,a,c){return o(i,String(s),a||t,c||function(l){return i.outEdges(l)})}function o(i,s,a,c){var l={},d=new r,u,h,p=function(m){var g=m.v!==u?m.v:m.w,y=l[g],b=a(m),v=h.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+b);v<y.distance&&(y.distance=v,y.predecessor=u,d.decrease(g,v))};for(i.nodes().forEach(function(m){var g=m===s?0:Number.POSITIVE_INFINITY;l[m]={distance:g},d.add(m,g)});d.size()>0&&(u=d.removeMin(),h=l[u],h.distance!==Number.POSITIVE_INFINITY);)c(u).forEach(p);return l}return qc}var Lc,Hg;function jS(){if(Hg)return Lc;Hg=1;var e=Kx(),r=Gt();Lc=t;function t(n,o,i){return r.transform(n.nodes(),function(s,a){s[a]=e(n,a,o,i)},{})}return Lc}var Fc,Ug;function Jx(){if(Ug)return Fc;Ug=1;var e=Gt();Fc=r;function r(t){var n=0,o=[],i={},s=[];function a(c){var l=i[c]={onStack:!0,lowlink:n,index:n++};if(o.push(c),t.successors(c).forEach(function(h){e.has(i,h)?i[h].onStack&&(l.lowlink=Math.min(l.lowlink,i[h].index)):(a(h),l.lowlink=Math.min(l.lowlink,i[h].lowlink))}),l.lowlink===l.index){var d=[],u;do u=o.pop(),i[u].onStack=!1,d.push(u);while(c!==u);s.push(d)}}return t.nodes().forEach(function(c){e.has(i,c)||a(c)}),s}return Fc}var zc,Kg;function ES(){if(Kg)return zc;Kg=1;var e=Gt(),r=Jx();zc=t;function t(n){return e.filter(r(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return zc}var Bc,Jg;function _S(){if(Jg)return Bc;Jg=1;var e=Gt();Bc=t;var r=e.constant(1);function t(o,i,s){return n(o,i||r,s||function(a){return o.outEdges(a)})}function n(o,i,s){var a={},c=o.nodes();return c.forEach(function(l){a[l]={},a[l][l]={distance:0},c.forEach(function(d){l!==d&&(a[l][d]={distance:Number.POSITIVE_INFINITY})}),s(l).forEach(function(d){var u=d.v===l?d.w:d.v,h=i(d);a[l][u]={distance:h,predecessor:l}})}),c.forEach(function(l){var d=a[l];c.forEach(function(u){var h=a[u];c.forEach(function(p){var m=h[l],g=d[p],y=h[p],b=m.distance+g.distance;b<y.distance&&(y.distance=b,y.predecessor=g.predecessor)})})}),a}return Bc}var Dc,Zg;function Zx(){if(Zg)return Dc;Zg=1;var e=Gt();Dc=r,r.CycleException=t;function r(n){var o={},i={},s=[];function a(c){if(e.has(i,c))throw new t;e.has(o,c)||(i[c]=!0,o[c]=!0,e.each(n.predecessors(c),a),delete i[c],s.push(c))}if(e.each(n.sinks(),a),e.size(o)!==n.nodeCount())throw new t;return s}function t(){}return t.prototype=new Error,Dc}var Wc,Xg;function kS(){if(Xg)return Wc;Xg=1;var e=Zx();Wc=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Wc}var Vc,Yg;function Xx(){if(Yg)return Vc;Yg=1;var e=Gt();Vc=r;function r(n,o,i){e.isArray(o)||(o=[o]);var s=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],c={};return e.each(o,function(l){if(!n.hasNode(l))throw new Error("Graph does not have node: "+l);t(n,l,i==="post",c,s,a)}),a}function t(n,o,i,s,a,c){e.has(s,o)||(s[o]=!0,i||c.push(o),e.each(a(o),function(l){t(n,l,i,s,a,c)}),i&&c.push(o))}return Vc}var Gc,Qg;function PS(){if(Qg)return Gc;Qg=1;var e=Xx();Gc=r;function r(t,n){return e(t,n,"post")}return Gc}var Hc,ey;function AS(){if(ey)return Hc;ey=1;var e=Xx();Hc=r;function r(t,n){return e(t,n,"pre")}return Hc}var Uc,ty;function RS(){if(ty)return Uc;ty=1;var e=Gt(),r=fu(),t=Ux();Uc=n;function n(o,i){var s=new r,a={},c=new t,l;function d(h){var p=h.v===l?h.w:h.v,m=c.priority(p);if(m!==void 0){var g=i(h);g<m&&(a[p]=l,c.decrease(p,g))}}if(o.nodeCount()===0)return s;e.each(o.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),s.setNode(h)}),c.decrease(o.nodes()[0],0);for(var u=!1;c.size()>0;){if(l=c.removeMin(),e.has(a,l))s.setEdge(l,a[l]);else{if(u)throw new Error("Input graph is not connected: "+o);u=!0}o.nodeEdges(l).forEach(d)}return s}return Uc}var Kc,ry;function MS(){return ry||(ry=1,Kc={components:SS(),dijkstra:Kx(),dijkstraAll:jS(),findCycles:ES(),floydWarshall:_S(),isAcyclic:kS(),postorder:PS(),preorder:AS(),prim:RS(),tarjan:Jx(),topsort:Zx()}),Kc}var Jc,ny;function TS(){if(ny)return Jc;ny=1;var e=wS();return Jc={Graph:e.Graph,json:CS(),alg:MS(),version:e.version},Jc}var Zc,oy;function Zt(){if(oy)return Zc;oy=1;var e;if(typeof Zd=="function")try{e=TS()}catch{}return e||(e=window.graphlib),Zc=e,Zc}var Xc,iy;function IS(){if(iy)return Xc;iy=1;var e=Cx(),r=1,t=4;function n(o){return e(o,r|t)}return Xc=n,Xc}var Yc,ay;function Ho(){if(ay)return Yc;ay=1;var e=fn(),r=yr(),t=qo(),n=Vt();function o(i,s,a){if(!n(a))return!1;var c=typeof s;return(c=="number"?r(a)&&t(s,a.length):c=="string"&&s in a)?e(a[s],i):!1}return Yc=o,Yc}var Qc,sy;function NS(){if(sy)return Qc;sy=1;var e=Go(),r=fn(),t=Ho(),n=Ur(),o=Object.prototype,i=o.hasOwnProperty,s=e(function(a,c){a=Object(a);var l=-1,d=c.length,u=d>2?c[2]:void 0;for(u&&t(c[0],c[1],u)&&(d=1);++l<d;)for(var h=c[l],p=n(h),m=-1,g=p.length;++m<g;){var y=p[m],b=a[y];(b===void 0||r(b,o[y])&&!i.call(a,y))&&(a[y]=h[y])}return a});return Qc=s,Qc}var el,cy;function OS(){if(cy)return el;cy=1;var e=mr(),r=yr(),t=Mr();function n(o){return function(i,s,a){var c=Object(i);if(!r(i)){var l=e(s,3);i=t(i),s=function(u){return l(c[u],u,c)}}var d=o(i,s,a);return d>-1?c[l?i[d]:d]:void 0}}return el=n,el}var tl,ly;function $S(){if(ly)return tl;ly=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return tl=r,tl}var rl,dy;function qS(){if(dy)return rl;dy=1;var e=$S(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return rl=t,rl}var nl,uy;function LS(){if(uy)return nl;uy=1;var e=qS(),r=Vt(),t=yn(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function c(l){if(typeof l=="number")return l;if(t(l))return n;if(r(l)){var d=typeof l.valueOf=="function"?l.valueOf():l;l=r(d)?d+"":d}if(typeof l!="string")return l===0?l:+l;l=e(l);var u=i.test(l);return u||s.test(l)?a(l.slice(2),u?2:8):o.test(l)?n:+l}return nl=c,nl}var ol,fy;function Yx(){if(fy)return ol;fy=1;var e=LS(),r=1/0,t=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===r||o===-r){var i=o<0?-1:1;return i*t}return o===o?o:0}return ol=n,ol}var il,hy;function FS(){if(hy)return il;hy=1;var e=Yx();function r(t){var n=e(t),o=n%1;return n===n?o?n-o:n:0}return il=r,il}var al,py;function zS(){if(py)return al;py=1;var e=Vx(),r=mr(),t=FS(),n=Math.max;function o(i,s,a){var c=i==null?0:i.length;if(!c)return-1;var l=a==null?0:t(a);return l<0&&(l=n(c+l,0)),e(i,r(s,3),l)}return al=o,al}var sl,gy;function BS(){if(gy)return sl;gy=1;var e=OS(),r=zS(),t=e(r);return sl=t,sl}var cl,yy;function Qx(){if(yy)return cl;yy=1;var e=uu();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return cl=r,cl}var ll,my;function DS(){if(my)return ll;my=1;var e=su(),r=Sx(),t=Ur();function n(o,i){return o==null?o:e(o,r(i),t)}return ll=n,ll}var dl,by;function WS(){if(by)return dl;by=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return dl=e,dl}var ul,xy;function VS(){if(xy)return ul;xy=1;var e=Oo(),r=cu(),t=mr();function n(o,i){var s={};return i=t(i,3),r(o,function(a,c,l){e(s,c,i(a,c,l))}),s}return ul=n,ul}var fl,vy;function hu(){if(vy)return fl;vy=1;var e=yn();function r(t,n,o){for(var i=-1,s=t.length;++i<s;){var a=t[i],c=n(a);if(c!=null&&(l===void 0?c===c&&!e(c):o(c,l)))var l=c,d=a}return d}return fl=r,fl}var hl,wy;function GS(){if(wy)return hl;wy=1;function e(r,t){return r>t}return hl=e,hl}var pl,Cy;function HS(){if(Cy)return pl;Cy=1;var e=hu(),r=GS(),t=Kr();function n(o){return o&&o.length?e(o,t,r):void 0}return pl=n,pl}var gl,Sy;function ev(){if(Sy)return gl;Sy=1;var e=Oo(),r=fn();function t(n,o,i){(i!==void 0&&!r(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return gl=t,gl}var yl,jy;function US(){if(jy)return yl;jy=1;var e=Gr(),r=zo(),t=lr(),n="[object Object]",o=Function.prototype,i=Object.prototype,s=o.toString,a=i.hasOwnProperty,c=s.call(Object);function l(d){if(!t(d)||e(d)!=n)return!1;var u=r(d);if(u===null)return!0;var h=a.call(u,"constructor")&&u.constructor;return typeof h=="function"&&h instanceof h&&s.call(h)==c}return yl=l,yl}var ml,Ey;function tv(){if(Ey)return ml;Ey=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return ml=e,ml}var bl,_y;function KS(){if(_y)return bl;_y=1;var e=Kn(),r=Ur();function t(n){return e(n,r(n))}return bl=t,bl}var xl,ky;function JS(){if(ky)return xl;ky=1;var e=ev(),r=dx(),t=xx(),n=ux(),o=wx(),i=Jn(),s=Ct(),a=Gx(),c=pn(),l=Un(),d=Vt(),u=US(),h=Zn(),p=tv(),m=KS();function g(y,b,v,w,x,C,S){var E=p(y,v),R=p(b,v),P=S.get(R);if(P){e(y,v,P);return}var I=C?C(E,R,v+"",y,b,S):void 0,M=I===void 0;if(M){var k=s(R),_=!k&&c(R),N=!k&&!_&&h(R);I=R,k||_||N?s(E)?I=E:a(E)?I=n(E):_?(M=!1,I=r(R,!0)):N?(M=!1,I=t(R,!0)):I=[]:u(R)||i(R)?(I=E,i(E)?I=m(E):(!d(E)||l(E))&&(I=o(R))):M=!1}M&&(S.set(R,I),x(I,R,w,C,S),S.delete(R)),e(y,v,I)}return xl=g,xl}var vl,Py;function ZS(){if(Py)return vl;Py=1;var e=No(),r=ev(),t=su(),n=JS(),o=Vt(),i=Ur(),s=tv();function a(c,l,d,u,h){c!==l&&t(l,function(p,m){if(h||(h=new e),o(p))n(c,l,m,d,a,u,h);else{var g=u?u(s(c,m),p,m+"",c,l,h):void 0;g===void 0&&(g=p),r(c,m,g)}},i)}return vl=a,vl}var wl,Ay;function XS(){if(Ay)return wl;Ay=1;var e=Go(),r=Ho();function t(n){return e(function(o,i){var s=-1,a=i.length,c=a>1?i[a-1]:void 0,l=a>2?i[2]:void 0;for(c=n.length>3&&typeof c=="function"?(a--,c):void 0,l&&r(i[0],i[1],l)&&(c=a<3?void 0:c,a=1),o=Object(o);++s<a;){var d=i[s];d&&n(o,d,s,c)}return o})}return wl=t,wl}var Cl,Ry;function YS(){if(Ry)return Cl;Ry=1;var e=ZS(),r=XS(),t=r(function(n,o,i){e(n,o,i)});return Cl=t,Cl}var Sl,My;function rv(){if(My)return Sl;My=1;function e(r,t){return r<t}return Sl=e,Sl}var jl,Ty;function QS(){if(Ty)return jl;Ty=1;var e=hu(),r=rv(),t=Kr();function n(o){return o&&o.length?e(o,t,r):void 0}return jl=n,jl}var El,Iy;function ej(){if(Iy)return El;Iy=1;var e=hu(),r=mr(),t=rv();function n(o,i){return o&&o.length?e(o,r(i,2),t):void 0}return El=n,El}var _l,Ny;function tj(){if(Ny)return _l;Ny=1;var e=Yt(),r=function(){return e.Date.now()};return _l=r,_l}var kl,Oy;function rj(){if(Oy)return kl;Oy=1;var e=$o(),r=Wo(),t=qo(),n=Vt(),o=Xn();function i(s,a,c,l){if(!n(s))return s;a=r(a,s);for(var d=-1,u=a.length,h=u-1,p=s;p!=null&&++d<u;){var m=o(a[d]),g=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return s;if(d!=h){var y=p[m];g=l?l(y,m,p):void 0,g===void 0&&(g=n(y)?y:t(a[d+1])?[]:{})}e(p,m,g),p=p[m]}return s}return kl=i,kl}var Pl,$y;function nj(){if($y)return Pl;$y=1;var e=Vo(),r=rj(),t=Wo();function n(o,i,s){for(var a=-1,c=i.length,l={};++a<c;){var d=i[a],u=e(o,d);s(u,d)&&r(l,t(d,o),u)}return l}return Pl=n,Pl}var Al,qy;function oj(){if(qy)return Al;qy=1;var e=nj(),r=Nx();function t(n,o){return e(n,o,function(i,s){return r(n,s)})}return Al=t,Al}var Rl,Ly;function ij(){if(Ly)return Rl;Ly=1;var e=Qx(),r=Dx(),t=Wx();function n(o){return t(r(o,void 0,e),o+"")}return Rl=n,Rl}var Ml,Fy;function aj(){if(Fy)return Ml;Fy=1;var e=oj(),r=ij(),t=r(function(n,o){return n==null?{}:e(n,o)});return Ml=t,Ml}var Tl,zy;function sj(){if(zy)return Tl;zy=1;var e=Math.ceil,r=Math.max;function t(n,o,i,s){for(var a=-1,c=r(e((o-n)/(i||1)),0),l=Array(c);c--;)l[s?c:++a]=n,n+=i;return l}return Tl=t,Tl}var Il,By;function cj(){if(By)return Il;By=1;var e=sj(),r=Ho(),t=Yx();function n(o){return function(i,s,a){return a&&typeof a!="number"&&r(i,s,a)&&(s=a=void 0),i=t(i),s===void 0?(s=i,i=0):s=t(s),a=a===void 0?i<s?1:-1:t(a),e(i,s,a,o)}}return Il=n,Il}var Nl,Dy;function lj(){if(Dy)return Nl;Dy=1;var e=cj(),r=e();return Nl=r,Nl}var Ol,Wy;function dj(){if(Wy)return Ol;Wy=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return Ol=e,Ol}var $l,Vy;function uj(){if(Vy)return $l;Vy=1;var e=yn();function r(t,n){if(t!==n){var o=t!==void 0,i=t===null,s=t===t,a=e(t),c=n!==void 0,l=n===null,d=n===n,u=e(n);if(!l&&!u&&!a&&t>n||a&&c&&d&&!l&&!u||i&&c&&d||!o&&d||!s)return 1;if(!i&&!a&&!u&&t<n||u&&o&&s&&!i&&!a||l&&o&&s||!c&&s||!d)return-1}return 0}return $l=r,$l}var ql,Gy;function fj(){if(Gy)return ql;Gy=1;var e=uj();function r(t,n,o){for(var i=-1,s=t.criteria,a=n.criteria,c=s.length,l=o.length;++i<c;){var d=e(s[i],a[i]);if(d){if(i>=l)return d;var u=o[i];return d*(u=="desc"?-1:1)}}return t.index-n.index}return ql=r,ql}var Ll,Hy;function hj(){if(Hy)return Ll;Hy=1;var e=Do(),r=Vo(),t=mr(),n=Fx(),o=dj(),i=Lo(),s=fj(),a=Kr(),c=Ct();function l(d,u,h){u.length?u=e(u,function(g){return c(g)?function(y){return r(y,g.length===1?g[0]:g)}:g}):u=[a];var p=-1;u=e(u,i(t));var m=n(d,function(g,y,b){var v=e(u,function(w){return w(g)});return{criteria:v,index:++p,value:g}});return o(m,function(g,y){return s(g,y,h)})}return Ll=l,Ll}var Fl,Uy;function pj(){if(Uy)return Fl;Uy=1;var e=uu(),r=hj(),t=Go(),n=Ho(),o=t(function(i,s){if(i==null)return[];var a=s.length;return a>1&&n(i,s[0],s[1])?s=[]:a>2&&n(s[0],s[1],s[2])&&(s=[s[0]]),r(i,e(s,1),[])});return Fl=o,Fl}var zl,Ky;function gj(){if(Ky)return zl;Ky=1;var e=Tx(),r=0;function t(n){var o=++r;return e(n)+o}return zl=t,zl}var Bl,Jy;function yj(){if(Jy)return Bl;Jy=1;function e(r,t,n){for(var o=-1,i=r.length,s=t.length,a={};++o<i;){var c=o<s?t[o]:void 0;n(a,r[o],c)}return a}return Bl=e,Bl}var Dl,Zy;function mj(){if(Zy)return Dl;Zy=1;var e=$o(),r=yj();function t(n,o){return r(n||[],o||[],e)}return Dl=t,Dl}var Wl,Xy;function yt(){if(Xy)return Wl;Xy=1;var e;if(typeof Zd=="function")try{e={cloneDeep:IS(),constant:au(),defaults:NS(),each:Ex(),filter:$x(),find:BS(),flatten:Qx(),forEach:jx(),forIn:DS(),has:qx(),isUndefined:Lx(),last:WS(),map:zx(),mapValues:VS(),max:HS(),merge:YS(),min:QS(),minBy:ej(),now:tj(),pick:aj(),range:lj(),reduce:Bx(),sortBy:pj(),uniqueId:gj(),values:Hx(),zipObject:mj()}}catch{}return e||(e=window._),Wl=e,Wl}var Vl,Yy;function bj(){if(Yy)return Vl;Yy=1,Vl=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return r(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&r(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,i=o._prev;i!==o;)n.push(JSON.stringify(i,t)),i=i._prev;return"["+n.join(", ")+"]"};function r(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,o){if(n!=="_next"&&n!=="_prev")return o}return Vl}var Gl,Qy;function xj(){if(Qy)return Gl;Qy=1;var e=yt(),r=Zt().Graph,t=bj();Gl=o;var n=e.constant(1);function o(l,d){if(l.nodeCount()<=1)return[];var u=a(l,d||n),h=i(u.graph,u.buckets,u.zeroIdx);return e.flatten(e.map(h,function(p){return l.outEdges(p.v,p.w)}),!0)}function i(l,d,u){for(var h=[],p=d[d.length-1],m=d[0],g;l.nodeCount();){for(;g=m.dequeue();)s(l,d,u,g);for(;g=p.dequeue();)s(l,d,u,g);if(l.nodeCount()){for(var y=d.length-2;y>0;--y)if(g=d[y].dequeue(),g){h=h.concat(s(l,d,u,g,!0));break}}}return h}function s(l,d,u,h,p){var m=p?[]:void 0;return e.forEach(l.inEdges(h.v),function(g){var y=l.edge(g),b=l.node(g.v);p&&m.push({v:g.v,w:g.w}),b.out-=y,c(d,u,b)}),e.forEach(l.outEdges(h.v),function(g){var y=l.edge(g),b=g.w,v=l.node(b);v.in-=y,c(d,u,v)}),l.removeNode(h.v),m}function a(l,d){var u=new r,h=0,p=0;e.forEach(l.nodes(),function(y){u.setNode(y,{v:y,in:0,out:0})}),e.forEach(l.edges(),function(y){var b=u.edge(y.v,y.w)||0,v=d(y),w=b+v;u.setEdge(y.v,y.w,w),p=Math.max(p,u.node(y.v).out+=v),h=Math.max(h,u.node(y.w).in+=v)});var m=e.range(p+h+3).map(function(){return new t}),g=h+1;return e.forEach(u.nodes(),function(y){c(m,g,u.node(y))}),{graph:u,buckets:m,zeroIdx:g}}function c(l,d,u){u.out?u.in?l[u.out-u.in+d].enqueue(u):l[l.length-1].enqueue(u):l[0].enqueue(u)}return Gl}var Hl,em;function vj(){if(em)return Hl;em=1;var e=yt(),r=xj();Hl={run:t,undo:o};function t(i){var s=i.graph().acyclicer==="greedy"?r(i,a(i)):n(i);e.forEach(s,function(c){var l=i.edge(c);i.removeEdge(c),l.forwardName=c.name,l.reversed=!0,i.setEdge(c.w,c.v,l,e.uniqueId("rev"))});function a(c){return function(l){return c.edge(l).weight}}}function n(i){var s=[],a={},c={};function l(d){e.has(c,d)||(c[d]=!0,a[d]=!0,e.forEach(i.outEdges(d),function(u){e.has(a,u.w)?s.push(u):l(u.w)}),delete a[d])}return e.forEach(i.nodes(),l),s}function o(i){e.forEach(i.edges(),function(s){var a=i.edge(s);if(a.reversed){i.removeEdge(s);var c=a.forwardName;delete a.reversed,delete a.forwardName,i.setEdge(s.w,s.v,a,c)}})}return Hl}var Ul,tm;function Nt(){if(tm)return Ul;tm=1;var e=yt(),r=Zt().Graph;Ul={addDummyNode:t,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:s,intersectRect:a,buildLayerMatrix:c,normalizeRanks:l,removeEmptyRanks:d,addBorderNode:u,maxRank:h,partition:p,time:m,notime:g};function t(y,b,v,w){var x;do x=e.uniqueId(w);while(y.hasNode(x));return v.dummy=b,y.setNode(x,v),x}function n(y){var b=new r().setGraph(y.graph());return e.forEach(y.nodes(),function(v){b.setNode(v,y.node(v))}),e.forEach(y.edges(),function(v){var w=b.edge(v.v,v.w)||{weight:0,minlen:1},x=y.edge(v);b.setEdge(v.v,v.w,{weight:w.weight+x.weight,minlen:Math.max(w.minlen,x.minlen)})}),b}function o(y){var b=new r({multigraph:y.isMultigraph()}).setGraph(y.graph());return e.forEach(y.nodes(),function(v){y.children(v).length||b.setNode(v,y.node(v))}),e.forEach(y.edges(),function(v){b.setEdge(v,y.edge(v))}),b}function i(y){var b=e.map(y.nodes(),function(v){var w={};return e.forEach(y.outEdges(v),function(x){w[x.w]=(w[x.w]||0)+y.edge(x).weight}),w});return e.zipObject(y.nodes(),b)}function s(y){var b=e.map(y.nodes(),function(v){var w={};return e.forEach(y.inEdges(v),function(x){w[x.v]=(w[x.v]||0)+y.edge(x).weight}),w});return e.zipObject(y.nodes(),b)}function a(y,b){var v=y.x,w=y.y,x=b.x-v,C=b.y-w,S=y.width/2,E=y.height/2;if(!x&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var R,P;return Math.abs(C)*S>Math.abs(x)*E?(C<0&&(E=-E),R=E*x/C,P=E):(x<0&&(S=-S),R=S,P=S*C/x),{x:v+R,y:w+P}}function c(y){var b=e.map(e.range(h(y)+1),function(){return[]});return e.forEach(y.nodes(),function(v){var w=y.node(v),x=w.rank;e.isUndefined(x)||(b[x][w.order]=v)}),b}function l(y){var b=e.min(e.map(y.nodes(),function(v){return y.node(v).rank}));e.forEach(y.nodes(),function(v){var w=y.node(v);e.has(w,"rank")&&(w.rank-=b)})}function d(y){var b=e.min(e.map(y.nodes(),function(C){return y.node(C).rank})),v=[];e.forEach(y.nodes(),function(C){var S=y.node(C).rank-b;v[S]||(v[S]=[]),v[S].push(C)});var w=0,x=y.graph().nodeRankFactor;e.forEach(v,function(C,S){e.isUndefined(C)&&S%x!==0?--w:w&&e.forEach(C,function(E){y.node(E).rank+=w})})}function u(y,b,v,w){var x={width:0,height:0};return arguments.length>=4&&(x.rank=v,x.order=w),t(y,"border",x,b)}function h(y){return e.max(e.map(y.nodes(),function(b){var v=y.node(b).rank;if(!e.isUndefined(v))return v}))}function p(y,b){var v={lhs:[],rhs:[]};return e.forEach(y,function(w){b(w)?v.lhs.push(w):v.rhs.push(w)}),v}function m(y,b){var v=e.now();try{return b()}finally{console.log(y+" time: "+(e.now()-v)+"ms")}}function g(y,b){return b()}return Ul}var Kl,rm;function wj(){if(rm)return Kl;rm=1;var e=yt(),r=Nt();Kl={run:t,undo:o};function t(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(s){n(i,s)})}function n(i,s){var a=s.v,c=i.node(a).rank,l=s.w,d=i.node(l).rank,u=s.name,h=i.edge(s),p=h.labelRank;if(d!==c+1){i.removeEdge(s);var m,g,y;for(y=0,++c;c<d;++y,++c)h.points=[],g={width:0,height:0,edgeLabel:h,edgeObj:s,rank:c},m=r.addDummyNode(i,"edge",g,"_d"),c===p&&(g.width=h.width,g.height=h.height,g.dummy="edge-label",g.labelpos=h.labelpos),i.setEdge(a,m,{weight:h.weight},u),y===0&&i.graph().dummyChains.push(m),a=m;i.setEdge(a,l,{weight:h.weight},u)}}function o(i){e.forEach(i.graph().dummyChains,function(s){var a=i.node(s),c=a.edgeLabel,l;for(i.setEdge(a.edgeObj,c);a.dummy;)l=i.successors(s)[0],i.removeNode(s),c.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(c.x=a.x,c.y=a.y,c.width=a.width,c.height=a.height),s=l,a=i.node(s)})}return Kl}var Jl,nm;function mo(){if(nm)return Jl;nm=1;var e=yt();Jl={longestPath:r,slack:t};function r(n){var o={};function i(s){var a=n.node(s);if(e.has(o,s))return a.rank;o[s]=!0;var c=e.min(e.map(n.outEdges(s),function(l){return i(l.w)-n.edge(l).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),a.rank=c}e.forEach(n.sources(),i)}function t(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return Jl}var Zl,om;function nv(){if(om)return Zl;om=1;var e=yt(),r=Zt().Graph,t=mo().slack;Zl=n;function n(a){var c=new r({directed:!1}),l=a.nodes()[0],d=a.nodeCount();c.setNode(l,{});for(var u,h;o(c,a)<d;)u=i(c,a),h=c.hasNode(u.v)?t(a,u):-t(a,u),s(c,a,h);return c}function o(a,c){function l(d){e.forEach(c.nodeEdges(d),function(u){var h=u.v,p=d===h?u.w:h;!a.hasNode(p)&&!t(c,u)&&(a.setNode(p,{}),a.setEdge(d,p,{}),l(p))})}return e.forEach(a.nodes(),l),a.nodeCount()}function i(a,c){return e.minBy(c.edges(),function(l){if(a.hasNode(l.v)!==a.hasNode(l.w))return t(c,l)})}function s(a,c,l){e.forEach(a.nodes(),function(d){c.node(d).rank+=l})}return Zl}var Xl,im;function Cj(){if(im)return Xl;im=1;var e=yt(),r=nv(),t=mo().slack,n=mo().longestPath,o=Zt().alg.preorder,i=Zt().alg.postorder,s=Nt().simplify;Xl=a,a.initLowLimValues=u,a.initCutValues=c,a.calcCutValue=d,a.leaveEdge=p,a.enterEdge=m,a.exchangeEdges=g;function a(w){w=s(w),n(w);var x=r(w);u(x),c(x,w);for(var C,S;C=p(x);)S=m(x,w,C),g(x,w,C,S)}function c(w,x){var C=i(w,w.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(S){l(w,x,S)})}function l(w,x,C){var S=w.node(C),E=S.parent;w.edge(C,E).cutvalue=d(w,x,C)}function d(w,x,C){var S=w.node(C),E=S.parent,R=!0,P=x.edge(C,E),I=0;return P||(R=!1,P=x.edge(E,C)),I=P.weight,e.forEach(x.nodeEdges(C),function(M){var k=M.v===C,_=k?M.w:M.v;if(_!==E){var N=k===R,O=x.edge(M).weight;if(I+=N?O:-O,b(w,C,_)){var V=w.edge(C,_).cutvalue;I+=N?-V:V}}}),I}function u(w,x){arguments.length<2&&(x=w.nodes()[0]),h(w,{},1,x)}function h(w,x,C,S,E){var R=C,P=w.node(S);return x[S]=!0,e.forEach(w.neighbors(S),function(I){e.has(x,I)||(C=h(w,x,C,I,S))}),P.low=R,P.lim=C++,E?P.parent=E:delete P.parent,C}function p(w){return e.find(w.edges(),function(x){return w.edge(x).cutvalue<0})}function m(w,x,C){var S=C.v,E=C.w;x.hasEdge(S,E)||(S=C.w,E=C.v);var R=w.node(S),P=w.node(E),I=R,M=!1;R.lim>P.lim&&(I=P,M=!0);var k=e.filter(x.edges(),function(_){return M===v(w,w.node(_.v),I)&&M!==v(w,w.node(_.w),I)});return e.minBy(k,function(_){return t(x,_)})}function g(w,x,C,S){var E=C.v,R=C.w;w.removeEdge(E,R),w.setEdge(S.v,S.w,{}),u(w),c(w,x),y(w,x)}function y(w,x){var C=e.find(w.nodes(),function(E){return!x.node(E).parent}),S=o(w,C);S=S.slice(1),e.forEach(S,function(E){var R=w.node(E).parent,P=x.edge(E,R),I=!1;P||(P=x.edge(R,E),I=!0),x.node(E).rank=x.node(R).rank+(I?P.minlen:-P.minlen)})}function b(w,x,C){return w.hasEdge(x,C)}function v(w,x,C){return C.low<=x.lim&&x.lim<=C.lim}return Xl}var Yl,am;function Sj(){if(am)return Yl;am=1;var e=mo(),r=e.longestPath,t=nv(),n=Cj();Yl=o;function o(c){switch(c.graph().ranker){case"network-simplex":a(c);break;case"tight-tree":s(c);break;case"longest-path":i(c);break;default:a(c)}}var i=r;function s(c){r(c),t(c)}function a(c){n(c)}return Yl}var Ql,sm;function jj(){if(sm)return Ql;sm=1;var e=yt();Ql=r;function r(o){var i=n(o);e.forEach(o.graph().dummyChains,function(s){for(var a=o.node(s),c=a.edgeObj,l=t(o,i,c.v,c.w),d=l.path,u=l.lca,h=0,p=d[h],m=!0;s!==c.w;){if(a=o.node(s),m){for(;(p=d[h])!==u&&o.node(p).maxRank<a.rank;)h++;p===u&&(m=!1)}if(!m){for(;h<d.length-1&&o.node(p=d[h+1]).minRank<=a.rank;)h++;p=d[h]}o.setParent(s,p),s=o.successors(s)[0]}})}function t(o,i,s,a){var c=[],l=[],d=Math.min(i[s].low,i[a].low),u=Math.max(i[s].lim,i[a].lim),h,p;h=s;do h=o.parent(h),c.push(h);while(h&&(i[h].low>d||u>i[h].lim));for(p=h,h=a;(h=o.parent(h))!==p;)l.push(h);return{path:c.concat(l.reverse()),lca:p}}function n(o){var i={},s=0;function a(c){var l=s;e.forEach(o.children(c),a),i[c]={low:l,lim:s++}}return e.forEach(o.children(),a),i}return Ql}var ed,cm;function Ej(){if(cm)return ed;cm=1;var e=yt(),r=Nt();ed={run:t,cleanup:s};function t(a){var c=r.addDummyNode(a,"root",{},"_root"),l=o(a),d=e.max(e.values(l))-1,u=2*d+1;a.graph().nestingRoot=c,e.forEach(a.edges(),function(p){a.edge(p).minlen*=u});var h=i(a)+1;e.forEach(a.children(),function(p){n(a,c,u,h,d,l,p)}),a.graph().nodeRankFactor=u}function n(a,c,l,d,u,h,p){var m=a.children(p);if(!m.length){p!==c&&a.setEdge(c,p,{weight:0,minlen:l});return}var g=r.addBorderNode(a,"_bt"),y=r.addBorderNode(a,"_bb"),b=a.node(p);a.setParent(g,p),b.borderTop=g,a.setParent(y,p),b.borderBottom=y,e.forEach(m,function(v){n(a,c,l,d,u,h,v);var w=a.node(v),x=w.borderTop?w.borderTop:v,C=w.borderBottom?w.borderBottom:v,S=w.borderTop?d:2*d,E=x!==C?1:u-h[p]+1;a.setEdge(g,x,{weight:S,minlen:E,nestingEdge:!0}),a.setEdge(C,y,{weight:S,minlen:E,nestingEdge:!0})}),a.parent(p)||a.setEdge(c,g,{weight:0,minlen:u+h[p]})}function o(a){var c={};function l(d,u){var h=a.children(d);h&&h.length&&e.forEach(h,function(p){l(p,u+1)}),c[d]=u}return e.forEach(a.children(),function(d){l(d,1)}),c}function i(a){return e.reduce(a.edges(),function(c,l){return c+a.edge(l).weight},0)}function s(a){var c=a.graph();a.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(a.edges(),function(l){var d=a.edge(l);d.nestingEdge&&a.removeEdge(l)})}return ed}var td,lm;function _j(){if(lm)return td;lm=1;var e=yt(),r=Nt();td=t;function t(o){function i(s){var a=o.children(s),c=o.node(s);if(a.length&&e.forEach(a,i),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var l=c.minRank,d=c.maxRank+1;l<d;++l)n(o,"borderLeft","_bl",s,c,l),n(o,"borderRight","_br",s,c,l)}}e.forEach(o.children(),i)}function n(o,i,s,a,c,l){var d={width:0,height:0,rank:l,borderType:i},u=c[i][l-1],h=r.addDummyNode(o,"border",d,s);c[i][l]=h,o.setParent(h,a),u&&o.setEdge(u,h,{weight:1})}return td}var rd,dm;function kj(){if(dm)return rd;dm=1;var e=yt();rd={adjust:r,undo:t};function r(l){var d=l.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&n(l)}function t(l){var d=l.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&i(l),(d==="lr"||d==="rl")&&(a(l),n(l))}function n(l){e.forEach(l.nodes(),function(d){o(l.node(d))}),e.forEach(l.edges(),function(d){o(l.edge(d))})}function o(l){var d=l.width;l.width=l.height,l.height=d}function i(l){e.forEach(l.nodes(),function(d){s(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,s),e.has(u,"y")&&s(u)})}function s(l){l.y=-l.y}function a(l){e.forEach(l.nodes(),function(d){c(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,c),e.has(u,"x")&&c(u)})}function c(l){var d=l.x;l.x=l.y,l.y=d}return rd}var nd,um;function Pj(){if(um)return nd;um=1;var e=yt();nd=r;function r(t){var n={},o=e.filter(t.nodes(),function(l){return!t.children(l).length}),i=e.max(e.map(o,function(l){return t.node(l).rank})),s=e.map(e.range(i+1),function(){return[]});function a(l){if(!e.has(n,l)){n[l]=!0;var d=t.node(l);s[d.rank].push(l),e.forEach(t.successors(l),a)}}var c=e.sortBy(o,function(l){return t.node(l).rank});return e.forEach(c,a),s}return nd}var od,fm;function Aj(){if(fm)return od;fm=1;var e=yt();od=r;function r(n,o){for(var i=0,s=1;s<o.length;++s)i+=t(n,o[s-1],o[s]);return i}function t(n,o,i){for(var s=e.zipObject(i,e.map(i,function(h,p){return p})),a=e.flatten(e.map(o,function(h){return e.sortBy(e.map(n.outEdges(h),function(p){return{pos:s[p.w],weight:n.edge(p).weight}}),"pos")}),!0),c=1;c<i.length;)c<<=1;var l=2*c-1;c-=1;var d=e.map(new Array(l),function(){return 0}),u=0;return e.forEach(a.forEach(function(h){var p=h.pos+c;d[p]+=h.weight;for(var m=0;p>0;)p%2&&(m+=d[p+1]),p=p-1>>1,d[p]+=h.weight;u+=h.weight*m})),u}return od}var id,hm;function Rj(){if(hm)return id;hm=1;var e=yt();id=r;function r(t,n){return e.map(n,function(o){var i=t.inEdges(o);if(i.length){var s=e.reduce(i,function(a,c){var l=t.edge(c),d=t.node(c.v);return{sum:a.sum+l.weight*d.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:o,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:o}})}return id}var ad,pm;function Mj(){if(pm)return ad;pm=1;var e=yt();ad=r;function r(o,i){var s={};e.forEach(o,function(c,l){var d=s[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:l};e.isUndefined(c.barycenter)||(d.barycenter=c.barycenter,d.weight=c.weight)}),e.forEach(i.edges(),function(c){var l=s[c.v],d=s[c.w];!e.isUndefined(l)&&!e.isUndefined(d)&&(d.indegree++,l.out.push(s[c.w]))});var a=e.filter(s,function(c){return!c.indegree});return t(a)}function t(o){var i=[];function s(l){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(l.barycenter)||d.barycenter>=l.barycenter)&&n(l,d)}}function a(l){return function(d){d.in.push(l),--d.indegree===0&&o.push(d)}}for(;o.length;){var c=o.pop();i.push(c),e.forEach(c.in.reverse(),s(c)),e.forEach(c.out,a(c))}return e.map(e.filter(i,function(l){return!l.merged}),function(l){return e.pick(l,["vs","i","barycenter","weight"])})}function n(o,i){var s=0,a=0;o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=s/a,o.weight=a,o.i=Math.min(i.i,o.i),i.merged=!0}return ad}var sd,gm;function Tj(){if(gm)return sd;gm=1;var e=yt(),r=Nt();sd=t;function t(i,s){var a=r.partition(i,function(g){return e.has(g,"barycenter")}),c=a.lhs,l=e.sortBy(a.rhs,function(g){return-g.i}),d=[],u=0,h=0,p=0;c.sort(o(!!s)),p=n(d,l,p),e.forEach(c,function(g){p+=g.vs.length,d.push(g.vs),u+=g.barycenter*g.weight,h+=g.weight,p=n(d,l,p)});var m={vs:e.flatten(d,!0)};return h&&(m.barycenter=u/h,m.weight=h),m}function n(i,s,a){for(var c;s.length&&(c=e.last(s)).i<=a;)s.pop(),i.push(c.vs),a++;return a}function o(i){return function(s,a){return s.barycenter<a.barycenter?-1:s.barycenter>a.barycenter?1:i?a.i-s.i:s.i-a.i}}return sd}var cd,ym;function Ij(){if(ym)return cd;ym=1;var e=yt(),r=Rj(),t=Mj(),n=Tj();cd=o;function o(a,c,l,d){var u=a.children(c),h=a.node(c),p=h?h.borderLeft:void 0,m=h?h.borderRight:void 0,g={};p&&(u=e.filter(u,function(C){return C!==p&&C!==m}));var y=r(a,u);e.forEach(y,function(C){if(a.children(C.v).length){var S=o(a,C.v,l,d);g[C.v]=S,e.has(S,"barycenter")&&s(C,S)}});var b=t(y,l);i(b,g);var v=n(b,d);if(p&&(v.vs=e.flatten([p,v.vs,m],!0),a.predecessors(p).length)){var w=a.node(a.predecessors(p)[0]),x=a.node(a.predecessors(m)[0]);e.has(v,"barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+w.order+x.order)/(v.weight+2),v.weight+=2}return v}function i(a,c){e.forEach(a,function(l){l.vs=e.flatten(l.vs.map(function(d){return c[d]?c[d].vs:d}),!0)})}function s(a,c){e.isUndefined(a.barycenter)?(a.barycenter=c.barycenter,a.weight=c.weight):(a.barycenter=(a.barycenter*a.weight+c.barycenter*c.weight)/(a.weight+c.weight),a.weight+=c.weight)}return cd}var ld,mm;function Nj(){if(mm)return ld;mm=1;var e=yt(),r=Zt().Graph;ld=t;function t(o,i,s){var a=n(o),c=new r({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(l){return o.node(l)});return e.forEach(o.nodes(),function(l){var d=o.node(l),u=o.parent(l);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(c.setNode(l),c.setParent(l,u||a),e.forEach(o[s](l),function(h){var p=h.v===l?h.w:h.v,m=c.edge(p,l),g=e.isUndefined(m)?0:m.weight;c.setEdge(p,l,{weight:o.edge(h).weight+g})}),e.has(d,"minRank")&&c.setNode(l,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),c}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return ld}var dd,bm;function Oj(){if(bm)return dd;bm=1;var e=yt();dd=r;function r(t,n,o){var i={},s;e.forEach(o,function(a){for(var c=t.parent(a),l,d;c;){if(l=t.parent(c),l?(d=i[l],i[l]=c):(d=s,s=c),d&&d!==c){n.setEdge(d,c);return}c=l}})}return dd}var ud,xm;function $j(){if(xm)return ud;xm=1;var e=yt(),r=Pj(),t=Aj(),n=Ij(),o=Nj(),i=Oj(),s=Zt().Graph,a=Nt();ud=c;function c(h){var p=a.maxRank(h),m=l(h,e.range(1,p+1),"inEdges"),g=l(h,e.range(p-1,-1,-1),"outEdges"),y=r(h);u(h,y);for(var b=Number.POSITIVE_INFINITY,v,w=0,x=0;x<4;++w,++x){d(w%2?m:g,w%4>=2),y=a.buildLayerMatrix(h);var C=t(h,y);C<b&&(x=0,v=e.cloneDeep(y),b=C)}u(h,v)}function l(h,p,m){return e.map(p,function(g){return o(h,g,m)})}function d(h,p){var m=new s;e.forEach(h,function(g){var y=g.graph().root,b=n(g,y,m,p);e.forEach(b.vs,function(v,w){g.node(v).order=w}),i(g,m,b.vs)})}function u(h,p){e.forEach(p,function(m){e.forEach(m,function(g,y){h.node(g).order=y})})}return ud}var fd,vm;function qj(){if(vm)return fd;vm=1;var e=yt(),r=Zt().Graph,t=Nt();fd={positionX:m,findType1Conflicts:n,findType2Conflicts:o,addConflict:s,hasConflict:a,verticalAlignment:c,horizontalCompaction:l,alignCoordinates:h,findSmallestWidthAlignment:u,balance:p};function n(b,v){var w={};function x(C,S){var E=0,R=0,P=C.length,I=e.last(S);return e.forEach(S,function(M,k){var _=i(b,M),N=_?b.node(_).order:P;(_||M===I)&&(e.forEach(S.slice(R,k+1),function(O){e.forEach(b.predecessors(O),function(V){var T=b.node(V),Z=T.order;(Z<E||N<Z)&&!(T.dummy&&b.node(O).dummy)&&s(w,V,O)})}),R=k+1,E=N)}),S}return e.reduce(v,x),w}function o(b,v){var w={};function x(S,E,R,P,I){var M;e.forEach(e.range(E,R),function(k){M=S[k],b.node(M).dummy&&e.forEach(b.predecessors(M),function(_){var N=b.node(_);N.dummy&&(N.order<P||N.order>I)&&s(w,_,M)})})}function C(S,E){var R=-1,P,I=0;return e.forEach(E,function(M,k){if(b.node(M).dummy==="border"){var _=b.predecessors(M);_.length&&(P=b.node(_[0]).order,x(E,I,k,R,P),I=k,R=P)}x(E,I,E.length,P,S.length)}),E}return e.reduce(v,C),w}function i(b,v){if(b.node(v).dummy)return e.find(b.predecessors(v),function(w){return b.node(w).dummy})}function s(b,v,w){if(v>w){var x=v;v=w,w=x}var C=b[v];C||(b[v]=C={}),C[w]=!0}function a(b,v,w){if(v>w){var x=v;v=w,w=x}return e.has(b[v],w)}function c(b,v,w,x){var C={},S={},E={};return e.forEach(v,function(R){e.forEach(R,function(P,I){C[P]=P,S[P]=P,E[P]=I})}),e.forEach(v,function(R){var P=-1;e.forEach(R,function(I){var M=x(I);if(M.length){M=e.sortBy(M,function(V){return E[V]});for(var k=(M.length-1)/2,_=Math.floor(k),N=Math.ceil(k);_<=N;++_){var O=M[_];S[I]===I&&P<E[O]&&!a(w,I,O)&&(S[O]=I,S[I]=C[I]=C[O],P=E[O])}}})}),{root:C,align:S}}function l(b,v,w,x,C){var S={},E=d(b,v,w,C),R=C?"borderLeft":"borderRight";function P(k,_){for(var N=E.nodes(),O=N.pop(),V={};O;)V[O]?k(O):(V[O]=!0,N.push(O),N=N.concat(_(O))),O=N.pop()}function I(k){S[k]=E.inEdges(k).reduce(function(_,N){return Math.max(_,S[N.v]+E.edge(N))},0)}function M(k){var _=E.outEdges(k).reduce(function(O,V){return Math.min(O,S[V.w]-E.edge(V))},Number.POSITIVE_INFINITY),N=b.node(k);_!==Number.POSITIVE_INFINITY&&N.borderType!==R&&(S[k]=Math.max(S[k],_))}return P(I,E.predecessors.bind(E)),P(M,E.successors.bind(E)),e.forEach(x,function(k){S[k]=S[w[k]]}),S}function d(b,v,w,x){var C=new r,S=b.graph(),E=g(S.nodesep,S.edgesep,x);return e.forEach(v,function(R){var P;e.forEach(R,function(I){var M=w[I];if(C.setNode(M),P){var k=w[P],_=C.edge(k,M);C.setEdge(k,M,Math.max(E(b,I,P),_||0))}P=I})}),C}function u(b,v){return e.minBy(e.values(v),function(w){var x=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(w,function(S,E){var R=y(b,E)/2;x=Math.max(S+R,x),C=Math.min(S-R,C)}),x-C})}function h(b,v){var w=e.values(v),x=e.min(w),C=e.max(w);e.forEach(["u","d"],function(S){e.forEach(["l","r"],function(E){var R=S+E,P=b[R],I;if(P!==v){var M=e.values(P);I=E==="l"?x-e.min(M):C-e.max(M),I&&(b[R]=e.mapValues(P,function(k){return k+I}))}})})}function p(b,v){return e.mapValues(b.ul,function(w,x){if(v)return b[v.toLowerCase()][x];var C=e.sortBy(e.map(b,x));return(C[1]+C[2])/2})}function m(b){var v=t.buildLayerMatrix(b),w=e.merge(n(b,v),o(b,v)),x={},C;e.forEach(["u","d"],function(E){C=E==="u"?v:e.values(v).reverse(),e.forEach(["l","r"],function(R){R==="r"&&(C=e.map(C,function(k){return e.values(k).reverse()}));var P=(E==="u"?b.predecessors:b.successors).bind(b),I=c(b,C,w,P),M=l(b,C,I.root,I.align,R==="r");R==="r"&&(M=e.mapValues(M,function(k){return-k})),x[E+R]=M})});var S=u(b,x);return h(x,S),p(x,b.graph().align)}function g(b,v,w){return function(x,C,S){var E=x.node(C),R=x.node(S),P=0,I;if(P+=E.width/2,e.has(E,"labelpos"))switch(E.labelpos.toLowerCase()){case"l":I=-E.width/2;break;case"r":I=E.width/2;break}if(I&&(P+=w?I:-I),I=0,P+=(E.dummy?v:b)/2,P+=(R.dummy?v:b)/2,P+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":I=R.width/2;break;case"r":I=-R.width/2;break}return I&&(P+=w?I:-I),I=0,P}}function y(b,v){return b.node(v).width}return fd}var hd,wm;function Lj(){if(wm)return hd;wm=1;var e=yt(),r=Nt(),t=qj().positionX;hd=n;function n(i){i=r.asNonCompoundGraph(i),o(i),e.forEach(t(i),function(s,a){i.node(a).x=s})}function o(i){var s=r.buildLayerMatrix(i),a=i.graph().ranksep,c=0;e.forEach(s,function(l){var d=e.max(e.map(l,function(u){return i.node(u).height}));e.forEach(l,function(u){i.node(u).y=c+d/2}),c+=d+a})}return hd}var pd,Cm;function Fj(){if(Cm)return pd;Cm=1;var e=yt(),r=vj(),t=wj(),n=Sj(),o=Nt().normalizeRanks,i=jj(),s=Nt().removeEmptyRanks,a=Ej(),c=_j(),l=kj(),d=$j(),u=Lj(),h=Nt(),p=Zt().Graph;pd=m;function m(q,D){var G=D&&D.debugTiming?h.time:h.notime;G("layout",function(){var B=G(" buildLayoutGraph",function(){return P(q)});G(" runLayout",function(){g(B,G)}),G(" updateInputGraph",function(){y(q,B)})})}function g(q,D){D(" makeSpaceForEdgeLabels",function(){I(q)}),D(" removeSelfEdges",function(){ue(q)}),D(" acyclic",function(){r.run(q)}),D(" nestingGraph.run",function(){a.run(q)}),D(" rank",function(){n(h.asNonCompoundGraph(q))}),D(" injectEdgeLabelProxies",function(){M(q)}),D(" removeEmptyRanks",function(){s(q)}),D(" nestingGraph.cleanup",function(){a.cleanup(q)}),D(" normalizeRanks",function(){o(q)}),D(" assignRankMinMax",function(){k(q)}),D(" removeEdgeLabelProxies",function(){_(q)}),D(" normalize.run",function(){t.run(q)}),D(" parentDummyChains",function(){i(q)}),D(" addBorderSegments",function(){c(q)}),D(" order",function(){d(q)}),D(" insertSelfEdges",function(){K(q)}),D(" adjustCoordinateSystem",function(){l.adjust(q)}),D(" position",function(){u(q)}),D(" positionSelfEdges",function(){ee(q)}),D(" removeBorderNodes",function(){Z(q)}),D(" normalize.undo",function(){t.undo(q)}),D(" fixupEdgeLabelCoords",function(){V(q)}),D(" undoCoordinateSystem",function(){l.undo(q)}),D(" translateGraph",function(){N(q)}),D(" assignNodeIntersects",function(){O(q)}),D(" reversePoints",function(){T(q)}),D(" acyclic.undo",function(){r.undo(q)})}function y(q,D){e.forEach(q.nodes(),function(G){var B=q.node(G),se=D.node(G);B&&(B.x=se.x,B.y=se.y,D.children(G).length&&(B.width=se.width,B.height=se.height))}),e.forEach(q.edges(),function(G){var B=q.edge(G),se=D.edge(G);B.points=se.points,e.has(se,"x")&&(B.x=se.x,B.y=se.y)}),q.graph().width=D.graph().width,q.graph().height=D.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],v={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},w=["acyclicer","ranker","rankdir","align"],x=["width","height"],C={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],E={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},R=["labelpos"];function P(q){var D=new p({multigraph:!0,compound:!0}),G=ae(q.graph());return D.setGraph(e.merge({},v,H(G,b),e.pick(G,w))),e.forEach(q.nodes(),function(B){var se=ae(q.node(B));D.setNode(B,e.defaults(H(se,x),C)),D.setParent(B,q.parent(B))}),e.forEach(q.edges(),function(B){var se=ae(q.edge(B));D.setEdge(B,e.merge({},E,H(se,S),e.pick(se,R)))}),D}function I(q){var D=q.graph();D.ranksep/=2,e.forEach(q.edges(),function(G){var B=q.edge(G);B.minlen*=2,B.labelpos.toLowerCase()!=="c"&&(D.rankdir==="TB"||D.rankdir==="BT"?B.width+=B.labeloffset:B.height+=B.labeloffset)})}function M(q){e.forEach(q.edges(),function(D){var G=q.edge(D);if(G.width&&G.height){var B=q.node(D.v),se=q.node(D.w),te={rank:(se.rank-B.rank)/2+B.rank,e:D};h.addDummyNode(q,"edge-proxy",te,"_ep")}})}function k(q){var D=0;e.forEach(q.nodes(),function(G){var B=q.node(G);B.borderTop&&(B.minRank=q.node(B.borderTop).rank,B.maxRank=q.node(B.borderBottom).rank,D=e.max(D,B.maxRank))}),q.graph().maxRank=D}function _(q){e.forEach(q.nodes(),function(D){var G=q.node(D);G.dummy==="edge-proxy"&&(q.edge(G.e).labelRank=G.rank,q.removeNode(D))})}function N(q){var D=Number.POSITIVE_INFINITY,G=0,B=Number.POSITIVE_INFINITY,se=0,te=q.graph(),le=te.marginx||0,ne=te.marginy||0;function ce(xe){var he=xe.x,U=xe.y,re=xe.width,fe=xe.height;D=Math.min(D,he-re/2),G=Math.max(G,he+re/2),B=Math.min(B,U-fe/2),se=Math.max(se,U+fe/2)}e.forEach(q.nodes(),function(xe){ce(q.node(xe))}),e.forEach(q.edges(),function(xe){var he=q.edge(xe);e.has(he,"x")&&ce(he)}),D-=le,B-=ne,e.forEach(q.nodes(),function(xe){var he=q.node(xe);he.x-=D,he.y-=B}),e.forEach(q.edges(),function(xe){var he=q.edge(xe);e.forEach(he.points,function(U){U.x-=D,U.y-=B}),e.has(he,"x")&&(he.x-=D),e.has(he,"y")&&(he.y-=B)}),te.width=G-D+le,te.height=se-B+ne}function O(q){e.forEach(q.edges(),function(D){var G=q.edge(D),B=q.node(D.v),se=q.node(D.w),te,le;G.points?(te=G.points[0],le=G.points[G.points.length-1]):(G.points=[],te=se,le=B),G.points.unshift(h.intersectRect(B,te)),G.points.push(h.intersectRect(se,le))})}function V(q){e.forEach(q.edges(),function(D){var G=q.edge(D);if(e.has(G,"x"))switch((G.labelpos==="l"||G.labelpos==="r")&&(G.width-=G.labeloffset),G.labelpos){case"l":G.x-=G.width/2+G.labeloffset;break;case"r":G.x+=G.width/2+G.labeloffset;break}})}function T(q){e.forEach(q.edges(),function(D){var G=q.edge(D);G.reversed&&G.points.reverse()})}function Z(q){e.forEach(q.nodes(),function(D){if(q.children(D).length){var G=q.node(D),B=q.node(G.borderTop),se=q.node(G.borderBottom),te=q.node(e.last(G.borderLeft)),le=q.node(e.last(G.borderRight));G.width=Math.abs(le.x-te.x),G.height=Math.abs(se.y-B.y),G.x=te.x+G.width/2,G.y=B.y+G.height/2}}),e.forEach(q.nodes(),function(D){q.node(D).dummy==="border"&&q.removeNode(D)})}function ue(q){e.forEach(q.edges(),function(D){if(D.v===D.w){var G=q.node(D.v);G.selfEdges||(G.selfEdges=[]),G.selfEdges.push({e:D,label:q.edge(D)}),q.removeEdge(D)}})}function K(q){var D=h.buildLayerMatrix(q);e.forEach(D,function(G){var B=0;e.forEach(G,function(se,te){var le=q.node(se);le.order=te+B,e.forEach(le.selfEdges,function(ne){h.addDummyNode(q,"selfedge",{width:ne.label.width,height:ne.label.height,rank:le.rank,order:te+ ++B,e:ne.e,label:ne.label},"_se")}),delete le.selfEdges})})}function ee(q){e.forEach(q.nodes(),function(D){var G=q.node(D);if(G.dummy==="selfedge"){var B=q.node(G.e.v),se=B.x+B.width/2,te=B.y,le=G.x-se,ne=B.height/2;q.setEdge(G.e,G.label),q.removeNode(D),G.label.points=[{x:se+2*le/3,y:te-ne},{x:se+5*le/6,y:te-ne},{x:se+le,y:te},{x:se+5*le/6,y:te+ne},{x:se+2*le/3,y:te+ne}],G.label.x=G.x,G.label.y=G.y}})}function H(q,D){return e.mapValues(e.pick(q,D),Number)}function ae(q){var D={};return e.forEach(q,function(G,B){D[B.toLowerCase()]=G}),D}return pd}var gd,Sm;function zj(){if(Sm)return gd;Sm=1;var e=yt(),r=Nt(),t=Zt().Graph;gd={debugOrdering:n};function n(o){var i=r.buildLayerMatrix(o),s=new t({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(a){s.setNode(a,{label:a}),s.setParent(a,"layer"+o.node(a).rank)}),e.forEach(o.edges(),function(a){s.setEdge(a.v,a.w,{},a.name)}),e.forEach(i,function(a,c){var l="layer"+c;s.setNode(l,{rank:"same"}),e.reduce(a,function(d,u){return s.setEdge(d,u,{style:"invis"}),u})}),s}return gd}var yd,jm;function Bj(){return jm||(jm=1,yd="0.8.5"),yd}var md,Em;function Dj(){return Em||(Em=1,md={graphlib:Zt(),layout:Fj(),debug:zj(),util:{time:Nt().time,notime:Nt().notime},version:Bj()}),md}var Wj=Dj();const _m=k1(Wj);function Vj(e,r,t){var h,p;const n=new Set(e.map(m=>m.id)),o=new Map(e.map(m=>[m.id,m])),i=new Set;for(const m of e)m.parent&&n.has(m.parent)&&i.add(m.parent);const s=new Map;for(const m of e){if(!m.hasBody||!i.has(m.id))continue;let g=`${m.id}.$body`;for(;n.has(g);)g+="$";s.set(m.id,g),n.add(g)}const a=new _m.graphlib.Graph({multigraph:!0,compound:!0}),c=t.compactSpacingScale??(t.spacingFactor>0?t.spacingFactor/1.3:1);a.setGraph({rankdir:t.rankDir,nodesep:t.compact?Math.max(t.nodeSep,24*c):t.nodeSep,edgesep:t.compact?Math.min(t.edgeSep,24*c):t.edgeSep,ranksep:t.compact?Math.min(t.rankSep,80*c):t.rankSep,ranker:"network-simplex"}),a.setDefaultEdgeLabel(()=>({})),a.setDefaultNodeLabel(()=>({}));for(const m of e)a.setNode(m.id,{width:m.width+2,height:m.height+2});for(const m of e)m.parent&&n.has(m.parent)&&a.setParent(m.id,m.parent);for(const[m,g]of s){const y=o.get(m);a.setNode(g,{width:y.width+2,height:y.height+2}),a.setParent(g,m)}for(const m of e){if(i.has(m.id)&&!s.has(m.id))continue;let g=m.parent;const y=new Set;for(;g&&!s.has(g)&&!y.has(g);)y.add(g),g=(h=o.get(g))==null?void 0:h.parent;const b=g&&s.get(g);b&&a.setEdge(b,s.get(m.id)??m.id,{minlen:1,weight:1},"parent-body")}for(const m of r){if(!n.has(m.source)||!n.has(m.target))continue;const g=s.get(m.source)??m.source,y=s.get(m.target)??m.target;if(i.has(g)||i.has(y))continue;const b=rx(m.label,m.icon??((p=m.data)==null?void 0:p.icon),t.edgeLabelFontSize),v=t.rankDir==="LR"||t.rankDir==="RL",w=(b.width?b.width+2*tx:0)+(m.connectorClearance??0);a.setEdge(g,y,{minlen:1,weight:1,...w?{width:v?w:Math.max(1,b.height),height:v?Math.max(1,b.height):w,labelpos:"c"}:{}},m.id)}_m.layout(a);const l=new Map;for(const m of e){if(i.has(m.id)&&!s.has(m.id))continue;const g=a.node(s.get(m.id)??m.id);g&&Number.isFinite(g.x)&&Number.isFinite(g.y)&&l.set(m.id,{x:g.x,y:g.y})}const d=t.compact?1:t.spacingFactor;if(d&&d!==1&&l.size){let m=1/0,g=1/0,y=-1/0,b=-1/0;l.forEach(x=>{m=Math.min(m,x.x),g=Math.min(g,x.y),y=Math.max(y,x.x),b=Math.max(b,x.y)});const v=(m+y)/2,w=(g+b)/2;l.forEach((x,C)=>l.set(C,{x:v+(x.x-v)*d,y:w+(x.y-w)*d}))}const u=t.nodeAlignment??"center";if(u!=="center"){const m=t.rankDir==="LR"||t.rankDir==="RL",g=m?"x":"y",y=m?"width":"height",b=t.rankDir==="RL"||t.rankDir==="BT"?-1:1,v=u==="leading"?-b:b,w=new Map;for(const x of e){const C=l.get(x.id);if(!C)continue;const S=C[g];w.set(S,Math.max(w.get(S)??0,x[y]))}for(const x of e){const C=l.get(x.id);if(!C)continue;const S=C[g],E=(w.get(S)-x[y])/2;l.set(x.id,{...C,[g]:S+v*E})}}return l}function Ad(e,r,t,n,o,i){const s=new Map,a=new Map(e.map(u=>[u.id,u]));for(const u of e){if(!u.parent||!a.has(u.parent))continue;const h=s.get(u.parent);h?h.push(u.id):s.set(u.parent,[u.id])}const c=(u,h=new Set)=>{var m;const p=(m=a.get(u))==null?void 0:m.parent;return!p||!a.has(p)||h.has(u)?0:(h.add(u),1+c(p,h))},l=[...s.keys()].sort((u,h)=>c(h)-c(u)),d=new Map;for(const u of l){const h=i==null?void 0:i.get(u),p=r.get(u);if(h&&p){d.set(u,{x1:p.x-h.w/2,y1:p.y-h.h/2,x2:p.x+h.w/2,y2:p.y+h.h/2});continue}const m=t.get(u);let g=p&&m?{x1:p.x-m.w/2,y1:p.y-m.h/2,x2:p.x+m.w/2,y2:p.y+m.h/2}:null;for(const v of s.get(u)||[]){let w=d.get(v);if(!w){const x=r.get(v);if(!x)continue;const C=t.get(v)||{w:60,h:60};w={x1:x.x-C.w/2,y1:x.y-C.h/2,x2:x.x+C.w/2,y2:x.y+C.h/2}}g=g?{x1:Math.min(g.x1,w.x1),y1:Math.min(g.y1,w.y1),x2:Math.max(g.x2,w.x2),y2:Math.max(g.y2,w.y2)}:{...w}}if(!g)continue;const y=n(u);g={x1:g.x1-y,y1:g.y1-y,x2:g.x2+y,y2:g.y2+y};const b=o(u);if(b){const v=g.x2-g.x1,w=g.y2-g.y1;if(b.w>v){const x=(b.w-v)/2;g.x1-=x,g.x2+=x}if(b.h>w){const x=(b.h-w)/2;g.y1-=x,g.y2+=x}}d.set(u,g)}return d}function km(e,r,t){var c,l,d;const n=[...r.weights],o=n.reduce((u,h)=>u+h,0),i=n[r.index]+n[r.index+1],s=Math.min(i*.95,Math.max(i*.05,n[r.index]+t/r.length*o));n[r.index]=s,n[r.index+1]=i-s;const a={...(l=(c=e.adjustment)==null?void 0:c.sections)==null?void 0:l[r.section]};if(r.axis==="y")a.rows=n;else{for(a.columns=[...a.columns??[]];a.columns.length<=r.row;)a.columns.push([]);a.columns[r.row]=n}return{...e,adjustment:{...e.adjustment,sections:{...(d=e.adjustment)==null?void 0:d.sections,[r.section]:a}}}}function ov(e){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)||e.enabled!==void 0&&typeof e.enabled!="boolean")throw new RangeError("Invalid grid adjustment.");const r=t=>Array.isArray(t)&&t.length<=1e4&&t.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1e6);if(e.sections!==void 0&&(!e.sections||typeof e.sections!="object"||Array.isArray(e.sections)))throw new RangeError("Invalid grid sections.");for(const[t,n]of Object.entries(e.sections??{}))if(["__proto__","constructor","prototype"].includes(t)||!n||typeof n!="object"||Array.isArray(n)||n.rows!==void 0&&!r(n.rows)||n.columns!==void 0&&(!Array.isArray(n.columns)||n.columns.length>1e4||!n.columns.every(r))||n.members!==void 0&&(!Array.isArray(n.members)||n.members.length>1e4||!n.members.every(o=>Array.isArray(o)&&o.length>0&&o.length<=1e4&&o.every(i=>typeof i=="string"&&i.length>0))||new Set(n.members.flat()).size!==n.members.flat().length))throw new RangeError("Invalid grid section proportions.")}function pu(e){const r=e.margin??15;if(!Number.isFinite(r)||r<0)throw new RangeError("Collision margin must be finite and non-negative.");return r}function Yn(e){const r=new Map(e.nodes.map(a=>[a.id,a])),t=new Map;for(const a of e.nodes){const c=a.parent&&r.has(a.parent)?a.parent:void 0,l=t.get(c)??[];l.push(a.id),t.set(c,l)}const n=[],o=new Map,i=a=>{const c=t.get(a),l=c?c.flatMap(i):e.positions.has(a)?[a]:[];return o.set(a,l),c&&n.push(c),l},s=t.get(void 0)??[];return s.forEach(i),n.push(s),{groups:n,leaves:o,children:t,roots:s}}function kr(e,r,t=e.fixedSizes){const n=Ad(e.nodes,r,e.sizes,e.padding,e.minSize,t);for(const o of e.nodes){if(n.has(o.id))continue;const i=r.get(o.id),s=e.sizes.get(o.id);i&&s&&n.set(o.id,ir({...i,...s}))}return n}function iv(e,r,t,n){const o=t.get(e),i=t.get(r);if(!o||!i)return;const s={x:Math.min(o.x2-i.x1,i.x2-o.x1)+n,y:Math.min(o.y2-i.y1,i.y2-o.y1)+n};if(s.x>.001&&s.y>.001)return{source:e,target:r,overlap:s}}function Vn(e,r,t){const n=[];for(const o of e)for(let i=0;i<o.length;i++)for(let s=i+1;s<o.length;s++){const a=iv(o[i],o[s],r,t);a&&n.push(a)}return n}function av(e,r={}){const t=pu(r),{groups:n}=Yn(e);return Vn(n,kr(e,e.positions),t)}function sv(e,r,t,n){var a,c,l;const o=new Set(e),i=(((l=(c=(a=r.adjustment)==null?void 0:a.sections)==null?void 0:c[t])==null?void 0:l.members)??[]).map(d=>d.filter(u=>o.delete(u))).filter(d=>d.length),s=e.filter(d=>o.has(d));for(let d=0;d<s.length;d+=n)i.push(s.slice(d,d+n));return i}function Gj(e,r,t,n,o){var v,w,x,C;if(t===n)return;const{groups:i,leaves:s}=Yn(e),a=i.find(S=>S.includes(t)&&S.includes(n));if(!a||a.some(S=>e.fixedIds.has(S)||(s.get(S)??[]).some(E=>e.fixedIds.has(E))))return;const c=kr(e,e.positions);if(a.some(S=>!c.has(S)))return;const l=((v=e.nodes.find(S=>S.id===t))==null?void 0:v.parent)??"canvas",d=(x=(w=r.adjustment)==null?void 0:w.sections)==null?void 0:x[l],u=[],h=[...a].sort((S,E)=>{const R=c.get(S),P=c.get(E),I=(R.y1+R.y2-P.y1-P.y2)/2;return Math.abs(I)>1?I:R.x1-P.x1});for(const S of h){const E=u.at(-1),R=c.get(S),P=E&&c.get(E[0]);P&&Math.abs(R.y1+R.y2-P.y1-P.y2)<2?E.push(S):u.push([S])}const p=u.map((S,E)=>{var R;return{weight:((R=d==null?void 0:d.rows)==null?void 0:R[E])??1,cells:S.map((P,I)=>{var M,k;return{id:P,weight:((k=(M=d==null?void 0:d.columns)==null?void 0:M[E])==null?void 0:k[I])??1}})}});for(const S of p)S.cells=S.cells.filter(E=>E.id!==t);const m=p.filter(S=>S.cells.length),g=m.findIndex(S=>S.cells.some(E=>E.id===n)),y=m[g];if(!y)return;o==="above"||o==="below"?m.splice(g+(o==="below"?1:0),0,{weight:1,cells:[{id:t,weight:1}]}):y.cells.splice(y.cells.findIndex(S=>S.id===n)+(o==="after"?1:0),0,{id:t,weight:1});const b=m.map(S=>S.cells.map(E=>E.id));if(JSON.stringify(b)!==JSON.stringify(u))return{...r,adjustment:{...r.adjustment,sections:{...(C=r.adjustment)==null?void 0:C.sections,[l]:{...d,members:b,rows:m.map(S=>S.weight),columns:m.map(S=>S.cells.map(E=>E.weight))}}}}}function bd(e,r={}){var d;ov(r.adjustment);const t=pu(r),n=typeof r.gaps=="object"?r.gaps:{x:r.gaps??t,y:r.gaps??t};if(!n||[n.x,n.y].some(u=>!Number.isFinite(u)||u<0))throw new RangeError("Grid gaps must be finite and non-negative.");const o=r.padding??0;if(!Number.isFinite(o)||o<0)throw new RangeError("Grid padding must be finite and non-negative.");if(r.columns!==void 0&&(!Number.isSafeInteger(r.columns)||r.columns<1))throw new RangeError("Grid columns must be a positive safe integer.");if(r.fill&&e.viewportSize)return Hj(e,r,n,o);const{groups:i,leaves:s}=Yn(e),a=new Map([...e.positions].map(([u,h])=>[u,{...h}])),c=new Set;for(const u of i){const h=kr(e,a),p=u.filter(M=>h.has(M));if(p.length<2)continue;if(p.some(M=>e.fixedIds.has(M)||(s.get(M)??[]).some(k=>e.fixedIds.has(k)))){p.forEach(M=>c.add(M));continue}const g=p.map(M=>h.get(M)),y=Math.max(...g.map(M=>M.x2-M.x1)),b=Math.max(...g.map(M=>M.y2-M.y1)),v=Math.min(p.length,r.columns??Math.ceil(Math.sqrt(p.length))),w=((d=e.nodes.find(M=>M.id===p[0]))==null?void 0:d.parent)??"canvas",x=sv(p,r,w,v),C=Math.max(...x.map(M=>M.length)),S=y+n.x,E=b+n.y,R=g.map(M=>({x:(M.x1+M.x2)/2,y:(M.y1+M.y2)/2})),P=(Math.min(...R.map(M=>M.x))+Math.max(...R.map(M=>M.x)))/2,I=(Math.min(...R.map(M=>M.y))+Math.max(...R.map(M=>M.y)))/2;x.forEach((M,k)=>M.forEach((_,N)=>{const O=h.get(_),V={x:P+(N-(C-1)/2)*S-(O.x1+O.x2)/2,y:I+(k-(x.length-1)/2)*E-(O.y1+O.y2)/2};for(const T of s.get(_)??[]){const Z=a.get(T);a.set(T,{x:Z.x+V.x,y:Z.y+V.y})}}))}const l=[...a].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:a,movedNodeIds:l,skippedNodeIds:[...c],collisions:Vn(i,kr(e,a),Math.min(n.x,n.y))}}function Hj(e,r,t,n){const{groups:o,children:i,roots:s}=Yn(e),a=new Map([...e.positions].map(([y,b])=>[y,{...b}]));if(e.nodes.some(y=>e.fixedIds.has(y.id)))return{positions:a,movedNodeIds:[],skippedNodeIds:e.nodes.map(y=>y.id),collisions:av(e,{margin:Math.min(t.x,t.y)})};const c=e.viewportSize,l=Math.min(n,Math.max(0,(c.w-1)/2)),d=Math.min(n,Math.max(0,(c.h-1)/2)),u={x1:l,y1:d,x2:Math.max(l+1,c.w-l),y2:Math.max(d+1,c.h-d)},h=new Map,p=[],m=(y,b,v="canvas")=>{var N,O;if(!y.length)return;const w=b.x2-b.x1,x=b.y2-b.y1,C=Math.min(y.length,r.columns??Math.max(1,Math.round(Math.sqrt(y.length*w/x)))),S=sv(y,r,v,C),E=S.length,R=Math.min(t.y,x/(2*E)),P=(O=(N=r.adjustment)==null?void 0:N.sections)==null?void 0:O[v],I=Array.from({length:E},(V,T)=>{var Z;return((Z=P==null?void 0:P.rows)==null?void 0:Z[T])??1}),M=I.reduce((V,T)=>V+T,0),k=x-(E-1)*R;let _=b.y1;for(let V=0;V<E;V++){const T=k*I[V]/M,Z=S[V].length,ue=Math.min(t.x,w/(2*Z)),K=Array.from({length:Z},(q,D)=>{var G,B;return((B=(G=P==null?void 0:P.columns)==null?void 0:G[V])==null?void 0:B[D])??1}),ee=K.reduce((q,D)=>q+D,0),H=w-(Z-1)*ue;let ae=b.x1;for(let q=0;q<Z;q++){const D=S[V][q],G=H*K[q]/ee,B=i.get(D);if(B){a.set(D,{x:ae+G/2,y:_+T/2}),h.set(D,{w:G,h:T});const se=Math.min(e.padding(D),Math.max(0,(Math.min(G,T)-1)/2));m(B,{x1:ae+se,y1:_+se,x2:ae+G-se,y2:_+T-se},D)}else a.has(D)&&(a.set(D,{x:ae+G/2,y:_+T/2}),h.set(D,{w:G,h:T}));q<Z-1&&p.push({section:v,axis:"x",row:V,index:q,weights:K,length:H,position:{x:ae+G+ue/2,y:_+T/2}}),ae+=G+ue}V<E-1&&p.push({section:v,axis:"y",row:V,index:V,weights:I,length:k,position:{x:b.x1+w/2,y:_+T+R/2}}),_+=T+R}};m(s,u);const g=[...a].filter(([y,b])=>{const v=e.positions.get(y);return!v||b.x!==v.x||b.y!==v.y}).map(([y])=>y);return{positions:a,movedNodeIds:g,skippedNodeIds:[],bounds:u,sizes:h,dividers:p,collisions:Vn(o,kr({...e,sizes:h},a,h),0)}}function Uj(e,r={}){const t=pu(r),n=r.maxIterations??50;if(!Number.isInteger(n)||n<0||n>1e3)throw new RangeError("Collision maxIterations must be an integer between 0 and 1000.");const{groups:o,leaves:i}=Yn(e),s=new Map([...e.positions].map(([u,h])=>[u,{...h}])),a=u=>e.fixedIds.has(u)||(i.get(u)??[]).some(h=>e.fixedIds.has(h));let c=Vn(o,kr(e,s),t),l=0;for(;c.length&&l<n;){let u=!1;for(const h of o){if(h.length<2)continue;const p=kr(e,s),m=(g,y,b)=>{for(const w of i.get(g)??[])s.get(w)[y]+=b;const v=p.get(g);y==="x"?(v.x1+=b,v.x2+=b):(v.y1+=b,v.y2+=b)};for(let g=0;g<h.length;g++)for(let y=g+1;y<h.length;y++){const b=h[g],v=h[y],w=iv(b,v,p,t);if(!w)continue;const x=a(b),C=a(v);if(x&&C)continue;const S=w.overlap.x<=w.overlap.y?"x":"y",E=p.get(b),R=p.get(v),P=S==="x"?E.x1+E.x2<=R.x1+R.x2?-1:1:E.y1+E.y2<=R.y1+R.y2?-1:1,I=w.overlap[S];x||m(b,S,P*I/(C?1:2)),C||m(v,S,-P*I/(x?1:2)),u=!0}}if(l++,c=Vn(o,kr(e,s),t),!u)break}const d=[...s].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:s,movedNodeIds:d,collisions:c,iterations:l,resolved:c.length===0}}function Kj({dividers:e,options:r,zoom:t,onChange:n}){const o=j.useRef();return f.jsx(f.Fragment,{children:e.map(i=>{const s=i.axis==="x",a=s?Q.PiArrowsHorizontal:Q.PiArrowsVertical,c=`${s?"Column":"Row"} divider ${i.index+1}${s?` in row ${i.row+1}`:""}`;return f.jsx("button",{type:"button",role:"separator","aria-label":c,"aria-orientation":s?"vertical":"horizontal","aria-valuemin":5,"aria-valuemax":95,"aria-valuenow":Math.round(100*i.weights[i.index]/(i.weights[i.index]+i.weights[i.index+1])),title:c,"data-flow-grid-adjustment":"",style:{position:"absolute",left:i.position.x,top:i.position.y,transform:"translate(-50%, -50%)",width:28,height:28,padding:3,border:"1px solid currentColor",borderRadius:4,background:"var(--chakra-colors-gray-100)",color:"var(--chakra-colors-gray-800)",display:"grid",placeItems:"center",cursor:s?"col-resize":"row-resize",touchAction:"none",pointerEvents:"auto",zIndex:30},onPointerDown:l=>{if(l.button!==0)return;l.preventDefault(),l.stopPropagation();const d=l.currentTarget.closest(".flow-sdk-canvas"),u=d.getBoundingClientRect();o.current={pointerId:l.pointerId,start:s?l.clientX:l.clientY,scale:t*(s?u.width/d.clientWidth:u.height/d.clientHeight),divider:i,options:r},l.currentTarget.setPointerCapture(l.pointerId)},onPointerMove:l=>{const d=o.current;if(!d||d.pointerId!==l.pointerId)return;l.preventDefault(),l.stopPropagation();const u=((s?l.clientX:l.clientY)-d.start)/d.scale;n(km(d.options,d.divider,u))},onPointerUp:l=>{o.current&&(l.stopPropagation(),o.current=void 0,l.currentTarget.releasePointerCapture(l.pointerId))},onPointerCancel:()=>{o.current&&n(o.current.options),o.current=void 0},onLostPointerCapture:()=>{o.current=void 0},onClick:l=>l.stopPropagation(),onKeyDown:l=>{l.key==="Escape"&&o.current&&(n(o.current.options),o.current=void 0);const d=(s?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).indexOf(l.key);d<0||(l.preventDefault(),l.stopPropagation(),n(km(r,i,i.length*(l.shiftKey?.1:.02)*(d===0?-1:1))))},children:f.jsx(a,{size:20,"aria-hidden":"true"})},`${i.section}:${i.axis}:${i.row}:${i.index}`)})})}const Pm=(e,r)=>e.left<r.right&&e.right>r.left&&e.top<r.bottom&&e.bottom>r.top,xd=new WeakMap;function Am(e,r){const t=[...r.querySelectorAll(".flow-sdk-edge-label")];if(!t.length){xd.delete(r);return}const n=r==null?void 0:r.getScreenCTM();if(!r||!n)return;const o=n.inverse(),i=(u,h=0)=>{const p=u.getBoundingClientRect(),m=new DOMPoint(p.left,p.top).matrixTransform(o),g=new DOMPoint(p.right,p.bottom).matrixTransform(o);return{left:m.x-h,right:g.x+h,top:m.y-h,bottom:g.y+h}},s=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(u=>u.closest(".flow-sdk-canvas")===e).filter(u=>{const h=u.getBoundingClientRect(),p=getComputedStyle(u);return h.width>0&&h.height>0&&p.visibility!=="hidden"&&p.opacity!=="0"}).map(u=>i(u,24));for(const u of r.querySelectorAll(".flow-sdk-container-label"))s.push(i(u,12));const a=new Map([...e.querySelectorAll(".flow-sdk-edge")].filter(u=>u.closest(".flow-sdk-canvas")===e).map(u=>[u.dataset.edgeId,u.querySelector("path")])),c=JSON.stringify([s,[...a].map(([u,h])=>[u,h==null?void 0:h.getAttribute("d")]),t.map(u=>{var m;const h=u.getBBox(),p=(m=u.querySelector("rect"))==null?void 0:m.getBBox();return[u.dataset.edgeId,u.dataset.labelTransform,u.dataset.labelHorizontal,h.x,h.y,h.width,h.height,p==null?void 0:p.width,p==null?void 0:p.height]})],(u,h)=>typeof h=="number"?Math.round(h*1e3)/1e3:h),l=xd.get(r);if((l==null?void 0:l.geometry)===c&&t.every(u=>l.transforms.has(u))){for(const u of t){const h=l.transforms.get(u);u.getAttribute("transform")!==h&&u.setAttribute("transform",h)}return}for(const u of t)u.setAttribute("transform",u.dataset.labelTransform??"");const d=new Map(t.map(u=>[u,i(u,8)]));for(const u of t){const h=u.dataset.labelHorizontal==="true",p=d.get(u);d.delete(u);const m=P=>s.some(I=>Pm(P,I))||[...d.values()].some(I=>Pm(P,I));if(!h&&!m(p)){d.set(u,p);continue}const g=a.get(u.dataset.edgeId),y=u.querySelector("rect");if(!g||!y)continue;const b=y.getBBox(),v=g.getTotalLength();if(!Number.isFinite(v)||v<=0)continue;const w=(p.left+p.right)/2,x=(p.top+p.bottom)/2,C=Math.min(256,Math.max(16,Math.ceil(v/24))),S=Array.from({length:C+1},(P,I)=>g.getPointAtLength(v*I/C)),R=Array.from({length:C+1},(P,I)=>{const M=v*I/C,k=S[I],_=h?{x:k.x,y:k.y-b.height/2-15}:k,N=g.getPointAtLength(Math.max(0,M-2)),O=g.getPointAtLength(Math.min(v,M+2));let V=Math.atan2(O.y-N.y,O.x-N.x)*180/Math.PI;V>90&&(V-=180),V<-90&&(V+=180);const T=Math.abs(V)<1;h&&(V=0);const Z=V*Math.PI/180,ue=Math.abs(Math.cos(Z))*b.width+Math.abs(Math.sin(Z))*b.height,K=Math.abs(Math.sin(Z))*b.width+Math.abs(Math.cos(Z))*b.height;return{point:_,angle:V,straight:T,score:Math.hypot(_.x-w,_.y-x),bounds:{left:_.x-ue/2-8,right:_.x+ue/2+8,top:_.y-K/2-8,bottom:_.y+K/2+8}}}).sort((P,I)=>P.score-I.score).find(P=>!m(P.bounds)&&(!h||P.straight&&!S.some(I=>I.x>P.bounds.left&&I.x<P.bounds.right&&I.y>P.bounds.top&&I.y<P.bounds.bottom)));R?(u.setAttribute("transform",`translate(${R.point.x} ${R.point.y}) rotate(${R.angle})`),d.set(u,R.bounds)):d.set(u,p)}xd.set(r,{geometry:c,transforms:new Map(t.map(u=>[u,u.getAttribute("transform")??""]))})}function Jj(e){const r=e.getBoundingClientRect(),t=r.height/e.offsetHeight;if(!Number.isFinite(t)||t<=0)return[];const n=Qb(e),o={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},i=[...e.querySelectorAll("[data-flow-property]")],s=new Set(i.filter(a=>a.hasAttribute("data-flow-inspection-row")&&a.getBoundingClientRect().height>0).map(a=>a.dataset.flowProperty));return i.flatMap(a=>{if(a.closest(".flow-sdk-node")!==e)return[];if(s.has(a.dataset.flowProperty)&&!a.hasAttribute("data-flow-inspection-row"))return[];const c=a.dataset.flowPortSide;if(c&&["top","right","bottom","left"].includes(c)){const d=Zb(n?qn(o,n):o,c,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:d.y,height:0,anchor:d,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const l=a.getBoundingClientRect();return!l.width||!l.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((l.top-r.top)/t*1e3)/1e3,height:Math.round(l.height/t*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function Zj({id:e,x:r,y:t,placed:n,hidden:o,gridDraggable:i,gridDragging:s,gridDropTarget:a,gridSize:c,gridPreview:l,onMount:d,drawHandles:u,drawMode:h,connectedPorts:p,resolvedRows:m,hasCollapseControl:g,handleColor:y,animated:b,animationColor:v,animationWidth:w=8,animationVariant:x,width:C=0,height:S=0,propertyMode:E,reversePorts:R,direction:P="LR",onPropertyRows:I,onSurface:M,children:k}){var B,se;const _=j.useRef(null),[N,O]=j.useState([]),V=m??N,[T,Z]=j.useState(),ue=j.useId(),K=j.useRef(),ee=!!l,H=!!(l!=null&&l.floating);j.useLayoutEffect(()=>{var xe;const te=_.current;if(!te||!ee)return;const le=te.cloneNode(!0);le.removeAttribute("data-node-id"),le.removeAttribute("data-grid-dragging"),le.removeAttribute("data-grid-draggable"),le.removeAttribute("data-grid-drop-target"),le.setAttribute("data-grid-preview",e),le.setAttribute("aria-hidden","true"),le.setAttribute("inert","");const ne=[le,...le.querySelectorAll("*")],ce=new Map(ne.filter(he=>he.id).map(he=>[he.id,`${he.id}-${ue}`]));for(const he of ne){he.id&&(he.id=ce.get(he.id));for(const U of[...he.attributes]){if(U.name==="id")continue;let re=U.value;for(const[fe,we]of ce)re===`#${fe}`&&(re=`#${we}`),re=re.split(`url(#${fe})`).join(`url(#${we})`);re!==U.value&&he.setAttribute(U.name,re)}}if(Object.assign(le.style,{opacity:"0.35",zIndex:H?"2147483647":"11",pointerEvents:"none",outline:"none",visibility:"visible"}),H){const he=getComputedStyle(te);le.setAttribute("data-grid-preview-floating",""),Object.assign(le.style,{position:"fixed",left:"0",top:"0",transformOrigin:"top left",font:he.font,color:he.color});for(const U of ne)U.removeAttribute("data-node-id"),U.style.pointerEvents="none"}return le.querySelectorAll(".flow-sdk-node-animation, .flow-sdk-handle, .flow-sdk-property-port, [data-flow-collapse-control]").forEach(he=>he.remove()),(xe=H?document.body:te.parentElement)==null||xe.appendChild(le),K.current=le,()=>{le.remove(),K.current=void 0}},[e,ue,ee,H]),j.useLayoutEffect(()=>{const te=K.current;if(!te||!l)return;const{x:le,y:ne,size:ce}=l;if(H&&_.current){const U=_.current,re=U.getBoundingClientRect(),fe=re.width/U.offsetWidth||1,we=re.height/U.offsetHeight||1,ie=re.left+(le-r)*fe,Ce=re.top+(ne-t)*we;te.style.transform=`translate3d(${ie}px, ${Ce}px, 0) scale(${fe}, ${we})`,te.style.width=`${U.offsetWidth}px`,te.style.height=`${U.offsetHeight}px`;return}const xe=ce?Math.round(le-ce.w/2):le,he=ce?Math.round(ne-ce.h/2):ne;te.style.transform=ce?`translate3d(${xe}px, ${he}px, 0)`:`translate(-50%, -50%) translate3d(${xe}px, ${he}px, 0)`,te.style.width=ce?`${Math.round(le+ce.w/2)-xe}px`:"",te.style.height=ce?`${Math.round(ne+ce.h/2)-he}px`:"",ce&&(te.style.setProperty("--flow-grid-width",`${ce.w}px`),te.style.setProperty("--flow-grid-height",`${ce.h}px`),te.style.setProperty("--flow-grid-font",`${Math.max(12,Math.min(48,ce.w/8,ce.h/5))}px`))},[l==null?void 0:l.x,l==null?void 0:l.y,(B=l==null?void 0:l.size)==null?void 0:B.w,(se=l==null?void 0:l.size)==null?void 0:se.h,H,r,t]),j.useLayoutEffect(()=>{const te=_.current;if(!te)return;const le=()=>{const xe=Qb(te);Z(he=>JSON.stringify(he)===JSON.stringify(xe)?he:xe),M==null||M(e,xe)};le();const ne=new ResizeObserver(le);ne.observe(te);const ce=te.querySelector("[data-flow-node-surface]");return ce&&ne.observe(ce),()=>ne.disconnect()},[e,k,M]),j.useLayoutEffect(()=>(d(e,_.current),()=>{d(e,null),M==null||M(e,void 0)}),[e,d,M]),j.useLayoutEffect(()=>{const te=_.current;if(!te)return;let le="";const ne=()=>{const U=Jj(te),re=E?U:U.filter(we=>we.anchor),fe=JSON.stringify(re);fe!==le&&(le=fe,O(re),I==null||I(e,re))};if(ne(),!E&&!te.querySelector("[data-flow-port-side]"))return;const ce=new ResizeObserver(ne),xe=()=>{ce.disconnect(),ce.observe(te),te.querySelectorAll("[data-flow-property]").forEach(U=>ce.observe(U)),ne()};xe();const he=new MutationObserver(xe);return he.observe(te,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["data-flow-property","data-flow-port-role","data-flow-port-side","data-flow-port-position","data-flow-port-placement"]}),te.addEventListener("scroll",ne,!0),()=>{ce.disconnect(),he.disconnect(),te.removeEventListener("scroll",ne,!0)}},[e,E,I,k]);const ae=c?Math.round(r-c.w/2):0,q=c?Math.round(t-c.h/2):0,D=c?Math.round(r+c.w/2)-ae:void 0,G=c?Math.round(t+c.h/2)-q:void 0;return f.jsxs("div",{ref:_,className:"flow-sdk-node","data-node-id":e,"data-grid-draggable":i||void 0,"data-grid-dragging":s||void 0,"data-grid-drop-target":a||void 0,"data-grid-fill":c?"":void 0,style:{transform:c?`translate3d(${ae}px, ${q}px, 0)`:`translate(-50%, -50%) translate3d(${r.toFixed(2)}px, ${t.toFixed(2)}px, 0)`,visibility:n&&!o?void 0:"hidden",cursor:i?s?"grabbing":"grab":void 0,zIndex:s?12:void 0,opacity:l?0:s?.75:void 0,outline:a?`2px solid ${y||"currentColor"}`:void 0,outlineOffset:a?8:void 0,width:D,height:G,...c?{"--flow-grid-width":`${c.w}px`,"--flow-grid-height":`${c.h}px`,"--flow-grid-font":`${Math.max(12,Math.min(48,c.w/8,c.h/5))}px`}:{}},children:[k,!c&&b&&w>0&&C>0&&S>0&&f.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:f.jsx(go,{variant:x,x:((T==null?void 0:T.left)??0)+w/2,y:((T==null?void 0:T.top)??0)+w/2,width:((T==null?void 0:T.width)??C)-w,height:((T==null?void 0:T.height)??S)-w,radius:((T==null?void 0:T.radius)??0)-w/2,path:T!=null&&T.outline?`M${T.outline.map(te=>`${te.x} ${te.y}`).join(" L")} Z`:void 0,color:v||y||"currentColor",strokeWidth:w})}),u&&E&&V.map(te=>["source","target"].filter(le=>!te.role||te.role===le).filter(le=>h||(p==null?void 0:p.has(`${le}:${te.property}`))).map(le=>{var ne;return f.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":te.property,"data-port-role":le,"data-port-side":(ne=te.anchor)==null?void 0:ne.side,"aria-label":`${le==="source"?"Connect":"Input"} ${te.property}`,title:`${le==="source"?"Connect":"Input"} ${te.property}`,style:{color:y,...te.anchor?{top:te.anchor.y,left:te.anchor.x-16}:{top:te.top+te.height/2,[le==="source"!=!!R?"right":"left"]:-16}},onClick:ce=>ce.stopPropagation()},`${te.property}:${le}`)})),u&&!g&&(!E||!V.length)&&(!E||!V.some(te=>te.anchor))&&f.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:y,left:((T==null?void 0:T.left)??0)+(P==="RL"?-36:P==="LR"?(T==null?void 0:T.width)??C:((T==null?void 0:T.width)??C)/2),top:((T==null?void 0:T.top)??0)+(P==="BT"?-36:P==="TB"?(T==null?void 0:T.height)??S:((T==null?void 0:T.height)??S)/2),transform:P==="BT"||P==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:te=>te.stopPropagation(),children:f.jsx(Q.PiPlusBold,{size:24})})]})}const Xj=j.memo(Zj);function Yj(e,r,t){const[n,o]=j.useState(()=>({nodes:new Set,edges:new Set})),i=j.useMemo(()=>{const a=new Set(e.map(p=>p.id)),c=r.filter(p=>a.has(p.source)&&a.has(p.target)).map(p=>({id:p.id,source:p.inverted?p.target:p.source,target:p.inverted?p.source:p.target})),l=new Set(c.map(p=>p.id)),d=new Set([...n.nodes].filter(p=>a.has(p))),u=new Set([...n.edges].filter(p=>l.has(p)));if(!t)return{nodes:a,edges:l,ready:l};for(const p of e)c.filter(g=>g.target===p.id&&g.source!==g.target).every(g=>u.has(g.id))&&d.add(p.id);let h=new Set(c.filter(p=>d.has(p.source)).map(p=>p.id));if(d.size<a.size&&!c.some(p=>h.has(p.id)&&!u.has(p.id))){const p=e.find(m=>!d.has(m.id));p&&d.add(p.id),h=new Set(c.filter(m=>d.has(m.source)).map(m=>m.id))}return{nodes:d,edges:u,ready:h}},[e,r,t,n]);j.useLayoutEffect(()=>{o(a=>{const c=t?i:{nodes:new Set,edges:new Set},l=(d,u)=>d.size===u.size&&[...d].every(h=>u.has(h));return l(a.nodes,c.nodes)&&l(a.edges,c.edges)?a:{nodes:c.nodes,edges:c.edges}})},[i,t]);const s=j.useCallback(a=>{o(c=>c.edges.has(a)?c:{...c,edges:new Set([...c.edges,a])})},[]);return{shown:i.nodes,ready:i.ready,complete:s}}class Qj{constructor(r,t,n){zt(this,"_pan");zt(this,"_zoom");zt(this,"minZoom");zt(this,"maxZoom");zt(this,"size",{w:0,h:0});zt(this,"listeners",new Set);zt(this,"cancelTransition");zt(this,"animationVersion",0);zt(this,"captureTransition");zt(this,"animationsDisabled",!1);zt(this,"finishTransition");this.minZoom=t,this.maxZoom=n,this._pan={...r.pan},this._zoom=this.clamp(r.zoom)}setAnimationsDisabled(r){var t;r!==this.animationsDisabled&&(this.animationsDisabled=r,r&&((t=this.finishTransition)==null||t.call(this),this.cancelAnimation()))}cancelAnimation(){var r;(r=this.cancelTransition)==null||r.call(this),this.cancelTransition=void 0,this.finishTransition=void 0,this.animationVersion++}coordinate(r){let t;this.captureTransition=n=>{t=n};try{r()}finally{this.captureTransition=void 0}return t}transition(r,t=!1){this.cancelAnimation();const n=this.state,o={pan:{...r.pan},zoom:this.clamp(r.zoom)},i=this.animationVersion,s=Kb(t,this.animationsDisabled),a=c=>{if(i!==this.animationVersion)return;const l=s?c:1;this.apply({x:n.pan.x+(o.pan.x-n.pan.x)*l,y:n.pan.y+(o.pan.y-n.pan.y)*l},n.zoom+(o.zoom-n.zoom)*l)};this.finishTransition=()=>a(1),this.captureTransition?this.captureTransition(a):this.cancelTransition=Jb(s,a,void 0,300/1.4)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(r){return Number.isFinite(r)?Math.max(this.minZoom,Math.min(this.maxZoom,r)):this.minZoom}set(r,t){this.cancelAnimation(),this.apply(r,t)}apply(r,t){let n=!1;if(r&&(r.x!==this._pan.x||r.y!==this._pan.y)&&(this._pan={x:r.x,y:r.y},n=!0),t!==void 0){const o=this.clamp(t);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(r,t){const n=this.clamp(r),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:t.x-(t.x-this._pan.x)*i,y:t.y-(t.y-this._pan.y)*i},n)}fit(r,t=0,n=!1,o=1){const i=r.x2-r.x1,s=r.y2-r.y1;if(!(i>0)||!(s>0)||!this.size.w||!this.size.h)return;const a=this.clamp(this.clamp(Math.min((this.size.w-2*t)/i,(this.size.h-2*t)/s))*o);this.transition({pan:{x:(this.size.w-a*(r.x1+r.x2))/2,y:(this.size.h-a*(r.y1+r.y2))/2},zoom:a},n)}center(r,t=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(r.x1+r.x2))/2,y:(this.size.h-n*(r.y1+r.y2))/2},zoom:n},t)}renderedToModel(r){return{x:(r.x-this._pan.x)/this._zoom,y:(r.y-this._pan.y)/this._zoom}}modelToRendered(r){return{x:r.x*this._zoom+this._pan.x,y:r.y*this._zoom+this._pan.y}}onChange(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}emit(){const r=this.state;this.listeners.forEach(t=>t(r))}}const eE={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},ao={w:60,h:60},vd=4,tE=30,rE=500,nE=45;function Rm(e){const[r,t]=[...e.values()];return!r||!t?null:{center:{x:(r.x+t.x)/2,y:(r.y+t.y)/2},distance:Math.max(1,Math.hypot(t.x-r.x,t.y-r.y))}}function oE(e){var Su,ju,Eu,_u,ku;const{nodes:r,edges:t,direction:n,nodeAlignment:o="center",edgeMode:i="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:c,spacingFactor:l=1.3,compactSpacingScale:d,minZoom:u,maxZoom:h,initialViewport:p,containerStyle:m,lineColor:g,drawMode:y,dragMode:b,multiSelect:v,isPerformanceMode:w,disableAnimations:x=!1}=e,[C,S]=j.useState(null),E=j.useMemo(()=>C?(C.mode==="connections"?rf:Zu)(C.id,r,t):null,[C,r,t]),R=i==="auto"||i==="properties",P=j.useMemo(()=>t.filter(A=>Pd(A,i)&&(!E||E.has(A.source)&&E.has(A.target))),[t,i,E]),I=j.useMemo(()=>C1(r,t,i,s,E),[r,t,i,s,E]),M=j.useRef(I);M.current=I;const k=j.useRef(e);k.current=e;const _=j.useRef(null),N=j.useRef(null),O=j.useRef(null),V=j.useRef(null),T=j.useMemo(()=>new Qj(p,u,h),[]);j.useEffect(()=>{T.minZoom=u,T.maxZoom=h},[T,u,h]),j.useLayoutEffect(()=>{T.setAnimationsDisabled(x)},[T,x]);const Z=j.useRef(new Map),ue=j.useRef(new Map),K=j.useRef(new Map),ee=j.useRef(null),[H,ae]=j.useState(new Map),q=j.useCallback((A,L)=>{ae(z=>{if(JSON.stringify(z.get(A))===JSON.stringify(L))return z;const J=new Map(z);return L?J.set(A,L):J.delete(A),J})},[]),[D,G]=j.useState(new Map),B=j.useRef(D),se=j.useCallback((A,L)=>{G(z=>{if(JSON.stringify(z.get(A)??[])===JSON.stringify(L))return z;const J=new Map(z);return L.length?J.set(A,L):J.delete(A),J})},[]),[te,le]=j.useState(()=>new Map),ne=j.useRef(te);ne.current=te;const[ce,xe]=j.useState(new Map),he=j.useRef(ce),U=()=>{he.current=new Map,xe(he.current)},re=j.useRef(new Map(Object.entries(e.fixedNodePositions??{}))),fe=j.useRef(new Set(Object.keys(e.fixedNodePositions??{}))),we=j.useRef(null),ie=j.useRef(!1),[Ce,$e]=j.useState(0),Ue=j.useRef(),Ve=j.useRef(),tt=j.useRef(null),ye=j.useRef(),Ae=j.useRef(!1),Le=j.useRef(null),be=j.useRef(null),Xe=j.useRef(),ut=j.useRef(l),Re=s,Ke=j.useRef(Re),[lt,Je]=j.useState(!0),[mt,At]=j.useState(!!((Su=e.initialNodeGrid)!=null&&Su.enabled)),[Jr,Tr]=j.useState([]),rt=j.useRef((ju=e.initialNodeGrid)!=null&&ju.enabled?{options:{...e.initialNodeGrid.options,animate:!1},order:[...e.initialNodeGrid.order??e.initialNodeGrid.options.order??r.map(A=>A.id)],previousPositions:new Map,previousViewport:p,previousSize:{w:0,h:0},ready:!1}:null),[We,Qt]=j.useState(null),ft=j.useRef(null);ft.current=E;const qt=j.useRef(1);qt.current=(C==null?void 0:C.mode)==="connections"?1.25:1;const dr=j.useRef(null),De=j.useRef(r),Ht=j.useRef([]),Lt=j.useRef(!1),ur=()=>{var A;(A=tt.current)==null||A.call(tt),tt.current=null,ye.current=void 0},F=()=>{be.current=null,Ht.current.length&&!re.current.size&&(Lt.current=!0),!ie.current&&k.current.fitOnInit!==!1&&(Ae.current=!0),clearTimeout(Ve.current),Ve.current=setTimeout(()=>{ie.current=ne.current.size>0,$e(A=>A+1)},rE)},$=(A,L,z,J=F,pe)=>{ur();const _e=new Map(ne.current),Se=new Map([...Z.current,...he.current]);tt.current=Jb(L,je=>{const Qe=new Map;if(A.forEach((qe,Be)=>{const Pe=_e.get(Be);Qe.set(Be,re.current.get(Be)??(Pe?{x:Pe.x+(qe.x-Pe.x)*je,y:Pe.y+(qe.y-Pe.y)*je}:qe))}),ne.current=Qe,le(Qe),pe){const qe=new Map;for(const[Be,Pe]of pe){const X=Se.get(Be)??Pe;qe.set(Be,{w:X.w+(Pe.w-X.w)*je,h:X.h+(Pe.h-X.h)*je})}he.current=qe,xe(qe)}z==null||z(je)},J)},oe=()=>{var Be;if(clearTimeout(Ue.current),rt.current){pt.arrangeNodesInGrid(rt.current.options);return}he.current.size&&U();const A=k.current,L=qt.current,z=M.current,J=new Set(A.nodes.filter(Pe=>Pe.label===void 0).map(Pe=>Pe.id)),pe=z.nodes.map(Pe=>{const X=ue.current.get(Pe.id);X&&(X.offsetWidth||X.offsetHeight)&&Z.current.set(Pe.id,{w:X.offsetWidth,h:X.offsetHeight});const Y=Z.current.get(Pe.id)||ao;return{id:Pe.id,parent:Pe.parent,width:Y.w,height:Y.h,hasBody:J.has(Pe.id)}});let _e;try{const Pe=A.compactPropertyLayout,X=A.edgeMode!=="nodes"&&A.edgeMode!=="workflow",Y=z.edges.map(ge=>({...ge,connectorClearance:Pe?X&&(ge.sourceProperty!==void 0||ge.targetProperty!==void 0)?w1:v1:0}));_e=Vj(pe,Y,{edgeLabelFontSize:A.edgeMode==="nodes"||A.edgeMode==="workflow"?ex:yo,rankDir:A.direction,compact:Pe,nodeAlignment:A.nodeAlignment,rankSep:A.rankSep*L,edgeSep:A.edgeSep*L,nodeSep:5*L,spacingFactor:A.spacingFactor??1.3,compactSpacingScale:(A.compactSpacingScale??(A.spacingFactor??1.3)/1.3)*L})}catch(Pe){console.warn("[flow-sdk] layout failed",Pe);return}const Se=[...re.current].find(([Pe])=>_e.has(Pe)),je=Se?{id:Se[0],position:Se[1]}:be.current?null:we.current;we.current=null;const Qe=je&&_e.get(je.id);if(je&&Qe){const Pe={x:je.position.x-Qe.x,y:je.position.y-Qe.y};_e=new Map([..._e].map(([X,Y])=>[X,{x:Y.x+Pe.x,y:Y.y+Pe.y}]))}for(const[Pe,X]of re.current)A.nodes.some(Y=>Y.id===Pe)?_e.set(Pe,X):re.current.delete(Pe);if(be.current){const Pe=JSON.stringify([pe,[..._e],T.size,A.isPerformanceMode,A.disableAnimations]);if(((Be=Xe.current)==null?void 0:Be.focus)===be.current&&Xe.current.geometry===Pe)return;Xe.current={focus:be.current,geometry:Pe}}else Xe.current=void 0;const qe=T.coordinate(()=>{var Pe;return(Pe=be.current)==null?void 0:Pe.call(be,_e)});$(_e,ie.current&&!A.isPerformanceMode&&!A.disableAnimations,qe)},me=j.useCallback(()=>{clearTimeout(Ve.current),clearTimeout(Ue.current),Ue.current=setTimeout(oe,k.current.layoutDebounce)},[]);j.useLayoutEffect(()=>{const A=e.fixedNodePositions??{};let L=!1;for(const z of fe.current)Object.prototype.hasOwnProperty.call(A,z)||(L=re.current.delete(z)||L);for(const[z,J]of Object.entries(A)){if(!r.some(_e=>_e.id===z)||!J||![J.x,J.y].every(Number.isFinite))continue;const pe=re.current.get(z);((pe==null?void 0:pe.x)!==J.x||(pe==null?void 0:pe.y)!==J.y)&&(re.current.set(z,{...J}),L=!0)}fe.current=new Set(Object.keys(A)),L&&me()},[e.fixedNodePositions,r,me]),j.useLayoutEffect(()=>{const A=new Map(De.current.map(L=>[L.id,L]));r.some(L=>{var z;return((z=A.get(L.id))==null?void 0:z.collapsed)===!0&&!L.collapsed})&&(Ht.current=r.filter(L=>!A.has(L.id)).map(L=>L.id)),De.current=r,ut.current!==l&&ne.current.size>0&&(ie.current=!0,Ae.current=!1,clearTimeout(Ve.current)),ut.current=l,Ke.current!==Re&&(Ae.current=!Le.current),Ke.current=Re,me()},[r,t,I.nodes,I.edges,Re,n,o,a,c,me,l,d,x,e.nodeGridSpacing]),j.useEffect(()=>()=>{clearTimeout(Ue.current),clearTimeout(Ve.current),ur()},[]);const Ee=j.useCallback((A,L)=>{var z,J;if(!ee.current&&typeof ResizeObserver<"u"&&(ee.current=new ResizeObserver(pe=>{let _e=!1;for(const Se of pe){const je=K.current.get(Se.target);if(!je||he.current.has(je))continue;const Qe=Se.target,qe=Qe.offsetWidth,Be=Qe.offsetHeight;if(!qe&&!Be)continue;const Pe=Z.current.get(je);if(Pe&&Pe.w===qe&&Pe.h===Be)continue;const X=ne.current.get(je);Pe&&X&&ie.current&&!we.current&&(we.current={id:je,position:{...X}}),Z.current.set(je,{w:qe,h:Be}),_e=!0}_e&&me()})),L){ue.current.set(A,L),K.current.set(L,A),(z=ee.current)==null||z.observe(L);const pe=L.offsetWidth,_e=L.offsetHeight;!he.current.has(A)&&(pe||_e)&&Z.current.set(A,{w:pe,h:_e})}else{const pe=ue.current.get(A);pe&&((J=ee.current)==null||J.unobserve(pe),K.current.delete(pe)),ue.current.delete(A),Z.current.delete(A),B.current.has(A)&&se(A,[])}me()},[me,se]);j.useEffect(()=>()=>{var A;return(A=ee.current)==null?void 0:A.disconnect()},[]);const Ie=A=>{var J;const L=(J=k.current.nodes.find(pe=>pe.id===A))==null?void 0:J.label;if(!L)return;const z=k.current.containerStyle(A);return{w:Ao(L,`bold ${z.fontSize}px ${_r}`)+2*nE,h:0}},Me=j.useMemo(()=>{const A=new Map;for(const L of r)L.label&&A.set(L.id,L.label);return A},[r]),Ye=j.useMemo(()=>Ad(I.nodes,te,new Map([...Z.current,...ce]),A=>m(A).padding,Ie,ce),[I.nodes,te,m,Me,ce]),et=j.useRef(Ye);et.current=Ye;const ze=j.useCallback(A=>{const L=et.current.get(A);if(L)return a1(L);const z=ne.current.get(A);if(!z)return;const J=he.current.get(A)||Z.current.get(A)||ao;return{x:z.x,y:z.y,w:J.w,h:J.h}},[]),ct=j.useMemo(()=>{const A=new Map;for(const L of r){const z=ze(L.id);z&&A.set(L.id,z)}return g1(D,A,H,t,n)},[D,r,te,Ye,H,t,n,ze]);B.current=ct;const ht=(A,L)=>{var pe;if(!R||L===void 0)return;const z=(pe=ct.get(A))==null?void 0:pe.find(_e=>_e.property===L),J=ze(A);return z&&!z.anchor&&J?J.y-J.h/2+z.top+z.height/2:void 0},wt=(A,L)=>{var pe,_e;if(L===void 0)return;const z=(_e=(pe=ct.get(A))==null?void 0:pe.find(Se=>Se.property===L))==null?void 0:_e.anchor,J=ze(A);return z&&J?{x:J.x-J.w/2+z.x,y:J.y-J.h/2+z.y,side:z.side}:void 0},St=(A,L)=>{const z=ze(A),J=H.get(A);return z&&J&&!Ye.has(A)&&ht(A,L)===void 0?qn(z,(n==="TB"||n==="BT")&&J.captionBottom!==void 0?{...J,height:Math.max(J.height,J.captionBottom-J.top),outline:void 0}:J):z},Rt=()=>{const A=[];ne.current.forEach((L,z)=>{if(et.current.has(z))return;const J=ze(z);J&&A.push(ir(J))}),et.current.forEach(L=>A.push(L));try{for(const L of[N.current,O.current]){const z=L==null?void 0:L.getBBox();z&&z.width>0&&z.height>0&&A.push({x1:z.x,y1:z.y,x2:z.x+z.width,y2:z.y+z.height})}}catch{}return ei(A)},Mt=()=>{var z,J;const{pan:A,zoom:L}=T;V.current&&(V.current.style.transform=`translate3d(${A.x}px, ${A.y}px, 0) scale(${L})`),(z=N.current)==null||z.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${L})`),(J=O.current)==null||J.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${L})`)};j.useEffect(()=>{Mt();let A=null,L;const z=T.onChange(()=>{Mt();const J=_.current;J&&(J.classList.add("flow-sdk-busy"),clearTimeout(L),L=setTimeout(()=>J.classList.remove("flow-sdk-busy"),150)),A===null&&(A=requestAnimationFrame(()=>{var pe,_e;A=null,(_e=(pe=k.current).onViewportChange)==null||_e.call(pe,T.state)}))});return()=>{z(),clearTimeout(L),A!==null&&cancelAnimationFrame(A)}},[]),j.useLayoutEffect(()=>{const A=_.current;if(!A)return;const L=()=>{var Se;if(!A.getClientRects().length)return;let J=A.clientWidth,pe=A.clientHeight;pe||(pe=Math.max(0,window.innerHeight-A.getBoundingClientRect().top-100),pe&&(A.style.height=`${pe}px`)),J||(J=window.innerWidth,J&&(A.style.width=`${J}px`));const _e=T.size.w!==J||T.size.h!==pe;T.size={w:J,h:pe},_e&&((Se=rt.current)!=null&&Se.options.fill)&&(!ie.current&&J>0&&pe>0?oe():me()),!ie.current&&!ne.current.size&&k.current.fitOnInit!==!1&&(T.set({x:J/2,y:pe/2}),Mt())};if(L(),typeof ResizeObserver>"u")return;const z=new ResizeObserver(L);return z.observe(A),()=>z.disconnect()},[T]),j.useLayoutEffect(()=>{if(Lt.current){Lt.current=!1;const L=Ht.current.flatMap(J=>{const pe=ze(J);return pe?[ir(pe)]:[]});Ht.current=[];const z=ei(L);if(z){Ae.current=!1,T.center(z,k.current.animateViewport);return}}if(!Ae.current)return;Ae.current=!1;const A=Rt();A&&(T.fit(A,50,ie.current&&k.current.animateViewport),ie.current||Mt())},[te]);const pt=j.useMemo(()=>{const A=X=>{const Y=k.current;if(Y.nodeGridSpacing!=="layout")return X;const ge=Y.direction==="LR"||Y.direction==="RL";return{...X,gaps:{x:ge?Y.rankSep:Y.edgeSep,y:ge?Y.edgeSep:Y.rankSep}}},L=()=>{const X=k.current,Y=M.current.nodes.filter(ge=>ar(ge.id,X.edges,X.edgeMode)&&(!ft.current||ft.current.has(ge.id)));return{nodes:Y,positions:ne.current,sizes:new Map(Y.map(ge=>[ge.id,Z.current.get(ge.id)??ao])),padding:ge=>k.current.containerStyle(ge).padding,minSize:Ie,fixedIds:new Set(re.current.keys()),viewportSize:{...T.size}}},z=X=>Zu(X,k.current.nodes,k.current.edges),J=(X,Y=!0,ge=()=>{},de,Fe,ve=!1)=>{clearTimeout(Ue.current),clearTimeout(Ve.current),ve||(be.current=null),Le.current=null,Ae.current=!1,Ht.current=[],Lt.current=!1;const ke=Y&&!k.current.isPerformanceMode&&!k.current.disableAnimations,Ze=T.coordinate(()=>{var nt;de?de(ke):ve&&((nt=be.current)==null||nt.call(be,X))});$(new Map([...X].map(([nt,st])=>[nt,{...st}])),ke,Ze,ge,Fe)},pe=(X,Y=50,ge=k.current.animateViewport,de=1,Fe=!1,ve)=>{const ke=Ze=>{const nt=M.current,st=X??new Set(nt.nodes.map(bt=>bt.id)),rr=new Set(nt.nodes.map(bt=>bt.parent).filter(Boolean));if(!Ze&&(!X||[...X].some(bt=>rr.has(bt))))return;const hr=Ze&&Ad(nt.nodes,Ze,Z.current,bt=>k.current.containerStyle(bt).padding,Ie),vn=new Map([...st].flatMap(bt=>{const or=hr==null?void 0:hr.get(bt);if(or)return[[bt,or]];const Ut=Ze==null?void 0:Ze.get(bt),vr=Z.current.get(bt)||ao,Pu=Ut?{...Ut,...vr}:ze(bt);return Pu?[[bt,ir(Pu)]]:[]}));let nr=ei([...vn.values()]);if(!nr)return;const xr=ve?vn.get(ve):void 0;if(xr){const bt=(xr.x1+xr.x2)/2,or=(xr.y1+xr.y2)/2,Ut=Math.max(bt-nr.x1,nr.x2-bt),vr=Math.max(or-nr.y1,nr.y2-or);nr={x1:bt-Ut,x2:bt+Ut,y1:or-vr,y2:or+vr}}Ae.current=!1,Ht.current=[],Lt.current=!1,T.fit(nr,Number.isFinite(Y)?Math.max(0,Y):50,ge,de)};be.current=Fe?ke:null,Fe||ke(ne.current)},_e=(X,Y,ge,de)=>{var ve;if(!ze(X))return;const Fe=Y==="connections"?je(X):z(X);if(Y==="connections"&&qt.current===1.25&&((ve=ft.current)==null?void 0:ve.size)===Fe.size&&[...Fe].every(ke=>ft.current.has(ke))){S({id:X,mode:Y});return}dr.current||(dr.current={pan:{...T.pan},zoom:T.zoom}),ft.current=Fe,k.current.compactPropertyLayout&&(Ae.current=!1,Le.current=()=>pe(ft.current??Fe,ge,de)),S({id:X,mode:Y}),k.current.compactPropertyLayout||pe(Fe,ge,de)},Se=X=>{Le.current?Le.current=X:X()},je=X=>rf(X,k.current.nodes,k.current.edges),Qe=(X=>{var Y,ge,de;if(X===void 0)return T.zoom;X<T.zoom&&((Y=rt.current)!=null&&Y.options.fill)&&!k.current.readOnly&&((de=(ge=k.current).onNodeGridZoomOut)==null?void 0:de.call(ge,rt.current.options))===!0||(be.current=null,T.set(void 0,X))}),qe=((X,Y=!1)=>{if(X===void 0)return T.pan;be.current=null,Y?T.transition({pan:X,zoom:T.zoom},!0):T.set(X)}),Be=(X,Y)=>{var de;const ge=(de=_.current)==null?void 0:de.getBoundingClientRect();return{x:X-((ge==null?void 0:ge.left)??0),y:Y-((ge==null?void 0:ge.top)??0)}},Pe=(X=0,Y=k.current.animateViewport,ge=!1)=>{if(ge){pe(void 0,X,Y,1,!0);return}be.current=null,Se(()=>{const de=Rt();de&&T.fit(de,X,Y)})};return{zoom:Qe,pan:qe,setEdgesVisible:Je,focusNode:(X,Y,ge,de)=>Se(()=>pe(new Set([X]),Y,ge,.6,de)),focusBranch:(X,Y,ge,de,Fe=!1,ve=1)=>Se(()=>pe(z(X),Y,ge,ve,de,Fe?X:void 0)),focusConnections:(X,Y,ge,de)=>Se(()=>pe(je(X),Y,ge,1,de)),isolateConnections:(X,Y,ge)=>_e(X,"connections",Y,ge),isolateBranch:(X,Y,ge)=>_e(X,"branch",Y,ge),restoreView:(X=k.current.animateViewport,Y,ge=!1)=>{be.current=null;const de=ge&&!rt.current&&!ft.current,Fe=k.current.compactPropertyLayout&&!!ft.current;ft.current=null,S(null);const ve=Y??dr.current;dr.current=null,ve&&de?(Ae.current=!1,Le.current=null,we.current=null,be.current=()=>T.transition(ve,X),me()):Fe?Le.current=()=>{ve&&T.transition(ve,X)}:ve&&Se(()=>T.transition(ve,X))},zoomAt:(X,Y)=>{var ge,de,Fe;X<T.zoom&&((ge=rt.current)!=null&&ge.options.fill)&&!k.current.readOnly&&((Fe=(de=k.current).onNodeGridZoomOut)==null?void 0:Fe.call(de,rt.current.options))===!0||(be.current=null,T.zoomAt(X,Y))},fit:Pe,centerAndFit:Pe,center:(X=k.current.animateViewport)=>{be.current=null;const Y=Rt();Y&&T.center(Y,X)},clientToModel:(X,Y)=>T.renderedToModel(Be(X,Y)),modelToClient:X=>{var de;const Y=(de=_.current)==null?void 0:de.getBoundingClientRect(),ge=T.modelToRendered(X);return{x:ge.x+((Y==null?void 0:Y.left)??0),y:ge.y+((Y==null?void 0:Y.top)??0)}},getNodeBox:X=>ze(X),detectNodeCollisions:X=>{const Y=L();return av({...Y,sizes:new Map([...Y.sizes,...he.current]),fixedSizes:he.current},X)},resolveNodeCollisions:(X={})=>{const Y=Uj(L(),X);return Y.movedNodeIds.length&&J(Y.positions,X.animate),Y},arrangeNodesInGrid:(X={})=>{const Y=L(),ge=rt.current;if(ge){Y.positions=new Map(Y.positions);for(const st of Y.nodes)Y.positions.has(st.id)||Y.positions.set(st.id,T.renderedToModel({x:T.size.w/2,y:T.size.h/2}));const ke=new Set(Y.nodes.map(st=>st.id));ge.order=ge.order.filter(st=>ke.has(st));const Ze=new Set(ge.order);ge.order.push(...Y.nodes.filter(st=>!Ze.has(st.id)).map(st=>st.id));const nt=new Map(ge.order.map((st,rr)=>[st,rr]));Y.nodes=[...Y.nodes].sort((st,rr)=>nt.get(st.id)-nt.get(rr.id))}const de=bd(Y,A(X)),Fe=de.sizes?JSON.stringify([[...de.positions],[...de.sizes]]):void 0;if(Fe&&Fe===ye.current&&X.animate!==!1&&!be.current)return de;Tr(de.dividers??[]),ge&&(ge.ready=!1);const ve=()=>{ge&&(ge.ready=!0),ge&&Y.nodes.length&&!ie.current&&(ie.current=!0,k.current.fitOnInit!==!1&&!X.fill?pt.centerAndFit(50,!1):k.current.fitOnInit===!1&&T.transition(p,!1)),$e(ke=>ke+1)};return!de.sizes&&he.current.size&&U(),Y.nodes.some(ke=>!ne.current.has(ke.id))||de.movedNodeIds.length||de.bounds||be.current?J(de.positions,X.animate,ve,de.bounds&&(!ge||!he.current.size)?ke=>T.transition({zoom:1,pan:{x:0,y:0}},ke):void 0,de.sizes,!!ge&&!de.bounds):ve(),ye.current=Fe,de},setNodeGridMode:(X,Y={})=>{var ge,de,Fe,ve;if(Y.order&&(!Array.isArray(Y.order)||Y.order.some(ke=>typeof ke!="string")||new Set(Y.order).size!==Y.order.length))throw new Error("Invalid grid node order.");if(X){bd(L(),A(Y));const ke=!rt.current||rt.current.options.fill&&!Y.fill;be.current=null,rt.current||(rt.current={options:Y,order:L().nodes.map(Ze=>Ze.id),previousPositions:new Map([...ne.current].map(([Ze,nt])=>[Ze,{...nt}])),previousViewport:{zoom:T.zoom,pan:{...T.pan}},previousSize:{...T.size},ready:!1}),ke&&pt.centerAndFit(80,Y.animate,!0),Y.order&&(rt.current.order=[...Y.order]),rt.current.options={...Y},At(!0),pt.arrangeNodesInGrid(Y),(de=(ge=k.current).onNodeGridModeChange)==null||de.call(ge,{...Y,order:[...rt.current.order]})}else{const ke=rt.current;if(!ke)return;if(T.size.w===ke.previousSize.w&&T.size.h===ke.previousSize.h&&ne.current.size===ke.previousPositions.size&&[...ne.current.keys()].every(st=>ke.previousPositions.has(st))?be.current=()=>T.transition(ke.previousViewport,Y.animate!==!1&&!k.current.disableAnimations&&!k.current.isPerformanceMode):pt.centerAndFit(80,Y.animate,!0),rt.current=null,At(!1),U(),(ve=(Fe=k.current).onNodeGridModeChange)==null||ve.call(Fe,null),Qt(null),!ke.previousPositions.size){me();return}const nt=new Map([...ne.current].map(([st,rr])=>[st,ke.previousPositions.get(st)??rr]));J(nt,Y.animate,void 0,void 0,void 0,!0)}},swapGridNodes:(X,Y,ge)=>{var vn,nr,xr,bt,or;const de=rt.current;if(!de||!de.ready||k.current.readOnly||X===Y)return!1;const Fe=L(),ve=Fe.nodes.find(Ut=>Ut.id===X),ke=Fe.nodes.find(Ut=>Ut.id===Y);if(!ve||!ke||ve.parent!==ke.parent)return!1;const Ze=bd(Fe,A(de.options));if(Ze.skippedNodeIds.includes(X)||Ze.skippedNodeIds.includes(Y))return!1;const nt=de.order.indexOf(X),st=de.order.indexOf(Y);if(nt<0||st<0)return!1;[de.order[nt],de.order[st]]=[de.order[st],de.order[nt]],be.current=null,de.options={...de.options,order:[...de.order]};const rr=ve.parent??"canvas",hr=(nr=(vn=de.options.adjustment)==null?void 0:vn.sections)==null?void 0:nr[rr];return hr!=null&&hr.members&&(de.options={...de.options,adjustment:{...de.options.adjustment,sections:{...(xr=de.options.adjustment)==null?void 0:xr.sections,[rr]:{...hr,members:hr.members.map(Ut=>Ut.map(vr=>vr===X?Y:vr===Y?X:vr))}}}}),pt.arrangeNodesInGrid({...de.options,animate:ge??de.options.animate}),(or=(bt=k.current).onNodeGridModeChange)==null||or.call(bt,{...de.options}),!0},setNodePosition:(X,Y,ge)=>{var Fe,ve,ke,Ze;if(!ne.current.has(X)||Y&&(!Number.isFinite(Y.x)||!Number.isFinite(Y.y)))return!1;if(ur(),!Y)return re.current.delete(X),(ve=(Fe=k.current).onFixedNodePositionsChange)==null||ve.call(Fe,Object.fromEntries(re.current)),me(),!0;const de=new Map(ne.current);return de.set(X,{...Y}),(ge==null?void 0:ge.persist)===!1?re.current.delete(X):re.current.set(X,{...Y}),ne.current=de,le(de),(ge==null?void 0:ge.persist)!==!1&&((Ze=(ke=k.current).onFixedNodePositionsChange)==null||Ze.call(ke,Object.fromEntries(re.current))),(ge==null?void 0:ge.persist)===!1&&me(),!0},getFixedNodePositions:()=>Object.fromEntries([...re.current].map(([X,Y])=>[X,{...Y}])),onViewportChange:X=>T.onChange(X)}},[]);j.useEffect(()=>{var A,L;return(L=(A=k.current).onInit)==null||L.call(A,pt),()=>T.cancelAnimation()},[pt]),j.useEffect(()=>{var A,L;if(Ce>0){const z=Le.current;Le.current=null,z==null||z(),(L=(A=k.current).onLayoutComplete)==null||L.call(A,pt)}},[pt,Ce]);const gt=j.useRef(null),vt=j.useRef(new Map),er=j.useRef(!1),[tr,Ft]=j.useState(null),[it,br]=j.useState(null),Ir=A=>{const L=_.current.getBoundingClientRect();return{x:(A.clientX-L.left)*(_.current.clientWidth/L.width||1),y:(A.clientY-L.top)*(_.current.clientHeight/L.height||1)}},fr=(A,L)=>{const z=k.current.nodes;for(let J=z.length-1;J>=0;J--){const pe=z[J].id;if(!ar(pe,k.current.edges,k.current.edgeMode)||ft.current&&!ft.current.has(pe)||pe===L||et.current.has(pe))continue;const _e=ze(pe);if(_e&&Xu(A,ir(_e)))return pe}for(const[J,pe]of et.current)if(ar(J,k.current.edges,k.current.edgeMode)&&!(ft.current&&!ft.current.has(J))&&J!==L&&Xu(A,pe))return J;return null},mn=(A,L)=>{const z=k.current.nodes.find(je=>je.id===A),J=ze(A);if(!z||!J)return null;const pe=ir({...J,x:J.x+L.x,y:J.y+L.y});let _e=null,Se=0;for(const je of k.current.nodes){if(je.id===A||je.parent!==z.parent||re.current.has(je.id)||et.current.has(je.id)||!ar(je.id,k.current.edges,k.current.edgeMode)||ft.current&&!ft.current.has(je.id))continue;const Qe=ze(je.id);if(!Qe)continue;const qe=ir(Qe),Be=Math.max(0,Math.min(pe.x2,qe.x2)-Math.max(pe.x1,qe.x1))*Math.max(0,Math.min(pe.y2,qe.y2)-Math.max(pe.y1,qe.y1));Be>Se&&(Se=Be,_e=je.id)}return _e},bn=(A,L)=>{const z=rt.current;if(!(z!=null&&z.ready)||k.current.readOnly)return;const J=k.current.nodes.filter(Be=>ar(Be.id,k.current.edges,k.current.edgeMode)&&(!ft.current||ft.current.has(Be.id))),pe=J.find(Be=>Be.id===A);if(!pe)return;const _e=_.current,Se=T.zoom*(_e&&_e.clientWidth?_e.getBoundingClientRect().width/_e.clientWidth:1),je=24/Se;let Qe;for(const Be of J){if(Be.id===A||Be.parent!==pe.parent)continue;const Pe=ze(Be.id);if(!Pe)continue;const X=ir(Pe),Y=Math.min(Pe.w/4,je),ge=Math.min(Pe.h/4,je),de=3/Se,Fe=[];if(L.y>X.y1+ge&&L.y<X.y2-ge)for(const ve of["before","after"]){const ke=ve==="before"?X.x1:X.x2,Ze=Math.abs(L.x-ke),nt=ve==="before"?L.x<ke:L.x>ke;Ze<=(nt?je:Y)&&Fe.push({side:ve,distance:Ze,marker:{x1:ke-de/2,x2:ke+de/2,y1:X.y1,y2:X.y2}})}if(L.x>=X.x1&&L.x<=X.x2)for(const ve of["above","below"]){const ke=ve==="above"?X.y1:X.y2,Ze=Math.abs(L.y-ke),nt=ve==="above"?L.y<ke:L.y>ke;Ze<=(nt?je:ge)&&Fe.push({side:ve,distance:Ze,marker:{x1:X.x1,x2:X.x2,y1:ke-de/2,y2:ke+de/2}})}for(const ve of Fe)(!Qe||ve.distance<Qe.distance)&&(Qe={id:Be.id,...ve})}if(!Qe)return;const qe=Gj({nodes:J,positions:ne.current,sizes:new Map([...Z.current,...he.current]),fixedSizes:he.current,padding:Be=>k.current.containerStyle(Be).padding,minSize:Ie,fixedIds:new Set(re.current.keys())},z.options,A,Qe.id,Qe.side);return qe?{options:qe,marker:Qe.marker}:void 0},Zr=(A,L)=>{if(k.current.edgeMode==="nodes"||k.current.edgeMode==="workflow")return null;const z=k.current.direction==="RL",J=Math.max(16,6/T.zoom);let pe=null;for(const _e of[...k.current.nodes].reverse()){if(!ar(_e.id,k.current.edges,k.current.edgeMode)||ft.current&&!ft.current.has(_e.id))continue;const Se=ze(_e.id),je=B.current.get(_e.id);if(!Se||!je||et.current.has(_e.id))continue;const Qe=Se.x+(L==="source"!==z?1:-1)*Se.w/2;for(const qe of je){if(qe.role&&qe.role!==L)continue;const Be=Se.y-Se.h/2+qe.top,Pe=Math.hypot(A.x-(qe.anchor?Se.x-Se.w/2+qe.anchor.x:Qe),A.y-Be-qe.height/2);if(!qe.anchor&&A.x>=Se.x-Se.w/2&&A.x<=Se.x+Se.w/2&&A.y>=Be&&A.y<=Be+qe.height)return{nodeId:_e.id,property:qe.property};Pe<=J&&(!pe||Pe<pe.distance)&&(pe={nodeId:_e.id,property:qe.property,distance:Pe})}}return pe},mv=A=>{var je,Qe;if(!A.currentTarget.contains(A.target)||(gt.current||(er.current=!1),A.target.closest(".flow-sdk-canvas")!==A.currentTarget)||A.button!==0)return;const L=A.target;if(L.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const z=k.current,J=Ir(A);if(A.pointerType==="touch"){vt.current.set(A.pointerId,J);const qe=Rm(vt.current);if(qe){Qt(null),gt.current={kind:"pinch",distance:qe.distance,zoom:T.zoom,anchor:T.renderedToModel(qe.center)},br(null),Ft(null),er.current=!0;for(const Be of vt.current.keys())A.currentTarget.setPointerCapture(Be);return}}if(gt.current)return;if(k.current.readOnly){z.dragMode&&(gt.current={kind:"pan",pointerId:A.pointerId,start:J,pan0:T.pan,moved:!1},A.currentTarget.setPointerCapture(A.pointerId));return}const pe=!rt.current||!!z.nodeGridConnections,_e=z.drawHandles&&L.closest(".flow-sdk-handle"),Se=z.drawHandles&&L.closest(".flow-sdk-property-port");if((!pe||!_e&&!Se&&(!z.drawMode||A.shiftKey))&&(rt.current||A.shiftKey&&(z.onNodeGridDrop||z.onNodeParentChange))){if(rt.current&&!rt.current.ready||L.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]"))return;const qe=(je=L.closest("[data-node-id]"))==null?void 0:je.dataset.nodeId;if(qe&&!re.current.has(qe)){L.setPointerCapture(A.pointerId),gt.current={kind:"grid",pointerId:A.pointerId,captureTarget:L,source:qe,start:J,moved:!1};return}if(qe)return}if(pe&&(z.drawMode||_e||Se)){const qe=T.renderedToModel(J),Be=z.drawMode?Zr(qe,"source"):null,Pe=Se||_e,X=Pe?(Qe=Pe.closest("[data-node-id]"))==null?void 0:Qe.dataset.nodeId:(Be==null?void 0:Be.nodeId)??fr(qe),Y=Se?Se.dataset.property:Be==null?void 0:Be.property;if(X){gt.current={kind:"draw",pointerId:A.pointerId,source:X,sourceProperty:Y,reverse:(Se==null?void 0:Se.dataset.portRole)==="target",startClient:{x:A.clientX,y:A.clientY}},er.current=!0,br({source:X,sourceProperty:Y,point:qe,target:null}),A.currentTarget.setPointerCapture(A.pointerId);return}}L.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(be.current=null,z.multiSelect?gt.current={kind:"box",pointerId:A.pointerId,start:J,current:J}:z.dragMode?gt.current={kind:"pan",pointerId:A.pointerId,start:J,pan0:T.pan,moved:!1}:gt.current={kind:"tap",pointerId:A.pointerId,start:J,moved:!1},A.currentTarget.setPointerCapture(A.pointerId))},bv=A=>{var J,pe,_e;const L=gt.current;if(!L)return;const z=Ir(A);if(vt.current.has(A.pointerId)&&vt.current.set(A.pointerId,z),L.kind==="pinch"){const Se=Rm(vt.current);if(!Se)return;const je=Math.max(T.minZoom,Math.min(T.maxZoom,L.zoom*Se.distance/L.distance));if(je<T.zoom&&((J=rt.current)!=null&&J.options.fill)&&((_e=(pe=k.current).onNodeGridZoomOut)==null?void 0:_e.call(pe,rt.current.options))===!0)return;T.set({x:Se.center.x-L.anchor.x*je,y:Se.center.y-L.anchor.y*je},je);return}if(L.pointerId===A.pointerId)switch(L.kind){case"grid":{const Se={x:z.x-L.start.x,y:z.y-L.start.y};if(!L.moved&&Math.hypot(Se.x,Se.y)<=vd)return;L.moved||(ur(),be.current=null,T.cancelAnimation()),L.moved=!0,er.current=!0,A.preventDefault();const je={x:Se.x/T.zoom,y:Se.y/T.zoom},Qe=!A.shiftKey&&z.x>=0&&z.y>=0&&z.x<=T.size.w&&z.y<=T.size.h?bn(L.source,T.renderedToModel(z)):void 0;Qt({source:L.source,offset:je,target:A.shiftKey||Qe?null:mn(L.source,je),shiftKey:A.shiftKey,insertion:Qe});break}case"pan":{const Se=z.x-L.start.x,je=z.y-L.start.y;if(!L.moved&&Math.hypot(Se,je)<=vd)return;L.moved=!0,er.current=!0,T.set({x:L.pan0.x+Se,y:L.pan0.y+je});break}case"tap":{Math.hypot(z.x-L.start.x,z.y-L.start.y)>vd&&(L.moved=!0);break}case"box":{er.current=!0,L.current=z,Ft({x1:Math.min(L.start.x,z.x),y1:Math.min(L.start.y,z.y),x2:Math.max(L.start.x,z.x),y2:Math.max(L.start.y,z.y)});break}case"draw":{const Se=T.renderedToModel(z),je=Zr(Se,L.reverse?"source":"target");br(L.reverse&&je?{source:je.nodeId,sourceProperty:je.property,point:Se,target:L.source,targetProperty:L.sourceProperty}:{source:L.source,sourceProperty:L.sourceProperty,point:Se,target:(je==null?void 0:je.nodeId)??fr(Se,L.source),targetProperty:je==null?void 0:je.property});break}}},vu=(A,L)=>{var pe,_e,Se,je,Qe,qe,Be,Pe,X,Y,ge;vt.current.delete(A.pointerId);const z=gt.current;if(!z)return;if(z.kind==="pinch"){const de=[...vt.current][0];gt.current=de&&k.current.dragMode&&!L?{kind:"pan",pointerId:de[0],start:de[1],pan0:T.pan,moved:!0}:null;return}if(z.pointerId!==A.pointerId)return;gt.current=null;try{(z.kind==="grid"?z.captureTarget:A.currentTarget).releasePointerCapture(A.pointerId)}catch{}const J=k.current;switch(L=L||!!J.readOnly,z.kind){case"grid":{if(Qt(null),L||!z.moved)break;const de=Ir(A);if(!A.shiftKey&&de.x>=0&&de.y>=0&&de.x<=T.size.w&&de.y<=T.size.h){const ve=bn(z.source,T.renderedToModel(de));if(ve){pt.setNodeGridMode(!0,{...ve.options,animate:!1});break}}if(((pe=J.onNodeGridDrop)==null?void 0:pe.call(J,z.source,{x:A.clientX,y:A.clientY},{shiftKey:A.shiftKey,ctrlKey:A.ctrlKey,metaKey:A.metaKey,altKey:A.altKey}))===!0||de.x<0||de.y<0||de.x>T.size.w||de.y>T.size.h)break;if(A.shiftKey){const ve=new Map(J.nodes.map(nt=>[nt.id,nt]));let ke=fr(T.renderedToModel(de),z.source);const Ze=new Set;for(;ke&&!((_e=ve.get(ke))!=null&&_e.acceptsChildren)&&!Ze.has(ke);)Ze.add(ke),ke=((Se=ve.get(ke))==null?void 0:Se.parent)??null;if(ke&&((je=ve.get(ke))!=null&&je.acceptsChildren)){let nt=ke;const st=new Set;for(;nt&&!st.has(nt);)st.add(nt),nt=(Qe=ve.get(nt))==null?void 0:Qe.parent;st.has(z.source)||(qe=J.onNodeParentChange)==null||qe.call(J,z.source,ke)}break}if(!rt.current)break;const Fe=mn(z.source,{x:(de.x-z.start.x)/T.zoom,y:(de.y-z.start.y)/T.zoom});Fe&&pt.swapGridNodes(z.source,Fe,!1);break}case"pan":case"tap":!L&&!z.moved&&((Be=J.onBackgroundTap)==null||Be.call(J));break;case"box":{if(Ft(null),L)break;const de=T.renderedToModel(z.start),Fe=T.renderedToModel(z.current),ve={x1:Math.min(de.x,Fe.x),y1:Math.min(de.y,Fe.y),x2:Math.max(de.x,Fe.x),y2:Math.max(de.y,Fe.y)};if(ve.x2-ve.x1<1&&ve.y2-ve.y1<1){(Pe=J.onBackgroundTap)==null||Pe.call(J);break}const ke=[];for(const Ze of J.nodes){const nt=ze(Ze.id);nt&&s1(ir(nt),ve)&&ke.push(Ze.id)}ke.length&&((X=J.onBoxSelect)==null||X.call(J,ke));break}case"draw":{if(br(null),L)break;const de=Ir(A),Fe=T.renderedToModel(de),ve=Zr(Fe,z.reverse?"source":"target"),ke=(ve==null?void 0:ve.nodeId)??fr(Fe);if(ke===z.source&&(z.sourceProperty===void 0||(ve==null?void 0:ve.property)===void 0||ve.property===z.sourceProperty))break;ke?(Y=J.onEdgeDraw)==null||Y.call(J,z.reverse?ke:z.source,z.reverse?z.source:ke,z.sourceProperty!==void 0||(ve==null?void 0:ve.property)!==void 0?{sourceProperty:z.reverse?ve==null?void 0:ve.property:z.sourceProperty,targetProperty:z.reverse?z.sourceProperty:ve==null?void 0:ve.property}:void 0):Math.max(Math.abs(A.clientX-z.startClient.x),Math.abs(A.clientY-z.startClient.y))>tE&&((ge=J.onDrawIntoSpace)==null||ge.call(J,z.source,Fe,z.sourceProperty,z.reverse));break}}},Nr=j.useCallback(()=>{var z;const A=gt.current,L=[...vt.current.keys()];A&&A.kind!=="pinch"&&L.push(A.pointerId),gt.current=null,vt.current.clear(),Qt(null),br(null),Ft(null);for(const J of L)(A==null?void 0:A.kind)==="grid"&&A.captureTarget.hasPointerCapture(J)&&A.captureTarget.releasePointerCapture(J),(z=_.current)!=null&&z.hasPointerCapture(J)&&_.current.releasePointerCapture(J)},[]);j.useEffect(()=>{const A=L=>{L.key==="Escape"&&Nr()};return window.addEventListener("keydown",A),window.addEventListener("blur",Nr),()=>{window.removeEventListener("keydown",A),window.removeEventListener("blur",Nr),gt.current=null,vt.current.clear()}},[Nr]),j.useEffect(()=>{Nr()},[y,b,v,i,n,e.drawHandles,e.readOnly,mt,Nr]);const xv=j.useMemo(()=>{const A=new Map,L=new Map;for(const z of P){if(z.source!==z.target)continue;const J=A.get(z.source)??0;A.set(z.source,J+1),L.set(z.id,J)}return L},[P]),Ko=eE[n],[Or,vv]=j.useState(null),Jo=Yj(r,P,!!((Eu=e.edgeReveal)!=null&&Eu.revealNodes));j.useLayoutEffect(()=>{_.current&&Or&&Am(_.current,Or)}),j.useEffect(()=>{const A=_.current;if(!A||!Or)return;const L=A.ownerDocument.fonts,z=()=>Am(A,Or);return L==null||L.addEventListener("loadingdone",z),()=>L==null?void 0:L.removeEventListener("loadingdone",z)},[Or]);const Zo=i1(P,St,Ko),wv=e.onEdgeSelect,Cv=e.onContainerSelect,wu=it?it.target&&St(it.target,it.targetProperty)||{x:it.point.x,y:it.point.y,w:1,h:1}:null,Cu=it?St(it.source,it.sourceProperty):null,xn=!mt||!!e.nodeGridConnections,Sv=["flow-sdk-canvas",y&&xn?"flow-sdk-draw":"",w?"flow-sdk-perf":""].filter(Boolean).join(" ");return f.jsxs("div",{ref:_,className:Sv,"data-edge-mode":i,"data-node-grid":mt||void 0,"data-grid-connections":e.nodeGridConnections||void 0,onPointerDownCapture:mv,onPointerMove:bv,onPointerUp:A=>vu(A,!1),onPointerCancel:A=>vu(A,!0),onLostPointerCapture:A=>{const L=gt.current;L&&(L.kind==="pinch"||L.pointerId===A.pointerId)&&Nr()},onClickCapture:A=>{if(!A.currentTarget.contains(A.target))return;const L=A.target instanceof Element&&A.target.closest("button[data-flow-fullscreen], button[data-flow-content-navigation]");(er.current||e.readOnly&&!L)&&(A.preventDefault(),A.stopPropagation())},children:[f.jsx("svg",{className:"flow-sdk-svg",children:f.jsxs("g",{ref:N,children:[f.jsx("g",{className:"flow-sdk-containers",children:[...Ye].filter(([A])=>ar(A,t,i)).filter(([A])=>!E||E.has(A)).map(([A,L])=>{var z,J;return f.jsx(b1,{id:A,rect:L,label:Me.get(A),labelLayer:Or,labelContent:(z=r.find(pe=>pe.id===A&&pe.label!==void 0))==null?void 0:z.element,style:m(A),onSelect:Cv,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(J=e.selectedNodeIds)==null?void 0:J.includes(A)},A)})}),f.jsx("g",{className:"flow-sdk-edges",children:lt&&xn&&P.map(A=>{var J,pe,_e;if(!Jo.ready.has(A.id)||E&&(!E.has(A.source)||!E.has(A.target)))return null;const L=St(A.source,A.sourceProperty),z=St(A.target,A.targetProperty);return!L||!z?null:f.jsx(of,{id:A.id,edgeData:A.data,validationIssue:A.validationIssue,edgeType:A.type,edgeRadius:e.edgeRadius,propertyMode:R,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:Jo.complete,source:L,target:z,sourceProperty:A.sourceProperty,targetProperty:A.targetProperty,sourceY:ht(A.source,A.sourceProperty),targetY:ht(A.target,A.targetProperty),sourcePort:wt(A.source,A.sourceProperty),targetPort:wt(A.target,A.targetProperty),dir:Ko,turn:((J=Zo.get(A.id))==null?void 0:J.turn)??A.turn,labelAtTarget:(pe=Zo.get(A.id))==null?void 0:pe.labelAtTarget,labelFraction:(_e=Zo.get(A.id))==null?void 0:_e.labelFraction,color:A.color,connectorColor:A.connectorColor,labelBg:A.labelBg,label:A.label,labelLayer:Or,dashed:A.dashed,animated:A.animated&&!w,inverted:A.inverted,loopIndex:xv.get(A.id)??0,onSelect:wv},A.id)})}),lt&&xn&&it&&Pd(it,i)&&Cu&&wu&&f.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:f.jsx(of,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:it.source,target:it.target??"",sourceProperty:it.sourceProperty,targetProperty:it.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:R,customEdgeTypes:e.customEdgeTypes,source:Cu,target:wu,sourceProperty:it.sourceProperty,targetProperty:it.targetProperty,sourceY:ht(it.source,it.sourceProperty),sourcePort:wt(it.source,it.sourceProperty),targetPort:it.target?wt(it.target,it.targetProperty):void 0,targetY:it.target?ht(it.target,it.targetProperty):void 0,dir:Ko,turn:.5,color:g,labelBg:g})})]})}),f.jsxs("div",{ref:V,className:"flow-sdk-nodes",children:[(We==null?void 0:We.insertion)&&f.jsx("div",{className:"flow-sdk-box","data-grid-insertion":"",style:{left:We.insertion.marker.x1,top:We.insertion.marker.y1,width:We.insertion.marker.x2-We.insertion.marker.x1,height:We.insertion.marker.y2-We.insertion.marker.y1,background:g,border:0}}),mt&&((_u=rt.current)==null?void 0:_u.options.fill)&&((ku=rt.current.options.adjustment)==null?void 0:ku.enabled)&&!e.readOnly&&f.jsx(Kj,{dividers:Jr,options:rt.current.options,zoom:T.zoom,onChange:A=>pt.setNodeGridMode(!0,{...A,animate:!1})}),r.map(A=>{var Fe,ve,ke;if((Fe=rt.current)!=null&&Fe.options.fill&&!ie.current)return null;const L=te.get(A.id),z=Ye.get(A.id);if(z&&A.label!==void 0)return null;const J=(L==null?void 0:L.x)??(z?(z.x1+z.x2)/2:0),pe=(L==null?void 0:L.y)??(z?(z.y1+z.y2)/2:0),_e=We!=null&&We.target?A.id===We.source?We.target:A.id===We.target?We.source:void 0:void 0,Se=_e?te.get(_e):void 0,je=We?te.get(We.source):void 0,Qe=We!=null&&We.target?te.get(We.target):void 0,qe=je&&Qe?{x:Qe.x-je.x,y:Qe.y-je.y}:void 0,Be=qe?qe.x**2+qe.y**2:0,Pe=Be&&We&&qe?Math.max(0,Math.min(1,(We.offset.x*qe.x+We.offset.y*qe.y)/Be)):0,X=Se?{x:J+(Se.x-J)*Pe,y:pe+(Se.y-pe)*Pe}:(We==null?void 0:We.source)===A.id?{x:J+We.offset.x,y:pe+We.offset.y}:void 0,Y=ce.get(A.id),ge=_e?ce.get(_e):void 0,de=Y&&ge?{w:Y.w+(ge.w-Y.w)*Pe,h:Y.h+(ge.h-Y.h)*Pe}:Y;return f.jsx(Xj,{id:A.id,x:J,y:pe,gridDraggable:mt&&!e.readOnly&&!re.current.has(A.id),gridDragging:(We==null?void 0:We.source)===A.id,gridDropTarget:(We==null?void 0:We.target)===A.id,gridSize:ce.get(A.id),gridPreview:X?{...X,size:de,floating:We==null?void 0:We.shiftKey}:void 0,placed:!!L||!!z,hidden:!mt&&!Jo.shown.has(A.id)||!ar(A.id,t,i)||!!E&&!E.has(A.id),onMount:Ee,drawHandles:e.drawHandles&&!e.readOnly&&xn,drawMode:y&&xn,connectedPorts:new Set(P.flatMap(Ze=>[...Ze.source===A.id&&Ze.sourceProperty!==void 0?[`source:${Ze.sourceProperty}`]:[],...Ze.target===A.id&&Ze.targetProperty!==void 0?[`target:${Ze.targetProperty}`]:[]])),hasCollapseControl:A.hasCollapseControl,handleColor:g,animated:A.animated&&!z&&!w&&!mt,animationColor:A.animationColor,animationWidth:A.animationWidth,animationVariant:A.animationVariant,width:(ve=Z.current.get(A.id))==null?void 0:ve.w,height:(ke=Z.current.get(A.id))==null?void 0:ke.h,propertyMode:R,resolvedRows:ct.get(A.id),reversePorts:n==="RL",direction:n,onPropertyRows:se,onSurface:q,children:Y?A.fillElement??A.element:A.element},A.id)})]}),tr&&f.jsx("div",{className:"flow-sdk-box",style:{left:tr.x1,top:tr.y1,width:tr.x2-tr.x1,height:tr.y2-tr.y1}}),f.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:f.jsx("g",{ref:O,transform:`translate(${T.pan.x} ${T.pan.y}) scale(${T.zoom})`,children:f.jsx("g",{ref:vv,className:"flow-sdk-labels",style:{pointerEvents:y?"none":"visiblePainted",outline:"none"}})})})]})}const iE=j.memo(oE);function gu(e=!0){const r=j.useRef(null);return j.useEffect(()=>{if(!e||!r.current)return;const t=i=>{i.stopPropagation()},n=r.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,t)),()=>{o.forEach(i=>n.removeEventListener(i,t))}},[e]),r}const cn=({nodeId:e,label:r,color:t,fontWeight:n="bold",fontSize:o="5xl",wrap:i=!1,isEditing:s,onEditStart:a,onEditEnd:c})=>{const{callbacks:l,config:d,readOnly:u}=He(),h=d.editable&&!u,[p,m]=j.useState(r),[g,y]=j.useState(),b=j.useRef(null),v=j.useRef(!1),w=gu(s);j.useEffect(()=>{if(s&&(v.current=!1,b.current)){b.current.focus();const C=b.current.value.length;b.current.setSelectionRange(C,C)}},[s]);const x=()=>{var S;if(v.current)return;v.current=!0;const C=p.trim();C&&C!==r&&((S=l.onNodeLabelChange)==null||S.call(l,e,C)),c()};return!h||!s?f.jsx(W.Text,{color:t,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:i?"normal":"nowrap",overflowWrap:i?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:r,onDoubleClick:h?C=>{C.stopPropagation(),y({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),m(r),a()}:void 0,cursor:h?"text":void 0,children:r}):f.jsxs("div",{ref:w,style:{position:"relative",width:"max-content",minWidth:g==null?void 0:g.width,maxWidth:900,height:g==null?void 0:g.height},children:[f.jsx(W.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:o,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),f.jsx(W.Input,{ref:b,value:p,onChange:C=>m(C.target.value),onBlur:x,onKeyDown:C=>{C.key==="Enter"&&x(),C.key==="Escape"&&(v.current=!0,c())},color:t,fontWeight:n,fontSize:o,bg:"transparent",borderWidth:0,_focus:{outline:"none",boxShadow:"none"},_focusVisible:{outline:"none",boxShadow:"none"},p:0,display:"block",position:"absolute",top:0,left:0,w:"100%",h:"100%",minW:0,minH:0,lineHeight:"normal"})]})};function cv({id:e,label:r,role:t,side:n,position:o=.5,placement:i,children:s,style:a}){return f.jsx("div",{"data-flow-property":e,"data-flow-port-role":t,"data-flow-port-side":n,"data-flow-port-position":n?o:void 0,"data-flow-port-placement":i,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:t==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??r??e})}const aE=xo.default.dialog`
211
211
  ${e=>gr(e.$surface,e.$border)}
212
212
  &,