gaesup-world 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blueprints-editor.cjs +1 -1
- package/dist/blueprints-editor.js +2 -2
- package/dist/core/interactions/components/Clicker/index.d.ts +1 -4
- package/dist/editor.cjs +1 -1
- package/dist/editor.js +2 -2
- package/dist/{index-Drmv86ws.js → index-3WAK67Ha.js} +1 -1
- package/dist/{index-DShLht0Q.js → index-B0oz8u47.js} +1 -1
- package/dist/index-B3DY2LIR.js +320 -0
- package/dist/{index-syAx2qzT.cjs → index-C7uc7Whg.cjs} +1 -1
- package/dist/index-Ctehfr0N.cjs +1 -0
- package/dist/{index-BUQXtHf3.js → index-DGifA0e6.js} +5 -4
- package/dist/{index-D0Rz5_-J.js → index-DRLvJF_k.js} +5 -4
- package/dist/index-De3ev_jU.cjs +1 -0
- package/dist/{index-DHZJyO9k.cjs → index-RPpT5kHy.cjs} +1 -1
- package/dist/index-TNaPJQpb.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +11 -11
- package/dist/network.cjs +1 -1
- package/dist/network.js +2 -2
- package/dist/{plugin-CS2nMv9n.cjs → plugin-B4lSjyeZ.cjs} +1 -1
- package/dist/{plugin-BEJHB06f.js → plugin-BFzSydfr.js} +35 -34
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +5 -5
- package/package.json +1 -1
- package/dist/index-CHoKlv0U.cjs +0 -1
- package/dist/index-D1hpjfAw.cjs +0 -1
- package/dist/index-HxpKt5rO.js +0 -320
- package/dist/index-co-QAQz9.cjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const o=require("react/jsx-runtime"),m=require("react"),ge=require("./gaesupStore-2zKBYTYo.cjs"),R=require("./index-CJj-Z7Jr.cjs"),xe=require("@react-three/fiber"),lt=require("@react-three/rapier"),Wc=require("zustand/traditional"),Me=require("zustand/shallow");require("react-dom");const _n=require("./assetStore-DVPge_2j.cjs"),xi=require("./index-DCa_lUwq.cjs"),li=require("zustand"),ma=require("zustand/react/shallow"),Fe=require("./loader-D7cEHkCq.cjs"),ei=require("./index-co-QAQz9.cjs"),ft=require("@react-three/drei"),Yp=require("three"),wo=require("./sfe-CpgzdMyB.cjs"),Zp=require("immer"),Xp=require("zustand/middleware/immer"),ga=require("three-stdlib"),ba=require("./weatherStore-1unmwIen.cjs"),xa=require("simplex-noise");function Kp(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const B=Kp(Yp);function Oe({label:e,min:t,max:n,step:i,value:s,suffix:r,onChange:a}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"#fff"},children:[o.jsx("span",{style:{width:60,flexShrink:0,color:"rgba(255,255,255,0.7)"},children:e}),o.jsx("input",{type:"range",min:t,max:n,step:i,value:s,onChange:l=>a(Number(l.target.value)),style:{flex:1,accentColor:"#0078d4"}}),o.jsxs("span",{style:{width:44,textAlign:"right",fontFamily:"monospace",fontSize:11},children:[typeof i=="number"&&i<1?s.toFixed(2):s,r??""]})]})}function nr({label:e,checked:t,onChange:n}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,color:"#fff"},children:[o.jsx("input",{type:"checkbox",checked:t,onChange:i=>n(i.target.checked),style:{accentColor:"#0078d4"}}),o.jsx("span",{children:e})]})}function Oi({title:e,children:t}){return o.jsxs("div",{style:{background:"rgba(0,0,0,0.2)",borderRadius:6,padding:"8px 10px",border:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",gap:6},children:[o.jsx("div",{style:{fontSize:10,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:.5},children:e}),t]})}function qp(){const e=ge.useGaesupStore(a=>a.cameraOption),t=ge.useGaesupStore(a=>a.setCameraOption),n=ge.useGaesupStore(a=>a.mode),i=m.useCallback((a,l)=>{t({[a]:l})},[t]),s=m.useCallback((a,l)=>{t({smoothing:{...e.smoothing,[a]:l}})},[t,e.smoothing]),r=a=>e[a]??0;return o.jsxs("div",{style:{padding:10,display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:-4},children:["Mode: ",n.control??"thirdPerson"]}),o.jsxs(Oi,{title:"Distance",children:[o.jsx(Oe,{label:"X",min:-50,max:50,step:1,value:r("xDistance"),onChange:a=>i("xDistance",a)}),o.jsx(Oe,{label:"Y",min:0,max:50,step:1,value:r("yDistance"),onChange:a=>i("yDistance",a)}),o.jsx(Oe,{label:"Z",min:-50,max:50,step:1,value:r("zDistance"),onChange:a=>i("zDistance",a)})]}),o.jsxs(Oi,{title:"FOV / Smoothing",children:[o.jsx(Oe,{label:"FOV",min:30,max:120,step:5,value:e.fov??75,suffix:"deg",onChange:a=>i("fov",a)}),o.jsx(Oe,{label:"Pos",min:.01,max:1,step:.01,value:e.smoothing?.position??.1,onChange:a=>s("position",a)}),o.jsx(Oe,{label:"Rot",min:.01,max:1,step:.01,value:e.smoothing?.rotation??.1,onChange:a=>s("rotation",a)}),o.jsx(Oe,{label:"FOV Sm",min:.01,max:1,step:.01,value:e.smoothing?.fov??.2,onChange:a=>s("fov",a)})]}),o.jsxs(Oi,{title:"Zoom",children:[o.jsx(nr,{label:"Enable Zoom",checked:e.enableZoom??!1,onChange:a=>i("enableZoom",a)}),o.jsx(Oe,{label:"Speed",min:1e-4,max:.01,step:1e-4,value:e.zoomSpeed??.001,onChange:a=>i("zoomSpeed",a)}),o.jsx(Oe,{label:"Min",min:.1,max:2,step:.1,value:e.minZoom??.5,onChange:a=>i("minZoom",a)}),o.jsx(Oe,{label:"Max",min:1,max:5,step:.1,value:e.maxZoom??2,onChange:a=>i("maxZoom",a)})]}),o.jsxs(Oi,{title:"Options",children:[o.jsx(nr,{label:"Collision",checked:e.enableCollision??!1,onChange:a=>i("enableCollision",a)}),o.jsx(nr,{label:"Focus Mode",checked:e.enableFocus??!1,onChange:a=>i("enableFocus",a)}),o.jsx(Oe,{label:"Focus Dist",min:1,max:50,step:1,value:e.focusDistance??15,onChange:a=>i("focusDistance",a)}),o.jsx(Oe,{label:"Max Dist",min:5,max:100,step:1,value:e.maxDistance??50,onChange:a=>i("maxDistance",a)})]}),o.jsxs(Oi,{title:"Bounds",children:[o.jsx(Oe,{label:"Min Y",min:-10,max:50,step:1,value:e.bounds?.minY??2,onChange:a=>t({bounds:{...e.bounds,minY:a}})}),o.jsx(Oe,{label:"Max Y",min:5,max:100,step:1,value:e.bounds?.maxY??50,onChange:a=>t({bounds:{...e.bounds,maxY:a}})})]})]})}const Qp=[{value:"thirdPerson",label:"Third Person"},{value:"firstPerson",label:"First Person"},{value:"chase",label:"Chase"},{value:"topDown",label:"Top Down"},{value:"isometric",label:"Isometric"},{value:"sideScroll",label:"Side-Scroller"},{value:"fixed",label:"Fixed"}];function Jp(){const{mode:e,setMode:t}=ge.useGaesupStore(ma.useShallow(i=>({mode:i.mode,setMode:i.setMode}))),n=e?.control||"thirdPerson";return o.jsx("div",{className:"cc-panel",children:o.jsx("div",{className:"cc-list",children:Qp.map(i=>o.jsx("button",{className:`cc-button ${n===i.value?"active":""}`,onClick:()=>t({control:i.value}),children:i.label},i.value))})})}const eh=[{key:"mode",label:"Mode",enabled:!0,format:"text"},{key:"position",label:"Position",enabled:!0,format:"vector3",precision:2},{key:"distance",label:"Distance",enabled:!0,format:"vector3",precision:2},{key:"fov",label:"FOV",enabled:!0,format:"angle",precision:1},{key:"velocity",label:"Velocity",enabled:!1,format:"vector3",precision:2},{key:"rotation",label:"Rotation",enabled:!1,format:"vector3",precision:2},{key:"zoom",label:"Zoom",enabled:!1,format:"number",precision:2},{key:"activeController",label:"Controller",enabled:!0,format:"text"}];function ir(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"}function th(){const e={frameCount:0,averageFrameTime:0,lastUpdateTime:Date.now(),mode:"unknown",activeController:"unknown",distance:null,fov:0,position:null,targetPosition:null,velocity:null,rotation:null},[t,n]=m.useState(e),i=ge.useGaesupStore(f=>f.mode),s=ge.useGaesupStore(f=>f.cameraOption),{activeState:r}=R.useStateSystem(),a=m.useRef(e),l=m.useCallback((f,p)=>f===p?!1:ir(f)?ir(p)?f.x!==p.x||f.y!==p.y||f.z!==p.z:!0:typeof f!="object"||f===null?!0:JSON.stringify(f)!==JSON.stringify(p),[]),c=m.useCallback(f=>ir(f)?{x:f.x,y:f.y,z:f.z}:null,[]),u=m.useCallback(()=>{const f=s?.xDistance!==void 0&&s?.yDistance!==void 0&&s?.zDistance!==void 0?{x:s.xDistance,y:s.yDistance,z:s.zDistance}:null,p={...a.current,mode:i?.control??"unknown",activeController:s?.mode??i?.control??"unknown",distance:f,fov:s?.fov??0,position:c(r?.position),targetPosition:c(s?.target),velocity:c(r?.velocity),rotation:c(r?.euler),lastUpdateTime:Date.now(),...s?.zoom!==void 0?{zoom:s.zoom}:{}};Object.keys(p).some(w=>l(p[w],a.current[w]))&&(a.current=p,n(p))},[i,s,r,l,c]);m.useEffect(()=>{u();const f=setInterval(u,100);return()=>{clearInterval(f)}},[u]);const d=m.useCallback((f,p=2)=>f==null?"N/A":typeof f=="object"&&f.x!==void 0?`X:${f.x.toFixed(p)} Y:${f.y.toFixed(p)} Z:${f.z.toFixed(p)}`:typeof f=="number"?f.toFixed(p):f.toString(),[]);return o.jsx("div",{className:"cd-panel",children:o.jsx("div",{className:"cd-grid",children:eh.map(f=>o.jsxs("div",{className:"cd-item",children:[o.jsx("span",{className:"cd-label",children:f.label}),o.jsx("span",{className:"cd-value",children:d(t[f.key])})]},f.key))})})}const nh=[{id:"classic",name:"Classic",description:"A traditional third-person view.",icon:"camera",config:{mode:"thirdPerson",distance:{x:0,y:8,z:10},fov:75,smoothing:{position:.1,rotation:.1,fov:.1}}},{id:"cinematic",name:"Cinematic",description:"Smooth, movie-like camera work.",icon:"camera",config:{mode:"chase",distance:{x:2,y:7,z:8},fov:60,smoothing:{position:.05,rotation:.05,fov:.05}}},{id:"action",name:"Action",description:"Responsive camera for fast gameplay.",icon:"camera",config:{mode:"thirdPerson",distance:{x:0,y:6,z:6},fov:85,smoothing:{position:.2,rotation:.2,fov:.2}}},{id:"strategy",name:"Strategy",description:"Top-down view for an overview.",icon:"camera",config:{mode:"topDown",distance:{x:0,y:20,z:0},fov:45,smoothing:{position:.1,rotation:.1,fov:.1}}},{id:"retro",name:"Retro",description:"Classic side-scroller style.",icon:"camera",config:{mode:"sideScroll",distance:{x:15,y:0,z:0},fov:75,smoothing:{position:.15,rotation:.15,fov:.15}}}];function ih(e,t){return!e||!t?!1:e.x===t.x&&e.y===t.y&&e.z===t.z}function oh(e){const t=e?.xDistance,n=e?.yDistance,i=e?.zDistance;if(!(t===void 0||n===void 0||i===void 0))return{x:t,y:n,z:i}}function Uc(){const[e]=m.useState(nh),t=ge.useGaesupStore(c=>c.setMode),n=ge.useGaesupStore(c=>c.setCameraOption),i=ge.useGaesupStore(c=>c.mode),s=ge.useGaesupStore(c=>c.cameraOption),[r,a]=m.useState(null),l=m.useCallback(c=>{t({control:c.config.mode}),n({xDistance:c.config.distance.x,yDistance:c.config.distance.y,zDistance:c.config.distance.z,fov:c.config.fov,smoothing:c.config.smoothing||{position:.1,rotation:.1,fov:.1}})},[t,n,s]);return m.useEffect(()=>{const c=e.find(u=>u.config.mode===i?.control&&ih(u.config.distance,oh(s)));a(c?c.id:null)},[i,s,e]),o.jsx("div",{className:"cp-panel",children:o.jsx("div",{className:"cp-grid",children:e.map(c=>o.jsxs("button",{className:`cp-item ${r===c.id?"active":""}`,onClick:()=>l(c),children:[o.jsx("div",{className:"cp-name",children:c.name}),o.jsx("div",{className:"cp-description",children:c.description})]},c.id))})})}function Vc({className:e="",style:t,children:n}={}){const[i,s]=m.useState("Settings"),r=()=>{switch(i){case"Settings":return o.jsx(qp,{});case"Controller":return o.jsx(Jp,{});case"Presets":return o.jsx(Uc,{});case"Debug":return o.jsx(th,{});default:return null}};return o.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[o.jsxs("div",{className:"panel-tabs",children:[o.jsx("button",{className:`panel-tab ${i==="Settings"?"active":""}`,onClick:()=>s("Settings"),children:"Settings"}),o.jsx("button",{className:`panel-tab ${i==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),o.jsx("button",{className:`panel-tab ${i==="Presets"?"active":""}`,onClick:()=>s("Presets"),children:"Presets"}),o.jsx("button",{className:`panel-tab ${i==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),o.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const sh=[{value:"idle",label:"Idle"},{value:"walk",label:"Walk"},{value:"run",label:"Run"},{value:"jump",label:"Jump"},{value:"fall",label:"Fall"},{value:"dance",label:"Dance"},{value:"wave",label:"Wave"}];function rh(){const{playAnimation:e,currentType:t,currentAnimation:n}=R.useAnimationBridge(),i=s=>{e(t,s)};return o.jsx("div",{className:"ac-panel",children:o.jsx("div",{className:"ac-grid",children:sh.map(s=>o.jsx("button",{className:`ac-button ${s.value===n?"active":""}`,onClick:()=>i(s.value),title:s.label,children:s.label},s.value))})})}const ah=[{key:"currentAnimation",label:"현재 애니메이션",format:"text",enabled:!0},{key:"animationType",label:"애니메이션 타입",format:"text",enabled:!0},{key:"isPlaying",label:"재생 상태",format:"text",enabled:!0},{key:"weight",label:"가중치",format:"number",enabled:!0},{key:"speed",label:"속도",format:"number",enabled:!0},{key:"blendDuration",label:"블렌드 시간",format:"number",enabled:!1},{key:"activeActions",label:"활성 액션",format:"number",enabled:!0},{key:"availableAnimations",label:"사용 가능 애니메이션",format:"array",enabled:!1},{key:"frameCount",label:"프레임 카운트",format:"number",enabled:!1},{key:"averageFrameTime",label:"평균 프레임 시간",format:"number",enabled:!1}];function lh(){const{bridge:e,currentType:t}=R.useAnimationBridge(),[n,i]=m.useState({frameCount:0,averageFrameTime:0,lastUpdateTime:Date.now(),currentAnimation:"idle",animationType:"character",availableAnimations:[],isPlaying:!1,weight:1,speed:1,blendDuration:.3,activeActions:0});m.useEffect(()=>{if(!e)return;const a=()=>{const c=e.snapshot(t);if(!c)return;const u=e.getMetrics(t);i(d=>({...d,currentAnimation:c.currentAnimation,animationType:t,availableAnimations:c.availableAnimations,isPlaying:c.isPlaying,weight:c.weight,speed:c.speed,activeActions:c.metrics.activeAnimations,frameCount:u?.totalActions||0,averageFrameTime:u?.mixerTime||0,lastUpdateTime:Date.now()}))};return a(),e.subscribe((c,u)=>{u===t&&a()})},[e,t]);const s=(a,l,c=2)=>{if(a==null)return"N/A";switch(l){case"array":return Array.isArray(a)?`${a.length} animations`:String(a);case"boolean":return a?"Yes":"No";case"number":return typeof a=="number"?a.toFixed(c):String(a);default:return String(a)}},r=a=>{if(a in n)return n[a]};return o.jsx("div",{className:"ad-panel",children:o.jsx("div",{className:"ad-content",children:ah.filter(a=>a.enabled).map(a=>o.jsxs("div",{className:"ad-item",children:[o.jsx("span",{className:"ad-label",children:a.label}),o.jsx("span",{className:"ad-value",children:s(r(a.key),a.format)})]},a.key))})})}const ch=()=>o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M8 5v14l11-7z"})}),uh=()=>o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),dh=()=>o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M6 6h2v12H6zm3.5 6l8.5 6V6z"})}),fh=()=>o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"})});function ph(){const{bridge:e,playAnimation:t,stopAnimation:n,currentType:i,currentAnimation:s}=R.useAnimationBridge(),[r,a]=m.useState(!1),[l,c]=m.useState([]),[u,d]=m.useState(30);m.useEffect(()=>{if(!e)return;const p=()=>{const w=e.snapshot(i);w&&(a(w.isPlaying),c(w.availableAnimations))};return p(),e.subscribe((w,b)=>{b===i&&p()})},[e,i]);const f=()=>{r?n(i):t(i,s)};return o.jsxs("div",{className:"ap-panel",children:[o.jsxs("div",{className:"ap-controls",children:[o.jsx("select",{className:"ap-select",value:s,onChange:p=>t(i,p.target.value),children:l.map(p=>o.jsx("option",{value:p,children:p},p))}),o.jsxs("div",{className:"ap-buttons",children:[o.jsx("button",{className:"ap-btn","aria-label":"previous animation",children:o.jsx(dh,{})}),o.jsx("button",{className:"ap-btn-primary",onClick:f,"aria-label":r?"pause":"play",children:r?o.jsx(uh,{}):o.jsx(ch,{})}),o.jsx("button",{className:"ap-btn","aria-label":"next animation",children:o.jsx(fh,{})})]})]}),o.jsxs("div",{className:"ap-timeline",children:[o.jsx("span",{className:"ap-time",children:"0:00"}),o.jsx("input",{type:"range",className:"ap-slider",min:"0",max:"100",value:u,onChange:p=>d(Number(p.target.value))}),o.jsx("span",{className:"ap-time",children:"1:30"})]})]})}function Yc({className:e="",style:t,children:n}={}){const[i,s]=m.useState("Player"),r=()=>{switch(i){case"Player":return o.jsx("div",{className:"panel-content-wrapper",children:o.jsx(ph,{})});case"Controller":return o.jsx("div",{className:"panel-content-wrapper",children:o.jsx(rh,{})});case"Debug":return o.jsx("div",{className:"panel-content-wrapper",children:o.jsx(lh,{})});default:return null}};return o.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[o.jsxs("div",{className:"panel-tabs",children:[o.jsx("button",{className:`panel-tab ${i==="Player"?"active":""}`,onClick:()=>s("Player"),children:"Player"}),o.jsx("button",{className:`panel-tab ${i==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),o.jsx("button",{className:`panel-tab ${i==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),o.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const il=[{id:"slow",name:"Slow",maxSpeed:5,acceleration:8},{id:"normal",name:"Normal",maxSpeed:10,acceleration:15},{id:"fast",name:"Fast",maxSpeed:20,acceleration:25},{id:"sprint",name:"Sprint",maxSpeed:35,acceleration:40}],ol=[{id:"eco",name:"Eco",maxSpeed:15,acceleration:10},{id:"comfort",name:"Comfort",maxSpeed:25,acceleration:20},{id:"sport",name:"Sport",maxSpeed:40,acceleration:35},{id:"turbo",name:"Turbo",maxSpeed:60,acceleration:50}];function hh(e,t){const n=e??"bottom-left",i={position:"fixed",zIndex:t??1e4};return n.includes("top")&&(i.top=12),n.includes("bottom")&&(i.bottom=12),n.includes("left")&&(i.left=12),n.includes("right")&&(i.right=12),i}function Zc(e){const t=hh(e.position,e.zIndex),n=ge.useGaesupStore(p=>p.mode),i=ge.useGaesupStore(p=>p.setMode),s=ge.useGaesupStore(p=>p.setPhysics),r=n?.type==="vehicle"?"vehicle":"character",a=r==="vehicle"?ol:il,[l,c]=m.useState(r==="vehicle"?"comfort":"normal"),u=m.useCallback((p,h)=>{const b=(p==="vehicle"?ol:il).find(S=>S.id===h);if(b){if(p==="vehicle"){s({maxSpeed:b.maxSpeed,accelRatio:b.acceleration});return}s({walkSpeed:Math.max(1,b.maxSpeed*.5),runSpeed:b.maxSpeed,accelRatio:b.acceleration})}},[s]),d=m.useCallback(p=>{c(p),u(r,p),e.onPresetChange?.(p)},[u,r,e]),f=m.useCallback(p=>{const h=p.target.value;i({type:h});const w=h==="vehicle"?"comfort":"normal";c(w),u(h,w),e.onPresetChange?.(w)},[u,i,e]);return o.jsxs("div",{className:`mc-panel ${e.compact?"compact":""}`,style:t,children:[o.jsxs("div",{className:"mc-setting-row",children:[o.jsx("label",{htmlFor:"motion-type-select",className:"mc-label",children:"Motion Type"}),o.jsxs("select",{id:"motion-type-select",className:"mc-select",value:r,onChange:f,children:[o.jsx("option",{value:"character",children:"Character"}),o.jsx("option",{value:"vehicle",children:"Vehicle"})]})]}),o.jsxs("div",{className:"mc-setting-row",children:[o.jsx("label",{className:"mc-label",children:"Presets"}),o.jsx("div",{className:"mc-presets-grid",children:a.map(p=>o.jsx("button",{className:`mc-preset-btn ${p.id===l?"active":""}`,onClick:()=>d(p.id),title:`Max Speed: ${p.maxSpeed}, Accel: ${p.acceleration}`,children:p.name},p.id))})]})]})}const sl=[{key:"motionType",label:"Motion Type",type:"text"},{key:"position",label:"Position",type:"vector3"},{key:"velocity",label:"Velocity",type:"vector3"},{key:"speed",label:"Speed",type:"number"},{key:"direction",label:"Direction",type:"vector3"},{key:"isGrounded",label:"Grounded",type:"text"},{key:"isMoving",label:"Moving",type:"text"},{key:"acceleration",label:"Acceleration",type:"number"},{key:"jumpForce",label:"Jump Force",type:"number"},{key:"maxSpeed",label:"Max Speed",type:"number"},{key:"totalDistance",label:"Total Distance",type:"number"},{key:"gameState",label:"Game State",type:"text"}];function mh(e,t){const n=e??"top-right",i={position:"fixed",zIndex:t??1e4};return n.includes("top")&&(i.top=12),n.includes("bottom")&&(i.bottom=12),n.includes("left")&&(i.left=12),n.includes("right")&&(i.right=12),i}function Xc(e){const t=e.embedded?{}:mh(e.position,e.zIndex),n=ge.useGaesupStore(d=>d.mode),i=ge.useGaesupStore(d=>d.physics),{activeState:s,gameStates:r}=R.useStateSystem(),a=e.precision??2,l=e.customFields?[...sl,...e.customFields]:sl,c=(d,f,p=2)=>{if(f==null)return"N/A";switch(d.type){case"vector3":if(Array.isArray(f)&&f.length===3){const[h,w,b]=f;return`X:${h.toFixed(p)} Y:${w.toFixed(p)} Z:${b.toFixed(p)}`}if(typeof f=="object"&&f!==null&&"x"in f&&"y"in f&&"z"in f){const h=f;return`X:${h.x.toFixed(p)} Y:${h.y.toFixed(p)} Z:${h.z.toFixed(p)}`}return String(f);case"number":return typeof f=="number"?f.toFixed(p):String(f);default:return String(f)}},u=d=>{if(d.value!==void 0)return d.value;switch(d.key){case"motionType":return n?.type??"character";case"position":return s?.position?{x:s.position.x,y:s.position.y,z:s.position.z}:{x:0,y:0,z:0};case"velocity":return s?.velocity?{x:s.velocity.x,y:s.velocity.y,z:s.velocity.z}:{x:0,y:0,z:0};case"speed":return s?.velocity?s.velocity.length():0;case"direction":return s?.direction?{x:s.direction.x,y:s.direction.y,z:s.direction.z}:{x:0,y:0,z:0};case"isGrounded":return r?.isOnTheGround?"Yes":"No";case"isMoving":return r?.isMoving?"Yes":"No";case"acceleration":return i?.accelRatio??0;case"jumpForce":return i?.jumpSpeed??0;case"maxSpeed":return n?.type==="character"?i?.runSpeed??0:i?.maxSpeed??0;case"totalDistance":return 0;case"gameState":return r?.isRiding?"riding":r?.isOnTheGround?"ground":"air";default:return null}};return o.jsx("div",{className:`md-panel ${e.compact?"compact":""} ${e.theme?`theme-${e.theme}`:""}`,style:t,children:o.jsx("div",{className:"md-content",children:l.map(d=>o.jsxs("div",{className:"md-item",children:[o.jsx("span",{className:"md-label",children:d.label}),o.jsx("span",{className:"md-value",children:c(d,u(d),a)})]},d.key))})})}function Kc({className:e="",style:t,children:n}={}){const[i,s]=m.useState("Controller"),r=()=>{switch(i){case"Controller":return o.jsx("div",{className:"panel-content-wrapper",children:o.jsx(Zc,{})});case"Debug":return o.jsx("div",{className:"panel-content-wrapper",children:o.jsx(Xc,{embedded:!0})});default:return null}};return o.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[o.jsxs("div",{className:"panel-tabs",children:[o.jsx("button",{className:`panel-tab ${i==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),o.jsx("button",{className:`panel-tab ${i==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),o.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const Ao=60,ko=({data:e,color:t,max:n,warn:i})=>{const r=e.filter(c=>isFinite(c));if(r.length<2)return null;const a=Math.max(1,n),l=r.map((c,u)=>{const d=u/(r.length-1)*100,f=40-c/a*40;return`${u===0?"M":"L"}${d.toFixed(2)},${f.toFixed(2)}`}).join(" ");return o.jsx("div",{className:"perf-chart",children:o.jsxs("svg",{width:"100%",height:40,preserveAspectRatio:"none",viewBox:"0 0 100 40",children:[i!==void 0&&o.jsx("line",{x1:"0",y1:40-i/a*40,x2:"100",y2:40-i/a*40,stroke:"#facc15",strokeWidth:"0.5",strokeDasharray:"3,3",opacity:.5}),o.jsx("path",{d:l,fill:"none",stroke:t,strokeWidth:"2",strokeLinejoin:"round",strokeLinecap:"round"})]})})},or=({value:e,max:t,color:n,label:i})=>{const s=t>0?Math.min(100,e/t*100):0;return o.jsxs("div",{style:{marginBottom:4},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,marginBottom:2},children:[o.jsx("span",{className:"perf-label",children:i}),o.jsx("span",{children:e.toFixed(1)})]}),o.jsx("div",{style:{height:4,background:"#1e293b",borderRadius:2,overflow:"hidden"},children:o.jsx("div",{style:{width:`${s}%`,height:"100%",background:n,borderRadius:2,transition:"width 0.3s"}})})]})};function qc({className:e="",style:t,children:n}={}){const i=ge.useGaesupStore(ma.useShallow(P=>P.performance)),[s,r]=m.useState({current:0,min:1/0,max:0,avg:0,p1Low:0,history:Array(Ao).fill(0)}),[a,l]=m.useState({used:0,limit:0,history:Array(Ao).fill(0)}),[c,u]=m.useState(0),[d,f]=m.useState(Array(Ao).fill(0)),[p,h]=m.useState(Array(Ao).fill(0)),w=m.useRef(0),b=m.useRef(0),S=m.useRef(0),x=m.useRef([]),_=m.useRef(0),g=m.useRef(null),y=m.useRef(0),v=m.useRef(0),j=m.useRef(0),T=m.useCallback(P=>{if(P.length<5)return 0;const z=[...P].filter(U=>U>0).sort((U,V)=>U-V),M=Math.max(1,Math.floor(z.length*.01));let F=0;for(let U=0;U<M;U++)F+=z[U]??0;return F/M},[]);m.useEffect(()=>{const P=window.performance.now();w.current=P,b.current=P,_.current=P;const z=M=>{const F=M-b.current;if(b.current=M,x.current.push(F),x.current.length>300&&x.current.shift(),y.current+=F,v.current++,v.current>=10){const U=y.current/v.current;u(U),h(V=>[...V.slice(1),U]),y.current=0,v.current=0}if(S.current++,M-w.current>=500){const U=S.current*1e3/(M-w.current),V=x.current.map(Q=>Q>0?1e3/Q:0),Z=M-_.current>3e3;r(Q=>{const K=[...Q.history.slice(1),U],E=Z?Math.min(Q.min===1/0?U:Q.min,U):1/0,C=Z?Math.max(Q.max,U):0,W=Z?K.filter(ee=>ee>0):[],X=W.length>0?W.reduce((ee,ne)=>ee+ne,0)/W.length:U,q=Z?T(V):U;return{current:U,min:E,max:C,avg:X,p1Low:q,history:K}});const Y=window.performance.memory;Y&&l(Q=>{const K=Math.round(Y.usedJSHeapSize/1048576),E=Math.round(Y.jsHeapSizeLimit/1048576);return{used:K,limit:E,history:[...Q.history.slice(1),K]}}),w.current=M,S.current=0}g.current=requestAnimationFrame(z)};return g.current=requestAnimationFrame(z),()=>{g.current&&cancelAnimationFrame(g.current)}},[T]),m.useEffect(()=>{const P=i.render.calls;P!==j.current&&(j.current=P,f(z=>[...z.slice(1),P]))},[i.render.calls]);const k=P=>P>=55?"#4ade80":P>=30?"#facc15":"#f87171",D=P=>P<=16.7?"#4ade80":P<=33.3?"#facc15":"#f87171",$=P=>P<=100?"#4ade80":P<=300?"#facc15":"#f87171",L=(P,z)=>{const M=z>0?P/z*100:0;return M<60?"#4ade80":M<80?"#facc15":"#f87171"},I=i.render.triangles,H=i.render.calls,N=i.engine.geometries,O=i.engine.textures;return o.jsxs("div",{className:`perf-panel ${e}`,style:t,children:[o.jsxs("div",{className:"perf-stat-group",children:[o.jsxs("div",{className:"perf-header",children:[o.jsx("h4",{className:"perf-title",children:"Frame Rate"}),o.jsxs("span",{className:"perf-current",style:{color:k(s.current)},children:[s.current.toFixed(0)," FPS"]})]}),o.jsxs("div",{className:"perf-details-grid",children:[o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Avg"}),s.avg.toFixed(1)]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Min"}),isFinite(s.min)?s.min.toFixed(1):"..."]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Max"}),s.max.toFixed(1)]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"1% Low"}),o.jsx("span",{style:{color:k(s.p1Low)},children:s.p1Low.toFixed(1)})]})]}),o.jsx(ko,{data:s.history,color:k(s.current),max:90,warn:60})]}),o.jsxs("div",{className:"perf-stat-group",children:[o.jsxs("div",{className:"perf-header",children:[o.jsx("h4",{className:"perf-title",children:"Frame Time"}),o.jsxs("span",{className:"perf-current",style:{color:D(c)},children:[c.toFixed(2)," ms"]})]}),o.jsx(or,{value:c,max:33.3,color:D(c),label:"Budget (16.7ms)"}),o.jsx(ko,{data:p,color:D(c),max:33.3,warn:16.7})]}),o.jsxs("div",{className:"perf-stat-group",children:[o.jsxs("div",{className:"perf-header",children:[o.jsx("h4",{className:"perf-title",children:"GPU Pipeline"}),o.jsxs("span",{className:"perf-current",style:{color:$(H)},children:[H," calls"]})]}),o.jsxs("div",{className:"perf-details-grid",children:[o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Triangles"}),I>=1e6?(I/1e6).toFixed(2)+"M":I>=1e3?(I/1e3).toFixed(1)+"K":I]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Draw Calls"}),o.jsx("span",{style:{color:$(H)},children:H})]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Tri/Call"}),H>0?Math.round(I/H):0]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Points"}),i.render.points]})]}),o.jsx(ko,{data:d,color:$(H),max:Math.max(200,...d)})]}),o.jsxs("div",{className:"perf-stat-group",children:[o.jsx("div",{className:"perf-header",children:o.jsx("h4",{className:"perf-title",children:"Resources"})}),o.jsxs("div",{className:"perf-details-grid",children:[o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Geometries"}),N]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Textures"}),O]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Programs"}),i.engine.programs]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Lines"}),i.render.lines]})]}),o.jsx(or,{value:N,max:200,color:N>150?"#f87171":"#4ade80",label:"Geometry Budget"}),o.jsx(or,{value:O,max:100,color:O>80?"#f87171":"#4ade80",label:"Texture Budget"})]}),o.jsxs("div",{className:"perf-stat-group",children:[o.jsxs("div",{className:"perf-header",children:[o.jsx("h4",{className:"perf-title",children:"Memory"}),o.jsxs("span",{className:"perf-current",style:{color:L(a.used,a.limit)},children:[a.used," MB"]})]}),o.jsxs("div",{className:"perf-details-grid",children:[o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Limit"}),a.limit," MB"]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Usage"}),a.limit>0?(a.used/a.limit*100).toFixed(0):0,"%"]})]}),o.jsx(ko,{data:a.history,color:L(a.used,a.limit),max:a.limit||1})]}),n]})}const Qc=({className:e="",style:t,children:n})=>{const i=ge.useGaesupStore(l=>l.mode),s=ge.useGaesupStore(l=>l.setMode),r=l=>{s({type:l,controller:"keyboard",control:l==="airplane"||l==="vehicle"?"chase":"thirdPerson"})},a=[{type:"character",label:"Character",description:"Walk around as character"},{type:"vehicle",label:"Vehicle",description:"Drive a ground vehicle"},{type:"airplane",label:"Airplane",description:"Fly an airplane"}];return o.jsxs("div",{className:`vehicle-panel ${e}`,style:t,children:[o.jsx("div",{className:"vehicle-panel__modes",children:a.map(l=>o.jsxs("button",{className:`vehicle-panel__mode-button ${i.type===l.type?"vehicle-panel__mode-button--active":""}`,onClick:()=>r(l.type),children:[o.jsx("span",{className:"vehicle-panel__mode-label",children:l.label}),o.jsx("span",{className:"vehicle-panel__mode-description",children:l.description})]},l.type))}),o.jsxs("div",{className:"vehicle-panel__info",children:[o.jsxs("div",{className:"vehicle-panel__info-item",children:[o.jsx("span",{className:"vehicle-panel__info-label",children:"Current Mode:"}),o.jsx("span",{className:"vehicle-panel__info-value",children:i.type})]}),o.jsxs("div",{className:"vehicle-panel__info-item",children:[o.jsx("span",{className:"vehicle-panel__info-label",children:"Controls:"}),o.jsx("span",{className:"vehicle-panel__info-value",children:i.type==="airplane"?"WASD + Space/Shift":"WASD + Space"})]})]}),n]})};function Ie(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,i;n<e.length;n++)(i=Ie(e[n]))!==""&&(t+=(t&&" ")+i);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var gh={value:()=>{}};function Es(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new ns(n)}function ns(e){this._=e}function bh(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",s=n.indexOf(".");if(s>=0&&(i=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}ns.prototype=Es.prototype={constructor:ns,on:function(e,t){var n=this._,i=bh(e+"",n),s,r=-1,a=i.length;if(arguments.length<2){for(;++r<a;)if((s=(e=i[r]).type)&&(s=xh(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++r<a;)if(s=(e=i[r]).type)n[s]=rl(n[s],e.name,t);else if(t==null)for(s in n)n[s]=rl(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ns(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),i=0,s,r;i<s;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(r=this._[e],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],s=0,r=i.length;s<r;++s)i[s].value.apply(t,n)}};function xh(e,t){for(var n=0,i=e.length,s;n<i;++n)if((s=e[n]).name===t)return s.value}function rl(e,t,n){for(var i=0,s=e.length;i<s;++i)if(e[i].name===t){e[i]=gh,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var Or="http://www.w3.org/1999/xhtml";const al={svg:"http://www.w3.org/2000/svg",xhtml:Or,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function As(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),al.hasOwnProperty(t)?{space:al[t],local:e}:e}function yh(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Or&&t.documentElement.namespaceURI===Or?t.createElement(e):t.createElementNS(n,e)}}function vh(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Jc(e){var t=As(e);return(t.local?vh:yh)(t)}function wh(){}function ya(e){return e==null?wh:function(){return this.querySelector(e)}}function Sh(e){typeof e!="function"&&(e=ya(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=i[s]=new Array(a),c,u,d=0;d<a;++d)(c=r[d])&&(u=e.call(c,c.__data__,d,r))&&("__data__"in c&&(u.__data__=c.__data__),l[d]=u);return new Ye(i,this._parents)}function _h(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Mh(){return[]}function eu(e){return e==null?Mh:function(){return this.querySelectorAll(e)}}function jh(e){return function(){return _h(e.apply(this,arguments))}}function Ch(e){typeof e=="function"?e=jh(e):e=eu(e);for(var t=this._groups,n=t.length,i=[],s=[],r=0;r<n;++r)for(var a=t[r],l=a.length,c,u=0;u<l;++u)(c=a[u])&&(i.push(e.call(c,c.__data__,u,a)),s.push(c));return new Ye(i,s)}function tu(e){return function(){return this.matches(e)}}function nu(e){return function(t){return t.matches(e)}}var Nh=Array.prototype.find;function Th(e){return function(){return Nh.call(this.children,e)}}function Ih(){return this.firstElementChild}function Eh(e){return this.select(e==null?Ih:Th(typeof e=="function"?e:nu(e)))}var Ah=Array.prototype.filter;function kh(){return Array.from(this.children)}function Bh(e){return function(){return Ah.call(this.children,e)}}function Ph(e){return this.selectAll(e==null?kh:Bh(typeof e=="function"?e:nu(e)))}function Rh(e){typeof e!="function"&&(e=tu(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=i[s]=[],c,u=0;u<a;++u)(c=r[u])&&e.call(c,c.__data__,u,r)&&l.push(c);return new Ye(i,this._parents)}function iu(e){return new Array(e.length)}function Dh(){return new Ye(this._enter||this._groups.map(iu),this._parents)}function us(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}us.prototype={constructor:us,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Lh(e){return function(){return e}}function Fh(e,t,n,i,s,r){for(var a=0,l,c=t.length,u=r.length;a<u;++a)(l=t[a])?(l.__data__=r[a],i[a]=l):n[a]=new us(e,r[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function zh(e,t,n,i,s,r,a){var l,c,u=new Map,d=t.length,f=r.length,p=new Array(d),h;for(l=0;l<d;++l)(c=t[l])&&(p[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<f;++l)h=a.call(e,r[l],l,r)+"",(c=u.get(h))?(i[l]=c,c.__data__=r[l],u.delete(h)):n[l]=new us(e,r[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function Oh(e){return e.__data__}function $h(e,t){if(!arguments.length)return Array.from(this,Oh);var n=t?zh:Fh,i=this._parents,s=this._groups;typeof e!="function"&&(e=Lh(e));for(var r=s.length,a=new Array(r),l=new Array(r),c=new Array(r),u=0;u<r;++u){var d=i[u],f=s[u],p=f.length,h=Gh(e.call(d,d&&d.__data__,u,i)),w=h.length,b=l[u]=new Array(w),S=a[u]=new Array(w),x=c[u]=new Array(p);n(d,f,b,S,x,h,t);for(var _=0,g=0,y,v;_<w;++_)if(y=b[_]){for(_>=g&&(g=_+1);!(v=S[g])&&++g<w;);y._next=v||null}}return a=new Ye(a,i),a._enter=l,a._exit=c,a}function Gh(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Hh(){return new Ye(this._exit||this._groups.map(iu),this._parents)}function Wh(e,t,n){var i=this.enter(),s=this,r=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?r.remove():n(r),i&&s?i.merge(s).order():s}function Uh(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,s=n.length,r=i.length,a=Math.min(s,r),l=new Array(s),c=0;c<a;++c)for(var u=n[c],d=i[c],f=u.length,p=l[c]=new Array(f),h,w=0;w<f;++w)(h=u[w]||d[w])&&(p[w]=h);for(;c<s;++c)l[c]=n[c];return new Ye(l,this._parents)}function Vh(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],s=i.length-1,r=i[s],a;--s>=0;)(a=i[s])&&(r&&a.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(a,r),r=a);return this}function Yh(e){e||(e=Zh);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var n=this._groups,i=n.length,s=new Array(i),r=0;r<i;++r){for(var a=n[r],l=a.length,c=s[r]=new Array(l),u,d=0;d<l;++d)(u=a[d])&&(c[d]=u);c.sort(t)}return new Ye(s,this._parents).order()}function Zh(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Xh(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Kh(){return Array.from(this)}function qh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],s=0,r=i.length;s<r;++s){var a=i[s];if(a)return a}return null}function Qh(){let e=0;for(const t of this)++e;return e}function Jh(){return!this.node()}function em(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var s=t[n],r=0,a=s.length,l;r<a;++r)(l=s[r])&&e.call(l,l.__data__,r,s);return this}function tm(e){return function(){this.removeAttribute(e)}}function nm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function im(e,t){return function(){this.setAttribute(e,t)}}function om(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function sm(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function rm(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function am(e,t){var n=As(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?nm:tm:typeof t=="function"?n.local?rm:sm:n.local?om:im)(n,t))}function ou(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lm(e){return function(){this.style.removeProperty(e)}}function cm(e,t,n){return function(){this.style.setProperty(e,t,n)}}function um(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function dm(e,t,n){return arguments.length>1?this.each((t==null?lm:typeof t=="function"?um:cm)(e,t,n??"")):_i(this.node(),e)}function _i(e,t){return e.style.getPropertyValue(t)||ou(e).getComputedStyle(e,null).getPropertyValue(t)}function fm(e){return function(){delete this[e]}}function pm(e,t){return function(){this[e]=t}}function hm(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function mm(e,t){return arguments.length>1?this.each((t==null?fm:typeof t=="function"?hm:pm)(e,t)):this.node()[e]}function su(e){return e.trim().split(/^|\s+/)}function va(e){return e.classList||new ru(e)}function ru(e){this._node=e,this._names=su(e.getAttribute("class")||"")}ru.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function au(e,t){for(var n=va(e),i=-1,s=t.length;++i<s;)n.add(t[i])}function lu(e,t){for(var n=va(e),i=-1,s=t.length;++i<s;)n.remove(t[i])}function gm(e){return function(){au(this,e)}}function bm(e){return function(){lu(this,e)}}function xm(e,t){return function(){(t.apply(this,arguments)?au:lu)(this,e)}}function ym(e,t){var n=su(e+"");if(arguments.length<2){for(var i=va(this.node()),s=-1,r=n.length;++s<r;)if(!i.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?xm:t?gm:bm)(n,t))}function vm(){this.textContent=""}function wm(e){return function(){this.textContent=e}}function Sm(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function _m(e){return arguments.length?this.each(e==null?vm:(typeof e=="function"?Sm:wm)(e)):this.node().textContent}function Mm(){this.innerHTML=""}function jm(e){return function(){this.innerHTML=e}}function Cm(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Nm(e){return arguments.length?this.each(e==null?Mm:(typeof e=="function"?Cm:jm)(e)):this.node().innerHTML}function Tm(){this.nextSibling&&this.parentNode.appendChild(this)}function Im(){return this.each(Tm)}function Em(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Am(){return this.each(Em)}function km(e){var t=typeof e=="function"?e:Jc(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Bm(){return null}function Pm(e,t){var n=typeof e=="function"?e:Jc(e),i=t==null?Bm:typeof t=="function"?t:ya(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Rm(){var e=this.parentNode;e&&e.removeChild(this)}function Dm(){return this.each(Rm)}function Lm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function zm(e){return this.select(e?Fm:Lm)}function Om(e){return arguments.length?this.property("__data__",e):this.node().__data__}function $m(e){return function(t){e.call(this,t,this.__data__)}}function Gm(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function Hm(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,s=t.length,r;n<s;++n)r=t[n],(!e.type||r.type===e.type)&&r.name===e.name?this.removeEventListener(r.type,r.listener,r.options):t[++i]=r;++i?t.length=i:delete this.__on}}}function Wm(e,t,n){return function(){var i=this.__on,s,r=$m(t);if(i){for(var a=0,l=i.length;a<l;++a)if((s=i[a]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=r,s.options=n),s.value=t;return}}this.addEventListener(e.type,r,n),s={type:e.type,name:e.name,value:t,listener:r,options:n},i?i.push(s):this.__on=[s]}}function Um(e,t,n){var i=Gm(e+""),s,r=i.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,d;c<u;++c)for(s=0,d=l[c];s<r;++s)if((a=i[s]).type===d.type&&a.name===d.name)return d.value}return}for(l=t?Wm:Hm,s=0;s<r;++s)this.each(l(i[s],t,n));return this}function cu(e,t,n){var i=ou(e),s=i.CustomEvent;typeof s=="function"?s=new s(t,n):(s=i.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Vm(e,t){return function(){return cu(this,e,t)}}function Ym(e,t){return function(){return cu(this,e,t.apply(this,arguments))}}function Zm(e,t){return this.each((typeof t=="function"?Ym:Vm)(e,t))}function*Xm(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],s=0,r=i.length,a;s<r;++s)(a=i[s])&&(yield a)}var uu=[null];function Ye(e,t){this._groups=e,this._parents=t}function So(){return new Ye([[document.documentElement]],uu)}function Km(){return this}Ye.prototype=So.prototype={constructor:Ye,select:Sh,selectAll:Ch,selectChild:Eh,selectChildren:Ph,filter:Rh,data:$h,enter:Dh,exit:Hh,join:Wh,merge:Uh,selection:Km,order:Vh,sort:Yh,call:Xh,nodes:Kh,node:qh,size:Qh,empty:Jh,each:em,attr:am,style:dm,property:mm,classed:ym,text:_m,html:Nm,raise:Im,lower:Am,append:km,insert:Pm,remove:Dm,clone:zm,datum:Om,on:Um,dispatch:Zm,[Symbol.iterator]:Xm};function Ve(e){return typeof e=="string"?new Ye([[document.querySelector(e)]],[document.documentElement]):new Ye([[e]],uu)}function qm(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ot(e,t){if(e=qm(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Qm={passive:!1},ro={capture:!0,passive:!1};function sr(e){e.stopImmediatePropagation()}function wi(e){e.preventDefault(),e.stopImmediatePropagation()}function du(e){var t=e.document.documentElement,n=Ve(e).on("dragstart.drag",wi,ro);"onselectstart"in t?n.on("selectstart.drag",wi,ro):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function fu(e,t){var n=e.document.documentElement,i=Ve(e).on("dragstart.drag",null);t&&(i.on("click.drag",wi,ro),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Bo=e=>()=>e;function $r(e,{sourceEvent:t,subject:n,target:i,identifier:s,active:r,x:a,y:l,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}$r.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Jm(e){return!e.ctrlKey&&!e.button}function eg(){return this.parentNode}function tg(e,t){return t??{x:e.x,y:e.y}}function ng(){return navigator.maxTouchPoints||"ontouchstart"in this}function pu(){var e=Jm,t=eg,n=tg,i=ng,s={},r=Es("start","drag","end"),a=0,l,c,u,d,f=0;function p(y){y.on("mousedown.drag",h).filter(i).on("touchstart.drag",S).on("touchmove.drag",x,Qm).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(y,v){if(!(d||!e.call(this,y,v))){var j=g(this,t.call(this,y,v),y,v,"mouse");j&&(Ve(y.view).on("mousemove.drag",w,ro).on("mouseup.drag",b,ro),du(y.view),sr(y),u=!1,l=y.clientX,c=y.clientY,j("start",y))}}function w(y){if(wi(y),!u){var v=y.clientX-l,j=y.clientY-c;u=v*v+j*j>f}s.mouse("drag",y)}function b(y){Ve(y.view).on("mousemove.drag mouseup.drag",null),fu(y.view,u),wi(y),s.mouse("end",y)}function S(y,v){if(e.call(this,y,v)){var j=y.changedTouches,T=t.call(this,y,v),k=j.length,D,$;for(D=0;D<k;++D)($=g(this,T,y,v,j[D].identifier,j[D]))&&(sr(y),$("start",y,j[D]))}}function x(y){var v=y.changedTouches,j=v.length,T,k;for(T=0;T<j;++T)(k=s[v[T].identifier])&&(wi(y),k("drag",y,v[T]))}function _(y){var v=y.changedTouches,j=v.length,T,k;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),T=0;T<j;++T)(k=s[v[T].identifier])&&(sr(y),k("end",y,v[T]))}function g(y,v,j,T,k,D){var $=r.copy(),L=ot(D||j,v),I,H,N;if((N=n.call(y,new $r("beforestart",{sourceEvent:j,target:p,identifier:k,active:a,x:L[0],y:L[1],dx:0,dy:0,dispatch:$}),T))!=null)return I=N.x-L[0]||0,H=N.y-L[1]||0,function O(P,z,M){var F=L,U;switch(P){case"start":s[k]=O,U=a++;break;case"end":delete s[k],--a;case"drag":L=ot(M||z,v),U=a;break}$.call(P,y,new $r(P,{sourceEvent:z,subject:N,target:p,identifier:k,active:U,x:L[0]+I,y:L[1]+H,dx:L[0]-F[0],dy:L[1]-F[1],dispatch:$}),T)}}return p.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Bo(!!y),p):e},p.container=function(y){return arguments.length?(t=typeof y=="function"?y:Bo(y),p):t},p.subject=function(y){return arguments.length?(n=typeof y=="function"?y:Bo(y),p):n},p.touchable=function(y){return arguments.length?(i=typeof y=="function"?y:Bo(!!y),p):i},p.on=function(){var y=r.on.apply(r,arguments);return y===r?p:y},p.clickDistance=function(y){return arguments.length?(f=(y=+y)*y,p):Math.sqrt(f)},p}function wa(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function hu(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function _o(){}var ao=.7,ds=1/ao,Si="\\s*([+-]?\\d+)\\s*",lo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Nt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ig=/^#([0-9a-f]{3,8})$/,og=new RegExp(`^rgb\\(${Si},${Si},${Si}\\)$`),sg=new RegExp(`^rgb\\(${Nt},${Nt},${Nt}\\)$`),rg=new RegExp(`^rgba\\(${Si},${Si},${Si},${lo}\\)$`),ag=new RegExp(`^rgba\\(${Nt},${Nt},${Nt},${lo}\\)$`),lg=new RegExp(`^hsl\\(${lo},${Nt},${Nt}\\)$`),cg=new RegExp(`^hsla\\(${lo},${Nt},${Nt},${lo}\\)$`),ll={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};wa(_o,oi,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:cl,formatHex:cl,formatHex8:ug,formatHsl:dg,formatRgb:ul,toString:ul});function cl(){return this.rgb().formatHex()}function ug(){return this.rgb().formatHex8()}function dg(){return mu(this).formatHsl()}function ul(){return this.rgb().formatRgb()}function oi(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=ig.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?dl(t):n===3?new $e(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Po(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Po(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=og.exec(e))?new $e(t[1],t[2],t[3],1):(t=sg.exec(e))?new $e(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=rg.exec(e))?Po(t[1],t[2],t[3],t[4]):(t=ag.exec(e))?Po(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=lg.exec(e))?hl(t[1],t[2]/100,t[3]/100,1):(t=cg.exec(e))?hl(t[1],t[2]/100,t[3]/100,t[4]):ll.hasOwnProperty(e)?dl(ll[e]):e==="transparent"?new $e(NaN,NaN,NaN,0):null}function dl(e){return new $e(e>>16&255,e>>8&255,e&255,1)}function Po(e,t,n,i){return i<=0&&(e=t=n=NaN),new $e(e,t,n,i)}function fg(e){return e instanceof _o||(e=oi(e)),e?(e=e.rgb(),new $e(e.r,e.g,e.b,e.opacity)):new $e}function Gr(e,t,n,i){return arguments.length===1?fg(e):new $e(e,t,n,i??1)}function $e(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}wa($e,Gr,hu(_o,{brighter(e){return e=e==null?ds:Math.pow(ds,e),new $e(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ao:Math.pow(ao,e),new $e(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new $e(ni(this.r),ni(this.g),ni(this.b),fs(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:fl,formatHex:fl,formatHex8:pg,formatRgb:pl,toString:pl}));function fl(){return`#${ti(this.r)}${ti(this.g)}${ti(this.b)}`}function pg(){return`#${ti(this.r)}${ti(this.g)}${ti(this.b)}${ti((isNaN(this.opacity)?1:this.opacity)*255)}`}function pl(){const e=fs(this.opacity);return`${e===1?"rgb(":"rgba("}${ni(this.r)}, ${ni(this.g)}, ${ni(this.b)}${e===1?")":`, ${e})`}`}function fs(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ni(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ti(e){return e=ni(e),(e<16?"0":"")+e.toString(16)}function hl(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new at(e,t,n,i)}function mu(e){if(e instanceof at)return new at(e.h,e.s,e.l,e.opacity);if(e instanceof _o||(e=oi(e)),!e)return new at;if(e instanceof at)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,s=Math.min(t,n,i),r=Math.max(t,n,i),a=NaN,l=r-s,c=(r+s)/2;return l?(t===r?a=(n-i)/l+(n<i)*6:n===r?a=(i-t)/l+2:a=(t-n)/l+4,l/=c<.5?r+s:2-r-s,a*=60):l=c>0&&c<1?0:a,new at(a,l,c,e.opacity)}function hg(e,t,n,i){return arguments.length===1?mu(e):new at(e,t,n,i??1)}function at(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}wa(at,hg,hu(_o,{brighter(e){return e=e==null?ds:Math.pow(ds,e),new at(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ao:Math.pow(ao,e),new at(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,s=2*n-i;return new $e(rr(e>=240?e-240:e+120,s,i),rr(e,s,i),rr(e<120?e+240:e-120,s,i),this.opacity)},clamp(){return new at(ml(this.h),Ro(this.s),Ro(this.l),fs(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=fs(this.opacity);return`${e===1?"hsl(":"hsla("}${ml(this.h)}, ${Ro(this.s)*100}%, ${Ro(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ml(e){return e=(e||0)%360,e<0?e+360:e}function Ro(e){return Math.max(0,Math.min(1,e||0))}function rr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Sa=e=>()=>e;function mg(e,t){return function(n){return e+n*t}}function gg(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function bg(e){return(e=+e)==1?gu:function(t,n){return n-t?gg(t,n,e):Sa(isNaN(t)?n:t)}}function gu(e,t){var n=t-e;return n?mg(e,n):Sa(isNaN(e)?t:e)}const ps=function e(t){var n=bg(t);function i(s,r){var a=n((s=Gr(s)).r,(r=Gr(r)).r),l=n(s.g,r.g),c=n(s.b,r.b),u=gu(s.opacity,r.opacity);return function(d){return s.r=a(d),s.g=l(d),s.b=c(d),s.opacity=u(d),s+""}}return i.gamma=e,i}(1);function xg(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),s;return function(r){for(s=0;s<n;++s)i[s]=e[s]*(1-r)+t[s]*r;return i}}function yg(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vg(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,s=new Array(i),r=new Array(n),a;for(a=0;a<i;++a)s[a]=qi(e[a],t[a]);for(;a<n;++a)r[a]=t[a];return function(l){for(a=0;a<i;++a)r[a]=s[a](l);return r}}function wg(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function Ct(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Sg(e,t){var n={},i={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=qi(e[s],t[s]):i[s]=t[s];return function(r){for(s in n)i[s]=n[s](r);return i}}var Hr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ar=new RegExp(Hr.source,"g");function _g(e){return function(){return e}}function Mg(e){return function(t){return e(t)+""}}function bu(e,t){var n=Hr.lastIndex=ar.lastIndex=0,i,s,r,a=-1,l=[],c=[];for(e=e+"",t=t+"";(i=Hr.exec(e))&&(s=ar.exec(t));)(r=s.index)>n&&(r=t.slice(n,r),l[a]?l[a]+=r:l[++a]=r),(i=i[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,c.push({i:a,x:Ct(i,s)})),n=ar.lastIndex;return n<t.length&&(r=t.slice(n),l[a]?l[a]+=r:l[++a]=r),l.length<2?c[0]?Mg(c[0].x):_g(t):(t=c.length,function(u){for(var d=0,f;d<t;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function qi(e,t){var n=typeof t,i;return t==null||n==="boolean"?Sa(t):(n==="number"?Ct:n==="string"?(i=oi(t))?(t=i,ps):bu:t instanceof oi?ps:t instanceof Date?wg:yg(t)?xg:Array.isArray(t)?vg:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Sg:Ct)(e,t)}var gl=180/Math.PI,Wr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xu(e,t,n,i,s,r){var a,l,c;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(c=e*n+t*i)&&(n-=e*c,i-=t*c),(l=Math.sqrt(n*n+i*i))&&(n/=l,i/=l,c/=l),e*i<t*n&&(e=-e,t=-t,c=-c,a=-a),{translateX:s,translateY:r,rotate:Math.atan2(t,e)*gl,skewX:Math.atan(c)*gl,scaleX:a,scaleY:l}}var Do;function jg(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Wr:xu(t.a,t.b,t.c,t.d,t.e,t.f)}function Cg(e){return e==null||(Do||(Do=document.createElementNS("http://www.w3.org/2000/svg","g")),Do.setAttribute("transform",e),!(e=Do.transform.baseVal.consolidate()))?Wr:(e=e.matrix,xu(e.a,e.b,e.c,e.d,e.e,e.f))}function yu(e,t,n,i){function s(u){return u.length?u.pop()+" ":""}function r(u,d,f,p,h,w){if(u!==f||d!==p){var b=h.push("translate(",null,t,null,n);w.push({i:b-4,x:Ct(u,f)},{i:b-2,x:Ct(d,p)})}else(f||p)&&h.push("translate("+f+t+p+n)}function a(u,d,f,p){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),p.push({i:f.push(s(f)+"rotate(",null,i)-2,x:Ct(u,d)})):d&&f.push(s(f)+"rotate("+d+i)}function l(u,d,f,p){u!==d?p.push({i:f.push(s(f)+"skewX(",null,i)-2,x:Ct(u,d)}):d&&f.push(s(f)+"skewX("+d+i)}function c(u,d,f,p,h,w){if(u!==f||d!==p){var b=h.push(s(h)+"scale(",null,",",null,")");w.push({i:b-4,x:Ct(u,f)},{i:b-2,x:Ct(d,p)})}else(f!==1||p!==1)&&h.push(s(h)+"scale("+f+","+p+")")}return function(u,d){var f=[],p=[];return u=e(u),d=e(d),r(u.translateX,u.translateY,d.translateX,d.translateY,f,p),a(u.rotate,d.rotate,f,p),l(u.skewX,d.skewX,f,p),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,p),u=d=null,function(h){for(var w=-1,b=p.length,S;++w<b;)f[(S=p[w]).i]=S.x(h);return f.join("")}}}var Ng=yu(jg,"px, ","px)","deg)"),Tg=yu(Cg,", ",")",")"),Ig=1e-12;function bl(e){return((e=Math.exp(e))+1/e)/2}function Eg(e){return((e=Math.exp(e))-1/e)/2}function Ag(e){return((e=Math.exp(2*e))-1)/(e+1)}const is=function e(t,n,i){function s(r,a){var l=r[0],c=r[1],u=r[2],d=a[0],f=a[1],p=a[2],h=d-l,w=f-c,b=h*h+w*w,S,x;if(b<Ig)x=Math.log(p/u)/t,S=function(T){return[l+T*h,c+T*w,u*Math.exp(t*T*x)]};else{var _=Math.sqrt(b),g=(p*p-u*u+i*b)/(2*u*n*_),y=(p*p-u*u-i*b)/(2*p*n*_),v=Math.log(Math.sqrt(g*g+1)-g),j=Math.log(Math.sqrt(y*y+1)-y);x=(j-v)/t,S=function(T){var k=T*x,D=bl(v),$=u/(n*_)*(D*Ag(t*k+v)-Eg(v));return[l+$*h,c+$*w,u*D/bl(t*k+v)]}}return S.duration=x*1e3*t/Math.SQRT2,S}return s.rho=function(r){var a=Math.max(.001,+r),l=a*a,c=l*l;return e(a,l,c)},s}(Math.SQRT2,2,4);var Mi=0,Zi=0,$i=0,vu=1e3,hs,Xi,ms=0,si=0,ks=0,co=typeof performance=="object"&&performance.now?performance:Date,wu=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function _a(){return si||(wu(kg),si=co.now()+ks)}function kg(){si=0}function gs(){this._call=this._time=this._next=null}gs.prototype=Su.prototype={constructor:gs,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?_a():+n)+(t==null?0:+t),!this._next&&Xi!==this&&(Xi?Xi._next=this:hs=this,Xi=this),this._call=e,this._time=n,Ur()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ur())}};function Su(e,t,n){var i=new gs;return i.restart(e,t,n),i}function Bg(){_a(),++Mi;for(var e=hs,t;e;)(t=si-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Mi}function xl(){si=(ms=co.now())+ks,Mi=Zi=0;try{Bg()}finally{Mi=0,Rg(),si=0}}function Pg(){var e=co.now(),t=e-ms;t>vu&&(ks-=t,ms=e)}function Rg(){for(var e,t=hs,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:hs=n);Xi=e,Ur(i)}function Ur(e){if(!Mi){Zi&&(Zi=clearTimeout(Zi));var t=e-si;t>24?(e<1/0&&(Zi=setTimeout(xl,e-co.now()-ks)),$i&&($i=clearInterval($i))):($i||(ms=co.now(),$i=setInterval(Pg,vu)),Mi=1,wu(xl))}}function yl(e,t,n){var i=new gs;return t=t==null?0:+t,i.restart(s=>{i.stop(),e(s+t)},t,n),i}var Dg=Es("start","end","cancel","interrupt"),Lg=[],_u=0,vl=1,Vr=2,os=3,wl=4,Yr=5,ss=6;function Bs(e,t,n,i,s,r){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;Fg(e,n,{name:t,index:i,group:s,on:Dg,tween:Lg,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:_u})}function Ma(e,t){var n=pt(e,t);if(n.state>_u)throw new Error("too late; already scheduled");return n}function It(e,t){var n=pt(e,t);if(n.state>os)throw new Error("too late; already running");return n}function pt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Fg(e,t,n){var i=e.__transition,s;i[t]=n,n.timer=Su(r,0,n.time);function r(u){n.state=vl,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,p,h;if(n.state!==vl)return c();for(d in i)if(h=i[d],h.name===n.name){if(h.state===os)return yl(a);h.state===wl?(h.state=ss,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete i[d]):+d<t&&(h.state=ss,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete i[d])}if(yl(function(){n.state===os&&(n.state=wl,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Vr,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Vr){for(n.state=os,s=new Array(p=n.tween.length),d=0,f=-1;d<p;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=Yr,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===Yr&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=ss,n.timer.stop(),delete i[t];for(var u in i)return;delete e.__transition}}function rs(e,t){var n=e.__transition,i,s,r=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((i=n[a]).name!==t){r=!1;continue}s=i.state>Vr&&i.state<Yr,i.state=ss,i.timer.stop(),i.on.call(s?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[a]}r&&delete e.__transition}}function zg(e){return this.each(function(){rs(this,e)})}function Og(e,t){var n,i;return function(){var s=It(this,e),r=s.tween;if(r!==n){i=n=r;for(var a=0,l=i.length;a<l;++a)if(i[a].name===t){i=i.slice(),i.splice(a,1);break}}s.tween=i}}function $g(e,t,n){var i,s;if(typeof n!="function")throw new Error;return function(){var r=It(this,e),a=r.tween;if(a!==i){s=(i=a).slice();for(var l={name:t,value:n},c=0,u=s.length;c<u;++c)if(s[c].name===t){s[c]=l;break}c===u&&s.push(l)}r.tween=s}}function Gg(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=pt(this.node(),n).tween,s=0,r=i.length,a;s<r;++s)if((a=i[s]).name===e)return a.value;return null}return this.each((t==null?Og:$g)(n,e,t))}function ja(e,t,n){var i=e._id;return e.each(function(){var s=It(this,i);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return pt(s,i).value[t]}}function Mu(e,t){var n;return(typeof t=="number"?Ct:t instanceof oi?ps:(n=oi(t))?(t=n,ps):bu)(e,t)}function Hg(e){return function(){this.removeAttribute(e)}}function Wg(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ug(e,t,n){var i,s=n+"",r;return function(){var a=this.getAttribute(e);return a===s?null:a===i?r:r=t(i=a,n)}}function Vg(e,t,n){var i,s=n+"",r;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===i?r:r=t(i=a,n)}}function Yg(e,t,n){var i,s,r;return function(){var a,l=n(this),c;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),c=l+"",a===c?null:a===i&&c===s?r:(s=c,r=t(i=a,l)))}}function Zg(e,t,n){var i,s,r;return function(){var a,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),c=l+"",a===c?null:a===i&&c===s?r:(s=c,r=t(i=a,l)))}}function Xg(e,t){var n=As(e),i=n==="transform"?Tg:Mu;return this.attrTween(e,typeof t=="function"?(n.local?Zg:Yg)(n,i,ja(this,"attr."+e,t)):t==null?(n.local?Wg:Hg)(n):(n.local?Vg:Ug)(n,i,t))}function Kg(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function qg(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Qg(e,t){var n,i;function s(){var r=t.apply(this,arguments);return r!==i&&(n=(i=r)&&qg(e,r)),n}return s._value=t,s}function Jg(e,t){var n,i;function s(){var r=t.apply(this,arguments);return r!==i&&(n=(i=r)&&Kg(e,r)),n}return s._value=t,s}function e0(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=As(e);return this.tween(n,(i.local?Qg:Jg)(i,t))}function t0(e,t){return function(){Ma(this,e).delay=+t.apply(this,arguments)}}function n0(e,t){return t=+t,function(){Ma(this,e).delay=t}}function i0(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?t0:n0)(t,e)):pt(this.node(),t).delay}function o0(e,t){return function(){It(this,e).duration=+t.apply(this,arguments)}}function s0(e,t){return t=+t,function(){It(this,e).duration=t}}function r0(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?o0:s0)(t,e)):pt(this.node(),t).duration}function a0(e,t){if(typeof t!="function")throw new Error;return function(){It(this,e).ease=t}}function l0(e){var t=this._id;return arguments.length?this.each(a0(t,e)):pt(this.node(),t).ease}function c0(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;It(this,e).ease=n}}function u0(e){if(typeof e!="function")throw new Error;return this.each(c0(this._id,e))}function d0(e){typeof e!="function"&&(e=tu(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=i[s]=[],c,u=0;u<a;++u)(c=r[u])&&e.call(c,c.__data__,u,r)&&l.push(c);return new Vt(i,this._parents,this._name,this._id)}function f0(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,s=n.length,r=Math.min(i,s),a=new Array(i),l=0;l<r;++l)for(var c=t[l],u=n[l],d=c.length,f=a[l]=new Array(d),p,h=0;h<d;++h)(p=c[h]||u[h])&&(f[h]=p);for(;l<i;++l)a[l]=t[l];return new Vt(a,this._parents,this._name,this._id)}function p0(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function h0(e,t,n){var i,s,r=p0(t)?Ma:It;return function(){var a=r(this,e),l=a.on;l!==i&&(s=(i=l).copy()).on(t,n),a.on=s}}function m0(e,t){var n=this._id;return arguments.length<2?pt(this.node(),n).on.on(e):this.each(h0(n,e,t))}function g0(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function b0(){return this.on("end.remove",g0(this._id))}function x0(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ya(e));for(var i=this._groups,s=i.length,r=new Array(s),a=0;a<s;++a)for(var l=i[a],c=l.length,u=r[a]=new Array(c),d,f,p=0;p<c;++p)(d=l[p])&&(f=e.call(d,d.__data__,p,l))&&("__data__"in d&&(f.__data__=d.__data__),u[p]=f,Bs(u[p],t,n,p,u,pt(d,n)));return new Vt(r,this._parents,t,n)}function y0(e){var t=this._name,n=this._id;typeof e!="function"&&(e=eu(e));for(var i=this._groups,s=i.length,r=[],a=[],l=0;l<s;++l)for(var c=i[l],u=c.length,d,f=0;f<u;++f)if(d=c[f]){for(var p=e.call(d,d.__data__,f,c),h,w=pt(d,n),b=0,S=p.length;b<S;++b)(h=p[b])&&Bs(h,t,n,b,p,w);r.push(p),a.push(d)}return new Vt(r,a,t,n)}var v0=So.prototype.constructor;function w0(){return new v0(this._groups,this._parents)}function S0(e,t){var n,i,s;return function(){var r=_i(this,e),a=(this.style.removeProperty(e),_i(this,e));return r===a?null:r===n&&a===i?s:s=t(n=r,i=a)}}function ju(e){return function(){this.style.removeProperty(e)}}function _0(e,t,n){var i,s=n+"",r;return function(){var a=_i(this,e);return a===s?null:a===i?r:r=t(i=a,n)}}function M0(e,t,n){var i,s,r;return function(){var a=_i(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),_i(this,e))),a===c?null:a===i&&c===s?r:(s=c,r=t(i=a,l))}}function j0(e,t){var n,i,s,r="style."+t,a="end."+r,l;return function(){var c=It(this,e),u=c.on,d=c.value[r]==null?l||(l=ju(t)):void 0;(u!==n||s!==d)&&(i=(n=u).copy()).on(a,s=d),c.on=i}}function C0(e,t,n){var i=(e+="")=="transform"?Ng:Mu;return t==null?this.styleTween(e,S0(e,i)).on("end.style."+e,ju(e)):typeof t=="function"?this.styleTween(e,M0(e,i,ja(this,"style."+e,t))).each(j0(this._id,e)):this.styleTween(e,_0(e,i,t),n).on("end.style."+e,null)}function N0(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function T0(e,t,n){var i,s;function r(){var a=t.apply(this,arguments);return a!==s&&(i=(s=a)&&N0(e,a,n)),i}return r._value=t,r}function I0(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,T0(e,t,n??""))}function E0(e){return function(){this.textContent=e}}function A0(e){return function(){var t=e(this);this.textContent=t??""}}function k0(e){return this.tween("text",typeof e=="function"?A0(ja(this,"text",e)):E0(e==null?"":e+""))}function B0(e){return function(t){this.textContent=e.call(this,t)}}function P0(e){var t,n;function i(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&B0(s)),t}return i._value=e,i}function R0(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,P0(e))}function D0(){for(var e=this._name,t=this._id,n=Cu(),i=this._groups,s=i.length,r=0;r<s;++r)for(var a=i[r],l=a.length,c,u=0;u<l;++u)if(c=a[u]){var d=pt(c,t);Bs(c,e,n,u,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Vt(i,this._parents,e,n)}function L0(){var e,t,n=this,i=n._id,s=n.size();return new Promise(function(r,a){var l={value:a},c={value:function(){--s===0&&r()}};n.each(function(){var u=It(this,i),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&r()})}var F0=0;function Vt(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function Cu(){return++F0}var $t=So.prototype;Vt.prototype={constructor:Vt,select:x0,selectAll:y0,selectChild:$t.selectChild,selectChildren:$t.selectChildren,filter:d0,merge:f0,selection:w0,transition:D0,call:$t.call,nodes:$t.nodes,node:$t.node,size:$t.size,empty:$t.empty,each:$t.each,on:m0,attr:Xg,attrTween:e0,style:C0,styleTween:I0,text:k0,textTween:R0,remove:b0,tween:Gg,delay:i0,duration:r0,ease:l0,easeVarying:u0,end:L0,[Symbol.iterator]:$t[Symbol.iterator]};function z0(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var O0={time:null,delay:0,duration:250,ease:z0};function $0(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function G0(e){var t,n;e instanceof Vt?(t=e._id,e=e._name):(t=Cu(),(n=O0).time=_a(),e=e==null?null:e+"");for(var i=this._groups,s=i.length,r=0;r<s;++r)for(var a=i[r],l=a.length,c,u=0;u<l;++u)(c=a[u])&&Bs(c,e,t,u,a,n||$0(c,t));return new Vt(i,this._parents,e,t)}So.prototype.interrupt=zg;So.prototype.transition=G0;const Lo=e=>()=>e;function H0(e,{sourceEvent:t,target:n,transform:i,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:s}})}function Ut(e,t,n){this.k=e,this.x=t,this.y=n}Ut.prototype={constructor:Ut,scale:function(e){return e===1?this:new Ut(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ut(this.k,this.x+this.k*e,this.y+this.k*t)},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 Ps=new Ut(1,0,0);Nu.prototype=Ut.prototype;function Nu(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ps;return e.__zoom}function lr(e){e.stopImmediatePropagation()}function Gi(e){e.preventDefault(),e.stopImmediatePropagation()}function W0(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function U0(){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 Sl(){return this.__zoom||Ps}function V0(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Y0(){return navigator.maxTouchPoints||"ontouchstart"in this}function Z0(e,t,n){var i=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],r=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s),a>r?(r+a)/2:Math.min(0,r)||Math.max(0,a))}function Tu(){var e=W0,t=U0,n=Z0,i=V0,s=Y0,r=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=is,u=Es("start","zoom","end"),d,f,p,h=500,w=150,b=0,S=10;function x(N){N.property("__zoom",Sl).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",$).filter(s).on("touchstart.zoom",L).on("touchmove.zoom",I).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(N,O,P,z){var M=N.selection?N.selection():N;M.property("__zoom",Sl),N!==M?v(N,O,P,z):M.interrupt().each(function(){j(this,arguments).event(z).start().zoom(null,typeof O=="function"?O.apply(this,arguments):O).end()})},x.scaleBy=function(N,O,P,z){x.scaleTo(N,function(){var M=this.__zoom.k,F=typeof O=="function"?O.apply(this,arguments):O;return M*F},P,z)},x.scaleTo=function(N,O,P,z){x.transform(N,function(){var M=t.apply(this,arguments),F=this.__zoom,U=P==null?y(M):typeof P=="function"?P.apply(this,arguments):P,V=F.invert(U),Z=typeof O=="function"?O.apply(this,arguments):O;return n(g(_(F,Z),U,V),M,a)},P,z)},x.translateBy=function(N,O,P,z){x.transform(N,function(){return n(this.__zoom.translate(typeof O=="function"?O.apply(this,arguments):O,typeof P=="function"?P.apply(this,arguments):P),t.apply(this,arguments),a)},null,z)},x.translateTo=function(N,O,P,z,M){x.transform(N,function(){var F=t.apply(this,arguments),U=this.__zoom,V=z==null?y(F):typeof z=="function"?z.apply(this,arguments):z;return n(Ps.translate(V[0],V[1]).scale(U.k).translate(typeof O=="function"?-O.apply(this,arguments):-O,typeof P=="function"?-P.apply(this,arguments):-P),F,a)},z,M)};function _(N,O){return O=Math.max(r[0],Math.min(r[1],O)),O===N.k?N:new Ut(O,N.x,N.y)}function g(N,O,P){var z=O[0]-P[0]*N.k,M=O[1]-P[1]*N.k;return z===N.x&&M===N.y?N:new Ut(N.k,z,M)}function y(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function v(N,O,P,z){N.on("start.zoom",function(){j(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(z).end()}).tween("zoom",function(){var M=this,F=arguments,U=j(M,F).event(z),V=t.apply(M,F),Z=P==null?y(V):typeof P=="function"?P.apply(M,F):P,Y=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),Q=M.__zoom,K=typeof O=="function"?O.apply(M,F):O,E=c(Q.invert(Z).concat(Y/Q.k),K.invert(Z).concat(Y/K.k));return function(C){if(C===1)C=K;else{var W=E(C),X=Y/W[2];C=new Ut(X,Z[0]-W[0]*X,Z[1]-W[1]*X)}U.zoom(null,C)}})}function j(N,O,P){return!P&&N.__zooming||new T(N,O)}function T(N,O){this.that=N,this.args=O,this.active=0,this.sourceEvent=null,this.extent=t.apply(N,O),this.taps=0}T.prototype={event:function(N){return N&&(this.sourceEvent=N),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(N,O){return this.mouse&&N!=="mouse"&&(this.mouse[1]=O.invert(this.mouse[0])),this.touch0&&N!=="touch"&&(this.touch0[1]=O.invert(this.touch0[0])),this.touch1&&N!=="touch"&&(this.touch1[1]=O.invert(this.touch1[0])),this.that.__zoom=O,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(N){var O=Ve(this.that).datum();u.call(N,this.that,new H0(N,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:u}),O)}};function k(N,...O){if(!e.apply(this,arguments))return;var P=j(this,O).event(N),z=this.__zoom,M=Math.max(r[0],Math.min(r[1],z.k*Math.pow(2,i.apply(this,arguments)))),F=ot(N);if(P.wheel)(P.mouse[0][0]!==F[0]||P.mouse[0][1]!==F[1])&&(P.mouse[1]=z.invert(P.mouse[0]=F)),clearTimeout(P.wheel);else{if(z.k===M)return;P.mouse=[F,z.invert(F)],rs(this),P.start()}Gi(N),P.wheel=setTimeout(U,w),P.zoom("mouse",n(g(_(z,M),P.mouse[0],P.mouse[1]),P.extent,a));function U(){P.wheel=null,P.end()}}function D(N,...O){if(p||!e.apply(this,arguments))return;var P=N.currentTarget,z=j(this,O,!0).event(N),M=Ve(N.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",Y,!0),F=ot(N,P),U=N.clientX,V=N.clientY;du(N.view),lr(N),z.mouse=[F,this.__zoom.invert(F)],rs(this),z.start();function Z(Q){if(Gi(Q),!z.moved){var K=Q.clientX-U,E=Q.clientY-V;z.moved=K*K+E*E>b}z.event(Q).zoom("mouse",n(g(z.that.__zoom,z.mouse[0]=ot(Q,P),z.mouse[1]),z.extent,a))}function Y(Q){M.on("mousemove.zoom mouseup.zoom",null),fu(Q.view,z.moved),Gi(Q),z.event(Q).end()}}function $(N,...O){if(e.apply(this,arguments)){var P=this.__zoom,z=ot(N.changedTouches?N.changedTouches[0]:N,this),M=P.invert(z),F=P.k*(N.shiftKey?.5:2),U=n(g(_(P,F),z,M),t.apply(this,O),a);Gi(N),l>0?Ve(this).transition().duration(l).call(v,U,z,N):Ve(this).call(x.transform,U,z,N)}}function L(N,...O){if(e.apply(this,arguments)){var P=N.touches,z=P.length,M=j(this,O,N.changedTouches.length===z).event(N),F,U,V,Z;for(lr(N),U=0;U<z;++U)V=P[U],Z=ot(V,this),Z=[Z,this.__zoom.invert(Z),V.identifier],M.touch0?!M.touch1&&M.touch0[2]!==Z[2]&&(M.touch1=Z,M.taps=0):(M.touch0=Z,F=!0,M.taps=1+!!d);d&&(d=clearTimeout(d)),F&&(M.taps<2&&(f=Z[0],d=setTimeout(function(){d=null},h)),rs(this),M.start())}}function I(N,...O){if(this.__zooming){var P=j(this,O).event(N),z=N.changedTouches,M=z.length,F,U,V,Z;for(Gi(N),F=0;F<M;++F)U=z[F],V=ot(U,this),P.touch0&&P.touch0[2]===U.identifier?P.touch0[0]=V:P.touch1&&P.touch1[2]===U.identifier&&(P.touch1[0]=V);if(U=P.that.__zoom,P.touch1){var Y=P.touch0[0],Q=P.touch0[1],K=P.touch1[0],E=P.touch1[1],C=(C=K[0]-Y[0])*C+(C=K[1]-Y[1])*C,W=(W=E[0]-Q[0])*W+(W=E[1]-Q[1])*W;U=_(U,Math.sqrt(C/W)),V=[(Y[0]+K[0])/2,(Y[1]+K[1])/2],Z=[(Q[0]+E[0])/2,(Q[1]+E[1])/2]}else if(P.touch0)V=P.touch0[0],Z=P.touch0[1];else return;P.zoom("touch",n(g(U,V,Z),P.extent,a))}}function H(N,...O){if(this.__zooming){var P=j(this,O).event(N),z=N.changedTouches,M=z.length,F,U;for(lr(N),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),F=0;F<M;++F)U=z[F],P.touch0&&P.touch0[2]===U.identifier?delete P.touch0:P.touch1&&P.touch1[2]===U.identifier&&delete P.touch1;if(P.touch1&&!P.touch0&&(P.touch0=P.touch1,delete P.touch1),P.touch0)P.touch0[1]=this.__zoom.invert(P.touch0[0]);else if(P.end(),P.taps===2&&(U=ot(U,this),Math.hypot(f[0]-U[0],f[1]-U[1])<S)){var V=Ve(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return x.wheelDelta=function(N){return arguments.length?(i=typeof N=="function"?N:Lo(+N),x):i},x.filter=function(N){return arguments.length?(e=typeof N=="function"?N:Lo(!!N),x):e},x.touchable=function(N){return arguments.length?(s=typeof N=="function"?N:Lo(!!N),x):s},x.extent=function(N){return arguments.length?(t=typeof N=="function"?N:Lo([[+N[0][0],+N[0][1]],[+N[1][0],+N[1][1]]]),x):t},x.scaleExtent=function(N){return arguments.length?(r[0]=+N[0],r[1]=+N[1],x):[r[0],r[1]]},x.translateExtent=function(N){return arguments.length?(a[0][0]=+N[0][0],a[1][0]=+N[1][0],a[0][1]=+N[0][1],a[1][1]=+N[1][1],x):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},x.constrain=function(N){return arguments.length?(n=N,x):n},x.duration=function(N){return arguments.length?(l=+N,x):l},x.interpolate=function(N){return arguments.length?(c=N,x):c},x.on=function(){var N=u.on.apply(u,arguments);return N===u?x:N},x.clickDistance=function(N){return arguments.length?(b=(N=+N)*N,x):Math.sqrt(b)},x.tapDistance=function(N){return arguments.length?(S=+N,x):S},x}const Tt={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.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 React Flow 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:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,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."},uo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Iu=["Enter"," ","Escape"],Eu={"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:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"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 ji;(function(e){e.Strict="strict",e.Loose="loose"})(ji||(ji={}));var ii;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ii||(ii={}));var fo;(function(e){e.Partial="partial",e.Full="full"})(fo||(fo={}));const Au={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var vn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(vn||(vn={}));var po;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(po||(po={}));var re;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(re||(re={}));const _l={[re.Left]:re.Right,[re.Right]:re.Left,[re.Top]:re.Bottom,[re.Bottom]:re.Top};function ku(e){return e===null?null:e?"valid":"invalid"}const Bu=e=>"id"in e&&"source"in e&&"target"in e,X0=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Ca=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Mo=(e,t=[0,0])=>{const{width:n,height:i}=Yt(e),s=e.origin??t,r=n*s[0],a=i*s[1];return{x:e.position.x-r,y:e.position.y-a}},K0=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,s)=>{const r=typeof s=="string";let a=!t.nodeLookup&&!r?s:void 0;t.nodeLookup&&(a=r?t.nodeLookup.get(s):Ca(s)?s:t.nodeLookup.get(s.id));const l=a?bs(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Rs(i,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ds(n)},jo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=Rs(n,bs(s)),i=!0)}),i?Ds(n):{x:0,y:0,width:0,height:0}},Na=(e,t,[n,i,s]=[0,0,1],r=!1,a=!1)=>{const l={...No(t,[n,i,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:p=!1}=u;if(a&&!f||p)continue;const h=d.width??u.width??u.initialWidth??null,w=d.height??u.height??u.initialHeight??null,b=ho(l,Ni(u)),S=(h??0)*(w??0),x=r&&b>0;(!u.internals.handleBounds||x||b>=S||u.dragging)&&c.push(u)}return c},q0=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function Q0(e,t){const n=new Map,i=t?.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&(t?.includeHiddenNodes||!s.hidden)&&(!i||i.has(s.id))&&n.set(s.id,s)}),n}async function J0({nodes:e,width:t,height:n,panZoom:i,minZoom:s,maxZoom:r},a){if(e.size===0)return Promise.resolve(!0);const l=Q0(e,a),c=jo(l),u=Ta(c,t,n,a?.minZoom??s,a?.maxZoom??r,a?.padding??.1);return await i.setViewport(u,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),Promise.resolve(!0)}function Pu({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:s,onError:r}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},d=a.origin??i;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)r?.("005",Tt.error005());else{const h=l.measured.width,w=l.measured.height;h&&w&&(f=[[c,u],[c+h,u+w]])}else l&&Ti(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const p=Ti(f)?ri(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&r?.("015",Tt.error015()),{position:{x:p.x-c+(a.measured.width??0)*d[0],y:p.y-u+(a.measured.height??0)*d[1]},positionAbsolute:p}}async function eb({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:s}){const r=new Set(e.map(p=>p.id)),a=[];for(const p of n){if(p.deletable===!1)continue;const h=r.has(p.id),w=!h&&p.parentId&&a.find(b=>b.id===p.parentId);(h||w)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=i.filter(p=>p.deletable!==!1),d=q0(a,c);for(const p of c)l.has(p.id)&&!d.find(w=>w.id===p.id)&&d.push(p);if(!s)return{edges:d,nodes:a};const f=await s({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const Ci=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ri=(e={x:0,y:0},t,n)=>({x:Ci(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ci(e.y,t[0][1],t[1][1]-(n?.height??0))});function Ru(e,t,n){const{width:i,height:s}=Yt(n),{x:r,y:a}=n.internals.positionAbsolute;return ri(e,[[r,a],[r+i,a+s]],t)}const Ml=(e,t,n)=>e<t?Ci(Math.abs(e-t),1,t)/t:e>n?-Ci(Math.abs(e-n),1,t)/t:0,Du=(e,t,n=15,i=40)=>{const s=Ml(e.x,i,t.width-i)*n,r=Ml(e.y,i,t.height-i)*n;return[s,r]},Rs=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Zr=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),Ds=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),Ni=(e,t=[0,0])=>{const{x:n,y:i}=Ca(e)?e.internals.positionAbsolute:Mo(e,t);return{x:n,y:i,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},bs=(e,t=[0,0])=>{const{x:n,y:i}=Ca(e)?e.internals.positionAbsolute:Mo(e,t);return{x:n,y:i,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:i+(e.measured?.height??e.height??e.initialHeight??0)}},Lu=(e,t)=>Ds(Rs(Zr(e),Zr(t))),ho=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*i)},jl=e=>ct(e.width)&&ct(e.height)&&ct(e.x)&&ct(e.y),ct=e=>!isNaN(e)&&isFinite(e),tb=(e,t)=>{},Co=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),No=({x:e,y:t},[n,i,s],r=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-i)/s};return r?Co(l,a):l},xs=({x:e,y:t},[n,i,s])=>({x:e*s+n,y:t*s+i});function pi(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function nb(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=pi(e,n),s=pi(e,t);return{top:i,right:s,bottom:i,left:s,x:s*2,y:i*2}}if(typeof e=="object"){const i=pi(e.top??e.y??0,n),s=pi(e.bottom??e.y??0,n),r=pi(e.left??e.x??0,t),a=pi(e.right??e.x??0,t);return{top:i,right:a,bottom:s,left:r,x:r+a,y:i+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ib(e,t,n,i,s,r){const{x:a,y:l}=xs(e,[t,n,i]),{x:c,y:u}=xs({x:e.x+e.width,y:e.y+e.height},[t,n,i]),d=s-c,f=r-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(d),bottom:Math.floor(f)}}const Ta=(e,t,n,i,s,r)=>{const a=nb(r,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),d=Ci(u,i,s),f=e.x+e.width/2,p=e.y+e.height/2,h=t/2-f*d,w=n/2-p*d,b=ib(e,h,w,d,t,n),S={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:h-S.left+S.right,y:w-S.top+S.bottom,zoom:d}},mo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ti(e){return e!=null&&e!=="parent"}function Yt(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Fu(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function zu(e,t={width:0,height:0},n,i,s){const r={...e},a=i.get(n);if(a){const l=a.origin||s;r.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],r.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return r}function Cl(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function ob(){let e,t;return{promise:new Promise((i,s)=>{e=i,t=s}),resolve:e,reject:t}}function sb(e){return{...Eu,...e||{}}}function Qi(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:s}){const{x:r,y:a}=ut(e),l=No({x:r-(s?.left??0),y:a-(s?.top??0)},i),{x:c,y:u}=n?Co(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const Ia=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ou=e=>e?.getRootNode?.()||window?.document,rb=["INPUT","SELECT","TEXTAREA"];function $u(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:rb.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Gu=e=>"clientX"in e,ut=(e,t)=>{const n=Gu(e),i=n?e.clientX:e.touches?.[0].clientX,s=n?e.clientY:e.touches?.[0].clientY;return{x:i-(t?.left??0),y:s-(t?.top??0)}},Nl=(e,t,n,i,s)=>{const r=t.querySelectorAll(`.${e}`);return!r||!r.length?null:Array.from(r).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:s,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/i,y:(l.top-n.top)/i,...Ia(a)}})};function Hu({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:s,sourceControlY:r,targetControlX:a,targetControlY:l}){const c=e*.125+s*.375+a*.375+n*.125,u=t*.125+r*.375+l*.375+i*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function Fo(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Tl({pos:e,x1:t,y1:n,x2:i,y2:s,c:r}){switch(e){case re.Left:return[t-Fo(t-i,r),n];case re.Right:return[t+Fo(i-t,r),n];case re.Top:return[t,n-Fo(n-s,r)];case re.Bottom:return[t,n+Fo(s-n,r)]}}function Wu({sourceX:e,sourceY:t,sourcePosition:n=re.Bottom,targetX:i,targetY:s,targetPosition:r=re.Top,curvature:a=.25}){const[l,c]=Tl({pos:n,x1:e,y1:t,x2:i,y2:s,c:a}),[u,d]=Tl({pos:r,x1:i,y1:s,x2:e,y2:t,c:a}),[f,p,h,w]=Hu({sourceX:e,sourceY:t,targetX:i,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${l},${c} ${u},${d} ${i},${s}`,f,p,h,w]}function Uu({sourceX:e,sourceY:t,targetX:n,targetY:i}){const s=Math.abs(n-e)/2,r=n<e?n+s:n-s,a=Math.abs(i-t)/2,l=i<t?i+a:i-a;return[r,l,s,a]}function ab({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:s=!1,zIndexMode:r="basic"}){if(r==="manual")return i;const a=s&&n?i+1e3:i,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return a+l}function lb({sourceNode:e,targetNode:t,width:n,height:i,transform:s}){const r=Rs(bs(e),bs(t));r.x===r.x2&&(r.x2+=1),r.y===r.y2&&(r.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:i/s[2]};return ho(a,Ds(r))>0}const cb=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,ub=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),db=(e,t,n={})=>{if(!e.source||!e.target)return t;const i=n.getEdgeId||cb;let s;return Bu(e)?s={...e}:s={...e,id:i(e)},ub(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function Vu({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[s,r,a,l]=Uu({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,s,r,a,l]}const Il={[re.Left]:{x:-1,y:0},[re.Right]:{x:1,y:0},[re.Top]:{x:0,y:-1},[re.Bottom]:{x:0,y:1}},fb=({source:e,sourcePosition:t=re.Bottom,target:n})=>t===re.Left||t===re.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},El=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function pb({source:e,sourcePosition:t=re.Bottom,target:n,targetPosition:i=re.Top,center:s,offset:r,stepPosition:a}){const l=Il[t],c=Il[i],u={x:e.x+l.x*r,y:e.y+l.y*r},d={x:n.x+c.x*r,y:n.y+c.y*r},f=fb({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",h=f[p];let w=[],b,S;const x={x:0,y:0},_={x:0,y:0},[,,g,y]=Uu({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(b=s.x??u.x+(d.x-u.x)*a,S=s.y??(u.y+d.y)/2):(b=s.x??(u.x+d.x)/2,S=s.y??u.y+(d.y-u.y)*a);const k=[{x:b,y:u.y},{x:b,y:d.y}],D=[{x:u.x,y:S},{x:d.x,y:S}];l[p]===h?w=p==="x"?k:D:w=p==="x"?D:k}else{const k=[{x:u.x,y:d.y}],D=[{x:d.x,y:u.y}];if(p==="x"?w=l.x===h?D:k:w=l.y===h?k:D,t===i){const N=Math.abs(e[p]-n[p]);if(N<=r){const O=Math.min(r-1,r-N);l[p]===h?x[p]=(u[p]>e[p]?-1:1)*O:_[p]=(d[p]>n[p]?-1:1)*O}}if(t!==i){const N=p==="x"?"y":"x",O=l[p]===c[N],P=u[N]>d[N],z=u[N]<d[N];(l[p]===1&&(!O&&P||O&&z)||l[p]!==1&&(!O&&z||O&&P))&&(w=p==="x"?k:D)}const $={x:u.x+x.x,y:u.y+x.y},L={x:d.x+_.x,y:d.y+_.y},I=Math.max(Math.abs($.x-w[0].x),Math.abs(L.x-w[0].x)),H=Math.max(Math.abs($.y-w[0].y),Math.abs(L.y-w[0].y));I>=H?(b=($.x+L.x)/2,S=w[0].y):(b=w[0].x,S=($.y+L.y)/2)}const v={x:u.x+x.x,y:u.y+x.y},j={x:d.x+_.x,y:d.y+_.y};return[[e,...v.x!==w[0].x||v.y!==w[0].y?[v]:[],...w,...j.x!==w[w.length-1].x||j.y!==w[w.length-1].y?[j]:[],n],b,S,g,y]}function hb(e,t,n,i){const s=Math.min(El(e,t)/2,El(t,n)/2,i),{x:r,y:a}=t;if(e.x===r&&r===n.x||e.y===a&&a===n.y)return`L${r} ${a}`;if(e.y===a){const u=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${r+s*u},${a}Q ${r},${a} ${r},${a+s*d}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${r},${a+s*c}Q ${r},${a} ${r+s*l},${a}`}function Xr({sourceX:e,sourceY:t,sourcePosition:n=re.Bottom,targetX:i,targetY:s,targetPosition:r=re.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:d=.5}){const[f,p,h,w,b]=pb({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:s},targetPosition:r,center:{x:l,y:c},offset:u,stepPosition:d});let S=`M${f[0].x} ${f[0].y}`;for(let x=1;x<f.length-1;x++)S+=hb(f[x-1],f[x],f[x+1],a);return S+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[S,p,h,w,b]}function Al(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function mb(e){const{sourceNode:t,targetNode:n}=e;if(!Al(t)||!Al(n))return null;const i=t.internals.handleBounds||kl(t.handles),s=n.internals.handleBounds||kl(n.handles),r=Bl(i?.source??[],e.sourceHandle),a=Bl(e.connectionMode===ji.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!r||!a)return e.onError?.("008",Tt.error008(r?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=r?.position||re.Bottom,c=a?.position||re.Top,u=ai(t,r,l),d=ai(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function kl(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function ai(e,t,n=re.Left,i=!1){const s=(t?.x??0)+e.internals.positionAbsolute.x,r=(t?.y??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??Yt(e);if(i)return{x:s+a/2,y:r+l/2};switch(t?.position??n){case re.Top:return{x:s+a/2,y:r};case re.Right:return{x:s+a,y:r+l/2};case re.Bottom:return{x:s+a/2,y:r+l};case re.Left:return{x:s,y:r+l/2}}}function Bl(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Kr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function gb(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:s}){const r=new Set;return e.reduce((a,l)=>([l.markerStart||i,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const u=Kr(c,t);r.has(u)||(a.push({id:u,color:c.color||n,...c}),r.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const Yu=1e3,bb=10,Ea={nodeOrigin:[0,0],nodeExtent:uo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},xb={...Ea,checkEquality:!0};function Aa(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function yb(e,t,n){const i=Aa(Ea,n);for(const s of e.values())if(s.parentId)Ba(s,e,t,i);else{const r=Mo(s,i.nodeOrigin),a=Ti(s.extent)?s.extent:i.nodeExtent,l=ri(r,a,Yt(s));s.internals.positionAbsolute=l}}function vb(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],i=[];for(const s of e.handles){const r={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(r):s.type==="target"&&i.push(r)}return{source:n,target:i}}function ka(e){return e==="manual"}function qr(e,t,n,i={}){const s=Aa(xb,i),r={i:0},a=new Map(t),l=s?.elevateNodesOnSelect&&!ka(s.zIndexMode)?Yu:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const d of e){let f=a.get(d.id);if(s.checkEquality&&d===f?.internals.userNode)t.set(d.id,f);else{const p=Mo(d,s.nodeOrigin),h=Ti(d.extent)?d.extent:s.nodeExtent,w=ri(p,h,Yt(d));f={...s.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:w,handleBounds:vb(d,f),z:Zu(d,l,s.zIndexMode),userNode:d}},t.set(d.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),d.parentId&&Ba(f,t,n,i,r),u||=d.selected??!1}return{nodesInitialized:c,hasSelectedNodes:u}}function wb(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Ba(e,t,n,i,s){const{elevateNodesOnSelect:r,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Aa(Ea,i),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}wb(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*bb),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=r&&!ka(c)?Yu:0,{x:p,y:h,z:w}=Sb(e,d,a,l,f,c),{positionAbsolute:b}=e.internals,S=p!==b.x||h!==b.y;(S||w!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x:p,y:h}:b,z:w}})}function Zu(e,t,n){const i=ct(e.zIndex)?e.zIndex:0;return ka(n)?i:i+(e.selected?t:0)}function Sb(e,t,n,i,s,r){const{x:a,y:l}=t.internals.positionAbsolute,c=Yt(e),u=Mo(e,n),d=Ti(e.extent)?ri(u,e.extent,c):u;let f=ri({x:a+d.x,y:l+d.y},i,c);e.extent==="parent"&&(f=Ru(f,c,t));const p=Zu(e,s,r),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function Pa(e,t,n,i=[0,0]){const s=[],r=new Map;for(const a of e){const l=t.get(a.parentId);if(!l)continue;const c=r.get(a.parentId)?.expandedRect??Ni(l),u=Lu(c,a.rect);r.set(a.parentId,{expandedRect:u,parent:l})}return r.size>0&&r.forEach(({expandedRect:a,parent:l},c)=>{const u=l.internals.positionAbsolute,d=Yt(l),f=l.origin??i,p=a.x<u.x?Math.round(Math.abs(u.x-a.x)):0,h=a.y<u.y?Math.round(Math.abs(u.y-a.y)):0,w=Math.max(d.width,Math.round(a.width)),b=Math.max(d.height,Math.round(a.height)),S=(w-d.width)*f[0],x=(b-d.height)*f[1];(p>0||h>0||S||x)&&(s.push({id:c,type:"position",position:{x:l.position.x-p+S,y:l.position.y-h+x}}),n.get(c)?.forEach(_=>{e.some(g=>g.id===_.id)||s.push({id:_.id,type:"position",position:{x:_.position.x+p,y:_.position.y+h}})})),(d.width<a.width||d.height<a.height||p||h)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:w+(p?f[0]*p-S:0),height:b+(h?f[1]*h-x:0)}})}),s}function _b(e,t,n,i,s,r,a){const l=i?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const u=[],d=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(d.transform),p=[];for(const h of e.values()){const w=t.get(h.id);if(!w)continue;if(w.hidden){t.set(w.id,{...w,internals:{...w.internals,handleBounds:void 0}}),c=!0;continue}const b=Ia(h.nodeElement),S=w.measured.width!==b.width||w.measured.height!==b.height;if(!!(b.width&&b.height&&(S||!w.internals.handleBounds||h.force))){const _=h.nodeElement.getBoundingClientRect(),g=Ti(w.extent)?w.extent:r;let{positionAbsolute:y}=w.internals;w.parentId&&w.extent==="parent"?y=Ru(y,b,t.get(w.parentId)):g&&(y=ri(y,g,b));const v={...w,measured:b,internals:{...w.internals,positionAbsolute:y,handleBounds:{source:Nl("source",h.nodeElement,_,f,w.id),target:Nl("target",h.nodeElement,_,f,w.id)}}};t.set(w.id,v),w.parentId&&Ba(v,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,S&&(u.push({id:w.id,type:"dimensions",dimensions:b}),w.expandParent&&w.parentId&&p.push({id:w.id,parentId:w.parentId,rect:Ni(v,s)}))}}if(p.length>0){const h=Pa(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function Mb({delta:e,panZoom:t,transform:n,translateExtent:i,width:s,height:r}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,r]],i),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function Pl(e,t,n,i,s,r){let a=s;const l=i.get(a)||new Map;i.set(a,l.set(n,t)),a=`${s}-${e}`;const c=i.get(a)||new Map;if(i.set(a,c.set(n,t)),r){a=`${s}-${e}-${r}`;const u=i.get(a)||new Map;i.set(a,u.set(n,t))}}function Xu(e,t,n){e.clear(),t.clear();for(const i of n){const{source:s,target:r,sourceHandle:a=null,targetHandle:l=null}=i,c={edgeId:i.id,source:s,target:r,sourceHandle:a,targetHandle:l},u=`${s}-${a}--${r}-${l}`,d=`${r}-${l}--${s}-${a}`;Pl("source",c,d,e,s,a),Pl("target",c,u,e,r,l),t.set(i.id,i)}}function Ku(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ku(n,t):!1}function Rl(e,t,n){let i=e;do{if(i?.matches?.(t))return!0;if(i===n)return!1;i=i?.parentElement}while(i);return!1}function jb(e,t,n,i){const s=new Map;for(const[r,a]of e)if((a.selected||a.id===i)&&(!a.parentId||!Ku(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(r);l&&s.set(r,{id:r,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function cr({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){const s=[];for(const[a,l]of t){const c=n.get(a)?.internals.userNode;c&&s.push({...c,position:l.position,dragging:i})}if(!e)return[s[0],s];const r=n.get(e)?.internals.userNode;return[r?{...r,position:t.get(e)?.position||r.position,dragging:i}:s[0],s]}function Cb({dragItems:e,snapGrid:t,x:n,y:i}){const s=e.values().next().value;if(!s)return null;const r={x:n-s.distance.x,y:i-s.distance.y},a=Co(r,t);return{x:a.x-r.x,y:a.y-r.y}}function Nb({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:s}){let r={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},d=null,f=!1,p=null,h=!1,w=!1,b=null;function S({noDragClassName:_,handleSelector:g,domNode:y,isSelectable:v,nodeId:j,nodeClickDistance:T=0}){p=Ve(y);function k({x:I,y:H}){const{nodeLookup:N,nodeExtent:O,snapGrid:P,snapToGrid:z,nodeOrigin:M,onNodeDrag:F,onSelectionDrag:U,onError:V,updateNodePositions:Z}=t();r={x:I,y:H};let Y=!1;const Q=l.size>1,K=Q&&O?Zr(jo(l)):null,E=Q&&z?Cb({dragItems:l,snapGrid:P,x:I,y:H}):null;for(const[C,W]of l){if(!N.has(C))continue;let X={x:I-W.distance.x,y:H-W.distance.y};z&&(X=E?{x:Math.round(X.x+E.x),y:Math.round(X.y+E.y)}:Co(X,P));let q=null;if(Q&&O&&!W.extent&&K){const{positionAbsolute:ie}=W.internals,oe=ie.x-K.x+O[0][0],J=ie.x+W.measured.width-K.x2+O[1][0],le=ie.y-K.y+O[0][1],ue=ie.y+W.measured.height-K.y2+O[1][1];q=[[oe,le],[J,ue]]}const{position:ee,positionAbsolute:ne}=Pu({nodeId:C,nextPosition:X,nodeLookup:N,nodeExtent:q||O,nodeOrigin:M,onError:V});Y=Y||W.position.x!==ee.x||W.position.y!==ee.y,W.position=ee,W.internals.positionAbsolute=ne}if(w=w||Y,!!Y&&(Z(l,!0),b&&(i||F||!j&&U))){const[C,W]=cr({nodeId:j,dragItems:l,nodeLookup:N});i?.(b,l,C,W),F?.(b,C,W),j||U?.(b,W)}}async function D(){if(!d)return;const{transform:I,panBy:H,autoPanSpeed:N,autoPanOnNodeDrag:O}=t();if(!O){c=!1,cancelAnimationFrame(a);return}const[P,z]=Du(u,d,N);(P!==0||z!==0)&&(r.x=(r.x??0)-P/I[2],r.y=(r.y??0)-z/I[2],await H({x:P,y:z})&&k(r)),a=requestAnimationFrame(D)}function $(I){const{nodeLookup:H,multiSelectionActive:N,nodesDraggable:O,transform:P,snapGrid:z,snapToGrid:M,selectNodesOnDrag:F,onNodeDragStart:U,onSelectionDragStart:V,unselectNodesAndEdges:Z}=t();f=!0,(!F||!v)&&!N&&j&&(H.get(j)?.selected||Z()),v&&F&&j&&e?.(j);const Y=Qi(I.sourceEvent,{transform:P,snapGrid:z,snapToGrid:M,containerBounds:d});if(r=Y,l=jb(H,O,Y,j),l.size>0&&(n||U||!j&&V)){const[Q,K]=cr({nodeId:j,dragItems:l,nodeLookup:H});n?.(I.sourceEvent,l,Q,K),U?.(I.sourceEvent,Q,K),j||V?.(I.sourceEvent,K)}}const L=pu().clickDistance(T).on("start",I=>{const{domNode:H,nodeDragThreshold:N,transform:O,snapGrid:P,snapToGrid:z}=t();d=H?.getBoundingClientRect()||null,h=!1,w=!1,b=I.sourceEvent,N===0&&$(I),r=Qi(I.sourceEvent,{transform:O,snapGrid:P,snapToGrid:z,containerBounds:d}),u=ut(I.sourceEvent,d)}).on("drag",I=>{const{autoPanOnNodeDrag:H,transform:N,snapGrid:O,snapToGrid:P,nodeDragThreshold:z,nodeLookup:M}=t(),F=Qi(I.sourceEvent,{transform:N,snapGrid:O,snapToGrid:P,containerBounds:d});if(b=I.sourceEvent,(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1||j&&!M.has(j))&&(h=!0),!h){if(!c&&H&&f&&(c=!0,D()),!f){const U=ut(I.sourceEvent,d),V=U.x-u.x,Z=U.y-u.y;Math.sqrt(V*V+Z*Z)>z&&$(I)}(r.x!==F.xSnapped||r.y!==F.ySnapped)&&l&&f&&(u=ut(I.sourceEvent,d),k(F))}}).on("end",I=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:H,updateNodePositions:N,onNodeDragStop:O,onSelectionDragStop:P}=t();if(w&&(N(l,!1),w=!1),s||O||!j&&P){const[z,M]=cr({nodeId:j,dragItems:l,nodeLookup:H,dragging:!1});s?.(I.sourceEvent,l,z,M),O?.(I.sourceEvent,z,M),j||P?.(I.sourceEvent,M)}}}).filter(I=>{const H=I.target;return!I.button&&(!_||!Rl(H,`.${_}`,y))&&(!g||Rl(H,g,y))});p.call(L)}function x(){p?.on(".drag",null)}return{update:S,destroy:x}}function Tb(e,t,n){const i=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const r of t.values())ho(s,Ni(r))>0&&i.push(r);return i}const Ib=250;function Eb(e,t,n,i){let s=[],r=1/0;const a=Tb(e,n,t+Ib);for(const l of a){const c=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const u of c){if(i.nodeId===u.nodeId&&i.type===u.type&&i.id===u.id)continue;const{x:d,y:f}=ai(l,u,u.position,!0),p=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(f-e.y,2));p>t||(p<r?(s=[{...u,x:d,y:f}],r=p):p===r&&s.push({...u,x:d,y:f}))}}if(!s.length)return null;if(s.length>1){const l=i.type==="source"?"target":"source";return s.find(c=>c.type===l)??s[0]}return s[0]}function qu(e,t,n,i,s,r=!1){const a=i.get(e);if(!a)return null;const l=s==="strict"?a.internals.handleBounds?.[t]:[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]],c=(n?l?.find(u=>u.id===n):l?.[0])??null;return c&&r?{...c,...ai(a,c,c.position,!0)}:c}function Qu(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Ab(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ju=()=>!0;function kb(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:s,edgeUpdaterType:r,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:p,cancelConnection:h,onConnectStart:w,onConnect:b,onConnectEnd:S,isValidConnection:x=Ju,onReconnectEnd:_,updateConnection:g,getTransform:y,getFromHandle:v,autoPanSpeed:j,dragThreshold:T=1,handleDomNode:k}){const D=Ou(e.target);let $=0,L;const{x:I,y:H}=ut(e),N=Qu(r,k),O=l?.getBoundingClientRect();let P=!1;if(!O||!N)return;const z=qu(s,N,i,c,t);if(!z)return;let M=ut(e,O),F=!1,U=null,V=!1,Z=null;function Y(){if(!d||!O)return;const[ee,ne]=Du(M,O,j);p({x:ee,y:ne}),$=requestAnimationFrame(Y)}const Q={...z,nodeId:s,type:N,position:z.position},K=c.get(s);let C={inProgress:!0,isValid:null,from:ai(K,Q,re.Left,!0),fromHandle:Q,fromPosition:Q.position,fromNode:K,to:M,toHandle:null,toPosition:_l[Q.position],toNode:null,pointer:M};function W(){P=!0,g(C),w?.(e,{nodeId:s,handleId:i,handleType:N})}T===0&&W();function X(ee){if(!P){const{x:ue,y:he}=ut(ee),be=ue-I,Ce=he-H;if(!(be*be+Ce*Ce>T*T))return;W()}if(!v()||!Q){q(ee);return}const ne=y();M=ut(ee,O),L=Eb(No(M,ne,!1,[1,1]),n,c,Q),F||(Y(),F=!0);const ie=ed(ee,{handle:L,connectionMode:t,fromNodeId:s,fromHandleId:i,fromType:a?"target":"source",isValidConnection:x,doc:D,lib:u,flowId:f,nodeLookup:c});Z=ie.handleDomNode,U=ie.connection,V=Ab(!!L,ie.isValid);const oe=c.get(s),J=oe?ai(oe,Q,re.Left,!0):C.from,le={...C,from:J,isValid:V,to:ie.toHandle&&V?xs({x:ie.toHandle.x,y:ie.toHandle.y},ne):M,toHandle:ie.toHandle,toPosition:V&&ie.toHandle?ie.toHandle.position:_l[Q.position],toNode:ie.toHandle?c.get(ie.toHandle.nodeId):null,pointer:M};g(le),C=le}function q(ee){if(!("touches"in ee&&ee.touches.length>0)){if(P){(L||Z)&&U&&V&&b?.(U);const{inProgress:ne,...ie}=C,oe={...ie,toPosition:C.toHandle?C.toPosition:null};S?.(ee,oe),r&&_?.(ee,oe)}h(),cancelAnimationFrame($),F=!1,V=!1,U=null,Z=null,D.removeEventListener("mousemove",X),D.removeEventListener("mouseup",q),D.removeEventListener("touchmove",X),D.removeEventListener("touchend",q)}}D.addEventListener("mousemove",X),D.addEventListener("mouseup",q),D.addEventListener("touchmove",X),D.addEventListener("touchend",q)}function ed(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:s,fromType:r,doc:a,lib:l,flowId:c,isValidConnection:u=Ju,nodeLookup:d}){const f=r==="target",p=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:w}=ut(e),b=a.elementFromPoint(h,w),S=b?.classList.contains(`${l}-flow__handle`)?b:p,x={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const _=Qu(void 0,S),g=S.getAttribute("data-nodeid"),y=S.getAttribute("data-handleid"),v=S.classList.contains("connectable"),j=S.classList.contains("connectableend");if(!g||!_)return x;const T={source:f?g:i,sourceHandle:f?y:s,target:f?i:g,targetHandle:f?s:y};x.connection=T;const D=v&&j&&(n===ji.Strict?f&&_==="source"||!f&&_==="target":g!==i||y!==s);x.isValid=D&&u(T),x.toHandle=qu(g,_,y,d,n,!0)}return x}const Qr={onPointerDown:kb,isValid:ed};function Bb({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const s=Ve(e);function r({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const w=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const y=n(),v=g.sourceEvent.ctrlKey&&mo()?10:1,j=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*d,T=y[2]*Math.pow(2,j*v);t.scaleTo(T)};let b=[0,0];const S=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(b=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},x=g=>{const y=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const v=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],j=[v[0]-b[0],v[1]-b[1]];b=v;const T=i()*Math.max(y[2],Math.log(y[2]))*(h?-1:1),k={x:y[0]-j[0]*T,y:y[1]-j[1]*T},D=[[0,0],[c,u]];t.setViewportConstrained({x:k.x,y:k.y,zoom:y[2]},D,l)},_=Tu().on("start",S).on("zoom",f?x:null).on("zoom.wheel",p?w:null);s.call(_,{})}function a(){s.on("zoom",null)}return{update:r,destroy:a,pointer:ot}}const Ls=e=>({x:e.x,y:e.y,zoom:e.k}),ur=({x:e,y:t,zoom:n})=>Ps.translate(e,t).scale(n),yi=(e,t)=>e.target.closest(`.${t}`),td=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Pb=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,dr=(e,t=0,n=Pb,i=()=>{})=>{const s=typeof t=="number"&&t>0;return s||i(),s?e.transition().duration(t).ease(n).on("end",i):e},nd=e=>{const t=e.ctrlKey&&mo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Rb({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:s,panOnScrollSpeed:r,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(yi(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const S=ot(d),x=nd(d),_=f*Math.pow(2,x);i.scaleTo(n,_,S,d);return}const p=d.deltaMode===1?20:1;let h=s===ii.Vertical?0:d.deltaX*p,w=s===ii.Horizontal?0:d.deltaY*p;!mo()&&d.shiftKey&&s!==ii.Vertical&&(h=d.deltaY*p,w=0),i.translateBy(n,-(h/f)*r,-(w/f)*r,{internal:!0});const b=Ls(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(d,b),e.panScrollTimeout=setTimeout(()=>{u?.(d,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(d,b))}}function Db({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,s){const r=i.type==="wheel",a=!t&&r&&!i.ctrlKey,l=yi(i,e);if(i.ctrlKey&&r&&l&&i.preventDefault(),a||l)return null;i.preventDefault(),n.call(this,i,s)}}function Lb({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{if(i.sourceEvent?.internal)return;const s=Ls(i.transform);e.mouseButton=i.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=s,i.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(i.sourceEvent,s)}}function Fb({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:s}){return r=>{e.usedRightMouseButton=!!(n&&td(t,e.mouseButton??0)),r.sourceEvent?.sync||i([r.transform.x,r.transform.y,r.transform.k]),s&&!r.sourceEvent?.internal&&s?.(r.sourceEvent,Ls(r.transform))}}function zb({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:s,onPaneContextMenu:r}){return a=>{if(!a.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,r&&td(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&r(a.sourceEvent),e.usedRightMouseButton=!1,i(!1),s)){const l=Ls(a.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(a.sourceEvent,l)},n?150:0)}}}function Ob({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:s,zoomOnDoubleClick:r,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{const p=e||t,h=n&&f.ctrlKey,w=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(yi(f,`${u}-flow__node`)||yi(f,`${u}-flow__edge`)))return!0;if(!i&&!p&&!s&&!r&&!n||a||d&&!w||yi(f,l)&&w||yi(f,c)&&(!w||s&&w&&!e)||!n&&f.ctrlKey&&w)return!1;if(!n&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!s&&!h&&w||!i&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(i)&&!i.includes(f.button)&&f.type==="mousedown")return!1;const b=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||w)&&b}}function $b({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:s,onPanZoom:r,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=Tu().scaleExtent([t,n]).translateExtent(i),p=Ve(e).call(f);_({x:s.x,y:s.y,zoom:Ci(s.zoom,t,n)},[[0,0],[d.width,d.height]],i);const h=p.on("wheel.zoom"),w=p.on("dblclick.zoom");f.wheelDelta(nd);function b(L,I){return p?new Promise(H=>{f?.interpolate(I?.interpolate==="linear"?qi:is).transform(dr(p,I?.duration,I?.ease,()=>H(!0)),L)}):Promise.resolve(!1)}function S({noWheelClassName:L,noPanClassName:I,onPaneContextMenu:H,userSelectionActive:N,panOnScroll:O,panOnDrag:P,panOnScrollMode:z,panOnScrollSpeed:M,preventScrolling:F,zoomOnPinch:U,zoomOnScroll:V,zoomOnDoubleClick:Z,zoomActivationKeyPressed:Y,lib:Q,onTransformChange:K,connectionInProgress:E,paneClickDistance:C,selectionOnDrag:W}){N&&!u.isZoomingOrPanning&&x();const X=O&&!Y&&!N;f.clickDistance(W?1/0:!ct(C)||C<0?0:C);const q=X?Rb({zoomPanValues:u,noWheelClassName:L,d3Selection:p,d3Zoom:f,panOnScrollMode:z,panOnScrollSpeed:M,zoomOnPinch:U,onPanZoomStart:a,onPanZoom:r,onPanZoomEnd:l}):Db({noWheelClassName:L,preventScrolling:F,d3ZoomHandler:h});if(p.on("wheel.zoom",q,{passive:!1}),!N){const ne=Lb({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",ne);const ie=Fb({zoomPanValues:u,panOnDrag:P,onPaneContextMenu:!!H,onPanZoom:r,onTransformChange:K});f.on("zoom",ie);const oe=zb({zoomPanValues:u,panOnDrag:P,panOnScroll:O,onPaneContextMenu:H,onPanZoomEnd:l,onDraggingChange:c});f.on("end",oe)}const ee=Ob({zoomActivationKeyPressed:Y,panOnDrag:P,zoomOnScroll:V,panOnScroll:O,zoomOnDoubleClick:Z,zoomOnPinch:U,userSelectionActive:N,noPanClassName:I,noWheelClassName:L,lib:Q,connectionInProgress:E});f.filter(ee),Z?p.on("dblclick.zoom",w):p.on("dblclick.zoom",null)}function x(){f.on("zoom",null)}async function _(L,I,H){const N=ur(L),O=f?.constrain()(N,I,H);return O&&await b(O),new Promise(P=>P(O))}async function g(L,I){const H=ur(L);return await b(H,I),new Promise(N=>N(H))}function y(L){if(p){const I=ur(L),H=p.property("__zoom");(H.k!==L.zoom||H.x!==L.x||H.y!==L.y)&&f?.transform(p,I,null,{sync:!0})}}function v(){const L=p?Nu(p.node()):{x:0,y:0,k:1};return{x:L.x,y:L.y,zoom:L.k}}function j(L,I){return p?new Promise(H=>{f?.interpolate(I?.interpolate==="linear"?qi:is).scaleTo(dr(p,I?.duration,I?.ease,()=>H(!0)),L)}):Promise.resolve(!1)}function T(L,I){return p?new Promise(H=>{f?.interpolate(I?.interpolate==="linear"?qi:is).scaleBy(dr(p,I?.duration,I?.ease,()=>H(!0)),L)}):Promise.resolve(!1)}function k(L){f?.scaleExtent(L)}function D(L){f?.translateExtent(L)}function $(L){const I=!ct(L)||L<0?0:L;f?.clickDistance(I)}return{update:S,destroy:x,setViewport:g,setViewportConstrained:_,getViewport:v,scaleTo:j,scaleBy:T,setScaleExtent:k,setTranslateExtent:D,syncViewport:y,setClickDistance:$}}var Ii;(function(e){e.Line="line",e.Handle="handle"})(Ii||(Ii={}));function Gb({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:s,affectsY:r}){const a=e-t,l=n-i,c=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&s&&(c[0]=c[0]*-1),l&&r&&(c[1]=c[1]*-1),c}function Dl(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:s}}function mn(e,t){return Math.max(0,t-e)}function gn(e,t){return Math.max(0,e-t)}function zo(e,t,n){return Math.max(0,t-e,e-n)}function Ll(e,t){return e?!t:t}function Hb(e,t,n,i,s,r,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,p=d&&f,{xSnapped:h,ySnapped:w}=n,{minWidth:b,maxWidth:S,minHeight:x,maxHeight:_}=i,{x:g,y,width:v,height:j,aspectRatio:T}=e;let k=Math.floor(d?h-e.pointerX:0),D=Math.floor(f?w-e.pointerY:0);const $=v+(c?-k:k),L=j+(u?-D:D),I=-r[0]*v,H=-r[1]*j;let N=zo($,b,S),O=zo(L,x,_);if(a){let M=0,F=0;c&&k<0?M=mn(g+k+I,a[0][0]):!c&&k>0&&(M=gn(g+$+I,a[1][0])),u&&D<0?F=mn(y+D+H,a[0][1]):!u&&D>0&&(F=gn(y+L+H,a[1][1])),N=Math.max(N,M),O=Math.max(O,F)}if(l){let M=0,F=0;c&&k>0?M=gn(g+k,l[0][0]):!c&&k<0&&(M=mn(g+$,l[1][0])),u&&D>0?F=gn(y+D,l[0][1]):!u&&D<0&&(F=mn(y+L,l[1][1])),N=Math.max(N,M),O=Math.max(O,F)}if(s){if(d){const M=zo($/T,x,_)*T;if(N=Math.max(N,M),a){let F=0;!c&&!u||c&&!u&&p?F=gn(y+H+$/T,a[1][1])*T:F=mn(y+H+(c?k:-k)/T,a[0][1])*T,N=Math.max(N,F)}if(l){let F=0;!c&&!u||c&&!u&&p?F=mn(y+$/T,l[1][1])*T:F=gn(y+(c?k:-k)/T,l[0][1])*T,N=Math.max(N,F)}}if(f){const M=zo(L*T,b,S)/T;if(O=Math.max(O,M),a){let F=0;!c&&!u||u&&!c&&p?F=gn(g+L*T+I,a[1][0])/T:F=mn(g+(u?D:-D)*T+I,a[0][0])/T,O=Math.max(O,F)}if(l){let F=0;!c&&!u||u&&!c&&p?F=mn(g+L*T,l[1][0])/T:F=gn(g+(u?D:-D)*T,l[0][0])/T,O=Math.max(O,F)}}}D=D+(D<0?O:-O),k=k+(k<0?N:-N),s&&(p?$>L*T?D=(Ll(c,u)?-k:k)/T:k=(Ll(c,u)?-D:D)*T:d?(D=k/T,u=c):(k=D*T,c=u));const P=c?g+k:g,z=u?y+D:y;return{width:v+(c?-k:k),height:j+(u?-D:D),x:r[0]*k*(c?-1:1)+P,y:r[1]*D*(u?-1:1)+z}}const id={width:0,height:0,x:0,y:0},Wb={...id,pointerX:0,pointerY:0,aspectRatio:1};function Ub(e){return[[0,0],[e.measured.width,e.measured.height]]}function Vb(e,t,n){const i=t.position.x+e.position.x,s=t.position.y+e.position.y,r=e.measured.width??0,a=e.measured.height??0,l=n[0]*r,c=n[1]*a;return[[i-l,s-c],[i+r-l,s+a-c]]}function Yb({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:s}){const r=Ve(e);let a={controlDirection:Dl("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:p,onResizeStart:h,onResize:w,onResizeEnd:b,shouldResize:S}){let x={...id},_={...Wb};a={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:Dl(u)};let g,y=null,v=[],j,T,k,D=!1;const $=pu().on("start",L=>{const{nodeLookup:I,transform:H,snapGrid:N,snapToGrid:O,nodeOrigin:P,paneDomNode:z}=n();if(g=I.get(t),!g)return;y=z?.getBoundingClientRect()??null;const{xSnapped:M,ySnapped:F}=Qi(L.sourceEvent,{transform:H,snapGrid:N,snapToGrid:O,containerBounds:y});x={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},_={...x,pointerX:M,pointerY:F,aspectRatio:x.width/x.height},j=void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(j=I.get(g.parentId),T=j&&g.extent==="parent"?Ub(j):void 0),v=[],k=void 0;for(const[U,V]of I)if(V.parentId===t&&(v.push({id:U,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const Z=Vb(V,g,V.origin??P);k?k=[[Math.min(Z[0][0],k[0][0]),Math.min(Z[0][1],k[0][1])],[Math.max(Z[1][0],k[1][0]),Math.max(Z[1][1],k[1][1])]]:k=Z}h?.(L,{...x})}).on("drag",L=>{const{transform:I,snapGrid:H,snapToGrid:N,nodeOrigin:O}=n(),P=Qi(L.sourceEvent,{transform:I,snapGrid:H,snapToGrid:N,containerBounds:y}),z=[];if(!g)return;const{x:M,y:F,width:U,height:V}=x,Z={},Y=g.origin??O,{width:Q,height:K,x:E,y:C}=Hb(_,a.controlDirection,P,a.boundaries,a.keepAspectRatio,Y,T,k),W=Q!==U,X=K!==V,q=E!==M&&W,ee=C!==F&&X;if(!q&&!ee&&!W&&!X)return;if((q||ee||Y[0]===1||Y[1]===1)&&(Z.x=q?E:x.x,Z.y=ee?C:x.y,x.x=Z.x,x.y=Z.y,v.length>0)){const J=E-M,le=C-F;for(const ue of v)ue.position={x:ue.position.x-J+Y[0]*(Q-U),y:ue.position.y-le+Y[1]*(K-V)},z.push(ue)}if((W||X)&&(Z.width=W&&(!a.resizeDirection||a.resizeDirection==="horizontal")?Q:x.width,Z.height=X&&(!a.resizeDirection||a.resizeDirection==="vertical")?K:x.height,x.width=Z.width,x.height=Z.height),j&&g.expandParent){const J=Y[0]*(Z.width??0);Z.x&&Z.x<J&&(x.x=J,_.x=_.x-(Z.x-J));const le=Y[1]*(Z.height??0);Z.y&&Z.y<le&&(x.y=le,_.y=_.y-(Z.y-le))}const ne=Gb({width:x.width,prevWidth:U,height:x.height,prevHeight:V,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),ie={...x,direction:ne};S?.(L,ie)!==!1&&(D=!0,w?.(L,ie),i(Z,z))}).on("end",L=>{D&&(b?.(L,{...x}),s?.({...x}),D=!1)});r.call($)}function c(){r.on(".drag",null)}return{update:l,destroy:c}}const Fs=m.createContext(null),Zb=Fs.Provider,od=Tt.error001();function me(e,t){const n=m.useContext(Fs);if(n===null)throw new Error(od);return Wc.useStoreWithEqualityFn(n,e,t)}function je(){const e=m.useContext(Fs);if(e===null)throw new Error(od);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Fl={display:"none"},Xb={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},sd="react-flow__node-desc",rd="react-flow__edge-desc",Kb="react-flow__aria-live",qb=e=>e.ariaLiveMessage,Qb=e=>e.ariaLabelConfig;function Jb({rfId:e}){const t=me(qb);return o.jsx("div",{id:`${Kb}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Xb,children:t})}function ex({rfId:e,disableKeyboardA11y:t}){const n=me(Qb);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${sd}-${e}`,style:Fl,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${rd}-${e}`,style:Fl,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(Jb,{rfId:e})]})}const zs=m.forwardRef(({position:e="top-left",children:t,className:n,style:i,...s},r)=>{const a=`${e}`.split("-");return o.jsx("div",{className:Ie(["react-flow__panel",n,...a]),style:i,ref:r,...s,children:t})});zs.displayName="Panel";function tx({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:o.jsx(zs,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:o.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const nx=e=>{const t=[],n=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&n.push(i);return{selectedNodes:t,selectedEdges:n}},Oo=e=>e.id;function ix(e,t){return Me.shallow(e.selectedNodes.map(Oo),t.selectedNodes.map(Oo))&&Me.shallow(e.selectedEdges.map(Oo),t.selectedEdges.map(Oo))}function ox({onSelectionChange:e}){const t=je(),{selectedNodes:n,selectedEdges:i}=me(nx,ix);return m.useEffect(()=>{const s={nodes:n,edges:i};e?.(s),t.getState().onSelectionChangeHandlers.forEach(r=>r(s))},[n,i,e]),null}const sx=e=>!!e.onSelectionChangeHandlers;function rx({onSelectionChange:e}){const t=me(sx);return e||t?o.jsx(ox,{onSelectionChange:e}):null}const Jr=typeof window<"u"?m.useLayoutEffect:m.useEffect,ad=[0,0],ax={x:0,y:0,zoom:1},lx=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],zl=[...lx,"rfId"],cx=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Ol={translateExtent:uo,nodeOrigin:ad,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function ux(e){const{setNodes:t,setEdges:n,setMinZoom:i,setMaxZoom:s,setTranslateExtent:r,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=me(cx,Me.shallow),u=je();Jr(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=Ol,l()}),[]);const d=m.useRef(Ol);return Jr(()=>{for(const f of zl){const p=e[f],h=d.current[f];p!==h&&(typeof e[f]>"u"||(f==="nodes"?t(p):f==="edges"?n(p):f==="minZoom"?i(p):f==="maxZoom"?s(p):f==="translateExtent"?r(p):f==="nodeExtent"?a(p):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:sb(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},zl.map(f=>e[f])),null}function $l(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function dx(e){const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const i=$l(),s=()=>n(i?.matches?"dark":"light");return s(),i?.addEventListener("change",s),()=>{i?.removeEventListener("change",s)}},[e]),t!==null?t:$l()?.matches?"dark":"light"}const Gl=typeof document<"u"?document:null;function go(e=null,t={target:Gl,actInsideInputWithModifier:!0}){const[n,i]=m.useState(!1),s=m.useRef(!1),r=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),m=require("react"),ge=require("./gaesupStore-2zKBYTYo.cjs"),R=require("./index-CJj-Z7Jr.cjs"),xe=require("@react-three/fiber"),lt=require("@react-three/rapier"),Wc=require("zustand/traditional"),Me=require("zustand/shallow");require("react-dom");const _n=require("./assetStore-DVPge_2j.cjs"),xi=require("./index-DCa_lUwq.cjs"),li=require("zustand"),ma=require("zustand/react/shallow"),Fe=require("./loader-D7cEHkCq.cjs"),ei=require("./index-De3ev_jU.cjs"),ft=require("@react-three/drei"),Yp=require("three"),wo=require("./sfe-CpgzdMyB.cjs"),Zp=require("immer"),Xp=require("zustand/middleware/immer"),ga=require("three-stdlib");require("reflect-metadata");const ba=require("./weatherStore-1unmwIen.cjs"),xa=require("simplex-noise");function Kp(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const B=Kp(Yp);function Oe({label:e,min:t,max:n,step:i,value:s,suffix:r,onChange:a}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"#fff"},children:[o.jsx("span",{style:{width:60,flexShrink:0,color:"rgba(255,255,255,0.7)"},children:e}),o.jsx("input",{type:"range",min:t,max:n,step:i,value:s,onChange:l=>a(Number(l.target.value)),style:{flex:1,accentColor:"#0078d4"}}),o.jsxs("span",{style:{width:44,textAlign:"right",fontFamily:"monospace",fontSize:11},children:[typeof i=="number"&&i<1?s.toFixed(2):s,r??""]})]})}function nr({label:e,checked:t,onChange:n}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,color:"#fff"},children:[o.jsx("input",{type:"checkbox",checked:t,onChange:i=>n(i.target.checked),style:{accentColor:"#0078d4"}}),o.jsx("span",{children:e})]})}function Oi({title:e,children:t}){return o.jsxs("div",{style:{background:"rgba(0,0,0,0.2)",borderRadius:6,padding:"8px 10px",border:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",gap:6},children:[o.jsx("div",{style:{fontSize:10,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:.5},children:e}),t]})}function qp(){const e=ge.useGaesupStore(a=>a.cameraOption),t=ge.useGaesupStore(a=>a.setCameraOption),n=ge.useGaesupStore(a=>a.mode),i=m.useCallback((a,l)=>{t({[a]:l})},[t]),s=m.useCallback((a,l)=>{t({smoothing:{...e.smoothing,[a]:l}})},[t,e.smoothing]),r=a=>e[a]??0;return o.jsxs("div",{style:{padding:10,display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:-4},children:["Mode: ",n.control??"thirdPerson"]}),o.jsxs(Oi,{title:"Distance",children:[o.jsx(Oe,{label:"X",min:-50,max:50,step:1,value:r("xDistance"),onChange:a=>i("xDistance",a)}),o.jsx(Oe,{label:"Y",min:0,max:50,step:1,value:r("yDistance"),onChange:a=>i("yDistance",a)}),o.jsx(Oe,{label:"Z",min:-50,max:50,step:1,value:r("zDistance"),onChange:a=>i("zDistance",a)})]}),o.jsxs(Oi,{title:"FOV / Smoothing",children:[o.jsx(Oe,{label:"FOV",min:30,max:120,step:5,value:e.fov??75,suffix:"deg",onChange:a=>i("fov",a)}),o.jsx(Oe,{label:"Pos",min:.01,max:1,step:.01,value:e.smoothing?.position??.1,onChange:a=>s("position",a)}),o.jsx(Oe,{label:"Rot",min:.01,max:1,step:.01,value:e.smoothing?.rotation??.1,onChange:a=>s("rotation",a)}),o.jsx(Oe,{label:"FOV Sm",min:.01,max:1,step:.01,value:e.smoothing?.fov??.2,onChange:a=>s("fov",a)})]}),o.jsxs(Oi,{title:"Zoom",children:[o.jsx(nr,{label:"Enable Zoom",checked:e.enableZoom??!1,onChange:a=>i("enableZoom",a)}),o.jsx(Oe,{label:"Speed",min:1e-4,max:.01,step:1e-4,value:e.zoomSpeed??.001,onChange:a=>i("zoomSpeed",a)}),o.jsx(Oe,{label:"Min",min:.1,max:2,step:.1,value:e.minZoom??.5,onChange:a=>i("minZoom",a)}),o.jsx(Oe,{label:"Max",min:1,max:5,step:.1,value:e.maxZoom??2,onChange:a=>i("maxZoom",a)})]}),o.jsxs(Oi,{title:"Options",children:[o.jsx(nr,{label:"Collision",checked:e.enableCollision??!1,onChange:a=>i("enableCollision",a)}),o.jsx(nr,{label:"Focus Mode",checked:e.enableFocus??!1,onChange:a=>i("enableFocus",a)}),o.jsx(Oe,{label:"Focus Dist",min:1,max:50,step:1,value:e.focusDistance??15,onChange:a=>i("focusDistance",a)}),o.jsx(Oe,{label:"Max Dist",min:5,max:100,step:1,value:e.maxDistance??50,onChange:a=>i("maxDistance",a)})]}),o.jsxs(Oi,{title:"Bounds",children:[o.jsx(Oe,{label:"Min Y",min:-10,max:50,step:1,value:e.bounds?.minY??2,onChange:a=>t({bounds:{...e.bounds,minY:a}})}),o.jsx(Oe,{label:"Max Y",min:5,max:100,step:1,value:e.bounds?.maxY??50,onChange:a=>t({bounds:{...e.bounds,maxY:a}})})]})]})}const Qp=[{value:"thirdPerson",label:"Third Person"},{value:"firstPerson",label:"First Person"},{value:"chase",label:"Chase"},{value:"topDown",label:"Top Down"},{value:"isometric",label:"Isometric"},{value:"sideScroll",label:"Side-Scroller"},{value:"fixed",label:"Fixed"}];function Jp(){const{mode:e,setMode:t}=ge.useGaesupStore(ma.useShallow(i=>({mode:i.mode,setMode:i.setMode}))),n=e?.control||"thirdPerson";return o.jsx("div",{className:"cc-panel",children:o.jsx("div",{className:"cc-list",children:Qp.map(i=>o.jsx("button",{className:`cc-button ${n===i.value?"active":""}`,onClick:()=>t({control:i.value}),children:i.label},i.value))})})}const eh=[{key:"mode",label:"Mode",enabled:!0,format:"text"},{key:"position",label:"Position",enabled:!0,format:"vector3",precision:2},{key:"distance",label:"Distance",enabled:!0,format:"vector3",precision:2},{key:"fov",label:"FOV",enabled:!0,format:"angle",precision:1},{key:"velocity",label:"Velocity",enabled:!1,format:"vector3",precision:2},{key:"rotation",label:"Rotation",enabled:!1,format:"vector3",precision:2},{key:"zoom",label:"Zoom",enabled:!1,format:"number",precision:2},{key:"activeController",label:"Controller",enabled:!0,format:"text"}];function ir(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"}function th(){const e={frameCount:0,averageFrameTime:0,lastUpdateTime:Date.now(),mode:"unknown",activeController:"unknown",distance:null,fov:0,position:null,targetPosition:null,velocity:null,rotation:null},[t,n]=m.useState(e),i=ge.useGaesupStore(f=>f.mode),s=ge.useGaesupStore(f=>f.cameraOption),{activeState:r}=R.useStateSystem(),a=m.useRef(e),l=m.useCallback((f,p)=>f===p?!1:ir(f)?ir(p)?f.x!==p.x||f.y!==p.y||f.z!==p.z:!0:typeof f!="object"||f===null?!0:JSON.stringify(f)!==JSON.stringify(p),[]),c=m.useCallback(f=>ir(f)?{x:f.x,y:f.y,z:f.z}:null,[]),u=m.useCallback(()=>{const f=s?.xDistance!==void 0&&s?.yDistance!==void 0&&s?.zDistance!==void 0?{x:s.xDistance,y:s.yDistance,z:s.zDistance}:null,p={...a.current,mode:i?.control??"unknown",activeController:s?.mode??i?.control??"unknown",distance:f,fov:s?.fov??0,position:c(r?.position),targetPosition:c(s?.target),velocity:c(r?.velocity),rotation:c(r?.euler),lastUpdateTime:Date.now(),...s?.zoom!==void 0?{zoom:s.zoom}:{}};Object.keys(p).some(w=>l(p[w],a.current[w]))&&(a.current=p,n(p))},[i,s,r,l,c]);m.useEffect(()=>{u();const f=setInterval(u,100);return()=>{clearInterval(f)}},[u]);const d=m.useCallback((f,p=2)=>f==null?"N/A":typeof f=="object"&&f.x!==void 0?`X:${f.x.toFixed(p)} Y:${f.y.toFixed(p)} Z:${f.z.toFixed(p)}`:typeof f=="number"?f.toFixed(p):f.toString(),[]);return o.jsx("div",{className:"cd-panel",children:o.jsx("div",{className:"cd-grid",children:eh.map(f=>o.jsxs("div",{className:"cd-item",children:[o.jsx("span",{className:"cd-label",children:f.label}),o.jsx("span",{className:"cd-value",children:d(t[f.key])})]},f.key))})})}const nh=[{id:"classic",name:"Classic",description:"A traditional third-person view.",icon:"camera",config:{mode:"thirdPerson",distance:{x:0,y:8,z:10},fov:75,smoothing:{position:.1,rotation:.1,fov:.1}}},{id:"cinematic",name:"Cinematic",description:"Smooth, movie-like camera work.",icon:"camera",config:{mode:"chase",distance:{x:2,y:7,z:8},fov:60,smoothing:{position:.05,rotation:.05,fov:.05}}},{id:"action",name:"Action",description:"Responsive camera for fast gameplay.",icon:"camera",config:{mode:"thirdPerson",distance:{x:0,y:6,z:6},fov:85,smoothing:{position:.2,rotation:.2,fov:.2}}},{id:"strategy",name:"Strategy",description:"Top-down view for an overview.",icon:"camera",config:{mode:"topDown",distance:{x:0,y:20,z:0},fov:45,smoothing:{position:.1,rotation:.1,fov:.1}}},{id:"retro",name:"Retro",description:"Classic side-scroller style.",icon:"camera",config:{mode:"sideScroll",distance:{x:15,y:0,z:0},fov:75,smoothing:{position:.15,rotation:.15,fov:.15}}}];function ih(e,t){return!e||!t?!1:e.x===t.x&&e.y===t.y&&e.z===t.z}function oh(e){const t=e?.xDistance,n=e?.yDistance,i=e?.zDistance;if(!(t===void 0||n===void 0||i===void 0))return{x:t,y:n,z:i}}function Uc(){const[e]=m.useState(nh),t=ge.useGaesupStore(c=>c.setMode),n=ge.useGaesupStore(c=>c.setCameraOption),i=ge.useGaesupStore(c=>c.mode),s=ge.useGaesupStore(c=>c.cameraOption),[r,a]=m.useState(null),l=m.useCallback(c=>{t({control:c.config.mode}),n({xDistance:c.config.distance.x,yDistance:c.config.distance.y,zDistance:c.config.distance.z,fov:c.config.fov,smoothing:c.config.smoothing||{position:.1,rotation:.1,fov:.1}})},[t,n,s]);return m.useEffect(()=>{const c=e.find(u=>u.config.mode===i?.control&&ih(u.config.distance,oh(s)));a(c?c.id:null)},[i,s,e]),o.jsx("div",{className:"cp-panel",children:o.jsx("div",{className:"cp-grid",children:e.map(c=>o.jsxs("button",{className:`cp-item ${r===c.id?"active":""}`,onClick:()=>l(c),children:[o.jsx("div",{className:"cp-name",children:c.name}),o.jsx("div",{className:"cp-description",children:c.description})]},c.id))})})}function Vc({className:e="",style:t,children:n}={}){const[i,s]=m.useState("Settings"),r=()=>{switch(i){case"Settings":return o.jsx(qp,{});case"Controller":return o.jsx(Jp,{});case"Presets":return o.jsx(Uc,{});case"Debug":return o.jsx(th,{});default:return null}};return o.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[o.jsxs("div",{className:"panel-tabs",children:[o.jsx("button",{className:`panel-tab ${i==="Settings"?"active":""}`,onClick:()=>s("Settings"),children:"Settings"}),o.jsx("button",{className:`panel-tab ${i==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),o.jsx("button",{className:`panel-tab ${i==="Presets"?"active":""}`,onClick:()=>s("Presets"),children:"Presets"}),o.jsx("button",{className:`panel-tab ${i==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),o.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const sh=[{value:"idle",label:"Idle"},{value:"walk",label:"Walk"},{value:"run",label:"Run"},{value:"jump",label:"Jump"},{value:"fall",label:"Fall"},{value:"dance",label:"Dance"},{value:"wave",label:"Wave"}];function rh(){const{playAnimation:e,currentType:t,currentAnimation:n}=R.useAnimationBridge(),i=s=>{e(t,s)};return o.jsx("div",{className:"ac-panel",children:o.jsx("div",{className:"ac-grid",children:sh.map(s=>o.jsx("button",{className:`ac-button ${s.value===n?"active":""}`,onClick:()=>i(s.value),title:s.label,children:s.label},s.value))})})}const ah=[{key:"currentAnimation",label:"현재 애니메이션",format:"text",enabled:!0},{key:"animationType",label:"애니메이션 타입",format:"text",enabled:!0},{key:"isPlaying",label:"재생 상태",format:"text",enabled:!0},{key:"weight",label:"가중치",format:"number",enabled:!0},{key:"speed",label:"속도",format:"number",enabled:!0},{key:"blendDuration",label:"블렌드 시간",format:"number",enabled:!1},{key:"activeActions",label:"활성 액션",format:"number",enabled:!0},{key:"availableAnimations",label:"사용 가능 애니메이션",format:"array",enabled:!1},{key:"frameCount",label:"프레임 카운트",format:"number",enabled:!1},{key:"averageFrameTime",label:"평균 프레임 시간",format:"number",enabled:!1}];function lh(){const{bridge:e,currentType:t}=R.useAnimationBridge(),[n,i]=m.useState({frameCount:0,averageFrameTime:0,lastUpdateTime:Date.now(),currentAnimation:"idle",animationType:"character",availableAnimations:[],isPlaying:!1,weight:1,speed:1,blendDuration:.3,activeActions:0});m.useEffect(()=>{if(!e)return;const a=()=>{const c=e.snapshot(t);if(!c)return;const u=e.getMetrics(t);i(d=>({...d,currentAnimation:c.currentAnimation,animationType:t,availableAnimations:c.availableAnimations,isPlaying:c.isPlaying,weight:c.weight,speed:c.speed,activeActions:c.metrics.activeAnimations,frameCount:u?.totalActions||0,averageFrameTime:u?.mixerTime||0,lastUpdateTime:Date.now()}))};return a(),e.subscribe((c,u)=>{u===t&&a()})},[e,t]);const s=(a,l,c=2)=>{if(a==null)return"N/A";switch(l){case"array":return Array.isArray(a)?`${a.length} animations`:String(a);case"boolean":return a?"Yes":"No";case"number":return typeof a=="number"?a.toFixed(c):String(a);default:return String(a)}},r=a=>{if(a in n)return n[a]};return o.jsx("div",{className:"ad-panel",children:o.jsx("div",{className:"ad-content",children:ah.filter(a=>a.enabled).map(a=>o.jsxs("div",{className:"ad-item",children:[o.jsx("span",{className:"ad-label",children:a.label}),o.jsx("span",{className:"ad-value",children:s(r(a.key),a.format)})]},a.key))})})}const ch=()=>o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M8 5v14l11-7z"})}),uh=()=>o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),dh=()=>o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M6 6h2v12H6zm3.5 6l8.5 6V6z"})}),fh=()=>o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"})});function ph(){const{bridge:e,playAnimation:t,stopAnimation:n,currentType:i,currentAnimation:s}=R.useAnimationBridge(),[r,a]=m.useState(!1),[l,c]=m.useState([]),[u,d]=m.useState(30);m.useEffect(()=>{if(!e)return;const p=()=>{const w=e.snapshot(i);w&&(a(w.isPlaying),c(w.availableAnimations))};return p(),e.subscribe((w,b)=>{b===i&&p()})},[e,i]);const f=()=>{r?n(i):t(i,s)};return o.jsxs("div",{className:"ap-panel",children:[o.jsxs("div",{className:"ap-controls",children:[o.jsx("select",{className:"ap-select",value:s,onChange:p=>t(i,p.target.value),children:l.map(p=>o.jsx("option",{value:p,children:p},p))}),o.jsxs("div",{className:"ap-buttons",children:[o.jsx("button",{className:"ap-btn","aria-label":"previous animation",children:o.jsx(dh,{})}),o.jsx("button",{className:"ap-btn-primary",onClick:f,"aria-label":r?"pause":"play",children:r?o.jsx(uh,{}):o.jsx(ch,{})}),o.jsx("button",{className:"ap-btn","aria-label":"next animation",children:o.jsx(fh,{})})]})]}),o.jsxs("div",{className:"ap-timeline",children:[o.jsx("span",{className:"ap-time",children:"0:00"}),o.jsx("input",{type:"range",className:"ap-slider",min:"0",max:"100",value:u,onChange:p=>d(Number(p.target.value))}),o.jsx("span",{className:"ap-time",children:"1:30"})]})]})}function Yc({className:e="",style:t,children:n}={}){const[i,s]=m.useState("Player"),r=()=>{switch(i){case"Player":return o.jsx("div",{className:"panel-content-wrapper",children:o.jsx(ph,{})});case"Controller":return o.jsx("div",{className:"panel-content-wrapper",children:o.jsx(rh,{})});case"Debug":return o.jsx("div",{className:"panel-content-wrapper",children:o.jsx(lh,{})});default:return null}};return o.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[o.jsxs("div",{className:"panel-tabs",children:[o.jsx("button",{className:`panel-tab ${i==="Player"?"active":""}`,onClick:()=>s("Player"),children:"Player"}),o.jsx("button",{className:`panel-tab ${i==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),o.jsx("button",{className:`panel-tab ${i==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),o.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const il=[{id:"slow",name:"Slow",maxSpeed:5,acceleration:8},{id:"normal",name:"Normal",maxSpeed:10,acceleration:15},{id:"fast",name:"Fast",maxSpeed:20,acceleration:25},{id:"sprint",name:"Sprint",maxSpeed:35,acceleration:40}],ol=[{id:"eco",name:"Eco",maxSpeed:15,acceleration:10},{id:"comfort",name:"Comfort",maxSpeed:25,acceleration:20},{id:"sport",name:"Sport",maxSpeed:40,acceleration:35},{id:"turbo",name:"Turbo",maxSpeed:60,acceleration:50}];function hh(e,t){const n=e??"bottom-left",i={position:"fixed",zIndex:t??1e4};return n.includes("top")&&(i.top=12),n.includes("bottom")&&(i.bottom=12),n.includes("left")&&(i.left=12),n.includes("right")&&(i.right=12),i}function Zc(e){const t=hh(e.position,e.zIndex),n=ge.useGaesupStore(p=>p.mode),i=ge.useGaesupStore(p=>p.setMode),s=ge.useGaesupStore(p=>p.setPhysics),r=n?.type==="vehicle"?"vehicle":"character",a=r==="vehicle"?ol:il,[l,c]=m.useState(r==="vehicle"?"comfort":"normal"),u=m.useCallback((p,h)=>{const b=(p==="vehicle"?ol:il).find(S=>S.id===h);if(b){if(p==="vehicle"){s({maxSpeed:b.maxSpeed,accelRatio:b.acceleration});return}s({walkSpeed:Math.max(1,b.maxSpeed*.5),runSpeed:b.maxSpeed,accelRatio:b.acceleration})}},[s]),d=m.useCallback(p=>{c(p),u(r,p),e.onPresetChange?.(p)},[u,r,e]),f=m.useCallback(p=>{const h=p.target.value;i({type:h});const w=h==="vehicle"?"comfort":"normal";c(w),u(h,w),e.onPresetChange?.(w)},[u,i,e]);return o.jsxs("div",{className:`mc-panel ${e.compact?"compact":""}`,style:t,children:[o.jsxs("div",{className:"mc-setting-row",children:[o.jsx("label",{htmlFor:"motion-type-select",className:"mc-label",children:"Motion Type"}),o.jsxs("select",{id:"motion-type-select",className:"mc-select",value:r,onChange:f,children:[o.jsx("option",{value:"character",children:"Character"}),o.jsx("option",{value:"vehicle",children:"Vehicle"})]})]}),o.jsxs("div",{className:"mc-setting-row",children:[o.jsx("label",{className:"mc-label",children:"Presets"}),o.jsx("div",{className:"mc-presets-grid",children:a.map(p=>o.jsx("button",{className:`mc-preset-btn ${p.id===l?"active":""}`,onClick:()=>d(p.id),title:`Max Speed: ${p.maxSpeed}, Accel: ${p.acceleration}`,children:p.name},p.id))})]})]})}const sl=[{key:"motionType",label:"Motion Type",type:"text"},{key:"position",label:"Position",type:"vector3"},{key:"velocity",label:"Velocity",type:"vector3"},{key:"speed",label:"Speed",type:"number"},{key:"direction",label:"Direction",type:"vector3"},{key:"isGrounded",label:"Grounded",type:"text"},{key:"isMoving",label:"Moving",type:"text"},{key:"acceleration",label:"Acceleration",type:"number"},{key:"jumpForce",label:"Jump Force",type:"number"},{key:"maxSpeed",label:"Max Speed",type:"number"},{key:"totalDistance",label:"Total Distance",type:"number"},{key:"gameState",label:"Game State",type:"text"}];function mh(e,t){const n=e??"top-right",i={position:"fixed",zIndex:t??1e4};return n.includes("top")&&(i.top=12),n.includes("bottom")&&(i.bottom=12),n.includes("left")&&(i.left=12),n.includes("right")&&(i.right=12),i}function Xc(e){const t=e.embedded?{}:mh(e.position,e.zIndex),n=ge.useGaesupStore(d=>d.mode),i=ge.useGaesupStore(d=>d.physics),{activeState:s,gameStates:r}=R.useStateSystem(),a=e.precision??2,l=e.customFields?[...sl,...e.customFields]:sl,c=(d,f,p=2)=>{if(f==null)return"N/A";switch(d.type){case"vector3":if(Array.isArray(f)&&f.length===3){const[h,w,b]=f;return`X:${h.toFixed(p)} Y:${w.toFixed(p)} Z:${b.toFixed(p)}`}if(typeof f=="object"&&f!==null&&"x"in f&&"y"in f&&"z"in f){const h=f;return`X:${h.x.toFixed(p)} Y:${h.y.toFixed(p)} Z:${h.z.toFixed(p)}`}return String(f);case"number":return typeof f=="number"?f.toFixed(p):String(f);default:return String(f)}},u=d=>{if(d.value!==void 0)return d.value;switch(d.key){case"motionType":return n?.type??"character";case"position":return s?.position?{x:s.position.x,y:s.position.y,z:s.position.z}:{x:0,y:0,z:0};case"velocity":return s?.velocity?{x:s.velocity.x,y:s.velocity.y,z:s.velocity.z}:{x:0,y:0,z:0};case"speed":return s?.velocity?s.velocity.length():0;case"direction":return s?.direction?{x:s.direction.x,y:s.direction.y,z:s.direction.z}:{x:0,y:0,z:0};case"isGrounded":return r?.isOnTheGround?"Yes":"No";case"isMoving":return r?.isMoving?"Yes":"No";case"acceleration":return i?.accelRatio??0;case"jumpForce":return i?.jumpSpeed??0;case"maxSpeed":return n?.type==="character"?i?.runSpeed??0:i?.maxSpeed??0;case"totalDistance":return 0;case"gameState":return r?.isRiding?"riding":r?.isOnTheGround?"ground":"air";default:return null}};return o.jsx("div",{className:`md-panel ${e.compact?"compact":""} ${e.theme?`theme-${e.theme}`:""}`,style:t,children:o.jsx("div",{className:"md-content",children:l.map(d=>o.jsxs("div",{className:"md-item",children:[o.jsx("span",{className:"md-label",children:d.label}),o.jsx("span",{className:"md-value",children:c(d,u(d),a)})]},d.key))})})}function Kc({className:e="",style:t,children:n}={}){const[i,s]=m.useState("Controller"),r=()=>{switch(i){case"Controller":return o.jsx("div",{className:"panel-content-wrapper",children:o.jsx(Zc,{})});case"Debug":return o.jsx("div",{className:"panel-content-wrapper",children:o.jsx(Xc,{embedded:!0})});default:return null}};return o.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[o.jsxs("div",{className:"panel-tabs",children:[o.jsx("button",{className:`panel-tab ${i==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),o.jsx("button",{className:`panel-tab ${i==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),o.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const Ao=60,ko=({data:e,color:t,max:n,warn:i})=>{const r=e.filter(c=>isFinite(c));if(r.length<2)return null;const a=Math.max(1,n),l=r.map((c,u)=>{const d=u/(r.length-1)*100,f=40-c/a*40;return`${u===0?"M":"L"}${d.toFixed(2)},${f.toFixed(2)}`}).join(" ");return o.jsx("div",{className:"perf-chart",children:o.jsxs("svg",{width:"100%",height:40,preserveAspectRatio:"none",viewBox:"0 0 100 40",children:[i!==void 0&&o.jsx("line",{x1:"0",y1:40-i/a*40,x2:"100",y2:40-i/a*40,stroke:"#facc15",strokeWidth:"0.5",strokeDasharray:"3,3",opacity:.5}),o.jsx("path",{d:l,fill:"none",stroke:t,strokeWidth:"2",strokeLinejoin:"round",strokeLinecap:"round"})]})})},or=({value:e,max:t,color:n,label:i})=>{const s=t>0?Math.min(100,e/t*100):0;return o.jsxs("div",{style:{marginBottom:4},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,marginBottom:2},children:[o.jsx("span",{className:"perf-label",children:i}),o.jsx("span",{children:e.toFixed(1)})]}),o.jsx("div",{style:{height:4,background:"#1e293b",borderRadius:2,overflow:"hidden"},children:o.jsx("div",{style:{width:`${s}%`,height:"100%",background:n,borderRadius:2,transition:"width 0.3s"}})})]})};function qc({className:e="",style:t,children:n}={}){const i=ge.useGaesupStore(ma.useShallow(P=>P.performance)),[s,r]=m.useState({current:0,min:1/0,max:0,avg:0,p1Low:0,history:Array(Ao).fill(0)}),[a,l]=m.useState({used:0,limit:0,history:Array(Ao).fill(0)}),[c,u]=m.useState(0),[d,f]=m.useState(Array(Ao).fill(0)),[p,h]=m.useState(Array(Ao).fill(0)),w=m.useRef(0),b=m.useRef(0),S=m.useRef(0),x=m.useRef([]),_=m.useRef(0),g=m.useRef(null),y=m.useRef(0),v=m.useRef(0),j=m.useRef(0),T=m.useCallback(P=>{if(P.length<5)return 0;const z=[...P].filter(U=>U>0).sort((U,V)=>U-V),M=Math.max(1,Math.floor(z.length*.01));let F=0;for(let U=0;U<M;U++)F+=z[U]??0;return F/M},[]);m.useEffect(()=>{const P=window.performance.now();w.current=P,b.current=P,_.current=P;const z=M=>{const F=M-b.current;if(b.current=M,x.current.push(F),x.current.length>300&&x.current.shift(),y.current+=F,v.current++,v.current>=10){const U=y.current/v.current;u(U),h(V=>[...V.slice(1),U]),y.current=0,v.current=0}if(S.current++,M-w.current>=500){const U=S.current*1e3/(M-w.current),V=x.current.map(Q=>Q>0?1e3/Q:0),Z=M-_.current>3e3;r(Q=>{const K=[...Q.history.slice(1),U],E=Z?Math.min(Q.min===1/0?U:Q.min,U):1/0,C=Z?Math.max(Q.max,U):0,W=Z?K.filter(ee=>ee>0):[],X=W.length>0?W.reduce((ee,ne)=>ee+ne,0)/W.length:U,q=Z?T(V):U;return{current:U,min:E,max:C,avg:X,p1Low:q,history:K}});const Y=window.performance.memory;Y&&l(Q=>{const K=Math.round(Y.usedJSHeapSize/1048576),E=Math.round(Y.jsHeapSizeLimit/1048576);return{used:K,limit:E,history:[...Q.history.slice(1),K]}}),w.current=M,S.current=0}g.current=requestAnimationFrame(z)};return g.current=requestAnimationFrame(z),()=>{g.current&&cancelAnimationFrame(g.current)}},[T]),m.useEffect(()=>{const P=i.render.calls;P!==j.current&&(j.current=P,f(z=>[...z.slice(1),P]))},[i.render.calls]);const k=P=>P>=55?"#4ade80":P>=30?"#facc15":"#f87171",D=P=>P<=16.7?"#4ade80":P<=33.3?"#facc15":"#f87171",$=P=>P<=100?"#4ade80":P<=300?"#facc15":"#f87171",L=(P,z)=>{const M=z>0?P/z*100:0;return M<60?"#4ade80":M<80?"#facc15":"#f87171"},I=i.render.triangles,H=i.render.calls,N=i.engine.geometries,O=i.engine.textures;return o.jsxs("div",{className:`perf-panel ${e}`,style:t,children:[o.jsxs("div",{className:"perf-stat-group",children:[o.jsxs("div",{className:"perf-header",children:[o.jsx("h4",{className:"perf-title",children:"Frame Rate"}),o.jsxs("span",{className:"perf-current",style:{color:k(s.current)},children:[s.current.toFixed(0)," FPS"]})]}),o.jsxs("div",{className:"perf-details-grid",children:[o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Avg"}),s.avg.toFixed(1)]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Min"}),isFinite(s.min)?s.min.toFixed(1):"..."]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Max"}),s.max.toFixed(1)]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"1% Low"}),o.jsx("span",{style:{color:k(s.p1Low)},children:s.p1Low.toFixed(1)})]})]}),o.jsx(ko,{data:s.history,color:k(s.current),max:90,warn:60})]}),o.jsxs("div",{className:"perf-stat-group",children:[o.jsxs("div",{className:"perf-header",children:[o.jsx("h4",{className:"perf-title",children:"Frame Time"}),o.jsxs("span",{className:"perf-current",style:{color:D(c)},children:[c.toFixed(2)," ms"]})]}),o.jsx(or,{value:c,max:33.3,color:D(c),label:"Budget (16.7ms)"}),o.jsx(ko,{data:p,color:D(c),max:33.3,warn:16.7})]}),o.jsxs("div",{className:"perf-stat-group",children:[o.jsxs("div",{className:"perf-header",children:[o.jsx("h4",{className:"perf-title",children:"GPU Pipeline"}),o.jsxs("span",{className:"perf-current",style:{color:$(H)},children:[H," calls"]})]}),o.jsxs("div",{className:"perf-details-grid",children:[o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Triangles"}),I>=1e6?(I/1e6).toFixed(2)+"M":I>=1e3?(I/1e3).toFixed(1)+"K":I]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Draw Calls"}),o.jsx("span",{style:{color:$(H)},children:H})]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Tri/Call"}),H>0?Math.round(I/H):0]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Points"}),i.render.points]})]}),o.jsx(ko,{data:d,color:$(H),max:Math.max(200,...d)})]}),o.jsxs("div",{className:"perf-stat-group",children:[o.jsx("div",{className:"perf-header",children:o.jsx("h4",{className:"perf-title",children:"Resources"})}),o.jsxs("div",{className:"perf-details-grid",children:[o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Geometries"}),N]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Textures"}),O]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Programs"}),i.engine.programs]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Lines"}),i.render.lines]})]}),o.jsx(or,{value:N,max:200,color:N>150?"#f87171":"#4ade80",label:"Geometry Budget"}),o.jsx(or,{value:O,max:100,color:O>80?"#f87171":"#4ade80",label:"Texture Budget"})]}),o.jsxs("div",{className:"perf-stat-group",children:[o.jsxs("div",{className:"perf-header",children:[o.jsx("h4",{className:"perf-title",children:"Memory"}),o.jsxs("span",{className:"perf-current",style:{color:L(a.used,a.limit)},children:[a.used," MB"]})]}),o.jsxs("div",{className:"perf-details-grid",children:[o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Limit"}),a.limit," MB"]}),o.jsxs("div",{children:[o.jsx("span",{className:"perf-label",children:"Usage"}),a.limit>0?(a.used/a.limit*100).toFixed(0):0,"%"]})]}),o.jsx(ko,{data:a.history,color:L(a.used,a.limit),max:a.limit||1})]}),n]})}const Qc=({className:e="",style:t,children:n})=>{const i=ge.useGaesupStore(l=>l.mode),s=ge.useGaesupStore(l=>l.setMode),r=l=>{s({type:l,controller:"keyboard",control:l==="airplane"||l==="vehicle"?"chase":"thirdPerson"})},a=[{type:"character",label:"Character",description:"Walk around as character"},{type:"vehicle",label:"Vehicle",description:"Drive a ground vehicle"},{type:"airplane",label:"Airplane",description:"Fly an airplane"}];return o.jsxs("div",{className:`vehicle-panel ${e}`,style:t,children:[o.jsx("div",{className:"vehicle-panel__modes",children:a.map(l=>o.jsxs("button",{className:`vehicle-panel__mode-button ${i.type===l.type?"vehicle-panel__mode-button--active":""}`,onClick:()=>r(l.type),children:[o.jsx("span",{className:"vehicle-panel__mode-label",children:l.label}),o.jsx("span",{className:"vehicle-panel__mode-description",children:l.description})]},l.type))}),o.jsxs("div",{className:"vehicle-panel__info",children:[o.jsxs("div",{className:"vehicle-panel__info-item",children:[o.jsx("span",{className:"vehicle-panel__info-label",children:"Current Mode:"}),o.jsx("span",{className:"vehicle-panel__info-value",children:i.type})]}),o.jsxs("div",{className:"vehicle-panel__info-item",children:[o.jsx("span",{className:"vehicle-panel__info-label",children:"Controls:"}),o.jsx("span",{className:"vehicle-panel__info-value",children:i.type==="airplane"?"WASD + Space/Shift":"WASD + Space"})]})]}),n]})};function Ie(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,i;n<e.length;n++)(i=Ie(e[n]))!==""&&(t+=(t&&" ")+i);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var gh={value:()=>{}};function Es(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new ns(n)}function ns(e){this._=e}function bh(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",s=n.indexOf(".");if(s>=0&&(i=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}ns.prototype=Es.prototype={constructor:ns,on:function(e,t){var n=this._,i=bh(e+"",n),s,r=-1,a=i.length;if(arguments.length<2){for(;++r<a;)if((s=(e=i[r]).type)&&(s=xh(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++r<a;)if(s=(e=i[r]).type)n[s]=rl(n[s],e.name,t);else if(t==null)for(s in n)n[s]=rl(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ns(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),i=0,s,r;i<s;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(r=this._[e],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],s=0,r=i.length;s<r;++s)i[s].value.apply(t,n)}};function xh(e,t){for(var n=0,i=e.length,s;n<i;++n)if((s=e[n]).name===t)return s.value}function rl(e,t,n){for(var i=0,s=e.length;i<s;++i)if(e[i].name===t){e[i]=gh,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var Or="http://www.w3.org/1999/xhtml";const al={svg:"http://www.w3.org/2000/svg",xhtml:Or,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function As(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),al.hasOwnProperty(t)?{space:al[t],local:e}:e}function yh(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Or&&t.documentElement.namespaceURI===Or?t.createElement(e):t.createElementNS(n,e)}}function vh(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Jc(e){var t=As(e);return(t.local?vh:yh)(t)}function wh(){}function ya(e){return e==null?wh:function(){return this.querySelector(e)}}function Sh(e){typeof e!="function"&&(e=ya(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=i[s]=new Array(a),c,u,d=0;d<a;++d)(c=r[d])&&(u=e.call(c,c.__data__,d,r))&&("__data__"in c&&(u.__data__=c.__data__),l[d]=u);return new Ye(i,this._parents)}function _h(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Mh(){return[]}function eu(e){return e==null?Mh:function(){return this.querySelectorAll(e)}}function jh(e){return function(){return _h(e.apply(this,arguments))}}function Ch(e){typeof e=="function"?e=jh(e):e=eu(e);for(var t=this._groups,n=t.length,i=[],s=[],r=0;r<n;++r)for(var a=t[r],l=a.length,c,u=0;u<l;++u)(c=a[u])&&(i.push(e.call(c,c.__data__,u,a)),s.push(c));return new Ye(i,s)}function tu(e){return function(){return this.matches(e)}}function nu(e){return function(t){return t.matches(e)}}var Nh=Array.prototype.find;function Th(e){return function(){return Nh.call(this.children,e)}}function Ih(){return this.firstElementChild}function Eh(e){return this.select(e==null?Ih:Th(typeof e=="function"?e:nu(e)))}var Ah=Array.prototype.filter;function kh(){return Array.from(this.children)}function Bh(e){return function(){return Ah.call(this.children,e)}}function Ph(e){return this.selectAll(e==null?kh:Bh(typeof e=="function"?e:nu(e)))}function Rh(e){typeof e!="function"&&(e=tu(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=i[s]=[],c,u=0;u<a;++u)(c=r[u])&&e.call(c,c.__data__,u,r)&&l.push(c);return new Ye(i,this._parents)}function iu(e){return new Array(e.length)}function Dh(){return new Ye(this._enter||this._groups.map(iu),this._parents)}function us(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}us.prototype={constructor:us,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Lh(e){return function(){return e}}function Fh(e,t,n,i,s,r){for(var a=0,l,c=t.length,u=r.length;a<u;++a)(l=t[a])?(l.__data__=r[a],i[a]=l):n[a]=new us(e,r[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function zh(e,t,n,i,s,r,a){var l,c,u=new Map,d=t.length,f=r.length,p=new Array(d),h;for(l=0;l<d;++l)(c=t[l])&&(p[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<f;++l)h=a.call(e,r[l],l,r)+"",(c=u.get(h))?(i[l]=c,c.__data__=r[l],u.delete(h)):n[l]=new us(e,r[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function Oh(e){return e.__data__}function $h(e,t){if(!arguments.length)return Array.from(this,Oh);var n=t?zh:Fh,i=this._parents,s=this._groups;typeof e!="function"&&(e=Lh(e));for(var r=s.length,a=new Array(r),l=new Array(r),c=new Array(r),u=0;u<r;++u){var d=i[u],f=s[u],p=f.length,h=Gh(e.call(d,d&&d.__data__,u,i)),w=h.length,b=l[u]=new Array(w),S=a[u]=new Array(w),x=c[u]=new Array(p);n(d,f,b,S,x,h,t);for(var _=0,g=0,y,v;_<w;++_)if(y=b[_]){for(_>=g&&(g=_+1);!(v=S[g])&&++g<w;);y._next=v||null}}return a=new Ye(a,i),a._enter=l,a._exit=c,a}function Gh(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Hh(){return new Ye(this._exit||this._groups.map(iu),this._parents)}function Wh(e,t,n){var i=this.enter(),s=this,r=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?r.remove():n(r),i&&s?i.merge(s).order():s}function Uh(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,s=n.length,r=i.length,a=Math.min(s,r),l=new Array(s),c=0;c<a;++c)for(var u=n[c],d=i[c],f=u.length,p=l[c]=new Array(f),h,w=0;w<f;++w)(h=u[w]||d[w])&&(p[w]=h);for(;c<s;++c)l[c]=n[c];return new Ye(l,this._parents)}function Vh(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],s=i.length-1,r=i[s],a;--s>=0;)(a=i[s])&&(r&&a.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(a,r),r=a);return this}function Yh(e){e||(e=Zh);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var n=this._groups,i=n.length,s=new Array(i),r=0;r<i;++r){for(var a=n[r],l=a.length,c=s[r]=new Array(l),u,d=0;d<l;++d)(u=a[d])&&(c[d]=u);c.sort(t)}return new Ye(s,this._parents).order()}function Zh(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Xh(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Kh(){return Array.from(this)}function qh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],s=0,r=i.length;s<r;++s){var a=i[s];if(a)return a}return null}function Qh(){let e=0;for(const t of this)++e;return e}function Jh(){return!this.node()}function em(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var s=t[n],r=0,a=s.length,l;r<a;++r)(l=s[r])&&e.call(l,l.__data__,r,s);return this}function tm(e){return function(){this.removeAttribute(e)}}function nm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function im(e,t){return function(){this.setAttribute(e,t)}}function om(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function sm(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function rm(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function am(e,t){var n=As(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?nm:tm:typeof t=="function"?n.local?rm:sm:n.local?om:im)(n,t))}function ou(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lm(e){return function(){this.style.removeProperty(e)}}function cm(e,t,n){return function(){this.style.setProperty(e,t,n)}}function um(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function dm(e,t,n){return arguments.length>1?this.each((t==null?lm:typeof t=="function"?um:cm)(e,t,n??"")):_i(this.node(),e)}function _i(e,t){return e.style.getPropertyValue(t)||ou(e).getComputedStyle(e,null).getPropertyValue(t)}function fm(e){return function(){delete this[e]}}function pm(e,t){return function(){this[e]=t}}function hm(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function mm(e,t){return arguments.length>1?this.each((t==null?fm:typeof t=="function"?hm:pm)(e,t)):this.node()[e]}function su(e){return e.trim().split(/^|\s+/)}function va(e){return e.classList||new ru(e)}function ru(e){this._node=e,this._names=su(e.getAttribute("class")||"")}ru.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function au(e,t){for(var n=va(e),i=-1,s=t.length;++i<s;)n.add(t[i])}function lu(e,t){for(var n=va(e),i=-1,s=t.length;++i<s;)n.remove(t[i])}function gm(e){return function(){au(this,e)}}function bm(e){return function(){lu(this,e)}}function xm(e,t){return function(){(t.apply(this,arguments)?au:lu)(this,e)}}function ym(e,t){var n=su(e+"");if(arguments.length<2){for(var i=va(this.node()),s=-1,r=n.length;++s<r;)if(!i.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?xm:t?gm:bm)(n,t))}function vm(){this.textContent=""}function wm(e){return function(){this.textContent=e}}function Sm(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function _m(e){return arguments.length?this.each(e==null?vm:(typeof e=="function"?Sm:wm)(e)):this.node().textContent}function Mm(){this.innerHTML=""}function jm(e){return function(){this.innerHTML=e}}function Cm(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Nm(e){return arguments.length?this.each(e==null?Mm:(typeof e=="function"?Cm:jm)(e)):this.node().innerHTML}function Tm(){this.nextSibling&&this.parentNode.appendChild(this)}function Im(){return this.each(Tm)}function Em(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Am(){return this.each(Em)}function km(e){var t=typeof e=="function"?e:Jc(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Bm(){return null}function Pm(e,t){var n=typeof e=="function"?e:Jc(e),i=t==null?Bm:typeof t=="function"?t:ya(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Rm(){var e=this.parentNode;e&&e.removeChild(this)}function Dm(){return this.each(Rm)}function Lm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function zm(e){return this.select(e?Fm:Lm)}function Om(e){return arguments.length?this.property("__data__",e):this.node().__data__}function $m(e){return function(t){e.call(this,t,this.__data__)}}function Gm(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function Hm(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,s=t.length,r;n<s;++n)r=t[n],(!e.type||r.type===e.type)&&r.name===e.name?this.removeEventListener(r.type,r.listener,r.options):t[++i]=r;++i?t.length=i:delete this.__on}}}function Wm(e,t,n){return function(){var i=this.__on,s,r=$m(t);if(i){for(var a=0,l=i.length;a<l;++a)if((s=i[a]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=r,s.options=n),s.value=t;return}}this.addEventListener(e.type,r,n),s={type:e.type,name:e.name,value:t,listener:r,options:n},i?i.push(s):this.__on=[s]}}function Um(e,t,n){var i=Gm(e+""),s,r=i.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,d;c<u;++c)for(s=0,d=l[c];s<r;++s)if((a=i[s]).type===d.type&&a.name===d.name)return d.value}return}for(l=t?Wm:Hm,s=0;s<r;++s)this.each(l(i[s],t,n));return this}function cu(e,t,n){var i=ou(e),s=i.CustomEvent;typeof s=="function"?s=new s(t,n):(s=i.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Vm(e,t){return function(){return cu(this,e,t)}}function Ym(e,t){return function(){return cu(this,e,t.apply(this,arguments))}}function Zm(e,t){return this.each((typeof t=="function"?Ym:Vm)(e,t))}function*Xm(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],s=0,r=i.length,a;s<r;++s)(a=i[s])&&(yield a)}var uu=[null];function Ye(e,t){this._groups=e,this._parents=t}function So(){return new Ye([[document.documentElement]],uu)}function Km(){return this}Ye.prototype=So.prototype={constructor:Ye,select:Sh,selectAll:Ch,selectChild:Eh,selectChildren:Ph,filter:Rh,data:$h,enter:Dh,exit:Hh,join:Wh,merge:Uh,selection:Km,order:Vh,sort:Yh,call:Xh,nodes:Kh,node:qh,size:Qh,empty:Jh,each:em,attr:am,style:dm,property:mm,classed:ym,text:_m,html:Nm,raise:Im,lower:Am,append:km,insert:Pm,remove:Dm,clone:zm,datum:Om,on:Um,dispatch:Zm,[Symbol.iterator]:Xm};function Ve(e){return typeof e=="string"?new Ye([[document.querySelector(e)]],[document.documentElement]):new Ye([[e]],uu)}function qm(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ot(e,t){if(e=qm(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Qm={passive:!1},ro={capture:!0,passive:!1};function sr(e){e.stopImmediatePropagation()}function wi(e){e.preventDefault(),e.stopImmediatePropagation()}function du(e){var t=e.document.documentElement,n=Ve(e).on("dragstart.drag",wi,ro);"onselectstart"in t?n.on("selectstart.drag",wi,ro):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function fu(e,t){var n=e.document.documentElement,i=Ve(e).on("dragstart.drag",null);t&&(i.on("click.drag",wi,ro),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Bo=e=>()=>e;function $r(e,{sourceEvent:t,subject:n,target:i,identifier:s,active:r,x:a,y:l,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}$r.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Jm(e){return!e.ctrlKey&&!e.button}function eg(){return this.parentNode}function tg(e,t){return t??{x:e.x,y:e.y}}function ng(){return navigator.maxTouchPoints||"ontouchstart"in this}function pu(){var e=Jm,t=eg,n=tg,i=ng,s={},r=Es("start","drag","end"),a=0,l,c,u,d,f=0;function p(y){y.on("mousedown.drag",h).filter(i).on("touchstart.drag",S).on("touchmove.drag",x,Qm).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(y,v){if(!(d||!e.call(this,y,v))){var j=g(this,t.call(this,y,v),y,v,"mouse");j&&(Ve(y.view).on("mousemove.drag",w,ro).on("mouseup.drag",b,ro),du(y.view),sr(y),u=!1,l=y.clientX,c=y.clientY,j("start",y))}}function w(y){if(wi(y),!u){var v=y.clientX-l,j=y.clientY-c;u=v*v+j*j>f}s.mouse("drag",y)}function b(y){Ve(y.view).on("mousemove.drag mouseup.drag",null),fu(y.view,u),wi(y),s.mouse("end",y)}function S(y,v){if(e.call(this,y,v)){var j=y.changedTouches,T=t.call(this,y,v),k=j.length,D,$;for(D=0;D<k;++D)($=g(this,T,y,v,j[D].identifier,j[D]))&&(sr(y),$("start",y,j[D]))}}function x(y){var v=y.changedTouches,j=v.length,T,k;for(T=0;T<j;++T)(k=s[v[T].identifier])&&(wi(y),k("drag",y,v[T]))}function _(y){var v=y.changedTouches,j=v.length,T,k;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),T=0;T<j;++T)(k=s[v[T].identifier])&&(sr(y),k("end",y,v[T]))}function g(y,v,j,T,k,D){var $=r.copy(),L=ot(D||j,v),I,H,N;if((N=n.call(y,new $r("beforestart",{sourceEvent:j,target:p,identifier:k,active:a,x:L[0],y:L[1],dx:0,dy:0,dispatch:$}),T))!=null)return I=N.x-L[0]||0,H=N.y-L[1]||0,function O(P,z,M){var F=L,U;switch(P){case"start":s[k]=O,U=a++;break;case"end":delete s[k],--a;case"drag":L=ot(M||z,v),U=a;break}$.call(P,y,new $r(P,{sourceEvent:z,subject:N,target:p,identifier:k,active:U,x:L[0]+I,y:L[1]+H,dx:L[0]-F[0],dy:L[1]-F[1],dispatch:$}),T)}}return p.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Bo(!!y),p):e},p.container=function(y){return arguments.length?(t=typeof y=="function"?y:Bo(y),p):t},p.subject=function(y){return arguments.length?(n=typeof y=="function"?y:Bo(y),p):n},p.touchable=function(y){return arguments.length?(i=typeof y=="function"?y:Bo(!!y),p):i},p.on=function(){var y=r.on.apply(r,arguments);return y===r?p:y},p.clickDistance=function(y){return arguments.length?(f=(y=+y)*y,p):Math.sqrt(f)},p}function wa(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function hu(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function _o(){}var ao=.7,ds=1/ao,Si="\\s*([+-]?\\d+)\\s*",lo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Nt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ig=/^#([0-9a-f]{3,8})$/,og=new RegExp(`^rgb\\(${Si},${Si},${Si}\\)$`),sg=new RegExp(`^rgb\\(${Nt},${Nt},${Nt}\\)$`),rg=new RegExp(`^rgba\\(${Si},${Si},${Si},${lo}\\)$`),ag=new RegExp(`^rgba\\(${Nt},${Nt},${Nt},${lo}\\)$`),lg=new RegExp(`^hsl\\(${lo},${Nt},${Nt}\\)$`),cg=new RegExp(`^hsla\\(${lo},${Nt},${Nt},${lo}\\)$`),ll={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};wa(_o,oi,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:cl,formatHex:cl,formatHex8:ug,formatHsl:dg,formatRgb:ul,toString:ul});function cl(){return this.rgb().formatHex()}function ug(){return this.rgb().formatHex8()}function dg(){return mu(this).formatHsl()}function ul(){return this.rgb().formatRgb()}function oi(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=ig.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?dl(t):n===3?new $e(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Po(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Po(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=og.exec(e))?new $e(t[1],t[2],t[3],1):(t=sg.exec(e))?new $e(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=rg.exec(e))?Po(t[1],t[2],t[3],t[4]):(t=ag.exec(e))?Po(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=lg.exec(e))?hl(t[1],t[2]/100,t[3]/100,1):(t=cg.exec(e))?hl(t[1],t[2]/100,t[3]/100,t[4]):ll.hasOwnProperty(e)?dl(ll[e]):e==="transparent"?new $e(NaN,NaN,NaN,0):null}function dl(e){return new $e(e>>16&255,e>>8&255,e&255,1)}function Po(e,t,n,i){return i<=0&&(e=t=n=NaN),new $e(e,t,n,i)}function fg(e){return e instanceof _o||(e=oi(e)),e?(e=e.rgb(),new $e(e.r,e.g,e.b,e.opacity)):new $e}function Gr(e,t,n,i){return arguments.length===1?fg(e):new $e(e,t,n,i??1)}function $e(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}wa($e,Gr,hu(_o,{brighter(e){return e=e==null?ds:Math.pow(ds,e),new $e(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ao:Math.pow(ao,e),new $e(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new $e(ni(this.r),ni(this.g),ni(this.b),fs(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:fl,formatHex:fl,formatHex8:pg,formatRgb:pl,toString:pl}));function fl(){return`#${ti(this.r)}${ti(this.g)}${ti(this.b)}`}function pg(){return`#${ti(this.r)}${ti(this.g)}${ti(this.b)}${ti((isNaN(this.opacity)?1:this.opacity)*255)}`}function pl(){const e=fs(this.opacity);return`${e===1?"rgb(":"rgba("}${ni(this.r)}, ${ni(this.g)}, ${ni(this.b)}${e===1?")":`, ${e})`}`}function fs(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ni(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ti(e){return e=ni(e),(e<16?"0":"")+e.toString(16)}function hl(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new at(e,t,n,i)}function mu(e){if(e instanceof at)return new at(e.h,e.s,e.l,e.opacity);if(e instanceof _o||(e=oi(e)),!e)return new at;if(e instanceof at)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,s=Math.min(t,n,i),r=Math.max(t,n,i),a=NaN,l=r-s,c=(r+s)/2;return l?(t===r?a=(n-i)/l+(n<i)*6:n===r?a=(i-t)/l+2:a=(t-n)/l+4,l/=c<.5?r+s:2-r-s,a*=60):l=c>0&&c<1?0:a,new at(a,l,c,e.opacity)}function hg(e,t,n,i){return arguments.length===1?mu(e):new at(e,t,n,i??1)}function at(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}wa(at,hg,hu(_o,{brighter(e){return e=e==null?ds:Math.pow(ds,e),new at(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ao:Math.pow(ao,e),new at(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,s=2*n-i;return new $e(rr(e>=240?e-240:e+120,s,i),rr(e,s,i),rr(e<120?e+240:e-120,s,i),this.opacity)},clamp(){return new at(ml(this.h),Ro(this.s),Ro(this.l),fs(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=fs(this.opacity);return`${e===1?"hsl(":"hsla("}${ml(this.h)}, ${Ro(this.s)*100}%, ${Ro(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ml(e){return e=(e||0)%360,e<0?e+360:e}function Ro(e){return Math.max(0,Math.min(1,e||0))}function rr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Sa=e=>()=>e;function mg(e,t){return function(n){return e+n*t}}function gg(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function bg(e){return(e=+e)==1?gu:function(t,n){return n-t?gg(t,n,e):Sa(isNaN(t)?n:t)}}function gu(e,t){var n=t-e;return n?mg(e,n):Sa(isNaN(e)?t:e)}const ps=function e(t){var n=bg(t);function i(s,r){var a=n((s=Gr(s)).r,(r=Gr(r)).r),l=n(s.g,r.g),c=n(s.b,r.b),u=gu(s.opacity,r.opacity);return function(d){return s.r=a(d),s.g=l(d),s.b=c(d),s.opacity=u(d),s+""}}return i.gamma=e,i}(1);function xg(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),s;return function(r){for(s=0;s<n;++s)i[s]=e[s]*(1-r)+t[s]*r;return i}}function yg(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vg(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,s=new Array(i),r=new Array(n),a;for(a=0;a<i;++a)s[a]=qi(e[a],t[a]);for(;a<n;++a)r[a]=t[a];return function(l){for(a=0;a<i;++a)r[a]=s[a](l);return r}}function wg(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function Ct(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Sg(e,t){var n={},i={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=qi(e[s],t[s]):i[s]=t[s];return function(r){for(s in n)i[s]=n[s](r);return i}}var Hr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ar=new RegExp(Hr.source,"g");function _g(e){return function(){return e}}function Mg(e){return function(t){return e(t)+""}}function bu(e,t){var n=Hr.lastIndex=ar.lastIndex=0,i,s,r,a=-1,l=[],c=[];for(e=e+"",t=t+"";(i=Hr.exec(e))&&(s=ar.exec(t));)(r=s.index)>n&&(r=t.slice(n,r),l[a]?l[a]+=r:l[++a]=r),(i=i[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,c.push({i:a,x:Ct(i,s)})),n=ar.lastIndex;return n<t.length&&(r=t.slice(n),l[a]?l[a]+=r:l[++a]=r),l.length<2?c[0]?Mg(c[0].x):_g(t):(t=c.length,function(u){for(var d=0,f;d<t;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function qi(e,t){var n=typeof t,i;return t==null||n==="boolean"?Sa(t):(n==="number"?Ct:n==="string"?(i=oi(t))?(t=i,ps):bu:t instanceof oi?ps:t instanceof Date?wg:yg(t)?xg:Array.isArray(t)?vg:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Sg:Ct)(e,t)}var gl=180/Math.PI,Wr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xu(e,t,n,i,s,r){var a,l,c;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(c=e*n+t*i)&&(n-=e*c,i-=t*c),(l=Math.sqrt(n*n+i*i))&&(n/=l,i/=l,c/=l),e*i<t*n&&(e=-e,t=-t,c=-c,a=-a),{translateX:s,translateY:r,rotate:Math.atan2(t,e)*gl,skewX:Math.atan(c)*gl,scaleX:a,scaleY:l}}var Do;function jg(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Wr:xu(t.a,t.b,t.c,t.d,t.e,t.f)}function Cg(e){return e==null||(Do||(Do=document.createElementNS("http://www.w3.org/2000/svg","g")),Do.setAttribute("transform",e),!(e=Do.transform.baseVal.consolidate()))?Wr:(e=e.matrix,xu(e.a,e.b,e.c,e.d,e.e,e.f))}function yu(e,t,n,i){function s(u){return u.length?u.pop()+" ":""}function r(u,d,f,p,h,w){if(u!==f||d!==p){var b=h.push("translate(",null,t,null,n);w.push({i:b-4,x:Ct(u,f)},{i:b-2,x:Ct(d,p)})}else(f||p)&&h.push("translate("+f+t+p+n)}function a(u,d,f,p){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),p.push({i:f.push(s(f)+"rotate(",null,i)-2,x:Ct(u,d)})):d&&f.push(s(f)+"rotate("+d+i)}function l(u,d,f,p){u!==d?p.push({i:f.push(s(f)+"skewX(",null,i)-2,x:Ct(u,d)}):d&&f.push(s(f)+"skewX("+d+i)}function c(u,d,f,p,h,w){if(u!==f||d!==p){var b=h.push(s(h)+"scale(",null,",",null,")");w.push({i:b-4,x:Ct(u,f)},{i:b-2,x:Ct(d,p)})}else(f!==1||p!==1)&&h.push(s(h)+"scale("+f+","+p+")")}return function(u,d){var f=[],p=[];return u=e(u),d=e(d),r(u.translateX,u.translateY,d.translateX,d.translateY,f,p),a(u.rotate,d.rotate,f,p),l(u.skewX,d.skewX,f,p),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,p),u=d=null,function(h){for(var w=-1,b=p.length,S;++w<b;)f[(S=p[w]).i]=S.x(h);return f.join("")}}}var Ng=yu(jg,"px, ","px)","deg)"),Tg=yu(Cg,", ",")",")"),Ig=1e-12;function bl(e){return((e=Math.exp(e))+1/e)/2}function Eg(e){return((e=Math.exp(e))-1/e)/2}function Ag(e){return((e=Math.exp(2*e))-1)/(e+1)}const is=function e(t,n,i){function s(r,a){var l=r[0],c=r[1],u=r[2],d=a[0],f=a[1],p=a[2],h=d-l,w=f-c,b=h*h+w*w,S,x;if(b<Ig)x=Math.log(p/u)/t,S=function(T){return[l+T*h,c+T*w,u*Math.exp(t*T*x)]};else{var _=Math.sqrt(b),g=(p*p-u*u+i*b)/(2*u*n*_),y=(p*p-u*u-i*b)/(2*p*n*_),v=Math.log(Math.sqrt(g*g+1)-g),j=Math.log(Math.sqrt(y*y+1)-y);x=(j-v)/t,S=function(T){var k=T*x,D=bl(v),$=u/(n*_)*(D*Ag(t*k+v)-Eg(v));return[l+$*h,c+$*w,u*D/bl(t*k+v)]}}return S.duration=x*1e3*t/Math.SQRT2,S}return s.rho=function(r){var a=Math.max(.001,+r),l=a*a,c=l*l;return e(a,l,c)},s}(Math.SQRT2,2,4);var Mi=0,Zi=0,$i=0,vu=1e3,hs,Xi,ms=0,si=0,ks=0,co=typeof performance=="object"&&performance.now?performance:Date,wu=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function _a(){return si||(wu(kg),si=co.now()+ks)}function kg(){si=0}function gs(){this._call=this._time=this._next=null}gs.prototype=Su.prototype={constructor:gs,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?_a():+n)+(t==null?0:+t),!this._next&&Xi!==this&&(Xi?Xi._next=this:hs=this,Xi=this),this._call=e,this._time=n,Ur()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ur())}};function Su(e,t,n){var i=new gs;return i.restart(e,t,n),i}function Bg(){_a(),++Mi;for(var e=hs,t;e;)(t=si-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Mi}function xl(){si=(ms=co.now())+ks,Mi=Zi=0;try{Bg()}finally{Mi=0,Rg(),si=0}}function Pg(){var e=co.now(),t=e-ms;t>vu&&(ks-=t,ms=e)}function Rg(){for(var e,t=hs,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:hs=n);Xi=e,Ur(i)}function Ur(e){if(!Mi){Zi&&(Zi=clearTimeout(Zi));var t=e-si;t>24?(e<1/0&&(Zi=setTimeout(xl,e-co.now()-ks)),$i&&($i=clearInterval($i))):($i||(ms=co.now(),$i=setInterval(Pg,vu)),Mi=1,wu(xl))}}function yl(e,t,n){var i=new gs;return t=t==null?0:+t,i.restart(s=>{i.stop(),e(s+t)},t,n),i}var Dg=Es("start","end","cancel","interrupt"),Lg=[],_u=0,vl=1,Vr=2,os=3,wl=4,Yr=5,ss=6;function Bs(e,t,n,i,s,r){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;Fg(e,n,{name:t,index:i,group:s,on:Dg,tween:Lg,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:_u})}function Ma(e,t){var n=pt(e,t);if(n.state>_u)throw new Error("too late; already scheduled");return n}function It(e,t){var n=pt(e,t);if(n.state>os)throw new Error("too late; already running");return n}function pt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Fg(e,t,n){var i=e.__transition,s;i[t]=n,n.timer=Su(r,0,n.time);function r(u){n.state=vl,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,p,h;if(n.state!==vl)return c();for(d in i)if(h=i[d],h.name===n.name){if(h.state===os)return yl(a);h.state===wl?(h.state=ss,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete i[d]):+d<t&&(h.state=ss,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete i[d])}if(yl(function(){n.state===os&&(n.state=wl,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Vr,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Vr){for(n.state=os,s=new Array(p=n.tween.length),d=0,f=-1;d<p;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=Yr,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===Yr&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=ss,n.timer.stop(),delete i[t];for(var u in i)return;delete e.__transition}}function rs(e,t){var n=e.__transition,i,s,r=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((i=n[a]).name!==t){r=!1;continue}s=i.state>Vr&&i.state<Yr,i.state=ss,i.timer.stop(),i.on.call(s?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[a]}r&&delete e.__transition}}function zg(e){return this.each(function(){rs(this,e)})}function Og(e,t){var n,i;return function(){var s=It(this,e),r=s.tween;if(r!==n){i=n=r;for(var a=0,l=i.length;a<l;++a)if(i[a].name===t){i=i.slice(),i.splice(a,1);break}}s.tween=i}}function $g(e,t,n){var i,s;if(typeof n!="function")throw new Error;return function(){var r=It(this,e),a=r.tween;if(a!==i){s=(i=a).slice();for(var l={name:t,value:n},c=0,u=s.length;c<u;++c)if(s[c].name===t){s[c]=l;break}c===u&&s.push(l)}r.tween=s}}function Gg(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=pt(this.node(),n).tween,s=0,r=i.length,a;s<r;++s)if((a=i[s]).name===e)return a.value;return null}return this.each((t==null?Og:$g)(n,e,t))}function ja(e,t,n){var i=e._id;return e.each(function(){var s=It(this,i);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return pt(s,i).value[t]}}function Mu(e,t){var n;return(typeof t=="number"?Ct:t instanceof oi?ps:(n=oi(t))?(t=n,ps):bu)(e,t)}function Hg(e){return function(){this.removeAttribute(e)}}function Wg(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ug(e,t,n){var i,s=n+"",r;return function(){var a=this.getAttribute(e);return a===s?null:a===i?r:r=t(i=a,n)}}function Vg(e,t,n){var i,s=n+"",r;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===i?r:r=t(i=a,n)}}function Yg(e,t,n){var i,s,r;return function(){var a,l=n(this),c;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),c=l+"",a===c?null:a===i&&c===s?r:(s=c,r=t(i=a,l)))}}function Zg(e,t,n){var i,s,r;return function(){var a,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),c=l+"",a===c?null:a===i&&c===s?r:(s=c,r=t(i=a,l)))}}function Xg(e,t){var n=As(e),i=n==="transform"?Tg:Mu;return this.attrTween(e,typeof t=="function"?(n.local?Zg:Yg)(n,i,ja(this,"attr."+e,t)):t==null?(n.local?Wg:Hg)(n):(n.local?Vg:Ug)(n,i,t))}function Kg(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function qg(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Qg(e,t){var n,i;function s(){var r=t.apply(this,arguments);return r!==i&&(n=(i=r)&&qg(e,r)),n}return s._value=t,s}function Jg(e,t){var n,i;function s(){var r=t.apply(this,arguments);return r!==i&&(n=(i=r)&&Kg(e,r)),n}return s._value=t,s}function e0(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=As(e);return this.tween(n,(i.local?Qg:Jg)(i,t))}function t0(e,t){return function(){Ma(this,e).delay=+t.apply(this,arguments)}}function n0(e,t){return t=+t,function(){Ma(this,e).delay=t}}function i0(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?t0:n0)(t,e)):pt(this.node(),t).delay}function o0(e,t){return function(){It(this,e).duration=+t.apply(this,arguments)}}function s0(e,t){return t=+t,function(){It(this,e).duration=t}}function r0(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?o0:s0)(t,e)):pt(this.node(),t).duration}function a0(e,t){if(typeof t!="function")throw new Error;return function(){It(this,e).ease=t}}function l0(e){var t=this._id;return arguments.length?this.each(a0(t,e)):pt(this.node(),t).ease}function c0(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;It(this,e).ease=n}}function u0(e){if(typeof e!="function")throw new Error;return this.each(c0(this._id,e))}function d0(e){typeof e!="function"&&(e=tu(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=i[s]=[],c,u=0;u<a;++u)(c=r[u])&&e.call(c,c.__data__,u,r)&&l.push(c);return new Vt(i,this._parents,this._name,this._id)}function f0(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,s=n.length,r=Math.min(i,s),a=new Array(i),l=0;l<r;++l)for(var c=t[l],u=n[l],d=c.length,f=a[l]=new Array(d),p,h=0;h<d;++h)(p=c[h]||u[h])&&(f[h]=p);for(;l<i;++l)a[l]=t[l];return new Vt(a,this._parents,this._name,this._id)}function p0(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function h0(e,t,n){var i,s,r=p0(t)?Ma:It;return function(){var a=r(this,e),l=a.on;l!==i&&(s=(i=l).copy()).on(t,n),a.on=s}}function m0(e,t){var n=this._id;return arguments.length<2?pt(this.node(),n).on.on(e):this.each(h0(n,e,t))}function g0(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function b0(){return this.on("end.remove",g0(this._id))}function x0(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ya(e));for(var i=this._groups,s=i.length,r=new Array(s),a=0;a<s;++a)for(var l=i[a],c=l.length,u=r[a]=new Array(c),d,f,p=0;p<c;++p)(d=l[p])&&(f=e.call(d,d.__data__,p,l))&&("__data__"in d&&(f.__data__=d.__data__),u[p]=f,Bs(u[p],t,n,p,u,pt(d,n)));return new Vt(r,this._parents,t,n)}function y0(e){var t=this._name,n=this._id;typeof e!="function"&&(e=eu(e));for(var i=this._groups,s=i.length,r=[],a=[],l=0;l<s;++l)for(var c=i[l],u=c.length,d,f=0;f<u;++f)if(d=c[f]){for(var p=e.call(d,d.__data__,f,c),h,w=pt(d,n),b=0,S=p.length;b<S;++b)(h=p[b])&&Bs(h,t,n,b,p,w);r.push(p),a.push(d)}return new Vt(r,a,t,n)}var v0=So.prototype.constructor;function w0(){return new v0(this._groups,this._parents)}function S0(e,t){var n,i,s;return function(){var r=_i(this,e),a=(this.style.removeProperty(e),_i(this,e));return r===a?null:r===n&&a===i?s:s=t(n=r,i=a)}}function ju(e){return function(){this.style.removeProperty(e)}}function _0(e,t,n){var i,s=n+"",r;return function(){var a=_i(this,e);return a===s?null:a===i?r:r=t(i=a,n)}}function M0(e,t,n){var i,s,r;return function(){var a=_i(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),_i(this,e))),a===c?null:a===i&&c===s?r:(s=c,r=t(i=a,l))}}function j0(e,t){var n,i,s,r="style."+t,a="end."+r,l;return function(){var c=It(this,e),u=c.on,d=c.value[r]==null?l||(l=ju(t)):void 0;(u!==n||s!==d)&&(i=(n=u).copy()).on(a,s=d),c.on=i}}function C0(e,t,n){var i=(e+="")=="transform"?Ng:Mu;return t==null?this.styleTween(e,S0(e,i)).on("end.style."+e,ju(e)):typeof t=="function"?this.styleTween(e,M0(e,i,ja(this,"style."+e,t))).each(j0(this._id,e)):this.styleTween(e,_0(e,i,t),n).on("end.style."+e,null)}function N0(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function T0(e,t,n){var i,s;function r(){var a=t.apply(this,arguments);return a!==s&&(i=(s=a)&&N0(e,a,n)),i}return r._value=t,r}function I0(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,T0(e,t,n??""))}function E0(e){return function(){this.textContent=e}}function A0(e){return function(){var t=e(this);this.textContent=t??""}}function k0(e){return this.tween("text",typeof e=="function"?A0(ja(this,"text",e)):E0(e==null?"":e+""))}function B0(e){return function(t){this.textContent=e.call(this,t)}}function P0(e){var t,n;function i(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&B0(s)),t}return i._value=e,i}function R0(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,P0(e))}function D0(){for(var e=this._name,t=this._id,n=Cu(),i=this._groups,s=i.length,r=0;r<s;++r)for(var a=i[r],l=a.length,c,u=0;u<l;++u)if(c=a[u]){var d=pt(c,t);Bs(c,e,n,u,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Vt(i,this._parents,e,n)}function L0(){var e,t,n=this,i=n._id,s=n.size();return new Promise(function(r,a){var l={value:a},c={value:function(){--s===0&&r()}};n.each(function(){var u=It(this,i),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&r()})}var F0=0;function Vt(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function Cu(){return++F0}var $t=So.prototype;Vt.prototype={constructor:Vt,select:x0,selectAll:y0,selectChild:$t.selectChild,selectChildren:$t.selectChildren,filter:d0,merge:f0,selection:w0,transition:D0,call:$t.call,nodes:$t.nodes,node:$t.node,size:$t.size,empty:$t.empty,each:$t.each,on:m0,attr:Xg,attrTween:e0,style:C0,styleTween:I0,text:k0,textTween:R0,remove:b0,tween:Gg,delay:i0,duration:r0,ease:l0,easeVarying:u0,end:L0,[Symbol.iterator]:$t[Symbol.iterator]};function z0(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var O0={time:null,delay:0,duration:250,ease:z0};function $0(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function G0(e){var t,n;e instanceof Vt?(t=e._id,e=e._name):(t=Cu(),(n=O0).time=_a(),e=e==null?null:e+"");for(var i=this._groups,s=i.length,r=0;r<s;++r)for(var a=i[r],l=a.length,c,u=0;u<l;++u)(c=a[u])&&Bs(c,e,t,u,a,n||$0(c,t));return new Vt(i,this._parents,e,t)}So.prototype.interrupt=zg;So.prototype.transition=G0;const Lo=e=>()=>e;function H0(e,{sourceEvent:t,target:n,transform:i,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:s}})}function Ut(e,t,n){this.k=e,this.x=t,this.y=n}Ut.prototype={constructor:Ut,scale:function(e){return e===1?this:new Ut(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ut(this.k,this.x+this.k*e,this.y+this.k*t)},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 Ps=new Ut(1,0,0);Nu.prototype=Ut.prototype;function Nu(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ps;return e.__zoom}function lr(e){e.stopImmediatePropagation()}function Gi(e){e.preventDefault(),e.stopImmediatePropagation()}function W0(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function U0(){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 Sl(){return this.__zoom||Ps}function V0(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Y0(){return navigator.maxTouchPoints||"ontouchstart"in this}function Z0(e,t,n){var i=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],r=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s),a>r?(r+a)/2:Math.min(0,r)||Math.max(0,a))}function Tu(){var e=W0,t=U0,n=Z0,i=V0,s=Y0,r=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=is,u=Es("start","zoom","end"),d,f,p,h=500,w=150,b=0,S=10;function x(N){N.property("__zoom",Sl).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",$).filter(s).on("touchstart.zoom",L).on("touchmove.zoom",I).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(N,O,P,z){var M=N.selection?N.selection():N;M.property("__zoom",Sl),N!==M?v(N,O,P,z):M.interrupt().each(function(){j(this,arguments).event(z).start().zoom(null,typeof O=="function"?O.apply(this,arguments):O).end()})},x.scaleBy=function(N,O,P,z){x.scaleTo(N,function(){var M=this.__zoom.k,F=typeof O=="function"?O.apply(this,arguments):O;return M*F},P,z)},x.scaleTo=function(N,O,P,z){x.transform(N,function(){var M=t.apply(this,arguments),F=this.__zoom,U=P==null?y(M):typeof P=="function"?P.apply(this,arguments):P,V=F.invert(U),Z=typeof O=="function"?O.apply(this,arguments):O;return n(g(_(F,Z),U,V),M,a)},P,z)},x.translateBy=function(N,O,P,z){x.transform(N,function(){return n(this.__zoom.translate(typeof O=="function"?O.apply(this,arguments):O,typeof P=="function"?P.apply(this,arguments):P),t.apply(this,arguments),a)},null,z)},x.translateTo=function(N,O,P,z,M){x.transform(N,function(){var F=t.apply(this,arguments),U=this.__zoom,V=z==null?y(F):typeof z=="function"?z.apply(this,arguments):z;return n(Ps.translate(V[0],V[1]).scale(U.k).translate(typeof O=="function"?-O.apply(this,arguments):-O,typeof P=="function"?-P.apply(this,arguments):-P),F,a)},z,M)};function _(N,O){return O=Math.max(r[0],Math.min(r[1],O)),O===N.k?N:new Ut(O,N.x,N.y)}function g(N,O,P){var z=O[0]-P[0]*N.k,M=O[1]-P[1]*N.k;return z===N.x&&M===N.y?N:new Ut(N.k,z,M)}function y(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function v(N,O,P,z){N.on("start.zoom",function(){j(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(z).end()}).tween("zoom",function(){var M=this,F=arguments,U=j(M,F).event(z),V=t.apply(M,F),Z=P==null?y(V):typeof P=="function"?P.apply(M,F):P,Y=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),Q=M.__zoom,K=typeof O=="function"?O.apply(M,F):O,E=c(Q.invert(Z).concat(Y/Q.k),K.invert(Z).concat(Y/K.k));return function(C){if(C===1)C=K;else{var W=E(C),X=Y/W[2];C=new Ut(X,Z[0]-W[0]*X,Z[1]-W[1]*X)}U.zoom(null,C)}})}function j(N,O,P){return!P&&N.__zooming||new T(N,O)}function T(N,O){this.that=N,this.args=O,this.active=0,this.sourceEvent=null,this.extent=t.apply(N,O),this.taps=0}T.prototype={event:function(N){return N&&(this.sourceEvent=N),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(N,O){return this.mouse&&N!=="mouse"&&(this.mouse[1]=O.invert(this.mouse[0])),this.touch0&&N!=="touch"&&(this.touch0[1]=O.invert(this.touch0[0])),this.touch1&&N!=="touch"&&(this.touch1[1]=O.invert(this.touch1[0])),this.that.__zoom=O,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(N){var O=Ve(this.that).datum();u.call(N,this.that,new H0(N,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:u}),O)}};function k(N,...O){if(!e.apply(this,arguments))return;var P=j(this,O).event(N),z=this.__zoom,M=Math.max(r[0],Math.min(r[1],z.k*Math.pow(2,i.apply(this,arguments)))),F=ot(N);if(P.wheel)(P.mouse[0][0]!==F[0]||P.mouse[0][1]!==F[1])&&(P.mouse[1]=z.invert(P.mouse[0]=F)),clearTimeout(P.wheel);else{if(z.k===M)return;P.mouse=[F,z.invert(F)],rs(this),P.start()}Gi(N),P.wheel=setTimeout(U,w),P.zoom("mouse",n(g(_(z,M),P.mouse[0],P.mouse[1]),P.extent,a));function U(){P.wheel=null,P.end()}}function D(N,...O){if(p||!e.apply(this,arguments))return;var P=N.currentTarget,z=j(this,O,!0).event(N),M=Ve(N.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",Y,!0),F=ot(N,P),U=N.clientX,V=N.clientY;du(N.view),lr(N),z.mouse=[F,this.__zoom.invert(F)],rs(this),z.start();function Z(Q){if(Gi(Q),!z.moved){var K=Q.clientX-U,E=Q.clientY-V;z.moved=K*K+E*E>b}z.event(Q).zoom("mouse",n(g(z.that.__zoom,z.mouse[0]=ot(Q,P),z.mouse[1]),z.extent,a))}function Y(Q){M.on("mousemove.zoom mouseup.zoom",null),fu(Q.view,z.moved),Gi(Q),z.event(Q).end()}}function $(N,...O){if(e.apply(this,arguments)){var P=this.__zoom,z=ot(N.changedTouches?N.changedTouches[0]:N,this),M=P.invert(z),F=P.k*(N.shiftKey?.5:2),U=n(g(_(P,F),z,M),t.apply(this,O),a);Gi(N),l>0?Ve(this).transition().duration(l).call(v,U,z,N):Ve(this).call(x.transform,U,z,N)}}function L(N,...O){if(e.apply(this,arguments)){var P=N.touches,z=P.length,M=j(this,O,N.changedTouches.length===z).event(N),F,U,V,Z;for(lr(N),U=0;U<z;++U)V=P[U],Z=ot(V,this),Z=[Z,this.__zoom.invert(Z),V.identifier],M.touch0?!M.touch1&&M.touch0[2]!==Z[2]&&(M.touch1=Z,M.taps=0):(M.touch0=Z,F=!0,M.taps=1+!!d);d&&(d=clearTimeout(d)),F&&(M.taps<2&&(f=Z[0],d=setTimeout(function(){d=null},h)),rs(this),M.start())}}function I(N,...O){if(this.__zooming){var P=j(this,O).event(N),z=N.changedTouches,M=z.length,F,U,V,Z;for(Gi(N),F=0;F<M;++F)U=z[F],V=ot(U,this),P.touch0&&P.touch0[2]===U.identifier?P.touch0[0]=V:P.touch1&&P.touch1[2]===U.identifier&&(P.touch1[0]=V);if(U=P.that.__zoom,P.touch1){var Y=P.touch0[0],Q=P.touch0[1],K=P.touch1[0],E=P.touch1[1],C=(C=K[0]-Y[0])*C+(C=K[1]-Y[1])*C,W=(W=E[0]-Q[0])*W+(W=E[1]-Q[1])*W;U=_(U,Math.sqrt(C/W)),V=[(Y[0]+K[0])/2,(Y[1]+K[1])/2],Z=[(Q[0]+E[0])/2,(Q[1]+E[1])/2]}else if(P.touch0)V=P.touch0[0],Z=P.touch0[1];else return;P.zoom("touch",n(g(U,V,Z),P.extent,a))}}function H(N,...O){if(this.__zooming){var P=j(this,O).event(N),z=N.changedTouches,M=z.length,F,U;for(lr(N),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),F=0;F<M;++F)U=z[F],P.touch0&&P.touch0[2]===U.identifier?delete P.touch0:P.touch1&&P.touch1[2]===U.identifier&&delete P.touch1;if(P.touch1&&!P.touch0&&(P.touch0=P.touch1,delete P.touch1),P.touch0)P.touch0[1]=this.__zoom.invert(P.touch0[0]);else if(P.end(),P.taps===2&&(U=ot(U,this),Math.hypot(f[0]-U[0],f[1]-U[1])<S)){var V=Ve(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return x.wheelDelta=function(N){return arguments.length?(i=typeof N=="function"?N:Lo(+N),x):i},x.filter=function(N){return arguments.length?(e=typeof N=="function"?N:Lo(!!N),x):e},x.touchable=function(N){return arguments.length?(s=typeof N=="function"?N:Lo(!!N),x):s},x.extent=function(N){return arguments.length?(t=typeof N=="function"?N:Lo([[+N[0][0],+N[0][1]],[+N[1][0],+N[1][1]]]),x):t},x.scaleExtent=function(N){return arguments.length?(r[0]=+N[0],r[1]=+N[1],x):[r[0],r[1]]},x.translateExtent=function(N){return arguments.length?(a[0][0]=+N[0][0],a[1][0]=+N[1][0],a[0][1]=+N[0][1],a[1][1]=+N[1][1],x):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},x.constrain=function(N){return arguments.length?(n=N,x):n},x.duration=function(N){return arguments.length?(l=+N,x):l},x.interpolate=function(N){return arguments.length?(c=N,x):c},x.on=function(){var N=u.on.apply(u,arguments);return N===u?x:N},x.clickDistance=function(N){return arguments.length?(b=(N=+N)*N,x):Math.sqrt(b)},x.tapDistance=function(N){return arguments.length?(S=+N,x):S},x}const Tt={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.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 React Flow 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:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,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."},uo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Iu=["Enter"," ","Escape"],Eu={"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:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"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 ji;(function(e){e.Strict="strict",e.Loose="loose"})(ji||(ji={}));var ii;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ii||(ii={}));var fo;(function(e){e.Partial="partial",e.Full="full"})(fo||(fo={}));const Au={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var vn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(vn||(vn={}));var po;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(po||(po={}));var re;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(re||(re={}));const _l={[re.Left]:re.Right,[re.Right]:re.Left,[re.Top]:re.Bottom,[re.Bottom]:re.Top};function ku(e){return e===null?null:e?"valid":"invalid"}const Bu=e=>"id"in e&&"source"in e&&"target"in e,X0=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Ca=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Mo=(e,t=[0,0])=>{const{width:n,height:i}=Yt(e),s=e.origin??t,r=n*s[0],a=i*s[1];return{x:e.position.x-r,y:e.position.y-a}},K0=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,s)=>{const r=typeof s=="string";let a=!t.nodeLookup&&!r?s:void 0;t.nodeLookup&&(a=r?t.nodeLookup.get(s):Ca(s)?s:t.nodeLookup.get(s.id));const l=a?bs(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Rs(i,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ds(n)},jo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=Rs(n,bs(s)),i=!0)}),i?Ds(n):{x:0,y:0,width:0,height:0}},Na=(e,t,[n,i,s]=[0,0,1],r=!1,a=!1)=>{const l={...No(t,[n,i,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:p=!1}=u;if(a&&!f||p)continue;const h=d.width??u.width??u.initialWidth??null,w=d.height??u.height??u.initialHeight??null,b=ho(l,Ni(u)),S=(h??0)*(w??0),x=r&&b>0;(!u.internals.handleBounds||x||b>=S||u.dragging)&&c.push(u)}return c},q0=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function Q0(e,t){const n=new Map,i=t?.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&(t?.includeHiddenNodes||!s.hidden)&&(!i||i.has(s.id))&&n.set(s.id,s)}),n}async function J0({nodes:e,width:t,height:n,panZoom:i,minZoom:s,maxZoom:r},a){if(e.size===0)return Promise.resolve(!0);const l=Q0(e,a),c=jo(l),u=Ta(c,t,n,a?.minZoom??s,a?.maxZoom??r,a?.padding??.1);return await i.setViewport(u,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),Promise.resolve(!0)}function Pu({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:s,onError:r}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},d=a.origin??i;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)r?.("005",Tt.error005());else{const h=l.measured.width,w=l.measured.height;h&&w&&(f=[[c,u],[c+h,u+w]])}else l&&Ti(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const p=Ti(f)?ri(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&r?.("015",Tt.error015()),{position:{x:p.x-c+(a.measured.width??0)*d[0],y:p.y-u+(a.measured.height??0)*d[1]},positionAbsolute:p}}async function eb({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:s}){const r=new Set(e.map(p=>p.id)),a=[];for(const p of n){if(p.deletable===!1)continue;const h=r.has(p.id),w=!h&&p.parentId&&a.find(b=>b.id===p.parentId);(h||w)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=i.filter(p=>p.deletable!==!1),d=q0(a,c);for(const p of c)l.has(p.id)&&!d.find(w=>w.id===p.id)&&d.push(p);if(!s)return{edges:d,nodes:a};const f=await s({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const Ci=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ri=(e={x:0,y:0},t,n)=>({x:Ci(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ci(e.y,t[0][1],t[1][1]-(n?.height??0))});function Ru(e,t,n){const{width:i,height:s}=Yt(n),{x:r,y:a}=n.internals.positionAbsolute;return ri(e,[[r,a],[r+i,a+s]],t)}const Ml=(e,t,n)=>e<t?Ci(Math.abs(e-t),1,t)/t:e>n?-Ci(Math.abs(e-n),1,t)/t:0,Du=(e,t,n=15,i=40)=>{const s=Ml(e.x,i,t.width-i)*n,r=Ml(e.y,i,t.height-i)*n;return[s,r]},Rs=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Zr=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),Ds=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),Ni=(e,t=[0,0])=>{const{x:n,y:i}=Ca(e)?e.internals.positionAbsolute:Mo(e,t);return{x:n,y:i,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},bs=(e,t=[0,0])=>{const{x:n,y:i}=Ca(e)?e.internals.positionAbsolute:Mo(e,t);return{x:n,y:i,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:i+(e.measured?.height??e.height??e.initialHeight??0)}},Lu=(e,t)=>Ds(Rs(Zr(e),Zr(t))),ho=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*i)},jl=e=>ct(e.width)&&ct(e.height)&&ct(e.x)&&ct(e.y),ct=e=>!isNaN(e)&&isFinite(e),tb=(e,t)=>{},Co=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),No=({x:e,y:t},[n,i,s],r=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-i)/s};return r?Co(l,a):l},xs=({x:e,y:t},[n,i,s])=>({x:e*s+n,y:t*s+i});function pi(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function nb(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=pi(e,n),s=pi(e,t);return{top:i,right:s,bottom:i,left:s,x:s*2,y:i*2}}if(typeof e=="object"){const i=pi(e.top??e.y??0,n),s=pi(e.bottom??e.y??0,n),r=pi(e.left??e.x??0,t),a=pi(e.right??e.x??0,t);return{top:i,right:a,bottom:s,left:r,x:r+a,y:i+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ib(e,t,n,i,s,r){const{x:a,y:l}=xs(e,[t,n,i]),{x:c,y:u}=xs({x:e.x+e.width,y:e.y+e.height},[t,n,i]),d=s-c,f=r-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(d),bottom:Math.floor(f)}}const Ta=(e,t,n,i,s,r)=>{const a=nb(r,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),d=Ci(u,i,s),f=e.x+e.width/2,p=e.y+e.height/2,h=t/2-f*d,w=n/2-p*d,b=ib(e,h,w,d,t,n),S={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:h-S.left+S.right,y:w-S.top+S.bottom,zoom:d}},mo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ti(e){return e!=null&&e!=="parent"}function Yt(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Fu(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function zu(e,t={width:0,height:0},n,i,s){const r={...e},a=i.get(n);if(a){const l=a.origin||s;r.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],r.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return r}function Cl(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function ob(){let e,t;return{promise:new Promise((i,s)=>{e=i,t=s}),resolve:e,reject:t}}function sb(e){return{...Eu,...e||{}}}function Qi(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:s}){const{x:r,y:a}=ut(e),l=No({x:r-(s?.left??0),y:a-(s?.top??0)},i),{x:c,y:u}=n?Co(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const Ia=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ou=e=>e?.getRootNode?.()||window?.document,rb=["INPUT","SELECT","TEXTAREA"];function $u(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:rb.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Gu=e=>"clientX"in e,ut=(e,t)=>{const n=Gu(e),i=n?e.clientX:e.touches?.[0].clientX,s=n?e.clientY:e.touches?.[0].clientY;return{x:i-(t?.left??0),y:s-(t?.top??0)}},Nl=(e,t,n,i,s)=>{const r=t.querySelectorAll(`.${e}`);return!r||!r.length?null:Array.from(r).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:s,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/i,y:(l.top-n.top)/i,...Ia(a)}})};function Hu({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:s,sourceControlY:r,targetControlX:a,targetControlY:l}){const c=e*.125+s*.375+a*.375+n*.125,u=t*.125+r*.375+l*.375+i*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function Fo(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Tl({pos:e,x1:t,y1:n,x2:i,y2:s,c:r}){switch(e){case re.Left:return[t-Fo(t-i,r),n];case re.Right:return[t+Fo(i-t,r),n];case re.Top:return[t,n-Fo(n-s,r)];case re.Bottom:return[t,n+Fo(s-n,r)]}}function Wu({sourceX:e,sourceY:t,sourcePosition:n=re.Bottom,targetX:i,targetY:s,targetPosition:r=re.Top,curvature:a=.25}){const[l,c]=Tl({pos:n,x1:e,y1:t,x2:i,y2:s,c:a}),[u,d]=Tl({pos:r,x1:i,y1:s,x2:e,y2:t,c:a}),[f,p,h,w]=Hu({sourceX:e,sourceY:t,targetX:i,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${l},${c} ${u},${d} ${i},${s}`,f,p,h,w]}function Uu({sourceX:e,sourceY:t,targetX:n,targetY:i}){const s=Math.abs(n-e)/2,r=n<e?n+s:n-s,a=Math.abs(i-t)/2,l=i<t?i+a:i-a;return[r,l,s,a]}function ab({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:s=!1,zIndexMode:r="basic"}){if(r==="manual")return i;const a=s&&n?i+1e3:i,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return a+l}function lb({sourceNode:e,targetNode:t,width:n,height:i,transform:s}){const r=Rs(bs(e),bs(t));r.x===r.x2&&(r.x2+=1),r.y===r.y2&&(r.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:i/s[2]};return ho(a,Ds(r))>0}const cb=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,ub=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),db=(e,t,n={})=>{if(!e.source||!e.target)return t;const i=n.getEdgeId||cb;let s;return Bu(e)?s={...e}:s={...e,id:i(e)},ub(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function Vu({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[s,r,a,l]=Uu({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,s,r,a,l]}const Il={[re.Left]:{x:-1,y:0},[re.Right]:{x:1,y:0},[re.Top]:{x:0,y:-1},[re.Bottom]:{x:0,y:1}},fb=({source:e,sourcePosition:t=re.Bottom,target:n})=>t===re.Left||t===re.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},El=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function pb({source:e,sourcePosition:t=re.Bottom,target:n,targetPosition:i=re.Top,center:s,offset:r,stepPosition:a}){const l=Il[t],c=Il[i],u={x:e.x+l.x*r,y:e.y+l.y*r},d={x:n.x+c.x*r,y:n.y+c.y*r},f=fb({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",h=f[p];let w=[],b,S;const x={x:0,y:0},_={x:0,y:0},[,,g,y]=Uu({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(b=s.x??u.x+(d.x-u.x)*a,S=s.y??(u.y+d.y)/2):(b=s.x??(u.x+d.x)/2,S=s.y??u.y+(d.y-u.y)*a);const k=[{x:b,y:u.y},{x:b,y:d.y}],D=[{x:u.x,y:S},{x:d.x,y:S}];l[p]===h?w=p==="x"?k:D:w=p==="x"?D:k}else{const k=[{x:u.x,y:d.y}],D=[{x:d.x,y:u.y}];if(p==="x"?w=l.x===h?D:k:w=l.y===h?k:D,t===i){const N=Math.abs(e[p]-n[p]);if(N<=r){const O=Math.min(r-1,r-N);l[p]===h?x[p]=(u[p]>e[p]?-1:1)*O:_[p]=(d[p]>n[p]?-1:1)*O}}if(t!==i){const N=p==="x"?"y":"x",O=l[p]===c[N],P=u[N]>d[N],z=u[N]<d[N];(l[p]===1&&(!O&&P||O&&z)||l[p]!==1&&(!O&&z||O&&P))&&(w=p==="x"?k:D)}const $={x:u.x+x.x,y:u.y+x.y},L={x:d.x+_.x,y:d.y+_.y},I=Math.max(Math.abs($.x-w[0].x),Math.abs(L.x-w[0].x)),H=Math.max(Math.abs($.y-w[0].y),Math.abs(L.y-w[0].y));I>=H?(b=($.x+L.x)/2,S=w[0].y):(b=w[0].x,S=($.y+L.y)/2)}const v={x:u.x+x.x,y:u.y+x.y},j={x:d.x+_.x,y:d.y+_.y};return[[e,...v.x!==w[0].x||v.y!==w[0].y?[v]:[],...w,...j.x!==w[w.length-1].x||j.y!==w[w.length-1].y?[j]:[],n],b,S,g,y]}function hb(e,t,n,i){const s=Math.min(El(e,t)/2,El(t,n)/2,i),{x:r,y:a}=t;if(e.x===r&&r===n.x||e.y===a&&a===n.y)return`L${r} ${a}`;if(e.y===a){const u=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${r+s*u},${a}Q ${r},${a} ${r},${a+s*d}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${r},${a+s*c}Q ${r},${a} ${r+s*l},${a}`}function Xr({sourceX:e,sourceY:t,sourcePosition:n=re.Bottom,targetX:i,targetY:s,targetPosition:r=re.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:d=.5}){const[f,p,h,w,b]=pb({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:s},targetPosition:r,center:{x:l,y:c},offset:u,stepPosition:d});let S=`M${f[0].x} ${f[0].y}`;for(let x=1;x<f.length-1;x++)S+=hb(f[x-1],f[x],f[x+1],a);return S+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[S,p,h,w,b]}function Al(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function mb(e){const{sourceNode:t,targetNode:n}=e;if(!Al(t)||!Al(n))return null;const i=t.internals.handleBounds||kl(t.handles),s=n.internals.handleBounds||kl(n.handles),r=Bl(i?.source??[],e.sourceHandle),a=Bl(e.connectionMode===ji.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!r||!a)return e.onError?.("008",Tt.error008(r?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=r?.position||re.Bottom,c=a?.position||re.Top,u=ai(t,r,l),d=ai(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function kl(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function ai(e,t,n=re.Left,i=!1){const s=(t?.x??0)+e.internals.positionAbsolute.x,r=(t?.y??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??Yt(e);if(i)return{x:s+a/2,y:r+l/2};switch(t?.position??n){case re.Top:return{x:s+a/2,y:r};case re.Right:return{x:s+a,y:r+l/2};case re.Bottom:return{x:s+a/2,y:r+l};case re.Left:return{x:s,y:r+l/2}}}function Bl(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Kr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function gb(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:s}){const r=new Set;return e.reduce((a,l)=>([l.markerStart||i,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const u=Kr(c,t);r.has(u)||(a.push({id:u,color:c.color||n,...c}),r.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const Yu=1e3,bb=10,Ea={nodeOrigin:[0,0],nodeExtent:uo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},xb={...Ea,checkEquality:!0};function Aa(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function yb(e,t,n){const i=Aa(Ea,n);for(const s of e.values())if(s.parentId)Ba(s,e,t,i);else{const r=Mo(s,i.nodeOrigin),a=Ti(s.extent)?s.extent:i.nodeExtent,l=ri(r,a,Yt(s));s.internals.positionAbsolute=l}}function vb(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],i=[];for(const s of e.handles){const r={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(r):s.type==="target"&&i.push(r)}return{source:n,target:i}}function ka(e){return e==="manual"}function qr(e,t,n,i={}){const s=Aa(xb,i),r={i:0},a=new Map(t),l=s?.elevateNodesOnSelect&&!ka(s.zIndexMode)?Yu:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const d of e){let f=a.get(d.id);if(s.checkEquality&&d===f?.internals.userNode)t.set(d.id,f);else{const p=Mo(d,s.nodeOrigin),h=Ti(d.extent)?d.extent:s.nodeExtent,w=ri(p,h,Yt(d));f={...s.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:w,handleBounds:vb(d,f),z:Zu(d,l,s.zIndexMode),userNode:d}},t.set(d.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),d.parentId&&Ba(f,t,n,i,r),u||=d.selected??!1}return{nodesInitialized:c,hasSelectedNodes:u}}function wb(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Ba(e,t,n,i,s){const{elevateNodesOnSelect:r,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Aa(Ea,i),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}wb(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*bb),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=r&&!ka(c)?Yu:0,{x:p,y:h,z:w}=Sb(e,d,a,l,f,c),{positionAbsolute:b}=e.internals,S=p!==b.x||h!==b.y;(S||w!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x:p,y:h}:b,z:w}})}function Zu(e,t,n){const i=ct(e.zIndex)?e.zIndex:0;return ka(n)?i:i+(e.selected?t:0)}function Sb(e,t,n,i,s,r){const{x:a,y:l}=t.internals.positionAbsolute,c=Yt(e),u=Mo(e,n),d=Ti(e.extent)?ri(u,e.extent,c):u;let f=ri({x:a+d.x,y:l+d.y},i,c);e.extent==="parent"&&(f=Ru(f,c,t));const p=Zu(e,s,r),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function Pa(e,t,n,i=[0,0]){const s=[],r=new Map;for(const a of e){const l=t.get(a.parentId);if(!l)continue;const c=r.get(a.parentId)?.expandedRect??Ni(l),u=Lu(c,a.rect);r.set(a.parentId,{expandedRect:u,parent:l})}return r.size>0&&r.forEach(({expandedRect:a,parent:l},c)=>{const u=l.internals.positionAbsolute,d=Yt(l),f=l.origin??i,p=a.x<u.x?Math.round(Math.abs(u.x-a.x)):0,h=a.y<u.y?Math.round(Math.abs(u.y-a.y)):0,w=Math.max(d.width,Math.round(a.width)),b=Math.max(d.height,Math.round(a.height)),S=(w-d.width)*f[0],x=(b-d.height)*f[1];(p>0||h>0||S||x)&&(s.push({id:c,type:"position",position:{x:l.position.x-p+S,y:l.position.y-h+x}}),n.get(c)?.forEach(_=>{e.some(g=>g.id===_.id)||s.push({id:_.id,type:"position",position:{x:_.position.x+p,y:_.position.y+h}})})),(d.width<a.width||d.height<a.height||p||h)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:w+(p?f[0]*p-S:0),height:b+(h?f[1]*h-x:0)}})}),s}function _b(e,t,n,i,s,r,a){const l=i?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const u=[],d=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(d.transform),p=[];for(const h of e.values()){const w=t.get(h.id);if(!w)continue;if(w.hidden){t.set(w.id,{...w,internals:{...w.internals,handleBounds:void 0}}),c=!0;continue}const b=Ia(h.nodeElement),S=w.measured.width!==b.width||w.measured.height!==b.height;if(!!(b.width&&b.height&&(S||!w.internals.handleBounds||h.force))){const _=h.nodeElement.getBoundingClientRect(),g=Ti(w.extent)?w.extent:r;let{positionAbsolute:y}=w.internals;w.parentId&&w.extent==="parent"?y=Ru(y,b,t.get(w.parentId)):g&&(y=ri(y,g,b));const v={...w,measured:b,internals:{...w.internals,positionAbsolute:y,handleBounds:{source:Nl("source",h.nodeElement,_,f,w.id),target:Nl("target",h.nodeElement,_,f,w.id)}}};t.set(w.id,v),w.parentId&&Ba(v,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,S&&(u.push({id:w.id,type:"dimensions",dimensions:b}),w.expandParent&&w.parentId&&p.push({id:w.id,parentId:w.parentId,rect:Ni(v,s)}))}}if(p.length>0){const h=Pa(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function Mb({delta:e,panZoom:t,transform:n,translateExtent:i,width:s,height:r}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,r]],i),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function Pl(e,t,n,i,s,r){let a=s;const l=i.get(a)||new Map;i.set(a,l.set(n,t)),a=`${s}-${e}`;const c=i.get(a)||new Map;if(i.set(a,c.set(n,t)),r){a=`${s}-${e}-${r}`;const u=i.get(a)||new Map;i.set(a,u.set(n,t))}}function Xu(e,t,n){e.clear(),t.clear();for(const i of n){const{source:s,target:r,sourceHandle:a=null,targetHandle:l=null}=i,c={edgeId:i.id,source:s,target:r,sourceHandle:a,targetHandle:l},u=`${s}-${a}--${r}-${l}`,d=`${r}-${l}--${s}-${a}`;Pl("source",c,d,e,s,a),Pl("target",c,u,e,r,l),t.set(i.id,i)}}function Ku(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ku(n,t):!1}function Rl(e,t,n){let i=e;do{if(i?.matches?.(t))return!0;if(i===n)return!1;i=i?.parentElement}while(i);return!1}function jb(e,t,n,i){const s=new Map;for(const[r,a]of e)if((a.selected||a.id===i)&&(!a.parentId||!Ku(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(r);l&&s.set(r,{id:r,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function cr({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){const s=[];for(const[a,l]of t){const c=n.get(a)?.internals.userNode;c&&s.push({...c,position:l.position,dragging:i})}if(!e)return[s[0],s];const r=n.get(e)?.internals.userNode;return[r?{...r,position:t.get(e)?.position||r.position,dragging:i}:s[0],s]}function Cb({dragItems:e,snapGrid:t,x:n,y:i}){const s=e.values().next().value;if(!s)return null;const r={x:n-s.distance.x,y:i-s.distance.y},a=Co(r,t);return{x:a.x-r.x,y:a.y-r.y}}function Nb({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:s}){let r={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},d=null,f=!1,p=null,h=!1,w=!1,b=null;function S({noDragClassName:_,handleSelector:g,domNode:y,isSelectable:v,nodeId:j,nodeClickDistance:T=0}){p=Ve(y);function k({x:I,y:H}){const{nodeLookup:N,nodeExtent:O,snapGrid:P,snapToGrid:z,nodeOrigin:M,onNodeDrag:F,onSelectionDrag:U,onError:V,updateNodePositions:Z}=t();r={x:I,y:H};let Y=!1;const Q=l.size>1,K=Q&&O?Zr(jo(l)):null,E=Q&&z?Cb({dragItems:l,snapGrid:P,x:I,y:H}):null;for(const[C,W]of l){if(!N.has(C))continue;let X={x:I-W.distance.x,y:H-W.distance.y};z&&(X=E?{x:Math.round(X.x+E.x),y:Math.round(X.y+E.y)}:Co(X,P));let q=null;if(Q&&O&&!W.extent&&K){const{positionAbsolute:ie}=W.internals,oe=ie.x-K.x+O[0][0],J=ie.x+W.measured.width-K.x2+O[1][0],le=ie.y-K.y+O[0][1],ue=ie.y+W.measured.height-K.y2+O[1][1];q=[[oe,le],[J,ue]]}const{position:ee,positionAbsolute:ne}=Pu({nodeId:C,nextPosition:X,nodeLookup:N,nodeExtent:q||O,nodeOrigin:M,onError:V});Y=Y||W.position.x!==ee.x||W.position.y!==ee.y,W.position=ee,W.internals.positionAbsolute=ne}if(w=w||Y,!!Y&&(Z(l,!0),b&&(i||F||!j&&U))){const[C,W]=cr({nodeId:j,dragItems:l,nodeLookup:N});i?.(b,l,C,W),F?.(b,C,W),j||U?.(b,W)}}async function D(){if(!d)return;const{transform:I,panBy:H,autoPanSpeed:N,autoPanOnNodeDrag:O}=t();if(!O){c=!1,cancelAnimationFrame(a);return}const[P,z]=Du(u,d,N);(P!==0||z!==0)&&(r.x=(r.x??0)-P/I[2],r.y=(r.y??0)-z/I[2],await H({x:P,y:z})&&k(r)),a=requestAnimationFrame(D)}function $(I){const{nodeLookup:H,multiSelectionActive:N,nodesDraggable:O,transform:P,snapGrid:z,snapToGrid:M,selectNodesOnDrag:F,onNodeDragStart:U,onSelectionDragStart:V,unselectNodesAndEdges:Z}=t();f=!0,(!F||!v)&&!N&&j&&(H.get(j)?.selected||Z()),v&&F&&j&&e?.(j);const Y=Qi(I.sourceEvent,{transform:P,snapGrid:z,snapToGrid:M,containerBounds:d});if(r=Y,l=jb(H,O,Y,j),l.size>0&&(n||U||!j&&V)){const[Q,K]=cr({nodeId:j,dragItems:l,nodeLookup:H});n?.(I.sourceEvent,l,Q,K),U?.(I.sourceEvent,Q,K),j||V?.(I.sourceEvent,K)}}const L=pu().clickDistance(T).on("start",I=>{const{domNode:H,nodeDragThreshold:N,transform:O,snapGrid:P,snapToGrid:z}=t();d=H?.getBoundingClientRect()||null,h=!1,w=!1,b=I.sourceEvent,N===0&&$(I),r=Qi(I.sourceEvent,{transform:O,snapGrid:P,snapToGrid:z,containerBounds:d}),u=ut(I.sourceEvent,d)}).on("drag",I=>{const{autoPanOnNodeDrag:H,transform:N,snapGrid:O,snapToGrid:P,nodeDragThreshold:z,nodeLookup:M}=t(),F=Qi(I.sourceEvent,{transform:N,snapGrid:O,snapToGrid:P,containerBounds:d});if(b=I.sourceEvent,(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1||j&&!M.has(j))&&(h=!0),!h){if(!c&&H&&f&&(c=!0,D()),!f){const U=ut(I.sourceEvent,d),V=U.x-u.x,Z=U.y-u.y;Math.sqrt(V*V+Z*Z)>z&&$(I)}(r.x!==F.xSnapped||r.y!==F.ySnapped)&&l&&f&&(u=ut(I.sourceEvent,d),k(F))}}).on("end",I=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:H,updateNodePositions:N,onNodeDragStop:O,onSelectionDragStop:P}=t();if(w&&(N(l,!1),w=!1),s||O||!j&&P){const[z,M]=cr({nodeId:j,dragItems:l,nodeLookup:H,dragging:!1});s?.(I.sourceEvent,l,z,M),O?.(I.sourceEvent,z,M),j||P?.(I.sourceEvent,M)}}}).filter(I=>{const H=I.target;return!I.button&&(!_||!Rl(H,`.${_}`,y))&&(!g||Rl(H,g,y))});p.call(L)}function x(){p?.on(".drag",null)}return{update:S,destroy:x}}function Tb(e,t,n){const i=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const r of t.values())ho(s,Ni(r))>0&&i.push(r);return i}const Ib=250;function Eb(e,t,n,i){let s=[],r=1/0;const a=Tb(e,n,t+Ib);for(const l of a){const c=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const u of c){if(i.nodeId===u.nodeId&&i.type===u.type&&i.id===u.id)continue;const{x:d,y:f}=ai(l,u,u.position,!0),p=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(f-e.y,2));p>t||(p<r?(s=[{...u,x:d,y:f}],r=p):p===r&&s.push({...u,x:d,y:f}))}}if(!s.length)return null;if(s.length>1){const l=i.type==="source"?"target":"source";return s.find(c=>c.type===l)??s[0]}return s[0]}function qu(e,t,n,i,s,r=!1){const a=i.get(e);if(!a)return null;const l=s==="strict"?a.internals.handleBounds?.[t]:[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]],c=(n?l?.find(u=>u.id===n):l?.[0])??null;return c&&r?{...c,...ai(a,c,c.position,!0)}:c}function Qu(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Ab(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ju=()=>!0;function kb(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:s,edgeUpdaterType:r,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:p,cancelConnection:h,onConnectStart:w,onConnect:b,onConnectEnd:S,isValidConnection:x=Ju,onReconnectEnd:_,updateConnection:g,getTransform:y,getFromHandle:v,autoPanSpeed:j,dragThreshold:T=1,handleDomNode:k}){const D=Ou(e.target);let $=0,L;const{x:I,y:H}=ut(e),N=Qu(r,k),O=l?.getBoundingClientRect();let P=!1;if(!O||!N)return;const z=qu(s,N,i,c,t);if(!z)return;let M=ut(e,O),F=!1,U=null,V=!1,Z=null;function Y(){if(!d||!O)return;const[ee,ne]=Du(M,O,j);p({x:ee,y:ne}),$=requestAnimationFrame(Y)}const Q={...z,nodeId:s,type:N,position:z.position},K=c.get(s);let C={inProgress:!0,isValid:null,from:ai(K,Q,re.Left,!0),fromHandle:Q,fromPosition:Q.position,fromNode:K,to:M,toHandle:null,toPosition:_l[Q.position],toNode:null,pointer:M};function W(){P=!0,g(C),w?.(e,{nodeId:s,handleId:i,handleType:N})}T===0&&W();function X(ee){if(!P){const{x:ue,y:he}=ut(ee),be=ue-I,Ce=he-H;if(!(be*be+Ce*Ce>T*T))return;W()}if(!v()||!Q){q(ee);return}const ne=y();M=ut(ee,O),L=Eb(No(M,ne,!1,[1,1]),n,c,Q),F||(Y(),F=!0);const ie=ed(ee,{handle:L,connectionMode:t,fromNodeId:s,fromHandleId:i,fromType:a?"target":"source",isValidConnection:x,doc:D,lib:u,flowId:f,nodeLookup:c});Z=ie.handleDomNode,U=ie.connection,V=Ab(!!L,ie.isValid);const oe=c.get(s),J=oe?ai(oe,Q,re.Left,!0):C.from,le={...C,from:J,isValid:V,to:ie.toHandle&&V?xs({x:ie.toHandle.x,y:ie.toHandle.y},ne):M,toHandle:ie.toHandle,toPosition:V&&ie.toHandle?ie.toHandle.position:_l[Q.position],toNode:ie.toHandle?c.get(ie.toHandle.nodeId):null,pointer:M};g(le),C=le}function q(ee){if(!("touches"in ee&&ee.touches.length>0)){if(P){(L||Z)&&U&&V&&b?.(U);const{inProgress:ne,...ie}=C,oe={...ie,toPosition:C.toHandle?C.toPosition:null};S?.(ee,oe),r&&_?.(ee,oe)}h(),cancelAnimationFrame($),F=!1,V=!1,U=null,Z=null,D.removeEventListener("mousemove",X),D.removeEventListener("mouseup",q),D.removeEventListener("touchmove",X),D.removeEventListener("touchend",q)}}D.addEventListener("mousemove",X),D.addEventListener("mouseup",q),D.addEventListener("touchmove",X),D.addEventListener("touchend",q)}function ed(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:s,fromType:r,doc:a,lib:l,flowId:c,isValidConnection:u=Ju,nodeLookup:d}){const f=r==="target",p=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:w}=ut(e),b=a.elementFromPoint(h,w),S=b?.classList.contains(`${l}-flow__handle`)?b:p,x={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const _=Qu(void 0,S),g=S.getAttribute("data-nodeid"),y=S.getAttribute("data-handleid"),v=S.classList.contains("connectable"),j=S.classList.contains("connectableend");if(!g||!_)return x;const T={source:f?g:i,sourceHandle:f?y:s,target:f?i:g,targetHandle:f?s:y};x.connection=T;const D=v&&j&&(n===ji.Strict?f&&_==="source"||!f&&_==="target":g!==i||y!==s);x.isValid=D&&u(T),x.toHandle=qu(g,_,y,d,n,!0)}return x}const Qr={onPointerDown:kb,isValid:ed};function Bb({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const s=Ve(e);function r({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const w=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const y=n(),v=g.sourceEvent.ctrlKey&&mo()?10:1,j=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*d,T=y[2]*Math.pow(2,j*v);t.scaleTo(T)};let b=[0,0];const S=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(b=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},x=g=>{const y=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const v=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],j=[v[0]-b[0],v[1]-b[1]];b=v;const T=i()*Math.max(y[2],Math.log(y[2]))*(h?-1:1),k={x:y[0]-j[0]*T,y:y[1]-j[1]*T},D=[[0,0],[c,u]];t.setViewportConstrained({x:k.x,y:k.y,zoom:y[2]},D,l)},_=Tu().on("start",S).on("zoom",f?x:null).on("zoom.wheel",p?w:null);s.call(_,{})}function a(){s.on("zoom",null)}return{update:r,destroy:a,pointer:ot}}const Ls=e=>({x:e.x,y:e.y,zoom:e.k}),ur=({x:e,y:t,zoom:n})=>Ps.translate(e,t).scale(n),yi=(e,t)=>e.target.closest(`.${t}`),td=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Pb=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,dr=(e,t=0,n=Pb,i=()=>{})=>{const s=typeof t=="number"&&t>0;return s||i(),s?e.transition().duration(t).ease(n).on("end",i):e},nd=e=>{const t=e.ctrlKey&&mo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Rb({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:s,panOnScrollSpeed:r,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(yi(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const S=ot(d),x=nd(d),_=f*Math.pow(2,x);i.scaleTo(n,_,S,d);return}const p=d.deltaMode===1?20:1;let h=s===ii.Vertical?0:d.deltaX*p,w=s===ii.Horizontal?0:d.deltaY*p;!mo()&&d.shiftKey&&s!==ii.Vertical&&(h=d.deltaY*p,w=0),i.translateBy(n,-(h/f)*r,-(w/f)*r,{internal:!0});const b=Ls(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(d,b),e.panScrollTimeout=setTimeout(()=>{u?.(d,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(d,b))}}function Db({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,s){const r=i.type==="wheel",a=!t&&r&&!i.ctrlKey,l=yi(i,e);if(i.ctrlKey&&r&&l&&i.preventDefault(),a||l)return null;i.preventDefault(),n.call(this,i,s)}}function Lb({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{if(i.sourceEvent?.internal)return;const s=Ls(i.transform);e.mouseButton=i.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=s,i.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(i.sourceEvent,s)}}function Fb({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:s}){return r=>{e.usedRightMouseButton=!!(n&&td(t,e.mouseButton??0)),r.sourceEvent?.sync||i([r.transform.x,r.transform.y,r.transform.k]),s&&!r.sourceEvent?.internal&&s?.(r.sourceEvent,Ls(r.transform))}}function zb({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:s,onPaneContextMenu:r}){return a=>{if(!a.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,r&&td(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&r(a.sourceEvent),e.usedRightMouseButton=!1,i(!1),s)){const l=Ls(a.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(a.sourceEvent,l)},n?150:0)}}}function Ob({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:s,zoomOnDoubleClick:r,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{const p=e||t,h=n&&f.ctrlKey,w=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(yi(f,`${u}-flow__node`)||yi(f,`${u}-flow__edge`)))return!0;if(!i&&!p&&!s&&!r&&!n||a||d&&!w||yi(f,l)&&w||yi(f,c)&&(!w||s&&w&&!e)||!n&&f.ctrlKey&&w)return!1;if(!n&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!s&&!h&&w||!i&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(i)&&!i.includes(f.button)&&f.type==="mousedown")return!1;const b=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||w)&&b}}function $b({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:s,onPanZoom:r,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=Tu().scaleExtent([t,n]).translateExtent(i),p=Ve(e).call(f);_({x:s.x,y:s.y,zoom:Ci(s.zoom,t,n)},[[0,0],[d.width,d.height]],i);const h=p.on("wheel.zoom"),w=p.on("dblclick.zoom");f.wheelDelta(nd);function b(L,I){return p?new Promise(H=>{f?.interpolate(I?.interpolate==="linear"?qi:is).transform(dr(p,I?.duration,I?.ease,()=>H(!0)),L)}):Promise.resolve(!1)}function S({noWheelClassName:L,noPanClassName:I,onPaneContextMenu:H,userSelectionActive:N,panOnScroll:O,panOnDrag:P,panOnScrollMode:z,panOnScrollSpeed:M,preventScrolling:F,zoomOnPinch:U,zoomOnScroll:V,zoomOnDoubleClick:Z,zoomActivationKeyPressed:Y,lib:Q,onTransformChange:K,connectionInProgress:E,paneClickDistance:C,selectionOnDrag:W}){N&&!u.isZoomingOrPanning&&x();const X=O&&!Y&&!N;f.clickDistance(W?1/0:!ct(C)||C<0?0:C);const q=X?Rb({zoomPanValues:u,noWheelClassName:L,d3Selection:p,d3Zoom:f,panOnScrollMode:z,panOnScrollSpeed:M,zoomOnPinch:U,onPanZoomStart:a,onPanZoom:r,onPanZoomEnd:l}):Db({noWheelClassName:L,preventScrolling:F,d3ZoomHandler:h});if(p.on("wheel.zoom",q,{passive:!1}),!N){const ne=Lb({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",ne);const ie=Fb({zoomPanValues:u,panOnDrag:P,onPaneContextMenu:!!H,onPanZoom:r,onTransformChange:K});f.on("zoom",ie);const oe=zb({zoomPanValues:u,panOnDrag:P,panOnScroll:O,onPaneContextMenu:H,onPanZoomEnd:l,onDraggingChange:c});f.on("end",oe)}const ee=Ob({zoomActivationKeyPressed:Y,panOnDrag:P,zoomOnScroll:V,panOnScroll:O,zoomOnDoubleClick:Z,zoomOnPinch:U,userSelectionActive:N,noPanClassName:I,noWheelClassName:L,lib:Q,connectionInProgress:E});f.filter(ee),Z?p.on("dblclick.zoom",w):p.on("dblclick.zoom",null)}function x(){f.on("zoom",null)}async function _(L,I,H){const N=ur(L),O=f?.constrain()(N,I,H);return O&&await b(O),new Promise(P=>P(O))}async function g(L,I){const H=ur(L);return await b(H,I),new Promise(N=>N(H))}function y(L){if(p){const I=ur(L),H=p.property("__zoom");(H.k!==L.zoom||H.x!==L.x||H.y!==L.y)&&f?.transform(p,I,null,{sync:!0})}}function v(){const L=p?Nu(p.node()):{x:0,y:0,k:1};return{x:L.x,y:L.y,zoom:L.k}}function j(L,I){return p?new Promise(H=>{f?.interpolate(I?.interpolate==="linear"?qi:is).scaleTo(dr(p,I?.duration,I?.ease,()=>H(!0)),L)}):Promise.resolve(!1)}function T(L,I){return p?new Promise(H=>{f?.interpolate(I?.interpolate==="linear"?qi:is).scaleBy(dr(p,I?.duration,I?.ease,()=>H(!0)),L)}):Promise.resolve(!1)}function k(L){f?.scaleExtent(L)}function D(L){f?.translateExtent(L)}function $(L){const I=!ct(L)||L<0?0:L;f?.clickDistance(I)}return{update:S,destroy:x,setViewport:g,setViewportConstrained:_,getViewport:v,scaleTo:j,scaleBy:T,setScaleExtent:k,setTranslateExtent:D,syncViewport:y,setClickDistance:$}}var Ii;(function(e){e.Line="line",e.Handle="handle"})(Ii||(Ii={}));function Gb({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:s,affectsY:r}){const a=e-t,l=n-i,c=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&s&&(c[0]=c[0]*-1),l&&r&&(c[1]=c[1]*-1),c}function Dl(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:s}}function mn(e,t){return Math.max(0,t-e)}function gn(e,t){return Math.max(0,e-t)}function zo(e,t,n){return Math.max(0,t-e,e-n)}function Ll(e,t){return e?!t:t}function Hb(e,t,n,i,s,r,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,p=d&&f,{xSnapped:h,ySnapped:w}=n,{minWidth:b,maxWidth:S,minHeight:x,maxHeight:_}=i,{x:g,y,width:v,height:j,aspectRatio:T}=e;let k=Math.floor(d?h-e.pointerX:0),D=Math.floor(f?w-e.pointerY:0);const $=v+(c?-k:k),L=j+(u?-D:D),I=-r[0]*v,H=-r[1]*j;let N=zo($,b,S),O=zo(L,x,_);if(a){let M=0,F=0;c&&k<0?M=mn(g+k+I,a[0][0]):!c&&k>0&&(M=gn(g+$+I,a[1][0])),u&&D<0?F=mn(y+D+H,a[0][1]):!u&&D>0&&(F=gn(y+L+H,a[1][1])),N=Math.max(N,M),O=Math.max(O,F)}if(l){let M=0,F=0;c&&k>0?M=gn(g+k,l[0][0]):!c&&k<0&&(M=mn(g+$,l[1][0])),u&&D>0?F=gn(y+D,l[0][1]):!u&&D<0&&(F=mn(y+L,l[1][1])),N=Math.max(N,M),O=Math.max(O,F)}if(s){if(d){const M=zo($/T,x,_)*T;if(N=Math.max(N,M),a){let F=0;!c&&!u||c&&!u&&p?F=gn(y+H+$/T,a[1][1])*T:F=mn(y+H+(c?k:-k)/T,a[0][1])*T,N=Math.max(N,F)}if(l){let F=0;!c&&!u||c&&!u&&p?F=mn(y+$/T,l[1][1])*T:F=gn(y+(c?k:-k)/T,l[0][1])*T,N=Math.max(N,F)}}if(f){const M=zo(L*T,b,S)/T;if(O=Math.max(O,M),a){let F=0;!c&&!u||u&&!c&&p?F=gn(g+L*T+I,a[1][0])/T:F=mn(g+(u?D:-D)*T+I,a[0][0])/T,O=Math.max(O,F)}if(l){let F=0;!c&&!u||u&&!c&&p?F=mn(g+L*T,l[1][0])/T:F=gn(g+(u?D:-D)*T,l[0][0])/T,O=Math.max(O,F)}}}D=D+(D<0?O:-O),k=k+(k<0?N:-N),s&&(p?$>L*T?D=(Ll(c,u)?-k:k)/T:k=(Ll(c,u)?-D:D)*T:d?(D=k/T,u=c):(k=D*T,c=u));const P=c?g+k:g,z=u?y+D:y;return{width:v+(c?-k:k),height:j+(u?-D:D),x:r[0]*k*(c?-1:1)+P,y:r[1]*D*(u?-1:1)+z}}const id={width:0,height:0,x:0,y:0},Wb={...id,pointerX:0,pointerY:0,aspectRatio:1};function Ub(e){return[[0,0],[e.measured.width,e.measured.height]]}function Vb(e,t,n){const i=t.position.x+e.position.x,s=t.position.y+e.position.y,r=e.measured.width??0,a=e.measured.height??0,l=n[0]*r,c=n[1]*a;return[[i-l,s-c],[i+r-l,s+a-c]]}function Yb({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:s}){const r=Ve(e);let a={controlDirection:Dl("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:p,onResizeStart:h,onResize:w,onResizeEnd:b,shouldResize:S}){let x={...id},_={...Wb};a={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:Dl(u)};let g,y=null,v=[],j,T,k,D=!1;const $=pu().on("start",L=>{const{nodeLookup:I,transform:H,snapGrid:N,snapToGrid:O,nodeOrigin:P,paneDomNode:z}=n();if(g=I.get(t),!g)return;y=z?.getBoundingClientRect()??null;const{xSnapped:M,ySnapped:F}=Qi(L.sourceEvent,{transform:H,snapGrid:N,snapToGrid:O,containerBounds:y});x={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},_={...x,pointerX:M,pointerY:F,aspectRatio:x.width/x.height},j=void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(j=I.get(g.parentId),T=j&&g.extent==="parent"?Ub(j):void 0),v=[],k=void 0;for(const[U,V]of I)if(V.parentId===t&&(v.push({id:U,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const Z=Vb(V,g,V.origin??P);k?k=[[Math.min(Z[0][0],k[0][0]),Math.min(Z[0][1],k[0][1])],[Math.max(Z[1][0],k[1][0]),Math.max(Z[1][1],k[1][1])]]:k=Z}h?.(L,{...x})}).on("drag",L=>{const{transform:I,snapGrid:H,snapToGrid:N,nodeOrigin:O}=n(),P=Qi(L.sourceEvent,{transform:I,snapGrid:H,snapToGrid:N,containerBounds:y}),z=[];if(!g)return;const{x:M,y:F,width:U,height:V}=x,Z={},Y=g.origin??O,{width:Q,height:K,x:E,y:C}=Hb(_,a.controlDirection,P,a.boundaries,a.keepAspectRatio,Y,T,k),W=Q!==U,X=K!==V,q=E!==M&&W,ee=C!==F&&X;if(!q&&!ee&&!W&&!X)return;if((q||ee||Y[0]===1||Y[1]===1)&&(Z.x=q?E:x.x,Z.y=ee?C:x.y,x.x=Z.x,x.y=Z.y,v.length>0)){const J=E-M,le=C-F;for(const ue of v)ue.position={x:ue.position.x-J+Y[0]*(Q-U),y:ue.position.y-le+Y[1]*(K-V)},z.push(ue)}if((W||X)&&(Z.width=W&&(!a.resizeDirection||a.resizeDirection==="horizontal")?Q:x.width,Z.height=X&&(!a.resizeDirection||a.resizeDirection==="vertical")?K:x.height,x.width=Z.width,x.height=Z.height),j&&g.expandParent){const J=Y[0]*(Z.width??0);Z.x&&Z.x<J&&(x.x=J,_.x=_.x-(Z.x-J));const le=Y[1]*(Z.height??0);Z.y&&Z.y<le&&(x.y=le,_.y=_.y-(Z.y-le))}const ne=Gb({width:x.width,prevWidth:U,height:x.height,prevHeight:V,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),ie={...x,direction:ne};S?.(L,ie)!==!1&&(D=!0,w?.(L,ie),i(Z,z))}).on("end",L=>{D&&(b?.(L,{...x}),s?.({...x}),D=!1)});r.call($)}function c(){r.on(".drag",null)}return{update:l,destroy:c}}const Fs=m.createContext(null),Zb=Fs.Provider,od=Tt.error001();function me(e,t){const n=m.useContext(Fs);if(n===null)throw new Error(od);return Wc.useStoreWithEqualityFn(n,e,t)}function je(){const e=m.useContext(Fs);if(e===null)throw new Error(od);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Fl={display:"none"},Xb={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},sd="react-flow__node-desc",rd="react-flow__edge-desc",Kb="react-flow__aria-live",qb=e=>e.ariaLiveMessage,Qb=e=>e.ariaLabelConfig;function Jb({rfId:e}){const t=me(qb);return o.jsx("div",{id:`${Kb}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Xb,children:t})}function ex({rfId:e,disableKeyboardA11y:t}){const n=me(Qb);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${sd}-${e}`,style:Fl,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${rd}-${e}`,style:Fl,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(Jb,{rfId:e})]})}const zs=m.forwardRef(({position:e="top-left",children:t,className:n,style:i,...s},r)=>{const a=`${e}`.split("-");return o.jsx("div",{className:Ie(["react-flow__panel",n,...a]),style:i,ref:r,...s,children:t})});zs.displayName="Panel";function tx({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:o.jsx(zs,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:o.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const nx=e=>{const t=[],n=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&n.push(i);return{selectedNodes:t,selectedEdges:n}},Oo=e=>e.id;function ix(e,t){return Me.shallow(e.selectedNodes.map(Oo),t.selectedNodes.map(Oo))&&Me.shallow(e.selectedEdges.map(Oo),t.selectedEdges.map(Oo))}function ox({onSelectionChange:e}){const t=je(),{selectedNodes:n,selectedEdges:i}=me(nx,ix);return m.useEffect(()=>{const s={nodes:n,edges:i};e?.(s),t.getState().onSelectionChangeHandlers.forEach(r=>r(s))},[n,i,e]),null}const sx=e=>!!e.onSelectionChangeHandlers;function rx({onSelectionChange:e}){const t=me(sx);return e||t?o.jsx(ox,{onSelectionChange:e}):null}const Jr=typeof window<"u"?m.useLayoutEffect:m.useEffect,ad=[0,0],ax={x:0,y:0,zoom:1},lx=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],zl=[...lx,"rfId"],cx=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Ol={translateExtent:uo,nodeOrigin:ad,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function ux(e){const{setNodes:t,setEdges:n,setMinZoom:i,setMaxZoom:s,setTranslateExtent:r,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=me(cx,Me.shallow),u=je();Jr(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=Ol,l()}),[]);const d=m.useRef(Ol);return Jr(()=>{for(const f of zl){const p=e[f],h=d.current[f];p!==h&&(typeof e[f]>"u"||(f==="nodes"?t(p):f==="edges"?n(p):f==="minZoom"?i(p):f==="maxZoom"?s(p):f==="translateExtent"?r(p):f==="nodeExtent"?a(p):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:sb(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},zl.map(f=>e[f])),null}function $l(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function dx(e){const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const i=$l(),s=()=>n(i?.matches?"dark":"light");return s(),i?.addEventListener("change",s),()=>{i?.removeEventListener("change",s)}},[e]),t!==null?t:$l()?.matches?"dark":"light"}const Gl=typeof document<"u"?document:null;function go(e=null,t={target:Gl,actInsideInputWithModifier:!0}){const[n,i]=m.useState(!1),s=m.useRef(!1),r=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
|
|
2
2
|
`).replace(`
|
|
3
3
|
|
|
4
4
|
`,`
|