@arudovwen/form-builder-react 1.9.6 → 1.9.7

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.
@@ -35,7 +35,7 @@
35
35
  ${i===e.id?" border-blue-200 bg-gray-100":"bg-white"} ${s.includes(n)?"min-h-[300px] pb-6 ":""}`,children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{draggable:!0,onDragStart:S=>{S.dataTransfer.setData("sectionid",e.id),S.dataTransfer.effectAllowed="move",b(!0)},onDragEnd:()=>b(!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:[a.jsx(te,{icon:"material-symbols:drag-indicator",iconClass:"text-gray-400 text-lg"}),a.jsx("h2",{className:"font-medium",children:e.title||"Section title"})]}),a.jsxs("div",{className:"flex items-center gap-x-2",children:[a.jsx("button",{type:"button",className:"p-1 text-xs border rounded-lg",onClick:()=>l(e),children:a.jsx(te,{icon:"fluent:edit-28-regular"})}),d>1&&a.jsx("button",{type:"button",className:"p-1 text-xs border rounded-lg",onClick:()=>r(e.id),children:a.jsx(te,{icon:"lets-icons:trash-duotone-line"})}),a.jsx("button",{type:"button",className:"p-1 text-xs rounded-lg",onClick:()=>t(n),children:a.jsx(te,{icon:s.includes(n)?"fa6-solid:chevron-up":"fa6-solid:chevron-down",iconClass:"text-base"})})]})]}),(e==null?void 0:e.description)&&s.includes(n)&&a.jsx("p",{className:"mt-2 text-sm text-gray-600",children:e==null?void 0:e.description}),s.includes(n)&&a.jsxs("div",{className:"h-full mt-4 transition-all duration-200",id:e.id,onDragOver:u,onDragEnd:()=>b(!1),onClick:()=>o(e.id),children:[a.jsx("hr",{className:"group-last:hidden"}),a.jsx("div",{className:"h-full mt-4 gap-y-6 ",children:a.jsx(Ou,{elementData:e==null?void 0:e.questionData,sectionId:e==null?void 0:e.id})})]})]})},e==null?void 0:e.id)},zu=({onAddTemplate:e,templates:n})=>{const i=[...Vu,...n||[]],[o,s]=x.useState(!1),[t,l]=x.useState(!1),r=x.useRef(null),d=x.useRef(null),{removeSection:u,addSection:b,formData:c,setIsDragging:m,setSelectedSection:h,selectedSection:v,activeSections:p,setActiveSections:y,setFormData:g,isDragging:S,pasteElement:f}=x.useContext(Ie);x.useEffect(()=>{const M=P=>{var T;const H=P.target;if(!(H.tagName==="INPUT"||H.tagName==="TEXTAREA"||H.isContentEditable)&&v){const L=((T=P.clipboardData)==null?void 0:T.getData("text"))||"";f(v,void 0,L)}};return window.addEventListener("paste",M),()=>{window.removeEventListener("paste",M)}},[v,f]);const w=x.useRef((c==null?void 0:c.length)||0);x.useEffect(()=>{var M;h(((M=c[0])==null?void 0:M.id)||null)},[]),x.useEffect(()=>{(c==null?void 0:c.length)>w.current&&d.current&&requestAnimationFrame(()=>{var M;(M=d.current)==null||M.scrollTo({top:d.current.scrollHeight,behavior:"smooth"})}),w.current=(c==null?void 0:c.length)||0},[c==null?void 0:c.length]);const C=x.useCallback(M=>{M.preventDefault(),M.dataTransfer.dropEffect="move"},[]),N=x.useCallback((M,P)=>{g(H=>{const T=H.findIndex(_=>_.id===M),L=H.findIndex(_=>_.id===P);if(T===-1||L===-1||T===L)return H;const B=[...H],[O]=B.splice(T,1);return B.splice(L,0,O),B})},[g]);function A(M){p.includes(M)?y(P=>P.filter(H=>H!==M)):y(P=>[...P,M])}function E(M){r.current=M,s(!0)}const k=M=>{var H,T,L,B;const P=(O,_={})=>({...JSON.parse(JSON.stringify(O)),..._});if(M.sections&&Array.isArray(M.sections)){const _=M.sections.filter(Boolean).map($=>{var z;const U=Be.v4(),V=(z=$.questionData)==null?void 0:z.map(J=>P(J,{id:Be.v4(),sectionId:U}));if(V){const J=new Map;$.questionData.forEach((ne,ie)=>{J.set(ne.id,V[ie].id)}),V.forEach(ne=>{ne.gridId&&J.has(ne.gridId)&&(ne.gridId=J.get(ne.gridId))})}return P($,{id:U,questionData:V||[]})});c.length===1&&c[0].title===""&&c[0].description===""&&(!((H=c[0])!=null&&H.questionData)||((L=(T=c[0])==null?void 0:T.questionData)==null?void 0:L.length)===0)?(g(_),_.length>0&&h((B=_[0])==null?void 0:B.id)):g($=>[...$,..._])}},I=ke("config");return a.jsxs("div",{className:"relative flex flex-col h-full pb-5 mx-auto gap-x-4 ",children:[o&&a.jsx(Hu,{isOpen:o,onClose:()=>s(!1),section:r.current}),a.jsxs("div",{id:"section-container",ref:d,className:"relative flex flex-col flex-1 w-full gap-y-3 container overflow-y-auto",children:[c==null?void 0:c.map((M,P)=>a.jsx(Gu,{section:M,index:P,selectedSection:v,setSelectedSection:h,activeSections:p,toggleSection:A,handleSectionEdit:E,removeSection:u,formDataLength:c.length,onDragOver:C,setIsDragging:m,isDragging:S,onReorderSection:N},M.id)),a.jsxs("div",{className:"flex justify-center gap-x-4",children:[a.jsxs("button",{type:"button",onClick:()=>b(),style:{color:(I==null?void 0:I.buttonColor)||"#333"},className:"text-sm font-medium",children:["+ Add section"," "]}),e||i!=null&&i.length?a.jsx("button",{type:"button",onClick:()=>{i!=null&&i.length?l(!0):e&&e()},style:{color:(I==null?void 0:I.buttonColor)||"#333"},className:"text-sm font-medium",children:"+ Add existing template"}):null]})]}),t&&a.jsx(Fu,{isOpen:t,onClose:()=>l(!1),templates:i,onSelect:k})]})},$u=()=>{const{formData:e,uploadUrl:n}=x.useContext(Ie),[i,o]=x.useState("multi"),s=ke("config");return a.jsxs("div",{className:"flex flex-col h-full w-full",children:[a.jsx("div",{className:"flex justify-center p-3 border-b border-gray-100 bg-gray-50/50",children:a.jsxs("div",{className:"flex bg-gray-200 p-1 rounded-lg text-sm font-medium",children:[a.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"}),a.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"})]})}),a.jsx("div",{className:"flex-1 overflow-y-auto w-full relative",children:a.jsx(Ao,{form_data:e,ignoreValidation:!0,config:s,uploadUrl:"https://beta.api.gateway.thetaskforge.co/edms/v1/fileupload/upload-document",renderType:i,onGetValues:t=>console.log(t)})})]})},wo=({loadingClass:e})=>{const n=be("h-full w-full min-h-[300px] flex justify-center items-center",e);return x.useEffect(()=>{const i=ke("config"),o=(i==null?void 0:i.loaderColor)||"#333";document.documentElement.style.setProperty("--loader-color",o)},[]),a.jsx("div",{className:n,children:a.jsx("span",{className:"loader"})})},ju=x.lazy(()=>Promise.resolve().then(()=>Tg));function Wu({questionData:e,uploadUrl:n,onAddTemplate:i,templates:o,viewMode:s="canvas"}){const{setFormData:t,addSection:l,setUploadUrl:r,showPreview:d,formData:u}=x.useContext(Ie);x.useEffect(()=>{e&&e.length>0&&t(e)},[e,t]),x.useEffect(()=>{r(n)},[n,r]);const b=x.useCallback(c=>{c.preventDefault();try{const m=JSON.parse(c.dataTransfer.getData("properties"));if((m==null?void 0:m.type)==="section"){l();return}}catch(m){console.error("Drop error:",m)}},[]);return a.jsxs("div",{className:"flex gap-x-6 h-full",children:[a.jsx("div",{onDragOver:c=>c.preventDefault(),onDrop:c=>b(c),className:" h-full overflow-y-auto no-scrollbar max-h-[calc(100vh-80px)] flex-1 form_builder",children:s==="canvas"?a.jsx(zu,{onAddTemplate:i,templates:o}):a.jsx(x.Suspense,{fallback:a.jsx(wo,{loadingClass:"!w-full !h-full"}),children:a.jsx(ju,{formData:u})})}),s==="canvas"&&a.jsx(de.Transition,{show:d,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:a.jsx("div",{className:"px-2 shadow_box min-w-0 bg-white border border-gray-100 rounded-lg container",children:a.jsx($u,{})})})]})}const Uu=[{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"}],qu=[{key:"pollComponents",title:"Poll Components"},{key:"layoutAndInfo",title:"Layout & Info"}],Yu=({formType:e="default"})=>{const[n,i]=x.useState(""),[o,s]=x.useState(!1),{setIsDragging:t,addElement:l,selectedSection:r,pasteElement:d}=x.useContext(Ie);x.useEffect(()=>{const f=()=>{try{const C=localStorage.getItem("form_builder_clipboard");if(C){const N=JSON.parse(C);(N==null?void 0:N.type)==="FORM_BUILDER_CLIPBOARD"&&(N!=null&&N.timestamp)?Date.now()-N.timestamp>6e4?(localStorage.removeItem("form_builder_clipboard"),s(!1)):s(!0):s(!1)}else s(!1)}catch(C){s(!1)}};f();const w=setInterval(f,1e3);return()=>clearInterval(w)},[]);const u=x.useCallback((f,w)=>{if(!r){Me.toast.error("Please select a section to add an element.");return}f.dataTransfer.setData("properties",JSON.stringify(w)),f.dataTransfer.effectAllowed="move",t(!0)},[t,r]);function b(f){if(!r){Me.toast.error("Please select a section to add an element.");return}const w={...f,id:Be.v4(),sectionId:r};l(w,r)}const c=ke("config")||{},m=c.elementColor,h=c.elementBgColor,v=c.elementBorderColor,p=Nd.filter(f=>f.label.toLowerCase().includes(n.toLowerCase())),y=e==="poll"?qu:Uu,g=e==="poll"?Ad:Cd,S=y==null?void 0:y.map(f=>({title:f.title,elements:p.filter(w=>{var C;return(C=g[f.key])==null?void 0:C.includes(w.type)})})).filter(f=>f.elements.length>0);return a.jsxs("div",{className:"pt-4 flex flex-col gap-y-6",children:[a.jsxs("div",{className:"px-5",children:[a.jsx("input",{className:"field-control",placeholder:"Search",value:n,onChange:f=>i(f.target.value),name:"search",id:"search",autoComplete:"off"}),o&&a.jsxs("button",{className:"w-full mt-3 flex items-center justify-center gap-2 py-2 px-3 bg-blue-50 text-blue-600 hover:bg-blue-100 rounded-lg text-sm font-medium transition-colors",onClick:()=>{if(!r){Me.toast.error("Please select a section to paste the element.");return}typeof d=="function"&&d(r)},title:"Paste copied element",children:[a.jsx(te,{icon:"lucide:clipboard-paste"}),"Paste Element (Ctrl+V)"]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto no-scrollbar max-h-[calc(100vh-100px)]",children:a.jsx("ul",{className:"grid gap-y-5 mt-3 px-5 ",children:S==null?void 0:S.map((f,w)=>{var C;return a.jsxs("li",{children:[a.jsx("h4",{className:"mb-2 text-[11px] font-bold text-gray-500 uppercase",children:f.title}),a.jsx("ul",{className:"grid grid-cols-2 gap-y-3 gap-x-4 mb-3",children:(C=f.elements)==null?void 0:C.map(N=>a.jsx("li",{onDragStart:A=>u(A,N),onDragEnd:()=>t(!1),onClick:()=>b(N),style:{borderColor:v,backgroundColor:h},className:`cursor-move text-[#475467] flex justify-between items-center \r
36
36
  border-[1.5px] border-[#98A2B3] rounded-lg py-2 px-2 shadow-custom\r
37
37
  hover:shadow-lg transition-all duration-200\r
38
- active:opacity-50 element_class`,draggable:!0,children:a.jsxs("span",{className:"flex flex-col items-center justify-center w-full gap-2",children:[a.jsx("span",{style:{color:m},children:a.jsx(te,{icon:N.icon,iconClass:"w-6 h-6"})}),a.jsx("span",{style:{color:m},className:"text-xs font-medium text-center",children:N.label})]})},N.type))})]},w)})})})]})},Ju=x.memo(Yu),We=({text:e="",isDisabled:n=!1,isLoading:i=!1,btnClass:o="bg-primary-500 text-white",icon:s="",iconPosition:t="left",iconClass:l="text-[20px]",loadingClass:r="",link:d="",div:u=!1,type:b="button",style:c,onClick:m})=>{const h=be("btn inline-flex justify-center",{"pointer-events-none":i,"opacity-40 cursor-not-allowed":n},o),v=()=>i?a.jsxs(a.Fragment,{children:[a.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:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.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..."]}):a.jsxs("span",{className:"flex items-center",children:[s&&t==="left"&&a.jsx("span",{className:`mr-[6px] ${l}`,children:a.jsx(te,{icon:s})}),e&&a.jsx("span",{children:e}),s&&t==="right"&&a.jsx("span",{className:`ml-[6px] ${l}`,children:a.jsx(te,{icon:s})})]});return u?a.jsx("div",{className:h,children:v()}):d?a.jsx(xr.Link,{to:d,className:h,children:v()}):a.jsx("button",{disabled:n,type:b,className:h,"data-testid":"btn",onClick:m,style:c,children:v()})};function Zu(){return a.jsx("div",{children:a.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",fill:"#D5D7DA"}),a.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",stroke:"#E9EAEB"}),a.jsx("path",{d:"M22.5 14L14.5 22M14.5 14L22.5 22",stroke:"#414651",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const Xu=({isOpen:e,onClose:n})=>{const{formData:i,uploadUrl:o}=x.useContext(Ie);if(!e)return null;const s=ke("config");return a.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:[a.jsx("button",{type:"button",onClick:n,className:"absolute text-sm top-3 right-4","aria-label":"close",children:a.jsx(Zu,{})})," ",a.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:a.jsx(Ao,{form_data:i,ignoreValidation:!0,config:s,uploadUrl:o})})]})};function Qu(){return a.jsx("div",{children:a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{width:"24",height:"24",rx:"6",fill:"currentColor"}),a.jsx("path",{d:"M14 16L10 12L14 8",stroke:"white",strokeWidth:"1.39167",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function Ru({title:e,goBackUrl:n,onSubmit:i,onPublish:o,previewLoading:s,saveLoading:t,publishLoading:l,onTitleChange:r,viewMode:d,setViewMode:u,onShowVersion:b}){const{formData:c,setShowPreview:m,showPreview:h,undo:v,redo:p,canUndo:y,canRedo:g}=x.useContext(Ie),[S,f]=x.useState(!1),[w,C]=x.useState(!1),[N,A]=x.useState(e||""),E=ke("config");function k(){try{localStorage.setItem("formData",JSON.stringify(c))}catch(P){console.warn("Could not save formData to localStorage",P)}i==null||i(c)}function I(){try{localStorage.setItem("formData",JSON.stringify(c))}catch(P){console.warn("Could not save formData to localStorage",P)}o==null||o(c)}function M(){C(!1),r&&N!==e&&r(N.trim())}return a.jsxs("div",{className:"px-[30px] py-3 flex justify-between items-center bg-[#F9F9FB] top_bar border-b h-full",children:[a.jsxs("span",{className:"flex items-center gap-x-2",children:[n&&a.jsx("button",{type:"button",onClick:()=>n(),style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:"flex items-center gap-x-3",children:a.jsx(Qu,{})})," ",w?a.jsx("input",{type:"text",value:N,onChange:P=>A(P.target.value),onBlur:M,autoFocus:!0,className:"w-48 px-2 py-1 text-sm font-semibold outline-gray-100 input form_title"}):a.jsx("h1",{title:"Click to edit",className:"text-base font-semibold cursor-pointer form_title",onClick:()=>C(!0),children:N||"Untitled"})]}),S&&a.jsx(Xu,{isOpen:S,onClose:()=>f(!1),element:void 0}),a.jsxs("div",{className:"flex justify-end text-xs gap-x-3 items-center",children:[u&&a.jsxs("div",{className:"flex border border-gray-300 rounded-lg overflow-hidden h-[36px] text-sm font-medium shadow-sm mr-2",children:[a.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 ${d==="canvas"?"bg-white font-medium":"bg-gray-100 text-gray-500 hover:bg-gray-50"}`,onClick:()=>u("canvas"),children:[a.jsx(te,{icon:"mdi:view-dashboard-outline",iconClass:"text-base"})," ","Builder"]}),a.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 ${d==="flow"?" bg-white font-medium":"bg-gray-100 text-gray-500 hover:bg-gray-50"}`,onClick:()=>u("flow"),children:[a.jsx(te,{icon:"mdi:sitemap-outline",iconClass:"text-base"})," Flow"]})]}),a.jsx(We,{onClick:v,text:"",btnClass:`!px-2 bg-transparent undo ${y?"":"opacity-50"}`,icon:"material-symbols:undo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!y}),a.jsx(We,{onClick:p,text:"",btnClass:`!px-2 bg-transparent redo ${g?"":"opacity-50"}`,icon:"material-symbols:redo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!g}),b&&a.jsx(We,{onClick:b,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"}}),a.jsx(We,{onClick:()=>m(P=>!P),text:h?"Hide Preview":"Preview",btnClass:"px-2 bg-transparent font-medium text-sm form_preview",icon:h?"iconamoon:eye-off-duotone":"solar:eye-bold-duotone",iconClass:"text-base",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:s,isLoading:s}),a.jsx(We,{onClick:k,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:t,isLoading:t}),a.jsx(We,{onClick:I,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:l,isLoading:l})]})]})}function ec({onSubmit:e,onChange:n,onLogAction:i,questionData:o,title:s,goBackUrl:t,loading:l,onPublish:r,previewLoading:d,saveLoading:u,publishLoading:b,onTitleChange:c,uploadUrl:m,onAddTemplate:h,templates:v,onShowVersion:p,formType:y="default"}){const[g,S]=x.useState("canvas");return a.jsxs(Ns,{onChange:n,onLogAction:i,children:[a.jsx(Me.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),a.jsx("div",{className:"w-full h-full bg-[#F8F9FC] flex flex-col",children:a.jsxs("div",{className:"flex flex-1 ",children:[g==="canvas"&&a.jsx("div",{children:a.jsx("div",{className:"w-[290px] h-screen border-r border-[#E4E7EC] bg-white ",children:a.jsx(Ju,{formType:y})})}),a.jsxs("div",{className:`flex-1 h-full max-h-full z-[1] ${g==="canvas"?"w-[calc(100%-250px)]":"w-full"}`,children:[a.jsx("div",{className:" h-[70px]",children:a.jsx(Ru,{title:s,goBackUrl:t,onSubmit:e,onPublish:r,previewLoading:d,saveLoading:u,publishLoading:b,onTitleChange:c,viewMode:g,setViewMode:S,onShowVersion:p})}),a.jsx("div",{className:"p-6 h-[calc(100vh-70px)]",children:l?a.jsx(wo,{loadingClass:"!w-full !h-[800px]"}):a.jsx(Wu,{questionData:o,uploadUrl:m,onAddTemplate:h,templates:v,viewMode:g})})]})]})})]})}const nc=({onSubmit:e,onChange:n,onLogAction:i,questionData:o,isReadOnly:s,config:t={buttonColor:"#333"},title:l,loading:r,goBackUrl:d,onPublish:u,previewLoading:b,saveLoading:c,publishLoading:m,onTitleChange:h,uploadUrl:v,onAddTemplate:p,templates:y,onShowVersion:g,formType:S})=>(x.useEffect(()=>{t&&Zs("config",t)},[t]),a.jsx(ec,{onSubmit:e,onChange:n,onLogAction:i,onPublish:u,questionData:o,isReadOnly:s,title:l,goBackUrl:d,loading:r,previewLoading:b,saveLoading:c,publishLoading:m,onTitleChange:h,uploadUrl:v,onAddTemplate:p,templates:y,onShowVersion:g,formType:S})),nn={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}`},ic=e=>({textField:R.string().nullable(),longText:R.string().nullable(),numberField:R.number().nullable().transform(i=>isNaN(i)?null:i),amountField:R.number().nullable().transform(i=>isNaN(i)?null:i),selectField:R.string().nullable(),checkbox:R.mixed().nullable(),radio:R.mixed().nullable(),matrix:R.mixed().nullable(),email:R.string().nullable().test("email-format",nn.email,i=>!i||i.trim()===""?!0:/^[A-Za-z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(i)),date:R.date().nullable().transform((i,o)=>o===""||o===null?null:i).typeError("Invalid date"),url:R.string().nullable().test("url-format",nn.url,i=>!i||i.trim()===""?!0:/^(https?:\/\/)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/.*)?$/.test(i))})[e]||R.mixed().nullable(),oc=(e,n,i)=>n?e.type==="boolean"?e.oneOf([!0],i||nn.required):e.required(i||nn.required):e,sc=(e,{minLength:n,maxLength:i,minLengthMessage:o,maxLengthMessage:s})=>{let t=e;return n&&(t=t.min(n,o||nn.minLength(n))),i&&(t=t.max(i,s||nn.maxLength(i))),t},ac=(e,{minAmount:n,maxAmount:i,minAmountMessage:o,maxAmountMessage:s})=>{let t=e;return n&&(t=t.min(parseFloat(String(n)),o||nn.minAmount(n))),i&&(t=t.max(parseFloat(String(i)),s||nn.maxAmount(i))),t},No=(e,n)=>{if(!e.isHidden)return!0;const i=e.visibilityDependentFields||[];return i.length?i.every(o=>{const s=n==null?void 0:n[o.id],t=o.fieldValue,l=s;switch(o.operator){case"equals":return String(t).toLowerCase()===String(l).toLowerCase();case"not_equals":return String(t).toLowerCase()!==String(l).toLowerCase();case"greater":return Number(l)>Number(t);case"less":return Number(l)<Number(t);case"contains":return String(l).toLowerCase().includes(String(t).toLowerCase());case"not_contains":return!String(l).toLowerCase().includes(String(t).toLowerCase());default:return!0}}):!0};function tc({formData:e,isReadOnly:n,answerData:i}){const o={};return e.forEach(({questionData:s})=>{s==null||s.forEach(t=>{if(!No(t,i))return;const{id:l,type:r,isRequired:d,requiredMessage:u,isDisabled:b}=t;let c=ic(r);c=oc(c,b||n?!1:d,u),r==="textField"||r==="longText"||r==="email"||r==="url"?c=sc(c,t):(r==="numberField"||r==="amountField")&&(c=ac(c,t)),t.requireAllChecked?c=c.test("require-all-checked","All options must be selected",m=>{var p;if(m==null||m===""||Array.isArray(m)&&m.length===0)return!d;const v=((p=t.options)==null?void 0:p.length)||0;return Array.isArray(m)?m.length>=v:v<=1}):t.minChecked&&(c=c.test("min-checked",`Please select at least ${t.minChecked} option(s)`,m=>m==null||m===""||Array.isArray(m)&&m.length===0?!d:Array.isArray(m)?m.length>=t.minChecked:1>=t.minChecked)),o[l]=c})}),R.object().shape(o)}const ra=e=>{try{const n=JSON.parse(e);if(Array.isArray(n))return n.map(i=>i.label).join(" > ")}catch(n){}return e},lc=({results:e})=>{var o,s,t,l;const[n,i]=x.useState(!0);return e?a.jsxs("div",{className:"mt-4 w-full",children:[n&&a.jsxs("div",{className:"p-4 mb-3 rounded-xl border border-gray-200 bg-gray-50/50 shadow-sm w-full transition-all duration-300",children:[a.jsx("div",{className:"flex justify-between items-center mb-4",children:a.jsxs("h4",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:["Live Results Breakdown (",e.totalResponses," Responses)"]})}),a.jsxs("div",{className:"space-y-4",children:[(e.type==="polling"||e.type==="polling")&&((o=e.responsesData)==null?void 0:o.options)&&e.responsesData.options.map((r,d)=>a.jsxs("div",{className:"w-full",children:[a.jsxs("div",{className:"flex justify-between items-center mb-1.5 text-sm font-semibold text-gray-800",children:[a.jsx("span",{children:r.label}),a.jsxs("span",{children:[Math.round(r.percentage),"% (",r.count,")"]})]}),a.jsx("div",{className:"w-full bg-gray-200 rounded-full h-1.5 overflow-hidden",children:a.jsx("div",{className:"bg-blue-600 h-1.5 rounded-full transition-all duration-700 ease-out",style:{width:`${r.percentage}%`}})})]},d)),e.type==="ranking"&&((s=e.responsesData)==null?void 0:s.rankings)&&e.responsesData.rankings.map((r,d)=>a.jsxs("div",{className:"w-full",children:[a.jsxs("div",{className:"flex justify-between items-center mb-1.5 text-sm font-semibold text-gray-800",children:[a.jsx("span",{className:"truncate pr-2",title:ra(r.label),children:ra(r.label)}),a.jsxs("span",{className:"shrink-0",children:[Math.round(r.percentage),"% (",r.count,")"]})]}),a.jsx("div",{className:"w-full bg-gray-200 rounded-full h-1.5 overflow-hidden",children:a.jsx("div",{className:"bg-purple-600 h-1.5 rounded-full transition-all duration-700 ease-out",style:{width:`${r.percentage}%`}})})]},d)),e.type==="nps"&&a.jsxs(a.Fragment,{children:[((t=e.responsesData)==null?void 0:t.nps)&&a.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 mb-4",children:[a.jsxs("div",{className:"p-3 bg-white rounded-lg border text-center",children:[a.jsx("div",{className:"text-xs text-gray-500 uppercase",children:"NPS Score"}),a.jsx("div",{className:"text-xl font-bold text-blue-600",children:e.responsesData.nps.score})]}),a.jsxs("div",{className:"p-3 bg-white rounded-lg border text-center",children:[a.jsx("div",{className:"text-xs text-green-500 uppercase",children:"Promoters"}),a.jsx("div",{className:"text-xl font-bold text-gray-800",children:e.responsesData.nps.promoters})]}),a.jsxs("div",{className:"p-3 bg-white rounded-lg border text-center",children:[a.jsx("div",{className:"text-xs text-yellow-500 uppercase",children:"Passives"}),a.jsx("div",{className:"text-xl font-bold text-gray-800",children:e.responsesData.nps.passives})]}),a.jsxs("div",{className:"p-3 bg-white rounded-lg border text-center",children:[a.jsx("div",{className:"text-xs text-red-500 uppercase",children:"Detractors"}),a.jsx("div",{className:"text-xl font-bold text-gray-800",children:e.responsesData.nps.detractors})]})]}),((l=e.responsesData)==null?void 0:l.options)&&a.jsx("div",{className:"grid grid-cols-11 gap-1",children:e.responsesData.options.map((r,d)=>a.jsxs("div",{className:"flex flex-col items-center group relative",children:[a.jsx("div",{className:"w-full bg-blue-100 rounded-t-sm flex items-end justify-center transition-all",style:{height:"60px"},children:a.jsx("div",{className:"w-full bg-blue-500 rounded-t-sm transition-all duration-500",style:{height:`${r.percentage}%`},title:`${r.percentage}% (${r.count} votes)`})}),a.jsx("div",{className:"text-xs font-medium text-gray-600 mt-1",children:r.label})]},d))})]})]})]}),a.jsxs("button",{type:"button",onClick:()=>i(!n),className:"flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-700 font-medium transition-colors",children:[a.jsx(te,{icon:"bx:bar-chart-alt-2",iconClass:"w-4 h-4"}),n?"Hide Results":"Show Results"]})]}):null},gn=({element:e,validationData:n})=>{var l;const i=ta[e.type],{answerData:o}=x.useContext(Ie),s=x.useMemo(()=>{var r;return(r=e==null?void 0:e.acceptedFiles)==null?void 0:r.map(d=>d.label).join(", ")},[e]),t=x.useMemo(()=>No(e,o),[o,e]);return i?a.jsxs("div",{className:`${t?"":"hidden"} min-w-0 w-full`,children:[a.jsx("div",{className:"mb-1.5 min-w-0",children:e.inputLabel&&a.jsxs("label",{className:"block text-sm font-medium input_label",children:[e.inputLabel," ",s&&a.jsxs("span",{className:"text-gray-400 text-xs",children:["(",s==null?void 0:s.toLowerCase(),")"]})]})}),a.jsx(i,{element:e,state:"view",validationData:{...n,isReadOnly:n.isReadOnly||e.isDisabled}}),e.description&&a.jsx("small",{className:"block text-gray-400 mt-0.5 text-xs",children:e.description}),(n==null?void 0:n.showResults)&&((l=n==null?void 0:n.pollResults)==null?void 0:l[e.id])&&a.jsx(lc,{results:n.pollResults[e.id]})]}):null},yn=(e,n)=>e!=null&&e.allowEdit?{...n,isReadOnly:!1}:n;function rc({form_data:e,options:n}){const i=(s,t)=>a.jsx("div",{className:"min-w-0",children:a.jsx(mi,{element:s,customClass:"p-0 min-h-[60px] border-none",children:t==null?void 0:t.map(l=>{var r,d,u;return a.jsxs(bi,{col:(r=l.gridPosition)==null?void 0:r.col,customClass:"p-0 relative",children:[a.jsx(gn,{element:l,validationData:yn(l,n)}),((u=(d=n==null?void 0:n.errors)==null?void 0:d[l.id])==null?void 0:u.message)&&a.jsx("div",{className:"absolute -bottom-[18px] left-0 text-xs text-red-600 whitespace-nowrap",children:n.errors[l.id].message})]},l.id)})})},s.id),o=s=>{var t,l;return a.jsxs("div",{className:be("group relative grid gap-y-[6px] min-w-0",s.elementClass),children:[a.jsx(gn,{element:s,validationData:yn(s,n)}),((l=(t=n==null?void 0:n.errors)==null?void 0:t[s.id])==null?void 0:l.message)&&a.jsx("div",{className:"absolute -bottom-[18px] left-0 text-xs text-red-600 whitespace-nowrap",children:n.errors[s.id].message})]},s.id)};return a.jsx("div",{className:"grid gap-y-10",children:e==null?void 0:e.map(s=>{var l,r;const t=new Map;return(l=s==null?void 0:s.questionData)==null||l.forEach(d=>{d.gridId&&(t.has(d.gridId)||t.set(d.gridId,[]),t.get(d.gridId).push(d))}),a.jsxs("div",{className:"pb-6 section_box min-w-0",children:[(s.title||s.description)&&a.jsxs("div",{className:"py-4 border-b border-gray-100 mb-7 section_box__title",children:[s.title&&a.jsx("h2",{className:"text-lg font-semibold mb-[4px]",children:s.title}),s.description&&a.jsx("p",{className:"text-sm",children:s.description})]}),a.jsx("div",{className:"grid gap-y-6 section_box__content min-w-0",children:(r=s==null?void 0:s.questionData)==null?void 0:r.map(d=>d.gridId?null:d.type==="grid"?i(d,t.get(d.id)||[]):o(d))})]},s.id)})})}function dc({form_data:e,options:n,current:i}){var o,s;return a.jsx("div",{className:"grid gap-y-3 multi_section__content min-w-0",children:(s=(o=e[i])==null?void 0:o.questionData)==null?void 0:s.map(t=>{var l,r,d,u;if(t.type==="grid"){const b=(r=(l=e[i])==null?void 0:l.questionData)==null?void 0:r.filter(c=>c.gridId===t.id);return a.jsx("div",{className:"min-w-0",children:a.jsx(mi,{element:t,customClass:"p-0 min-h-[60px] border-none",children:b==null?void 0:b.map(c=>{var m,h,v;return a.jsxs(bi,{col:(m=c.gridPosition)==null?void 0:m.col,customClass:"p-0",children:[a.jsx(gn,{element:c,validationData:yn(c,n)}),a.jsx("div",{className:"mt-1 text-xs text-red-600 min-h-[1rem]",children:(v=(h=n==null?void 0:n.errors)==null?void 0:h[c.id])==null?void 0:v.message})]},c.id)})})},t.id)}return t.gridId?null:a.jsxs("div",{className:be("group relative grid gap-y-[6px] min-w-0",t.elementClass),children:[a.jsx(gn,{element:t,validationData:yn(t,n)}),a.jsx("div",{className:"mt-1 text-xs text-red-600 min-h-[1rem]",children:(u=(d=n==null?void 0:n.errors)==null?void 0:d[t.id])==null?void 0:u.message})]},t.id)})})}const Co=ke("config");function uc({element:e,options:n,onNext:i,onPrev:o,isFirst:s,isLast:t,isReadOnly:l}){if(!e)return a.jsx("div",{className:"flex items-center justify-center min-h-[500px] text-gray-500",children:"No questions available."});const r=b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),i())},d=b=>{var c;return a.jsx("div",{className:"min-w-0 w-full",children:a.jsx(mi,{element:b,customClass:"p-0 min-h-[60px] border-none w-full",children:(c=b.gridChildren)==null?void 0:c.map(m=>{var h,v,p;return a.jsxs(bi,{col:(h=m.gridPosition)==null?void 0:h.col,customClass:"p-0",children:[a.jsx(gn,{element:m,validationData:yn(m,n)}),a.jsx("div",{className:"mt-1 text-xs text-red-600 min-h-[1rem]",children:(p=(v=n==null?void 0:n.errors)==null?void 0:v[m.id])==null?void 0:p.message})]},m.id)})})},b.id)},u=b=>{var c,m;return a.jsxs("div",{className:be("group relative grid gap-y-[6px] min-w-0 w-full",b.elementClass),children:[a.jsx(gn,{element:b,validationData:yn(b,n)}),a.jsx("div",{className:"mt-1 text-xs text-red-600 min-h-[1rem]",children:(m=(c=n==null?void 0:n.errors)==null?void 0:c[b.id])==null?void 0:m.message})]},b.id)};return a.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:a.jsxs(de.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:[a.jsx("div",{className:"text-left w-full mb-8",children:e.type==="grid"?d(e):u(e)}),!l&&a.jsxs("div",{className:"flex items-center gap-4 mt-8",children:[a.jsx(We,{type:"button",text:t?n!=null&&n.isSubmitting?"Submitting...":"Submit":"OK",onClick:i,style:{background:(Co==null?void 0:Co.buttonColor)||"#333"},btnClass:`text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg ${t?"submit_btn":"continue_btn next_btn text-sm"}`,isDisabled:(n==null?void 0:n.apiActivityCount)>0||t&&(n==null?void 0:n.isSubmitting)}),!t&&a.jsx("span",{className:"text-xs text-gray-400 font-medium hidden sm:inline-block",children:"press Enter ↵"}),!s&&a.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:[a.jsx(te,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]})]},e.id)})}function cc(e){return e.reduce((n,i)=>(n[i.id]=i.value,n),{})}const bc=({form_data:e,answerData:n=[],ignoreValidation:i=!1,onSubmitData:o,onGetValues:s,isReadOnly:t=!1,renderType:l="multi",children:r,hideFooter:d=!1,uploadUrl:u,pollResults:b,showResults:c})=>{var F,Y,oe,K,q,W,G,j,ee,X;const{setAnswerData:m,setUploadUrl:h,apiActivityCount:v}=x.useContext(Ie),[p,y]=x.useState(0),[g,S]=x.useState(0),f=x.useMemo(()=>e.filter(Z=>!Z.isHidden).map(Z=>{var le;return Z.isDisabled||Z.disabled?{...Z,questionData:(le=Z==null?void 0:Z.questionData)==null?void 0:le.map(re=>({...re,isDisabled:!0}))}:Z}),[e]),w=(F=f==null?void 0:f.length)!=null?F:0,C=ke("config"),N=x.useCallback(async(Z,se,le)=>{const re=tc({formData:f,isReadOnly:t,answerData:Z});return uo(re)(Z,se,le)},[f,t]),A=Je.useForm({resolver:N,mode:"onSubmit",defaultValues:{}}),{register:E,setValue:k,control:I,handleSubmit:M,reset:P,getValues:H,watch:T,formState:{errors:L,isSubmitting:B},trigger:O,setError:_,clearErrors:D}=A,$=Je.useWatch({control:I}),U=x.useMemo(()=>$,[JSON.stringify($)]),V=x.useMemo(()=>{if(l!=="conversational")return[];const Z=[];return f.forEach(se=>{var le;(le=se==null?void 0:se.questionData)==null||le.forEach(re=>{var fe;if(No(re,U))if(re.type==="grid"){const he=(fe=se==null?void 0:se.questionData)==null?void 0:fe.filter(Te=>Te.gridId===re.id);Z.push({...re,gridChildren:he})}else re.gridId||Z.push(re)})}),Z},[f,U,l]),z=x.useCallback(Z=>{s&&s(Z)},[s]);x.useEffect(()=>{h(u)},[h,u]),x.useEffect(()=>{if(!(f!=null&&f.length)||!s)return;const Z=f.flatMap(se=>{var le;return(le=se==null?void 0:se.questionData)==null?void 0:le.map(re=>({id:re.id,value:U[re.id]||"",sectionId:se.id,type:re.type,metaData:{prefix:re.prefix,dateFormat:re.dateFormat,...U[`${re.id}_metaData`]?{responseObject:U[`${re.id}_metaData`]}:{}}}))});z(Z),m(U)},[U,f,z,s,m]),x.useEffect(()=>{n!=null&&n.length&&P(cc(n))},[n,P]);const J=x.useCallback(Z=>{const se=f.flatMap(le=>{var re;return(re=le==null?void 0:le.questionData)==null?void 0:re.map(fe=>({id:fe.id,value:Z[fe.id]||"",sectionId:le.id,type:fe.type,metaData:{prefix:fe.prefix,dateFormat:fe.dateFormat,...Z[`${fe.id}_metaData`]?{responseObject:Z[`${fe.id}_metaData`]}:{}}}))});Object.keys(L).length>0||o==null||o(se)},[L,f,o]),ne=x.useCallback(async()=>{var Z,se;if(l==="conversational"){if(!i){const le=V[g];if(!le)return;const re=le.gridChildren?le.gridChildren.map(he=>he.id):[le.id];if(!await O(re))return}g<V.length-1?S(le=>le+1):M(J)();return}if(!i){const le=(se=(Z=f==null?void 0:f[p])==null?void 0:Z.questionData)==null?void 0:se.map(fe=>fe.id);if(!await O(le))return}y(le=>le+1)},[p,g,V,f,i,O,l,M,J]),ie=x.useCallback(()=>{if(l==="conversational"){S(Z=>Math.max(0,Z-1));return}y(Z=>Z-1)},[l]),Q=x.useMemo(()=>({register:E,setValue:k,watch:T,errors:L,trigger:O,isSubmitting:B,isReadOnly:t,getValues:H,setError:_,clearErrors:D,apiActivityCount:v,pollResults:b,showResults:c,isViewer:!0}),[E,k,T,L,O,B,t,H,_,D,v,b,c]);return a.jsxs(Je.FormProvider,{...A,children:[a.jsx(Me.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),a.jsxs("form",{onSubmit:M(J),className:"container h-full mx-auto",children:[a.jsx("div",{className:"relative flex flex-col w-full min-w-0 py-4 gap-y-12",children:a.jsxs("div",{className:"multi_section__box min-w-0",children:[l==="multi"&&(((Y=f==null?void 0:f[p])==null?void 0:Y.title)||((oe=f==null?void 0:f[p])==null?void 0:oe.description))&&a.jsxs("div",{className:"py-4 mb-4 border-b border-gray-100 multi_section__title",children:[((K=f[p])==null?void 0:K.title)&&a.jsx("h2",{className:"text-lg font-semibold mb-[6px]",children:(q=f[p])==null?void 0:q.title}),((W=f[p])==null?void 0:W.description)&&a.jsx("p",{className:"text-sm",children:(G=f[p])==null?void 0:G.description})]}),l==="multi"?a.jsx(dc,{form_data:f,options:Q,current:p}):l==="conversational"?a.jsx(uc,{element:V[g],options:Q,onNext:ne,onPrev:ie,isFirst:g===0,isLast:g===V.length-1,isReadOnly:t}):a.jsx(rc,{form_data:f,options:Q})]},l==="conversational"?`conv-${g}`:(j=f==null?void 0:f[p])==null?void 0:j.id)}),!d&&l!=="conversational"&&a.jsx("footer",{className:"flex items-center justify-end gap-4 footer flex-wrap",children:l==="multi"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex gap-x-4 justify-between navigation_container w-full",children:[a.jsxs("div",{children:[" ",p>0&&a.jsxs("button",{type:"button",onClick:ie,className:"text-gray-400 hover:text-gray-600 font-medium text-sm flex items-center gap-1 transition-colors back_btn",children:[a.jsx(te,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]}),p<w-1&&a.jsx(We,{type:"button",text:"Next",onClick:ne,style:{background:(C==null?void 0:C.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"})]}),(p===w-1||t)&&!i&&((ee=typeof r=="function"?r({isUploading:v>0,isSubmitting:B,hasErrors:Object.keys(L).length>0}):r)!=null?ee:a.jsx(We,{isDisabled:B||Object.keys(L).length>0||v>0,isLoading:B,type:"submit",text:"Submit",style:{background:(C==null?void 0:C.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&&((X=typeof r=="function"?r({isUploading:v>0,isSubmitting:B,hasErrors:Object.keys(L).length>0}):r)!=null?X:a.jsx(We,{isDisabled:B||Object.keys(L).length>0||v>0,isLoading:B,type:"submit",text:"Submit",style:{background:(C==null?void 0:C.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"}))}),l==="conversational"&&V.length>0&&a.jsx("div",{className:"fixed bottom-0 left-0 w-full h-1.5 bg-gray-200",children:a.jsx("div",{className:"h-full bg-blue-600 transition-all duration-500 ease-out",style:{width:`${(g+1)/V.length*100}%`,background:(C==null?void 0:C.buttonColor)||"#2563EB"}})})]})]})},mc=x.memo(bc);function Ao({answerData:e,form_data:n,ignoreValidation:i,onSubmit:o,isReadOnly:s=!1,loading:t=!1,config:l={buttonColor:"#333"},renderType:r,children:d,hideFooter:u,onGetValues:b,uploadUrl:c,pollResults:m,showResults:h}){x.useEffect(()=>{l&&Zs("config",l)},[l]);const v=x.useCallback(p=>{b&&b(p)},[b]);return t?a.jsx(wo,{}):n?a.jsxs("div",{className:"w-full h-full min-w-0",children:[a.jsx("div",{id:"root-portal"}),a.jsx(Ns,{children:a.jsx(mc,{form_data:n,answerData:e,ignoreValidation:i,onSubmitData:o,isReadOnly:s,renderType:r,hideFooter:u,onGetValues:v,uploadUrl:c,pollResults:m,showResults:h,children:d})})]}):a.jsx("div",{children:a.jsx("p",{className:"p-6 text-sm text-gray-400",children:"Error: No form data available."})})}function Ee(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=Ee(e[i]))!==""&&(n+=(n&&" ")+o);else for(let i in e)e[i]&&(n+=(n&&" ")+i);return n}var vc={value:()=>{}};function vi(){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 fi(i)}function fi(e){this._=e}function fc(e,n){return e.trim().split(/^|\s+/).map(function(i){var o="",s=i.indexOf(".");if(s>=0&&(o=i.slice(s+1),i=i.slice(0,s)),i&&!n.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:o}})}fi.prototype=vi.prototype={constructor:fi,on:function(e,n){var i=this._,o=fc(e+"",i),s,t=-1,l=o.length;if(arguments.length<2){for(;++t<l;)if((s=(e=o[t]).type)&&(s=hc(i[s],e.name)))return s;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++t<l;)if(s=(e=o[t]).type)i[s]=da(i[s],e.name,n);else if(n==null)for(s in i)i[s]=da(i[s],e.name,null);return this},copy:function(){var e={},n=this._;for(var i in n)e[i]=n[i].slice();return new fi(e)},call:function(e,n){if((s=arguments.length-2)>0)for(var i=new Array(s),o=0,s,t;o<s;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(t=this._[e],o=0,s=t.length;o<s;++o)t[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],s=0,t=o.length;s<t;++s)o[s].value.apply(n,i)}};function hc(e,n){for(var i=0,o=e.length,s;i<o;++i)if((s=e[i]).name===n)return s.value}function da(e,n,i){for(var o=0,s=e.length;o<s;++o)if(e[o].name===n){e[o]=vc,e=e.slice(0,o).concat(e.slice(o+1));break}return i!=null&&e.push({name:n,value:i}),e}var ko="http://www.w3.org/1999/xhtml";const ua={svg:"http://www.w3.org/2000/svg",xhtml:ko,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function hi(e){var n=e+="",i=n.indexOf(":");return i>=0&&(n=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),ua.hasOwnProperty(n)?{space:ua[n],local:e}:e}function pc(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===ko&&n.documentElement.namespaceURI===ko?n.createElement(e):n.createElementNS(i,e)}}function gc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ca(e){var n=hi(e);return(n.local?gc:pc)(n)}function yc(){}function Eo(e){return e==null?yc:function(){return this.querySelector(e)}}function xc(e){typeof e!="function"&&(e=Eo(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var t=n[s],l=t.length,r=o[s]=new Array(l),d,u,b=0;b<l;++b)(d=t[b])&&(u=e.call(d,d.__data__,b,t))&&("__data__"in d&&(u.__data__=d.__data__),r[b]=u);return new _e(o,this._parents)}function Sc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function wc(){return[]}function ba(e){return e==null?wc:function(){return this.querySelectorAll(e)}}function Nc(e){return function(){return Sc(e.apply(this,arguments))}}function Cc(e){typeof e=="function"?e=Nc(e):e=ba(e);for(var n=this._groups,i=n.length,o=[],s=[],t=0;t<i;++t)for(var l=n[t],r=l.length,d,u=0;u<r;++u)(d=l[u])&&(o.push(e.call(d,d.__data__,u,l)),s.push(d));return new _e(o,s)}function ma(e){return function(){return this.matches(e)}}function va(e){return function(n){return n.matches(e)}}var Ac=Array.prototype.find;function kc(e){return function(){return Ac.call(this.children,e)}}function Ec(){return this.firstElementChild}function Mc(e){return this.select(e==null?Ec:kc(typeof e=="function"?e:va(e)))}var Tc=Array.prototype.filter;function Pc(){return Array.from(this.children)}function Lc(e){return function(){return Tc.call(this.children,e)}}function Bc(e){return this.selectAll(e==null?Pc:Lc(typeof e=="function"?e:va(e)))}function Ic(e){typeof e!="function"&&(e=ma(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var t=n[s],l=t.length,r=o[s]=[],d,u=0;u<l;++u)(d=t[u])&&e.call(d,d.__data__,u,t)&&r.push(d);return new _e(o,this._parents)}function fa(e){return new Array(e.length)}function Dc(){return new _e(this._enter||this._groups.map(fa),this._parents)}function pi(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}pi.prototype={constructor:pi,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 _c(e){return function(){return e}}function Oc(e,n,i,o,s,t){for(var l=0,r,d=n.length,u=t.length;l<u;++l)(r=n[l])?(r.__data__=t[l],o[l]=r):i[l]=new pi(e,t[l]);for(;l<d;++l)(r=n[l])&&(s[l]=r)}function Kc(e,n,i,o,s,t,l){var r,d,u=new Map,b=n.length,c=t.length,m=new Array(b),h;for(r=0;r<b;++r)(d=n[r])&&(m[r]=h=l.call(d,d.__data__,r,n)+"",u.has(h)?s[r]=d:u.set(h,d));for(r=0;r<c;++r)h=l.call(e,t[r],r,t)+"",(d=u.get(h))?(o[r]=d,d.__data__=t[r],u.delete(h)):i[r]=new pi(e,t[r]);for(r=0;r<b;++r)(d=n[r])&&u.get(m[r])===d&&(s[r]=d)}function Hc(e){return e.__data__}function Fc(e,n){if(!arguments.length)return Array.from(this,Hc);var i=n?Kc:Oc,o=this._parents,s=this._groups;typeof e!="function"&&(e=_c(e));for(var t=s.length,l=new Array(t),r=new Array(t),d=new Array(t),u=0;u<t;++u){var b=o[u],c=s[u],m=c.length,h=Vc(e.call(b,b&&b.__data__,u,o)),v=h.length,p=r[u]=new Array(v),y=l[u]=new Array(v),g=d[u]=new Array(m);i(b,c,p,y,g,h,n);for(var S=0,f=0,w,C;S<v;++S)if(w=p[S]){for(S>=f&&(f=S+1);!(C=y[f])&&++f<v;);w._next=C||null}}return l=new _e(l,o),l._enter=r,l._exit=d,l}function Vc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Gc(){return new _e(this._exit||this._groups.map(fa),this._parents)}function zc(e,n,i){var o=this.enter(),s=this,t=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),n!=null&&(s=n(s),s&&(s=s.selection())),i==null?t.remove():i(t),o&&s?o.merge(s).order():s}function $c(e){for(var n=e.selection?e.selection():e,i=this._groups,o=n._groups,s=i.length,t=o.length,l=Math.min(s,t),r=new Array(s),d=0;d<l;++d)for(var u=i[d],b=o[d],c=u.length,m=r[d]=new Array(c),h,v=0;v<c;++v)(h=u[v]||b[v])&&(m[v]=h);for(;d<s;++d)r[d]=i[d];return new _e(r,this._parents)}function jc(){for(var e=this._groups,n=-1,i=e.length;++n<i;)for(var o=e[n],s=o.length-1,t=o[s],l;--s>=0;)(l=o[s])&&(t&&l.compareDocumentPosition(t)^4&&t.parentNode.insertBefore(l,t),t=l);return this}function Wc(e){e||(e=Uc);function n(c,m){return c&&m?e(c.__data__,m.__data__):!c-!m}for(var i=this._groups,o=i.length,s=new Array(o),t=0;t<o;++t){for(var l=i[t],r=l.length,d=s[t]=new Array(r),u,b=0;b<r;++b)(u=l[b])&&(d[b]=u);d.sort(n)}return new _e(s,this._parents).order()}function Uc(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function qc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Yc(){return Array.from(this)}function Jc(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],s=0,t=o.length;s<t;++s){var l=o[s];if(l)return l}return null}function Zc(){let e=0;for(const n of this)++e;return e}function Xc(){return!this.node()}function Qc(e){for(var n=this._groups,i=0,o=n.length;i<o;++i)for(var s=n[i],t=0,l=s.length,r;t<l;++t)(r=s[t])&&e.call(r,r.__data__,t,s);return this}function Rc(e){return function(){this.removeAttribute(e)}}function eb(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nb(e,n){return function(){this.setAttribute(e,n)}}function ib(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function ob(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function sb(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 ab(e,n){var i=hi(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?eb:Rc:typeof n=="function"?i.local?sb:ob:i.local?ib:nb)(i,n))}function ha(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function tb(e){return function(){this.style.removeProperty(e)}}function lb(e,n,i){return function(){this.style.setProperty(e,n,i)}}function rb(e,n,i){return function(){var o=n.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,i)}}function db(e,n,i){return arguments.length>1?this.each((n==null?tb:typeof n=="function"?rb:lb)(e,n,i==null?"":i)):xn(this.node(),e)}function xn(e,n){return e.style.getPropertyValue(n)||ha(e).getComputedStyle(e,null).getPropertyValue(n)}function ub(e){return function(){delete this[e]}}function cb(e,n){return function(){this[e]=n}}function bb(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function mb(e,n){return arguments.length>1?this.each((n==null?ub:typeof n=="function"?bb:cb)(e,n)):this.node()[e]}function pa(e){return e.trim().split(/^|\s+/)}function Mo(e){return e.classList||new ga(e)}function ga(e){this._node=e,this._names=pa(e.getAttribute("class")||"")}ga.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 ya(e,n){for(var i=Mo(e),o=-1,s=n.length;++o<s;)i.add(n[o])}function xa(e,n){for(var i=Mo(e),o=-1,s=n.length;++o<s;)i.remove(n[o])}function vb(e){return function(){ya(this,e)}}function fb(e){return function(){xa(this,e)}}function hb(e,n){return function(){(n.apply(this,arguments)?ya:xa)(this,e)}}function pb(e,n){var i=pa(e+"");if(arguments.length<2){for(var o=Mo(this.node()),s=-1,t=i.length;++s<t;)if(!o.contains(i[s]))return!1;return!0}return this.each((typeof n=="function"?hb:n?vb:fb)(i,n))}function gb(){this.textContent=""}function yb(e){return function(){this.textContent=e}}function xb(e){return function(){var n=e.apply(this,arguments);this.textContent=n==null?"":n}}function Sb(e){return arguments.length?this.each(e==null?gb:(typeof e=="function"?xb:yb)(e)):this.node().textContent}function wb(){this.innerHTML=""}function Nb(e){return function(){this.innerHTML=e}}function Cb(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n==null?"":n}}function Ab(e){return arguments.length?this.each(e==null?wb:(typeof e=="function"?Cb:Nb)(e)):this.node().innerHTML}function kb(){this.nextSibling&&this.parentNode.appendChild(this)}function Eb(){return this.each(kb)}function Mb(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Tb(){return this.each(Mb)}function Pb(e){var n=typeof e=="function"?e:ca(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function Lb(){return null}function Bb(e,n){var i=typeof e=="function"?e:ca(e),o=n==null?Lb:typeof n=="function"?n:Eo(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),o.apply(this,arguments)||null)})}function Ib(){var e=this.parentNode;e&&e.removeChild(this)}function Db(){return this.each(Ib)}function _b(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function Ob(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function Kb(e){return this.select(e?Ob:_b)}function Hb(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Fb(e){return function(n){e.call(this,n,this.__data__)}}function Vb(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 Gb(e){return function(){var n=this.__on;if(n){for(var i=0,o=-1,s=n.length,t;i<s;++i)t=n[i],(!e.type||t.type===e.type)&&t.name===e.name?this.removeEventListener(t.type,t.listener,t.options):n[++o]=t;++o?n.length=o:delete this.__on}}}function zb(e,n,i){return function(){var o=this.__on,s,t=Fb(n);if(o){for(var l=0,r=o.length;l<r;++l)if((s=o[l]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=t,s.options=i),s.value=n;return}}this.addEventListener(e.type,t,i),s={type:e.type,name:e.name,value:n,listener:t,options:i},o?o.push(s):this.__on=[s]}}function $b(e,n,i){var o=Vb(e+""),s,t=o.length,l;if(arguments.length<2){var r=this.node().__on;if(r){for(var d=0,u=r.length,b;d<u;++d)for(s=0,b=r[d];s<t;++s)if((l=o[s]).type===b.type&&l.name===b.name)return b.value}return}for(r=n?zb:Gb,s=0;s<t;++s)this.each(r(o[s],n,i));return this}function Sa(e,n,i){var o=ha(e),s=o.CustomEvent;typeof s=="function"?s=new s(n,i):(s=o.document.createEvent("Event"),i?(s.initEvent(n,i.bubbles,i.cancelable),s.detail=i.detail):s.initEvent(n,!1,!1)),e.dispatchEvent(s)}function jb(e,n){return function(){return Sa(this,e,n)}}function Wb(e,n){return function(){return Sa(this,e,n.apply(this,arguments))}}function Ub(e,n){return this.each((typeof n=="function"?Wb:jb)(e,n))}function*qb(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],s=0,t=o.length,l;s<t;++s)(l=o[s])&&(yield l)}var wa=[null];function _e(e,n){this._groups=e,this._parents=n}function Hn(){return new _e([[document.documentElement]],wa)}function Yb(){return this}_e.prototype=Hn.prototype={constructor:_e,select:xc,selectAll:Cc,selectChild:Mc,selectChildren:Bc,filter:Ic,data:Fc,enter:Dc,exit:Gc,join:zc,merge:$c,selection:Yb,order:jc,sort:Wc,call:qc,nodes:Yc,node:Jc,size:Zc,empty:Xc,each:Qc,attr:ab,style:db,property:mb,classed:pb,text:Sb,html:Ab,raise:Eb,lower:Tb,append:Pb,insert:Bb,remove:Db,clone:Kb,datum:Hb,on:$b,dispatch:Ub,[Symbol.iterator]:qb};function Oe(e){return typeof e=="string"?new _e([[document.querySelector(e)]],[document.documentElement]):new _e([[e]],wa)}function Jb(e){let n;for(;n=e.sourceEvent;)e=n;return e}function He(e,n){if(e=Jb(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 s=n.getBoundingClientRect();return[e.clientX-s.left-n.clientLeft,e.clientY-s.top-n.clientTop]}}return[e.pageX,e.pageY]}const Zb={passive:!1},Fn={capture:!0,passive:!1};function To(e){e.stopImmediatePropagation()}function Sn(e){e.preventDefault(),e.stopImmediatePropagation()}function Na(e){var n=e.document.documentElement,i=Oe(e).on("dragstart.drag",Sn,Fn);"onselectstart"in n?i.on("selectstart.drag",Sn,Fn):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Ca(e,n){var i=e.document.documentElement,o=Oe(e).on("dragstart.drag",null);n&&(o.on("click.drag",Sn,Fn),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 gi=e=>()=>e;function Po(e,{sourceEvent:n,subject:i,target:o,identifier:s,active:t,x:l,y:r,dx:d,dy:u,dispatch:b}){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:s,enumerable:!0,configurable:!0},active:{value:t,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:r,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:b}})}Po.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Xb(e){return!e.ctrlKey&&!e.button}function Qb(){return this.parentNode}function Rb(e,n){return n==null?{x:e.x,y:e.y}:n}function em(){return navigator.maxTouchPoints||"ontouchstart"in this}function Aa(){var e=Xb,n=Qb,i=Rb,o=em,s={},t=vi("start","drag","end"),l=0,r,d,u,b,c=0;function m(w){w.on("mousedown.drag",h).filter(o).on("touchstart.drag",y).on("touchmove.drag",g,Zb).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,C){if(!(b||!e.call(this,w,C))){var N=f(this,n.call(this,w,C),w,C,"mouse");N&&(Oe(w.view).on("mousemove.drag",v,Fn).on("mouseup.drag",p,Fn),Na(w.view),To(w),u=!1,r=w.clientX,d=w.clientY,N("start",w))}}function v(w){if(Sn(w),!u){var C=w.clientX-r,N=w.clientY-d;u=C*C+N*N>c}s.mouse("drag",w)}function p(w){Oe(w.view).on("mousemove.drag mouseup.drag",null),Ca(w.view,u),Sn(w),s.mouse("end",w)}function y(w,C){if(e.call(this,w,C)){var N=w.changedTouches,A=n.call(this,w,C),E=N.length,k,I;for(k=0;k<E;++k)(I=f(this,A,w,C,N[k].identifier,N[k]))&&(To(w),I("start",w,N[k]))}}function g(w){var C=w.changedTouches,N=C.length,A,E;for(A=0;A<N;++A)(E=s[C[A].identifier])&&(Sn(w),E("drag",w,C[A]))}function S(w){var C=w.changedTouches,N=C.length,A,E;for(b&&clearTimeout(b),b=setTimeout(function(){b=null},500),A=0;A<N;++A)(E=s[C[A].identifier])&&(To(w),E("end",w,C[A]))}function f(w,C,N,A,E,k){var I=t.copy(),M=He(k||N,C),P,H,T;if((T=i.call(w,new Po("beforestart",{sourceEvent:N,target:m,identifier:E,active:l,x:M[0],y:M[1],dx:0,dy:0,dispatch:I}),A))!=null)return P=T.x-M[0]||0,H=T.y-M[1]||0,function L(B,O,_){var D=M,$;switch(B){case"start":s[E]=L,$=l++;break;case"end":delete s[E],--l;case"drag":M=He(_||O,C),$=l;break}I.call(B,w,new Po(B,{sourceEvent:O,subject:T,target:m,identifier:E,active:$,x:M[0]+P,y:M[1]+H,dx:M[0]-D[0],dy:M[1]-D[1],dispatch:I}),A)}}return m.filter=function(w){return arguments.length?(e=typeof w=="function"?w:gi(!!w),m):e},m.container=function(w){return arguments.length?(n=typeof w=="function"?w:gi(w),m):n},m.subject=function(w){return arguments.length?(i=typeof w=="function"?w:gi(w),m):i},m.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:gi(!!w),m):o},m.on=function(){var w=t.on.apply(t,arguments);return w===t?m:w},m.clickDistance=function(w){return arguments.length?(c=(w=+w)*w,m):Math.sqrt(c)},m}function Lo(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function ka(e,n){var i=Object.create(e.prototype);for(var o in n)i[o]=n[o];return i}function Vn(){}var Gn=.7,yi=1/Gn,wn="\\s*([+-]?\\d+)\\s*",zn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ue="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",nm=/^#([0-9a-f]{3,8})$/,im=new RegExp(`^rgb\\(${wn},${wn},${wn}\\)$`),om=new RegExp(`^rgb\\(${Ue},${Ue},${Ue}\\)$`),sm=new RegExp(`^rgba\\(${wn},${wn},${wn},${zn}\\)$`),am=new RegExp(`^rgba\\(${Ue},${Ue},${Ue},${zn}\\)$`),tm=new RegExp(`^hsl\\(${zn},${Ue},${Ue}\\)$`),lm=new RegExp(`^hsla\\(${zn},${Ue},${Ue},${zn}\\)$`),Ea={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};Lo(Vn,rn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ma,formatHex:Ma,formatHex8:rm,formatHsl:dm,formatRgb:Ta,toString:Ta});function Ma(){return this.rgb().formatHex()}function rm(){return this.rgb().formatHex8()}function dm(){return Da(this).formatHsl()}function Ta(){return this.rgb().formatRgb()}function rn(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=nm.exec(e))?(i=n[1].length,n=parseInt(n[1],16),i===6?Pa(n):i===3?new De(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):i===8?xi(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?xi(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=im.exec(e))?new De(n[1],n[2],n[3],1):(n=om.exec(e))?new De(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=sm.exec(e))?xi(n[1],n[2],n[3],n[4]):(n=am.exec(e))?xi(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=tm.exec(e))?Ia(n[1],n[2]/100,n[3]/100,1):(n=lm.exec(e))?Ia(n[1],n[2]/100,n[3]/100,n[4]):Ea.hasOwnProperty(e)?Pa(Ea[e]):e==="transparent"?new De(NaN,NaN,NaN,0):null}function Pa(e){return new De(e>>16&255,e>>8&255,e&255,1)}function xi(e,n,i,o){return o<=0&&(e=n=i=NaN),new De(e,n,i,o)}function um(e){return e instanceof Vn||(e=rn(e)),e?(e=e.rgb(),new De(e.r,e.g,e.b,e.opacity)):new De}function Bo(e,n,i,o){return arguments.length===1?um(e):new De(e,n,i,o==null?1:o)}function De(e,n,i,o){this.r=+e,this.g=+n,this.b=+i,this.opacity=+o}Lo(De,Bo,ka(Vn,{brighter(e){return e=e==null?yi:Math.pow(yi,e),new De(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Gn:Math.pow(Gn,e),new De(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new De(dn(this.r),dn(this.g),dn(this.b),Si(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:La,formatHex:La,formatHex8:cm,formatRgb:Ba,toString:Ba}));function La(){return`#${un(this.r)}${un(this.g)}${un(this.b)}`}function cm(){return`#${un(this.r)}${un(this.g)}${un(this.b)}${un((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ba(){const e=Si(this.opacity);return`${e===1?"rgb(":"rgba("}${dn(this.r)}, ${dn(this.g)}, ${dn(this.b)}${e===1?")":`, ${e})`}`}function Si(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function dn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function un(e){return e=dn(e),(e<16?"0":"")+e.toString(16)}function Ia(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 Da(e){if(e instanceof Fe)return new Fe(e.h,e.s,e.l,e.opacity);if(e instanceof Vn||(e=rn(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,s=Math.min(n,i,o),t=Math.max(n,i,o),l=NaN,r=t-s,d=(t+s)/2;return r?(n===t?l=(i-o)/r+(i<o)*6:i===t?l=(o-n)/r+2:l=(n-i)/r+4,r/=d<.5?t+s:2-t-s,l*=60):r=d>0&&d<1?0:l,new Fe(l,r,d,e.opacity)}function bm(e,n,i,o){return arguments.length===1?Da(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}Lo(Fe,bm,ka(Vn,{brighter(e){return e=e==null?yi:Math.pow(yi,e),new Fe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Gn:Math.pow(Gn,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,s=2*i-o;return new De(Io(e>=240?e-240:e+120,s,o),Io(e,s,o),Io(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new Fe(_a(this.h),wi(this.s),wi(this.l),Si(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=Si(this.opacity);return`${e===1?"hsl(":"hsla("}${_a(this.h)}, ${wi(this.s)*100}%, ${wi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _a(e){return e=(e||0)%360,e<0?e+360:e}function wi(e){return Math.max(0,Math.min(1,e||0))}function Io(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 Do=e=>()=>e;function mm(e,n){return function(i){return e+i*n}}function vm(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 fm(e){return(e=+e)==1?Oa:function(n,i){return i-n?vm(n,i,e):Do(isNaN(n)?i:n)}}function Oa(e,n){var i=n-e;return i?mm(e,i):Do(isNaN(e)?n:e)}const Ni=function e(n){var i=fm(n);function o(s,t){var l=i((s=Bo(s)).r,(t=Bo(t)).r),r=i(s.g,t.g),d=i(s.b,t.b),u=Oa(s.opacity,t.opacity);return function(b){return s.r=l(b),s.g=r(b),s.b=d(b),s.opacity=u(b),s+""}}return o.gamma=e,o}(1);function hm(e,n){n||(n=[]);var i=e?Math.min(n.length,e.length):0,o=n.slice(),s;return function(t){for(s=0;s<i;++s)o[s]=e[s]*(1-t)+n[s]*t;return o}}function pm(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function gm(e,n){var i=n?n.length:0,o=e?Math.min(i,e.length):0,s=new Array(o),t=new Array(i),l;for(l=0;l<o;++l)s[l]=$n(e[l],n[l]);for(;l<i;++l)t[l]=n[l];return function(r){for(l=0;l<o;++l)t[l]=s[l](r);return t}}function ym(e,n){var i=new Date;return e=+e,n=+n,function(o){return i.setTime(e*(1-o)+n*o),i}}function qe(e,n){return e=+e,n=+n,function(i){return e*(1-i)+n*i}}function xm(e,n){var i={},o={},s;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(s in n)s in e?i[s]=$n(e[s],n[s]):o[s]=n[s];return function(t){for(s in i)o[s]=i[s](t);return o}}var _o=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Oo=new RegExp(_o.source,"g");function Sm(e){return function(){return e}}function wm(e){return function(n){return e(n)+""}}function Ka(e,n){var i=_o.lastIndex=Oo.lastIndex=0,o,s,t,l=-1,r=[],d=[];for(e=e+"",n=n+"";(o=_o.exec(e))&&(s=Oo.exec(n));)(t=s.index)>i&&(t=n.slice(i,t),r[l]?r[l]+=t:r[++l]=t),(o=o[0])===(s=s[0])?r[l]?r[l]+=s:r[++l]=s:(r[++l]=null,d.push({i:l,x:qe(o,s)})),i=Oo.lastIndex;return i<n.length&&(t=n.slice(i),r[l]?r[l]+=t:r[++l]=t),r.length<2?d[0]?wm(d[0].x):Sm(n):(n=d.length,function(u){for(var b=0,c;b<n;++b)r[(c=d[b]).i]=c.x(u);return r.join("")})}function $n(e,n){var i=typeof n,o;return n==null||i==="boolean"?Do(n):(i==="number"?qe:i==="string"?(o=rn(n))?(n=o,Ni):Ka:n instanceof rn?Ni:n instanceof Date?ym:pm(n)?hm:Array.isArray(n)?gm:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?xm:qe)(e,n)}var Ha=180/Math.PI,Ko={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Fa(e,n,i,o,s,t){var l,r,d;return(l=Math.sqrt(e*e+n*n))&&(e/=l,n/=l),(d=e*i+n*o)&&(i-=e*d,o-=n*d),(r=Math.sqrt(i*i+o*o))&&(i/=r,o/=r,d/=r),e*o<n*i&&(e=-e,n=-n,d=-d,l=-l),{translateX:s,translateY:t,rotate:Math.atan2(n,e)*Ha,skewX:Math.atan(d)*Ha,scaleX:l,scaleY:r}}var Ci;function Nm(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Ko:Fa(n.a,n.b,n.c,n.d,n.e,n.f)}function Cm(e){return e==null||(Ci||(Ci=document.createElementNS("http://www.w3.org/2000/svg","g")),Ci.setAttribute("transform",e),!(e=Ci.transform.baseVal.consolidate()))?Ko:(e=e.matrix,Fa(e.a,e.b,e.c,e.d,e.e,e.f))}function Va(e,n,i,o){function s(u){return u.length?u.pop()+" ":""}function t(u,b,c,m,h,v){if(u!==c||b!==m){var p=h.push("translate(",null,n,null,i);v.push({i:p-4,x:qe(u,c)},{i:p-2,x:qe(b,m)})}else(c||m)&&h.push("translate("+c+n+m+i)}function l(u,b,c,m){u!==b?(u-b>180?b+=360:b-u>180&&(u+=360),m.push({i:c.push(s(c)+"rotate(",null,o)-2,x:qe(u,b)})):b&&c.push(s(c)+"rotate("+b+o)}function r(u,b,c,m){u!==b?m.push({i:c.push(s(c)+"skewX(",null,o)-2,x:qe(u,b)}):b&&c.push(s(c)+"skewX("+b+o)}function d(u,b,c,m,h,v){if(u!==c||b!==m){var p=h.push(s(h)+"scale(",null,",",null,")");v.push({i:p-4,x:qe(u,c)},{i:p-2,x:qe(b,m)})}else(c!==1||m!==1)&&h.push(s(h)+"scale("+c+","+m+")")}return function(u,b){var c=[],m=[];return u=e(u),b=e(b),t(u.translateX,u.translateY,b.translateX,b.translateY,c,m),l(u.rotate,b.rotate,c,m),r(u.skewX,b.skewX,c,m),d(u.scaleX,u.scaleY,b.scaleX,b.scaleY,c,m),u=b=null,function(h){for(var v=-1,p=m.length,y;++v<p;)c[(y=m[v]).i]=y.x(h);return c.join("")}}}var Am=Va(Nm,"px, ","px)","deg)"),km=Va(Cm,", ",")",")"),Em=1e-12;function Ga(e){return((e=Math.exp(e))+1/e)/2}function Mm(e){return((e=Math.exp(e))-1/e)/2}function Tm(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ai=function e(n,i,o){function s(t,l){var r=t[0],d=t[1],u=t[2],b=l[0],c=l[1],m=l[2],h=b-r,v=c-d,p=h*h+v*v,y,g;if(p<Em)g=Math.log(m/u)/n,y=function(A){return[r+A*h,d+A*v,u*Math.exp(n*A*g)]};else{var S=Math.sqrt(p),f=(m*m-u*u+o*p)/(2*u*i*S),w=(m*m-u*u-o*p)/(2*m*i*S),C=Math.log(Math.sqrt(f*f+1)-f),N=Math.log(Math.sqrt(w*w+1)-w);g=(N-C)/n,y=function(A){var E=A*g,k=Ga(C),I=u/(i*S)*(k*Tm(n*E+C)-Mm(C));return[r+I*h,d+I*v,u*k/Ga(n*E+C)]}}return y.duration=g*1e3*n/Math.SQRT2,y}return s.rho=function(t){var l=Math.max(.001,+t),r=l*l,d=r*r;return e(l,r,d)},s}(Math.SQRT2,2,4);var Nn=0,jn=0,Wn=0,za=1e3,ki,Un,Ei=0,cn=0,Mi=0,qn=typeof performance=="object"&&performance.now?performance:Date,$a=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ho(){return cn||($a(Pm),cn=qn.now()+Mi)}function Pm(){cn=0}function Ti(){this._call=this._time=this._next=null}Ti.prototype=ja.prototype={constructor:Ti,restart:function(e,n,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?Ho():+i)+(n==null?0:+n),!this._next&&Un!==this&&(Un?Un._next=this:ki=this,Un=this),this._call=e,this._time=i,Fo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Fo())}};function ja(e,n,i){var o=new Ti;return o.restart(e,n,i),o}function Lm(){Ho(),++Nn;for(var e=ki,n;e;)(n=cn-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Nn}function Wa(){cn=(Ei=qn.now())+Mi,Nn=jn=0;try{Lm()}finally{Nn=0,Im(),cn=0}}function Bm(){var e=qn.now(),n=e-Ei;n>za&&(Mi-=n,Ei=e)}function Im(){for(var e,n=ki,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:ki=i);Un=e,Fo(o)}function Fo(e){if(!Nn){jn&&(jn=clearTimeout(jn));var n=e-cn;n>24?(e<1/0&&(jn=setTimeout(Wa,e-qn.now()-Mi)),Wn&&(Wn=clearInterval(Wn))):(Wn||(Ei=qn.now(),Wn=setInterval(Bm,za)),Nn=1,$a(Wa))}}function Ua(e,n,i){var o=new Ti;return n=n==null?0:+n,o.restart(s=>{o.stop(),e(s+n)},n,i),o}var Dm=vi("start","end","cancel","interrupt"),_m=[],qa=0,Ya=1,Vo=2,Pi=3,Ja=4,Go=5,Li=6;function Bi(e,n,i,o,s,t){var l=e.__transition;if(!l)e.__transition={};else if(i in l)return;Om(e,i,{name:n,index:o,group:s,on:Dm,tween:_m,time:t.time,delay:t.delay,duration:t.duration,ease:t.ease,timer:null,state:qa})}function zo(e,n){var i=Ve(e,n);if(i.state>qa)throw new Error("too late; already scheduled");return i}function Ye(e,n){var i=Ve(e,n);if(i.state>Pi)throw new Error("too late; already running");return i}function Ve(e,n){var i=e.__transition;if(!i||!(i=i[n]))throw new Error("transition not found");return i}function Om(e,n,i){var o=e.__transition,s;o[n]=i,i.timer=ja(t,0,i.time);function t(u){i.state=Ya,i.timer.restart(l,i.delay,i.time),i.delay<=u&&l(u-i.delay)}function l(u){var b,c,m,h;if(i.state!==Ya)return d();for(b in o)if(h=o[b],h.name===i.name){if(h.state===Pi)return Ua(l);h.state===Ja?(h.state=Li,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[b]):+b<n&&(h.state=Li,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[b])}if(Ua(function(){i.state===Pi&&(i.state=Ja,i.timer.restart(r,i.delay,i.time),r(u))}),i.state=Vo,i.on.call("start",e,e.__data__,i.index,i.group),i.state===Vo){for(i.state=Pi,s=new Array(m=i.tween.length),b=0,c=-1;b<m;++b)(h=i.tween[b].value.call(e,e.__data__,i.index,i.group))&&(s[++c]=h);s.length=c+1}}function r(u){for(var b=u<i.duration?i.ease.call(null,u/i.duration):(i.timer.restart(d),i.state=Go,1),c=-1,m=s.length;++c<m;)s[c].call(e,b);i.state===Go&&(i.on.call("end",e,e.__data__,i.index,i.group),d())}function d(){i.state=Li,i.timer.stop(),delete o[n];for(var u in o)return;delete e.__transition}}function Ii(e,n){var i=e.__transition,o,s,t=!0,l;if(i){n=n==null?null:n+"";for(l in i){if((o=i[l]).name!==n){t=!1;continue}s=o.state>Vo&&o.state<Go,o.state=Li,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete i[l]}t&&delete e.__transition}}function Km(e){return this.each(function(){Ii(this,e)})}function Hm(e,n){var i,o;return function(){var s=Ye(this,e),t=s.tween;if(t!==i){o=i=t;for(var l=0,r=o.length;l<r;++l)if(o[l].name===n){o=o.slice(),o.splice(l,1);break}}s.tween=o}}function Fm(e,n,i){var o,s;if(typeof i!="function")throw new Error;return function(){var t=Ye(this,e),l=t.tween;if(l!==o){s=(o=l).slice();for(var r={name:n,value:i},d=0,u=s.length;d<u;++d)if(s[d].name===n){s[d]=r;break}d===u&&s.push(r)}t.tween=s}}function Vm(e,n){var i=this._id;if(e+="",arguments.length<2){for(var o=Ve(this.node(),i).tween,s=0,t=o.length,l;s<t;++s)if((l=o[s]).name===e)return l.value;return null}return this.each((n==null?Hm:Fm)(i,e,n))}function $o(e,n,i){var o=e._id;return e.each(function(){var s=Ye(this,o);(s.value||(s.value={}))[n]=i.apply(this,arguments)}),function(s){return Ve(s,o).value[n]}}function Za(e,n){var i;return(typeof n=="number"?qe:n instanceof rn?Ni:(i=rn(n))?(n=i,Ni):Ka)(e,n)}function Gm(e){return function(){this.removeAttribute(e)}}function zm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function $m(e,n,i){var o,s=i+"",t;return function(){var l=this.getAttribute(e);return l===s?null:l===o?t:t=n(o=l,i)}}function jm(e,n,i){var o,s=i+"",t;return function(){var l=this.getAttributeNS(e.space,e.local);return l===s?null:l===o?t:t=n(o=l,i)}}function Wm(e,n,i){var o,s,t;return function(){var l,r=i(this),d;return r==null?void this.removeAttribute(e):(l=this.getAttribute(e),d=r+"",l===d?null:l===o&&d===s?t:(s=d,t=n(o=l,r)))}}function Um(e,n,i){var o,s,t;return function(){var l,r=i(this),d;return r==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),d=r+"",l===d?null:l===o&&d===s?t:(s=d,t=n(o=l,r)))}}function qm(e,n){var i=hi(e),o=i==="transform"?km:Za;return this.attrTween(e,typeof n=="function"?(i.local?Um:Wm)(i,o,$o(this,"attr."+e,n)):n==null?(i.local?zm:Gm)(i):(i.local?jm:$m)(i,o,n))}function Ym(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function Jm(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function Zm(e,n){var i,o;function s(){var t=n.apply(this,arguments);return t!==o&&(i=(o=t)&&Jm(e,t)),i}return s._value=n,s}function Xm(e,n){var i,o;function s(){var t=n.apply(this,arguments);return t!==o&&(i=(o=t)&&Ym(e,t)),i}return s._value=n,s}function Qm(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=hi(e);return this.tween(i,(o.local?Zm:Xm)(o,n))}function Rm(e,n){return function(){zo(this,e).delay=+n.apply(this,arguments)}}function ev(e,n){return n=+n,function(){zo(this,e).delay=n}}function nv(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Rm:ev)(n,e)):Ve(this.node(),n).delay}function iv(e,n){return function(){Ye(this,e).duration=+n.apply(this,arguments)}}function ov(e,n){return n=+n,function(){Ye(this,e).duration=n}}function sv(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?iv:ov)(n,e)):Ve(this.node(),n).duration}function av(e,n){if(typeof n!="function")throw new Error;return function(){Ye(this,e).ease=n}}function tv(e){var n=this._id;return arguments.length?this.each(av(n,e)):Ve(this.node(),n).ease}function lv(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;Ye(this,e).ease=i}}function rv(e){if(typeof e!="function")throw new Error;return this.each(lv(this._id,e))}function dv(e){typeof e!="function"&&(e=ma(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var t=n[s],l=t.length,r=o[s]=[],d,u=0;u<l;++u)(d=t[u])&&e.call(d,d.__data__,u,t)&&r.push(d);return new Ze(o,this._parents,this._name,this._id)}function uv(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,i=e._groups,o=n.length,s=i.length,t=Math.min(o,s),l=new Array(o),r=0;r<t;++r)for(var d=n[r],u=i[r],b=d.length,c=l[r]=new Array(b),m,h=0;h<b;++h)(m=d[h]||u[h])&&(c[h]=m);for(;r<o;++r)l[r]=n[r];return new Ze(l,this._parents,this._name,this._id)}function cv(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 bv(e,n,i){var o,s,t=cv(n)?zo:Ye;return function(){var l=t(this,e),r=l.on;r!==o&&(s=(o=r).copy()).on(n,i),l.on=s}}function mv(e,n){var i=this._id;return arguments.length<2?Ve(this.node(),i).on.on(e):this.each(bv(i,e,n))}function vv(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function fv(){return this.on("end.remove",vv(this._id))}function hv(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Eo(e));for(var o=this._groups,s=o.length,t=new Array(s),l=0;l<s;++l)for(var r=o[l],d=r.length,u=t[l]=new Array(d),b,c,m=0;m<d;++m)(b=r[m])&&(c=e.call(b,b.__data__,m,r))&&("__data__"in b&&(c.__data__=b.__data__),u[m]=c,Bi(u[m],n,i,m,u,Ve(b,i)));return new Ze(t,this._parents,n,i)}function pv(e){var n=this._name,i=this._id;typeof e!="function"&&(e=ba(e));for(var o=this._groups,s=o.length,t=[],l=[],r=0;r<s;++r)for(var d=o[r],u=d.length,b,c=0;c<u;++c)if(b=d[c]){for(var m=e.call(b,b.__data__,c,d),h,v=Ve(b,i),p=0,y=m.length;p<y;++p)(h=m[p])&&Bi(h,n,i,p,m,v);t.push(m),l.push(b)}return new Ze(t,l,n,i)}var gv=Hn.prototype.constructor;function yv(){return new gv(this._groups,this._parents)}function xv(e,n){var i,o,s;return function(){var t=xn(this,e),l=(this.style.removeProperty(e),xn(this,e));return t===l?null:t===i&&l===o?s:s=n(i=t,o=l)}}function Xa(e){return function(){this.style.removeProperty(e)}}function Sv(e,n,i){var o,s=i+"",t;return function(){var l=xn(this,e);return l===s?null:l===o?t:t=n(o=l,i)}}function wv(e,n,i){var o,s,t;return function(){var l=xn(this,e),r=i(this),d=r+"";return r==null&&(d=r=(this.style.removeProperty(e),xn(this,e))),l===d?null:l===o&&d===s?t:(s=d,t=n(o=l,r))}}function Nv(e,n){var i,o,s,t="style."+n,l="end."+t,r;return function(){var d=Ye(this,e),u=d.on,b=d.value[t]==null?r||(r=Xa(n)):void 0;(u!==i||s!==b)&&(o=(i=u).copy()).on(l,s=b),d.on=o}}function Cv(e,n,i){var o=(e+="")=="transform"?Am:Za;return n==null?this.styleTween(e,xv(e,o)).on("end.style."+e,Xa(e)):typeof n=="function"?this.styleTween(e,wv(e,o,$o(this,"style."+e,n))).each(Nv(this._id,e)):this.styleTween(e,Sv(e,o,n),i).on("end.style."+e,null)}function Av(e,n,i){return function(o){this.style.setProperty(e,n.call(this,o),i)}}function kv(e,n,i){var o,s;function t(){var l=n.apply(this,arguments);return l!==s&&(o=(s=l)&&Av(e,l,i)),o}return t._value=n,t}function Ev(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,kv(e,n,i==null?"":i))}function Mv(e){return function(){this.textContent=e}}function Tv(e){return function(){var n=e(this);this.textContent=n==null?"":n}}function Pv(e){return this.tween("text",typeof e=="function"?Tv($o(this,"text",e)):Mv(e==null?"":e+""))}function Lv(e){return function(n){this.textContent=e.call(this,n)}}function Bv(e){var n,i;function o(){var s=e.apply(this,arguments);return s!==i&&(n=(i=s)&&Lv(s)),n}return o._value=e,o}function Iv(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,Bv(e))}function Dv(){for(var e=this._name,n=this._id,i=Qa(),o=this._groups,s=o.length,t=0;t<s;++t)for(var l=o[t],r=l.length,d,u=0;u<r;++u)if(d=l[u]){var b=Ve(d,n);Bi(d,e,i,u,l,{time:b.time+b.delay+b.duration,delay:0,duration:b.duration,ease:b.ease})}return new Ze(o,this._parents,e,i)}function _v(){var e,n,i=this,o=i._id,s=i.size();return new Promise(function(t,l){var r={value:l},d={value:function(){--s===0&&t()}};i.each(function(){var u=Ye(this,o),b=u.on;b!==e&&(n=(e=b).copy(),n._.cancel.push(r),n._.interrupt.push(r),n._.end.push(d)),u.on=n}),s===0&&t()})}var Ov=0;function Ze(e,n,i,o){this._groups=e,this._parents=n,this._name=i,this._id=o}function Qa(){return++Ov}var Xe=Hn.prototype;Ze.prototype={constructor:Ze,select:hv,selectAll:pv,selectChild:Xe.selectChild,selectChildren:Xe.selectChildren,filter:dv,merge:uv,selection:yv,transition:Dv,call:Xe.call,nodes:Xe.nodes,node:Xe.node,size:Xe.size,empty:Xe.empty,each:Xe.each,on:mv,attr:qm,attrTween:Qm,style:Cv,styleTween:Ev,text:Pv,textTween:Iv,remove:fv,tween:Vm,delay:nv,duration:sv,ease:tv,easeVarying:rv,end:_v,[Symbol.iterator]:Xe[Symbol.iterator]};function Kv(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Hv={time:null,delay:0,duration:250,ease:Kv};function Fv(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 Vv(e){var n,i;e instanceof Ze?(n=e._id,e=e._name):(n=Qa(),(i=Hv).time=Ho(),e=e==null?null:e+"");for(var o=this._groups,s=o.length,t=0;t<s;++t)for(var l=o[t],r=l.length,d,u=0;u<r;++u)(d=l[u])&&Bi(d,e,n,u,l,i||Fv(d,n));return new Ze(o,this._parents,e,n)}Hn.prototype.interrupt=Km,Hn.prototype.transition=Vv;const Di=e=>()=>e;function Gv(e,{sourceEvent:n,target:i,transform:o,dispatch:s}){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:s}})}function Qe(e,n,i){this.k=e,this.x=n,this.y=i}Qe.prototype={constructor:Qe,scale:function(e){return e===1?this:new Qe(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new Qe(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 _i=new Qe(1,0,0);Ra.prototype=Qe.prototype;function Ra(e){for(;!e.__zoom;)if(!(e=e.parentNode))return _i;return e.__zoom}function jo(e){e.stopImmediatePropagation()}function Yn(e){e.preventDefault(),e.stopImmediatePropagation()}function zv(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function $v(){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 et(){return this.__zoom||_i}function jv(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Wv(){return navigator.maxTouchPoints||"ontouchstart"in this}function Uv(e,n,i){var o=e.invertX(n[0][0])-i[0][0],s=e.invertX(n[1][0])-i[1][0],t=e.invertY(n[0][1])-i[0][1],l=e.invertY(n[1][1])-i[1][1];return e.translate(s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s),l>t?(t+l)/2:Math.min(0,t)||Math.max(0,l))}function nt(){var e=zv,n=$v,i=Uv,o=jv,s=Wv,t=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],r=250,d=Ai,u=vi("start","zoom","end"),b,c,m,h=500,v=150,p=0,y=10;function g(T){T.property("__zoom",et).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",I).filter(s).on("touchstart.zoom",M).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(T,L,B,O){var _=T.selection?T.selection():T;_.property("__zoom",et),T!==_?C(T,L,B,O):_.interrupt().each(function(){N(this,arguments).event(O).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},g.scaleBy=function(T,L,B,O){g.scaleTo(T,function(){var _=this.__zoom.k,D=typeof L=="function"?L.apply(this,arguments):L;return _*D},B,O)},g.scaleTo=function(T,L,B,O){g.transform(T,function(){var _=n.apply(this,arguments),D=this.__zoom,$=B==null?w(_):typeof B=="function"?B.apply(this,arguments):B,U=D.invert($),V=typeof L=="function"?L.apply(this,arguments):L;return i(f(S(D,V),$,U),_,l)},B,O)},g.translateBy=function(T,L,B,O){g.transform(T,function(){return i(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof B=="function"?B.apply(this,arguments):B),n.apply(this,arguments),l)},null,O)},g.translateTo=function(T,L,B,O,_){g.transform(T,function(){var D=n.apply(this,arguments),$=this.__zoom,U=O==null?w(D):typeof O=="function"?O.apply(this,arguments):O;return i(_i.translate(U[0],U[1]).scale($.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof B=="function"?-B.apply(this,arguments):-B),D,l)},O,_)};function S(T,L){return L=Math.max(t[0],Math.min(t[1],L)),L===T.k?T:new Qe(L,T.x,T.y)}function f(T,L,B){var O=L[0]-B[0]*T.k,_=L[1]-B[1]*T.k;return O===T.x&&_===T.y?T:new Qe(T.k,O,_)}function w(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function C(T,L,B,O){T.on("start.zoom",function(){N(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(O).end()}).tween("zoom",function(){var _=this,D=arguments,$=N(_,D).event(O),U=n.apply(_,D),V=B==null?w(U):typeof B=="function"?B.apply(_,D):B,z=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),J=_.__zoom,ne=typeof L=="function"?L.apply(_,D):L,ie=d(J.invert(V).concat(z/J.k),ne.invert(V).concat(z/ne.k));return function(Q){if(Q===1)Q=ne;else{var F=ie(Q),Y=z/F[2];Q=new Qe(Y,V[0]-F[0]*Y,V[1]-F[1]*Y)}$.zoom(null,Q)}})}function N(T,L,B){return!B&&T.__zooming||new A(T,L)}function A(T,L){this.that=T,this.args=L,this.active=0,this.sourceEvent=null,this.extent=n.apply(T,L),this.taps=0}A.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,L){return this.mouse&&T!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var L=Oe(this.that).datum();u.call(T,this.that,new Gv(T,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),L)}};function E(T,...L){if(!e.apply(this,arguments))return;var B=N(this,L).event(T),O=this.__zoom,_=Math.max(t[0],Math.min(t[1],O.k*Math.pow(2,o.apply(this,arguments)))),D=He(T);if(B.wheel)(B.mouse[0][0]!==D[0]||B.mouse[0][1]!==D[1])&&(B.mouse[1]=O.invert(B.mouse[0]=D)),clearTimeout(B.wheel);else{if(O.k===_)return;B.mouse=[D,O.invert(D)],Ii(this),B.start()}Yn(T),B.wheel=setTimeout($,v),B.zoom("mouse",i(f(S(O,_),B.mouse[0],B.mouse[1]),B.extent,l));function $(){B.wheel=null,B.end()}}function k(T,...L){if(m||!e.apply(this,arguments))return;var B=T.currentTarget,O=N(this,L,!0).event(T),_=Oe(T.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",z,!0),D=He(T,B),$=T.clientX,U=T.clientY;Na(T.view),jo(T),O.mouse=[D,this.__zoom.invert(D)],Ii(this),O.start();function V(J){if(Yn(J),!O.moved){var ne=J.clientX-$,ie=J.clientY-U;O.moved=ne*ne+ie*ie>p}O.event(J).zoom("mouse",i(f(O.that.__zoom,O.mouse[0]=He(J,B),O.mouse[1]),O.extent,l))}function z(J){_.on("mousemove.zoom mouseup.zoom",null),Ca(J.view,O.moved),Yn(J),O.event(J).end()}}function I(T,...L){if(e.apply(this,arguments)){var B=this.__zoom,O=He(T.changedTouches?T.changedTouches[0]:T,this),_=B.invert(O),D=B.k*(T.shiftKey?.5:2),$=i(f(S(B,D),O,_),n.apply(this,L),l);Yn(T),r>0?Oe(this).transition().duration(r).call(C,$,O,T):Oe(this).call(g.transform,$,O,T)}}function M(T,...L){if(e.apply(this,arguments)){var B=T.touches,O=B.length,_=N(this,L,T.changedTouches.length===O).event(T),D,$,U,V;for(jo(T),$=0;$<O;++$)U=B[$],V=He(U,this),V=[V,this.__zoom.invert(V),U.identifier],_.touch0?!_.touch1&&_.touch0[2]!==V[2]&&(_.touch1=V,_.taps=0):(_.touch0=V,D=!0,_.taps=1+!!b);b&&(b=clearTimeout(b)),D&&(_.taps<2&&(c=V[0],b=setTimeout(function(){b=null},h)),Ii(this),_.start())}}function P(T,...L){if(this.__zooming){var B=N(this,L).event(T),O=T.changedTouches,_=O.length,D,$,U,V;for(Yn(T),D=0;D<_;++D)$=O[D],U=He($,this),B.touch0&&B.touch0[2]===$.identifier?B.touch0[0]=U:B.touch1&&B.touch1[2]===$.identifier&&(B.touch1[0]=U);if($=B.that.__zoom,B.touch1){var z=B.touch0[0],J=B.touch0[1],ne=B.touch1[0],ie=B.touch1[1],Q=(Q=ne[0]-z[0])*Q+(Q=ne[1]-z[1])*Q,F=(F=ie[0]-J[0])*F+(F=ie[1]-J[1])*F;$=S($,Math.sqrt(Q/F)),U=[(z[0]+ne[0])/2,(z[1]+ne[1])/2],V=[(J[0]+ie[0])/2,(J[1]+ie[1])/2]}else if(B.touch0)U=B.touch0[0],V=B.touch0[1];else return;B.zoom("touch",i(f($,U,V),B.extent,l))}}function H(T,...L){if(this.__zooming){var B=N(this,L).event(T),O=T.changedTouches,_=O.length,D,$;for(jo(T),m&&clearTimeout(m),m=setTimeout(function(){m=null},h),D=0;D<_;++D)$=O[D],B.touch0&&B.touch0[2]===$.identifier?delete B.touch0:B.touch1&&B.touch1[2]===$.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&&($=He($,this),Math.hypot(c[0]-$[0],c[1]-$[1])<y)){var U=Oe(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return g.wheelDelta=function(T){return arguments.length?(o=typeof T=="function"?T:Di(+T),g):o},g.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Di(!!T),g):e},g.touchable=function(T){return arguments.length?(s=typeof T=="function"?T:Di(!!T),g):s},g.extent=function(T){return arguments.length?(n=typeof T=="function"?T:Di([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),g):n},g.scaleExtent=function(T){return arguments.length?(t[0]=+T[0],t[1]=+T[1],g):[t[0],t[1]]},g.translateExtent=function(T){return arguments.length?(l[0][0]=+T[0][0],l[1][0]=+T[1][0],l[0][1]=+T[0][1],l[1][1]=+T[1][1],g):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},g.constrain=function(T){return arguments.length?(i=T,g):i},g.duration=function(T){return arguments.length?(r=+T,g):r},g.interpolate=function(T){return arguments.length?(d=T,g):d},g.on=function(){var T=u.on.apply(u,arguments);return T===u?g:T},g.clickDistance=function(T){return arguments.length?(p=(T=+T)*T,g):Math.sqrt(p)},g.tapDistance=function(T){return arguments.length?(y=+T,g):y},g}const Ke={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.`},Jn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],it=["Enter"," ","Escape"],ot={"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 Cn;(function(e){e.Strict="strict",e.Loose="loose"})(Cn||(Cn={}));var bn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(bn||(bn={}));var Zn;(function(e){e.Partial="partial",e.Full="full"})(Zn||(Zn={}));const st={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var on;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(on||(on={}));var An;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(An||(An={}));var ae;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ae||(ae={}));const at={[ae.Left]:ae.Right,[ae.Right]:ae.Left,[ae.Top]:ae.Bottom,[ae.Bottom]:ae.Top};function tt(e){return e===null?null:e?"valid":"invalid"}const lt=e=>"id"in e&&"source"in e&&"target"in e,qv=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Wo=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Xn=(e,n=[0,0])=>{var r;const{width:i,height:o}=Re(e),s=(r=e.origin)!=null?r:n,t=i*s[0],l=o*s[1];return{x:e.position.x-t,y:e.position.y-l}},Yv=(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,s)=>{const t=typeof s=="string";let l=!n.nodeLookup&&!t?s:void 0;n.nodeLookup&&(l=t?n.nodeLookup.get(s):Wo(s)?s:n.nodeLookup.get(s.id));const r=l?Hi(l,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Oi(o,r)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ki(i)},Qn=(e,n={})=>{let i={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(s=>{(n.filter===void 0||n.filter(s))&&(i=Oi(i,Hi(s)),o=!0)}),o?Ki(i):{x:0,y:0,width:0,height:0}},Uo=(e,n,[i,o,s]=[0,0,1],t=!1,l=!1)=>{var m,h,v,p,y,g;const r=(n.x-i)/s,d=(n.y-o)/s,u=n.width/s,b=n.height/s,c=[];for(const S of e.values()){const{measured:f,selectable:w=!0,hidden:C=!1}=S;if(l&&!w||C)continue;const N=(v=(h=(m=f.width)!=null?m:S.width)!=null?h:S.initialWidth)!=null?v:0,A=(g=(y=(p=f.height)!=null?p:S.height)!=null?y:S.initialHeight)!=null?g:0,{x:E,y:k}=S.internals.positionAbsolute,I=bt(r,d,u,b,E,k,N,A),M=N*A,P=t&&I>0;(!S.internals.handleBounds||P||I>=M||S.dragging)&&c.push(S)}return c},Jv=(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 Zv(e,n){const i=new Map,o=n!=null&&n.nodes?new Set(n.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((n==null?void 0:n.includeHiddenNodes)||!s.hidden)&&(!o||o.has(s.id))&&i.set(s.id,s)}),i}async function Xv({nodes:e,width:n,height:i,panZoom:o,minZoom:s,maxZoom:t},l){var b,c,m;if(e.size===0)return!0;const r=Zv(e,l),d=Qn(r),u=Jo(d,n,i,(b=l==null?void 0:l.minZoom)!=null?b:s,(c=l==null?void 0:l.maxZoom)!=null?c:t,(m=l==null?void 0:l.padding)!=null?m:.1);return await o.setViewport(u,{duration:l==null?void 0:l.duration,ease:l==null?void 0:l.ease,interpolate:l==null?void 0:l.interpolate}),!0}function rt({nodeId:e,nextPosition:n,nodeLookup:i,nodeOrigin:o=[0,0],nodeExtent:s,onError:t}){var h,v,p;const l=i.get(e),r=l.parentId?i.get(l.parentId):void 0,{x:d,y:u}=r?r.internals.positionAbsolute:{x:0,y:0},b=(h=l.origin)!=null?h:o;let c=l.extent||s;if(l.extent==="parent"&&!l.expandParent)if(!r)t==null||t("005",Ke.error005());else{const y=r.measured.width,g=r.measured.height;y&&g&&(c=[[d,u],[d+y,u+g]])}else r&&vn(l.extent)&&(c=[[l.extent[0][0]+d,l.extent[0][1]+u],[l.extent[1][0]+d,l.extent[1][1]+u]]);const m=vn(c)?mn(n,c,l.measured):n;return(l.measured.width===void 0||l.measured.height===void 0)&&(t==null||t("015",Ke.error015())),{position:{x:m.x-d+((v=l.measured.width)!=null?v:0)*b[0],y:m.y-u+((p=l.measured.height)!=null?p:0)*b[1]},positionAbsolute:m}}async function Qv({nodesToRemove:e=[],edgesToRemove:n=[],nodes:i,edges:o,onBeforeDelete:s}){const t=new Set(e.map(m=>m.id)),l=[];for(const m of i){if(m.deletable===!1)continue;const h=t.has(m.id),v=!h&&m.parentId&&l.find(p=>p.id===m.parentId);(h||v)&&l.push(m)}const r=new Set(n.map(m=>m.id)),d=o.filter(m=>m.deletable!==!1),b=Jv(l,d);for(const m of d)r.has(m.id)&&!b.find(v=>v.id===m.id)&&b.push(m);if(!s)return{edges:b,nodes:l};const c=await s({nodes:l,edges:b});return typeof c=="boolean"?c?{edges:b,nodes:l}:{edges:[],nodes:[]}:c}const kn=(e,n=0,i=1)=>Math.min(Math.max(e,n),i),mn=(e={x:0,y:0},n,i)=>{var o,s;return{x:kn(e.x,n[0][0],n[1][0]-((o=i==null?void 0:i.width)!=null?o:0)),y:kn(e.y,n[0][1],n[1][1]-((s=i==null?void 0:i.height)!=null?s:0))}};function dt(e,n,i){const{width:o,height:s}=Re(i),{x:t,y:l}=i.internals.positionAbsolute;return mn(e,[[t,l],[t+o,l+s]],n)}const ut=(e,n,i)=>e<n?kn(Math.abs(e-n),1,n)/n:e>i?-kn(Math.abs(e-i),1,n)/n:0,qo=(e,n,i=15,o=40)=>{const s=ut(e.x,o,n.width-o)*i,t=ut(e.y,o,n.height-o)*i;return[s,t]},Oi=(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)}),Yo=({x:e,y:n,width:i,height:o})=>({x:e,y:n,x2:e+i,y2:n+o}),Ki=({x:e,y:n,x2:i,y2:o})=>({x:e,y:n,width:i-e,height:o-n}),Rn=(e,n=[0,0])=>{var s,t,l,r,d,u,b,c;const{x:i,y:o}=Wo(e)?e.internals.positionAbsolute:Xn(e,n);return{x:i,y:o,width:(r=(l=(t=(s=e.measured)==null?void 0:s.width)!=null?t:e.width)!=null?l:e.initialWidth)!=null?r:0,height:(c=(b=(u=(d=e.measured)==null?void 0:d.height)!=null?u:e.height)!=null?b:e.initialHeight)!=null?c:0}},Hi=(e,n=[0,0])=>{var s,t,l,r,d,u,b,c;const{x:i,y:o}=Wo(e)?e.internals.positionAbsolute:Xn(e,n);return{x:i,y:o,x2:i+((r=(l=(t=(s=e.measured)==null?void 0:s.width)!=null?t:e.width)!=null?l:e.initialWidth)!=null?r:0),y2:o+((c=(b=(u=(d=e.measured)==null?void 0:d.height)!=null?u:e.height)!=null?b:e.initialHeight)!=null?c:0)}},ct=(e,n)=>Ki(Oi(Yo(e),Yo(n))),bt=(e,n,i,o,s,t,l,r)=>{const d=Math.max(0,Math.min(e+i,s+l)-Math.max(e,s)),u=Math.max(0,Math.min(n+o,t+r)-Math.max(n,t));return Math.ceil(d*u)},Fi=(e,n)=>bt(e.x,e.y,e.width,e.height,n.x,n.y,n.width,n.height),mt=e=>Ge(e.width)&&Ge(e.height)&&Ge(e.x)&&Ge(e.y),Ge=e=>!isNaN(e)&&isFinite(e),vt=(e,n)=>(i,o)=>{process.env.NODE_ENV==="development"&&console.warn(`[${e}]: ${o} Help: ${n}error#${i}`)},ei=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),ni=({x:e,y:n},[i,o,s],t=!1,l=[1,1])=>{const r={x:(e-i)/s,y:(n-o)/s};return t?ei(r,l):r},En=({x:e,y:n},[i,o,s])=>({x:e*s+i,y:n*s+o});function Mn(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 Rv(e,n,i){var o,s,t,l,r,d,u,b;if(typeof e=="string"||typeof e=="number"){const c=Mn(e,i),m=Mn(e,n);return{top:c,right:m,bottom:c,left:m,x:m*2,y:c*2}}if(typeof e=="object"){const c=Mn((s=(o=e.top)!=null?o:e.y)!=null?s:0,i),m=Mn((l=(t=e.bottom)!=null?t:e.y)!=null?l:0,i),h=Mn((d=(r=e.left)!=null?r:e.x)!=null?d:0,n),v=Mn((b=(u=e.right)!=null?u:e.x)!=null?b:0,n);return{top:c,right:v,bottom:m,left:h,x:h+v,y:c+m}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ef(e,n,i,o,s,t){const{x:l,y:r}=En(e,[n,i,o]),{x:d,y:u}=En({x:e.x+e.width,y:e.y+e.height},[n,i,o]),b=s-d,c=t-u;return{left:Math.floor(l),top:Math.floor(r),right:Math.floor(b),bottom:Math.floor(c)}}const Jo=(e,n,i,o,s,t)=>{const l=Rv(t,n,i),r=(n-l.x)/e.width,d=(i-l.y)/e.height,u=Math.min(r,d),b=kn(u,o,s),c=e.x+e.width/2,m=e.y+e.height/2,h=n/2-c*b,v=i/2-m*b,p=ef(e,h,v,b,n,i),y={left:Math.min(p.left-l.left,0),top:Math.min(p.top-l.top,0),right:Math.min(p.right-l.right,0),bottom:Math.min(p.bottom-l.bottom,0)};return{x:h-y.left+y.right,y:v-y.top+y.bottom,zoom:b}},ii=()=>{var e;return typeof navigator!="undefined"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function vn(e){return e!=null&&e!=="parent"}function Re(e){var n,i,o,s,t,l,r,d;return{width:(s=(o=(i=(n=e.measured)==null?void 0:n.width)!=null?i:e.width)!=null?o:e.initialWidth)!=null?s:0,height:(d=(r=(l=(t=e.measured)==null?void 0:t.height)!=null?l:e.height)!=null?r:e.initialHeight)!=null?d:0}}function ft(e){var n,i,o,s,t,l;return((o=(i=(n=e.measured)==null?void 0:n.width)!=null?i:e.width)!=null?o:e.initialWidth)!==void 0&&((l=(t=(s=e.measured)==null?void 0:s.height)!=null?t:e.height)!=null?l:e.initialHeight)!==void 0}function ht(e,n={width:0,height:0},i,o,s){var r,d;const t={...e},l=o.get(i);if(l){const u=l.origin||s;t.x+=l.internals.positionAbsolute.x-((r=n.width)!=null?r:0)*u[0],t.y+=l.internals.positionAbsolute.y-((d=n.height)!=null?d:0)*u[1]}return t}function pt(e,n){if(e.size!==n.size)return!1;for(const i of e)if(!n.has(i))return!1;return!0}function nf(){let e,n;return{promise:new Promise((o,s)=>{e=o,n=s}),resolve:e,reject:n}}function of(e){return{...ot,...e||{}}}function oi(e,{snapGrid:n=[0,0],snapToGrid:i=!1,transform:o,containerBounds:s}){var b,c;const{x:t,y:l}=ze(e),r=ni({x:t-((b=s==null?void 0:s.left)!=null?b:0),y:l-((c=s==null?void 0:s.top)!=null?c:0)},o),{x:d,y:u}=i?ei(r,n):r;return{xSnapped:d,ySnapped:u,...r}}const Zo=e=>({width:e.offsetWidth,height:e.offsetHeight}),gt=e=>{var n;return((n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},sf=["INPUT","SELECT","TEXTAREA"];function yt(e){var o,s;const n=((s=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:s[0])||e.target;return(n==null?void 0:n.nodeType)!==1?!1:sf.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const xt=e=>"clientX"in e,ze=(e,n)=>{var t,l,r,d;const i=xt(e),o=i?e.clientX:(t=e.touches)==null?void 0:t[0].clientX,s=i?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:o-((r=n==null?void 0:n.left)!=null?r:0),y:s-((d=n==null?void 0:n.top)!=null?d:0)}},St=(e,n,i,o,s)=>{const t=n.querySelectorAll(`.${e}`);return!t||!t.length?null:Array.from(t).map(l=>{const r=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:s,position:l.getAttribute("data-handlepos"),x:(r.left-i.left)/o,y:(r.top-i.top)/o,...Zo(l)}})};function wt({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:s,sourceControlY:t,targetControlX:l,targetControlY:r}){const d=e*.125+s*.375+l*.375+i*.125,u=n*.125+t*.375+r*.375+o*.125,b=Math.abs(d-e),c=Math.abs(u-n);return[d,u,b,c]}function Vi(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function Nt({pos:e,x1:n,y1:i,x2:o,y2:s,c:t}){switch(e){case ae.Left:return[n-Vi(n-o,t),i];case ae.Right:return[n+Vi(o-n,t),i];case ae.Top:return[n,i-Vi(i-s,t)];case ae.Bottom:return[n,i+Vi(s-i,t)]}}function Ct({sourceX:e,sourceY:n,sourcePosition:i=ae.Bottom,targetX:o,targetY:s,targetPosition:t=ae.Top,curvature:l=.25}){const[r,d]=Nt({pos:i,x1:e,y1:n,x2:o,y2:s,c:l}),[u,b]=Nt({pos:t,x1:o,y1:s,x2:e,y2:n,c:l}),[c,m,h,v]=wt({sourceX:e,sourceY:n,targetX:o,targetY:s,sourceControlX:r,sourceControlY:d,targetControlX:u,targetControlY:b});return[`M${e},${n} C${r},${d} ${u},${b} ${o},${s}`,c,m,h,v]}function At({sourceX:e,sourceY:n,targetX:i,targetY:o}){const s=Math.abs(i-e)/2,t=i<e?i+s:i-s,l=Math.abs(o-n)/2,r=o<n?o+l:o-l;return[t,r,s,l]}function af({sourceNode:e,targetNode:n,selected:i=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:t="basic"}){if(t==="manual")return o;const l=s&&i?o+1e3:o,r=Math.max(e.parentId||s&&e.selected?e.internals.z:0,n.parentId||s&&n.selected?n.internals.z:0);return l+r}function tf({sourceNode:e,targetNode:n,width:i,height:o,transform:s}){const t=Oi(Hi(e),Hi(n));t.x===t.x2&&(t.x2+=1),t.y===t.y2&&(t.y2+=1);const l={x:-s[0]/s[2],y:-s[1]/s[2],width:i/s[2],height:o/s[2]};return Fi(l,Ki(t))>0}const lf=({source:e,sourceHandle:n,target:i,targetHandle:o})=>`xy-edge__${e}${n||""}-${i}${o||""}`,rf=(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)),df=(e,n,i={})=>{var t;if(!e.source||!e.target)return(t=i.onError)==null||t.call(i,"006",Ke.error006()),n;const o=i.getEdgeId||lf;let s;return lt(e)?s={...e}:s={...e,id:o(e)},rf(s,n)?n:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,n.concat(s))};function kt({sourceX:e,sourceY:n,targetX:i,targetY:o}){const[s,t,l,r]=At({sourceX:e,sourceY:n,targetX:i,targetY:o});return[`M ${e},${n}L ${i},${o}`,s,t,l,r]}const Et={[ae.Left]:{x:-1,y:0},[ae.Right]:{x:1,y:0},[ae.Top]:{x:0,y:-1},[ae.Bottom]:{x:0,y:1}},uf=({source:e,sourcePosition:n=ae.Bottom,target:i})=>n===ae.Left||n===ae.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},Mt=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function cf({source:e,sourcePosition:n=ae.Bottom,target:i,targetPosition:o=ae.Top,center:s,offset:t,stepPosition:l}){var E,k,I,M;const r=Et[n],d=Et[o],u={x:e.x+r.x*t,y:e.y+r.y*t},b={x:i.x+d.x*t,y:i.y+d.y*t},c=uf({source:u,sourcePosition:n,target:b}),m=c.x!==0?"x":"y",h=c[m];let v=[],p,y;const g={x:0,y:0},S={x:0,y:0},[,,f,w]=At({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(r[m]*d[m]===-1){m==="x"?(p=(E=s.x)!=null?E:u.x+(b.x-u.x)*l,y=(k=s.y)!=null?k:(u.y+b.y)/2):(p=(I=s.x)!=null?I:(u.x+b.x)/2,y=(M=s.y)!=null?M:u.y+(b.y-u.y)*l);const P=[{x:p,y:u.y},{x:p,y:b.y}],H=[{x:u.x,y},{x:b.x,y}];r[m]===h?v=m==="x"?P:H:v=m==="x"?H:P}else{const P=[{x:u.x,y:b.y}],H=[{x:b.x,y:u.y}];if(m==="x"?v=r.x===h?H:P:v=r.y===h?P:H,n===o){const _=Math.abs(e[m]-i[m]);if(_<=t){const D=Math.min(t-1,t-_);r[m]===h?g[m]=(u[m]>e[m]?-1:1)*D:S[m]=(b[m]>i[m]?-1:1)*D}}if(n!==o){const _=m==="x"?"y":"x",D=r[m]===d[_],$=u[_]>b[_],U=u[_]<b[_];(r[m]===1&&(!D&&$||D&&U)||r[m]!==1&&(!D&&U||D&&$))&&(v=m==="x"?P:H)}const T={x:u.x+g.x,y:u.y+g.y},L={x:b.x+S.x,y:b.y+S.y},B=Math.max(Math.abs(T.x-v[0].x),Math.abs(L.x-v[0].x)),O=Math.max(Math.abs(T.y-v[0].y),Math.abs(L.y-v[0].y));B>=O?(p=(T.x+L.x)/2,y=v[0].y):(p=v[0].x,y=(T.y+L.y)/2)}const C={x:u.x+g.x,y:u.y+g.y},N={x:b.x+S.x,y:b.y+S.y};return[[e,...C.x!==v[0].x||C.y!==v[0].y?[C]:[],...v,...N.x!==v[v.length-1].x||N.y!==v[v.length-1].y?[N]:[],i],p,y,f,w]}function bf(e,n,i,o){const s=Math.min(Mt(e,n)/2,Mt(n,i)/2,o),{x:t,y:l}=n;if(e.x===t&&t===i.x||e.y===l&&l===i.y)return`L${t} ${l}`;if(e.y===l){const u=e.x<i.x?-1:1,b=e.y<i.y?1:-1;return`L ${t+s*u},${l}Q ${t},${l} ${t},${l+s*b}`}const r=e.x<i.x?1:-1,d=e.y<i.y?-1:1;return`L ${t},${l+s*d}Q ${t},${l} ${t+s*r},${l}`}function Xo({sourceX:e,sourceY:n,sourcePosition:i=ae.Bottom,targetX:o,targetY:s,targetPosition:t=ae.Top,borderRadius:l=5,centerX:r,centerY:d,offset:u=20,stepPosition:b=.5}){const[c,m,h,v,p]=cf({source:{x:e,y:n},sourcePosition:i,target:{x:o,y:s},targetPosition:t,center:{x:r,y:d},offset:u,stepPosition:b});let y=`M${c[0].x} ${c[0].y}`;for(let g=1;g<c.length-1;g++)y+=bf(c[g-1],c[g],c[g+1],l);return y+=`L${c[c.length-1].x} ${c[c.length-1].y}`,[y,m,h,v,p]}function Tt(e){var n;return e&&!!(e.internals.handleBounds||(n=e.handles)!=null&&n.length)&&!!(e.measured.width||e.width||e.initialWidth)}function mf(e){var c,m,h,v,p;const{sourceNode:n,targetNode:i}=e;if(!Tt(n)||!Tt(i))return null;const o=n.internals.handleBounds||Pt(n.handles),s=i.internals.handleBounds||Pt(i.handles),t=Lt((c=o==null?void 0:o.source)!=null?c:[],e.sourceHandle),l=Lt(e.connectionMode===Cn.Strict?(m=s==null?void 0:s.target)!=null?m:[]:((h=s==null?void 0:s.target)!=null?h:[]).concat((v=s==null?void 0:s.source)!=null?v:[]),e.targetHandle);if(!t||!l)return(p=e.onError)==null||p.call(e,"008",Ke.error008(t?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const r=(t==null?void 0:t.position)||ae.Bottom,d=(l==null?void 0:l.position)||ae.Top,u=fn(n,t,r),b=fn(i,l,d);return{sourceX:u.x,sourceY:u.y,targetX:b.x,targetY:b.y,sourcePosition:r,targetPosition:d}}function Pt(e){var o,s;if(!e)return null;const n=[],i=[];for(const t of e)t.width=(o=t.width)!=null?o:1,t.height=(s=t.height)!=null?s:1,t.type==="source"?n.push(t):t.type==="target"&&i.push(t);return{source:n,target:i}}function fn(e,n,i=ae.Left,o=!1){var u,b,c;const s=((u=n==null?void 0:n.x)!=null?u:0)+e.internals.positionAbsolute.x,t=((b=n==null?void 0:n.y)!=null?b:0)+e.internals.positionAbsolute.y,{width:l,height:r}=n!=null?n:Re(e);if(o)return{x:s+l/2,y:t+r/2};switch((c=n==null?void 0:n.position)!=null?c:i){case ae.Top:return{x:s+l/2,y:t};case ae.Right:return{x:s+l,y:t+r/2};case ae.Bottom:return{x:s+l/2,y:t+r};case ae.Left:return{x:s,y:t+r/2}}}function Lt(e,n){return e&&(n?e.find(i=>i.id===n):e[0])||null}function Qo(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function vf(e,{id:n,defaultColor:i,defaultMarkerStart:o,defaultMarkerEnd:s}){const t=new Set;return e.reduce((l,r)=>([r.markerStart||o,r.markerEnd||s].forEach(d=>{if(d&&typeof d=="object"){const u=Qo(d,n);t.has(u)||(l.push({id:u,color:d.color||i,...d}),t.add(u))}}),l),[]).sort((l,r)=>l.id.localeCompare(r.id))}const Bt=1e3,ff=10,Ro={nodeOrigin:[0,0],nodeExtent:Jn,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},hf={...Ro,checkEquality:!0};function es(e,n){const i={...e};for(const o in n)n[o]!==void 0&&(i[o]=n[o]);return i}function pf(e,n,i){const o=es(Ro,i);for(const s of e.values())if(s.parentId)os(s,e,n,o);else{const t=Xn(s,o.nodeOrigin),l=vn(s.extent)?s.extent:o.nodeExtent,r=mn(t,l,Re(s));s.internals.positionAbsolute=r}}function gf(e,n){var s,t;if(!e.handles)return e.measured?n==null?void 0:n.internals.handleBounds:void 0;const i=[],o=[];for(const l of e.handles){const r={id:l.id,width:(s=l.width)!=null?s:1,height:(t=l.height)!=null?t:1,nodeId:e.id,x:l.x,y:l.y,position:l.position,type:l.type};l.type==="source"?i.push(r):l.type==="target"&&o.push(r)}return{source:i,target:o}}function ns(e){return e==="manual"}function is(e,n,i,o={}){var b,c,m;const s=es(hf,o),t={i:0},l=new Map(n),r=s!=null&&s.elevateNodesOnSelect&&!ns(s.zIndexMode)?Bt:0;let d=e.length>0,u=!1;n.clear(),i.clear();for(const h of e){let v=l.get(h.id);if(s.checkEquality&&h===(v==null?void 0:v.internals.userNode))n.set(h.id,v);else{const p=Xn(h,s.nodeOrigin),y=vn(h.extent)?h.extent:s.nodeExtent,g=mn(p,y,Re(h));v={...s.defaults,...h,measured:{width:(b=h.measured)==null?void 0:b.width,height:(c=h.measured)==null?void 0:c.height},internals:{positionAbsolute:g,handleBounds:gf(h,v),z:It(h,r,s.zIndexMode),userNode:h}},n.set(h.id,v)}(v.measured===void 0||v.measured.width===void 0||v.measured.height===void 0)&&!v.hidden&&(d=!1),h.parentId&&os(v,n,i,o,t),u||(u=(m=h.selected)!=null?m:!1)}return{nodesInitialized:d,hasSelectedNodes:u}}function yf(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 os(e,n,i,o,s){const{elevateNodesOnSelect:t,nodeOrigin:l,nodeExtent:r,zIndexMode:d}=es(Ro,o),u=e.parentId,b=n.get(u);if(!b){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}yf(e,i),s&&!b.parentId&&b.internals.rootParentIndex===void 0&&d==="auto"&&(b.internals.rootParentIndex=++s.i,b.internals.z=b.internals.z+s.i*ff),s&&b.internals.rootParentIndex!==void 0&&(s.i=b.internals.rootParentIndex);const c=t&&!ns(d)?Bt:0,{x:m,y:h,z:v}=xf(e,b,l,r,c,d),{positionAbsolute:p}=e.internals,y=m!==p.x||h!==p.y;(y||v!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:m,y:h}:p,z:v}})}function It(e,n,i){const o=Ge(e.zIndex)?e.zIndex:0;return ns(i)?o:o+(e.selected?n:0)}function xf(e,n,i,o,s,t){var v;const{x:l,y:r}=n.internals.positionAbsolute,d=Re(e),u=Xn(e,i),b=vn(e.extent)?mn(u,e.extent,d):u;let c=mn({x:l+b.x,y:r+b.y},o,d);e.extent==="parent"&&(c=dt(c,d,n));const m=It(e,s,t),h=(v=n.internals.z)!=null?v:0;return{x:c.x,y:c.y,z:h>=m?h+1:m}}function ss(e,n,i,o=[0,0]){var l,r;const s=[],t=new Map;for(const d of e){const u=n.get(d.parentId);if(!u)continue;const b=(r=(l=t.get(d.parentId))==null?void 0:l.expandedRect)!=null?r:Rn(u),c=ct(b,d.rect);t.set(d.parentId,{expandedRect:c,parent:u})}return t.size>0&&t.forEach(({expandedRect:d,parent:u},b)=>{var w,C;const c=u.internals.positionAbsolute,m=Re(u),h=(w=u.origin)!=null?w:o,v=d.x<c.x?Math.round(Math.abs(c.x-d.x)):0,p=d.y<c.y?Math.round(Math.abs(c.y-d.y)):0,y=Math.max(m.width,Math.round(d.width)),g=Math.max(m.height,Math.round(d.height)),S=(y-m.width)*h[0],f=(g-m.height)*h[1];(v>0||p>0||S||f)&&(s.push({id:b,type:"position",position:{x:u.position.x-v+S,y:u.position.y-p+f}}),(C=i.get(b))==null||C.forEach(N=>{e.some(A=>A.id===N.id)||s.push({id:N.id,type:"position",position:{x:N.position.x+v,y:N.position.y+p}})})),(m.width<d.width||m.height<d.height||v||p)&&s.push({id:b,type:"dimensions",setAttributes:!0,dimensions:{width:y+(v?h[0]*v-S:0),height:g+(p?h[1]*p-f:0)}})}),s}function Sf(e,n,i,o,s,t,l){const r=o==null?void 0:o.querySelector(".xyflow__viewport");let d=!1;if(!r)return{changes:[],updatedInternals:d};const u=[],b=window.getComputedStyle(r),{m22:c}=new window.DOMMatrixReadOnly(b.transform),m=[];for(const h of e.values()){const v=n.get(h.id);if(!v)continue;if(v.hidden){n.set(v.id,{...v,internals:{...v.internals,handleBounds:void 0}}),d=!0;continue}const p=Zo(h.nodeElement),y=v.measured.width!==p.width||v.measured.height!==p.height;if(!!(p.width&&p.height&&(y||!v.internals.handleBounds||h.force))){const S=h.nodeElement.getBoundingClientRect(),f=vn(v.extent)?v.extent:t;let{positionAbsolute:w}=v.internals;v.parentId&&v.extent==="parent"?w=dt(w,p,n.get(v.parentId)):f&&(w=mn(w,f,p));const C={...v,measured:p,internals:{...v.internals,positionAbsolute:w,handleBounds:{source:St("source",h.nodeElement,S,c,v.id),target:St("target",h.nodeElement,S,c,v.id)}}};n.set(v.id,C),v.parentId&&os(C,n,i,{nodeOrigin:s,zIndexMode:l}),d=!0,y&&(u.push({id:v.id,type:"dimensions",dimensions:p}),v.expandParent&&v.parentId&&m.push({id:v.id,parentId:v.parentId,rect:Rn(C,s)}))}}if(m.length>0){const h=ss(m,n,i,s);u.push(...h)}return{changes:u,updatedInternals:d}}async function wf({delta:e,panZoom:n,transform:i,translateExtent:o,width:s,height:t}){if(!n||!e.x&&!e.y)return!1;const l=await n.setViewportConstrained({x:i[0]+e.x,y:i[1]+e.y,zoom:i[2]},[[0,0],[s,t]],o);return!!l&&(l.x!==i[0]||l.y!==i[1]||l.k!==i[2])}function Dt(e,n,i,o,s,t){let l=s;const r=o.get(l)||new Map;o.set(l,r.set(i,n)),l=`${s}-${e}`;const d=o.get(l)||new Map;if(o.set(l,d.set(i,n)),t){l=`${s}-${e}-${t}`;const u=o.get(l)||new Map;o.set(l,u.set(i,n))}}function _t(e,n,i){e.clear(),n.clear();for(const o of i){const{source:s,target:t,sourceHandle:l=null,targetHandle:r=null}=o,d={edgeId:o.id,source:s,target:t,sourceHandle:l,targetHandle:r},u=`${s}-${l}--${t}-${r}`,b=`${t}-${r}--${s}-${l}`;Dt("source",d,b,e,s,l),Dt("target",d,u,e,t,r),n.set(o.id,o)}}function Ot(e,n){if(!e.parentId)return!1;const i=n.get(e.parentId);return i?i.selected?!0:Ot(i,n):!1}function Kt(e,n,i){var s;let o=e;do{if((s=o==null?void 0:o.matches)!=null&&s.call(o,n))return!0;if(o===i)return!1;o=o==null?void 0:o.parentElement}while(o);return!1}function Nf(e,n,i,o){var t,l;const s=new Map;for(const[r,d]of e)if((d.selected||d.id===o)&&(!d.parentId||!Ot(d,e))&&(d.draggable||n&&typeof d.draggable=="undefined")){const u=e.get(r);u&&s.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:(t=u.measured.width)!=null?t:0,height:(l=u.measured.height)!=null?l:0}})}return s}function as({nodeId:e,dragItems:n,nodeLookup:i,dragging:o=!0}){var l,r,d;const s=[];for(const[u,b]of n){const c=(l=i.get(u))==null?void 0:l.internals.userNode;c&&s.push({...c,position:b.position,dragging:o})}if(!e)return[s[0],s];const t=(r=i.get(e))==null?void 0:r.internals.userNode;return[t?{...t,position:((d=n.get(e))==null?void 0:d.position)||t.position,dragging:o}:s[0],s]}function Cf({dragItems:e,snapGrid:n,x:i,y:o}){const s=e.values().next().value;if(!s)return null;const t={x:i-s.distance.x,y:o-s.distance.y},l=ei(t,n);return{x:l.x-t.x,y:l.y-t.y}}function Af({onNodeMouseDown:e,getStoreItems:n,onDragStart:i,onDrag:o,onDragStop:s}){let t={x:null,y:null},l=0,r=new Map,d=!1,u={x:0,y:0},b=null,c=!1,m=null,h=!1,v=!1,p=null;function y({noDragClassName:S,handleSelector:f,domNode:w,isSelectable:C,nodeId:N,nodeClickDistance:A=0}){m=Oe(w);function E({x:P,y:H}){const{nodeLookup:T,nodeExtent:L,snapGrid:B,snapToGrid:O,nodeOrigin:_,onNodeDrag:D,onSelectionDrag:$,onError:U,updateNodePositions:V}=n();t={x:P,y:H};let z=!1;const J=r.size>1,ne=J&&L?Yo(Qn(r)):null,ie=J&&O?Cf({dragItems:r,snapGrid:B,x:P,y:H}):null;for(const[Q,F]of r){if(!T.has(Q))continue;let Y={x:P-F.distance.x,y:H-F.distance.y};O&&(Y=ie?{x:Math.round(Y.x+ie.x),y:Math.round(Y.y+ie.y)}:ei(Y,B));let oe=null;if(J&&L&&!F.extent&&ne){const{positionAbsolute:W}=F.internals,G=W.x-ne.x+L[0][0],j=W.x+F.measured.width-ne.x2+L[1][0],ee=W.y-ne.y+L[0][1],X=W.y+F.measured.height-ne.y2+L[1][1];oe=[[G,ee],[j,X]]}const{position:K,positionAbsolute:q}=rt({nodeId:Q,nextPosition:Y,nodeLookup:T,nodeExtent:oe||L,nodeOrigin:_,onError:U});z=z||F.position.x!==K.x||F.position.y!==K.y,F.position=K,F.internals.positionAbsolute=q}if(v=v||z,!!z&&(V(r,!0),p&&(o||D||!N&&$))){const[Q,F]=as({nodeId:N,dragItems:r,nodeLookup:T});o==null||o(p,r,Q,F),D==null||D(p,Q,F),N||$==null||$(p,F)}}async function k(){var _,D;if(!b)return;const{transform:P,panBy:H,autoPanSpeed:T,autoPanOnNodeDrag:L}=n();if(!L){d=!1,cancelAnimationFrame(l);return}const[B,O]=qo(u,b,T);(B!==0||O!==0)&&(t.x=((_=t.x)!=null?_:0)-B/P[2],t.y=((D=t.y)!=null?D:0)-O/P[2],await H({x:B,y:O})&&E(t)),l=requestAnimationFrame(k)}function I(P){var J;const{nodeLookup:H,multiSelectionActive:T,nodesDraggable:L,transform:B,snapGrid:O,snapToGrid:_,selectNodesOnDrag:D,onNodeDragStart:$,onSelectionDragStart:U,unselectNodesAndEdges:V}=n();c=!0,(!D||!C)&&!T&&N&&((J=H.get(N))!=null&&J.selected||V()),C&&D&&N&&(e==null||e(N));const z=oi(P.sourceEvent,{transform:B,snapGrid:O,snapToGrid:_,containerBounds:b});if(t=z,r=Nf(H,L,z,N),r.size>0&&(i||$||!N&&U)){const[ne,ie]=as({nodeId:N,dragItems:r,nodeLookup:H});i==null||i(P.sourceEvent,r,ne,ie),$==null||$(P.sourceEvent,ne,ie),N||U==null||U(P.sourceEvent,ie)}}const M=Aa().clickDistance(A).on("start",P=>{const{domNode:H,nodeDragThreshold:T,transform:L,snapGrid:B,snapToGrid:O}=n();b=(H==null?void 0:H.getBoundingClientRect())||null,h=!1,v=!1,p=P.sourceEvent,T===0&&I(P),t=oi(P.sourceEvent,{transform:L,snapGrid:B,snapToGrid:O,containerBounds:b}),u=ze(P.sourceEvent,b)}).on("drag",P=>{const{autoPanOnNodeDrag:H,transform:T,snapGrid:L,snapToGrid:B,nodeDragThreshold:O,nodeLookup:_}=n(),D=oi(P.sourceEvent,{transform:T,snapGrid:L,snapToGrid:B,containerBounds:b});if(p=P.sourceEvent,(P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1||N&&!_.has(N))&&(h=!0),!h){if(!d&&H&&c&&(d=!0,k()),!c){const $=ze(P.sourceEvent,b),U=$.x-u.x,V=$.y-u.y;Math.sqrt(U*U+V*V)>O&&I(P)}(t.x!==D.xSnapped||t.y!==D.ySnapped)&&r&&c&&(u=ze(P.sourceEvent,b),E(D))}}).on("end",P=>{if(!c||h){h&&r.size>0&&n().updateNodePositions(r,!1);return}if(d=!1,c=!1,cancelAnimationFrame(l),r.size>0){const{nodeLookup:H,updateNodePositions:T,onNodeDragStop:L,onSelectionDragStop:B}=n();if(v&&(T(r,!1),v=!1),s||L||!N&&B){const[O,_]=as({nodeId:N,dragItems:r,nodeLookup:H,dragging:!1});s==null||s(P.sourceEvent,r,O,_),L==null||L(P.sourceEvent,O,_),N||B==null||B(P.sourceEvent,_)}}}).filter(P=>{const H=P.target;return!P.button&&(!S||!Kt(H,`.${S}`,w))&&(!f||Kt(H,f,w))});m.call(M)}function g(){m==null||m.on(".drag",null)}return{update:y,destroy:g}}function kf(e,n,i){const o=[],s={x:e.x-i,y:e.y-i,width:i*2,height:i*2};for(const t of n.values())Fi(s,Rn(t))>0&&o.push(t);return o}const Ef=250;function Mf(e,n,i,o){var r,d,u,b,c;let s=[],t=1/0;const l=kf(e,i,n+Ef);for(const m of l){const h=[...(d=(r=m.internals.handleBounds)==null?void 0:r.source)!=null?d:[],...(b=(u=m.internals.handleBounds)==null?void 0:u.target)!=null?b:[]];for(const v of h){if(o.nodeId===v.nodeId&&o.type===v.type&&o.id===v.id)continue;const{x:p,y}=fn(m,v,v.position,!0),g=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(y-e.y,2));g>n||(g<t?(s=[{...v,x:p,y}],t=g):g===t&&s.push({...v,x:p,y}))}}if(!s.length)return null;if(s.length>1){const m=o.type==="source"?"target":"source";return(c=s.find(h=>h.type===m))!=null?c:s[0]}return s[0]}function Ht(e,n,i,o,s,t=!1){var u,b,c,m,h,v;const l=o.get(e);if(!l)return null;const r=s==="strict"?(u=l.internals.handleBounds)==null?void 0:u[n]:[...(c=(b=l.internals.handleBounds)==null?void 0:b.source)!=null?c:[],...(h=(m=l.internals.handleBounds)==null?void 0:m.target)!=null?h:[]],d=(v=i?r==null?void 0:r.find(p=>p.id===i):r==null?void 0:r[0])!=null?v:null;return d&&t?{...d,...fn(l,d,d.position,!0)}:d}function Ft(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function Tf(e,n){let i=null;return n?i=!0:e&&!n&&(i=!1),i}const Vt=()=>!0;function Pf(e,{connectionMode:n,connectionRadius:i,handleId:o,nodeId:s,edgeUpdaterType:t,isTarget:l,domNode:r,nodeLookup:d,lib:u,autoPanOnConnect:b,flowId:c,panBy:m,cancelConnection:h,onConnectStart:v,onConnect:p,onConnectEnd:y,isValidConnection:g=Vt,onReconnectEnd:S,updateConnection:f,getTransform:w,getFromHandle:C,autoPanSpeed:N,dragThreshold:A=1,handleDomNode:E}){const k=gt(e.target);let I=0,M;const{x:P,y:H}=ze(e),T=Ft(t,E),L=r==null?void 0:r.getBoundingClientRect();let B=!1;if(!L||!T)return;const O=Ht(s,T,o,d,n);if(!O)return;let _=ze(e,L),D=!1,$=null,U=!1,V=null;function z(){if(!b||!L)return;const[K,q]=qo(_,L,N);m({x:K,y:q}),I=requestAnimationFrame(z)}const J={...O,nodeId:s,type:T,position:O.position},ne=d.get(s);let Q={inProgress:!0,isValid:null,from:fn(ne,J,ae.Left,!0),fromHandle:J,fromPosition:J.position,fromNode:ne,to:_,toHandle:null,toPosition:at[J.position],toNode:null,pointer:_};function F(){B=!0,f(Q),v==null||v(e,{nodeId:s,handleId:o,handleType:T})}A===0&&F();function Y(K){if(!B){const{x:X,y:Z}=ze(K),se=X-P,le=Z-H;if(!(se*se+le*le>A*A))return;F()}if(!C()||!J){oe(K);return}const q=w();_=ze(K,L),M=Mf(ni(_,q,!1,[1,1]),i,d,J),D||(z(),D=!0);const W=Gt(K,{handle:M,connectionMode:n,fromNodeId:s,fromHandleId:o,fromType:l?"target":"source",isValidConnection:g,doc:k,lib:u,flowId:c,nodeLookup:d});V=W.handleDomNode,$=W.connection,U=Tf(!!M,W.isValid);const G=d.get(s),j=G?fn(G,J,ae.Left,!0):Q.from,ee={...Q,from:j,isValid:U,to:W.toHandle&&U?En({x:W.toHandle.x,y:W.toHandle.y},q):_,toHandle:W.toHandle,toPosition:U&&W.toHandle?W.toHandle.position:at[J.position],toNode:W.toHandle?d.get(W.toHandle.nodeId):null,pointer:_};f(ee),Q=ee}function oe(K){if(!("touches"in K&&K.touches.length>0)){if(B){(M||V)&&$&&U&&(p==null||p($));const{inProgress:q,...W}=Q,G={...W,toPosition:Q.toHandle?Q.toPosition:null};y==null||y(K,G),t&&(S==null||S(K,G))}h(),cancelAnimationFrame(I),D=!1,U=!1,$=null,V=null,k.removeEventListener("mousemove",Y),k.removeEventListener("mouseup",oe),k.removeEventListener("touchmove",Y),k.removeEventListener("touchend",oe)}}k.addEventListener("mousemove",Y),k.addEventListener("mouseup",oe),k.addEventListener("touchmove",Y),k.addEventListener("touchend",oe)}function Gt(e,{handle:n,connectionMode:i,fromNodeId:o,fromHandleId:s,fromType:t,doc:l,lib:r,flowId:d,isValidConnection:u=Vt,nodeLookup:b}){const c=t==="target",m=n?l.querySelector(`.${r}-flow__handle[data-id="${d}-${n==null?void 0:n.nodeId}-${n==null?void 0:n.id}-${n==null?void 0:n.type}"]`):null,{x:h,y:v}=ze(e),p=l.elementFromPoint(h,v),y=p!=null&&p.classList.contains(`${r}-flow__handle`)?p:m,g={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const S=Ft(void 0,y),f=y.getAttribute("data-nodeid"),w=y.getAttribute("data-handleid"),C=y.classList.contains("connectable"),N=y.classList.contains("connectableend");if(!f||!S)return g;const A={source:c?f:o,sourceHandle:c?w:s,target:c?o:f,targetHandle:c?s:w};g.connection=A;const k=C&&N&&(i===Cn.Strict?c&&S==="source"||!c&&S==="target":f!==o||w!==s);g.isValid=k&&u(A),g.toHandle=Ht(f,S,w,b,i,!0)}return g}const ts={onPointerDown:Pf,isValid:Gt};function Lf({domNode:e,panZoom:n,getTransform:i,getViewScale:o}){const s=Oe(e);function t({translateExtent:r,width:d,height:u,zoomStep:b=1,pannable:c=!0,zoomable:m=!0,inversePan:h=!1}){const v=f=>{if(f.sourceEvent.type!=="wheel"||!n)return;const w=i(),C=f.sourceEvent.ctrlKey&&ii()?10:1,N=-f.sourceEvent.deltaY*(f.sourceEvent.deltaMode===1?.05:f.sourceEvent.deltaMode?1:.002)*b,A=w[2]*Math.pow(2,N*C);n.scaleTo(A)};let p=[0,0];const y=f=>{var w,C;(f.sourceEvent.type==="mousedown"||f.sourceEvent.type==="touchstart")&&(p=[(w=f.sourceEvent.clientX)!=null?w:f.sourceEvent.touches[0].clientX,(C=f.sourceEvent.clientY)!=null?C:f.sourceEvent.touches[0].clientY])},g=f=>{var I,M;const w=i();if(f.sourceEvent.type!=="mousemove"&&f.sourceEvent.type!=="touchmove"||!n)return;const C=[(I=f.sourceEvent.clientX)!=null?I:f.sourceEvent.touches[0].clientX,(M=f.sourceEvent.clientY)!=null?M:f.sourceEvent.touches[0].clientY],N=[C[0]-p[0],C[1]-p[1]];p=C;const A=o()*Math.max(w[2],Math.log(w[2]))*(h?-1:1),E={x:w[0]-N[0]*A,y:w[1]-N[1]*A},k=[[0,0],[d,u]];n.setViewportConstrained({x:E.x,y:E.y,zoom:w[2]},k,r)},S=nt().on("start",y).on("zoom",c?g:null).on("zoom.wheel",m?v:null);s.call(S,{})}function l(){s.on("zoom",null)}return{update:t,destroy:l,pointer:He}}const Gi=e=>({x:e.x,y:e.y,zoom:e.k}),ls=({x:e,y:n,zoom:i})=>_i.translate(e,n).scale(i),Tn=(e,n)=>e.target.closest(`.${n}`),zt=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Bf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,rs=(e,n=0,i=Bf,o=()=>{})=>{const s=typeof n=="number"&&n>0;return s||o(),s?e.transition().duration(n).ease(i).on("end",o):e},$t=e=>{const n=e.ctrlKey&&ii()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function If({zoomPanValues:e,noWheelClassName:n,d3Selection:i,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:t,zoomOnPinch:l,onPanZoomStart:r,onPanZoom:d,onPanZoomEnd:u}){return b=>{if(Tn(b,n))return b.ctrlKey&&b.preventDefault(),!1;b.preventDefault(),b.stopImmediatePropagation();const c=i.property("__zoom").k||1;if(b.ctrlKey&&l){const y=He(b),g=$t(b),S=c*Math.pow(2,g);o.scaleTo(i,S,y,b);return}const m=b.deltaMode===1?20:1;let h=s===bn.Vertical?0:b.deltaX*m,v=s===bn.Horizontal?0:b.deltaY*m;!ii()&&b.shiftKey&&s!==bn.Vertical&&(h=b.deltaY*m,v=0),o.translateBy(i,-(h/c)*t,-(v/c)*t,{internal:!0});const p=Gi(i.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d==null||d(b,p),e.panScrollTimeout=setTimeout(()=>{u==null||u(b,p),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,r==null||r(b,p))}}function Df({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:i}){return function(o,s){const t=o.type==="wheel",l=!n&&t&&!o.ctrlKey,r=Tn(o,e);if(o.ctrlKey&&t&&r&&o.preventDefault(),l||r)return null;o.preventDefault(),i.call(this,o,s)}}function _f({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:i}){return o=>{var t,l,r;if((t=o.sourceEvent)!=null&&t.internal)return;const s=Gi(o.transform);e.mouseButton=((l=o.sourceEvent)==null?void 0:l.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((r=o.sourceEvent)==null?void 0:r.type)==="mousedown"&&n(!0),i&&(i==null||i(o.sourceEvent,s))}}function Of({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:i,onTransformChange:o,onPanZoom:s}){return t=>{var l,r,d;e.usedRightMouseButton=!!(i&&zt(n,(l=e.mouseButton)!=null?l:0)),(r=t.sourceEvent)!=null&&r.sync||o([t.transform.x,t.transform.y,t.transform.k]),s&&!((d=t.sourceEvent)!=null&&d.internal)&&(s==null||s(t.sourceEvent,Gi(t.transform)))}}function Kf({zoomPanValues:e,panOnDrag:n,panOnScroll:i,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:t}){return l=>{var r,d;if(!((r=l.sourceEvent)!=null&&r.internal)&&(e.isZoomingOrPanning=!1,t&&zt(n,(d=e.mouseButton)!=null?d:0)&&!e.usedRightMouseButton&&l.sourceEvent&&t(l.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const u=Gi(l.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(l.sourceEvent,u)},i?150:0)}}}function Hf({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:i,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:t,userSelectionActive:l,noWheelClassName:r,noPanClassName:d,lib:u,connectionInProgress:b}){return c=>{var y;const m=e||n,h=i&&c.ctrlKey,v=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(Tn(c,`${u}-flow__node`)||Tn(c,`${u}-flow__edge`)))return!0;if(!o&&!m&&!s&&!t&&!i||l||b&&!v||Tn(c,r)&&v||Tn(c,d)&&(!v||s&&v&&!e)||!i&&c.ctrlKey&&v)return!1;if(!i&&c.type==="touchstart"&&((y=c.touches)==null?void 0:y.length)>1)return c.preventDefault(),!1;if(!m&&!s&&!h&&v||!o&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(o)&&!o.includes(c.button)&&c.type==="mousedown")return!1;const p=Array.isArray(o)&&o.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||v)&&p}}function Ff({domNode:e,minZoom:n,maxZoom:i,translateExtent:o,viewport:s,onPanZoom:t,onPanZoomStart:l,onPanZoomEnd:r,onDraggingChange:d}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},b=e.getBoundingClientRect(),c=nt().scaleExtent([n,i]).translateExtent(o),m=Oe(e).call(c);S({x:s.x,y:s.y,zoom:kn(s.zoom,n,i)},[[0,0],[b.width,b.height]],o);const h=m.on("wheel.zoom"),v=m.on("dblclick.zoom");c.wheelDelta($t);async function p(M,P){return m?new Promise(H=>{c==null||c.interpolate((P==null?void 0:P.interpolate)==="linear"?$n:Ai).transform(rs(m,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),M)}):!1}function y({noWheelClassName:M,noPanClassName:P,onPaneContextMenu:H,userSelectionActive:T,panOnScroll:L,panOnDrag:B,panOnScrollMode:O,panOnScrollSpeed:_,preventScrolling:D,zoomOnPinch:$,zoomOnScroll:U,zoomOnDoubleClick:V,zoomActivationKeyPressed:z,lib:J,onTransformChange:ne,connectionInProgress:ie,paneClickDistance:Q,selectionOnDrag:F}){T&&!u.isZoomingOrPanning&&g();const Y=L&&!z&&!T;c.clickDistance(F?1/0:!Ge(Q)||Q<0?0:Q);const oe=Y?If({zoomPanValues:u,noWheelClassName:M,d3Selection:m,d3Zoom:c,panOnScrollMode:O,panOnScrollSpeed:_,zoomOnPinch:$,onPanZoomStart:l,onPanZoom:t,onPanZoomEnd:r}):Df({noWheelClassName:M,preventScrolling:D,d3ZoomHandler:h});m.on("wheel.zoom",oe,{passive:!1});const K=_f({zoomPanValues:u,onDraggingChange:d,onPanZoomStart:l});c.on("start",K);const q=Of({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!H,onPanZoom:t,onTransformChange:ne});c.on("zoom",q);const W=Kf({zoomPanValues:u,panOnDrag:B,panOnScroll:L,onPaneContextMenu:H,onPanZoomEnd:r,onDraggingChange:d});c.on("end",W);const G=Hf({zoomActivationKeyPressed:z,panOnDrag:B,zoomOnScroll:U,panOnScroll:L,zoomOnDoubleClick:V,zoomOnPinch:$,userSelectionActive:T,noPanClassName:P,noWheelClassName:M,lib:J,connectionInProgress:ie});c.filter(G),V?m.on("dblclick.zoom",v):m.on("dblclick.zoom",null)}function g(){c.on("zoom",null)}async function S(M,P,H){const T=ls(M),L=c==null?void 0:c.constrain()(T,P,H);return L&&await p(L),L}async function f(M,P){const H=ls(M);return await p(H,P),H}function w(M){if(m){const P=ls(M),H=m.property("__zoom");(H.k!==M.zoom||H.x!==M.x||H.y!==M.y)&&(c==null||c.transform(m,P,null,{sync:!0}))}}function C(){const M=m?Ra(m.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}async function N(M,P){return m?new Promise(H=>{c==null||c.interpolate((P==null?void 0:P.interpolate)==="linear"?$n:Ai).scaleTo(rs(m,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),M)}):!1}async function A(M,P){return m?new Promise(H=>{c==null||c.interpolate((P==null?void 0:P.interpolate)==="linear"?$n:Ai).scaleBy(rs(m,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),M)}):!1}function E(M){c==null||c.scaleExtent(M)}function k(M){c==null||c.translateExtent(M)}function I(M){const P=!Ge(M)||M<0?0:M;c==null||c.clickDistance(P)}return{update:y,destroy:g,setViewport:f,setViewportConstrained:S,getViewport:C,scaleTo:N,scaleBy:A,setScaleExtent:E,setTranslateExtent:k,syncViewport:w,setClickDistance:I}}var Pn;(function(e){e.Line="line",e.Handle="handle"})(Pn||(Pn={}));function Vf({width:e,prevWidth:n,height:i,prevHeight:o,affectsX:s,affectsY:t}){const l=e-n,r=i-o,d=[l>0?1:l<0?-1:0,r>0?1:r<0?-1:0];return l&&s&&(d[0]=d[0]*-1),r&&t&&(d[1]=d[1]*-1),d}function jt(e){const n=e.includes("right")||e.includes("left"),i=e.includes("bottom")||e.includes("top"),o=e.includes("left"),s=e.includes("top");return{isHorizontal:n,isVertical:i,affectsX:o,affectsY:s}}function sn(e,n){return Math.max(0,n-e)}function an(e,n){return Math.max(0,e-n)}function zi(e,n,i){return Math.max(0,n-e,e-i)}function Wt(e,n){return e?!n:n}function Gf(e,n,i,o,s,t,l,r){let{affectsX:d,affectsY:u}=n;const{isHorizontal:b,isVertical:c}=n,m=b&&c,{xSnapped:h,ySnapped:v}=i,{minWidth:p,maxWidth:y,minHeight:g,maxHeight:S}=o,{x:f,y:w,width:C,height:N,aspectRatio:A}=e;let E=Math.floor(b?h-e.pointerX:0),k=Math.floor(c?v-e.pointerY:0);const I=C+(d?-E:E),M=N+(u?-k:k),P=-t[0]*C,H=-t[1]*N;let T=zi(I,p,y),L=zi(M,g,S);if(l){let _=0,D=0;d&&E<0?_=sn(f+E+P,l[0][0]):!d&&E>0&&(_=an(f+I+P,l[1][0])),u&&k<0?D=sn(w+k+H,l[0][1]):!u&&k>0&&(D=an(w+M+H,l[1][1])),T=Math.max(T,_),L=Math.max(L,D)}if(r){let _=0,D=0;d&&E>0?_=an(f+E,r[0][0]):!d&&E<0&&(_=sn(f+I,r[1][0])),u&&k>0?D=an(w+k,r[0][1]):!u&&k<0&&(D=sn(w+M,r[1][1])),T=Math.max(T,_),L=Math.max(L,D)}if(s){if(b){const _=zi(I/A,g,S)*A;if(T=Math.max(T,_),l){let D=0;!d&&!u||d&&!u&&m?D=an(w+H+I/A,l[1][1])*A:D=sn(w+H+(d?E:-E)/A,l[0][1])*A,T=Math.max(T,D)}if(r){let D=0;!d&&!u||d&&!u&&m?D=sn(w+I/A,r[1][1])*A:D=an(w+(d?E:-E)/A,r[0][1])*A,T=Math.max(T,D)}}if(c){const _=zi(M*A,p,y)/A;if(L=Math.max(L,_),l){let D=0;!d&&!u||u&&!d&&m?D=an(f+M*A+P,l[1][0])/A:D=sn(f+(u?k:-k)*A+P,l[0][0])/A,L=Math.max(L,D)}if(r){let D=0;!d&&!u||u&&!d&&m?D=sn(f+M*A,r[1][0])/A:D=an(f+(u?k:-k)*A,r[0][0])/A,L=Math.max(L,D)}}}k=k+(k<0?L:-L),E=E+(E<0?T:-T),s&&(m?I>M*A?k=(Wt(d,u)?-E:E)/A:E=(Wt(d,u)?-k:k)*A:b?(k=E/A,u=d):(E=k*A,d=u));const B=d?f+E:f,O=u?w+k:w;return{width:C+(d?-E:E),height:N+(u?-k:k),x:t[0]*E*(d?-1:1)+B,y:t[1]*k*(u?-1:1)+O}}const Ut={width:0,height:0,x:0,y:0},zf={...Ut,pointerX:0,pointerY:0,aspectRatio:1};function $f(e,n,i){var u,b;const o=n.position.x+e.position.x,s=n.position.y+e.position.y,t=(u=e.measured.width)!=null?u:0,l=(b=e.measured.height)!=null?b:0,r=i[0]*t,d=i[1]*l;return[[o-r,s-d],[o+t-r,s+l-d]]}function jf({domNode:e,nodeId:n,getStoreItems:i,onChange:o,onEnd:s}){const t=Oe(e);let l={controlDirection:jt("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:b,keepAspectRatio:c,resizeDirection:m,onResizeStart:h,onResize:v,onResizeEnd:p,shouldResize:y}){let g={...Ut},S={...zf};l={boundaries:b,resizeDirection:m,keepAspectRatio:c,controlDirection:jt(u)};let f,w=null,C=[],N,A,E,k=!1;const I=Aa().on("start",M=>{var $,U,V,z,J,ne;const{nodeLookup:P,transform:H,snapGrid:T,snapToGrid:L,nodeOrigin:B,paneDomNode:O}=i();if(f=P.get(n),!f)return;w=($=O==null?void 0:O.getBoundingClientRect())!=null?$:null;const{xSnapped:_,ySnapped:D}=oi(M.sourceEvent,{transform:H,snapGrid:T,snapToGrid:L,containerBounds:w});g={width:(U=f.measured.width)!=null?U:0,height:(V=f.measured.height)!=null?V:0,x:(z=f.position.x)!=null?z:0,y:(J=f.position.y)!=null?J:0},S={...g,pointerX:_,pointerY:D,aspectRatio:g.width/g.height},N=void 0,A=vn(f.extent)?f.extent:void 0,f.parentId&&(f.extent==="parent"||f.expandParent)&&(N=P.get(f.parentId)),N&&f.extent==="parent"&&(A=[[0,0],[N.measured.width,N.measured.height]]),C=[],E=void 0;for(const[ie,Q]of P)if(Q.parentId===n&&(C.push({id:ie,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const F=$f(Q,f,(ne=Q.origin)!=null?ne: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}h==null||h(M,{...g})}).on("drag",M=>{var j,ee,X;const{transform:P,snapGrid:H,snapToGrid:T,nodeOrigin:L}=i(),B=oi(M.sourceEvent,{transform:P,snapGrid:H,snapToGrid:T,containerBounds:w}),O=[];if(!f)return;const{x:_,y:D,width:$,height:U}=g,V={},z=(j=f.origin)!=null?j:L,{width:J,height:ne,x:ie,y:Q}=Gf(S,l.controlDirection,B,l.boundaries,l.keepAspectRatio,z,A,E),F=J!==$,Y=ne!==U,oe=ie!==_&&F,K=Q!==D&&Y;if(!oe&&!K&&!F&&!Y)return;if((oe||K||z[0]===1||z[1]===1)&&(V.x=oe?ie:g.x,V.y=K?Q:g.y,g.x=V.x,g.y=V.y,C.length>0)){const Z=ie-_,se=Q-D;for(const le of C)le.position={x:le.position.x-Z+z[0]*(J-$),y:le.position.y-se+z[1]*(ne-U)},O.push(le)}if((F||Y)&&(V.width=F&&(!l.resizeDirection||l.resizeDirection==="horizontal")?J:g.width,V.height=Y&&(!l.resizeDirection||l.resizeDirection==="vertical")?ne:g.height,g.width=V.width,g.height=V.height),N&&f.expandParent){const Z=z[0]*((ee=V.width)!=null?ee:0);V.x&&V.x<Z&&(g.x=Z,S.x=S.x-(V.x-Z));const se=z[1]*((X=V.height)!=null?X:0);V.y&&V.y<se&&(g.y=se,S.y=S.y-(V.y-se))}const q=Vf({width:g.width,prevWidth:$,height:g.height,prevHeight:U,affectsX:l.controlDirection.affectsX,affectsY:l.controlDirection.affectsY}),W={...g,direction:q};(y==null?void 0:y(M,W))!==!1&&(k=!0,v==null||v(M,W),o(V,O))}).on("end",M=>{k&&(p==null||p(M,{...g}),s==null||s({...g}),k=!1)});t.call(I)}function d(){t.on(".drag",null)}return{update:r,destroy:d}}function Wf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $i={exports:{}},ds={},ji={exports:{}},us={};/**
38
+ active:opacity-50 element_class`,draggable:!0,children:a.jsxs("span",{className:"flex flex-col items-center justify-center w-full gap-2",children:[a.jsx("span",{style:{color:m},children:a.jsx(te,{icon:N.icon,iconClass:"w-6 h-6"})}),a.jsx("span",{style:{color:m},className:"text-xs font-medium text-center",children:N.label})]})},N.type))})]},w)})})})]})},Ju=x.memo(Yu),We=({text:e="",isDisabled:n=!1,isLoading:i=!1,btnClass:o="bg-primary-500 text-white",icon:s="",iconPosition:t="left",iconClass:l="text-[20px]",loadingClass:r="",link:d="",div:u=!1,type:b="button",style:c,onClick:m})=>{const h=be("btn inline-flex justify-center",{"pointer-events-none":i,"opacity-40 cursor-not-allowed":n},o),v=()=>i?a.jsxs(a.Fragment,{children:[a.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:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.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..."]}):a.jsxs("span",{className:"flex items-center",children:[s&&t==="left"&&a.jsx("span",{className:`mr-[6px] ${l}`,children:a.jsx(te,{icon:s})}),e&&a.jsx("span",{children:e}),s&&t==="right"&&a.jsx("span",{className:`ml-[6px] ${l}`,children:a.jsx(te,{icon:s})})]});return u?a.jsx("div",{className:h,children:v()}):d?a.jsx(xr.Link,{to:d,className:h,children:v()}):a.jsx("button",{disabled:n,type:b,className:h,"data-testid":"btn",onClick:m,style:c,children:v()})};function Zu(){return a.jsx("div",{children:a.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",fill:"#D5D7DA"}),a.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",stroke:"#E9EAEB"}),a.jsx("path",{d:"M22.5 14L14.5 22M14.5 14L22.5 22",stroke:"#414651",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const Xu=({isOpen:e,onClose:n})=>{const{formData:i,uploadUrl:o}=x.useContext(Ie);if(!e)return null;const s=ke("config");return a.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:[a.jsx("button",{type:"button",onClick:n,className:"absolute text-sm top-3 right-4","aria-label":"close",children:a.jsx(Zu,{})})," ",a.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:a.jsx(Ao,{form_data:i,ignoreValidation:!0,config:s,uploadUrl:o})})]})};function Qu(){return a.jsx("div",{children:a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{width:"24",height:"24",rx:"6",fill:"currentColor"}),a.jsx("path",{d:"M14 16L10 12L14 8",stroke:"white",strokeWidth:"1.39167",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function Ru({title:e,goBackUrl:n,onSubmit:i,onPublish:o,previewLoading:s,saveLoading:t,publishLoading:l,onTitleChange:r,viewMode:d,setViewMode:u,onShowVersion:b}){const{formData:c,setShowPreview:m,showPreview:h,undo:v,redo:p,canUndo:y,canRedo:g}=x.useContext(Ie),[S,f]=x.useState(!1),[w,C]=x.useState(!1),[N,A]=x.useState(e||""),E=ke("config");function k(){try{localStorage.setItem("formData",JSON.stringify(c))}catch(P){console.warn("Could not save formData to localStorage",P)}i==null||i(c)}function I(){try{localStorage.setItem("formData",JSON.stringify(c))}catch(P){console.warn("Could not save formData to localStorage",P)}o==null||o(c)}function M(){C(!1),r&&N!==e&&r(N.trim())}return a.jsxs("div",{className:"px-[30px] py-3 flex justify-between items-center bg-[#F9F9FB] top_bar border-b h-full",children:[a.jsxs("span",{className:"flex items-center gap-x-2",children:[n&&a.jsx("button",{type:"button",onClick:()=>n(),style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:"flex items-center gap-x-3",children:a.jsx(Qu,{})})," ",w?a.jsx("input",{type:"text",value:N,onChange:P=>A(P.target.value),onBlur:M,autoFocus:!0,className:"w-48 px-2 py-1 text-sm font-semibold outline-gray-100 input form_title"}):a.jsx("h1",{title:"Click to edit",className:"text-base font-semibold cursor-pointer form_title",onClick:()=>C(!0),children:N||"Untitled"})]}),S&&a.jsx(Xu,{isOpen:S,onClose:()=>f(!1),element:void 0}),a.jsxs("div",{className:"flex justify-end text-xs gap-x-3 items-center",children:[u&&a.jsxs("div",{className:"flex border border-gray-300 rounded-lg overflow-hidden h-[36px] text-sm font-medium shadow-sm mr-2",children:[a.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 ${d==="canvas"?"bg-white font-medium":"bg-gray-100 text-gray-500 hover:bg-gray-50"}`,onClick:()=>u("canvas"),children:[a.jsx(te,{icon:"mdi:view-dashboard-outline",iconClass:"text-base"})," ","Builder"]}),a.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 ${d==="flow"?" bg-white font-medium":"bg-gray-100 text-gray-500 hover:bg-gray-50"}`,onClick:()=>u("flow"),children:[a.jsx(te,{icon:"mdi:sitemap-outline",iconClass:"text-base"})," Flow"]})]}),a.jsx(We,{onClick:v,text:"",btnClass:`!px-2 bg-transparent undo ${y?"":"opacity-50"}`,icon:"material-symbols:undo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!y}),a.jsx(We,{onClick:p,text:"",btnClass:`!px-2 bg-transparent redo ${g?"":"opacity-50"}`,icon:"material-symbols:redo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!g}),b&&a.jsx(We,{onClick:b,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"}}),a.jsx(We,{onClick:()=>m(P=>!P),text:h?"Hide Preview":"Preview",btnClass:"px-2 bg-transparent font-medium text-sm form_preview",icon:h?"iconamoon:eye-off-duotone":"solar:eye-bold-duotone",iconClass:"text-base",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:s,isLoading:s}),a.jsx(We,{onClick:k,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:t,isLoading:t}),a.jsx(We,{onClick:I,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:l,isLoading:l})]})]})}function ec({onSubmit:e,onChange:n,onLogAction:i,questionData:o,title:s,goBackUrl:t,loading:l,onPublish:r,previewLoading:d,saveLoading:u,publishLoading:b,onTitleChange:c,uploadUrl:m,onAddTemplate:h,templates:v,onShowVersion:p,formType:y="default"}){const[g,S]=x.useState("canvas");return a.jsxs(Ns,{onChange:n,onLogAction:i,children:[a.jsx(Me.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),a.jsx("div",{className:"w-full h-full bg-[#F8F9FC] flex flex-col",children:a.jsxs("div",{className:"flex flex-1 ",children:[g==="canvas"&&a.jsx("div",{children:a.jsx("div",{className:"w-[290px] h-screen border-r border-[#E4E7EC] bg-white ",children:a.jsx(Ju,{formType:y})})}),a.jsxs("div",{className:`flex-1 h-full max-h-full z-[1] ${g==="canvas"?"w-[calc(100%-250px)]":"w-full"}`,children:[a.jsx("div",{className:" h-[70px]",children:a.jsx(Ru,{title:s,goBackUrl:t,onSubmit:e,onPublish:r,previewLoading:d,saveLoading:u,publishLoading:b,onTitleChange:c,viewMode:g,setViewMode:S,onShowVersion:p})}),a.jsx("div",{className:"p-6 h-[calc(100vh-70px)]",children:l?a.jsx(wo,{loadingClass:"!w-full !h-[800px]"}):a.jsx(Wu,{questionData:o,uploadUrl:m,onAddTemplate:h,templates:v,viewMode:g})})]})]})})]})}const nc=({onSubmit:e,onChange:n,onLogAction:i,questionData:o,isReadOnly:s,config:t={buttonColor:"#333"},title:l,loading:r,goBackUrl:d,onPublish:u,previewLoading:b,saveLoading:c,publishLoading:m,onTitleChange:h,uploadUrl:v,onAddTemplate:p,templates:y,onShowVersion:g,formType:S})=>(x.useEffect(()=>{t&&Zs("config",t)},[t]),a.jsx(ec,{onSubmit:e,onChange:n,onLogAction:i,onPublish:u,questionData:o,isReadOnly:s,title:l,goBackUrl:d,loading:r,previewLoading:b,saveLoading:c,publishLoading:m,onTitleChange:h,uploadUrl:v,onAddTemplate:p,templates:y,onShowVersion:g,formType:S})),nn={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}`},ic=e=>({textField:R.string().nullable(),longText:R.string().nullable(),numberField:R.number().nullable().transform(i=>isNaN(i)?null:i),amountField:R.number().nullable().transform(i=>isNaN(i)?null:i),selectField:R.string().nullable(),checkbox:R.mixed().nullable(),radio:R.mixed().nullable(),matrix:R.mixed().nullable(),email:R.string().nullable().test("email-format",nn.email,i=>!i||i.trim()===""?!0:/^[A-Za-z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(i)),date:R.date().nullable().transform((i,o)=>o===""||o===null?null:i).typeError("Invalid date"),url:R.string().nullable().test("url-format",nn.url,i=>!i||i.trim()===""?!0:/^(https?:\/\/)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/.*)?$/.test(i))})[e]||R.mixed().nullable(),oc=(e,n,i)=>n?e.type==="boolean"?e.oneOf([!0],i||nn.required):e.required(i||nn.required):e,sc=(e,{minLength:n,maxLength:i,minLengthMessage:o,maxLengthMessage:s})=>{let t=e;return n&&(t=t.min(n,o||nn.minLength(n))),i&&(t=t.max(i,s||nn.maxLength(i))),t},ac=(e,{minAmount:n,maxAmount:i,minAmountMessage:o,maxAmountMessage:s})=>{let t=e;return n&&(t=t.min(parseFloat(String(n)),o||nn.minAmount(n))),i&&(t=t.max(parseFloat(String(i)),s||nn.maxAmount(i))),t},No=(e,n)=>{if(!e.isHidden)return!0;const i=e.visibilityDependentFields||[];return i.length?i.every(o=>{const s=n==null?void 0:n[o.id],t=o.fieldValue,l=s;switch(o.operator){case"equals":return String(t).toLowerCase()===String(l).toLowerCase();case"not_equals":return String(t).toLowerCase()!==String(l).toLowerCase();case"greater":return Number(l)>Number(t);case"less":return Number(l)<Number(t);case"contains":return String(l).toLowerCase().includes(String(t).toLowerCase());case"not_contains":return!String(l).toLowerCase().includes(String(t).toLowerCase());default:return!0}}):!0};function tc({formData:e,isReadOnly:n,answerData:i}){const o={};return e.forEach(({questionData:s})=>{s==null||s.forEach(t=>{if(!No(t,i))return;const{id:l,type:r,isRequired:d,requiredMessage:u,isDisabled:b}=t;let c=ic(r);c=oc(c,b||n?!1:d,u),r==="textField"||r==="longText"||r==="email"||r==="url"?c=sc(c,t):(r==="numberField"||r==="amountField")&&(c=ac(c,t)),t.requireAllChecked?c=c.test("require-all-checked","All options must be selected",m=>{var p;if(m==null||m===""||Array.isArray(m)&&m.length===0)return!d;const v=((p=t.options)==null?void 0:p.length)||0;return Array.isArray(m)?m.length>=v:v<=1}):t.minChecked&&(c=c.test("min-checked",`Please select at least ${t.minChecked} option(s)`,m=>m==null||m===""||Array.isArray(m)&&m.length===0?!d:Array.isArray(m)?m.length>=t.minChecked:1>=t.minChecked)),o[l]=c})}),R.object().shape(o)}const ra=e=>{try{const n=JSON.parse(e);if(Array.isArray(n))return n.map(i=>i.label).join(" > ")}catch(n){}return e},lc=({results:e})=>{var o,s,t,l,r,d,u;const[n,i]=x.useState(!0);return e?a.jsxs("div",{className:"mt-4 w-full",children:[n&&a.jsxs("div",{className:"p-4 mb-3 rounded-xl border border-gray-200 bg-gray-50/50 shadow-sm w-full transition-all duration-300",children:[a.jsx("div",{className:"flex justify-between items-center mb-4",children:a.jsxs("h4",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider",children:["Live Results Breakdown (",e.totalResponses," Responses)"]})}),a.jsxs("div",{className:"space-y-4",children:[["polling","checkbox","radio","imageChoice"].includes(e.type)&&((o=e.responsesData)==null?void 0:o.options)&&e.responsesData.options.map((b,c)=>a.jsxs("div",{className:"w-full",children:[a.jsxs("div",{className:"flex justify-between items-center mb-1.5 text-sm font-semibold text-gray-800",children:[a.jsx("span",{children:b.label}),a.jsxs("span",{children:[Math.round(b.percentage),"% (",b.count,")"]})]}),a.jsx("div",{className:"w-full bg-gray-200 rounded-full h-1.5 overflow-hidden",children:a.jsx("div",{className:"bg-blue-600 h-1.5 rounded-full transition-all duration-700 ease-out",style:{width:`${b.percentage}%`}})})]},c)),e.type==="rating"&&((s=e.responsesData)==null?void 0:s.options)&&a.jsxs(a.Fragment,{children:[((t=e.responsesData)==null?void 0:t.average)!==void 0&&a.jsxs("div",{className:"mb-4 p-3 bg-white rounded-lg border text-center w-32 mx-auto",children:[a.jsx("div",{className:"text-xs text-gray-500 uppercase",children:"Average Rating"}),a.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:e.responsesData.average})]}),e.responsesData.options.map((b,c)=>a.jsxs("div",{className:"w-full",children:[a.jsxs("div",{className:"flex justify-between items-center mb-1.5 text-sm font-semibold text-gray-800",children:[a.jsx("span",{children:b.label}),a.jsxs("span",{children:[Math.round(b.percentage),"% (",b.count,")"]})]}),a.jsx("div",{className:"w-full bg-gray-200 rounded-full h-1.5 overflow-hidden",children:a.jsx("div",{className:"bg-yellow-500 h-1.5 rounded-full transition-all duration-700 ease-out",style:{width:`${b.percentage}%`}})})]},c))]}),e.type==="matrix"&&((l=e.responsesData)==null?void 0:l.rows)&&a.jsx("div",{className:"space-y-6",children:e.responsesData.rows.map((b,c)=>{var m;return a.jsxs("div",{className:"w-full bg-white p-3 rounded-lg border",children:[a.jsxs("h5",{className:"font-semibold text-gray-800 mb-3 text-sm",children:[b.label," ",a.jsxs("span",{className:"text-gray-400 font-normal text-xs ml-1",children:["(",b.totalResponses," Responses)"]})]}),a.jsx("div",{className:"space-y-3",children:(m=b.columns)==null?void 0:m.map((h,v)=>a.jsxs("div",{className:"w-full",children:[a.jsxs("div",{className:"flex justify-between items-center mb-1 text-xs text-gray-600",children:[a.jsx("span",{children:h.label}),a.jsxs("span",{children:[Math.round(h.percentage),"% (",h.count,")"]})]}),a.jsx("div",{className:"w-full bg-gray-100 rounded-full h-1 overflow-hidden",children:a.jsx("div",{className:"bg-indigo-500 h-1 rounded-full transition-all duration-700 ease-out",style:{width:`${h.percentage}%`}})})]},v))})]},c)})}),e.type==="ranking"&&((r=e.responsesData)==null?void 0:r.rankings)&&e.responsesData.rankings.map((b,c)=>a.jsxs("div",{className:"w-full",children:[a.jsxs("div",{className:"flex justify-between items-center mb-1.5 text-sm font-semibold text-gray-800",children:[a.jsx("span",{className:"truncate pr-2",title:ra(b.label),children:ra(b.label)}),a.jsxs("span",{className:"shrink-0",children:[Math.round(b.percentage),"% (",b.count,")"]})]}),a.jsx("div",{className:"w-full bg-gray-200 rounded-full h-1.5 overflow-hidden",children:a.jsx("div",{className:"bg-purple-600 h-1.5 rounded-full transition-all duration-700 ease-out",style:{width:`${b.percentage}%`}})})]},c)),e.type==="nps"&&a.jsxs(a.Fragment,{children:[((d=e.responsesData)==null?void 0:d.nps)&&a.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 mb-4",children:[a.jsxs("div",{className:"p-3 bg-white rounded-lg border text-center",children:[a.jsx("div",{className:"text-xs text-gray-500 uppercase",children:"NPS Score"}),a.jsx("div",{className:"text-xl font-bold text-blue-600",children:e.responsesData.nps.score})]}),a.jsxs("div",{className:"p-3 bg-white rounded-lg border text-center",children:[a.jsx("div",{className:"text-xs text-green-500 uppercase",children:"Promoters"}),a.jsx("div",{className:"text-xl font-bold text-gray-800",children:e.responsesData.nps.promoters})]}),a.jsxs("div",{className:"p-3 bg-white rounded-lg border text-center",children:[a.jsx("div",{className:"text-xs text-yellow-500 uppercase",children:"Passives"}),a.jsx("div",{className:"text-xl font-bold text-gray-800",children:e.responsesData.nps.passives})]}),a.jsxs("div",{className:"p-3 bg-white rounded-lg border text-center",children:[a.jsx("div",{className:"text-xs text-red-500 uppercase",children:"Detractors"}),a.jsx("div",{className:"text-xl font-bold text-gray-800",children:e.responsesData.nps.detractors})]})]}),((u=e.responsesData)==null?void 0:u.options)&&a.jsx("div",{className:"grid grid-cols-11 gap-1",children:e.responsesData.options.map((b,c)=>a.jsxs("div",{className:"flex flex-col items-center group relative",children:[a.jsx("div",{className:"w-full bg-blue-100 rounded-t-sm flex items-end justify-center transition-all",style:{height:"60px"},children:a.jsx("div",{className:"w-full bg-blue-500 rounded-t-sm transition-all duration-500",style:{height:`${b.percentage}%`},title:`${b.percentage}% (${b.count} votes)`})}),a.jsx("div",{className:"text-xs font-medium text-gray-600 mt-1",children:b.label})]},c))})]})]})]}),a.jsxs("button",{type:"button",onClick:()=>i(!n),className:"flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-700 font-medium transition-colors",children:[a.jsx(te,{icon:"bx:bar-chart-alt-2",iconClass:"w-4 h-4"}),n?"Hide Results":"Show Results"]})]}):null},gn=({element:e,validationData:n})=>{var l;const i=ta[e.type],{answerData:o}=x.useContext(Ie),s=x.useMemo(()=>{var r;return(r=e==null?void 0:e.acceptedFiles)==null?void 0:r.map(d=>d.label).join(", ")},[e]),t=x.useMemo(()=>No(e,o),[o,e]);return i?a.jsxs("div",{className:`${t?"":"hidden"} min-w-0 w-full`,children:[a.jsx("div",{className:"mb-1.5 min-w-0",children:e.inputLabel&&a.jsxs("label",{className:"block text-sm font-medium input_label",children:[e.inputLabel," ",s&&a.jsxs("span",{className:"text-gray-400 text-xs",children:["(",s==null?void 0:s.toLowerCase(),")"]})]})}),a.jsx(i,{element:e,state:"view",validationData:{...n,isReadOnly:n.isReadOnly||e.isDisabled}}),e.description&&a.jsx("small",{className:"block text-gray-400 mt-0.5 text-xs",children:e.description}),(n==null?void 0:n.showResults)&&((l=n==null?void 0:n.pollResults)==null?void 0:l[e.id])&&a.jsx(lc,{results:n.pollResults[e.id]})]}):null},yn=(e,n)=>e!=null&&e.allowEdit?{...n,isReadOnly:!1}:n;function rc({form_data:e,options:n}){const i=(s,t)=>a.jsx("div",{className:"min-w-0",children:a.jsx(mi,{element:s,customClass:"p-0 min-h-[60px] border-none",children:t==null?void 0:t.map(l=>{var r,d,u;return a.jsxs(bi,{col:(r=l.gridPosition)==null?void 0:r.col,customClass:"p-0 relative",children:[a.jsx(gn,{element:l,validationData:yn(l,n)}),((u=(d=n==null?void 0:n.errors)==null?void 0:d[l.id])==null?void 0:u.message)&&a.jsx("div",{className:"absolute -bottom-[18px] left-0 text-xs text-red-600 whitespace-nowrap",children:n.errors[l.id].message})]},l.id)})})},s.id),o=s=>{var t,l;return a.jsxs("div",{className:be("group relative grid gap-y-[6px] min-w-0",s.elementClass),children:[a.jsx(gn,{element:s,validationData:yn(s,n)}),((l=(t=n==null?void 0:n.errors)==null?void 0:t[s.id])==null?void 0:l.message)&&a.jsx("div",{className:"absolute -bottom-[18px] left-0 text-xs text-red-600 whitespace-nowrap",children:n.errors[s.id].message})]},s.id)};return a.jsx("div",{className:"grid gap-y-10",children:e==null?void 0:e.map(s=>{var l,r;const t=new Map;return(l=s==null?void 0:s.questionData)==null||l.forEach(d=>{d.gridId&&(t.has(d.gridId)||t.set(d.gridId,[]),t.get(d.gridId).push(d))}),a.jsxs("div",{className:"pb-6 section_box min-w-0",children:[(s.title||s.description)&&a.jsxs("div",{className:"py-4 border-b border-gray-100 mb-7 section_box__title",children:[s.title&&a.jsx("h2",{className:"text-lg font-semibold mb-[4px]",children:s.title}),s.description&&a.jsx("p",{className:"text-sm",children:s.description})]}),a.jsx("div",{className:"grid gap-y-6 section_box__content min-w-0",children:(r=s==null?void 0:s.questionData)==null?void 0:r.map(d=>d.gridId?null:d.type==="grid"?i(d,t.get(d.id)||[]):o(d))})]},s.id)})})}function dc({form_data:e,options:n,current:i}){var o,s;return a.jsx("div",{className:"grid gap-y-3 multi_section__content min-w-0",children:(s=(o=e[i])==null?void 0:o.questionData)==null?void 0:s.map(t=>{var l,r,d,u;if(t.type==="grid"){const b=(r=(l=e[i])==null?void 0:l.questionData)==null?void 0:r.filter(c=>c.gridId===t.id);return a.jsx("div",{className:"min-w-0",children:a.jsx(mi,{element:t,customClass:"p-0 min-h-[60px] border-none",children:b==null?void 0:b.map(c=>{var m,h,v;return a.jsxs(bi,{col:(m=c.gridPosition)==null?void 0:m.col,customClass:"p-0",children:[a.jsx(gn,{element:c,validationData:yn(c,n)}),a.jsx("div",{className:"mt-1 text-xs text-red-600 min-h-[1rem]",children:(v=(h=n==null?void 0:n.errors)==null?void 0:h[c.id])==null?void 0:v.message})]},c.id)})})},t.id)}return t.gridId?null:a.jsxs("div",{className:be("group relative grid gap-y-[6px] min-w-0",t.elementClass),children:[a.jsx(gn,{element:t,validationData:yn(t,n)}),a.jsx("div",{className:"mt-1 text-xs text-red-600 min-h-[1rem]",children:(u=(d=n==null?void 0:n.errors)==null?void 0:d[t.id])==null?void 0:u.message})]},t.id)})})}const Co=ke("config");function uc({element:e,options:n,onNext:i,onPrev:o,isFirst:s,isLast:t,isReadOnly:l}){if(!e)return a.jsx("div",{className:"flex items-center justify-center min-h-[500px] text-gray-500",children:"No questions available."});const r=b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),i())},d=b=>{var c;return a.jsx("div",{className:"min-w-0 w-full",children:a.jsx(mi,{element:b,customClass:"p-0 min-h-[60px] border-none w-full",children:(c=b.gridChildren)==null?void 0:c.map(m=>{var h,v,p;return a.jsxs(bi,{col:(h=m.gridPosition)==null?void 0:h.col,customClass:"p-0",children:[a.jsx(gn,{element:m,validationData:yn(m,n)}),a.jsx("div",{className:"mt-1 text-xs text-red-600 min-h-[1rem]",children:(p=(v=n==null?void 0:n.errors)==null?void 0:v[m.id])==null?void 0:p.message})]},m.id)})})},b.id)},u=b=>{var c,m;return a.jsxs("div",{className:be("group relative grid gap-y-[6px] min-w-0 w-full",b.elementClass),children:[a.jsx(gn,{element:b,validationData:yn(b,n)}),a.jsx("div",{className:"mt-1 text-xs text-red-600 min-h-[1rem]",children:(m=(c=n==null?void 0:n.errors)==null?void 0:c[b.id])==null?void 0:m.message})]},b.id)};return a.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:a.jsxs(de.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:[a.jsx("div",{className:"text-left w-full mb-8",children:e.type==="grid"?d(e):u(e)}),!l&&a.jsxs("div",{className:"flex items-center gap-4 mt-8",children:[a.jsx(We,{type:"button",text:t?n!=null&&n.isSubmitting?"Submitting...":"Submit":"OK",onClick:i,style:{background:(Co==null?void 0:Co.buttonColor)||"#333"},btnClass:`text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg ${t?"submit_btn":"continue_btn next_btn text-sm"}`,isDisabled:(n==null?void 0:n.apiActivityCount)>0||t&&(n==null?void 0:n.isSubmitting)}),!t&&a.jsx("span",{className:"text-xs text-gray-400 font-medium hidden sm:inline-block",children:"press Enter ↵"}),!s&&a.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:[a.jsx(te,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]})]},e.id)})}function cc(e){return e.reduce((n,i)=>(n[i.id]=i.value,n),{})}const bc=({form_data:e,answerData:n=[],ignoreValidation:i=!1,onSubmitData:o,onGetValues:s,isReadOnly:t=!1,renderType:l="multi",children:r,hideFooter:d=!1,uploadUrl:u,pollResults:b,showResults:c})=>{var F,Y,oe,K,q,W,G,j,ee,X;const{setAnswerData:m,setUploadUrl:h,apiActivityCount:v}=x.useContext(Ie),[p,y]=x.useState(0),[g,S]=x.useState(0),f=x.useMemo(()=>e.filter(Z=>!Z.isHidden).map(Z=>{var le;return Z.isDisabled||Z.disabled?{...Z,questionData:(le=Z==null?void 0:Z.questionData)==null?void 0:le.map(re=>({...re,isDisabled:!0}))}:Z}),[e]),w=(F=f==null?void 0:f.length)!=null?F:0,C=ke("config"),N=x.useCallback(async(Z,se,le)=>{const re=tc({formData:f,isReadOnly:t,answerData:Z});return uo(re)(Z,se,le)},[f,t]),A=Je.useForm({resolver:N,mode:"onSubmit",defaultValues:{}}),{register:E,setValue:k,control:I,handleSubmit:M,reset:P,getValues:H,watch:T,formState:{errors:L,isSubmitting:B},trigger:O,setError:_,clearErrors:D}=A,$=Je.useWatch({control:I}),U=x.useMemo(()=>$,[JSON.stringify($)]),V=x.useMemo(()=>{if(l!=="conversational")return[];const Z=[];return f.forEach(se=>{var le;(le=se==null?void 0:se.questionData)==null||le.forEach(re=>{var fe;if(No(re,U))if(re.type==="grid"){const he=(fe=se==null?void 0:se.questionData)==null?void 0:fe.filter(Te=>Te.gridId===re.id);Z.push({...re,gridChildren:he})}else re.gridId||Z.push(re)})}),Z},[f,U,l]),z=x.useCallback(Z=>{s&&s(Z)},[s]);x.useEffect(()=>{h(u)},[h,u]),x.useEffect(()=>{if(!(f!=null&&f.length)||!s)return;const Z=f.flatMap(se=>{var le;return(le=se==null?void 0:se.questionData)==null?void 0:le.map(re=>({id:re.id,value:U[re.id]||"",sectionId:se.id,type:re.type,metaData:{prefix:re.prefix,dateFormat:re.dateFormat,...U[`${re.id}_metaData`]?{responseObject:U[`${re.id}_metaData`]}:{}}}))});z(Z),m(U)},[U,f,z,s,m]),x.useEffect(()=>{n!=null&&n.length&&P(cc(n))},[n,P]);const J=x.useCallback(Z=>{const se=f.flatMap(le=>{var re;return(re=le==null?void 0:le.questionData)==null?void 0:re.map(fe=>({id:fe.id,value:Z[fe.id]||"",sectionId:le.id,type:fe.type,metaData:{prefix:fe.prefix,dateFormat:fe.dateFormat,...Z[`${fe.id}_metaData`]?{responseObject:Z[`${fe.id}_metaData`]}:{}}}))});Object.keys(L).length>0||o==null||o(se)},[L,f,o]),ne=x.useCallback(async()=>{var Z,se;if(l==="conversational"){if(!i){const le=V[g];if(!le)return;const re=le.gridChildren?le.gridChildren.map(he=>he.id):[le.id];if(!await O(re))return}g<V.length-1?S(le=>le+1):M(J)();return}if(!i){const le=(se=(Z=f==null?void 0:f[p])==null?void 0:Z.questionData)==null?void 0:se.map(fe=>fe.id);if(!await O(le))return}y(le=>le+1)},[p,g,V,f,i,O,l,M,J]),ie=x.useCallback(()=>{if(l==="conversational"){S(Z=>Math.max(0,Z-1));return}y(Z=>Z-1)},[l]),Q=x.useMemo(()=>({register:E,setValue:k,watch:T,errors:L,trigger:O,isSubmitting:B,isReadOnly:t,getValues:H,setError:_,clearErrors:D,apiActivityCount:v,pollResults:b,showResults:c,isViewer:!0}),[E,k,T,L,O,B,t,H,_,D,v,b,c]);return a.jsxs(Je.FormProvider,{...A,children:[a.jsx(Me.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),a.jsxs("form",{onSubmit:M(J),className:"container h-full mx-auto",children:[a.jsx("div",{className:"relative flex flex-col w-full min-w-0 py-4 gap-y-12",children:a.jsxs("div",{className:"multi_section__box min-w-0",children:[l==="multi"&&(((Y=f==null?void 0:f[p])==null?void 0:Y.title)||((oe=f==null?void 0:f[p])==null?void 0:oe.description))&&a.jsxs("div",{className:"py-4 mb-4 border-b border-gray-100 multi_section__title",children:[((K=f[p])==null?void 0:K.title)&&a.jsx("h2",{className:"text-lg font-semibold mb-[6px]",children:(q=f[p])==null?void 0:q.title}),((W=f[p])==null?void 0:W.description)&&a.jsx("p",{className:"text-sm",children:(G=f[p])==null?void 0:G.description})]}),l==="multi"?a.jsx(dc,{form_data:f,options:Q,current:p}):l==="conversational"?a.jsx(uc,{element:V[g],options:Q,onNext:ne,onPrev:ie,isFirst:g===0,isLast:g===V.length-1,isReadOnly:t}):a.jsx(rc,{form_data:f,options:Q})]},l==="conversational"?`conv-${g}`:(j=f==null?void 0:f[p])==null?void 0:j.id)}),!d&&l!=="conversational"&&a.jsx("footer",{className:"flex items-center justify-end gap-4 footer flex-wrap",children:l==="multi"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex gap-x-4 justify-between navigation_container w-full",children:[a.jsxs("div",{children:[" ",p>0&&a.jsxs("button",{type:"button",onClick:ie,className:"text-gray-400 hover:text-gray-600 font-medium text-sm flex items-center gap-1 transition-colors back_btn",children:[a.jsx(te,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]}),p<w-1&&a.jsx(We,{type:"button",text:"Next",onClick:ne,style:{background:(C==null?void 0:C.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"})]}),(p===w-1||t)&&!i&&((ee=typeof r=="function"?r({isUploading:v>0,isSubmitting:B,hasErrors:Object.keys(L).length>0}):r)!=null?ee:a.jsx(We,{isDisabled:B||Object.keys(L).length>0||v>0,isLoading:B,type:"submit",text:"Submit",style:{background:(C==null?void 0:C.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&&((X=typeof r=="function"?r({isUploading:v>0,isSubmitting:B,hasErrors:Object.keys(L).length>0}):r)!=null?X:a.jsx(We,{isDisabled:B||Object.keys(L).length>0||v>0,isLoading:B,type:"submit",text:"Submit",style:{background:(C==null?void 0:C.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"}))}),l==="conversational"&&V.length>0&&a.jsx("div",{className:"fixed bottom-0 left-0 w-full h-1.5 bg-gray-200",children:a.jsx("div",{className:"h-full bg-blue-600 transition-all duration-500 ease-out",style:{width:`${(g+1)/V.length*100}%`,background:(C==null?void 0:C.buttonColor)||"#2563EB"}})})]})]})},mc=x.memo(bc);function Ao({answerData:e,form_data:n,ignoreValidation:i,onSubmit:o,isReadOnly:s=!1,loading:t=!1,config:l={buttonColor:"#333"},renderType:r,children:d,hideFooter:u,onGetValues:b,uploadUrl:c,pollResults:m,showResults:h}){x.useEffect(()=>{l&&Zs("config",l)},[l]);const v=x.useCallback(p=>{b&&b(p)},[b]);return t?a.jsx(wo,{}):n?a.jsxs("div",{className:"w-full h-full min-w-0",children:[a.jsx("div",{id:"root-portal"}),a.jsx(Ns,{children:a.jsx(mc,{form_data:n,answerData:e,ignoreValidation:i,onSubmitData:o,isReadOnly:s,renderType:r,hideFooter:u,onGetValues:v,uploadUrl:c,pollResults:m,showResults:h,children:d})})]}):a.jsx("div",{children:a.jsx("p",{className:"p-6 text-sm text-gray-400",children:"Error: No form data available."})})}function Ee(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=Ee(e[i]))!==""&&(n+=(n&&" ")+o);else for(let i in e)e[i]&&(n+=(n&&" ")+i);return n}var vc={value:()=>{}};function vi(){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 fi(i)}function fi(e){this._=e}function fc(e,n){return e.trim().split(/^|\s+/).map(function(i){var o="",s=i.indexOf(".");if(s>=0&&(o=i.slice(s+1),i=i.slice(0,s)),i&&!n.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:o}})}fi.prototype=vi.prototype={constructor:fi,on:function(e,n){var i=this._,o=fc(e+"",i),s,t=-1,l=o.length;if(arguments.length<2){for(;++t<l;)if((s=(e=o[t]).type)&&(s=hc(i[s],e.name)))return s;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++t<l;)if(s=(e=o[t]).type)i[s]=da(i[s],e.name,n);else if(n==null)for(s in i)i[s]=da(i[s],e.name,null);return this},copy:function(){var e={},n=this._;for(var i in n)e[i]=n[i].slice();return new fi(e)},call:function(e,n){if((s=arguments.length-2)>0)for(var i=new Array(s),o=0,s,t;o<s;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(t=this._[e],o=0,s=t.length;o<s;++o)t[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],s=0,t=o.length;s<t;++s)o[s].value.apply(n,i)}};function hc(e,n){for(var i=0,o=e.length,s;i<o;++i)if((s=e[i]).name===n)return s.value}function da(e,n,i){for(var o=0,s=e.length;o<s;++o)if(e[o].name===n){e[o]=vc,e=e.slice(0,o).concat(e.slice(o+1));break}return i!=null&&e.push({name:n,value:i}),e}var ko="http://www.w3.org/1999/xhtml";const ua={svg:"http://www.w3.org/2000/svg",xhtml:ko,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function hi(e){var n=e+="",i=n.indexOf(":");return i>=0&&(n=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),ua.hasOwnProperty(n)?{space:ua[n],local:e}:e}function pc(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===ko&&n.documentElement.namespaceURI===ko?n.createElement(e):n.createElementNS(i,e)}}function gc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ca(e){var n=hi(e);return(n.local?gc:pc)(n)}function yc(){}function Eo(e){return e==null?yc:function(){return this.querySelector(e)}}function xc(e){typeof e!="function"&&(e=Eo(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var t=n[s],l=t.length,r=o[s]=new Array(l),d,u,b=0;b<l;++b)(d=t[b])&&(u=e.call(d,d.__data__,b,t))&&("__data__"in d&&(u.__data__=d.__data__),r[b]=u);return new _e(o,this._parents)}function Sc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function wc(){return[]}function ba(e){return e==null?wc:function(){return this.querySelectorAll(e)}}function Nc(e){return function(){return Sc(e.apply(this,arguments))}}function Cc(e){typeof e=="function"?e=Nc(e):e=ba(e);for(var n=this._groups,i=n.length,o=[],s=[],t=0;t<i;++t)for(var l=n[t],r=l.length,d,u=0;u<r;++u)(d=l[u])&&(o.push(e.call(d,d.__data__,u,l)),s.push(d));return new _e(o,s)}function ma(e){return function(){return this.matches(e)}}function va(e){return function(n){return n.matches(e)}}var Ac=Array.prototype.find;function kc(e){return function(){return Ac.call(this.children,e)}}function Ec(){return this.firstElementChild}function Mc(e){return this.select(e==null?Ec:kc(typeof e=="function"?e:va(e)))}var Tc=Array.prototype.filter;function Pc(){return Array.from(this.children)}function Lc(e){return function(){return Tc.call(this.children,e)}}function Bc(e){return this.selectAll(e==null?Pc:Lc(typeof e=="function"?e:va(e)))}function Ic(e){typeof e!="function"&&(e=ma(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var t=n[s],l=t.length,r=o[s]=[],d,u=0;u<l;++u)(d=t[u])&&e.call(d,d.__data__,u,t)&&r.push(d);return new _e(o,this._parents)}function fa(e){return new Array(e.length)}function Dc(){return new _e(this._enter||this._groups.map(fa),this._parents)}function pi(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}pi.prototype={constructor:pi,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 _c(e){return function(){return e}}function Oc(e,n,i,o,s,t){for(var l=0,r,d=n.length,u=t.length;l<u;++l)(r=n[l])?(r.__data__=t[l],o[l]=r):i[l]=new pi(e,t[l]);for(;l<d;++l)(r=n[l])&&(s[l]=r)}function Kc(e,n,i,o,s,t,l){var r,d,u=new Map,b=n.length,c=t.length,m=new Array(b),h;for(r=0;r<b;++r)(d=n[r])&&(m[r]=h=l.call(d,d.__data__,r,n)+"",u.has(h)?s[r]=d:u.set(h,d));for(r=0;r<c;++r)h=l.call(e,t[r],r,t)+"",(d=u.get(h))?(o[r]=d,d.__data__=t[r],u.delete(h)):i[r]=new pi(e,t[r]);for(r=0;r<b;++r)(d=n[r])&&u.get(m[r])===d&&(s[r]=d)}function Hc(e){return e.__data__}function Fc(e,n){if(!arguments.length)return Array.from(this,Hc);var i=n?Kc:Oc,o=this._parents,s=this._groups;typeof e!="function"&&(e=_c(e));for(var t=s.length,l=new Array(t),r=new Array(t),d=new Array(t),u=0;u<t;++u){var b=o[u],c=s[u],m=c.length,h=Vc(e.call(b,b&&b.__data__,u,o)),v=h.length,p=r[u]=new Array(v),y=l[u]=new Array(v),g=d[u]=new Array(m);i(b,c,p,y,g,h,n);for(var S=0,f=0,w,C;S<v;++S)if(w=p[S]){for(S>=f&&(f=S+1);!(C=y[f])&&++f<v;);w._next=C||null}}return l=new _e(l,o),l._enter=r,l._exit=d,l}function Vc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Gc(){return new _e(this._exit||this._groups.map(fa),this._parents)}function zc(e,n,i){var o=this.enter(),s=this,t=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),n!=null&&(s=n(s),s&&(s=s.selection())),i==null?t.remove():i(t),o&&s?o.merge(s).order():s}function $c(e){for(var n=e.selection?e.selection():e,i=this._groups,o=n._groups,s=i.length,t=o.length,l=Math.min(s,t),r=new Array(s),d=0;d<l;++d)for(var u=i[d],b=o[d],c=u.length,m=r[d]=new Array(c),h,v=0;v<c;++v)(h=u[v]||b[v])&&(m[v]=h);for(;d<s;++d)r[d]=i[d];return new _e(r,this._parents)}function jc(){for(var e=this._groups,n=-1,i=e.length;++n<i;)for(var o=e[n],s=o.length-1,t=o[s],l;--s>=0;)(l=o[s])&&(t&&l.compareDocumentPosition(t)^4&&t.parentNode.insertBefore(l,t),t=l);return this}function Wc(e){e||(e=Uc);function n(c,m){return c&&m?e(c.__data__,m.__data__):!c-!m}for(var i=this._groups,o=i.length,s=new Array(o),t=0;t<o;++t){for(var l=i[t],r=l.length,d=s[t]=new Array(r),u,b=0;b<r;++b)(u=l[b])&&(d[b]=u);d.sort(n)}return new _e(s,this._parents).order()}function Uc(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function qc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Yc(){return Array.from(this)}function Jc(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],s=0,t=o.length;s<t;++s){var l=o[s];if(l)return l}return null}function Zc(){let e=0;for(const n of this)++e;return e}function Xc(){return!this.node()}function Qc(e){for(var n=this._groups,i=0,o=n.length;i<o;++i)for(var s=n[i],t=0,l=s.length,r;t<l;++t)(r=s[t])&&e.call(r,r.__data__,t,s);return this}function Rc(e){return function(){this.removeAttribute(e)}}function eb(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nb(e,n){return function(){this.setAttribute(e,n)}}function ib(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function ob(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function sb(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 ab(e,n){var i=hi(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?eb:Rc:typeof n=="function"?i.local?sb:ob:i.local?ib:nb)(i,n))}function ha(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function tb(e){return function(){this.style.removeProperty(e)}}function lb(e,n,i){return function(){this.style.setProperty(e,n,i)}}function rb(e,n,i){return function(){var o=n.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,i)}}function db(e,n,i){return arguments.length>1?this.each((n==null?tb:typeof n=="function"?rb:lb)(e,n,i==null?"":i)):xn(this.node(),e)}function xn(e,n){return e.style.getPropertyValue(n)||ha(e).getComputedStyle(e,null).getPropertyValue(n)}function ub(e){return function(){delete this[e]}}function cb(e,n){return function(){this[e]=n}}function bb(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function mb(e,n){return arguments.length>1?this.each((n==null?ub:typeof n=="function"?bb:cb)(e,n)):this.node()[e]}function pa(e){return e.trim().split(/^|\s+/)}function Mo(e){return e.classList||new ga(e)}function ga(e){this._node=e,this._names=pa(e.getAttribute("class")||"")}ga.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 ya(e,n){for(var i=Mo(e),o=-1,s=n.length;++o<s;)i.add(n[o])}function xa(e,n){for(var i=Mo(e),o=-1,s=n.length;++o<s;)i.remove(n[o])}function vb(e){return function(){ya(this,e)}}function fb(e){return function(){xa(this,e)}}function hb(e,n){return function(){(n.apply(this,arguments)?ya:xa)(this,e)}}function pb(e,n){var i=pa(e+"");if(arguments.length<2){for(var o=Mo(this.node()),s=-1,t=i.length;++s<t;)if(!o.contains(i[s]))return!1;return!0}return this.each((typeof n=="function"?hb:n?vb:fb)(i,n))}function gb(){this.textContent=""}function yb(e){return function(){this.textContent=e}}function xb(e){return function(){var n=e.apply(this,arguments);this.textContent=n==null?"":n}}function Sb(e){return arguments.length?this.each(e==null?gb:(typeof e=="function"?xb:yb)(e)):this.node().textContent}function wb(){this.innerHTML=""}function Nb(e){return function(){this.innerHTML=e}}function Cb(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n==null?"":n}}function Ab(e){return arguments.length?this.each(e==null?wb:(typeof e=="function"?Cb:Nb)(e)):this.node().innerHTML}function kb(){this.nextSibling&&this.parentNode.appendChild(this)}function Eb(){return this.each(kb)}function Mb(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Tb(){return this.each(Mb)}function Pb(e){var n=typeof e=="function"?e:ca(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function Lb(){return null}function Bb(e,n){var i=typeof e=="function"?e:ca(e),o=n==null?Lb:typeof n=="function"?n:Eo(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),o.apply(this,arguments)||null)})}function Ib(){var e=this.parentNode;e&&e.removeChild(this)}function Db(){return this.each(Ib)}function _b(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function Ob(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function Kb(e){return this.select(e?Ob:_b)}function Hb(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Fb(e){return function(n){e.call(this,n,this.__data__)}}function Vb(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 Gb(e){return function(){var n=this.__on;if(n){for(var i=0,o=-1,s=n.length,t;i<s;++i)t=n[i],(!e.type||t.type===e.type)&&t.name===e.name?this.removeEventListener(t.type,t.listener,t.options):n[++o]=t;++o?n.length=o:delete this.__on}}}function zb(e,n,i){return function(){var o=this.__on,s,t=Fb(n);if(o){for(var l=0,r=o.length;l<r;++l)if((s=o[l]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=t,s.options=i),s.value=n;return}}this.addEventListener(e.type,t,i),s={type:e.type,name:e.name,value:n,listener:t,options:i},o?o.push(s):this.__on=[s]}}function $b(e,n,i){var o=Vb(e+""),s,t=o.length,l;if(arguments.length<2){var r=this.node().__on;if(r){for(var d=0,u=r.length,b;d<u;++d)for(s=0,b=r[d];s<t;++s)if((l=o[s]).type===b.type&&l.name===b.name)return b.value}return}for(r=n?zb:Gb,s=0;s<t;++s)this.each(r(o[s],n,i));return this}function Sa(e,n,i){var o=ha(e),s=o.CustomEvent;typeof s=="function"?s=new s(n,i):(s=o.document.createEvent("Event"),i?(s.initEvent(n,i.bubbles,i.cancelable),s.detail=i.detail):s.initEvent(n,!1,!1)),e.dispatchEvent(s)}function jb(e,n){return function(){return Sa(this,e,n)}}function Wb(e,n){return function(){return Sa(this,e,n.apply(this,arguments))}}function Ub(e,n){return this.each((typeof n=="function"?Wb:jb)(e,n))}function*qb(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],s=0,t=o.length,l;s<t;++s)(l=o[s])&&(yield l)}var wa=[null];function _e(e,n){this._groups=e,this._parents=n}function Hn(){return new _e([[document.documentElement]],wa)}function Yb(){return this}_e.prototype=Hn.prototype={constructor:_e,select:xc,selectAll:Cc,selectChild:Mc,selectChildren:Bc,filter:Ic,data:Fc,enter:Dc,exit:Gc,join:zc,merge:$c,selection:Yb,order:jc,sort:Wc,call:qc,nodes:Yc,node:Jc,size:Zc,empty:Xc,each:Qc,attr:ab,style:db,property:mb,classed:pb,text:Sb,html:Ab,raise:Eb,lower:Tb,append:Pb,insert:Bb,remove:Db,clone:Kb,datum:Hb,on:$b,dispatch:Ub,[Symbol.iterator]:qb};function Oe(e){return typeof e=="string"?new _e([[document.querySelector(e)]],[document.documentElement]):new _e([[e]],wa)}function Jb(e){let n;for(;n=e.sourceEvent;)e=n;return e}function He(e,n){if(e=Jb(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 s=n.getBoundingClientRect();return[e.clientX-s.left-n.clientLeft,e.clientY-s.top-n.clientTop]}}return[e.pageX,e.pageY]}const Zb={passive:!1},Fn={capture:!0,passive:!1};function To(e){e.stopImmediatePropagation()}function Sn(e){e.preventDefault(),e.stopImmediatePropagation()}function Na(e){var n=e.document.documentElement,i=Oe(e).on("dragstart.drag",Sn,Fn);"onselectstart"in n?i.on("selectstart.drag",Sn,Fn):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Ca(e,n){var i=e.document.documentElement,o=Oe(e).on("dragstart.drag",null);n&&(o.on("click.drag",Sn,Fn),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 gi=e=>()=>e;function Po(e,{sourceEvent:n,subject:i,target:o,identifier:s,active:t,x:l,y:r,dx:d,dy:u,dispatch:b}){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:s,enumerable:!0,configurable:!0},active:{value:t,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:r,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:b}})}Po.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Xb(e){return!e.ctrlKey&&!e.button}function Qb(){return this.parentNode}function Rb(e,n){return n==null?{x:e.x,y:e.y}:n}function em(){return navigator.maxTouchPoints||"ontouchstart"in this}function Aa(){var e=Xb,n=Qb,i=Rb,o=em,s={},t=vi("start","drag","end"),l=0,r,d,u,b,c=0;function m(w){w.on("mousedown.drag",h).filter(o).on("touchstart.drag",y).on("touchmove.drag",g,Zb).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,C){if(!(b||!e.call(this,w,C))){var N=f(this,n.call(this,w,C),w,C,"mouse");N&&(Oe(w.view).on("mousemove.drag",v,Fn).on("mouseup.drag",p,Fn),Na(w.view),To(w),u=!1,r=w.clientX,d=w.clientY,N("start",w))}}function v(w){if(Sn(w),!u){var C=w.clientX-r,N=w.clientY-d;u=C*C+N*N>c}s.mouse("drag",w)}function p(w){Oe(w.view).on("mousemove.drag mouseup.drag",null),Ca(w.view,u),Sn(w),s.mouse("end",w)}function y(w,C){if(e.call(this,w,C)){var N=w.changedTouches,A=n.call(this,w,C),E=N.length,k,I;for(k=0;k<E;++k)(I=f(this,A,w,C,N[k].identifier,N[k]))&&(To(w),I("start",w,N[k]))}}function g(w){var C=w.changedTouches,N=C.length,A,E;for(A=0;A<N;++A)(E=s[C[A].identifier])&&(Sn(w),E("drag",w,C[A]))}function S(w){var C=w.changedTouches,N=C.length,A,E;for(b&&clearTimeout(b),b=setTimeout(function(){b=null},500),A=0;A<N;++A)(E=s[C[A].identifier])&&(To(w),E("end",w,C[A]))}function f(w,C,N,A,E,k){var I=t.copy(),M=He(k||N,C),P,H,T;if((T=i.call(w,new Po("beforestart",{sourceEvent:N,target:m,identifier:E,active:l,x:M[0],y:M[1],dx:0,dy:0,dispatch:I}),A))!=null)return P=T.x-M[0]||0,H=T.y-M[1]||0,function L(B,O,_){var D=M,$;switch(B){case"start":s[E]=L,$=l++;break;case"end":delete s[E],--l;case"drag":M=He(_||O,C),$=l;break}I.call(B,w,new Po(B,{sourceEvent:O,subject:T,target:m,identifier:E,active:$,x:M[0]+P,y:M[1]+H,dx:M[0]-D[0],dy:M[1]-D[1],dispatch:I}),A)}}return m.filter=function(w){return arguments.length?(e=typeof w=="function"?w:gi(!!w),m):e},m.container=function(w){return arguments.length?(n=typeof w=="function"?w:gi(w),m):n},m.subject=function(w){return arguments.length?(i=typeof w=="function"?w:gi(w),m):i},m.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:gi(!!w),m):o},m.on=function(){var w=t.on.apply(t,arguments);return w===t?m:w},m.clickDistance=function(w){return arguments.length?(c=(w=+w)*w,m):Math.sqrt(c)},m}function Lo(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function ka(e,n){var i=Object.create(e.prototype);for(var o in n)i[o]=n[o];return i}function Vn(){}var Gn=.7,yi=1/Gn,wn="\\s*([+-]?\\d+)\\s*",zn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ue="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",nm=/^#([0-9a-f]{3,8})$/,im=new RegExp(`^rgb\\(${wn},${wn},${wn}\\)$`),om=new RegExp(`^rgb\\(${Ue},${Ue},${Ue}\\)$`),sm=new RegExp(`^rgba\\(${wn},${wn},${wn},${zn}\\)$`),am=new RegExp(`^rgba\\(${Ue},${Ue},${Ue},${zn}\\)$`),tm=new RegExp(`^hsl\\(${zn},${Ue},${Ue}\\)$`),lm=new RegExp(`^hsla\\(${zn},${Ue},${Ue},${zn}\\)$`),Ea={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};Lo(Vn,rn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ma,formatHex:Ma,formatHex8:rm,formatHsl:dm,formatRgb:Ta,toString:Ta});function Ma(){return this.rgb().formatHex()}function rm(){return this.rgb().formatHex8()}function dm(){return Da(this).formatHsl()}function Ta(){return this.rgb().formatRgb()}function rn(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=nm.exec(e))?(i=n[1].length,n=parseInt(n[1],16),i===6?Pa(n):i===3?new De(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):i===8?xi(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?xi(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=im.exec(e))?new De(n[1],n[2],n[3],1):(n=om.exec(e))?new De(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=sm.exec(e))?xi(n[1],n[2],n[3],n[4]):(n=am.exec(e))?xi(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=tm.exec(e))?Ia(n[1],n[2]/100,n[3]/100,1):(n=lm.exec(e))?Ia(n[1],n[2]/100,n[3]/100,n[4]):Ea.hasOwnProperty(e)?Pa(Ea[e]):e==="transparent"?new De(NaN,NaN,NaN,0):null}function Pa(e){return new De(e>>16&255,e>>8&255,e&255,1)}function xi(e,n,i,o){return o<=0&&(e=n=i=NaN),new De(e,n,i,o)}function um(e){return e instanceof Vn||(e=rn(e)),e?(e=e.rgb(),new De(e.r,e.g,e.b,e.opacity)):new De}function Bo(e,n,i,o){return arguments.length===1?um(e):new De(e,n,i,o==null?1:o)}function De(e,n,i,o){this.r=+e,this.g=+n,this.b=+i,this.opacity=+o}Lo(De,Bo,ka(Vn,{brighter(e){return e=e==null?yi:Math.pow(yi,e),new De(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Gn:Math.pow(Gn,e),new De(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new De(dn(this.r),dn(this.g),dn(this.b),Si(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:La,formatHex:La,formatHex8:cm,formatRgb:Ba,toString:Ba}));function La(){return`#${un(this.r)}${un(this.g)}${un(this.b)}`}function cm(){return`#${un(this.r)}${un(this.g)}${un(this.b)}${un((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ba(){const e=Si(this.opacity);return`${e===1?"rgb(":"rgba("}${dn(this.r)}, ${dn(this.g)}, ${dn(this.b)}${e===1?")":`, ${e})`}`}function Si(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function dn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function un(e){return e=dn(e),(e<16?"0":"")+e.toString(16)}function Ia(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 Da(e){if(e instanceof Fe)return new Fe(e.h,e.s,e.l,e.opacity);if(e instanceof Vn||(e=rn(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,s=Math.min(n,i,o),t=Math.max(n,i,o),l=NaN,r=t-s,d=(t+s)/2;return r?(n===t?l=(i-o)/r+(i<o)*6:i===t?l=(o-n)/r+2:l=(n-i)/r+4,r/=d<.5?t+s:2-t-s,l*=60):r=d>0&&d<1?0:l,new Fe(l,r,d,e.opacity)}function bm(e,n,i,o){return arguments.length===1?Da(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}Lo(Fe,bm,ka(Vn,{brighter(e){return e=e==null?yi:Math.pow(yi,e),new Fe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Gn:Math.pow(Gn,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,s=2*i-o;return new De(Io(e>=240?e-240:e+120,s,o),Io(e,s,o),Io(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new Fe(_a(this.h),wi(this.s),wi(this.l),Si(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=Si(this.opacity);return`${e===1?"hsl(":"hsla("}${_a(this.h)}, ${wi(this.s)*100}%, ${wi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _a(e){return e=(e||0)%360,e<0?e+360:e}function wi(e){return Math.max(0,Math.min(1,e||0))}function Io(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 Do=e=>()=>e;function mm(e,n){return function(i){return e+i*n}}function vm(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 fm(e){return(e=+e)==1?Oa:function(n,i){return i-n?vm(n,i,e):Do(isNaN(n)?i:n)}}function Oa(e,n){var i=n-e;return i?mm(e,i):Do(isNaN(e)?n:e)}const Ni=function e(n){var i=fm(n);function o(s,t){var l=i((s=Bo(s)).r,(t=Bo(t)).r),r=i(s.g,t.g),d=i(s.b,t.b),u=Oa(s.opacity,t.opacity);return function(b){return s.r=l(b),s.g=r(b),s.b=d(b),s.opacity=u(b),s+""}}return o.gamma=e,o}(1);function hm(e,n){n||(n=[]);var i=e?Math.min(n.length,e.length):0,o=n.slice(),s;return function(t){for(s=0;s<i;++s)o[s]=e[s]*(1-t)+n[s]*t;return o}}function pm(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function gm(e,n){var i=n?n.length:0,o=e?Math.min(i,e.length):0,s=new Array(o),t=new Array(i),l;for(l=0;l<o;++l)s[l]=$n(e[l],n[l]);for(;l<i;++l)t[l]=n[l];return function(r){for(l=0;l<o;++l)t[l]=s[l](r);return t}}function ym(e,n){var i=new Date;return e=+e,n=+n,function(o){return i.setTime(e*(1-o)+n*o),i}}function qe(e,n){return e=+e,n=+n,function(i){return e*(1-i)+n*i}}function xm(e,n){var i={},o={},s;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(s in n)s in e?i[s]=$n(e[s],n[s]):o[s]=n[s];return function(t){for(s in i)o[s]=i[s](t);return o}}var _o=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Oo=new RegExp(_o.source,"g");function Sm(e){return function(){return e}}function wm(e){return function(n){return e(n)+""}}function Ka(e,n){var i=_o.lastIndex=Oo.lastIndex=0,o,s,t,l=-1,r=[],d=[];for(e=e+"",n=n+"";(o=_o.exec(e))&&(s=Oo.exec(n));)(t=s.index)>i&&(t=n.slice(i,t),r[l]?r[l]+=t:r[++l]=t),(o=o[0])===(s=s[0])?r[l]?r[l]+=s:r[++l]=s:(r[++l]=null,d.push({i:l,x:qe(o,s)})),i=Oo.lastIndex;return i<n.length&&(t=n.slice(i),r[l]?r[l]+=t:r[++l]=t),r.length<2?d[0]?wm(d[0].x):Sm(n):(n=d.length,function(u){for(var b=0,c;b<n;++b)r[(c=d[b]).i]=c.x(u);return r.join("")})}function $n(e,n){var i=typeof n,o;return n==null||i==="boolean"?Do(n):(i==="number"?qe:i==="string"?(o=rn(n))?(n=o,Ni):Ka:n instanceof rn?Ni:n instanceof Date?ym:pm(n)?hm:Array.isArray(n)?gm:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?xm:qe)(e,n)}var Ha=180/Math.PI,Ko={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Fa(e,n,i,o,s,t){var l,r,d;return(l=Math.sqrt(e*e+n*n))&&(e/=l,n/=l),(d=e*i+n*o)&&(i-=e*d,o-=n*d),(r=Math.sqrt(i*i+o*o))&&(i/=r,o/=r,d/=r),e*o<n*i&&(e=-e,n=-n,d=-d,l=-l),{translateX:s,translateY:t,rotate:Math.atan2(n,e)*Ha,skewX:Math.atan(d)*Ha,scaleX:l,scaleY:r}}var Ci;function Nm(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Ko:Fa(n.a,n.b,n.c,n.d,n.e,n.f)}function Cm(e){return e==null||(Ci||(Ci=document.createElementNS("http://www.w3.org/2000/svg","g")),Ci.setAttribute("transform",e),!(e=Ci.transform.baseVal.consolidate()))?Ko:(e=e.matrix,Fa(e.a,e.b,e.c,e.d,e.e,e.f))}function Va(e,n,i,o){function s(u){return u.length?u.pop()+" ":""}function t(u,b,c,m,h,v){if(u!==c||b!==m){var p=h.push("translate(",null,n,null,i);v.push({i:p-4,x:qe(u,c)},{i:p-2,x:qe(b,m)})}else(c||m)&&h.push("translate("+c+n+m+i)}function l(u,b,c,m){u!==b?(u-b>180?b+=360:b-u>180&&(u+=360),m.push({i:c.push(s(c)+"rotate(",null,o)-2,x:qe(u,b)})):b&&c.push(s(c)+"rotate("+b+o)}function r(u,b,c,m){u!==b?m.push({i:c.push(s(c)+"skewX(",null,o)-2,x:qe(u,b)}):b&&c.push(s(c)+"skewX("+b+o)}function d(u,b,c,m,h,v){if(u!==c||b!==m){var p=h.push(s(h)+"scale(",null,",",null,")");v.push({i:p-4,x:qe(u,c)},{i:p-2,x:qe(b,m)})}else(c!==1||m!==1)&&h.push(s(h)+"scale("+c+","+m+")")}return function(u,b){var c=[],m=[];return u=e(u),b=e(b),t(u.translateX,u.translateY,b.translateX,b.translateY,c,m),l(u.rotate,b.rotate,c,m),r(u.skewX,b.skewX,c,m),d(u.scaleX,u.scaleY,b.scaleX,b.scaleY,c,m),u=b=null,function(h){for(var v=-1,p=m.length,y;++v<p;)c[(y=m[v]).i]=y.x(h);return c.join("")}}}var Am=Va(Nm,"px, ","px)","deg)"),km=Va(Cm,", ",")",")"),Em=1e-12;function Ga(e){return((e=Math.exp(e))+1/e)/2}function Mm(e){return((e=Math.exp(e))-1/e)/2}function Tm(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ai=function e(n,i,o){function s(t,l){var r=t[0],d=t[1],u=t[2],b=l[0],c=l[1],m=l[2],h=b-r,v=c-d,p=h*h+v*v,y,g;if(p<Em)g=Math.log(m/u)/n,y=function(A){return[r+A*h,d+A*v,u*Math.exp(n*A*g)]};else{var S=Math.sqrt(p),f=(m*m-u*u+o*p)/(2*u*i*S),w=(m*m-u*u-o*p)/(2*m*i*S),C=Math.log(Math.sqrt(f*f+1)-f),N=Math.log(Math.sqrt(w*w+1)-w);g=(N-C)/n,y=function(A){var E=A*g,k=Ga(C),I=u/(i*S)*(k*Tm(n*E+C)-Mm(C));return[r+I*h,d+I*v,u*k/Ga(n*E+C)]}}return y.duration=g*1e3*n/Math.SQRT2,y}return s.rho=function(t){var l=Math.max(.001,+t),r=l*l,d=r*r;return e(l,r,d)},s}(Math.SQRT2,2,4);var Nn=0,jn=0,Wn=0,za=1e3,ki,Un,Ei=0,cn=0,Mi=0,qn=typeof performance=="object"&&performance.now?performance:Date,$a=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ho(){return cn||($a(Pm),cn=qn.now()+Mi)}function Pm(){cn=0}function Ti(){this._call=this._time=this._next=null}Ti.prototype=ja.prototype={constructor:Ti,restart:function(e,n,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?Ho():+i)+(n==null?0:+n),!this._next&&Un!==this&&(Un?Un._next=this:ki=this,Un=this),this._call=e,this._time=i,Fo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Fo())}};function ja(e,n,i){var o=new Ti;return o.restart(e,n,i),o}function Lm(){Ho(),++Nn;for(var e=ki,n;e;)(n=cn-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Nn}function Wa(){cn=(Ei=qn.now())+Mi,Nn=jn=0;try{Lm()}finally{Nn=0,Im(),cn=0}}function Bm(){var e=qn.now(),n=e-Ei;n>za&&(Mi-=n,Ei=e)}function Im(){for(var e,n=ki,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:ki=i);Un=e,Fo(o)}function Fo(e){if(!Nn){jn&&(jn=clearTimeout(jn));var n=e-cn;n>24?(e<1/0&&(jn=setTimeout(Wa,e-qn.now()-Mi)),Wn&&(Wn=clearInterval(Wn))):(Wn||(Ei=qn.now(),Wn=setInterval(Bm,za)),Nn=1,$a(Wa))}}function Ua(e,n,i){var o=new Ti;return n=n==null?0:+n,o.restart(s=>{o.stop(),e(s+n)},n,i),o}var Dm=vi("start","end","cancel","interrupt"),_m=[],qa=0,Ya=1,Vo=2,Pi=3,Ja=4,Go=5,Li=6;function Bi(e,n,i,o,s,t){var l=e.__transition;if(!l)e.__transition={};else if(i in l)return;Om(e,i,{name:n,index:o,group:s,on:Dm,tween:_m,time:t.time,delay:t.delay,duration:t.duration,ease:t.ease,timer:null,state:qa})}function zo(e,n){var i=Ve(e,n);if(i.state>qa)throw new Error("too late; already scheduled");return i}function Ye(e,n){var i=Ve(e,n);if(i.state>Pi)throw new Error("too late; already running");return i}function Ve(e,n){var i=e.__transition;if(!i||!(i=i[n]))throw new Error("transition not found");return i}function Om(e,n,i){var o=e.__transition,s;o[n]=i,i.timer=ja(t,0,i.time);function t(u){i.state=Ya,i.timer.restart(l,i.delay,i.time),i.delay<=u&&l(u-i.delay)}function l(u){var b,c,m,h;if(i.state!==Ya)return d();for(b in o)if(h=o[b],h.name===i.name){if(h.state===Pi)return Ua(l);h.state===Ja?(h.state=Li,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[b]):+b<n&&(h.state=Li,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[b])}if(Ua(function(){i.state===Pi&&(i.state=Ja,i.timer.restart(r,i.delay,i.time),r(u))}),i.state=Vo,i.on.call("start",e,e.__data__,i.index,i.group),i.state===Vo){for(i.state=Pi,s=new Array(m=i.tween.length),b=0,c=-1;b<m;++b)(h=i.tween[b].value.call(e,e.__data__,i.index,i.group))&&(s[++c]=h);s.length=c+1}}function r(u){for(var b=u<i.duration?i.ease.call(null,u/i.duration):(i.timer.restart(d),i.state=Go,1),c=-1,m=s.length;++c<m;)s[c].call(e,b);i.state===Go&&(i.on.call("end",e,e.__data__,i.index,i.group),d())}function d(){i.state=Li,i.timer.stop(),delete o[n];for(var u in o)return;delete e.__transition}}function Ii(e,n){var i=e.__transition,o,s,t=!0,l;if(i){n=n==null?null:n+"";for(l in i){if((o=i[l]).name!==n){t=!1;continue}s=o.state>Vo&&o.state<Go,o.state=Li,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete i[l]}t&&delete e.__transition}}function Km(e){return this.each(function(){Ii(this,e)})}function Hm(e,n){var i,o;return function(){var s=Ye(this,e),t=s.tween;if(t!==i){o=i=t;for(var l=0,r=o.length;l<r;++l)if(o[l].name===n){o=o.slice(),o.splice(l,1);break}}s.tween=o}}function Fm(e,n,i){var o,s;if(typeof i!="function")throw new Error;return function(){var t=Ye(this,e),l=t.tween;if(l!==o){s=(o=l).slice();for(var r={name:n,value:i},d=0,u=s.length;d<u;++d)if(s[d].name===n){s[d]=r;break}d===u&&s.push(r)}t.tween=s}}function Vm(e,n){var i=this._id;if(e+="",arguments.length<2){for(var o=Ve(this.node(),i).tween,s=0,t=o.length,l;s<t;++s)if((l=o[s]).name===e)return l.value;return null}return this.each((n==null?Hm:Fm)(i,e,n))}function $o(e,n,i){var o=e._id;return e.each(function(){var s=Ye(this,o);(s.value||(s.value={}))[n]=i.apply(this,arguments)}),function(s){return Ve(s,o).value[n]}}function Za(e,n){var i;return(typeof n=="number"?qe:n instanceof rn?Ni:(i=rn(n))?(n=i,Ni):Ka)(e,n)}function Gm(e){return function(){this.removeAttribute(e)}}function zm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function $m(e,n,i){var o,s=i+"",t;return function(){var l=this.getAttribute(e);return l===s?null:l===o?t:t=n(o=l,i)}}function jm(e,n,i){var o,s=i+"",t;return function(){var l=this.getAttributeNS(e.space,e.local);return l===s?null:l===o?t:t=n(o=l,i)}}function Wm(e,n,i){var o,s,t;return function(){var l,r=i(this),d;return r==null?void this.removeAttribute(e):(l=this.getAttribute(e),d=r+"",l===d?null:l===o&&d===s?t:(s=d,t=n(o=l,r)))}}function Um(e,n,i){var o,s,t;return function(){var l,r=i(this),d;return r==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),d=r+"",l===d?null:l===o&&d===s?t:(s=d,t=n(o=l,r)))}}function qm(e,n){var i=hi(e),o=i==="transform"?km:Za;return this.attrTween(e,typeof n=="function"?(i.local?Um:Wm)(i,o,$o(this,"attr."+e,n)):n==null?(i.local?zm:Gm)(i):(i.local?jm:$m)(i,o,n))}function Ym(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function Jm(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function Zm(e,n){var i,o;function s(){var t=n.apply(this,arguments);return t!==o&&(i=(o=t)&&Jm(e,t)),i}return s._value=n,s}function Xm(e,n){var i,o;function s(){var t=n.apply(this,arguments);return t!==o&&(i=(o=t)&&Ym(e,t)),i}return s._value=n,s}function Qm(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=hi(e);return this.tween(i,(o.local?Zm:Xm)(o,n))}function Rm(e,n){return function(){zo(this,e).delay=+n.apply(this,arguments)}}function ev(e,n){return n=+n,function(){zo(this,e).delay=n}}function nv(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Rm:ev)(n,e)):Ve(this.node(),n).delay}function iv(e,n){return function(){Ye(this,e).duration=+n.apply(this,arguments)}}function ov(e,n){return n=+n,function(){Ye(this,e).duration=n}}function sv(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?iv:ov)(n,e)):Ve(this.node(),n).duration}function av(e,n){if(typeof n!="function")throw new Error;return function(){Ye(this,e).ease=n}}function tv(e){var n=this._id;return arguments.length?this.each(av(n,e)):Ve(this.node(),n).ease}function lv(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;Ye(this,e).ease=i}}function rv(e){if(typeof e!="function")throw new Error;return this.each(lv(this._id,e))}function dv(e){typeof e!="function"&&(e=ma(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var t=n[s],l=t.length,r=o[s]=[],d,u=0;u<l;++u)(d=t[u])&&e.call(d,d.__data__,u,t)&&r.push(d);return new Ze(o,this._parents,this._name,this._id)}function uv(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,i=e._groups,o=n.length,s=i.length,t=Math.min(o,s),l=new Array(o),r=0;r<t;++r)for(var d=n[r],u=i[r],b=d.length,c=l[r]=new Array(b),m,h=0;h<b;++h)(m=d[h]||u[h])&&(c[h]=m);for(;r<o;++r)l[r]=n[r];return new Ze(l,this._parents,this._name,this._id)}function cv(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 bv(e,n,i){var o,s,t=cv(n)?zo:Ye;return function(){var l=t(this,e),r=l.on;r!==o&&(s=(o=r).copy()).on(n,i),l.on=s}}function mv(e,n){var i=this._id;return arguments.length<2?Ve(this.node(),i).on.on(e):this.each(bv(i,e,n))}function vv(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function fv(){return this.on("end.remove",vv(this._id))}function hv(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Eo(e));for(var o=this._groups,s=o.length,t=new Array(s),l=0;l<s;++l)for(var r=o[l],d=r.length,u=t[l]=new Array(d),b,c,m=0;m<d;++m)(b=r[m])&&(c=e.call(b,b.__data__,m,r))&&("__data__"in b&&(c.__data__=b.__data__),u[m]=c,Bi(u[m],n,i,m,u,Ve(b,i)));return new Ze(t,this._parents,n,i)}function pv(e){var n=this._name,i=this._id;typeof e!="function"&&(e=ba(e));for(var o=this._groups,s=o.length,t=[],l=[],r=0;r<s;++r)for(var d=o[r],u=d.length,b,c=0;c<u;++c)if(b=d[c]){for(var m=e.call(b,b.__data__,c,d),h,v=Ve(b,i),p=0,y=m.length;p<y;++p)(h=m[p])&&Bi(h,n,i,p,m,v);t.push(m),l.push(b)}return new Ze(t,l,n,i)}var gv=Hn.prototype.constructor;function yv(){return new gv(this._groups,this._parents)}function xv(e,n){var i,o,s;return function(){var t=xn(this,e),l=(this.style.removeProperty(e),xn(this,e));return t===l?null:t===i&&l===o?s:s=n(i=t,o=l)}}function Xa(e){return function(){this.style.removeProperty(e)}}function Sv(e,n,i){var o,s=i+"",t;return function(){var l=xn(this,e);return l===s?null:l===o?t:t=n(o=l,i)}}function wv(e,n,i){var o,s,t;return function(){var l=xn(this,e),r=i(this),d=r+"";return r==null&&(d=r=(this.style.removeProperty(e),xn(this,e))),l===d?null:l===o&&d===s?t:(s=d,t=n(o=l,r))}}function Nv(e,n){var i,o,s,t="style."+n,l="end."+t,r;return function(){var d=Ye(this,e),u=d.on,b=d.value[t]==null?r||(r=Xa(n)):void 0;(u!==i||s!==b)&&(o=(i=u).copy()).on(l,s=b),d.on=o}}function Cv(e,n,i){var o=(e+="")=="transform"?Am:Za;return n==null?this.styleTween(e,xv(e,o)).on("end.style."+e,Xa(e)):typeof n=="function"?this.styleTween(e,wv(e,o,$o(this,"style."+e,n))).each(Nv(this._id,e)):this.styleTween(e,Sv(e,o,n),i).on("end.style."+e,null)}function Av(e,n,i){return function(o){this.style.setProperty(e,n.call(this,o),i)}}function kv(e,n,i){var o,s;function t(){var l=n.apply(this,arguments);return l!==s&&(o=(s=l)&&Av(e,l,i)),o}return t._value=n,t}function Ev(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,kv(e,n,i==null?"":i))}function Mv(e){return function(){this.textContent=e}}function Tv(e){return function(){var n=e(this);this.textContent=n==null?"":n}}function Pv(e){return this.tween("text",typeof e=="function"?Tv($o(this,"text",e)):Mv(e==null?"":e+""))}function Lv(e){return function(n){this.textContent=e.call(this,n)}}function Bv(e){var n,i;function o(){var s=e.apply(this,arguments);return s!==i&&(n=(i=s)&&Lv(s)),n}return o._value=e,o}function Iv(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,Bv(e))}function Dv(){for(var e=this._name,n=this._id,i=Qa(),o=this._groups,s=o.length,t=0;t<s;++t)for(var l=o[t],r=l.length,d,u=0;u<r;++u)if(d=l[u]){var b=Ve(d,n);Bi(d,e,i,u,l,{time:b.time+b.delay+b.duration,delay:0,duration:b.duration,ease:b.ease})}return new Ze(o,this._parents,e,i)}function _v(){var e,n,i=this,o=i._id,s=i.size();return new Promise(function(t,l){var r={value:l},d={value:function(){--s===0&&t()}};i.each(function(){var u=Ye(this,o),b=u.on;b!==e&&(n=(e=b).copy(),n._.cancel.push(r),n._.interrupt.push(r),n._.end.push(d)),u.on=n}),s===0&&t()})}var Ov=0;function Ze(e,n,i,o){this._groups=e,this._parents=n,this._name=i,this._id=o}function Qa(){return++Ov}var Xe=Hn.prototype;Ze.prototype={constructor:Ze,select:hv,selectAll:pv,selectChild:Xe.selectChild,selectChildren:Xe.selectChildren,filter:dv,merge:uv,selection:yv,transition:Dv,call:Xe.call,nodes:Xe.nodes,node:Xe.node,size:Xe.size,empty:Xe.empty,each:Xe.each,on:mv,attr:qm,attrTween:Qm,style:Cv,styleTween:Ev,text:Pv,textTween:Iv,remove:fv,tween:Vm,delay:nv,duration:sv,ease:tv,easeVarying:rv,end:_v,[Symbol.iterator]:Xe[Symbol.iterator]};function Kv(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Hv={time:null,delay:0,duration:250,ease:Kv};function Fv(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 Vv(e){var n,i;e instanceof Ze?(n=e._id,e=e._name):(n=Qa(),(i=Hv).time=Ho(),e=e==null?null:e+"");for(var o=this._groups,s=o.length,t=0;t<s;++t)for(var l=o[t],r=l.length,d,u=0;u<r;++u)(d=l[u])&&Bi(d,e,n,u,l,i||Fv(d,n));return new Ze(o,this._parents,e,n)}Hn.prototype.interrupt=Km,Hn.prototype.transition=Vv;const Di=e=>()=>e;function Gv(e,{sourceEvent:n,target:i,transform:o,dispatch:s}){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:s}})}function Qe(e,n,i){this.k=e,this.x=n,this.y=i}Qe.prototype={constructor:Qe,scale:function(e){return e===1?this:new Qe(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new Qe(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 _i=new Qe(1,0,0);Ra.prototype=Qe.prototype;function Ra(e){for(;!e.__zoom;)if(!(e=e.parentNode))return _i;return e.__zoom}function jo(e){e.stopImmediatePropagation()}function Yn(e){e.preventDefault(),e.stopImmediatePropagation()}function zv(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function $v(){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 et(){return this.__zoom||_i}function jv(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Wv(){return navigator.maxTouchPoints||"ontouchstart"in this}function Uv(e,n,i){var o=e.invertX(n[0][0])-i[0][0],s=e.invertX(n[1][0])-i[1][0],t=e.invertY(n[0][1])-i[0][1],l=e.invertY(n[1][1])-i[1][1];return e.translate(s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s),l>t?(t+l)/2:Math.min(0,t)||Math.max(0,l))}function nt(){var e=zv,n=$v,i=Uv,o=jv,s=Wv,t=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],r=250,d=Ai,u=vi("start","zoom","end"),b,c,m,h=500,v=150,p=0,y=10;function g(T){T.property("__zoom",et).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",I).filter(s).on("touchstart.zoom",M).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(T,L,B,O){var _=T.selection?T.selection():T;_.property("__zoom",et),T!==_?C(T,L,B,O):_.interrupt().each(function(){N(this,arguments).event(O).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},g.scaleBy=function(T,L,B,O){g.scaleTo(T,function(){var _=this.__zoom.k,D=typeof L=="function"?L.apply(this,arguments):L;return _*D},B,O)},g.scaleTo=function(T,L,B,O){g.transform(T,function(){var _=n.apply(this,arguments),D=this.__zoom,$=B==null?w(_):typeof B=="function"?B.apply(this,arguments):B,U=D.invert($),V=typeof L=="function"?L.apply(this,arguments):L;return i(f(S(D,V),$,U),_,l)},B,O)},g.translateBy=function(T,L,B,O){g.transform(T,function(){return i(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof B=="function"?B.apply(this,arguments):B),n.apply(this,arguments),l)},null,O)},g.translateTo=function(T,L,B,O,_){g.transform(T,function(){var D=n.apply(this,arguments),$=this.__zoom,U=O==null?w(D):typeof O=="function"?O.apply(this,arguments):O;return i(_i.translate(U[0],U[1]).scale($.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof B=="function"?-B.apply(this,arguments):-B),D,l)},O,_)};function S(T,L){return L=Math.max(t[0],Math.min(t[1],L)),L===T.k?T:new Qe(L,T.x,T.y)}function f(T,L,B){var O=L[0]-B[0]*T.k,_=L[1]-B[1]*T.k;return O===T.x&&_===T.y?T:new Qe(T.k,O,_)}function w(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function C(T,L,B,O){T.on("start.zoom",function(){N(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(O).end()}).tween("zoom",function(){var _=this,D=arguments,$=N(_,D).event(O),U=n.apply(_,D),V=B==null?w(U):typeof B=="function"?B.apply(_,D):B,z=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),J=_.__zoom,ne=typeof L=="function"?L.apply(_,D):L,ie=d(J.invert(V).concat(z/J.k),ne.invert(V).concat(z/ne.k));return function(Q){if(Q===1)Q=ne;else{var F=ie(Q),Y=z/F[2];Q=new Qe(Y,V[0]-F[0]*Y,V[1]-F[1]*Y)}$.zoom(null,Q)}})}function N(T,L,B){return!B&&T.__zooming||new A(T,L)}function A(T,L){this.that=T,this.args=L,this.active=0,this.sourceEvent=null,this.extent=n.apply(T,L),this.taps=0}A.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,L){return this.mouse&&T!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var L=Oe(this.that).datum();u.call(T,this.that,new Gv(T,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),L)}};function E(T,...L){if(!e.apply(this,arguments))return;var B=N(this,L).event(T),O=this.__zoom,_=Math.max(t[0],Math.min(t[1],O.k*Math.pow(2,o.apply(this,arguments)))),D=He(T);if(B.wheel)(B.mouse[0][0]!==D[0]||B.mouse[0][1]!==D[1])&&(B.mouse[1]=O.invert(B.mouse[0]=D)),clearTimeout(B.wheel);else{if(O.k===_)return;B.mouse=[D,O.invert(D)],Ii(this),B.start()}Yn(T),B.wheel=setTimeout($,v),B.zoom("mouse",i(f(S(O,_),B.mouse[0],B.mouse[1]),B.extent,l));function $(){B.wheel=null,B.end()}}function k(T,...L){if(m||!e.apply(this,arguments))return;var B=T.currentTarget,O=N(this,L,!0).event(T),_=Oe(T.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",z,!0),D=He(T,B),$=T.clientX,U=T.clientY;Na(T.view),jo(T),O.mouse=[D,this.__zoom.invert(D)],Ii(this),O.start();function V(J){if(Yn(J),!O.moved){var ne=J.clientX-$,ie=J.clientY-U;O.moved=ne*ne+ie*ie>p}O.event(J).zoom("mouse",i(f(O.that.__zoom,O.mouse[0]=He(J,B),O.mouse[1]),O.extent,l))}function z(J){_.on("mousemove.zoom mouseup.zoom",null),Ca(J.view,O.moved),Yn(J),O.event(J).end()}}function I(T,...L){if(e.apply(this,arguments)){var B=this.__zoom,O=He(T.changedTouches?T.changedTouches[0]:T,this),_=B.invert(O),D=B.k*(T.shiftKey?.5:2),$=i(f(S(B,D),O,_),n.apply(this,L),l);Yn(T),r>0?Oe(this).transition().duration(r).call(C,$,O,T):Oe(this).call(g.transform,$,O,T)}}function M(T,...L){if(e.apply(this,arguments)){var B=T.touches,O=B.length,_=N(this,L,T.changedTouches.length===O).event(T),D,$,U,V;for(jo(T),$=0;$<O;++$)U=B[$],V=He(U,this),V=[V,this.__zoom.invert(V),U.identifier],_.touch0?!_.touch1&&_.touch0[2]!==V[2]&&(_.touch1=V,_.taps=0):(_.touch0=V,D=!0,_.taps=1+!!b);b&&(b=clearTimeout(b)),D&&(_.taps<2&&(c=V[0],b=setTimeout(function(){b=null},h)),Ii(this),_.start())}}function P(T,...L){if(this.__zooming){var B=N(this,L).event(T),O=T.changedTouches,_=O.length,D,$,U,V;for(Yn(T),D=0;D<_;++D)$=O[D],U=He($,this),B.touch0&&B.touch0[2]===$.identifier?B.touch0[0]=U:B.touch1&&B.touch1[2]===$.identifier&&(B.touch1[0]=U);if($=B.that.__zoom,B.touch1){var z=B.touch0[0],J=B.touch0[1],ne=B.touch1[0],ie=B.touch1[1],Q=(Q=ne[0]-z[0])*Q+(Q=ne[1]-z[1])*Q,F=(F=ie[0]-J[0])*F+(F=ie[1]-J[1])*F;$=S($,Math.sqrt(Q/F)),U=[(z[0]+ne[0])/2,(z[1]+ne[1])/2],V=[(J[0]+ie[0])/2,(J[1]+ie[1])/2]}else if(B.touch0)U=B.touch0[0],V=B.touch0[1];else return;B.zoom("touch",i(f($,U,V),B.extent,l))}}function H(T,...L){if(this.__zooming){var B=N(this,L).event(T),O=T.changedTouches,_=O.length,D,$;for(jo(T),m&&clearTimeout(m),m=setTimeout(function(){m=null},h),D=0;D<_;++D)$=O[D],B.touch0&&B.touch0[2]===$.identifier?delete B.touch0:B.touch1&&B.touch1[2]===$.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&&($=He($,this),Math.hypot(c[0]-$[0],c[1]-$[1])<y)){var U=Oe(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return g.wheelDelta=function(T){return arguments.length?(o=typeof T=="function"?T:Di(+T),g):o},g.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Di(!!T),g):e},g.touchable=function(T){return arguments.length?(s=typeof T=="function"?T:Di(!!T),g):s},g.extent=function(T){return arguments.length?(n=typeof T=="function"?T:Di([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),g):n},g.scaleExtent=function(T){return arguments.length?(t[0]=+T[0],t[1]=+T[1],g):[t[0],t[1]]},g.translateExtent=function(T){return arguments.length?(l[0][0]=+T[0][0],l[1][0]=+T[1][0],l[0][1]=+T[0][1],l[1][1]=+T[1][1],g):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},g.constrain=function(T){return arguments.length?(i=T,g):i},g.duration=function(T){return arguments.length?(r=+T,g):r},g.interpolate=function(T){return arguments.length?(d=T,g):d},g.on=function(){var T=u.on.apply(u,arguments);return T===u?g:T},g.clickDistance=function(T){return arguments.length?(p=(T=+T)*T,g):Math.sqrt(p)},g.tapDistance=function(T){return arguments.length?(y=+T,g):y},g}const Ke={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.`},Jn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],it=["Enter"," ","Escape"],ot={"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 Cn;(function(e){e.Strict="strict",e.Loose="loose"})(Cn||(Cn={}));var bn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(bn||(bn={}));var Zn;(function(e){e.Partial="partial",e.Full="full"})(Zn||(Zn={}));const st={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var on;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(on||(on={}));var An;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(An||(An={}));var ae;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ae||(ae={}));const at={[ae.Left]:ae.Right,[ae.Right]:ae.Left,[ae.Top]:ae.Bottom,[ae.Bottom]:ae.Top};function tt(e){return e===null?null:e?"valid":"invalid"}const lt=e=>"id"in e&&"source"in e&&"target"in e,qv=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Wo=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Xn=(e,n=[0,0])=>{var r;const{width:i,height:o}=Re(e),s=(r=e.origin)!=null?r:n,t=i*s[0],l=o*s[1];return{x:e.position.x-t,y:e.position.y-l}},Yv=(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,s)=>{const t=typeof s=="string";let l=!n.nodeLookup&&!t?s:void 0;n.nodeLookup&&(l=t?n.nodeLookup.get(s):Wo(s)?s:n.nodeLookup.get(s.id));const r=l?Hi(l,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Oi(o,r)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ki(i)},Qn=(e,n={})=>{let i={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(s=>{(n.filter===void 0||n.filter(s))&&(i=Oi(i,Hi(s)),o=!0)}),o?Ki(i):{x:0,y:0,width:0,height:0}},Uo=(e,n,[i,o,s]=[0,0,1],t=!1,l=!1)=>{var m,h,v,p,y,g;const r=(n.x-i)/s,d=(n.y-o)/s,u=n.width/s,b=n.height/s,c=[];for(const S of e.values()){const{measured:f,selectable:w=!0,hidden:C=!1}=S;if(l&&!w||C)continue;const N=(v=(h=(m=f.width)!=null?m:S.width)!=null?h:S.initialWidth)!=null?v:0,A=(g=(y=(p=f.height)!=null?p:S.height)!=null?y:S.initialHeight)!=null?g:0,{x:E,y:k}=S.internals.positionAbsolute,I=bt(r,d,u,b,E,k,N,A),M=N*A,P=t&&I>0;(!S.internals.handleBounds||P||I>=M||S.dragging)&&c.push(S)}return c},Jv=(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 Zv(e,n){const i=new Map,o=n!=null&&n.nodes?new Set(n.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((n==null?void 0:n.includeHiddenNodes)||!s.hidden)&&(!o||o.has(s.id))&&i.set(s.id,s)}),i}async function Xv({nodes:e,width:n,height:i,panZoom:o,minZoom:s,maxZoom:t},l){var b,c,m;if(e.size===0)return!0;const r=Zv(e,l),d=Qn(r),u=Jo(d,n,i,(b=l==null?void 0:l.minZoom)!=null?b:s,(c=l==null?void 0:l.maxZoom)!=null?c:t,(m=l==null?void 0:l.padding)!=null?m:.1);return await o.setViewport(u,{duration:l==null?void 0:l.duration,ease:l==null?void 0:l.ease,interpolate:l==null?void 0:l.interpolate}),!0}function rt({nodeId:e,nextPosition:n,nodeLookup:i,nodeOrigin:o=[0,0],nodeExtent:s,onError:t}){var h,v,p;const l=i.get(e),r=l.parentId?i.get(l.parentId):void 0,{x:d,y:u}=r?r.internals.positionAbsolute:{x:0,y:0},b=(h=l.origin)!=null?h:o;let c=l.extent||s;if(l.extent==="parent"&&!l.expandParent)if(!r)t==null||t("005",Ke.error005());else{const y=r.measured.width,g=r.measured.height;y&&g&&(c=[[d,u],[d+y,u+g]])}else r&&vn(l.extent)&&(c=[[l.extent[0][0]+d,l.extent[0][1]+u],[l.extent[1][0]+d,l.extent[1][1]+u]]);const m=vn(c)?mn(n,c,l.measured):n;return(l.measured.width===void 0||l.measured.height===void 0)&&(t==null||t("015",Ke.error015())),{position:{x:m.x-d+((v=l.measured.width)!=null?v:0)*b[0],y:m.y-u+((p=l.measured.height)!=null?p:0)*b[1]},positionAbsolute:m}}async function Qv({nodesToRemove:e=[],edgesToRemove:n=[],nodes:i,edges:o,onBeforeDelete:s}){const t=new Set(e.map(m=>m.id)),l=[];for(const m of i){if(m.deletable===!1)continue;const h=t.has(m.id),v=!h&&m.parentId&&l.find(p=>p.id===m.parentId);(h||v)&&l.push(m)}const r=new Set(n.map(m=>m.id)),d=o.filter(m=>m.deletable!==!1),b=Jv(l,d);for(const m of d)r.has(m.id)&&!b.find(v=>v.id===m.id)&&b.push(m);if(!s)return{edges:b,nodes:l};const c=await s({nodes:l,edges:b});return typeof c=="boolean"?c?{edges:b,nodes:l}:{edges:[],nodes:[]}:c}const kn=(e,n=0,i=1)=>Math.min(Math.max(e,n),i),mn=(e={x:0,y:0},n,i)=>{var o,s;return{x:kn(e.x,n[0][0],n[1][0]-((o=i==null?void 0:i.width)!=null?o:0)),y:kn(e.y,n[0][1],n[1][1]-((s=i==null?void 0:i.height)!=null?s:0))}};function dt(e,n,i){const{width:o,height:s}=Re(i),{x:t,y:l}=i.internals.positionAbsolute;return mn(e,[[t,l],[t+o,l+s]],n)}const ut=(e,n,i)=>e<n?kn(Math.abs(e-n),1,n)/n:e>i?-kn(Math.abs(e-i),1,n)/n:0,qo=(e,n,i=15,o=40)=>{const s=ut(e.x,o,n.width-o)*i,t=ut(e.y,o,n.height-o)*i;return[s,t]},Oi=(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)}),Yo=({x:e,y:n,width:i,height:o})=>({x:e,y:n,x2:e+i,y2:n+o}),Ki=({x:e,y:n,x2:i,y2:o})=>({x:e,y:n,width:i-e,height:o-n}),Rn=(e,n=[0,0])=>{var s,t,l,r,d,u,b,c;const{x:i,y:o}=Wo(e)?e.internals.positionAbsolute:Xn(e,n);return{x:i,y:o,width:(r=(l=(t=(s=e.measured)==null?void 0:s.width)!=null?t:e.width)!=null?l:e.initialWidth)!=null?r:0,height:(c=(b=(u=(d=e.measured)==null?void 0:d.height)!=null?u:e.height)!=null?b:e.initialHeight)!=null?c:0}},Hi=(e,n=[0,0])=>{var s,t,l,r,d,u,b,c;const{x:i,y:o}=Wo(e)?e.internals.positionAbsolute:Xn(e,n);return{x:i,y:o,x2:i+((r=(l=(t=(s=e.measured)==null?void 0:s.width)!=null?t:e.width)!=null?l:e.initialWidth)!=null?r:0),y2:o+((c=(b=(u=(d=e.measured)==null?void 0:d.height)!=null?u:e.height)!=null?b:e.initialHeight)!=null?c:0)}},ct=(e,n)=>Ki(Oi(Yo(e),Yo(n))),bt=(e,n,i,o,s,t,l,r)=>{const d=Math.max(0,Math.min(e+i,s+l)-Math.max(e,s)),u=Math.max(0,Math.min(n+o,t+r)-Math.max(n,t));return Math.ceil(d*u)},Fi=(e,n)=>bt(e.x,e.y,e.width,e.height,n.x,n.y,n.width,n.height),mt=e=>Ge(e.width)&&Ge(e.height)&&Ge(e.x)&&Ge(e.y),Ge=e=>!isNaN(e)&&isFinite(e),vt=(e,n)=>(i,o)=>{process.env.NODE_ENV==="development"&&console.warn(`[${e}]: ${o} Help: ${n}error#${i}`)},ei=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),ni=({x:e,y:n},[i,o,s],t=!1,l=[1,1])=>{const r={x:(e-i)/s,y:(n-o)/s};return t?ei(r,l):r},En=({x:e,y:n},[i,o,s])=>({x:e*s+i,y:n*s+o});function Mn(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 Rv(e,n,i){var o,s,t,l,r,d,u,b;if(typeof e=="string"||typeof e=="number"){const c=Mn(e,i),m=Mn(e,n);return{top:c,right:m,bottom:c,left:m,x:m*2,y:c*2}}if(typeof e=="object"){const c=Mn((s=(o=e.top)!=null?o:e.y)!=null?s:0,i),m=Mn((l=(t=e.bottom)!=null?t:e.y)!=null?l:0,i),h=Mn((d=(r=e.left)!=null?r:e.x)!=null?d:0,n),v=Mn((b=(u=e.right)!=null?u:e.x)!=null?b:0,n);return{top:c,right:v,bottom:m,left:h,x:h+v,y:c+m}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ef(e,n,i,o,s,t){const{x:l,y:r}=En(e,[n,i,o]),{x:d,y:u}=En({x:e.x+e.width,y:e.y+e.height},[n,i,o]),b=s-d,c=t-u;return{left:Math.floor(l),top:Math.floor(r),right:Math.floor(b),bottom:Math.floor(c)}}const Jo=(e,n,i,o,s,t)=>{const l=Rv(t,n,i),r=(n-l.x)/e.width,d=(i-l.y)/e.height,u=Math.min(r,d),b=kn(u,o,s),c=e.x+e.width/2,m=e.y+e.height/2,h=n/2-c*b,v=i/2-m*b,p=ef(e,h,v,b,n,i),y={left:Math.min(p.left-l.left,0),top:Math.min(p.top-l.top,0),right:Math.min(p.right-l.right,0),bottom:Math.min(p.bottom-l.bottom,0)};return{x:h-y.left+y.right,y:v-y.top+y.bottom,zoom:b}},ii=()=>{var e;return typeof navigator!="undefined"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function vn(e){return e!=null&&e!=="parent"}function Re(e){var n,i,o,s,t,l,r,d;return{width:(s=(o=(i=(n=e.measured)==null?void 0:n.width)!=null?i:e.width)!=null?o:e.initialWidth)!=null?s:0,height:(d=(r=(l=(t=e.measured)==null?void 0:t.height)!=null?l:e.height)!=null?r:e.initialHeight)!=null?d:0}}function ft(e){var n,i,o,s,t,l;return((o=(i=(n=e.measured)==null?void 0:n.width)!=null?i:e.width)!=null?o:e.initialWidth)!==void 0&&((l=(t=(s=e.measured)==null?void 0:s.height)!=null?t:e.height)!=null?l:e.initialHeight)!==void 0}function ht(e,n={width:0,height:0},i,o,s){var r,d;const t={...e},l=o.get(i);if(l){const u=l.origin||s;t.x+=l.internals.positionAbsolute.x-((r=n.width)!=null?r:0)*u[0],t.y+=l.internals.positionAbsolute.y-((d=n.height)!=null?d:0)*u[1]}return t}function pt(e,n){if(e.size!==n.size)return!1;for(const i of e)if(!n.has(i))return!1;return!0}function nf(){let e,n;return{promise:new Promise((o,s)=>{e=o,n=s}),resolve:e,reject:n}}function of(e){return{...ot,...e||{}}}function oi(e,{snapGrid:n=[0,0],snapToGrid:i=!1,transform:o,containerBounds:s}){var b,c;const{x:t,y:l}=ze(e),r=ni({x:t-((b=s==null?void 0:s.left)!=null?b:0),y:l-((c=s==null?void 0:s.top)!=null?c:0)},o),{x:d,y:u}=i?ei(r,n):r;return{xSnapped:d,ySnapped:u,...r}}const Zo=e=>({width:e.offsetWidth,height:e.offsetHeight}),gt=e=>{var n;return((n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},sf=["INPUT","SELECT","TEXTAREA"];function yt(e){var o,s;const n=((s=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:s[0])||e.target;return(n==null?void 0:n.nodeType)!==1?!1:sf.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const xt=e=>"clientX"in e,ze=(e,n)=>{var t,l,r,d;const i=xt(e),o=i?e.clientX:(t=e.touches)==null?void 0:t[0].clientX,s=i?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:o-((r=n==null?void 0:n.left)!=null?r:0),y:s-((d=n==null?void 0:n.top)!=null?d:0)}},St=(e,n,i,o,s)=>{const t=n.querySelectorAll(`.${e}`);return!t||!t.length?null:Array.from(t).map(l=>{const r=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:s,position:l.getAttribute("data-handlepos"),x:(r.left-i.left)/o,y:(r.top-i.top)/o,...Zo(l)}})};function wt({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:s,sourceControlY:t,targetControlX:l,targetControlY:r}){const d=e*.125+s*.375+l*.375+i*.125,u=n*.125+t*.375+r*.375+o*.125,b=Math.abs(d-e),c=Math.abs(u-n);return[d,u,b,c]}function Vi(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function Nt({pos:e,x1:n,y1:i,x2:o,y2:s,c:t}){switch(e){case ae.Left:return[n-Vi(n-o,t),i];case ae.Right:return[n+Vi(o-n,t),i];case ae.Top:return[n,i-Vi(i-s,t)];case ae.Bottom:return[n,i+Vi(s-i,t)]}}function Ct({sourceX:e,sourceY:n,sourcePosition:i=ae.Bottom,targetX:o,targetY:s,targetPosition:t=ae.Top,curvature:l=.25}){const[r,d]=Nt({pos:i,x1:e,y1:n,x2:o,y2:s,c:l}),[u,b]=Nt({pos:t,x1:o,y1:s,x2:e,y2:n,c:l}),[c,m,h,v]=wt({sourceX:e,sourceY:n,targetX:o,targetY:s,sourceControlX:r,sourceControlY:d,targetControlX:u,targetControlY:b});return[`M${e},${n} C${r},${d} ${u},${b} ${o},${s}`,c,m,h,v]}function At({sourceX:e,sourceY:n,targetX:i,targetY:o}){const s=Math.abs(i-e)/2,t=i<e?i+s:i-s,l=Math.abs(o-n)/2,r=o<n?o+l:o-l;return[t,r,s,l]}function af({sourceNode:e,targetNode:n,selected:i=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:t="basic"}){if(t==="manual")return o;const l=s&&i?o+1e3:o,r=Math.max(e.parentId||s&&e.selected?e.internals.z:0,n.parentId||s&&n.selected?n.internals.z:0);return l+r}function tf({sourceNode:e,targetNode:n,width:i,height:o,transform:s}){const t=Oi(Hi(e),Hi(n));t.x===t.x2&&(t.x2+=1),t.y===t.y2&&(t.y2+=1);const l={x:-s[0]/s[2],y:-s[1]/s[2],width:i/s[2],height:o/s[2]};return Fi(l,Ki(t))>0}const lf=({source:e,sourceHandle:n,target:i,targetHandle:o})=>`xy-edge__${e}${n||""}-${i}${o||""}`,rf=(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)),df=(e,n,i={})=>{var t;if(!e.source||!e.target)return(t=i.onError)==null||t.call(i,"006",Ke.error006()),n;const o=i.getEdgeId||lf;let s;return lt(e)?s={...e}:s={...e,id:o(e)},rf(s,n)?n:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,n.concat(s))};function kt({sourceX:e,sourceY:n,targetX:i,targetY:o}){const[s,t,l,r]=At({sourceX:e,sourceY:n,targetX:i,targetY:o});return[`M ${e},${n}L ${i},${o}`,s,t,l,r]}const Et={[ae.Left]:{x:-1,y:0},[ae.Right]:{x:1,y:0},[ae.Top]:{x:0,y:-1},[ae.Bottom]:{x:0,y:1}},uf=({source:e,sourcePosition:n=ae.Bottom,target:i})=>n===ae.Left||n===ae.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},Mt=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function cf({source:e,sourcePosition:n=ae.Bottom,target:i,targetPosition:o=ae.Top,center:s,offset:t,stepPosition:l}){var E,k,I,M;const r=Et[n],d=Et[o],u={x:e.x+r.x*t,y:e.y+r.y*t},b={x:i.x+d.x*t,y:i.y+d.y*t},c=uf({source:u,sourcePosition:n,target:b}),m=c.x!==0?"x":"y",h=c[m];let v=[],p,y;const g={x:0,y:0},S={x:0,y:0},[,,f,w]=At({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(r[m]*d[m]===-1){m==="x"?(p=(E=s.x)!=null?E:u.x+(b.x-u.x)*l,y=(k=s.y)!=null?k:(u.y+b.y)/2):(p=(I=s.x)!=null?I:(u.x+b.x)/2,y=(M=s.y)!=null?M:u.y+(b.y-u.y)*l);const P=[{x:p,y:u.y},{x:p,y:b.y}],H=[{x:u.x,y},{x:b.x,y}];r[m]===h?v=m==="x"?P:H:v=m==="x"?H:P}else{const P=[{x:u.x,y:b.y}],H=[{x:b.x,y:u.y}];if(m==="x"?v=r.x===h?H:P:v=r.y===h?P:H,n===o){const _=Math.abs(e[m]-i[m]);if(_<=t){const D=Math.min(t-1,t-_);r[m]===h?g[m]=(u[m]>e[m]?-1:1)*D:S[m]=(b[m]>i[m]?-1:1)*D}}if(n!==o){const _=m==="x"?"y":"x",D=r[m]===d[_],$=u[_]>b[_],U=u[_]<b[_];(r[m]===1&&(!D&&$||D&&U)||r[m]!==1&&(!D&&U||D&&$))&&(v=m==="x"?P:H)}const T={x:u.x+g.x,y:u.y+g.y},L={x:b.x+S.x,y:b.y+S.y},B=Math.max(Math.abs(T.x-v[0].x),Math.abs(L.x-v[0].x)),O=Math.max(Math.abs(T.y-v[0].y),Math.abs(L.y-v[0].y));B>=O?(p=(T.x+L.x)/2,y=v[0].y):(p=v[0].x,y=(T.y+L.y)/2)}const C={x:u.x+g.x,y:u.y+g.y},N={x:b.x+S.x,y:b.y+S.y};return[[e,...C.x!==v[0].x||C.y!==v[0].y?[C]:[],...v,...N.x!==v[v.length-1].x||N.y!==v[v.length-1].y?[N]:[],i],p,y,f,w]}function bf(e,n,i,o){const s=Math.min(Mt(e,n)/2,Mt(n,i)/2,o),{x:t,y:l}=n;if(e.x===t&&t===i.x||e.y===l&&l===i.y)return`L${t} ${l}`;if(e.y===l){const u=e.x<i.x?-1:1,b=e.y<i.y?1:-1;return`L ${t+s*u},${l}Q ${t},${l} ${t},${l+s*b}`}const r=e.x<i.x?1:-1,d=e.y<i.y?-1:1;return`L ${t},${l+s*d}Q ${t},${l} ${t+s*r},${l}`}function Xo({sourceX:e,sourceY:n,sourcePosition:i=ae.Bottom,targetX:o,targetY:s,targetPosition:t=ae.Top,borderRadius:l=5,centerX:r,centerY:d,offset:u=20,stepPosition:b=.5}){const[c,m,h,v,p]=cf({source:{x:e,y:n},sourcePosition:i,target:{x:o,y:s},targetPosition:t,center:{x:r,y:d},offset:u,stepPosition:b});let y=`M${c[0].x} ${c[0].y}`;for(let g=1;g<c.length-1;g++)y+=bf(c[g-1],c[g],c[g+1],l);return y+=`L${c[c.length-1].x} ${c[c.length-1].y}`,[y,m,h,v,p]}function Tt(e){var n;return e&&!!(e.internals.handleBounds||(n=e.handles)!=null&&n.length)&&!!(e.measured.width||e.width||e.initialWidth)}function mf(e){var c,m,h,v,p;const{sourceNode:n,targetNode:i}=e;if(!Tt(n)||!Tt(i))return null;const o=n.internals.handleBounds||Pt(n.handles),s=i.internals.handleBounds||Pt(i.handles),t=Lt((c=o==null?void 0:o.source)!=null?c:[],e.sourceHandle),l=Lt(e.connectionMode===Cn.Strict?(m=s==null?void 0:s.target)!=null?m:[]:((h=s==null?void 0:s.target)!=null?h:[]).concat((v=s==null?void 0:s.source)!=null?v:[]),e.targetHandle);if(!t||!l)return(p=e.onError)==null||p.call(e,"008",Ke.error008(t?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const r=(t==null?void 0:t.position)||ae.Bottom,d=(l==null?void 0:l.position)||ae.Top,u=fn(n,t,r),b=fn(i,l,d);return{sourceX:u.x,sourceY:u.y,targetX:b.x,targetY:b.y,sourcePosition:r,targetPosition:d}}function Pt(e){var o,s;if(!e)return null;const n=[],i=[];for(const t of e)t.width=(o=t.width)!=null?o:1,t.height=(s=t.height)!=null?s:1,t.type==="source"?n.push(t):t.type==="target"&&i.push(t);return{source:n,target:i}}function fn(e,n,i=ae.Left,o=!1){var u,b,c;const s=((u=n==null?void 0:n.x)!=null?u:0)+e.internals.positionAbsolute.x,t=((b=n==null?void 0:n.y)!=null?b:0)+e.internals.positionAbsolute.y,{width:l,height:r}=n!=null?n:Re(e);if(o)return{x:s+l/2,y:t+r/2};switch((c=n==null?void 0:n.position)!=null?c:i){case ae.Top:return{x:s+l/2,y:t};case ae.Right:return{x:s+l,y:t+r/2};case ae.Bottom:return{x:s+l/2,y:t+r};case ae.Left:return{x:s,y:t+r/2}}}function Lt(e,n){return e&&(n?e.find(i=>i.id===n):e[0])||null}function Qo(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function vf(e,{id:n,defaultColor:i,defaultMarkerStart:o,defaultMarkerEnd:s}){const t=new Set;return e.reduce((l,r)=>([r.markerStart||o,r.markerEnd||s].forEach(d=>{if(d&&typeof d=="object"){const u=Qo(d,n);t.has(u)||(l.push({id:u,color:d.color||i,...d}),t.add(u))}}),l),[]).sort((l,r)=>l.id.localeCompare(r.id))}const Bt=1e3,ff=10,Ro={nodeOrigin:[0,0],nodeExtent:Jn,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},hf={...Ro,checkEquality:!0};function es(e,n){const i={...e};for(const o in n)n[o]!==void 0&&(i[o]=n[o]);return i}function pf(e,n,i){const o=es(Ro,i);for(const s of e.values())if(s.parentId)os(s,e,n,o);else{const t=Xn(s,o.nodeOrigin),l=vn(s.extent)?s.extent:o.nodeExtent,r=mn(t,l,Re(s));s.internals.positionAbsolute=r}}function gf(e,n){var s,t;if(!e.handles)return e.measured?n==null?void 0:n.internals.handleBounds:void 0;const i=[],o=[];for(const l of e.handles){const r={id:l.id,width:(s=l.width)!=null?s:1,height:(t=l.height)!=null?t:1,nodeId:e.id,x:l.x,y:l.y,position:l.position,type:l.type};l.type==="source"?i.push(r):l.type==="target"&&o.push(r)}return{source:i,target:o}}function ns(e){return e==="manual"}function is(e,n,i,o={}){var b,c,m;const s=es(hf,o),t={i:0},l=new Map(n),r=s!=null&&s.elevateNodesOnSelect&&!ns(s.zIndexMode)?Bt:0;let d=e.length>0,u=!1;n.clear(),i.clear();for(const h of e){let v=l.get(h.id);if(s.checkEquality&&h===(v==null?void 0:v.internals.userNode))n.set(h.id,v);else{const p=Xn(h,s.nodeOrigin),y=vn(h.extent)?h.extent:s.nodeExtent,g=mn(p,y,Re(h));v={...s.defaults,...h,measured:{width:(b=h.measured)==null?void 0:b.width,height:(c=h.measured)==null?void 0:c.height},internals:{positionAbsolute:g,handleBounds:gf(h,v),z:It(h,r,s.zIndexMode),userNode:h}},n.set(h.id,v)}(v.measured===void 0||v.measured.width===void 0||v.measured.height===void 0)&&!v.hidden&&(d=!1),h.parentId&&os(v,n,i,o,t),u||(u=(m=h.selected)!=null?m:!1)}return{nodesInitialized:d,hasSelectedNodes:u}}function yf(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 os(e,n,i,o,s){const{elevateNodesOnSelect:t,nodeOrigin:l,nodeExtent:r,zIndexMode:d}=es(Ro,o),u=e.parentId,b=n.get(u);if(!b){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}yf(e,i),s&&!b.parentId&&b.internals.rootParentIndex===void 0&&d==="auto"&&(b.internals.rootParentIndex=++s.i,b.internals.z=b.internals.z+s.i*ff),s&&b.internals.rootParentIndex!==void 0&&(s.i=b.internals.rootParentIndex);const c=t&&!ns(d)?Bt:0,{x:m,y:h,z:v}=xf(e,b,l,r,c,d),{positionAbsolute:p}=e.internals,y=m!==p.x||h!==p.y;(y||v!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:m,y:h}:p,z:v}})}function It(e,n,i){const o=Ge(e.zIndex)?e.zIndex:0;return ns(i)?o:o+(e.selected?n:0)}function xf(e,n,i,o,s,t){var v;const{x:l,y:r}=n.internals.positionAbsolute,d=Re(e),u=Xn(e,i),b=vn(e.extent)?mn(u,e.extent,d):u;let c=mn({x:l+b.x,y:r+b.y},o,d);e.extent==="parent"&&(c=dt(c,d,n));const m=It(e,s,t),h=(v=n.internals.z)!=null?v:0;return{x:c.x,y:c.y,z:h>=m?h+1:m}}function ss(e,n,i,o=[0,0]){var l,r;const s=[],t=new Map;for(const d of e){const u=n.get(d.parentId);if(!u)continue;const b=(r=(l=t.get(d.parentId))==null?void 0:l.expandedRect)!=null?r:Rn(u),c=ct(b,d.rect);t.set(d.parentId,{expandedRect:c,parent:u})}return t.size>0&&t.forEach(({expandedRect:d,parent:u},b)=>{var w,C;const c=u.internals.positionAbsolute,m=Re(u),h=(w=u.origin)!=null?w:o,v=d.x<c.x?Math.round(Math.abs(c.x-d.x)):0,p=d.y<c.y?Math.round(Math.abs(c.y-d.y)):0,y=Math.max(m.width,Math.round(d.width)),g=Math.max(m.height,Math.round(d.height)),S=(y-m.width)*h[0],f=(g-m.height)*h[1];(v>0||p>0||S||f)&&(s.push({id:b,type:"position",position:{x:u.position.x-v+S,y:u.position.y-p+f}}),(C=i.get(b))==null||C.forEach(N=>{e.some(A=>A.id===N.id)||s.push({id:N.id,type:"position",position:{x:N.position.x+v,y:N.position.y+p}})})),(m.width<d.width||m.height<d.height||v||p)&&s.push({id:b,type:"dimensions",setAttributes:!0,dimensions:{width:y+(v?h[0]*v-S:0),height:g+(p?h[1]*p-f:0)}})}),s}function Sf(e,n,i,o,s,t,l){const r=o==null?void 0:o.querySelector(".xyflow__viewport");let d=!1;if(!r)return{changes:[],updatedInternals:d};const u=[],b=window.getComputedStyle(r),{m22:c}=new window.DOMMatrixReadOnly(b.transform),m=[];for(const h of e.values()){const v=n.get(h.id);if(!v)continue;if(v.hidden){n.set(v.id,{...v,internals:{...v.internals,handleBounds:void 0}}),d=!0;continue}const p=Zo(h.nodeElement),y=v.measured.width!==p.width||v.measured.height!==p.height;if(!!(p.width&&p.height&&(y||!v.internals.handleBounds||h.force))){const S=h.nodeElement.getBoundingClientRect(),f=vn(v.extent)?v.extent:t;let{positionAbsolute:w}=v.internals;v.parentId&&v.extent==="parent"?w=dt(w,p,n.get(v.parentId)):f&&(w=mn(w,f,p));const C={...v,measured:p,internals:{...v.internals,positionAbsolute:w,handleBounds:{source:St("source",h.nodeElement,S,c,v.id),target:St("target",h.nodeElement,S,c,v.id)}}};n.set(v.id,C),v.parentId&&os(C,n,i,{nodeOrigin:s,zIndexMode:l}),d=!0,y&&(u.push({id:v.id,type:"dimensions",dimensions:p}),v.expandParent&&v.parentId&&m.push({id:v.id,parentId:v.parentId,rect:Rn(C,s)}))}}if(m.length>0){const h=ss(m,n,i,s);u.push(...h)}return{changes:u,updatedInternals:d}}async function wf({delta:e,panZoom:n,transform:i,translateExtent:o,width:s,height:t}){if(!n||!e.x&&!e.y)return!1;const l=await n.setViewportConstrained({x:i[0]+e.x,y:i[1]+e.y,zoom:i[2]},[[0,0],[s,t]],o);return!!l&&(l.x!==i[0]||l.y!==i[1]||l.k!==i[2])}function Dt(e,n,i,o,s,t){let l=s;const r=o.get(l)||new Map;o.set(l,r.set(i,n)),l=`${s}-${e}`;const d=o.get(l)||new Map;if(o.set(l,d.set(i,n)),t){l=`${s}-${e}-${t}`;const u=o.get(l)||new Map;o.set(l,u.set(i,n))}}function _t(e,n,i){e.clear(),n.clear();for(const o of i){const{source:s,target:t,sourceHandle:l=null,targetHandle:r=null}=o,d={edgeId:o.id,source:s,target:t,sourceHandle:l,targetHandle:r},u=`${s}-${l}--${t}-${r}`,b=`${t}-${r}--${s}-${l}`;Dt("source",d,b,e,s,l),Dt("target",d,u,e,t,r),n.set(o.id,o)}}function Ot(e,n){if(!e.parentId)return!1;const i=n.get(e.parentId);return i?i.selected?!0:Ot(i,n):!1}function Kt(e,n,i){var s;let o=e;do{if((s=o==null?void 0:o.matches)!=null&&s.call(o,n))return!0;if(o===i)return!1;o=o==null?void 0:o.parentElement}while(o);return!1}function Nf(e,n,i,o){var t,l;const s=new Map;for(const[r,d]of e)if((d.selected||d.id===o)&&(!d.parentId||!Ot(d,e))&&(d.draggable||n&&typeof d.draggable=="undefined")){const u=e.get(r);u&&s.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:(t=u.measured.width)!=null?t:0,height:(l=u.measured.height)!=null?l:0}})}return s}function as({nodeId:e,dragItems:n,nodeLookup:i,dragging:o=!0}){var l,r,d;const s=[];for(const[u,b]of n){const c=(l=i.get(u))==null?void 0:l.internals.userNode;c&&s.push({...c,position:b.position,dragging:o})}if(!e)return[s[0],s];const t=(r=i.get(e))==null?void 0:r.internals.userNode;return[t?{...t,position:((d=n.get(e))==null?void 0:d.position)||t.position,dragging:o}:s[0],s]}function Cf({dragItems:e,snapGrid:n,x:i,y:o}){const s=e.values().next().value;if(!s)return null;const t={x:i-s.distance.x,y:o-s.distance.y},l=ei(t,n);return{x:l.x-t.x,y:l.y-t.y}}function Af({onNodeMouseDown:e,getStoreItems:n,onDragStart:i,onDrag:o,onDragStop:s}){let t={x:null,y:null},l=0,r=new Map,d=!1,u={x:0,y:0},b=null,c=!1,m=null,h=!1,v=!1,p=null;function y({noDragClassName:S,handleSelector:f,domNode:w,isSelectable:C,nodeId:N,nodeClickDistance:A=0}){m=Oe(w);function E({x:P,y:H}){const{nodeLookup:T,nodeExtent:L,snapGrid:B,snapToGrid:O,nodeOrigin:_,onNodeDrag:D,onSelectionDrag:$,onError:U,updateNodePositions:V}=n();t={x:P,y:H};let z=!1;const J=r.size>1,ne=J&&L?Yo(Qn(r)):null,ie=J&&O?Cf({dragItems:r,snapGrid:B,x:P,y:H}):null;for(const[Q,F]of r){if(!T.has(Q))continue;let Y={x:P-F.distance.x,y:H-F.distance.y};O&&(Y=ie?{x:Math.round(Y.x+ie.x),y:Math.round(Y.y+ie.y)}:ei(Y,B));let oe=null;if(J&&L&&!F.extent&&ne){const{positionAbsolute:W}=F.internals,G=W.x-ne.x+L[0][0],j=W.x+F.measured.width-ne.x2+L[1][0],ee=W.y-ne.y+L[0][1],X=W.y+F.measured.height-ne.y2+L[1][1];oe=[[G,ee],[j,X]]}const{position:K,positionAbsolute:q}=rt({nodeId:Q,nextPosition:Y,nodeLookup:T,nodeExtent:oe||L,nodeOrigin:_,onError:U});z=z||F.position.x!==K.x||F.position.y!==K.y,F.position=K,F.internals.positionAbsolute=q}if(v=v||z,!!z&&(V(r,!0),p&&(o||D||!N&&$))){const[Q,F]=as({nodeId:N,dragItems:r,nodeLookup:T});o==null||o(p,r,Q,F),D==null||D(p,Q,F),N||$==null||$(p,F)}}async function k(){var _,D;if(!b)return;const{transform:P,panBy:H,autoPanSpeed:T,autoPanOnNodeDrag:L}=n();if(!L){d=!1,cancelAnimationFrame(l);return}const[B,O]=qo(u,b,T);(B!==0||O!==0)&&(t.x=((_=t.x)!=null?_:0)-B/P[2],t.y=((D=t.y)!=null?D:0)-O/P[2],await H({x:B,y:O})&&E(t)),l=requestAnimationFrame(k)}function I(P){var J;const{nodeLookup:H,multiSelectionActive:T,nodesDraggable:L,transform:B,snapGrid:O,snapToGrid:_,selectNodesOnDrag:D,onNodeDragStart:$,onSelectionDragStart:U,unselectNodesAndEdges:V}=n();c=!0,(!D||!C)&&!T&&N&&((J=H.get(N))!=null&&J.selected||V()),C&&D&&N&&(e==null||e(N));const z=oi(P.sourceEvent,{transform:B,snapGrid:O,snapToGrid:_,containerBounds:b});if(t=z,r=Nf(H,L,z,N),r.size>0&&(i||$||!N&&U)){const[ne,ie]=as({nodeId:N,dragItems:r,nodeLookup:H});i==null||i(P.sourceEvent,r,ne,ie),$==null||$(P.sourceEvent,ne,ie),N||U==null||U(P.sourceEvent,ie)}}const M=Aa().clickDistance(A).on("start",P=>{const{domNode:H,nodeDragThreshold:T,transform:L,snapGrid:B,snapToGrid:O}=n();b=(H==null?void 0:H.getBoundingClientRect())||null,h=!1,v=!1,p=P.sourceEvent,T===0&&I(P),t=oi(P.sourceEvent,{transform:L,snapGrid:B,snapToGrid:O,containerBounds:b}),u=ze(P.sourceEvent,b)}).on("drag",P=>{const{autoPanOnNodeDrag:H,transform:T,snapGrid:L,snapToGrid:B,nodeDragThreshold:O,nodeLookup:_}=n(),D=oi(P.sourceEvent,{transform:T,snapGrid:L,snapToGrid:B,containerBounds:b});if(p=P.sourceEvent,(P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1||N&&!_.has(N))&&(h=!0),!h){if(!d&&H&&c&&(d=!0,k()),!c){const $=ze(P.sourceEvent,b),U=$.x-u.x,V=$.y-u.y;Math.sqrt(U*U+V*V)>O&&I(P)}(t.x!==D.xSnapped||t.y!==D.ySnapped)&&r&&c&&(u=ze(P.sourceEvent,b),E(D))}}).on("end",P=>{if(!c||h){h&&r.size>0&&n().updateNodePositions(r,!1);return}if(d=!1,c=!1,cancelAnimationFrame(l),r.size>0){const{nodeLookup:H,updateNodePositions:T,onNodeDragStop:L,onSelectionDragStop:B}=n();if(v&&(T(r,!1),v=!1),s||L||!N&&B){const[O,_]=as({nodeId:N,dragItems:r,nodeLookup:H,dragging:!1});s==null||s(P.sourceEvent,r,O,_),L==null||L(P.sourceEvent,O,_),N||B==null||B(P.sourceEvent,_)}}}).filter(P=>{const H=P.target;return!P.button&&(!S||!Kt(H,`.${S}`,w))&&(!f||Kt(H,f,w))});m.call(M)}function g(){m==null||m.on(".drag",null)}return{update:y,destroy:g}}function kf(e,n,i){const o=[],s={x:e.x-i,y:e.y-i,width:i*2,height:i*2};for(const t of n.values())Fi(s,Rn(t))>0&&o.push(t);return o}const Ef=250;function Mf(e,n,i,o){var r,d,u,b,c;let s=[],t=1/0;const l=kf(e,i,n+Ef);for(const m of l){const h=[...(d=(r=m.internals.handleBounds)==null?void 0:r.source)!=null?d:[],...(b=(u=m.internals.handleBounds)==null?void 0:u.target)!=null?b:[]];for(const v of h){if(o.nodeId===v.nodeId&&o.type===v.type&&o.id===v.id)continue;const{x:p,y}=fn(m,v,v.position,!0),g=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(y-e.y,2));g>n||(g<t?(s=[{...v,x:p,y}],t=g):g===t&&s.push({...v,x:p,y}))}}if(!s.length)return null;if(s.length>1){const m=o.type==="source"?"target":"source";return(c=s.find(h=>h.type===m))!=null?c:s[0]}return s[0]}function Ht(e,n,i,o,s,t=!1){var u,b,c,m,h,v;const l=o.get(e);if(!l)return null;const r=s==="strict"?(u=l.internals.handleBounds)==null?void 0:u[n]:[...(c=(b=l.internals.handleBounds)==null?void 0:b.source)!=null?c:[],...(h=(m=l.internals.handleBounds)==null?void 0:m.target)!=null?h:[]],d=(v=i?r==null?void 0:r.find(p=>p.id===i):r==null?void 0:r[0])!=null?v:null;return d&&t?{...d,...fn(l,d,d.position,!0)}:d}function Ft(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function Tf(e,n){let i=null;return n?i=!0:e&&!n&&(i=!1),i}const Vt=()=>!0;function Pf(e,{connectionMode:n,connectionRadius:i,handleId:o,nodeId:s,edgeUpdaterType:t,isTarget:l,domNode:r,nodeLookup:d,lib:u,autoPanOnConnect:b,flowId:c,panBy:m,cancelConnection:h,onConnectStart:v,onConnect:p,onConnectEnd:y,isValidConnection:g=Vt,onReconnectEnd:S,updateConnection:f,getTransform:w,getFromHandle:C,autoPanSpeed:N,dragThreshold:A=1,handleDomNode:E}){const k=gt(e.target);let I=0,M;const{x:P,y:H}=ze(e),T=Ft(t,E),L=r==null?void 0:r.getBoundingClientRect();let B=!1;if(!L||!T)return;const O=Ht(s,T,o,d,n);if(!O)return;let _=ze(e,L),D=!1,$=null,U=!1,V=null;function z(){if(!b||!L)return;const[K,q]=qo(_,L,N);m({x:K,y:q}),I=requestAnimationFrame(z)}const J={...O,nodeId:s,type:T,position:O.position},ne=d.get(s);let Q={inProgress:!0,isValid:null,from:fn(ne,J,ae.Left,!0),fromHandle:J,fromPosition:J.position,fromNode:ne,to:_,toHandle:null,toPosition:at[J.position],toNode:null,pointer:_};function F(){B=!0,f(Q),v==null||v(e,{nodeId:s,handleId:o,handleType:T})}A===0&&F();function Y(K){if(!B){const{x:X,y:Z}=ze(K),se=X-P,le=Z-H;if(!(se*se+le*le>A*A))return;F()}if(!C()||!J){oe(K);return}const q=w();_=ze(K,L),M=Mf(ni(_,q,!1,[1,1]),i,d,J),D||(z(),D=!0);const W=Gt(K,{handle:M,connectionMode:n,fromNodeId:s,fromHandleId:o,fromType:l?"target":"source",isValidConnection:g,doc:k,lib:u,flowId:c,nodeLookup:d});V=W.handleDomNode,$=W.connection,U=Tf(!!M,W.isValid);const G=d.get(s),j=G?fn(G,J,ae.Left,!0):Q.from,ee={...Q,from:j,isValid:U,to:W.toHandle&&U?En({x:W.toHandle.x,y:W.toHandle.y},q):_,toHandle:W.toHandle,toPosition:U&&W.toHandle?W.toHandle.position:at[J.position],toNode:W.toHandle?d.get(W.toHandle.nodeId):null,pointer:_};f(ee),Q=ee}function oe(K){if(!("touches"in K&&K.touches.length>0)){if(B){(M||V)&&$&&U&&(p==null||p($));const{inProgress:q,...W}=Q,G={...W,toPosition:Q.toHandle?Q.toPosition:null};y==null||y(K,G),t&&(S==null||S(K,G))}h(),cancelAnimationFrame(I),D=!1,U=!1,$=null,V=null,k.removeEventListener("mousemove",Y),k.removeEventListener("mouseup",oe),k.removeEventListener("touchmove",Y),k.removeEventListener("touchend",oe)}}k.addEventListener("mousemove",Y),k.addEventListener("mouseup",oe),k.addEventListener("touchmove",Y),k.addEventListener("touchend",oe)}function Gt(e,{handle:n,connectionMode:i,fromNodeId:o,fromHandleId:s,fromType:t,doc:l,lib:r,flowId:d,isValidConnection:u=Vt,nodeLookup:b}){const c=t==="target",m=n?l.querySelector(`.${r}-flow__handle[data-id="${d}-${n==null?void 0:n.nodeId}-${n==null?void 0:n.id}-${n==null?void 0:n.type}"]`):null,{x:h,y:v}=ze(e),p=l.elementFromPoint(h,v),y=p!=null&&p.classList.contains(`${r}-flow__handle`)?p:m,g={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const S=Ft(void 0,y),f=y.getAttribute("data-nodeid"),w=y.getAttribute("data-handleid"),C=y.classList.contains("connectable"),N=y.classList.contains("connectableend");if(!f||!S)return g;const A={source:c?f:o,sourceHandle:c?w:s,target:c?o:f,targetHandle:c?s:w};g.connection=A;const k=C&&N&&(i===Cn.Strict?c&&S==="source"||!c&&S==="target":f!==o||w!==s);g.isValid=k&&u(A),g.toHandle=Ht(f,S,w,b,i,!0)}return g}const ts={onPointerDown:Pf,isValid:Gt};function Lf({domNode:e,panZoom:n,getTransform:i,getViewScale:o}){const s=Oe(e);function t({translateExtent:r,width:d,height:u,zoomStep:b=1,pannable:c=!0,zoomable:m=!0,inversePan:h=!1}){const v=f=>{if(f.sourceEvent.type!=="wheel"||!n)return;const w=i(),C=f.sourceEvent.ctrlKey&&ii()?10:1,N=-f.sourceEvent.deltaY*(f.sourceEvent.deltaMode===1?.05:f.sourceEvent.deltaMode?1:.002)*b,A=w[2]*Math.pow(2,N*C);n.scaleTo(A)};let p=[0,0];const y=f=>{var w,C;(f.sourceEvent.type==="mousedown"||f.sourceEvent.type==="touchstart")&&(p=[(w=f.sourceEvent.clientX)!=null?w:f.sourceEvent.touches[0].clientX,(C=f.sourceEvent.clientY)!=null?C:f.sourceEvent.touches[0].clientY])},g=f=>{var I,M;const w=i();if(f.sourceEvent.type!=="mousemove"&&f.sourceEvent.type!=="touchmove"||!n)return;const C=[(I=f.sourceEvent.clientX)!=null?I:f.sourceEvent.touches[0].clientX,(M=f.sourceEvent.clientY)!=null?M:f.sourceEvent.touches[0].clientY],N=[C[0]-p[0],C[1]-p[1]];p=C;const A=o()*Math.max(w[2],Math.log(w[2]))*(h?-1:1),E={x:w[0]-N[0]*A,y:w[1]-N[1]*A},k=[[0,0],[d,u]];n.setViewportConstrained({x:E.x,y:E.y,zoom:w[2]},k,r)},S=nt().on("start",y).on("zoom",c?g:null).on("zoom.wheel",m?v:null);s.call(S,{})}function l(){s.on("zoom",null)}return{update:t,destroy:l,pointer:He}}const Gi=e=>({x:e.x,y:e.y,zoom:e.k}),ls=({x:e,y:n,zoom:i})=>_i.translate(e,n).scale(i),Tn=(e,n)=>e.target.closest(`.${n}`),zt=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Bf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,rs=(e,n=0,i=Bf,o=()=>{})=>{const s=typeof n=="number"&&n>0;return s||o(),s?e.transition().duration(n).ease(i).on("end",o):e},$t=e=>{const n=e.ctrlKey&&ii()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function If({zoomPanValues:e,noWheelClassName:n,d3Selection:i,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:t,zoomOnPinch:l,onPanZoomStart:r,onPanZoom:d,onPanZoomEnd:u}){return b=>{if(Tn(b,n))return b.ctrlKey&&b.preventDefault(),!1;b.preventDefault(),b.stopImmediatePropagation();const c=i.property("__zoom").k||1;if(b.ctrlKey&&l){const y=He(b),g=$t(b),S=c*Math.pow(2,g);o.scaleTo(i,S,y,b);return}const m=b.deltaMode===1?20:1;let h=s===bn.Vertical?0:b.deltaX*m,v=s===bn.Horizontal?0:b.deltaY*m;!ii()&&b.shiftKey&&s!==bn.Vertical&&(h=b.deltaY*m,v=0),o.translateBy(i,-(h/c)*t,-(v/c)*t,{internal:!0});const p=Gi(i.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d==null||d(b,p),e.panScrollTimeout=setTimeout(()=>{u==null||u(b,p),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,r==null||r(b,p))}}function Df({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:i}){return function(o,s){const t=o.type==="wheel",l=!n&&t&&!o.ctrlKey,r=Tn(o,e);if(o.ctrlKey&&t&&r&&o.preventDefault(),l||r)return null;o.preventDefault(),i.call(this,o,s)}}function _f({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:i}){return o=>{var t,l,r;if((t=o.sourceEvent)!=null&&t.internal)return;const s=Gi(o.transform);e.mouseButton=((l=o.sourceEvent)==null?void 0:l.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((r=o.sourceEvent)==null?void 0:r.type)==="mousedown"&&n(!0),i&&(i==null||i(o.sourceEvent,s))}}function Of({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:i,onTransformChange:o,onPanZoom:s}){return t=>{var l,r,d;e.usedRightMouseButton=!!(i&&zt(n,(l=e.mouseButton)!=null?l:0)),(r=t.sourceEvent)!=null&&r.sync||o([t.transform.x,t.transform.y,t.transform.k]),s&&!((d=t.sourceEvent)!=null&&d.internal)&&(s==null||s(t.sourceEvent,Gi(t.transform)))}}function Kf({zoomPanValues:e,panOnDrag:n,panOnScroll:i,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:t}){return l=>{var r,d;if(!((r=l.sourceEvent)!=null&&r.internal)&&(e.isZoomingOrPanning=!1,t&&zt(n,(d=e.mouseButton)!=null?d:0)&&!e.usedRightMouseButton&&l.sourceEvent&&t(l.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const u=Gi(l.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(l.sourceEvent,u)},i?150:0)}}}function Hf({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:i,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:t,userSelectionActive:l,noWheelClassName:r,noPanClassName:d,lib:u,connectionInProgress:b}){return c=>{var y;const m=e||n,h=i&&c.ctrlKey,v=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(Tn(c,`${u}-flow__node`)||Tn(c,`${u}-flow__edge`)))return!0;if(!o&&!m&&!s&&!t&&!i||l||b&&!v||Tn(c,r)&&v||Tn(c,d)&&(!v||s&&v&&!e)||!i&&c.ctrlKey&&v)return!1;if(!i&&c.type==="touchstart"&&((y=c.touches)==null?void 0:y.length)>1)return c.preventDefault(),!1;if(!m&&!s&&!h&&v||!o&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(o)&&!o.includes(c.button)&&c.type==="mousedown")return!1;const p=Array.isArray(o)&&o.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||v)&&p}}function Ff({domNode:e,minZoom:n,maxZoom:i,translateExtent:o,viewport:s,onPanZoom:t,onPanZoomStart:l,onPanZoomEnd:r,onDraggingChange:d}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},b=e.getBoundingClientRect(),c=nt().scaleExtent([n,i]).translateExtent(o),m=Oe(e).call(c);S({x:s.x,y:s.y,zoom:kn(s.zoom,n,i)},[[0,0],[b.width,b.height]],o);const h=m.on("wheel.zoom"),v=m.on("dblclick.zoom");c.wheelDelta($t);async function p(M,P){return m?new Promise(H=>{c==null||c.interpolate((P==null?void 0:P.interpolate)==="linear"?$n:Ai).transform(rs(m,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),M)}):!1}function y({noWheelClassName:M,noPanClassName:P,onPaneContextMenu:H,userSelectionActive:T,panOnScroll:L,panOnDrag:B,panOnScrollMode:O,panOnScrollSpeed:_,preventScrolling:D,zoomOnPinch:$,zoomOnScroll:U,zoomOnDoubleClick:V,zoomActivationKeyPressed:z,lib:J,onTransformChange:ne,connectionInProgress:ie,paneClickDistance:Q,selectionOnDrag:F}){T&&!u.isZoomingOrPanning&&g();const Y=L&&!z&&!T;c.clickDistance(F?1/0:!Ge(Q)||Q<0?0:Q);const oe=Y?If({zoomPanValues:u,noWheelClassName:M,d3Selection:m,d3Zoom:c,panOnScrollMode:O,panOnScrollSpeed:_,zoomOnPinch:$,onPanZoomStart:l,onPanZoom:t,onPanZoomEnd:r}):Df({noWheelClassName:M,preventScrolling:D,d3ZoomHandler:h});m.on("wheel.zoom",oe,{passive:!1});const K=_f({zoomPanValues:u,onDraggingChange:d,onPanZoomStart:l});c.on("start",K);const q=Of({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!H,onPanZoom:t,onTransformChange:ne});c.on("zoom",q);const W=Kf({zoomPanValues:u,panOnDrag:B,panOnScroll:L,onPaneContextMenu:H,onPanZoomEnd:r,onDraggingChange:d});c.on("end",W);const G=Hf({zoomActivationKeyPressed:z,panOnDrag:B,zoomOnScroll:U,panOnScroll:L,zoomOnDoubleClick:V,zoomOnPinch:$,userSelectionActive:T,noPanClassName:P,noWheelClassName:M,lib:J,connectionInProgress:ie});c.filter(G),V?m.on("dblclick.zoom",v):m.on("dblclick.zoom",null)}function g(){c.on("zoom",null)}async function S(M,P,H){const T=ls(M),L=c==null?void 0:c.constrain()(T,P,H);return L&&await p(L),L}async function f(M,P){const H=ls(M);return await p(H,P),H}function w(M){if(m){const P=ls(M),H=m.property("__zoom");(H.k!==M.zoom||H.x!==M.x||H.y!==M.y)&&(c==null||c.transform(m,P,null,{sync:!0}))}}function C(){const M=m?Ra(m.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}async function N(M,P){return m?new Promise(H=>{c==null||c.interpolate((P==null?void 0:P.interpolate)==="linear"?$n:Ai).scaleTo(rs(m,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),M)}):!1}async function A(M,P){return m?new Promise(H=>{c==null||c.interpolate((P==null?void 0:P.interpolate)==="linear"?$n:Ai).scaleBy(rs(m,P==null?void 0:P.duration,P==null?void 0:P.ease,()=>H(!0)),M)}):!1}function E(M){c==null||c.scaleExtent(M)}function k(M){c==null||c.translateExtent(M)}function I(M){const P=!Ge(M)||M<0?0:M;c==null||c.clickDistance(P)}return{update:y,destroy:g,setViewport:f,setViewportConstrained:S,getViewport:C,scaleTo:N,scaleBy:A,setScaleExtent:E,setTranslateExtent:k,syncViewport:w,setClickDistance:I}}var Pn;(function(e){e.Line="line",e.Handle="handle"})(Pn||(Pn={}));function Vf({width:e,prevWidth:n,height:i,prevHeight:o,affectsX:s,affectsY:t}){const l=e-n,r=i-o,d=[l>0?1:l<0?-1:0,r>0?1:r<0?-1:0];return l&&s&&(d[0]=d[0]*-1),r&&t&&(d[1]=d[1]*-1),d}function jt(e){const n=e.includes("right")||e.includes("left"),i=e.includes("bottom")||e.includes("top"),o=e.includes("left"),s=e.includes("top");return{isHorizontal:n,isVertical:i,affectsX:o,affectsY:s}}function sn(e,n){return Math.max(0,n-e)}function an(e,n){return Math.max(0,e-n)}function zi(e,n,i){return Math.max(0,n-e,e-i)}function Wt(e,n){return e?!n:n}function Gf(e,n,i,o,s,t,l,r){let{affectsX:d,affectsY:u}=n;const{isHorizontal:b,isVertical:c}=n,m=b&&c,{xSnapped:h,ySnapped:v}=i,{minWidth:p,maxWidth:y,minHeight:g,maxHeight:S}=o,{x:f,y:w,width:C,height:N,aspectRatio:A}=e;let E=Math.floor(b?h-e.pointerX:0),k=Math.floor(c?v-e.pointerY:0);const I=C+(d?-E:E),M=N+(u?-k:k),P=-t[0]*C,H=-t[1]*N;let T=zi(I,p,y),L=zi(M,g,S);if(l){let _=0,D=0;d&&E<0?_=sn(f+E+P,l[0][0]):!d&&E>0&&(_=an(f+I+P,l[1][0])),u&&k<0?D=sn(w+k+H,l[0][1]):!u&&k>0&&(D=an(w+M+H,l[1][1])),T=Math.max(T,_),L=Math.max(L,D)}if(r){let _=0,D=0;d&&E>0?_=an(f+E,r[0][0]):!d&&E<0&&(_=sn(f+I,r[1][0])),u&&k>0?D=an(w+k,r[0][1]):!u&&k<0&&(D=sn(w+M,r[1][1])),T=Math.max(T,_),L=Math.max(L,D)}if(s){if(b){const _=zi(I/A,g,S)*A;if(T=Math.max(T,_),l){let D=0;!d&&!u||d&&!u&&m?D=an(w+H+I/A,l[1][1])*A:D=sn(w+H+(d?E:-E)/A,l[0][1])*A,T=Math.max(T,D)}if(r){let D=0;!d&&!u||d&&!u&&m?D=sn(w+I/A,r[1][1])*A:D=an(w+(d?E:-E)/A,r[0][1])*A,T=Math.max(T,D)}}if(c){const _=zi(M*A,p,y)/A;if(L=Math.max(L,_),l){let D=0;!d&&!u||u&&!d&&m?D=an(f+M*A+P,l[1][0])/A:D=sn(f+(u?k:-k)*A+P,l[0][0])/A,L=Math.max(L,D)}if(r){let D=0;!d&&!u||u&&!d&&m?D=sn(f+M*A,r[1][0])/A:D=an(f+(u?k:-k)*A,r[0][0])/A,L=Math.max(L,D)}}}k=k+(k<0?L:-L),E=E+(E<0?T:-T),s&&(m?I>M*A?k=(Wt(d,u)?-E:E)/A:E=(Wt(d,u)?-k:k)*A:b?(k=E/A,u=d):(E=k*A,d=u));const B=d?f+E:f,O=u?w+k:w;return{width:C+(d?-E:E),height:N+(u?-k:k),x:t[0]*E*(d?-1:1)+B,y:t[1]*k*(u?-1:1)+O}}const Ut={width:0,height:0,x:0,y:0},zf={...Ut,pointerX:0,pointerY:0,aspectRatio:1};function $f(e,n,i){var u,b;const o=n.position.x+e.position.x,s=n.position.y+e.position.y,t=(u=e.measured.width)!=null?u:0,l=(b=e.measured.height)!=null?b:0,r=i[0]*t,d=i[1]*l;return[[o-r,s-d],[o+t-r,s+l-d]]}function jf({domNode:e,nodeId:n,getStoreItems:i,onChange:o,onEnd:s}){const t=Oe(e);let l={controlDirection:jt("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:b,keepAspectRatio:c,resizeDirection:m,onResizeStart:h,onResize:v,onResizeEnd:p,shouldResize:y}){let g={...Ut},S={...zf};l={boundaries:b,resizeDirection:m,keepAspectRatio:c,controlDirection:jt(u)};let f,w=null,C=[],N,A,E,k=!1;const I=Aa().on("start",M=>{var $,U,V,z,J,ne;const{nodeLookup:P,transform:H,snapGrid:T,snapToGrid:L,nodeOrigin:B,paneDomNode:O}=i();if(f=P.get(n),!f)return;w=($=O==null?void 0:O.getBoundingClientRect())!=null?$:null;const{xSnapped:_,ySnapped:D}=oi(M.sourceEvent,{transform:H,snapGrid:T,snapToGrid:L,containerBounds:w});g={width:(U=f.measured.width)!=null?U:0,height:(V=f.measured.height)!=null?V:0,x:(z=f.position.x)!=null?z:0,y:(J=f.position.y)!=null?J:0},S={...g,pointerX:_,pointerY:D,aspectRatio:g.width/g.height},N=void 0,A=vn(f.extent)?f.extent:void 0,f.parentId&&(f.extent==="parent"||f.expandParent)&&(N=P.get(f.parentId)),N&&f.extent==="parent"&&(A=[[0,0],[N.measured.width,N.measured.height]]),C=[],E=void 0;for(const[ie,Q]of P)if(Q.parentId===n&&(C.push({id:ie,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const F=$f(Q,f,(ne=Q.origin)!=null?ne: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}h==null||h(M,{...g})}).on("drag",M=>{var j,ee,X;const{transform:P,snapGrid:H,snapToGrid:T,nodeOrigin:L}=i(),B=oi(M.sourceEvent,{transform:P,snapGrid:H,snapToGrid:T,containerBounds:w}),O=[];if(!f)return;const{x:_,y:D,width:$,height:U}=g,V={},z=(j=f.origin)!=null?j:L,{width:J,height:ne,x:ie,y:Q}=Gf(S,l.controlDirection,B,l.boundaries,l.keepAspectRatio,z,A,E),F=J!==$,Y=ne!==U,oe=ie!==_&&F,K=Q!==D&&Y;if(!oe&&!K&&!F&&!Y)return;if((oe||K||z[0]===1||z[1]===1)&&(V.x=oe?ie:g.x,V.y=K?Q:g.y,g.x=V.x,g.y=V.y,C.length>0)){const Z=ie-_,se=Q-D;for(const le of C)le.position={x:le.position.x-Z+z[0]*(J-$),y:le.position.y-se+z[1]*(ne-U)},O.push(le)}if((F||Y)&&(V.width=F&&(!l.resizeDirection||l.resizeDirection==="horizontal")?J:g.width,V.height=Y&&(!l.resizeDirection||l.resizeDirection==="vertical")?ne:g.height,g.width=V.width,g.height=V.height),N&&f.expandParent){const Z=z[0]*((ee=V.width)!=null?ee:0);V.x&&V.x<Z&&(g.x=Z,S.x=S.x-(V.x-Z));const se=z[1]*((X=V.height)!=null?X:0);V.y&&V.y<se&&(g.y=se,S.y=S.y-(V.y-se))}const q=Vf({width:g.width,prevWidth:$,height:g.height,prevHeight:U,affectsX:l.controlDirection.affectsX,affectsY:l.controlDirection.affectsY}),W={...g,direction:q};(y==null?void 0:y(M,W))!==!1&&(k=!0,v==null||v(M,W),o(V,O))}).on("end",M=>{k&&(p==null||p(M,{...g}),s==null||s({...g}),k=!1)});t.call(I)}function d(){t.on(".drag",null)}return{update:r,destroy:d}}function Wf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $i={exports:{}},ds={},ji={exports:{}},us={};/**
39
39
  * @license React
40
40
  * use-sync-external-store-shim.production.js
41
41
  *