@arudovwen/form-builder-react 1.8.1 → 1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(ge,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react/jsx-runtime"),require("react"),require("uuid"),require("react-datepicker"),require("@headlessui/react"),require("sonner"),require("axios"),require("react-currency-input-field"),require("react-dom"),require("react-hook-form"),require("@hookform/resolvers"),require("yup"),require("papaparse"),require("xlsx"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","uuid","react-datepicker","@headlessui/react","sonner","axios","react-currency-input-field","react-dom","react-hook-form","@hookform/resolvers","yup","papaparse","xlsx","react-router-dom"],t):(ge=typeof globalThis!="undefined"?globalThis:ge||self,t(ge.FormBuilder={},ge.jsxRuntime,ge.React,ge.uuid,ge.DatePicker,ge.react,ge.sonner,ge.axios,ge.CurrencyInput,ge.ReactDOM,ge.reactHookForm,ge.resolvers,ge.yup,ge.Papa,ge.XLSX,ge.reactRouterDom))})(this,function(ge,t,x,Ce,dr,re,Ee,Xe,ei,ur,Ve,fs,cr,mr,br,vr){"use strict";function ps(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:()=>e[i]})}}return n.default=e,Object.freeze(n)}const ne=ps(cr),gs=ps(br),Ae=x.createContext(void 0),ys={title:"",description:"",id:Ce.v4(),questionData:[],disabled:!1,isHidden:!1},xs=({children:e,onChange:n,onLogAction:i})=>{const[o,s]=x.useState(!0),[a,l]=x.useState({}),[r,d]=x.useState({}),[u,m]=x.useState([ys]),[c,b]=x.useState(()=>{try{const V=sessionStorage.getItem("editor_past");return V?JSON.parse(V):[]}catch(V){return[]}}),[v,h]=x.useState(()=>{try{const V=sessionStorage.getItem("editor_future");return V?JSON.parse(V):[]}catch(V){return[]}});x.useEffect(()=>{n&&n(u)},[u,n]),x.useEffect(()=>{sessionStorage.setItem("editor_past",JSON.stringify(c))},[c]),x.useEffect(()=>{sessionStorage.setItem("editor_future",JSON.stringify(v))},[v]);const p=x.useRef(Date.now()),g=x.useCallback(V=>{m(G=>{const H=typeof V=="function"?V(G):V;if(JSON.stringify(G)!==JSON.stringify(H)){const $=Date.now();b(F=>F.length>0&&JSON.stringify(F[F.length-1])===JSON.stringify(G)?F:$-p.current<800&&F.length>0?(p.current=$,F):(p.current=$,[...F,G])),h([])}return H})},[]),f=x.useCallback(()=>{if(c.length===0)return;const V=c[c.length-1],G=c.slice(0,c.length-1);b(G),h([u,...v]),m(V),i==null||i("UNDO",null)},[c,v,u,i]),N=x.useCallback(()=>{if(v.length===0)return;const V=v[0],G=v.slice(1);h(G),b([...c,u]),m(V),i==null||i("REDO",null)},[c,v,u,i]),y=u,S=c.length>0,w=v.length>0,[A,C]=x.useState(!1),[E,k]=x.useState(null),[I,P]=x.useState([0]),[T,O]=x.useState(""),[M,_]=x.useState(0),B=x.useCallback(()=>{},[]),K=x.useCallback(()=>{const V=Ce.v4();g(G=>[...G,{...ys,id:V}]),k(V),P([y.length]),i==null||i("ADD_SECTION",{sectionId:V})},[y,i,g]),D=x.useCallback(V=>{g(G=>G.filter(H=>H.id!==V)),k(null),i==null||i("REMOVE_SECTION",{sectionId:V})},[i,g]),L=x.useCallback((V,G)=>{const H=y.find(F=>F.id===G),$=H==null?void 0:H.questionData.find(F=>F.id===V);$&&(g(F=>F==null?void 0:F.map(q=>q.id===G?{...q,questionData:q==null?void 0:q.questionData.filter(R=>$.type==="grid"?R.gridId!==$.id&&R.id!==$.id:R.id!==V)}:q)),i==null||i("REMOVE_ELEMENT",{sectionId:G,elementId:V}))},[y,g,i]),z=x.useCallback((V,G)=>{const H=y.find(R=>R.id===G);if(!H)return;const $=H==null?void 0:H.questionData.findIndex(R=>R.id===V);if($===-1)return;const F=H==null?void 0:H.questionData[$],q=(R,Z={})=>({...JSON.parse(JSON.stringify(R)),id:Ce.v4(),...Z});g(R=>R==null?void 0:R.map(Z=>{var ee;if(Z.id!==G)return Z;const J=[...Z.questionData];if(F.type==="grid"){const ae=(ee=J==null?void 0:J.map((pe,Ne)=>({e:pe,i:Ne})).filter(({e:pe})=>pe.id===F.id||pe.gridId===F.id))==null?void 0:ee.map(({i:pe})=>pe),ue=ae.length?Math.max(...ae)+1:$+1,me=Ce.v4(),ye=q(F,{});ye.id=me;const be=J.filter(pe=>pe.gridId===F.id),we=be==null?void 0:be.map(pe=>q(pe,{gridId:me})),Me=[...J.slice(0,ue),ye,...we,...J.slice(ue)];return{...Z,questionData:Me}}else if(F.gridId){const{gridId:ae,gridPosition:ue,...me}=F,ye=q(me,{}),be=J.reduce((Me,pe,Ne)=>pe.id===F.gridId||pe.gridId===F.gridId?Ne:Me,$),we=[...J.slice(0,be+1),ye,...J.slice(be+1)];return{...Z,questionData:we}}else{const ae=q(F,{}),ue=[...J.slice(0,$+1),ae,...J.slice($+1)];return{...Z,questionData:ue}}})),i==null||i("DUPLICATE_ELEMENT",{sectionId:G,elementId:V})},[y,g,i]),U=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,questionData:V}:$)),i==null||i("UPDATE_ELEMENT_POSITION",{sectionId:G})},[g,i]),W=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,questionData:[...$==null?void 0:$.questionData,V]}:$)),i==null||i("ADD_ELEMENT",{sectionId:G,element:V})},[g,i]),Y=x.useCallback((V,G,H)=>{g($=>$==null?void 0:$.map(F=>F.id===G?{...F,questionData:[...F==null?void 0:F.questionData.slice(0,H),V,...F==null?void 0:F.questionData.slice(H)]}:F)),i==null||i("ADD_ELEMENT_IN_POSITION",{sectionId:G,element:V,index:H})},[g,i]),X=x.useCallback((V,G,H)=>{g($=>$==null?void 0:$.map(F=>{var q;return F.id===H?{...F,questionData:(q=F==null?void 0:F.questionData)==null?void 0:q.map(R=>{var Z;return R.type==="grid"&&R.gridData?{...R,gridData:(Z=R.gridData)==null?void 0:Z.map((J,ee)=>ee===V?{...J,...G}:J).concat(V>=R.gridData.length?{...G}:[])}:R})}:F})),i==null||i("UPDATE_GRID_ELEMENT",{sectionId:H,gridIndex:V,element:G})},[g,i]),ie=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>{var F;return $.id===G?{...$,questionData:(F=$==null?void 0:$.questionData)==null?void 0:F.map(q=>q.id===V.id?{...q,...V}:q)}:$})),i==null||i("UPDATE_ELEMENT",{sectionId:G,value:V})},[g,i]),se=x.useCallback(V=>{const{draggedId:G,sectionId:H,targetIndex:$,targetId:F,targetGridId:q,targetCol:R}=V;g(Z=>Z.map(J=>{if(J.id!==H)return J;const ee=[...J==null?void 0:J.questionData],ae=ee.findIndex(me=>me.id===G);if(ae===-1)return J;const ue={...ee[ae]};if(q!==void 0&&R!==void 0){if(ue.type==="grid")return J;const me=ee.findIndex(be=>{var we;return be.id!==G&&be.gridId===q&&((we=be.gridPosition)==null?void 0:we.col)===R});let ye=ee.map(be=>be.id===G?{...be,gridId:q,gridPosition:{col:R}}:be);return me!==-1&&(ye=ye.map((be,we)=>{if(we!==me)return be;const Me={...be};return delete Me.gridId,delete Me.gridPosition,Me})),{...J,questionData:ye}}if(ue.gridId&&$!==void 0&&q===void 0){const me={...ue};delete me.gridId,delete me.gridPosition;const ye=ee.filter(we=>we.id!==G),be=Math.min($,ye.length);return ye.splice(be,0,me),{...J,questionData:ye}}if(!ue.gridId&&$!==void 0&&q===void 0&&!F){ee.splice(ae,1);const me=Math.min($,ee.length);return ee.splice(me,0,ue),{...J,questionData:ee}}if(F){const me=ee.findIndex(ye=>ye.id===F);return me===-1?J:(ee.splice(ae,1),ee.splice(me,0,ue),{...J,questionData:ee})}return J})),i==null||i("MOVE_ELEMENT",V)},[g,i]),Q=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,...V}:$)),i==null||i("UPDATE_SECTION",{sectionId:G,value:V})},[g,i]),j=x.useMemo(()=>({formData:y,setFormData:g,handleDragStop:B,removeElement:L,elementData:r,setElementData:d,updateElementPosition:U,addElement:W,addElementInPosition:Y,updateElement:ie,addSection:K,removeSection:D,updateSection:Q,isDragging:A,setIsDragging:C,selectedSection:E,setSelectedSection:k,activeSections:I,setActiveSections:P,updateGridElement:X,answerData:a,setAnswerData:l,uploadUrl:T,setUploadUrl:O,apiActivityCount:M,setApiActivityCount:_,duplicateElement:z,moveElement:se,showPreview:o,setShowPreview:s,undo:f,redo:N,canUndo:S,canRedo:w}),[y,B,L,r,U,W,Y,ie,K,D,Q,A,E,I,X,a,T,M,z,se,o,f,N,S,w]);return t.jsx(Ae.Provider,{value:j,children:e})};function Ss(e){var n,i,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(n=0;n<s;n++)e[n]&&(i=Ss(e[n]))&&(o&&(o+=" "),o+=i)}else for(i in e)e[i]&&(o&&(o+=" "),o+=i);return o}function de(){for(var e,n,i=0,o="",s=arguments.length;i<s;i++)(e=arguments[i])&&(n=Ss(e))&&(o&&(o+=" "),o+=n);return o}function hr({type:e="calendar",className:n}){return t.jsx(t.Fragment,{children:e==="calendar"?t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[t.jsx("path",{d:"M6.66406 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.3359 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2.91406 7.57495H17.0807",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M17.5 7.08341V14.1667C17.5 16.6667 16.25 18.3334 13.3333 18.3334H6.66667C3.75 18.3334 2.5 16.6667 2.5 14.1667V7.08341C2.5 4.58341 3.75 2.91675 6.66667 2.91675H13.3333C16.25 2.91675 17.5 4.58341 17.5 7.08341Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.0762 11.4167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.0762 13.9167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M9.99803 11.4167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M9.99803 13.9167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M6.91209 11.4167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M6.91209 13.9167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[t.jsx("path",{d:"M10 6.66663V10.8333",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M10.0026 18.3333C5.9776 18.3333 2.71094 15.0667 2.71094 11.0417C2.71094 7.01667 5.9776 3.75 10.0026 3.75C14.0276 3.75 17.2943 7.01667 17.2943 11.0417",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M7.5 1.66663H12.5",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M12.4141 15.4167V14.4501C12.4141 13.2584 13.2641 12.7667 14.2974 13.3667L15.1307 13.8501L15.9641 14.3334C16.9974 14.9334 16.9974 15.9084 15.9641 16.5084L15.1307 16.9917L14.2974 17.4751C13.2641 18.0751 12.4141 17.5834 12.4141 16.3917V15.4167Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const Ji=({value:e=null,onGetValue:n,readOnly:i=!1,dateFormat:o="dd/MM/yyyy",name:s,placeholder:a="Select date",minDate:l,maxDate:r,showYearDropdown:d})=>{const u=e?new Date(e):null,[m,c]=x.useState(u);x.useEffect(()=>{const v=e?new Date(e):null;(v&&m&&v.getTime()!==m.getTime()||!v&&m||v&&!m)&&c(v)},[e]),x.useEffect(()=>{n&&n(s,m)},[m,n,s]);const b=v=>{c(v)};return t.jsx("div",{className:"builder_date__picker",children:t.jsx(dr,{showIcon:!0,icon:t.jsx(hr,{className:"react-datepicker__calendar-icon"}),showPopperArrow:!1,dateFormat:o,disabled:i,selected:m,onChange:b,className:"field-control",portalId:"root-portal",placeholderText:a,minDate:l,maxDate:r,showYearDropdown:d,scrollableYearDropdown:!0,yearDropdownItemNumber:40})})};function fr({element:e,validationData:n}){const{register:i=()=>({}),setValue:o,watch:s}=n||{};let a;return s&&(a=s()[e.id]),x.useEffect(()=>{i(e.id)},[e.id]),t.jsx(Ji,{name:e.id,value:a,onGetValue:o,readOnly:n==null?void 0:n.isReadOnly,dateFormat:(e==null?void 0:e.dateFormat)||"dd/MM/yyyy",minDate:e==null?void 0:e.minDate,maxDate:e==null?void 0:e.maxDate,showYearDropdown:e==null?void 0:e.allowYearPicker})}function Zi({element:e,validationData:n}){var o;const{register:i=()=>({})}=n||{};return t.jsx("div",{children:t.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:de("field-control",e==null?void 0:e.customClass),...i(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly,inputMode:(e==null?void 0:e.inputMode)||void 0,"aria-invalid":!!((o=n==null?void 0:n.errors)!=null&&o[e==null?void 0:e.id]),pattern:(e==null?void 0:e.pattern)||void 0})})}function pr(e,n){const i=e.icons,o=e.aliases||Object.create(null),s=Object.create(null);function a(l){if(i[l])return s[l]=[];if(!(l in s)){s[l]=null;const r=o[l]&&o[l].parent,d=r&&a(r);d&&(s[l]=[r].concat(d))}return s[l]}return Object.keys(i).concat(Object.keys(o)).forEach(a),s}const ws=Object.freeze({left:0,top:0,width:16,height:16}),ni=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Xi=Object.freeze({...ws,...ni}),Qi=Object.freeze({...Xi,body:"",hidden:!1});function gr(e,n){const i={};!e.hFlip!=!n.hFlip&&(i.hFlip=!0),!e.vFlip!=!n.vFlip&&(i.vFlip=!0);const o=((e.rotate||0)+(n.rotate||0))%4;return o&&(i.rotate=o),i}function Ns(e,n){const i=gr(e,n);for(const o in Qi)o in ni?o in e&&!(o in i)&&(i[o]=ni[o]):o in n?i[o]=n[o]:o in e&&(i[o]=e[o]);return i}function yr(e,n,i){const o=e.icons,s=e.aliases||Object.create(null);let a={};function l(r){a=Ns(o[r]||s[r],a)}return l(n),i.forEach(l),Ns(e,a)}function As(e,n){const i=[];if(typeof e!="object"||typeof e.icons!="object")return i;e.not_found instanceof Array&&e.not_found.forEach(s=>{n(s,null),i.push(s)});const o=pr(e);for(const s in o){const a=o[s];a&&(n(s,yr(e,s,a)),i.push(s))}return i}const xr={provider:"",aliases:{},not_found:{},...ws};function Ri(e,n){for(const i in n)if(i in e&&typeof e[i]!=typeof n[i])return!1;return!0}function Cs(e){if(typeof e!="object"||e===null)return null;const n=e;if(typeof n.prefix!="string"||!e.icons||typeof e.icons!="object"||!Ri(e,xr))return null;const i=n.icons;for(const s in i){const a=i[s];if(!s||typeof a.body!="string"||!Ri(a,Qi))return null}const o=n.aliases||Object.create(null);for(const s in o){const a=o[s],l=a.parent;if(!s||typeof l!="string"||!i[l]&&!o[l]||!Ri(a,Qi))return null}return n}const ks=Object.create(null);function Sr(e,n){return{provider:e,prefix:n,icons:Object.create(null),missing:new Set}}function dn(e,n){const i=ks[e]||(ks[e]=Object.create(null));return i[n]||(i[n]=Sr(e,n))}function Ms(e,n){return Cs(n)?As(n,(i,o)=>{o?e.icons[i]=o:e.missing.add(i)}):[]}function wr(e,n,i){try{if(typeof i.body=="string")return e.icons[n]={...i},!0}catch(o){}return!1}const Es=/^[a-z0-9]+(-[a-z0-9]+)*$/,ii=(e,n,i,o="")=>{const s=e.split(":");if(e.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;o=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const r=s.pop(),d=s.pop(),u={provider:s.length>0?s[0]:o,prefix:d,name:r};return n&&!oi(u)?null:u}const a=s[0],l=a.split("-");if(l.length>1){const r={provider:o,prefix:l.shift(),name:l.join("-")};return n&&!oi(r)?null:r}if(i&&o===""){const r={provider:o,prefix:"",name:a};return n&&!oi(r,i)?null:r}return null},oi=(e,n)=>e?!!((n&&e.prefix===""||e.prefix)&&e.name):!1;let En=!1;function Ts(e){return typeof e=="boolean"&&(En=e),En}function Ps(e){const n=typeof e=="string"?ii(e,!0,En):e;if(n){const i=dn(n.provider,n.prefix),o=n.name;return i.icons[o]||(i.missing.has(o)?null:void 0)}}function Nr(e,n){const i=ii(e,!0,En);if(!i)return!1;const o=dn(i.provider,i.prefix);return n?wr(o,i.name,n):(o.missing.add(i.name),!0)}function Ar(e,n){if(typeof e!="object")return!1;if(typeof n!="string"&&(n=e.provider||""),En&&!n&&!e.prefix){let s=!1;return Cs(e)&&(e.prefix="",As(e,(a,l)=>{Nr(a,l)&&(s=!0)})),s}const i=e.prefix;if(!oi({prefix:i,name:"a"}))return!1;const o=dn(n,i);return!!Ms(o,e)}const Ls=Object.freeze({width:null,height:null}),Bs=Object.freeze({...Ls,...ni}),Cr=/(-?[0-9.]*[0-9]+[0-9.]*)/g,kr=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Is(e,n,i){if(n===1)return e;if(i=i||100,typeof e=="number")return Math.ceil(e*n*i)/i;if(typeof e!="string")return e;const o=e.split(Cr);if(o===null||!o.length)return e;const s=[];let a=o.shift(),l=kr.test(a);for(;;){if(l){const r=parseFloat(a);isNaN(r)?s.push(a):s.push(Math.ceil(r*n*i)/i)}else s.push(a);if(a=o.shift(),a===void 0)return s.join("");l=!l}}function Mr(e,n="defs"){let i="";const o=e.indexOf("<"+n);for(;o>=0;){const s=e.indexOf(">",o),a=e.indexOf("</"+n);if(s===-1||a===-1)break;const l=e.indexOf(">",a);if(l===-1)break;i+=e.slice(s+1,a).trim(),e=e.slice(0,o).trim()+e.slice(l+1)}return{defs:i,content:e}}function Er(e,n){return e?"<defs>"+e+"</defs>"+n:n}function Tr(e,n,i){const o=Mr(e);return Er(o.defs,n+o.content+i)}const Pr=e=>e==="unset"||e==="undefined"||e==="none";function Lr(e,n){const i={...Xi,...e},o={...Bs,...n},s={left:i.left,top:i.top,width:i.width,height:i.height};let a=i.body;[i,o].forEach(p=>{const g=[],f=p.hFlip,N=p.vFlip;let y=p.rotate;f?N?y+=2:(g.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),g.push("scale(-1 1)"),s.top=s.left=0):N&&(g.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),g.push("scale(1 -1)"),s.top=s.left=0);let S;switch(y<0&&(y-=Math.floor(y/4)*4),y=y%4,y){case 1:S=s.height/2+s.top,g.unshift("rotate(90 "+S.toString()+" "+S.toString()+")");break;case 2:g.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:S=s.width/2+s.left,g.unshift("rotate(-90 "+S.toString()+" "+S.toString()+")");break}y%2===1&&(s.left!==s.top&&(S=s.left,s.left=s.top,s.top=S),s.width!==s.height&&(S=s.width,s.width=s.height,s.height=S)),g.length&&(a=Tr(a,'<g transform="'+g.join(" ")+'">',"</g>"))});const l=o.width,r=o.height,d=s.width,u=s.height;let m,c;l===null?(c=r===null?"1em":r==="auto"?u:r,m=Is(c,d/u)):(m=l==="auto"?d:l,c=r===null?Is(m,u/d):r==="auto"?u:r);const b={},v=(p,g)=>{Pr(g)||(b[p]=g.toString())};v("width",m),v("height",c);const h=[s.left,s.top,d,u];return b.viewBox=h.join(" "),{attributes:b,viewBox:h,body:a}}const Br=/\sid="(\S+)"/g,Ir="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Dr=0;function _r(e,n=Ir){const i=[];let o;for(;o=Br.exec(e);)i.push(o[1]);if(!i.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return i.forEach(a=>{const l=typeof n=="function"?n(a):n+(Dr++).toString(),r=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+r+')([")]|\\.[a-z])',"g"),"$1"+l+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const eo=Object.create(null);function Or(e,n){eo[e]=n}function no(e){return eo[e]||eo[""]}function io(e){let n;if(typeof e.resources=="string")n=[e.resources];else if(n=e.resources,!(n instanceof Array)||!n.length)return null;return{resources:n,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const oo=Object.create(null),Tn=["https://api.simplesvg.com","https://api.unisvg.com"],si=[];for(;Tn.length>0;)Tn.length===1||Math.random()>.5?si.push(Tn.shift()):si.push(Tn.pop());oo[""]=io({resources:["https://api.iconify.design"].concat(si)});function Kr(e,n){const i=io(n);return i===null?!1:(oo[e]=i,!0)}function so(e){return oo[e]}let Ds=(()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch(n){}})();function Hr(e,n){const i=so(e);if(!i)return 0;let o;if(!i.maxURL)o=0;else{let s=0;i.resources.forEach(l=>{s=Math.max(s,l.length)});const a=n+".json?icons=";o=i.maxURL-s-i.path.length-a.length}return o}function Gr(e){return e===404}const Fr=(e,n,i)=>{const o=[],s=Hr(e,n),a="icons";let l={type:a,provider:e,prefix:n,icons:[]},r=0;return i.forEach((d,u)=>{r+=d.length+1,r>=s&&u>0&&(o.push(l),l={type:a,provider:e,prefix:n,icons:[]},r=d.length),l.icons.push(d)}),o.push(l),o};function Vr(e){if(typeof e=="string"){const n=so(e);if(n)return n.path}return"/"}const zr={prepare:Fr,send:(e,n,i)=>{if(!Ds){i("abort",424);return}let o=Vr(n.provider);switch(n.type){case"icons":{const a=n.prefix,r=n.icons.join(","),d=new URLSearchParams({icons:r});o+=a+".json?"+d.toString();break}case"custom":{const a=n.uri;o+=a.slice(0,1)==="/"?a.slice(1):a;break}default:i("abort",400);return}let s=503;Ds(e+o).then(a=>{const l=a.status;if(l!==200){setTimeout(()=>{i(Gr(l)?"abort":"next",l)});return}return s=501,a.json()}).then(a=>{if(typeof a!="object"||a===null){setTimeout(()=>{a===404?i("abort",a):i("next",s)});return}setTimeout(()=>{i("success",a)})}).catch(()=>{i("next",s)})}};function _s(e,n){e.forEach(i=>{const o=i.loaderCallbacks;o&&(i.loaderCallbacks=o.filter(s=>s.id!==n))})}function Wr(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const n=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!n.length)return;let i=!1;const o=e.provider,s=e.prefix;n.forEach(a=>{const l=a.icons,r=l.pending.length;l.pending=l.pending.filter(d=>{if(d.prefix!==s)return!0;const u=d.name;if(e.icons[u])l.loaded.push({provider:o,prefix:s,name:u});else if(e.missing.has(u))l.missing.push({provider:o,prefix:s,name:u});else return i=!0,!0;return!1}),l.pending.length!==r&&(i||_s([e],a.id),a.callback(l.loaded.slice(0),l.missing.slice(0),l.pending.slice(0),a.abort))})}))}let $r=0;function jr(e,n,i){const o=$r++,s=_s.bind(null,i,o);if(!n.pending.length)return s;const a={id:o,icons:n,callback:e,abort:s};return i.forEach(l=>{(l.loaderCallbacks||(l.loaderCallbacks=[])).push(a)}),s}function Ur(e){const n={loaded:[],missing:[],pending:[]},i=Object.create(null);e.sort((s,a)=>s.provider!==a.provider?s.provider.localeCompare(a.provider):s.prefix!==a.prefix?s.prefix.localeCompare(a.prefix):s.name.localeCompare(a.name));let o={provider:"",prefix:"",name:""};return e.forEach(s=>{if(o.name===s.name&&o.prefix===s.prefix&&o.provider===s.provider)return;o=s;const a=s.provider,l=s.prefix,r=s.name,d=i[a]||(i[a]=Object.create(null)),u=d[l]||(d[l]=dn(a,l));let m;r in u.icons?m=n.loaded:l===""||u.missing.has(r)?m=n.missing:m=n.pending;const c={provider:a,prefix:l,name:r};m.push(c)}),n}function qr(e,n=!0,i=!1){const o=[];return e.forEach(s=>{const a=typeof s=="string"?ii(s,n,i):s;a&&o.push(a)}),o}const Yr={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Jr(e,n,i,o){const s=e.resources.length,a=e.random?Math.floor(Math.random()*s):e.index;let l;if(e.random){let A=e.resources.slice(0);for(l=[];A.length>1;){const C=Math.floor(Math.random()*A.length);l.push(A[C]),A=A.slice(0,C).concat(A.slice(C+1))}l=l.concat(A)}else l=e.resources.slice(a).concat(e.resources.slice(0,a));const r=Date.now();let d="pending",u=0,m,c=null,b=[],v=[];typeof o=="function"&&v.push(o);function h(){c&&(clearTimeout(c),c=null)}function p(){d==="pending"&&(d="aborted"),h(),b.forEach(A=>{A.status==="pending"&&(A.status="aborted")}),b=[]}function g(A,C){C&&(v=[]),typeof A=="function"&&v.push(A)}function f(){return{startTime:r,payload:n,status:d,queriesSent:u,queriesPending:b.length,subscribe:g,abort:p}}function N(){d="failed",v.forEach(A=>{A(void 0,m)})}function y(){b.forEach(A=>{A.status==="pending"&&(A.status="aborted")}),b=[]}function S(A,C,E){const k=C!=="success";switch(b=b.filter(I=>I!==A),d){case"pending":break;case"failed":if(k||!e.dataAfterTimeout)return;break;default:return}if(C==="abort"){m=E,N();return}if(k){m=E,b.length||(l.length?w():N());return}if(h(),y(),!e.random){const I=e.resources.indexOf(A.resource);I!==-1&&I!==e.index&&(e.index=I)}d="completed",v.forEach(I=>{I(E)})}function w(){if(d!=="pending")return;h();const A=l.shift();if(A===void 0){if(b.length){c=setTimeout(()=>{h(),d==="pending"&&(y(),N())},e.timeout);return}N();return}const C={status:"pending",resource:A,callback:(E,k)=>{S(C,E,k)}};b.push(C),u++,c=setTimeout(w,e.rotate),i(A,n,C.callback)}return setTimeout(w),f}function Os(e){const n={...Yr,...e};let i=[];function o(){i=i.filter(r=>r().status==="pending")}function s(r,d,u){const m=Jr(n,r,d,(c,b)=>{o(),u&&u(c,b)});return i.push(m),m}function a(r){return i.find(d=>r(d))||null}return{query:s,find:a,setIndex:r=>{n.index=r},getIndex:()=>n.index,cleanup:o}}function Ks(){}const ao=Object.create(null);function Zr(e){if(!ao[e]){const n=so(e);if(!n)return;const i=Os(n),o={config:n,redundancy:i};ao[e]=o}return ao[e]}function Xr(e,n,i){let o,s;if(typeof e=="string"){const a=no(e);if(!a)return i(void 0,424),Ks;s=a.send;const l=Zr(e);l&&(o=l.redundancy)}else{const a=io(e);if(a){o=Os(a);const l=e.resources?e.resources[0]:"",r=no(l);r&&(s=r.send)}}return!o||!s?(i(void 0,424),Ks):o.query(n,s,i)().abort}function Hs(){}function Qr(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Wr(e)}))}function Rr(e){const n=[],i=[];return e.forEach(o=>{(o.match(Es)?n:i).push(o)}),{valid:n,invalid:i}}function Pn(e,n,i){function o(){const s=e.pendingIcons;n.forEach(a=>{s&&s.delete(a),e.icons[a]||e.missing.add(a)})}if(i&&typeof i=="object")try{if(!Ms(e,i).length){o();return}}catch(s){console.error(s)}o(),Qr(e)}function Gs(e,n){e instanceof Promise?e.then(i=>{n(i)}).catch(()=>{n(null)}):n(e)}function ed(e,n){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(n).sort():e.iconsToLoad=n,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:i,prefix:o}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const a=e.loadIcon;if(e.loadIcons&&(s.length>1||!a)){Gs(e.loadIcons(s,o,i),m=>{Pn(e,s,m)});return}if(a){s.forEach(m=>{const c=a(m,o,i);Gs(c,b=>{const v=b?{prefix:o,icons:{[m]:b}}:null;Pn(e,[m],v)})});return}const{valid:l,invalid:r}=Rr(s);if(r.length&&Pn(e,r,null),!l.length)return;const d=o.match(Es)?no(i):null;if(!d){Pn(e,l,null);return}d.prepare(i,o,l).forEach(m=>{Xr(i,m,c=>{Pn(e,m.icons,c)})})}))}const nd=(e,n)=>{const i=qr(e,!0,Ts()),o=Ur(i);if(!o.pending.length){let d=!0;return n&&setTimeout(()=>{d&&n(o.loaded,o.missing,o.pending,Hs)}),()=>{d=!1}}const s=Object.create(null),a=[];let l,r;return o.pending.forEach(d=>{const{provider:u,prefix:m}=d;if(m===r&&u===l)return;l=u,r=m,a.push(dn(u,m));const c=s[u]||(s[u]=Object.create(null));c[m]||(c[m]=[])}),o.pending.forEach(d=>{const{provider:u,prefix:m,name:c}=d,b=dn(u,m),v=b.pendingIcons||(b.pendingIcons=new Set);v.has(c)||(v.add(c),s[u][m].push(c))}),a.forEach(d=>{const u=s[d.provider][d.prefix];u.length&&ed(d,u)}),n?jr(n,o,a):Hs};function id(e,n){const i={...e};for(const o in n){const s=n[o],a=typeof s;o in Ls?(s===null||s&&(a==="string"||a==="number"))&&(i[o]=s):a===typeof i[o]&&(i[o]=o==="rotate"?s%4:s)}return i}const od=/[\s,]+/;function sd(e,n){n.split(od).forEach(i=>{switch(i.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function ad(e,n=0){const i=e.replace(/^-?[0-9.]*/,"");function o(s){for(;s<0;)s+=4;return s%4}if(i===""){const s=parseInt(e);return isNaN(s)?0:o(s)}else if(i!==e){let s=0;switch(i){case"%":s=25;break;case"deg":s=90}if(s){let a=parseFloat(e.slice(0,e.length-i.length));return isNaN(a)?0:(a=a/s,a%1===0?o(a):0)}}return n}function td(e,n){let i=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in n)i+=" "+o+'="'+n[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+i+">"+e+"</svg>"}function ld(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function rd(e){return"data:image/svg+xml,"+ld(e)}function dd(e){return'url("'+rd(e)+'")'}let Ln;function ud(){try{Ln=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){Ln=null}}function cd(e){return Ln===void 0&&ud(),Ln?Ln.createHTML(e):e}const Fs={...Bs,inline:!1},md={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},bd={display:"inline-block"},to={backgroundColor:"currentColor"},Vs={backgroundColor:"transparent"},zs={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Ws={WebkitMask:to,mask:to,background:Vs};for(const e in Ws){const n=Ws[e];for(const i in zs)n[e+i]=zs[i]}const vd={...Fs,inline:!0};function $s(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const hd=(e,n,i)=>{const o=n.inline?vd:Fs,s=id(o,n),a=n.mode||"svg",l={},r=n.style||{},d={...a==="svg"?md:{}};if(i){const g=ii(i,!1,!0);if(g){const f=["iconify"],N=["provider","prefix"];for(const y of N)g[y]&&f.push("iconify--"+g[y]);d.className=f.join(" ")}}for(let g in n){const f=n[g];if(f!==void 0)switch(g){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":d.ref=f;break;case"className":d[g]=(d[g]?d[g]+" ":"")+f;break;case"inline":case"hFlip":case"vFlip":s[g]=f===!0||f==="true"||f===1;break;case"flip":typeof f=="string"&&sd(s,f);break;case"color":l.color=f;break;case"rotate":typeof f=="string"?s[g]=ad(f):typeof f=="number"&&(s[g]=f);break;case"ariaHidden":case"aria-hidden":f!==!0&&f!=="true"&&delete d["aria-hidden"];break;default:o[g]===void 0&&(d[g]=f)}}const u=Lr(e,s),m=u.attributes;if(s.inline&&(l.verticalAlign="-0.125em"),a==="svg"){d.style={...l,...r},Object.assign(d,m);let g=0,f=n.id;return typeof f=="string"&&(f=f.replace(/-/g,"_")),d.dangerouslySetInnerHTML={__html:cd(_r(u.body,f?()=>f+"ID"+g++:"iconifyReact"))},x.createElement("svg",d)}const{body:c,width:b,height:v}=e,h=a==="mask"||(a==="bg"?!1:c.indexOf("currentColor")!==-1),p=td(c,{...m,width:b+"",height:v+""});return d.style={...l,"--svg":dd(p),width:$s(m.width),height:$s(m.height),...bd,...h?to:Vs,...r},x.createElement("span",d)};if(Ts(!0),Or("",zr),typeof document!="undefined"&&typeof window!="undefined"){const e=window;if(e.IconifyPreload!==void 0){const n=e.IconifyPreload,i="Invalid IconifyPreload syntax.";typeof n=="object"&&n!==null&&(n instanceof Array?n:[n]).forEach(o=>{try{(typeof o!="object"||o===null||o instanceof Array||typeof o.icons!="object"||typeof o.prefix!="string"||!Ar(o))&&console.error(i)}catch(s){console.error(i)}})}if(e.IconifyProviders!==void 0){const n=e.IconifyProviders;if(typeof n=="object"&&n!==null)for(let i in n){const o="IconifyProviders["+i+"] is invalid.";try{const s=n[i];if(typeof s!="object"||!s||s.resources===void 0)continue;Kr(i,s)||console.error(o)}catch(s){console.error(o)}}}}function js(e){const[n,i]=x.useState(!!e.ssr),[o,s]=x.useState({});function a(v){if(v){const h=e.icon;if(typeof h=="object")return{name:"",data:h};const p=Ps(h);if(p)return{name:h,data:p}}return{name:""}}const[l,r]=x.useState(a(!!e.ssr));function d(){const v=o.callback;v&&(v(),s({}))}function u(v){if(JSON.stringify(l)!==JSON.stringify(v))return d(),r(v),!0}function m(){var v;const h=e.icon;if(typeof h=="object"){u({name:"",data:h});return}const p=Ps(h);if(u({name:h,data:p}))if(p===void 0){const g=nd([h],m);s({callback:g})}else p&&((v=e.onLoad)===null||v===void 0||v.call(e,h))}x.useEffect(()=>(i(!0),d),[]),x.useEffect(()=>{n&&m()},[e.icon,n]);const{name:c,data:b}=l;return b?hd({...Xi,...b},e,c):e.children?e.children:e.fallback?e.fallback:x.createElement("span",{})}const Us=x.forwardRef((e,n)=>js({...e,_ref:n}));x.forwardRef((e,n)=>js({inline:!0,...e,_ref:n}));function te({icon:e,iconClass:n}){return t.jsx(t.Fragment,{children:t.jsx(Us,{icon:e,className:n})})}function lo({element:e,validationData:n,placeholder:i}){var c;const{register:o=()=>({}),setValue:s,isReadOnly:a,watch:l,getValues:r}=n||{},[d,u]=x.useState(()=>{const b=r==null?void 0:r(e.id);return Array.isArray(b)?b:[]}),m=x.useMemo(()=>d==null?void 0:d.map(b=>b.label).join(", "),[d]);return x.useEffect(()=>{o(e.id)},[e.id,o]),x.useEffect(()=>{if(!l)return;const b=l(v=>{const h=v[e.id];h!==void 0&&u(Array.isArray(h)?h:[])});return()=>{var v;return(v=b.unsubscribe)==null?void 0:v.call(b)}},[l,e.id]),t.jsx("div",{className:"custom-select",children:t.jsx(re.Listbox,{value:d||[],onChange:b=>{u(b),s==null||s(e.id,b)},multiple:!0,disabled:a,by:"value",children:t.jsxs("div",{className:"custom-select__wrapper",children:[t.jsxs(re.Listbox.Button,{className:"custom-select__control field-control",disabled:a,children:[t.jsx("span",{className:"custom-select__value",children:(d==null?void 0:d.length)>0?m:t.jsx("span",{className:"custom-select__placeholder",children:i!=null?i:" Select options"})}),t.jsx("span",{className:"custom-select__icon",children:t.jsx(te,{icon:"lucide:chevron-down"})})]}),t.jsx(re.Transition,{as:x.Fragment,leave:"custom-select__transition",children:t.jsx(re.Listbox.Options,{anchor:"bottom start",className:"custom-select__options",children:(c=e==null?void 0:e.options)==null?void 0:c.map((b,v)=>t.jsx(re.Listbox.Option,{value:b,className:({active:h})=>`custom-select__option ${h?"custom-select__option--active":""}`,children:({selected:h})=>t.jsxs("div",{className:"custom-select__option-row",children:[t.jsx("span",{className:`custom-select__option-label ${h?"custom-select__option--selected":""}`,children:b.label}),h&&t.jsx("span",{className:"custom-select__check",children:"✓"})]})},v))})})]})})})}const fd=["jpg","jpeg","png","gif","bmp","webp","svg","image"],pd=(e="")=>{var i;const n=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return fd.includes(n)||e.startsWith("data:image/")?"image":n==="pdf"||e.startsWith("data:application/pdf")?"pdf":["doc","docx"].includes(n)?"word":["xls","xlsx","csv"].includes(n)?"excel":["ppt","pptx"].includes(n)?"powerpoint":"other"},gd={pdf:"vscode-icons:file-type-pdf2",word:"vscode-icons:file-type-word",excel:"vscode-icons:file-type-excel",powerpoint:"vscode-icons:file-type-powerpoint2"};function qs({fileUrl:e,fileName:n,removeFile:i}){const[o,s]=x.useState(!1),[a,l]=x.useState("unknown"),[r,d]=x.useState(null);x.useEffect(()=>{e&&l(pd(e))},[e]),x.useEffect(()=>{if(a==="pdf"&&(e!=null&&e.startsWith("data:")))try{const v=atob(e.split(",")[1]),h=new ArrayBuffer(v.length),p=new Uint8Array(h);for(let N=0;N<v.length;N++)p[N]=v.charCodeAt(N);const g=new Blob([h],{type:"application/pdf"}),f=URL.createObjectURL(g);return d(f),()=>URL.revokeObjectURL(f)}catch(v){console.error("Error creating blob URL:",v)}else d(null)},[e,a]);const u=()=>{a==="image"||a==="pdf"?s(!0):window.open(r||e,"_blank")},m=()=>s(!1),c=n||(e==null?void 0:e.split("/").pop())||"Unknown file";function b(v,h="download"){if(!v)return;if(v.startsWith("data:")){const g=document.createElement("a");g.href=v,g.download=h,document.body.appendChild(g),g.click(),document.body.removeChild(g);return}const p=document.createElement("a");p.href=v,p.setAttribute("download",h),document.body.appendChild(p),p.click(),document.body.removeChild(p)}return t.jsxs("div",{className:"mt-2 field-control !py-1 !bg-gray-50 !flex justify-between gap-x-8 items-center",children:[t.jsxs("div",{onClick:u,className:"!flex items-center rounded cursor-pointer gap-x-3",title:`Click to preview ${c}`,children:[a==="image"&&t.jsx("div",{className:"flex items-center justify-center ",children:t.jsx(te,{iconClass:"text-4xl",icon:"fluent-color:image-48"})}),a!=="image"&&t.jsx(te,{icon:gd[a],iconClass:"text-4xl"}),t.jsx("span",{className:"text-sm font-semibold text-center text-gray-700 truncate max-w-[300px]",children:c})]}),t.jsxs("div",{className:"flex gap-x-1 items-center",children:[t.jsx("button",{type:"button",className:"p-2",onClick:()=>b(r||e,n),title:`Download ${c}`,children:t.jsx(te,{icon:"streamline-flex:download-tray-solid"})}),i&&t.jsx("button",{type:"button",className:"p-2 text-lg text-red-500",onClick:i,children:t.jsx(te,{icon:"lets-icons:trash-duotone"})})]}),o&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:m,children:t.jsxs("div",{className:"relative bg-white p-8 rounded-lg w-full max-w-[90vw] max-h-[90vh] overflow-auto",onClick:v=>v.stopPropagation(),children:[t.jsx("button",{onClick:m,className:"absolute text-2xl font-bold text-gray-700 top-2 right-2","aria-label":"Close preview",children:"×"}),a==="image"?t.jsx("img",{src:e,alt:c,className:"max-w-full max-h-[80vh] mx-auto object-contain",crossOrigin:"anonymous"}):a==="pdf"?t.jsx("iframe",{src:r||e,title:c,className:"w-full h-[80vh] rounded border"}):null]})})]})}const xe=e=>{const n=typeof window!="undefined"?localStorage.getItem(e):"";try{return JSON.parse(n)}catch(i){return n}},Ys=(e,n)=>{const i=typeof n!="string"?JSON.stringify(n):n;return localStorage.setItem(e,i)},yd=5*1024*1024;function xd({onFileLoaded:e,disabled:n=!1,handleDeleteFile:i,multiple:o=!1,list:s=null,accept:a=[]}){const{uploadUrl:l,setApiActivityCount:r}=x.useContext(Ae),d=x.useRef(null),[u,m]=x.useState(s),[c,b]=x.useState(!1);x.useEffect(()=>{m(s)},[s]);const v=x.useMemo(()=>a==null?void 0:a.map(w=>w.value).join(", "),[a]),h=x.useMemo(()=>a==null?void 0:a.map(w=>w.label).join(", "),[a]),p=x.useCallback(async w=>{var E,k;const A=xe("token"),C=((E=xe("orgData"))==null?void 0:E.id)||xe("organizationId");try{const{data:I}=await Xe.post(l,{...w,service:"FORM",organizationId:C||""},{headers:{Authorization:`Bearer ${A}`}});return(k=I==null?void 0:I.data)==null?void 0:k.url}catch(I){throw console.error("File upload error:",I),new Error("Failed to upload file to server")}},[l]),g=x.useCallback(w=>new Promise((A,C)=>{const E=new FileReader;E.onloadend=async()=>{try{const k=E.result.replace(/^data:.*;base64,/,""),I=l?await p({base64:k,ext:`.${w.name.split(".").pop()}`,fileName:w.name}):E.result;A({base64:I,type:w.type,name:w.name})}catch(k){C(k)}},E.onerror=()=>C(new Error("File read failed")),E.readAsDataURL(w)}),[l,p]),f=x.useCallback(w=>{var C;const A=v?(C=v.split(","))==null?void 0:C.map(E=>E.trim()):[];for(const E of w){if(E.size>yd)return Ee.toast.error(`File "${E.name}" exceeds 5MB limit (${(E.size/1024/1024).toFixed(2)}MB)`),!1;if(A.length&&!A.some(k=>E.type===k||E.name.toLowerCase().endsWith(k.replace("*",""))))return Ee.toast.error(`File "${E.name}" is not an allowed type. Allowed: ${h||"any"}`),!1}return!0},[v,h]),N=x.useCallback(async w=>{const A=Array.from(w.target.files||[]);if(!(!A.length||c)){if(!f(A)){d.current&&(d.current.value="");return}try{b(!0),r==null||r(k=>k+1);const C=await Promise.all(A==null?void 0:A.map(g)),E=o&&u?[...u,...C]:C;m(E),e(E),Ee.toast.success(`Successfully uploaded ${A.length} file(s)`)}catch(C){console.error("Upload error:",C),Ee.toast.error("Failed to upload file(s). Please try again.")}finally{b(!1),r==null||r(C=>Math.max(0,C-1)),d.current&&(d.current.value="")}}},[c,f,g,e,o,u,r]),y=x.useCallback(w=>{c||(d.current&&(d.current.value=""),m(A=>{const C=w===void 0?null:(A==null?void 0:A.filter((E,k)=>k!==w))||null;return e(C),C}),i==null||i())},[i,e,c]),S=u&&u.length>0;return t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[!n&&t.jsxs("div",{className:"!flex field-control !py-0 !px-0 relative",children:[t.jsx("input",{ref:d,type:"file",onChange:N,disabled:n||c,multiple:o,accept:v||"",className:`w-full text-sm text-gray-500 file:mr-4 flex-1 file:px-4 !py-1 !pl-1\r
1
+ (function(ge,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react/jsx-runtime"),require("react"),require("uuid"),require("react-datepicker"),require("@headlessui/react"),require("sonner"),require("axios"),require("react-currency-input-field"),require("react-dom"),require("react-hook-form"),require("@hookform/resolvers"),require("yup"),require("papaparse"),require("xlsx"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","uuid","react-datepicker","@headlessui/react","sonner","axios","react-currency-input-field","react-dom","react-hook-form","@hookform/resolvers","yup","papaparse","xlsx","react-router-dom"],t):(ge=typeof globalThis!="undefined"?globalThis:ge||self,t(ge.FormBuilder={},ge.jsxRuntime,ge.React,ge.uuid,ge.DatePicker,ge.react,ge.sonner,ge.axios,ge.CurrencyInput,ge.ReactDOM,ge.reactHookForm,ge.resolvers,ge.yup,ge.Papa,ge.XLSX,ge.reactRouterDom))})(this,function(ge,t,x,Ce,dr,re,Ee,Xe,ei,ur,Ve,fs,cr,mr,br,vr){"use strict";function ps(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:()=>e[i]})}}return n.default=e,Object.freeze(n)}const ne=ps(cr),gs=ps(br),Ae=x.createContext(void 0),ys={title:"",description:"",id:Ce.v4(),questionData:[],disabled:!1,isHidden:!1},xs=({children:e,onChange:n,onLogAction:i})=>{const[o,s]=x.useState(!0),[a,l]=x.useState({}),[r,d]=x.useState({}),[u,m]=x.useState([ys]),[c,b]=x.useState(()=>{try{const V=sessionStorage.getItem("editor_past");return V?JSON.parse(V):[]}catch(V){return[]}}),[v,h]=x.useState(()=>{try{const V=sessionStorage.getItem("editor_future");return V?JSON.parse(V):[]}catch(V){return[]}});x.useEffect(()=>{n&&n(u)},[u,n]),x.useEffect(()=>{try{sessionStorage.setItem("editor_past",JSON.stringify(c))}catch(V){console.warn("Could not save editor_past to sessionStorage",V)}},[c]),x.useEffect(()=>{try{sessionStorage.setItem("editor_future",JSON.stringify(v))}catch(V){console.warn("Could not save editor_future to sessionStorage",V)}},[v]);const p=x.useRef(Date.now()),g=x.useCallback(V=>{m(G=>{const H=typeof V=="function"?V(G):V;if(JSON.stringify(G)!==JSON.stringify(H)){const $=Date.now();b(F=>{if(F.length>0&&JSON.stringify(F[F.length-1])===JSON.stringify(G))return F;if($-p.current<800&&F.length>0)return p.current=$,F;p.current=$;const q=[...F,G];return q.length>20?q.slice(q.length-20):q}),h([])}return H})},[]),f=x.useCallback(()=>{if(c.length===0)return;const V=c[c.length-1],G=c.slice(0,c.length-1);b(G),h([u,...v]),m(V),i==null||i("UNDO",null)},[c,v,u,i]),N=x.useCallback(()=>{if(v.length===0)return;const V=v[0],G=v.slice(1);h(G),b([...c,u]),m(V),i==null||i("REDO",null)},[c,v,u,i]),y=u,S=c.length>0,w=v.length>0,[A,C]=x.useState(!1),[E,k]=x.useState(null),[I,P]=x.useState([0]),[T,O]=x.useState(""),[M,_]=x.useState(0),B=x.useCallback(()=>{},[]),K=x.useCallback(()=>{const V=Ce.v4();g(G=>[...G,{...ys,id:V}]),k(V),P([y.length]),i==null||i("ADD_SECTION",{sectionId:V})},[y,i,g]),D=x.useCallback(V=>{g(G=>G.filter(H=>H.id!==V)),k(null),i==null||i("REMOVE_SECTION",{sectionId:V})},[i,g]),L=x.useCallback((V,G)=>{const H=y.find(F=>F.id===G),$=H==null?void 0:H.questionData.find(F=>F.id===V);$&&(g(F=>F==null?void 0:F.map(q=>q.id===G?{...q,questionData:q==null?void 0:q.questionData.filter(R=>$.type==="grid"?R.gridId!==$.id&&R.id!==$.id:R.id!==V)}:q)),i==null||i("REMOVE_ELEMENT",{sectionId:G,elementId:V}))},[y,g,i]),z=x.useCallback((V,G)=>{const H=y.find(R=>R.id===G);if(!H)return;const $=H==null?void 0:H.questionData.findIndex(R=>R.id===V);if($===-1)return;const F=H==null?void 0:H.questionData[$],q=(R,Z={})=>({...JSON.parse(JSON.stringify(R)),id:Ce.v4(),...Z});g(R=>R==null?void 0:R.map(Z=>{var ee;if(Z.id!==G)return Z;const J=[...Z.questionData];if(F.type==="grid"){const ae=(ee=J==null?void 0:J.map((pe,Ne)=>({e:pe,i:Ne})).filter(({e:pe})=>pe.id===F.id||pe.gridId===F.id))==null?void 0:ee.map(({i:pe})=>pe),ue=ae.length?Math.max(...ae)+1:$+1,me=Ce.v4(),ye=q(F,{});ye.id=me;const be=J.filter(pe=>pe.gridId===F.id),we=be==null?void 0:be.map(pe=>q(pe,{gridId:me})),Me=[...J.slice(0,ue),ye,...we,...J.slice(ue)];return{...Z,questionData:Me}}else if(F.gridId){const{gridId:ae,gridPosition:ue,...me}=F,ye=q(me,{}),be=J.reduce((Me,pe,Ne)=>pe.id===F.gridId||pe.gridId===F.gridId?Ne:Me,$),we=[...J.slice(0,be+1),ye,...J.slice(be+1)];return{...Z,questionData:we}}else{const ae=q(F,{}),ue=[...J.slice(0,$+1),ae,...J.slice($+1)];return{...Z,questionData:ue}}})),i==null||i("DUPLICATE_ELEMENT",{sectionId:G,elementId:V})},[y,g,i]),U=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,questionData:V}:$)),i==null||i("UPDATE_ELEMENT_POSITION",{sectionId:G})},[g,i]),W=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,questionData:[...$==null?void 0:$.questionData,V]}:$)),i==null||i("ADD_ELEMENT",{sectionId:G,element:V})},[g,i]),Y=x.useCallback((V,G,H)=>{g($=>$==null?void 0:$.map(F=>F.id===G?{...F,questionData:[...F==null?void 0:F.questionData.slice(0,H),V,...F==null?void 0:F.questionData.slice(H)]}:F)),i==null||i("ADD_ELEMENT_IN_POSITION",{sectionId:G,element:V,index:H})},[g,i]),X=x.useCallback((V,G,H)=>{g($=>$==null?void 0:$.map(F=>{var q;return F.id===H?{...F,questionData:(q=F==null?void 0:F.questionData)==null?void 0:q.map(R=>{var Z;return R.type==="grid"&&R.gridData?{...R,gridData:(Z=R.gridData)==null?void 0:Z.map((J,ee)=>ee===V?{...J,...G}:J).concat(V>=R.gridData.length?{...G}:[])}:R})}:F})),i==null||i("UPDATE_GRID_ELEMENT",{sectionId:H,gridIndex:V,element:G})},[g,i]),ie=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>{var F;return $.id===G?{...$,questionData:(F=$==null?void 0:$.questionData)==null?void 0:F.map(q=>q.id===V.id?{...q,...V}:q)}:$})),i==null||i("UPDATE_ELEMENT",{sectionId:G,value:V})},[g,i]),se=x.useCallback(V=>{const{draggedId:G,sectionId:H,targetIndex:$,targetId:F,targetGridId:q,targetCol:R}=V;g(Z=>Z.map(J=>{if(J.id!==H)return J;const ee=[...J==null?void 0:J.questionData],ae=ee.findIndex(me=>me.id===G);if(ae===-1)return J;const ue={...ee[ae]};if(q!==void 0&&R!==void 0){if(ue.type==="grid")return J;const me=ee.findIndex(be=>{var we;return be.id!==G&&be.gridId===q&&((we=be.gridPosition)==null?void 0:we.col)===R});let ye=ee.map(be=>be.id===G?{...be,gridId:q,gridPosition:{col:R}}:be);return me!==-1&&(ye=ye.map((be,we)=>{if(we!==me)return be;const Me={...be};return delete Me.gridId,delete Me.gridPosition,Me})),{...J,questionData:ye}}if(ue.gridId&&$!==void 0&&q===void 0){const me={...ue};delete me.gridId,delete me.gridPosition;const ye=ee.filter(we=>we.id!==G),be=Math.min($,ye.length);return ye.splice(be,0,me),{...J,questionData:ye}}if(!ue.gridId&&$!==void 0&&q===void 0&&!F){ee.splice(ae,1);const me=Math.min($,ee.length);return ee.splice(me,0,ue),{...J,questionData:ee}}if(F){const me=ee.findIndex(ye=>ye.id===F);return me===-1?J:(ee.splice(ae,1),ee.splice(me,0,ue),{...J,questionData:ee})}return J})),i==null||i("MOVE_ELEMENT",V)},[g,i]),Q=x.useCallback((V,G)=>{g(H=>H==null?void 0:H.map($=>$.id===G?{...$,...V}:$)),i==null||i("UPDATE_SECTION",{sectionId:G,value:V})},[g,i]),j=x.useMemo(()=>({formData:y,setFormData:g,handleDragStop:B,removeElement:L,elementData:r,setElementData:d,updateElementPosition:U,addElement:W,addElementInPosition:Y,updateElement:ie,addSection:K,removeSection:D,updateSection:Q,isDragging:A,setIsDragging:C,selectedSection:E,setSelectedSection:k,activeSections:I,setActiveSections:P,updateGridElement:X,answerData:a,setAnswerData:l,uploadUrl:T,setUploadUrl:O,apiActivityCount:M,setApiActivityCount:_,duplicateElement:z,moveElement:se,showPreview:o,setShowPreview:s,undo:f,redo:N,canUndo:S,canRedo:w}),[y,B,L,r,U,W,Y,ie,K,D,Q,A,E,I,X,a,T,M,z,se,o,f,N,S,w]);return t.jsx(Ae.Provider,{value:j,children:e})};function Ss(e){var n,i,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(n=0;n<s;n++)e[n]&&(i=Ss(e[n]))&&(o&&(o+=" "),o+=i)}else for(i in e)e[i]&&(o&&(o+=" "),o+=i);return o}function de(){for(var e,n,i=0,o="",s=arguments.length;i<s;i++)(e=arguments[i])&&(n=Ss(e))&&(o&&(o+=" "),o+=n);return o}function hr({type:e="calendar",className:n}){return t.jsx(t.Fragment,{children:e==="calendar"?t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[t.jsx("path",{d:"M6.66406 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.3359 1.66675V4.16675",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2.91406 7.57495H17.0807",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M17.5 7.08341V14.1667C17.5 16.6667 16.25 18.3334 13.3333 18.3334H6.66667C3.75 18.3334 2.5 16.6667 2.5 14.1667V7.08341C2.5 4.58341 3.75 2.91675 6.66667 2.91675H13.3333C16.25 2.91675 17.5 4.58341 17.5 7.08341Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.0762 11.4167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M13.0762 13.9167H13.0836",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M9.99803 11.4167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M9.99803 13.9167H10.0055",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M6.91209 11.4167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M6.91209 13.9167H6.91957",stroke:"#292D32",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,children:[t.jsx("path",{d:"M10 6.66663V10.8333",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M10.0026 18.3333C5.9776 18.3333 2.71094 15.0667 2.71094 11.0417C2.71094 7.01667 5.9776 3.75 10.0026 3.75C14.0276 3.75 17.2943 7.01667 17.2943 11.0417",stroke:"#535862",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M7.5 1.66663H12.5",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M12.4141 15.4167V14.4501C12.4141 13.2584 13.2641 12.7667 14.2974 13.3667L15.1307 13.8501L15.9641 14.3334C16.9974 14.9334 16.9974 15.9084 15.9641 16.5084L15.1307 16.9917L14.2974 17.4751C13.2641 18.0751 12.4141 17.5834 12.4141 16.3917V15.4167Z",stroke:"#535862",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const Ji=({value:e=null,onGetValue:n,readOnly:i=!1,dateFormat:o="dd/MM/yyyy",name:s,placeholder:a="Select date",minDate:l,maxDate:r,showYearDropdown:d})=>{const u=h=>{if(!h)return null;const p=new Date(h);return isNaN(p.getTime())?null:p},m=u(e),[c,b]=x.useState(m);x.useEffect(()=>{const h=u(e);(h&&c&&h.getTime()!==c.getTime()||!h&&c||h&&!c)&&b(h)},[e]),x.useEffect(()=>{n&&n(s,c)},[c,n,s]);const v=h=>{b(h)};return t.jsx("div",{className:"builder_date__picker",children:t.jsx(dr,{showIcon:!0,icon:t.jsx(hr,{className:"react-datepicker__calendar-icon"}),showPopperArrow:!1,dateFormat:o,disabled:i,selected:c,onChange:v,className:"field-control",portalId:"root-portal",placeholderText:a,minDate:l,maxDate:r,showYearDropdown:d,scrollableYearDropdown:!0,yearDropdownItemNumber:40})})};function fr({element:e,validationData:n}){const{register:i=()=>({}),setValue:o,watch:s}=n||{};let a;return s&&(a=s()[e.id]),x.useEffect(()=>{i(e.id)},[e.id]),t.jsx(Ji,{name:e.id,value:a,onGetValue:o,readOnly:n==null?void 0:n.isReadOnly,dateFormat:(e==null?void 0:e.dateFormat)||"dd/MM/yyyy",minDate:e==null?void 0:e.minDate,maxDate:e==null?void 0:e.maxDate,showYearDropdown:e==null?void 0:e.allowYearPicker})}function Zi({element:e,validationData:n}){var o;const{register:i=()=>({})}=n||{};return t.jsx("div",{children:t.jsx("input",{placeholder:(e==null?void 0:e.placeholder)||"",type:(e==null?void 0:e.inputType)||"text",className:de("field-control",e==null?void 0:e.customClass),...i(e==null?void 0:e.id),disabled:n==null?void 0:n.isReadOnly,inputMode:(e==null?void 0:e.inputMode)||void 0,"aria-invalid":!!((o=n==null?void 0:n.errors)!=null&&o[e==null?void 0:e.id]),pattern:(e==null?void 0:e.pattern)||void 0})})}function pr(e,n){const i=e.icons,o=e.aliases||Object.create(null),s=Object.create(null);function a(l){if(i[l])return s[l]=[];if(!(l in s)){s[l]=null;const r=o[l]&&o[l].parent,d=r&&a(r);d&&(s[l]=[r].concat(d))}return s[l]}return Object.keys(i).concat(Object.keys(o)).forEach(a),s}const ws=Object.freeze({left:0,top:0,width:16,height:16}),ni=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Xi=Object.freeze({...ws,...ni}),Qi=Object.freeze({...Xi,body:"",hidden:!1});function gr(e,n){const i={};!e.hFlip!=!n.hFlip&&(i.hFlip=!0),!e.vFlip!=!n.vFlip&&(i.vFlip=!0);const o=((e.rotate||0)+(n.rotate||0))%4;return o&&(i.rotate=o),i}function Ns(e,n){const i=gr(e,n);for(const o in Qi)o in ni?o in e&&!(o in i)&&(i[o]=ni[o]):o in n?i[o]=n[o]:o in e&&(i[o]=e[o]);return i}function yr(e,n,i){const o=e.icons,s=e.aliases||Object.create(null);let a={};function l(r){a=Ns(o[r]||s[r],a)}return l(n),i.forEach(l),Ns(e,a)}function As(e,n){const i=[];if(typeof e!="object"||typeof e.icons!="object")return i;e.not_found instanceof Array&&e.not_found.forEach(s=>{n(s,null),i.push(s)});const o=pr(e);for(const s in o){const a=o[s];a&&(n(s,yr(e,s,a)),i.push(s))}return i}const xr={provider:"",aliases:{},not_found:{},...ws};function Ri(e,n){for(const i in n)if(i in e&&typeof e[i]!=typeof n[i])return!1;return!0}function Cs(e){if(typeof e!="object"||e===null)return null;const n=e;if(typeof n.prefix!="string"||!e.icons||typeof e.icons!="object"||!Ri(e,xr))return null;const i=n.icons;for(const s in i){const a=i[s];if(!s||typeof a.body!="string"||!Ri(a,Qi))return null}const o=n.aliases||Object.create(null);for(const s in o){const a=o[s],l=a.parent;if(!s||typeof l!="string"||!i[l]&&!o[l]||!Ri(a,Qi))return null}return n}const ks=Object.create(null);function Sr(e,n){return{provider:e,prefix:n,icons:Object.create(null),missing:new Set}}function dn(e,n){const i=ks[e]||(ks[e]=Object.create(null));return i[n]||(i[n]=Sr(e,n))}function Ms(e,n){return Cs(n)?As(n,(i,o)=>{o?e.icons[i]=o:e.missing.add(i)}):[]}function wr(e,n,i){try{if(typeof i.body=="string")return e.icons[n]={...i},!0}catch(o){}return!1}const Es=/^[a-z0-9]+(-[a-z0-9]+)*$/,ii=(e,n,i,o="")=>{const s=e.split(":");if(e.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;o=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const r=s.pop(),d=s.pop(),u={provider:s.length>0?s[0]:o,prefix:d,name:r};return n&&!oi(u)?null:u}const a=s[0],l=a.split("-");if(l.length>1){const r={provider:o,prefix:l.shift(),name:l.join("-")};return n&&!oi(r)?null:r}if(i&&o===""){const r={provider:o,prefix:"",name:a};return n&&!oi(r,i)?null:r}return null},oi=(e,n)=>e?!!((n&&e.prefix===""||e.prefix)&&e.name):!1;let En=!1;function Ts(e){return typeof e=="boolean"&&(En=e),En}function Ps(e){const n=typeof e=="string"?ii(e,!0,En):e;if(n){const i=dn(n.provider,n.prefix),o=n.name;return i.icons[o]||(i.missing.has(o)?null:void 0)}}function Nr(e,n){const i=ii(e,!0,En);if(!i)return!1;const o=dn(i.provider,i.prefix);return n?wr(o,i.name,n):(o.missing.add(i.name),!0)}function Ar(e,n){if(typeof e!="object")return!1;if(typeof n!="string"&&(n=e.provider||""),En&&!n&&!e.prefix){let s=!1;return Cs(e)&&(e.prefix="",As(e,(a,l)=>{Nr(a,l)&&(s=!0)})),s}const i=e.prefix;if(!oi({prefix:i,name:"a"}))return!1;const o=dn(n,i);return!!Ms(o,e)}const Ls=Object.freeze({width:null,height:null}),Bs=Object.freeze({...Ls,...ni}),Cr=/(-?[0-9.]*[0-9]+[0-9.]*)/g,kr=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Is(e,n,i){if(n===1)return e;if(i=i||100,typeof e=="number")return Math.ceil(e*n*i)/i;if(typeof e!="string")return e;const o=e.split(Cr);if(o===null||!o.length)return e;const s=[];let a=o.shift(),l=kr.test(a);for(;;){if(l){const r=parseFloat(a);isNaN(r)?s.push(a):s.push(Math.ceil(r*n*i)/i)}else s.push(a);if(a=o.shift(),a===void 0)return s.join("");l=!l}}function Mr(e,n="defs"){let i="";const o=e.indexOf("<"+n);for(;o>=0;){const s=e.indexOf(">",o),a=e.indexOf("</"+n);if(s===-1||a===-1)break;const l=e.indexOf(">",a);if(l===-1)break;i+=e.slice(s+1,a).trim(),e=e.slice(0,o).trim()+e.slice(l+1)}return{defs:i,content:e}}function Er(e,n){return e?"<defs>"+e+"</defs>"+n:n}function Tr(e,n,i){const o=Mr(e);return Er(o.defs,n+o.content+i)}const Pr=e=>e==="unset"||e==="undefined"||e==="none";function Lr(e,n){const i={...Xi,...e},o={...Bs,...n},s={left:i.left,top:i.top,width:i.width,height:i.height};let a=i.body;[i,o].forEach(p=>{const g=[],f=p.hFlip,N=p.vFlip;let y=p.rotate;f?N?y+=2:(g.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),g.push("scale(-1 1)"),s.top=s.left=0):N&&(g.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),g.push("scale(1 -1)"),s.top=s.left=0);let S;switch(y<0&&(y-=Math.floor(y/4)*4),y=y%4,y){case 1:S=s.height/2+s.top,g.unshift("rotate(90 "+S.toString()+" "+S.toString()+")");break;case 2:g.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:S=s.width/2+s.left,g.unshift("rotate(-90 "+S.toString()+" "+S.toString()+")");break}y%2===1&&(s.left!==s.top&&(S=s.left,s.left=s.top,s.top=S),s.width!==s.height&&(S=s.width,s.width=s.height,s.height=S)),g.length&&(a=Tr(a,'<g transform="'+g.join(" ")+'">',"</g>"))});const l=o.width,r=o.height,d=s.width,u=s.height;let m,c;l===null?(c=r===null?"1em":r==="auto"?u:r,m=Is(c,d/u)):(m=l==="auto"?d:l,c=r===null?Is(m,u/d):r==="auto"?u:r);const b={},v=(p,g)=>{Pr(g)||(b[p]=g.toString())};v("width",m),v("height",c);const h=[s.left,s.top,d,u];return b.viewBox=h.join(" "),{attributes:b,viewBox:h,body:a}}const Br=/\sid="(\S+)"/g,Ir="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Dr=0;function _r(e,n=Ir){const i=[];let o;for(;o=Br.exec(e);)i.push(o[1]);if(!i.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return i.forEach(a=>{const l=typeof n=="function"?n(a):n+(Dr++).toString(),r=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+r+')([")]|\\.[a-z])',"g"),"$1"+l+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const eo=Object.create(null);function Or(e,n){eo[e]=n}function no(e){return eo[e]||eo[""]}function io(e){let n;if(typeof e.resources=="string")n=[e.resources];else if(n=e.resources,!(n instanceof Array)||!n.length)return null;return{resources:n,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const oo=Object.create(null),Tn=["https://api.simplesvg.com","https://api.unisvg.com"],si=[];for(;Tn.length>0;)Tn.length===1||Math.random()>.5?si.push(Tn.shift()):si.push(Tn.pop());oo[""]=io({resources:["https://api.iconify.design"].concat(si)});function Kr(e,n){const i=io(n);return i===null?!1:(oo[e]=i,!0)}function so(e){return oo[e]}let Ds=(()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch(n){}})();function Hr(e,n){const i=so(e);if(!i)return 0;let o;if(!i.maxURL)o=0;else{let s=0;i.resources.forEach(l=>{s=Math.max(s,l.length)});const a=n+".json?icons=";o=i.maxURL-s-i.path.length-a.length}return o}function Gr(e){return e===404}const Fr=(e,n,i)=>{const o=[],s=Hr(e,n),a="icons";let l={type:a,provider:e,prefix:n,icons:[]},r=0;return i.forEach((d,u)=>{r+=d.length+1,r>=s&&u>0&&(o.push(l),l={type:a,provider:e,prefix:n,icons:[]},r=d.length),l.icons.push(d)}),o.push(l),o};function Vr(e){if(typeof e=="string"){const n=so(e);if(n)return n.path}return"/"}const zr={prepare:Fr,send:(e,n,i)=>{if(!Ds){i("abort",424);return}let o=Vr(n.provider);switch(n.type){case"icons":{const a=n.prefix,r=n.icons.join(","),d=new URLSearchParams({icons:r});o+=a+".json?"+d.toString();break}case"custom":{const a=n.uri;o+=a.slice(0,1)==="/"?a.slice(1):a;break}default:i("abort",400);return}let s=503;Ds(e+o).then(a=>{const l=a.status;if(l!==200){setTimeout(()=>{i(Gr(l)?"abort":"next",l)});return}return s=501,a.json()}).then(a=>{if(typeof a!="object"||a===null){setTimeout(()=>{a===404?i("abort",a):i("next",s)});return}setTimeout(()=>{i("success",a)})}).catch(()=>{i("next",s)})}};function _s(e,n){e.forEach(i=>{const o=i.loaderCallbacks;o&&(i.loaderCallbacks=o.filter(s=>s.id!==n))})}function Wr(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const n=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!n.length)return;let i=!1;const o=e.provider,s=e.prefix;n.forEach(a=>{const l=a.icons,r=l.pending.length;l.pending=l.pending.filter(d=>{if(d.prefix!==s)return!0;const u=d.name;if(e.icons[u])l.loaded.push({provider:o,prefix:s,name:u});else if(e.missing.has(u))l.missing.push({provider:o,prefix:s,name:u});else return i=!0,!0;return!1}),l.pending.length!==r&&(i||_s([e],a.id),a.callback(l.loaded.slice(0),l.missing.slice(0),l.pending.slice(0),a.abort))})}))}let $r=0;function jr(e,n,i){const o=$r++,s=_s.bind(null,i,o);if(!n.pending.length)return s;const a={id:o,icons:n,callback:e,abort:s};return i.forEach(l=>{(l.loaderCallbacks||(l.loaderCallbacks=[])).push(a)}),s}function Ur(e){const n={loaded:[],missing:[],pending:[]},i=Object.create(null);e.sort((s,a)=>s.provider!==a.provider?s.provider.localeCompare(a.provider):s.prefix!==a.prefix?s.prefix.localeCompare(a.prefix):s.name.localeCompare(a.name));let o={provider:"",prefix:"",name:""};return e.forEach(s=>{if(o.name===s.name&&o.prefix===s.prefix&&o.provider===s.provider)return;o=s;const a=s.provider,l=s.prefix,r=s.name,d=i[a]||(i[a]=Object.create(null)),u=d[l]||(d[l]=dn(a,l));let m;r in u.icons?m=n.loaded:l===""||u.missing.has(r)?m=n.missing:m=n.pending;const c={provider:a,prefix:l,name:r};m.push(c)}),n}function qr(e,n=!0,i=!1){const o=[];return e.forEach(s=>{const a=typeof s=="string"?ii(s,n,i):s;a&&o.push(a)}),o}const Yr={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Jr(e,n,i,o){const s=e.resources.length,a=e.random?Math.floor(Math.random()*s):e.index;let l;if(e.random){let A=e.resources.slice(0);for(l=[];A.length>1;){const C=Math.floor(Math.random()*A.length);l.push(A[C]),A=A.slice(0,C).concat(A.slice(C+1))}l=l.concat(A)}else l=e.resources.slice(a).concat(e.resources.slice(0,a));const r=Date.now();let d="pending",u=0,m,c=null,b=[],v=[];typeof o=="function"&&v.push(o);function h(){c&&(clearTimeout(c),c=null)}function p(){d==="pending"&&(d="aborted"),h(),b.forEach(A=>{A.status==="pending"&&(A.status="aborted")}),b=[]}function g(A,C){C&&(v=[]),typeof A=="function"&&v.push(A)}function f(){return{startTime:r,payload:n,status:d,queriesSent:u,queriesPending:b.length,subscribe:g,abort:p}}function N(){d="failed",v.forEach(A=>{A(void 0,m)})}function y(){b.forEach(A=>{A.status==="pending"&&(A.status="aborted")}),b=[]}function S(A,C,E){const k=C!=="success";switch(b=b.filter(I=>I!==A),d){case"pending":break;case"failed":if(k||!e.dataAfterTimeout)return;break;default:return}if(C==="abort"){m=E,N();return}if(k){m=E,b.length||(l.length?w():N());return}if(h(),y(),!e.random){const I=e.resources.indexOf(A.resource);I!==-1&&I!==e.index&&(e.index=I)}d="completed",v.forEach(I=>{I(E)})}function w(){if(d!=="pending")return;h();const A=l.shift();if(A===void 0){if(b.length){c=setTimeout(()=>{h(),d==="pending"&&(y(),N())},e.timeout);return}N();return}const C={status:"pending",resource:A,callback:(E,k)=>{S(C,E,k)}};b.push(C),u++,c=setTimeout(w,e.rotate),i(A,n,C.callback)}return setTimeout(w),f}function Os(e){const n={...Yr,...e};let i=[];function o(){i=i.filter(r=>r().status==="pending")}function s(r,d,u){const m=Jr(n,r,d,(c,b)=>{o(),u&&u(c,b)});return i.push(m),m}function a(r){return i.find(d=>r(d))||null}return{query:s,find:a,setIndex:r=>{n.index=r},getIndex:()=>n.index,cleanup:o}}function Ks(){}const ao=Object.create(null);function Zr(e){if(!ao[e]){const n=so(e);if(!n)return;const i=Os(n),o={config:n,redundancy:i};ao[e]=o}return ao[e]}function Xr(e,n,i){let o,s;if(typeof e=="string"){const a=no(e);if(!a)return i(void 0,424),Ks;s=a.send;const l=Zr(e);l&&(o=l.redundancy)}else{const a=io(e);if(a){o=Os(a);const l=e.resources?e.resources[0]:"",r=no(l);r&&(s=r.send)}}return!o||!s?(i(void 0,424),Ks):o.query(n,s,i)().abort}function Hs(){}function Qr(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Wr(e)}))}function Rr(e){const n=[],i=[];return e.forEach(o=>{(o.match(Es)?n:i).push(o)}),{valid:n,invalid:i}}function Pn(e,n,i){function o(){const s=e.pendingIcons;n.forEach(a=>{s&&s.delete(a),e.icons[a]||e.missing.add(a)})}if(i&&typeof i=="object")try{if(!Ms(e,i).length){o();return}}catch(s){console.error(s)}o(),Qr(e)}function Gs(e,n){e instanceof Promise?e.then(i=>{n(i)}).catch(()=>{n(null)}):n(e)}function ed(e,n){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(n).sort():e.iconsToLoad=n,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:i,prefix:o}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const a=e.loadIcon;if(e.loadIcons&&(s.length>1||!a)){Gs(e.loadIcons(s,o,i),m=>{Pn(e,s,m)});return}if(a){s.forEach(m=>{const c=a(m,o,i);Gs(c,b=>{const v=b?{prefix:o,icons:{[m]:b}}:null;Pn(e,[m],v)})});return}const{valid:l,invalid:r}=Rr(s);if(r.length&&Pn(e,r,null),!l.length)return;const d=o.match(Es)?no(i):null;if(!d){Pn(e,l,null);return}d.prepare(i,o,l).forEach(m=>{Xr(i,m,c=>{Pn(e,m.icons,c)})})}))}const nd=(e,n)=>{const i=qr(e,!0,Ts()),o=Ur(i);if(!o.pending.length){let d=!0;return n&&setTimeout(()=>{d&&n(o.loaded,o.missing,o.pending,Hs)}),()=>{d=!1}}const s=Object.create(null),a=[];let l,r;return o.pending.forEach(d=>{const{provider:u,prefix:m}=d;if(m===r&&u===l)return;l=u,r=m,a.push(dn(u,m));const c=s[u]||(s[u]=Object.create(null));c[m]||(c[m]=[])}),o.pending.forEach(d=>{const{provider:u,prefix:m,name:c}=d,b=dn(u,m),v=b.pendingIcons||(b.pendingIcons=new Set);v.has(c)||(v.add(c),s[u][m].push(c))}),a.forEach(d=>{const u=s[d.provider][d.prefix];u.length&&ed(d,u)}),n?jr(n,o,a):Hs};function id(e,n){const i={...e};for(const o in n){const s=n[o],a=typeof s;o in Ls?(s===null||s&&(a==="string"||a==="number"))&&(i[o]=s):a===typeof i[o]&&(i[o]=o==="rotate"?s%4:s)}return i}const od=/[\s,]+/;function sd(e,n){n.split(od).forEach(i=>{switch(i.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function ad(e,n=0){const i=e.replace(/^-?[0-9.]*/,"");function o(s){for(;s<0;)s+=4;return s%4}if(i===""){const s=parseInt(e);return isNaN(s)?0:o(s)}else if(i!==e){let s=0;switch(i){case"%":s=25;break;case"deg":s=90}if(s){let a=parseFloat(e.slice(0,e.length-i.length));return isNaN(a)?0:(a=a/s,a%1===0?o(a):0)}}return n}function td(e,n){let i=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in n)i+=" "+o+'="'+n[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+i+">"+e+"</svg>"}function ld(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function rd(e){return"data:image/svg+xml,"+ld(e)}function dd(e){return'url("'+rd(e)+'")'}let Ln;function ud(){try{Ln=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){Ln=null}}function cd(e){return Ln===void 0&&ud(),Ln?Ln.createHTML(e):e}const Fs={...Bs,inline:!1},md={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},bd={display:"inline-block"},to={backgroundColor:"currentColor"},Vs={backgroundColor:"transparent"},zs={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Ws={WebkitMask:to,mask:to,background:Vs};for(const e in Ws){const n=Ws[e];for(const i in zs)n[e+i]=zs[i]}const vd={...Fs,inline:!0};function $s(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const hd=(e,n,i)=>{const o=n.inline?vd:Fs,s=id(o,n),a=n.mode||"svg",l={},r=n.style||{},d={...a==="svg"?md:{}};if(i){const g=ii(i,!1,!0);if(g){const f=["iconify"],N=["provider","prefix"];for(const y of N)g[y]&&f.push("iconify--"+g[y]);d.className=f.join(" ")}}for(let g in n){const f=n[g];if(f!==void 0)switch(g){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":d.ref=f;break;case"className":d[g]=(d[g]?d[g]+" ":"")+f;break;case"inline":case"hFlip":case"vFlip":s[g]=f===!0||f==="true"||f===1;break;case"flip":typeof f=="string"&&sd(s,f);break;case"color":l.color=f;break;case"rotate":typeof f=="string"?s[g]=ad(f):typeof f=="number"&&(s[g]=f);break;case"ariaHidden":case"aria-hidden":f!==!0&&f!=="true"&&delete d["aria-hidden"];break;default:o[g]===void 0&&(d[g]=f)}}const u=Lr(e,s),m=u.attributes;if(s.inline&&(l.verticalAlign="-0.125em"),a==="svg"){d.style={...l,...r},Object.assign(d,m);let g=0,f=n.id;return typeof f=="string"&&(f=f.replace(/-/g,"_")),d.dangerouslySetInnerHTML={__html:cd(_r(u.body,f?()=>f+"ID"+g++:"iconifyReact"))},x.createElement("svg",d)}const{body:c,width:b,height:v}=e,h=a==="mask"||(a==="bg"?!1:c.indexOf("currentColor")!==-1),p=td(c,{...m,width:b+"",height:v+""});return d.style={...l,"--svg":dd(p),width:$s(m.width),height:$s(m.height),...bd,...h?to:Vs,...r},x.createElement("span",d)};if(Ts(!0),Or("",zr),typeof document!="undefined"&&typeof window!="undefined"){const e=window;if(e.IconifyPreload!==void 0){const n=e.IconifyPreload,i="Invalid IconifyPreload syntax.";typeof n=="object"&&n!==null&&(n instanceof Array?n:[n]).forEach(o=>{try{(typeof o!="object"||o===null||o instanceof Array||typeof o.icons!="object"||typeof o.prefix!="string"||!Ar(o))&&console.error(i)}catch(s){console.error(i)}})}if(e.IconifyProviders!==void 0){const n=e.IconifyProviders;if(typeof n=="object"&&n!==null)for(let i in n){const o="IconifyProviders["+i+"] is invalid.";try{const s=n[i];if(typeof s!="object"||!s||s.resources===void 0)continue;Kr(i,s)||console.error(o)}catch(s){console.error(o)}}}}function js(e){const[n,i]=x.useState(!!e.ssr),[o,s]=x.useState({});function a(v){if(v){const h=e.icon;if(typeof h=="object")return{name:"",data:h};const p=Ps(h);if(p)return{name:h,data:p}}return{name:""}}const[l,r]=x.useState(a(!!e.ssr));function d(){const v=o.callback;v&&(v(),s({}))}function u(v){if(JSON.stringify(l)!==JSON.stringify(v))return d(),r(v),!0}function m(){var v;const h=e.icon;if(typeof h=="object"){u({name:"",data:h});return}const p=Ps(h);if(u({name:h,data:p}))if(p===void 0){const g=nd([h],m);s({callback:g})}else p&&((v=e.onLoad)===null||v===void 0||v.call(e,h))}x.useEffect(()=>(i(!0),d),[]),x.useEffect(()=>{n&&m()},[e.icon,n]);const{name:c,data:b}=l;return b?hd({...Xi,...b},e,c):e.children?e.children:e.fallback?e.fallback:x.createElement("span",{})}const Us=x.forwardRef((e,n)=>js({...e,_ref:n}));x.forwardRef((e,n)=>js({inline:!0,...e,_ref:n}));function te({icon:e,iconClass:n}){return t.jsx(t.Fragment,{children:t.jsx(Us,{icon:e,className:n})})}function lo({element:e,validationData:n,placeholder:i}){var c;const{register:o=()=>({}),setValue:s,isReadOnly:a,watch:l,getValues:r}=n||{},[d,u]=x.useState(()=>{const b=r==null?void 0:r(e.id);return Array.isArray(b)?b:[]}),m=x.useMemo(()=>d==null?void 0:d.map(b=>b.label).join(", "),[d]);return x.useEffect(()=>{o(e.id)},[e.id,o]),x.useEffect(()=>{if(!l)return;const b=l(v=>{const h=v[e.id];h!==void 0&&u(Array.isArray(h)?h:[])});return()=>{var v;return(v=b.unsubscribe)==null?void 0:v.call(b)}},[l,e.id]),t.jsx("div",{className:"custom-select",children:t.jsx(re.Listbox,{value:d||[],onChange:b=>{u(b),s==null||s(e.id,b)},multiple:!0,disabled:a,by:"value",children:t.jsxs("div",{className:"custom-select__wrapper",children:[t.jsxs(re.Listbox.Button,{className:"custom-select__control field-control",disabled:a,children:[t.jsx("span",{className:"custom-select__value",children:(d==null?void 0:d.length)>0?m:t.jsx("span",{className:"custom-select__placeholder",children:i!=null?i:" Select options"})}),t.jsx("span",{className:"custom-select__icon",children:t.jsx(te,{icon:"lucide:chevron-down"})})]}),t.jsx(re.Transition,{as:x.Fragment,leave:"custom-select__transition",children:t.jsx(re.Listbox.Options,{anchor:"bottom start",className:"custom-select__options",children:(c=e==null?void 0:e.options)==null?void 0:c.map((b,v)=>t.jsx(re.Listbox.Option,{value:b,className:({active:h})=>`custom-select__option ${h?"custom-select__option--active":""}`,children:({selected:h})=>t.jsxs("div",{className:"custom-select__option-row",children:[t.jsx("span",{className:`custom-select__option-label ${h?"custom-select__option--selected":""}`,children:b.label}),h&&t.jsx("span",{className:"custom-select__check",children:"✓"})]})},v))})})]})})})}const fd=["jpg","jpeg","png","gif","bmp","webp","svg","image"],pd=(e="")=>{var i;const n=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return fd.includes(n)||e.startsWith("data:image/")?"image":n==="pdf"||e.startsWith("data:application/pdf")?"pdf":["doc","docx"].includes(n)?"word":["xls","xlsx","csv"].includes(n)?"excel":["ppt","pptx"].includes(n)?"powerpoint":"other"},gd={pdf:"vscode-icons:file-type-pdf2",word:"vscode-icons:file-type-word",excel:"vscode-icons:file-type-excel",powerpoint:"vscode-icons:file-type-powerpoint2"};function qs({fileUrl:e,fileName:n,removeFile:i}){const[o,s]=x.useState(!1),[a,l]=x.useState("unknown"),[r,d]=x.useState(null);x.useEffect(()=>{e&&l(pd(e))},[e]),x.useEffect(()=>{if(a==="pdf"&&(e!=null&&e.startsWith("data:")))try{const v=atob(e.split(",")[1]),h=new ArrayBuffer(v.length),p=new Uint8Array(h);for(let N=0;N<v.length;N++)p[N]=v.charCodeAt(N);const g=new Blob([h],{type:"application/pdf"}),f=URL.createObjectURL(g);return d(f),()=>URL.revokeObjectURL(f)}catch(v){console.error("Error creating blob URL:",v)}else d(null)},[e,a]);const u=()=>{a==="image"||a==="pdf"?s(!0):window.open(r||e,"_blank")},m=()=>s(!1),c=n||(e==null?void 0:e.split("/").pop())||"Unknown file";function b(v,h="download"){if(!v)return;if(v.startsWith("data:")){const g=document.createElement("a");g.href=v,g.download=h,document.body.appendChild(g),g.click(),document.body.removeChild(g);return}const p=document.createElement("a");p.href=v,p.setAttribute("download",h),document.body.appendChild(p),p.click(),document.body.removeChild(p)}return t.jsxs("div",{className:"mt-2 field-control !py-1 !bg-gray-50 !flex justify-between gap-x-8 items-center",children:[t.jsxs("div",{onClick:u,className:"!flex items-center rounded cursor-pointer gap-x-3",title:`Click to preview ${c}`,children:[a==="image"&&t.jsx("div",{className:"flex items-center justify-center ",children:t.jsx(te,{iconClass:"text-4xl",icon:"fluent-color:image-48"})}),a!=="image"&&t.jsx(te,{icon:gd[a],iconClass:"text-4xl"}),t.jsx("span",{className:"text-sm font-semibold text-center text-gray-700 truncate max-w-[300px]",children:c})]}),t.jsxs("div",{className:"flex gap-x-1 items-center",children:[t.jsx("button",{type:"button",className:"p-2",onClick:()=>b(r||e,n),title:`Download ${c}`,children:t.jsx(te,{icon:"streamline-flex:download-tray-solid"})}),i&&t.jsx("button",{type:"button",className:"p-2 text-lg text-red-500",onClick:i,children:t.jsx(te,{icon:"lets-icons:trash-duotone"})})]}),o&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:m,children:t.jsxs("div",{className:"relative bg-white p-8 rounded-lg w-full max-w-[90vw] max-h-[90vh] overflow-auto",onClick:v=>v.stopPropagation(),children:[t.jsx("button",{onClick:m,className:"absolute text-2xl font-bold text-gray-700 top-2 right-2","aria-label":"Close preview",children:"×"}),a==="image"?t.jsx("img",{src:e,alt:c,className:"max-w-full max-h-[80vh] mx-auto object-contain",crossOrigin:"anonymous"}):a==="pdf"?t.jsx("iframe",{src:r||e,title:c,className:"w-full h-[80vh] rounded border"}):null]})})]})}const xe=e=>{const n=typeof window!="undefined"?localStorage.getItem(e):"";try{return JSON.parse(n)}catch(i){return n}},Ys=(e,n)=>{const i=typeof n!="string"?JSON.stringify(n):n;return localStorage.setItem(e,i)},yd=5*1024*1024;function xd({onFileLoaded:e,disabled:n=!1,handleDeleteFile:i,multiple:o=!1,list:s=null,accept:a=[]}){const{uploadUrl:l,setApiActivityCount:r}=x.useContext(Ae),d=x.useRef(null),[u,m]=x.useState(s),[c,b]=x.useState(!1);x.useEffect(()=>{m(s)},[s]);const v=x.useMemo(()=>a==null?void 0:a.map(w=>w.value).join(", "),[a]),h=x.useMemo(()=>a==null?void 0:a.map(w=>w.label).join(", "),[a]),p=x.useCallback(async w=>{var E,k;const A=xe("token"),C=((E=xe("orgData"))==null?void 0:E.id)||xe("organizationId");try{const{data:I}=await Xe.post(l,{...w,service:"FORM",organizationId:C||""},{headers:{Authorization:`Bearer ${A}`}});return(k=I==null?void 0:I.data)==null?void 0:k.url}catch(I){throw console.error("File upload error:",I),new Error("Failed to upload file to server")}},[l]),g=x.useCallback(w=>new Promise((A,C)=>{const E=new FileReader;E.onloadend=async()=>{try{const k=E.result.replace(/^data:.*;base64,/,""),I=l?await p({base64:k,ext:`.${w.name.split(".").pop()}`,fileName:w.name}):E.result;A({base64:I,type:w.type,name:w.name})}catch(k){C(k)}},E.onerror=()=>C(new Error("File read failed")),E.readAsDataURL(w)}),[l,p]),f=x.useCallback(w=>{var C;const A=v?(C=v.split(","))==null?void 0:C.map(E=>E.trim()):[];for(const E of w){if(E.size>yd)return Ee.toast.error(`File "${E.name}" exceeds 5MB limit (${(E.size/1024/1024).toFixed(2)}MB)`),!1;if(A.length&&!A.some(k=>E.type===k||E.name.toLowerCase().endsWith(k.replace("*",""))))return Ee.toast.error(`File "${E.name}" is not an allowed type. Allowed: ${h||"any"}`),!1}return!0},[v,h]),N=x.useCallback(async w=>{const A=Array.from(w.target.files||[]);if(!(!A.length||c)){if(!f(A)){d.current&&(d.current.value="");return}try{b(!0),r==null||r(k=>k+1);const C=await Promise.all(A==null?void 0:A.map(g)),E=o&&u?[...u,...C]:C;m(E),e(E),Ee.toast.success(`Successfully uploaded ${A.length} file(s)`)}catch(C){console.error("Upload error:",C),Ee.toast.error("Failed to upload file(s). Please try again.")}finally{b(!1),r==null||r(C=>Math.max(0,C-1)),d.current&&(d.current.value="")}}},[c,f,g,e,o,u,r]),y=x.useCallback(w=>{c||(d.current&&(d.current.value=""),m(A=>{const C=w===void 0?null:(A==null?void 0:A.filter((E,k)=>k!==w))||null;return e(C),C}),i==null||i())},[i,e,c]),S=u&&u.length>0;return t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[!n&&t.jsxs("div",{className:"!flex field-control !py-0 !px-0 relative",children:[t.jsx("input",{ref:d,type:"file",onChange:N,disabled:n||c,multiple:o,accept:v||"",className:`w-full text-sm text-gray-500 file:mr-4 flex-1 file:px-4 !py-1 !pl-1\r
2
2
  file:rounded-[6px] file:py-[6px] file:border-0\r
3
3
  file:text-sm file:font-semibold\r
4
4
  file:bg-blue-50 file:text-blue-700\r
@@ -27,7 +27,7 @@
27
27
  ${i===e.id?" border-blue-200 bg-gray-100":"bg-white"} ${s.includes(n)?"min-h-[300px] pb-6 ":""}`,children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{draggable:!0,onDragStart:g=>{g.dataTransfer.setData("sectionid",e.id),g.dataTransfer.effectAllowed="move",m(!0)},onDragEnd:()=>m(!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:[t.jsx(te,{icon:"material-symbols:drag-indicator",iconClass:"text-gray-400 text-lg"}),t.jsx("h2",{className:"font-medium",children:e.title||"Section title"})]}),t.jsxs("div",{className:"flex items-center gap-x-2",children:[t.jsx("button",{type:"button",className:"p-1 text-xs border rounded-lg",onClick:()=>l(e),children:t.jsx(te,{icon:"fluent:edit-28-regular"})}),d>1&&t.jsx("button",{type:"button",className:"p-1 text-xs border rounded-lg",onClick:()=>r(e.id),children:t.jsx(te,{icon:"lets-icons:trash-duotone-line"})}),t.jsx("button",{type:"button",className:"p-1 text-xs rounded-lg",onClick:()=>a(n),children:t.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)&&t.jsx("p",{className:"mt-2 text-sm text-gray-600",children:e==null?void 0:e.description}),s.includes(n)&&t.jsxs("div",{className:"h-full mt-4 transition-all duration-200",id:e.id,onDragOver:u,onDragEnd:()=>m(!1),onClick:()=>o(e.id),children:[t.jsx("hr",{className:"group-last:hidden"}),t.jsx("div",{className:"h-full mt-4 gap-y-6 ",children:t.jsx(Tu,{elementData:e==null?void 0:e.questionData,sectionId:e==null?void 0:e.id})})]})]})},e==null?void 0:e.id)},_u=({onAddTemplate:e,templates:n})=>{const i=[...Iu,...n||[]],[o,s]=x.useState(!1),[a,l]=x.useState(!1),r=x.useRef(null),d=x.useRef(null),{removeSection:u,addSection:m,formData:c,setIsDragging:b,setSelectedSection:v,selectedSection:h,activeSections:p,setActiveSections:g,setFormData:f}=x.useContext(Ae),N=x.useRef((c==null?void 0:c.length)||0);x.useEffect(()=>{var k;v(((k=c[0])==null?void 0:k.id)||null)},[]),x.useEffect(()=>{(c==null?void 0:c.length)>N.current&&d.current&&requestAnimationFrame(()=>{var k;(k=d.current)==null||k.scrollTo({top:d.current.scrollHeight,behavior:"smooth"})}),N.current=(c==null?void 0:c.length)||0},[c==null?void 0:c.length]);const y=x.useCallback(k=>{k.preventDefault(),k.dataTransfer.dropEffect="move",d.current&&(d.current.scrollTop=d.current.scrollHeight)},[]),S=x.useCallback((k,I)=>{f(P=>{const T=P.findIndex(B=>B.id===k),O=P.findIndex(B=>B.id===I);if(T===-1||O===-1||T===O)return P;const M=[...P],[_]=M.splice(T,1);return M.splice(O,0,_),M})},[f]);function w(k){p.includes(k)?g(I=>I.filter(P=>P!==k)):g(I=>[...I,k])}function A(k){r.current=k,s(!0)}const C=k=>{var P,T,O,M;const I=(_,B={})=>({...JSON.parse(JSON.stringify(_)),...B});if(k.sections&&Array.isArray(k.sections)){const B=k.sections.filter(Boolean).map(D=>{var U;const L=Ce.v4(),z=(U=D.questionData)==null?void 0:U.map(W=>I(W,{id:Ce.v4(),sectionId:L}));if(z){const W=new Map;D.questionData.forEach((Y,X)=>{W.set(Y.id,z[X].id)}),z.forEach(Y=>{Y.gridId&&W.has(Y.gridId)&&(Y.gridId=W.get(Y.gridId))})}return I(D,{id:L,questionData:z||[]})});c.length===1&&c[0].title===""&&c[0].description===""&&(!((P=c[0])!=null&&P.questionData)||((O=(T=c[0])==null?void 0:T.questionData)==null?void 0:O.length)===0)?(f(B),B.length>0&&v((M=B[0])==null?void 0:M.id)):f(D=>[...D,...B])}},E=xe("config");return t.jsxs("div",{className:"relative flex flex-col h-full pb-5 mx-auto gap-x-4 ",children:[o&&t.jsx(Lu,{isOpen:o,onClose:()=>s(!1),section:r.current}),t.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((k,I)=>t.jsx(Du,{section:k,index:I,selectedSection:h,setSelectedSection:v,activeSections:p,toggleSection:w,handleSectionEdit:A,removeSection:u,formDataLength:c.length,onDragOver:y,setIsDragging:b,onReorderSection:S},k.id)),t.jsxs("div",{className:"flex justify-center gap-x-4",children:[t.jsxs("button",{type:"button",onClick:()=>m(),style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:"text-sm font-medium",children:["+ Add section"," "]}),e||i!=null&&i.length?t.jsx("button",{type:"button",onClick:()=>{i!=null&&i.length?l(!0):e&&e()},style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:"text-sm font-medium",children:"+ Add existing template"}):null]})]}),a&&t.jsx(Bu,{isOpen:a,onClose:()=>l(!1),templates:i,onSelect:C})]})},Ou=()=>{const{formData:e,uploadUrl:n}=x.useContext(Ae),[i,o]=x.useState("multi"),s=xe("config");return t.jsxs("div",{className:"flex flex-col h-full w-full",children:[t.jsx("div",{className:"flex justify-center p-3 border-b border-gray-100 bg-gray-50/50",children:t.jsxs("div",{className:"flex bg-gray-200 p-1 rounded-lg text-sm font-medium",children:[t.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"}),t.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"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto w-full relative",children:t.jsx(wo,{form_data:e,ignoreValidation:!0,config:s,uploadUrl:n,renderType:i,onGetValues:a=>console.log(a)})})]})},go=({loadingClass:e})=>{const n=de("h-full w-full min-h-[300px] flex justify-center items-center",e);return x.useEffect(()=>{const i=xe("config"),o=(i==null?void 0:i.loaderColor)||"#333";document.documentElement.style.setProperty("--loader-color",o)},[]),t.jsx("div",{className:n,children:t.jsx("span",{className:"loader"})})},Ku=x.lazy(()=>Promise.resolve().then(()=>yg));function Hu({questionData:e,uploadUrl:n,onAddTemplate:i,templates:o,viewMode:s="canvas"}){const{setFormData:a,addSection:l,setUploadUrl:r,showPreview:d,formData:u}=x.useContext(Ae);x.useEffect(()=>{e&&e.length>0&&a(e)},[e,a]),x.useEffect(()=>{r(n)},[n,r]);const m=x.useCallback(c=>{c.preventDefault();try{const b=JSON.parse(c.dataTransfer.getData("properties"));if((b==null?void 0:b.type)==="section"){l();return}}catch(b){console.error("Drop error:",b)}},[]);return t.jsxs("div",{className:"flex gap-x-6 h-full",children:[t.jsx("div",{onDragOver:c=>c.preventDefault(),onDrop:c=>m(c),className:" h-full overflow-y-auto no-scrollbar max-h-[calc(100vh-80px)] flex-1 form_builder",children:s==="canvas"?t.jsx(_u,{onAddTemplate:i,templates:o}):t.jsx(x.Suspense,{fallback:t.jsx(go,{loadingClass:"!w-full !h-full"}),children:t.jsx(Ku,{formData:u})})}),s==="canvas"&&t.jsx(re.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:t.jsx("div",{className:"px-2 shadow_box min-w-0 bg-white border border-gray-100 rounded-lg container",children:t.jsx(Ou,{})})})]})}const yo=[{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"}],Gu=()=>{const[e,n]=x.useState(""),{setIsDragging:i,addElement:o,selectedSection:s}=x.useContext(Ae),a=x.useCallback((v,h)=>{if(!s){Ee.toast.error("Please select a section to add an element.");return}v.dataTransfer.setData("properties",JSON.stringify(h)),v.dataTransfer.effectAllowed="move",i(!0)},[i,s]);function l(v){if(!s){Ee.toast.error("Please select a section to add an element.");return}const h={...v,id:Ce.v4(),sectionId:s};o(h,s)}const r=xe("config")||{},d=r.elementColor,u=r.elementBgColor,m=r.elementBorderColor,c=Ld.filter(v=>v.label.toLowerCase().includes(e.toLowerCase())),b=yo==null?void 0:yo.map(v=>({title:v.title,elements:c.filter(h=>{var p;return(p=Bd[v.key])==null?void 0:p.includes(h.type)})})).filter(v=>v.elements.length>0);return t.jsxs("div",{className:"pt-4 flex flex-col gap-y-6",children:[t.jsx("div",{className:"px-5",children:t.jsx("input",{className:"field-control",placeholder:"Search",value:e,onChange:v=>n(v.target.value),name:"search",id:"search"})}),t.jsx("div",{className:"flex-1 overflow-y-auto no-scrollbar max-h-[calc(100vh-100px)]",children:t.jsx("ul",{className:"grid gap-y-5 mt-3 px-5 ",children:b==null?void 0:b.map((v,h)=>{var p;return t.jsxs("li",{children:[t.jsx("h4",{className:"mb-2 text-[11px] font-bold text-gray-500 uppercase",children:v.title}),t.jsx("ul",{className:"grid grid-cols-2 gap-y-3 gap-x-4 mb-3",children:(p=v.elements)==null?void 0:p.map(g=>t.jsx("li",{onDragStart:f=>a(f,g),onDragEnd:()=>i(!1),onClick:()=>l(g),style:{borderColor:m,backgroundColor:u},className:`cursor-move text-[#475467] flex justify-between items-center \r
28
28
  border-[1.5px] border-[#98A2B3] rounded-lg py-2 px-2 shadow-custom\r
29
29
  hover:shadow-lg transition-all duration-200\r
30
- active:opacity-50 element_class`,draggable:!0,children:t.jsxs("span",{className:"flex flex-col items-center justify-center w-full gap-2",children:[t.jsx("span",{style:{color:d},children:t.jsx(te,{icon:g.icon,iconClass:"w-6 h-6"})}),t.jsx("span",{style:{color:d},className:"text-xs font-medium text-center",children:g.label})]})},g.type))})]},h)})})})]})},Fu=x.memo(Gu),Ke=({text:e="",isDisabled:n=!1,isLoading:i=!1,btnClass:o="bg-primary-500 text-white",icon:s="",iconPosition:a="left",iconClass:l="text-[20px]",loadingClass:r="",link:d="",div:u=!1,type:m="button",style:c,onClick:b})=>{const v=de("btn inline-flex justify-center",{"pointer-events-none":i,"opacity-40 cursor-not-allowed":n},o),h=()=>i?t.jsxs(t.Fragment,{children:[t.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:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.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..."]}):t.jsxs("span",{className:"flex items-center",children:[s&&a==="left"&&t.jsx("span",{className:`mr-[6px] ${l}`,children:t.jsx(te,{icon:s})}),e&&t.jsx("span",{children:e}),s&&a==="right"&&t.jsx("span",{className:`ml-[6px] ${l}`,children:t.jsx(te,{icon:s})})]});return u?t.jsx("div",{className:v,children:h()}):d?t.jsx(vr.Link,{to:d,className:v,children:h()}):t.jsx("button",{disabled:n,type:m,className:v,"data-testid":"btn",onClick:b,style:c,children:h()})};function Vu(){return t.jsx("div",{children:t.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",fill:"#D5D7DA"}),t.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",stroke:"#E9EAEB"}),t.jsx("path",{d:"M22.5 14L14.5 22M14.5 14L22.5 22",stroke:"#414651",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const zu=({isOpen:e,onClose:n})=>{const{formData:i,uploadUrl:o}=x.useContext(Ae);if(!e)return null;const s=xe("config");return t.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:[t.jsx("button",{type:"button",onClick:n,className:"absolute text-sm top-3 right-4","aria-label":"close",children:t.jsx(Vu,{})})," ",t.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:t.jsx(wo,{form_data:i,ignoreValidation:!0,config:s,uploadUrl:o})})]})};function Wu(){return t.jsx("div",{children:t.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("rect",{width:"24",height:"24",rx:"6",fill:"currentColor"}),t.jsx("path",{d:"M14 16L10 12L14 8",stroke:"white",strokeWidth:"1.39167",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function $u({title:e,goBackUrl:n,onSubmit:i,onPublish:o,previewLoading:s,saveLoading:a,publishLoading:l,onTitleChange:r,viewMode:d,setViewMode:u,onShowVersion:m}){const{formData:c,setShowPreview:b,showPreview:v,undo:h,redo:p,canUndo:g,canRedo:f}=x.useContext(Ae),[N,y]=x.useState(!1),[S,w]=x.useState(!1),[A,C]=x.useState(e||""),E=xe("config");function k(){localStorage.setItem("formData",JSON.stringify(c)),i==null||i(c)}function I(){localStorage.setItem("formData",JSON.stringify(c)),o==null||o(c)}function P(){w(!1),r&&A!==e&&r(A.trim())}return t.jsxs("div",{className:"px-[30px] py-3 flex justify-between items-center bg-[#F9F9FB] top_bar border-b h-full",children:[t.jsxs("span",{className:"flex items-center gap-x-2",children:[n&&t.jsx("button",{type:"button",onClick:()=>n(),style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:"flex items-center gap-x-3",children:t.jsx(Wu,{})})," ",S?t.jsx("input",{type:"text",value:A,onChange:T=>C(T.target.value),onBlur:P,autoFocus:!0,className:"w-48 px-2 py-1 text-sm font-semibold outline-gray-100 input form_title"}):t.jsx("h1",{title:"Click to edit",className:"text-base font-semibold cursor-pointer form_title",onClick:()=>w(!0),children:A||"Untitled"})]}),N&&t.jsx(zu,{isOpen:N,onClose:()=>y(!1),element:void 0}),t.jsxs("div",{className:"flex justify-end text-xs gap-x-3 items-center",children:[u&&t.jsxs("div",{className:"flex border border-gray-300 rounded-lg overflow-hidden h-[36px] text-sm font-medium shadow-sm mr-2",children:[t.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:[t.jsx(te,{icon:"mdi:view-dashboard-outline",iconClass:"text-base"})," ","Builder"]}),t.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:[t.jsx(te,{icon:"mdi:sitemap-outline",iconClass:"text-base"})," Flow"]})]}),t.jsx(Ke,{onClick:h,text:"",btnClass:`!px-2 bg-transparent undo ${g?"":"opacity-50"}`,icon:"material-symbols:undo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!g}),t.jsx(Ke,{onClick:p,text:"",btnClass:`!px-2 bg-transparent redo ${f?"":"opacity-50"}`,icon:"material-symbols:redo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!f}),m&&t.jsx(Ke,{onClick:m,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"}}),t.jsx(Ke,{onClick:()=>b(T=>!T),text:v?"Hide Preview":"Preview",btnClass:"px-2 bg-transparent font-medium text-sm form_preview",icon:v?"iconamoon:eye-off-duotone":"solar:eye-bold-duotone",iconClass:"text-base",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:s,isLoading:s}),t.jsx(Ke,{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:a,isLoading:a}),t.jsx(Ke,{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 ju({onSubmit:e,onChange:n,onLogAction:i,questionData:o,title:s,goBackUrl:a,loading:l,onPublish:r,previewLoading:d,saveLoading:u,publishLoading:m,onTitleChange:c,uploadUrl:b,onAddTemplate:v,templates:h,onShowVersion:p}){const[g,f]=x.useState("canvas");return t.jsxs(xs,{onChange:n,onLogAction:i,children:[t.jsx(Ee.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),t.jsx("div",{className:"w-full h-full bg-[#F8F9FC] flex flex-col",children:t.jsxs("div",{className:"flex flex-1 ",children:[g==="canvas"&&t.jsx("div",{children:t.jsx("div",{className:"w-[250px] h-screen border-r border-[#E4E7EC] bg-white ",children:t.jsx(Fu,{})})}),t.jsxs("div",{className:`flex-1 h-full max-h-full z-[1] ${g==="canvas"?"w-[calc(100%-250px)]":"w-full"}`,children:[t.jsx("div",{className:" h-[70px]",children:t.jsx($u,{title:s,goBackUrl:a,onSubmit:e,onPublish:r,previewLoading:d,saveLoading:u,publishLoading:m,onTitleChange:c,viewMode:g,setViewMode:f,onShowVersion:p})}),t.jsx("div",{className:"p-6 h-[calc(100vh-70px)]",children:l?t.jsx(go,{loadingClass:"!w-full !h-[800px]"}):t.jsx(Hu,{questionData:o,uploadUrl:b,onAddTemplate:v,templates:h,viewMode:g})})]})]})})]})}const Uu=({onSubmit:e,onChange:n,onLogAction:i,questionData:o,isReadOnly:s,config:a={buttonColor:"#333"},title:l,loading:r,goBackUrl:d,onPublish:u,previewLoading:m,saveLoading:c,publishLoading:b,onTitleChange:v,uploadUrl:h,onAddTemplate:p,templates:g,onShowVersion:f})=>(x.useEffect(()=>{a&&Ys("config",a)},[a]),t.jsx(ju,{onSubmit:e,onChange:n,onLogAction:i,onPublish:u,questionData:o,isReadOnly:s,title:l,goBackUrl:d,loading:r,previewLoading:m,saveLoading:c,publishLoading:b,onTitleChange:v,uploadUrl:h,onAddTemplate:p,templates:g,onShowVersion:f})),Ue={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}`},qu=(e,n=!1)=>({textField:ne.string().nullable(),longText:ne.string().nullable(),numberField:ne.number().nullable().transform(o=>isNaN(o)?null:o),amountField:ne.number().nullable().transform(o=>isNaN(o)?null:o),selectField:ne.string().nullable(),checkbox:ne.mixed().nullable(),radio:ne.mixed().nullable(),matrix:ne.mixed().nullable(),email:ne.string().nullable().test("email-format",Ue.email,o=>!o||o.trim()===""?!0:/^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/.test(o)),date:ne.date().nullable().transform((o,s)=>n&&s===""?null:o).typeError("Invalid date"),url:ne.string().nullable().test("url-format",Ue.url,o=>!o||o.trim()===""?!0:/^(https?:\/\/)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/.*)?$/.test(o))})[e]||ne.mixed().nullable(),Yu=(e,n,i)=>n?e.type==="boolean"?e.oneOf([!0],i||Ue.required):e.required(i||Ue.required):e,Ju=(e,{minLength:n,maxLength:i,minLengthMessage:o,maxLengthMessage:s})=>{let a=e;return n&&(a=a.min(n,o||Ue.minLength(n))),i&&(a=a.max(i,s||Ue.maxLength(i))),a},Zu=(e,{minAmount:n,maxAmount:i,minAmountMessage:o,maxAmountMessage:s})=>{let a=e;return n&&(a=a.min(parseFloat(String(n)),o||Ue.minAmount(n))),i&&(a=a.max(parseFloat(String(i)),s||Ue.maxAmount(i))),a},xo=(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],a=o.fieldValue,l=s;switch(o.operator){case"equals":return String(a).toLowerCase()===String(l).toLowerCase();case"not_equals":return String(a).toLowerCase()!==String(l).toLowerCase();case"greater":return Number(l)>Number(a);case"less":return Number(l)<Number(a);case"contains":return String(l).toLowerCase().includes(String(a).toLowerCase());case"not_contains":return!String(l).toLowerCase().includes(String(a).toLowerCase());default:return!0}}):!0};function Xu({formData:e,isReadOnly:n,answerData:i}){const o={};return e.forEach(({questionData:s})=>{s==null||s.forEach(a=>{if(!xo(a,i))return;const{id:l,type:r,isRequired:d,requiredMessage:u,isDisabled:m}=a;let c=qu(r,n);c=Yu(c,m||n?!1:d,u),r==="textField"||r==="longText"||r==="email"||r==="url"?c=Ju(c,a):(r==="numberField"||r==="amountField")&&(c=Zu(c,a)),o[l]=c})}),ne.object().shape(o)}const mn=({element:e,validationData:n})=>{const i=na[e.type],{answerData:o}=x.useContext(Ae),s=x.useMemo(()=>{var l;return(l=e==null?void 0:e.acceptedFiles)==null?void 0:l.map(r=>r.label).join(", ")},[e]),a=x.useMemo(()=>xo(e,o),[o,e]);return i?t.jsxs("div",{className:`${a?"":"hidden"} min-w-0 w-full`,children:[t.jsx("div",{className:"mb-1.5 min-w-0",children:e.inputLabel&&t.jsxs("label",{className:"block text-sm font-medium input_label",children:[e.inputLabel," ",s&&t.jsxs("span",{className:"text-gray-400 text-xs",children:["(",s==null?void 0:s.toLowerCase(),")"]})]})}),t.jsx(i,{element:e,state:"edit",validationData:{...n,isReadOnly:n.isReadOnly||e.isDisabled}}),e.description&&t.jsx("small",{className:"block text-gray-400 mt-0.5 text-xs",children:e.description})]}):null},bn=(e,n)=>e!=null&&e.allowEdit?{...n,isReadOnly:!1}:n;function Qu({form_data:e,options:n}){const i=(s,a)=>t.jsx("div",{className:"min-w-0",children:t.jsx(ri,{element:s,customClass:"p-0 min-h-[60px] border-none",children:a==null?void 0:a.map(l=>{var r,d,u;return t.jsxs(li,{col:(r=l.gridPosition)==null?void 0:r.col,customClass:"p-0",children:[t.jsx(mn,{element:l,validationData:bn(l,n)}),((u=(d=n==null?void 0:n.errors)==null?void 0:d[l.id])==null?void 0:u.message)&&t.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[l.id].message})]},l.id)})})},s.id),o=s=>{var a,l;return t.jsxs("div",{className:de("group relative grid gap-y-[6px] min-w-0",s.elementClass),children:[t.jsx(mn,{element:s,validationData:bn(s,n)}),((l=(a=n==null?void 0:n.errors)==null?void 0:a[s.id])==null?void 0:l.message)&&t.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[s.id].message})]},s.id)};return t.jsx("div",{className:"grid gap-y-10",children:e==null?void 0:e.map(s=>{var l,r;const a=new Map;return(l=s==null?void 0:s.questionData)==null||l.forEach(d=>{d.gridId&&(a.has(d.gridId)||a.set(d.gridId,[]),a.get(d.gridId).push(d))}),t.jsxs("div",{className:"pb-6 section_box min-w-0",children:[(s.title||s.description)&&t.jsxs("div",{className:"py-4 border-b border-gray-100 mb-7 section_box__title",children:[s.title&&t.jsx("h2",{className:"text-lg font-semibold mb-[4px]",children:s.title}),s.description&&t.jsx("p",{className:"text-sm",children:s.description})]}),t.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,a.get(d.id)||[]):o(d))})]},s.id)})})}function Ru({form_data:e,options:n,current:i}){var o,s;return t.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(a=>{var l,r,d,u;if(a.type==="grid"){const m=(r=(l=e[i])==null?void 0:l.questionData)==null?void 0:r.filter(c=>c.gridId===a.id);return t.jsx("div",{className:"min-w-0",children:t.jsx(ri,{element:a,customClass:"p-0 min-h-[60px] border-none",children:m==null?void 0:m.map(c=>{var b,v,h;return t.jsxs(li,{col:(b=c.gridPosition)==null?void 0:b.col,customClass:"p-0",children:[t.jsx(mn,{element:c,validationData:bn(c,n)}),t.jsx("div",{className:"mt-1 text-xs text-red-600",children:(h=(v=n==null?void 0:n.errors)==null?void 0:v[c.id])==null?void 0:h.message})]},c.id)})})},a.id)}return a.gridId?null:t.jsxs("div",{className:de("group relative grid gap-y-[6px] min-w-0",a.elementClass),children:[t.jsx(mn,{element:a,validationData:bn(a,n)}),t.jsx("div",{className:"mt-1 text-xs text-red-600",children:(u=(d=n==null?void 0:n.errors)==null?void 0:d[a.id])==null?void 0:u.message})]},a.id)})})}const So=xe("config");function ec({element:e,options:n,onNext:i,onPrev:o,isFirst:s,isLast:a,isReadOnly:l}){if(!e)return t.jsx("div",{className:"flex items-center justify-center min-h-[500px] text-gray-500",children:"No questions available."});const r=m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),i())},d=m=>{var c;return t.jsx("div",{className:"min-w-0 w-full",children:t.jsx(ri,{element:m,customClass:"p-0 min-h-[60px] border-none w-full",children:(c=m.gridChildren)==null?void 0:c.map(b=>{var v,h,p;return t.jsxs(li,{col:(v=b.gridPosition)==null?void 0:v.col,customClass:"p-0",children:[t.jsx(mn,{element:b,validationData:bn(b,n)}),((p=(h=n==null?void 0:n.errors)==null?void 0:h[b.id])==null?void 0:p.message)&&t.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[b.id].message})]},b.id)})})},m.id)},u=m=>{var c,b;return t.jsxs("div",{className:de("group relative grid gap-y-[6px] min-w-0 w-full",m.elementClass),children:[t.jsx(mn,{element:m,validationData:bn(m,n)}),((b=(c=n==null?void 0:n.errors)==null?void 0:c[m.id])==null?void 0:b.message)&&t.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[m.id].message})]},m.id)};return t.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:t.jsxs(re.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:[t.jsx("div",{className:"text-left w-full mb-8",children:e.type==="grid"?d(e):u(e)}),!l&&t.jsxs("div",{className:"flex items-center gap-4 mt-8",children:[t.jsx(Ke,{type:"button",text:a?n!=null&&n.isSubmitting?"Submitting...":"Submit":"OK",onClick:i,style:{background:(So==null?void 0:So.buttonColor)||"#333"},btnClass:`text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg ${a?"submit_btn":"continue_btn next_btn text-sm"}`,isDisabled:(n==null?void 0:n.apiActivityCount)>0||a&&(n==null?void 0:n.isSubmitting)}),!a&&t.jsx("span",{className:"text-xs text-gray-400 font-medium hidden sm:inline-block",children:"press Enter ↵"}),!s&&t.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:[t.jsx(te,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]})]},e.id)})}function nc(e){return e.reduce((n,i)=>(n[i.id]=i.value,n),{})}const ic=({form_data:e,answerData:n=[],ignoreValidation:i=!1,onSubmitData:o,onGetValues:s,isReadOnly:a=!1,renderType:l="multi",children:r,hideFooter:d=!1,uploadUrl:u})=>{var se,Q,j,V,G,H,$,F,q,R;const{setAnswerData:m,setUploadUrl:c,apiActivityCount:b}=x.useContext(Ae),[v,h]=x.useState(0),[p,g]=x.useState(0),f=x.useMemo(()=>e.filter(Z=>!Z.isHidden).map(Z=>{var ee;return Z.isDisabled||Z.disabled?{...Z,questionData:(ee=Z==null?void 0:Z.questionData)==null?void 0:ee.map(ae=>({...ae,isDisabled:!0}))}:Z}),[e]),N=(se=f==null?void 0:f.length)!=null?se:0,y=xe("config"),S=x.useCallback(async(Z,J,ee)=>{const ae=Xu({formData:f,isReadOnly:a,answerData:Z});return ro(ae)(Z,J,ee)},[f,a]),w=Ve.useForm({resolver:S,mode:"onSubmit",defaultValues:{}}),{register:A,setValue:C,control:E,handleSubmit:k,reset:I,getValues:P,watch:T,formState:{errors:O,isSubmitting:M},trigger:_,setError:B,clearErrors:K}=w,D=Ve.useWatch({control:E}),L=x.useMemo(()=>D,[JSON.stringify(D)]),z=x.useMemo(()=>{if(l!=="conversational")return[];const Z=[];return f.forEach(J=>{var ee;(ee=J==null?void 0:J.questionData)==null||ee.forEach(ae=>{var ue;if(xo(ae,L))if(ae.type==="grid"){const me=(ue=J==null?void 0:J.questionData)==null?void 0:ue.filter(ye=>ye.gridId===ae.id);Z.push({...ae,gridChildren:me})}else ae.gridId||Z.push(ae)})}),Z},[f,L,l]),U=x.useCallback(Z=>{s&&s(Z)},[s]);x.useEffect(()=>{c(u)},[c,u]),x.useEffect(()=>{if(!(f!=null&&f.length)||!s)return;const Z=f.flatMap(J=>{var ee;return(ee=J==null?void 0:J.questionData)==null?void 0:ee.map(ae=>({id:ae.id,value:L[ae.id]||"",sectionId:J.id,type:ae.type,metaData:{prefix:ae.prefix,dateFormat:ae.dateFormat}}))});U(Z),m(L)},[L,f,U,s,m]),x.useEffect(()=>{n!=null&&n.length&&I(nc(n))},[n,I]);const W=x.useCallback(Z=>{const J=f.flatMap(ee=>{var ae;return(ae=ee==null?void 0:ee.questionData)==null?void 0:ae.map(ue=>({id:ue.id,value:Z[ue.id]||"",sectionId:ee.id,type:ue.type,metaData:{prefix:ue.prefix,dateFormat:ue.dateFormat}}))});Object.keys(O).length>0||o==null||o(J)},[O,f,o]),Y=x.useCallback(async()=>{var Z,J;if(l==="conversational"){if(!i){const ee=z[p];if(!ee)return;const ae=ee.gridChildren?ee.gridChildren.map(me=>me.id):[ee.id];if(!await _(ae))return}p<z.length-1?g(ee=>ee+1):k(W)();return}if(!i){const ee=(J=(Z=f==null?void 0:f[v])==null?void 0:Z.questionData)==null?void 0:J.map(ue=>ue.id);if(!await _(ee))return}h(ee=>ee+1)},[v,p,z,f,i,_,l,k,W]),X=x.useCallback(()=>{if(l==="conversational"){g(Z=>Math.max(0,Z-1));return}h(Z=>Z-1)},[l]),ie=x.useMemo(()=>({register:A,setValue:C,watch:T,errors:O,trigger:_,isSubmitting:M,isReadOnly:a,getValues:P,setError:B,clearErrors:K,apiActivityCount:b}),[A,C,T,O,_,M,a,P,B,K,b]);return t.jsxs(Ve.FormProvider,{...w,children:[t.jsx(Ee.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),t.jsxs("form",{onSubmit:k(W),className:"container h-full mx-auto",children:[t.jsx("div",{className:"relative flex flex-col w-full min-w-0 py-4 gap-y-12",children:t.jsxs("div",{className:"multi_section__box min-w-0",children:[l==="multi"&&(((Q=f==null?void 0:f[v])==null?void 0:Q.title)||((j=f==null?void 0:f[v])==null?void 0:j.description))&&t.jsxs("div",{className:"py-4 mb-4 border-b border-gray-100 multi_section__title",children:[((V=f[v])==null?void 0:V.title)&&t.jsx("h2",{className:"text-lg font-semibold mb-[6px]",children:(G=f[v])==null?void 0:G.title}),((H=f[v])==null?void 0:H.description)&&t.jsx("p",{className:"text-sm",children:($=f[v])==null?void 0:$.description})]}),l==="multi"?t.jsx(Ru,{form_data:f,options:ie,current:v}):l==="conversational"?t.jsx(ec,{element:z[p],options:ie,onNext:Y,onPrev:X,isFirst:p===0,isLast:p===z.length-1,isReadOnly:a}):t.jsx(Qu,{form_data:f,options:ie})]},l==="conversational"?`conv-${p}`:(F=f==null?void 0:f[v])==null?void 0:F.id)}),!d&&l!=="conversational"&&t.jsx("footer",{className:"flex items-center justify-end gap-4 footer flex-wrap",children:l==="multi"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex gap-x-4 justify-between navigation_container w-full",children:[t.jsxs("div",{children:[" ",v>0&&t.jsxs("button",{type:"button",onClick:X,className:"text-gray-400 hover:text-gray-600 font-medium text-sm flex items-center gap-1 transition-colors back_btn",children:[t.jsx(te,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]}),v<N-1&&t.jsx(Ke,{type:"button",text:"Next",onClick:Y,style:{background:(y==null?void 0:y.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"})]}),(v===N-1||a)&&!i&&((q=typeof r=="function"?r({isUploading:b>0,isSubmitting:M,hasErrors:Object.keys(O).length>0}):r)!=null?q:t.jsx(Ke,{isDisabled:M||Object.keys(O).length>0||b>0,isLoading:M,type:"submit",text:"Submit",style:{background:(y==null?void 0:y.buttonColor)||"#333"},btnClass:"text-gray-700 border-[#98A2B3] submit_btn !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg submit_btn"}))]}):!i&&((R=typeof r=="function"?r({isUploading:b>0,isSubmitting:M,hasErrors:Object.keys(O).length>0}):r)!=null?R:t.jsx(Ke,{isDisabled:M||Object.keys(O).length>0||b>0,isLoading:M,type:"submit",text:"Submit",style:{background:(y==null?void 0:y.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"&&z.length>0&&t.jsx("div",{className:"fixed bottom-0 left-0 w-full h-1.5 bg-gray-200",children:t.jsx("div",{className:"h-full bg-blue-600 transition-all duration-500 ease-out",style:{width:`${(p+1)/z.length*100}%`,background:(y==null?void 0:y.buttonColor)||"#2563EB"}})})]})]})},oc=x.memo(ic);function wo({answerData:e,form_data:n,ignoreValidation:i,onSubmit:o,isReadOnly:s=!1,loading:a=!1,config:l={buttonColor:"#333"},renderType:r,children:d,hideFooter:u,onGetValues:m,uploadUrl:c}){x.useEffect(()=>{l&&Ys("config",l)},[l]);const b=x.useCallback(v=>{m&&m(v)},[m]);return a?t.jsx(go,{}):n?t.jsxs("div",{className:"w-full h-full min-w-0",children:[t.jsx("div",{id:"root-portal"}),t.jsx(xs,{children:t.jsx(oc,{form_data:n,answerData:e,ignoreValidation:i,onSubmitData:o,isReadOnly:s,renderType:r,hideFooter:u,onGetValues:b,uploadUrl:c,children:d})})]}):t.jsx("div",{children:t.jsx("p",{className:"p-6 text-sm text-gray-400",children:"Error: No form data available."})})}function Se(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=Se(e[i]))!==""&&(n+=(n&&" ")+o);else for(let i in e)e[i]&&(n+=(n&&" ")+i);return n}var sc={value:()=>{}};function di(){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 ui(i)}function ui(e){this._=e}function ac(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}})}ui.prototype=di.prototype={constructor:ui,on:function(e,n){var i=this._,o=ac(e+"",i),s,a=-1,l=o.length;if(arguments.length<2){for(;++a<l;)if((s=(e=o[a]).type)&&(s=tc(i[s],e.name)))return s;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++a<l;)if(s=(e=o[a]).type)i[s]=oa(i[s],e.name,n);else if(n==null)for(s in i)i[s]=oa(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 ui(e)},call:function(e,n){if((s=arguments.length-2)>0)for(var i=new Array(s),o=0,s,a;o<s;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],o=0,s=a.length;o<s;++o)a[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,a=o.length;s<a;++s)o[s].value.apply(n,i)}};function tc(e,n){for(var i=0,o=e.length,s;i<o;++i)if((s=e[i]).name===n)return s.value}function oa(e,n,i){for(var o=0,s=e.length;o<s;++o)if(e[o].name===n){e[o]=sc,e=e.slice(0,o).concat(e.slice(o+1));break}return i!=null&&e.push({name:n,value:i}),e}var No="http://www.w3.org/1999/xhtml";const sa={svg:"http://www.w3.org/2000/svg",xhtml:No,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ci(e){var n=e+="",i=n.indexOf(":");return i>=0&&(n=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),sa.hasOwnProperty(n)?{space:sa[n],local:e}:e}function lc(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===No&&n.documentElement.namespaceURI===No?n.createElement(e):n.createElementNS(i,e)}}function rc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function aa(e){var n=ci(e);return(n.local?rc:lc)(n)}function dc(){}function Ao(e){return e==null?dc:function(){return this.querySelector(e)}}function uc(e){typeof e!="function"&&(e=Ao(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var a=n[s],l=a.length,r=o[s]=new Array(l),d,u,m=0;m<l;++m)(d=a[m])&&(u=e.call(d,d.__data__,m,a))&&("__data__"in d&&(u.__data__=d.__data__),r[m]=u);return new Te(o,this._parents)}function cc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function mc(){return[]}function ta(e){return e==null?mc:function(){return this.querySelectorAll(e)}}function bc(e){return function(){return cc(e.apply(this,arguments))}}function vc(e){typeof e=="function"?e=bc(e):e=ta(e);for(var n=this._groups,i=n.length,o=[],s=[],a=0;a<i;++a)for(var l=n[a],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 Te(o,s)}function la(e){return function(){return this.matches(e)}}function ra(e){return function(n){return n.matches(e)}}var hc=Array.prototype.find;function fc(e){return function(){return hc.call(this.children,e)}}function pc(){return this.firstElementChild}function gc(e){return this.select(e==null?pc:fc(typeof e=="function"?e:ra(e)))}var yc=Array.prototype.filter;function xc(){return Array.from(this.children)}function Sc(e){return function(){return yc.call(this.children,e)}}function wc(e){return this.selectAll(e==null?xc:Sc(typeof e=="function"?e:ra(e)))}function Nc(e){typeof e!="function"&&(e=la(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var a=n[s],l=a.length,r=o[s]=[],d,u=0;u<l;++u)(d=a[u])&&e.call(d,d.__data__,u,a)&&r.push(d);return new Te(o,this._parents)}function da(e){return new Array(e.length)}function Ac(){return new Te(this._enter||this._groups.map(da),this._parents)}function mi(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}mi.prototype={constructor:mi,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 Cc(e){return function(){return e}}function kc(e,n,i,o,s,a){for(var l=0,r,d=n.length,u=a.length;l<u;++l)(r=n[l])?(r.__data__=a[l],o[l]=r):i[l]=new mi(e,a[l]);for(;l<d;++l)(r=n[l])&&(s[l]=r)}function Mc(e,n,i,o,s,a,l){var r,d,u=new Map,m=n.length,c=a.length,b=new Array(m),v;for(r=0;r<m;++r)(d=n[r])&&(b[r]=v=l.call(d,d.__data__,r,n)+"",u.has(v)?s[r]=d:u.set(v,d));for(r=0;r<c;++r)v=l.call(e,a[r],r,a)+"",(d=u.get(v))?(o[r]=d,d.__data__=a[r],u.delete(v)):i[r]=new mi(e,a[r]);for(r=0;r<m;++r)(d=n[r])&&u.get(b[r])===d&&(s[r]=d)}function Ec(e){return e.__data__}function Tc(e,n){if(!arguments.length)return Array.from(this,Ec);var i=n?Mc:kc,o=this._parents,s=this._groups;typeof e!="function"&&(e=Cc(e));for(var a=s.length,l=new Array(a),r=new Array(a),d=new Array(a),u=0;u<a;++u){var m=o[u],c=s[u],b=c.length,v=Pc(e.call(m,m&&m.__data__,u,o)),h=v.length,p=r[u]=new Array(h),g=l[u]=new Array(h),f=d[u]=new Array(b);i(m,c,p,g,f,v,n);for(var N=0,y=0,S,w;N<h;++N)if(S=p[N]){for(N>=y&&(y=N+1);!(w=g[y])&&++y<h;);S._next=w||null}}return l=new Te(l,o),l._enter=r,l._exit=d,l}function Pc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Lc(){return new Te(this._exit||this._groups.map(da),this._parents)}function Bc(e,n,i){var o=this.enter(),s=this,a=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?a.remove():i(a),o&&s?o.merge(s).order():s}function Ic(e){for(var n=e.selection?e.selection():e,i=this._groups,o=n._groups,s=i.length,a=o.length,l=Math.min(s,a),r=new Array(s),d=0;d<l;++d)for(var u=i[d],m=o[d],c=u.length,b=r[d]=new Array(c),v,h=0;h<c;++h)(v=u[h]||m[h])&&(b[h]=v);for(;d<s;++d)r[d]=i[d];return new Te(r,this._parents)}function Dc(){for(var e=this._groups,n=-1,i=e.length;++n<i;)for(var o=e[n],s=o.length-1,a=o[s],l;--s>=0;)(l=o[s])&&(a&&l.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(l,a),a=l);return this}function _c(e){e||(e=Oc);function n(c,b){return c&&b?e(c.__data__,b.__data__):!c-!b}for(var i=this._groups,o=i.length,s=new Array(o),a=0;a<o;++a){for(var l=i[a],r=l.length,d=s[a]=new Array(r),u,m=0;m<r;++m)(u=l[m])&&(d[m]=u);d.sort(n)}return new Te(s,this._parents).order()}function Oc(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function Kc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Hc(){return Array.from(this)}function Gc(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],s=0,a=o.length;s<a;++s){var l=o[s];if(l)return l}return null}function Fc(){let e=0;for(const n of this)++e;return e}function Vc(){return!this.node()}function zc(e){for(var n=this._groups,i=0,o=n.length;i<o;++i)for(var s=n[i],a=0,l=s.length,r;a<l;++a)(r=s[a])&&e.call(r,r.__data__,a,s);return this}function Wc(e){return function(){this.removeAttribute(e)}}function $c(e){return function(){this.removeAttributeNS(e.space,e.local)}}function jc(e,n){return function(){this.setAttribute(e,n)}}function Uc(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function qc(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function Yc(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 Jc(e,n){var i=ci(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?$c:Wc:typeof n=="function"?i.local?Yc:qc:i.local?Uc:jc)(i,n))}function ua(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Zc(e){return function(){this.style.removeProperty(e)}}function Xc(e,n,i){return function(){this.style.setProperty(e,n,i)}}function Qc(e,n,i){return function(){var o=n.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,i)}}function Rc(e,n,i){return arguments.length>1?this.each((n==null?Zc:typeof n=="function"?Qc:Xc)(e,n,i==null?"":i)):vn(this.node(),e)}function vn(e,n){return e.style.getPropertyValue(n)||ua(e).getComputedStyle(e,null).getPropertyValue(n)}function em(e){return function(){delete this[e]}}function nm(e,n){return function(){this[e]=n}}function im(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function om(e,n){return arguments.length>1?this.each((n==null?em:typeof n=="function"?im:nm)(e,n)):this.node()[e]}function ca(e){return e.trim().split(/^|\s+/)}function Co(e){return e.classList||new ma(e)}function ma(e){this._node=e,this._names=ca(e.getAttribute("class")||"")}ma.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 ba(e,n){for(var i=Co(e),o=-1,s=n.length;++o<s;)i.add(n[o])}function va(e,n){for(var i=Co(e),o=-1,s=n.length;++o<s;)i.remove(n[o])}function sm(e){return function(){ba(this,e)}}function am(e){return function(){va(this,e)}}function tm(e,n){return function(){(n.apply(this,arguments)?ba:va)(this,e)}}function lm(e,n){var i=ca(e+"");if(arguments.length<2){for(var o=Co(this.node()),s=-1,a=i.length;++s<a;)if(!o.contains(i[s]))return!1;return!0}return this.each((typeof n=="function"?tm:n?sm:am)(i,n))}function rm(){this.textContent=""}function dm(e){return function(){this.textContent=e}}function um(e){return function(){var n=e.apply(this,arguments);this.textContent=n==null?"":n}}function cm(e){return arguments.length?this.each(e==null?rm:(typeof e=="function"?um:dm)(e)):this.node().textContent}function mm(){this.innerHTML=""}function bm(e){return function(){this.innerHTML=e}}function vm(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n==null?"":n}}function hm(e){return arguments.length?this.each(e==null?mm:(typeof e=="function"?vm:bm)(e)):this.node().innerHTML}function fm(){this.nextSibling&&this.parentNode.appendChild(this)}function pm(){return this.each(fm)}function gm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ym(){return this.each(gm)}function xm(e){var n=typeof e=="function"?e:aa(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function Sm(){return null}function wm(e,n){var i=typeof e=="function"?e:aa(e),o=n==null?Sm:typeof n=="function"?n:Ao(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),o.apply(this,arguments)||null)})}function Nm(){var e=this.parentNode;e&&e.removeChild(this)}function Am(){return this.each(Nm)}function Cm(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function km(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function Mm(e){return this.select(e?km:Cm)}function Em(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Tm(e){return function(n){e.call(this,n,this.__data__)}}function Pm(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 Lm(e){return function(){var n=this.__on;if(n){for(var i=0,o=-1,s=n.length,a;i<s;++i)a=n[i],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):n[++o]=a;++o?n.length=o:delete this.__on}}}function Bm(e,n,i){return function(){var o=this.__on,s,a=Tm(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=a,s.options=i),s.value=n;return}}this.addEventListener(e.type,a,i),s={type:e.type,name:e.name,value:n,listener:a,options:i},o?o.push(s):this.__on=[s]}}function Im(e,n,i){var o=Pm(e+""),s,a=o.length,l;if(arguments.length<2){var r=this.node().__on;if(r){for(var d=0,u=r.length,m;d<u;++d)for(s=0,m=r[d];s<a;++s)if((l=o[s]).type===m.type&&l.name===m.name)return m.value}return}for(r=n?Bm:Lm,s=0;s<a;++s)this.each(r(o[s],n,i));return this}function ha(e,n,i){var o=ua(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 Dm(e,n){return function(){return ha(this,e,n)}}function _m(e,n){return function(){return ha(this,e,n.apply(this,arguments))}}function Om(e,n){return this.each((typeof n=="function"?_m:Dm)(e,n))}function*Km(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],s=0,a=o.length,l;s<a;++s)(l=o[s])&&(yield l)}var fa=[null];function Te(e,n){this._groups=e,this._parents=n}function In(){return new Te([[document.documentElement]],fa)}function Hm(){return this}Te.prototype=In.prototype={constructor:Te,select:uc,selectAll:vc,selectChild:gc,selectChildren:wc,filter:Nc,data:Tc,enter:Ac,exit:Lc,join:Bc,merge:Ic,selection:Hm,order:Dc,sort:_c,call:Kc,nodes:Hc,node:Gc,size:Fc,empty:Vc,each:zc,attr:Jc,style:Rc,property:om,classed:lm,text:cm,html:hm,raise:pm,lower:ym,append:xm,insert:wm,remove:Am,clone:Mm,datum:Em,on:Im,dispatch:Om,[Symbol.iterator]:Km};function Pe(e){return typeof e=="string"?new Te([[document.querySelector(e)]],[document.documentElement]):new Te([[e]],fa)}function Gm(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Be(e,n){if(e=Gm(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 Fm={passive:!1},Dn={capture:!0,passive:!1};function ko(e){e.stopImmediatePropagation()}function hn(e){e.preventDefault(),e.stopImmediatePropagation()}function pa(e){var n=e.document.documentElement,i=Pe(e).on("dragstart.drag",hn,Dn);"onselectstart"in n?i.on("selectstart.drag",hn,Dn):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function ga(e,n){var i=e.document.documentElement,o=Pe(e).on("dragstart.drag",null);n&&(o.on("click.drag",hn,Dn),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 bi=e=>()=>e;function Mo(e,{sourceEvent:n,subject:i,target:o,identifier:s,active:a,x:l,y:r,dx:d,dy:u,dispatch:m}){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:a,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:m}})}Mo.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Vm(e){return!e.ctrlKey&&!e.button}function zm(){return this.parentNode}function Wm(e,n){return n==null?{x:e.x,y:e.y}:n}function $m(){return navigator.maxTouchPoints||"ontouchstart"in this}function ya(){var e=Vm,n=zm,i=Wm,o=$m,s={},a=di("start","drag","end"),l=0,r,d,u,m,c=0;function b(S){S.on("mousedown.drag",v).filter(o).on("touchstart.drag",g).on("touchmove.drag",f,Fm).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(S,w){if(!(m||!e.call(this,S,w))){var A=y(this,n.call(this,S,w),S,w,"mouse");A&&(Pe(S.view).on("mousemove.drag",h,Dn).on("mouseup.drag",p,Dn),pa(S.view),ko(S),u=!1,r=S.clientX,d=S.clientY,A("start",S))}}function h(S){if(hn(S),!u){var w=S.clientX-r,A=S.clientY-d;u=w*w+A*A>c}s.mouse("drag",S)}function p(S){Pe(S.view).on("mousemove.drag mouseup.drag",null),ga(S.view,u),hn(S),s.mouse("end",S)}function g(S,w){if(e.call(this,S,w)){var A=S.changedTouches,C=n.call(this,S,w),E=A.length,k,I;for(k=0;k<E;++k)(I=y(this,C,S,w,A[k].identifier,A[k]))&&(ko(S),I("start",S,A[k]))}}function f(S){var w=S.changedTouches,A=w.length,C,E;for(C=0;C<A;++C)(E=s[w[C].identifier])&&(hn(S),E("drag",S,w[C]))}function N(S){var w=S.changedTouches,A=w.length,C,E;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),C=0;C<A;++C)(E=s[w[C].identifier])&&(ko(S),E("end",S,w[C]))}function y(S,w,A,C,E,k){var I=a.copy(),P=Be(k||A,w),T,O,M;if((M=i.call(S,new Mo("beforestart",{sourceEvent:A,target:b,identifier:E,active:l,x:P[0],y:P[1],dx:0,dy:0,dispatch:I}),C))!=null)return T=M.x-P[0]||0,O=M.y-P[1]||0,function _(B,K,D){var L=P,z;switch(B){case"start":s[E]=_,z=l++;break;case"end":delete s[E],--l;case"drag":P=Be(D||K,w),z=l;break}I.call(B,S,new Mo(B,{sourceEvent:K,subject:M,target:b,identifier:E,active:z,x:P[0]+T,y:P[1]+O,dx:P[0]-L[0],dy:P[1]-L[1],dispatch:I}),C)}}return b.filter=function(S){return arguments.length?(e=typeof S=="function"?S:bi(!!S),b):e},b.container=function(S){return arguments.length?(n=typeof S=="function"?S:bi(S),b):n},b.subject=function(S){return arguments.length?(i=typeof S=="function"?S:bi(S),b):i},b.touchable=function(S){return arguments.length?(o=typeof S=="function"?S:bi(!!S),b):o},b.on=function(){var S=a.on.apply(a,arguments);return S===a?b:S},b.clickDistance=function(S){return arguments.length?(c=(S=+S)*S,b):Math.sqrt(c)},b}function Eo(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function xa(e,n){var i=Object.create(e.prototype);for(var o in n)i[o]=n[o];return i}function _n(){}var On=.7,vi=1/On,fn="\\s*([+-]?\\d+)\\s*",Kn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",He="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",jm=/^#([0-9a-f]{3,8})$/,Um=new RegExp(`^rgb\\(${fn},${fn},${fn}\\)$`),qm=new RegExp(`^rgb\\(${He},${He},${He}\\)$`),Ym=new RegExp(`^rgba\\(${fn},${fn},${fn},${Kn}\\)$`),Jm=new RegExp(`^rgba\\(${He},${He},${He},${Kn}\\)$`),Zm=new RegExp(`^hsl\\(${Kn},${He},${He}\\)$`),Xm=new RegExp(`^hsla\\(${Kn},${He},${He},${Kn}\\)$`),Sa={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};Eo(_n,Qe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:wa,formatHex:wa,formatHex8:Qm,formatHsl:Rm,formatRgb:Na,toString:Na});function wa(){return this.rgb().formatHex()}function Qm(){return this.rgb().formatHex8()}function Rm(){return Ea(this).formatHsl()}function Na(){return this.rgb().formatRgb()}function Qe(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=jm.exec(e))?(i=n[1].length,n=parseInt(n[1],16),i===6?Aa(n):i===3?new ke(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):i===8?hi(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?hi(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=Um.exec(e))?new ke(n[1],n[2],n[3],1):(n=qm.exec(e))?new ke(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=Ym.exec(e))?hi(n[1],n[2],n[3],n[4]):(n=Jm.exec(e))?hi(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=Zm.exec(e))?Ma(n[1],n[2]/100,n[3]/100,1):(n=Xm.exec(e))?Ma(n[1],n[2]/100,n[3]/100,n[4]):Sa.hasOwnProperty(e)?Aa(Sa[e]):e==="transparent"?new ke(NaN,NaN,NaN,0):null}function Aa(e){return new ke(e>>16&255,e>>8&255,e&255,1)}function hi(e,n,i,o){return o<=0&&(e=n=i=NaN),new ke(e,n,i,o)}function eb(e){return e instanceof _n||(e=Qe(e)),e?(e=e.rgb(),new ke(e.r,e.g,e.b,e.opacity)):new ke}function To(e,n,i,o){return arguments.length===1?eb(e):new ke(e,n,i,o==null?1:o)}function ke(e,n,i,o){this.r=+e,this.g=+n,this.b=+i,this.opacity=+o}Eo(ke,To,xa(_n,{brighter(e){return e=e==null?vi:Math.pow(vi,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?On:Math.pow(On,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ke(Re(this.r),Re(this.g),Re(this.b),fi(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:Ca,formatHex:Ca,formatHex8:nb,formatRgb:ka,toString:ka}));function Ca(){return`#${en(this.r)}${en(this.g)}${en(this.b)}`}function nb(){return`#${en(this.r)}${en(this.g)}${en(this.b)}${en((isNaN(this.opacity)?1:this.opacity)*255)}`}function ka(){const e=fi(this.opacity);return`${e===1?"rgb(":"rgba("}${Re(this.r)}, ${Re(this.g)}, ${Re(this.b)}${e===1?")":`, ${e})`}`}function fi(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Re(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function en(e){return e=Re(e),(e<16?"0":"")+e.toString(16)}function Ma(e,n,i,o){return o<=0?e=n=i=NaN:i<=0||i>=1?e=n=NaN:n<=0&&(e=NaN),new Ie(e,n,i,o)}function Ea(e){if(e instanceof Ie)return new Ie(e.h,e.s,e.l,e.opacity);if(e instanceof _n||(e=Qe(e)),!e)return new Ie;if(e instanceof Ie)return e;e=e.rgb();var n=e.r/255,i=e.g/255,o=e.b/255,s=Math.min(n,i,o),a=Math.max(n,i,o),l=NaN,r=a-s,d=(a+s)/2;return r?(n===a?l=(i-o)/r+(i<o)*6:i===a?l=(o-n)/r+2:l=(n-i)/r+4,r/=d<.5?a+s:2-a-s,l*=60):r=d>0&&d<1?0:l,new Ie(l,r,d,e.opacity)}function ib(e,n,i,o){return arguments.length===1?Ea(e):new Ie(e,n,i,o==null?1:o)}function Ie(e,n,i,o){this.h=+e,this.s=+n,this.l=+i,this.opacity=+o}Eo(Ie,ib,xa(_n,{brighter(e){return e=e==null?vi:Math.pow(vi,e),new Ie(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?On:Math.pow(On,e),new Ie(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 ke(Po(e>=240?e-240:e+120,s,o),Po(e,s,o),Po(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new Ie(Ta(this.h),pi(this.s),pi(this.l),fi(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=fi(this.opacity);return`${e===1?"hsl(":"hsla("}${Ta(this.h)}, ${pi(this.s)*100}%, ${pi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ta(e){return e=(e||0)%360,e<0?e+360:e}function pi(e){return Math.max(0,Math.min(1,e||0))}function Po(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 Lo=e=>()=>e;function ob(e,n){return function(i){return e+i*n}}function sb(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 ab(e){return(e=+e)==1?Pa:function(n,i){return i-n?sb(n,i,e):Lo(isNaN(n)?i:n)}}function Pa(e,n){var i=n-e;return i?ob(e,i):Lo(isNaN(e)?n:e)}const gi=function e(n){var i=ab(n);function o(s,a){var l=i((s=To(s)).r,(a=To(a)).r),r=i(s.g,a.g),d=i(s.b,a.b),u=Pa(s.opacity,a.opacity);return function(m){return s.r=l(m),s.g=r(m),s.b=d(m),s.opacity=u(m),s+""}}return o.gamma=e,o}(1);function tb(e,n){n||(n=[]);var i=e?Math.min(n.length,e.length):0,o=n.slice(),s;return function(a){for(s=0;s<i;++s)o[s]=e[s]*(1-a)+n[s]*a;return o}}function lb(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rb(e,n){var i=n?n.length:0,o=e?Math.min(i,e.length):0,s=new Array(o),a=new Array(i),l;for(l=0;l<o;++l)s[l]=Hn(e[l],n[l]);for(;l<i;++l)a[l]=n[l];return function(r){for(l=0;l<o;++l)a[l]=s[l](r);return a}}function db(e,n){var i=new Date;return e=+e,n=+n,function(o){return i.setTime(e*(1-o)+n*o),i}}function Ge(e,n){return e=+e,n=+n,function(i){return e*(1-i)+n*i}}function ub(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]=Hn(e[s],n[s]):o[s]=n[s];return function(a){for(s in i)o[s]=i[s](a);return o}}var Bo=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Io=new RegExp(Bo.source,"g");function cb(e){return function(){return e}}function mb(e){return function(n){return e(n)+""}}function La(e,n){var i=Bo.lastIndex=Io.lastIndex=0,o,s,a,l=-1,r=[],d=[];for(e=e+"",n=n+"";(o=Bo.exec(e))&&(s=Io.exec(n));)(a=s.index)>i&&(a=n.slice(i,a),r[l]?r[l]+=a:r[++l]=a),(o=o[0])===(s=s[0])?r[l]?r[l]+=s:r[++l]=s:(r[++l]=null,d.push({i:l,x:Ge(o,s)})),i=Io.lastIndex;return i<n.length&&(a=n.slice(i),r[l]?r[l]+=a:r[++l]=a),r.length<2?d[0]?mb(d[0].x):cb(n):(n=d.length,function(u){for(var m=0,c;m<n;++m)r[(c=d[m]).i]=c.x(u);return r.join("")})}function Hn(e,n){var i=typeof n,o;return n==null||i==="boolean"?Lo(n):(i==="number"?Ge:i==="string"?(o=Qe(n))?(n=o,gi):La:n instanceof Qe?gi:n instanceof Date?db:lb(n)?tb:Array.isArray(n)?rb:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?ub:Ge)(e,n)}var Ba=180/Math.PI,Do={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ia(e,n,i,o,s,a){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:a,rotate:Math.atan2(n,e)*Ba,skewX:Math.atan(d)*Ba,scaleX:l,scaleY:r}}var yi;function bb(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Do:Ia(n.a,n.b,n.c,n.d,n.e,n.f)}function vb(e){return e==null||(yi||(yi=document.createElementNS("http://www.w3.org/2000/svg","g")),yi.setAttribute("transform",e),!(e=yi.transform.baseVal.consolidate()))?Do:(e=e.matrix,Ia(e.a,e.b,e.c,e.d,e.e,e.f))}function Da(e,n,i,o){function s(u){return u.length?u.pop()+" ":""}function a(u,m,c,b,v,h){if(u!==c||m!==b){var p=v.push("translate(",null,n,null,i);h.push({i:p-4,x:Ge(u,c)},{i:p-2,x:Ge(m,b)})}else(c||b)&&v.push("translate("+c+n+b+i)}function l(u,m,c,b){u!==m?(u-m>180?m+=360:m-u>180&&(u+=360),b.push({i:c.push(s(c)+"rotate(",null,o)-2,x:Ge(u,m)})):m&&c.push(s(c)+"rotate("+m+o)}function r(u,m,c,b){u!==m?b.push({i:c.push(s(c)+"skewX(",null,o)-2,x:Ge(u,m)}):m&&c.push(s(c)+"skewX("+m+o)}function d(u,m,c,b,v,h){if(u!==c||m!==b){var p=v.push(s(v)+"scale(",null,",",null,")");h.push({i:p-4,x:Ge(u,c)},{i:p-2,x:Ge(m,b)})}else(c!==1||b!==1)&&v.push(s(v)+"scale("+c+","+b+")")}return function(u,m){var c=[],b=[];return u=e(u),m=e(m),a(u.translateX,u.translateY,m.translateX,m.translateY,c,b),l(u.rotate,m.rotate,c,b),r(u.skewX,m.skewX,c,b),d(u.scaleX,u.scaleY,m.scaleX,m.scaleY,c,b),u=m=null,function(v){for(var h=-1,p=b.length,g;++h<p;)c[(g=b[h]).i]=g.x(v);return c.join("")}}}var hb=Da(bb,"px, ","px)","deg)"),fb=Da(vb,", ",")",")"),pb=1e-12;function _a(e){return((e=Math.exp(e))+1/e)/2}function gb(e){return((e=Math.exp(e))-1/e)/2}function yb(e){return((e=Math.exp(2*e))-1)/(e+1)}const xi=function e(n,i,o){function s(a,l){var r=a[0],d=a[1],u=a[2],m=l[0],c=l[1],b=l[2],v=m-r,h=c-d,p=v*v+h*h,g,f;if(p<pb)f=Math.log(b/u)/n,g=function(C){return[r+C*v,d+C*h,u*Math.exp(n*C*f)]};else{var N=Math.sqrt(p),y=(b*b-u*u+o*p)/(2*u*i*N),S=(b*b-u*u-o*p)/(2*b*i*N),w=Math.log(Math.sqrt(y*y+1)-y),A=Math.log(Math.sqrt(S*S+1)-S);f=(A-w)/n,g=function(C){var E=C*f,k=_a(w),I=u/(i*N)*(k*yb(n*E+w)-gb(w));return[r+I*v,d+I*h,u*k/_a(n*E+w)]}}return g.duration=f*1e3*n/Math.SQRT2,g}return s.rho=function(a){var l=Math.max(.001,+a),r=l*l,d=r*r;return e(l,r,d)},s}(Math.SQRT2,2,4);var pn=0,Gn=0,Fn=0,Oa=1e3,Si,Vn,wi=0,nn=0,Ni=0,zn=typeof performance=="object"&&performance.now?performance:Date,Ka=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function _o(){return nn||(Ka(xb),nn=zn.now()+Ni)}function xb(){nn=0}function Ai(){this._call=this._time=this._next=null}Ai.prototype=Ha.prototype={constructor:Ai,restart:function(e,n,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?_o():+i)+(n==null?0:+n),!this._next&&Vn!==this&&(Vn?Vn._next=this:Si=this,Vn=this),this._call=e,this._time=i,Oo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Oo())}};function Ha(e,n,i){var o=new Ai;return o.restart(e,n,i),o}function Sb(){_o(),++pn;for(var e=Si,n;e;)(n=nn-e._time)>=0&&e._call.call(void 0,n),e=e._next;--pn}function Ga(){nn=(wi=zn.now())+Ni,pn=Gn=0;try{Sb()}finally{pn=0,Nb(),nn=0}}function wb(){var e=zn.now(),n=e-wi;n>Oa&&(Ni-=n,wi=e)}function Nb(){for(var e,n=Si,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:Si=i);Vn=e,Oo(o)}function Oo(e){if(!pn){Gn&&(Gn=clearTimeout(Gn));var n=e-nn;n>24?(e<1/0&&(Gn=setTimeout(Ga,e-zn.now()-Ni)),Fn&&(Fn=clearInterval(Fn))):(Fn||(wi=zn.now(),Fn=setInterval(wb,Oa)),pn=1,Ka(Ga))}}function Fa(e,n,i){var o=new Ai;return n=n==null?0:+n,o.restart(s=>{o.stop(),e(s+n)},n,i),o}var Ab=di("start","end","cancel","interrupt"),Cb=[],Va=0,za=1,Ko=2,Ci=3,Wa=4,Ho=5,ki=6;function Mi(e,n,i,o,s,a){var l=e.__transition;if(!l)e.__transition={};else if(i in l)return;kb(e,i,{name:n,index:o,group:s,on:Ab,tween:Cb,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:Va})}function Go(e,n){var i=De(e,n);if(i.state>Va)throw new Error("too late; already scheduled");return i}function Fe(e,n){var i=De(e,n);if(i.state>Ci)throw new Error("too late; already running");return i}function De(e,n){var i=e.__transition;if(!i||!(i=i[n]))throw new Error("transition not found");return i}function kb(e,n,i){var o=e.__transition,s;o[n]=i,i.timer=Ha(a,0,i.time);function a(u){i.state=za,i.timer.restart(l,i.delay,i.time),i.delay<=u&&l(u-i.delay)}function l(u){var m,c,b,v;if(i.state!==za)return d();for(m in o)if(v=o[m],v.name===i.name){if(v.state===Ci)return Fa(l);v.state===Wa?(v.state=ki,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete o[m]):+m<n&&(v.state=ki,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete o[m])}if(Fa(function(){i.state===Ci&&(i.state=Wa,i.timer.restart(r,i.delay,i.time),r(u))}),i.state=Ko,i.on.call("start",e,e.__data__,i.index,i.group),i.state===Ko){for(i.state=Ci,s=new Array(b=i.tween.length),m=0,c=-1;m<b;++m)(v=i.tween[m].value.call(e,e.__data__,i.index,i.group))&&(s[++c]=v);s.length=c+1}}function r(u){for(var m=u<i.duration?i.ease.call(null,u/i.duration):(i.timer.restart(d),i.state=Ho,1),c=-1,b=s.length;++c<b;)s[c].call(e,m);i.state===Ho&&(i.on.call("end",e,e.__data__,i.index,i.group),d())}function d(){i.state=ki,i.timer.stop(),delete o[n];for(var u in o)return;delete e.__transition}}function Ei(e,n){var i=e.__transition,o,s,a=!0,l;if(i){n=n==null?null:n+"";for(l in i){if((o=i[l]).name!==n){a=!1;continue}s=o.state>Ko&&o.state<Ho,o.state=ki,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete i[l]}a&&delete e.__transition}}function Mb(e){return this.each(function(){Ei(this,e)})}function Eb(e,n){var i,o;return function(){var s=Fe(this,e),a=s.tween;if(a!==i){o=i=a;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 Tb(e,n,i){var o,s;if(typeof i!="function")throw new Error;return function(){var a=Fe(this,e),l=a.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)}a.tween=s}}function Pb(e,n){var i=this._id;if(e+="",arguments.length<2){for(var o=De(this.node(),i).tween,s=0,a=o.length,l;s<a;++s)if((l=o[s]).name===e)return l.value;return null}return this.each((n==null?Eb:Tb)(i,e,n))}function Fo(e,n,i){var o=e._id;return e.each(function(){var s=Fe(this,o);(s.value||(s.value={}))[n]=i.apply(this,arguments)}),function(s){return De(s,o).value[n]}}function $a(e,n){var i;return(typeof n=="number"?Ge:n instanceof Qe?gi:(i=Qe(n))?(n=i,gi):La)(e,n)}function Lb(e){return function(){this.removeAttribute(e)}}function Bb(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ib(e,n,i){var o,s=i+"",a;return function(){var l=this.getAttribute(e);return l===s?null:l===o?a:a=n(o=l,i)}}function Db(e,n,i){var o,s=i+"",a;return function(){var l=this.getAttributeNS(e.space,e.local);return l===s?null:l===o?a:a=n(o=l,i)}}function _b(e,n,i){var o,s,a;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?a:(s=d,a=n(o=l,r)))}}function Ob(e,n,i){var o,s,a;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?a:(s=d,a=n(o=l,r)))}}function Kb(e,n){var i=ci(e),o=i==="transform"?fb:$a;return this.attrTween(e,typeof n=="function"?(i.local?Ob:_b)(i,o,Fo(this,"attr."+e,n)):n==null?(i.local?Bb:Lb)(i):(i.local?Db:Ib)(i,o,n))}function Hb(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function Gb(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function Fb(e,n){var i,o;function s(){var a=n.apply(this,arguments);return a!==o&&(i=(o=a)&&Gb(e,a)),i}return s._value=n,s}function Vb(e,n){var i,o;function s(){var a=n.apply(this,arguments);return a!==o&&(i=(o=a)&&Hb(e,a)),i}return s._value=n,s}function zb(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=ci(e);return this.tween(i,(o.local?Fb:Vb)(o,n))}function Wb(e,n){return function(){Go(this,e).delay=+n.apply(this,arguments)}}function $b(e,n){return n=+n,function(){Go(this,e).delay=n}}function jb(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Wb:$b)(n,e)):De(this.node(),n).delay}function Ub(e,n){return function(){Fe(this,e).duration=+n.apply(this,arguments)}}function qb(e,n){return n=+n,function(){Fe(this,e).duration=n}}function Yb(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Ub:qb)(n,e)):De(this.node(),n).duration}function Jb(e,n){if(typeof n!="function")throw new Error;return function(){Fe(this,e).ease=n}}function Zb(e){var n=this._id;return arguments.length?this.each(Jb(n,e)):De(this.node(),n).ease}function Xb(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;Fe(this,e).ease=i}}function Qb(e){if(typeof e!="function")throw new Error;return this.each(Xb(this._id,e))}function Rb(e){typeof e!="function"&&(e=la(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var a=n[s],l=a.length,r=o[s]=[],d,u=0;u<l;++u)(d=a[u])&&e.call(d,d.__data__,u,a)&&r.push(d);return new ze(o,this._parents,this._name,this._id)}function ev(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,i=e._groups,o=n.length,s=i.length,a=Math.min(o,s),l=new Array(o),r=0;r<a;++r)for(var d=n[r],u=i[r],m=d.length,c=l[r]=new Array(m),b,v=0;v<m;++v)(b=d[v]||u[v])&&(c[v]=b);for(;r<o;++r)l[r]=n[r];return new ze(l,this._parents,this._name,this._id)}function nv(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 iv(e,n,i){var o,s,a=nv(n)?Go:Fe;return function(){var l=a(this,e),r=l.on;r!==o&&(s=(o=r).copy()).on(n,i),l.on=s}}function ov(e,n){var i=this._id;return arguments.length<2?De(this.node(),i).on.on(e):this.each(iv(i,e,n))}function sv(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function av(){return this.on("end.remove",sv(this._id))}function tv(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Ao(e));for(var o=this._groups,s=o.length,a=new Array(s),l=0;l<s;++l)for(var r=o[l],d=r.length,u=a[l]=new Array(d),m,c,b=0;b<d;++b)(m=r[b])&&(c=e.call(m,m.__data__,b,r))&&("__data__"in m&&(c.__data__=m.__data__),u[b]=c,Mi(u[b],n,i,b,u,De(m,i)));return new ze(a,this._parents,n,i)}function lv(e){var n=this._name,i=this._id;typeof e!="function"&&(e=ta(e));for(var o=this._groups,s=o.length,a=[],l=[],r=0;r<s;++r)for(var d=o[r],u=d.length,m,c=0;c<u;++c)if(m=d[c]){for(var b=e.call(m,m.__data__,c,d),v,h=De(m,i),p=0,g=b.length;p<g;++p)(v=b[p])&&Mi(v,n,i,p,b,h);a.push(b),l.push(m)}return new ze(a,l,n,i)}var rv=In.prototype.constructor;function dv(){return new rv(this._groups,this._parents)}function uv(e,n){var i,o,s;return function(){var a=vn(this,e),l=(this.style.removeProperty(e),vn(this,e));return a===l?null:a===i&&l===o?s:s=n(i=a,o=l)}}function ja(e){return function(){this.style.removeProperty(e)}}function cv(e,n,i){var o,s=i+"",a;return function(){var l=vn(this,e);return l===s?null:l===o?a:a=n(o=l,i)}}function mv(e,n,i){var o,s,a;return function(){var l=vn(this,e),r=i(this),d=r+"";return r==null&&(d=r=(this.style.removeProperty(e),vn(this,e))),l===d?null:l===o&&d===s?a:(s=d,a=n(o=l,r))}}function bv(e,n){var i,o,s,a="style."+n,l="end."+a,r;return function(){var d=Fe(this,e),u=d.on,m=d.value[a]==null?r||(r=ja(n)):void 0;(u!==i||s!==m)&&(o=(i=u).copy()).on(l,s=m),d.on=o}}function vv(e,n,i){var o=(e+="")=="transform"?hb:$a;return n==null?this.styleTween(e,uv(e,o)).on("end.style."+e,ja(e)):typeof n=="function"?this.styleTween(e,mv(e,o,Fo(this,"style."+e,n))).each(bv(this._id,e)):this.styleTween(e,cv(e,o,n),i).on("end.style."+e,null)}function hv(e,n,i){return function(o){this.style.setProperty(e,n.call(this,o),i)}}function fv(e,n,i){var o,s;function a(){var l=n.apply(this,arguments);return l!==s&&(o=(s=l)&&hv(e,l,i)),o}return a._value=n,a}function pv(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,fv(e,n,i==null?"":i))}function gv(e){return function(){this.textContent=e}}function yv(e){return function(){var n=e(this);this.textContent=n==null?"":n}}function xv(e){return this.tween("text",typeof e=="function"?yv(Fo(this,"text",e)):gv(e==null?"":e+""))}function Sv(e){return function(n){this.textContent=e.call(this,n)}}function wv(e){var n,i;function o(){var s=e.apply(this,arguments);return s!==i&&(n=(i=s)&&Sv(s)),n}return o._value=e,o}function Nv(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,wv(e))}function Av(){for(var e=this._name,n=this._id,i=Ua(),o=this._groups,s=o.length,a=0;a<s;++a)for(var l=o[a],r=l.length,d,u=0;u<r;++u)if(d=l[u]){var m=De(d,n);Mi(d,e,i,u,l,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new ze(o,this._parents,e,i)}function Cv(){var e,n,i=this,o=i._id,s=i.size();return new Promise(function(a,l){var r={value:l},d={value:function(){--s===0&&a()}};i.each(function(){var u=Fe(this,o),m=u.on;m!==e&&(n=(e=m).copy(),n._.cancel.push(r),n._.interrupt.push(r),n._.end.push(d)),u.on=n}),s===0&&a()})}var kv=0;function ze(e,n,i,o){this._groups=e,this._parents=n,this._name=i,this._id=o}function Ua(){return++kv}var We=In.prototype;ze.prototype={constructor:ze,select:tv,selectAll:lv,selectChild:We.selectChild,selectChildren:We.selectChildren,filter:Rb,merge:ev,selection:dv,transition:Av,call:We.call,nodes:We.nodes,node:We.node,size:We.size,empty:We.empty,each:We.each,on:ov,attr:Kb,attrTween:zb,style:vv,styleTween:pv,text:xv,textTween:Nv,remove:av,tween:Pb,delay:jb,duration:Yb,ease:Zb,easeVarying:Qb,end:Cv,[Symbol.iterator]:We[Symbol.iterator]};function Mv(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ev={time:null,delay:0,duration:250,ease:Mv};function Tv(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 Pv(e){var n,i;e instanceof ze?(n=e._id,e=e._name):(n=Ua(),(i=Ev).time=_o(),e=e==null?null:e+"");for(var o=this._groups,s=o.length,a=0;a<s;++a)for(var l=o[a],r=l.length,d,u=0;u<r;++u)(d=l[u])&&Mi(d,e,n,u,l,i||Tv(d,n));return new ze(o,this._parents,e,n)}In.prototype.interrupt=Mb,In.prototype.transition=Pv;const Ti=e=>()=>e;function Lv(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 $e(e,n,i){this.k=e,this.x=n,this.y=i}$e.prototype={constructor:$e,scale:function(e){return e===1?this:new $e(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new $e(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 Pi=new $e(1,0,0);qa.prototype=$e.prototype;function qa(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Pi;return e.__zoom}function Vo(e){e.stopImmediatePropagation()}function Wn(e){e.preventDefault(),e.stopImmediatePropagation()}function Bv(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Iv(){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 Ya(){return this.__zoom||Pi}function Dv(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function _v(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ov(e,n,i){var o=e.invertX(n[0][0])-i[0][0],s=e.invertX(n[1][0])-i[1][0],a=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>a?(a+l)/2:Math.min(0,a)||Math.max(0,l))}function Ja(){var e=Bv,n=Iv,i=Ov,o=Dv,s=_v,a=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],r=250,d=xi,u=di("start","zoom","end"),m,c,b,v=500,h=150,p=0,g=10;function f(M){M.property("__zoom",Ya).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",I).filter(s).on("touchstart.zoom",P).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}f.transform=function(M,_,B,K){var D=M.selection?M.selection():M;D.property("__zoom",Ya),M!==D?w(M,_,B,K):D.interrupt().each(function(){A(this,arguments).event(K).start().zoom(null,typeof _=="function"?_.apply(this,arguments):_).end()})},f.scaleBy=function(M,_,B,K){f.scaleTo(M,function(){var D=this.__zoom.k,L=typeof _=="function"?_.apply(this,arguments):_;return D*L},B,K)},f.scaleTo=function(M,_,B,K){f.transform(M,function(){var D=n.apply(this,arguments),L=this.__zoom,z=B==null?S(D):typeof B=="function"?B.apply(this,arguments):B,U=L.invert(z),W=typeof _=="function"?_.apply(this,arguments):_;return i(y(N(L,W),z,U),D,l)},B,K)},f.translateBy=function(M,_,B,K){f.transform(M,function(){return i(this.__zoom.translate(typeof _=="function"?_.apply(this,arguments):_,typeof B=="function"?B.apply(this,arguments):B),n.apply(this,arguments),l)},null,K)},f.translateTo=function(M,_,B,K,D){f.transform(M,function(){var L=n.apply(this,arguments),z=this.__zoom,U=K==null?S(L):typeof K=="function"?K.apply(this,arguments):K;return i(Pi.translate(U[0],U[1]).scale(z.k).translate(typeof _=="function"?-_.apply(this,arguments):-_,typeof B=="function"?-B.apply(this,arguments):-B),L,l)},K,D)};function N(M,_){return _=Math.max(a[0],Math.min(a[1],_)),_===M.k?M:new $e(_,M.x,M.y)}function y(M,_,B){var K=_[0]-B[0]*M.k,D=_[1]-B[1]*M.k;return K===M.x&&D===M.y?M:new $e(M.k,K,D)}function S(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function w(M,_,B,K){M.on("start.zoom",function(){A(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(K).end()}).tween("zoom",function(){var D=this,L=arguments,z=A(D,L).event(K),U=n.apply(D,L),W=B==null?S(U):typeof B=="function"?B.apply(D,L):B,Y=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),X=D.__zoom,ie=typeof _=="function"?_.apply(D,L):_,se=d(X.invert(W).concat(Y/X.k),ie.invert(W).concat(Y/ie.k));return function(Q){if(Q===1)Q=ie;else{var j=se(Q),V=Y/j[2];Q=new $e(V,W[0]-j[0]*V,W[1]-j[1]*V)}z.zoom(null,Q)}})}function A(M,_,B){return!B&&M.__zooming||new C(M,_)}function C(M,_){this.that=M,this.args=_,this.active=0,this.sourceEvent=null,this.extent=n.apply(M,_),this.taps=0}C.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,_){return this.mouse&&M!=="mouse"&&(this.mouse[1]=_.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=_.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=_.invert(this.touch1[0])),this.that.__zoom=_,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var _=Pe(this.that).datum();u.call(M,this.that,new Lv(M,{sourceEvent:this.sourceEvent,target:f,transform:this.that.__zoom,dispatch:u}),_)}};function E(M,..._){if(!e.apply(this,arguments))return;var B=A(this,_).event(M),K=this.__zoom,D=Math.max(a[0],Math.min(a[1],K.k*Math.pow(2,o.apply(this,arguments)))),L=Be(M);if(B.wheel)(B.mouse[0][0]!==L[0]||B.mouse[0][1]!==L[1])&&(B.mouse[1]=K.invert(B.mouse[0]=L)),clearTimeout(B.wheel);else{if(K.k===D)return;B.mouse=[L,K.invert(L)],Ei(this),B.start()}Wn(M),B.wheel=setTimeout(z,h),B.zoom("mouse",i(y(N(K,D),B.mouse[0],B.mouse[1]),B.extent,l));function z(){B.wheel=null,B.end()}}function k(M,..._){if(b||!e.apply(this,arguments))return;var B=M.currentTarget,K=A(this,_,!0).event(M),D=Pe(M.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",Y,!0),L=Be(M,B),z=M.clientX,U=M.clientY;pa(M.view),Vo(M),K.mouse=[L,this.__zoom.invert(L)],Ei(this),K.start();function W(X){if(Wn(X),!K.moved){var ie=X.clientX-z,se=X.clientY-U;K.moved=ie*ie+se*se>p}K.event(X).zoom("mouse",i(y(K.that.__zoom,K.mouse[0]=Be(X,B),K.mouse[1]),K.extent,l))}function Y(X){D.on("mousemove.zoom mouseup.zoom",null),ga(X.view,K.moved),Wn(X),K.event(X).end()}}function I(M,..._){if(e.apply(this,arguments)){var B=this.__zoom,K=Be(M.changedTouches?M.changedTouches[0]:M,this),D=B.invert(K),L=B.k*(M.shiftKey?.5:2),z=i(y(N(B,L),K,D),n.apply(this,_),l);Wn(M),r>0?Pe(this).transition().duration(r).call(w,z,K,M):Pe(this).call(f.transform,z,K,M)}}function P(M,..._){if(e.apply(this,arguments)){var B=M.touches,K=B.length,D=A(this,_,M.changedTouches.length===K).event(M),L,z,U,W;for(Vo(M),z=0;z<K;++z)U=B[z],W=Be(U,this),W=[W,this.__zoom.invert(W),U.identifier],D.touch0?!D.touch1&&D.touch0[2]!==W[2]&&(D.touch1=W,D.taps=0):(D.touch0=W,L=!0,D.taps=1+!!m);m&&(m=clearTimeout(m)),L&&(D.taps<2&&(c=W[0],m=setTimeout(function(){m=null},v)),Ei(this),D.start())}}function T(M,..._){if(this.__zooming){var B=A(this,_).event(M),K=M.changedTouches,D=K.length,L,z,U,W;for(Wn(M),L=0;L<D;++L)z=K[L],U=Be(z,this),B.touch0&&B.touch0[2]===z.identifier?B.touch0[0]=U:B.touch1&&B.touch1[2]===z.identifier&&(B.touch1[0]=U);if(z=B.that.__zoom,B.touch1){var Y=B.touch0[0],X=B.touch0[1],ie=B.touch1[0],se=B.touch1[1],Q=(Q=ie[0]-Y[0])*Q+(Q=ie[1]-Y[1])*Q,j=(j=se[0]-X[0])*j+(j=se[1]-X[1])*j;z=N(z,Math.sqrt(Q/j)),U=[(Y[0]+ie[0])/2,(Y[1]+ie[1])/2],W=[(X[0]+se[0])/2,(X[1]+se[1])/2]}else if(B.touch0)U=B.touch0[0],W=B.touch0[1];else return;B.zoom("touch",i(y(z,U,W),B.extent,l))}}function O(M,..._){if(this.__zooming){var B=A(this,_).event(M),K=M.changedTouches,D=K.length,L,z;for(Vo(M),b&&clearTimeout(b),b=setTimeout(function(){b=null},v),L=0;L<D;++L)z=K[L],B.touch0&&B.touch0[2]===z.identifier?delete B.touch0:B.touch1&&B.touch1[2]===z.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&&(z=Be(z,this),Math.hypot(c[0]-z[0],c[1]-z[1])<g)){var U=Pe(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return f.wheelDelta=function(M){return arguments.length?(o=typeof M=="function"?M:Ti(+M),f):o},f.filter=function(M){return arguments.length?(e=typeof M=="function"?M:Ti(!!M),f):e},f.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:Ti(!!M),f):s},f.extent=function(M){return arguments.length?(n=typeof M=="function"?M:Ti([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),f):n},f.scaleExtent=function(M){return arguments.length?(a[0]=+M[0],a[1]=+M[1],f):[a[0],a[1]]},f.translateExtent=function(M){return arguments.length?(l[0][0]=+M[0][0],l[1][0]=+M[1][0],l[0][1]=+M[0][1],l[1][1]=+M[1][1],f):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},f.constrain=function(M){return arguments.length?(i=M,f):i},f.duration=function(M){return arguments.length?(r=+M,f):r},f.interpolate=function(M){return arguments.length?(d=M,f):d},f.on=function(){var M=u.on.apply(u,arguments);return M===u?f:M},f.clickDistance=function(M){return arguments.length?(p=(M=+M)*M,f):Math.sqrt(p)},f.tapDistance=function(M){return arguments.length?(g=+M,f):g},f}const Le={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.`},$n=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Za=["Enter"," ","Escape"],Xa={"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 gn;(function(e){e.Strict="strict",e.Loose="loose"})(gn||(gn={}));var on;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(on||(on={}));var jn;(function(e){e.Partial="partial",e.Full="full"})(jn||(jn={}));const Qa={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var qe;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(qe||(qe={}));var yn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(yn||(yn={}));var oe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(oe||(oe={}));const Ra={[oe.Left]:oe.Right,[oe.Right]:oe.Left,[oe.Top]:oe.Bottom,[oe.Bottom]:oe.Top};function et(e){return e===null?null:e?"valid":"invalid"}const nt=e=>"id"in e&&"source"in e&&"target"in e,Kv=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),zo=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Un=(e,n=[0,0])=>{var r;const{width:i,height:o}=je(e),s=(r=e.origin)!=null?r:n,a=i*s[0],l=o*s[1];return{x:e.position.x-a,y:e.position.y-l}},Hv=(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 a=typeof s=="string";let l=!n.nodeLookup&&!a?s:void 0;n.nodeLookup&&(l=a?n.nodeLookup.get(s):zo(s)?s:n.nodeLookup.get(s.id));const r=l?Ii(l,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Li(o,r)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Bi(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=Li(i,Ii(s)),o=!0)}),o?Bi(i):{x:0,y:0,width:0,height:0}},Wo=(e,n,[i,o,s]=[0,0,1],a=!1,l=!1)=>{var b,v,h,p,g,f;const r=(n.x-i)/s,d=(n.y-o)/s,u=n.width/s,m=n.height/s,c=[];for(const N of e.values()){const{measured:y,selectable:S=!0,hidden:w=!1}=N;if(l&&!S||w)continue;const A=(h=(v=(b=y.width)!=null?b:N.width)!=null?v:N.initialWidth)!=null?h:0,C=(f=(g=(p=y.height)!=null?p:N.height)!=null?g:N.initialHeight)!=null?f:0,{x:E,y:k}=N.internals.positionAbsolute,I=tt(r,d,u,m,E,k,A,C),P=A*C,T=a&&I>0;(!N.internals.handleBounds||T||I>=P||N.dragging)&&c.push(N)}return c},Gv=(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 Fv(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 Vv({nodes:e,width:n,height:i,panZoom:o,minZoom:s,maxZoom:a},l){var m,c,b;if(e.size===0)return!0;const r=Fv(e,l),d=qn(r),u=Uo(d,n,i,(m=l==null?void 0:l.minZoom)!=null?m:s,(c=l==null?void 0:l.maxZoom)!=null?c:a,(b=l==null?void 0:l.padding)!=null?b:.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 it({nodeId:e,nextPosition:n,nodeLookup:i,nodeOrigin:o=[0,0],nodeExtent:s,onError:a}){var v,h,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},m=(v=l.origin)!=null?v:o;let c=l.extent||s;if(l.extent==="parent"&&!l.expandParent)if(!r)a==null||a("005",Le.error005());else{const g=r.measured.width,f=r.measured.height;g&&f&&(c=[[d,u],[d+g,u+f]])}else r&&an(l.extent)&&(c=[[l.extent[0][0]+d,l.extent[0][1]+u],[l.extent[1][0]+d,l.extent[1][1]+u]]);const b=an(c)?sn(n,c,l.measured):n;return(l.measured.width===void 0||l.measured.height===void 0)&&(a==null||a("015",Le.error015())),{position:{x:b.x-d+((h=l.measured.width)!=null?h:0)*m[0],y:b.y-u+((p=l.measured.height)!=null?p:0)*m[1]},positionAbsolute:b}}async function zv({nodesToRemove:e=[],edgesToRemove:n=[],nodes:i,edges:o,onBeforeDelete:s}){const a=new Set(e.map(b=>b.id)),l=[];for(const b of i){if(b.deletable===!1)continue;const v=a.has(b.id),h=!v&&b.parentId&&l.find(p=>p.id===b.parentId);(v||h)&&l.push(b)}const r=new Set(n.map(b=>b.id)),d=o.filter(b=>b.deletable!==!1),m=Gv(l,d);for(const b of d)r.has(b.id)&&!m.find(h=>h.id===b.id)&&m.push(b);if(!s)return{edges:m,nodes:l};const c=await s({nodes:l,edges:m});return typeof c=="boolean"?c?{edges:m,nodes:l}:{edges:[],nodes:[]}:c}const xn=(e,n=0,i=1)=>Math.min(Math.max(e,n),i),sn=(e={x:0,y:0},n,i)=>{var o,s;return{x:xn(e.x,n[0][0],n[1][0]-((o=i==null?void 0:i.width)!=null?o:0)),y:xn(e.y,n[0][1],n[1][1]-((s=i==null?void 0:i.height)!=null?s:0))}};function ot(e,n,i){const{width:o,height:s}=je(i),{x:a,y:l}=i.internals.positionAbsolute;return sn(e,[[a,l],[a+o,l+s]],n)}const st=(e,n,i)=>e<n?xn(Math.abs(e-n),1,n)/n:e>i?-xn(Math.abs(e-i),1,n)/n:0,$o=(e,n,i=15,o=40)=>{const s=st(e.x,o,n.width-o)*i,a=st(e.y,o,n.height-o)*i;return[s,a]},Li=(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)}),jo=({x:e,y:n,width:i,height:o})=>({x:e,y:n,x2:e+i,y2:n+o}),Bi=({x:e,y:n,x2:i,y2:o})=>({x:e,y:n,width:i-e,height:o-n}),Yn=(e,n=[0,0])=>{var s,a,l,r,d,u,m,c;const{x:i,y:o}=zo(e)?e.internals.positionAbsolute:Un(e,n);return{x:i,y:o,width:(r=(l=(a=(s=e.measured)==null?void 0:s.width)!=null?a:e.width)!=null?l:e.initialWidth)!=null?r:0,height:(c=(m=(u=(d=e.measured)==null?void 0:d.height)!=null?u:e.height)!=null?m:e.initialHeight)!=null?c:0}},Ii=(e,n=[0,0])=>{var s,a,l,r,d,u,m,c;const{x:i,y:o}=zo(e)?e.internals.positionAbsolute:Un(e,n);return{x:i,y:o,x2:i+((r=(l=(a=(s=e.measured)==null?void 0:s.width)!=null?a:e.width)!=null?l:e.initialWidth)!=null?r:0),y2:o+((c=(m=(u=(d=e.measured)==null?void 0:d.height)!=null?u:e.height)!=null?m:e.initialHeight)!=null?c:0)}},at=(e,n)=>Bi(Li(jo(e),jo(n))),tt=(e,n,i,o,s,a,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,a+r)-Math.max(n,a));return Math.ceil(d*u)},Di=(e,n)=>tt(e.x,e.y,e.width,e.height,n.x,n.y,n.width,n.height),lt=e=>_e(e.width)&&_e(e.height)&&_e(e.x)&&_e(e.y),_e=e=>!isNaN(e)&&isFinite(e),rt=(e,n)=>(i,o)=>{process.env.NODE_ENV==="development"&&console.warn(`[${e}]: ${o} Help: ${n}error#${i}`)},Jn=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),Zn=({x:e,y:n},[i,o,s],a=!1,l=[1,1])=>{const r={x:(e-i)/s,y:(n-o)/s};return a?Jn(r,l):r},Sn=({x:e,y:n},[i,o,s])=>({x:e*s+i,y:n*s+o});function wn(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 Wv(e,n,i){var o,s,a,l,r,d,u,m;if(typeof e=="string"||typeof e=="number"){const c=wn(e,i),b=wn(e,n);return{top:c,right:b,bottom:c,left:b,x:b*2,y:c*2}}if(typeof e=="object"){const c=wn((s=(o=e.top)!=null?o:e.y)!=null?s:0,i),b=wn((l=(a=e.bottom)!=null?a:e.y)!=null?l:0,i),v=wn((d=(r=e.left)!=null?r:e.x)!=null?d:0,n),h=wn((m=(u=e.right)!=null?u:e.x)!=null?m:0,n);return{top:c,right:h,bottom:b,left:v,x:v+h,y:c+b}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function $v(e,n,i,o,s,a){const{x:l,y:r}=Sn(e,[n,i,o]),{x:d,y:u}=Sn({x:e.x+e.width,y:e.y+e.height},[n,i,o]),m=s-d,c=a-u;return{left:Math.floor(l),top:Math.floor(r),right:Math.floor(m),bottom:Math.floor(c)}}const Uo=(e,n,i,o,s,a)=>{const l=Wv(a,n,i),r=(n-l.x)/e.width,d=(i-l.y)/e.height,u=Math.min(r,d),m=xn(u,o,s),c=e.x+e.width/2,b=e.y+e.height/2,v=n/2-c*m,h=i/2-b*m,p=$v(e,v,h,m,n,i),g={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:v-g.left+g.right,y:h-g.top+g.bottom,zoom:m}},Xn=()=>{var e;return typeof navigator!="undefined"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function an(e){return e!=null&&e!=="parent"}function je(e){var n,i,o,s,a,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=(a=e.measured)==null?void 0:a.height)!=null?l:e.height)!=null?r:e.initialHeight)!=null?d:0}}function dt(e){var n,i,o,s,a,l;return((o=(i=(n=e.measured)==null?void 0:n.width)!=null?i:e.width)!=null?o:e.initialWidth)!==void 0&&((l=(a=(s=e.measured)==null?void 0:s.height)!=null?a:e.height)!=null?l:e.initialHeight)!==void 0}function ut(e,n={width:0,height:0},i,o,s){var r,d;const a={...e},l=o.get(i);if(l){const u=l.origin||s;a.x+=l.internals.positionAbsolute.x-((r=n.width)!=null?r:0)*u[0],a.y+=l.internals.positionAbsolute.y-((d=n.height)!=null?d:0)*u[1]}return a}function ct(e,n){if(e.size!==n.size)return!1;for(const i of e)if(!n.has(i))return!1;return!0}function jv(){let e,n;return{promise:new Promise((o,s)=>{e=o,n=s}),resolve:e,reject:n}}function Uv(e){return{...Xa,...e||{}}}function Qn(e,{snapGrid:n=[0,0],snapToGrid:i=!1,transform:o,containerBounds:s}){var m,c;const{x:a,y:l}=Oe(e),r=Zn({x:a-((m=s==null?void 0:s.left)!=null?m:0),y:l-((c=s==null?void 0:s.top)!=null?c:0)},o),{x:d,y:u}=i?Jn(r,n):r;return{xSnapped:d,ySnapped:u,...r}}const qo=e=>({width:e.offsetWidth,height:e.offsetHeight}),mt=e=>{var n;return((n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},qv=["INPUT","SELECT","TEXTAREA"];function bt(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:qv.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const vt=e=>"clientX"in e,Oe=(e,n)=>{var a,l,r,d;const i=vt(e),o=i?e.clientX:(a=e.touches)==null?void 0:a[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)}},ht=(e,n,i,o,s)=>{const a=n.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).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,...qo(l)}})};function ft({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:l,targetControlY:r}){const d=e*.125+s*.375+l*.375+i*.125,u=n*.125+a*.375+r*.375+o*.125,m=Math.abs(d-e),c=Math.abs(u-n);return[d,u,m,c]}function _i(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function pt({pos:e,x1:n,y1:i,x2:o,y2:s,c:a}){switch(e){case oe.Left:return[n-_i(n-o,a),i];case oe.Right:return[n+_i(o-n,a),i];case oe.Top:return[n,i-_i(i-s,a)];case oe.Bottom:return[n,i+_i(s-i,a)]}}function gt({sourceX:e,sourceY:n,sourcePosition:i=oe.Bottom,targetX:o,targetY:s,targetPosition:a=oe.Top,curvature:l=.25}){const[r,d]=pt({pos:i,x1:e,y1:n,x2:o,y2:s,c:l}),[u,m]=pt({pos:a,x1:o,y1:s,x2:e,y2:n,c:l}),[c,b,v,h]=ft({sourceX:e,sourceY:n,targetX:o,targetY:s,sourceControlX:r,sourceControlY:d,targetControlX:u,targetControlY:m});return[`M${e},${n} C${r},${d} ${u},${m} ${o},${s}`,c,b,v,h]}function yt({sourceX:e,sourceY:n,targetX:i,targetY:o}){const s=Math.abs(i-e)/2,a=i<e?i+s:i-s,l=Math.abs(o-n)/2,r=o<n?o+l:o-l;return[a,r,s,l]}function Yv({sourceNode:e,targetNode:n,selected:i=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:a="basic"}){if(a==="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 Jv({sourceNode:e,targetNode:n,width:i,height:o,transform:s}){const a=Li(Ii(e),Ii(n));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const l={x:-s[0]/s[2],y:-s[1]/s[2],width:i/s[2],height:o/s[2]};return Di(l,Bi(a))>0}const Zv=({source:e,sourceHandle:n,target:i,targetHandle:o})=>`xy-edge__${e}${n||""}-${i}${o||""}`,Xv=(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)),Qv=(e,n,i={})=>{var a;if(!e.source||!e.target)return(a=i.onError)==null||a.call(i,"006",Le.error006()),n;const o=i.getEdgeId||Zv;let s;return nt(e)?s={...e}:s={...e,id:o(e)},Xv(s,n)?n:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,n.concat(s))};function xt({sourceX:e,sourceY:n,targetX:i,targetY:o}){const[s,a,l,r]=yt({sourceX:e,sourceY:n,targetX:i,targetY:o});return[`M ${e},${n}L ${i},${o}`,s,a,l,r]}const St={[oe.Left]:{x:-1,y:0},[oe.Right]:{x:1,y:0},[oe.Top]:{x:0,y:-1},[oe.Bottom]:{x:0,y:1}},Rv=({source:e,sourcePosition:n=oe.Bottom,target:i})=>n===oe.Left||n===oe.Right?e.x<i.x?{x:1,y:0}:{x:-1,y:0}:e.y<i.y?{x:0,y:1}:{x:0,y:-1},wt=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function eh({source:e,sourcePosition:n=oe.Bottom,target:i,targetPosition:o=oe.Top,center:s,offset:a,stepPosition:l}){var E,k,I,P;const r=St[n],d=St[o],u={x:e.x+r.x*a,y:e.y+r.y*a},m={x:i.x+d.x*a,y:i.y+d.y*a},c=Rv({source:u,sourcePosition:n,target:m}),b=c.x!==0?"x":"y",v=c[b];let h=[],p,g;const f={x:0,y:0},N={x:0,y:0},[,,y,S]=yt({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(r[b]*d[b]===-1){b==="x"?(p=(E=s.x)!=null?E:u.x+(m.x-u.x)*l,g=(k=s.y)!=null?k:(u.y+m.y)/2):(p=(I=s.x)!=null?I:(u.x+m.x)/2,g=(P=s.y)!=null?P:u.y+(m.y-u.y)*l);const T=[{x:p,y:u.y},{x:p,y:m.y}],O=[{x:u.x,y:g},{x:m.x,y:g}];r[b]===v?h=b==="x"?T:O:h=b==="x"?O:T}else{const T=[{x:u.x,y:m.y}],O=[{x:m.x,y:u.y}];if(b==="x"?h=r.x===v?O:T:h=r.y===v?T:O,n===o){const D=Math.abs(e[b]-i[b]);if(D<=a){const L=Math.min(a-1,a-D);r[b]===v?f[b]=(u[b]>e[b]?-1:1)*L:N[b]=(m[b]>i[b]?-1:1)*L}}if(n!==o){const D=b==="x"?"y":"x",L=r[b]===d[D],z=u[D]>m[D],U=u[D]<m[D];(r[b]===1&&(!L&&z||L&&U)||r[b]!==1&&(!L&&U||L&&z))&&(h=b==="x"?T:O)}const M={x:u.x+f.x,y:u.y+f.y},_={x:m.x+N.x,y:m.y+N.y},B=Math.max(Math.abs(M.x-h[0].x),Math.abs(_.x-h[0].x)),K=Math.max(Math.abs(M.y-h[0].y),Math.abs(_.y-h[0].y));B>=K?(p=(M.x+_.x)/2,g=h[0].y):(p=h[0].x,g=(M.y+_.y)/2)}const w={x:u.x+f.x,y:u.y+f.y},A={x:m.x+N.x,y:m.y+N.y};return[[e,...w.x!==h[0].x||w.y!==h[0].y?[w]:[],...h,...A.x!==h[h.length-1].x||A.y!==h[h.length-1].y?[A]:[],i],p,g,y,S]}function nh(e,n,i,o){const s=Math.min(wt(e,n)/2,wt(n,i)/2,o),{x:a,y:l}=n;if(e.x===a&&a===i.x||e.y===l&&l===i.y)return`L${a} ${l}`;if(e.y===l){const u=e.x<i.x?-1:1,m=e.y<i.y?1:-1;return`L ${a+s*u},${l}Q ${a},${l} ${a},${l+s*m}`}const r=e.x<i.x?1:-1,d=e.y<i.y?-1:1;return`L ${a},${l+s*d}Q ${a},${l} ${a+s*r},${l}`}function Yo({sourceX:e,sourceY:n,sourcePosition:i=oe.Bottom,targetX:o,targetY:s,targetPosition:a=oe.Top,borderRadius:l=5,centerX:r,centerY:d,offset:u=20,stepPosition:m=.5}){const[c,b,v,h,p]=eh({source:{x:e,y:n},sourcePosition:i,target:{x:o,y:s},targetPosition:a,center:{x:r,y:d},offset:u,stepPosition:m});let g=`M${c[0].x} ${c[0].y}`;for(let f=1;f<c.length-1;f++)g+=nh(c[f-1],c[f],c[f+1],l);return g+=`L${c[c.length-1].x} ${c[c.length-1].y}`,[g,b,v,h,p]}function Nt(e){var n;return e&&!!(e.internals.handleBounds||(n=e.handles)!=null&&n.length)&&!!(e.measured.width||e.width||e.initialWidth)}function ih(e){var c,b,v,h,p;const{sourceNode:n,targetNode:i}=e;if(!Nt(n)||!Nt(i))return null;const o=n.internals.handleBounds||At(n.handles),s=i.internals.handleBounds||At(i.handles),a=Ct((c=o==null?void 0:o.source)!=null?c:[],e.sourceHandle),l=Ct(e.connectionMode===gn.Strict?(b=s==null?void 0:s.target)!=null?b:[]:((v=s==null?void 0:s.target)!=null?v:[]).concat((h=s==null?void 0:s.source)!=null?h:[]),e.targetHandle);if(!a||!l)return(p=e.onError)==null||p.call(e,"008",Le.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const r=(a==null?void 0:a.position)||oe.Bottom,d=(l==null?void 0:l.position)||oe.Top,u=tn(n,a,r),m=tn(i,l,d);return{sourceX:u.x,sourceY:u.y,targetX:m.x,targetY:m.y,sourcePosition:r,targetPosition:d}}function At(e){var o,s;if(!e)return null;const n=[],i=[];for(const a of e)a.width=(o=a.width)!=null?o:1,a.height=(s=a.height)!=null?s:1,a.type==="source"?n.push(a):a.type==="target"&&i.push(a);return{source:n,target:i}}function tn(e,n,i=oe.Left,o=!1){var u,m,c;const s=((u=n==null?void 0:n.x)!=null?u:0)+e.internals.positionAbsolute.x,a=((m=n==null?void 0:n.y)!=null?m:0)+e.internals.positionAbsolute.y,{width:l,height:r}=n!=null?n:je(e);if(o)return{x:s+l/2,y:a+r/2};switch((c=n==null?void 0:n.position)!=null?c:i){case oe.Top:return{x:s+l/2,y:a};case oe.Right:return{x:s+l,y:a+r/2};case oe.Bottom:return{x:s+l/2,y:a+r};case oe.Left:return{x:s,y:a+r/2}}}function Ct(e,n){return e&&(n?e.find(i=>i.id===n):e[0])||null}function Jo(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function oh(e,{id:n,defaultColor:i,defaultMarkerStart:o,defaultMarkerEnd:s}){const a=new Set;return e.reduce((l,r)=>([r.markerStart||o,r.markerEnd||s].forEach(d=>{if(d&&typeof d=="object"){const u=Jo(d,n);a.has(u)||(l.push({id:u,color:d.color||i,...d}),a.add(u))}}),l),[]).sort((l,r)=>l.id.localeCompare(r.id))}const kt=1e3,sh=10,Zo={nodeOrigin:[0,0],nodeExtent:$n,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ah={...Zo,checkEquality:!0};function Xo(e,n){const i={...e};for(const o in n)n[o]!==void 0&&(i[o]=n[o]);return i}function th(e,n,i){const o=Xo(Zo,i);for(const s of e.values())if(s.parentId)es(s,e,n,o);else{const a=Un(s,o.nodeOrigin),l=an(s.extent)?s.extent:o.nodeExtent,r=sn(a,l,je(s));s.internals.positionAbsolute=r}}function lh(e,n){var s,a;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:(a=l.height)!=null?a: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 Qo(e){return e==="manual"}function Ro(e,n,i,o={}){var m,c,b;const s=Xo(ah,o),a={i:0},l=new Map(n),r=s!=null&&s.elevateNodesOnSelect&&!Qo(s.zIndexMode)?kt:0;let d=e.length>0,u=!1;n.clear(),i.clear();for(const v of e){let h=l.get(v.id);if(s.checkEquality&&v===(h==null?void 0:h.internals.userNode))n.set(v.id,h);else{const p=Un(v,s.nodeOrigin),g=an(v.extent)?v.extent:s.nodeExtent,f=sn(p,g,je(v));h={...s.defaults,...v,measured:{width:(m=v.measured)==null?void 0:m.width,height:(c=v.measured)==null?void 0:c.height},internals:{positionAbsolute:f,handleBounds:lh(v,h),z:Mt(v,r,s.zIndexMode),userNode:v}},n.set(v.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(d=!1),v.parentId&&es(h,n,i,o,a),u||(u=(b=v.selected)!=null?b:!1)}return{nodesInitialized:d,hasSelectedNodes:u}}function rh(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 es(e,n,i,o,s){const{elevateNodesOnSelect:a,nodeOrigin:l,nodeExtent:r,zIndexMode:d}=Xo(Zo,o),u=e.parentId,m=n.get(u);if(!m){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}rh(e,i),s&&!m.parentId&&m.internals.rootParentIndex===void 0&&d==="auto"&&(m.internals.rootParentIndex=++s.i,m.internals.z=m.internals.z+s.i*sh),s&&m.internals.rootParentIndex!==void 0&&(s.i=m.internals.rootParentIndex);const c=a&&!Qo(d)?kt:0,{x:b,y:v,z:h}=dh(e,m,l,r,c,d),{positionAbsolute:p}=e.internals,g=b!==p.x||v!==p.y;(g||h!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:g?{x:b,y:v}:p,z:h}})}function Mt(e,n,i){const o=_e(e.zIndex)?e.zIndex:0;return Qo(i)?o:o+(e.selected?n:0)}function dh(e,n,i,o,s,a){var h;const{x:l,y:r}=n.internals.positionAbsolute,d=je(e),u=Un(e,i),m=an(e.extent)?sn(u,e.extent,d):u;let c=sn({x:l+m.x,y:r+m.y},o,d);e.extent==="parent"&&(c=ot(c,d,n));const b=Mt(e,s,a),v=(h=n.internals.z)!=null?h:0;return{x:c.x,y:c.y,z:v>=b?v+1:b}}function ns(e,n,i,o=[0,0]){var l,r;const s=[],a=new Map;for(const d of e){const u=n.get(d.parentId);if(!u)continue;const m=(r=(l=a.get(d.parentId))==null?void 0:l.expandedRect)!=null?r:Yn(u),c=at(m,d.rect);a.set(d.parentId,{expandedRect:c,parent:u})}return a.size>0&&a.forEach(({expandedRect:d,parent:u},m)=>{var S,w;const c=u.internals.positionAbsolute,b=je(u),v=(S=u.origin)!=null?S:o,h=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,g=Math.max(b.width,Math.round(d.width)),f=Math.max(b.height,Math.round(d.height)),N=(g-b.width)*v[0],y=(f-b.height)*v[1];(h>0||p>0||N||y)&&(s.push({id:m,type:"position",position:{x:u.position.x-h+N,y:u.position.y-p+y}}),(w=i.get(m))==null||w.forEach(A=>{e.some(C=>C.id===A.id)||s.push({id:A.id,type:"position",position:{x:A.position.x+h,y:A.position.y+p}})})),(b.width<d.width||b.height<d.height||h||p)&&s.push({id:m,type:"dimensions",setAttributes:!0,dimensions:{width:g+(h?v[0]*h-N:0),height:f+(p?v[1]*p-y:0)}})}),s}function uh(e,n,i,o,s,a,l){const r=o==null?void 0:o.querySelector(".xyflow__viewport");let d=!1;if(!r)return{changes:[],updatedInternals:d};const u=[],m=window.getComputedStyle(r),{m22:c}=new window.DOMMatrixReadOnly(m.transform),b=[];for(const v of e.values()){const h=n.get(v.id);if(!h)continue;if(h.hidden){n.set(h.id,{...h,internals:{...h.internals,handleBounds:void 0}}),d=!0;continue}const p=qo(v.nodeElement),g=h.measured.width!==p.width||h.measured.height!==p.height;if(!!(p.width&&p.height&&(g||!h.internals.handleBounds||v.force))){const N=v.nodeElement.getBoundingClientRect(),y=an(h.extent)?h.extent:a;let{positionAbsolute:S}=h.internals;h.parentId&&h.extent==="parent"?S=ot(S,p,n.get(h.parentId)):y&&(S=sn(S,y,p));const w={...h,measured:p,internals:{...h.internals,positionAbsolute:S,handleBounds:{source:ht("source",v.nodeElement,N,c,h.id),target:ht("target",v.nodeElement,N,c,h.id)}}};n.set(h.id,w),h.parentId&&es(w,n,i,{nodeOrigin:s,zIndexMode:l}),d=!0,g&&(u.push({id:h.id,type:"dimensions",dimensions:p}),h.expandParent&&h.parentId&&b.push({id:h.id,parentId:h.parentId,rect:Yn(w,s)}))}}if(b.length>0){const v=ns(b,n,i,s);u.push(...v)}return{changes:u,updatedInternals:d}}async function ch({delta:e,panZoom:n,transform:i,translateExtent:o,width:s,height:a}){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,a]],o);return!!l&&(l.x!==i[0]||l.y!==i[1]||l.k!==i[2])}function Et(e,n,i,o,s,a){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)),a){l=`${s}-${e}-${a}`;const u=o.get(l)||new Map;o.set(l,u.set(i,n))}}function Tt(e,n,i){e.clear(),n.clear();for(const o of i){const{source:s,target:a,sourceHandle:l=null,targetHandle:r=null}=o,d={edgeId:o.id,source:s,target:a,sourceHandle:l,targetHandle:r},u=`${s}-${l}--${a}-${r}`,m=`${a}-${r}--${s}-${l}`;Et("source",d,m,e,s,l),Et("target",d,u,e,a,r),n.set(o.id,o)}}function Pt(e,n){if(!e.parentId)return!1;const i=n.get(e.parentId);return i?i.selected?!0:Pt(i,n):!1}function Lt(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 mh(e,n,i,o){var a,l;const s=new Map;for(const[r,d]of e)if((d.selected||d.id===o)&&(!d.parentId||!Pt(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:(a=u.measured.width)!=null?a:0,height:(l=u.measured.height)!=null?l:0}})}return s}function is({nodeId:e,dragItems:n,nodeLookup:i,dragging:o=!0}){var l,r,d;const s=[];for(const[u,m]of n){const c=(l=i.get(u))==null?void 0:l.internals.userNode;c&&s.push({...c,position:m.position,dragging:o})}if(!e)return[s[0],s];const a=(r=i.get(e))==null?void 0:r.internals.userNode;return[a?{...a,position:((d=n.get(e))==null?void 0:d.position)||a.position,dragging:o}:s[0],s]}function bh({dragItems:e,snapGrid:n,x:i,y:o}){const s=e.values().next().value;if(!s)return null;const a={x:i-s.distance.x,y:o-s.distance.y},l=Jn(a,n);return{x:l.x-a.x,y:l.y-a.y}}function vh({onNodeMouseDown:e,getStoreItems:n,onDragStart:i,onDrag:o,onDragStop:s}){let a={x:null,y:null},l=0,r=new Map,d=!1,u={x:0,y:0},m=null,c=!1,b=null,v=!1,h=!1,p=null;function g({noDragClassName:N,handleSelector:y,domNode:S,isSelectable:w,nodeId:A,nodeClickDistance:C=0}){b=Pe(S);function E({x:T,y:O}){const{nodeLookup:M,nodeExtent:_,snapGrid:B,snapToGrid:K,nodeOrigin:D,onNodeDrag:L,onSelectionDrag:z,onError:U,updateNodePositions:W}=n();a={x:T,y:O};let Y=!1;const X=r.size>1,ie=X&&_?jo(qn(r)):null,se=X&&K?bh({dragItems:r,snapGrid:B,x:T,y:O}):null;for(const[Q,j]of r){if(!M.has(Q))continue;let V={x:T-j.distance.x,y:O-j.distance.y};K&&(V=se?{x:Math.round(V.x+se.x),y:Math.round(V.y+se.y)}:Jn(V,B));let G=null;if(X&&_&&!j.extent&&ie){const{positionAbsolute:F}=j.internals,q=F.x-ie.x+_[0][0],R=F.x+j.measured.width-ie.x2+_[1][0],Z=F.y-ie.y+_[0][1],J=F.y+j.measured.height-ie.y2+_[1][1];G=[[q,Z],[R,J]]}const{position:H,positionAbsolute:$}=it({nodeId:Q,nextPosition:V,nodeLookup:M,nodeExtent:G||_,nodeOrigin:D,onError:U});Y=Y||j.position.x!==H.x||j.position.y!==H.y,j.position=H,j.internals.positionAbsolute=$}if(h=h||Y,!!Y&&(W(r,!0),p&&(o||L||!A&&z))){const[Q,j]=is({nodeId:A,dragItems:r,nodeLookup:M});o==null||o(p,r,Q,j),L==null||L(p,Q,j),A||z==null||z(p,j)}}async function k(){var D,L;if(!m)return;const{transform:T,panBy:O,autoPanSpeed:M,autoPanOnNodeDrag:_}=n();if(!_){d=!1,cancelAnimationFrame(l);return}const[B,K]=$o(u,m,M);(B!==0||K!==0)&&(a.x=((D=a.x)!=null?D:0)-B/T[2],a.y=((L=a.y)!=null?L:0)-K/T[2],await O({x:B,y:K})&&E(a)),l=requestAnimationFrame(k)}function I(T){var X;const{nodeLookup:O,multiSelectionActive:M,nodesDraggable:_,transform:B,snapGrid:K,snapToGrid:D,selectNodesOnDrag:L,onNodeDragStart:z,onSelectionDragStart:U,unselectNodesAndEdges:W}=n();c=!0,(!L||!w)&&!M&&A&&((X=O.get(A))!=null&&X.selected||W()),w&&L&&A&&(e==null||e(A));const Y=Qn(T.sourceEvent,{transform:B,snapGrid:K,snapToGrid:D,containerBounds:m});if(a=Y,r=mh(O,_,Y,A),r.size>0&&(i||z||!A&&U)){const[ie,se]=is({nodeId:A,dragItems:r,nodeLookup:O});i==null||i(T.sourceEvent,r,ie,se),z==null||z(T.sourceEvent,ie,se),A||U==null||U(T.sourceEvent,se)}}const P=ya().clickDistance(C).on("start",T=>{const{domNode:O,nodeDragThreshold:M,transform:_,snapGrid:B,snapToGrid:K}=n();m=(O==null?void 0:O.getBoundingClientRect())||null,v=!1,h=!1,p=T.sourceEvent,M===0&&I(T),a=Qn(T.sourceEvent,{transform:_,snapGrid:B,snapToGrid:K,containerBounds:m}),u=Oe(T.sourceEvent,m)}).on("drag",T=>{const{autoPanOnNodeDrag:O,transform:M,snapGrid:_,snapToGrid:B,nodeDragThreshold:K,nodeLookup:D}=n(),L=Qn(T.sourceEvent,{transform:M,snapGrid:_,snapToGrid:B,containerBounds:m});if(p=T.sourceEvent,(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1||A&&!D.has(A))&&(v=!0),!v){if(!d&&O&&c&&(d=!0,k()),!c){const z=Oe(T.sourceEvent,m),U=z.x-u.x,W=z.y-u.y;Math.sqrt(U*U+W*W)>K&&I(T)}(a.x!==L.xSnapped||a.y!==L.ySnapped)&&r&&c&&(u=Oe(T.sourceEvent,m),E(L))}}).on("end",T=>{if(!c||v){v&&r.size>0&&n().updateNodePositions(r,!1);return}if(d=!1,c=!1,cancelAnimationFrame(l),r.size>0){const{nodeLookup:O,updateNodePositions:M,onNodeDragStop:_,onSelectionDragStop:B}=n();if(h&&(M(r,!1),h=!1),s||_||!A&&B){const[K,D]=is({nodeId:A,dragItems:r,nodeLookup:O,dragging:!1});s==null||s(T.sourceEvent,r,K,D),_==null||_(T.sourceEvent,K,D),A||B==null||B(T.sourceEvent,D)}}}).filter(T=>{const O=T.target;return!T.button&&(!N||!Lt(O,`.${N}`,S))&&(!y||Lt(O,y,S))});b.call(P)}function f(){b==null||b.on(".drag",null)}return{update:g,destroy:f}}function hh(e,n,i){const o=[],s={x:e.x-i,y:e.y-i,width:i*2,height:i*2};for(const a of n.values())Di(s,Yn(a))>0&&o.push(a);return o}const fh=250;function ph(e,n,i,o){var r,d,u,m,c;let s=[],a=1/0;const l=hh(e,i,n+fh);for(const b of l){const v=[...(d=(r=b.internals.handleBounds)==null?void 0:r.source)!=null?d:[],...(m=(u=b.internals.handleBounds)==null?void 0:u.target)!=null?m:[]];for(const h of v){if(o.nodeId===h.nodeId&&o.type===h.type&&o.id===h.id)continue;const{x:p,y:g}=tn(b,h,h.position,!0),f=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(g-e.y,2));f>n||(f<a?(s=[{...h,x:p,y:g}],a=f):f===a&&s.push({...h,x:p,y:g}))}}if(!s.length)return null;if(s.length>1){const b=o.type==="source"?"target":"source";return(c=s.find(v=>v.type===b))!=null?c:s[0]}return s[0]}function Bt(e,n,i,o,s,a=!1){var u,m,c,b,v,h;const l=o.get(e);if(!l)return null;const r=s==="strict"?(u=l.internals.handleBounds)==null?void 0:u[n]:[...(c=(m=l.internals.handleBounds)==null?void 0:m.source)!=null?c:[],...(v=(b=l.internals.handleBounds)==null?void 0:b.target)!=null?v:[]],d=(h=i?r==null?void 0:r.find(p=>p.id===i):r==null?void 0:r[0])!=null?h:null;return d&&a?{...d,...tn(l,d,d.position,!0)}:d}function It(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function gh(e,n){let i=null;return n?i=!0:e&&!n&&(i=!1),i}const Dt=()=>!0;function yh(e,{connectionMode:n,connectionRadius:i,handleId:o,nodeId:s,edgeUpdaterType:a,isTarget:l,domNode:r,nodeLookup:d,lib:u,autoPanOnConnect:m,flowId:c,panBy:b,cancelConnection:v,onConnectStart:h,onConnect:p,onConnectEnd:g,isValidConnection:f=Dt,onReconnectEnd:N,updateConnection:y,getTransform:S,getFromHandle:w,autoPanSpeed:A,dragThreshold:C=1,handleDomNode:E}){const k=mt(e.target);let I=0,P;const{x:T,y:O}=Oe(e),M=It(a,E),_=r==null?void 0:r.getBoundingClientRect();let B=!1;if(!_||!M)return;const K=Bt(s,M,o,d,n);if(!K)return;let D=Oe(e,_),L=!1,z=null,U=!1,W=null;function Y(){if(!m||!_)return;const[H,$]=$o(D,_,A);b({x:H,y:$}),I=requestAnimationFrame(Y)}const X={...K,nodeId:s,type:M,position:K.position},ie=d.get(s);let Q={inProgress:!0,isValid:null,from:tn(ie,X,oe.Left,!0),fromHandle:X,fromPosition:X.position,fromNode:ie,to:D,toHandle:null,toPosition:Ra[X.position],toNode:null,pointer:D};function j(){B=!0,y(Q),h==null||h(e,{nodeId:s,handleId:o,handleType:M})}C===0&&j();function V(H){if(!B){const{x:J,y:ee}=Oe(H),ae=J-T,ue=ee-O;if(!(ae*ae+ue*ue>C*C))return;j()}if(!w()||!X){G(H);return}const $=S();D=Oe(H,_),P=ph(Zn(D,$,!1,[1,1]),i,d,X),L||(Y(),L=!0);const F=_t(H,{handle:P,connectionMode:n,fromNodeId:s,fromHandleId:o,fromType:l?"target":"source",isValidConnection:f,doc:k,lib:u,flowId:c,nodeLookup:d});W=F.handleDomNode,z=F.connection,U=gh(!!P,F.isValid);const q=d.get(s),R=q?tn(q,X,oe.Left,!0):Q.from,Z={...Q,from:R,isValid:U,to:F.toHandle&&U?Sn({x:F.toHandle.x,y:F.toHandle.y},$):D,toHandle:F.toHandle,toPosition:U&&F.toHandle?F.toHandle.position:Ra[X.position],toNode:F.toHandle?d.get(F.toHandle.nodeId):null,pointer:D};y(Z),Q=Z}function G(H){if(!("touches"in H&&H.touches.length>0)){if(B){(P||W)&&z&&U&&(p==null||p(z));const{inProgress:$,...F}=Q,q={...F,toPosition:Q.toHandle?Q.toPosition:null};g==null||g(H,q),a&&(N==null||N(H,q))}v(),cancelAnimationFrame(I),L=!1,U=!1,z=null,W=null,k.removeEventListener("mousemove",V),k.removeEventListener("mouseup",G),k.removeEventListener("touchmove",V),k.removeEventListener("touchend",G)}}k.addEventListener("mousemove",V),k.addEventListener("mouseup",G),k.addEventListener("touchmove",V),k.addEventListener("touchend",G)}function _t(e,{handle:n,connectionMode:i,fromNodeId:o,fromHandleId:s,fromType:a,doc:l,lib:r,flowId:d,isValidConnection:u=Dt,nodeLookup:m}){const c=a==="target",b=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:v,y:h}=Oe(e),p=l.elementFromPoint(v,h),g=p!=null&&p.classList.contains(`${r}-flow__handle`)?p:b,f={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){const N=It(void 0,g),y=g.getAttribute("data-nodeid"),S=g.getAttribute("data-handleid"),w=g.classList.contains("connectable"),A=g.classList.contains("connectableend");if(!y||!N)return f;const C={source:c?y:o,sourceHandle:c?S:s,target:c?o:y,targetHandle:c?s:S};f.connection=C;const k=w&&A&&(i===gn.Strict?c&&N==="source"||!c&&N==="target":y!==o||S!==s);f.isValid=k&&u(C),f.toHandle=Bt(y,N,S,m,i,!0)}return f}const os={onPointerDown:yh,isValid:_t};function xh({domNode:e,panZoom:n,getTransform:i,getViewScale:o}){const s=Pe(e);function a({translateExtent:r,width:d,height:u,zoomStep:m=1,pannable:c=!0,zoomable:b=!0,inversePan:v=!1}){const h=y=>{if(y.sourceEvent.type!=="wheel"||!n)return;const S=i(),w=y.sourceEvent.ctrlKey&&Xn()?10:1,A=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*m,C=S[2]*Math.pow(2,A*w);n.scaleTo(C)};let p=[0,0];const g=y=>{var S,w;(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(p=[(S=y.sourceEvent.clientX)!=null?S:y.sourceEvent.touches[0].clientX,(w=y.sourceEvent.clientY)!=null?w:y.sourceEvent.touches[0].clientY])},f=y=>{var I,P;const S=i();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!n)return;const w=[(I=y.sourceEvent.clientX)!=null?I:y.sourceEvent.touches[0].clientX,(P=y.sourceEvent.clientY)!=null?P:y.sourceEvent.touches[0].clientY],A=[w[0]-p[0],w[1]-p[1]];p=w;const C=o()*Math.max(S[2],Math.log(S[2]))*(v?-1:1),E={x:S[0]-A[0]*C,y:S[1]-A[1]*C},k=[[0,0],[d,u]];n.setViewportConstrained({x:E.x,y:E.y,zoom:S[2]},k,r)},N=Ja().on("start",g).on("zoom",c?f:null).on("zoom.wheel",b?h:null);s.call(N,{})}function l(){s.on("zoom",null)}return{update:a,destroy:l,pointer:Be}}const Oi=e=>({x:e.x,y:e.y,zoom:e.k}),ss=({x:e,y:n,zoom:i})=>Pi.translate(e,n).scale(i),Nn=(e,n)=>e.target.closest(`.${n}`),Ot=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Sh=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,as=(e,n=0,i=Sh,o=()=>{})=>{const s=typeof n=="number"&&n>0;return s||o(),s?e.transition().duration(n).ease(i).on("end",o):e},Kt=e=>{const n=e.ctrlKey&&Xn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function wh({zoomPanValues:e,noWheelClassName:n,d3Selection:i,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:l,onPanZoomStart:r,onPanZoom:d,onPanZoomEnd:u}){return m=>{if(Nn(m,n))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const c=i.property("__zoom").k||1;if(m.ctrlKey&&l){const g=Be(m),f=Kt(m),N=c*Math.pow(2,f);o.scaleTo(i,N,g,m);return}const b=m.deltaMode===1?20:1;let v=s===on.Vertical?0:m.deltaX*b,h=s===on.Horizontal?0:m.deltaY*b;!Xn()&&m.shiftKey&&s!==on.Vertical&&(v=m.deltaY*b,h=0),o.translateBy(i,-(v/c)*a,-(h/c)*a,{internal:!0});const p=Oi(i.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d==null||d(m,p),e.panScrollTimeout=setTimeout(()=>{u==null||u(m,p),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,r==null||r(m,p))}}function Nh({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:i}){return function(o,s){const a=o.type==="wheel",l=!n&&a&&!o.ctrlKey,r=Nn(o,e);if(o.ctrlKey&&a&&r&&o.preventDefault(),l||r)return null;o.preventDefault(),i.call(this,o,s)}}function Ah({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:i}){return o=>{var a,l,r;if((a=o.sourceEvent)!=null&&a.internal)return;const s=Oi(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 Ch({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:i,onTransformChange:o,onPanZoom:s}){return a=>{var l,r,d;e.usedRightMouseButton=!!(i&&Ot(n,(l=e.mouseButton)!=null?l:0)),(r=a.sourceEvent)!=null&&r.sync||o([a.transform.x,a.transform.y,a.transform.k]),s&&!((d=a.sourceEvent)!=null&&d.internal)&&(s==null||s(a.sourceEvent,Oi(a.transform)))}}function kh({zoomPanValues:e,panOnDrag:n,panOnScroll:i,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:a}){return l=>{var r,d;if(!((r=l.sourceEvent)!=null&&r.internal)&&(e.isZoomingOrPanning=!1,a&&Ot(n,(d=e.mouseButton)!=null?d:0)&&!e.usedRightMouseButton&&l.sourceEvent&&a(l.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const u=Oi(l.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(l.sourceEvent,u)},i?150:0)}}}function Mh({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:i,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:l,noWheelClassName:r,noPanClassName:d,lib:u,connectionInProgress:m}){return c=>{var g;const b=e||n,v=i&&c.ctrlKey,h=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(Nn(c,`${u}-flow__node`)||Nn(c,`${u}-flow__edge`)))return!0;if(!o&&!b&&!s&&!a&&!i||l||m&&!h||Nn(c,r)&&h||Nn(c,d)&&(!h||s&&h&&!e)||!i&&c.ctrlKey&&h)return!1;if(!i&&c.type==="touchstart"&&((g=c.touches)==null?void 0:g.length)>1)return c.preventDefault(),!1;if(!b&&!s&&!v&&h||!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||h)&&p}}function Eh({domNode:e,minZoom:n,maxZoom:i,translateExtent:o,viewport:s,onPanZoom:a,onPanZoomStart:l,onPanZoomEnd:r,onDraggingChange:d}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),c=Ja().scaleExtent([n,i]).translateExtent(o),b=Pe(e).call(c);N({x:s.x,y:s.y,zoom:xn(s.zoom,n,i)},[[0,0],[m.width,m.height]],o);const v=b.on("wheel.zoom"),h=b.on("dblclick.zoom");c.wheelDelta(Kt);async function p(P,T){return b?new Promise(O=>{c==null||c.interpolate((T==null?void 0:T.interpolate)==="linear"?Hn:xi).transform(as(b,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>O(!0)),P)}):!1}function g({noWheelClassName:P,noPanClassName:T,onPaneContextMenu:O,userSelectionActive:M,panOnScroll:_,panOnDrag:B,panOnScrollMode:K,panOnScrollSpeed:D,preventScrolling:L,zoomOnPinch:z,zoomOnScroll:U,zoomOnDoubleClick:W,zoomActivationKeyPressed:Y,lib:X,onTransformChange:ie,connectionInProgress:se,paneClickDistance:Q,selectionOnDrag:j}){M&&!u.isZoomingOrPanning&&f();const V=_&&!Y&&!M;c.clickDistance(j?1/0:!_e(Q)||Q<0?0:Q);const G=V?wh({zoomPanValues:u,noWheelClassName:P,d3Selection:b,d3Zoom:c,panOnScrollMode:K,panOnScrollSpeed:D,zoomOnPinch:z,onPanZoomStart:l,onPanZoom:a,onPanZoomEnd:r}):Nh({noWheelClassName:P,preventScrolling:L,d3ZoomHandler:v});b.on("wheel.zoom",G,{passive:!1});const H=Ah({zoomPanValues:u,onDraggingChange:d,onPanZoomStart:l});c.on("start",H);const $=Ch({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!O,onPanZoom:a,onTransformChange:ie});c.on("zoom",$);const F=kh({zoomPanValues:u,panOnDrag:B,panOnScroll:_,onPaneContextMenu:O,onPanZoomEnd:r,onDraggingChange:d});c.on("end",F);const q=Mh({zoomActivationKeyPressed:Y,panOnDrag:B,zoomOnScroll:U,panOnScroll:_,zoomOnDoubleClick:W,zoomOnPinch:z,userSelectionActive:M,noPanClassName:T,noWheelClassName:P,lib:X,connectionInProgress:se});c.filter(q),W?b.on("dblclick.zoom",h):b.on("dblclick.zoom",null)}function f(){c.on("zoom",null)}async function N(P,T,O){const M=ss(P),_=c==null?void 0:c.constrain()(M,T,O);return _&&await p(_),_}async function y(P,T){const O=ss(P);return await p(O,T),O}function S(P){if(b){const T=ss(P),O=b.property("__zoom");(O.k!==P.zoom||O.x!==P.x||O.y!==P.y)&&(c==null||c.transform(b,T,null,{sync:!0}))}}function w(){const P=b?qa(b.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}async function A(P,T){return b?new Promise(O=>{c==null||c.interpolate((T==null?void 0:T.interpolate)==="linear"?Hn:xi).scaleTo(as(b,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>O(!0)),P)}):!1}async function C(P,T){return b?new Promise(O=>{c==null||c.interpolate((T==null?void 0:T.interpolate)==="linear"?Hn:xi).scaleBy(as(b,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>O(!0)),P)}):!1}function E(P){c==null||c.scaleExtent(P)}function k(P){c==null||c.translateExtent(P)}function I(P){const T=!_e(P)||P<0?0:P;c==null||c.clickDistance(T)}return{update:g,destroy:f,setViewport:y,setViewportConstrained:N,getViewport:w,scaleTo:A,scaleBy:C,setScaleExtent:E,setTranslateExtent:k,syncViewport:S,setClickDistance:I}}var An;(function(e){e.Line="line",e.Handle="handle"})(An||(An={}));function Th({width:e,prevWidth:n,height:i,prevHeight:o,affectsX:s,affectsY:a}){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&&a&&(d[1]=d[1]*-1),d}function Ht(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 Ye(e,n){return Math.max(0,n-e)}function Je(e,n){return Math.max(0,e-n)}function Ki(e,n,i){return Math.max(0,n-e,e-i)}function Gt(e,n){return e?!n:n}function Ph(e,n,i,o,s,a,l,r){let{affectsX:d,affectsY:u}=n;const{isHorizontal:m,isVertical:c}=n,b=m&&c,{xSnapped:v,ySnapped:h}=i,{minWidth:p,maxWidth:g,minHeight:f,maxHeight:N}=o,{x:y,y:S,width:w,height:A,aspectRatio:C}=e;let E=Math.floor(m?v-e.pointerX:0),k=Math.floor(c?h-e.pointerY:0);const I=w+(d?-E:E),P=A+(u?-k:k),T=-a[0]*w,O=-a[1]*A;let M=Ki(I,p,g),_=Ki(P,f,N);if(l){let D=0,L=0;d&&E<0?D=Ye(y+E+T,l[0][0]):!d&&E>0&&(D=Je(y+I+T,l[1][0])),u&&k<0?L=Ye(S+k+O,l[0][1]):!u&&k>0&&(L=Je(S+P+O,l[1][1])),M=Math.max(M,D),_=Math.max(_,L)}if(r){let D=0,L=0;d&&E>0?D=Je(y+E,r[0][0]):!d&&E<0&&(D=Ye(y+I,r[1][0])),u&&k>0?L=Je(S+k,r[0][1]):!u&&k<0&&(L=Ye(S+P,r[1][1])),M=Math.max(M,D),_=Math.max(_,L)}if(s){if(m){const D=Ki(I/C,f,N)*C;if(M=Math.max(M,D),l){let L=0;!d&&!u||d&&!u&&b?L=Je(S+O+I/C,l[1][1])*C:L=Ye(S+O+(d?E:-E)/C,l[0][1])*C,M=Math.max(M,L)}if(r){let L=0;!d&&!u||d&&!u&&b?L=Ye(S+I/C,r[1][1])*C:L=Je(S+(d?E:-E)/C,r[0][1])*C,M=Math.max(M,L)}}if(c){const D=Ki(P*C,p,g)/C;if(_=Math.max(_,D),l){let L=0;!d&&!u||u&&!d&&b?L=Je(y+P*C+T,l[1][0])/C:L=Ye(y+(u?k:-k)*C+T,l[0][0])/C,_=Math.max(_,L)}if(r){let L=0;!d&&!u||u&&!d&&b?L=Ye(y+P*C,r[1][0])/C:L=Je(y+(u?k:-k)*C,r[0][0])/C,_=Math.max(_,L)}}}k=k+(k<0?_:-_),E=E+(E<0?M:-M),s&&(b?I>P*C?k=(Gt(d,u)?-E:E)/C:E=(Gt(d,u)?-k:k)*C:m?(k=E/C,u=d):(E=k*C,d=u));const B=d?y+E:y,K=u?S+k:S;return{width:w+(d?-E:E),height:A+(u?-k:k),x:a[0]*E*(d?-1:1)+B,y:a[1]*k*(u?-1:1)+K}}const Ft={width:0,height:0,x:0,y:0},Lh={...Ft,pointerX:0,pointerY:0,aspectRatio:1};function Bh(e,n,i){var u,m;const o=n.position.x+e.position.x,s=n.position.y+e.position.y,a=(u=e.measured.width)!=null?u:0,l=(m=e.measured.height)!=null?m:0,r=i[0]*a,d=i[1]*l;return[[o-r,s-d],[o+a-r,s+l-d]]}function Ih({domNode:e,nodeId:n,getStoreItems:i,onChange:o,onEnd:s}){const a=Pe(e);let l={controlDirection:Ht("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:m,keepAspectRatio:c,resizeDirection:b,onResizeStart:v,onResize:h,onResizeEnd:p,shouldResize:g}){let f={...Ft},N={...Lh};l={boundaries:m,resizeDirection:b,keepAspectRatio:c,controlDirection:Ht(u)};let y,S=null,w=[],A,C,E,k=!1;const I=ya().on("start",P=>{var z,U,W,Y,X,ie;const{nodeLookup:T,transform:O,snapGrid:M,snapToGrid:_,nodeOrigin:B,paneDomNode:K}=i();if(y=T.get(n),!y)return;S=(z=K==null?void 0:K.getBoundingClientRect())!=null?z:null;const{xSnapped:D,ySnapped:L}=Qn(P.sourceEvent,{transform:O,snapGrid:M,snapToGrid:_,containerBounds:S});f={width:(U=y.measured.width)!=null?U:0,height:(W=y.measured.height)!=null?W:0,x:(Y=y.position.x)!=null?Y:0,y:(X=y.position.y)!=null?X:0},N={...f,pointerX:D,pointerY:L,aspectRatio:f.width/f.height},A=void 0,C=an(y.extent)?y.extent:void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(A=T.get(y.parentId)),A&&y.extent==="parent"&&(C=[[0,0],[A.measured.width,A.measured.height]]),w=[],E=void 0;for(const[se,Q]of T)if(Q.parentId===n&&(w.push({id:se,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const j=Bh(Q,y,(ie=Q.origin)!=null?ie:B);E?E=[[Math.min(j[0][0],E[0][0]),Math.min(j[0][1],E[0][1])],[Math.max(j[1][0],E[1][0]),Math.max(j[1][1],E[1][1])]]:E=j}v==null||v(P,{...f})}).on("drag",P=>{var R,Z,J;const{transform:T,snapGrid:O,snapToGrid:M,nodeOrigin:_}=i(),B=Qn(P.sourceEvent,{transform:T,snapGrid:O,snapToGrid:M,containerBounds:S}),K=[];if(!y)return;const{x:D,y:L,width:z,height:U}=f,W={},Y=(R=y.origin)!=null?R:_,{width:X,height:ie,x:se,y:Q}=Ph(N,l.controlDirection,B,l.boundaries,l.keepAspectRatio,Y,C,E),j=X!==z,V=ie!==U,G=se!==D&&j,H=Q!==L&&V;if(!G&&!H&&!j&&!V)return;if((G||H||Y[0]===1||Y[1]===1)&&(W.x=G?se:f.x,W.y=H?Q:f.y,f.x=W.x,f.y=W.y,w.length>0)){const ee=se-D,ae=Q-L;for(const ue of w)ue.position={x:ue.position.x-ee+Y[0]*(X-z),y:ue.position.y-ae+Y[1]*(ie-U)},K.push(ue)}if((j||V)&&(W.width=j&&(!l.resizeDirection||l.resizeDirection==="horizontal")?X:f.width,W.height=V&&(!l.resizeDirection||l.resizeDirection==="vertical")?ie:f.height,f.width=W.width,f.height=W.height),A&&y.expandParent){const ee=Y[0]*((Z=W.width)!=null?Z:0);W.x&&W.x<ee&&(f.x=ee,N.x=N.x-(W.x-ee));const ae=Y[1]*((J=W.height)!=null?J:0);W.y&&W.y<ae&&(f.y=ae,N.y=N.y-(W.y-ae))}const $=Th({width:f.width,prevWidth:z,height:f.height,prevHeight:U,affectsX:l.controlDirection.affectsX,affectsY:l.controlDirection.affectsY}),F={...f,direction:$};(g==null?void 0:g(P,F))!==!1&&(k=!0,h==null||h(P,F),o(W,K))}).on("end",P=>{k&&(p==null||p(P,{...f}),s==null||s({...f}),k=!1)});a.call(I)}function d(){a.on(".drag",null)}return{update:r,destroy:d}}function Dh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Hi={exports:{}},ts={},Gi={exports:{}},ls={};/**
30
+ active:opacity-50 element_class`,draggable:!0,children:t.jsxs("span",{className:"flex flex-col items-center justify-center w-full gap-2",children:[t.jsx("span",{style:{color:d},children:t.jsx(te,{icon:g.icon,iconClass:"w-6 h-6"})}),t.jsx("span",{style:{color:d},className:"text-xs font-medium text-center",children:g.label})]})},g.type))})]},h)})})})]})},Fu=x.memo(Gu),Ke=({text:e="",isDisabled:n=!1,isLoading:i=!1,btnClass:o="bg-primary-500 text-white",icon:s="",iconPosition:a="left",iconClass:l="text-[20px]",loadingClass:r="",link:d="",div:u=!1,type:m="button",style:c,onClick:b})=>{const v=de("btn inline-flex justify-center",{"pointer-events-none":i,"opacity-40 cursor-not-allowed":n},o),h=()=>i?t.jsxs(t.Fragment,{children:[t.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:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.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..."]}):t.jsxs("span",{className:"flex items-center",children:[s&&a==="left"&&t.jsx("span",{className:`mr-[6px] ${l}`,children:t.jsx(te,{icon:s})}),e&&t.jsx("span",{children:e}),s&&a==="right"&&t.jsx("span",{className:`ml-[6px] ${l}`,children:t.jsx(te,{icon:s})})]});return u?t.jsx("div",{className:v,children:h()}):d?t.jsx(vr.Link,{to:d,className:v,children:h()}):t.jsx("button",{disabled:n,type:m,className:v,"data-testid":"btn",onClick:b,style:c,children:h()})};function Vu(){return t.jsx("div",{children:t.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",fill:"#D5D7DA"}),t.jsx("rect",{x:"0.5",y:"0.5",width:"35",height:"35",rx:"7.5",stroke:"#E9EAEB"}),t.jsx("path",{d:"M22.5 14L14.5 22M14.5 14L22.5 22",stroke:"#414651",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const zu=({isOpen:e,onClose:n})=>{const{formData:i,uploadUrl:o}=x.useContext(Ae);if(!e)return null;const s=xe("config");return t.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:[t.jsx("button",{type:"button",onClick:n,className:"absolute text-sm top-3 right-4","aria-label":"close",children:t.jsx(Vu,{})})," ",t.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:t.jsx(wo,{form_data:i,ignoreValidation:!0,config:s,uploadUrl:o})})]})};function Wu(){return t.jsx("div",{children:t.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("rect",{width:"24",height:"24",rx:"6",fill:"currentColor"}),t.jsx("path",{d:"M14 16L10 12L14 8",stroke:"white",strokeWidth:"1.39167",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function $u({title:e,goBackUrl:n,onSubmit:i,onPublish:o,previewLoading:s,saveLoading:a,publishLoading:l,onTitleChange:r,viewMode:d,setViewMode:u,onShowVersion:m}){const{formData:c,setShowPreview:b,showPreview:v,undo:h,redo:p,canUndo:g,canRedo:f}=x.useContext(Ae),[N,y]=x.useState(!1),[S,w]=x.useState(!1),[A,C]=x.useState(e||""),E=xe("config");function k(){try{localStorage.setItem("formData",JSON.stringify(c))}catch(T){console.warn("Could not save formData to localStorage",T)}i==null||i(c)}function I(){try{localStorage.setItem("formData",JSON.stringify(c))}catch(T){console.warn("Could not save formData to localStorage",T)}o==null||o(c)}function P(){w(!1),r&&A!==e&&r(A.trim())}return t.jsxs("div",{className:"px-[30px] py-3 flex justify-between items-center bg-[#F9F9FB] top_bar border-b h-full",children:[t.jsxs("span",{className:"flex items-center gap-x-2",children:[n&&t.jsx("button",{type:"button",onClick:()=>n(),style:{color:(E==null?void 0:E.buttonColor)||"#333"},className:"flex items-center gap-x-3",children:t.jsx(Wu,{})})," ",S?t.jsx("input",{type:"text",value:A,onChange:T=>C(T.target.value),onBlur:P,autoFocus:!0,className:"w-48 px-2 py-1 text-sm font-semibold outline-gray-100 input form_title"}):t.jsx("h1",{title:"Click to edit",className:"text-base font-semibold cursor-pointer form_title",onClick:()=>w(!0),children:A||"Untitled"})]}),N&&t.jsx(zu,{isOpen:N,onClose:()=>y(!1),element:void 0}),t.jsxs("div",{className:"flex justify-end text-xs gap-x-3 items-center",children:[u&&t.jsxs("div",{className:"flex border border-gray-300 rounded-lg overflow-hidden h-[36px] text-sm font-medium shadow-sm mr-2",children:[t.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:[t.jsx(te,{icon:"mdi:view-dashboard-outline",iconClass:"text-base"})," ","Builder"]}),t.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:[t.jsx(te,{icon:"mdi:sitemap-outline",iconClass:"text-base"})," Flow"]})]}),t.jsx(Ke,{onClick:h,text:"",btnClass:`!px-2 bg-transparent undo ${g?"":"opacity-50"}`,icon:"material-symbols:undo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!g}),t.jsx(Ke,{onClick:p,text:"",btnClass:`!px-2 bg-transparent redo ${f?"":"opacity-50"}`,icon:"material-symbols:redo",iconClass:"text-xl !mr-0",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:!f}),m&&t.jsx(Ke,{onClick:m,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"}}),t.jsx(Ke,{onClick:()=>b(T=>!T),text:v?"Hide Preview":"Preview",btnClass:"px-2 bg-transparent font-medium text-sm form_preview",icon:v?"iconamoon:eye-off-duotone":"solar:eye-bold-duotone",iconClass:"text-base",style:{color:(E==null?void 0:E.buttonColor)||"#333"},isDisabled:s,isLoading:s}),t.jsx(Ke,{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:a,isLoading:a}),t.jsx(Ke,{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 ju({onSubmit:e,onChange:n,onLogAction:i,questionData:o,title:s,goBackUrl:a,loading:l,onPublish:r,previewLoading:d,saveLoading:u,publishLoading:m,onTitleChange:c,uploadUrl:b,onAddTemplate:v,templates:h,onShowVersion:p}){const[g,f]=x.useState("canvas");return t.jsxs(xs,{onChange:n,onLogAction:i,children:[t.jsx(Ee.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),t.jsx("div",{className:"w-full h-full bg-[#F8F9FC] flex flex-col",children:t.jsxs("div",{className:"flex flex-1 ",children:[g==="canvas"&&t.jsx("div",{children:t.jsx("div",{className:"w-[250px] h-screen border-r border-[#E4E7EC] bg-white ",children:t.jsx(Fu,{})})}),t.jsxs("div",{className:`flex-1 h-full max-h-full z-[1] ${g==="canvas"?"w-[calc(100%-250px)]":"w-full"}`,children:[t.jsx("div",{className:" h-[70px]",children:t.jsx($u,{title:s,goBackUrl:a,onSubmit:e,onPublish:r,previewLoading:d,saveLoading:u,publishLoading:m,onTitleChange:c,viewMode:g,setViewMode:f,onShowVersion:p})}),t.jsx("div",{className:"p-6 h-[calc(100vh-70px)]",children:l?t.jsx(go,{loadingClass:"!w-full !h-[800px]"}):t.jsx(Hu,{questionData:o,uploadUrl:b,onAddTemplate:v,templates:h,viewMode:g})})]})]})})]})}const Uu=({onSubmit:e,onChange:n,onLogAction:i,questionData:o,isReadOnly:s,config:a={buttonColor:"#333"},title:l,loading:r,goBackUrl:d,onPublish:u,previewLoading:m,saveLoading:c,publishLoading:b,onTitleChange:v,uploadUrl:h,onAddTemplate:p,templates:g,onShowVersion:f})=>(x.useEffect(()=>{a&&Ys("config",a)},[a]),t.jsx(ju,{onSubmit:e,onChange:n,onLogAction:i,onPublish:u,questionData:o,isReadOnly:s,title:l,goBackUrl:d,loading:r,previewLoading:m,saveLoading:c,publishLoading:b,onTitleChange:v,uploadUrl:h,onAddTemplate:p,templates:g,onShowVersion:f})),Ue={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}`},qu=(e,n=!1)=>({textField:ne.string().nullable(),longText:ne.string().nullable(),numberField:ne.number().nullable().transform(o=>isNaN(o)?null:o),amountField:ne.number().nullable().transform(o=>isNaN(o)?null:o),selectField:ne.string().nullable(),checkbox:ne.mixed().nullable(),radio:ne.mixed().nullable(),matrix:ne.mixed().nullable(),email:ne.string().nullable().test("email-format",Ue.email,o=>!o||o.trim()===""?!0:/^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/.test(o)),date:ne.date().nullable().transform((o,s)=>n&&s===""?null:o).typeError("Invalid date"),url:ne.string().nullable().test("url-format",Ue.url,o=>!o||o.trim()===""?!0:/^(https?:\/\/)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/.*)?$/.test(o))})[e]||ne.mixed().nullable(),Yu=(e,n,i)=>n?e.type==="boolean"?e.oneOf([!0],i||Ue.required):e.required(i||Ue.required):e,Ju=(e,{minLength:n,maxLength:i,minLengthMessage:o,maxLengthMessage:s})=>{let a=e;return n&&(a=a.min(n,o||Ue.minLength(n))),i&&(a=a.max(i,s||Ue.maxLength(i))),a},Zu=(e,{minAmount:n,maxAmount:i,minAmountMessage:o,maxAmountMessage:s})=>{let a=e;return n&&(a=a.min(parseFloat(String(n)),o||Ue.minAmount(n))),i&&(a=a.max(parseFloat(String(i)),s||Ue.maxAmount(i))),a},xo=(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],a=o.fieldValue,l=s;switch(o.operator){case"equals":return String(a).toLowerCase()===String(l).toLowerCase();case"not_equals":return String(a).toLowerCase()!==String(l).toLowerCase();case"greater":return Number(l)>Number(a);case"less":return Number(l)<Number(a);case"contains":return String(l).toLowerCase().includes(String(a).toLowerCase());case"not_contains":return!String(l).toLowerCase().includes(String(a).toLowerCase());default:return!0}}):!0};function Xu({formData:e,isReadOnly:n,answerData:i}){const o={};return e.forEach(({questionData:s})=>{s==null||s.forEach(a=>{if(!xo(a,i))return;const{id:l,type:r,isRequired:d,requiredMessage:u,isDisabled:m}=a;let c=qu(r,n);c=Yu(c,m||n?!1:d,u),r==="textField"||r==="longText"||r==="email"||r==="url"?c=Ju(c,a):(r==="numberField"||r==="amountField")&&(c=Zu(c,a)),o[l]=c})}),ne.object().shape(o)}const mn=({element:e,validationData:n})=>{const i=na[e.type],{answerData:o}=x.useContext(Ae),s=x.useMemo(()=>{var l;return(l=e==null?void 0:e.acceptedFiles)==null?void 0:l.map(r=>r.label).join(", ")},[e]),a=x.useMemo(()=>xo(e,o),[o,e]);return i?t.jsxs("div",{className:`${a?"":"hidden"} min-w-0 w-full`,children:[t.jsx("div",{className:"mb-1.5 min-w-0",children:e.inputLabel&&t.jsxs("label",{className:"block text-sm font-medium input_label",children:[e.inputLabel," ",s&&t.jsxs("span",{className:"text-gray-400 text-xs",children:["(",s==null?void 0:s.toLowerCase(),")"]})]})}),t.jsx(i,{element:e,state:"edit",validationData:{...n,isReadOnly:n.isReadOnly||e.isDisabled}}),e.description&&t.jsx("small",{className:"block text-gray-400 mt-0.5 text-xs",children:e.description})]}):null},bn=(e,n)=>e!=null&&e.allowEdit?{...n,isReadOnly:!1}:n;function Qu({form_data:e,options:n}){const i=(s,a)=>t.jsx("div",{className:"min-w-0",children:t.jsx(ri,{element:s,customClass:"p-0 min-h-[60px] border-none",children:a==null?void 0:a.map(l=>{var r,d,u;return t.jsxs(li,{col:(r=l.gridPosition)==null?void 0:r.col,customClass:"p-0",children:[t.jsx(mn,{element:l,validationData:bn(l,n)}),((u=(d=n==null?void 0:n.errors)==null?void 0:d[l.id])==null?void 0:u.message)&&t.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[l.id].message})]},l.id)})})},s.id),o=s=>{var a,l;return t.jsxs("div",{className:de("group relative grid gap-y-[6px] min-w-0",s.elementClass),children:[t.jsx(mn,{element:s,validationData:bn(s,n)}),((l=(a=n==null?void 0:n.errors)==null?void 0:a[s.id])==null?void 0:l.message)&&t.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[s.id].message})]},s.id)};return t.jsx("div",{className:"grid gap-y-10",children:e==null?void 0:e.map(s=>{var l,r;const a=new Map;return(l=s==null?void 0:s.questionData)==null||l.forEach(d=>{d.gridId&&(a.has(d.gridId)||a.set(d.gridId,[]),a.get(d.gridId).push(d))}),t.jsxs("div",{className:"pb-6 section_box min-w-0",children:[(s.title||s.description)&&t.jsxs("div",{className:"py-4 border-b border-gray-100 mb-7 section_box__title",children:[s.title&&t.jsx("h2",{className:"text-lg font-semibold mb-[4px]",children:s.title}),s.description&&t.jsx("p",{className:"text-sm",children:s.description})]}),t.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,a.get(d.id)||[]):o(d))})]},s.id)})})}function Ru({form_data:e,options:n,current:i}){var o,s;return t.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(a=>{var l,r,d,u;if(a.type==="grid"){const m=(r=(l=e[i])==null?void 0:l.questionData)==null?void 0:r.filter(c=>c.gridId===a.id);return t.jsx("div",{className:"min-w-0",children:t.jsx(ri,{element:a,customClass:"p-0 min-h-[60px] border-none",children:m==null?void 0:m.map(c=>{var b,v,h;return t.jsxs(li,{col:(b=c.gridPosition)==null?void 0:b.col,customClass:"p-0",children:[t.jsx(mn,{element:c,validationData:bn(c,n)}),t.jsx("div",{className:"mt-1 text-xs text-red-600",children:(h=(v=n==null?void 0:n.errors)==null?void 0:v[c.id])==null?void 0:h.message})]},c.id)})})},a.id)}return a.gridId?null:t.jsxs("div",{className:de("group relative grid gap-y-[6px] min-w-0",a.elementClass),children:[t.jsx(mn,{element:a,validationData:bn(a,n)}),t.jsx("div",{className:"mt-1 text-xs text-red-600",children:(u=(d=n==null?void 0:n.errors)==null?void 0:d[a.id])==null?void 0:u.message})]},a.id)})})}const So=xe("config");function ec({element:e,options:n,onNext:i,onPrev:o,isFirst:s,isLast:a,isReadOnly:l}){if(!e)return t.jsx("div",{className:"flex items-center justify-center min-h-[500px] text-gray-500",children:"No questions available."});const r=m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),i())},d=m=>{var c;return t.jsx("div",{className:"min-w-0 w-full",children:t.jsx(ri,{element:m,customClass:"p-0 min-h-[60px] border-none w-full",children:(c=m.gridChildren)==null?void 0:c.map(b=>{var v,h,p;return t.jsxs(li,{col:(v=b.gridPosition)==null?void 0:v.col,customClass:"p-0",children:[t.jsx(mn,{element:b,validationData:bn(b,n)}),((p=(h=n==null?void 0:n.errors)==null?void 0:h[b.id])==null?void 0:p.message)&&t.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[b.id].message})]},b.id)})})},m.id)},u=m=>{var c,b;return t.jsxs("div",{className:de("group relative grid gap-y-[6px] min-w-0 w-full",m.elementClass),children:[t.jsx(mn,{element:m,validationData:bn(m,n)}),((b=(c=n==null?void 0:n.errors)==null?void 0:c[m.id])==null?void 0:b.message)&&t.jsx("div",{className:"mt-1 text-xs text-red-600",children:n.errors[m.id].message})]},m.id)};return t.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:t.jsxs(re.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:[t.jsx("div",{className:"text-left w-full mb-8",children:e.type==="grid"?d(e):u(e)}),!l&&t.jsxs("div",{className:"flex items-center gap-4 mt-8",children:[t.jsx(Ke,{type:"button",text:a?n!=null&&n.isSubmitting?"Submitting...":"Submit":"OK",onClick:i,style:{background:(So==null?void 0:So.buttonColor)||"#333"},btnClass:`text-gray-700 border-[#98A2B3] !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg ${a?"submit_btn":"continue_btn next_btn text-sm"}`,isDisabled:(n==null?void 0:n.apiActivityCount)>0||a&&(n==null?void 0:n.isSubmitting)}),!a&&t.jsx("span",{className:"text-xs text-gray-400 font-medium hidden sm:inline-block",children:"press Enter ↵"}),!s&&t.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:[t.jsx(te,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]})]},e.id)})}function nc(e){return e.reduce((n,i)=>(n[i.id]=i.value,n),{})}const ic=({form_data:e,answerData:n=[],ignoreValidation:i=!1,onSubmitData:o,onGetValues:s,isReadOnly:a=!1,renderType:l="multi",children:r,hideFooter:d=!1,uploadUrl:u})=>{var se,Q,j,V,G,H,$,F,q,R;const{setAnswerData:m,setUploadUrl:c,apiActivityCount:b}=x.useContext(Ae),[v,h]=x.useState(0),[p,g]=x.useState(0),f=x.useMemo(()=>e.filter(Z=>!Z.isHidden).map(Z=>{var ee;return Z.isDisabled||Z.disabled?{...Z,questionData:(ee=Z==null?void 0:Z.questionData)==null?void 0:ee.map(ae=>({...ae,isDisabled:!0}))}:Z}),[e]),N=(se=f==null?void 0:f.length)!=null?se:0,y=xe("config"),S=x.useCallback(async(Z,J,ee)=>{const ae=Xu({formData:f,isReadOnly:a,answerData:Z});return ro(ae)(Z,J,ee)},[f,a]),w=Ve.useForm({resolver:S,mode:"onSubmit",defaultValues:{}}),{register:A,setValue:C,control:E,handleSubmit:k,reset:I,getValues:P,watch:T,formState:{errors:O,isSubmitting:M},trigger:_,setError:B,clearErrors:K}=w,D=Ve.useWatch({control:E}),L=x.useMemo(()=>D,[JSON.stringify(D)]),z=x.useMemo(()=>{if(l!=="conversational")return[];const Z=[];return f.forEach(J=>{var ee;(ee=J==null?void 0:J.questionData)==null||ee.forEach(ae=>{var ue;if(xo(ae,L))if(ae.type==="grid"){const me=(ue=J==null?void 0:J.questionData)==null?void 0:ue.filter(ye=>ye.gridId===ae.id);Z.push({...ae,gridChildren:me})}else ae.gridId||Z.push(ae)})}),Z},[f,L,l]),U=x.useCallback(Z=>{s&&s(Z)},[s]);x.useEffect(()=>{c(u)},[c,u]),x.useEffect(()=>{if(!(f!=null&&f.length)||!s)return;const Z=f.flatMap(J=>{var ee;return(ee=J==null?void 0:J.questionData)==null?void 0:ee.map(ae=>({id:ae.id,value:L[ae.id]||"",sectionId:J.id,type:ae.type,metaData:{prefix:ae.prefix,dateFormat:ae.dateFormat}}))});U(Z),m(L)},[L,f,U,s,m]),x.useEffect(()=>{n!=null&&n.length&&I(nc(n))},[n,I]);const W=x.useCallback(Z=>{const J=f.flatMap(ee=>{var ae;return(ae=ee==null?void 0:ee.questionData)==null?void 0:ae.map(ue=>({id:ue.id,value:Z[ue.id]||"",sectionId:ee.id,type:ue.type,metaData:{prefix:ue.prefix,dateFormat:ue.dateFormat}}))});Object.keys(O).length>0||o==null||o(J)},[O,f,o]),Y=x.useCallback(async()=>{var Z,J;if(l==="conversational"){if(!i){const ee=z[p];if(!ee)return;const ae=ee.gridChildren?ee.gridChildren.map(me=>me.id):[ee.id];if(!await _(ae))return}p<z.length-1?g(ee=>ee+1):k(W)();return}if(!i){const ee=(J=(Z=f==null?void 0:f[v])==null?void 0:Z.questionData)==null?void 0:J.map(ue=>ue.id);if(!await _(ee))return}h(ee=>ee+1)},[v,p,z,f,i,_,l,k,W]),X=x.useCallback(()=>{if(l==="conversational"){g(Z=>Math.max(0,Z-1));return}h(Z=>Z-1)},[l]),ie=x.useMemo(()=>({register:A,setValue:C,watch:T,errors:O,trigger:_,isSubmitting:M,isReadOnly:a,getValues:P,setError:B,clearErrors:K,apiActivityCount:b}),[A,C,T,O,_,M,a,P,B,K,b]);return t.jsxs(Ve.FormProvider,{...w,children:[t.jsx(Ee.Toaster,{position:"top-right",richColors:!0,closeButton:!0}),t.jsxs("form",{onSubmit:k(W),className:"container h-full mx-auto",children:[t.jsx("div",{className:"relative flex flex-col w-full min-w-0 py-4 gap-y-12",children:t.jsxs("div",{className:"multi_section__box min-w-0",children:[l==="multi"&&(((Q=f==null?void 0:f[v])==null?void 0:Q.title)||((j=f==null?void 0:f[v])==null?void 0:j.description))&&t.jsxs("div",{className:"py-4 mb-4 border-b border-gray-100 multi_section__title",children:[((V=f[v])==null?void 0:V.title)&&t.jsx("h2",{className:"text-lg font-semibold mb-[6px]",children:(G=f[v])==null?void 0:G.title}),((H=f[v])==null?void 0:H.description)&&t.jsx("p",{className:"text-sm",children:($=f[v])==null?void 0:$.description})]}),l==="multi"?t.jsx(Ru,{form_data:f,options:ie,current:v}):l==="conversational"?t.jsx(ec,{element:z[p],options:ie,onNext:Y,onPrev:X,isFirst:p===0,isLast:p===z.length-1,isReadOnly:a}):t.jsx(Qu,{form_data:f,options:ie})]},l==="conversational"?`conv-${p}`:(F=f==null?void 0:f[v])==null?void 0:F.id)}),!d&&l!=="conversational"&&t.jsx("footer",{className:"flex items-center justify-end gap-4 footer flex-wrap",children:l==="multi"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex gap-x-4 justify-between navigation_container w-full",children:[t.jsxs("div",{children:[" ",v>0&&t.jsxs("button",{type:"button",onClick:X,className:"text-gray-400 hover:text-gray-600 font-medium text-sm flex items-center gap-1 transition-colors back_btn",children:[t.jsx(te,{icon:"material-symbols:arrow-upward-rounded",iconClass:"text-lg"}),"Back"]})]}),v<N-1&&t.jsx(Ke,{type:"button",text:"Next",onClick:Y,style:{background:(y==null?void 0:y.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"})]}),(v===N-1||a)&&!i&&((q=typeof r=="function"?r({isUploading:b>0,isSubmitting:M,hasErrors:Object.keys(O).length>0}):r)!=null?q:t.jsx(Ke,{isDisabled:M||Object.keys(O).length>0||b>0,isLoading:M,type:"submit",text:"Submit",style:{background:(y==null?void 0:y.buttonColor)||"#333"},btnClass:"text-gray-700 border-[#98A2B3] submit_btn !font-medium !py-[10px] px-10 bg-blue-600 text-white rounded-lg submit_btn"}))]}):!i&&((R=typeof r=="function"?r({isUploading:b>0,isSubmitting:M,hasErrors:Object.keys(O).length>0}):r)!=null?R:t.jsx(Ke,{isDisabled:M||Object.keys(O).length>0||b>0,isLoading:M,type:"submit",text:"Submit",style:{background:(y==null?void 0:y.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"&&z.length>0&&t.jsx("div",{className:"fixed bottom-0 left-0 w-full h-1.5 bg-gray-200",children:t.jsx("div",{className:"h-full bg-blue-600 transition-all duration-500 ease-out",style:{width:`${(p+1)/z.length*100}%`,background:(y==null?void 0:y.buttonColor)||"#2563EB"}})})]})]})},oc=x.memo(ic);function wo({answerData:e,form_data:n,ignoreValidation:i,onSubmit:o,isReadOnly:s=!1,loading:a=!1,config:l={buttonColor:"#333"},renderType:r,children:d,hideFooter:u,onGetValues:m,uploadUrl:c}){x.useEffect(()=>{l&&Ys("config",l)},[l]);const b=x.useCallback(v=>{m&&m(v)},[m]);return a?t.jsx(go,{}):n?t.jsxs("div",{className:"w-full h-full min-w-0",children:[t.jsx("div",{id:"root-portal"}),t.jsx(xs,{children:t.jsx(oc,{form_data:n,answerData:e,ignoreValidation:i,onSubmitData:o,isReadOnly:s,renderType:r,hideFooter:u,onGetValues:b,uploadUrl:c,children:d})})]}):t.jsx("div",{children:t.jsx("p",{className:"p-6 text-sm text-gray-400",children:"Error: No form data available."})})}function Se(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=Se(e[i]))!==""&&(n+=(n&&" ")+o);else for(let i in e)e[i]&&(n+=(n&&" ")+i);return n}var sc={value:()=>{}};function di(){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 ui(i)}function ui(e){this._=e}function ac(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}})}ui.prototype=di.prototype={constructor:ui,on:function(e,n){var i=this._,o=ac(e+"",i),s,a=-1,l=o.length;if(arguments.length<2){for(;++a<l;)if((s=(e=o[a]).type)&&(s=tc(i[s],e.name)))return s;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++a<l;)if(s=(e=o[a]).type)i[s]=oa(i[s],e.name,n);else if(n==null)for(s in i)i[s]=oa(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 ui(e)},call:function(e,n){if((s=arguments.length-2)>0)for(var i=new Array(s),o=0,s,a;o<s;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],o=0,s=a.length;o<s;++o)a[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,a=o.length;s<a;++s)o[s].value.apply(n,i)}};function tc(e,n){for(var i=0,o=e.length,s;i<o;++i)if((s=e[i]).name===n)return s.value}function oa(e,n,i){for(var o=0,s=e.length;o<s;++o)if(e[o].name===n){e[o]=sc,e=e.slice(0,o).concat(e.slice(o+1));break}return i!=null&&e.push({name:n,value:i}),e}var No="http://www.w3.org/1999/xhtml";const sa={svg:"http://www.w3.org/2000/svg",xhtml:No,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ci(e){var n=e+="",i=n.indexOf(":");return i>=0&&(n=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),sa.hasOwnProperty(n)?{space:sa[n],local:e}:e}function lc(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===No&&n.documentElement.namespaceURI===No?n.createElement(e):n.createElementNS(i,e)}}function rc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function aa(e){var n=ci(e);return(n.local?rc:lc)(n)}function dc(){}function Ao(e){return e==null?dc:function(){return this.querySelector(e)}}function uc(e){typeof e!="function"&&(e=Ao(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var a=n[s],l=a.length,r=o[s]=new Array(l),d,u,m=0;m<l;++m)(d=a[m])&&(u=e.call(d,d.__data__,m,a))&&("__data__"in d&&(u.__data__=d.__data__),r[m]=u);return new Te(o,this._parents)}function cc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function mc(){return[]}function ta(e){return e==null?mc:function(){return this.querySelectorAll(e)}}function bc(e){return function(){return cc(e.apply(this,arguments))}}function vc(e){typeof e=="function"?e=bc(e):e=ta(e);for(var n=this._groups,i=n.length,o=[],s=[],a=0;a<i;++a)for(var l=n[a],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 Te(o,s)}function la(e){return function(){return this.matches(e)}}function ra(e){return function(n){return n.matches(e)}}var hc=Array.prototype.find;function fc(e){return function(){return hc.call(this.children,e)}}function pc(){return this.firstElementChild}function gc(e){return this.select(e==null?pc:fc(typeof e=="function"?e:ra(e)))}var yc=Array.prototype.filter;function xc(){return Array.from(this.children)}function Sc(e){return function(){return yc.call(this.children,e)}}function wc(e){return this.selectAll(e==null?xc:Sc(typeof e=="function"?e:ra(e)))}function Nc(e){typeof e!="function"&&(e=la(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var a=n[s],l=a.length,r=o[s]=[],d,u=0;u<l;++u)(d=a[u])&&e.call(d,d.__data__,u,a)&&r.push(d);return new Te(o,this._parents)}function da(e){return new Array(e.length)}function Ac(){return new Te(this._enter||this._groups.map(da),this._parents)}function mi(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}mi.prototype={constructor:mi,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 Cc(e){return function(){return e}}function kc(e,n,i,o,s,a){for(var l=0,r,d=n.length,u=a.length;l<u;++l)(r=n[l])?(r.__data__=a[l],o[l]=r):i[l]=new mi(e,a[l]);for(;l<d;++l)(r=n[l])&&(s[l]=r)}function Mc(e,n,i,o,s,a,l){var r,d,u=new Map,m=n.length,c=a.length,b=new Array(m),v;for(r=0;r<m;++r)(d=n[r])&&(b[r]=v=l.call(d,d.__data__,r,n)+"",u.has(v)?s[r]=d:u.set(v,d));for(r=0;r<c;++r)v=l.call(e,a[r],r,a)+"",(d=u.get(v))?(o[r]=d,d.__data__=a[r],u.delete(v)):i[r]=new mi(e,a[r]);for(r=0;r<m;++r)(d=n[r])&&u.get(b[r])===d&&(s[r]=d)}function Ec(e){return e.__data__}function Tc(e,n){if(!arguments.length)return Array.from(this,Ec);var i=n?Mc:kc,o=this._parents,s=this._groups;typeof e!="function"&&(e=Cc(e));for(var a=s.length,l=new Array(a),r=new Array(a),d=new Array(a),u=0;u<a;++u){var m=o[u],c=s[u],b=c.length,v=Pc(e.call(m,m&&m.__data__,u,o)),h=v.length,p=r[u]=new Array(h),g=l[u]=new Array(h),f=d[u]=new Array(b);i(m,c,p,g,f,v,n);for(var N=0,y=0,S,w;N<h;++N)if(S=p[N]){for(N>=y&&(y=N+1);!(w=g[y])&&++y<h;);S._next=w||null}}return l=new Te(l,o),l._enter=r,l._exit=d,l}function Pc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Lc(){return new Te(this._exit||this._groups.map(da),this._parents)}function Bc(e,n,i){var o=this.enter(),s=this,a=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?a.remove():i(a),o&&s?o.merge(s).order():s}function Ic(e){for(var n=e.selection?e.selection():e,i=this._groups,o=n._groups,s=i.length,a=o.length,l=Math.min(s,a),r=new Array(s),d=0;d<l;++d)for(var u=i[d],m=o[d],c=u.length,b=r[d]=new Array(c),v,h=0;h<c;++h)(v=u[h]||m[h])&&(b[h]=v);for(;d<s;++d)r[d]=i[d];return new Te(r,this._parents)}function Dc(){for(var e=this._groups,n=-1,i=e.length;++n<i;)for(var o=e[n],s=o.length-1,a=o[s],l;--s>=0;)(l=o[s])&&(a&&l.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(l,a),a=l);return this}function _c(e){e||(e=Oc);function n(c,b){return c&&b?e(c.__data__,b.__data__):!c-!b}for(var i=this._groups,o=i.length,s=new Array(o),a=0;a<o;++a){for(var l=i[a],r=l.length,d=s[a]=new Array(r),u,m=0;m<r;++m)(u=l[m])&&(d[m]=u);d.sort(n)}return new Te(s,this._parents).order()}function Oc(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function Kc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Hc(){return Array.from(this)}function Gc(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],s=0,a=o.length;s<a;++s){var l=o[s];if(l)return l}return null}function Fc(){let e=0;for(const n of this)++e;return e}function Vc(){return!this.node()}function zc(e){for(var n=this._groups,i=0,o=n.length;i<o;++i)for(var s=n[i],a=0,l=s.length,r;a<l;++a)(r=s[a])&&e.call(r,r.__data__,a,s);return this}function Wc(e){return function(){this.removeAttribute(e)}}function $c(e){return function(){this.removeAttributeNS(e.space,e.local)}}function jc(e,n){return function(){this.setAttribute(e,n)}}function Uc(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function qc(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function Yc(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 Jc(e,n){var i=ci(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?$c:Wc:typeof n=="function"?i.local?Yc:qc:i.local?Uc:jc)(i,n))}function ua(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Zc(e){return function(){this.style.removeProperty(e)}}function Xc(e,n,i){return function(){this.style.setProperty(e,n,i)}}function Qc(e,n,i){return function(){var o=n.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,i)}}function Rc(e,n,i){return arguments.length>1?this.each((n==null?Zc:typeof n=="function"?Qc:Xc)(e,n,i==null?"":i)):vn(this.node(),e)}function vn(e,n){return e.style.getPropertyValue(n)||ua(e).getComputedStyle(e,null).getPropertyValue(n)}function em(e){return function(){delete this[e]}}function nm(e,n){return function(){this[e]=n}}function im(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function om(e,n){return arguments.length>1?this.each((n==null?em:typeof n=="function"?im:nm)(e,n)):this.node()[e]}function ca(e){return e.trim().split(/^|\s+/)}function Co(e){return e.classList||new ma(e)}function ma(e){this._node=e,this._names=ca(e.getAttribute("class")||"")}ma.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 ba(e,n){for(var i=Co(e),o=-1,s=n.length;++o<s;)i.add(n[o])}function va(e,n){for(var i=Co(e),o=-1,s=n.length;++o<s;)i.remove(n[o])}function sm(e){return function(){ba(this,e)}}function am(e){return function(){va(this,e)}}function tm(e,n){return function(){(n.apply(this,arguments)?ba:va)(this,e)}}function lm(e,n){var i=ca(e+"");if(arguments.length<2){for(var o=Co(this.node()),s=-1,a=i.length;++s<a;)if(!o.contains(i[s]))return!1;return!0}return this.each((typeof n=="function"?tm:n?sm:am)(i,n))}function rm(){this.textContent=""}function dm(e){return function(){this.textContent=e}}function um(e){return function(){var n=e.apply(this,arguments);this.textContent=n==null?"":n}}function cm(e){return arguments.length?this.each(e==null?rm:(typeof e=="function"?um:dm)(e)):this.node().textContent}function mm(){this.innerHTML=""}function bm(e){return function(){this.innerHTML=e}}function vm(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n==null?"":n}}function hm(e){return arguments.length?this.each(e==null?mm:(typeof e=="function"?vm:bm)(e)):this.node().innerHTML}function fm(){this.nextSibling&&this.parentNode.appendChild(this)}function pm(){return this.each(fm)}function gm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ym(){return this.each(gm)}function xm(e){var n=typeof e=="function"?e:aa(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function Sm(){return null}function wm(e,n){var i=typeof e=="function"?e:aa(e),o=n==null?Sm:typeof n=="function"?n:Ao(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),o.apply(this,arguments)||null)})}function Nm(){var e=this.parentNode;e&&e.removeChild(this)}function Am(){return this.each(Nm)}function Cm(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function km(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function Mm(e){return this.select(e?km:Cm)}function Em(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Tm(e){return function(n){e.call(this,n,this.__data__)}}function Pm(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 Lm(e){return function(){var n=this.__on;if(n){for(var i=0,o=-1,s=n.length,a;i<s;++i)a=n[i],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):n[++o]=a;++o?n.length=o:delete this.__on}}}function Bm(e,n,i){return function(){var o=this.__on,s,a=Tm(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=a,s.options=i),s.value=n;return}}this.addEventListener(e.type,a,i),s={type:e.type,name:e.name,value:n,listener:a,options:i},o?o.push(s):this.__on=[s]}}function Im(e,n,i){var o=Pm(e+""),s,a=o.length,l;if(arguments.length<2){var r=this.node().__on;if(r){for(var d=0,u=r.length,m;d<u;++d)for(s=0,m=r[d];s<a;++s)if((l=o[s]).type===m.type&&l.name===m.name)return m.value}return}for(r=n?Bm:Lm,s=0;s<a;++s)this.each(r(o[s],n,i));return this}function ha(e,n,i){var o=ua(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 Dm(e,n){return function(){return ha(this,e,n)}}function _m(e,n){return function(){return ha(this,e,n.apply(this,arguments))}}function Om(e,n){return this.each((typeof n=="function"?_m:Dm)(e,n))}function*Km(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var o=e[n],s=0,a=o.length,l;s<a;++s)(l=o[s])&&(yield l)}var fa=[null];function Te(e,n){this._groups=e,this._parents=n}function In(){return new Te([[document.documentElement]],fa)}function Hm(){return this}Te.prototype=In.prototype={constructor:Te,select:uc,selectAll:vc,selectChild:gc,selectChildren:wc,filter:Nc,data:Tc,enter:Ac,exit:Lc,join:Bc,merge:Ic,selection:Hm,order:Dc,sort:_c,call:Kc,nodes:Hc,node:Gc,size:Fc,empty:Vc,each:zc,attr:Jc,style:Rc,property:om,classed:lm,text:cm,html:hm,raise:pm,lower:ym,append:xm,insert:wm,remove:Am,clone:Mm,datum:Em,on:Im,dispatch:Om,[Symbol.iterator]:Km};function Pe(e){return typeof e=="string"?new Te([[document.querySelector(e)]],[document.documentElement]):new Te([[e]],fa)}function Gm(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Be(e,n){if(e=Gm(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 Fm={passive:!1},Dn={capture:!0,passive:!1};function ko(e){e.stopImmediatePropagation()}function hn(e){e.preventDefault(),e.stopImmediatePropagation()}function pa(e){var n=e.document.documentElement,i=Pe(e).on("dragstart.drag",hn,Dn);"onselectstart"in n?i.on("selectstart.drag",hn,Dn):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function ga(e,n){var i=e.document.documentElement,o=Pe(e).on("dragstart.drag",null);n&&(o.on("click.drag",hn,Dn),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 bi=e=>()=>e;function Mo(e,{sourceEvent:n,subject:i,target:o,identifier:s,active:a,x:l,y:r,dx:d,dy:u,dispatch:m}){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:a,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:m}})}Mo.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Vm(e){return!e.ctrlKey&&!e.button}function zm(){return this.parentNode}function Wm(e,n){return n==null?{x:e.x,y:e.y}:n}function $m(){return navigator.maxTouchPoints||"ontouchstart"in this}function ya(){var e=Vm,n=zm,i=Wm,o=$m,s={},a=di("start","drag","end"),l=0,r,d,u,m,c=0;function b(S){S.on("mousedown.drag",v).filter(o).on("touchstart.drag",g).on("touchmove.drag",f,Fm).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(S,w){if(!(m||!e.call(this,S,w))){var A=y(this,n.call(this,S,w),S,w,"mouse");A&&(Pe(S.view).on("mousemove.drag",h,Dn).on("mouseup.drag",p,Dn),pa(S.view),ko(S),u=!1,r=S.clientX,d=S.clientY,A("start",S))}}function h(S){if(hn(S),!u){var w=S.clientX-r,A=S.clientY-d;u=w*w+A*A>c}s.mouse("drag",S)}function p(S){Pe(S.view).on("mousemove.drag mouseup.drag",null),ga(S.view,u),hn(S),s.mouse("end",S)}function g(S,w){if(e.call(this,S,w)){var A=S.changedTouches,C=n.call(this,S,w),E=A.length,k,I;for(k=0;k<E;++k)(I=y(this,C,S,w,A[k].identifier,A[k]))&&(ko(S),I("start",S,A[k]))}}function f(S){var w=S.changedTouches,A=w.length,C,E;for(C=0;C<A;++C)(E=s[w[C].identifier])&&(hn(S),E("drag",S,w[C]))}function N(S){var w=S.changedTouches,A=w.length,C,E;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),C=0;C<A;++C)(E=s[w[C].identifier])&&(ko(S),E("end",S,w[C]))}function y(S,w,A,C,E,k){var I=a.copy(),P=Be(k||A,w),T,O,M;if((M=i.call(S,new Mo("beforestart",{sourceEvent:A,target:b,identifier:E,active:l,x:P[0],y:P[1],dx:0,dy:0,dispatch:I}),C))!=null)return T=M.x-P[0]||0,O=M.y-P[1]||0,function _(B,K,D){var L=P,z;switch(B){case"start":s[E]=_,z=l++;break;case"end":delete s[E],--l;case"drag":P=Be(D||K,w),z=l;break}I.call(B,S,new Mo(B,{sourceEvent:K,subject:M,target:b,identifier:E,active:z,x:P[0]+T,y:P[1]+O,dx:P[0]-L[0],dy:P[1]-L[1],dispatch:I}),C)}}return b.filter=function(S){return arguments.length?(e=typeof S=="function"?S:bi(!!S),b):e},b.container=function(S){return arguments.length?(n=typeof S=="function"?S:bi(S),b):n},b.subject=function(S){return arguments.length?(i=typeof S=="function"?S:bi(S),b):i},b.touchable=function(S){return arguments.length?(o=typeof S=="function"?S:bi(!!S),b):o},b.on=function(){var S=a.on.apply(a,arguments);return S===a?b:S},b.clickDistance=function(S){return arguments.length?(c=(S=+S)*S,b):Math.sqrt(c)},b}function Eo(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function xa(e,n){var i=Object.create(e.prototype);for(var o in n)i[o]=n[o];return i}function _n(){}var On=.7,vi=1/On,fn="\\s*([+-]?\\d+)\\s*",Kn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",He="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",jm=/^#([0-9a-f]{3,8})$/,Um=new RegExp(`^rgb\\(${fn},${fn},${fn}\\)$`),qm=new RegExp(`^rgb\\(${He},${He},${He}\\)$`),Ym=new RegExp(`^rgba\\(${fn},${fn},${fn},${Kn}\\)$`),Jm=new RegExp(`^rgba\\(${He},${He},${He},${Kn}\\)$`),Zm=new RegExp(`^hsl\\(${Kn},${He},${He}\\)$`),Xm=new RegExp(`^hsla\\(${Kn},${He},${He},${Kn}\\)$`),Sa={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};Eo(_n,Qe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:wa,formatHex:wa,formatHex8:Qm,formatHsl:Rm,formatRgb:Na,toString:Na});function wa(){return this.rgb().formatHex()}function Qm(){return this.rgb().formatHex8()}function Rm(){return Ea(this).formatHsl()}function Na(){return this.rgb().formatRgb()}function Qe(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=jm.exec(e))?(i=n[1].length,n=parseInt(n[1],16),i===6?Aa(n):i===3?new ke(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):i===8?hi(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?hi(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=Um.exec(e))?new ke(n[1],n[2],n[3],1):(n=qm.exec(e))?new ke(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=Ym.exec(e))?hi(n[1],n[2],n[3],n[4]):(n=Jm.exec(e))?hi(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=Zm.exec(e))?Ma(n[1],n[2]/100,n[3]/100,1):(n=Xm.exec(e))?Ma(n[1],n[2]/100,n[3]/100,n[4]):Sa.hasOwnProperty(e)?Aa(Sa[e]):e==="transparent"?new ke(NaN,NaN,NaN,0):null}function Aa(e){return new ke(e>>16&255,e>>8&255,e&255,1)}function hi(e,n,i,o){return o<=0&&(e=n=i=NaN),new ke(e,n,i,o)}function eb(e){return e instanceof _n||(e=Qe(e)),e?(e=e.rgb(),new ke(e.r,e.g,e.b,e.opacity)):new ke}function To(e,n,i,o){return arguments.length===1?eb(e):new ke(e,n,i,o==null?1:o)}function ke(e,n,i,o){this.r=+e,this.g=+n,this.b=+i,this.opacity=+o}Eo(ke,To,xa(_n,{brighter(e){return e=e==null?vi:Math.pow(vi,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?On:Math.pow(On,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ke(Re(this.r),Re(this.g),Re(this.b),fi(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:Ca,formatHex:Ca,formatHex8:nb,formatRgb:ka,toString:ka}));function Ca(){return`#${en(this.r)}${en(this.g)}${en(this.b)}`}function nb(){return`#${en(this.r)}${en(this.g)}${en(this.b)}${en((isNaN(this.opacity)?1:this.opacity)*255)}`}function ka(){const e=fi(this.opacity);return`${e===1?"rgb(":"rgba("}${Re(this.r)}, ${Re(this.g)}, ${Re(this.b)}${e===1?")":`, ${e})`}`}function fi(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Re(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function en(e){return e=Re(e),(e<16?"0":"")+e.toString(16)}function Ma(e,n,i,o){return o<=0?e=n=i=NaN:i<=0||i>=1?e=n=NaN:n<=0&&(e=NaN),new Ie(e,n,i,o)}function Ea(e){if(e instanceof Ie)return new Ie(e.h,e.s,e.l,e.opacity);if(e instanceof _n||(e=Qe(e)),!e)return new Ie;if(e instanceof Ie)return e;e=e.rgb();var n=e.r/255,i=e.g/255,o=e.b/255,s=Math.min(n,i,o),a=Math.max(n,i,o),l=NaN,r=a-s,d=(a+s)/2;return r?(n===a?l=(i-o)/r+(i<o)*6:i===a?l=(o-n)/r+2:l=(n-i)/r+4,r/=d<.5?a+s:2-a-s,l*=60):r=d>0&&d<1?0:l,new Ie(l,r,d,e.opacity)}function ib(e,n,i,o){return arguments.length===1?Ea(e):new Ie(e,n,i,o==null?1:o)}function Ie(e,n,i,o){this.h=+e,this.s=+n,this.l=+i,this.opacity=+o}Eo(Ie,ib,xa(_n,{brighter(e){return e=e==null?vi:Math.pow(vi,e),new Ie(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?On:Math.pow(On,e),new Ie(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 ke(Po(e>=240?e-240:e+120,s,o),Po(e,s,o),Po(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new Ie(Ta(this.h),pi(this.s),pi(this.l),fi(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=fi(this.opacity);return`${e===1?"hsl(":"hsla("}${Ta(this.h)}, ${pi(this.s)*100}%, ${pi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ta(e){return e=(e||0)%360,e<0?e+360:e}function pi(e){return Math.max(0,Math.min(1,e||0))}function Po(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 Lo=e=>()=>e;function ob(e,n){return function(i){return e+i*n}}function sb(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 ab(e){return(e=+e)==1?Pa:function(n,i){return i-n?sb(n,i,e):Lo(isNaN(n)?i:n)}}function Pa(e,n){var i=n-e;return i?ob(e,i):Lo(isNaN(e)?n:e)}const gi=function e(n){var i=ab(n);function o(s,a){var l=i((s=To(s)).r,(a=To(a)).r),r=i(s.g,a.g),d=i(s.b,a.b),u=Pa(s.opacity,a.opacity);return function(m){return s.r=l(m),s.g=r(m),s.b=d(m),s.opacity=u(m),s+""}}return o.gamma=e,o}(1);function tb(e,n){n||(n=[]);var i=e?Math.min(n.length,e.length):0,o=n.slice(),s;return function(a){for(s=0;s<i;++s)o[s]=e[s]*(1-a)+n[s]*a;return o}}function lb(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rb(e,n){var i=n?n.length:0,o=e?Math.min(i,e.length):0,s=new Array(o),a=new Array(i),l;for(l=0;l<o;++l)s[l]=Hn(e[l],n[l]);for(;l<i;++l)a[l]=n[l];return function(r){for(l=0;l<o;++l)a[l]=s[l](r);return a}}function db(e,n){var i=new Date;return e=+e,n=+n,function(o){return i.setTime(e*(1-o)+n*o),i}}function Ge(e,n){return e=+e,n=+n,function(i){return e*(1-i)+n*i}}function ub(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]=Hn(e[s],n[s]):o[s]=n[s];return function(a){for(s in i)o[s]=i[s](a);return o}}var Bo=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Io=new RegExp(Bo.source,"g");function cb(e){return function(){return e}}function mb(e){return function(n){return e(n)+""}}function La(e,n){var i=Bo.lastIndex=Io.lastIndex=0,o,s,a,l=-1,r=[],d=[];for(e=e+"",n=n+"";(o=Bo.exec(e))&&(s=Io.exec(n));)(a=s.index)>i&&(a=n.slice(i,a),r[l]?r[l]+=a:r[++l]=a),(o=o[0])===(s=s[0])?r[l]?r[l]+=s:r[++l]=s:(r[++l]=null,d.push({i:l,x:Ge(o,s)})),i=Io.lastIndex;return i<n.length&&(a=n.slice(i),r[l]?r[l]+=a:r[++l]=a),r.length<2?d[0]?mb(d[0].x):cb(n):(n=d.length,function(u){for(var m=0,c;m<n;++m)r[(c=d[m]).i]=c.x(u);return r.join("")})}function Hn(e,n){var i=typeof n,o;return n==null||i==="boolean"?Lo(n):(i==="number"?Ge:i==="string"?(o=Qe(n))?(n=o,gi):La:n instanceof Qe?gi:n instanceof Date?db:lb(n)?tb:Array.isArray(n)?rb:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?ub:Ge)(e,n)}var Ba=180/Math.PI,Do={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ia(e,n,i,o,s,a){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:a,rotate:Math.atan2(n,e)*Ba,skewX:Math.atan(d)*Ba,scaleX:l,scaleY:r}}var yi;function bb(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Do:Ia(n.a,n.b,n.c,n.d,n.e,n.f)}function vb(e){return e==null||(yi||(yi=document.createElementNS("http://www.w3.org/2000/svg","g")),yi.setAttribute("transform",e),!(e=yi.transform.baseVal.consolidate()))?Do:(e=e.matrix,Ia(e.a,e.b,e.c,e.d,e.e,e.f))}function Da(e,n,i,o){function s(u){return u.length?u.pop()+" ":""}function a(u,m,c,b,v,h){if(u!==c||m!==b){var p=v.push("translate(",null,n,null,i);h.push({i:p-4,x:Ge(u,c)},{i:p-2,x:Ge(m,b)})}else(c||b)&&v.push("translate("+c+n+b+i)}function l(u,m,c,b){u!==m?(u-m>180?m+=360:m-u>180&&(u+=360),b.push({i:c.push(s(c)+"rotate(",null,o)-2,x:Ge(u,m)})):m&&c.push(s(c)+"rotate("+m+o)}function r(u,m,c,b){u!==m?b.push({i:c.push(s(c)+"skewX(",null,o)-2,x:Ge(u,m)}):m&&c.push(s(c)+"skewX("+m+o)}function d(u,m,c,b,v,h){if(u!==c||m!==b){var p=v.push(s(v)+"scale(",null,",",null,")");h.push({i:p-4,x:Ge(u,c)},{i:p-2,x:Ge(m,b)})}else(c!==1||b!==1)&&v.push(s(v)+"scale("+c+","+b+")")}return function(u,m){var c=[],b=[];return u=e(u),m=e(m),a(u.translateX,u.translateY,m.translateX,m.translateY,c,b),l(u.rotate,m.rotate,c,b),r(u.skewX,m.skewX,c,b),d(u.scaleX,u.scaleY,m.scaleX,m.scaleY,c,b),u=m=null,function(v){for(var h=-1,p=b.length,g;++h<p;)c[(g=b[h]).i]=g.x(v);return c.join("")}}}var hb=Da(bb,"px, ","px)","deg)"),fb=Da(vb,", ",")",")"),pb=1e-12;function _a(e){return((e=Math.exp(e))+1/e)/2}function gb(e){return((e=Math.exp(e))-1/e)/2}function yb(e){return((e=Math.exp(2*e))-1)/(e+1)}const xi=function e(n,i,o){function s(a,l){var r=a[0],d=a[1],u=a[2],m=l[0],c=l[1],b=l[2],v=m-r,h=c-d,p=v*v+h*h,g,f;if(p<pb)f=Math.log(b/u)/n,g=function(C){return[r+C*v,d+C*h,u*Math.exp(n*C*f)]};else{var N=Math.sqrt(p),y=(b*b-u*u+o*p)/(2*u*i*N),S=(b*b-u*u-o*p)/(2*b*i*N),w=Math.log(Math.sqrt(y*y+1)-y),A=Math.log(Math.sqrt(S*S+1)-S);f=(A-w)/n,g=function(C){var E=C*f,k=_a(w),I=u/(i*N)*(k*yb(n*E+w)-gb(w));return[r+I*v,d+I*h,u*k/_a(n*E+w)]}}return g.duration=f*1e3*n/Math.SQRT2,g}return s.rho=function(a){var l=Math.max(.001,+a),r=l*l,d=r*r;return e(l,r,d)},s}(Math.SQRT2,2,4);var pn=0,Gn=0,Fn=0,Oa=1e3,Si,Vn,wi=0,nn=0,Ni=0,zn=typeof performance=="object"&&performance.now?performance:Date,Ka=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function _o(){return nn||(Ka(xb),nn=zn.now()+Ni)}function xb(){nn=0}function Ai(){this._call=this._time=this._next=null}Ai.prototype=Ha.prototype={constructor:Ai,restart:function(e,n,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?_o():+i)+(n==null?0:+n),!this._next&&Vn!==this&&(Vn?Vn._next=this:Si=this,Vn=this),this._call=e,this._time=i,Oo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Oo())}};function Ha(e,n,i){var o=new Ai;return o.restart(e,n,i),o}function Sb(){_o(),++pn;for(var e=Si,n;e;)(n=nn-e._time)>=0&&e._call.call(void 0,n),e=e._next;--pn}function Ga(){nn=(wi=zn.now())+Ni,pn=Gn=0;try{Sb()}finally{pn=0,Nb(),nn=0}}function wb(){var e=zn.now(),n=e-wi;n>Oa&&(Ni-=n,wi=e)}function Nb(){for(var e,n=Si,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:Si=i);Vn=e,Oo(o)}function Oo(e){if(!pn){Gn&&(Gn=clearTimeout(Gn));var n=e-nn;n>24?(e<1/0&&(Gn=setTimeout(Ga,e-zn.now()-Ni)),Fn&&(Fn=clearInterval(Fn))):(Fn||(wi=zn.now(),Fn=setInterval(wb,Oa)),pn=1,Ka(Ga))}}function Fa(e,n,i){var o=new Ai;return n=n==null?0:+n,o.restart(s=>{o.stop(),e(s+n)},n,i),o}var Ab=di("start","end","cancel","interrupt"),Cb=[],Va=0,za=1,Ko=2,Ci=3,Wa=4,Ho=5,ki=6;function Mi(e,n,i,o,s,a){var l=e.__transition;if(!l)e.__transition={};else if(i in l)return;kb(e,i,{name:n,index:o,group:s,on:Ab,tween:Cb,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:Va})}function Go(e,n){var i=De(e,n);if(i.state>Va)throw new Error("too late; already scheduled");return i}function Fe(e,n){var i=De(e,n);if(i.state>Ci)throw new Error("too late; already running");return i}function De(e,n){var i=e.__transition;if(!i||!(i=i[n]))throw new Error("transition not found");return i}function kb(e,n,i){var o=e.__transition,s;o[n]=i,i.timer=Ha(a,0,i.time);function a(u){i.state=za,i.timer.restart(l,i.delay,i.time),i.delay<=u&&l(u-i.delay)}function l(u){var m,c,b,v;if(i.state!==za)return d();for(m in o)if(v=o[m],v.name===i.name){if(v.state===Ci)return Fa(l);v.state===Wa?(v.state=ki,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete o[m]):+m<n&&(v.state=ki,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete o[m])}if(Fa(function(){i.state===Ci&&(i.state=Wa,i.timer.restart(r,i.delay,i.time),r(u))}),i.state=Ko,i.on.call("start",e,e.__data__,i.index,i.group),i.state===Ko){for(i.state=Ci,s=new Array(b=i.tween.length),m=0,c=-1;m<b;++m)(v=i.tween[m].value.call(e,e.__data__,i.index,i.group))&&(s[++c]=v);s.length=c+1}}function r(u){for(var m=u<i.duration?i.ease.call(null,u/i.duration):(i.timer.restart(d),i.state=Ho,1),c=-1,b=s.length;++c<b;)s[c].call(e,m);i.state===Ho&&(i.on.call("end",e,e.__data__,i.index,i.group),d())}function d(){i.state=ki,i.timer.stop(),delete o[n];for(var u in o)return;delete e.__transition}}function Ei(e,n){var i=e.__transition,o,s,a=!0,l;if(i){n=n==null?null:n+"";for(l in i){if((o=i[l]).name!==n){a=!1;continue}s=o.state>Ko&&o.state<Ho,o.state=ki,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete i[l]}a&&delete e.__transition}}function Mb(e){return this.each(function(){Ei(this,e)})}function Eb(e,n){var i,o;return function(){var s=Fe(this,e),a=s.tween;if(a!==i){o=i=a;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 Tb(e,n,i){var o,s;if(typeof i!="function")throw new Error;return function(){var a=Fe(this,e),l=a.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)}a.tween=s}}function Pb(e,n){var i=this._id;if(e+="",arguments.length<2){for(var o=De(this.node(),i).tween,s=0,a=o.length,l;s<a;++s)if((l=o[s]).name===e)return l.value;return null}return this.each((n==null?Eb:Tb)(i,e,n))}function Fo(e,n,i){var o=e._id;return e.each(function(){var s=Fe(this,o);(s.value||(s.value={}))[n]=i.apply(this,arguments)}),function(s){return De(s,o).value[n]}}function $a(e,n){var i;return(typeof n=="number"?Ge:n instanceof Qe?gi:(i=Qe(n))?(n=i,gi):La)(e,n)}function Lb(e){return function(){this.removeAttribute(e)}}function Bb(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ib(e,n,i){var o,s=i+"",a;return function(){var l=this.getAttribute(e);return l===s?null:l===o?a:a=n(o=l,i)}}function Db(e,n,i){var o,s=i+"",a;return function(){var l=this.getAttributeNS(e.space,e.local);return l===s?null:l===o?a:a=n(o=l,i)}}function _b(e,n,i){var o,s,a;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?a:(s=d,a=n(o=l,r)))}}function Ob(e,n,i){var o,s,a;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?a:(s=d,a=n(o=l,r)))}}function Kb(e,n){var i=ci(e),o=i==="transform"?fb:$a;return this.attrTween(e,typeof n=="function"?(i.local?Ob:_b)(i,o,Fo(this,"attr."+e,n)):n==null?(i.local?Bb:Lb)(i):(i.local?Db:Ib)(i,o,n))}function Hb(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function Gb(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function Fb(e,n){var i,o;function s(){var a=n.apply(this,arguments);return a!==o&&(i=(o=a)&&Gb(e,a)),i}return s._value=n,s}function Vb(e,n){var i,o;function s(){var a=n.apply(this,arguments);return a!==o&&(i=(o=a)&&Hb(e,a)),i}return s._value=n,s}function zb(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=ci(e);return this.tween(i,(o.local?Fb:Vb)(o,n))}function Wb(e,n){return function(){Go(this,e).delay=+n.apply(this,arguments)}}function $b(e,n){return n=+n,function(){Go(this,e).delay=n}}function jb(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Wb:$b)(n,e)):De(this.node(),n).delay}function Ub(e,n){return function(){Fe(this,e).duration=+n.apply(this,arguments)}}function qb(e,n){return n=+n,function(){Fe(this,e).duration=n}}function Yb(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Ub:qb)(n,e)):De(this.node(),n).duration}function Jb(e,n){if(typeof n!="function")throw new Error;return function(){Fe(this,e).ease=n}}function Zb(e){var n=this._id;return arguments.length?this.each(Jb(n,e)):De(this.node(),n).ease}function Xb(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;Fe(this,e).ease=i}}function Qb(e){if(typeof e!="function")throw new Error;return this.each(Xb(this._id,e))}function Rb(e){typeof e!="function"&&(e=la(e));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var a=n[s],l=a.length,r=o[s]=[],d,u=0;u<l;++u)(d=a[u])&&e.call(d,d.__data__,u,a)&&r.push(d);return new ze(o,this._parents,this._name,this._id)}function ev(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,i=e._groups,o=n.length,s=i.length,a=Math.min(o,s),l=new Array(o),r=0;r<a;++r)for(var d=n[r],u=i[r],m=d.length,c=l[r]=new Array(m),b,v=0;v<m;++v)(b=d[v]||u[v])&&(c[v]=b);for(;r<o;++r)l[r]=n[r];return new ze(l,this._parents,this._name,this._id)}function nv(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 iv(e,n,i){var o,s,a=nv(n)?Go:Fe;return function(){var l=a(this,e),r=l.on;r!==o&&(s=(o=r).copy()).on(n,i),l.on=s}}function ov(e,n){var i=this._id;return arguments.length<2?De(this.node(),i).on.on(e):this.each(iv(i,e,n))}function sv(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function av(){return this.on("end.remove",sv(this._id))}function tv(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Ao(e));for(var o=this._groups,s=o.length,a=new Array(s),l=0;l<s;++l)for(var r=o[l],d=r.length,u=a[l]=new Array(d),m,c,b=0;b<d;++b)(m=r[b])&&(c=e.call(m,m.__data__,b,r))&&("__data__"in m&&(c.__data__=m.__data__),u[b]=c,Mi(u[b],n,i,b,u,De(m,i)));return new ze(a,this._parents,n,i)}function lv(e){var n=this._name,i=this._id;typeof e!="function"&&(e=ta(e));for(var o=this._groups,s=o.length,a=[],l=[],r=0;r<s;++r)for(var d=o[r],u=d.length,m,c=0;c<u;++c)if(m=d[c]){for(var b=e.call(m,m.__data__,c,d),v,h=De(m,i),p=0,g=b.length;p<g;++p)(v=b[p])&&Mi(v,n,i,p,b,h);a.push(b),l.push(m)}return new ze(a,l,n,i)}var rv=In.prototype.constructor;function dv(){return new rv(this._groups,this._parents)}function uv(e,n){var i,o,s;return function(){var a=vn(this,e),l=(this.style.removeProperty(e),vn(this,e));return a===l?null:a===i&&l===o?s:s=n(i=a,o=l)}}function ja(e){return function(){this.style.removeProperty(e)}}function cv(e,n,i){var o,s=i+"",a;return function(){var l=vn(this,e);return l===s?null:l===o?a:a=n(o=l,i)}}function mv(e,n,i){var o,s,a;return function(){var l=vn(this,e),r=i(this),d=r+"";return r==null&&(d=r=(this.style.removeProperty(e),vn(this,e))),l===d?null:l===o&&d===s?a:(s=d,a=n(o=l,r))}}function bv(e,n){var i,o,s,a="style."+n,l="end."+a,r;return function(){var d=Fe(this,e),u=d.on,m=d.value[a]==null?r||(r=ja(n)):void 0;(u!==i||s!==m)&&(o=(i=u).copy()).on(l,s=m),d.on=o}}function vv(e,n,i){var o=(e+="")=="transform"?hb:$a;return n==null?this.styleTween(e,uv(e,o)).on("end.style."+e,ja(e)):typeof n=="function"?this.styleTween(e,mv(e,o,Fo(this,"style."+e,n))).each(bv(this._id,e)):this.styleTween(e,cv(e,o,n),i).on("end.style."+e,null)}function hv(e,n,i){return function(o){this.style.setProperty(e,n.call(this,o),i)}}function fv(e,n,i){var o,s;function a(){var l=n.apply(this,arguments);return l!==s&&(o=(s=l)&&hv(e,l,i)),o}return a._value=n,a}function pv(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,fv(e,n,i==null?"":i))}function gv(e){return function(){this.textContent=e}}function yv(e){return function(){var n=e(this);this.textContent=n==null?"":n}}function xv(e){return this.tween("text",typeof e=="function"?yv(Fo(this,"text",e)):gv(e==null?"":e+""))}function Sv(e){return function(n){this.textContent=e.call(this,n)}}function wv(e){var n,i;function o(){var s=e.apply(this,arguments);return s!==i&&(n=(i=s)&&Sv(s)),n}return o._value=e,o}function Nv(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,wv(e))}function Av(){for(var e=this._name,n=this._id,i=Ua(),o=this._groups,s=o.length,a=0;a<s;++a)for(var l=o[a],r=l.length,d,u=0;u<r;++u)if(d=l[u]){var m=De(d,n);Mi(d,e,i,u,l,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new ze(o,this._parents,e,i)}function Cv(){var e,n,i=this,o=i._id,s=i.size();return new Promise(function(a,l){var r={value:l},d={value:function(){--s===0&&a()}};i.each(function(){var u=Fe(this,o),m=u.on;m!==e&&(n=(e=m).copy(),n._.cancel.push(r),n._.interrupt.push(r),n._.end.push(d)),u.on=n}),s===0&&a()})}var kv=0;function ze(e,n,i,o){this._groups=e,this._parents=n,this._name=i,this._id=o}function Ua(){return++kv}var We=In.prototype;ze.prototype={constructor:ze,select:tv,selectAll:lv,selectChild:We.selectChild,selectChildren:We.selectChildren,filter:Rb,merge:ev,selection:dv,transition:Av,call:We.call,nodes:We.nodes,node:We.node,size:We.size,empty:We.empty,each:We.each,on:ov,attr:Kb,attrTween:zb,style:vv,styleTween:pv,text:xv,textTween:Nv,remove:av,tween:Pb,delay:jb,duration:Yb,ease:Zb,easeVarying:Qb,end:Cv,[Symbol.iterator]:We[Symbol.iterator]};function Mv(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ev={time:null,delay:0,duration:250,ease:Mv};function Tv(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 Pv(e){var n,i;e instanceof ze?(n=e._id,e=e._name):(n=Ua(),(i=Ev).time=_o(),e=e==null?null:e+"");for(var o=this._groups,s=o.length,a=0;a<s;++a)for(var l=o[a],r=l.length,d,u=0;u<r;++u)(d=l[u])&&Mi(d,e,n,u,l,i||Tv(d,n));return new ze(o,this._parents,e,n)}In.prototype.interrupt=Mb,In.prototype.transition=Pv;const Ti=e=>()=>e;function Lv(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 $e(e,n,i){this.k=e,this.x=n,this.y=i}$e.prototype={constructor:$e,scale:function(e){return e===1?this:new $e(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new $e(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 Pi=new $e(1,0,0);qa.prototype=$e.prototype;function qa(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Pi;return e.__zoom}function Vo(e){e.stopImmediatePropagation()}function Wn(e){e.preventDefault(),e.stopImmediatePropagation()}function Bv(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Iv(){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 Ya(){return this.__zoom||Pi}function Dv(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function _v(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ov(e,n,i){var o=e.invertX(n[0][0])-i[0][0],s=e.invertX(n[1][0])-i[1][0],a=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>a?(a+l)/2:Math.min(0,a)||Math.max(0,l))}function Ja(){var e=Bv,n=Iv,i=Ov,o=Dv,s=_v,a=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],r=250,d=xi,u=di("start","zoom","end"),m,c,b,v=500,h=150,p=0,g=10;function f(M){M.property("__zoom",Ya).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",I).filter(s).on("touchstart.zoom",P).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}f.transform=function(M,_,B,K){var D=M.selection?M.selection():M;D.property("__zoom",Ya),M!==D?w(M,_,B,K):D.interrupt().each(function(){A(this,arguments).event(K).start().zoom(null,typeof _=="function"?_.apply(this,arguments):_).end()})},f.scaleBy=function(M,_,B,K){f.scaleTo(M,function(){var D=this.__zoom.k,L=typeof _=="function"?_.apply(this,arguments):_;return D*L},B,K)},f.scaleTo=function(M,_,B,K){f.transform(M,function(){var D=n.apply(this,arguments),L=this.__zoom,z=B==null?S(D):typeof B=="function"?B.apply(this,arguments):B,U=L.invert(z),W=typeof _=="function"?_.apply(this,arguments):_;return i(y(N(L,W),z,U),D,l)},B,K)},f.translateBy=function(M,_,B,K){f.transform(M,function(){return i(this.__zoom.translate(typeof _=="function"?_.apply(this,arguments):_,typeof B=="function"?B.apply(this,arguments):B),n.apply(this,arguments),l)},null,K)},f.translateTo=function(M,_,B,K,D){f.transform(M,function(){var L=n.apply(this,arguments),z=this.__zoom,U=K==null?S(L):typeof K=="function"?K.apply(this,arguments):K;return i(Pi.translate(U[0],U[1]).scale(z.k).translate(typeof _=="function"?-_.apply(this,arguments):-_,typeof B=="function"?-B.apply(this,arguments):-B),L,l)},K,D)};function N(M,_){return _=Math.max(a[0],Math.min(a[1],_)),_===M.k?M:new $e(_,M.x,M.y)}function y(M,_,B){var K=_[0]-B[0]*M.k,D=_[1]-B[1]*M.k;return K===M.x&&D===M.y?M:new $e(M.k,K,D)}function S(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function w(M,_,B,K){M.on("start.zoom",function(){A(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(K).end()}).tween("zoom",function(){var D=this,L=arguments,z=A(D,L).event(K),U=n.apply(D,L),W=B==null?S(U):typeof B=="function"?B.apply(D,L):B,Y=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),X=D.__zoom,ie=typeof _=="function"?_.apply(D,L):_,se=d(X.invert(W).concat(Y/X.k),ie.invert(W).concat(Y/ie.k));return function(Q){if(Q===1)Q=ie;else{var j=se(Q),V=Y/j[2];Q=new $e(V,W[0]-j[0]*V,W[1]-j[1]*V)}z.zoom(null,Q)}})}function A(M,_,B){return!B&&M.__zooming||new C(M,_)}function C(M,_){this.that=M,this.args=_,this.active=0,this.sourceEvent=null,this.extent=n.apply(M,_),this.taps=0}C.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,_){return this.mouse&&M!=="mouse"&&(this.mouse[1]=_.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=_.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=_.invert(this.touch1[0])),this.that.__zoom=_,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var _=Pe(this.that).datum();u.call(M,this.that,new Lv(M,{sourceEvent:this.sourceEvent,target:f,transform:this.that.__zoom,dispatch:u}),_)}};function E(M,..._){if(!e.apply(this,arguments))return;var B=A(this,_).event(M),K=this.__zoom,D=Math.max(a[0],Math.min(a[1],K.k*Math.pow(2,o.apply(this,arguments)))),L=Be(M);if(B.wheel)(B.mouse[0][0]!==L[0]||B.mouse[0][1]!==L[1])&&(B.mouse[1]=K.invert(B.mouse[0]=L)),clearTimeout(B.wheel);else{if(K.k===D)return;B.mouse=[L,K.invert(L)],Ei(this),B.start()}Wn(M),B.wheel=setTimeout(z,h),B.zoom("mouse",i(y(N(K,D),B.mouse[0],B.mouse[1]),B.extent,l));function z(){B.wheel=null,B.end()}}function k(M,..._){if(b||!e.apply(this,arguments))return;var B=M.currentTarget,K=A(this,_,!0).event(M),D=Pe(M.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",Y,!0),L=Be(M,B),z=M.clientX,U=M.clientY;pa(M.view),Vo(M),K.mouse=[L,this.__zoom.invert(L)],Ei(this),K.start();function W(X){if(Wn(X),!K.moved){var ie=X.clientX-z,se=X.clientY-U;K.moved=ie*ie+se*se>p}K.event(X).zoom("mouse",i(y(K.that.__zoom,K.mouse[0]=Be(X,B),K.mouse[1]),K.extent,l))}function Y(X){D.on("mousemove.zoom mouseup.zoom",null),ga(X.view,K.moved),Wn(X),K.event(X).end()}}function I(M,..._){if(e.apply(this,arguments)){var B=this.__zoom,K=Be(M.changedTouches?M.changedTouches[0]:M,this),D=B.invert(K),L=B.k*(M.shiftKey?.5:2),z=i(y(N(B,L),K,D),n.apply(this,_),l);Wn(M),r>0?Pe(this).transition().duration(r).call(w,z,K,M):Pe(this).call(f.transform,z,K,M)}}function P(M,..._){if(e.apply(this,arguments)){var B=M.touches,K=B.length,D=A(this,_,M.changedTouches.length===K).event(M),L,z,U,W;for(Vo(M),z=0;z<K;++z)U=B[z],W=Be(U,this),W=[W,this.__zoom.invert(W),U.identifier],D.touch0?!D.touch1&&D.touch0[2]!==W[2]&&(D.touch1=W,D.taps=0):(D.touch0=W,L=!0,D.taps=1+!!m);m&&(m=clearTimeout(m)),L&&(D.taps<2&&(c=W[0],m=setTimeout(function(){m=null},v)),Ei(this),D.start())}}function T(M,..._){if(this.__zooming){var B=A(this,_).event(M),K=M.changedTouches,D=K.length,L,z,U,W;for(Wn(M),L=0;L<D;++L)z=K[L],U=Be(z,this),B.touch0&&B.touch0[2]===z.identifier?B.touch0[0]=U:B.touch1&&B.touch1[2]===z.identifier&&(B.touch1[0]=U);if(z=B.that.__zoom,B.touch1){var Y=B.touch0[0],X=B.touch0[1],ie=B.touch1[0],se=B.touch1[1],Q=(Q=ie[0]-Y[0])*Q+(Q=ie[1]-Y[1])*Q,j=(j=se[0]-X[0])*j+(j=se[1]-X[1])*j;z=N(z,Math.sqrt(Q/j)),U=[(Y[0]+ie[0])/2,(Y[1]+ie[1])/2],W=[(X[0]+se[0])/2,(X[1]+se[1])/2]}else if(B.touch0)U=B.touch0[0],W=B.touch0[1];else return;B.zoom("touch",i(y(z,U,W),B.extent,l))}}function O(M,..._){if(this.__zooming){var B=A(this,_).event(M),K=M.changedTouches,D=K.length,L,z;for(Vo(M),b&&clearTimeout(b),b=setTimeout(function(){b=null},v),L=0;L<D;++L)z=K[L],B.touch0&&B.touch0[2]===z.identifier?delete B.touch0:B.touch1&&B.touch1[2]===z.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&&(z=Be(z,this),Math.hypot(c[0]-z[0],c[1]-z[1])<g)){var U=Pe(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return f.wheelDelta=function(M){return arguments.length?(o=typeof M=="function"?M:Ti(+M),f):o},f.filter=function(M){return arguments.length?(e=typeof M=="function"?M:Ti(!!M),f):e},f.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:Ti(!!M),f):s},f.extent=function(M){return arguments.length?(n=typeof M=="function"?M:Ti([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),f):n},f.scaleExtent=function(M){return arguments.length?(a[0]=+M[0],a[1]=+M[1],f):[a[0],a[1]]},f.translateExtent=function(M){return arguments.length?(l[0][0]=+M[0][0],l[1][0]=+M[1][0],l[0][1]=+M[0][1],l[1][1]=+M[1][1],f):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},f.constrain=function(M){return arguments.length?(i=M,f):i},f.duration=function(M){return arguments.length?(r=+M,f):r},f.interpolate=function(M){return arguments.length?(d=M,f):d},f.on=function(){var M=u.on.apply(u,arguments);return M===u?f:M},f.clickDistance=function(M){return arguments.length?(p=(M=+M)*M,f):Math.sqrt(p)},f.tapDistance=function(M){return arguments.length?(g=+M,f):g},f}const Le={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.`},$n=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Za=["Enter"," ","Escape"],Xa={"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 gn;(function(e){e.Strict="strict",e.Loose="loose"})(gn||(gn={}));var on;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(on||(on={}));var jn;(function(e){e.Partial="partial",e.Full="full"})(jn||(jn={}));const Qa={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var qe;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(qe||(qe={}));var yn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(yn||(yn={}));var oe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(oe||(oe={}));const Ra={[oe.Left]:oe.Right,[oe.Right]:oe.Left,[oe.Top]:oe.Bottom,[oe.Bottom]:oe.Top};function et(e){return e===null?null:e?"valid":"invalid"}const nt=e=>"id"in e&&"source"in e&&"target"in e,Kv=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),zo=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Un=(e,n=[0,0])=>{var r;const{width:i,height:o}=je(e),s=(r=e.origin)!=null?r:n,a=i*s[0],l=o*s[1];return{x:e.position.x-a,y:e.position.y-l}},Hv=(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 a=typeof s=="string";let l=!n.nodeLookup&&!a?s:void 0;n.nodeLookup&&(l=a?n.nodeLookup.get(s):zo(s)?s:n.nodeLookup.get(s.id));const r=l?Ii(l,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Li(o,r)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Bi(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=Li(i,Ii(s)),o=!0)}),o?Bi(i):{x:0,y:0,width:0,height:0}},Wo=(e,n,[i,o,s]=[0,0,1],a=!1,l=!1)=>{var b,v,h,p,g,f;const r=(n.x-i)/s,d=(n.y-o)/s,u=n.width/s,m=n.height/s,c=[];for(const N of e.values()){const{measured:y,selectable:S=!0,hidden:w=!1}=N;if(l&&!S||w)continue;const A=(h=(v=(b=y.width)!=null?b:N.width)!=null?v:N.initialWidth)!=null?h:0,C=(f=(g=(p=y.height)!=null?p:N.height)!=null?g:N.initialHeight)!=null?f:0,{x:E,y:k}=N.internals.positionAbsolute,I=tt(r,d,u,m,E,k,A,C),P=A*C,T=a&&I>0;(!N.internals.handleBounds||T||I>=P||N.dragging)&&c.push(N)}return c},Gv=(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 Fv(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 Vv({nodes:e,width:n,height:i,panZoom:o,minZoom:s,maxZoom:a},l){var m,c,b;if(e.size===0)return!0;const r=Fv(e,l),d=qn(r),u=Uo(d,n,i,(m=l==null?void 0:l.minZoom)!=null?m:s,(c=l==null?void 0:l.maxZoom)!=null?c:a,(b=l==null?void 0:l.padding)!=null?b:.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 it({nodeId:e,nextPosition:n,nodeLookup:i,nodeOrigin:o=[0,0],nodeExtent:s,onError:a}){var v,h,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},m=(v=l.origin)!=null?v:o;let c=l.extent||s;if(l.extent==="parent"&&!l.expandParent)if(!r)a==null||a("005",Le.error005());else{const g=r.measured.width,f=r.measured.height;g&&f&&(c=[[d,u],[d+g,u+f]])}else r&&an(l.extent)&&(c=[[l.extent[0][0]+d,l.extent[0][1]+u],[l.extent[1][0]+d,l.extent[1][1]+u]]);const b=an(c)?sn(n,c,l.measured):n;return(l.measured.width===void 0||l.measured.height===void 0)&&(a==null||a("015",Le.error015())),{position:{x:b.x-d+((h=l.measured.width)!=null?h:0)*m[0],y:b.y-u+((p=l.measured.height)!=null?p:0)*m[1]},positionAbsolute:b}}async function zv({nodesToRemove:e=[],edgesToRemove:n=[],nodes:i,edges:o,onBeforeDelete:s}){const a=new Set(e.map(b=>b.id)),l=[];for(const b of i){if(b.deletable===!1)continue;const v=a.has(b.id),h=!v&&b.parentId&&l.find(p=>p.id===b.parentId);(v||h)&&l.push(b)}const r=new Set(n.map(b=>b.id)),d=o.filter(b=>b.deletable!==!1),m=Gv(l,d);for(const b of d)r.has(b.id)&&!m.find(h=>h.id===b.id)&&m.push(b);if(!s)return{edges:m,nodes:l};const c=await s({nodes:l,edges:m});return typeof c=="boolean"?c?{edges:m,nodes:l}:{edges:[],nodes:[]}:c}const xn=(e,n=0,i=1)=>Math.min(Math.max(e,n),i),sn=(e={x:0,y:0},n,i)=>{var o,s;return{x:xn(e.x,n[0][0],n[1][0]-((o=i==null?void 0:i.width)!=null?o:0)),y:xn(e.y,n[0][1],n[1][1]-((s=i==null?void 0:i.height)!=null?s:0))}};function ot(e,n,i){const{width:o,height:s}=je(i),{x:a,y:l}=i.internals.positionAbsolute;return sn(e,[[a,l],[a+o,l+s]],n)}const st=(e,n,i)=>e<n?xn(Math.abs(e-n),1,n)/n:e>i?-xn(Math.abs(e-i),1,n)/n:0,$o=(e,n,i=15,o=40)=>{const s=st(e.x,o,n.width-o)*i,a=st(e.y,o,n.height-o)*i;return[s,a]},Li=(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)}),jo=({x:e,y:n,width:i,height:o})=>({x:e,y:n,x2:e+i,y2:n+o}),Bi=({x:e,y:n,x2:i,y2:o})=>({x:e,y:n,width:i-e,height:o-n}),Yn=(e,n=[0,0])=>{var s,a,l,r,d,u,m,c;const{x:i,y:o}=zo(e)?e.internals.positionAbsolute:Un(e,n);return{x:i,y:o,width:(r=(l=(a=(s=e.measured)==null?void 0:s.width)!=null?a:e.width)!=null?l:e.initialWidth)!=null?r:0,height:(c=(m=(u=(d=e.measured)==null?void 0:d.height)!=null?u:e.height)!=null?m:e.initialHeight)!=null?c:0}},Ii=(e,n=[0,0])=>{var s,a,l,r,d,u,m,c;const{x:i,y:o}=zo(e)?e.internals.positionAbsolute:Un(e,n);return{x:i,y:o,x2:i+((r=(l=(a=(s=e.measured)==null?void 0:s.width)!=null?a:e.width)!=null?l:e.initialWidth)!=null?r:0),y2:o+((c=(m=(u=(d=e.measured)==null?void 0:d.height)!=null?u:e.height)!=null?m:e.initialHeight)!=null?c:0)}},at=(e,n)=>Bi(Li(jo(e),jo(n))),tt=(e,n,i,o,s,a,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,a+r)-Math.max(n,a));return Math.ceil(d*u)},Di=(e,n)=>tt(e.x,e.y,e.width,e.height,n.x,n.y,n.width,n.height),lt=e=>_e(e.width)&&_e(e.height)&&_e(e.x)&&_e(e.y),_e=e=>!isNaN(e)&&isFinite(e),rt=(e,n)=>(i,o)=>{process.env.NODE_ENV==="development"&&console.warn(`[${e}]: ${o} Help: ${n}error#${i}`)},Jn=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),Zn=({x:e,y:n},[i,o,s],a=!1,l=[1,1])=>{const r={x:(e-i)/s,y:(n-o)/s};return a?Jn(r,l):r},Sn=({x:e,y:n},[i,o,s])=>({x:e*s+i,y:n*s+o});function wn(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 Wv(e,n,i){var o,s,a,l,r,d,u,m;if(typeof e=="string"||typeof e=="number"){const c=wn(e,i),b=wn(e,n);return{top:c,right:b,bottom:c,left:b,x:b*2,y:c*2}}if(typeof e=="object"){const c=wn((s=(o=e.top)!=null?o:e.y)!=null?s:0,i),b=wn((l=(a=e.bottom)!=null?a:e.y)!=null?l:0,i),v=wn((d=(r=e.left)!=null?r:e.x)!=null?d:0,n),h=wn((m=(u=e.right)!=null?u:e.x)!=null?m:0,n);return{top:c,right:h,bottom:b,left:v,x:v+h,y:c+b}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function $v(e,n,i,o,s,a){const{x:l,y:r}=Sn(e,[n,i,o]),{x:d,y:u}=Sn({x:e.x+e.width,y:e.y+e.height},[n,i,o]),m=s-d,c=a-u;return{left:Math.floor(l),top:Math.floor(r),right:Math.floor(m),bottom:Math.floor(c)}}const Uo=(e,n,i,o,s,a)=>{const l=Wv(a,n,i),r=(n-l.x)/e.width,d=(i-l.y)/e.height,u=Math.min(r,d),m=xn(u,o,s),c=e.x+e.width/2,b=e.y+e.height/2,v=n/2-c*m,h=i/2-b*m,p=$v(e,v,h,m,n,i),g={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:v-g.left+g.right,y:h-g.top+g.bottom,zoom:m}},Xn=()=>{var e;return typeof navigator!="undefined"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function an(e){return e!=null&&e!=="parent"}function je(e){var n,i,o,s,a,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=(a=e.measured)==null?void 0:a.height)!=null?l:e.height)!=null?r:e.initialHeight)!=null?d:0}}function dt(e){var n,i,o,s,a,l;return((o=(i=(n=e.measured)==null?void 0:n.width)!=null?i:e.width)!=null?o:e.initialWidth)!==void 0&&((l=(a=(s=e.measured)==null?void 0:s.height)!=null?a:e.height)!=null?l:e.initialHeight)!==void 0}function ut(e,n={width:0,height:0},i,o,s){var r,d;const a={...e},l=o.get(i);if(l){const u=l.origin||s;a.x+=l.internals.positionAbsolute.x-((r=n.width)!=null?r:0)*u[0],a.y+=l.internals.positionAbsolute.y-((d=n.height)!=null?d:0)*u[1]}return a}function ct(e,n){if(e.size!==n.size)return!1;for(const i of e)if(!n.has(i))return!1;return!0}function jv(){let e,n;return{promise:new Promise((o,s)=>{e=o,n=s}),resolve:e,reject:n}}function Uv(e){return{...Xa,...e||{}}}function Qn(e,{snapGrid:n=[0,0],snapToGrid:i=!1,transform:o,containerBounds:s}){var m,c;const{x:a,y:l}=Oe(e),r=Zn({x:a-((m=s==null?void 0:s.left)!=null?m:0),y:l-((c=s==null?void 0:s.top)!=null?c:0)},o),{x:d,y:u}=i?Jn(r,n):r;return{xSnapped:d,ySnapped:u,...r}}const qo=e=>({width:e.offsetWidth,height:e.offsetHeight}),mt=e=>{var n;return((n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},qv=["INPUT","SELECT","TEXTAREA"];function bt(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:qv.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const vt=e=>"clientX"in e,Oe=(e,n)=>{var a,l,r,d;const i=vt(e),o=i?e.clientX:(a=e.touches)==null?void 0:a[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)}},ht=(e,n,i,o,s)=>{const a=n.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).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,...qo(l)}})};function ft({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:l,targetControlY:r}){const d=e*.125+s*.375+l*.375+i*.125,u=n*.125+a*.375+r*.375+o*.125,m=Math.abs(d-e),c=Math.abs(u-n);return[d,u,m,c]}function _i(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function pt({pos:e,x1:n,y1:i,x2:o,y2:s,c:a}){switch(e){case oe.Left:return[n-_i(n-o,a),i];case oe.Right:return[n+_i(o-n,a),i];case oe.Top:return[n,i-_i(i-s,a)];case oe.Bottom:return[n,i+_i(s-i,a)]}}function gt({sourceX:e,sourceY:n,sourcePosition:i=oe.Bottom,targetX:o,targetY:s,targetPosition:a=oe.Top,curvature:l=.25}){const[r,d]=pt({pos:i,x1:e,y1:n,x2:o,y2:s,c:l}),[u,m]=pt({pos:a,x1:o,y1:s,x2:e,y2:n,c:l}),[c,b,v,h]=ft({sourceX:e,sourceY:n,targetX:o,targetY:s,sourceControlX:r,sourceControlY:d,targetControlX:u,targetControlY:m});return[`M${e},${n} C${r},${d} ${u},${m} ${o},${s}`,c,b,v,h]}function yt({sourceX:e,sourceY:n,targetX:i,targetY:o}){const s=Math.abs(i-e)/2,a=i<e?i+s:i-s,l=Math.abs(o-n)/2,r=o<n?o+l:o-l;return[a,r,s,l]}function Yv({sourceNode:e,targetNode:n,selected:i=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:a="basic"}){if(a==="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 Jv({sourceNode:e,targetNode:n,width:i,height:o,transform:s}){const a=Li(Ii(e),Ii(n));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const l={x:-s[0]/s[2],y:-s[1]/s[2],width:i/s[2],height:o/s[2]};return Di(l,Bi(a))>0}const Zv=({source:e,sourceHandle:n,target:i,targetHandle:o})=>`xy-edge__${e}${n||""}-${i}${o||""}`,Xv=(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)),Qv=(e,n,i={})=>{var a;if(!e.source||!e.target)return(a=i.onError)==null||a.call(i,"006",Le.error006()),n;const o=i.getEdgeId||Zv;let s;return nt(e)?s={...e}:s={...e,id:o(e)},Xv(s,n)?n:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,n.concat(s))};function xt({sourceX:e,sourceY:n,targetX:i,targetY:o}){const[s,a,l,r]=yt({sourceX:e,sourceY:n,targetX:i,targetY:o});return[`M ${e},${n}L ${i},${o}`,s,a,l,r]}const St={[oe.Left]:{x:-1,y:0},[oe.Right]:{x:1,y:0},[oe.Top]:{x:0,y:-1},[oe.Bottom]:{x:0,y:1}},Rv=({source:e,sourcePosition:n=oe.Bottom,target:i})=>n===oe.Left||n===oe.Right?e.x<i.x?{x:1,y:0}:{x:-1,y:0}:e.y<i.y?{x:0,y:1}:{x:0,y:-1},wt=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function eh({source:e,sourcePosition:n=oe.Bottom,target:i,targetPosition:o=oe.Top,center:s,offset:a,stepPosition:l}){var E,k,I,P;const r=St[n],d=St[o],u={x:e.x+r.x*a,y:e.y+r.y*a},m={x:i.x+d.x*a,y:i.y+d.y*a},c=Rv({source:u,sourcePosition:n,target:m}),b=c.x!==0?"x":"y",v=c[b];let h=[],p,g;const f={x:0,y:0},N={x:0,y:0},[,,y,S]=yt({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(r[b]*d[b]===-1){b==="x"?(p=(E=s.x)!=null?E:u.x+(m.x-u.x)*l,g=(k=s.y)!=null?k:(u.y+m.y)/2):(p=(I=s.x)!=null?I:(u.x+m.x)/2,g=(P=s.y)!=null?P:u.y+(m.y-u.y)*l);const T=[{x:p,y:u.y},{x:p,y:m.y}],O=[{x:u.x,y:g},{x:m.x,y:g}];r[b]===v?h=b==="x"?T:O:h=b==="x"?O:T}else{const T=[{x:u.x,y:m.y}],O=[{x:m.x,y:u.y}];if(b==="x"?h=r.x===v?O:T:h=r.y===v?T:O,n===o){const D=Math.abs(e[b]-i[b]);if(D<=a){const L=Math.min(a-1,a-D);r[b]===v?f[b]=(u[b]>e[b]?-1:1)*L:N[b]=(m[b]>i[b]?-1:1)*L}}if(n!==o){const D=b==="x"?"y":"x",L=r[b]===d[D],z=u[D]>m[D],U=u[D]<m[D];(r[b]===1&&(!L&&z||L&&U)||r[b]!==1&&(!L&&U||L&&z))&&(h=b==="x"?T:O)}const M={x:u.x+f.x,y:u.y+f.y},_={x:m.x+N.x,y:m.y+N.y},B=Math.max(Math.abs(M.x-h[0].x),Math.abs(_.x-h[0].x)),K=Math.max(Math.abs(M.y-h[0].y),Math.abs(_.y-h[0].y));B>=K?(p=(M.x+_.x)/2,g=h[0].y):(p=h[0].x,g=(M.y+_.y)/2)}const w={x:u.x+f.x,y:u.y+f.y},A={x:m.x+N.x,y:m.y+N.y};return[[e,...w.x!==h[0].x||w.y!==h[0].y?[w]:[],...h,...A.x!==h[h.length-1].x||A.y!==h[h.length-1].y?[A]:[],i],p,g,y,S]}function nh(e,n,i,o){const s=Math.min(wt(e,n)/2,wt(n,i)/2,o),{x:a,y:l}=n;if(e.x===a&&a===i.x||e.y===l&&l===i.y)return`L${a} ${l}`;if(e.y===l){const u=e.x<i.x?-1:1,m=e.y<i.y?1:-1;return`L ${a+s*u},${l}Q ${a},${l} ${a},${l+s*m}`}const r=e.x<i.x?1:-1,d=e.y<i.y?-1:1;return`L ${a},${l+s*d}Q ${a},${l} ${a+s*r},${l}`}function Yo({sourceX:e,sourceY:n,sourcePosition:i=oe.Bottom,targetX:o,targetY:s,targetPosition:a=oe.Top,borderRadius:l=5,centerX:r,centerY:d,offset:u=20,stepPosition:m=.5}){const[c,b,v,h,p]=eh({source:{x:e,y:n},sourcePosition:i,target:{x:o,y:s},targetPosition:a,center:{x:r,y:d},offset:u,stepPosition:m});let g=`M${c[0].x} ${c[0].y}`;for(let f=1;f<c.length-1;f++)g+=nh(c[f-1],c[f],c[f+1],l);return g+=`L${c[c.length-1].x} ${c[c.length-1].y}`,[g,b,v,h,p]}function Nt(e){var n;return e&&!!(e.internals.handleBounds||(n=e.handles)!=null&&n.length)&&!!(e.measured.width||e.width||e.initialWidth)}function ih(e){var c,b,v,h,p;const{sourceNode:n,targetNode:i}=e;if(!Nt(n)||!Nt(i))return null;const o=n.internals.handleBounds||At(n.handles),s=i.internals.handleBounds||At(i.handles),a=Ct((c=o==null?void 0:o.source)!=null?c:[],e.sourceHandle),l=Ct(e.connectionMode===gn.Strict?(b=s==null?void 0:s.target)!=null?b:[]:((v=s==null?void 0:s.target)!=null?v:[]).concat((h=s==null?void 0:s.source)!=null?h:[]),e.targetHandle);if(!a||!l)return(p=e.onError)==null||p.call(e,"008",Le.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const r=(a==null?void 0:a.position)||oe.Bottom,d=(l==null?void 0:l.position)||oe.Top,u=tn(n,a,r),m=tn(i,l,d);return{sourceX:u.x,sourceY:u.y,targetX:m.x,targetY:m.y,sourcePosition:r,targetPosition:d}}function At(e){var o,s;if(!e)return null;const n=[],i=[];for(const a of e)a.width=(o=a.width)!=null?o:1,a.height=(s=a.height)!=null?s:1,a.type==="source"?n.push(a):a.type==="target"&&i.push(a);return{source:n,target:i}}function tn(e,n,i=oe.Left,o=!1){var u,m,c;const s=((u=n==null?void 0:n.x)!=null?u:0)+e.internals.positionAbsolute.x,a=((m=n==null?void 0:n.y)!=null?m:0)+e.internals.positionAbsolute.y,{width:l,height:r}=n!=null?n:je(e);if(o)return{x:s+l/2,y:a+r/2};switch((c=n==null?void 0:n.position)!=null?c:i){case oe.Top:return{x:s+l/2,y:a};case oe.Right:return{x:s+l,y:a+r/2};case oe.Bottom:return{x:s+l/2,y:a+r};case oe.Left:return{x:s,y:a+r/2}}}function Ct(e,n){return e&&(n?e.find(i=>i.id===n):e[0])||null}function Jo(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function oh(e,{id:n,defaultColor:i,defaultMarkerStart:o,defaultMarkerEnd:s}){const a=new Set;return e.reduce((l,r)=>([r.markerStart||o,r.markerEnd||s].forEach(d=>{if(d&&typeof d=="object"){const u=Jo(d,n);a.has(u)||(l.push({id:u,color:d.color||i,...d}),a.add(u))}}),l),[]).sort((l,r)=>l.id.localeCompare(r.id))}const kt=1e3,sh=10,Zo={nodeOrigin:[0,0],nodeExtent:$n,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ah={...Zo,checkEquality:!0};function Xo(e,n){const i={...e};for(const o in n)n[o]!==void 0&&(i[o]=n[o]);return i}function th(e,n,i){const o=Xo(Zo,i);for(const s of e.values())if(s.parentId)es(s,e,n,o);else{const a=Un(s,o.nodeOrigin),l=an(s.extent)?s.extent:o.nodeExtent,r=sn(a,l,je(s));s.internals.positionAbsolute=r}}function lh(e,n){var s,a;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:(a=l.height)!=null?a: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 Qo(e){return e==="manual"}function Ro(e,n,i,o={}){var m,c,b;const s=Xo(ah,o),a={i:0},l=new Map(n),r=s!=null&&s.elevateNodesOnSelect&&!Qo(s.zIndexMode)?kt:0;let d=e.length>0,u=!1;n.clear(),i.clear();for(const v of e){let h=l.get(v.id);if(s.checkEquality&&v===(h==null?void 0:h.internals.userNode))n.set(v.id,h);else{const p=Un(v,s.nodeOrigin),g=an(v.extent)?v.extent:s.nodeExtent,f=sn(p,g,je(v));h={...s.defaults,...v,measured:{width:(m=v.measured)==null?void 0:m.width,height:(c=v.measured)==null?void 0:c.height},internals:{positionAbsolute:f,handleBounds:lh(v,h),z:Mt(v,r,s.zIndexMode),userNode:v}},n.set(v.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(d=!1),v.parentId&&es(h,n,i,o,a),u||(u=(b=v.selected)!=null?b:!1)}return{nodesInitialized:d,hasSelectedNodes:u}}function rh(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 es(e,n,i,o,s){const{elevateNodesOnSelect:a,nodeOrigin:l,nodeExtent:r,zIndexMode:d}=Xo(Zo,o),u=e.parentId,m=n.get(u);if(!m){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}rh(e,i),s&&!m.parentId&&m.internals.rootParentIndex===void 0&&d==="auto"&&(m.internals.rootParentIndex=++s.i,m.internals.z=m.internals.z+s.i*sh),s&&m.internals.rootParentIndex!==void 0&&(s.i=m.internals.rootParentIndex);const c=a&&!Qo(d)?kt:0,{x:b,y:v,z:h}=dh(e,m,l,r,c,d),{positionAbsolute:p}=e.internals,g=b!==p.x||v!==p.y;(g||h!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:g?{x:b,y:v}:p,z:h}})}function Mt(e,n,i){const o=_e(e.zIndex)?e.zIndex:0;return Qo(i)?o:o+(e.selected?n:0)}function dh(e,n,i,o,s,a){var h;const{x:l,y:r}=n.internals.positionAbsolute,d=je(e),u=Un(e,i),m=an(e.extent)?sn(u,e.extent,d):u;let c=sn({x:l+m.x,y:r+m.y},o,d);e.extent==="parent"&&(c=ot(c,d,n));const b=Mt(e,s,a),v=(h=n.internals.z)!=null?h:0;return{x:c.x,y:c.y,z:v>=b?v+1:b}}function ns(e,n,i,o=[0,0]){var l,r;const s=[],a=new Map;for(const d of e){const u=n.get(d.parentId);if(!u)continue;const m=(r=(l=a.get(d.parentId))==null?void 0:l.expandedRect)!=null?r:Yn(u),c=at(m,d.rect);a.set(d.parentId,{expandedRect:c,parent:u})}return a.size>0&&a.forEach(({expandedRect:d,parent:u},m)=>{var S,w;const c=u.internals.positionAbsolute,b=je(u),v=(S=u.origin)!=null?S:o,h=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,g=Math.max(b.width,Math.round(d.width)),f=Math.max(b.height,Math.round(d.height)),N=(g-b.width)*v[0],y=(f-b.height)*v[1];(h>0||p>0||N||y)&&(s.push({id:m,type:"position",position:{x:u.position.x-h+N,y:u.position.y-p+y}}),(w=i.get(m))==null||w.forEach(A=>{e.some(C=>C.id===A.id)||s.push({id:A.id,type:"position",position:{x:A.position.x+h,y:A.position.y+p}})})),(b.width<d.width||b.height<d.height||h||p)&&s.push({id:m,type:"dimensions",setAttributes:!0,dimensions:{width:g+(h?v[0]*h-N:0),height:f+(p?v[1]*p-y:0)}})}),s}function uh(e,n,i,o,s,a,l){const r=o==null?void 0:o.querySelector(".xyflow__viewport");let d=!1;if(!r)return{changes:[],updatedInternals:d};const u=[],m=window.getComputedStyle(r),{m22:c}=new window.DOMMatrixReadOnly(m.transform),b=[];for(const v of e.values()){const h=n.get(v.id);if(!h)continue;if(h.hidden){n.set(h.id,{...h,internals:{...h.internals,handleBounds:void 0}}),d=!0;continue}const p=qo(v.nodeElement),g=h.measured.width!==p.width||h.measured.height!==p.height;if(!!(p.width&&p.height&&(g||!h.internals.handleBounds||v.force))){const N=v.nodeElement.getBoundingClientRect(),y=an(h.extent)?h.extent:a;let{positionAbsolute:S}=h.internals;h.parentId&&h.extent==="parent"?S=ot(S,p,n.get(h.parentId)):y&&(S=sn(S,y,p));const w={...h,measured:p,internals:{...h.internals,positionAbsolute:S,handleBounds:{source:ht("source",v.nodeElement,N,c,h.id),target:ht("target",v.nodeElement,N,c,h.id)}}};n.set(h.id,w),h.parentId&&es(w,n,i,{nodeOrigin:s,zIndexMode:l}),d=!0,g&&(u.push({id:h.id,type:"dimensions",dimensions:p}),h.expandParent&&h.parentId&&b.push({id:h.id,parentId:h.parentId,rect:Yn(w,s)}))}}if(b.length>0){const v=ns(b,n,i,s);u.push(...v)}return{changes:u,updatedInternals:d}}async function ch({delta:e,panZoom:n,transform:i,translateExtent:o,width:s,height:a}){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,a]],o);return!!l&&(l.x!==i[0]||l.y!==i[1]||l.k!==i[2])}function Et(e,n,i,o,s,a){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)),a){l=`${s}-${e}-${a}`;const u=o.get(l)||new Map;o.set(l,u.set(i,n))}}function Tt(e,n,i){e.clear(),n.clear();for(const o of i){const{source:s,target:a,sourceHandle:l=null,targetHandle:r=null}=o,d={edgeId:o.id,source:s,target:a,sourceHandle:l,targetHandle:r},u=`${s}-${l}--${a}-${r}`,m=`${a}-${r}--${s}-${l}`;Et("source",d,m,e,s,l),Et("target",d,u,e,a,r),n.set(o.id,o)}}function Pt(e,n){if(!e.parentId)return!1;const i=n.get(e.parentId);return i?i.selected?!0:Pt(i,n):!1}function Lt(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 mh(e,n,i,o){var a,l;const s=new Map;for(const[r,d]of e)if((d.selected||d.id===o)&&(!d.parentId||!Pt(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:(a=u.measured.width)!=null?a:0,height:(l=u.measured.height)!=null?l:0}})}return s}function is({nodeId:e,dragItems:n,nodeLookup:i,dragging:o=!0}){var l,r,d;const s=[];for(const[u,m]of n){const c=(l=i.get(u))==null?void 0:l.internals.userNode;c&&s.push({...c,position:m.position,dragging:o})}if(!e)return[s[0],s];const a=(r=i.get(e))==null?void 0:r.internals.userNode;return[a?{...a,position:((d=n.get(e))==null?void 0:d.position)||a.position,dragging:o}:s[0],s]}function bh({dragItems:e,snapGrid:n,x:i,y:o}){const s=e.values().next().value;if(!s)return null;const a={x:i-s.distance.x,y:o-s.distance.y},l=Jn(a,n);return{x:l.x-a.x,y:l.y-a.y}}function vh({onNodeMouseDown:e,getStoreItems:n,onDragStart:i,onDrag:o,onDragStop:s}){let a={x:null,y:null},l=0,r=new Map,d=!1,u={x:0,y:0},m=null,c=!1,b=null,v=!1,h=!1,p=null;function g({noDragClassName:N,handleSelector:y,domNode:S,isSelectable:w,nodeId:A,nodeClickDistance:C=0}){b=Pe(S);function E({x:T,y:O}){const{nodeLookup:M,nodeExtent:_,snapGrid:B,snapToGrid:K,nodeOrigin:D,onNodeDrag:L,onSelectionDrag:z,onError:U,updateNodePositions:W}=n();a={x:T,y:O};let Y=!1;const X=r.size>1,ie=X&&_?jo(qn(r)):null,se=X&&K?bh({dragItems:r,snapGrid:B,x:T,y:O}):null;for(const[Q,j]of r){if(!M.has(Q))continue;let V={x:T-j.distance.x,y:O-j.distance.y};K&&(V=se?{x:Math.round(V.x+se.x),y:Math.round(V.y+se.y)}:Jn(V,B));let G=null;if(X&&_&&!j.extent&&ie){const{positionAbsolute:F}=j.internals,q=F.x-ie.x+_[0][0],R=F.x+j.measured.width-ie.x2+_[1][0],Z=F.y-ie.y+_[0][1],J=F.y+j.measured.height-ie.y2+_[1][1];G=[[q,Z],[R,J]]}const{position:H,positionAbsolute:$}=it({nodeId:Q,nextPosition:V,nodeLookup:M,nodeExtent:G||_,nodeOrigin:D,onError:U});Y=Y||j.position.x!==H.x||j.position.y!==H.y,j.position=H,j.internals.positionAbsolute=$}if(h=h||Y,!!Y&&(W(r,!0),p&&(o||L||!A&&z))){const[Q,j]=is({nodeId:A,dragItems:r,nodeLookup:M});o==null||o(p,r,Q,j),L==null||L(p,Q,j),A||z==null||z(p,j)}}async function k(){var D,L;if(!m)return;const{transform:T,panBy:O,autoPanSpeed:M,autoPanOnNodeDrag:_}=n();if(!_){d=!1,cancelAnimationFrame(l);return}const[B,K]=$o(u,m,M);(B!==0||K!==0)&&(a.x=((D=a.x)!=null?D:0)-B/T[2],a.y=((L=a.y)!=null?L:0)-K/T[2],await O({x:B,y:K})&&E(a)),l=requestAnimationFrame(k)}function I(T){var X;const{nodeLookup:O,multiSelectionActive:M,nodesDraggable:_,transform:B,snapGrid:K,snapToGrid:D,selectNodesOnDrag:L,onNodeDragStart:z,onSelectionDragStart:U,unselectNodesAndEdges:W}=n();c=!0,(!L||!w)&&!M&&A&&((X=O.get(A))!=null&&X.selected||W()),w&&L&&A&&(e==null||e(A));const Y=Qn(T.sourceEvent,{transform:B,snapGrid:K,snapToGrid:D,containerBounds:m});if(a=Y,r=mh(O,_,Y,A),r.size>0&&(i||z||!A&&U)){const[ie,se]=is({nodeId:A,dragItems:r,nodeLookup:O});i==null||i(T.sourceEvent,r,ie,se),z==null||z(T.sourceEvent,ie,se),A||U==null||U(T.sourceEvent,se)}}const P=ya().clickDistance(C).on("start",T=>{const{domNode:O,nodeDragThreshold:M,transform:_,snapGrid:B,snapToGrid:K}=n();m=(O==null?void 0:O.getBoundingClientRect())||null,v=!1,h=!1,p=T.sourceEvent,M===0&&I(T),a=Qn(T.sourceEvent,{transform:_,snapGrid:B,snapToGrid:K,containerBounds:m}),u=Oe(T.sourceEvent,m)}).on("drag",T=>{const{autoPanOnNodeDrag:O,transform:M,snapGrid:_,snapToGrid:B,nodeDragThreshold:K,nodeLookup:D}=n(),L=Qn(T.sourceEvent,{transform:M,snapGrid:_,snapToGrid:B,containerBounds:m});if(p=T.sourceEvent,(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1||A&&!D.has(A))&&(v=!0),!v){if(!d&&O&&c&&(d=!0,k()),!c){const z=Oe(T.sourceEvent,m),U=z.x-u.x,W=z.y-u.y;Math.sqrt(U*U+W*W)>K&&I(T)}(a.x!==L.xSnapped||a.y!==L.ySnapped)&&r&&c&&(u=Oe(T.sourceEvent,m),E(L))}}).on("end",T=>{if(!c||v){v&&r.size>0&&n().updateNodePositions(r,!1);return}if(d=!1,c=!1,cancelAnimationFrame(l),r.size>0){const{nodeLookup:O,updateNodePositions:M,onNodeDragStop:_,onSelectionDragStop:B}=n();if(h&&(M(r,!1),h=!1),s||_||!A&&B){const[K,D]=is({nodeId:A,dragItems:r,nodeLookup:O,dragging:!1});s==null||s(T.sourceEvent,r,K,D),_==null||_(T.sourceEvent,K,D),A||B==null||B(T.sourceEvent,D)}}}).filter(T=>{const O=T.target;return!T.button&&(!N||!Lt(O,`.${N}`,S))&&(!y||Lt(O,y,S))});b.call(P)}function f(){b==null||b.on(".drag",null)}return{update:g,destroy:f}}function hh(e,n,i){const o=[],s={x:e.x-i,y:e.y-i,width:i*2,height:i*2};for(const a of n.values())Di(s,Yn(a))>0&&o.push(a);return o}const fh=250;function ph(e,n,i,o){var r,d,u,m,c;let s=[],a=1/0;const l=hh(e,i,n+fh);for(const b of l){const v=[...(d=(r=b.internals.handleBounds)==null?void 0:r.source)!=null?d:[],...(m=(u=b.internals.handleBounds)==null?void 0:u.target)!=null?m:[]];for(const h of v){if(o.nodeId===h.nodeId&&o.type===h.type&&o.id===h.id)continue;const{x:p,y:g}=tn(b,h,h.position,!0),f=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(g-e.y,2));f>n||(f<a?(s=[{...h,x:p,y:g}],a=f):f===a&&s.push({...h,x:p,y:g}))}}if(!s.length)return null;if(s.length>1){const b=o.type==="source"?"target":"source";return(c=s.find(v=>v.type===b))!=null?c:s[0]}return s[0]}function Bt(e,n,i,o,s,a=!1){var u,m,c,b,v,h;const l=o.get(e);if(!l)return null;const r=s==="strict"?(u=l.internals.handleBounds)==null?void 0:u[n]:[...(c=(m=l.internals.handleBounds)==null?void 0:m.source)!=null?c:[],...(v=(b=l.internals.handleBounds)==null?void 0:b.target)!=null?v:[]],d=(h=i?r==null?void 0:r.find(p=>p.id===i):r==null?void 0:r[0])!=null?h:null;return d&&a?{...d,...tn(l,d,d.position,!0)}:d}function It(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function gh(e,n){let i=null;return n?i=!0:e&&!n&&(i=!1),i}const Dt=()=>!0;function yh(e,{connectionMode:n,connectionRadius:i,handleId:o,nodeId:s,edgeUpdaterType:a,isTarget:l,domNode:r,nodeLookup:d,lib:u,autoPanOnConnect:m,flowId:c,panBy:b,cancelConnection:v,onConnectStart:h,onConnect:p,onConnectEnd:g,isValidConnection:f=Dt,onReconnectEnd:N,updateConnection:y,getTransform:S,getFromHandle:w,autoPanSpeed:A,dragThreshold:C=1,handleDomNode:E}){const k=mt(e.target);let I=0,P;const{x:T,y:O}=Oe(e),M=It(a,E),_=r==null?void 0:r.getBoundingClientRect();let B=!1;if(!_||!M)return;const K=Bt(s,M,o,d,n);if(!K)return;let D=Oe(e,_),L=!1,z=null,U=!1,W=null;function Y(){if(!m||!_)return;const[H,$]=$o(D,_,A);b({x:H,y:$}),I=requestAnimationFrame(Y)}const X={...K,nodeId:s,type:M,position:K.position},ie=d.get(s);let Q={inProgress:!0,isValid:null,from:tn(ie,X,oe.Left,!0),fromHandle:X,fromPosition:X.position,fromNode:ie,to:D,toHandle:null,toPosition:Ra[X.position],toNode:null,pointer:D};function j(){B=!0,y(Q),h==null||h(e,{nodeId:s,handleId:o,handleType:M})}C===0&&j();function V(H){if(!B){const{x:J,y:ee}=Oe(H),ae=J-T,ue=ee-O;if(!(ae*ae+ue*ue>C*C))return;j()}if(!w()||!X){G(H);return}const $=S();D=Oe(H,_),P=ph(Zn(D,$,!1,[1,1]),i,d,X),L||(Y(),L=!0);const F=_t(H,{handle:P,connectionMode:n,fromNodeId:s,fromHandleId:o,fromType:l?"target":"source",isValidConnection:f,doc:k,lib:u,flowId:c,nodeLookup:d});W=F.handleDomNode,z=F.connection,U=gh(!!P,F.isValid);const q=d.get(s),R=q?tn(q,X,oe.Left,!0):Q.from,Z={...Q,from:R,isValid:U,to:F.toHandle&&U?Sn({x:F.toHandle.x,y:F.toHandle.y},$):D,toHandle:F.toHandle,toPosition:U&&F.toHandle?F.toHandle.position:Ra[X.position],toNode:F.toHandle?d.get(F.toHandle.nodeId):null,pointer:D};y(Z),Q=Z}function G(H){if(!("touches"in H&&H.touches.length>0)){if(B){(P||W)&&z&&U&&(p==null||p(z));const{inProgress:$,...F}=Q,q={...F,toPosition:Q.toHandle?Q.toPosition:null};g==null||g(H,q),a&&(N==null||N(H,q))}v(),cancelAnimationFrame(I),L=!1,U=!1,z=null,W=null,k.removeEventListener("mousemove",V),k.removeEventListener("mouseup",G),k.removeEventListener("touchmove",V),k.removeEventListener("touchend",G)}}k.addEventListener("mousemove",V),k.addEventListener("mouseup",G),k.addEventListener("touchmove",V),k.addEventListener("touchend",G)}function _t(e,{handle:n,connectionMode:i,fromNodeId:o,fromHandleId:s,fromType:a,doc:l,lib:r,flowId:d,isValidConnection:u=Dt,nodeLookup:m}){const c=a==="target",b=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:v,y:h}=Oe(e),p=l.elementFromPoint(v,h),g=p!=null&&p.classList.contains(`${r}-flow__handle`)?p:b,f={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){const N=It(void 0,g),y=g.getAttribute("data-nodeid"),S=g.getAttribute("data-handleid"),w=g.classList.contains("connectable"),A=g.classList.contains("connectableend");if(!y||!N)return f;const C={source:c?y:o,sourceHandle:c?S:s,target:c?o:y,targetHandle:c?s:S};f.connection=C;const k=w&&A&&(i===gn.Strict?c&&N==="source"||!c&&N==="target":y!==o||S!==s);f.isValid=k&&u(C),f.toHandle=Bt(y,N,S,m,i,!0)}return f}const os={onPointerDown:yh,isValid:_t};function xh({domNode:e,panZoom:n,getTransform:i,getViewScale:o}){const s=Pe(e);function a({translateExtent:r,width:d,height:u,zoomStep:m=1,pannable:c=!0,zoomable:b=!0,inversePan:v=!1}){const h=y=>{if(y.sourceEvent.type!=="wheel"||!n)return;const S=i(),w=y.sourceEvent.ctrlKey&&Xn()?10:1,A=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*m,C=S[2]*Math.pow(2,A*w);n.scaleTo(C)};let p=[0,0];const g=y=>{var S,w;(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(p=[(S=y.sourceEvent.clientX)!=null?S:y.sourceEvent.touches[0].clientX,(w=y.sourceEvent.clientY)!=null?w:y.sourceEvent.touches[0].clientY])},f=y=>{var I,P;const S=i();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!n)return;const w=[(I=y.sourceEvent.clientX)!=null?I:y.sourceEvent.touches[0].clientX,(P=y.sourceEvent.clientY)!=null?P:y.sourceEvent.touches[0].clientY],A=[w[0]-p[0],w[1]-p[1]];p=w;const C=o()*Math.max(S[2],Math.log(S[2]))*(v?-1:1),E={x:S[0]-A[0]*C,y:S[1]-A[1]*C},k=[[0,0],[d,u]];n.setViewportConstrained({x:E.x,y:E.y,zoom:S[2]},k,r)},N=Ja().on("start",g).on("zoom",c?f:null).on("zoom.wheel",b?h:null);s.call(N,{})}function l(){s.on("zoom",null)}return{update:a,destroy:l,pointer:Be}}const Oi=e=>({x:e.x,y:e.y,zoom:e.k}),ss=({x:e,y:n,zoom:i})=>Pi.translate(e,n).scale(i),Nn=(e,n)=>e.target.closest(`.${n}`),Ot=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Sh=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,as=(e,n=0,i=Sh,o=()=>{})=>{const s=typeof n=="number"&&n>0;return s||o(),s?e.transition().duration(n).ease(i).on("end",o):e},Kt=e=>{const n=e.ctrlKey&&Xn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function wh({zoomPanValues:e,noWheelClassName:n,d3Selection:i,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:l,onPanZoomStart:r,onPanZoom:d,onPanZoomEnd:u}){return m=>{if(Nn(m,n))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const c=i.property("__zoom").k||1;if(m.ctrlKey&&l){const g=Be(m),f=Kt(m),N=c*Math.pow(2,f);o.scaleTo(i,N,g,m);return}const b=m.deltaMode===1?20:1;let v=s===on.Vertical?0:m.deltaX*b,h=s===on.Horizontal?0:m.deltaY*b;!Xn()&&m.shiftKey&&s!==on.Vertical&&(v=m.deltaY*b,h=0),o.translateBy(i,-(v/c)*a,-(h/c)*a,{internal:!0});const p=Oi(i.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d==null||d(m,p),e.panScrollTimeout=setTimeout(()=>{u==null||u(m,p),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,r==null||r(m,p))}}function Nh({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:i}){return function(o,s){const a=o.type==="wheel",l=!n&&a&&!o.ctrlKey,r=Nn(o,e);if(o.ctrlKey&&a&&r&&o.preventDefault(),l||r)return null;o.preventDefault(),i.call(this,o,s)}}function Ah({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:i}){return o=>{var a,l,r;if((a=o.sourceEvent)!=null&&a.internal)return;const s=Oi(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 Ch({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:i,onTransformChange:o,onPanZoom:s}){return a=>{var l,r,d;e.usedRightMouseButton=!!(i&&Ot(n,(l=e.mouseButton)!=null?l:0)),(r=a.sourceEvent)!=null&&r.sync||o([a.transform.x,a.transform.y,a.transform.k]),s&&!((d=a.sourceEvent)!=null&&d.internal)&&(s==null||s(a.sourceEvent,Oi(a.transform)))}}function kh({zoomPanValues:e,panOnDrag:n,panOnScroll:i,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:a}){return l=>{var r,d;if(!((r=l.sourceEvent)!=null&&r.internal)&&(e.isZoomingOrPanning=!1,a&&Ot(n,(d=e.mouseButton)!=null?d:0)&&!e.usedRightMouseButton&&l.sourceEvent&&a(l.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const u=Oi(l.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(l.sourceEvent,u)},i?150:0)}}}function Mh({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:i,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:l,noWheelClassName:r,noPanClassName:d,lib:u,connectionInProgress:m}){return c=>{var g;const b=e||n,v=i&&c.ctrlKey,h=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(Nn(c,`${u}-flow__node`)||Nn(c,`${u}-flow__edge`)))return!0;if(!o&&!b&&!s&&!a&&!i||l||m&&!h||Nn(c,r)&&h||Nn(c,d)&&(!h||s&&h&&!e)||!i&&c.ctrlKey&&h)return!1;if(!i&&c.type==="touchstart"&&((g=c.touches)==null?void 0:g.length)>1)return c.preventDefault(),!1;if(!b&&!s&&!v&&h||!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||h)&&p}}function Eh({domNode:e,minZoom:n,maxZoom:i,translateExtent:o,viewport:s,onPanZoom:a,onPanZoomStart:l,onPanZoomEnd:r,onDraggingChange:d}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),c=Ja().scaleExtent([n,i]).translateExtent(o),b=Pe(e).call(c);N({x:s.x,y:s.y,zoom:xn(s.zoom,n,i)},[[0,0],[m.width,m.height]],o);const v=b.on("wheel.zoom"),h=b.on("dblclick.zoom");c.wheelDelta(Kt);async function p(P,T){return b?new Promise(O=>{c==null||c.interpolate((T==null?void 0:T.interpolate)==="linear"?Hn:xi).transform(as(b,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>O(!0)),P)}):!1}function g({noWheelClassName:P,noPanClassName:T,onPaneContextMenu:O,userSelectionActive:M,panOnScroll:_,panOnDrag:B,panOnScrollMode:K,panOnScrollSpeed:D,preventScrolling:L,zoomOnPinch:z,zoomOnScroll:U,zoomOnDoubleClick:W,zoomActivationKeyPressed:Y,lib:X,onTransformChange:ie,connectionInProgress:se,paneClickDistance:Q,selectionOnDrag:j}){M&&!u.isZoomingOrPanning&&f();const V=_&&!Y&&!M;c.clickDistance(j?1/0:!_e(Q)||Q<0?0:Q);const G=V?wh({zoomPanValues:u,noWheelClassName:P,d3Selection:b,d3Zoom:c,panOnScrollMode:K,panOnScrollSpeed:D,zoomOnPinch:z,onPanZoomStart:l,onPanZoom:a,onPanZoomEnd:r}):Nh({noWheelClassName:P,preventScrolling:L,d3ZoomHandler:v});b.on("wheel.zoom",G,{passive:!1});const H=Ah({zoomPanValues:u,onDraggingChange:d,onPanZoomStart:l});c.on("start",H);const $=Ch({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!O,onPanZoom:a,onTransformChange:ie});c.on("zoom",$);const F=kh({zoomPanValues:u,panOnDrag:B,panOnScroll:_,onPaneContextMenu:O,onPanZoomEnd:r,onDraggingChange:d});c.on("end",F);const q=Mh({zoomActivationKeyPressed:Y,panOnDrag:B,zoomOnScroll:U,panOnScroll:_,zoomOnDoubleClick:W,zoomOnPinch:z,userSelectionActive:M,noPanClassName:T,noWheelClassName:P,lib:X,connectionInProgress:se});c.filter(q),W?b.on("dblclick.zoom",h):b.on("dblclick.zoom",null)}function f(){c.on("zoom",null)}async function N(P,T,O){const M=ss(P),_=c==null?void 0:c.constrain()(M,T,O);return _&&await p(_),_}async function y(P,T){const O=ss(P);return await p(O,T),O}function S(P){if(b){const T=ss(P),O=b.property("__zoom");(O.k!==P.zoom||O.x!==P.x||O.y!==P.y)&&(c==null||c.transform(b,T,null,{sync:!0}))}}function w(){const P=b?qa(b.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}async function A(P,T){return b?new Promise(O=>{c==null||c.interpolate((T==null?void 0:T.interpolate)==="linear"?Hn:xi).scaleTo(as(b,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>O(!0)),P)}):!1}async function C(P,T){return b?new Promise(O=>{c==null||c.interpolate((T==null?void 0:T.interpolate)==="linear"?Hn:xi).scaleBy(as(b,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>O(!0)),P)}):!1}function E(P){c==null||c.scaleExtent(P)}function k(P){c==null||c.translateExtent(P)}function I(P){const T=!_e(P)||P<0?0:P;c==null||c.clickDistance(T)}return{update:g,destroy:f,setViewport:y,setViewportConstrained:N,getViewport:w,scaleTo:A,scaleBy:C,setScaleExtent:E,setTranslateExtent:k,syncViewport:S,setClickDistance:I}}var An;(function(e){e.Line="line",e.Handle="handle"})(An||(An={}));function Th({width:e,prevWidth:n,height:i,prevHeight:o,affectsX:s,affectsY:a}){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&&a&&(d[1]=d[1]*-1),d}function Ht(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 Ye(e,n){return Math.max(0,n-e)}function Je(e,n){return Math.max(0,e-n)}function Ki(e,n,i){return Math.max(0,n-e,e-i)}function Gt(e,n){return e?!n:n}function Ph(e,n,i,o,s,a,l,r){let{affectsX:d,affectsY:u}=n;const{isHorizontal:m,isVertical:c}=n,b=m&&c,{xSnapped:v,ySnapped:h}=i,{minWidth:p,maxWidth:g,minHeight:f,maxHeight:N}=o,{x:y,y:S,width:w,height:A,aspectRatio:C}=e;let E=Math.floor(m?v-e.pointerX:0),k=Math.floor(c?h-e.pointerY:0);const I=w+(d?-E:E),P=A+(u?-k:k),T=-a[0]*w,O=-a[1]*A;let M=Ki(I,p,g),_=Ki(P,f,N);if(l){let D=0,L=0;d&&E<0?D=Ye(y+E+T,l[0][0]):!d&&E>0&&(D=Je(y+I+T,l[1][0])),u&&k<0?L=Ye(S+k+O,l[0][1]):!u&&k>0&&(L=Je(S+P+O,l[1][1])),M=Math.max(M,D),_=Math.max(_,L)}if(r){let D=0,L=0;d&&E>0?D=Je(y+E,r[0][0]):!d&&E<0&&(D=Ye(y+I,r[1][0])),u&&k>0?L=Je(S+k,r[0][1]):!u&&k<0&&(L=Ye(S+P,r[1][1])),M=Math.max(M,D),_=Math.max(_,L)}if(s){if(m){const D=Ki(I/C,f,N)*C;if(M=Math.max(M,D),l){let L=0;!d&&!u||d&&!u&&b?L=Je(S+O+I/C,l[1][1])*C:L=Ye(S+O+(d?E:-E)/C,l[0][1])*C,M=Math.max(M,L)}if(r){let L=0;!d&&!u||d&&!u&&b?L=Ye(S+I/C,r[1][1])*C:L=Je(S+(d?E:-E)/C,r[0][1])*C,M=Math.max(M,L)}}if(c){const D=Ki(P*C,p,g)/C;if(_=Math.max(_,D),l){let L=0;!d&&!u||u&&!d&&b?L=Je(y+P*C+T,l[1][0])/C:L=Ye(y+(u?k:-k)*C+T,l[0][0])/C,_=Math.max(_,L)}if(r){let L=0;!d&&!u||u&&!d&&b?L=Ye(y+P*C,r[1][0])/C:L=Je(y+(u?k:-k)*C,r[0][0])/C,_=Math.max(_,L)}}}k=k+(k<0?_:-_),E=E+(E<0?M:-M),s&&(b?I>P*C?k=(Gt(d,u)?-E:E)/C:E=(Gt(d,u)?-k:k)*C:m?(k=E/C,u=d):(E=k*C,d=u));const B=d?y+E:y,K=u?S+k:S;return{width:w+(d?-E:E),height:A+(u?-k:k),x:a[0]*E*(d?-1:1)+B,y:a[1]*k*(u?-1:1)+K}}const Ft={width:0,height:0,x:0,y:0},Lh={...Ft,pointerX:0,pointerY:0,aspectRatio:1};function Bh(e,n,i){var u,m;const o=n.position.x+e.position.x,s=n.position.y+e.position.y,a=(u=e.measured.width)!=null?u:0,l=(m=e.measured.height)!=null?m:0,r=i[0]*a,d=i[1]*l;return[[o-r,s-d],[o+a-r,s+l-d]]}function Ih({domNode:e,nodeId:n,getStoreItems:i,onChange:o,onEnd:s}){const a=Pe(e);let l={controlDirection:Ht("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:m,keepAspectRatio:c,resizeDirection:b,onResizeStart:v,onResize:h,onResizeEnd:p,shouldResize:g}){let f={...Ft},N={...Lh};l={boundaries:m,resizeDirection:b,keepAspectRatio:c,controlDirection:Ht(u)};let y,S=null,w=[],A,C,E,k=!1;const I=ya().on("start",P=>{var z,U,W,Y,X,ie;const{nodeLookup:T,transform:O,snapGrid:M,snapToGrid:_,nodeOrigin:B,paneDomNode:K}=i();if(y=T.get(n),!y)return;S=(z=K==null?void 0:K.getBoundingClientRect())!=null?z:null;const{xSnapped:D,ySnapped:L}=Qn(P.sourceEvent,{transform:O,snapGrid:M,snapToGrid:_,containerBounds:S});f={width:(U=y.measured.width)!=null?U:0,height:(W=y.measured.height)!=null?W:0,x:(Y=y.position.x)!=null?Y:0,y:(X=y.position.y)!=null?X:0},N={...f,pointerX:D,pointerY:L,aspectRatio:f.width/f.height},A=void 0,C=an(y.extent)?y.extent:void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(A=T.get(y.parentId)),A&&y.extent==="parent"&&(C=[[0,0],[A.measured.width,A.measured.height]]),w=[],E=void 0;for(const[se,Q]of T)if(Q.parentId===n&&(w.push({id:se,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const j=Bh(Q,y,(ie=Q.origin)!=null?ie:B);E?E=[[Math.min(j[0][0],E[0][0]),Math.min(j[0][1],E[0][1])],[Math.max(j[1][0],E[1][0]),Math.max(j[1][1],E[1][1])]]:E=j}v==null||v(P,{...f})}).on("drag",P=>{var R,Z,J;const{transform:T,snapGrid:O,snapToGrid:M,nodeOrigin:_}=i(),B=Qn(P.sourceEvent,{transform:T,snapGrid:O,snapToGrid:M,containerBounds:S}),K=[];if(!y)return;const{x:D,y:L,width:z,height:U}=f,W={},Y=(R=y.origin)!=null?R:_,{width:X,height:ie,x:se,y:Q}=Ph(N,l.controlDirection,B,l.boundaries,l.keepAspectRatio,Y,C,E),j=X!==z,V=ie!==U,G=se!==D&&j,H=Q!==L&&V;if(!G&&!H&&!j&&!V)return;if((G||H||Y[0]===1||Y[1]===1)&&(W.x=G?se:f.x,W.y=H?Q:f.y,f.x=W.x,f.y=W.y,w.length>0)){const ee=se-D,ae=Q-L;for(const ue of w)ue.position={x:ue.position.x-ee+Y[0]*(X-z),y:ue.position.y-ae+Y[1]*(ie-U)},K.push(ue)}if((j||V)&&(W.width=j&&(!l.resizeDirection||l.resizeDirection==="horizontal")?X:f.width,W.height=V&&(!l.resizeDirection||l.resizeDirection==="vertical")?ie:f.height,f.width=W.width,f.height=W.height),A&&y.expandParent){const ee=Y[0]*((Z=W.width)!=null?Z:0);W.x&&W.x<ee&&(f.x=ee,N.x=N.x-(W.x-ee));const ae=Y[1]*((J=W.height)!=null?J:0);W.y&&W.y<ae&&(f.y=ae,N.y=N.y-(W.y-ae))}const $=Th({width:f.width,prevWidth:z,height:f.height,prevHeight:U,affectsX:l.controlDirection.affectsX,affectsY:l.controlDirection.affectsY}),F={...f,direction:$};(g==null?void 0:g(P,F))!==!1&&(k=!0,h==null||h(P,F),o(W,K))}).on("end",P=>{k&&(p==null||p(P,{...f}),s==null||s({...f}),k=!1)});a.call(I)}function d(){a.on(".drag",null)}return{update:r,destroy:d}}function Dh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Hi={exports:{}},ts={},Gi={exports:{}},ls={};/**
31
31
  * @license React
32
32
  * use-sync-external-store-shim.production.js
33
33
  *