@arudovwen/form-builder-react 1.7.0 → 1.7.1

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.
@@ -1,4 +1,4 @@
1
- import { H as o, V as m } from "./index-pNsPMz_J.js";
1
+ import { H as o, V as m } from "./index-CAKsnsol.js";
2
2
  export {
3
3
  o as FormBuilder,
4
4
  m as FormViewer
@@ -27,7 +27,7 @@
27
27
  ${i===e.id?" border-blue-200 bg-gray-100":"bg-white"} ${a.includes(n)?"min-h-[300px] pb-6 ":""}`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{draggable:!0,onDragStart:v=>{v.dataTransfer.setData("sectionid",e.id),v.dataTransfer.effectAllowed="move",d(!0)},onDragEnd:()=>d(!1),onClick:()=>o(e.id),className:"flex-1 h-full py-4 cursor-grab active:cursor-grabbing flex items-center gap-2",title:"Drag to reorder section",children:[c.jsx(se,{icon:"material-symbols:drag-indicator",iconClass:"text-gray-400 text-lg"}),c.jsx("h2",{className:"font-medium",children:e.title||"Section title"})]}),c.jsxs("div",{className:"flex items-center gap-x-2",children:[c.jsx("button",{type:"button",className:"p-1 text-xs border rounded-lg",onClick:()=>t(e),children:c.jsx(se,{icon:"fluent:edit-28-regular"})}),l>1&&c.jsx("button",{type:"button",className:"p-1 text-xs border rounded-lg",onClick:()=>r(e.id),children:c.jsx(se,{icon:"lets-icons:trash-duotone-line"})}),c.jsx("button",{type:"button",className:"p-1 text-xs rounded-lg",onClick:()=>s(n),children:c.jsx(se,{icon:a.includes(n)?"fa6-solid:chevron-up":"fa6-solid:chevron-down",iconClass:"text-base"})})]})]}),(e==null?void 0:e.description)&&a.includes(n)&&c.jsx("p",{className:"mt-2 text-sm text-gray-600",children:e==null?void 0:e.description}),a.includes(n)&&c.jsxs("div",{className:"h-full mt-4 transition-all duration-200",id:e.id,onDragOver:u,onDragEnd:()=>d(!1),onClick:()=>o(e.id),children:[c.jsx("hr",{className:"group-last:hidden"}),c.jsx("div",{className:"h-full mt-4 gap-y-6 ",children:c.jsx(IS,{elementData:e.questionData,sectionId:e.id})})]})]})},e.id)},FS=({onAddTemplate:e,templates:n})=>{const i=[...DS,...n||[]],[o,a]=C.useState(!1),[s,t]=C.useState(!1),r=C.useRef(null),l=C.useRef(null),{removeSection:u,addSection:d,formData:b,setIsDragging:m,setSelectedSection:f,selectedSection:h,activeSections:g,setActiveSections:v,setFormData:p}=C.useContext(Ce),S=C.useRef((b==null?void 0:b.length)||0);C.useEffect(()=>{var _;f(((_=b[0])==null?void 0:_.id)||null)},[]),C.useEffect(()=>{(b==null?void 0:b.length)>S.current&&l.current&&requestAnimationFrame(()=>{var _;(_=l.current)==null||_.scrollTo({top:l.current.scrollHeight,behavior:"smooth"})}),S.current=(b==null?void 0:b.length)||0},[b==null?void 0:b.length]);const y=C.useCallback(_=>{_.preventDefault(),_.dataTransfer.dropEffect="move",l.current&&(l.current.scrollTop=l.current.scrollHeight)},[]),x=C.useCallback((_,P)=>{p(k=>{const M=k.findIndex(B=>B.id===_),L=k.findIndex(B=>B.id===P);if(M===-1||L===-1||M===L)return k;const T=[...k],[O]=T.splice(M,1);return T.splice(L,0,O),T})},[p]);function w(_){g.includes(_)?v(P=>P.filter(k=>k!==_)):v(P=>[...P,_])}function A(_){r.current=_,a(!0)}const N=_=>{const P=(k,M={})=>({...JSON.parse(JSON.stringify(k)),...M});if(_.sections&&Array.isArray(_.sections)){const M=_.sections.filter(Boolean).map(T=>{var K;const O=_e.v4(),B=(K=T.questionData)==null?void 0:K.map(G=>P(G,{id:_e.v4(),sectionId:O}));if(B){const G=new Map;T.questionData.forEach((I,Y)=>{G.set(I.id,B[Y].id)}),B.forEach(I=>{I.gridId&&G.has(I.gridId)&&(I.gridId=G.get(I.gridId))})}return P(T,{id:O,questionData:B||[]})});b.length===1&&b[0].title===""&&b[0].description===""&&(!b[0].questionData||b[0].questionData.length===0)?(p(M),M.length>0&&f(M[0].id)):p(T=>[...T,...M])}},E=Se("config");return c.jsxs("div",{ref:l,className:"relative flex flex-col h-full pb-5 mx-auto gap-x-4 ",children:[o&&c.jsx(BS,{isOpen:o,onClose:()=>a(!1),section:r.current}),c.jsxs("div",{id:"section-container",className:"relative flex flex-col flex-1 w-full gap-y-3 container overflow-y-auto",children:[b==null?void 0:b.map((_,P)=>c.jsx(qS,{section:_,index:P,selectedSection:h,setSelectedSection:f,activeSections:g,toggleSection:w,handleSectionEdit:A,removeSection:u,formDataLength:b.length,onDragOver:y,setIsDragging:m,onReorderSection:x},_.id)),c.jsxs("div",{className:"flex justify-center gap-x-4",children:[c.jsxs("button",{type:"button",onClick:()=>d(),style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:"text-sm font-medium",children:["+ Add section"," "]}),e||i!=null&&i.length?c.jsx("button",{type:"button",onClick:()=>{i!=null&&i.length?t(!0):e&&e()},style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:"text-sm font-medium",children:"+ Add existing template"}):null]})]}),s&&c.jsx(OS,{isOpen:s,onClose:()=>t(!1),templates:i,onSelect:N})]})},GS=()=>{const{formData:e,uploadUrl:n}=C.useContext(Ce),[i,o]=C.useState("multi"),a=Se("config");return c.jsxs("div",{className:"flex flex-col h-full w-full",children:[c.jsx("div",{className:"flex justify-center p-3 border-b border-gray-100 bg-gray-50/50",children:c.jsxs("div",{className:"flex bg-gray-200 p-1 rounded-lg text-sm font-medium",children:[c.jsx("button",{type:"button",className:`px-4 py-1.5 rounded-md transition-all ${i==="multi"?"bg-white shadow-sm text-gray-900":"text-gray-500 hover:text-gray-700"}`,onClick:()=>o("multi"),children:"Standard"}),c.jsx("button",{type:"button",className:`px-4 py-1.5 rounded-md transition-all ${i==="conversational"?"bg-white shadow-sm text-gray-900":"text-gray-500 hover:text-gray-700"}`,onClick:()=>o("conversational"),children:"Conversational"})]})}),c.jsx("div",{className:"flex-1 overflow-y-auto w-full relative",children:c.jsx(ga,{form_data:e,ignoreValidation:!0,config:a,uploadUrl:n,renderType:i,onGetValues:s=>console.log(s)})})]})},fa=({loadingClass:e})=>{const n=ue("h-full w-full min-h-[300px] flex justify-center items-center",e);return C.useEffect(()=>{const i=Se("config"),o=(i==null?void 0:i.loaderColor)||"#333";document.documentElement.style.setProperty("--loader-color",o)},[]),c.jsx("div",{className:n,children:c.jsx("span",{className:"loader"})})},KS=C.lazy(()=>Promise.resolve().then(()=>DP));function HS({questionData:e,uploadUrl:n,onAddTemplate:i,templates:o,viewMode:a="canvas"}){const{setFormData:s,addSection:t,setUploadUrl:r,showPreview:l,formData:u}=C.useContext(Ce);C.useEffect(()=>{e&&e.length>0&&s(e)},[e,s]),C.useEffect(()=>{r(n)},[n,r]);const d=C.useCallback(b=>{b.preventDefault();try{const m=JSON.parse(b.dataTransfer.getData("properties"));if((m==null?void 0:m.type)==="section"){t();return}}catch(m){console.error("Drop error:",m)}},[]);return c.jsxs("div",{className:"flex gap-x-6 h-full",children:[c.jsx("div",{onDragOver:b=>b.preventDefault(),onDrop:b=>d(b),className:" h-full overflow-y-auto no-scrollbar max-h-[calc(100vh-80px)] flex-1 form_builder",children:a==="canvas"?c.jsx(FS,{onAddTemplate:i,templates:o}):c.jsx(C.Suspense,{fallback:c.jsx(fa,{loadingClass:"!w-full !h-full"}),children:c.jsx(KS,{formData:u})})}),a==="canvas"&&c.jsx(le.Transition,{show:l,as:"div",enter:"transition-all duration-300 ease-in-out origin-right",enterFrom:"opacity-0 w-0 translate-x-10 px-0 overflow-hidden border-transparent shadow-none",enterTo:"opacity-100 w-2/5 translate-x-0",leave:"transition-all duration-300 ease-in-out origin-right",leaveFrom:"opacity-100 w-2/5 translate-x-0",leaveTo:"opacity-0 w-0 translate-x-10 px-0 overflow-hidden border-transparent shadow-none",className:"shrink-0 overflow-y-auto no-scrollbar max-h-[calc(100vh-70px)] form_preview w-2/5 min-w-0",children:c.jsx("div",{className:"px-2 shadow_box min-w-0 bg-white border border-gray-100 rounded-lg container",children:c.jsx(GS,{})})})]})}const va=[{key:"textFields",title:"Text Fields"},{key:"selectionFields",title:"Selection Fields"},{key:"dateAndTime",title:"Date & Time"},{key:"fileAndMedia",title:"File & Media"},{key:"layoutAndDisplay",title:"Layout & Display"},{key:"advancedData",title:"Advanced / Data"}],VS=()=>{const[e,n]=C.useState(""),{setIsDragging:i,addElement:o,selectedSection:a}=C.useContext(Ce),s=C.useCallback((f,h)=>{if(!a){Pe.toast.error("Please select a section to add an element.");return}f.dataTransfer.setData("properties",JSON.stringify(h)),f.dataTransfer.effectAllowed="move",i(!0)},[i,a]);function t(f){if(!a){Pe.toast.error("Please select a section to add an element.");return}const h={...f,id:_e.v4(),sectionId:a};o(h,a)}const r=Se("config")||{},l=r.elementColor,u=r.elementBgColor,d=r.elementBorderColor,b=B1.filter(f=>f.label.toLowerCase().includes(e.toLowerCase())),m=va==null?void 0:va.map(f=>({title:f.title,elements:b.filter(h=>{var g;return(g=O1[f.key])==null?void 0:g.includes(h.type)})})).filter(f=>f.elements.length>0);return c.jsxs("div",{className:"pt-4 flex flex-col gap-y-6",children:[c.jsx("div",{className:"px-5",children:c.jsx("input",{className:"field-control",placeholder:"Search",value:e,onChange:f=>n(f.target.value),name:"search",id:"search"})}),c.jsx("div",{className:"flex-1 overflow-y-auto no-scrollbar max-h-[calc(100vh-100px)]",children:c.jsx("ul",{className:"grid gap-y-5 mt-3 px-5 ",children:m==null?void 0:m.map((f,h)=>{var g;return c.jsxs("li",{children:[c.jsx("h4",{className:"mb-2 text-[11px] font-bold text-gray-500 uppercase",children:f.title}),c.jsx("ul",{className:"grid grid-cols-2 gap-y-3 gap-x-4 mb-3",children:(g=f.elements)==null?void 0:g.map(v=>c.jsx("li",{onDragStart:p=>s(p,v),onDragEnd:()=>i(!1),onClick:()=>t(v),style:{borderColor:d,backgroundColor:u},className:`cursor-move text-[#475467] flex justify-between items-center \r
28
28
  border-[1.5px] border-[#98A2B3] rounded-lg py-2 px-2 shadow-custom\r
29
29
  hover:shadow-lg transition-all duration-200\r
30
- active:opacity-50 element_class`,draggable:!0,children:c.jsxs("span",{className:"flex flex-col items-center justify-center w-full gap-2",children:[c.jsx("span",{style:{color:l},children:c.jsx(se,{icon:v.icon,iconClass:"w-6 h-6"})}),c.jsx("span",{style:{color:l},className:"text-xs font-medium text-center",children:v.label})]})},v.type))})]},h)})})})]})},zS=C.memo(VS),Ue=({text:e="",isDisabled:n=!1,isLoading:i=!1,btnClass:o="bg-primary-500 text-white",icon:a="",iconPosition:s="left",iconClass:t="text-[20px]",loadingClass:r="",link:l="",div:u=!1,type:d="button",style:b,onClick:m})=>{const f=ue("btn inline-flex justify-center",{"pointer-events-none":i,"opacity-40 cursor-not-allowed":n},o),h=()=>i?c.jsxs(c.Fragment,{children:[c.jsxs("svg",{className:`animate-spin -ml-1 mr-3 h-5 w-5 ${r}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Submitting..."]}):c.jsxs("span",{className:"flex items-center",children:[a&&s==="left"&&c.jsx("span",{className:`mr-[6px] ${t}`,children:c.jsx(se,{icon:a})}),e&&c.jsx("span",{children:e}),a&&s==="right"&&c.jsx("span",{className:`ml-[6px] ${t}`,children:c.jsx(se,{icon:a})})]});return u?c.jsx("div",{className:f,children:h()}):l?c.jsx(px.Link,{to:l,className:f,children:h()}):c.jsx("button",{disabled:n,type:d,className:f,"data-testid":"btn",onClick:m,style:b,children:h()})};function jS(){return c.jsx("div",{children:c.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",fill:"#D5D7DA"}),c.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",stroke:"#E9EAEB"}),c.jsx("path",{d:"M22.5 14L14.5 22M14.5 14L22.5 22",stroke:"#414651",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const US=({isOpen:e,onClose:n})=>{const{formData:i,uploadUrl:o}=C.useContext(Ce);if(!e)return null;const a=Se("config");return c.jsxs("div",{className:"fixed inset-0 flex justify-center z-[999] cursor-default no-drag select-none w-screen h-screen pt-20 bg-[#F8F9FC]",children:[c.jsx("button",{type:"button",onClick:n,className:"absolute text-sm top-3 right-4","aria-label":"close",children:c.jsx(jS,{})})," ",c.jsx("div",{className:"max-h-[80vh] overflow-y-auto h-max w-full max-w-[650px] min-w-0 border border-[#D5D9EB] rounded-lg bg-white form_submit container",children:c.jsx(ga,{form_data:i,ignoreValidation:!0,config:a,uploadUrl:o})})]})};function WS(){return c.jsx("div",{children:c.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("rect",{width:"24",height:"24",rx:"6",fill:"currentColor"}),c.jsx("path",{d:"M14 16L10 12L14 8",stroke:"white",strokeWidth:"1.39167",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function $S({title:e,goBackUrl:n,onSubmit:i,onPublish:o,previewLoading:a,saveLoading:s,publishLoading:t,onTitleChange:r,viewMode:l,setViewMode:u,onShowVersion:d}){const{formData:b,setShowPreview:m,showPreview:f,undo:h,redo:g,canUndo:v,canRedo:p}=C.useContext(Ce),[S,y]=C.useState(!1),[x,w]=C.useState(!1),[A,N]=C.useState(e||""),E=Se("config");function _(){localStorage.setItem("formData",JSON.stringify(b)),i==null||i(b)}function P(){localStorage.setItem("formData",JSON.stringify(b)),o==null||o(b)}function k(){w(!1),r&&A!==e&&r(A.trim())}return c.jsxs("div",{className:"px-[30px] py-3 flex justify-between items-center bg-[#F9F9FB] top_bar border-b h-full",children:[c.jsxs("span",{className:"flex items-center gap-x-2",children:[n&&c.jsx("button",{type:"button",onClick:()=>n(),style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:"flex items-center gap-x-3",children:c.jsx(WS,{})})," ",x?c.jsx("input",{type:"text",value:A,onChange:M=>N(M.target.value),onBlur:k,autoFocus:!0,className:"w-48 px-2 py-1 text-sm font-semibold outline-gray-100 input form_title"}):c.jsx("h1",{title:"Click to edit",className:"text-base font-semibold cursor-pointer form_title",onClick:()=>w(!0),children:A||"Untitled"})]}),S&&c.jsx(US,{isOpen:S,onClose:()=>y(!1),element:void 0}),c.jsxs("div",{className:"flex justify-end text-xs gap-x-3 items-center",children:[u&&c.jsxs("div",{className:"flex border border-gray-300 rounded-lg overflow-hidden h-[36px] text-sm font-medium shadow-sm mr-2",children:[c.jsxs("button",{type:"button",style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:`px-3 flex items-center gap-1.5 transition-colors canvas_view ${l==="canvas"?"bg-white font-medium":"bg-gray-100 text-gray-500 hover:bg-gray-50"}`,onClick:()=>u("canvas"),children:[c.jsx(se,{icon:"mdi:view-dashboard-outline",iconClass:"text-base"})," ","Builder"]}),c.jsxs("button",{type:"button",style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:`px-3 flex items-center gap-1.5 border-l border-gray-300 transition-colors flow_view ${l==="flow"?" bg-white font-medium":"bg-gray-100 text-gray-500 hover:bg-gray-50"}`,onClick:()=>u("flow"),children:[c.jsx(se,{icon:"mdi:sitemap-outline",iconClass:"text-base"})," Flow"]})]}),c.jsx(Ue,{onClick:h,text:"",btnClass:`!px-2 bg-transparent undo ${v?"":"opacity-50"}`,icon:"material-symbols:undo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!v}),c.jsx(Ue,{onClick:g,text:"",btnClass:`!px-2 bg-transparent redo ${p?"":"opacity-50"}`,icon:"material-symbols:redo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!p}),d&&c.jsx(Ue,{onClick:d,text:"Versions",btnClass:"px-2 bg-transparent font-medium text-sm",icon:"tabler:history",iconClass:"text-xl",style:{color:(E==null?void 0:E.buttonColor)||"#333"}}),c.jsx(Ue,{onClick:()=>m(M=>!M),text:f?"Hide Preview":"Preview",btnClass:"px-2 bg-transparent font-medium text-sm form_preview",icon:f?"iconamoon:eye-off-duotone":"solar:eye-bold-duotone",iconClass:"text-base",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:a,isLoading:a}),c.jsx(Ue,{onClick:_,text:"Save",btnClass:"px-2 bg-transparent font-medium text-sm form_save__btn",icon:"lets-icons:save-duotone",iconClass:"text-base",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:s,isLoading:s}),c.jsx(Ue,{onClick:P,text:"Publish",style:{background:(E==null?void 0:E.buttonColor)||"#333"},btnClass:"border-[#98A2B3] font-medium text-sm py-2 px-6 text-white rounded-lg form_publish__btn",isDisabled:t,isLoading:t})]})]})}function YS({onSubmit:e,onChange:n,onLogAction:i,questionData:o,title:a,goBackUrl:s,loading:t,onPublish:r,previewLoading:l,saveLoading:u,publishLoading:d,onTitleChange:b,uploadUrl:m,onAddTemplate:f,templates:h,onShowVersion:g}){const[v,p]=C.useState("canvas");return c.jsxs(Qd,{onChange:n,onLogAction:i,children:[c.jsx(Pe.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),c.jsx("div",{className:"w-full h-full bg-[#F8F9FC] flex flex-col",children:c.jsxs("div",{className:"flex flex-1 ",children:[v==="canvas"&&c.jsx("div",{children:c.jsx("div",{className:"w-[250px] h-screen border-r border-[#E4E7EC] bg-white ",children:c.jsx(zS,{})})}),c.jsxs("div",{className:`flex-1 h-full max-h-full z-[1] ${v==="canvas"?"w-[calc(100%-250px)]":"w-full"}`,children:[c.jsx("div",{className:" h-[70px]",children:c.jsx($S,{title:a,goBackUrl:s,onSubmit:e,onPublish:r,previewLoading:l,saveLoading:u,publishLoading:d,onTitleChange:b,viewMode:v,setViewMode:p,onShowVersion:g})}),c.jsx("div",{className:"p-6 h-[calc(100vh-70px)]",children:t?c.jsx(fa,{loadingClass:"!w-full !h-[800px]"}):c.jsx(HS,{questionData:o,uploadUrl:m,onAddTemplate:f,templates:h,viewMode:v})})]})]})})]})}const JS=({onSubmit:e,onChange:n,onLogAction:i,questionData:o,isReadOnly:a,config:s={buttonColor:"#333"},title:t,loading:r,goBackUrl:l,onPublish:u,previewLoading:d,saveLoading:b,publishLoading:m,onTitleChange:f,uploadUrl:h,onAddTemplate:g,templates:v,onShowVersion:p})=>(C.useEffect(()=>{s&&_c("config",s)},[s]),c.jsx(YS,{onSubmit:e,onChange:n,onLogAction:i,onPublish:u,questionData:o,isReadOnly:a,title:t,goBackUrl:l,loading:r,previewLoading:d,saveLoading:b,publishLoading:m,onTitleChange:f,uploadUrl:h,onAddTemplate:g,templates:v,onShowVersion:p})),rn={required:"This field is required",email:"Invalid email format",url:"Invalid url format",minLength:e=>`Minimum length is ${e}`,maxLength:e=>`Maximum length is ${e}`,minAmount:e=>`Minimum amount is ${e}`,maxAmount:e=>`Maximum amount is ${e}`},ZS=(e,n=!1)=>({textField:ie.string().nullable(),longText:ie.string().nullable(),numberField:ie.number().nullable().transform(o=>isNaN(o)?null:o),amountField:ie.number().nullable().transform(o=>isNaN(o)?null:o),selectField:ie.string().nullable(),checkbox:ie.mixed().nullable(),radio:ie.mixed().nullable(),matrix:ie.mixed().nullable(),email:ie.string().nullable().test("email-format",rn.email,o=>!o||o.trim()===""?!0:/^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/.test(o)),date:ie.date().nullable().transform((o,a)=>n&&a===""?null:o).typeError("Invalid date"),url:ie.string().nullable().test("url-format",rn.url,o=>!o||o.trim()===""?!0:/^(https?:\/\/)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/.*)?$/.test(o))})[e]||ie.mixed().nullable(),XS=(e,n,i)=>n?e.type==="boolean"?e.oneOf([!0],i||rn.required):e.required(i||rn.required):e,QS=(e,{minLength:n,maxLength:i,minLengthMessage:o,maxLengthMessage:a})=>{let s=e;return n&&(s=s.min(n,o||rn.minLength(n))),i&&(s=s.max(i,a||rn.maxLength(i))),s},RS=(e,{minAmount:n,maxAmount:i,minAmountMessage:o,maxAmountMessage:a})=>{let s=e;return n&&(s=s.min(parseFloat(String(n)),o||rn.minAmount(n))),i&&(s=s.max(parseFloat(String(i)),a||rn.maxAmount(i))),s},ha=(e,n)=>{if(!e.isHidden)return!0;const i=e.visibilityDependentFields||[];return i.length?i.every(o=>{const a=n==null?void 0:n[o.id],s=o.fieldValue,t=a;switch(o.operator){case"equals":return String(s).toLowerCase()===String(t).toLowerCase();case"not_equals":return String(s).toLowerCase()!==String(t).toLowerCase();case"greater":return Number(t)>Number(s);case"less":return Number(t)<Number(s);case"contains":return String(t).toLowerCase().includes(String(s).toLowerCase());case"not_contains":return!String(t).toLowerCase().includes(String(s).toLowerCase());default:return!0}}):!0};function ew({formData:e,isReadOnly:n,answerData:i}){const o={};return e.forEach(({questionData:a})=>{a==null||a.forEach(s=>{if(!ha(s,i))return;const{id:t,type:r,isRequired:l,requiredMessage:u,isDisabled:d}=s;let b=ZS(r,n);b=XS(b,d||n?!1:l,u),r==="textField"||r==="longText"||r==="email"||r==="url"?b=QS(b,s):(r==="numberField"||r==="amountField")&&(b=RS(b,s)),o[t]=b})}),ie.object().shape(o)}const Pn=({element:e,validationData:n})=>{const i=Lc[e.type],{answerData:o}=C.useContext(Ce),a=C.useMemo(()=>{var t;return(t=e==null?void 0:e.acceptedFiles)==null?void 0:t.map(r=>r.label).join(", ")},[e]),s=C.useMemo(()=>ha(e,o),[o,e]);return i?c.jsxs("div",{className:`${s?"":"invisible h-0"} min-w-0 w-full`,children:[c.jsxs("div",{className:"mb-1.5 min-w-0",children:[e.inputLabel&&c.jsxs("label",{className:"block text-sm font-medium input_label",children:[e.inputLabel," ",a&&c.jsxs("span",{className:"text-gray-400 text-xs",children:["(",a==null?void 0:a.toLowerCase(),")"]})]}),e.description&&c.jsxs("small",{className:"block text-gray-400 mt-0.5 text-xs",children:[" ",e.description]})]}),c.jsx(i,{element:e,state:"edit",validationData:{...n,isReadOnly:n.isReadOnly||e.isDisabled}})]}):null},In=(e,n)=>e!=null&&e.allowEdit?{...n,isReadOnly:!1}:n;function nw({form_data:e,options:n}){const i=(a,s)=>c.jsx("div",{className:"min-w-0",children:c.jsx(Gi,{element:a,customClass:"p-0 min-h-[60px] border-none",children:s==null?void 0:s.map(t=>{var r,l,u;return c.jsxs(Fi,{col:(r=t.gridPosition)==null?void 0:r.col,customClass:"p-0",children:[c.jsx(Pn,{element:t,validationData:In(t,n)}),((u=(l=n==null?void 0:n.errors)==null?void 0:l[t.id])==null?void 0:u.message)&&c.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[t.id].message})]},t.id)})})},a.id),o=a=>{var s,t;return c.jsxs("div",{className:ue("group relative grid gap-y-[6px] min-w-0",a.elementClass),children:[c.jsx(Pn,{element:a,validationData:In(a,n)}),((t=(s=n==null?void 0:n.errors)==null?void 0:s[a.id])==null?void 0:t.message)&&c.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[a.id].message})]},a.id)};return c.jsx("div",{className:"grid gap-y-10",children:e==null?void 0:e.map(a=>{var t,r;const s=new Map;return(t=a.questionData)==null||t.forEach(l=>{l.gridId&&(s.has(l.gridId)||s.set(l.gridId,[]),s.get(l.gridId).push(l))}),c.jsxs("div",{className:"pb-6 section_box min-w-0",children:[(a.title||a.description)&&c.jsxs("div",{className:"py-4 border-b border-gray-100 mb-7 section_box__title",children:[a.title&&c.jsx("h2",{className:"text-lg font-semibold mb-[4px]",children:a.title}),a.description&&c.jsx("p",{className:"text-sm",children:a.description})]}),c.jsx("div",{className:"grid gap-y-6 section_box__content min-w-0",children:(r=a.questionData)==null?void 0:r.map(l=>l.gridId?null:l.type==="grid"?i(l,s.get(l.id)||[]):o(l))})]},a.id)})})}function iw({form_data:e,options:n,current:i}){var o;return c.jsx("div",{className:"grid gap-y-3 multi_section__content min-w-0",children:(o=e[i].questionData)==null?void 0:o.map(a=>{var s,t;if(a.type==="grid"){const r=e[i].questionData.filter(l=>l.gridId===a.id);return c.jsx("div",{className:"min-w-0",children:c.jsx(Gi,{element:a,customClass:"p-0 min-h-[60px] border-none",children:r==null?void 0:r.map(l=>{var u,d,b;return c.jsxs(Fi,{col:(u=l.gridPosition)==null?void 0:u.col,customClass:"p-0",children:[c.jsx(Pn,{element:l,validationData:In(l,n)}),c.jsx("div",{className:"mt-1 text-xs text-red-600",children:(b=(d=n==null?void 0:n.errors)==null?void 0:d[l.id])==null?void 0:b.message})]},l.id)})})},a.id)}return a.gridId?null:c.jsxs("div",{className:ue("group relative grid gap-y-[6px] min-w-0",a.elementClass),children:[c.jsx(Pn,{element:a,validationData:In(a,n)}),c.jsx("div",{className:"mt-1 text-xs text-red-600",children:(t=(s=n==null?void 0:n.errors)==null?void 0:s[a.id])==null?void 0:t.message})]},a.id)})})}const pa=Se("config");function ow({element:e,options:n,onNext:i,onPrev:o,isFirst:a,isLast:s,isReadOnly:t}){if(!e)return c.jsx("div",{className:"flex items-center justify-center min-h-[500px] text-gray-500",children:"No questions available."});const r=d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),i())},l=d=>{var b;return c.jsx("div",{className:"min-w-0 w-full",children:c.jsx(Gi,{element:d,customClass:"p-0 min-h-[60px] border-none w-full",children:(b=d.gridChildren)==null?void 0:b.map(m=>{var f,h,g;return c.jsxs(Fi,{col:(f=m.gridPosition)==null?void 0:f.col,customClass:"p-0",children:[c.jsx(Pn,{element:m,validationData:In(m,n)}),((g=(h=n==null?void 0:n.errors)==null?void 0:h[m.id])==null?void 0:g.message)&&c.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[m.id].message})]},m.id)})})},d.id)},u=d=>{var b,m;return c.jsxs("div",{className:ue("group relative grid gap-y-[6px] min-w-0 w-full",d.elementClass),children:[c.jsx(Pn,{element:d,validationData:In(d,n)}),((m=(b=n==null?void 0:n.errors)==null?void 0:b[d.id])==null?void 0:m.message)&&c.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[d.id].message})]},d.id)};return c.jsx("div",{className:"flex flex-col items-center justify-center min-h-[500px] w-full p-4 sm:p-8 outline-none",onKeyDown:r,tabIndex:0,children:c.jsxs(le.Transition,{as:"div",show:!0,appear:!0,enter:"transition-all duration-500 ease-out",enterFrom:"opacity-0 translate-y-8",enterTo:"opacity-100 translate-y-0",leave:"transition-all duration-300 ease-in",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-8",className:"w-full max-w-2xl",children:[c.jsx("div",{className:"text-left w-full mb-8",children:e.type==="grid"?l(e):u(e)}),!t&&c.jsxs("div",{className:"flex items-center gap-4 mt-8",children:[c.jsx(Ue,{type:"button",text:s?n!=null&&n.isSubmitting?"Submitting...":"Submit":"OK",onClick:i,style:{background:(pa==null?void 0:pa.buttonColor)||"#333"},btnClass:`text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg ${s?"submit_btn":"continue_btn next_btn text-sm"}`}),!s&&c.jsx("span",{className:"text-xs text-gray-400 font-medium hidden sm:inline-block",children:"press Enter ↵"}),!a&&c.jsxs("button",{type:"button",onClick:o,className:"text-gray-400 hover:text-gray-600 font-medium text-sm ml-auto flex items-center gap-1 transition-colors",children:[c.jsx(se,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]})]},e.id)})}function aw(e){return e.reduce((n,i)=>(n[i.id]=i.value,n),{})}const sw=({form_data:e,answerData:n=[],ignoreValidation:i=!1,onSubmitData:o,onGetValues:a,isReadOnly:s=!1,renderType:t="multi",children:r,hideFooter:l=!1,uploadUrl:u})=>{var H,U,q,F,W,z,V,Q;const{setAnswerData:d,setUploadUrl:b}=C.useContext(Ce),[m,f]=C.useState(0),[h,g]=C.useState(0),v=C.useMemo(()=>e.filter(j=>!j.isHidden).map(j=>{var $;return j.isDisabled||j.disabled?{...j,questionData:($=j.questionData)==null?void 0:$.map(ne=>({...ne,isDisabled:!0}))}:j}),[e]),p=(H=v==null?void 0:v.length)!=null?H:0,S=Se("config"),y=C.useCallback(async(j,X,$)=>{const ne=ew({formData:v,isReadOnly:s,answerData:j});return sa(ne)(j,X,$)},[v,s]),x=Xe.useForm({resolver:y,mode:"onSubmit",defaultValues:{}}),{register:w,setValue:A,control:N,handleSubmit:E,reset:_,getValues:P,watch:k,formState:{errors:M,isSubmitting:L},trigger:T,setError:O,clearErrors:B}=x,K=Xe.useWatch({control:N}),G=C.useMemo(()=>K,[JSON.stringify(K)]),I=C.useMemo(()=>{if(t!=="conversational")return[];const j=[];return v.forEach(X=>{var $;($=X.questionData)==null||$.forEach(ne=>{var ee;if(ha(ne,G))if(ne.type==="grid"){const ae=(ee=X.questionData)==null?void 0:ee.filter(re=>re.gridId===ne.id);j.push({...ne,gridChildren:ae})}else ne.gridId||j.push(ne)})}),j},[v,G,t]),Y=C.useCallback(j=>{a&&a(j)},[a]);C.useEffect(()=>{b(u)},[b,u]),C.useEffect(()=>{if(!(v!=null&&v.length)||!a)return;const j=v.flatMap(X=>{var $;return($=X.questionData)==null?void 0:$.map(ne=>({id:ne.id,value:G[ne.id]||"",sectionId:X.id,type:ne.type,metaData:{prefix:ne.prefix,dateFormat:ne.dateFormat}}))});Y(j),d(G)},[G,v,Y,a,d]),C.useEffect(()=>{n!=null&&n.length&&_(aw(n))},[n,_]);const Z=C.useCallback(j=>{const X=v.flatMap($=>{var ne;return(ne=$.questionData)==null?void 0:ne.map(ee=>({id:ee.id,value:j[ee.id]||"",sectionId:$.id,type:ee.type,metaData:{prefix:ee.prefix,dateFormat:ee.dateFormat}}))});Object.keys(M).length>0||o==null||o(X)},[M,v,o]),J=C.useCallback(async()=>{var j,X;if(t==="conversational"){if(!i){const $=I[h];if(!$)return;const ne=$.gridChildren?$.gridChildren.map(ae=>ae.id):[$.id];if(!await T(ne))return}h<I.length-1?g($=>$+1):E(Z)();return}if(!i){const $=(X=(j=v==null?void 0:v[m])==null?void 0:j.questionData)==null?void 0:X.map(ee=>ee.id);if(!await T($))return}f($=>$+1)},[m,h,I,v,i,T,t,E,Z]),R=C.useCallback(()=>{if(t==="conversational"){g(j=>Math.max(0,j-1));return}f(j=>j-1)},[t]),D=C.useMemo(()=>({register:w,setValue:A,watch:k,errors:M,trigger:T,isSubmitting:L,isReadOnly:s,getValues:P,setError:O,clearErrors:B}),[w,A,k,M,T,L,s,P,O,B]);return c.jsxs(Xe.FormProvider,{...x,children:[c.jsx(Pe.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),c.jsxs("form",{onSubmit:E(Z),className:"container h-full mx-auto",children:[c.jsx("div",{className:"relative flex flex-col w-full min-w-0 py-4 gap-y-12",children:c.jsxs("div",{className:"multi_section__box min-w-0",children:[t==="multi"&&(((U=v==null?void 0:v[m])==null?void 0:U.title)||((q=v==null?void 0:v[m])==null?void 0:q.description))&&c.jsxs("div",{className:"py-4 mb-4 border-b border-gray-100 multi_section__title",children:[((F=v[m])==null?void 0:F.title)&&c.jsx("h2",{className:"text-lg font-semibold mb-[6px]",children:(W=v[m])==null?void 0:W.title}),((z=v[m])==null?void 0:z.description)&&c.jsx("p",{className:"text-sm",children:(V=v[m])==null?void 0:V.description})]}),t==="multi"?c.jsx(iw,{form_data:v,options:D,current:m}):t==="conversational"?c.jsx(ow,{element:I[h],options:D,onNext:J,onPrev:R,isFirst:h===0,isLast:h===I.length-1,isReadOnly:s}):c.jsx(nw,{form_data:v,options:D})]},t==="conversational"?`conv-${h}`:(Q=v==null?void 0:v[m])==null?void 0:Q.id)}),!l&&t!=="conversational"&&c.jsx("footer",{className:"flex items-center justify-end gap-4 footer flex-wrap",children:t==="multi"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex gap-x-4 justify-between navigation_container w-full",children:[c.jsxs("div",{children:[" ",m>0&&c.jsxs("button",{type:"button",onClick:R,className:"text-gray-400 hover:text-gray-600 font-medium text-sm flex items-center gap-1 transition-colors back_btn",children:[c.jsx(se,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]}),m<p-1&&c.jsx(Ue,{type:"button",text:"Next",onClick:J,style:{background:(S==null?void 0:S.buttonColor)||"#333"},btnClass:"text-gray-700 next_btn text-sm border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg continue_btn"})]}),(m===p-1||s)&&!i&&(r!=null?r:c.jsx(Ue,{isDisabled:L||Object.keys(M).length>0,isLoading:L,type:"submit",text:"Submit",style:{background:(S==null?void 0:S.buttonColor)||"#333"},btnClass:"text-gray-700 border-[#98A2B3] submit_btn !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg submit_btn"}))]}):!i&&(r!=null?r:c.jsx(Ue,{isDisabled:L||Object.keys(M).length>0,isLoading:L,type:"submit",text:"Submit",style:{background:(S==null?void 0:S.buttonColor)||"#333"},btnClass:"text-gray-700 border-[#98A2B3] submit_btn !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg submit_btn"}))}),t==="conversational"&&I.length>0&&c.jsx("div",{className:"fixed bottom-0 left-0 w-full h-1.5 bg-gray-200",children:c.jsx("div",{className:"h-full bg-blue-600 transition-all duration-500 ease-out",style:{width:`${(h+1)/I.length*100}%`,background:(S==null?void 0:S.buttonColor)||"#2563EB"}})})]})]})},tw=C.memo(sw);function ga({answerData:e,form_data:n,ignoreValidation:i,onSubmit:o,isReadOnly:a=!1,loading:s=!1,config:t={buttonColor:"#333"},renderType:r,children:l,hideFooter:u,onGetValues:d,uploadUrl:b}){C.useEffect(()=>{t&&_c("config",t)},[t]);const m=C.useCallback(f=>{d&&d(f)},[d]);return s?c.jsx(fa,{}):n?c.jsxs("div",{className:"w-full h-full min-w-0",children:[c.jsx("div",{id:"root-portal"}),c.jsx(Qd,{children:c.jsx(tw,{form_data:n,answerData:e,ignoreValidation:i,onSubmitData:o,isReadOnly:a,renderType:r,hideFooter:u,onGetValues:m,uploadUrl:b,children:l})})]}):c.jsx("div",{children:c.jsx("p",{className:"p-6 text-sm text-gray-400",children:"Error: No form data available."})})}function we(e){if(typeof e=="string"||typeof e=="number")return""+e;let n="";if(Array.isArray(e))for(let i=0,o;i<e.length;i++)(o=we(e[i]))!==""&&(n+=(n&&" ")+o);else for(let i in e)e[i]&&(n+=(n&&" ")+i);return n}var rw={value:()=>{}};function Ki(){for(var e=0,n=arguments.length,i={},o;e<n;++e){if(!(o=arguments[e]+"")||o in i||/[\s.]/.test(o))throw new Error("illegal type: "+o);i[o]=[]}return new Hi(i)}function Hi(e){this._=e}function lw(e,n){return e.trim().split(/^|\s+/).map(function(i){var o="",a=i.indexOf(".");if(a>=0&&(o=i.slice(a+1),i=i.slice(0,a)),i&&!n.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:o}})}Hi.prototype=Ki.prototype={constructor:Hi,on:function(e,n){var i=this._,o=lw(e+"",i),a,s=-1,t=o.length;if(arguments.length<2){for(;++s<t;)if((a=(e=o[s]).type)&&(a=uw(i[a],e.name)))return a;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++s<t;)if(a=(e=o[s]).type)i[a]=Oc(i[a],e.name,n);else if(n==null)for(a in i)i[a]=Oc(i[a],e.name,null);return this},copy:function(){var e={},n=this._;for(var i in n)e[i]=n[i].slice();return new Hi(e)},call:function(e,n){if((a=arguments.length-2)>0)for(var i=new Array(a),o=0,a,s;o<a;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],o=0,a=s.length;o<a;++o)s[o].value.apply(n,i)},apply:function(e,n,i){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],a=0,s=o.length;a<s;++a)o[a].value.apply(n,i)}};function uw(e,n){for(var i=0,o=e.length,a;i<o;++i)if((a=e[i]).name===n)return a.value}function Oc(e,n,i){for(var o=0,a=e.length;o<a;++o)if(e[o].name===n){e[o]=rw,e=e.slice(0,o).concat(e.slice(o+1));break}return i!=null&&e.push({name:n,value:i}),e}var ya="http://www.w3.org/1999/xhtml";const Dc={svg:"http://www.w3.org/2000/svg",xhtml:ya,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Vi(e){var n=e+="",i=n.indexOf(":");return i>=0&&(n=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),Dc.hasOwnProperty(n)?{space:Dc[n],local:e}:e}function dw(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===ya&&n.documentElement.namespaceURI===ya?n.createElement(e):n.createElementNS(i,e)}}function cw(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qc(e){var n=Vi(e);return(n.local?cw:dw)(n)}function bw(){}function xa(e){return e==null?bw:function(){return this.querySelector(e)}}function mw(e){typeof e!="function"&&(e=xa(e));for(var n=this._groups,i=n.length,o=new Array(i),a=0;a<i;++a)for(var s=n[a],t=s.length,r=o[a]=new Array(t),l,u,d=0;d<t;++d)(l=s[d])&&(u=e.call(l,l.__data__,d,s))&&("__data__"in l&&(u.__data__=l.__data__),r[d]=u);return new Ie(o,this._parents)}function fw(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function vw(){return[]}function Fc(e){return e==null?vw:function(){return this.querySelectorAll(e)}}function hw(e){return function(){return fw(e.apply(this,arguments))}}function pw(e){typeof e=="function"?e=hw(e):e=Fc(e);for(var n=this._groups,i=n.length,o=[],a=[],s=0;s<i;++s)for(var t=n[s],r=t.length,l,u=0;u<r;++u)(l=t[u])&&(o.push(e.call(l,l.__data__,u,t)),a.push(l));return new Ie(o,a)}function Gc(e){return function(){return this.matches(e)}}function Kc(e){return function(n){return n.matches(e)}}var gw=Array.prototype.find;function yw(e){return function(){return gw.call(this.children,e)}}function xw(){return this.firstElementChild}function Sw(e){return this.select(e==null?xw:yw(typeof e=="function"?e:Kc(e)))}var ww=Array.prototype.filter;function Aw(){return Array.from(this.children)}function Nw(e){return function(){return ww.call(this.children,e)}}function Cw(e){return this.selectAll(e==null?Aw:Nw(typeof e=="function"?e:Kc(e)))}function _w(e){typeof e!="function"&&(e=Gc(e));for(var n=this._groups,i=n.length,o=new Array(i),a=0;a<i;++a)for(var s=n[a],t=s.length,r=o[a]=[],l,u=0;u<t;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&r.push(l);return new Ie(o,this._parents)}function Hc(e){return new Array(e.length)}function Ew(){return new Ie(this._enter||this._groups.map(Hc),this._parents)}function zi(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}zi.prototype={constructor:zi,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function kw(e){return function(){return e}}function Mw(e,n,i,o,a,s){for(var t=0,r,l=n.length,u=s.length;t<u;++t)(r=n[t])?(r.__data__=s[t],o[t]=r):i[t]=new zi(e,s[t]);for(;t<l;++t)(r=n[t])&&(a[t]=r)}function Tw(e,n,i,o,a,s,t){var r,l,u=new Map,d=n.length,b=s.length,m=new Array(d),f;for(r=0;r<d;++r)(l=n[r])&&(m[r]=f=t.call(l,l.__data__,r,n)+"",u.has(f)?a[r]=l:u.set(f,l));for(r=0;r<b;++r)f=t.call(e,s[r],r,s)+"",(l=u.get(f))?(o[r]=l,l.__data__=s[r],u.delete(f)):i[r]=new zi(e,s[r]);for(r=0;r<d;++r)(l=n[r])&&u.get(m[r])===l&&(a[r]=l)}function Pw(e){return e.__data__}function Iw(e,n){if(!arguments.length)return Array.from(this,Pw);var i=n?Tw:Mw,o=this._parents,a=this._groups;typeof e!="function"&&(e=kw(e));for(var s=a.length,t=new Array(s),r=new Array(s),l=new Array(s),u=0;u<s;++u){var d=o[u],b=a[u],m=b.length,f=Lw(e.call(d,d&&d.__data__,u,o)),h=f.length,g=r[u]=new Array(h),v=t[u]=new Array(h),p=l[u]=new Array(m);i(d,b,g,v,p,f,n);for(var S=0,y=0,x,w;S<h;++S)if(x=g[S]){for(S>=y&&(y=S+1);!(w=v[y])&&++y<h;);x._next=w||null}}return t=new Ie(t,o),t._enter=r,t._exit=l,t}function Lw(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Bw(){return new Ie(this._exit||this._groups.map(Hc),this._parents)}function Ow(e,n,i){var o=this.enter(),a=this,s=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),n!=null&&(a=n(a),a&&(a=a.selection())),i==null?s.remove():i(s),o&&a?o.merge(a).order():a}function Dw(e){for(var n=e.selection?e.selection():e,i=this._groups,o=n._groups,a=i.length,s=o.length,t=Math.min(a,s),r=new Array(a),l=0;l<t;++l)for(var u=i[l],d=o[l],b=u.length,m=r[l]=new Array(b),f,h=0;h<b;++h)(f=u[h]||d[h])&&(m[h]=f);for(;l<a;++l)r[l]=i[l];return new Ie(r,this._parents)}function qw(){for(var e=this._groups,n=-1,i=e.length;++n<i;)for(var o=e[n],a=o.length-1,s=o[a],t;--a>=0;)(t=o[a])&&(s&&t.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(t,s),s=t);return this}function Fw(e){e||(e=Gw);function n(b,m){return b&&m?e(b.__data__,m.__data__):!b-!m}for(var i=this._groups,o=i.length,a=new Array(o),s=0;s<o;++s){for(var t=i[s],r=t.length,l=a[s]=new Array(r),u,d=0;d<r;++d)(u=t[d])&&(l[d]=u);l.sort(n)}return new Ie(a,this._parents).order()}function Gw(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function Kw(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Hw(){return Array.from(this)}function Vw(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],a=0,s=o.length;a<s;++a){var t=o[a];if(t)return t}return null}function zw(){let e=0;for(const n of this)++e;return e}function jw(){return!this.node()}function Uw(e){for(var n=this._groups,i=0,o=n.length;i<o;++i)for(var a=n[i],s=0,t=a.length,r;s<t;++s)(r=a[s])&&e.call(r,r.__data__,s,a);return this}function Ww(e){return function(){this.removeAttribute(e)}}function $w(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Yw(e,n){return function(){this.setAttribute(e,n)}}function Jw(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function Zw(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function Xw(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,i)}}function Qw(e,n){var i=Vi(e);if(arguments.length<2){var o=this.node();return i.local?o.getAttributeNS(i.space,i.local):o.getAttribute(i)}return this.each((n==null?i.local?$w:Ww:typeof n=="function"?i.local?Xw:Zw:i.local?Jw:Yw)(i,n))}function Vc(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Rw(e){return function(){this.style.removeProperty(e)}}function eA(e,n,i){return function(){this.style.setProperty(e,n,i)}}function nA(e,n,i){return function(){var o=n.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,i)}}function iA(e,n,i){return arguments.length>1?this.each((n==null?Rw:typeof n=="function"?nA:eA)(e,n,i==null?"":i)):Ln(this.node(),e)}function Ln(e,n){return e.style.getPropertyValue(n)||Vc(e).getComputedStyle(e,null).getPropertyValue(n)}function oA(e){return function(){delete this[e]}}function aA(e,n){return function(){this[e]=n}}function sA(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function tA(e,n){return arguments.length>1?this.each((n==null?oA:typeof n=="function"?sA:aA)(e,n)):this.node()[e]}function zc(e){return e.trim().split(/^|\s+/)}function Sa(e){return e.classList||new jc(e)}function jc(e){this._node=e,this._names=zc(e.getAttribute("class")||"")}jc.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Uc(e,n){for(var i=Sa(e),o=-1,a=n.length;++o<a;)i.add(n[o])}function Wc(e,n){for(var i=Sa(e),o=-1,a=n.length;++o<a;)i.remove(n[o])}function rA(e){return function(){Uc(this,e)}}function lA(e){return function(){Wc(this,e)}}function uA(e,n){return function(){(n.apply(this,arguments)?Uc:Wc)(this,e)}}function dA(e,n){var i=zc(e+"");if(arguments.length<2){for(var o=Sa(this.node()),a=-1,s=i.length;++a<s;)if(!o.contains(i[a]))return!1;return!0}return this.each((typeof n=="function"?uA:n?rA:lA)(i,n))}function cA(){this.textContent=""}function bA(e){return function(){this.textContent=e}}function mA(e){return function(){var n=e.apply(this,arguments);this.textContent=n==null?"":n}}function fA(e){return arguments.length?this.each(e==null?cA:(typeof e=="function"?mA:bA)(e)):this.node().textContent}function vA(){this.innerHTML=""}function hA(e){return function(){this.innerHTML=e}}function pA(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n==null?"":n}}function gA(e){return arguments.length?this.each(e==null?vA:(typeof e=="function"?pA:hA)(e)):this.node().innerHTML}function yA(){this.nextSibling&&this.parentNode.appendChild(this)}function xA(){return this.each(yA)}function SA(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function wA(){return this.each(SA)}function AA(e){var n=typeof e=="function"?e:qc(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function NA(){return null}function CA(e,n){var i=typeof e=="function"?e:qc(e),o=n==null?NA:typeof n=="function"?n:xa(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),o.apply(this,arguments)||null)})}function _A(){var e=this.parentNode;e&&e.removeChild(this)}function EA(){return this.each(_A)}function kA(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function MA(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function TA(e){return this.select(e?MA:kA)}function PA(e){return arguments.length?this.property("__data__",e):this.node().__data__}function IA(e){return function(n){e.call(this,n,this.__data__)}}function LA(e){return e.trim().split(/^|\s+/).map(function(n){var i="",o=n.indexOf(".");return o>=0&&(i=n.slice(o+1),n=n.slice(0,o)),{type:n,name:i}})}function BA(e){return function(){var n=this.__on;if(n){for(var i=0,o=-1,a=n.length,s;i<a;++i)s=n[i],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):n[++o]=s;++o?n.length=o:delete this.__on}}}function OA(e,n,i){return function(){var o=this.__on,a,s=IA(n);if(o){for(var t=0,r=o.length;t<r;++t)if((a=o[t]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=s,a.options=i),a.value=n;return}}this.addEventListener(e.type,s,i),a={type:e.type,name:e.name,value:n,listener:s,options:i},o?o.push(a):this.__on=[a]}}function DA(e,n,i){var o=LA(e+""),a,s=o.length,t;if(arguments.length<2){var r=this.node().__on;if(r){for(var l=0,u=r.length,d;l<u;++l)for(a=0,d=r[l];a<s;++a)if((t=o[a]).type===d.type&&t.name===d.name)return d.value}return}for(r=n?OA:BA,a=0;a<s;++a)this.each(r(o[a],n,i));return this}function $c(e,n,i){var o=Vc(e),a=o.CustomEvent;typeof a=="function"?a=new a(n,i):(a=o.document.createEvent("Event"),i?(a.initEvent(n,i.bubbles,i.cancelable),a.detail=i.detail):a.initEvent(n,!1,!1)),e.dispatchEvent(a)}function qA(e,n){return function(){return $c(this,e,n)}}function FA(e,n){return function(){return $c(this,e,n.apply(this,arguments))}}function GA(e,n){return this.each((typeof n=="function"?FA:qA)(e,n))}function*KA(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],a=0,s=o.length,t;a<s;++a)(t=o[a])&&(yield t)}var Yc=[null];function Ie(e,n){this._groups=e,this._parents=n}function ii(){return new Ie([[document.documentElement]],Yc)}function HA(){return this}Ie.prototype=ii.prototype={constructor:Ie,select:mw,selectAll:pw,selectChild:Sw,selectChildren:Cw,filter:_w,data:Iw,enter:Ew,exit:Bw,join:Ow,merge:Dw,selection:HA,order:qw,sort:Fw,call:Kw,nodes:Hw,node:Vw,size:zw,empty:jw,each:Uw,attr:Qw,style:iA,property:tA,classed:dA,text:fA,html:gA,raise:xA,lower:wA,append:AA,insert:CA,remove:EA,clone:TA,datum:PA,on:DA,dispatch:GA,[Symbol.iterator]:KA};function Le(e){return typeof e=="string"?new Ie([[document.querySelector(e)]],[document.documentElement]):new Ie([[e]],Yc)}function VA(e){let n;for(;n=e.sourceEvent;)e=n;return e}function qe(e,n){if(e=VA(e),n===void 0&&(n=e.currentTarget),n){var i=n.ownerSVGElement||n;if(i.createSVGPoint){var o=i.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(n.getScreenCTM().inverse()),[o.x,o.y]}if(n.getBoundingClientRect){var a=n.getBoundingClientRect();return[e.clientX-a.left-n.clientLeft,e.clientY-a.top-n.clientTop]}}return[e.pageX,e.pageY]}const zA={passive:!1},oi={capture:!0,passive:!1};function wa(e){e.stopImmediatePropagation()}function Bn(e){e.preventDefault(),e.stopImmediatePropagation()}function Jc(e){var n=e.document.documentElement,i=Le(e).on("dragstart.drag",Bn,oi);"onselectstart"in n?i.on("selectstart.drag",Bn,oi):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Zc(e,n){var i=e.document.documentElement,o=Le(e).on("dragstart.drag",null);n&&(o.on("click.drag",Bn,oi),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in i?o.on("selectstart.drag",null):(i.style.MozUserSelect=i.__noselect,delete i.__noselect)}const ji=e=>()=>e;function Aa(e,{sourceEvent:n,subject:i,target:o,identifier:a,active:s,x:t,y:r,dx:l,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:t,enumerable:!0,configurable:!0},y:{value:r,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}Aa.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function jA(e){return!e.ctrlKey&&!e.button}function UA(){return this.parentNode}function WA(e,n){return n==null?{x:e.x,y:e.y}:n}function $A(){return navigator.maxTouchPoints||"ontouchstart"in this}function Xc(){var e=jA,n=UA,i=WA,o=$A,a={},s=Ki("start","drag","end"),t=0,r,l,u,d,b=0;function m(x){x.on("mousedown.drag",f).filter(o).on("touchstart.drag",v).on("touchmove.drag",p,zA).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(x,w){if(!(d||!e.call(this,x,w))){var A=y(this,n.call(this,x,w),x,w,"mouse");A&&(Le(x.view).on("mousemove.drag",h,oi).on("mouseup.drag",g,oi),Jc(x.view),wa(x),u=!1,r=x.clientX,l=x.clientY,A("start",x))}}function h(x){if(Bn(x),!u){var w=x.clientX-r,A=x.clientY-l;u=w*w+A*A>b}a.mouse("drag",x)}function g(x){Le(x.view).on("mousemove.drag mouseup.drag",null),Zc(x.view,u),Bn(x),a.mouse("end",x)}function v(x,w){if(e.call(this,x,w)){var A=x.changedTouches,N=n.call(this,x,w),E=A.length,_,P;for(_=0;_<E;++_)(P=y(this,N,x,w,A[_].identifier,A[_]))&&(wa(x),P("start",x,A[_]))}}function p(x){var w=x.changedTouches,A=w.length,N,E;for(N=0;N<A;++N)(E=a[w[N].identifier])&&(Bn(x),E("drag",x,w[N]))}function S(x){var w=x.changedTouches,A=w.length,N,E;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),N=0;N<A;++N)(E=a[w[N].identifier])&&(wa(x),E("end",x,w[N]))}function y(x,w,A,N,E,_){var P=s.copy(),k=qe(_||A,w),M,L,T;if((T=i.call(x,new Aa("beforestart",{sourceEvent:A,target:m,identifier:E,active:t,x:k[0],y:k[1],dx:0,dy:0,dispatch:P}),N))!=null)return M=T.x-k[0]||0,L=T.y-k[1]||0,function O(B,K,G){var I=k,Y;switch(B){case"start":a[E]=O,Y=t++;break;case"end":delete a[E],--t;case"drag":k=qe(G||K,w),Y=t;break}P.call(B,x,new Aa(B,{sourceEvent:K,subject:T,target:m,identifier:E,active:Y,x:k[0]+M,y:k[1]+L,dx:k[0]-I[0],dy:k[1]-I[1],dispatch:P}),N)}}return m.filter=function(x){return arguments.length?(e=typeof x=="function"?x:ji(!!x),m):e},m.container=function(x){return arguments.length?(n=typeof x=="function"?x:ji(x),m):n},m.subject=function(x){return arguments.length?(i=typeof x=="function"?x:ji(x),m):i},m.touchable=function(x){return arguments.length?(o=typeof x=="function"?x:ji(!!x),m):o},m.on=function(){var x=s.on.apply(s,arguments);return x===s?m:x},m.clickDistance=function(x){return arguments.length?(b=(x=+x)*x,m):Math.sqrt(b)},m}function Na(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function Qc(e,n){var i=Object.create(e.prototype);for(var o in n)i[o]=n[o];return i}function ai(){}var si=.7,Ui=1/si,On="\\s*([+-]?\\d+)\\s*",ti="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",We="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",YA=/^#([0-9a-f]{3,8})$/,JA=new RegExp(`^rgb\\(${On},${On},${On}\\)$`),ZA=new RegExp(`^rgb\\(${We},${We},${We}\\)$`),XA=new RegExp(`^rgba\\(${On},${On},${On},${ti}\\)$`),QA=new RegExp(`^rgba\\(${We},${We},${We},${ti}\\)$`),RA=new RegExp(`^hsl\\(${ti},${We},${We}\\)$`),eN=new RegExp(`^hsla\\(${ti},${We},${We},${ti}\\)$`),Rc={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Na(ai,fn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:eb,formatHex:eb,formatHex8:nN,formatHsl:iN,formatRgb:nb,toString:nb});function eb(){return this.rgb().formatHex()}function nN(){return this.rgb().formatHex8()}function iN(){return tb(this).formatHsl()}function nb(){return this.rgb().formatRgb()}function fn(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=YA.exec(e))?(i=n[1].length,n=parseInt(n[1],16),i===6?ib(n):i===3?new ke(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):i===8?Wi(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?Wi(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=JA.exec(e))?new ke(n[1],n[2],n[3],1):(n=ZA.exec(e))?new ke(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=XA.exec(e))?Wi(n[1],n[2],n[3],n[4]):(n=QA.exec(e))?Wi(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=RA.exec(e))?sb(n[1],n[2]/100,n[3]/100,1):(n=eN.exec(e))?sb(n[1],n[2]/100,n[3]/100,n[4]):Rc.hasOwnProperty(e)?ib(Rc[e]):e==="transparent"?new ke(NaN,NaN,NaN,0):null}function ib(e){return new ke(e>>16&255,e>>8&255,e&255,1)}function Wi(e,n,i,o){return o<=0&&(e=n=i=NaN),new ke(e,n,i,o)}function oN(e){return e instanceof ai||(e=fn(e)),e?(e=e.rgb(),new ke(e.r,e.g,e.b,e.opacity)):new ke}function Ca(e,n,i,o){return arguments.length===1?oN(e):new ke(e,n,i,o==null?1:o)}function ke(e,n,i,o){this.r=+e,this.g=+n,this.b=+i,this.opacity=+o}Na(ke,Ca,Qc(ai,{brighter(e){return e=e==null?Ui:Math.pow(Ui,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?si:Math.pow(si,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ke(vn(this.r),vn(this.g),vn(this.b),$i(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ob,formatHex:ob,formatHex8:aN,formatRgb:ab,toString:ab}));function ob(){return`#${hn(this.r)}${hn(this.g)}${hn(this.b)}`}function aN(){return`#${hn(this.r)}${hn(this.g)}${hn(this.b)}${hn((isNaN(this.opacity)?1:this.opacity)*255)}`}function ab(){const e=$i(this.opacity);return`${e===1?"rgb(":"rgba("}${vn(this.r)}, ${vn(this.g)}, ${vn(this.b)}${e===1?")":`, ${e})`}`}function $i(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function vn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function hn(e){return e=vn(e),(e<16?"0":"")+e.toString(16)}function sb(e,n,i,o){return o<=0?e=n=i=NaN:i<=0||i>=1?e=n=NaN:n<=0&&(e=NaN),new Fe(e,n,i,o)}function tb(e){if(e instanceof Fe)return new Fe(e.h,e.s,e.l,e.opacity);if(e instanceof ai||(e=fn(e)),!e)return new Fe;if(e instanceof Fe)return e;e=e.rgb();var n=e.r/255,i=e.g/255,o=e.b/255,a=Math.min(n,i,o),s=Math.max(n,i,o),t=NaN,r=s-a,l=(s+a)/2;return r?(n===s?t=(i-o)/r+(i<o)*6:i===s?t=(o-n)/r+2:t=(n-i)/r+4,r/=l<.5?s+a:2-s-a,t*=60):r=l>0&&l<1?0:t,new Fe(t,r,l,e.opacity)}function sN(e,n,i,o){return arguments.length===1?tb(e):new Fe(e,n,i,o==null?1:o)}function Fe(e,n,i,o){this.h=+e,this.s=+n,this.l=+i,this.opacity=+o}Na(Fe,sN,Qc(ai,{brighter(e){return e=e==null?Ui:Math.pow(Ui,e),new Fe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?si:Math.pow(si,e),new Fe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,i=this.l,o=i+(i<.5?i:1-i)*n,a=2*i-o;return new ke(_a(e>=240?e-240:e+120,a,o),_a(e,a,o),_a(e<120?e+240:e-120,a,o),this.opacity)},clamp(){return new Fe(rb(this.h),Yi(this.s),Yi(this.l),$i(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=$i(this.opacity);return`${e===1?"hsl(":"hsla("}${rb(this.h)}, ${Yi(this.s)*100}%, ${Yi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function rb(e){return e=(e||0)%360,e<0?e+360:e}function Yi(e){return Math.max(0,Math.min(1,e||0))}function _a(e,n,i){return(e<60?n+(i-n)*e/60:e<180?i:e<240?n+(i-n)*(240-e)/60:n)*255}const Ea=e=>()=>e;function tN(e,n){return function(i){return e+i*n}}function rN(e,n,i){return e=Math.pow(e,i),n=Math.pow(n,i)-e,i=1/i,function(o){return Math.pow(e+o*n,i)}}function lN(e){return(e=+e)==1?lb:function(n,i){return i-n?rN(n,i,e):Ea(isNaN(n)?i:n)}}function lb(e,n){var i=n-e;return i?tN(e,i):Ea(isNaN(e)?n:e)}const Ji=function e(n){var i=lN(n);function o(a,s){var t=i((a=Ca(a)).r,(s=Ca(s)).r),r=i(a.g,s.g),l=i(a.b,s.b),u=lb(a.opacity,s.opacity);return function(d){return a.r=t(d),a.g=r(d),a.b=l(d),a.opacity=u(d),a+""}}return o.gamma=e,o}(1);function uN(e,n){n||(n=[]);var i=e?Math.min(n.length,e.length):0,o=n.slice(),a;return function(s){for(a=0;a<i;++a)o[a]=e[a]*(1-s)+n[a]*s;return o}}function dN(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function cN(e,n){var i=n?n.length:0,o=e?Math.min(i,e.length):0,a=new Array(o),s=new Array(i),t;for(t=0;t<o;++t)a[t]=ri(e[t],n[t]);for(;t<i;++t)s[t]=n[t];return function(r){for(t=0;t<o;++t)s[t]=a[t](r);return s}}function bN(e,n){var i=new Date;return e=+e,n=+n,function(o){return i.setTime(e*(1-o)+n*o),i}}function $e(e,n){return e=+e,n=+n,function(i){return e*(1-i)+n*i}}function mN(e,n){var i={},o={},a;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(a in n)a in e?i[a]=ri(e[a],n[a]):o[a]=n[a];return function(s){for(a in i)o[a]=i[a](s);return o}}var ka=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ma=new RegExp(ka.source,"g");function fN(e){return function(){return e}}function vN(e){return function(n){return e(n)+""}}function ub(e,n){var i=ka.lastIndex=Ma.lastIndex=0,o,a,s,t=-1,r=[],l=[];for(e=e+"",n=n+"";(o=ka.exec(e))&&(a=Ma.exec(n));)(s=a.index)>i&&(s=n.slice(i,s),r[t]?r[t]+=s:r[++t]=s),(o=o[0])===(a=a[0])?r[t]?r[t]+=a:r[++t]=a:(r[++t]=null,l.push({i:t,x:$e(o,a)})),i=Ma.lastIndex;return i<n.length&&(s=n.slice(i),r[t]?r[t]+=s:r[++t]=s),r.length<2?l[0]?vN(l[0].x):fN(n):(n=l.length,function(u){for(var d=0,b;d<n;++d)r[(b=l[d]).i]=b.x(u);return r.join("")})}function ri(e,n){var i=typeof n,o;return n==null||i==="boolean"?Ea(n):(i==="number"?$e:i==="string"?(o=fn(n))?(n=o,Ji):ub:n instanceof fn?Ji:n instanceof Date?bN:dN(n)?uN:Array.isArray(n)?cN:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?mN:$e)(e,n)}var db=180/Math.PI,Ta={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cb(e,n,i,o,a,s){var t,r,l;return(t=Math.sqrt(e*e+n*n))&&(e/=t,n/=t),(l=e*i+n*o)&&(i-=e*l,o-=n*l),(r=Math.sqrt(i*i+o*o))&&(i/=r,o/=r,l/=r),e*o<n*i&&(e=-e,n=-n,l=-l,t=-t),{translateX:a,translateY:s,rotate:Math.atan2(n,e)*db,skewX:Math.atan(l)*db,scaleX:t,scaleY:r}}var Zi;function hN(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Ta:cb(n.a,n.b,n.c,n.d,n.e,n.f)}function pN(e){return e==null||(Zi||(Zi=document.createElementNS("http://www.w3.org/2000/svg","g")),Zi.setAttribute("transform",e),!(e=Zi.transform.baseVal.consolidate()))?Ta:(e=e.matrix,cb(e.a,e.b,e.c,e.d,e.e,e.f))}function bb(e,n,i,o){function a(u){return u.length?u.pop()+" ":""}function s(u,d,b,m,f,h){if(u!==b||d!==m){var g=f.push("translate(",null,n,null,i);h.push({i:g-4,x:$e(u,b)},{i:g-2,x:$e(d,m)})}else(b||m)&&f.push("translate("+b+n+m+i)}function t(u,d,b,m){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),m.push({i:b.push(a(b)+"rotate(",null,o)-2,x:$e(u,d)})):d&&b.push(a(b)+"rotate("+d+o)}function r(u,d,b,m){u!==d?m.push({i:b.push(a(b)+"skewX(",null,o)-2,x:$e(u,d)}):d&&b.push(a(b)+"skewX("+d+o)}function l(u,d,b,m,f,h){if(u!==b||d!==m){var g=f.push(a(f)+"scale(",null,",",null,")");h.push({i:g-4,x:$e(u,b)},{i:g-2,x:$e(d,m)})}else(b!==1||m!==1)&&f.push(a(f)+"scale("+b+","+m+")")}return function(u,d){var b=[],m=[];return u=e(u),d=e(d),s(u.translateX,u.translateY,d.translateX,d.translateY,b,m),t(u.rotate,d.rotate,b,m),r(u.skewX,d.skewX,b,m),l(u.scaleX,u.scaleY,d.scaleX,d.scaleY,b,m),u=d=null,function(f){for(var h=-1,g=m.length,v;++h<g;)b[(v=m[h]).i]=v.x(f);return b.join("")}}}var gN=bb(hN,"px, ","px)","deg)"),yN=bb(pN,", ",")",")"),xN=1e-12;function mb(e){return((e=Math.exp(e))+1/e)/2}function SN(e){return((e=Math.exp(e))-1/e)/2}function wN(e){return((e=Math.exp(2*e))-1)/(e+1)}const Xi=function e(n,i,o){function a(s,t){var r=s[0],l=s[1],u=s[2],d=t[0],b=t[1],m=t[2],f=d-r,h=b-l,g=f*f+h*h,v,p;if(g<xN)p=Math.log(m/u)/n,v=function(N){return[r+N*f,l+N*h,u*Math.exp(n*N*p)]};else{var S=Math.sqrt(g),y=(m*m-u*u+o*g)/(2*u*i*S),x=(m*m-u*u-o*g)/(2*m*i*S),w=Math.log(Math.sqrt(y*y+1)-y),A=Math.log(Math.sqrt(x*x+1)-x);p=(A-w)/n,v=function(N){var E=N*p,_=mb(w),P=u/(i*S)*(_*wN(n*E+w)-SN(w));return[r+P*f,l+P*h,u*_/mb(n*E+w)]}}return v.duration=p*1e3*n/Math.SQRT2,v}return a.rho=function(s){var t=Math.max(.001,+s),r=t*t,l=r*r;return e(t,r,l)},a}(Math.SQRT2,2,4);var Dn=0,li=0,ui=0,fb=1e3,Qi,di,Ri=0,pn=0,eo=0,ci=typeof performance=="object"&&performance.now?performance:Date,vb=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Pa(){return pn||(vb(AN),pn=ci.now()+eo)}function AN(){pn=0}function no(){this._call=this._time=this._next=null}no.prototype=hb.prototype={constructor:no,restart:function(e,n,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?Pa():+i)+(n==null?0:+n),!this._next&&di!==this&&(di?di._next=this:Qi=this,di=this),this._call=e,this._time=i,Ia()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ia())}};function hb(e,n,i){var o=new no;return o.restart(e,n,i),o}function NN(){Pa(),++Dn;for(var e=Qi,n;e;)(n=pn-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Dn}function pb(){pn=(Ri=ci.now())+eo,Dn=li=0;try{NN()}finally{Dn=0,_N(),pn=0}}function CN(){var e=ci.now(),n=e-Ri;n>fb&&(eo-=n,Ri=e)}function _N(){for(var e,n=Qi,i,o=1/0;n;)n._call?(o>n._time&&(o=n._time),e=n,n=n._next):(i=n._next,n._next=null,n=e?e._next=i:Qi=i);di=e,Ia(o)}function Ia(e){if(!Dn){li&&(li=clearTimeout(li));var n=e-pn;n>24?(e<1/0&&(li=setTimeout(pb,e-ci.now()-eo)),ui&&(ui=clearInterval(ui))):(ui||(Ri=ci.now(),ui=setInterval(CN,fb)),Dn=1,vb(pb))}}function gb(e,n,i){var o=new no;return n=n==null?0:+n,o.restart(a=>{o.stop(),e(a+n)},n,i),o}var EN=Ki("start","end","cancel","interrupt"),kN=[],yb=0,xb=1,La=2,io=3,Sb=4,Ba=5,oo=6;function ao(e,n,i,o,a,s){var t=e.__transition;if(!t)e.__transition={};else if(i in t)return;MN(e,i,{name:n,index:o,group:a,on:EN,tween:kN,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:yb})}function Oa(e,n){var i=Ge(e,n);if(i.state>yb)throw new Error("too late; already scheduled");return i}function Ye(e,n){var i=Ge(e,n);if(i.state>io)throw new Error("too late; already running");return i}function Ge(e,n){var i=e.__transition;if(!i||!(i=i[n]))throw new Error("transition not found");return i}function MN(e,n,i){var o=e.__transition,a;o[n]=i,i.timer=hb(s,0,i.time);function s(u){i.state=xb,i.timer.restart(t,i.delay,i.time),i.delay<=u&&t(u-i.delay)}function t(u){var d,b,m,f;if(i.state!==xb)return l();for(d in o)if(f=o[d],f.name===i.name){if(f.state===io)return gb(t);f.state===Sb?(f.state=oo,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete o[d]):+d<n&&(f.state=oo,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete o[d])}if(gb(function(){i.state===io&&(i.state=Sb,i.timer.restart(r,i.delay,i.time),r(u))}),i.state=La,i.on.call("start",e,e.__data__,i.index,i.group),i.state===La){for(i.state=io,a=new Array(m=i.tween.length),d=0,b=-1;d<m;++d)(f=i.tween[d].value.call(e,e.__data__,i.index,i.group))&&(a[++b]=f);a.length=b+1}}function r(u){for(var d=u<i.duration?i.ease.call(null,u/i.duration):(i.timer.restart(l),i.state=Ba,1),b=-1,m=a.length;++b<m;)a[b].call(e,d);i.state===Ba&&(i.on.call("end",e,e.__data__,i.index,i.group),l())}function l(){i.state=oo,i.timer.stop(),delete o[n];for(var u in o)return;delete e.__transition}}function so(e,n){var i=e.__transition,o,a,s=!0,t;if(i){n=n==null?null:n+"";for(t in i){if((o=i[t]).name!==n){s=!1;continue}a=o.state>La&&o.state<Ba,o.state=oo,o.timer.stop(),o.on.call(a?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete i[t]}s&&delete e.__transition}}function TN(e){return this.each(function(){so(this,e)})}function PN(e,n){var i,o;return function(){var a=Ye(this,e),s=a.tween;if(s!==i){o=i=s;for(var t=0,r=o.length;t<r;++t)if(o[t].name===n){o=o.slice(),o.splice(t,1);break}}a.tween=o}}function IN(e,n,i){var o,a;if(typeof i!="function")throw new Error;return function(){var s=Ye(this,e),t=s.tween;if(t!==o){a=(o=t).slice();for(var r={name:n,value:i},l=0,u=a.length;l<u;++l)if(a[l].name===n){a[l]=r;break}l===u&&a.push(r)}s.tween=a}}function LN(e,n){var i=this._id;if(e+="",arguments.length<2){for(var o=Ge(this.node(),i).tween,a=0,s=o.length,t;a<s;++a)if((t=o[a]).name===e)return t.value;return null}return this.each((n==null?PN:IN)(i,e,n))}function Da(e,n,i){var o=e._id;return e.each(function(){var a=Ye(this,o);(a.value||(a.value={}))[n]=i.apply(this,arguments)}),function(a){return Ge(a,o).value[n]}}function wb(e,n){var i;return(typeof n=="number"?$e:n instanceof fn?Ji:(i=fn(n))?(n=i,Ji):ub)(e,n)}function BN(e){return function(){this.removeAttribute(e)}}function ON(e){return function(){this.removeAttributeNS(e.space,e.local)}}function DN(e,n,i){var o,a=i+"",s;return function(){var t=this.getAttribute(e);return t===a?null:t===o?s:s=n(o=t,i)}}function qN(e,n,i){var o,a=i+"",s;return function(){var t=this.getAttributeNS(e.space,e.local);return t===a?null:t===o?s:s=n(o=t,i)}}function FN(e,n,i){var o,a,s;return function(){var t,r=i(this),l;return r==null?void this.removeAttribute(e):(t=this.getAttribute(e),l=r+"",t===l?null:t===o&&l===a?s:(a=l,s=n(o=t,r)))}}function GN(e,n,i){var o,a,s;return function(){var t,r=i(this),l;return r==null?void this.removeAttributeNS(e.space,e.local):(t=this.getAttributeNS(e.space,e.local),l=r+"",t===l?null:t===o&&l===a?s:(a=l,s=n(o=t,r)))}}function KN(e,n){var i=Vi(e),o=i==="transform"?yN:wb;return this.attrTween(e,typeof n=="function"?(i.local?GN:FN)(i,o,Da(this,"attr."+e,n)):n==null?(i.local?ON:BN)(i):(i.local?qN:DN)(i,o,n))}function HN(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function VN(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function zN(e,n){var i,o;function a(){var s=n.apply(this,arguments);return s!==o&&(i=(o=s)&&VN(e,s)),i}return a._value=n,a}function jN(e,n){var i,o;function a(){var s=n.apply(this,arguments);return s!==o&&(i=(o=s)&&HN(e,s)),i}return a._value=n,a}function UN(e,n){var i="attr."+e;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(n==null)return this.tween(i,null);if(typeof n!="function")throw new Error;var o=Vi(e);return this.tween(i,(o.local?zN:jN)(o,n))}function WN(e,n){return function(){Oa(this,e).delay=+n.apply(this,arguments)}}function $N(e,n){return n=+n,function(){Oa(this,e).delay=n}}function YN(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?WN:$N)(n,e)):Ge(this.node(),n).delay}function JN(e,n){return function(){Ye(this,e).duration=+n.apply(this,arguments)}}function ZN(e,n){return n=+n,function(){Ye(this,e).duration=n}}function XN(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?JN:ZN)(n,e)):Ge(this.node(),n).duration}function QN(e,n){if(typeof n!="function")throw new Error;return function(){Ye(this,e).ease=n}}function RN(e){var n=this._id;return arguments.length?this.each(QN(n,e)):Ge(this.node(),n).ease}function eC(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;Ye(this,e).ease=i}}function nC(e){if(typeof e!="function")throw new Error;return this.each(eC(this._id,e))}function iC(e){typeof e!="function"&&(e=Gc(e));for(var n=this._groups,i=n.length,o=new Array(i),a=0;a<i;++a)for(var s=n[a],t=s.length,r=o[a]=[],l,u=0;u<t;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&r.push(l);return new Qe(o,this._parents,this._name,this._id)}function oC(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,i=e._groups,o=n.length,a=i.length,s=Math.min(o,a),t=new Array(o),r=0;r<s;++r)for(var l=n[r],u=i[r],d=l.length,b=t[r]=new Array(d),m,f=0;f<d;++f)(m=l[f]||u[f])&&(b[f]=m);for(;r<o;++r)t[r]=n[r];return new Qe(t,this._parents,this._name,this._id)}function aC(e){return(e+"").trim().split(/^|\s+/).every(function(n){var i=n.indexOf(".");return i>=0&&(n=n.slice(0,i)),!n||n==="start"})}function sC(e,n,i){var o,a,s=aC(n)?Oa:Ye;return function(){var t=s(this,e),r=t.on;r!==o&&(a=(o=r).copy()).on(n,i),t.on=a}}function tC(e,n){var i=this._id;return arguments.length<2?Ge(this.node(),i).on.on(e):this.each(sC(i,e,n))}function rC(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function lC(){return this.on("end.remove",rC(this._id))}function uC(e){var n=this._name,i=this._id;typeof e!="function"&&(e=xa(e));for(var o=this._groups,a=o.length,s=new Array(a),t=0;t<a;++t)for(var r=o[t],l=r.length,u=s[t]=new Array(l),d,b,m=0;m<l;++m)(d=r[m])&&(b=e.call(d,d.__data__,m,r))&&("__data__"in d&&(b.__data__=d.__data__),u[m]=b,ao(u[m],n,i,m,u,Ge(d,i)));return new Qe(s,this._parents,n,i)}function dC(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Fc(e));for(var o=this._groups,a=o.length,s=[],t=[],r=0;r<a;++r)for(var l=o[r],u=l.length,d,b=0;b<u;++b)if(d=l[b]){for(var m=e.call(d,d.__data__,b,l),f,h=Ge(d,i),g=0,v=m.length;g<v;++g)(f=m[g])&&ao(f,n,i,g,m,h);s.push(m),t.push(d)}return new Qe(s,t,n,i)}var cC=ii.prototype.constructor;function bC(){return new cC(this._groups,this._parents)}function mC(e,n){var i,o,a;return function(){var s=Ln(this,e),t=(this.style.removeProperty(e),Ln(this,e));return s===t?null:s===i&&t===o?a:a=n(i=s,o=t)}}function Ab(e){return function(){this.style.removeProperty(e)}}function fC(e,n,i){var o,a=i+"",s;return function(){var t=Ln(this,e);return t===a?null:t===o?s:s=n(o=t,i)}}function vC(e,n,i){var o,a,s;return function(){var t=Ln(this,e),r=i(this),l=r+"";return r==null&&(l=r=(this.style.removeProperty(e),Ln(this,e))),t===l?null:t===o&&l===a?s:(a=l,s=n(o=t,r))}}function hC(e,n){var i,o,a,s="style."+n,t="end."+s,r;return function(){var l=Ye(this,e),u=l.on,d=l.value[s]==null?r||(r=Ab(n)):void 0;(u!==i||a!==d)&&(o=(i=u).copy()).on(t,a=d),l.on=o}}function pC(e,n,i){var o=(e+="")=="transform"?gN:wb;return n==null?this.styleTween(e,mC(e,o)).on("end.style."+e,Ab(e)):typeof n=="function"?this.styleTween(e,vC(e,o,Da(this,"style."+e,n))).each(hC(this._id,e)):this.styleTween(e,fC(e,o,n),i).on("end.style."+e,null)}function gC(e,n,i){return function(o){this.style.setProperty(e,n.call(this,o),i)}}function yC(e,n,i){var o,a;function s(){var t=n.apply(this,arguments);return t!==a&&(o=(a=t)&&gC(e,t,i)),o}return s._value=n,s}function xC(e,n,i){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(n==null)return this.tween(o,null);if(typeof n!="function")throw new Error;return this.tween(o,yC(e,n,i==null?"":i))}function SC(e){return function(){this.textContent=e}}function wC(e){return function(){var n=e(this);this.textContent=n==null?"":n}}function AC(e){return this.tween("text",typeof e=="function"?wC(Da(this,"text",e)):SC(e==null?"":e+""))}function NC(e){return function(n){this.textContent=e.call(this,n)}}function CC(e){var n,i;function o(){var a=e.apply(this,arguments);return a!==i&&(n=(i=a)&&NC(a)),n}return o._value=e,o}function _C(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,CC(e))}function EC(){for(var e=this._name,n=this._id,i=Nb(),o=this._groups,a=o.length,s=0;s<a;++s)for(var t=o[s],r=t.length,l,u=0;u<r;++u)if(l=t[u]){var d=Ge(l,n);ao(l,e,i,u,t,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Qe(o,this._parents,e,i)}function kC(){var e,n,i=this,o=i._id,a=i.size();return new Promise(function(s,t){var r={value:t},l={value:function(){--a===0&&s()}};i.each(function(){var u=Ye(this,o),d=u.on;d!==e&&(n=(e=d).copy(),n._.cancel.push(r),n._.interrupt.push(r),n._.end.push(l)),u.on=n}),a===0&&s()})}var MC=0;function Qe(e,n,i,o){this._groups=e,this._parents=n,this._name=i,this._id=o}function Nb(){return++MC}var Re=ii.prototype;Qe.prototype={constructor:Qe,select:uC,selectAll:dC,selectChild:Re.selectChild,selectChildren:Re.selectChildren,filter:iC,merge:oC,selection:bC,transition:EC,call:Re.call,nodes:Re.nodes,node:Re.node,size:Re.size,empty:Re.empty,each:Re.each,on:tC,attr:KN,attrTween:UN,style:pC,styleTween:xC,text:AC,textTween:_C,remove:lC,tween:LN,delay:YN,duration:XN,ease:RN,easeVarying:nC,end:kC,[Symbol.iterator]:Re[Symbol.iterator]};function TC(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var PC={time:null,delay:0,duration:250,ease:TC};function IC(e,n){for(var i;!(i=e.__transition)||!(i=i[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return i}function LC(e){var n,i;e instanceof Qe?(n=e._id,e=e._name):(n=Nb(),(i=PC).time=Pa(),e=e==null?null:e+"");for(var o=this._groups,a=o.length,s=0;s<a;++s)for(var t=o[s],r=t.length,l,u=0;u<r;++u)(l=t[u])&&ao(l,e,n,u,t,i||IC(l,n));return new Qe(o,this._parents,e,n)}ii.prototype.interrupt=TN,ii.prototype.transition=LC;const to=e=>()=>e;function BC(e,{sourceEvent:n,target:i,transform:o,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:a}})}function en(e,n,i){this.k=e,this.x=n,this.y=i}en.prototype={constructor:en,scale:function(e){return e===1?this:new en(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new en(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ro=new en(1,0,0);Cb.prototype=en.prototype;function Cb(e){for(;!e.__zoom;)if(!(e=e.parentNode))return ro;return e.__zoom}function qa(e){e.stopImmediatePropagation()}function bi(e){e.preventDefault(),e.stopImmediatePropagation()}function OC(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function DC(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function _b(){return this.__zoom||ro}function qC(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function FC(){return navigator.maxTouchPoints||"ontouchstart"in this}function GC(e,n,i){var o=e.invertX(n[0][0])-i[0][0],a=e.invertX(n[1][0])-i[1][0],s=e.invertY(n[0][1])-i[0][1],t=e.invertY(n[1][1])-i[1][1];return e.translate(a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a),t>s?(s+t)/2:Math.min(0,s)||Math.max(0,t))}function Eb(){var e=OC,n=DC,i=GC,o=qC,a=FC,s=[0,1/0],t=[[-1/0,-1/0],[1/0,1/0]],r=250,l=Xi,u=Ki("start","zoom","end"),d,b,m,f=500,h=150,g=0,v=10;function p(T){T.property("__zoom",_b).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",P).filter(a).on("touchstart.zoom",k).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}p.transform=function(T,O,B,K){var G=T.selection?T.selection():T;G.property("__zoom",_b),T!==G?w(T,O,B,K):G.interrupt().each(function(){A(this,arguments).event(K).start().zoom(null,typeof O=="function"?O.apply(this,arguments):O).end()})},p.scaleBy=function(T,O,B,K){p.scaleTo(T,function(){var G=this.__zoom.k,I=typeof O=="function"?O.apply(this,arguments):O;return G*I},B,K)},p.scaleTo=function(T,O,B,K){p.transform(T,function(){var G=n.apply(this,arguments),I=this.__zoom,Y=B==null?x(G):typeof B=="function"?B.apply(this,arguments):B,Z=I.invert(Y),J=typeof O=="function"?O.apply(this,arguments):O;return i(y(S(I,J),Y,Z),G,t)},B,K)},p.translateBy=function(T,O,B,K){p.transform(T,function(){return i(this.__zoom.translate(typeof O=="function"?O.apply(this,arguments):O,typeof B=="function"?B.apply(this,arguments):B),n.apply(this,arguments),t)},null,K)},p.translateTo=function(T,O,B,K,G){p.transform(T,function(){var I=n.apply(this,arguments),Y=this.__zoom,Z=K==null?x(I):typeof K=="function"?K.apply(this,arguments):K;return i(ro.translate(Z[0],Z[1]).scale(Y.k).translate(typeof O=="function"?-O.apply(this,arguments):-O,typeof B=="function"?-B.apply(this,arguments):-B),I,t)},K,G)};function S(T,O){return O=Math.max(s[0],Math.min(s[1],O)),O===T.k?T:new en(O,T.x,T.y)}function y(T,O,B){var K=O[0]-B[0]*T.k,G=O[1]-B[1]*T.k;return K===T.x&&G===T.y?T:new en(T.k,K,G)}function x(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function w(T,O,B,K){T.on("start.zoom",function(){A(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(K).end()}).tween("zoom",function(){var G=this,I=arguments,Y=A(G,I).event(K),Z=n.apply(G,I),J=B==null?x(Z):typeof B=="function"?B.apply(G,I):B,R=Math.max(Z[1][0]-Z[0][0],Z[1][1]-Z[0][1]),D=G.__zoom,H=typeof O=="function"?O.apply(G,I):O,U=l(D.invert(J).concat(R/D.k),H.invert(J).concat(R/H.k));return function(q){if(q===1)q=H;else{var F=U(q),W=R/F[2];q=new en(W,J[0]-F[0]*W,J[1]-F[1]*W)}Y.zoom(null,q)}})}function A(T,O,B){return!B&&T.__zooming||new N(T,O)}function N(T,O){this.that=T,this.args=O,this.active=0,this.sourceEvent=null,this.extent=n.apply(T,O),this.taps=0}N.prototype={event:function(T){return T&&(this.sourceEvent=T),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(T,O){return this.mouse&&T!=="mouse"&&(this.mouse[1]=O.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=O.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=O.invert(this.touch1[0])),this.that.__zoom=O,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var O=Le(this.that).datum();u.call(T,this.that,new BC(T,{sourceEvent:this.sourceEvent,target:p,transform:this.that.__zoom,dispatch:u}),O)}};function E(T,...O){if(!e.apply(this,arguments))return;var B=A(this,O).event(T),K=this.__zoom,G=Math.max(s[0],Math.min(s[1],K.k*Math.pow(2,o.apply(this,arguments)))),I=qe(T);if(B.wheel)(B.mouse[0][0]!==I[0]||B.mouse[0][1]!==I[1])&&(B.mouse[1]=K.invert(B.mouse[0]=I)),clearTimeout(B.wheel);else{if(K.k===G)return;B.mouse=[I,K.invert(I)],so(this),B.start()}bi(T),B.wheel=setTimeout(Y,h),B.zoom("mouse",i(y(S(K,G),B.mouse[0],B.mouse[1]),B.extent,t));function Y(){B.wheel=null,B.end()}}function _(T,...O){if(m||!e.apply(this,arguments))return;var B=T.currentTarget,K=A(this,O,!0).event(T),G=Le(T.view).on("mousemove.zoom",J,!0).on("mouseup.zoom",R,!0),I=qe(T,B),Y=T.clientX,Z=T.clientY;Jc(T.view),qa(T),K.mouse=[I,this.__zoom.invert(I)],so(this),K.start();function J(D){if(bi(D),!K.moved){var H=D.clientX-Y,U=D.clientY-Z;K.moved=H*H+U*U>g}K.event(D).zoom("mouse",i(y(K.that.__zoom,K.mouse[0]=qe(D,B),K.mouse[1]),K.extent,t))}function R(D){G.on("mousemove.zoom mouseup.zoom",null),Zc(D.view,K.moved),bi(D),K.event(D).end()}}function P(T,...O){if(e.apply(this,arguments)){var B=this.__zoom,K=qe(T.changedTouches?T.changedTouches[0]:T,this),G=B.invert(K),I=B.k*(T.shiftKey?.5:2),Y=i(y(S(B,I),K,G),n.apply(this,O),t);bi(T),r>0?Le(this).transition().duration(r).call(w,Y,K,T):Le(this).call(p.transform,Y,K,T)}}function k(T,...O){if(e.apply(this,arguments)){var B=T.touches,K=B.length,G=A(this,O,T.changedTouches.length===K).event(T),I,Y,Z,J;for(qa(T),Y=0;Y<K;++Y)Z=B[Y],J=qe(Z,this),J=[J,this.__zoom.invert(J),Z.identifier],G.touch0?!G.touch1&&G.touch0[2]!==J[2]&&(G.touch1=J,G.taps=0):(G.touch0=J,I=!0,G.taps=1+!!d);d&&(d=clearTimeout(d)),I&&(G.taps<2&&(b=J[0],d=setTimeout(function(){d=null},f)),so(this),G.start())}}function M(T,...O){if(this.__zooming){var B=A(this,O).event(T),K=T.changedTouches,G=K.length,I,Y,Z,J;for(bi(T),I=0;I<G;++I)Y=K[I],Z=qe(Y,this),B.touch0&&B.touch0[2]===Y.identifier?B.touch0[0]=Z:B.touch1&&B.touch1[2]===Y.identifier&&(B.touch1[0]=Z);if(Y=B.that.__zoom,B.touch1){var R=B.touch0[0],D=B.touch0[1],H=B.touch1[0],U=B.touch1[1],q=(q=H[0]-R[0])*q+(q=H[1]-R[1])*q,F=(F=U[0]-D[0])*F+(F=U[1]-D[1])*F;Y=S(Y,Math.sqrt(q/F)),Z=[(R[0]+H[0])/2,(R[1]+H[1])/2],J=[(D[0]+U[0])/2,(D[1]+U[1])/2]}else if(B.touch0)Z=B.touch0[0],J=B.touch0[1];else return;B.zoom("touch",i(y(Y,Z,J),B.extent,t))}}function L(T,...O){if(this.__zooming){var B=A(this,O).event(T),K=T.changedTouches,G=K.length,I,Y;for(qa(T),m&&clearTimeout(m),m=setTimeout(function(){m=null},f),I=0;I<G;++I)Y=K[I],B.touch0&&B.touch0[2]===Y.identifier?delete B.touch0:B.touch1&&B.touch1[2]===Y.identifier&&delete B.touch1;if(B.touch1&&!B.touch0&&(B.touch0=B.touch1,delete B.touch1),B.touch0)B.touch0[1]=this.__zoom.invert(B.touch0[0]);else if(B.end(),B.taps===2&&(Y=qe(Y,this),Math.hypot(b[0]-Y[0],b[1]-Y[1])<v)){var Z=Le(this).on("dblclick.zoom");Z&&Z.apply(this,arguments)}}}return p.wheelDelta=function(T){return arguments.length?(o=typeof T=="function"?T:to(+T),p):o},p.filter=function(T){return arguments.length?(e=typeof T=="function"?T:to(!!T),p):e},p.touchable=function(T){return arguments.length?(a=typeof T=="function"?T:to(!!T),p):a},p.extent=function(T){return arguments.length?(n=typeof T=="function"?T:to([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),p):n},p.scaleExtent=function(T){return arguments.length?(s[0]=+T[0],s[1]=+T[1],p):[s[0],s[1]]},p.translateExtent=function(T){return arguments.length?(t[0][0]=+T[0][0],t[1][0]=+T[1][0],t[0][1]=+T[0][1],t[1][1]=+T[1][1],p):[[t[0][0],t[0][1]],[t[1][0],t[1][1]]]},p.constrain=function(T){return arguments.length?(i=T,p):i},p.duration=function(T){return arguments.length?(r=+T,p):r},p.interpolate=function(T){return arguments.length?(l=T,p):l},p.on=function(){var T=u.on.apply(u,arguments);return T===u?p:T},p.clickDistance=function(T){return arguments.length?(g=(T=+T)*T,p):Math.sqrt(g)},p.tapDistance=function(T){return arguments.length?(v=+T,p):v},p}const Be={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:n,sourceHandle:i,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?i:o}", edge id: ${n}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},mi=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],kb=["Enter"," ","Escape"],Mb={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:n,y:i})=>`Moved selected node ${e}. New position, x: ${n}, y: ${i}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var qn;(function(e){e.Strict="strict",e.Loose="loose"})(qn||(qn={}));var gn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(gn||(gn={}));var fi;(function(e){e.Partial="partial",e.Full="full"})(fi||(fi={}));const Tb={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ln;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ln||(ln={}));var Fn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Fn||(Fn={}));var oe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(oe||(oe={}));const Pb={[oe.Left]:oe.Right,[oe.Right]:oe.Left,[oe.Top]:oe.Bottom,[oe.Bottom]:oe.Top};function Ib(e){return e===null?null:e?"valid":"invalid"}const Lb=e=>"id"in e&&"source"in e&&"target"in e,KC=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Fa=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vi=(e,n=[0,0])=>{var r;const{width:i,height:o}=nn(e),a=(r=e.origin)!=null?r:n,s=i*a[0],t=o*a[1];return{x:e.position.x-s,y:e.position.y-t}},HC=(e,n={nodeOrigin:[0,0]})=>{if(process.env.NODE_ENV==="development"&&!n.nodeLookup&&console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."),e.length===0)return{x:0,y:0,width:0,height:0};const i=e.reduce((o,a)=>{const s=typeof a=="string";let t=!n.nodeLookup&&!s?a:void 0;n.nodeLookup&&(t=s?n.nodeLookup.get(a):Fa(a)?a:n.nodeLookup.get(a.id));const r=t?co(t,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return lo(o,r)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return uo(i)},hi=(e,n={})=>{let i={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(a=>{(n.filter===void 0||n.filter(a))&&(i=lo(i,co(a)),o=!0)}),o?uo(i):{x:0,y:0,width:0,height:0}},Ga=(e,n,[i,o,a]=[0,0,1],s=!1,t=!1)=>{var m,f,h,g,v,p;const r=(n.x-i)/a,l=(n.y-o)/a,u=n.width/a,d=n.height/a,b=[];for(const S of e.values()){const{measured:y,selectable:x=!0,hidden:w=!1}=S;if(t&&!x||w)continue;const A=(h=(f=(m=y.width)!=null?m:S.width)!=null?f:S.initialWidth)!=null?h:0,N=(p=(v=(g=y.height)!=null?g:S.height)!=null?v:S.initialHeight)!=null?p:0,{x:E,y:_}=S.internals.positionAbsolute,P=Fb(r,l,u,d,E,_,A,N),k=A*N,M=s&&P>0;(!S.internals.handleBounds||M||P>=k||S.dragging)&&b.push(S)}return b},VC=(e,n)=>{const i=new Set;return e.forEach(o=>{i.add(o.id)}),n.filter(o=>i.has(o.source)||i.has(o.target))};function zC(e,n){const i=new Map,o=n!=null&&n.nodes?new Set(n.nodes.map(a=>a.id)):null;return e.forEach(a=>{a.measured.width&&a.measured.height&&((n==null?void 0:n.includeHiddenNodes)||!a.hidden)&&(!o||o.has(a.id))&&i.set(a.id,a)}),i}async function jC({nodes:e,width:n,height:i,panZoom:o,minZoom:a,maxZoom:s},t){var d,b,m;if(e.size===0)return!0;const r=zC(e,t),l=hi(r),u=Va(l,n,i,(d=t==null?void 0:t.minZoom)!=null?d:a,(b=t==null?void 0:t.maxZoom)!=null?b:s,(m=t==null?void 0:t.padding)!=null?m:.1);return await o.setViewport(u,{duration:t==null?void 0:t.duration,ease:t==null?void 0:t.ease,interpolate:t==null?void 0:t.interpolate}),!0}function Bb({nodeId:e,nextPosition:n,nodeLookup:i,nodeOrigin:o=[0,0],nodeExtent:a,onError:s}){var f,h,g;const t=i.get(e),r=t.parentId?i.get(t.parentId):void 0,{x:l,y:u}=r?r.internals.positionAbsolute:{x:0,y:0},d=(f=t.origin)!=null?f:o;let b=t.extent||a;if(t.extent==="parent"&&!t.expandParent)if(!r)s==null||s("005",Be.error005());else{const v=r.measured.width,p=r.measured.height;v&&p&&(b=[[l,u],[l+v,u+p]])}else r&&xn(t.extent)&&(b=[[t.extent[0][0]+l,t.extent[0][1]+u],[t.extent[1][0]+l,t.extent[1][1]+u]]);const m=xn(b)?yn(n,b,t.measured):n;return(t.measured.width===void 0||t.measured.height===void 0)&&(s==null||s("015",Be.error015())),{position:{x:m.x-l+((h=t.measured.width)!=null?h:0)*d[0],y:m.y-u+((g=t.measured.height)!=null?g:0)*d[1]},positionAbsolute:m}}async function UC({nodesToRemove:e=[],edgesToRemove:n=[],nodes:i,edges:o,onBeforeDelete:a}){const s=new Set(e.map(m=>m.id)),t=[];for(const m of i){if(m.deletable===!1)continue;const f=s.has(m.id),h=!f&&m.parentId&&t.find(g=>g.id===m.parentId);(f||h)&&t.push(m)}const r=new Set(n.map(m=>m.id)),l=o.filter(m=>m.deletable!==!1),d=VC(t,l);for(const m of l)r.has(m.id)&&!d.find(h=>h.id===m.id)&&d.push(m);if(!a)return{edges:d,nodes:t};const b=await a({nodes:t,edges:d});return typeof b=="boolean"?b?{edges:d,nodes:t}:{edges:[],nodes:[]}:b}const Gn=(e,n=0,i=1)=>Math.min(Math.max(e,n),i),yn=(e={x:0,y:0},n,i)=>{var o,a;return{x:Gn(e.x,n[0][0],n[1][0]-((o=i==null?void 0:i.width)!=null?o:0)),y:Gn(e.y,n[0][1],n[1][1]-((a=i==null?void 0:i.height)!=null?a:0))}};function Ob(e,n,i){const{width:o,height:a}=nn(i),{x:s,y:t}=i.internals.positionAbsolute;return yn(e,[[s,t],[s+o,t+a]],n)}const Db=(e,n,i)=>e<n?Gn(Math.abs(e-n),1,n)/n:e>i?-Gn(Math.abs(e-i),1,n)/n:0,Ka=(e,n,i=15,o=40)=>{const a=Db(e.x,o,n.width-o)*i,s=Db(e.y,o,n.height-o)*i;return[a,s]},lo=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),Ha=({x:e,y:n,width:i,height:o})=>({x:e,y:n,x2:e+i,y2:n+o}),uo=({x:e,y:n,x2:i,y2:o})=>({x:e,y:n,width:i-e,height:o-n}),pi=(e,n=[0,0])=>{var a,s,t,r,l,u,d,b;const{x:i,y:o}=Fa(e)?e.internals.positionAbsolute:vi(e,n);return{x:i,y:o,width:(r=(t=(s=(a=e.measured)==null?void 0:a.width)!=null?s:e.width)!=null?t:e.initialWidth)!=null?r:0,height:(b=(d=(u=(l=e.measured)==null?void 0:l.height)!=null?u:e.height)!=null?d:e.initialHeight)!=null?b:0}},co=(e,n=[0,0])=>{var a,s,t,r,l,u,d,b;const{x:i,y:o}=Fa(e)?e.internals.positionAbsolute:vi(e,n);return{x:i,y:o,x2:i+((r=(t=(s=(a=e.measured)==null?void 0:a.width)!=null?s:e.width)!=null?t:e.initialWidth)!=null?r:0),y2:o+((b=(d=(u=(l=e.measured)==null?void 0:l.height)!=null?u:e.height)!=null?d:e.initialHeight)!=null?b:0)}},qb=(e,n)=>uo(lo(Ha(e),Ha(n))),Fb=(e,n,i,o,a,s,t,r)=>{const l=Math.max(0,Math.min(e+i,a+t)-Math.max(e,a)),u=Math.max(0,Math.min(n+o,s+r)-Math.max(n,s));return Math.ceil(l*u)},bo=(e,n)=>Fb(e.x,e.y,e.width,e.height,n.x,n.y,n.width,n.height),Gb=e=>Ke(e.width)&&Ke(e.height)&&Ke(e.x)&&Ke(e.y),Ke=e=>!isNaN(e)&&isFinite(e),Kb=(e,n)=>(i,o)=>{process.env.NODE_ENV==="development"&&console.warn(`[${e}]: ${o} Help: ${n}error#${i}`)},gi=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),yi=({x:e,y:n},[i,o,a],s=!1,t=[1,1])=>{const r={x:(e-i)/a,y:(n-o)/a};return s?gi(r,t):r},Kn=({x:e,y:n},[i,o,a])=>({x:e*a+i,y:n*a+o});function Hn(e,n){if(typeof e=="number")return Math.floor((n-n/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const i=parseFloat(e);if(!Number.isNaN(i))return Math.floor(i)}if(typeof e=="string"&&e.endsWith("%")){const i=parseFloat(e);if(!Number.isNaN(i))return Math.floor(n*i*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function WC(e,n,i){var o,a,s,t,r,l,u,d;if(typeof e=="string"||typeof e=="number"){const b=Hn(e,i),m=Hn(e,n);return{top:b,right:m,bottom:b,left:m,x:m*2,y:b*2}}if(typeof e=="object"){const b=Hn((a=(o=e.top)!=null?o:e.y)!=null?a:0,i),m=Hn((t=(s=e.bottom)!=null?s:e.y)!=null?t:0,i),f=Hn((l=(r=e.left)!=null?r:e.x)!=null?l:0,n),h=Hn((d=(u=e.right)!=null?u:e.x)!=null?d:0,n);return{top:b,right:h,bottom:m,left:f,x:f+h,y:b+m}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function $C(e,n,i,o,a,s){const{x:t,y:r}=Kn(e,[n,i,o]),{x:l,y:u}=Kn({x:e.x+e.width,y:e.y+e.height},[n,i,o]),d=a-l,b=s-u;return{left:Math.floor(t),top:Math.floor(r),right:Math.floor(d),bottom:Math.floor(b)}}const Va=(e,n,i,o,a,s)=>{const t=WC(s,n,i),r=(n-t.x)/e.width,l=(i-t.y)/e.height,u=Math.min(r,l),d=Gn(u,o,a),b=e.x+e.width/2,m=e.y+e.height/2,f=n/2-b*d,h=i/2-m*d,g=$C(e,f,h,d,n,i),v={left:Math.min(g.left-t.left,0),top:Math.min(g.top-t.top,0),right:Math.min(g.right-t.right,0),bottom:Math.min(g.bottom-t.bottom,0)};return{x:f-v.left+v.right,y:h-v.top+v.bottom,zoom:d}},xi=()=>{var e;return typeof navigator!="undefined"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function xn(e){return e!=null&&e!=="parent"}function nn(e){var n,i,o,a,s,t,r,l;return{width:(a=(o=(i=(n=e.measured)==null?void 0:n.width)!=null?i:e.width)!=null?o:e.initialWidth)!=null?a:0,height:(l=(r=(t=(s=e.measured)==null?void 0:s.height)!=null?t:e.height)!=null?r:e.initialHeight)!=null?l:0}}function Hb(e){var n,i,o,a,s,t;return((o=(i=(n=e.measured)==null?void 0:n.width)!=null?i:e.width)!=null?o:e.initialWidth)!==void 0&&((t=(s=(a=e.measured)==null?void 0:a.height)!=null?s:e.height)!=null?t:e.initialHeight)!==void 0}function Vb(e,n={width:0,height:0},i,o,a){var r,l;const s={...e},t=o.get(i);if(t){const u=t.origin||a;s.x+=t.internals.positionAbsolute.x-((r=n.width)!=null?r:0)*u[0],s.y+=t.internals.positionAbsolute.y-((l=n.height)!=null?l:0)*u[1]}return s}function zb(e,n){if(e.size!==n.size)return!1;for(const i of e)if(!n.has(i))return!1;return!0}function YC(){let e,n;return{promise:new Promise((o,a)=>{e=o,n=a}),resolve:e,reject:n}}function JC(e){return{...Mb,...e||{}}}function Si(e,{snapGrid:n=[0,0],snapToGrid:i=!1,transform:o,containerBounds:a}){var d,b;const{x:s,y:t}=He(e),r=yi({x:s-((d=a==null?void 0:a.left)!=null?d:0),y:t-((b=a==null?void 0:a.top)!=null?b:0)},o),{x:l,y:u}=i?gi(r,n):r;return{xSnapped:l,ySnapped:u,...r}}const za=e=>({width:e.offsetWidth,height:e.offsetHeight}),jb=e=>{var n;return((n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},ZC=["INPUT","SELECT","TEXTAREA"];function Ub(e){var o,a;const n=((a=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:a[0])||e.target;return(n==null?void 0:n.nodeType)!==1?!1:ZC.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const Wb=e=>"clientX"in e,He=(e,n)=>{var s,t,r,l;const i=Wb(e),o=i?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,a=i?e.clientY:(t=e.touches)==null?void 0:t[0].clientY;return{x:o-((r=n==null?void 0:n.left)!=null?r:0),y:a-((l=n==null?void 0:n.top)!=null?l:0)}},$b=(e,n,i,o,a)=>{const s=n.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(t=>{const r=t.getBoundingClientRect();return{id:t.getAttribute("data-handleid"),type:e,nodeId:a,position:t.getAttribute("data-handlepos"),x:(r.left-i.left)/o,y:(r.top-i.top)/o,...za(t)}})};function Yb({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:a,sourceControlY:s,targetControlX:t,targetControlY:r}){const l=e*.125+a*.375+t*.375+i*.125,u=n*.125+s*.375+r*.375+o*.125,d=Math.abs(l-e),b=Math.abs(u-n);return[l,u,d,b]}function mo(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function Jb({pos:e,x1:n,y1:i,x2:o,y2:a,c:s}){switch(e){case oe.Left:return[n-mo(n-o,s),i];case oe.Right:return[n+mo(o-n,s),i];case oe.Top:return[n,i-mo(i-a,s)];case oe.Bottom:return[n,i+mo(a-i,s)]}}function Zb({sourceX:e,sourceY:n,sourcePosition:i=oe.Bottom,targetX:o,targetY:a,targetPosition:s=oe.Top,curvature:t=.25}){const[r,l]=Jb({pos:i,x1:e,y1:n,x2:o,y2:a,c:t}),[u,d]=Jb({pos:s,x1:o,y1:a,x2:e,y2:n,c:t}),[b,m,f,h]=Yb({sourceX:e,sourceY:n,targetX:o,targetY:a,sourceControlX:r,sourceControlY:l,targetControlX:u,targetControlY:d});return[`M${e},${n} C${r},${l} ${u},${d} ${o},${a}`,b,m,f,h]}function Xb({sourceX:e,sourceY:n,targetX:i,targetY:o}){const a=Math.abs(i-e)/2,s=i<e?i+a:i-a,t=Math.abs(o-n)/2,r=o<n?o+t:o-t;return[s,r,a,t]}function XC({sourceNode:e,targetNode:n,selected:i=!1,zIndex:o=0,elevateOnSelect:a=!1,zIndexMode:s="basic"}){if(s==="manual")return o;const t=a&&i?o+1e3:o,r=Math.max(e.parentId||a&&e.selected?e.internals.z:0,n.parentId||a&&n.selected?n.internals.z:0);return t+r}function QC({sourceNode:e,targetNode:n,width:i,height:o,transform:a}){const s=lo(co(e),co(n));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);const t={x:-a[0]/a[2],y:-a[1]/a[2],width:i/a[2],height:o/a[2]};return bo(t,uo(s))>0}const RC=({source:e,sourceHandle:n,target:i,targetHandle:o})=>`xy-edge__${e}${n||""}-${i}${o||""}`,e_=(e,n)=>n.some(i=>i.source===e.source&&i.target===e.target&&(i.sourceHandle===e.sourceHandle||!i.sourceHandle&&!e.sourceHandle)&&(i.targetHandle===e.targetHandle||!i.targetHandle&&!e.targetHandle)),n_=(e,n,i={})=>{var s;if(!e.source||!e.target)return(s=i.onError)==null||s.call(i,"006",Be.error006()),n;const o=i.getEdgeId||RC;let a;return Lb(e)?a={...e}:a={...e,id:o(e)},e_(a,n)?n:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,n.concat(a))};function Qb({sourceX:e,sourceY:n,targetX:i,targetY:o}){const[a,s,t,r]=Xb({sourceX:e,sourceY:n,targetX:i,targetY:o});return[`M ${e},${n}L ${i},${o}`,a,s,t,r]}const Rb={[oe.Left]:{x:-1,y:0},[oe.Right]:{x:1,y:0},[oe.Top]:{x:0,y:-1},[oe.Bottom]:{x:0,y:1}},i_=({source:e,sourcePosition:n=oe.Bottom,target:i})=>n===oe.Left||n===oe.Right?e.x<i.x?{x:1,y:0}:{x:-1,y:0}:e.y<i.y?{x:0,y:1}:{x:0,y:-1},em=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function o_({source:e,sourcePosition:n=oe.Bottom,target:i,targetPosition:o=oe.Top,center:a,offset:s,stepPosition:t}){var E,_,P,k;const r=Rb[n],l=Rb[o],u={x:e.x+r.x*s,y:e.y+r.y*s},d={x:i.x+l.x*s,y:i.y+l.y*s},b=i_({source:u,sourcePosition:n,target:d}),m=b.x!==0?"x":"y",f=b[m];let h=[],g,v;const p={x:0,y:0},S={x:0,y:0},[,,y,x]=Xb({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(r[m]*l[m]===-1){m==="x"?(g=(E=a.x)!=null?E:u.x+(d.x-u.x)*t,v=(_=a.y)!=null?_:(u.y+d.y)/2):(g=(P=a.x)!=null?P:(u.x+d.x)/2,v=(k=a.y)!=null?k:u.y+(d.y-u.y)*t);const M=[{x:g,y:u.y},{x:g,y:d.y}],L=[{x:u.x,y:v},{x:d.x,y:v}];r[m]===f?h=m==="x"?M:L:h=m==="x"?L:M}else{const M=[{x:u.x,y:d.y}],L=[{x:d.x,y:u.y}];if(m==="x"?h=r.x===f?L:M:h=r.y===f?M:L,n===o){const G=Math.abs(e[m]-i[m]);if(G<=s){const I=Math.min(s-1,s-G);r[m]===f?p[m]=(u[m]>e[m]?-1:1)*I:S[m]=(d[m]>i[m]?-1:1)*I}}if(n!==o){const G=m==="x"?"y":"x",I=r[m]===l[G],Y=u[G]>d[G],Z=u[G]<d[G];(r[m]===1&&(!I&&Y||I&&Z)||r[m]!==1&&(!I&&Z||I&&Y))&&(h=m==="x"?M:L)}const T={x:u.x+p.x,y:u.y+p.y},O={x:d.x+S.x,y:d.y+S.y},B=Math.max(Math.abs(T.x-h[0].x),Math.abs(O.x-h[0].x)),K=Math.max(Math.abs(T.y-h[0].y),Math.abs(O.y-h[0].y));B>=K?(g=(T.x+O.x)/2,v=h[0].y):(g=h[0].x,v=(T.y+O.y)/2)}const w={x:u.x+p.x,y:u.y+p.y},A={x:d.x+S.x,y:d.y+S.y};return[[e,...w.x!==h[0].x||w.y!==h[0].y?[w]:[],...h,...A.x!==h[h.length-1].x||A.y!==h[h.length-1].y?[A]:[],i],g,v,y,x]}function a_(e,n,i,o){const a=Math.min(em(e,n)/2,em(n,i)/2,o),{x:s,y:t}=n;if(e.x===s&&s===i.x||e.y===t&&t===i.y)return`L${s} ${t}`;if(e.y===t){const u=e.x<i.x?-1:1,d=e.y<i.y?1:-1;return`L ${s+a*u},${t}Q ${s},${t} ${s},${t+a*d}`}const r=e.x<i.x?1:-1,l=e.y<i.y?-1:1;return`L ${s},${t+a*l}Q ${s},${t} ${s+a*r},${t}`}function ja({sourceX:e,sourceY:n,sourcePosition:i=oe.Bottom,targetX:o,targetY:a,targetPosition:s=oe.Top,borderRadius:t=5,centerX:r,centerY:l,offset:u=20,stepPosition:d=.5}){const[b,m,f,h,g]=o_({source:{x:e,y:n},sourcePosition:i,target:{x:o,y:a},targetPosition:s,center:{x:r,y:l},offset:u,stepPosition:d});let v=`M${b[0].x} ${b[0].y}`;for(let p=1;p<b.length-1;p++)v+=a_(b[p-1],b[p],b[p+1],t);return v+=`L${b[b.length-1].x} ${b[b.length-1].y}`,[v,m,f,h,g]}function nm(e){var n;return e&&!!(e.internals.handleBounds||(n=e.handles)!=null&&n.length)&&!!(e.measured.width||e.width||e.initialWidth)}function s_(e){var b,m,f,h,g;const{sourceNode:n,targetNode:i}=e;if(!nm(n)||!nm(i))return null;const o=n.internals.handleBounds||im(n.handles),a=i.internals.handleBounds||im(i.handles),s=om((b=o==null?void 0:o.source)!=null?b:[],e.sourceHandle),t=om(e.connectionMode===qn.Strict?(m=a==null?void 0:a.target)!=null?m:[]:((f=a==null?void 0:a.target)!=null?f:[]).concat((h=a==null?void 0:a.source)!=null?h:[]),e.targetHandle);if(!s||!t)return(g=e.onError)==null||g.call(e,"008",Be.error008(s?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const r=(s==null?void 0:s.position)||oe.Bottom,l=(t==null?void 0:t.position)||oe.Top,u=Sn(n,s,r),d=Sn(i,t,l);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:r,targetPosition:l}}function im(e){var o,a;if(!e)return null;const n=[],i=[];for(const s of e)s.width=(o=s.width)!=null?o:1,s.height=(a=s.height)!=null?a:1,s.type==="source"?n.push(s):s.type==="target"&&i.push(s);return{source:n,target:i}}function Sn(e,n,i=oe.Left,o=!1){var u,d,b;const a=((u=n==null?void 0:n.x)!=null?u:0)+e.internals.positionAbsolute.x,s=((d=n==null?void 0:n.y)!=null?d:0)+e.internals.positionAbsolute.y,{width:t,height:r}=n!=null?n:nn(e);if(o)return{x:a+t/2,y:s+r/2};switch((b=n==null?void 0:n.position)!=null?b:i){case oe.Top:return{x:a+t/2,y:s};case oe.Right:return{x:a+t,y:s+r/2};case oe.Bottom:return{x:a+t/2,y:s+r};case oe.Left:return{x:a,y:s+r/2}}}function om(e,n){return e&&(n?e.find(i=>i.id===n):e[0])||null}function Ua(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function t_(e,{id:n,defaultColor:i,defaultMarkerStart:o,defaultMarkerEnd:a}){const s=new Set;return e.reduce((t,r)=>([r.markerStart||o,r.markerEnd||a].forEach(l=>{if(l&&typeof l=="object"){const u=Ua(l,n);s.has(u)||(t.push({id:u,color:l.color||i,...l}),s.add(u))}}),t),[]).sort((t,r)=>t.id.localeCompare(r.id))}const am=1e3,r_=10,Wa={nodeOrigin:[0,0],nodeExtent:mi,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},l_={...Wa,checkEquality:!0};function $a(e,n){const i={...e};for(const o in n)n[o]!==void 0&&(i[o]=n[o]);return i}function u_(e,n,i){const o=$a(Wa,i);for(const a of e.values())if(a.parentId)Za(a,e,n,o);else{const s=vi(a,o.nodeOrigin),t=xn(a.extent)?a.extent:o.nodeExtent,r=yn(s,t,nn(a));a.internals.positionAbsolute=r}}function d_(e,n){var a,s;if(!e.handles)return e.measured?n==null?void 0:n.internals.handleBounds:void 0;const i=[],o=[];for(const t of e.handles){const r={id:t.id,width:(a=t.width)!=null?a:1,height:(s=t.height)!=null?s:1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type==="source"?i.push(r):t.type==="target"&&o.push(r)}return{source:i,target:o}}function Ya(e){return e==="manual"}function Ja(e,n,i,o={}){var d,b,m;const a=$a(l_,o),s={i:0},t=new Map(n),r=a!=null&&a.elevateNodesOnSelect&&!Ya(a.zIndexMode)?am:0;let l=e.length>0,u=!1;n.clear(),i.clear();for(const f of e){let h=t.get(f.id);if(a.checkEquality&&f===(h==null?void 0:h.internals.userNode))n.set(f.id,h);else{const g=vi(f,a.nodeOrigin),v=xn(f.extent)?f.extent:a.nodeExtent,p=yn(g,v,nn(f));h={...a.defaults,...f,measured:{width:(d=f.measured)==null?void 0:d.width,height:(b=f.measured)==null?void 0:b.height},internals:{positionAbsolute:p,handleBounds:d_(f,h),z:sm(f,r,a.zIndexMode),userNode:f}},n.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(l=!1),f.parentId&&Za(h,n,i,o,s),u||(u=(m=f.selected)!=null?m:!1)}return{nodesInitialized:l,hasSelectedNodes:u}}function c_(e,n){if(!e.parentId)return;const i=n.get(e.parentId);i?i.set(e.id,e):n.set(e.parentId,new Map([[e.id,e]]))}function Za(e,n,i,o,a){const{elevateNodesOnSelect:s,nodeOrigin:t,nodeExtent:r,zIndexMode:l}=$a(Wa,o),u=e.parentId,d=n.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}c_(e,i),a&&!d.parentId&&d.internals.rootParentIndex===void 0&&l==="auto"&&(d.internals.rootParentIndex=++a.i,d.internals.z=d.internals.z+a.i*r_),a&&d.internals.rootParentIndex!==void 0&&(a.i=d.internals.rootParentIndex);const b=s&&!Ya(l)?am:0,{x:m,y:f,z:h}=b_(e,d,t,r,b,l),{positionAbsolute:g}=e.internals,v=m!==g.x||f!==g.y;(v||h!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:m,y:f}:g,z:h}})}function sm(e,n,i){const o=Ke(e.zIndex)?e.zIndex:0;return Ya(i)?o:o+(e.selected?n:0)}function b_(e,n,i,o,a,s){var h;const{x:t,y:r}=n.internals.positionAbsolute,l=nn(e),u=vi(e,i),d=xn(e.extent)?yn(u,e.extent,l):u;let b=yn({x:t+d.x,y:r+d.y},o,l);e.extent==="parent"&&(b=Ob(b,l,n));const m=sm(e,a,s),f=(h=n.internals.z)!=null?h:0;return{x:b.x,y:b.y,z:f>=m?f+1:m}}function Xa(e,n,i,o=[0,0]){var t,r;const a=[],s=new Map;for(const l of e){const u=n.get(l.parentId);if(!u)continue;const d=(r=(t=s.get(l.parentId))==null?void 0:t.expandedRect)!=null?r:pi(u),b=qb(d,l.rect);s.set(l.parentId,{expandedRect:b,parent:u})}return s.size>0&&s.forEach(({expandedRect:l,parent:u},d)=>{var x,w;const b=u.internals.positionAbsolute,m=nn(u),f=(x=u.origin)!=null?x:o,h=l.x<b.x?Math.round(Math.abs(b.x-l.x)):0,g=l.y<b.y?Math.round(Math.abs(b.y-l.y)):0,v=Math.max(m.width,Math.round(l.width)),p=Math.max(m.height,Math.round(l.height)),S=(v-m.width)*f[0],y=(p-m.height)*f[1];(h>0||g>0||S||y)&&(a.push({id:d,type:"position",position:{x:u.position.x-h+S,y:u.position.y-g+y}}),(w=i.get(d))==null||w.forEach(A=>{e.some(N=>N.id===A.id)||a.push({id:A.id,type:"position",position:{x:A.position.x+h,y:A.position.y+g}})})),(m.width<l.width||m.height<l.height||h||g)&&a.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?f[0]*h-S:0),height:p+(g?f[1]*g-y:0)}})}),a}function m_(e,n,i,o,a,s,t){const r=o==null?void 0:o.querySelector(".xyflow__viewport");let l=!1;if(!r)return{changes:[],updatedInternals:l};const u=[],d=window.getComputedStyle(r),{m22:b}=new window.DOMMatrixReadOnly(d.transform),m=[];for(const f of e.values()){const h=n.get(f.id);if(!h)continue;if(h.hidden){n.set(h.id,{...h,internals:{...h.internals,handleBounds:void 0}}),l=!0;continue}const g=za(f.nodeElement),v=h.measured.width!==g.width||h.measured.height!==g.height;if(!!(g.width&&g.height&&(v||!h.internals.handleBounds||f.force))){const S=f.nodeElement.getBoundingClientRect(),y=xn(h.extent)?h.extent:s;let{positionAbsolute:x}=h.internals;h.parentId&&h.extent==="parent"?x=Ob(x,g,n.get(h.parentId)):y&&(x=yn(x,y,g));const w={...h,measured:g,internals:{...h.internals,positionAbsolute:x,handleBounds:{source:$b("source",f.nodeElement,S,b,h.id),target:$b("target",f.nodeElement,S,b,h.id)}}};n.set(h.id,w),h.parentId&&Za(w,n,i,{nodeOrigin:a,zIndexMode:t}),l=!0,v&&(u.push({id:h.id,type:"dimensions",dimensions:g}),h.expandParent&&h.parentId&&m.push({id:h.id,parentId:h.parentId,rect:pi(w,a)}))}}if(m.length>0){const f=Xa(m,n,i,a);u.push(...f)}return{changes:u,updatedInternals:l}}async function f_({delta:e,panZoom:n,transform:i,translateExtent:o,width:a,height:s}){if(!n||!e.x&&!e.y)return!1;const t=await n.setViewportConstrained({x:i[0]+e.x,y:i[1]+e.y,zoom:i[2]},[[0,0],[a,s]],o);return!!t&&(t.x!==i[0]||t.y!==i[1]||t.k!==i[2])}function tm(e,n,i,o,a,s){let t=a;const r=o.get(t)||new Map;o.set(t,r.set(i,n)),t=`${a}-${e}`;const l=o.get(t)||new Map;if(o.set(t,l.set(i,n)),s){t=`${a}-${e}-${s}`;const u=o.get(t)||new Map;o.set(t,u.set(i,n))}}function rm(e,n,i){e.clear(),n.clear();for(const o of i){const{source:a,target:s,sourceHandle:t=null,targetHandle:r=null}=o,l={edgeId:o.id,source:a,target:s,sourceHandle:t,targetHandle:r},u=`${a}-${t}--${s}-${r}`,d=`${s}-${r}--${a}-${t}`;tm("source",l,d,e,a,t),tm("target",l,u,e,s,r),n.set(o.id,o)}}function lm(e,n){if(!e.parentId)return!1;const i=n.get(e.parentId);return i?i.selected?!0:lm(i,n):!1}function um(e,n,i){var a;let o=e;do{if((a=o==null?void 0:o.matches)!=null&&a.call(o,n))return!0;if(o===i)return!1;o=o==null?void 0:o.parentElement}while(o);return!1}function v_(e,n,i,o){var s,t;const a=new Map;for(const[r,l]of e)if((l.selected||l.id===o)&&(!l.parentId||!lm(l,e))&&(l.draggable||n&&typeof l.draggable=="undefined")){const u=e.get(r);u&&a.set(r,{id:r,position:u.position||{x:0,y:0},distance:{x:i.x-u.internals.positionAbsolute.x,y:i.y-u.internals.positionAbsolute.y},extent:u.extent,parentId:u.parentId,origin:u.origin,expandParent:u.expandParent,internals:{positionAbsolute:u.internals.positionAbsolute||{x:0,y:0}},measured:{width:(s=u.measured.width)!=null?s:0,height:(t=u.measured.height)!=null?t:0}})}return a}function Qa({nodeId:e,dragItems:n,nodeLookup:i,dragging:o=!0}){var t,r,l;const a=[];for(const[u,d]of n){const b=(t=i.get(u))==null?void 0:t.internals.userNode;b&&a.push({...b,position:d.position,dragging:o})}if(!e)return[a[0],a];const s=(r=i.get(e))==null?void 0:r.internals.userNode;return[s?{...s,position:((l=n.get(e))==null?void 0:l.position)||s.position,dragging:o}:a[0],a]}function h_({dragItems:e,snapGrid:n,x:i,y:o}){const a=e.values().next().value;if(!a)return null;const s={x:i-a.distance.x,y:o-a.distance.y},t=gi(s,n);return{x:t.x-s.x,y:t.y-s.y}}function p_({onNodeMouseDown:e,getStoreItems:n,onDragStart:i,onDrag:o,onDragStop:a}){let s={x:null,y:null},t=0,r=new Map,l=!1,u={x:0,y:0},d=null,b=!1,m=null,f=!1,h=!1,g=null;function v({noDragClassName:S,handleSelector:y,domNode:x,isSelectable:w,nodeId:A,nodeClickDistance:N=0}){m=Le(x);function E({x:M,y:L}){const{nodeLookup:T,nodeExtent:O,snapGrid:B,snapToGrid:K,nodeOrigin:G,onNodeDrag:I,onSelectionDrag:Y,onError:Z,updateNodePositions:J}=n();s={x:M,y:L};let R=!1;const D=r.size>1,H=D&&O?Ha(hi(r)):null,U=D&&K?h_({dragItems:r,snapGrid:B,x:M,y:L}):null;for(const[q,F]of r){if(!T.has(q))continue;let W={x:M-F.distance.x,y:L-F.distance.y};K&&(W=U?{x:Math.round(W.x+U.x),y:Math.round(W.y+U.y)}:gi(W,B));let z=null;if(D&&O&&!F.extent&&H){const{positionAbsolute:j}=F.internals,X=j.x-H.x+O[0][0],$=j.x+F.measured.width-H.x2+O[1][0],ne=j.y-H.y+O[0][1],ee=j.y+F.measured.height-H.y2+O[1][1];z=[[X,ne],[$,ee]]}const{position:V,positionAbsolute:Q}=Bb({nodeId:q,nextPosition:W,nodeLookup:T,nodeExtent:z||O,nodeOrigin:G,onError:Z});R=R||F.position.x!==V.x||F.position.y!==V.y,F.position=V,F.internals.positionAbsolute=Q}if(h=h||R,!!R&&(J(r,!0),g&&(o||I||!A&&Y))){const[q,F]=Qa({nodeId:A,dragItems:r,nodeLookup:T});o==null||o(g,r,q,F),I==null||I(g,q,F),A||Y==null||Y(g,F)}}async function _(){var G,I;if(!d)return;const{transform:M,panBy:L,autoPanSpeed:T,autoPanOnNodeDrag:O}=n();if(!O){l=!1,cancelAnimationFrame(t);return}const[B,K]=Ka(u,d,T);(B!==0||K!==0)&&(s.x=((G=s.x)!=null?G:0)-B/M[2],s.y=((I=s.y)!=null?I:0)-K/M[2],await L({x:B,y:K})&&E(s)),t=requestAnimationFrame(_)}function P(M){var D;const{nodeLookup:L,multiSelectionActive:T,nodesDraggable:O,transform:B,snapGrid:K,snapToGrid:G,selectNodesOnDrag:I,onNodeDragStart:Y,onSelectionDragStart:Z,unselectNodesAndEdges:J}=n();b=!0,(!I||!w)&&!T&&A&&((D=L.get(A))!=null&&D.selected||J()),w&&I&&A&&(e==null||e(A));const R=Si(M.sourceEvent,{transform:B,snapGrid:K,snapToGrid:G,containerBounds:d});if(s=R,r=v_(L,O,R,A),r.size>0&&(i||Y||!A&&Z)){const[H,U]=Qa({nodeId:A,dragItems:r,nodeLookup:L});i==null||i(M.sourceEvent,r,H,U),Y==null||Y(M.sourceEvent,H,U),A||Z==null||Z(M.sourceEvent,U)}}const k=Xc().clickDistance(N).on("start",M=>{const{domNode:L,nodeDragThreshold:T,transform:O,snapGrid:B,snapToGrid:K}=n();d=(L==null?void 0:L.getBoundingClientRect())||null,f=!1,h=!1,g=M.sourceEvent,T===0&&P(M),s=Si(M.sourceEvent,{transform:O,snapGrid:B,snapToGrid:K,containerBounds:d}),u=He(M.sourceEvent,d)}).on("drag",M=>{const{autoPanOnNodeDrag:L,transform:T,snapGrid:O,snapToGrid:B,nodeDragThreshold:K,nodeLookup:G}=n(),I=Si(M.sourceEvent,{transform:T,snapGrid:O,snapToGrid:B,containerBounds:d});if(g=M.sourceEvent,(M.sourceEvent.type==="touchmove"&&M.sourceEvent.touches.length>1||A&&!G.has(A))&&(f=!0),!f){if(!l&&L&&b&&(l=!0,_()),!b){const Y=He(M.sourceEvent,d),Z=Y.x-u.x,J=Y.y-u.y;Math.sqrt(Z*Z+J*J)>K&&P(M)}(s.x!==I.xSnapped||s.y!==I.ySnapped)&&r&&b&&(u=He(M.sourceEvent,d),E(I))}}).on("end",M=>{if(!b||f){f&&r.size>0&&n().updateNodePositions(r,!1);return}if(l=!1,b=!1,cancelAnimationFrame(t),r.size>0){const{nodeLookup:L,updateNodePositions:T,onNodeDragStop:O,onSelectionDragStop:B}=n();if(h&&(T(r,!1),h=!1),a||O||!A&&B){const[K,G]=Qa({nodeId:A,dragItems:r,nodeLookup:L,dragging:!1});a==null||a(M.sourceEvent,r,K,G),O==null||O(M.sourceEvent,K,G),A||B==null||B(M.sourceEvent,G)}}}).filter(M=>{const L=M.target;return!M.button&&(!S||!um(L,`.${S}`,x))&&(!y||um(L,y,x))});m.call(k)}function p(){m==null||m.on(".drag",null)}return{update:v,destroy:p}}function g_(e,n,i){const o=[],a={x:e.x-i,y:e.y-i,width:i*2,height:i*2};for(const s of n.values())bo(a,pi(s))>0&&o.push(s);return o}const y_=250;function x_(e,n,i,o){var r,l,u,d,b;let a=[],s=1/0;const t=g_(e,i,n+y_);for(const m of t){const f=[...(l=(r=m.internals.handleBounds)==null?void 0:r.source)!=null?l:[],...(d=(u=m.internals.handleBounds)==null?void 0:u.target)!=null?d:[]];for(const h of f){if(o.nodeId===h.nodeId&&o.type===h.type&&o.id===h.id)continue;const{x:g,y:v}=Sn(m,h,h.position,!0),p=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(v-e.y,2));p>n||(p<s?(a=[{...h,x:g,y:v}],s=p):p===s&&a.push({...h,x:g,y:v}))}}if(!a.length)return null;if(a.length>1){const m=o.type==="source"?"target":"source";return(b=a.find(f=>f.type===m))!=null?b:a[0]}return a[0]}function dm(e,n,i,o,a,s=!1){var u,d,b,m,f,h;const t=o.get(e);if(!t)return null;const r=a==="strict"?(u=t.internals.handleBounds)==null?void 0:u[n]:[...(b=(d=t.internals.handleBounds)==null?void 0:d.source)!=null?b:[],...(f=(m=t.internals.handleBounds)==null?void 0:m.target)!=null?f:[]],l=(h=i?r==null?void 0:r.find(g=>g.id===i):r==null?void 0:r[0])!=null?h:null;return l&&s?{...l,...Sn(t,l,l.position,!0)}:l}function cm(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function S_(e,n){let i=null;return n?i=!0:e&&!n&&(i=!1),i}const bm=()=>!0;function w_(e,{connectionMode:n,connectionRadius:i,handleId:o,nodeId:a,edgeUpdaterType:s,isTarget:t,domNode:r,nodeLookup:l,lib:u,autoPanOnConnect:d,flowId:b,panBy:m,cancelConnection:f,onConnectStart:h,onConnect:g,onConnectEnd:v,isValidConnection:p=bm,onReconnectEnd:S,updateConnection:y,getTransform:x,getFromHandle:w,autoPanSpeed:A,dragThreshold:N=1,handleDomNode:E}){const _=jb(e.target);let P=0,k;const{x:M,y:L}=He(e),T=cm(s,E),O=r==null?void 0:r.getBoundingClientRect();let B=!1;if(!O||!T)return;const K=dm(a,T,o,l,n);if(!K)return;let G=He(e,O),I=!1,Y=null,Z=!1,J=null;function R(){if(!d||!O)return;const[V,Q]=Ka(G,O,A);m({x:V,y:Q}),P=requestAnimationFrame(R)}const D={...K,nodeId:a,type:T,position:K.position},H=l.get(a);let q={inProgress:!0,isValid:null,from:Sn(H,D,oe.Left,!0),fromHandle:D,fromPosition:D.position,fromNode:H,to:G,toHandle:null,toPosition:Pb[D.position],toNode:null,pointer:G};function F(){B=!0,y(q),h==null||h(e,{nodeId:a,handleId:o,handleType:T})}N===0&&F();function W(V){if(!B){const{x:ee,y:ae}=He(V),re=ee-M,be=ae-L;if(!(re*re+be*be>N*N))return;F()}if(!w()||!D){z(V);return}const Q=x();G=He(V,O),k=x_(yi(G,Q,!1,[1,1]),i,l,D),I||(R(),I=!0);const j=mm(V,{handle:k,connectionMode:n,fromNodeId:a,fromHandleId:o,fromType:t?"target":"source",isValidConnection:p,doc:_,lib:u,flowId:b,nodeLookup:l});J=j.handleDomNode,Y=j.connection,Z=S_(!!k,j.isValid);const X=l.get(a),$=X?Sn(X,D,oe.Left,!0):q.from,ne={...q,from:$,isValid:Z,to:j.toHandle&&Z?Kn({x:j.toHandle.x,y:j.toHandle.y},Q):G,toHandle:j.toHandle,toPosition:Z&&j.toHandle?j.toHandle.position:Pb[D.position],toNode:j.toHandle?l.get(j.toHandle.nodeId):null,pointer:G};y(ne),q=ne}function z(V){if(!("touches"in V&&V.touches.length>0)){if(B){(k||J)&&Y&&Z&&(g==null||g(Y));const{inProgress:Q,...j}=q,X={...j,toPosition:q.toHandle?q.toPosition:null};v==null||v(V,X),s&&(S==null||S(V,X))}f(),cancelAnimationFrame(P),I=!1,Z=!1,Y=null,J=null,_.removeEventListener("mousemove",W),_.removeEventListener("mouseup",z),_.removeEventListener("touchmove",W),_.removeEventListener("touchend",z)}}_.addEventListener("mousemove",W),_.addEventListener("mouseup",z),_.addEventListener("touchmove",W),_.addEventListener("touchend",z)}function mm(e,{handle:n,connectionMode:i,fromNodeId:o,fromHandleId:a,fromType:s,doc:t,lib:r,flowId:l,isValidConnection:u=bm,nodeLookup:d}){const b=s==="target",m=n?t.querySelector(`.${r}-flow__handle[data-id="${l}-${n==null?void 0:n.nodeId}-${n==null?void 0:n.id}-${n==null?void 0:n.type}"]`):null,{x:f,y:h}=He(e),g=t.elementFromPoint(f,h),v=g!=null&&g.classList.contains(`${r}-flow__handle`)?g:m,p={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const S=cm(void 0,v),y=v.getAttribute("data-nodeid"),x=v.getAttribute("data-handleid"),w=v.classList.contains("connectable"),A=v.classList.contains("connectableend");if(!y||!S)return p;const N={source:b?y:o,sourceHandle:b?x:a,target:b?o:y,targetHandle:b?a:x};p.connection=N;const _=w&&A&&(i===qn.Strict?b&&S==="source"||!b&&S==="target":y!==o||x!==a);p.isValid=_&&u(N),p.toHandle=dm(y,S,x,d,i,!0)}return p}const Ra={onPointerDown:w_,isValid:mm};function A_({domNode:e,panZoom:n,getTransform:i,getViewScale:o}){const a=Le(e);function s({translateExtent:r,width:l,height:u,zoomStep:d=1,pannable:b=!0,zoomable:m=!0,inversePan:f=!1}){const h=y=>{if(y.sourceEvent.type!=="wheel"||!n)return;const x=i(),w=y.sourceEvent.ctrlKey&&xi()?10:1,A=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*d,N=x[2]*Math.pow(2,A*w);n.scaleTo(N)};let g=[0,0];const v=y=>{var x,w;(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(g=[(x=y.sourceEvent.clientX)!=null?x:y.sourceEvent.touches[0].clientX,(w=y.sourceEvent.clientY)!=null?w:y.sourceEvent.touches[0].clientY])},p=y=>{var P,k;const x=i();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!n)return;const w=[(P=y.sourceEvent.clientX)!=null?P:y.sourceEvent.touches[0].clientX,(k=y.sourceEvent.clientY)!=null?k:y.sourceEvent.touches[0].clientY],A=[w[0]-g[0],w[1]-g[1]];g=w;const N=o()*Math.max(x[2],Math.log(x[2]))*(f?-1:1),E={x:x[0]-A[0]*N,y:x[1]-A[1]*N},_=[[0,0],[l,u]];n.setViewportConstrained({x:E.x,y:E.y,zoom:x[2]},_,r)},S=Eb().on("start",v).on("zoom",b?p:null).on("zoom.wheel",m?h:null);a.call(S,{})}function t(){a.on("zoom",null)}return{update:s,destroy:t,pointer:qe}}const fo=e=>({x:e.x,y:e.y,zoom:e.k}),es=({x:e,y:n,zoom:i})=>ro.translate(e,n).scale(i),Vn=(e,n)=>e.target.closest(`.${n}`),fm=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),N_=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ns=(e,n=0,i=N_,o=()=>{})=>{const a=typeof n=="number"&&n>0;return a||o(),a?e.transition().duration(n).ease(i).on("end",o):e},vm=e=>{const n=e.ctrlKey&&xi()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function C_({zoomPanValues:e,noWheelClassName:n,d3Selection:i,d3Zoom:o,panOnScrollMode:a,panOnScrollSpeed:s,zoomOnPinch:t,onPanZoomStart:r,onPanZoom:l,onPanZoomEnd:u}){return d=>{if(Vn(d,n))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const b=i.property("__zoom").k||1;if(d.ctrlKey&&t){const v=qe(d),p=vm(d),S=b*Math.pow(2,p);o.scaleTo(i,S,v,d);return}const m=d.deltaMode===1?20:1;let f=a===gn.Vertical?0:d.deltaX*m,h=a===gn.Horizontal?0:d.deltaY*m;!xi()&&d.shiftKey&&a!==gn.Vertical&&(f=d.deltaY*m,h=0),o.translateBy(i,-(f/b)*s,-(h/b)*s,{internal:!0});const g=fo(i.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l==null||l(d,g),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,g),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,r==null||r(d,g))}}function __({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:i}){return function(o,a){const s=o.type==="wheel",t=!n&&s&&!o.ctrlKey,r=Vn(o,e);if(o.ctrlKey&&s&&r&&o.preventDefault(),t||r)return null;o.preventDefault(),i.call(this,o,a)}}function E_({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:i}){return o=>{var s,t,r;if((s=o.sourceEvent)!=null&&s.internal)return;const a=fo(o.transform);e.mouseButton=((t=o.sourceEvent)==null?void 0:t.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((r=o.sourceEvent)==null?void 0:r.type)==="mousedown"&&n(!0),i&&(i==null||i(o.sourceEvent,a))}}function k_({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:i,onTransformChange:o,onPanZoom:a}){return s=>{var t,r,l;e.usedRightMouseButton=!!(i&&fm(n,(t=e.mouseButton)!=null?t:0)),(r=s.sourceEvent)!=null&&r.sync||o([s.transform.x,s.transform.y,s.transform.k]),a&&!((l=s.sourceEvent)!=null&&l.internal)&&(a==null||a(s.sourceEvent,fo(s.transform)))}}function M_({zoomPanValues:e,panOnDrag:n,panOnScroll:i,onDraggingChange:o,onPanZoomEnd:a,onPaneContextMenu:s}){return t=>{var r,l;if(!((r=t.sourceEvent)!=null&&r.internal)&&(e.isZoomingOrPanning=!1,s&&fm(n,(l=e.mouseButton)!=null?l:0)&&!e.usedRightMouseButton&&t.sourceEvent&&s(t.sourceEvent),e.usedRightMouseButton=!1,o(!1),a)){const u=fo(t.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(t.sourceEvent,u)},i?150:0)}}}function T_({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:i,panOnDrag:o,panOnScroll:a,zoomOnDoubleClick:s,userSelectionActive:t,noWheelClassName:r,noPanClassName:l,lib:u,connectionInProgress:d}){return b=>{var v;const m=e||n,f=i&&b.ctrlKey,h=b.type==="wheel";if(b.button===1&&b.type==="mousedown"&&(Vn(b,`${u}-flow__node`)||Vn(b,`${u}-flow__edge`)))return!0;if(!o&&!m&&!a&&!s&&!i||t||d&&!h||Vn(b,r)&&h||Vn(b,l)&&(!h||a&&h&&!e)||!i&&b.ctrlKey&&h)return!1;if(!i&&b.type==="touchstart"&&((v=b.touches)==null?void 0:v.length)>1)return b.preventDefault(),!1;if(!m&&!a&&!f&&h||!o&&(b.type==="mousedown"||b.type==="touchstart")||Array.isArray(o)&&!o.includes(b.button)&&b.type==="mousedown")return!1;const g=Array.isArray(o)&&o.includes(b.button)||!b.button||b.button<=1;return(!b.ctrlKey||h)&&g}}function P_({domNode:e,minZoom:n,maxZoom:i,translateExtent:o,viewport:a,onPanZoom:s,onPanZoomStart:t,onPanZoomEnd:r,onDraggingChange:l}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),b=Eb().scaleExtent([n,i]).translateExtent(o),m=Le(e).call(b);S({x:a.x,y:a.y,zoom:Gn(a.zoom,n,i)},[[0,0],[d.width,d.height]],o);const f=m.on("wheel.zoom"),h=m.on("dblclick.zoom");b.wheelDelta(vm);async function g(k,M){return m?new Promise(L=>{b==null||b.interpolate((M==null?void 0:M.interpolate)==="linear"?ri:Xi).transform(ns(m,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),k)}):!1}function v({noWheelClassName:k,noPanClassName:M,onPaneContextMenu:L,userSelectionActive:T,panOnScroll:O,panOnDrag:B,panOnScrollMode:K,panOnScrollSpeed:G,preventScrolling:I,zoomOnPinch:Y,zoomOnScroll:Z,zoomOnDoubleClick:J,zoomActivationKeyPressed:R,lib:D,onTransformChange:H,connectionInProgress:U,paneClickDistance:q,selectionOnDrag:F}){T&&!u.isZoomingOrPanning&&p();const W=O&&!R&&!T;b.clickDistance(F?1/0:!Ke(q)||q<0?0:q);const z=W?C_({zoomPanValues:u,noWheelClassName:k,d3Selection:m,d3Zoom:b,panOnScrollMode:K,panOnScrollSpeed:G,zoomOnPinch:Y,onPanZoomStart:t,onPanZoom:s,onPanZoomEnd:r}):__({noWheelClassName:k,preventScrolling:I,d3ZoomHandler:f});m.on("wheel.zoom",z,{passive:!1});const V=E_({zoomPanValues:u,onDraggingChange:l,onPanZoomStart:t});b.on("start",V);const Q=k_({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!L,onPanZoom:s,onTransformChange:H});b.on("zoom",Q);const j=M_({zoomPanValues:u,panOnDrag:B,panOnScroll:O,onPaneContextMenu:L,onPanZoomEnd:r,onDraggingChange:l});b.on("end",j);const X=T_({zoomActivationKeyPressed:R,panOnDrag:B,zoomOnScroll:Z,panOnScroll:O,zoomOnDoubleClick:J,zoomOnPinch:Y,userSelectionActive:T,noPanClassName:M,noWheelClassName:k,lib:D,connectionInProgress:U});b.filter(X),J?m.on("dblclick.zoom",h):m.on("dblclick.zoom",null)}function p(){b.on("zoom",null)}async function S(k,M,L){const T=es(k),O=b==null?void 0:b.constrain()(T,M,L);return O&&await g(O),O}async function y(k,M){const L=es(k);return await g(L,M),L}function x(k){if(m){const M=es(k),L=m.property("__zoom");(L.k!==k.zoom||L.x!==k.x||L.y!==k.y)&&(b==null||b.transform(m,M,null,{sync:!0}))}}function w(){const k=m?Cb(m.node()):{x:0,y:0,k:1};return{x:k.x,y:k.y,zoom:k.k}}async function A(k,M){return m?new Promise(L=>{b==null||b.interpolate((M==null?void 0:M.interpolate)==="linear"?ri:Xi).scaleTo(ns(m,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),k)}):!1}async function N(k,M){return m?new Promise(L=>{b==null||b.interpolate((M==null?void 0:M.interpolate)==="linear"?ri:Xi).scaleBy(ns(m,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),k)}):!1}function E(k){b==null||b.scaleExtent(k)}function _(k){b==null||b.translateExtent(k)}function P(k){const M=!Ke(k)||k<0?0:k;b==null||b.clickDistance(M)}return{update:v,destroy:p,setViewport:y,setViewportConstrained:S,getViewport:w,scaleTo:A,scaleBy:N,setScaleExtent:E,setTranslateExtent:_,syncViewport:x,setClickDistance:P}}var zn;(function(e){e.Line="line",e.Handle="handle"})(zn||(zn={}));function I_({width:e,prevWidth:n,height:i,prevHeight:o,affectsX:a,affectsY:s}){const t=e-n,r=i-o,l=[t>0?1:t<0?-1:0,r>0?1:r<0?-1:0];return t&&a&&(l[0]=l[0]*-1),r&&s&&(l[1]=l[1]*-1),l}function hm(e){const n=e.includes("right")||e.includes("left"),i=e.includes("bottom")||e.includes("top"),o=e.includes("left"),a=e.includes("top");return{isHorizontal:n,isVertical:i,affectsX:o,affectsY:a}}function un(e,n){return Math.max(0,n-e)}function dn(e,n){return Math.max(0,e-n)}function vo(e,n,i){return Math.max(0,n-e,e-i)}function pm(e,n){return e?!n:n}function L_(e,n,i,o,a,s,t,r){let{affectsX:l,affectsY:u}=n;const{isHorizontal:d,isVertical:b}=n,m=d&&b,{xSnapped:f,ySnapped:h}=i,{minWidth:g,maxWidth:v,minHeight:p,maxHeight:S}=o,{x:y,y:x,width:w,height:A,aspectRatio:N}=e;let E=Math.floor(d?f-e.pointerX:0),_=Math.floor(b?h-e.pointerY:0);const P=w+(l?-E:E),k=A+(u?-_:_),M=-s[0]*w,L=-s[1]*A;let T=vo(P,g,v),O=vo(k,p,S);if(t){let G=0,I=0;l&&E<0?G=un(y+E+M,t[0][0]):!l&&E>0&&(G=dn(y+P+M,t[1][0])),u&&_<0?I=un(x+_+L,t[0][1]):!u&&_>0&&(I=dn(x+k+L,t[1][1])),T=Math.max(T,G),O=Math.max(O,I)}if(r){let G=0,I=0;l&&E>0?G=dn(y+E,r[0][0]):!l&&E<0&&(G=un(y+P,r[1][0])),u&&_>0?I=dn(x+_,r[0][1]):!u&&_<0&&(I=un(x+k,r[1][1])),T=Math.max(T,G),O=Math.max(O,I)}if(a){if(d){const G=vo(P/N,p,S)*N;if(T=Math.max(T,G),t){let I=0;!l&&!u||l&&!u&&m?I=dn(x+L+P/N,t[1][1])*N:I=un(x+L+(l?E:-E)/N,t[0][1])*N,T=Math.max(T,I)}if(r){let I=0;!l&&!u||l&&!u&&m?I=un(x+P/N,r[1][1])*N:I=dn(x+(l?E:-E)/N,r[0][1])*N,T=Math.max(T,I)}}if(b){const G=vo(k*N,g,v)/N;if(O=Math.max(O,G),t){let I=0;!l&&!u||u&&!l&&m?I=dn(y+k*N+M,t[1][0])/N:I=un(y+(u?_:-_)*N+M,t[0][0])/N,O=Math.max(O,I)}if(r){let I=0;!l&&!u||u&&!l&&m?I=un(y+k*N,r[1][0])/N:I=dn(y+(u?_:-_)*N,r[0][0])/N,O=Math.max(O,I)}}}_=_+(_<0?O:-O),E=E+(E<0?T:-T),a&&(m?P>k*N?_=(pm(l,u)?-E:E)/N:E=(pm(l,u)?-_:_)*N:d?(_=E/N,u=l):(E=_*N,l=u));const B=l?y+E:y,K=u?x+_:x;return{width:w+(l?-E:E),height:A+(u?-_:_),x:s[0]*E*(l?-1:1)+B,y:s[1]*_*(u?-1:1)+K}}const gm={width:0,height:0,x:0,y:0},B_={...gm,pointerX:0,pointerY:0,aspectRatio:1};function O_(e,n,i){var u,d;const o=n.position.x+e.position.x,a=n.position.y+e.position.y,s=(u=e.measured.width)!=null?u:0,t=(d=e.measured.height)!=null?d:0,r=i[0]*s,l=i[1]*t;return[[o-r,a-l],[o+s-r,a+t-l]]}function D_({domNode:e,nodeId:n,getStoreItems:i,onChange:o,onEnd:a}){const s=Le(e);let t={controlDirection:hm("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function r({controlPosition:u,boundaries:d,keepAspectRatio:b,resizeDirection:m,onResizeStart:f,onResize:h,onResizeEnd:g,shouldResize:v}){let p={...gm},S={...B_};t={boundaries:d,resizeDirection:m,keepAspectRatio:b,controlDirection:hm(u)};let y,x=null,w=[],A,N,E,_=!1;const P=Xc().on("start",k=>{var Y,Z,J,R,D,H;const{nodeLookup:M,transform:L,snapGrid:T,snapToGrid:O,nodeOrigin:B,paneDomNode:K}=i();if(y=M.get(n),!y)return;x=(Y=K==null?void 0:K.getBoundingClientRect())!=null?Y:null;const{xSnapped:G,ySnapped:I}=Si(k.sourceEvent,{transform:L,snapGrid:T,snapToGrid:O,containerBounds:x});p={width:(Z=y.measured.width)!=null?Z:0,height:(J=y.measured.height)!=null?J:0,x:(R=y.position.x)!=null?R:0,y:(D=y.position.y)!=null?D:0},S={...p,pointerX:G,pointerY:I,aspectRatio:p.width/p.height},A=void 0,N=xn(y.extent)?y.extent:void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(A=M.get(y.parentId)),A&&y.extent==="parent"&&(N=[[0,0],[A.measured.width,A.measured.height]]),w=[],E=void 0;for(const[U,q]of M)if(q.parentId===n&&(w.push({id:U,position:{...q.position},extent:q.extent}),q.extent==="parent"||q.expandParent)){const F=O_(q,y,(H=q.origin)!=null?H:B);E?E=[[Math.min(F[0][0],E[0][0]),Math.min(F[0][1],E[0][1])],[Math.max(F[1][0],E[1][0]),Math.max(F[1][1],E[1][1])]]:E=F}f==null||f(k,{...p})}).on("drag",k=>{var $,ne,ee;const{transform:M,snapGrid:L,snapToGrid:T,nodeOrigin:O}=i(),B=Si(k.sourceEvent,{transform:M,snapGrid:L,snapToGrid:T,containerBounds:x}),K=[];if(!y)return;const{x:G,y:I,width:Y,height:Z}=p,J={},R=($=y.origin)!=null?$:O,{width:D,height:H,x:U,y:q}=L_(S,t.controlDirection,B,t.boundaries,t.keepAspectRatio,R,N,E),F=D!==Y,W=H!==Z,z=U!==G&&F,V=q!==I&&W;if(!z&&!V&&!F&&!W)return;if((z||V||R[0]===1||R[1]===1)&&(J.x=z?U:p.x,J.y=V?q:p.y,p.x=J.x,p.y=J.y,w.length>0)){const ae=U-G,re=q-I;for(const be of w)be.position={x:be.position.x-ae+R[0]*(D-Y),y:be.position.y-re+R[1]*(H-Z)},K.push(be)}if((F||W)&&(J.width=F&&(!t.resizeDirection||t.resizeDirection==="horizontal")?D:p.width,J.height=W&&(!t.resizeDirection||t.resizeDirection==="vertical")?H:p.height,p.width=J.width,p.height=J.height),A&&y.expandParent){const ae=R[0]*((ne=J.width)!=null?ne:0);J.x&&J.x<ae&&(p.x=ae,S.x=S.x-(J.x-ae));const re=R[1]*((ee=J.height)!=null?ee:0);J.y&&J.y<re&&(p.y=re,S.y=S.y-(J.y-re))}const Q=I_({width:p.width,prevWidth:Y,height:p.height,prevHeight:Z,affectsX:t.controlDirection.affectsX,affectsY:t.controlDirection.affectsY}),j={...p,direction:Q};(v==null?void 0:v(k,j))!==!1&&(_=!0,h==null||h(k,j),o(J,K))}).on("end",k=>{_&&(g==null||g(k,{...p}),a==null||a({...p}),_=!1)});s.call(P)}function l(){s.on(".drag",null)}return{update:r,destroy:l}}var ho=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ym(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var po={exports:{}},is={},go={exports:{}},os={};/**
30
+ active:opacity-50 element_class`,draggable:!0,children:c.jsxs("span",{className:"flex flex-col items-center justify-center w-full gap-2",children:[c.jsx("span",{style:{color:l},children:c.jsx(se,{icon:v.icon,iconClass:"w-6 h-6"})}),c.jsx("span",{style:{color:l},className:"text-xs font-medium text-center",children:v.label})]})},v.type))})]},h)})})})]})},zS=C.memo(VS),Ue=({text:e="",isDisabled:n=!1,isLoading:i=!1,btnClass:o="bg-primary-500 text-white",icon:a="",iconPosition:s="left",iconClass:t="text-[20px]",loadingClass:r="",link:l="",div:u=!1,type:d="button",style:b,onClick:m})=>{const f=ue("btn inline-flex justify-center",{"pointer-events-none":i,"opacity-40 cursor-not-allowed":n},o),h=()=>i?c.jsxs(c.Fragment,{children:[c.jsxs("svg",{className:`animate-spin -ml-1 mr-3 h-5 w-5 ${r}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Submitting..."]}):c.jsxs("span",{className:"flex items-center",children:[a&&s==="left"&&c.jsx("span",{className:`mr-[6px] ${t}`,children:c.jsx(se,{icon:a})}),e&&c.jsx("span",{children:e}),a&&s==="right"&&c.jsx("span",{className:`ml-[6px] ${t}`,children:c.jsx(se,{icon:a})})]});return u?c.jsx("div",{className:f,children:h()}):l?c.jsx(px.Link,{to:l,className:f,children:h()}):c.jsx("button",{disabled:n,type:d,className:f,"data-testid":"btn",onClick:m,style:b,children:h()})};function jS(){return c.jsx("div",{children:c.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",fill:"#D5D7DA"}),c.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",stroke:"#E9EAEB"}),c.jsx("path",{d:"M22.5 14L14.5 22M14.5 14L22.5 22",stroke:"#414651",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const US=({isOpen:e,onClose:n})=>{const{formData:i,uploadUrl:o}=C.useContext(Ce);if(!e)return null;const a=Se("config");return c.jsxs("div",{className:"fixed inset-0 flex justify-center z-[999] cursor-default no-drag select-none w-screen h-screen pt-20 bg-[#F8F9FC]",children:[c.jsx("button",{type:"button",onClick:n,className:"absolute text-sm top-3 right-4","aria-label":"close",children:c.jsx(jS,{})})," ",c.jsx("div",{className:"max-h-[80vh] overflow-y-auto h-max w-full max-w-[650px] min-w-0 border border-[#D5D9EB] rounded-lg bg-white form_submit container",children:c.jsx(ga,{form_data:i,ignoreValidation:!0,config:a,uploadUrl:o})})]})};function WS(){return c.jsx("div",{children:c.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("rect",{width:"24",height:"24",rx:"6",fill:"currentColor"}),c.jsx("path",{d:"M14 16L10 12L14 8",stroke:"white",strokeWidth:"1.39167",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function $S({title:e,goBackUrl:n,onSubmit:i,onPublish:o,previewLoading:a,saveLoading:s,publishLoading:t,onTitleChange:r,viewMode:l,setViewMode:u,onShowVersion:d}){const{formData:b,setShowPreview:m,showPreview:f,undo:h,redo:g,canUndo:v,canRedo:p}=C.useContext(Ce),[S,y]=C.useState(!1),[x,w]=C.useState(!1),[A,N]=C.useState(e||""),E=Se("config");function _(){localStorage.setItem("formData",JSON.stringify(b)),i==null||i(b)}function P(){localStorage.setItem("formData",JSON.stringify(b)),o==null||o(b)}function k(){w(!1),r&&A!==e&&r(A.trim())}return c.jsxs("div",{className:"px-[30px] py-3 flex justify-between items-center bg-[#F9F9FB] top_bar border-b h-full",children:[c.jsxs("span",{className:"flex items-center gap-x-2",children:[n&&c.jsx("button",{type:"button",onClick:()=>n(),style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:"flex items-center gap-x-3",children:c.jsx(WS,{})})," ",x?c.jsx("input",{type:"text",value:A,onChange:M=>N(M.target.value),onBlur:k,autoFocus:!0,className:"w-48 px-2 py-1 text-sm font-semibold outline-gray-100 input form_title"}):c.jsx("h1",{title:"Click to edit",className:"text-base font-semibold cursor-pointer form_title",onClick:()=>w(!0),children:A||"Untitled"})]}),S&&c.jsx(US,{isOpen:S,onClose:()=>y(!1),element:void 0}),c.jsxs("div",{className:"flex justify-end text-xs gap-x-3 items-center",children:[u&&c.jsxs("div",{className:"flex border border-gray-300 rounded-lg overflow-hidden h-[36px] text-sm font-medium shadow-sm mr-2",children:[c.jsxs("button",{type:"button",style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:`px-3 flex items-center gap-1.5 transition-colors canvas_view ${l==="canvas"?"bg-white font-medium":"bg-gray-100 text-gray-500 hover:bg-gray-50"}`,onClick:()=>u("canvas"),children:[c.jsx(se,{icon:"mdi:view-dashboard-outline",iconClass:"text-base"})," ","Builder"]}),c.jsxs("button",{type:"button",style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:`px-3 flex items-center gap-1.5 border-l border-gray-300 transition-colors flow_view ${l==="flow"?" bg-white font-medium":"bg-gray-100 text-gray-500 hover:bg-gray-50"}`,onClick:()=>u("flow"),children:[c.jsx(se,{icon:"mdi:sitemap-outline",iconClass:"text-base"})," Flow"]})]}),c.jsx(Ue,{onClick:h,text:"",btnClass:`!px-2 bg-transparent undo ${v?"":"opacity-50"}`,icon:"material-symbols:undo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!v}),c.jsx(Ue,{onClick:g,text:"",btnClass:`!px-2 bg-transparent redo ${p?"":"opacity-50"}`,icon:"material-symbols:redo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!p}),d&&c.jsx(Ue,{onClick:d,text:"Versions",btnClass:"px-2 bg-transparent font-medium text-sm version_btn",icon:"tabler:history",iconClass:"text-xl",style:{color:(E==null?void 0:E.buttonColor)||"#333"}}),c.jsx(Ue,{onClick:()=>m(M=>!M),text:f?"Hide Preview":"Preview",btnClass:"px-2 bg-transparent font-medium text-sm form_preview",icon:f?"iconamoon:eye-off-duotone":"solar:eye-bold-duotone",iconClass:"text-base",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:a,isLoading:a}),c.jsx(Ue,{onClick:_,text:"Save",btnClass:"px-2 bg-transparent font-medium text-sm form_save__btn",icon:"lets-icons:save-duotone",iconClass:"text-base",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:s,isLoading:s}),c.jsx(Ue,{onClick:P,text:"Publish",style:{background:(E==null?void 0:E.buttonColor)||"#333"},btnClass:"border-[#98A2B3] font-medium text-sm py-2 px-6 text-white rounded-lg form_publish__btn",isDisabled:t,isLoading:t})]})]})}function YS({onSubmit:e,onChange:n,onLogAction:i,questionData:o,title:a,goBackUrl:s,loading:t,onPublish:r,previewLoading:l,saveLoading:u,publishLoading:d,onTitleChange:b,uploadUrl:m,onAddTemplate:f,templates:h,onShowVersion:g}){const[v,p]=C.useState("canvas");return c.jsxs(Qd,{onChange:n,onLogAction:i,children:[c.jsx(Pe.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),c.jsx("div",{className:"w-full h-full bg-[#F8F9FC] flex flex-col",children:c.jsxs("div",{className:"flex flex-1 ",children:[v==="canvas"&&c.jsx("div",{children:c.jsx("div",{className:"w-[250px] h-screen border-r border-[#E4E7EC] bg-white ",children:c.jsx(zS,{})})}),c.jsxs("div",{className:`flex-1 h-full max-h-full z-[1] ${v==="canvas"?"w-[calc(100%-250px)]":"w-full"}`,children:[c.jsx("div",{className:" h-[70px]",children:c.jsx($S,{title:a,goBackUrl:s,onSubmit:e,onPublish:r,previewLoading:l,saveLoading:u,publishLoading:d,onTitleChange:b,viewMode:v,setViewMode:p,onShowVersion:g})}),c.jsx("div",{className:"p-6 h-[calc(100vh-70px)]",children:t?c.jsx(fa,{loadingClass:"!w-full !h-[800px]"}):c.jsx(HS,{questionData:o,uploadUrl:m,onAddTemplate:f,templates:h,viewMode:v})})]})]})})]})}const JS=({onSubmit:e,onChange:n,onLogAction:i,questionData:o,isReadOnly:a,config:s={buttonColor:"#333"},title:t,loading:r,goBackUrl:l,onPublish:u,previewLoading:d,saveLoading:b,publishLoading:m,onTitleChange:f,uploadUrl:h,onAddTemplate:g,templates:v,onShowVersion:p})=>(C.useEffect(()=>{s&&_c("config",s)},[s]),c.jsx(YS,{onSubmit:e,onChange:n,onLogAction:i,onPublish:u,questionData:o,isReadOnly:a,title:t,goBackUrl:l,loading:r,previewLoading:d,saveLoading:b,publishLoading:m,onTitleChange:f,uploadUrl:h,onAddTemplate:g,templates:v,onShowVersion:p})),rn={required:"This field is required",email:"Invalid email format",url:"Invalid url format",minLength:e=>`Minimum length is ${e}`,maxLength:e=>`Maximum length is ${e}`,minAmount:e=>`Minimum amount is ${e}`,maxAmount:e=>`Maximum amount is ${e}`},ZS=(e,n=!1)=>({textField:ie.string().nullable(),longText:ie.string().nullable(),numberField:ie.number().nullable().transform(o=>isNaN(o)?null:o),amountField:ie.number().nullable().transform(o=>isNaN(o)?null:o),selectField:ie.string().nullable(),checkbox:ie.mixed().nullable(),radio:ie.mixed().nullable(),matrix:ie.mixed().nullable(),email:ie.string().nullable().test("email-format",rn.email,o=>!o||o.trim()===""?!0:/^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/.test(o)),date:ie.date().nullable().transform((o,a)=>n&&a===""?null:o).typeError("Invalid date"),url:ie.string().nullable().test("url-format",rn.url,o=>!o||o.trim()===""?!0:/^(https?:\/\/)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/.*)?$/.test(o))})[e]||ie.mixed().nullable(),XS=(e,n,i)=>n?e.type==="boolean"?e.oneOf([!0],i||rn.required):e.required(i||rn.required):e,QS=(e,{minLength:n,maxLength:i,minLengthMessage:o,maxLengthMessage:a})=>{let s=e;return n&&(s=s.min(n,o||rn.minLength(n))),i&&(s=s.max(i,a||rn.maxLength(i))),s},RS=(e,{minAmount:n,maxAmount:i,minAmountMessage:o,maxAmountMessage:a})=>{let s=e;return n&&(s=s.min(parseFloat(String(n)),o||rn.minAmount(n))),i&&(s=s.max(parseFloat(String(i)),a||rn.maxAmount(i))),s},ha=(e,n)=>{if(!e.isHidden)return!0;const i=e.visibilityDependentFields||[];return i.length?i.every(o=>{const a=n==null?void 0:n[o.id],s=o.fieldValue,t=a;switch(o.operator){case"equals":return String(s).toLowerCase()===String(t).toLowerCase();case"not_equals":return String(s).toLowerCase()!==String(t).toLowerCase();case"greater":return Number(t)>Number(s);case"less":return Number(t)<Number(s);case"contains":return String(t).toLowerCase().includes(String(s).toLowerCase());case"not_contains":return!String(t).toLowerCase().includes(String(s).toLowerCase());default:return!0}}):!0};function ew({formData:e,isReadOnly:n,answerData:i}){const o={};return e.forEach(({questionData:a})=>{a==null||a.forEach(s=>{if(!ha(s,i))return;const{id:t,type:r,isRequired:l,requiredMessage:u,isDisabled:d}=s;let b=ZS(r,n);b=XS(b,d||n?!1:l,u),r==="textField"||r==="longText"||r==="email"||r==="url"?b=QS(b,s):(r==="numberField"||r==="amountField")&&(b=RS(b,s)),o[t]=b})}),ie.object().shape(o)}const Pn=({element:e,validationData:n})=>{const i=Lc[e.type],{answerData:o}=C.useContext(Ce),a=C.useMemo(()=>{var t;return(t=e==null?void 0:e.acceptedFiles)==null?void 0:t.map(r=>r.label).join(", ")},[e]),s=C.useMemo(()=>ha(e,o),[o,e]);return i?c.jsxs("div",{className:`${s?"":"invisible h-0"} min-w-0 w-full`,children:[c.jsxs("div",{className:"mb-1.5 min-w-0",children:[e.inputLabel&&c.jsxs("label",{className:"block text-sm font-medium input_label",children:[e.inputLabel," ",a&&c.jsxs("span",{className:"text-gray-400 text-xs",children:["(",a==null?void 0:a.toLowerCase(),")"]})]}),e.description&&c.jsxs("small",{className:"block text-gray-400 mt-0.5 text-xs",children:[" ",e.description]})]}),c.jsx(i,{element:e,state:"edit",validationData:{...n,isReadOnly:n.isReadOnly||e.isDisabled}})]}):null},In=(e,n)=>e!=null&&e.allowEdit?{...n,isReadOnly:!1}:n;function nw({form_data:e,options:n}){const i=(a,s)=>c.jsx("div",{className:"min-w-0",children:c.jsx(Gi,{element:a,customClass:"p-0 min-h-[60px] border-none",children:s==null?void 0:s.map(t=>{var r,l,u;return c.jsxs(Fi,{col:(r=t.gridPosition)==null?void 0:r.col,customClass:"p-0",children:[c.jsx(Pn,{element:t,validationData:In(t,n)}),((u=(l=n==null?void 0:n.errors)==null?void 0:l[t.id])==null?void 0:u.message)&&c.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[t.id].message})]},t.id)})})},a.id),o=a=>{var s,t;return c.jsxs("div",{className:ue("group relative grid gap-y-[6px] min-w-0",a.elementClass),children:[c.jsx(Pn,{element:a,validationData:In(a,n)}),((t=(s=n==null?void 0:n.errors)==null?void 0:s[a.id])==null?void 0:t.message)&&c.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[a.id].message})]},a.id)};return c.jsx("div",{className:"grid gap-y-10",children:e==null?void 0:e.map(a=>{var t,r;const s=new Map;return(t=a.questionData)==null||t.forEach(l=>{l.gridId&&(s.has(l.gridId)||s.set(l.gridId,[]),s.get(l.gridId).push(l))}),c.jsxs("div",{className:"pb-6 section_box min-w-0",children:[(a.title||a.description)&&c.jsxs("div",{className:"py-4 border-b border-gray-100 mb-7 section_box__title",children:[a.title&&c.jsx("h2",{className:"text-lg font-semibold mb-[4px]",children:a.title}),a.description&&c.jsx("p",{className:"text-sm",children:a.description})]}),c.jsx("div",{className:"grid gap-y-6 section_box__content min-w-0",children:(r=a.questionData)==null?void 0:r.map(l=>l.gridId?null:l.type==="grid"?i(l,s.get(l.id)||[]):o(l))})]},a.id)})})}function iw({form_data:e,options:n,current:i}){var o;return c.jsx("div",{className:"grid gap-y-3 multi_section__content min-w-0",children:(o=e[i].questionData)==null?void 0:o.map(a=>{var s,t;if(a.type==="grid"){const r=e[i].questionData.filter(l=>l.gridId===a.id);return c.jsx("div",{className:"min-w-0",children:c.jsx(Gi,{element:a,customClass:"p-0 min-h-[60px] border-none",children:r==null?void 0:r.map(l=>{var u,d,b;return c.jsxs(Fi,{col:(u=l.gridPosition)==null?void 0:u.col,customClass:"p-0",children:[c.jsx(Pn,{element:l,validationData:In(l,n)}),c.jsx("div",{className:"mt-1 text-xs text-red-600",children:(b=(d=n==null?void 0:n.errors)==null?void 0:d[l.id])==null?void 0:b.message})]},l.id)})})},a.id)}return a.gridId?null:c.jsxs("div",{className:ue("group relative grid gap-y-[6px] min-w-0",a.elementClass),children:[c.jsx(Pn,{element:a,validationData:In(a,n)}),c.jsx("div",{className:"mt-1 text-xs text-red-600",children:(t=(s=n==null?void 0:n.errors)==null?void 0:s[a.id])==null?void 0:t.message})]},a.id)})})}const pa=Se("config");function ow({element:e,options:n,onNext:i,onPrev:o,isFirst:a,isLast:s,isReadOnly:t}){if(!e)return c.jsx("div",{className:"flex items-center justify-center min-h-[500px] text-gray-500",children:"No questions available."});const r=d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),i())},l=d=>{var b;return c.jsx("div",{className:"min-w-0 w-full",children:c.jsx(Gi,{element:d,customClass:"p-0 min-h-[60px] border-none w-full",children:(b=d.gridChildren)==null?void 0:b.map(m=>{var f,h,g;return c.jsxs(Fi,{col:(f=m.gridPosition)==null?void 0:f.col,customClass:"p-0",children:[c.jsx(Pn,{element:m,validationData:In(m,n)}),((g=(h=n==null?void 0:n.errors)==null?void 0:h[m.id])==null?void 0:g.message)&&c.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[m.id].message})]},m.id)})})},d.id)},u=d=>{var b,m;return c.jsxs("div",{className:ue("group relative grid gap-y-[6px] min-w-0 w-full",d.elementClass),children:[c.jsx(Pn,{element:d,validationData:In(d,n)}),((m=(b=n==null?void 0:n.errors)==null?void 0:b[d.id])==null?void 0:m.message)&&c.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[d.id].message})]},d.id)};return c.jsx("div",{className:"flex flex-col items-center justify-center min-h-[500px] w-full p-4 sm:p-8 outline-none",onKeyDown:r,tabIndex:0,children:c.jsxs(le.Transition,{as:"div",show:!0,appear:!0,enter:"transition-all duration-500 ease-out",enterFrom:"opacity-0 translate-y-8",enterTo:"opacity-100 translate-y-0",leave:"transition-all duration-300 ease-in",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-8",className:"w-full max-w-2xl",children:[c.jsx("div",{className:"text-left w-full mb-8",children:e.type==="grid"?l(e):u(e)}),!t&&c.jsxs("div",{className:"flex items-center gap-4 mt-8",children:[c.jsx(Ue,{type:"button",text:s?n!=null&&n.isSubmitting?"Submitting...":"Submit":"OK",onClick:i,style:{background:(pa==null?void 0:pa.buttonColor)||"#333"},btnClass:`text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg ${s?"submit_btn":"continue_btn next_btn text-sm"}`}),!s&&c.jsx("span",{className:"text-xs text-gray-400 font-medium hidden sm:inline-block",children:"press Enter ↵"}),!a&&c.jsxs("button",{type:"button",onClick:o,className:"text-gray-400 hover:text-gray-600 font-medium text-sm ml-auto flex items-center gap-1 transition-colors",children:[c.jsx(se,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]})]},e.id)})}function aw(e){return e.reduce((n,i)=>(n[i.id]=i.value,n),{})}const sw=({form_data:e,answerData:n=[],ignoreValidation:i=!1,onSubmitData:o,onGetValues:a,isReadOnly:s=!1,renderType:t="multi",children:r,hideFooter:l=!1,uploadUrl:u})=>{var H,U,q,F,W,z,V,Q;const{setAnswerData:d,setUploadUrl:b}=C.useContext(Ce),[m,f]=C.useState(0),[h,g]=C.useState(0),v=C.useMemo(()=>e.filter(j=>!j.isHidden).map(j=>{var $;return j.isDisabled||j.disabled?{...j,questionData:($=j.questionData)==null?void 0:$.map(ne=>({...ne,isDisabled:!0}))}:j}),[e]),p=(H=v==null?void 0:v.length)!=null?H:0,S=Se("config"),y=C.useCallback(async(j,X,$)=>{const ne=ew({formData:v,isReadOnly:s,answerData:j});return sa(ne)(j,X,$)},[v,s]),x=Xe.useForm({resolver:y,mode:"onSubmit",defaultValues:{}}),{register:w,setValue:A,control:N,handleSubmit:E,reset:_,getValues:P,watch:k,formState:{errors:M,isSubmitting:L},trigger:T,setError:O,clearErrors:B}=x,K=Xe.useWatch({control:N}),G=C.useMemo(()=>K,[JSON.stringify(K)]),I=C.useMemo(()=>{if(t!=="conversational")return[];const j=[];return v.forEach(X=>{var $;($=X.questionData)==null||$.forEach(ne=>{var ee;if(ha(ne,G))if(ne.type==="grid"){const ae=(ee=X.questionData)==null?void 0:ee.filter(re=>re.gridId===ne.id);j.push({...ne,gridChildren:ae})}else ne.gridId||j.push(ne)})}),j},[v,G,t]),Y=C.useCallback(j=>{a&&a(j)},[a]);C.useEffect(()=>{b(u)},[b,u]),C.useEffect(()=>{if(!(v!=null&&v.length)||!a)return;const j=v.flatMap(X=>{var $;return($=X.questionData)==null?void 0:$.map(ne=>({id:ne.id,value:G[ne.id]||"",sectionId:X.id,type:ne.type,metaData:{prefix:ne.prefix,dateFormat:ne.dateFormat}}))});Y(j),d(G)},[G,v,Y,a,d]),C.useEffect(()=>{n!=null&&n.length&&_(aw(n))},[n,_]);const Z=C.useCallback(j=>{const X=v.flatMap($=>{var ne;return(ne=$.questionData)==null?void 0:ne.map(ee=>({id:ee.id,value:j[ee.id]||"",sectionId:$.id,type:ee.type,metaData:{prefix:ee.prefix,dateFormat:ee.dateFormat}}))});Object.keys(M).length>0||o==null||o(X)},[M,v,o]),J=C.useCallback(async()=>{var j,X;if(t==="conversational"){if(!i){const $=I[h];if(!$)return;const ne=$.gridChildren?$.gridChildren.map(ae=>ae.id):[$.id];if(!await T(ne))return}h<I.length-1?g($=>$+1):E(Z)();return}if(!i){const $=(X=(j=v==null?void 0:v[m])==null?void 0:j.questionData)==null?void 0:X.map(ee=>ee.id);if(!await T($))return}f($=>$+1)},[m,h,I,v,i,T,t,E,Z]),R=C.useCallback(()=>{if(t==="conversational"){g(j=>Math.max(0,j-1));return}f(j=>j-1)},[t]),D=C.useMemo(()=>({register:w,setValue:A,watch:k,errors:M,trigger:T,isSubmitting:L,isReadOnly:s,getValues:P,setError:O,clearErrors:B}),[w,A,k,M,T,L,s,P,O,B]);return c.jsxs(Xe.FormProvider,{...x,children:[c.jsx(Pe.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),c.jsxs("form",{onSubmit:E(Z),className:"container h-full mx-auto",children:[c.jsx("div",{className:"relative flex flex-col w-full min-w-0 py-4 gap-y-12",children:c.jsxs("div",{className:"multi_section__box min-w-0",children:[t==="multi"&&(((U=v==null?void 0:v[m])==null?void 0:U.title)||((q=v==null?void 0:v[m])==null?void 0:q.description))&&c.jsxs("div",{className:"py-4 mb-4 border-b border-gray-100 multi_section__title",children:[((F=v[m])==null?void 0:F.title)&&c.jsx("h2",{className:"text-lg font-semibold mb-[6px]",children:(W=v[m])==null?void 0:W.title}),((z=v[m])==null?void 0:z.description)&&c.jsx("p",{className:"text-sm",children:(V=v[m])==null?void 0:V.description})]}),t==="multi"?c.jsx(iw,{form_data:v,options:D,current:m}):t==="conversational"?c.jsx(ow,{element:I[h],options:D,onNext:J,onPrev:R,isFirst:h===0,isLast:h===I.length-1,isReadOnly:s}):c.jsx(nw,{form_data:v,options:D})]},t==="conversational"?`conv-${h}`:(Q=v==null?void 0:v[m])==null?void 0:Q.id)}),!l&&t!=="conversational"&&c.jsx("footer",{className:"flex items-center justify-end gap-4 footer flex-wrap",children:t==="multi"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex gap-x-4 justify-between navigation_container w-full",children:[c.jsxs("div",{children:[" ",m>0&&c.jsxs("button",{type:"button",onClick:R,className:"text-gray-400 hover:text-gray-600 font-medium text-sm flex items-center gap-1 transition-colors back_btn",children:[c.jsx(se,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]}),m<p-1&&c.jsx(Ue,{type:"button",text:"Next",onClick:J,style:{background:(S==null?void 0:S.buttonColor)||"#333"},btnClass:"text-gray-700 next_btn text-sm border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg continue_btn"})]}),(m===p-1||s)&&!i&&(r!=null?r:c.jsx(Ue,{isDisabled:L||Object.keys(M).length>0,isLoading:L,type:"submit",text:"Submit",style:{background:(S==null?void 0:S.buttonColor)||"#333"},btnClass:"text-gray-700 border-[#98A2B3] submit_btn !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg submit_btn"}))]}):!i&&(r!=null?r:c.jsx(Ue,{isDisabled:L||Object.keys(M).length>0,isLoading:L,type:"submit",text:"Submit",style:{background:(S==null?void 0:S.buttonColor)||"#333"},btnClass:"text-gray-700 border-[#98A2B3] submit_btn !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg submit_btn"}))}),t==="conversational"&&I.length>0&&c.jsx("div",{className:"fixed bottom-0 left-0 w-full h-1.5 bg-gray-200",children:c.jsx("div",{className:"h-full bg-blue-600 transition-all duration-500 ease-out",style:{width:`${(h+1)/I.length*100}%`,background:(S==null?void 0:S.buttonColor)||"#2563EB"}})})]})]})},tw=C.memo(sw);function ga({answerData:e,form_data:n,ignoreValidation:i,onSubmit:o,isReadOnly:a=!1,loading:s=!1,config:t={buttonColor:"#333"},renderType:r,children:l,hideFooter:u,onGetValues:d,uploadUrl:b}){C.useEffect(()=>{t&&_c("config",t)},[t]);const m=C.useCallback(f=>{d&&d(f)},[d]);return s?c.jsx(fa,{}):n?c.jsxs("div",{className:"w-full h-full min-w-0",children:[c.jsx("div",{id:"root-portal"}),c.jsx(Qd,{children:c.jsx(tw,{form_data:n,answerData:e,ignoreValidation:i,onSubmitData:o,isReadOnly:a,renderType:r,hideFooter:u,onGetValues:m,uploadUrl:b,children:l})})]}):c.jsx("div",{children:c.jsx("p",{className:"p-6 text-sm text-gray-400",children:"Error: No form data available."})})}function we(e){if(typeof e=="string"||typeof e=="number")return""+e;let n="";if(Array.isArray(e))for(let i=0,o;i<e.length;i++)(o=we(e[i]))!==""&&(n+=(n&&" ")+o);else for(let i in e)e[i]&&(n+=(n&&" ")+i);return n}var rw={value:()=>{}};function Ki(){for(var e=0,n=arguments.length,i={},o;e<n;++e){if(!(o=arguments[e]+"")||o in i||/[\s.]/.test(o))throw new Error("illegal type: "+o);i[o]=[]}return new Hi(i)}function Hi(e){this._=e}function lw(e,n){return e.trim().split(/^|\s+/).map(function(i){var o="",a=i.indexOf(".");if(a>=0&&(o=i.slice(a+1),i=i.slice(0,a)),i&&!n.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:o}})}Hi.prototype=Ki.prototype={constructor:Hi,on:function(e,n){var i=this._,o=lw(e+"",i),a,s=-1,t=o.length;if(arguments.length<2){for(;++s<t;)if((a=(e=o[s]).type)&&(a=uw(i[a],e.name)))return a;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++s<t;)if(a=(e=o[s]).type)i[a]=Oc(i[a],e.name,n);else if(n==null)for(a in i)i[a]=Oc(i[a],e.name,null);return this},copy:function(){var e={},n=this._;for(var i in n)e[i]=n[i].slice();return new Hi(e)},call:function(e,n){if((a=arguments.length-2)>0)for(var i=new Array(a),o=0,a,s;o<a;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],o=0,a=s.length;o<a;++o)s[o].value.apply(n,i)},apply:function(e,n,i){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],a=0,s=o.length;a<s;++a)o[a].value.apply(n,i)}};function uw(e,n){for(var i=0,o=e.length,a;i<o;++i)if((a=e[i]).name===n)return a.value}function Oc(e,n,i){for(var o=0,a=e.length;o<a;++o)if(e[o].name===n){e[o]=rw,e=e.slice(0,o).concat(e.slice(o+1));break}return i!=null&&e.push({name:n,value:i}),e}var ya="http://www.w3.org/1999/xhtml";const Dc={svg:"http://www.w3.org/2000/svg",xhtml:ya,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Vi(e){var n=e+="",i=n.indexOf(":");return i>=0&&(n=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),Dc.hasOwnProperty(n)?{space:Dc[n],local:e}:e}function dw(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===ya&&n.documentElement.namespaceURI===ya?n.createElement(e):n.createElementNS(i,e)}}function cw(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qc(e){var n=Vi(e);return(n.local?cw:dw)(n)}function bw(){}function xa(e){return e==null?bw:function(){return this.querySelector(e)}}function mw(e){typeof e!="function"&&(e=xa(e));for(var n=this._groups,i=n.length,o=new Array(i),a=0;a<i;++a)for(var s=n[a],t=s.length,r=o[a]=new Array(t),l,u,d=0;d<t;++d)(l=s[d])&&(u=e.call(l,l.__data__,d,s))&&("__data__"in l&&(u.__data__=l.__data__),r[d]=u);return new Ie(o,this._parents)}function fw(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function vw(){return[]}function Fc(e){return e==null?vw:function(){return this.querySelectorAll(e)}}function hw(e){return function(){return fw(e.apply(this,arguments))}}function pw(e){typeof e=="function"?e=hw(e):e=Fc(e);for(var n=this._groups,i=n.length,o=[],a=[],s=0;s<i;++s)for(var t=n[s],r=t.length,l,u=0;u<r;++u)(l=t[u])&&(o.push(e.call(l,l.__data__,u,t)),a.push(l));return new Ie(o,a)}function Gc(e){return function(){return this.matches(e)}}function Kc(e){return function(n){return n.matches(e)}}var gw=Array.prototype.find;function yw(e){return function(){return gw.call(this.children,e)}}function xw(){return this.firstElementChild}function Sw(e){return this.select(e==null?xw:yw(typeof e=="function"?e:Kc(e)))}var ww=Array.prototype.filter;function Aw(){return Array.from(this.children)}function Nw(e){return function(){return ww.call(this.children,e)}}function Cw(e){return this.selectAll(e==null?Aw:Nw(typeof e=="function"?e:Kc(e)))}function _w(e){typeof e!="function"&&(e=Gc(e));for(var n=this._groups,i=n.length,o=new Array(i),a=0;a<i;++a)for(var s=n[a],t=s.length,r=o[a]=[],l,u=0;u<t;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&r.push(l);return new Ie(o,this._parents)}function Hc(e){return new Array(e.length)}function Ew(){return new Ie(this._enter||this._groups.map(Hc),this._parents)}function zi(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}zi.prototype={constructor:zi,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function kw(e){return function(){return e}}function Mw(e,n,i,o,a,s){for(var t=0,r,l=n.length,u=s.length;t<u;++t)(r=n[t])?(r.__data__=s[t],o[t]=r):i[t]=new zi(e,s[t]);for(;t<l;++t)(r=n[t])&&(a[t]=r)}function Tw(e,n,i,o,a,s,t){var r,l,u=new Map,d=n.length,b=s.length,m=new Array(d),f;for(r=0;r<d;++r)(l=n[r])&&(m[r]=f=t.call(l,l.__data__,r,n)+"",u.has(f)?a[r]=l:u.set(f,l));for(r=0;r<b;++r)f=t.call(e,s[r],r,s)+"",(l=u.get(f))?(o[r]=l,l.__data__=s[r],u.delete(f)):i[r]=new zi(e,s[r]);for(r=0;r<d;++r)(l=n[r])&&u.get(m[r])===l&&(a[r]=l)}function Pw(e){return e.__data__}function Iw(e,n){if(!arguments.length)return Array.from(this,Pw);var i=n?Tw:Mw,o=this._parents,a=this._groups;typeof e!="function"&&(e=kw(e));for(var s=a.length,t=new Array(s),r=new Array(s),l=new Array(s),u=0;u<s;++u){var d=o[u],b=a[u],m=b.length,f=Lw(e.call(d,d&&d.__data__,u,o)),h=f.length,g=r[u]=new Array(h),v=t[u]=new Array(h),p=l[u]=new Array(m);i(d,b,g,v,p,f,n);for(var S=0,y=0,x,w;S<h;++S)if(x=g[S]){for(S>=y&&(y=S+1);!(w=v[y])&&++y<h;);x._next=w||null}}return t=new Ie(t,o),t._enter=r,t._exit=l,t}function Lw(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Bw(){return new Ie(this._exit||this._groups.map(Hc),this._parents)}function Ow(e,n,i){var o=this.enter(),a=this,s=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),n!=null&&(a=n(a),a&&(a=a.selection())),i==null?s.remove():i(s),o&&a?o.merge(a).order():a}function Dw(e){for(var n=e.selection?e.selection():e,i=this._groups,o=n._groups,a=i.length,s=o.length,t=Math.min(a,s),r=new Array(a),l=0;l<t;++l)for(var u=i[l],d=o[l],b=u.length,m=r[l]=new Array(b),f,h=0;h<b;++h)(f=u[h]||d[h])&&(m[h]=f);for(;l<a;++l)r[l]=i[l];return new Ie(r,this._parents)}function qw(){for(var e=this._groups,n=-1,i=e.length;++n<i;)for(var o=e[n],a=o.length-1,s=o[a],t;--a>=0;)(t=o[a])&&(s&&t.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(t,s),s=t);return this}function Fw(e){e||(e=Gw);function n(b,m){return b&&m?e(b.__data__,m.__data__):!b-!m}for(var i=this._groups,o=i.length,a=new Array(o),s=0;s<o;++s){for(var t=i[s],r=t.length,l=a[s]=new Array(r),u,d=0;d<r;++d)(u=t[d])&&(l[d]=u);l.sort(n)}return new Ie(a,this._parents).order()}function Gw(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function Kw(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Hw(){return Array.from(this)}function Vw(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],a=0,s=o.length;a<s;++a){var t=o[a];if(t)return t}return null}function zw(){let e=0;for(const n of this)++e;return e}function jw(){return!this.node()}function Uw(e){for(var n=this._groups,i=0,o=n.length;i<o;++i)for(var a=n[i],s=0,t=a.length,r;s<t;++s)(r=a[s])&&e.call(r,r.__data__,s,a);return this}function Ww(e){return function(){this.removeAttribute(e)}}function $w(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Yw(e,n){return function(){this.setAttribute(e,n)}}function Jw(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function Zw(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function Xw(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,i)}}function Qw(e,n){var i=Vi(e);if(arguments.length<2){var o=this.node();return i.local?o.getAttributeNS(i.space,i.local):o.getAttribute(i)}return this.each((n==null?i.local?$w:Ww:typeof n=="function"?i.local?Xw:Zw:i.local?Jw:Yw)(i,n))}function Vc(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Rw(e){return function(){this.style.removeProperty(e)}}function eA(e,n,i){return function(){this.style.setProperty(e,n,i)}}function nA(e,n,i){return function(){var o=n.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,i)}}function iA(e,n,i){return arguments.length>1?this.each((n==null?Rw:typeof n=="function"?nA:eA)(e,n,i==null?"":i)):Ln(this.node(),e)}function Ln(e,n){return e.style.getPropertyValue(n)||Vc(e).getComputedStyle(e,null).getPropertyValue(n)}function oA(e){return function(){delete this[e]}}function aA(e,n){return function(){this[e]=n}}function sA(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function tA(e,n){return arguments.length>1?this.each((n==null?oA:typeof n=="function"?sA:aA)(e,n)):this.node()[e]}function zc(e){return e.trim().split(/^|\s+/)}function Sa(e){return e.classList||new jc(e)}function jc(e){this._node=e,this._names=zc(e.getAttribute("class")||"")}jc.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Uc(e,n){for(var i=Sa(e),o=-1,a=n.length;++o<a;)i.add(n[o])}function Wc(e,n){for(var i=Sa(e),o=-1,a=n.length;++o<a;)i.remove(n[o])}function rA(e){return function(){Uc(this,e)}}function lA(e){return function(){Wc(this,e)}}function uA(e,n){return function(){(n.apply(this,arguments)?Uc:Wc)(this,e)}}function dA(e,n){var i=zc(e+"");if(arguments.length<2){for(var o=Sa(this.node()),a=-1,s=i.length;++a<s;)if(!o.contains(i[a]))return!1;return!0}return this.each((typeof n=="function"?uA:n?rA:lA)(i,n))}function cA(){this.textContent=""}function bA(e){return function(){this.textContent=e}}function mA(e){return function(){var n=e.apply(this,arguments);this.textContent=n==null?"":n}}function fA(e){return arguments.length?this.each(e==null?cA:(typeof e=="function"?mA:bA)(e)):this.node().textContent}function vA(){this.innerHTML=""}function hA(e){return function(){this.innerHTML=e}}function pA(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n==null?"":n}}function gA(e){return arguments.length?this.each(e==null?vA:(typeof e=="function"?pA:hA)(e)):this.node().innerHTML}function yA(){this.nextSibling&&this.parentNode.appendChild(this)}function xA(){return this.each(yA)}function SA(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function wA(){return this.each(SA)}function AA(e){var n=typeof e=="function"?e:qc(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function NA(){return null}function CA(e,n){var i=typeof e=="function"?e:qc(e),o=n==null?NA:typeof n=="function"?n:xa(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),o.apply(this,arguments)||null)})}function _A(){var e=this.parentNode;e&&e.removeChild(this)}function EA(){return this.each(_A)}function kA(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function MA(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function TA(e){return this.select(e?MA:kA)}function PA(e){return arguments.length?this.property("__data__",e):this.node().__data__}function IA(e){return function(n){e.call(this,n,this.__data__)}}function LA(e){return e.trim().split(/^|\s+/).map(function(n){var i="",o=n.indexOf(".");return o>=0&&(i=n.slice(o+1),n=n.slice(0,o)),{type:n,name:i}})}function BA(e){return function(){var n=this.__on;if(n){for(var i=0,o=-1,a=n.length,s;i<a;++i)s=n[i],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):n[++o]=s;++o?n.length=o:delete this.__on}}}function OA(e,n,i){return function(){var o=this.__on,a,s=IA(n);if(o){for(var t=0,r=o.length;t<r;++t)if((a=o[t]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=s,a.options=i),a.value=n;return}}this.addEventListener(e.type,s,i),a={type:e.type,name:e.name,value:n,listener:s,options:i},o?o.push(a):this.__on=[a]}}function DA(e,n,i){var o=LA(e+""),a,s=o.length,t;if(arguments.length<2){var r=this.node().__on;if(r){for(var l=0,u=r.length,d;l<u;++l)for(a=0,d=r[l];a<s;++a)if((t=o[a]).type===d.type&&t.name===d.name)return d.value}return}for(r=n?OA:BA,a=0;a<s;++a)this.each(r(o[a],n,i));return this}function $c(e,n,i){var o=Vc(e),a=o.CustomEvent;typeof a=="function"?a=new a(n,i):(a=o.document.createEvent("Event"),i?(a.initEvent(n,i.bubbles,i.cancelable),a.detail=i.detail):a.initEvent(n,!1,!1)),e.dispatchEvent(a)}function qA(e,n){return function(){return $c(this,e,n)}}function FA(e,n){return function(){return $c(this,e,n.apply(this,arguments))}}function GA(e,n){return this.each((typeof n=="function"?FA:qA)(e,n))}function*KA(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],a=0,s=o.length,t;a<s;++a)(t=o[a])&&(yield t)}var Yc=[null];function Ie(e,n){this._groups=e,this._parents=n}function ii(){return new Ie([[document.documentElement]],Yc)}function HA(){return this}Ie.prototype=ii.prototype={constructor:Ie,select:mw,selectAll:pw,selectChild:Sw,selectChildren:Cw,filter:_w,data:Iw,enter:Ew,exit:Bw,join:Ow,merge:Dw,selection:HA,order:qw,sort:Fw,call:Kw,nodes:Hw,node:Vw,size:zw,empty:jw,each:Uw,attr:Qw,style:iA,property:tA,classed:dA,text:fA,html:gA,raise:xA,lower:wA,append:AA,insert:CA,remove:EA,clone:TA,datum:PA,on:DA,dispatch:GA,[Symbol.iterator]:KA};function Le(e){return typeof e=="string"?new Ie([[document.querySelector(e)]],[document.documentElement]):new Ie([[e]],Yc)}function VA(e){let n;for(;n=e.sourceEvent;)e=n;return e}function qe(e,n){if(e=VA(e),n===void 0&&(n=e.currentTarget),n){var i=n.ownerSVGElement||n;if(i.createSVGPoint){var o=i.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(n.getScreenCTM().inverse()),[o.x,o.y]}if(n.getBoundingClientRect){var a=n.getBoundingClientRect();return[e.clientX-a.left-n.clientLeft,e.clientY-a.top-n.clientTop]}}return[e.pageX,e.pageY]}const zA={passive:!1},oi={capture:!0,passive:!1};function wa(e){e.stopImmediatePropagation()}function Bn(e){e.preventDefault(),e.stopImmediatePropagation()}function Jc(e){var n=e.document.documentElement,i=Le(e).on("dragstart.drag",Bn,oi);"onselectstart"in n?i.on("selectstart.drag",Bn,oi):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Zc(e,n){var i=e.document.documentElement,o=Le(e).on("dragstart.drag",null);n&&(o.on("click.drag",Bn,oi),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in i?o.on("selectstart.drag",null):(i.style.MozUserSelect=i.__noselect,delete i.__noselect)}const ji=e=>()=>e;function Aa(e,{sourceEvent:n,subject:i,target:o,identifier:a,active:s,x:t,y:r,dx:l,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:t,enumerable:!0,configurable:!0},y:{value:r,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}Aa.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function jA(e){return!e.ctrlKey&&!e.button}function UA(){return this.parentNode}function WA(e,n){return n==null?{x:e.x,y:e.y}:n}function $A(){return navigator.maxTouchPoints||"ontouchstart"in this}function Xc(){var e=jA,n=UA,i=WA,o=$A,a={},s=Ki("start","drag","end"),t=0,r,l,u,d,b=0;function m(x){x.on("mousedown.drag",f).filter(o).on("touchstart.drag",v).on("touchmove.drag",p,zA).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(x,w){if(!(d||!e.call(this,x,w))){var A=y(this,n.call(this,x,w),x,w,"mouse");A&&(Le(x.view).on("mousemove.drag",h,oi).on("mouseup.drag",g,oi),Jc(x.view),wa(x),u=!1,r=x.clientX,l=x.clientY,A("start",x))}}function h(x){if(Bn(x),!u){var w=x.clientX-r,A=x.clientY-l;u=w*w+A*A>b}a.mouse("drag",x)}function g(x){Le(x.view).on("mousemove.drag mouseup.drag",null),Zc(x.view,u),Bn(x),a.mouse("end",x)}function v(x,w){if(e.call(this,x,w)){var A=x.changedTouches,N=n.call(this,x,w),E=A.length,_,P;for(_=0;_<E;++_)(P=y(this,N,x,w,A[_].identifier,A[_]))&&(wa(x),P("start",x,A[_]))}}function p(x){var w=x.changedTouches,A=w.length,N,E;for(N=0;N<A;++N)(E=a[w[N].identifier])&&(Bn(x),E("drag",x,w[N]))}function S(x){var w=x.changedTouches,A=w.length,N,E;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),N=0;N<A;++N)(E=a[w[N].identifier])&&(wa(x),E("end",x,w[N]))}function y(x,w,A,N,E,_){var P=s.copy(),k=qe(_||A,w),M,L,T;if((T=i.call(x,new Aa("beforestart",{sourceEvent:A,target:m,identifier:E,active:t,x:k[0],y:k[1],dx:0,dy:0,dispatch:P}),N))!=null)return M=T.x-k[0]||0,L=T.y-k[1]||0,function O(B,K,G){var I=k,Y;switch(B){case"start":a[E]=O,Y=t++;break;case"end":delete a[E],--t;case"drag":k=qe(G||K,w),Y=t;break}P.call(B,x,new Aa(B,{sourceEvent:K,subject:T,target:m,identifier:E,active:Y,x:k[0]+M,y:k[1]+L,dx:k[0]-I[0],dy:k[1]-I[1],dispatch:P}),N)}}return m.filter=function(x){return arguments.length?(e=typeof x=="function"?x:ji(!!x),m):e},m.container=function(x){return arguments.length?(n=typeof x=="function"?x:ji(x),m):n},m.subject=function(x){return arguments.length?(i=typeof x=="function"?x:ji(x),m):i},m.touchable=function(x){return arguments.length?(o=typeof x=="function"?x:ji(!!x),m):o},m.on=function(){var x=s.on.apply(s,arguments);return x===s?m:x},m.clickDistance=function(x){return arguments.length?(b=(x=+x)*x,m):Math.sqrt(b)},m}function Na(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function Qc(e,n){var i=Object.create(e.prototype);for(var o in n)i[o]=n[o];return i}function ai(){}var si=.7,Ui=1/si,On="\\s*([+-]?\\d+)\\s*",ti="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",We="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",YA=/^#([0-9a-f]{3,8})$/,JA=new RegExp(`^rgb\\(${On},${On},${On}\\)$`),ZA=new RegExp(`^rgb\\(${We},${We},${We}\\)$`),XA=new RegExp(`^rgba\\(${On},${On},${On},${ti}\\)$`),QA=new RegExp(`^rgba\\(${We},${We},${We},${ti}\\)$`),RA=new RegExp(`^hsl\\(${ti},${We},${We}\\)$`),eN=new RegExp(`^hsla\\(${ti},${We},${We},${ti}\\)$`),Rc={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Na(ai,fn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:eb,formatHex:eb,formatHex8:nN,formatHsl:iN,formatRgb:nb,toString:nb});function eb(){return this.rgb().formatHex()}function nN(){return this.rgb().formatHex8()}function iN(){return tb(this).formatHsl()}function nb(){return this.rgb().formatRgb()}function fn(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=YA.exec(e))?(i=n[1].length,n=parseInt(n[1],16),i===6?ib(n):i===3?new ke(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):i===8?Wi(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?Wi(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=JA.exec(e))?new ke(n[1],n[2],n[3],1):(n=ZA.exec(e))?new ke(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=XA.exec(e))?Wi(n[1],n[2],n[3],n[4]):(n=QA.exec(e))?Wi(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=RA.exec(e))?sb(n[1],n[2]/100,n[3]/100,1):(n=eN.exec(e))?sb(n[1],n[2]/100,n[3]/100,n[4]):Rc.hasOwnProperty(e)?ib(Rc[e]):e==="transparent"?new ke(NaN,NaN,NaN,0):null}function ib(e){return new ke(e>>16&255,e>>8&255,e&255,1)}function Wi(e,n,i,o){return o<=0&&(e=n=i=NaN),new ke(e,n,i,o)}function oN(e){return e instanceof ai||(e=fn(e)),e?(e=e.rgb(),new ke(e.r,e.g,e.b,e.opacity)):new ke}function Ca(e,n,i,o){return arguments.length===1?oN(e):new ke(e,n,i,o==null?1:o)}function ke(e,n,i,o){this.r=+e,this.g=+n,this.b=+i,this.opacity=+o}Na(ke,Ca,Qc(ai,{brighter(e){return e=e==null?Ui:Math.pow(Ui,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?si:Math.pow(si,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ke(vn(this.r),vn(this.g),vn(this.b),$i(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ob,formatHex:ob,formatHex8:aN,formatRgb:ab,toString:ab}));function ob(){return`#${hn(this.r)}${hn(this.g)}${hn(this.b)}`}function aN(){return`#${hn(this.r)}${hn(this.g)}${hn(this.b)}${hn((isNaN(this.opacity)?1:this.opacity)*255)}`}function ab(){const e=$i(this.opacity);return`${e===1?"rgb(":"rgba("}${vn(this.r)}, ${vn(this.g)}, ${vn(this.b)}${e===1?")":`, ${e})`}`}function $i(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function vn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function hn(e){return e=vn(e),(e<16?"0":"")+e.toString(16)}function sb(e,n,i,o){return o<=0?e=n=i=NaN:i<=0||i>=1?e=n=NaN:n<=0&&(e=NaN),new Fe(e,n,i,o)}function tb(e){if(e instanceof Fe)return new Fe(e.h,e.s,e.l,e.opacity);if(e instanceof ai||(e=fn(e)),!e)return new Fe;if(e instanceof Fe)return e;e=e.rgb();var n=e.r/255,i=e.g/255,o=e.b/255,a=Math.min(n,i,o),s=Math.max(n,i,o),t=NaN,r=s-a,l=(s+a)/2;return r?(n===s?t=(i-o)/r+(i<o)*6:i===s?t=(o-n)/r+2:t=(n-i)/r+4,r/=l<.5?s+a:2-s-a,t*=60):r=l>0&&l<1?0:t,new Fe(t,r,l,e.opacity)}function sN(e,n,i,o){return arguments.length===1?tb(e):new Fe(e,n,i,o==null?1:o)}function Fe(e,n,i,o){this.h=+e,this.s=+n,this.l=+i,this.opacity=+o}Na(Fe,sN,Qc(ai,{brighter(e){return e=e==null?Ui:Math.pow(Ui,e),new Fe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?si:Math.pow(si,e),new Fe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,i=this.l,o=i+(i<.5?i:1-i)*n,a=2*i-o;return new ke(_a(e>=240?e-240:e+120,a,o),_a(e,a,o),_a(e<120?e+240:e-120,a,o),this.opacity)},clamp(){return new Fe(rb(this.h),Yi(this.s),Yi(this.l),$i(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=$i(this.opacity);return`${e===1?"hsl(":"hsla("}${rb(this.h)}, ${Yi(this.s)*100}%, ${Yi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function rb(e){return e=(e||0)%360,e<0?e+360:e}function Yi(e){return Math.max(0,Math.min(1,e||0))}function _a(e,n,i){return(e<60?n+(i-n)*e/60:e<180?i:e<240?n+(i-n)*(240-e)/60:n)*255}const Ea=e=>()=>e;function tN(e,n){return function(i){return e+i*n}}function rN(e,n,i){return e=Math.pow(e,i),n=Math.pow(n,i)-e,i=1/i,function(o){return Math.pow(e+o*n,i)}}function lN(e){return(e=+e)==1?lb:function(n,i){return i-n?rN(n,i,e):Ea(isNaN(n)?i:n)}}function lb(e,n){var i=n-e;return i?tN(e,i):Ea(isNaN(e)?n:e)}const Ji=function e(n){var i=lN(n);function o(a,s){var t=i((a=Ca(a)).r,(s=Ca(s)).r),r=i(a.g,s.g),l=i(a.b,s.b),u=lb(a.opacity,s.opacity);return function(d){return a.r=t(d),a.g=r(d),a.b=l(d),a.opacity=u(d),a+""}}return o.gamma=e,o}(1);function uN(e,n){n||(n=[]);var i=e?Math.min(n.length,e.length):0,o=n.slice(),a;return function(s){for(a=0;a<i;++a)o[a]=e[a]*(1-s)+n[a]*s;return o}}function dN(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function cN(e,n){var i=n?n.length:0,o=e?Math.min(i,e.length):0,a=new Array(o),s=new Array(i),t;for(t=0;t<o;++t)a[t]=ri(e[t],n[t]);for(;t<i;++t)s[t]=n[t];return function(r){for(t=0;t<o;++t)s[t]=a[t](r);return s}}function bN(e,n){var i=new Date;return e=+e,n=+n,function(o){return i.setTime(e*(1-o)+n*o),i}}function $e(e,n){return e=+e,n=+n,function(i){return e*(1-i)+n*i}}function mN(e,n){var i={},o={},a;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(a in n)a in e?i[a]=ri(e[a],n[a]):o[a]=n[a];return function(s){for(a in i)o[a]=i[a](s);return o}}var ka=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ma=new RegExp(ka.source,"g");function fN(e){return function(){return e}}function vN(e){return function(n){return e(n)+""}}function ub(e,n){var i=ka.lastIndex=Ma.lastIndex=0,o,a,s,t=-1,r=[],l=[];for(e=e+"",n=n+"";(o=ka.exec(e))&&(a=Ma.exec(n));)(s=a.index)>i&&(s=n.slice(i,s),r[t]?r[t]+=s:r[++t]=s),(o=o[0])===(a=a[0])?r[t]?r[t]+=a:r[++t]=a:(r[++t]=null,l.push({i:t,x:$e(o,a)})),i=Ma.lastIndex;return i<n.length&&(s=n.slice(i),r[t]?r[t]+=s:r[++t]=s),r.length<2?l[0]?vN(l[0].x):fN(n):(n=l.length,function(u){for(var d=0,b;d<n;++d)r[(b=l[d]).i]=b.x(u);return r.join("")})}function ri(e,n){var i=typeof n,o;return n==null||i==="boolean"?Ea(n):(i==="number"?$e:i==="string"?(o=fn(n))?(n=o,Ji):ub:n instanceof fn?Ji:n instanceof Date?bN:dN(n)?uN:Array.isArray(n)?cN:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?mN:$e)(e,n)}var db=180/Math.PI,Ta={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cb(e,n,i,o,a,s){var t,r,l;return(t=Math.sqrt(e*e+n*n))&&(e/=t,n/=t),(l=e*i+n*o)&&(i-=e*l,o-=n*l),(r=Math.sqrt(i*i+o*o))&&(i/=r,o/=r,l/=r),e*o<n*i&&(e=-e,n=-n,l=-l,t=-t),{translateX:a,translateY:s,rotate:Math.atan2(n,e)*db,skewX:Math.atan(l)*db,scaleX:t,scaleY:r}}var Zi;function hN(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Ta:cb(n.a,n.b,n.c,n.d,n.e,n.f)}function pN(e){return e==null||(Zi||(Zi=document.createElementNS("http://www.w3.org/2000/svg","g")),Zi.setAttribute("transform",e),!(e=Zi.transform.baseVal.consolidate()))?Ta:(e=e.matrix,cb(e.a,e.b,e.c,e.d,e.e,e.f))}function bb(e,n,i,o){function a(u){return u.length?u.pop()+" ":""}function s(u,d,b,m,f,h){if(u!==b||d!==m){var g=f.push("translate(",null,n,null,i);h.push({i:g-4,x:$e(u,b)},{i:g-2,x:$e(d,m)})}else(b||m)&&f.push("translate("+b+n+m+i)}function t(u,d,b,m){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),m.push({i:b.push(a(b)+"rotate(",null,o)-2,x:$e(u,d)})):d&&b.push(a(b)+"rotate("+d+o)}function r(u,d,b,m){u!==d?m.push({i:b.push(a(b)+"skewX(",null,o)-2,x:$e(u,d)}):d&&b.push(a(b)+"skewX("+d+o)}function l(u,d,b,m,f,h){if(u!==b||d!==m){var g=f.push(a(f)+"scale(",null,",",null,")");h.push({i:g-4,x:$e(u,b)},{i:g-2,x:$e(d,m)})}else(b!==1||m!==1)&&f.push(a(f)+"scale("+b+","+m+")")}return function(u,d){var b=[],m=[];return u=e(u),d=e(d),s(u.translateX,u.translateY,d.translateX,d.translateY,b,m),t(u.rotate,d.rotate,b,m),r(u.skewX,d.skewX,b,m),l(u.scaleX,u.scaleY,d.scaleX,d.scaleY,b,m),u=d=null,function(f){for(var h=-1,g=m.length,v;++h<g;)b[(v=m[h]).i]=v.x(f);return b.join("")}}}var gN=bb(hN,"px, ","px)","deg)"),yN=bb(pN,", ",")",")"),xN=1e-12;function mb(e){return((e=Math.exp(e))+1/e)/2}function SN(e){return((e=Math.exp(e))-1/e)/2}function wN(e){return((e=Math.exp(2*e))-1)/(e+1)}const Xi=function e(n,i,o){function a(s,t){var r=s[0],l=s[1],u=s[2],d=t[0],b=t[1],m=t[2],f=d-r,h=b-l,g=f*f+h*h,v,p;if(g<xN)p=Math.log(m/u)/n,v=function(N){return[r+N*f,l+N*h,u*Math.exp(n*N*p)]};else{var S=Math.sqrt(g),y=(m*m-u*u+o*g)/(2*u*i*S),x=(m*m-u*u-o*g)/(2*m*i*S),w=Math.log(Math.sqrt(y*y+1)-y),A=Math.log(Math.sqrt(x*x+1)-x);p=(A-w)/n,v=function(N){var E=N*p,_=mb(w),P=u/(i*S)*(_*wN(n*E+w)-SN(w));return[r+P*f,l+P*h,u*_/mb(n*E+w)]}}return v.duration=p*1e3*n/Math.SQRT2,v}return a.rho=function(s){var t=Math.max(.001,+s),r=t*t,l=r*r;return e(t,r,l)},a}(Math.SQRT2,2,4);var Dn=0,li=0,ui=0,fb=1e3,Qi,di,Ri=0,pn=0,eo=0,ci=typeof performance=="object"&&performance.now?performance:Date,vb=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Pa(){return pn||(vb(AN),pn=ci.now()+eo)}function AN(){pn=0}function no(){this._call=this._time=this._next=null}no.prototype=hb.prototype={constructor:no,restart:function(e,n,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?Pa():+i)+(n==null?0:+n),!this._next&&di!==this&&(di?di._next=this:Qi=this,di=this),this._call=e,this._time=i,Ia()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ia())}};function hb(e,n,i){var o=new no;return o.restart(e,n,i),o}function NN(){Pa(),++Dn;for(var e=Qi,n;e;)(n=pn-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Dn}function pb(){pn=(Ri=ci.now())+eo,Dn=li=0;try{NN()}finally{Dn=0,_N(),pn=0}}function CN(){var e=ci.now(),n=e-Ri;n>fb&&(eo-=n,Ri=e)}function _N(){for(var e,n=Qi,i,o=1/0;n;)n._call?(o>n._time&&(o=n._time),e=n,n=n._next):(i=n._next,n._next=null,n=e?e._next=i:Qi=i);di=e,Ia(o)}function Ia(e){if(!Dn){li&&(li=clearTimeout(li));var n=e-pn;n>24?(e<1/0&&(li=setTimeout(pb,e-ci.now()-eo)),ui&&(ui=clearInterval(ui))):(ui||(Ri=ci.now(),ui=setInterval(CN,fb)),Dn=1,vb(pb))}}function gb(e,n,i){var o=new no;return n=n==null?0:+n,o.restart(a=>{o.stop(),e(a+n)},n,i),o}var EN=Ki("start","end","cancel","interrupt"),kN=[],yb=0,xb=1,La=2,io=3,Sb=4,Ba=5,oo=6;function ao(e,n,i,o,a,s){var t=e.__transition;if(!t)e.__transition={};else if(i in t)return;MN(e,i,{name:n,index:o,group:a,on:EN,tween:kN,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:yb})}function Oa(e,n){var i=Ge(e,n);if(i.state>yb)throw new Error("too late; already scheduled");return i}function Ye(e,n){var i=Ge(e,n);if(i.state>io)throw new Error("too late; already running");return i}function Ge(e,n){var i=e.__transition;if(!i||!(i=i[n]))throw new Error("transition not found");return i}function MN(e,n,i){var o=e.__transition,a;o[n]=i,i.timer=hb(s,0,i.time);function s(u){i.state=xb,i.timer.restart(t,i.delay,i.time),i.delay<=u&&t(u-i.delay)}function t(u){var d,b,m,f;if(i.state!==xb)return l();for(d in o)if(f=o[d],f.name===i.name){if(f.state===io)return gb(t);f.state===Sb?(f.state=oo,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete o[d]):+d<n&&(f.state=oo,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete o[d])}if(gb(function(){i.state===io&&(i.state=Sb,i.timer.restart(r,i.delay,i.time),r(u))}),i.state=La,i.on.call("start",e,e.__data__,i.index,i.group),i.state===La){for(i.state=io,a=new Array(m=i.tween.length),d=0,b=-1;d<m;++d)(f=i.tween[d].value.call(e,e.__data__,i.index,i.group))&&(a[++b]=f);a.length=b+1}}function r(u){for(var d=u<i.duration?i.ease.call(null,u/i.duration):(i.timer.restart(l),i.state=Ba,1),b=-1,m=a.length;++b<m;)a[b].call(e,d);i.state===Ba&&(i.on.call("end",e,e.__data__,i.index,i.group),l())}function l(){i.state=oo,i.timer.stop(),delete o[n];for(var u in o)return;delete e.__transition}}function so(e,n){var i=e.__transition,o,a,s=!0,t;if(i){n=n==null?null:n+"";for(t in i){if((o=i[t]).name!==n){s=!1;continue}a=o.state>La&&o.state<Ba,o.state=oo,o.timer.stop(),o.on.call(a?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete i[t]}s&&delete e.__transition}}function TN(e){return this.each(function(){so(this,e)})}function PN(e,n){var i,o;return function(){var a=Ye(this,e),s=a.tween;if(s!==i){o=i=s;for(var t=0,r=o.length;t<r;++t)if(o[t].name===n){o=o.slice(),o.splice(t,1);break}}a.tween=o}}function IN(e,n,i){var o,a;if(typeof i!="function")throw new Error;return function(){var s=Ye(this,e),t=s.tween;if(t!==o){a=(o=t).slice();for(var r={name:n,value:i},l=0,u=a.length;l<u;++l)if(a[l].name===n){a[l]=r;break}l===u&&a.push(r)}s.tween=a}}function LN(e,n){var i=this._id;if(e+="",arguments.length<2){for(var o=Ge(this.node(),i).tween,a=0,s=o.length,t;a<s;++a)if((t=o[a]).name===e)return t.value;return null}return this.each((n==null?PN:IN)(i,e,n))}function Da(e,n,i){var o=e._id;return e.each(function(){var a=Ye(this,o);(a.value||(a.value={}))[n]=i.apply(this,arguments)}),function(a){return Ge(a,o).value[n]}}function wb(e,n){var i;return(typeof n=="number"?$e:n instanceof fn?Ji:(i=fn(n))?(n=i,Ji):ub)(e,n)}function BN(e){return function(){this.removeAttribute(e)}}function ON(e){return function(){this.removeAttributeNS(e.space,e.local)}}function DN(e,n,i){var o,a=i+"",s;return function(){var t=this.getAttribute(e);return t===a?null:t===o?s:s=n(o=t,i)}}function qN(e,n,i){var o,a=i+"",s;return function(){var t=this.getAttributeNS(e.space,e.local);return t===a?null:t===o?s:s=n(o=t,i)}}function FN(e,n,i){var o,a,s;return function(){var t,r=i(this),l;return r==null?void this.removeAttribute(e):(t=this.getAttribute(e),l=r+"",t===l?null:t===o&&l===a?s:(a=l,s=n(o=t,r)))}}function GN(e,n,i){var o,a,s;return function(){var t,r=i(this),l;return r==null?void this.removeAttributeNS(e.space,e.local):(t=this.getAttributeNS(e.space,e.local),l=r+"",t===l?null:t===o&&l===a?s:(a=l,s=n(o=t,r)))}}function KN(e,n){var i=Vi(e),o=i==="transform"?yN:wb;return this.attrTween(e,typeof n=="function"?(i.local?GN:FN)(i,o,Da(this,"attr."+e,n)):n==null?(i.local?ON:BN)(i):(i.local?qN:DN)(i,o,n))}function HN(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function VN(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function zN(e,n){var i,o;function a(){var s=n.apply(this,arguments);return s!==o&&(i=(o=s)&&VN(e,s)),i}return a._value=n,a}function jN(e,n){var i,o;function a(){var s=n.apply(this,arguments);return s!==o&&(i=(o=s)&&HN(e,s)),i}return a._value=n,a}function UN(e,n){var i="attr."+e;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(n==null)return this.tween(i,null);if(typeof n!="function")throw new Error;var o=Vi(e);return this.tween(i,(o.local?zN:jN)(o,n))}function WN(e,n){return function(){Oa(this,e).delay=+n.apply(this,arguments)}}function $N(e,n){return n=+n,function(){Oa(this,e).delay=n}}function YN(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?WN:$N)(n,e)):Ge(this.node(),n).delay}function JN(e,n){return function(){Ye(this,e).duration=+n.apply(this,arguments)}}function ZN(e,n){return n=+n,function(){Ye(this,e).duration=n}}function XN(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?JN:ZN)(n,e)):Ge(this.node(),n).duration}function QN(e,n){if(typeof n!="function")throw new Error;return function(){Ye(this,e).ease=n}}function RN(e){var n=this._id;return arguments.length?this.each(QN(n,e)):Ge(this.node(),n).ease}function eC(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;Ye(this,e).ease=i}}function nC(e){if(typeof e!="function")throw new Error;return this.each(eC(this._id,e))}function iC(e){typeof e!="function"&&(e=Gc(e));for(var n=this._groups,i=n.length,o=new Array(i),a=0;a<i;++a)for(var s=n[a],t=s.length,r=o[a]=[],l,u=0;u<t;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&r.push(l);return new Qe(o,this._parents,this._name,this._id)}function oC(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,i=e._groups,o=n.length,a=i.length,s=Math.min(o,a),t=new Array(o),r=0;r<s;++r)for(var l=n[r],u=i[r],d=l.length,b=t[r]=new Array(d),m,f=0;f<d;++f)(m=l[f]||u[f])&&(b[f]=m);for(;r<o;++r)t[r]=n[r];return new Qe(t,this._parents,this._name,this._id)}function aC(e){return(e+"").trim().split(/^|\s+/).every(function(n){var i=n.indexOf(".");return i>=0&&(n=n.slice(0,i)),!n||n==="start"})}function sC(e,n,i){var o,a,s=aC(n)?Oa:Ye;return function(){var t=s(this,e),r=t.on;r!==o&&(a=(o=r).copy()).on(n,i),t.on=a}}function tC(e,n){var i=this._id;return arguments.length<2?Ge(this.node(),i).on.on(e):this.each(sC(i,e,n))}function rC(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function lC(){return this.on("end.remove",rC(this._id))}function uC(e){var n=this._name,i=this._id;typeof e!="function"&&(e=xa(e));for(var o=this._groups,a=o.length,s=new Array(a),t=0;t<a;++t)for(var r=o[t],l=r.length,u=s[t]=new Array(l),d,b,m=0;m<l;++m)(d=r[m])&&(b=e.call(d,d.__data__,m,r))&&("__data__"in d&&(b.__data__=d.__data__),u[m]=b,ao(u[m],n,i,m,u,Ge(d,i)));return new Qe(s,this._parents,n,i)}function dC(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Fc(e));for(var o=this._groups,a=o.length,s=[],t=[],r=0;r<a;++r)for(var l=o[r],u=l.length,d,b=0;b<u;++b)if(d=l[b]){for(var m=e.call(d,d.__data__,b,l),f,h=Ge(d,i),g=0,v=m.length;g<v;++g)(f=m[g])&&ao(f,n,i,g,m,h);s.push(m),t.push(d)}return new Qe(s,t,n,i)}var cC=ii.prototype.constructor;function bC(){return new cC(this._groups,this._parents)}function mC(e,n){var i,o,a;return function(){var s=Ln(this,e),t=(this.style.removeProperty(e),Ln(this,e));return s===t?null:s===i&&t===o?a:a=n(i=s,o=t)}}function Ab(e){return function(){this.style.removeProperty(e)}}function fC(e,n,i){var o,a=i+"",s;return function(){var t=Ln(this,e);return t===a?null:t===o?s:s=n(o=t,i)}}function vC(e,n,i){var o,a,s;return function(){var t=Ln(this,e),r=i(this),l=r+"";return r==null&&(l=r=(this.style.removeProperty(e),Ln(this,e))),t===l?null:t===o&&l===a?s:(a=l,s=n(o=t,r))}}function hC(e,n){var i,o,a,s="style."+n,t="end."+s,r;return function(){var l=Ye(this,e),u=l.on,d=l.value[s]==null?r||(r=Ab(n)):void 0;(u!==i||a!==d)&&(o=(i=u).copy()).on(t,a=d),l.on=o}}function pC(e,n,i){var o=(e+="")=="transform"?gN:wb;return n==null?this.styleTween(e,mC(e,o)).on("end.style."+e,Ab(e)):typeof n=="function"?this.styleTween(e,vC(e,o,Da(this,"style."+e,n))).each(hC(this._id,e)):this.styleTween(e,fC(e,o,n),i).on("end.style."+e,null)}function gC(e,n,i){return function(o){this.style.setProperty(e,n.call(this,o),i)}}function yC(e,n,i){var o,a;function s(){var t=n.apply(this,arguments);return t!==a&&(o=(a=t)&&gC(e,t,i)),o}return s._value=n,s}function xC(e,n,i){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(n==null)return this.tween(o,null);if(typeof n!="function")throw new Error;return this.tween(o,yC(e,n,i==null?"":i))}function SC(e){return function(){this.textContent=e}}function wC(e){return function(){var n=e(this);this.textContent=n==null?"":n}}function AC(e){return this.tween("text",typeof e=="function"?wC(Da(this,"text",e)):SC(e==null?"":e+""))}function NC(e){return function(n){this.textContent=e.call(this,n)}}function CC(e){var n,i;function o(){var a=e.apply(this,arguments);return a!==i&&(n=(i=a)&&NC(a)),n}return o._value=e,o}function _C(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,CC(e))}function EC(){for(var e=this._name,n=this._id,i=Nb(),o=this._groups,a=o.length,s=0;s<a;++s)for(var t=o[s],r=t.length,l,u=0;u<r;++u)if(l=t[u]){var d=Ge(l,n);ao(l,e,i,u,t,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Qe(o,this._parents,e,i)}function kC(){var e,n,i=this,o=i._id,a=i.size();return new Promise(function(s,t){var r={value:t},l={value:function(){--a===0&&s()}};i.each(function(){var u=Ye(this,o),d=u.on;d!==e&&(n=(e=d).copy(),n._.cancel.push(r),n._.interrupt.push(r),n._.end.push(l)),u.on=n}),a===0&&s()})}var MC=0;function Qe(e,n,i,o){this._groups=e,this._parents=n,this._name=i,this._id=o}function Nb(){return++MC}var Re=ii.prototype;Qe.prototype={constructor:Qe,select:uC,selectAll:dC,selectChild:Re.selectChild,selectChildren:Re.selectChildren,filter:iC,merge:oC,selection:bC,transition:EC,call:Re.call,nodes:Re.nodes,node:Re.node,size:Re.size,empty:Re.empty,each:Re.each,on:tC,attr:KN,attrTween:UN,style:pC,styleTween:xC,text:AC,textTween:_C,remove:lC,tween:LN,delay:YN,duration:XN,ease:RN,easeVarying:nC,end:kC,[Symbol.iterator]:Re[Symbol.iterator]};function TC(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var PC={time:null,delay:0,duration:250,ease:TC};function IC(e,n){for(var i;!(i=e.__transition)||!(i=i[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return i}function LC(e){var n,i;e instanceof Qe?(n=e._id,e=e._name):(n=Nb(),(i=PC).time=Pa(),e=e==null?null:e+"");for(var o=this._groups,a=o.length,s=0;s<a;++s)for(var t=o[s],r=t.length,l,u=0;u<r;++u)(l=t[u])&&ao(l,e,n,u,t,i||IC(l,n));return new Qe(o,this._parents,e,n)}ii.prototype.interrupt=TN,ii.prototype.transition=LC;const to=e=>()=>e;function BC(e,{sourceEvent:n,target:i,transform:o,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:a}})}function en(e,n,i){this.k=e,this.x=n,this.y=i}en.prototype={constructor:en,scale:function(e){return e===1?this:new en(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new en(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ro=new en(1,0,0);Cb.prototype=en.prototype;function Cb(e){for(;!e.__zoom;)if(!(e=e.parentNode))return ro;return e.__zoom}function qa(e){e.stopImmediatePropagation()}function bi(e){e.preventDefault(),e.stopImmediatePropagation()}function OC(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function DC(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function _b(){return this.__zoom||ro}function qC(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function FC(){return navigator.maxTouchPoints||"ontouchstart"in this}function GC(e,n,i){var o=e.invertX(n[0][0])-i[0][0],a=e.invertX(n[1][0])-i[1][0],s=e.invertY(n[0][1])-i[0][1],t=e.invertY(n[1][1])-i[1][1];return e.translate(a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a),t>s?(s+t)/2:Math.min(0,s)||Math.max(0,t))}function Eb(){var e=OC,n=DC,i=GC,o=qC,a=FC,s=[0,1/0],t=[[-1/0,-1/0],[1/0,1/0]],r=250,l=Xi,u=Ki("start","zoom","end"),d,b,m,f=500,h=150,g=0,v=10;function p(T){T.property("__zoom",_b).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",P).filter(a).on("touchstart.zoom",k).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}p.transform=function(T,O,B,K){var G=T.selection?T.selection():T;G.property("__zoom",_b),T!==G?w(T,O,B,K):G.interrupt().each(function(){A(this,arguments).event(K).start().zoom(null,typeof O=="function"?O.apply(this,arguments):O).end()})},p.scaleBy=function(T,O,B,K){p.scaleTo(T,function(){var G=this.__zoom.k,I=typeof O=="function"?O.apply(this,arguments):O;return G*I},B,K)},p.scaleTo=function(T,O,B,K){p.transform(T,function(){var G=n.apply(this,arguments),I=this.__zoom,Y=B==null?x(G):typeof B=="function"?B.apply(this,arguments):B,Z=I.invert(Y),J=typeof O=="function"?O.apply(this,arguments):O;return i(y(S(I,J),Y,Z),G,t)},B,K)},p.translateBy=function(T,O,B,K){p.transform(T,function(){return i(this.__zoom.translate(typeof O=="function"?O.apply(this,arguments):O,typeof B=="function"?B.apply(this,arguments):B),n.apply(this,arguments),t)},null,K)},p.translateTo=function(T,O,B,K,G){p.transform(T,function(){var I=n.apply(this,arguments),Y=this.__zoom,Z=K==null?x(I):typeof K=="function"?K.apply(this,arguments):K;return i(ro.translate(Z[0],Z[1]).scale(Y.k).translate(typeof O=="function"?-O.apply(this,arguments):-O,typeof B=="function"?-B.apply(this,arguments):-B),I,t)},K,G)};function S(T,O){return O=Math.max(s[0],Math.min(s[1],O)),O===T.k?T:new en(O,T.x,T.y)}function y(T,O,B){var K=O[0]-B[0]*T.k,G=O[1]-B[1]*T.k;return K===T.x&&G===T.y?T:new en(T.k,K,G)}function x(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function w(T,O,B,K){T.on("start.zoom",function(){A(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(K).end()}).tween("zoom",function(){var G=this,I=arguments,Y=A(G,I).event(K),Z=n.apply(G,I),J=B==null?x(Z):typeof B=="function"?B.apply(G,I):B,R=Math.max(Z[1][0]-Z[0][0],Z[1][1]-Z[0][1]),D=G.__zoom,H=typeof O=="function"?O.apply(G,I):O,U=l(D.invert(J).concat(R/D.k),H.invert(J).concat(R/H.k));return function(q){if(q===1)q=H;else{var F=U(q),W=R/F[2];q=new en(W,J[0]-F[0]*W,J[1]-F[1]*W)}Y.zoom(null,q)}})}function A(T,O,B){return!B&&T.__zooming||new N(T,O)}function N(T,O){this.that=T,this.args=O,this.active=0,this.sourceEvent=null,this.extent=n.apply(T,O),this.taps=0}N.prototype={event:function(T){return T&&(this.sourceEvent=T),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(T,O){return this.mouse&&T!=="mouse"&&(this.mouse[1]=O.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=O.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=O.invert(this.touch1[0])),this.that.__zoom=O,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var O=Le(this.that).datum();u.call(T,this.that,new BC(T,{sourceEvent:this.sourceEvent,target:p,transform:this.that.__zoom,dispatch:u}),O)}};function E(T,...O){if(!e.apply(this,arguments))return;var B=A(this,O).event(T),K=this.__zoom,G=Math.max(s[0],Math.min(s[1],K.k*Math.pow(2,o.apply(this,arguments)))),I=qe(T);if(B.wheel)(B.mouse[0][0]!==I[0]||B.mouse[0][1]!==I[1])&&(B.mouse[1]=K.invert(B.mouse[0]=I)),clearTimeout(B.wheel);else{if(K.k===G)return;B.mouse=[I,K.invert(I)],so(this),B.start()}bi(T),B.wheel=setTimeout(Y,h),B.zoom("mouse",i(y(S(K,G),B.mouse[0],B.mouse[1]),B.extent,t));function Y(){B.wheel=null,B.end()}}function _(T,...O){if(m||!e.apply(this,arguments))return;var B=T.currentTarget,K=A(this,O,!0).event(T),G=Le(T.view).on("mousemove.zoom",J,!0).on("mouseup.zoom",R,!0),I=qe(T,B),Y=T.clientX,Z=T.clientY;Jc(T.view),qa(T),K.mouse=[I,this.__zoom.invert(I)],so(this),K.start();function J(D){if(bi(D),!K.moved){var H=D.clientX-Y,U=D.clientY-Z;K.moved=H*H+U*U>g}K.event(D).zoom("mouse",i(y(K.that.__zoom,K.mouse[0]=qe(D,B),K.mouse[1]),K.extent,t))}function R(D){G.on("mousemove.zoom mouseup.zoom",null),Zc(D.view,K.moved),bi(D),K.event(D).end()}}function P(T,...O){if(e.apply(this,arguments)){var B=this.__zoom,K=qe(T.changedTouches?T.changedTouches[0]:T,this),G=B.invert(K),I=B.k*(T.shiftKey?.5:2),Y=i(y(S(B,I),K,G),n.apply(this,O),t);bi(T),r>0?Le(this).transition().duration(r).call(w,Y,K,T):Le(this).call(p.transform,Y,K,T)}}function k(T,...O){if(e.apply(this,arguments)){var B=T.touches,K=B.length,G=A(this,O,T.changedTouches.length===K).event(T),I,Y,Z,J;for(qa(T),Y=0;Y<K;++Y)Z=B[Y],J=qe(Z,this),J=[J,this.__zoom.invert(J),Z.identifier],G.touch0?!G.touch1&&G.touch0[2]!==J[2]&&(G.touch1=J,G.taps=0):(G.touch0=J,I=!0,G.taps=1+!!d);d&&(d=clearTimeout(d)),I&&(G.taps<2&&(b=J[0],d=setTimeout(function(){d=null},f)),so(this),G.start())}}function M(T,...O){if(this.__zooming){var B=A(this,O).event(T),K=T.changedTouches,G=K.length,I,Y,Z,J;for(bi(T),I=0;I<G;++I)Y=K[I],Z=qe(Y,this),B.touch0&&B.touch0[2]===Y.identifier?B.touch0[0]=Z:B.touch1&&B.touch1[2]===Y.identifier&&(B.touch1[0]=Z);if(Y=B.that.__zoom,B.touch1){var R=B.touch0[0],D=B.touch0[1],H=B.touch1[0],U=B.touch1[1],q=(q=H[0]-R[0])*q+(q=H[1]-R[1])*q,F=(F=U[0]-D[0])*F+(F=U[1]-D[1])*F;Y=S(Y,Math.sqrt(q/F)),Z=[(R[0]+H[0])/2,(R[1]+H[1])/2],J=[(D[0]+U[0])/2,(D[1]+U[1])/2]}else if(B.touch0)Z=B.touch0[0],J=B.touch0[1];else return;B.zoom("touch",i(y(Y,Z,J),B.extent,t))}}function L(T,...O){if(this.__zooming){var B=A(this,O).event(T),K=T.changedTouches,G=K.length,I,Y;for(qa(T),m&&clearTimeout(m),m=setTimeout(function(){m=null},f),I=0;I<G;++I)Y=K[I],B.touch0&&B.touch0[2]===Y.identifier?delete B.touch0:B.touch1&&B.touch1[2]===Y.identifier&&delete B.touch1;if(B.touch1&&!B.touch0&&(B.touch0=B.touch1,delete B.touch1),B.touch0)B.touch0[1]=this.__zoom.invert(B.touch0[0]);else if(B.end(),B.taps===2&&(Y=qe(Y,this),Math.hypot(b[0]-Y[0],b[1]-Y[1])<v)){var Z=Le(this).on("dblclick.zoom");Z&&Z.apply(this,arguments)}}}return p.wheelDelta=function(T){return arguments.length?(o=typeof T=="function"?T:to(+T),p):o},p.filter=function(T){return arguments.length?(e=typeof T=="function"?T:to(!!T),p):e},p.touchable=function(T){return arguments.length?(a=typeof T=="function"?T:to(!!T),p):a},p.extent=function(T){return arguments.length?(n=typeof T=="function"?T:to([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),p):n},p.scaleExtent=function(T){return arguments.length?(s[0]=+T[0],s[1]=+T[1],p):[s[0],s[1]]},p.translateExtent=function(T){return arguments.length?(t[0][0]=+T[0][0],t[1][0]=+T[1][0],t[0][1]=+T[0][1],t[1][1]=+T[1][1],p):[[t[0][0],t[0][1]],[t[1][0],t[1][1]]]},p.constrain=function(T){return arguments.length?(i=T,p):i},p.duration=function(T){return arguments.length?(r=+T,p):r},p.interpolate=function(T){return arguments.length?(l=T,p):l},p.on=function(){var T=u.on.apply(u,arguments);return T===u?p:T},p.clickDistance=function(T){return arguments.length?(g=(T=+T)*T,p):Math.sqrt(g)},p.tapDistance=function(T){return arguments.length?(v=+T,p):v},p}const Be={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:n,sourceHandle:i,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?i:o}", edge id: ${n}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},mi=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],kb=["Enter"," ","Escape"],Mb={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:n,y:i})=>`Moved selected node ${e}. New position, x: ${n}, y: ${i}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var qn;(function(e){e.Strict="strict",e.Loose="loose"})(qn||(qn={}));var gn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(gn||(gn={}));var fi;(function(e){e.Partial="partial",e.Full="full"})(fi||(fi={}));const Tb={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ln;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ln||(ln={}));var Fn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Fn||(Fn={}));var oe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(oe||(oe={}));const Pb={[oe.Left]:oe.Right,[oe.Right]:oe.Left,[oe.Top]:oe.Bottom,[oe.Bottom]:oe.Top};function Ib(e){return e===null?null:e?"valid":"invalid"}const Lb=e=>"id"in e&&"source"in e&&"target"in e,KC=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Fa=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vi=(e,n=[0,0])=>{var r;const{width:i,height:o}=nn(e),a=(r=e.origin)!=null?r:n,s=i*a[0],t=o*a[1];return{x:e.position.x-s,y:e.position.y-t}},HC=(e,n={nodeOrigin:[0,0]})=>{if(process.env.NODE_ENV==="development"&&!n.nodeLookup&&console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."),e.length===0)return{x:0,y:0,width:0,height:0};const i=e.reduce((o,a)=>{const s=typeof a=="string";let t=!n.nodeLookup&&!s?a:void 0;n.nodeLookup&&(t=s?n.nodeLookup.get(a):Fa(a)?a:n.nodeLookup.get(a.id));const r=t?co(t,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return lo(o,r)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return uo(i)},hi=(e,n={})=>{let i={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(a=>{(n.filter===void 0||n.filter(a))&&(i=lo(i,co(a)),o=!0)}),o?uo(i):{x:0,y:0,width:0,height:0}},Ga=(e,n,[i,o,a]=[0,0,1],s=!1,t=!1)=>{var m,f,h,g,v,p;const r=(n.x-i)/a,l=(n.y-o)/a,u=n.width/a,d=n.height/a,b=[];for(const S of e.values()){const{measured:y,selectable:x=!0,hidden:w=!1}=S;if(t&&!x||w)continue;const A=(h=(f=(m=y.width)!=null?m:S.width)!=null?f:S.initialWidth)!=null?h:0,N=(p=(v=(g=y.height)!=null?g:S.height)!=null?v:S.initialHeight)!=null?p:0,{x:E,y:_}=S.internals.positionAbsolute,P=Fb(r,l,u,d,E,_,A,N),k=A*N,M=s&&P>0;(!S.internals.handleBounds||M||P>=k||S.dragging)&&b.push(S)}return b},VC=(e,n)=>{const i=new Set;return e.forEach(o=>{i.add(o.id)}),n.filter(o=>i.has(o.source)||i.has(o.target))};function zC(e,n){const i=new Map,o=n!=null&&n.nodes?new Set(n.nodes.map(a=>a.id)):null;return e.forEach(a=>{a.measured.width&&a.measured.height&&((n==null?void 0:n.includeHiddenNodes)||!a.hidden)&&(!o||o.has(a.id))&&i.set(a.id,a)}),i}async function jC({nodes:e,width:n,height:i,panZoom:o,minZoom:a,maxZoom:s},t){var d,b,m;if(e.size===0)return!0;const r=zC(e,t),l=hi(r),u=Va(l,n,i,(d=t==null?void 0:t.minZoom)!=null?d:a,(b=t==null?void 0:t.maxZoom)!=null?b:s,(m=t==null?void 0:t.padding)!=null?m:.1);return await o.setViewport(u,{duration:t==null?void 0:t.duration,ease:t==null?void 0:t.ease,interpolate:t==null?void 0:t.interpolate}),!0}function Bb({nodeId:e,nextPosition:n,nodeLookup:i,nodeOrigin:o=[0,0],nodeExtent:a,onError:s}){var f,h,g;const t=i.get(e),r=t.parentId?i.get(t.parentId):void 0,{x:l,y:u}=r?r.internals.positionAbsolute:{x:0,y:0},d=(f=t.origin)!=null?f:o;let b=t.extent||a;if(t.extent==="parent"&&!t.expandParent)if(!r)s==null||s("005",Be.error005());else{const v=r.measured.width,p=r.measured.height;v&&p&&(b=[[l,u],[l+v,u+p]])}else r&&xn(t.extent)&&(b=[[t.extent[0][0]+l,t.extent[0][1]+u],[t.extent[1][0]+l,t.extent[1][1]+u]]);const m=xn(b)?yn(n,b,t.measured):n;return(t.measured.width===void 0||t.measured.height===void 0)&&(s==null||s("015",Be.error015())),{position:{x:m.x-l+((h=t.measured.width)!=null?h:0)*d[0],y:m.y-u+((g=t.measured.height)!=null?g:0)*d[1]},positionAbsolute:m}}async function UC({nodesToRemove:e=[],edgesToRemove:n=[],nodes:i,edges:o,onBeforeDelete:a}){const s=new Set(e.map(m=>m.id)),t=[];for(const m of i){if(m.deletable===!1)continue;const f=s.has(m.id),h=!f&&m.parentId&&t.find(g=>g.id===m.parentId);(f||h)&&t.push(m)}const r=new Set(n.map(m=>m.id)),l=o.filter(m=>m.deletable!==!1),d=VC(t,l);for(const m of l)r.has(m.id)&&!d.find(h=>h.id===m.id)&&d.push(m);if(!a)return{edges:d,nodes:t};const b=await a({nodes:t,edges:d});return typeof b=="boolean"?b?{edges:d,nodes:t}:{edges:[],nodes:[]}:b}const Gn=(e,n=0,i=1)=>Math.min(Math.max(e,n),i),yn=(e={x:0,y:0},n,i)=>{var o,a;return{x:Gn(e.x,n[0][0],n[1][0]-((o=i==null?void 0:i.width)!=null?o:0)),y:Gn(e.y,n[0][1],n[1][1]-((a=i==null?void 0:i.height)!=null?a:0))}};function Ob(e,n,i){const{width:o,height:a}=nn(i),{x:s,y:t}=i.internals.positionAbsolute;return yn(e,[[s,t],[s+o,t+a]],n)}const Db=(e,n,i)=>e<n?Gn(Math.abs(e-n),1,n)/n:e>i?-Gn(Math.abs(e-i),1,n)/n:0,Ka=(e,n,i=15,o=40)=>{const a=Db(e.x,o,n.width-o)*i,s=Db(e.y,o,n.height-o)*i;return[a,s]},lo=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),Ha=({x:e,y:n,width:i,height:o})=>({x:e,y:n,x2:e+i,y2:n+o}),uo=({x:e,y:n,x2:i,y2:o})=>({x:e,y:n,width:i-e,height:o-n}),pi=(e,n=[0,0])=>{var a,s,t,r,l,u,d,b;const{x:i,y:o}=Fa(e)?e.internals.positionAbsolute:vi(e,n);return{x:i,y:o,width:(r=(t=(s=(a=e.measured)==null?void 0:a.width)!=null?s:e.width)!=null?t:e.initialWidth)!=null?r:0,height:(b=(d=(u=(l=e.measured)==null?void 0:l.height)!=null?u:e.height)!=null?d:e.initialHeight)!=null?b:0}},co=(e,n=[0,0])=>{var a,s,t,r,l,u,d,b;const{x:i,y:o}=Fa(e)?e.internals.positionAbsolute:vi(e,n);return{x:i,y:o,x2:i+((r=(t=(s=(a=e.measured)==null?void 0:a.width)!=null?s:e.width)!=null?t:e.initialWidth)!=null?r:0),y2:o+((b=(d=(u=(l=e.measured)==null?void 0:l.height)!=null?u:e.height)!=null?d:e.initialHeight)!=null?b:0)}},qb=(e,n)=>uo(lo(Ha(e),Ha(n))),Fb=(e,n,i,o,a,s,t,r)=>{const l=Math.max(0,Math.min(e+i,a+t)-Math.max(e,a)),u=Math.max(0,Math.min(n+o,s+r)-Math.max(n,s));return Math.ceil(l*u)},bo=(e,n)=>Fb(e.x,e.y,e.width,e.height,n.x,n.y,n.width,n.height),Gb=e=>Ke(e.width)&&Ke(e.height)&&Ke(e.x)&&Ke(e.y),Ke=e=>!isNaN(e)&&isFinite(e),Kb=(e,n)=>(i,o)=>{process.env.NODE_ENV==="development"&&console.warn(`[${e}]: ${o} Help: ${n}error#${i}`)},gi=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),yi=({x:e,y:n},[i,o,a],s=!1,t=[1,1])=>{const r={x:(e-i)/a,y:(n-o)/a};return s?gi(r,t):r},Kn=({x:e,y:n},[i,o,a])=>({x:e*a+i,y:n*a+o});function Hn(e,n){if(typeof e=="number")return Math.floor((n-n/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const i=parseFloat(e);if(!Number.isNaN(i))return Math.floor(i)}if(typeof e=="string"&&e.endsWith("%")){const i=parseFloat(e);if(!Number.isNaN(i))return Math.floor(n*i*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function WC(e,n,i){var o,a,s,t,r,l,u,d;if(typeof e=="string"||typeof e=="number"){const b=Hn(e,i),m=Hn(e,n);return{top:b,right:m,bottom:b,left:m,x:m*2,y:b*2}}if(typeof e=="object"){const b=Hn((a=(o=e.top)!=null?o:e.y)!=null?a:0,i),m=Hn((t=(s=e.bottom)!=null?s:e.y)!=null?t:0,i),f=Hn((l=(r=e.left)!=null?r:e.x)!=null?l:0,n),h=Hn((d=(u=e.right)!=null?u:e.x)!=null?d:0,n);return{top:b,right:h,bottom:m,left:f,x:f+h,y:b+m}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function $C(e,n,i,o,a,s){const{x:t,y:r}=Kn(e,[n,i,o]),{x:l,y:u}=Kn({x:e.x+e.width,y:e.y+e.height},[n,i,o]),d=a-l,b=s-u;return{left:Math.floor(t),top:Math.floor(r),right:Math.floor(d),bottom:Math.floor(b)}}const Va=(e,n,i,o,a,s)=>{const t=WC(s,n,i),r=(n-t.x)/e.width,l=(i-t.y)/e.height,u=Math.min(r,l),d=Gn(u,o,a),b=e.x+e.width/2,m=e.y+e.height/2,f=n/2-b*d,h=i/2-m*d,g=$C(e,f,h,d,n,i),v={left:Math.min(g.left-t.left,0),top:Math.min(g.top-t.top,0),right:Math.min(g.right-t.right,0),bottom:Math.min(g.bottom-t.bottom,0)};return{x:f-v.left+v.right,y:h-v.top+v.bottom,zoom:d}},xi=()=>{var e;return typeof navigator!="undefined"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function xn(e){return e!=null&&e!=="parent"}function nn(e){var n,i,o,a,s,t,r,l;return{width:(a=(o=(i=(n=e.measured)==null?void 0:n.width)!=null?i:e.width)!=null?o:e.initialWidth)!=null?a:0,height:(l=(r=(t=(s=e.measured)==null?void 0:s.height)!=null?t:e.height)!=null?r:e.initialHeight)!=null?l:0}}function Hb(e){var n,i,o,a,s,t;return((o=(i=(n=e.measured)==null?void 0:n.width)!=null?i:e.width)!=null?o:e.initialWidth)!==void 0&&((t=(s=(a=e.measured)==null?void 0:a.height)!=null?s:e.height)!=null?t:e.initialHeight)!==void 0}function Vb(e,n={width:0,height:0},i,o,a){var r,l;const s={...e},t=o.get(i);if(t){const u=t.origin||a;s.x+=t.internals.positionAbsolute.x-((r=n.width)!=null?r:0)*u[0],s.y+=t.internals.positionAbsolute.y-((l=n.height)!=null?l:0)*u[1]}return s}function zb(e,n){if(e.size!==n.size)return!1;for(const i of e)if(!n.has(i))return!1;return!0}function YC(){let e,n;return{promise:new Promise((o,a)=>{e=o,n=a}),resolve:e,reject:n}}function JC(e){return{...Mb,...e||{}}}function Si(e,{snapGrid:n=[0,0],snapToGrid:i=!1,transform:o,containerBounds:a}){var d,b;const{x:s,y:t}=He(e),r=yi({x:s-((d=a==null?void 0:a.left)!=null?d:0),y:t-((b=a==null?void 0:a.top)!=null?b:0)},o),{x:l,y:u}=i?gi(r,n):r;return{xSnapped:l,ySnapped:u,...r}}const za=e=>({width:e.offsetWidth,height:e.offsetHeight}),jb=e=>{var n;return((n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},ZC=["INPUT","SELECT","TEXTAREA"];function Ub(e){var o,a;const n=((a=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:a[0])||e.target;return(n==null?void 0:n.nodeType)!==1?!1:ZC.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const Wb=e=>"clientX"in e,He=(e,n)=>{var s,t,r,l;const i=Wb(e),o=i?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,a=i?e.clientY:(t=e.touches)==null?void 0:t[0].clientY;return{x:o-((r=n==null?void 0:n.left)!=null?r:0),y:a-((l=n==null?void 0:n.top)!=null?l:0)}},$b=(e,n,i,o,a)=>{const s=n.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(t=>{const r=t.getBoundingClientRect();return{id:t.getAttribute("data-handleid"),type:e,nodeId:a,position:t.getAttribute("data-handlepos"),x:(r.left-i.left)/o,y:(r.top-i.top)/o,...za(t)}})};function Yb({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:a,sourceControlY:s,targetControlX:t,targetControlY:r}){const l=e*.125+a*.375+t*.375+i*.125,u=n*.125+s*.375+r*.375+o*.125,d=Math.abs(l-e),b=Math.abs(u-n);return[l,u,d,b]}function mo(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function Jb({pos:e,x1:n,y1:i,x2:o,y2:a,c:s}){switch(e){case oe.Left:return[n-mo(n-o,s),i];case oe.Right:return[n+mo(o-n,s),i];case oe.Top:return[n,i-mo(i-a,s)];case oe.Bottom:return[n,i+mo(a-i,s)]}}function Zb({sourceX:e,sourceY:n,sourcePosition:i=oe.Bottom,targetX:o,targetY:a,targetPosition:s=oe.Top,curvature:t=.25}){const[r,l]=Jb({pos:i,x1:e,y1:n,x2:o,y2:a,c:t}),[u,d]=Jb({pos:s,x1:o,y1:a,x2:e,y2:n,c:t}),[b,m,f,h]=Yb({sourceX:e,sourceY:n,targetX:o,targetY:a,sourceControlX:r,sourceControlY:l,targetControlX:u,targetControlY:d});return[`M${e},${n} C${r},${l} ${u},${d} ${o},${a}`,b,m,f,h]}function Xb({sourceX:e,sourceY:n,targetX:i,targetY:o}){const a=Math.abs(i-e)/2,s=i<e?i+a:i-a,t=Math.abs(o-n)/2,r=o<n?o+t:o-t;return[s,r,a,t]}function XC({sourceNode:e,targetNode:n,selected:i=!1,zIndex:o=0,elevateOnSelect:a=!1,zIndexMode:s="basic"}){if(s==="manual")return o;const t=a&&i?o+1e3:o,r=Math.max(e.parentId||a&&e.selected?e.internals.z:0,n.parentId||a&&n.selected?n.internals.z:0);return t+r}function QC({sourceNode:e,targetNode:n,width:i,height:o,transform:a}){const s=lo(co(e),co(n));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);const t={x:-a[0]/a[2],y:-a[1]/a[2],width:i/a[2],height:o/a[2]};return bo(t,uo(s))>0}const RC=({source:e,sourceHandle:n,target:i,targetHandle:o})=>`xy-edge__${e}${n||""}-${i}${o||""}`,e_=(e,n)=>n.some(i=>i.source===e.source&&i.target===e.target&&(i.sourceHandle===e.sourceHandle||!i.sourceHandle&&!e.sourceHandle)&&(i.targetHandle===e.targetHandle||!i.targetHandle&&!e.targetHandle)),n_=(e,n,i={})=>{var s;if(!e.source||!e.target)return(s=i.onError)==null||s.call(i,"006",Be.error006()),n;const o=i.getEdgeId||RC;let a;return Lb(e)?a={...e}:a={...e,id:o(e)},e_(a,n)?n:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,n.concat(a))};function Qb({sourceX:e,sourceY:n,targetX:i,targetY:o}){const[a,s,t,r]=Xb({sourceX:e,sourceY:n,targetX:i,targetY:o});return[`M ${e},${n}L ${i},${o}`,a,s,t,r]}const Rb={[oe.Left]:{x:-1,y:0},[oe.Right]:{x:1,y:0},[oe.Top]:{x:0,y:-1},[oe.Bottom]:{x:0,y:1}},i_=({source:e,sourcePosition:n=oe.Bottom,target:i})=>n===oe.Left||n===oe.Right?e.x<i.x?{x:1,y:0}:{x:-1,y:0}:e.y<i.y?{x:0,y:1}:{x:0,y:-1},em=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function o_({source:e,sourcePosition:n=oe.Bottom,target:i,targetPosition:o=oe.Top,center:a,offset:s,stepPosition:t}){var E,_,P,k;const r=Rb[n],l=Rb[o],u={x:e.x+r.x*s,y:e.y+r.y*s},d={x:i.x+l.x*s,y:i.y+l.y*s},b=i_({source:u,sourcePosition:n,target:d}),m=b.x!==0?"x":"y",f=b[m];let h=[],g,v;const p={x:0,y:0},S={x:0,y:0},[,,y,x]=Xb({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(r[m]*l[m]===-1){m==="x"?(g=(E=a.x)!=null?E:u.x+(d.x-u.x)*t,v=(_=a.y)!=null?_:(u.y+d.y)/2):(g=(P=a.x)!=null?P:(u.x+d.x)/2,v=(k=a.y)!=null?k:u.y+(d.y-u.y)*t);const M=[{x:g,y:u.y},{x:g,y:d.y}],L=[{x:u.x,y:v},{x:d.x,y:v}];r[m]===f?h=m==="x"?M:L:h=m==="x"?L:M}else{const M=[{x:u.x,y:d.y}],L=[{x:d.x,y:u.y}];if(m==="x"?h=r.x===f?L:M:h=r.y===f?M:L,n===o){const G=Math.abs(e[m]-i[m]);if(G<=s){const I=Math.min(s-1,s-G);r[m]===f?p[m]=(u[m]>e[m]?-1:1)*I:S[m]=(d[m]>i[m]?-1:1)*I}}if(n!==o){const G=m==="x"?"y":"x",I=r[m]===l[G],Y=u[G]>d[G],Z=u[G]<d[G];(r[m]===1&&(!I&&Y||I&&Z)||r[m]!==1&&(!I&&Z||I&&Y))&&(h=m==="x"?M:L)}const T={x:u.x+p.x,y:u.y+p.y},O={x:d.x+S.x,y:d.y+S.y},B=Math.max(Math.abs(T.x-h[0].x),Math.abs(O.x-h[0].x)),K=Math.max(Math.abs(T.y-h[0].y),Math.abs(O.y-h[0].y));B>=K?(g=(T.x+O.x)/2,v=h[0].y):(g=h[0].x,v=(T.y+O.y)/2)}const w={x:u.x+p.x,y:u.y+p.y},A={x:d.x+S.x,y:d.y+S.y};return[[e,...w.x!==h[0].x||w.y!==h[0].y?[w]:[],...h,...A.x!==h[h.length-1].x||A.y!==h[h.length-1].y?[A]:[],i],g,v,y,x]}function a_(e,n,i,o){const a=Math.min(em(e,n)/2,em(n,i)/2,o),{x:s,y:t}=n;if(e.x===s&&s===i.x||e.y===t&&t===i.y)return`L${s} ${t}`;if(e.y===t){const u=e.x<i.x?-1:1,d=e.y<i.y?1:-1;return`L ${s+a*u},${t}Q ${s},${t} ${s},${t+a*d}`}const r=e.x<i.x?1:-1,l=e.y<i.y?-1:1;return`L ${s},${t+a*l}Q ${s},${t} ${s+a*r},${t}`}function ja({sourceX:e,sourceY:n,sourcePosition:i=oe.Bottom,targetX:o,targetY:a,targetPosition:s=oe.Top,borderRadius:t=5,centerX:r,centerY:l,offset:u=20,stepPosition:d=.5}){const[b,m,f,h,g]=o_({source:{x:e,y:n},sourcePosition:i,target:{x:o,y:a},targetPosition:s,center:{x:r,y:l},offset:u,stepPosition:d});let v=`M${b[0].x} ${b[0].y}`;for(let p=1;p<b.length-1;p++)v+=a_(b[p-1],b[p],b[p+1],t);return v+=`L${b[b.length-1].x} ${b[b.length-1].y}`,[v,m,f,h,g]}function nm(e){var n;return e&&!!(e.internals.handleBounds||(n=e.handles)!=null&&n.length)&&!!(e.measured.width||e.width||e.initialWidth)}function s_(e){var b,m,f,h,g;const{sourceNode:n,targetNode:i}=e;if(!nm(n)||!nm(i))return null;const o=n.internals.handleBounds||im(n.handles),a=i.internals.handleBounds||im(i.handles),s=om((b=o==null?void 0:o.source)!=null?b:[],e.sourceHandle),t=om(e.connectionMode===qn.Strict?(m=a==null?void 0:a.target)!=null?m:[]:((f=a==null?void 0:a.target)!=null?f:[]).concat((h=a==null?void 0:a.source)!=null?h:[]),e.targetHandle);if(!s||!t)return(g=e.onError)==null||g.call(e,"008",Be.error008(s?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const r=(s==null?void 0:s.position)||oe.Bottom,l=(t==null?void 0:t.position)||oe.Top,u=Sn(n,s,r),d=Sn(i,t,l);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:r,targetPosition:l}}function im(e){var o,a;if(!e)return null;const n=[],i=[];for(const s of e)s.width=(o=s.width)!=null?o:1,s.height=(a=s.height)!=null?a:1,s.type==="source"?n.push(s):s.type==="target"&&i.push(s);return{source:n,target:i}}function Sn(e,n,i=oe.Left,o=!1){var u,d,b;const a=((u=n==null?void 0:n.x)!=null?u:0)+e.internals.positionAbsolute.x,s=((d=n==null?void 0:n.y)!=null?d:0)+e.internals.positionAbsolute.y,{width:t,height:r}=n!=null?n:nn(e);if(o)return{x:a+t/2,y:s+r/2};switch((b=n==null?void 0:n.position)!=null?b:i){case oe.Top:return{x:a+t/2,y:s};case oe.Right:return{x:a+t,y:s+r/2};case oe.Bottom:return{x:a+t/2,y:s+r};case oe.Left:return{x:a,y:s+r/2}}}function om(e,n){return e&&(n?e.find(i=>i.id===n):e[0])||null}function Ua(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function t_(e,{id:n,defaultColor:i,defaultMarkerStart:o,defaultMarkerEnd:a}){const s=new Set;return e.reduce((t,r)=>([r.markerStart||o,r.markerEnd||a].forEach(l=>{if(l&&typeof l=="object"){const u=Ua(l,n);s.has(u)||(t.push({id:u,color:l.color||i,...l}),s.add(u))}}),t),[]).sort((t,r)=>t.id.localeCompare(r.id))}const am=1e3,r_=10,Wa={nodeOrigin:[0,0],nodeExtent:mi,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},l_={...Wa,checkEquality:!0};function $a(e,n){const i={...e};for(const o in n)n[o]!==void 0&&(i[o]=n[o]);return i}function u_(e,n,i){const o=$a(Wa,i);for(const a of e.values())if(a.parentId)Za(a,e,n,o);else{const s=vi(a,o.nodeOrigin),t=xn(a.extent)?a.extent:o.nodeExtent,r=yn(s,t,nn(a));a.internals.positionAbsolute=r}}function d_(e,n){var a,s;if(!e.handles)return e.measured?n==null?void 0:n.internals.handleBounds:void 0;const i=[],o=[];for(const t of e.handles){const r={id:t.id,width:(a=t.width)!=null?a:1,height:(s=t.height)!=null?s:1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type==="source"?i.push(r):t.type==="target"&&o.push(r)}return{source:i,target:o}}function Ya(e){return e==="manual"}function Ja(e,n,i,o={}){var d,b,m;const a=$a(l_,o),s={i:0},t=new Map(n),r=a!=null&&a.elevateNodesOnSelect&&!Ya(a.zIndexMode)?am:0;let l=e.length>0,u=!1;n.clear(),i.clear();for(const f of e){let h=t.get(f.id);if(a.checkEquality&&f===(h==null?void 0:h.internals.userNode))n.set(f.id,h);else{const g=vi(f,a.nodeOrigin),v=xn(f.extent)?f.extent:a.nodeExtent,p=yn(g,v,nn(f));h={...a.defaults,...f,measured:{width:(d=f.measured)==null?void 0:d.width,height:(b=f.measured)==null?void 0:b.height},internals:{positionAbsolute:p,handleBounds:d_(f,h),z:sm(f,r,a.zIndexMode),userNode:f}},n.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(l=!1),f.parentId&&Za(h,n,i,o,s),u||(u=(m=f.selected)!=null?m:!1)}return{nodesInitialized:l,hasSelectedNodes:u}}function c_(e,n){if(!e.parentId)return;const i=n.get(e.parentId);i?i.set(e.id,e):n.set(e.parentId,new Map([[e.id,e]]))}function Za(e,n,i,o,a){const{elevateNodesOnSelect:s,nodeOrigin:t,nodeExtent:r,zIndexMode:l}=$a(Wa,o),u=e.parentId,d=n.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}c_(e,i),a&&!d.parentId&&d.internals.rootParentIndex===void 0&&l==="auto"&&(d.internals.rootParentIndex=++a.i,d.internals.z=d.internals.z+a.i*r_),a&&d.internals.rootParentIndex!==void 0&&(a.i=d.internals.rootParentIndex);const b=s&&!Ya(l)?am:0,{x:m,y:f,z:h}=b_(e,d,t,r,b,l),{positionAbsolute:g}=e.internals,v=m!==g.x||f!==g.y;(v||h!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:m,y:f}:g,z:h}})}function sm(e,n,i){const o=Ke(e.zIndex)?e.zIndex:0;return Ya(i)?o:o+(e.selected?n:0)}function b_(e,n,i,o,a,s){var h;const{x:t,y:r}=n.internals.positionAbsolute,l=nn(e),u=vi(e,i),d=xn(e.extent)?yn(u,e.extent,l):u;let b=yn({x:t+d.x,y:r+d.y},o,l);e.extent==="parent"&&(b=Ob(b,l,n));const m=sm(e,a,s),f=(h=n.internals.z)!=null?h:0;return{x:b.x,y:b.y,z:f>=m?f+1:m}}function Xa(e,n,i,o=[0,0]){var t,r;const a=[],s=new Map;for(const l of e){const u=n.get(l.parentId);if(!u)continue;const d=(r=(t=s.get(l.parentId))==null?void 0:t.expandedRect)!=null?r:pi(u),b=qb(d,l.rect);s.set(l.parentId,{expandedRect:b,parent:u})}return s.size>0&&s.forEach(({expandedRect:l,parent:u},d)=>{var x,w;const b=u.internals.positionAbsolute,m=nn(u),f=(x=u.origin)!=null?x:o,h=l.x<b.x?Math.round(Math.abs(b.x-l.x)):0,g=l.y<b.y?Math.round(Math.abs(b.y-l.y)):0,v=Math.max(m.width,Math.round(l.width)),p=Math.max(m.height,Math.round(l.height)),S=(v-m.width)*f[0],y=(p-m.height)*f[1];(h>0||g>0||S||y)&&(a.push({id:d,type:"position",position:{x:u.position.x-h+S,y:u.position.y-g+y}}),(w=i.get(d))==null||w.forEach(A=>{e.some(N=>N.id===A.id)||a.push({id:A.id,type:"position",position:{x:A.position.x+h,y:A.position.y+g}})})),(m.width<l.width||m.height<l.height||h||g)&&a.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?f[0]*h-S:0),height:p+(g?f[1]*g-y:0)}})}),a}function m_(e,n,i,o,a,s,t){const r=o==null?void 0:o.querySelector(".xyflow__viewport");let l=!1;if(!r)return{changes:[],updatedInternals:l};const u=[],d=window.getComputedStyle(r),{m22:b}=new window.DOMMatrixReadOnly(d.transform),m=[];for(const f of e.values()){const h=n.get(f.id);if(!h)continue;if(h.hidden){n.set(h.id,{...h,internals:{...h.internals,handleBounds:void 0}}),l=!0;continue}const g=za(f.nodeElement),v=h.measured.width!==g.width||h.measured.height!==g.height;if(!!(g.width&&g.height&&(v||!h.internals.handleBounds||f.force))){const S=f.nodeElement.getBoundingClientRect(),y=xn(h.extent)?h.extent:s;let{positionAbsolute:x}=h.internals;h.parentId&&h.extent==="parent"?x=Ob(x,g,n.get(h.parentId)):y&&(x=yn(x,y,g));const w={...h,measured:g,internals:{...h.internals,positionAbsolute:x,handleBounds:{source:$b("source",f.nodeElement,S,b,h.id),target:$b("target",f.nodeElement,S,b,h.id)}}};n.set(h.id,w),h.parentId&&Za(w,n,i,{nodeOrigin:a,zIndexMode:t}),l=!0,v&&(u.push({id:h.id,type:"dimensions",dimensions:g}),h.expandParent&&h.parentId&&m.push({id:h.id,parentId:h.parentId,rect:pi(w,a)}))}}if(m.length>0){const f=Xa(m,n,i,a);u.push(...f)}return{changes:u,updatedInternals:l}}async function f_({delta:e,panZoom:n,transform:i,translateExtent:o,width:a,height:s}){if(!n||!e.x&&!e.y)return!1;const t=await n.setViewportConstrained({x:i[0]+e.x,y:i[1]+e.y,zoom:i[2]},[[0,0],[a,s]],o);return!!t&&(t.x!==i[0]||t.y!==i[1]||t.k!==i[2])}function tm(e,n,i,o,a,s){let t=a;const r=o.get(t)||new Map;o.set(t,r.set(i,n)),t=`${a}-${e}`;const l=o.get(t)||new Map;if(o.set(t,l.set(i,n)),s){t=`${a}-${e}-${s}`;const u=o.get(t)||new Map;o.set(t,u.set(i,n))}}function rm(e,n,i){e.clear(),n.clear();for(const o of i){const{source:a,target:s,sourceHandle:t=null,targetHandle:r=null}=o,l={edgeId:o.id,source:a,target:s,sourceHandle:t,targetHandle:r},u=`${a}-${t}--${s}-${r}`,d=`${s}-${r}--${a}-${t}`;tm("source",l,d,e,a,t),tm("target",l,u,e,s,r),n.set(o.id,o)}}function lm(e,n){if(!e.parentId)return!1;const i=n.get(e.parentId);return i?i.selected?!0:lm(i,n):!1}function um(e,n,i){var a;let o=e;do{if((a=o==null?void 0:o.matches)!=null&&a.call(o,n))return!0;if(o===i)return!1;o=o==null?void 0:o.parentElement}while(o);return!1}function v_(e,n,i,o){var s,t;const a=new Map;for(const[r,l]of e)if((l.selected||l.id===o)&&(!l.parentId||!lm(l,e))&&(l.draggable||n&&typeof l.draggable=="undefined")){const u=e.get(r);u&&a.set(r,{id:r,position:u.position||{x:0,y:0},distance:{x:i.x-u.internals.positionAbsolute.x,y:i.y-u.internals.positionAbsolute.y},extent:u.extent,parentId:u.parentId,origin:u.origin,expandParent:u.expandParent,internals:{positionAbsolute:u.internals.positionAbsolute||{x:0,y:0}},measured:{width:(s=u.measured.width)!=null?s:0,height:(t=u.measured.height)!=null?t:0}})}return a}function Qa({nodeId:e,dragItems:n,nodeLookup:i,dragging:o=!0}){var t,r,l;const a=[];for(const[u,d]of n){const b=(t=i.get(u))==null?void 0:t.internals.userNode;b&&a.push({...b,position:d.position,dragging:o})}if(!e)return[a[0],a];const s=(r=i.get(e))==null?void 0:r.internals.userNode;return[s?{...s,position:((l=n.get(e))==null?void 0:l.position)||s.position,dragging:o}:a[0],a]}function h_({dragItems:e,snapGrid:n,x:i,y:o}){const a=e.values().next().value;if(!a)return null;const s={x:i-a.distance.x,y:o-a.distance.y},t=gi(s,n);return{x:t.x-s.x,y:t.y-s.y}}function p_({onNodeMouseDown:e,getStoreItems:n,onDragStart:i,onDrag:o,onDragStop:a}){let s={x:null,y:null},t=0,r=new Map,l=!1,u={x:0,y:0},d=null,b=!1,m=null,f=!1,h=!1,g=null;function v({noDragClassName:S,handleSelector:y,domNode:x,isSelectable:w,nodeId:A,nodeClickDistance:N=0}){m=Le(x);function E({x:M,y:L}){const{nodeLookup:T,nodeExtent:O,snapGrid:B,snapToGrid:K,nodeOrigin:G,onNodeDrag:I,onSelectionDrag:Y,onError:Z,updateNodePositions:J}=n();s={x:M,y:L};let R=!1;const D=r.size>1,H=D&&O?Ha(hi(r)):null,U=D&&K?h_({dragItems:r,snapGrid:B,x:M,y:L}):null;for(const[q,F]of r){if(!T.has(q))continue;let W={x:M-F.distance.x,y:L-F.distance.y};K&&(W=U?{x:Math.round(W.x+U.x),y:Math.round(W.y+U.y)}:gi(W,B));let z=null;if(D&&O&&!F.extent&&H){const{positionAbsolute:j}=F.internals,X=j.x-H.x+O[0][0],$=j.x+F.measured.width-H.x2+O[1][0],ne=j.y-H.y+O[0][1],ee=j.y+F.measured.height-H.y2+O[1][1];z=[[X,ne],[$,ee]]}const{position:V,positionAbsolute:Q}=Bb({nodeId:q,nextPosition:W,nodeLookup:T,nodeExtent:z||O,nodeOrigin:G,onError:Z});R=R||F.position.x!==V.x||F.position.y!==V.y,F.position=V,F.internals.positionAbsolute=Q}if(h=h||R,!!R&&(J(r,!0),g&&(o||I||!A&&Y))){const[q,F]=Qa({nodeId:A,dragItems:r,nodeLookup:T});o==null||o(g,r,q,F),I==null||I(g,q,F),A||Y==null||Y(g,F)}}async function _(){var G,I;if(!d)return;const{transform:M,panBy:L,autoPanSpeed:T,autoPanOnNodeDrag:O}=n();if(!O){l=!1,cancelAnimationFrame(t);return}const[B,K]=Ka(u,d,T);(B!==0||K!==0)&&(s.x=((G=s.x)!=null?G:0)-B/M[2],s.y=((I=s.y)!=null?I:0)-K/M[2],await L({x:B,y:K})&&E(s)),t=requestAnimationFrame(_)}function P(M){var D;const{nodeLookup:L,multiSelectionActive:T,nodesDraggable:O,transform:B,snapGrid:K,snapToGrid:G,selectNodesOnDrag:I,onNodeDragStart:Y,onSelectionDragStart:Z,unselectNodesAndEdges:J}=n();b=!0,(!I||!w)&&!T&&A&&((D=L.get(A))!=null&&D.selected||J()),w&&I&&A&&(e==null||e(A));const R=Si(M.sourceEvent,{transform:B,snapGrid:K,snapToGrid:G,containerBounds:d});if(s=R,r=v_(L,O,R,A),r.size>0&&(i||Y||!A&&Z)){const[H,U]=Qa({nodeId:A,dragItems:r,nodeLookup:L});i==null||i(M.sourceEvent,r,H,U),Y==null||Y(M.sourceEvent,H,U),A||Z==null||Z(M.sourceEvent,U)}}const k=Xc().clickDistance(N).on("start",M=>{const{domNode:L,nodeDragThreshold:T,transform:O,snapGrid:B,snapToGrid:K}=n();d=(L==null?void 0:L.getBoundingClientRect())||null,f=!1,h=!1,g=M.sourceEvent,T===0&&P(M),s=Si(M.sourceEvent,{transform:O,snapGrid:B,snapToGrid:K,containerBounds:d}),u=He(M.sourceEvent,d)}).on("drag",M=>{const{autoPanOnNodeDrag:L,transform:T,snapGrid:O,snapToGrid:B,nodeDragThreshold:K,nodeLookup:G}=n(),I=Si(M.sourceEvent,{transform:T,snapGrid:O,snapToGrid:B,containerBounds:d});if(g=M.sourceEvent,(M.sourceEvent.type==="touchmove"&&M.sourceEvent.touches.length>1||A&&!G.has(A))&&(f=!0),!f){if(!l&&L&&b&&(l=!0,_()),!b){const Y=He(M.sourceEvent,d),Z=Y.x-u.x,J=Y.y-u.y;Math.sqrt(Z*Z+J*J)>K&&P(M)}(s.x!==I.xSnapped||s.y!==I.ySnapped)&&r&&b&&(u=He(M.sourceEvent,d),E(I))}}).on("end",M=>{if(!b||f){f&&r.size>0&&n().updateNodePositions(r,!1);return}if(l=!1,b=!1,cancelAnimationFrame(t),r.size>0){const{nodeLookup:L,updateNodePositions:T,onNodeDragStop:O,onSelectionDragStop:B}=n();if(h&&(T(r,!1),h=!1),a||O||!A&&B){const[K,G]=Qa({nodeId:A,dragItems:r,nodeLookup:L,dragging:!1});a==null||a(M.sourceEvent,r,K,G),O==null||O(M.sourceEvent,K,G),A||B==null||B(M.sourceEvent,G)}}}).filter(M=>{const L=M.target;return!M.button&&(!S||!um(L,`.${S}`,x))&&(!y||um(L,y,x))});m.call(k)}function p(){m==null||m.on(".drag",null)}return{update:v,destroy:p}}function g_(e,n,i){const o=[],a={x:e.x-i,y:e.y-i,width:i*2,height:i*2};for(const s of n.values())bo(a,pi(s))>0&&o.push(s);return o}const y_=250;function x_(e,n,i,o){var r,l,u,d,b;let a=[],s=1/0;const t=g_(e,i,n+y_);for(const m of t){const f=[...(l=(r=m.internals.handleBounds)==null?void 0:r.source)!=null?l:[],...(d=(u=m.internals.handleBounds)==null?void 0:u.target)!=null?d:[]];for(const h of f){if(o.nodeId===h.nodeId&&o.type===h.type&&o.id===h.id)continue;const{x:g,y:v}=Sn(m,h,h.position,!0),p=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(v-e.y,2));p>n||(p<s?(a=[{...h,x:g,y:v}],s=p):p===s&&a.push({...h,x:g,y:v}))}}if(!a.length)return null;if(a.length>1){const m=o.type==="source"?"target":"source";return(b=a.find(f=>f.type===m))!=null?b:a[0]}return a[0]}function dm(e,n,i,o,a,s=!1){var u,d,b,m,f,h;const t=o.get(e);if(!t)return null;const r=a==="strict"?(u=t.internals.handleBounds)==null?void 0:u[n]:[...(b=(d=t.internals.handleBounds)==null?void 0:d.source)!=null?b:[],...(f=(m=t.internals.handleBounds)==null?void 0:m.target)!=null?f:[]],l=(h=i?r==null?void 0:r.find(g=>g.id===i):r==null?void 0:r[0])!=null?h:null;return l&&s?{...l,...Sn(t,l,l.position,!0)}:l}function cm(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function S_(e,n){let i=null;return n?i=!0:e&&!n&&(i=!1),i}const bm=()=>!0;function w_(e,{connectionMode:n,connectionRadius:i,handleId:o,nodeId:a,edgeUpdaterType:s,isTarget:t,domNode:r,nodeLookup:l,lib:u,autoPanOnConnect:d,flowId:b,panBy:m,cancelConnection:f,onConnectStart:h,onConnect:g,onConnectEnd:v,isValidConnection:p=bm,onReconnectEnd:S,updateConnection:y,getTransform:x,getFromHandle:w,autoPanSpeed:A,dragThreshold:N=1,handleDomNode:E}){const _=jb(e.target);let P=0,k;const{x:M,y:L}=He(e),T=cm(s,E),O=r==null?void 0:r.getBoundingClientRect();let B=!1;if(!O||!T)return;const K=dm(a,T,o,l,n);if(!K)return;let G=He(e,O),I=!1,Y=null,Z=!1,J=null;function R(){if(!d||!O)return;const[V,Q]=Ka(G,O,A);m({x:V,y:Q}),P=requestAnimationFrame(R)}const D={...K,nodeId:a,type:T,position:K.position},H=l.get(a);let q={inProgress:!0,isValid:null,from:Sn(H,D,oe.Left,!0),fromHandle:D,fromPosition:D.position,fromNode:H,to:G,toHandle:null,toPosition:Pb[D.position],toNode:null,pointer:G};function F(){B=!0,y(q),h==null||h(e,{nodeId:a,handleId:o,handleType:T})}N===0&&F();function W(V){if(!B){const{x:ee,y:ae}=He(V),re=ee-M,be=ae-L;if(!(re*re+be*be>N*N))return;F()}if(!w()||!D){z(V);return}const Q=x();G=He(V,O),k=x_(yi(G,Q,!1,[1,1]),i,l,D),I||(R(),I=!0);const j=mm(V,{handle:k,connectionMode:n,fromNodeId:a,fromHandleId:o,fromType:t?"target":"source",isValidConnection:p,doc:_,lib:u,flowId:b,nodeLookup:l});J=j.handleDomNode,Y=j.connection,Z=S_(!!k,j.isValid);const X=l.get(a),$=X?Sn(X,D,oe.Left,!0):q.from,ne={...q,from:$,isValid:Z,to:j.toHandle&&Z?Kn({x:j.toHandle.x,y:j.toHandle.y},Q):G,toHandle:j.toHandle,toPosition:Z&&j.toHandle?j.toHandle.position:Pb[D.position],toNode:j.toHandle?l.get(j.toHandle.nodeId):null,pointer:G};y(ne),q=ne}function z(V){if(!("touches"in V&&V.touches.length>0)){if(B){(k||J)&&Y&&Z&&(g==null||g(Y));const{inProgress:Q,...j}=q,X={...j,toPosition:q.toHandle?q.toPosition:null};v==null||v(V,X),s&&(S==null||S(V,X))}f(),cancelAnimationFrame(P),I=!1,Z=!1,Y=null,J=null,_.removeEventListener("mousemove",W),_.removeEventListener("mouseup",z),_.removeEventListener("touchmove",W),_.removeEventListener("touchend",z)}}_.addEventListener("mousemove",W),_.addEventListener("mouseup",z),_.addEventListener("touchmove",W),_.addEventListener("touchend",z)}function mm(e,{handle:n,connectionMode:i,fromNodeId:o,fromHandleId:a,fromType:s,doc:t,lib:r,flowId:l,isValidConnection:u=bm,nodeLookup:d}){const b=s==="target",m=n?t.querySelector(`.${r}-flow__handle[data-id="${l}-${n==null?void 0:n.nodeId}-${n==null?void 0:n.id}-${n==null?void 0:n.type}"]`):null,{x:f,y:h}=He(e),g=t.elementFromPoint(f,h),v=g!=null&&g.classList.contains(`${r}-flow__handle`)?g:m,p={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const S=cm(void 0,v),y=v.getAttribute("data-nodeid"),x=v.getAttribute("data-handleid"),w=v.classList.contains("connectable"),A=v.classList.contains("connectableend");if(!y||!S)return p;const N={source:b?y:o,sourceHandle:b?x:a,target:b?o:y,targetHandle:b?a:x};p.connection=N;const _=w&&A&&(i===qn.Strict?b&&S==="source"||!b&&S==="target":y!==o||x!==a);p.isValid=_&&u(N),p.toHandle=dm(y,S,x,d,i,!0)}return p}const Ra={onPointerDown:w_,isValid:mm};function A_({domNode:e,panZoom:n,getTransform:i,getViewScale:o}){const a=Le(e);function s({translateExtent:r,width:l,height:u,zoomStep:d=1,pannable:b=!0,zoomable:m=!0,inversePan:f=!1}){const h=y=>{if(y.sourceEvent.type!=="wheel"||!n)return;const x=i(),w=y.sourceEvent.ctrlKey&&xi()?10:1,A=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*d,N=x[2]*Math.pow(2,A*w);n.scaleTo(N)};let g=[0,0];const v=y=>{var x,w;(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(g=[(x=y.sourceEvent.clientX)!=null?x:y.sourceEvent.touches[0].clientX,(w=y.sourceEvent.clientY)!=null?w:y.sourceEvent.touches[0].clientY])},p=y=>{var P,k;const x=i();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!n)return;const w=[(P=y.sourceEvent.clientX)!=null?P:y.sourceEvent.touches[0].clientX,(k=y.sourceEvent.clientY)!=null?k:y.sourceEvent.touches[0].clientY],A=[w[0]-g[0],w[1]-g[1]];g=w;const N=o()*Math.max(x[2],Math.log(x[2]))*(f?-1:1),E={x:x[0]-A[0]*N,y:x[1]-A[1]*N},_=[[0,0],[l,u]];n.setViewportConstrained({x:E.x,y:E.y,zoom:x[2]},_,r)},S=Eb().on("start",v).on("zoom",b?p:null).on("zoom.wheel",m?h:null);a.call(S,{})}function t(){a.on("zoom",null)}return{update:s,destroy:t,pointer:qe}}const fo=e=>({x:e.x,y:e.y,zoom:e.k}),es=({x:e,y:n,zoom:i})=>ro.translate(e,n).scale(i),Vn=(e,n)=>e.target.closest(`.${n}`),fm=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),N_=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ns=(e,n=0,i=N_,o=()=>{})=>{const a=typeof n=="number"&&n>0;return a||o(),a?e.transition().duration(n).ease(i).on("end",o):e},vm=e=>{const n=e.ctrlKey&&xi()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function C_({zoomPanValues:e,noWheelClassName:n,d3Selection:i,d3Zoom:o,panOnScrollMode:a,panOnScrollSpeed:s,zoomOnPinch:t,onPanZoomStart:r,onPanZoom:l,onPanZoomEnd:u}){return d=>{if(Vn(d,n))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const b=i.property("__zoom").k||1;if(d.ctrlKey&&t){const v=qe(d),p=vm(d),S=b*Math.pow(2,p);o.scaleTo(i,S,v,d);return}const m=d.deltaMode===1?20:1;let f=a===gn.Vertical?0:d.deltaX*m,h=a===gn.Horizontal?0:d.deltaY*m;!xi()&&d.shiftKey&&a!==gn.Vertical&&(f=d.deltaY*m,h=0),o.translateBy(i,-(f/b)*s,-(h/b)*s,{internal:!0});const g=fo(i.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l==null||l(d,g),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,g),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,r==null||r(d,g))}}function __({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:i}){return function(o,a){const s=o.type==="wheel",t=!n&&s&&!o.ctrlKey,r=Vn(o,e);if(o.ctrlKey&&s&&r&&o.preventDefault(),t||r)return null;o.preventDefault(),i.call(this,o,a)}}function E_({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:i}){return o=>{var s,t,r;if((s=o.sourceEvent)!=null&&s.internal)return;const a=fo(o.transform);e.mouseButton=((t=o.sourceEvent)==null?void 0:t.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((r=o.sourceEvent)==null?void 0:r.type)==="mousedown"&&n(!0),i&&(i==null||i(o.sourceEvent,a))}}function k_({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:i,onTransformChange:o,onPanZoom:a}){return s=>{var t,r,l;e.usedRightMouseButton=!!(i&&fm(n,(t=e.mouseButton)!=null?t:0)),(r=s.sourceEvent)!=null&&r.sync||o([s.transform.x,s.transform.y,s.transform.k]),a&&!((l=s.sourceEvent)!=null&&l.internal)&&(a==null||a(s.sourceEvent,fo(s.transform)))}}function M_({zoomPanValues:e,panOnDrag:n,panOnScroll:i,onDraggingChange:o,onPanZoomEnd:a,onPaneContextMenu:s}){return t=>{var r,l;if(!((r=t.sourceEvent)!=null&&r.internal)&&(e.isZoomingOrPanning=!1,s&&fm(n,(l=e.mouseButton)!=null?l:0)&&!e.usedRightMouseButton&&t.sourceEvent&&s(t.sourceEvent),e.usedRightMouseButton=!1,o(!1),a)){const u=fo(t.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(t.sourceEvent,u)},i?150:0)}}}function T_({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:i,panOnDrag:o,panOnScroll:a,zoomOnDoubleClick:s,userSelectionActive:t,noWheelClassName:r,noPanClassName:l,lib:u,connectionInProgress:d}){return b=>{var v;const m=e||n,f=i&&b.ctrlKey,h=b.type==="wheel";if(b.button===1&&b.type==="mousedown"&&(Vn(b,`${u}-flow__node`)||Vn(b,`${u}-flow__edge`)))return!0;if(!o&&!m&&!a&&!s&&!i||t||d&&!h||Vn(b,r)&&h||Vn(b,l)&&(!h||a&&h&&!e)||!i&&b.ctrlKey&&h)return!1;if(!i&&b.type==="touchstart"&&((v=b.touches)==null?void 0:v.length)>1)return b.preventDefault(),!1;if(!m&&!a&&!f&&h||!o&&(b.type==="mousedown"||b.type==="touchstart")||Array.isArray(o)&&!o.includes(b.button)&&b.type==="mousedown")return!1;const g=Array.isArray(o)&&o.includes(b.button)||!b.button||b.button<=1;return(!b.ctrlKey||h)&&g}}function P_({domNode:e,minZoom:n,maxZoom:i,translateExtent:o,viewport:a,onPanZoom:s,onPanZoomStart:t,onPanZoomEnd:r,onDraggingChange:l}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),b=Eb().scaleExtent([n,i]).translateExtent(o),m=Le(e).call(b);S({x:a.x,y:a.y,zoom:Gn(a.zoom,n,i)},[[0,0],[d.width,d.height]],o);const f=m.on("wheel.zoom"),h=m.on("dblclick.zoom");b.wheelDelta(vm);async function g(k,M){return m?new Promise(L=>{b==null||b.interpolate((M==null?void 0:M.interpolate)==="linear"?ri:Xi).transform(ns(m,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),k)}):!1}function v({noWheelClassName:k,noPanClassName:M,onPaneContextMenu:L,userSelectionActive:T,panOnScroll:O,panOnDrag:B,panOnScrollMode:K,panOnScrollSpeed:G,preventScrolling:I,zoomOnPinch:Y,zoomOnScroll:Z,zoomOnDoubleClick:J,zoomActivationKeyPressed:R,lib:D,onTransformChange:H,connectionInProgress:U,paneClickDistance:q,selectionOnDrag:F}){T&&!u.isZoomingOrPanning&&p();const W=O&&!R&&!T;b.clickDistance(F?1/0:!Ke(q)||q<0?0:q);const z=W?C_({zoomPanValues:u,noWheelClassName:k,d3Selection:m,d3Zoom:b,panOnScrollMode:K,panOnScrollSpeed:G,zoomOnPinch:Y,onPanZoomStart:t,onPanZoom:s,onPanZoomEnd:r}):__({noWheelClassName:k,preventScrolling:I,d3ZoomHandler:f});m.on("wheel.zoom",z,{passive:!1});const V=E_({zoomPanValues:u,onDraggingChange:l,onPanZoomStart:t});b.on("start",V);const Q=k_({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!L,onPanZoom:s,onTransformChange:H});b.on("zoom",Q);const j=M_({zoomPanValues:u,panOnDrag:B,panOnScroll:O,onPaneContextMenu:L,onPanZoomEnd:r,onDraggingChange:l});b.on("end",j);const X=T_({zoomActivationKeyPressed:R,panOnDrag:B,zoomOnScroll:Z,panOnScroll:O,zoomOnDoubleClick:J,zoomOnPinch:Y,userSelectionActive:T,noPanClassName:M,noWheelClassName:k,lib:D,connectionInProgress:U});b.filter(X),J?m.on("dblclick.zoom",h):m.on("dblclick.zoom",null)}function p(){b.on("zoom",null)}async function S(k,M,L){const T=es(k),O=b==null?void 0:b.constrain()(T,M,L);return O&&await g(O),O}async function y(k,M){const L=es(k);return await g(L,M),L}function x(k){if(m){const M=es(k),L=m.property("__zoom");(L.k!==k.zoom||L.x!==k.x||L.y!==k.y)&&(b==null||b.transform(m,M,null,{sync:!0}))}}function w(){const k=m?Cb(m.node()):{x:0,y:0,k:1};return{x:k.x,y:k.y,zoom:k.k}}async function A(k,M){return m?new Promise(L=>{b==null||b.interpolate((M==null?void 0:M.interpolate)==="linear"?ri:Xi).scaleTo(ns(m,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),k)}):!1}async function N(k,M){return m?new Promise(L=>{b==null||b.interpolate((M==null?void 0:M.interpolate)==="linear"?ri:Xi).scaleBy(ns(m,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>L(!0)),k)}):!1}function E(k){b==null||b.scaleExtent(k)}function _(k){b==null||b.translateExtent(k)}function P(k){const M=!Ke(k)||k<0?0:k;b==null||b.clickDistance(M)}return{update:v,destroy:p,setViewport:y,setViewportConstrained:S,getViewport:w,scaleTo:A,scaleBy:N,setScaleExtent:E,setTranslateExtent:_,syncViewport:x,setClickDistance:P}}var zn;(function(e){e.Line="line",e.Handle="handle"})(zn||(zn={}));function I_({width:e,prevWidth:n,height:i,prevHeight:o,affectsX:a,affectsY:s}){const t=e-n,r=i-o,l=[t>0?1:t<0?-1:0,r>0?1:r<0?-1:0];return t&&a&&(l[0]=l[0]*-1),r&&s&&(l[1]=l[1]*-1),l}function hm(e){const n=e.includes("right")||e.includes("left"),i=e.includes("bottom")||e.includes("top"),o=e.includes("left"),a=e.includes("top");return{isHorizontal:n,isVertical:i,affectsX:o,affectsY:a}}function un(e,n){return Math.max(0,n-e)}function dn(e,n){return Math.max(0,e-n)}function vo(e,n,i){return Math.max(0,n-e,e-i)}function pm(e,n){return e?!n:n}function L_(e,n,i,o,a,s,t,r){let{affectsX:l,affectsY:u}=n;const{isHorizontal:d,isVertical:b}=n,m=d&&b,{xSnapped:f,ySnapped:h}=i,{minWidth:g,maxWidth:v,minHeight:p,maxHeight:S}=o,{x:y,y:x,width:w,height:A,aspectRatio:N}=e;let E=Math.floor(d?f-e.pointerX:0),_=Math.floor(b?h-e.pointerY:0);const P=w+(l?-E:E),k=A+(u?-_:_),M=-s[0]*w,L=-s[1]*A;let T=vo(P,g,v),O=vo(k,p,S);if(t){let G=0,I=0;l&&E<0?G=un(y+E+M,t[0][0]):!l&&E>0&&(G=dn(y+P+M,t[1][0])),u&&_<0?I=un(x+_+L,t[0][1]):!u&&_>0&&(I=dn(x+k+L,t[1][1])),T=Math.max(T,G),O=Math.max(O,I)}if(r){let G=0,I=0;l&&E>0?G=dn(y+E,r[0][0]):!l&&E<0&&(G=un(y+P,r[1][0])),u&&_>0?I=dn(x+_,r[0][1]):!u&&_<0&&(I=un(x+k,r[1][1])),T=Math.max(T,G),O=Math.max(O,I)}if(a){if(d){const G=vo(P/N,p,S)*N;if(T=Math.max(T,G),t){let I=0;!l&&!u||l&&!u&&m?I=dn(x+L+P/N,t[1][1])*N:I=un(x+L+(l?E:-E)/N,t[0][1])*N,T=Math.max(T,I)}if(r){let I=0;!l&&!u||l&&!u&&m?I=un(x+P/N,r[1][1])*N:I=dn(x+(l?E:-E)/N,r[0][1])*N,T=Math.max(T,I)}}if(b){const G=vo(k*N,g,v)/N;if(O=Math.max(O,G),t){let I=0;!l&&!u||u&&!l&&m?I=dn(y+k*N+M,t[1][0])/N:I=un(y+(u?_:-_)*N+M,t[0][0])/N,O=Math.max(O,I)}if(r){let I=0;!l&&!u||u&&!l&&m?I=un(y+k*N,r[1][0])/N:I=dn(y+(u?_:-_)*N,r[0][0])/N,O=Math.max(O,I)}}}_=_+(_<0?O:-O),E=E+(E<0?T:-T),a&&(m?P>k*N?_=(pm(l,u)?-E:E)/N:E=(pm(l,u)?-_:_)*N:d?(_=E/N,u=l):(E=_*N,l=u));const B=l?y+E:y,K=u?x+_:x;return{width:w+(l?-E:E),height:A+(u?-_:_),x:s[0]*E*(l?-1:1)+B,y:s[1]*_*(u?-1:1)+K}}const gm={width:0,height:0,x:0,y:0},B_={...gm,pointerX:0,pointerY:0,aspectRatio:1};function O_(e,n,i){var u,d;const o=n.position.x+e.position.x,a=n.position.y+e.position.y,s=(u=e.measured.width)!=null?u:0,t=(d=e.measured.height)!=null?d:0,r=i[0]*s,l=i[1]*t;return[[o-r,a-l],[o+s-r,a+t-l]]}function D_({domNode:e,nodeId:n,getStoreItems:i,onChange:o,onEnd:a}){const s=Le(e);let t={controlDirection:hm("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function r({controlPosition:u,boundaries:d,keepAspectRatio:b,resizeDirection:m,onResizeStart:f,onResize:h,onResizeEnd:g,shouldResize:v}){let p={...gm},S={...B_};t={boundaries:d,resizeDirection:m,keepAspectRatio:b,controlDirection:hm(u)};let y,x=null,w=[],A,N,E,_=!1;const P=Xc().on("start",k=>{var Y,Z,J,R,D,H;const{nodeLookup:M,transform:L,snapGrid:T,snapToGrid:O,nodeOrigin:B,paneDomNode:K}=i();if(y=M.get(n),!y)return;x=(Y=K==null?void 0:K.getBoundingClientRect())!=null?Y:null;const{xSnapped:G,ySnapped:I}=Si(k.sourceEvent,{transform:L,snapGrid:T,snapToGrid:O,containerBounds:x});p={width:(Z=y.measured.width)!=null?Z:0,height:(J=y.measured.height)!=null?J:0,x:(R=y.position.x)!=null?R:0,y:(D=y.position.y)!=null?D:0},S={...p,pointerX:G,pointerY:I,aspectRatio:p.width/p.height},A=void 0,N=xn(y.extent)?y.extent:void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(A=M.get(y.parentId)),A&&y.extent==="parent"&&(N=[[0,0],[A.measured.width,A.measured.height]]),w=[],E=void 0;for(const[U,q]of M)if(q.parentId===n&&(w.push({id:U,position:{...q.position},extent:q.extent}),q.extent==="parent"||q.expandParent)){const F=O_(q,y,(H=q.origin)!=null?H:B);E?E=[[Math.min(F[0][0],E[0][0]),Math.min(F[0][1],E[0][1])],[Math.max(F[1][0],E[1][0]),Math.max(F[1][1],E[1][1])]]:E=F}f==null||f(k,{...p})}).on("drag",k=>{var $,ne,ee;const{transform:M,snapGrid:L,snapToGrid:T,nodeOrigin:O}=i(),B=Si(k.sourceEvent,{transform:M,snapGrid:L,snapToGrid:T,containerBounds:x}),K=[];if(!y)return;const{x:G,y:I,width:Y,height:Z}=p,J={},R=($=y.origin)!=null?$:O,{width:D,height:H,x:U,y:q}=L_(S,t.controlDirection,B,t.boundaries,t.keepAspectRatio,R,N,E),F=D!==Y,W=H!==Z,z=U!==G&&F,V=q!==I&&W;if(!z&&!V&&!F&&!W)return;if((z||V||R[0]===1||R[1]===1)&&(J.x=z?U:p.x,J.y=V?q:p.y,p.x=J.x,p.y=J.y,w.length>0)){const ae=U-G,re=q-I;for(const be of w)be.position={x:be.position.x-ae+R[0]*(D-Y),y:be.position.y-re+R[1]*(H-Z)},K.push(be)}if((F||W)&&(J.width=F&&(!t.resizeDirection||t.resizeDirection==="horizontal")?D:p.width,J.height=W&&(!t.resizeDirection||t.resizeDirection==="vertical")?H:p.height,p.width=J.width,p.height=J.height),A&&y.expandParent){const ae=R[0]*((ne=J.width)!=null?ne:0);J.x&&J.x<ae&&(p.x=ae,S.x=S.x-(J.x-ae));const re=R[1]*((ee=J.height)!=null?ee:0);J.y&&J.y<re&&(p.y=re,S.y=S.y-(J.y-re))}const Q=I_({width:p.width,prevWidth:Y,height:p.height,prevHeight:Z,affectsX:t.controlDirection.affectsX,affectsY:t.controlDirection.affectsY}),j={...p,direction:Q};(v==null?void 0:v(k,j))!==!1&&(_=!0,h==null||h(k,j),o(J,K))}).on("end",k=>{_&&(g==null||g(k,{...p}),a==null||a({...p}),_=!1)});s.call(P)}function l(){s.on(".drag",null)}return{update:r,destroy:l}}var ho=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ym(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var po={exports:{}},is={},go={exports:{}},os={};/**
31
31
  * @license React
32
32
  * use-sync-external-store-shim.production.js
33
33
  *
@@ -7504,7 +7504,7 @@ const $o = _e(Zo), Qo = R.object({
7504
7504
  const a = se("config"), s = (a == null ? void 0 : a.loaderColor) || "#333";
7505
7505
  document.documentElement.style.setProperty("--loader-color", s);
7506
7506
  }, []), /* @__PURE__ */ i("div", { className: n, children: /* @__PURE__ */ i("span", { className: "loader" }) });
7507
- }, ss = ne.lazy(() => import("./logic-flow-DziuWDEF.js"));
7507
+ }, ss = ne.lazy(() => import("./logic-flow-BD7m9aZW.js"));
7508
7508
  function ls({
7509
7509
  questionData: e,
7510
7510
  uploadUrl: n,
@@ -7948,7 +7948,7 @@ function ms({
7948
7948
  {
7949
7949
  onClick: c,
7950
7950
  text: "Versions",
7951
- btnClass: "px-2 bg-transparent font-medium text-sm",
7951
+ btnClass: "px-2 bg-transparent font-medium text-sm version_btn",
7952
7952
  icon: "tabler:history",
7953
7953
  iconClass: "text-xl",
7954
7954
  style: { color: (w == null ? void 0 : w.buttonColor) || "#333" }
@@ -1,7 +1,7 @@
1
1
  import { jsxs as fe, jsx as z, Fragment as Xe } from "react/jsx-runtime";
2
2
  import Tt, { memo as de, useState as qe, useCallback as Ne, forwardRef as Fv, useRef as ie, useEffect as oe, useContext as Pt, createContext as jn, useMemo as Ae, useLayoutEffect as A_ } from "react";
3
3
  import "react-dom";
4
- import { A as R_ } from "./index-pNsPMz_J.js";
4
+ import { A as R_ } from "./index-CAKsnsol.js";
5
5
  function he(e) {
6
6
  if (typeof e == "string" || typeof e == "number") return "" + e;
7
7
  let t = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arudovwen/form-builder-react",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "A React-based form builder component library.",
5
5
  "type": "module",
6
6
  "main": "./dist/form-builder.umd.js",