@synnaxlabs/pluto 0.42.3 → 0.42.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var kf=Object.defineProperty;var Mf=(e,t,n)=>t in e?kf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var tt=(e,t,n)=>Mf(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./jsx-runtime-CITbqOLs.cjs"),g=require("react"),Z=require("./Divider-Dut8qPee.cjs"),u=require("./css-9iEiTRNL.cjs"),ss=require("./external-CzTBFiv_.cjs"),st=require("./state-_FFrG5nH.cjs"),_f=require("./Stack-BbwDtaE6.cjs"),ge=require("./external-DQwznOyH.cjs"),ne=require("./Space-DvalhzRj.cjs"),Ie=require("./hooks-B5aLaWzS.cjs"),Pf=require("./useVirtualCursorDragWebKit-DDmXE4RW.cjs"),Q=require("./Provider-Cw0mSr2D.cjs"),Lf=require("./external-BGBgNbe2.cjs"),Le=require("./external-DGJ8YAe-.cjs"),El=require("./external-Dq8-cbf3.cjs"),Ns=require("./WithIcon-BgS5shNZ.cjs"),Me=require("./toArray-BvVYuN_b.cjs"),Nf=require("./external-DmryCcwg.cjs"),In=require("./external-CTc1n-JC.cjs"),he=require("./Toggle-C0lZDyeo.cjs"),mt=require("./Text-C8GBHl-F.cjs"),nt=require("./provider-aWtsGnV8.cjs"),Re=require("./Text-CMTkSEWx.cjs"),z=require("./value-Bq1w9UY8.cjs"),me=require("./Haul-C6i2oI7z.cjs"),Ne=require("./useMemoCompare-C2X7Mzx8.cjs"),Ur=require("./dimensions-By-vgVks.cjs"),Jo=require("./font-XlUAG1-r.cjs"),Ge=require("./Dropdown-BSSe1E1e.cjs"),ze=require("./deep-BNa3STCp.cjs"),pe=require("zod"),Ke=require("./external-zbKPQ9ls.cjs"),Ts=require("./Pack-DeZUUdJM.cjs"),kt=require("./ContextMenu-HpMLd1Ht.cjs"),Tf=require("./Text-DkA06TeT.cjs"),yl=require("./external-DiLZ1dEk.cjs");require("./Item-DSBs9VLu.cjs");const Sl=require("react-dom"),Mt=require("./external-B8uaUKhb.cjs"),Rl=require("./units-CX_coN92.cjs"),$f=require("./useClickOutside-CSff8yb-.cjs"),Qo=require("./useDebouncedCallback-DnwYZzjR.cjs"),Af=require("./external-CUgPP-JD.cjs"),xs=require("./eraser-BkqFgBRY.cjs"),_o=require("./DateTime-BsjSfOY-.cjs"),If=require("./external-BwUa_5Vs.cjs"),Df=require("./Video-DgjuFLiE.cjs"),zf=(e,t,n=150)=>{const[s,r]=g.useState(e);return g.useEffect(()=>{const i=setTimeout(()=>r(t),n);return()=>clearTimeout(i)},[t,n]),s},Bf=Object.freeze(Object.defineProperty({__proto__:null,Config:he.Config,Dialog:he.Dialog,chooseLocation:he.chooseLocation,formatTip:he.formatTip,useConfig:he.useConfig,wrap:he.wrap},Symbol.toStringTag,{value:"Module"})),er=({ref:e,location:t,style:n,size:s,className:r,children:i,onDragStart:l,sizeUnits:c="px",showHandle:a=!0,...x})=>{const d=u.K.construct(t),p=u.K.direction(d),m=u.g.dimension(p);return o.jsxRuntimeExports.jsxs(ne.Core,{className:u.CSS(u.CSS.B("resize"),u.CSS.loc(d),u.CSS.dir(p),r),style:{[m]:`${s}${c}`,...n},ref:e,...x,children:[i,a&&o.jsxRuntimeExports.jsx("div",{draggable:!0,className:u.CSS(u.CSS.BE("resize","handle"),u.CSS.bordered(u.K.swap(d))),onDragStart:l,onDrag:ge.preventDefault,onDragEnd:ge.preventDefault})]})},tr=({onResize:e,count:t,initialSizes:n=[],minSize:s=100,direction:r="x"})=>{const i=g.useRef(null),[l,c]=g.useState({sizeDistribution:Of(n,t),root:null}),a=g.useCallback((p,m,f)=>{if(i.current==null)return;const h=u.$t.dim(u.$t.construct(i.current),r);c(j=>po(j,h,p,s,m,f))},[s,c,r]);g.useEffect(()=>e==null?void 0:e(l.sizeDistribution),[l.sizeDistribution,e]);const x=g.useCallback((p,m)=>{p.preventDefault();const f=r==="x"?"clientX":"clientY",h=y=>a(m,y[f]),j=()=>{c(y=>({...y,root:null})),document.removeEventListener("mousemove",h)};c(y=>({...y,root:p[f]})),document.addEventListener("mousemove",h),document.addEventListener("mouseup",j,{once:!0})},[c,r,po]);return{setSize:g.useCallback((p,m)=>a(p,void 0,m),[po]),props:{direction:r,sizeDistribution:l.sizeDistribution,onDragHandle:x,ref:i}}},nr=({ref:e,direction:t="x",children:n,sizeDistribution:s,onDragHandle:r,className:i,...l})=>{const c=u.g.construct(t),a=g.Children.toArray(n);return s=Vf(s),o.jsxRuntimeExports.jsx(ne.Space,{...l,ref:e,direction:c,className:u.CSS(u.CSS.B("resize-multiple"),i),empty:!0,grow:!0,children:a.map((x,d)=>o.jsxRuntimeExports.jsx(er,{onDragStart:p=>r(p,d),location:u.g.location(c),size:s[d]*100,sizeUnits:"%",showHandle:d!==a.length-1,children:x},d))})},Of=(e,t)=>{const n=e.reduce((r,i)=>r+i,0),s=t-e.length;if(s<=0)return e.slice(0,t).map(r=>r/n);if(e.every(r=>r<=1)){const r=1-n;return[...e,...Array(s).fill(r/s)]}return e.map(()=>1/t)},xo=.001,Vf=e=>e.every(t=>u.Wt.closeTo(t,1/e.length),xo)?e.map((t,n)=>n%2===0?t+xo:n===e.length-1?t:t-xo):e,po=(e,t,n,s,r,i)=>{const l=Cl(e,t,n,r,i),[c,a]=Ff(e.sizeDistribution,n,l,s/t),x=a?r??null:e.root;return{...e,sizeDistribution:c,root:x}},Cl=(e,t,n,s,r)=>{let i;if(r!=null)r>1&&(r/=t),i=r-e.sizeDistribution[n];else if(s!=null){if(e.root===null)throw new Error("resize root is null during handle drag");i=(s-e.root)/t}else throw new Error("must provide either a MouseEvent or a targetSize");return i},Ff=(e,t,n,s)=>{let r=t;for(;r>0&&e[r]+n<=s;)r--;const i=e[r]+n,l=Hf(r,e,s,n),c=e[l]-n;return i<s||c<s?[e,!1]:[e.map((a,x)=>x===r?i:x===l?c:a),!0]},Hf=(e,t,n,s)=>(e===t.length-1?Wf:Zf)(e,t,n,s),Zf=(e,t,n,s)=>{let r=e+1;for(;r<t.length-1&&t[r]-s<=n;)r++;return r},Wf=(e,t,n,s)=>{let r=e-1;for(;r>0&&t[r]-s<=n;)r--;return r},mo=2,Yf=100,wl=({onCollapse:e,onResize:t,location:n="left",minSize:s,maxSize:r,initialSize:i=200,collapseThreshold:l=1/0,className:c,...a})=>{const[x,d]=g.useState(u.Y(i,s,r)),p=g.useRef(null),m=u.K.construct(n),f=g.useCallback(E=>{if(p.current===null)return 0;const C=u.$t.dim(E,u.K.direction(m),!0)*(1-2*Number(["bottom","right"].includes(m))),L=p.current+C,T=u.Y(L,s,r);return(T-L)/(s??Yf)>l?mo:T},[m,s,r,l]),h=g.useRef(null),j=g.useCallback(E=>{const C=f(E);d(C),h.current!=null&&(t==null||t(C,u.$t.construct(h.current)))},[t,f]),y=g.useCallback(()=>d(E=>(p.current=E,E)),[d]),S=g.useCallback(E=>f(E)===mo&&(e==null?void 0:e()),[e,f]);g.useEffect(()=>{s==null||r==null||d(E=>{const C=u.Y(E,s,r);return p.current=C,C})},[s,r]);const b=Ke.useCursorDrag({onMove:j,onStart:y,onEnd:S});return o.jsxRuntimeExports.jsx(er,{ref:h,location:m,size:x,onDragStart:b,className:u.clsx(c,u.CSS.expanded(x!==mo)),...a})},Gf=Object.freeze(Object.defineProperty({__proto__:null,Core:er,Multiple:nr,Single:wl,calculateDiffPercentage:Cl,useMultiple:tr},Symbol.toStringTag,{value:"Module"})),os="y",Jr=28,Kf=32,qf=40,Xf=.5,Uf=({data:e,...t})=>{const{setSize:n,props:{sizeDistribution:s,ref:r,...i}}=tr({direction:os,count:e.length,minSize:Jr}),l=c=>{if(r.current==null)return;const a=u.$t.dim(u.$t.construct(r.current),os);s[c]<qf/a?n(c,e[c].initialSize??Xf):n(c,Jr+1)};return o.jsxRuntimeExports.jsx(nr,{empty:!0,className:u.CSS.B("accordion"),sizeDistribution:s,ref:r,...t,...i,children:e.map((c,a)=>g.createElement(eh,{...c,key:c.key,index:a,direction:os,onExpand:l,parent:r,size:s[a]}))})},Jf=o.jsxRuntimeExports.jsx(Z.y4.Caret.Down,{"aria-label":"contract"}),Qf=o.jsxRuntimeExports.jsx(Z.y4.Caret.Right,{"aria-label":"expand"}),eh=({index:e,name:t,content:n,actions:s,size:r,parent:i,onExpand:l})=>{let c=!0;if(i.current!=null){const x=u.$t.dim(u.$t.construct(i.current),os);c=r*x>Kf}const a=c?Jf:Qf;return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsxs(ss.Header,{level:"p",className:u.CSS.expanded(c),empty:!0,children:[o.jsxRuntimeExports.jsx(ss.ButtonTitle,{startIcon:a,onClick:()=>l(e),children:t}),s!=null&&o.jsxRuntimeExports.jsx(ss.Actions,{children:s})]}),n]})},th=Object.freeze(Object.defineProperty({__proto__:null,Accordion:Uf},Symbol.toStringTag,{value:"Module"})),nh=(e,t)=>Me.A(e).map(s=>typeof s=="string"?s.split(t).map(r=>({label:r})):s).flat(),bl=({segments:e,shade:t,level:n,weight:s,separator:r,transform:i})=>{let c=nh(e,r);return i!=null&&(c=c.map(i)),c.map(({label:a,icon:x,href:d,...p},m)=>{const f=[o.jsxRuntimeExports.jsx(Z.y4.Caret.Right,{style:{transform:"scale(0.8) translateY(0.5px)",color:u.CSS.shade(t)}},`${a}-${m}`)];if(x!=null){const j=Le.resolve(x);j!=null&&f.push(j)}const h={weight:s,shade:t,level:n,style:{marginLeft:x!=null?"0.5rem":"0"},children:a,...p};return d!=null?f.push(o.jsxRuntimeExports.jsx(El.Link,{...h,href:d},a)):f.push(o.jsxRuntimeExports.jsx(Z.Text,{...h},a)),f}).flat()},vl=({children:e,icon:t,shade:n=9,weight:s,size:r=.5,url:i,level:l="p",separator:c=".",className:a,hideFirst:x=!0,...d})=>{i!=null&&(e=i);const p=bl({segments:e,separator:c,shade:n,level:l,weight:s});return x&&p.shift(),o.jsxRuntimeExports.jsxs(Ns.WithIcon,{className:u.CSS(a,u.CSS.B("breadcrumb"),x&&u.CSS.M("hide-first")),level:l,shade:n,weight:s,size:r,x:!0,...d,children:[Le.resolve(t),...p]})},sh=({url:e,className:t,level:n="p",separator:s="/",weight:r,shade:i=9})=>{const l=bl({segments:e,separator:s,shade:i,level:n,weight:r,transform:(c,a)=>({...c,label:c.label.split("-").map(x=>u.d.capitalize(x)).join(" "),href:`/${e.split(s).slice(0,a+1).join("/")}`})});return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(t,u.CSS.B("breadcrumb"),u.CSS.BM("breadcrumb","url")),x:!0,size:"small",align:"center",children:l})},oh=Object.freeze(Object.defineProperty({__proto__:null,Breadcrumb:vl,URL:sh},Symbol.toStringTag,{value:"Module"})),kl=({variant:e="info",...t})=>e==="loading"?o.jsxRuntimeExports.jsx(Z.y4.Loading,{...t}):o.jsxRuntimeExports.jsx(Z.y4.Circle,{color:Re.VARIANT_COLORS[e],...t}),rh=({action:e})=>g.isValidElement(e)?e:g.createElement(he.Button,{...e,key:e.key}),ih=({status:{key:e,time:t,count:n,message:s,description:r,variant:i},silence:l,actions:c,className:a,children:x,...d})=>{const p=g.useRef(null);return o.jsxRuntimeExports.jsxs(ne.Space,{className:u.CSS(u.CSS.B("notification"),a),y:!0,empty:!0,ref:p,...d,children:[o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,justify:"spaceBetween",grow:!0,style:{width:"100%"},children:[o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(kl,{style:{height:"2.25rem",width:"2.5rem"},variant:i}),o.jsxRuntimeExports.jsx(Z.Text,{level:"small",shade:11,children:`x${n}`}),o.jsxRuntimeExports.jsx(_o.DateTime,{className:u.CSS(u.CSS.BE("notification","time")),level:"small",format:"time",children:t})]}),o.jsxRuntimeExports.jsx(he.Icon,{className:u.CSS(u.CSS.BE("notification","silence")),variant:"outlined",size:"small",onClick:()=>l(e),children:o.jsxRuntimeExports.jsx(Z.y4.Close,{})})]}),o.jsxRuntimeExports.jsxs(ne.Space,{y:!0,align:"start",className:u.CSS(u.CSS.BE("notification","content")),size:"small",children:[x??o.jsxRuntimeExports.jsx(Z.Text,{className:u.CSS(u.CSS.BE("notification","message")),level:"p",style:{flexGrow:1},children:s}),r!=null&&o.jsxRuntimeExports.jsx(Z.Text,{className:u.CSS(u.CSS.BE("notification","description")),level:"small",style:{flexGrow:1},children:r})]}),c!=null&&o.jsxRuntimeExports.jsx(ne.Space,{x:!0,align:"center",justify:"end",className:u.CSS(u.CSS.BE("notification","actions")),children:Me.A(c).map(m=>o.jsxRuntimeExports.jsx(rh,{action:m},m.key))})]},t.toString())},lh=Object.freeze(Object.defineProperty({__proto__:null,Aggregator:Re.Aggregator,Circle:kl,Notification:ih,Text:Re.Text,VARIANTS:nt.VARIANTS,VARIANT_COLORS:Re.VARIANT_COLORS,specZ:nt.specZ,useAdder:Re.useAdder,useErrorHandler:Re.useErrorHandler,useNotifications:Re.useNotifications,variantZ:nt.variantZ},Symbol.toStringTag,{value:"Module"})),sr=({aetherKey:e,enabled:t=!0})=>{const{setState:n}=Q.useLifecycle({aetherKey:e,type:xs.Eraser.TYPE,schema:xs.eraserStateZ,initialState:{region:u.$t.ZERO,enabled:t}}),s=Z.useSyncedRef(t);return{erase:g.useCallback(i=>{n({enabled:s.current,region:i})},[n,s])}},ch=({aetherKey:e,children:t})=>{const{erase:n}=sr({aetherKey:e}),s=Ge.useResize(n);return o.jsxRuntimeExports.jsx("div",{ref:s,className:u.CSS(u.CSS.inheritDims()),children:t})},ah=Object.freeze(Object.defineProperty({__proto__:null,Eraser:ch,use:sr},Symbol.toStringTag,{value:"Module"})),uh=({items:e,initialKey:t})=>{const[n,s]=g.useState(t),r=l=>s(l===n?void 0:l),i=e.find(l=>l.key===n);return{onSelect:r,activeItem:i}},xh=({activeItem:e,children:t,onSelect:n,location:s="left",collapseThreshold:r=.65,className:i,onResize:l,onCollapse:c,eraseEnabled:a,...x})=>{const d=u.K.direction(s);a??(a=e!=null);const p=g.useCallback(()=>{c?c():e!=null&&(n==null||n(e.key))},[n,e==null?void 0:e.key,c]),{erase:m}=sr({enabled:a}),f=g.useCallback((b,E)=>{l==null||l(b,E),m(E)},[l,m]),{content:h,minSize:j,maxSize:y,initialSize:S=0}=e??{};return o.jsxRuntimeExports.jsx(wl,{className:u.CSS(u.CSS.B("nav-drawer"),u.CSS.dir(d),u.CSS.visible(e!=null),i),collapseThreshold:r,onCollapse:p,location:s,onResize:f,minSize:j,maxSize:y,initialSize:S,...x,children:h})},dh=Object.freeze(Object.defineProperty({__proto__:null,Bar:ge.Bar,Drawer:xh,useDrawer:uh},Symbol.toStringTag,{value:"Module"})),rs={...z.ZERO_CONTEXT_VALUE,state:nt.tv.connectivity.DEFAULT},Ml=g.createContext(rs),_l=()=>g.use(Ml),qe=()=>_l().client,ph=()=>_l().state,Qr={connected:"success",connecting:"info",disconnected:"info",failed:"error"},Pl="serverVersionMismatch",mh=(e,t,n)=>`Cluster version ${n!=null?`${n} `:""}is ${e?"older":"newer"} than client version ${t}. Compatibility issues may arise.`,Ll=({children:e,connParams:t})=>{const[n,s,r]=Z.useCombinedStateAndRef(rs),{path:i}=Q.useUnidirectional({type:z.Provider.TYPE,schema:z.Provider.stateZ,state:{props:t??null,state:null}}),l=Re.useAdder(),c=g.useCallback(a=>{r.current.state.status!==a.status&&l({variant:Qr[a.status],message:a.message??u.d.capitalize(a.status)}),s(x=>({...x,state:a}))},[l]);return Q.useAsyncEffect(async()=>{if(n.client!=null&&n.client.close(),t==null)return s(rs);const a=new nt.tv({...t,connectivityPollFrequency:nt.S.seconds(2)});s({client:a,state:{clusterKey:"",status:"connecting",message:"Connecting...",clientServerCompatible:!1,clientVersion:a.clientVersion}});const x=await a.connectivity.check();if(s({client:a,state:x}),l({variant:Qr[x.status],message:x.message??x.status.toUpperCase()}),x.status==="connected"&&!x.clientServerCompatible){const d=x.nodeVersion==null||u.Jt.semVerOlder(x.nodeVersion,x.clientVersion),p=mh(d,x.clientVersion,x.nodeVersion);l({variant:"warning",message:"Incompatible cluster version",description:p,data:{type:Pl,oldServer:d,nodeVersion:x.nodeVersion,clientVersion:x.clientVersion}})}return a.connectivity.onChange(c),()=>{a.close(),s(rs)}},[t,c]),o.jsxRuntimeExports.jsx(Ml,{value:n,children:o.jsxRuntimeExports.jsx(Q.Composite,{path:i,children:e})})},fh=Object.freeze(Object.defineProperty({__proto__:null,Provider:Ll,SERVER_VERSION_MISMATCH:Pl,use:qe,useConnectionState:ph},Symbol.toStringTag,{value:"Module"})),Nl=g.createContext({aliases:{},getName:async()=>await Promise.resolve(void 0),setAlias:null}),ln=()=>g.use(Nl),Tl=e=>ln().aliases[e]??null,$s=()=>ln().aliases,As=(e,t="")=>{const{getName:n}=ln(),[s,r]=g.useState(t);return Q.useAsyncEffect(async()=>{const i=await n(e);r(i)},[e,n]),s??t},or=()=>ln().activeRange??void 0,$l=({activeRange:e,children:t})=>{const n=qe(),[s,r]=g.useState({}),i=g.useCallback(a=>{r(x=>{const d={...x};return a.forEach(({variant:p,key:m,value:f})=>{const h=Number(m.split("---")[1]);p==="delete"?delete d[h]:d[f.channel]=f.alias}),d})},[r]),l=g.useCallback(async(a,x)=>{if(n==null||e==null)return;await(await n.ranges.retrieve(e)).setAlias(a,x)},[n,e]),c=g.useCallback(async a=>{if(n==null||a===0)return;const x=s[a];return x??(await n.channels.retrieve(a)).name},[s,n]);return Q.useAsyncEffect(async()=>{if(n==null||e==null){r({});return}const a=await n.ranges.retrieve(e),x=await a.listAliases();r(x);const d=await a.openAliasTracker(),p=d.onChange(i);return()=>{p(),d.close()}},[n,e]),o.jsxRuntimeExports.jsx(Nl,{value:{aliases:s,activeRange:e,setAlias:e!=null?l:null,getName:c},children:t})},hh=({channelKey:e,value:t,shadow:n,className:s,...r})=>{const[i,l]=g.useState(!1),{setAlias:c}=ln(),a=Tl(e),x=As(e);let d=o.jsxRuntimeExports.jsx(Z.y4.Rename,{});i?d=o.jsxRuntimeExports.jsx(Z.y4.Loading,{}):a===t&&(d=o.jsxRuntimeExports.jsx(Z.y4.Check,{}));const p=c!=null&&!i&&a!==t&&e!==0,m=Re.useErrorHandler(),f=()=>{p&&m(async()=>{l(!0),await c(e,t),l(!1)},"Failed to set channel alias")},h=()=>{var y;a!=null&&((y=r.onChange)==null||y.call(r,a))},j=()=>e===0?o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:"Select a channel to enable alias syncing with this label"}):c==null?o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:"Select a range to enable alias syncing with this label"}):t.length===0?o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:"Enter a value to enable alias syncing with this label"}):a===t?o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:"Alias synced with this label"}):o.jsxRuntimeExports.jsxs(Z.Text,{level:"small",children:["Sync alias for ",x," with this label"]});return o.jsxRuntimeExports.jsxs(mt.Text,{value:t,...r,children:[p&&o.jsxRuntimeExports.jsx(he.Icon,{onClick:h,tooltip:o.jsxRuntimeExports.jsxs(Z.Text,{level:"small",children:["Set ",x," as label"]}),tooltipLocation:{y:"top"},variant:"outlined",children:o.jsxRuntimeExports.jsx(Z.y4.Sync,{})}),o.jsxRuntimeExports.jsx(he.Icon,{onClick:f,disabled:!p,tooltip:o.jsxRuntimeExports.jsx(j,{}),tooltipLocation:{y:"top"},variant:"outlined",children:d})]})},ot="channel";var ei=180/Math.PI,Po={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Al(e,t,n,s,r,i){var l,c,a;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(a=e*n+t*s)&&(n-=e*a,s-=t*a),(c=Math.sqrt(n*n+s*s))&&(n/=c,s/=c,a/=c),e*s<t*n&&(e=-e,t=-t,a=-a,l=-l),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ei,skewX:Math.atan(a)*ei,scaleX:l,scaleY:c}}var Gn;function gh(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Po:Al(t.a,t.b,t.c,t.d,t.e,t.f)}function jh(e){return e==null||(Gn||(Gn=document.createElementNS("http://www.w3.org/2000/svg","g")),Gn.setAttribute("transform",e),!(e=Gn.transform.baseVal.consolidate()))?Po:(e=e.matrix,Al(e.a,e.b,e.c,e.d,e.e,e.f))}function Il(e,t,n,s){function r(x){return x.length?x.pop()+" ":""}function i(x,d,p,m,f,h){if(x!==p||d!==m){var j=f.push("translate(",null,t,null,n);h.push({i:j-4,x:z.interpolateNumber(x,p)},{i:j-2,x:z.interpolateNumber(d,m)})}else(p||m)&&f.push("translate("+p+t+m+n)}function l(x,d,p,m){x!==d?(x-d>180?d+=360:d-x>180&&(x+=360),m.push({i:p.push(r(p)+"rotate(",null,s)-2,x:z.interpolateNumber(x,d)})):d&&p.push(r(p)+"rotate("+d+s)}function c(x,d,p,m){x!==d?m.push({i:p.push(r(p)+"skewX(",null,s)-2,x:z.interpolateNumber(x,d)}):d&&p.push(r(p)+"skewX("+d+s)}function a(x,d,p,m,f,h){if(x!==p||d!==m){var j=f.push(r(f)+"scale(",null,",",null,")");h.push({i:j-4,x:z.interpolateNumber(x,p)},{i:j-2,x:z.interpolateNumber(d,m)})}else(p!==1||m!==1)&&f.push(r(f)+"scale("+p+","+m+")")}return function(x,d){var p=[],m=[];return x=e(x),d=e(d),i(x.translateX,x.translateY,d.translateX,d.translateY,p,m),l(x.rotate,d.rotate,p,m),c(x.skewX,d.skewX,p,m),a(x.scaleX,x.scaleY,d.scaleX,d.scaleY,p,m),x=d=null,function(f){for(var h=-1,j=m.length,y;++h<j;)p[(y=m[h]).i]=y.x(f);return p.join("")}}}var Eh=Il(gh,"px, ","px)","deg)"),yh=Il(jh,", ",")",")"),Sh=1e-12;function ti(e){return((e=Math.exp(e))+1/e)/2}function Rh(e){return((e=Math.exp(e))-1/e)/2}function Ch(e){return((e=Math.exp(2*e))-1)/(e+1)}const wh=function e(t,n,s){function r(i,l){var c=i[0],a=i[1],x=i[2],d=l[0],p=l[1],m=l[2],f=d-c,h=p-a,j=f*f+h*h,y,S;if(j<Sh)S=Math.log(m/x)/t,y=function(P){return[c+P*f,a+P*h,x*Math.exp(t*P*S)]};else{var b=Math.sqrt(j),E=(m*m-x*x+s*j)/(2*x*n*b),C=(m*m-x*x-s*j)/(2*m*n*b),L=Math.log(Math.sqrt(E*E+1)-E),T=Math.log(Math.sqrt(C*C+1)-C);S=(T-L)/t,y=function(P){var O=P*S,I=ti(L),D=x/(n*b)*(I*Ch(t*O+L)-Rh(L));return[c+D*f,a+D*h,x*I/ti(t*O+L)]}}return y.duration=S*1e3*t/Math.SQRT2,y}return r.rho=function(i){var l=Math.max(.001,+i),c=l*l,a=c*c;return e(l,c,a)},r}(Math.SQRT2,2,4),bh=Object.freeze(Object.defineProperty({__proto__:null,Base:z.Base,Bottom:z.Bottom,Right:z.Right,Top:z.Top,axisStateZ:z.axisStateZ,newCanvas:z.newCanvas,newTickFactory:z.newTickFactory,tickFactoryProps:z.tickFactoryProps,tickType:z.tickType},Symbol.toStringTag,{value:"Module"})),vh={region:u.$t.ZERO,dpr:1,os:u.S.getOS()},kh={gl:null,lower2d:null,upper2d:null,bootstrapped:!1},Mh=({children:e,resizeDebounce:t=100,className:n,...s})=>{const[{path:r},{bootstrapped:i,dpr:l},c]=Q.use$1({type:z.Canvas.TYPE,schema:z.canvasStateZ,initialState:vh}),a=g.useRef({...kh}),x=g.useRef(!1),d=g.useCallback(j=>{a.current.bootstrapped&&(c(()=>({bootstrapped:!0,region:j,dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})})),x.current=!0)},[c]),p=g.useRef(null),m=Ge.useResize(d,{debounce:t}),f=Z.useCombinedRefs(p,m);g.useEffect(()=>{const j=()=>{window.devicePixelRatio===l||!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.$t.construct(p.current),dpr:window.devicePixelRatio}))};window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`).addEventListener("change",j,{once:!0})},[l]),g.useEffect(()=>{const j=()=>{!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.$t.construct(p.current),glCanvas:void 0,upper2dCanvas:void 0,lower2dCanvas:void 0}))};window.addEventListener("focus",j),window.addEventListener("blur",j)},[c]);const h=g.useCallback(j=>{if(j==null)return;j.className.includes("gl")?a.current.gl=j:j.className.includes("upper2d")?a.current.upper2d=j:a.current.lower2d=j;const{gl:y,lower2d:S,upper2d:b,bootstrapped:E}=a.current;if(y==null||S==null||b==null||E)return;a.current.bootstrapped=!0;const C=y.transferControlToOffscreen(),L=b.transferControlToOffscreen(),T=S.transferControlToOffscreen();c({glCanvas:C,upper2dCanvas:L,lower2dCanvas:T,bootstrap:!0,bootstrapped:!1,region:u.$t.construct(y),dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})},[C,L,T])},[c]);return o.jsxRuntimeExports.jsxs("div",{ref:f,className:u.CSS(u.CSS.B("canvas-container"),n),...s,children:[o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","lower2d"))}),o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","gl"))}),o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","upper2d"))}),o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:i&&e})]})},Dn=(e,t)=>Ge.useResize(g.useCallback((n,s)=>{const r=document.querySelector(".pluto-canvas--lower2d");r!=null&&e(u.b.XY.translate(u.J.scale(u.$t.topLeft(r),-1)).box(n),s)},[e]),t),_h=Object.freeze(Object.defineProperty({__proto__:null,Canvas:Mh,useRegion:Dn},Symbol.toStringTag,{value:"Module"})),Dl=g.createContext(null),rt=e=>{const t=g.use(Dl);if(t==null)throw new Error(`Cannot to use ${e} as a non-child of LinePlot.`);return t},zl=e=>{const t=rt("Viewport"),{addViewportHandler:n}=t;g.useEffect(()=>n(e),[n,e])},zn=(e,t)=>{const{setGridEntry:n,removeGridEntry:s}=rt(t),{key:r}=e;return Q.useEffectCompare(()=>{u.K.outer.parse(e.loc),n(e)},([c],[a])=>ze.x.equal(c,a),[e]),g.useEffect(()=>()=>s(r),[]),{gridArea:u.g.swap(u.K.direction(e.loc))==="x"?`axis-start-${r} / plot-start / axis-end-${r} / plot-end`:`plot-start / axis-start-${r} / plot-end / axis-end-${r}`}},Bl=({aetherKey:e,style:t,resizeDebounce:n=0,clearOverScan:s=u.J.ZERO,children:r,hold:i=!1,onHold:l,visible:c,...a})=>{const[x,d]=g.useState([]),p=Ne.useMemoDeepEqualProps({clearOverScan:s,hold:i,visible:c}),[{path:m},{grid:f},h]=Q.use$1({aetherKey:e,type:z.LinePlot.TYPE,schema:z.linePlotStateZ,initialState:{container:u.$t.ZERO,viewport:u.$t.DECIMAL,grid:{},...p}}),j=g.useCallback(B=>{c&&h(_=>({..._,container:B}))},[h,c]),y=Dn(j,{debounce:n});g.useEffect(()=>h(B=>({...B,...p})),[p]);const S=g.useRef(new Map),b=g.useCallback(B=>(S.current.set(B,null),()=>S.current.delete(B)),[S]),E=g.useCallback(B=>{const{mode:_,box:R,stage:k}=B;(_==="pan"&&k!=="start"||_==="zoom"||_==="zoomReset"&&k==="start")&&h(v=>({...v,viewport:R})),S.current.forEach((v,M)=>M(B))},[h]),C=g.useCallback(B=>{h(_=>({..._,grid:{..._.grid,[B.key]:B}}))},[h]),L=g.useCallback(B=>h(_=>{const{[B]:R,...k}=_.grid;return{..._,grid:k}}),[h]),T=g.useCallback(B=>{d(_=>[..._.filter(({key:R})=>R!==B.key),B])},[d]),P=g.useCallback(B=>d(_=>_.filter(({key:R})=>R!==B)),[T]),O=g.useMemo(()=>Ph(f),[f]),I=g.useCallback(B=>{h(_=>({..._,hold:B})),l==null||l(B)},[h,l]),D=`line-plot-${e}`,H=g.useMemo(()=>({lines:x,setGridEntry:C,removeGridEntry:L,setLine:T,removeLine:P,setViewport:E,addViewportHandler:b,setHold:I,id:D}),[D,x,C,L,T,P,E,b,I]);return o.jsxRuntimeExports.jsx("div",{id:D,className:u.CSS.B("line-plot"),style:{...t,...O},ref:y,...a,children:o.jsxRuntimeExports.jsx(Dl,{value:H,children:o.jsxRuntimeExports.jsx(Q.Composite,{path:m,children:r})})})},Ph=e=>{const t=u.CSS.newGridBuilder();return z.regions("top",e).forEach(({key:n,size:s})=>t.row(`axis-start-${n}`,`axis-end-${n}`,s)),t.row("plot-start","plot-end","minmax(0, 1fr)"),z.regions("bottom",e).reverse().forEach(({key:n,size:s})=>t.row(`axis-start-${n}`,`axis-end-${n}`,s)),z.regions("left",e).forEach(({key:n,size:s})=>t.col(`axis-start-${n}`,`axis-end-${n}`,s)),t.col("plot-start","plot-end","minmax(0, 1fr)"),z.regions("right",e).forEach(({key:n,size:s})=>t.col(`axis-start-${n}`,`axis-end-${n}`,s)),t.build()},rr=e=>{const t=e==="x"?"bottom":"left",n=e==="x"?z.XAxis.TYPE:z.YAxis.TYPE,s=`${e}-axis`,r=({aetherKey:i,children:l,location:c=t,label:a="",labelLevel:x="small",labelDirection:d=e,onLabelChange:p,color:m,labelSize:f,showGrid:h,type:j,bounds:y,className:S,tickSpacing:b,autoBounds:E,axisKey:C,autoBoundUpdateInterval:L,onAutoBoundsChange:T,style:P,...O})=>{const I=((a==null?void 0:a.length)??0)>0,D=Q.useUniqueKey(i),H=Ne.useMemoDeepEqualProps({location:c,showGrid:h,type:j,bounds:y,axisKey:C,label:a,labelDirection:d,tickSpacing:b,autoBounds:E,autoBoundUpdateInterval:L}),[{path:B},{size:_,labelSize:R,...k},v]=Q.use$1({aetherKey:D,type:n,schema:z.coreAxisStateZ,initialState:H});g.useEffect(()=>v(V=>({...V,...H})),[H]),g.useEffect(()=>{const{lower:V,upper:F}=z.parseAutoBounds(k.autoBounds);k.bounds!=null&&(V&&(y==null?void 0:y.lower)!==k.bounds.lower||F&&(y==null?void 0:y.upper)!==k.bounds.upper)&&(T==null||T(k.bounds))},[k.autoBounds,k.bounds]);const M=zn({loc:c,key:`${n}-${D}`,size:_+R,order:1},`${e.toUpperCase()}Axis`),A=Jo.useTypography(x).toString(),$=g.useRef(0);return g.useEffect(()=>{if(e==="y"){if(a==null)return;let F=Ur.dimensions(a,A)[u.g.dimension(u.g.construct(d))];F>0&&(F+=9),v(W=>({...W,labelSize:F}))}else{let F=Ur.dimensions(a,A).height*1.3;F>0&&(F+=12);const W=$.current;z.withinSizeThreshold(W,F)||($.current=F,v(ee=>({...ee,labelSize:F})))}},[a,d,A]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(S,u.CSS.B("axis"),u.CSS.B(s),u.CSS.loc(c)),style:{...P,...M},align:"center",justify:c!=="left"?"end":"start",direction:u.g.swap(e),...O,children:I&&o.jsxRuntimeExports.jsx(Z.MaybeEditable,{className:u.CSS(u.CSS.BE("axis","label"),u.CSS.dir(d)),value:a,onChange:p,level:x})}),o.jsxRuntimeExports.jsx(Q.Composite,{path:B,children:l})]})};return r.displayName=`${e.toUpperCase()}Axis`,r},Ol=rr("x"),Vl=rr("y"),Fl=u.J.xy.extend({root:u.K.corner,units:pe.z.object({x:pe.z.enum(["px","decimal"]),y:pe.z.enum(["px","decimal"])})}),Lh=Fl.partial({root:!0,units:!0}),Nh=e=>{var n,s,r,i;const t={};return t[((n=e.root)==null?void 0:n.x)??"left"]=((s=e==null?void 0:e.units)==null?void 0:s.x)==="px"?`${e.x}px`:`${e.x*100}%`,t[((r=e.root)==null?void 0:r.y)??"top"]=((i=e==null?void 0:e.units)==null?void 0:i.y)==="px"?`${e.y}px`:`${e.y*100}%`,t},Th=(e,t)=>{var i,l,c,a,x,d;const n={x:e.x,y:e.y};if(t.current==null)return n;const s=u.$t.construct(t.current),r=u.$t.construct(t.current.parentElement);return((i=e.units)==null?void 0:i.x)==="decimal"?((l=e.root)==null?void 0:l.x)==="right"&&(n.x=1-e.x):((c=e.root)==null?void 0:c.x)==="right"?n.x=1-(e.x+u.$t.width(s))/u.$t.width(r):n.x/=u.$t.width(r),((a=e.units)==null?void 0:a.y)==="decimal"?((x=e.root)==null?void 0:x.y)==="bottom"&&(n.y=1-e.y):((d=e.root)==null?void 0:d.y)==="bottom"?n.y=1-(e.y+u.$t.height(s))/u.$t.height(r):n.y/=u.$t.height(r),n},Hl=(e,t)=>{if(t.current==null)return null;const n=u.$t.construct(t.current.parentElement),s=u.$t.construct(t.current),r={x:e.x,y:e.y,root:{...u.K.TOP_LEFT},units:{x:"px",y:"px"}};return e.x>.8?(r.x=(1-e.x)*u.$t.width(n)-u.$t.width(s),r.root.x="right"):e.x<.2?r.x=e.x*u.$t.width(n):r.units.x="decimal",e.y>.8?(r.y=(1-e.y)*u.$t.height(n)-u.$t.height(s),r.root.y="bottom"):e.y<.2?r.y=e.y*u.$t.height(n):r.units.y="decimal",r.x=Math.round(r.x*100)/100,{...r,...u.J.truncate(r,3)}},ni=u.$t.reRoot(u.$t.DECIMAL,u.K.TOP_LEFT),$h={x:.1,y:.1,root:u.K.TOP_LEFT,units:{x:"decimal",y:"decimal"}},ir=g.memo(({className:e,value:t,onChange:n,style:s,draggable:r=!0,initial:i=$h,...l})=>{const[c,a]=st.usePurePassthrough({value:t,onChange:n,initial:i}),x=g.useRef(c),d=Z.useSyncedRef(r===!1),p=g.useRef(null);c!==null&&(s={...s,...Nh(c)});const m=g.useCallback(h=>{var L;if(((L=p.current)==null?void 0:L.parentElement)==null)return x.current;const j=u.$t.construct(p.current.parentElement),y=u.b.XY.scale(j).scale(ni),S=y.box(u.$t.construct(p.current)),b=u.b.XY.clamp(u.$t.construct(u.$t.topLeft(ni),{width:1-u.$t.width(S),height:1-u.$t.height(S)})),E=u.J.translate(u.J.construct(x.current),u.$t.signedDims(y.box(h))),C=b.pos(E);return Hl(C,p)},[]),f=Ke.useCursorDrag({onStart:g.useCallback(()=>{x.current=Th(x.current,p)},[]),onMove:g.useCallback(h=>{if(d.current)return;const j=m(h);j!==null&&a(j)},[]),onEnd:g.useCallback(h=>{if(d.current)return;const j=m(h);j!==null&&(x.current=j)},[])});return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(e,u.CSS.B("legend")),bordered:!0,rounded:!0,style:s,onDragStart:f,draggable:r,borderShade:5,ref:p,onDrag:ge.preventDefault,onDragEnd:ge.preventDefault,background:1,...l})});ir.displayName="Legend.Container";const Is=g.memo(({data:e,onEntryChange:t,onVisibleChange:n,allowVisibleChange:s=!0,shade:r=1})=>o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:e.sort((i,l)=>i.label.localeCompare(l.label)).map(({key:i,color:l,label:c,visible:a=!0})=>o.jsxRuntimeExports.jsxs(ne.Space,{style:{cursor:"pointer"},x:!0,align:"center",size:"small",justify:"spaceBetween",grow:!0,children:[o.jsxRuntimeExports.jsxs(ne.Space,{direction:"x",align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(Ke.Swatch,{value:l,onChange:x=>t==null?void 0:t({key:i,color:x,label:c,visible:a}),onVisibleChange:n,allowChange:t!=null,draggable:!1,size:"tiny"}),o.jsxRuntimeExports.jsx(Z.MaybeEditable,{level:"small",value:c,onChange:x=>t==null?void 0:t({key:i,color:l,label:x,visible:a}),noWrap:!0,shade:a?10:7,onDoubleClick:x=>x.stopPropagation()})]}),s&&o.jsxRuntimeExports.jsx(he.Icon,{className:u.CSS.B("visible-toggle"),onClick:x=>{x.stopPropagation(),t==null||t({key:i,color:l,label:c,visible:!a})},onDoubleClick:x=>x.stopPropagation(),size:"tiny",shade:r,children:a?o.jsxRuntimeExports.jsx(Z.y4.Visible,{}):o.jsxRuntimeExports.jsx(Z.y4.Hidden,{})})]},i))}));Is.displayName="LegendSwatches";const lr=({data:e=[],onEntryChange:t,position:n,onPositionChange:s,allowVisibleChange:r=!0,...i})=>{const[l,c]=g.useState(!1);return e.length===0?null:o.jsxRuntimeExports.jsx(ir,{...i,className:r?u.CSS.M("with-visible-toggle"):void 0,draggable:!l,value:n,onChange:s,size:r?0:"tiny",children:o.jsxRuntimeExports.jsx(Is,{data:e,onEntryChange:t,onVisibleChange:c,allowVisibleChange:r})})},Ah=Object.freeze(Object.defineProperty({__proto__:null,Container:ir,LegendSwatches:Is,Simple:lr,calcStickyPos:Hl,completeStickyXYz:Fl,stickyXYz:Lh},Symbol.toStringTag,{value:"Module"})),cr=g.memo(({className:e,style:t,onLineChange:n,...s})=>{const{lines:r}=rt("Legend");return rt("Legend"),o.jsxRuntimeExports.jsx(lr,{data:r,onEntryChange:n,...s})});cr.displayName="FloatingLegend";const Ih=({onLineChange:e})=>{const{lines:t}=rt("Legend"),n=Q.useUniqueKey(),s=zn({key:n,size:t.length>0?36:0,loc:"bottom",order:5},"Legend");return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS.BE("legend","container"),align:"center",x:!0,style:{...s,padding:"0 1rem",height:"var(--pluto-height-medium)",margin:"1rem 0 ",width:"fit-content"},children:o.jsxRuntimeExports.jsx(Is,{data:t,onEntryChange:e,shade:0})})},Zl=({variant:e="floating",...t})=>e==="floating"?o.jsxRuntimeExports.jsx(cr,{...t}):o.jsxRuntimeExports.jsx(Ih,{...t}),ar=g.memo(({aetherKey:e,...t})=>(Q.useUnidirectional({aetherKey:e,type:z.Line.TYPE,schema:z.stateZ,state:t}),null));ar.displayName="Line";const Dh=Object.freeze(Object.defineProperty({__proto__:null,Line:ar},Symbol.toStringTag,{value:"Module"})),ur=({aetherKey:e,color:t,label:n="",visible:s=!0,...r})=>{const i=Q.useUniqueKey(e),{setLine:l,removeLine:c}=rt("Line");return g.useEffect(()=>(l({key:i,color:t,label:n,visible:s}),()=>c(i)),[n,t,s]),o.jsxRuntimeExports.jsx(ar,{aetherKey:i,color:t,label:n,visible:s,...r})},Wl=({level:e="h2",...t})=>{const n=Q.useUniqueKey(),s=Jo.useTypography(e),r=zn({key:n,size:(s.lineHeight+2)*s.baseSize,loc:"top",order:10},"Title");return o.jsxRuntimeExports.jsx(ne.Space,{justify:"center",align:"center",style:r,children:o.jsxRuntimeExports.jsx(Z.MaybeEditable,{...t,level:e})})},Yl=({aetherKey:e,...t})=>{const n=Q.useUniqueKey(e),[,,s]=Q.use$1({aetherKey:n,type:z.Tooltip.TYPE,schema:z.tooltipStateZ,initialState:{position:null,...t}}),r=g.useRef(null),i=g.useCallback(c=>{const a=document.querySelector(".pluto-canvas-container");if(a==null)return;const x=u.$t.topLeft(a);s({position:u.J.translation(x,u.J.construct(c))})},[s]),l=g.useCallback(()=>s({position:null}),[s]);return g.useEffect(()=>{if(r.current===null)return;const c=r.current.parentElement;if(c!=null)return c.addEventListener("mousemove",i),c.addEventListener("mouseleave",l),()=>{c.removeEventListener("mousemove",i),c.removeEventListener("mouseleave",l)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:r})},zh=Object.freeze(Object.defineProperty({__proto__:null,Tooltip:Yl},Symbol.toStringTag,{value:"Module"})),Gl=()=>{const e=g.useRef(new Map),t=g.useCallback(s=>{const{request:r,response:i}=s,l=e.current.get(r);l!=null&&(l(i.bounds),e.current.delete(r))},[]),[,,n]=Q.use$1({type:z.BoundQuerier.TYPE,schema:z.boundQuerierStateZ,onAetherChange:t,initialState:{request:"",response:{request:"",bounds:{}}}});return g.useCallback(async()=>await new Promise(s=>{const r=u.Lt.create();e.current.set(r,s),n(i=>({...i,request:r}))}),[])},Bh=({ref:e})=>(e.current=Gl(),null),Oh={select:"pointer",zoom:"crosshair",pan:"grab",zoomReset:"crosshair",click:"pointer",cancel:"default"},Kl=({className:e,mode:t,maskBox:n,children:s,style:r,...i})=>o.jsxRuntimeExports.jsxs("div",{className:u.CSS(u.CSS.noSelect,u.CSS.BE("viewport-mask","container"),e),style:{cursor:Oh[t],...r},...i,children:[o.jsxRuntimeExports.jsx("div",{style:{...u.$t.css(n),display:u.$t.areaIsZero(n)?"none":"block"},className:u.CSS.BE("viewport-mask","selection")}),s]}),Vh=[],xr=({data:e,emptyContent:t,value:n,onChange:s,allowMultiple:r,allowNone:i,hideColumnHeader:l=!1,columns:c=Vh,visible:a,itemHeight:x=Re.Column.itemHeight,listItem:d=he.componentRenderProp(Re.Column.Item),replaceOnSingle:p,omit:m,autoSelectOnNone:f,trigger:h,extraDialogContent:j,variant:y="connected",...S})=>{let b=o.jsxRuntimeExports.jsxs(Re.Hover,{disabled:!a,children:[j,o.jsxRuntimeExports.jsx(Re.Column.Header,{hide:l||d!=null,columns:c,children:o.jsxRuntimeExports.jsx(Re.Core.Virtual,{itemHeight:x,children:d})})]});return y!=="connected"&&(b=o.jsxRuntimeExports.jsx(Ts.Pack,{y:!0,className:u.CSS.B("select-dialog-content"),children:b})),o.jsxRuntimeExports.jsx(Re.List,{data:e,emptyContent:t,omit:m,children:o.jsxRuntimeExports.jsx(Re.Selector,{value:n,onChange:s,allowMultiple:r,allowNone:i,replaceOnSingle:p,autoSelectOnNone:f,children:o.jsxRuntimeExports.jsxs(Ge.Dialog,{visible:a,className:u.CSS.B("select"),keepMounted:!1,variant:y,...S,children:[h,b]})})})},it=({children:e=Fh,value:t,onChange:n,entryRenderKey:s="key",allowNone:r=!1,allowMultiple:i=!1,data:l,replaceOnSingle:c,className:a,size:x="medium",actions:d,pack:p=!0,variant:m,...f})=>{const{onSelect:h}=Re.useSelect({allowMultiple:i,allowNone:r,replaceOnSingle:c,data:l,value:t,onChange:n}),j=S=>{m!=="preview"&&h(S)},y=l==null?void 0:l.map(S=>e({key:S.key,onClick:()=>j(S.key),size:x,selected:S.key===t,entry:S,title:S[s]}));return p?o.jsxRuntimeExports.jsxs(Ts.Pack,{borderShade:5,className:u.CSS(u.CSS.B("select-button"),a),size:x,...f,children:[y,d]}):o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:y})},Fh=({key:e,onClick:t,selected:n,title:s,size:r})=>o.jsxRuntimeExports.jsx(he.Button,{onClick:t,variant:n?"filled":"outlined",size:r,children:s},e),ql=({selected:e,renderKey:t,toggle:n,visible:s,children:r,...i})=>o.jsxRuntimeExports.jsx(he.Button,{className:u.CSS.B("select-dropdown-button"),onClick:n,variant:"outlined",endIcon:o.jsxRuntimeExports.jsx(In.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:s}),...i,children:r??(e==null?void 0:e[t])}),Xl=he.componentRenderProp(ql),Ds=({data:e,value:t,columns:n=[],children:s=Xl,entryRenderKey:r="key",allowNone:i=!1,onChange:l,disabled:c,hideColumnHeader:a=!0,variant:x,dropdownVariant:d,...p})=>{const{close:m,visible:f,toggle:h}=Ge.use(),[j,y]=g.useState((e==null?void 0:e.find(E=>E.key===t))??null);g.useEffect(()=>{y((e==null?void 0:e.find(E=>E.key===t))??null)},[e,t]);const S=g.useCallback((E,C)=>{if(!(Array.isArray(E)||E===null)){if(m(),E==null)return y(null),l(t);y(C.entries[0]),l(E)}},[l,t,m,y]),b={selected:j,renderKey:r,toggle:h,visible:f,disabled:c};return x!=null&&(b.variant=x),o.jsxRuntimeExports.jsx(xr,{close:m,data:e,visible:f,value:t,onChange:S,allowMultiple:!1,allowNone:i,columns:n,hideColumnHeader:a,variant:d,trigger:o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:s(b)}),...p})},Hh=[{key:"start",icon:o.jsxRuntimeExports.jsx(Z.y4.TextAlign.Left,{})},{key:"center",icon:o.jsxRuntimeExports.jsx(Z.y4.TextAlign.Center,{})},{key:"end",icon:o.jsxRuntimeExports.jsx(Z.y4.TextAlign.Right,{})}],Zh=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(he.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),zs=({children:e=Zh,...t})=>o.jsxRuntimeExports.jsx(it,{...t,allowMultiple:!1,data:Hh,children:e}),Wh=[{key:"large",label:"L"},{key:"medium",label:"M"},{key:"small",label:"S"}],Ul=e=>o.jsxRuntimeExports.jsx(it,{...e,data:Wh,entryRenderKey:"label"}),Yh=new Set([u.g$2.UUID,u.g$2.JSON]),Jl=u.g$2.ALL.filter(e=>e!==u.g$2.UNKNOWN).map(e=>({key:e.toString(),name:Yh.has(e)?e.toString().toUpperCase():u.d.capitalize(e.toString())})),Gh=Jl.filter(e=>!new u.g$2(e.key).isVariable),Kh=[{key:"name",name:"Name"}],qh=({hideVariableDensity:e=!1,...t})=>o.jsxRuntimeExports.jsx(Ds,{...t,data:e?Gh:Jl,columns:Kh,entryRenderKey:"name"}),Xh=[{key:"x",icon:o.jsxRuntimeExports.jsx(Z.y4.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(Z.y4.Arrow.Up,{})}],Uh=[{key:"x",icon:o.jsxRuntimeExports.jsx(Z.y4.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(Z.y4.Arrow.Down,{})}],Jh=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(he.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),Ql=({children:e=Jh,yDirection:t="up",...n})=>o.jsxRuntimeExports.jsx(it,{...n,allowMultiple:!1,data:t==="up"?Xh:Uh,children:e}),ec=e=>o.jsxRuntimeExports.jsx(he.Icon,{className:u.CSS.BE("select","clear"),variant:"outlined",...e,children:o.jsxRuntimeExports.jsx(Z.y4.Close,{"aria-label":"clear"})}),ft=({onChange:e,value:t,entryRenderKey:n="key",data:s,inputProps:r,allowNone:i=!0,searcher:l,className:c,variant:a="button",hideColumnHeader:x=!1,disabled:d,children:p,dropdownVariant:m="connected",placeholder:f=Bs,inputPlaceholder:h=f,triggerTooltip:j,dropdownZIndex:y,filter:S,actions:b,...E})=>{const{visible:C,open:L,close:T,toggle:P}=Ge.use(),[O,I]=g.useState(null),D=l!=null;Q.useAsyncEffect(async()=>{if(Re.selectValueIsZero(t))return I(null);if((O==null?void 0:O.key)===t)return;let k=null;if(D)try{[k]=await l.retrieve([t])}finally{k??(k=null)}else s!=null&&(k=s.find(v=>v.key===t)??null);I(k)},[l,t,s]);const H=g.useCallback((k,v)=>{Array.isArray(k)||(I(k==null?null:v.entries[0]),T(),e(k,v))},[e,i]),B=g.useMemo(()=>D?Mt.Search:Mt.Filter,[D]),_=o.jsxRuntimeExports.jsx(B,{searcher:l,filter:S,children:({onChange:k})=>o.jsxRuntimeExports.jsx(Qh,{...r,autoFocus:m==="modal",variant:a,onChange:k,onFocus:L,selected:O,entryRenderKey:n,visible:C,allowNone:i,className:c,dropdownVariant:m,disabled:d,placeholder:h,children:b})}),R=o.jsxRuntimeExports.jsx(he.Button,{tooltip:j,variant:"outlined",onClick:P,disabled:d,children:O!=null?tc(n,O):f});return o.jsxRuntimeExports.jsx(xr,{close:T,zIndex:y,data:s,allowMultiple:!1,visible:C,value:t,hideColumnHeader:x,onChange:H,allowNone:i,listItem:p,variant:m,trigger:m!=="modal"?_:R,extraDialogContent:m==="modal"?_:void 0,keepMounted:!1,...E})},Bs="Select",tc=(e,t)=>t==null?"":typeof e=="function"?e(t):t[e].toString(),Qh=({entryRenderKey:e,selected:t,visible:n,onChange:s,onFocus:r,allowNone:i=!0,placeholder:l=Bs,className:c,disabled:a,dropdownVariant:x,children:d,...p})=>{const{clear:m}=Re.useSelectionUtils(),[f,h]=g.useState("");g.useEffect(()=>{if(!n){if(u.w$2(t==null?void 0:t.key))return h("");t!=null&&h(tc(e,t))}},[t,n,e]);const j=C=>{s(C),h(C)},y=()=>{f===""&&s(""),h(""),r==null||r()},S=C=>{n||(C.preventDefault(),r==null||r())},b=()=>{h(""),m==null||m()};let E;return x!=="modal"&&(E=o.jsxRuntimeExports.jsx(In.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:n})),o.jsxRuntimeExports.jsxs(mt.Text,{className:u.CSS(u.CSS.BE("select","input"),c),value:f,onChange:j,onFocus:y,onKeyDown:Ie.matchCallback([["Enter"]],C=>{C.preventDefault(),!n&&(r==null||r())}),endContent:E,style:{flexGrow:1},onClick:S,placeholder:l,disabled:a,...p,children:[d,i&&o.jsxRuntimeExports.jsx(ec,{onClick:b,disabled:a})]})},vn=({children:e="",size:t="medium",color:n,icon:s,onClose:r,className:i,onDragStart:l,...c})=>{const a=u.Dt.cssString(n);s==null&&n!=null&&(s=o.jsxRuntimeExports.jsx(Z.y4.Circle,{fill:a}));const x=r==null?void 0:o.jsxRuntimeExports.jsx(he.Icon,{"aria-label":"close",size:"small",className:u.CSS.BE("tag","close"),shade:1,sharp:!0,onClick:d=>{d.stopPropagation(),r()},children:o.jsxRuntimeExports.jsx(Z.y4.Close,{})});return o.jsxRuntimeExports.jsx(Ns.WithIcon,{startIcon:s,endIcon:x,className:u.CSS(i,u.CSS.B("tag"),u.CSS.size(t),r!=null&&u.CSS.BM("tag","closeable")),level:st.ComponentSizeLevels[t],noWrap:!0,align:"center",size:"small",onDragStart:l,...c,children:e})},e1=Object.freeze(Object.defineProperty({__proto__:null,Tag:vn},Symbol.toStringTag,{value:"Module"})),dr=({entryKey:e,entryRenderKey:t,entry:n,loading:s,...r})=>{let i=e;return n!=null&&(i=typeof t=="function"?t(n):n[t]),g.createElement(vn,{size:"small",variant:"outlined",className:u.CSS(n==null&&!s&&u.CSS.BEM("select-multiple","tag","invalid")),draggable:!0,...r,key:e.toString()},u.Gt(i))},t1=he.componentRenderProp(dr),cn=({onChange:e,value:t,className:n,data:s,columns:r=[],entryRenderKey:i="key",emptyContent:l,searcher:c,renderTag:a=t1,placeholder:x,onTagDragStart:d,allowMultiple:p,allowNone:m,replaceOnSingle:f,onTagDragEnd:h,style:j,addPlaceholder:y="Add",children:S,dropdownVariant:b="connected",actions:E,...C})=>{const{visible:L,open:T,close:P}=Ge.use(),[O,I]=g.useState([]),[D,H]=g.useState(!1),B=c!=null;Q.useAsyncEffect(async()=>{H(!0),Re.selectValueIsZero(t)&&I([]);const M=O.map(V=>V.key),A=Me.A(t);if(u.F.unorderedPrimitiveArrays(M,A)===u.F.EQUAL)return;let $=[];if(B)try{$=await c.retrieve(A)}finally{H(!1)}else s!=null&&($=s.filter(V=>A.includes(V.key)));I($)},[c,B,t,s]);const _=g.useCallback((M,A)=>{M!=null&&(I(A.entries),e(Me.A(M),A))},[e]),R=g.useMemo(()=>B?Mt.Search:Mt.Filter,[B]);let k,v;if(b==="connected")v=o.jsxRuntimeExports.jsx(R,{searcher:c,children:({onChange:M,value:A})=>o.jsxRuntimeExports.jsx(n1,{dropdownVariant:b,value:A,selectedKeys:t,className:n,onChange:M,loading:D,selected:O,onFocus:T,entryRenderKey:i,visible:L,renderTag:a,placeholder:x,onTagDragStart:d,onTagDragEnd:h,style:j,children:E})});else{const M=Me.A(t);v=o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",grow:!0,style:j,size:"small",children:[M.map(A=>{const $=O.find(V=>V.key===A);return a({key:A,entryKey:A,entryRenderKey:i,loading:D,entry:$,onClose:()=>{const V=M.filter(F=>F!==A);e(V,{clicked:null,clickedIndex:-1,entries:[]})},onDragStart:V=>d==null?void 0:d(V,A),onDragEnd:V=>h==null?void 0:h(V,A)})}),M.length>0?o.jsxRuntimeExports.jsx(he.Icon,{onClick:T,children:o.jsxRuntimeExports.jsx(Z.y4.Add,{style:{color:"var(--pluto-gray-l9)"}})}):o.jsxRuntimeExports.jsx(he.Button,{onClick:T,shade:0,textShade:9,startIcon:o.jsxRuntimeExports.jsx(Z.y4.Add,{}),variant:"text",children:y})]}),k=o.jsxRuntimeExports.jsx(R,{searcher:c,children:A=>o.jsxRuntimeExports.jsx(mt.Text,{autoFocus:!0,placeholder:"Search",...A,children:E})})}return o.jsxRuntimeExports.jsx(xr,{close:P,data:s,emptyContent:l,visible:L,value:t,onChange:_,allowNone:m,replaceOnSingle:f,columns:r,allowMultiple:!0,listItem:S,trigger:v,extraDialogContent:k,variant:b,...C})},n1=({selectedKeys:e,loading:t,selected:n,onChange:s,onFocus:r,visible:i,entryRenderKey:l,renderTag:c,placeholder:a=Bs,onTagDragStart:x,onTagDragEnd:d,value:p,className:m,children:f,dropdownVariant:h,...j})=>{const{onSelect:y,clear:S}=Re.useSelectionUtils(),b=g.useRef(null);g.useLayoutEffect(()=>{var P;i&&((P=b.current)==null||P.focus())},[i,n]);const E=()=>{i||s(""),r==null||r()},C=()=>{i||r==null||r()},L=()=>{i||s("")};let T;return h!=="modal"&&(T=o.jsxRuntimeExports.jsx(In.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:i})),o.jsxRuntimeExports.jsxs(mt.Text,{ref:b,className:u.CSS(u.CSS.BE("select-multiple","input"),u.CSS.visible(i),m),onBlur:L,placeholder:a,value:p,onChange:s,onFocus:E,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",onClick:C,endContent:T,variant:"button",...j,children:[o.jsxRuntimeExports.jsx(ne.Space,{x:!0,className:u.CSS.BE("select-multiple","tags"),align:"center",grow:!0,size:"small",children:Me.A(e).map(P=>{const O=n.find(I=>I.key===P);return c({key:P,entryKey:P,entryRenderKey:l,loading:t,entry:O,onClose:()=>y==null?void 0:y(P),onDragStart:I=>x==null?void 0:x(I,P),onDragEnd:I=>d==null?void 0:d(I,P)})})}),f,o.jsxRuntimeExports.jsx(ec,{onClick:S})]})},s1=[{key:"h2",label:"XL"},{key:"h3",label:"L"},{key:"h4",label:"M"},{key:"h5",label:"S"},{key:"small",label:"XS"}],an=e=>o.jsxRuntimeExports.jsx(it,{...e,data:s1,entryRenderKey:"label"}),o1=[{key:600,label:"Bold"},{key:500,label:"Medium"},{key:400,label:"Normal"},{key:250,label:"Light"}],nc=e=>o.jsxRuntimeExports.jsx(it,{...e,data:o1,entryRenderKey:"label"}),r1=Object.freeze(Object.defineProperty({__proto__:null,Level:an,Weight:nc},Symbol.toStringTag,{value:"Module"})),i1=Object.freeze(Object.defineProperty({__proto__:null,BaseButton:ql,Button:it,ComponentSize:Ul,DEFAULT_PLACEHOLDER:Bs,DataType:qh,Direction:Ql,DropdownButton:Ds,Multiple:cn,MultipleTag:dr,Single:ft,Text:r1,TextAlignment:zs,defaultButton:Xl},Symbol.toStringTag,{value:"Module"})),l1=11,c1=6,a1=2,si=5,u1=e=>u.$t.width(e)<si&&u.$t.height(e)<si,jn=e=>{const t=u.$t.width(e),n=u.$t.height(e);return Math.min(t,n)<.001?l1:c1},x1=["zoom","pan","select","zoomReset","cancel"],Rn=[...x1,"click"],d1=pe.z.enum(Rn),sc=["zoom","select"],En={defaultMode:"zoom",zoom:[["MouseLeft"]],zoomReset:[["MouseLeft","Control"]],pan:[["MouseLeft","Shift"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},oc={defaultMode:"pan",pan:[["MouseLeft"]],zoom:[["MouseLeft","Shift"]],zoomReset:[["MouseLeft","Control"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},rc={defaultMode:"select",select:[["MouseLeft"]],pan:[["MouseLeft","Shift"]],zoom:[["MouseLeft","Alt"]],zoomReset:[["MouseLeft","Control"]],cancel:[["Escape"]]},pr={zoom:En,pan:oc,select:rc,zoomReset:En,click:En,cancel:En},p1=e=>{const t=Object.entries(e);return Object.fromEntries(t.map(([n,s])=>n==="defaultMode"?[n,s]:[n,s.map(r=>r.filter(i=>i!=="MouseLeft")).filter(r=>r.length>0)]))},m1=u.$t.construct(0,0,1,1,u.K.TOP_LEFT),f1={width:30,height:50},ic=({onChange:e,triggers:t,initial:n=m1,threshold:s=f1,ref:r})=>{const i=(t==null?void 0:t.defaultMode)??"zoom",[l,c]=g.useState(u.$t.ZERO),[a,x]=g.useState(i),[d,p]=Z.useStateRef(n),m=g.useRef(u.J.ZERO),f=g.useRef(null),h=u._.construct(s);g.useEffect(()=>p(()=>u.$t.truncate(n,jn(n))),[n]),g.useEffect(()=>x(i),[i]);const[j,y,S,b]=Ne.useMemoCompare(()=>{const O={...pr[i],...t},I=Ie.flattenConfig(O),D=p1(O);return[O,I,D,Ie.flattenConfig(D)]},Ie.compareModeConfigs,[t]),E=g.useCallback(({box:O,triggers:I,stage:D,cursor:H})=>{if(f.current==null)return;const B=Ie.determineMode(j,I),_=u.$t.construct(f.current);if(B==null)return;if(B==="cancel"){c(u.$t.ZERO),e==null||e({box:d.current,mode:B,stage:D,cursor:H});return}if(B==="zoomReset")return c(u.$t.ZERO),e==null||e({box:u.$t.DECIMAL,mode:B,stage:D,cursor:H}),p(u.$t.DECIMAL);const R=u1(O);if(D==="end"){if(R){B==="zoom"&&c(u.$t.ZERO),e==null||e({box:d.current,mode:"click",stage:D,cursor:H});return}return p(v=>{if(B==="pan"){const A=oi(O,v,_);return A===null||u.$t.equals(A,v)?v:(e==null||e({box:A,mode:B,stage:D,cursor:H}),A)}const M=C(O,v,_);return M===null?v:(e==null||e({box:M,mode:B,stage:D,cursor:H}),B==="zoom"?(c(u.$t.ZERO),M):u.$t.truncate(v,jn(v)))})}if(sc.includes(B))return R?void 0:c(u.b.XY.scale(_).clamp(_).translate({x:-u.$t.left(_),y:-u.$t.top(_)}).box(ri(h,O,_)));if(c(v=>u.$t.areaIsZero(v)?v:u.$t.ZERO),u.J.distance(H,m.current)<a1)return;m.current=H;const k=oi(O,d.current,_);e==null||e({box:k,mode:B,stage:D,cursor:H})},[c,x,e,j,s.height,s.width,p,f,jn]);g.useImperativeHandle(r,()=>({reset:()=>{c(u.$t.ZERO),p(u.$t.DECIMAL),e==null||e({box:u.$t.DECIMAL,mode:"zoomReset",stage:"start",cursor:u.J.ZERO})}}),[e]);const C=g.useCallback((O,I,D)=>{const H=Lo(I,D).box(ri(h,O,D));return u.$t.truncate(H,jn(H))},[s]),L=Ie.useHeldRef({triggers:[["Control"]]}),T=Ie.useHeldRef({triggers:[["Alt"]]});g.useEffect(()=>{const O=I=>{if(f.current==null)return;let D=1;I.deltaY<0?D-=.035:D+=.035;const H=u.$t.construct(f.current),B=u.J.construct(I);if(Array.from(f.current.children).push(f.current),!u.$t.contains(H,B)||f.current!==I.target&&Ge.findParent(I.target,A=>A===f.current)==null)return;const k=Lo(d.current,u.$t.construct(f.current)).pos(u.J.construct(I));let M=u.b.XY.magnify({x:L.current.held?1:D,y:T.current.held?1:D}).box(d.current);M=u.$t.translate(M,{x:L.current.held?0:k.x*(1-D),y:T.current.held?0:k.y*(1-D)}),p(M),e==null||e({stage:"end",box:M,cursor:u.J.construct(I),mode:"zoom"})};return window.addEventListener("wheel",O),()=>window.removeEventListener("wheel",O)},[p,e]),yl.useDrag({bound:f,onDrag:E,triggers:y,loose:!0});const P=g.useCallback(({triggers:O,stage:I})=>{if(I==="end")return x(i);const D=Ie.determineMode(S,O);D!=null&&x(D)},[S,i,e]);return Ie.use({triggers:b,callback:P,region:f}),{maskBox:l,ref:f,mode:a}},Lo=(e,t)=>u.b.XY.scale(t).clamp(t).scale(e),oi=(e,t,n)=>{let s=u.$t.signedDims(Lo(t,n).box(e));s={signedWidth:-s.signedWidth,signedHeight:-s.signedHeight};const r=u.b.XY.translate(u.J.construct(s)).box(t);return u.$t.truncate(r,jn(r))},ri=(e,t,n)=>u.$t.height(t)<=e.height?u.$t.construct(u.$t.left(t),u.$t.top(n),u.$t.width(t),u.$t.height(n)):u.$t.width(t)<=e.width?u.$t.construct(u.$t.left(n),u.$t.top(t),u.$t.width(n),u.$t.height(t)):t,h1=({mode:e,triggers:t})=>o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",children:[o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:u.d.capitalize(e)}),o.jsxRuntimeExports.jsx(ne.Space,{empty:!0,x:!0,align:"center",children:o.jsxRuntimeExports.jsx(Tf.Text,{trigger:t[0],level:"small"})})]}),g1={zoom:o.jsxRuntimeExports.jsx(Z.y4.Zoom,{}),pan:o.jsxRuntimeExports.jsx(Z.y4.Pan,{}),select:o.jsxRuntimeExports.jsx(Z.y4.Selection,{}),zoomReset:o.jsxRuntimeExports.jsx(Z.y4.Expand,{}),click:o.jsxRuntimeExports.jsx(Z.y4.Bolt,{})},j1=({triggers:e,disable:t=["zoomReset","click"],...n})=>{const s=[...t,"cancel"],r=Object.entries(e).filter(([i])=>!s.includes(i)&&Rn.includes(i)).map(([i,l])=>({key:i,icon:g1[i],tooltip:o.jsxRuntimeExports.jsx(h1,{mode:i,triggers:l})})).sort((i,l)=>Rn.indexOf(i.key)-Rn.indexOf(l.key));return o.jsxRuntimeExports.jsx(it,{...n,data:r,entryRenderKey:"icon",children:({title:i,entry:l,...c})=>g.createElement(he.Icon,{...c,key:l.key,variant:c.selected?"filled":"outlined",size:"small",tooltip:l.tooltip,tooltipLocation:u.K.BOTTOM_LEFT},l.icon)})},E1=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_TRIGGERS:pr,MASK_MODES:sc,MODES:Rn,Mask:Kl,PAN_DEFAULT_TRIGGERS:oc,SELECT_DEFAULT_TRIGGERS:rc,SelectMode:j1,ZOOM_DEFAULT_TRIGGERS:En,modeZ:d1,use:ic},Symbol.toStringTag,{value:"Module"})),y1=e=>e==null?null:e.closest(".pluto-line-plot__viewport")??null,lc=({ref:e,children:t,initial:n=u.$t.DECIMAL,onChange:s,...r})=>{const{setViewport:i}=rt("Viewport");g.useLayoutEffect(()=>{i({box:n,mode:"zoom",cursor:u.J.ZERO,stage:"start"})},[i,n]);const l=g.useCallback(a=>{i(a),s==null||s(a)},[s,i]),c=ic({onChange:l,initial:n,ref:e,...r});return o.jsxRuntimeExports.jsx(Kl,{className:u.CSS.BE("line-plot","viewport"),...c,children:t})},S1=Object.freeze(Object.defineProperty({__proto__:null,BoundsQuerier:Bh,Floating:cr,Legend:Zl,Line:ur,LinePlot:Bl,Title:Wl,Tooltip:zh,Viewport:lc,XAxis:Ol,YAxis:Vl,axisFactory:rr,selectViewportEl:y1,useBoundQuerier:Gl,useContext:rt,useGridEntry:zn,useViewport:zl},Symbol.toStringTag,{value:"Module"})),R1=({aetherKey:e,...t})=>(Q.use$1({aetherKey:e,type:z.Annotation.TYPE,schema:z.annotationStateZ,initialState:t}),null),cc=({aetherKey:e,menu:t,...n})=>{const s=Q.useUniqueKey(e),{setViewport:r,setHold:i}=rt("Range.Provider"),[,{hovered:l,count:c},a]=Q.use$1({aetherKey:s,type:z.Provider$1.TYPE,schema:z.providerStateZ,initialState:{...n,cursor:null,hovered:null,count:0}}),x=zn({key:s,loc:"top",size:c>0?32:0,order:3},"Annotation.Provider"),d=kt.useContextMenu(),p=Z.useSyncedRef(d.visible),m=g.useCallback(f=>{const h=y=>{a(S=>({...S,cursor:{x:y.clientX,y:y.clientY}}))},j=f.currentTarget;j.addEventListener("mousemove",h),j.addEventListener("mouseleave",()=>{j.removeEventListener("mousemove",h),p.current||a(y=>({...y,cursor:null}))},{once:!0})},[a]);return o.jsxRuntimeExports.jsx(kt.ContextMenu,{...d,menu:()=>t==null||l==null?null:t(l),children:o.jsxRuntimeExports.jsx(ne.Space,{style:{...x,cursor:l!=null?"pointer":"default",width:"100%",height:"100%"},onContextMenu:d.open,className:d.className,onClick:()=>{l!=null&&(r({box:u.$t.construct({x:l.viewport.lower,y:0},{x:l.viewport.upper,y:1}),mode:"zoom",cursor:u.J.ZERO,stage:"start"}),i(!0))},onMouseEnter:m})})},C1=Object.freeze(Object.defineProperty({__proto__:null,Annotation:R1,Provider:cc},Symbol.toStringTag,{value:"Module"})),ac={defaultMode:"empty",one:[["1"]],two:[["2"]],clear:[["Shift"]],empty:[[]]},w1=Ie.flattenConfig(ac),uc=({aetherKey:e})=>{const t=Q.useUniqueKey(e),[,,n]=Q.use$1({aetherKey:t,type:z.Measure.TYPE,schema:z.measureStateZ,initialState:{hover:null,one:null,two:null}}),s=g.useRef(null),r=Ie.useHeldRef({triggers:w1,loose:!0}),i=g.useCallback(({mode:a,cursor:x})=>{if(a==="click"){const d=Ie.determineMode(ac,r.current.triggers,{loose:!0});if(["one","two"].includes(d))return n(p=>({...p,[d]:x}));n(d==="clear"?p=>({...p,one:null,two:null}):p=>({...p,one:p.one??x,two:p.one!==null?x:p.two}))}},[n,r]);zl(i);const l=g.useCallback(a=>n(x=>({...x,hover:u.J.construct(a)})),[n]),c=g.useCallback(()=>{n(a=>({...a,hover:null}))},[n]);return g.useEffect(()=>{if(s.current===null)return;const a=s.current.parentElement;if(a!=null)return a.addEventListener("mousemove",l),a.addEventListener("mouseleave",c),()=>{a.removeEventListener("mousemove",l),a.removeEventListener("mouseleave",c)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:s})},b1=Object.freeze(Object.defineProperty({__proto__:null,Measure:uc},Symbol.toStringTag,{value:"Module"})),mr=({aetherKey:e,label:t,position:n,onLabelChange:s,onPositionChange:r,onUnitsChange:i,units:l="",color:c,lineWidth:a,lineDash:x,className:d,onSelect:p,style:m,...f})=>{const[h,j]=st.usePurePassthrough({value:t,onChange:s,initial:""}),y=Z.useSyncedRef(r),[,{pixelPosition:S},b]=Q.use$1({aetherKey:e,type:z.Rule.TYPE,schema:z.ruleStateZ,initialState:{color:c,dragging:!1,position:n,lineWidth:a,lineDash:x},onAetherChange:g.useCallback(({position:B})=>{var _;B!=null&&((_=y.current)==null||_.call(y,B))},[y])}),E=g.useRef(S);S!==E.current&&(E.current=S);const{id:C}=rt("Rule"),L=document.getElementById(C),T=L==null?void 0:L.querySelector(".pluto-line-plot__viewport"),P=g.useRef(S);g.useEffect(()=>{b(B=>({...B,position:n,color:c,lineWidth:a,lineDash:x}))},[n,c,a,x]);const O=Ke.useCursorDrag({onStart:g.useCallback(()=>{p==null||p(),b(B=>({...B,dragging:!0})),P.current=E.current},[]),onMove:B=>{b(_=>({..._,pixelPosition:(P.current??0)+u.$t.signedHeight(B)}))},onEnd:g.useCallback(()=>{b(B=>({...B,dragging:!1})),P.current=S},[])}),I=g.useRef(null);if(n==null||S==null)return null;const D=u.Dt.pickByContrast(c,u.Dt.BLACK,u.Dt.WHITE),H=o.jsxRuntimeExports.jsxs("div",{ref:I,className:u.CSS.B("rule"),style:{top:`calc(${S}px - 0.5rem)`},children:[o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("rule","drag-handle"),onDragStart:O,draggable:!0}),o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",className:u.CSS(d,u.CSS.BE("rule","tag")),bordered:!0,onClick:p,size:1,rounded:!0,style:{borderColor:u.Dt.cssString(c),backgroundColor:u.Dt.hex(u.Dt.setAlpha(c,.7)),...m},...f,children:[o.jsxRuntimeExports.jsx(Z.Editable,{className:u.CSS.B("label"),level:"small",value:h,onChange:j,color:D}),o.jsxRuntimeExports.jsx(Ns.Divider,{y:!0,style:{borderColor:u.Dt.cssString(c)}}),o.jsxRuntimeExports.jsxs(ne.Space,{size:"small",x:!0,align:"center",children:[o.jsxRuntimeExports.jsx(Z.Editable,{value:n.toFixed(2),onChange:B=>{const _=Number(B);isFinite(_)&&(r==null||r(_))},level:"small",color:D}),o.jsxRuntimeExports.jsx(Z.MaybeEditable,{level:"small",color:D,value:l,onChange:i})]})]})]});return T==null?H:Sl.createPortal(H,T)},v1=Object.freeze(Object.defineProperty({__proto__:null,Rule:mr},Symbol.toStringTag,{value:"Module"})),xc=me.canDropOfType(ot),k1=({lines:e,axes:t,showTitle:n=!0,title:s="",onTitleChange:r,showLegend:i=!0,legendPosition:l,onLegendPositionChange:c,titleLevel:a="h4",onLineChange:x,onRuleChange:d,onAxisChannelDrop:p,onAxisChange:m,rules:f,enableTooltip:h=!0,enableMeasure:j=!1,initialViewport:y=u.$t.DECIMAL,legendVariant:S,onViewportChange:b,viewportTriggers:E,annotationProvider:C,onSelectRule:L,children:T,...P})=>{var B;const O=t.filter(({location:_})=>u.K.isY(_)),I=g.useRef(null),D=Z.usePrevious(e.length),H=Z.usePrevious(P.hold);return(D===0&&e.length!==0||H===!0&&P.hold===!1)&&((B=I.current)==null||B.reset()),o.jsxRuntimeExports.jsxs(Bl,{...P,children:[O.map((_,R)=>{const k=e.filter(A=>A.axes.x===_.key),v=t.filter(({location:A})=>u.K.isX(A)),M=f==null?void 0:f.filter(A=>[...v.map(({key:$})=>$),_.key].includes(A.axis));return o.jsxRuntimeExports.jsx(M1,{axis:_,index:R,lines:k,yAxes:v,rules:M,onAxisChannelDrop:p,onAxisChange:m,annotationProvider:C,onRuleChange:d,onSelectRule:L},_.key)}),i&&o.jsxRuntimeExports.jsx(Zl,{onLineChange:x,position:l,onPositionChange:c,variant:S}),n&&o.jsxRuntimeExports.jsx(Wl,{value:s,onChange:r,level:a}),o.jsxRuntimeExports.jsxs(lc,{initial:y,onChange:b,triggers:E,ref:I,children:[h&&o.jsxRuntimeExports.jsx(Yl,{}),j&&o.jsxRuntimeExports.jsx(uc,{}),T]})]})},M1=({yAxes:e,lines:t,index:n,rules:s,onRuleChange:r,onSelectRule:i,onAxisChannelDrop:l,onAxisChange:c,axis:{location:a,key:x,showGrid:d,...p},annotationProvider:m})=>{const f=me.useDrop({type:"Channel.LinePlot.XAxis",canDrop:xc,onDrop:g.useCallback(({items:y})=>{const S=me.filterByType(ot,y);return l==null||l(x,S.map(({key:b})=>b)),S},[x,l])}),h=s==null?void 0:s.filter(y=>y.axis===x),j=me.useDraggingState();return o.jsxRuntimeExports.jsxs(Ol,{...p,...f,location:a,axisKey:x,showGrid:d??n===0,className:u.CSS(u.CSS.dropRegion(me.canDropOfType(ot)(j))),onAutoBoundsChange:y=>c==null?void 0:c({key:x,bounds:y}),children:[e.map((y,S)=>{const b=t.filter(C=>C.axes.y===y.key),E=s==null?void 0:s.filter(C=>C.axis===y.key);return o.jsxRuntimeExports.jsx(P1,{axis:{...y,showGrid:d??(n===0&&S===0)},lines:b,rules:E,onRuleChange:r,onAxisChannelDrop:l,onAxisChange:c,onSelectRule:i},y.key)}),h==null?void 0:h.map(y=>g.createElement(mr,{aetherKey:y.key,...y,key:y.key,onLabelChange:S=>r==null?void 0:r({key:y.key,label:S}),onPositionChange:S=>r==null?void 0:r({key:y.key,position:S}),onUnitsChange:S=>r==null?void 0:r({key:y.key,units:S}),onSelect:()=>i==null?void 0:i(y.key)})),o.jsxRuntimeExports.jsx(cc,{...m})]})},_1=({channels:{x:e,y:t}})=>`${e??0}-${t}`,P1=({lines:e,rules:t,onRuleChange:n,onAxisChannelDrop:s,onAxisChange:r,axis:{key:i,location:l,...c},onSelectRule:a})=>{const x=me.useDrop({type:"Channel.LinePlot.YAxis",canDrop:xc,onDrop:g.useCallback(({items:p})=>{const m=me.filterByType(ot,p);return s==null||s(i,m.map(({key:f})=>f)),m},[i,s])}),d=me.useDraggingState();return o.jsxRuntimeExports.jsxs(Vl,{...c,...x,location:l,axisKey:i,className:u.CSS(u.CSS.dropRegion(me.canDropOfType(ot)(d))),onAutoBoundsChange:p=>r==null?void 0:r({key:i,bounds:p}),children:[e.map(p=>o.jsxRuntimeExports.jsx(L1,{line:p},_1(p))),t==null?void 0:t.map(p=>g.createElement(mr,{aetherKey:p.key,...p,key:p.key,onLabelChange:m=>n==null?void 0:n({key:p.key,label:m}),onPositionChange:m=>n==null?void 0:n({key:p.key,position:m}),onUnitsChange:m=>n==null?void 0:n({key:p.key,units:m}),onClick:()=>a==null?void 0:a(p.key)}))]})},L1=({line:e})=>e.variant==="static"?o.jsxRuntimeExports.jsx(T1,{line:e}):o.jsxRuntimeExports.jsx(N1,{line:e}),N1=({line:{key:e,timeSpan:t,channels:{x:n,y:s},axes:r,...i}})=>{const{xTelem:l,yTelem:c}=g.useMemo(()=>{const a=Number(t.valueOf())*3,x=z.streamChannelData({timeSpan:t,channel:s,keepFor:a}),d=n!=null&&n!==0;return{xTelem:z.streamChannelData({timeSpan:t,channel:d?n:s,useIndexOfChannel:!d,keepFor:a}),yTelem:x}},[t.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(ur,{aetherKey:e,y:c,x:l,...i})},T1=({line:{timeRange:e,key:t,channels:{x:n,y:s},...r}})=>{const{xTelem:i,yTelem:l}=g.useMemo(()=>{const c=z.channelData({timeRange:e,channel:s}),a=n!=null&&n!==0;return{xTelem:z.channelData({timeRange:e,channel:a?n:s,useIndexOfChannel:!a}),yTelem:c}},[e.start.valueOf(),e.end.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(ur,{aetherKey:t,y:l,x:i,...r})},ii=[{key:"name",name:"Name"},{key:"alias",name:"Alias"},{key:"rate",name:"Rate"},{key:"dataType",name:"Data Type"},{key:"index",name:"Index"},{key:"key",name:"Key"},{key:"isIndex",name:"Is Index"}],ds=({items:e},t)=>{const n=me.filterByType(ot,e);return n.length>0&&!n.every(s=>t.includes(s.key))},dc=["name","alias"],pc=e=>{const t=$s();return g.useMemo(()=>e.length===0?ii:ii.filter(n=>e.includes(n.key)),[e,t])},mc=e=>{if(e==null)return Z.y4.Channel;if(nt.jv.isCalculated(e))return Z.y4.Calculation;if(e.isIndex)return Z.y4.Index;const t=new u.g$2(e.dataType);return t.isInteger?Z.y4.Binary:t.isFloat?Z.y4.Decimal:t.equals(u.g$2.STRING)?Z.y4.String:t.equals(u.g$2.JSON)?Z.y4.JSON:Z.y4.Channel},$1=({key:e,...t})=>{const n=mc(t.entry);return o.jsxRuntimeExports.jsx(dr,{icon:o.jsxRuntimeExports.jsx(n,{}),...t},e)},A1=({columns:e=dc,onChange:t,className:n,value:s,searchOptions:r,...i})=>{const l=qe(),c=$s(),a=pc(e),x=or(),d=Ne.useMemoDeepEqualProps(r),p=g.useMemo(()=>l==null?void 0:l.channels.newSearcherWithOptions({rangeKey:x,internal:!1,...d}),[l,x,d]),m=l!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:f,onDragEnd:h,...j}=me.useDragAndDrop({type:"Channel.SelectMultiple",canDrop:g.useCallback(C=>ds(C,Me.A(s)),[s]),onDrop:g.useCallback(({items:C})=>{const L=me.filterByType(ot,C);if(L.length===0)return[];const T=u.c$1.unique([...Me.A(s),...L.map(P=>P.key)]);return t(T,{clickedIndex:null,clicked:null,entries:[]}),L},[t,s])}),y=me.useDraggingState(),S=g.useCallback(({dropped:C})=>{t(Me.A(s).filter(L=>!C.some(T=>T.key===L)),{clickedIndex:null,clicked:null,entries:[]})},[t,s]),b=g.useCallback((C,L)=>f([{key:L,type:ot}],S),[f,S]),E=g.useCallback(C=>c[C.key]??C.name,[c]);return o.jsxRuntimeExports.jsx(cn,{className:u.CSS(n,u.CSS.dropRegion(ds(y,Me.A(s)))),value:s,onTagDragStart:b,onTagDragEnd:h,searcher:p,onChange:t,columns:a,emptyContent:m,entryRenderKey:E,renderTag:$1,...j,...i})},Dt=({columns:e=dc,onChange:t,value:n,className:s,data:r,searchOptions:i,...l})=>{const c=qe(),a=$s(),x=pc(e),d=or(),p=Ne.useMemoDeepEqualProps(i),m=g.useMemo(()=>{if(!(r!=null&&r.length>0))return c==null?void 0:c.channels.newSearcherWithOptions({rangeKey:d,internal:!1,...p})},[c,d,r==null?void 0:r.length,p]),f=c!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),h=g.useId(),j=g.useMemo(()=>({key:h,type:"Channel.SelectMultiple"}),[h]),{startDrag:y,onDragEnd:S,...b}=me.useDragAndDrop({type:"Channel.SelectSingle",canDrop:g.useCallback(T=>ds(T,Me.o(n)),[n]),onDrop:g.useCallback(({items:T})=>{const P=me.filterByType(ot,T);return P.length===0?[]:(t(P[0].key,{clickedIndex:null,clicked:null,entries:[]}),P)},[j,t])}),E=me.useDraggingState(),C=g.useCallback(()=>n!=null&&y([{type:ot,key:n}]),[y,n]),L=g.useCallback(T=>a[T.key]??T.name,[a]);return o.jsxRuntimeExports.jsx(ft,{data:r,className:u.CSS(s,u.CSS.dropRegion(ds(E,Me.o(n)))),value:n,onDragStart:C,onDragEnd:S,onChange:t,searcher:m,columns:x,emptyContent:f,entryRenderKey:L,...b,...l})},I1=Object.freeze(Object.defineProperty({__proto__:null,AliasInput:hh,AliasProvider:$l,LinePlot:k1,SelectMultiple:A1,SelectSingle:Dt,resolveIcon:mc,useActiveRange:or,useAlias:Tl,useAliases:$s,useContext:ln,useName:As},Symbol.toStringTag,{value:"Module"})),_t=({path:e,optional:t=!1,onChange:n})=>{const s=ht(),{get:r,bind:i,set:l,setStatus:c}=s,[a,x]=g.useState(r(e,{optional:t}));g.useEffect(()=>(x(r(e,{optional:t})),i({path:e,onChange:x,listenToChildren:!1})),[e,n,i,r]);const d=g.useCallback(f=>{n==null||n(f,{...s,path:e}),l(e,f)},[e,l,n]),p=g.useCallback(f=>c(e,f),[e,c]);if(a==null){if(!t)throw new Error(`Field state is null: ${e}`);return null}let m;return s.mode==="preview"&&(m="preview"),{onChange:d,setStatus:p,variant:m,...a}},fc=(e,t=!1,n)=>{const{get:s,bind:r}=ht(n),[,i]=g.useState(0);return g.useEffect(()=>(i(l=>l+1),r({path:e,onChange:()=>i(l=>l+1)})),[e,r]),s(e,{optional:t})??null},hc=(e,t=!1,n)=>{var l;const{get:s,bind:r}=ht(n),[,i]=g.useState(0);return g.useEffect(()=>(i(c=>c+1),r({path:e,onChange:()=>i(c=>c+1)})),[e,r]),((l=s(e,{optional:t}))==null?void 0:l.value)??null},D1=e=>{var t,n;return((n=(t=fc(e,!0))==null?void 0:t.status)==null?void 0:n.variant)==="success"},z1=({path:e,ctx:t,onChange:n})=>{const s=ht(t);g.useEffect(()=>s.bind({path:e,onChange:r=>n(r,s),listenToChildren:!1}),[e,s])},B1=({path:e,optional:t=!1})=>{const{bind:n,get:s}=ht(),[r,i]=g.useState(s(e,{optional:t}));if(g.useEffect(()=>(i(s(e,{optional:t})),n({path:e,onChange:l=>i({...l,value:u.Qt(l.value)}),listenToChildren:!0})),[e,n,s]),r==null&&!t)throw new Error("Field state is null");return(r==null?void 0:r.value)??null},gc=(e,t)=>({add:(n,s)=>{const r=u.Qt(e.get(t).value);r.splice(s,0,...Me.A(n)),e.set(t,r,{validateChildren:!1})},push:(n,s)=>{const r=u.Qt(e.get(t).value);r.push(...Me.A(n)),s!=null&&r.sort(s),e.set(t,r,{validateChildren:!1})},remove:n=>{const s=e.get(t).value,r=new Set(Me.A(n));e.set(t,s.filter((i,l)=>!r.has(l)))},keepOnly:n=>{const s=e.get(t).value,r=new Set(Me.A(n));e.set(t,s.filter((i,l)=>r.has(l)))},set:n=>e.set(t,st.executeSetter(n,e.get(t).value)),sort:n=>{const s=u.Qt(e.get(t).value);s.sort(n),e.set(t,s)}}),O1=({path:e,updateOnChildren:t=!1,ctx:n})=>{const s=ht(n),{bind:r,get:i}=s,[l,c]=g.useState(i(e).value);return g.useEffect(()=>(c(i(e).value),r({path:e,onChange:a=>{c(u.Qt(a.value))},listenToChildren:t})),[e,r,i,c]),g.useMemo(()=>({value:l,...gc(s,e)}),[l,s,e])},jc=g.createContext({mode:"normal",bind:()=>()=>{},set:()=>{},reset:()=>{},remove:()=>{},get:()=>({value:void 0,status:{key:"",variant:"success",message:""},touched:!1,required:!1}),validate:()=>!1,validateAsync:()=>Promise.resolve(!1),value:()=>({}),has:()=>!1,setStatus:()=>{},clearStatuses:()=>{},setCurrentStateAsInitialValues:()=>{}}),ht=e=>{const t=g.use(jc);return e??t},li=e=>({key:e,variant:"success",message:""}),V1=e=>e.code===pe.z.ZodIssueCode.custom&&e.params!=null&&"variant"in e.params?e.params.variant:"error",Ec=({values:e,sync:t=!1,schema:n,mode:s="normal",onChange:r,onHasTouched:i})=>{const l=Z.useInitializerRef(()=>({state:ze.x.copy(e),statuses:new Map,touched:new Set,listeners:new Map,parentListeners:new Map})),c=Z.useSyncedRef(n),a=Z.useSyncedRef(r),x=Z.useSyncedRef(e),d=Z.useSyncedRef(i),p=Re.useErrorHandler(),m=g.useCallback(()=>{x.current=ze.x.copy(l.current.state),S()},[]),f=g.useCallback(({path:_,onChange:R,listenToChildren:k=!1})=>{var $;const{parentListeners:v,listeners:M}=l.current,A=k?v:M;return A.has(_)||A.set(_,new Set),($=A.get(_))==null||$.add(R),()=>{var V;return(V=A.get(_))==null?void 0:V.delete(R)}},[]),h=g.useCallback((_,{optional:R}={optional:!1})=>{const{state:k,statuses:v,touched:M}=l.current,A=ze.x.get(k,_,{optional:R});if(A==null)return null;const $={value:A,status:v.get(_)??li(_),touched:M.has(_),required:!1};if(c.current==null)return $;const V=c.current,F=u.L.getFieldSchema(V,_,{optional:!0});return F==null||"isOptional"in F&&typeof F.isOptional=="function"&&($.required=!F.isOptional()),$},[]),j=g.useCallback(_=>{var M;const{touched:R}=l.current,k=R.size===0;R.add(_);const v=R.size===0;k!==v&&((M=d.current)==null||M.call(d,!v))},[]),y=g.useCallback(_=>{var M;const{touched:R}=l.current,k=R.size===0;R.delete(_);const v=R.size===0;k!==v&&((M=d.current)==null||M.call(d,!v))},[]),S=g.useCallback(()=>{var v;const{touched:_}=l.current,R=_.size===0;_.clear();const k=_.size===0;R!==k&&((v=d.current)==null||v.call(d,!k))},[]),b=g.useCallback(_=>{const{state:R,statuses:k,listeners:v,parentListeners:M}=l.current;ze.x.remove(R,_),k.delete(_),y(_),v.delete(_),M.delete(_)},[]),E=g.useCallback(_=>{const{statuses:R}=l.current;l.current.state=_??ze.x.copy(x.current),L(""),R.clear(),S()},[]),C=g.useCallback(_=>{var v;const{listeners:R}=l.current,k=h(_,{optional:!0});k!=null&&((v=R.get(_))==null||v.forEach(M=>M(k)))},[]),L=g.useCallback(_=>{const{listeners:R,parentListeners:k}=l.current,v=R.get(_);if(_==""&&([...R.keys()].forEach($=>{var F;const V=h($,{optional:!0});V!=null&&((F=R.get($))==null||F.forEach(W=>{W(V)}))}),[...k.keys()].forEach($=>{var F;const V=h($,{optional:!0});V!=null&&((F=k.get($))==null||F.forEach(W=>{W(V)}))})),v!=null){const M=h(_,{optional:!0});M!=null&&v.forEach(A=>{A(M)})}k.forEach((M,A)=>{if(ze.x.pathsMatch(_,A)){const V=h(A,{optional:!0});V!=null&&M.forEach(F=>{F(V)})}})},[]),T=g.useCallback((_,R="",k=!0)=>{const{statuses:v,listeners:M}=l.current;if(_.success){const F=[...v.keys()];return v.clear(),F.forEach(W=>C(W)),!0}let A=!0;const $=new Set(_.error.issues.map(F=>F.path.join(".")));let V=(F,W)=>F===W;return k&&(V=(F,W)=>ze.x.pathsMatch(F,W)),_.error.issues.forEach(F=>{var oe;const{message:W}=F,ee=F.path.join(".");if(!V(ee,R))return;const te=V1(F);te!=="warning"&&(A=!1),v.set(ee,{key:ee,variant:te,message:W}),j(ee);let se=h(ee,{optional:!0});se??(se={value:void 0,status:v.get(ee)??li(ee),touched:!1,required:!1}),(oe=M.get(ee))==null||oe.forEach(J=>J(se))}),v.forEach((F,W)=>{$.has(W)||(v.delete(W),C(W))}),A},[]),P=g.useCallback((_,R)=>{if(c.current==null)return!0;const{state:k}=l.current,v=c.current.safeParse(k);return T(v,_,R)},[T]),O=g.useCallback(async(_,R)=>{if(c.current==null)return!0;const{state:k}=l.current,v=await c.current.safeParseAsync(k);return T(v,_,R)},[T]),I=g.useCallback((_,R,k={})=>{const v=ze.x.get(l.current.state,_,{optional:!0}),{validateChildren:M=!0}=k,{state:A}=l.current,$=ze.x.get(x.current,_,{optional:!0});ze.x.equal($,R)?y(_):j(_),_.length===0?l.current.state=R:ze.x.set(A,_,R),L(_),p(async()=>{var W;let F;try{F=P(_,M)}catch{F=await O(_,M)}(W=a.current)==null||W.call(a,{values:l.current.state,path:_,prev:v,valid:F})},"Failed to validate form")},[]),D=g.useCallback(_=>ze.x.has(l.current.state,_),[]),H=g.useCallback((_,R)=>{l.current.statuses.set(_,R),j(_),C(_)},[]),B=g.useCallback(()=>{const{statuses:_}=l.current;_.clear(),_.forEach((R,k)=>C(k))},[]);return g.useEffect(()=>{if(!t)return;const{listeners:_}=l.current;l.current.state=e,_.forEach((R,k)=>{const v=h(k,{optional:!0});v!=null&&R.forEach(M=>M(v))})},[t,e]),g.useMemo(()=>({bind:f,set:I,get:h,mode:s,validate:P,validateAsync:O,value:()=>l.current.state,has:D,remove:b,setStatus:H,clearStatuses:B,reset:E,setCurrentStateAsInitialValues:m}),[f,I,h,P,O,D,b,H,B,E,s,m])},F1=({children:e,...t})=>o.jsxRuntimeExports.jsx(jc,{value:t,children:e}),H1=he.componentRenderProp(mt.Text),Ce=({path:e,children:t=H1,label:n,padHelpText:s=!0,visible:r=!0,hideIfNull:i=!1,optional:l,onChange:c,className:a,...x})=>{const d=_t({path:e,optional:l??i,onChange:c}),p=ht();if(d==null)return null;if(e==null)throw new Error("No path provided to Form Field");if(n??(n=u.d.capitalize(ze.x.element(e,-1))),r=typeof r=="function"?r(d,p):r,!r)return null;const m=d.status.message,{onChange:f,value:h}=d,j={onChange:f,value:h};return d.variant!=null&&(j.variant=d.variant),o.jsxRuntimeExports.jsx(ge.Item,{padHelpText:s,helpText:m,helpTextVariant:d.status.variant,label:n,required:d.required,className:u.CSS(a,u.CSS.BE("field",e.split(".").join("-")),u.CSS.M(d.status.variant)),...x,children:t(j)})},Pt=e=>({fieldKey:t,fieldProps:n,inputProps:s})=>{const r=({inputProps:i,path:l,fieldKey:c=t,...a})=>o.jsxRuntimeExports.jsx(Ce,{...n,...a,path:c?`${l}.${c}`:l,children:x=>o.jsxRuntimeExports.jsx(e,{...x,...s,...i})});return r.displayName=e.displayName,r},yc=Pt(ge.Numeric),Ze=yc({}),Sc=Pt(mt.Text),fr=Sc({}),Rc=Pt(Q.Switch$1),Os=Rc({}),Z1=Pt(ft),W1=Pt(cn),Y1=Pt(Ds),G1=Pt(it),hr=({key:e,open:t,onChange:n})=>{const s=Ne.useMemoPrimitiveArray(e);Q.useAsyncEffect(async()=>{if(t==null)return;const r=await t();if(r==null)return;const i=r.onChange(n);return async()=>{i(),await r.close()}},[t==null,s])},K1=({fetchInitialValue:e,...t})=>{const[n,s]=g.useState(void 0);return Q.useAsyncEffect(async()=>{s(await e())},[e]),hr({...t,onChange:s}),n},q1=Object.freeze(Object.defineProperty({__proto__:null,useListener:hr,useState:K1},Symbol.toStringTag,{value:"Module"})),X1=({key:e,name:t,queryFn:n,values:s,openObservable:r,applyChanges:i,applyObservable:l,...c})=>{const a=qe(),x=Re.useErrorHandler(),d=Ne.useMemoPrimitiveArray(e),p=Ec({values:s,...c,sync:!1,onChange:h=>{a!=null&&x(async()=>{await(i==null?void 0:i({...h,client:a}))},`Failed to apply changes for ${t}`)}});Q.useAsyncEffect(async()=>{if(a!=null)try{const h=await n({client:a});p.set("",h)}catch(h){x(h,`Failed to retrieve ${t}`)}},[d,a==null?void 0:a.key]);const m=g.useCallback(async()=>{if(a!=null)return await(r==null?void 0:r(a))},[d,a==null?void 0:a.key]),f=g.useCallback(h=>l==null?void 0:l({changes:h,ctx:p}),[d,l]);return hr({key:d,open:m,onChange:f}),p},U1=Object.freeze(Object.defineProperty({__proto__:null,Field:Ce,Form:F1,NumericField:Ze,SwitchField:Os,TextField:fr,buildButtonSelectField:G1,buildDropdownButtonSelectField:Y1,buildNumericField:yc,buildSelectMultiField:W1,buildSelectSingleField:Z1,buildSwitchField:Rc,buildTextField:Sc,fieldArrayUtils:gc,fieldBuilder:Pt,use:Ec,useChildFieldValues:B1,useContext:ht,useField:_t,useFieldArray:O1,useFieldListener:z1,useFieldState:fc,useFieldValid:D1,useFieldValue:hc,useSynced:X1},Symbol.toStringTag,{value:"Module"})),J1=[{key:"name",name:"Name"},{key:"location",name:"Location",render:({entry:{location:e,rackName:t}})=>o.jsxRuntimeExports.jsx(vl,{level:"small",shade:9,weight:450,style:{marginTop:"0.25rem"},size:"tiny",children:t?`${t}.${e}`:e})}],Q1=({searchOptions:e,filter:t,...n})=>{const s=qe();let r=s==null?void 0:s.hardware.devices;e!=null&&s!=null&&(r=s.hardware.devices.newSearcherWithOptions(e));const[i,l]=g.useState(new Map),c=g.useCallback(a=>((t==null?void 0:t(a))??a).map(d=>({...d,rackName:i.get(d.rack)})),[t,i]);return Q.useAsyncEffect(async()=>{if(s==null){l(new Map);return}const a=await s.hardware.racks.retrieve([]);l(new Map(a.map(({key:x,name:d})=>[x,d])))},[s==null?void 0:s.key]),o.jsxRuntimeExports.jsx(ft,{columns:J1,searcher:r,entryRenderKey:"name",filter:c,...n})},eg=Object.freeze(Object.defineProperty({__proto__:null,SelectSingle:Q1},Symbol.toStringTag,{value:"Module"})),tg=[{key:"name",name:"Name"},{key:"location",name:"Location"}],ng=e=>{const t=qe();return o.jsxRuntimeExports.jsx(ft,{columns:tg,searcher:t==null?void 0:t.hardware.racks,entryRenderKey:"name",...e})},sg=Object.freeze(Object.defineProperty({__proto__:null,SelectSingle:ng},Symbol.toStringTag,{value:"Module"})),Qt="label",gr=[{key:"color",name:"Color",render:({entry:e})=>o.jsxRuntimeExports.jsx(Z.y4.Circle,{name:"circle",color:e.color,style:{height:"2.5rem",width:"2.5rem"}})},{key:"name",name:"Name"}],ps=({items:e},t)=>{const n=me.filterByType(Qt,e);return n.length>0&&!n.every(s=>t.includes(s.key))},og=({entry:e,loading:t,entryKey:n,entryRenderKey:s,...r})=>o.jsxRuntimeExports.jsx(vn,{color:e==null?void 0:e.color,...r,children:e==null?void 0:e.name}),rg=he.componentRenderProp(og),ig=({onChange:e,className:t,value:n,...s})=>{const r=qe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=me.useDragAndDrop({type:"Label.SelectMultiple",canDrop:g.useCallback(m=>ps(m,Me.A(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=me.filterByType(Qt,m);if(f.length===0)return[];const h=u.c$1.unique([...Me.A(n),...f.map(j=>j.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),x=me.useDraggingState(),d=g.useCallback(({dropped:m})=>{e(Me.A(n).filter(f=>!m.some(h=>h.key===f)),{clickedIndex:null,clicked:null,entries:[]})},[e,n]),p=g.useCallback((m,f)=>l([{key:f,type:Qt}],d),[l,d]);return o.jsxRuntimeExports.jsx(cn,{className:u.CSS(t,u.CSS.dropRegion(ps(x,Me.A(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.labels,onChange:e,columns:gr,emptyContent:i,renderTag:rg,addPlaceholder:"Label",...a,...s})},Cc=({value:e,onChange:t})=>{const n=qe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),r=g.useId(),i=g.useMemo(()=>({key:r,type:"Label.SelectMultiple"}),[r]),l=me.useDragAndDrop({type:"Label.SelectSingle",canDrop:g.useCallback(x=>ps(x,Me.o(e)),[e]),onDrop:g.useCallback(({items:x})=>{const d=me.filterByType(Qt,x);return d.length===0?[]:(t(d[0].key,{clickedIndex:null,clicked:null,entries:[]}),d)},[i,t])}),c=me.useDraggingState(),a=g.useCallback(()=>e!=null&&l.startDrag([{type:Qt,key:e}]),[l.startDrag,e]);return{emptyContent:s,dragging:c,...l,onDragStart:a,searcher:n==null?void 0:n.labels}},lg=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=Cc({value:t,onChange:e});return o.jsxRuntimeExports.jsx(ft,{data:s,className:u.CSS(n,u.CSS.dropRegion(ps(i,Me.o(t)))),value:t,onChange:e,columns:gr,entryRenderKey:"name",...l,...r})},cg=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=Cc({value:t,onChange:n});return o.jsxRuntimeExports.jsx(ft,{data:e,value:t,onChange:n,columns:gr,entryRenderKey:"name",...i,...s})},ag=Object.freeze(Object.defineProperty({__proto__:null,HAUL_TYPE:Qt,SelectButton:cg,SelectMultiple:ig,SelectSingle:lg},Symbol.toStringTag,{value:"Module"})),Vs=new Error("Tab not found"),ug=new Error("Invalid Mosaic"),ms=(e,t,n="center",s,r)=>{if(e=lt(e),s===void 0)return No(e,t);const i=To(e,s);if(n==="center")return i.tabs||(i.tabs=[]),r!==void 0&&r>=0&&r<=i.tabs.length?i.tabs.splice(r,0,t):i.tabs.push(t),i.selected=t.tabKey,e;const l=i.key*2,c=i.key*2+1,a=n==="top"||n==="left"?l:c;if(To(e,a).key!==i.key)return ms(e,t,"center",a);if(i.tabs==null||i.tabs.length===0)return ms(e,t,"center",s);const[x,d,p]=hg(n);if(i.direction=p,i[x]={key:0,tabs:[t],selected:t.tabKey},i[d]={key:0,tabs:i.tabs,selected:i.selected},i.first==null||i.last==null)throw ug;return i.first.key=l,i.last.key=c,i.tabs=void 0,i.size=void 0,i.selected=void 0,e},xg=(e,t,n)=>{var i;e=lt(e);const[s,r]=zt(e,t);if(s==null||r==null)throw Vs;return r.tabs=(i=r.tabs)==null?void 0:i.map(l=>l.tabKey===t?n(l):l),e},No=(e,t)=>(e=lt(e),e.tabs!=null?(e.tabs.push(t),e.selected=t.tabKey,e):(e.first!=null?e.first=No(e.first,t):e.last!=null&&(e.last=No(e.last,t)),e)),fs=e=>{e=lt(e);const t=[];if(e.tabs!=null&&(e.selected=Le.resetSelection(e.selected,e.tabs),e.selected!=null&&t.push(e.selected)),e.first!=null){const[n,s]=fs(e.first);e.first=n,t.push(...s)}if(e.last!=null){const[n,s]=fs(e.last);e.last=n,t.push(...s)}return[e,t]},jr=(e,t)=>{var r;e=lt(e);const[,n]=zt(e,t);if(n==null)return[e,null];n.tabs=(r=n.tabs)==null?void 0:r.filter(i=>i.tabKey!==t),n.selected=Le.resetSelection(n.selected,n.tabs),e=fg(e);const s=n.selected??hs(e);return[e,s]},hs=e=>e.selected!=null?e.selected:e.first!=null?hs(e.first):e.last!=null?hs(e.last):null,wc=(e,t)=>{e=lt(e);const[n,s]=zt(e,t);if(n==null||s==null)throw Vs;return s.selected=t,e},bc=(e,t,n,s,r)=>{e=lt(e);const[i,l]=zt(e,t);if(i==null||l==null)throw Vs;const[c,a]=jr(e,t);return[ms(c,i,n,s,r),a]},kn=(e,t)=>{if(e.tabs!=null)return e.tabs.some(n=>n.tabKey===t)?e:void 0;if(e.first!=null){const n=kn(e.first,t);if(n!=null)return n}if(e.last!=null){const n=kn(e.last,t);if(n!=null)return n}},vc=(e,t,n)=>{const s=gs(e,t);if(s==null)throw new Error("Node not found");return s.size=n,e},dg=(e,t,n)=>{e=lt(e);const s=kn(e,t);if(s==null)throw new Error("Tab not found");if(s.tabs==null||s.tabs.length===0)throw new Error("Node has no tabs");const r=s.tabs.findIndex(d=>d.tabKey===t);if(r===-1)throw new Error("Tab not found in node");const i=s.tabs[r];s.tabs=s.tabs.filter(d=>d.tabKey!==t);const l=s.key*2,a={key:s.key*2+1,tabs:[i],selected:i.tabKey},x={key:l,tabs:s.tabs,selected:s.selected};return x.selected=Le.resetSelection(x.selected,x.tabs),s.direction=n,s.first=x,s.last=a,s.tabs=void 0,s.selected=void 0,e},pg=(e,t)=>{const n=kn(e,t);return n==null?!1:n.tabs!=null&&n.tabs.length>1},kc=(e,t,n)=>{e=lt(e);const[,s]=zt(e,t);if((s==null?void 0:s.tabs)==null)throw Vs;return s.tabs=Le.rename(t,n,(s==null?void 0:s.tabs)??[]),e},mg=e=>e.tabs!=null?e.tabs.length===0:e.first==null&&e.last==null,To=(e,t)=>{const n=gs(e,t);if(n!=null)return n;const s=Math.floor(t/2);return s===0?e:To(e,s)},fg=e=>{let t=!0;for(;t;)[e,t]=$o(e);return e=Io(e,1),e},$o=e=>{if(e.first==null||e.last==null)return[e,!1];if(ai(e.first))return[ci(e.last),!0];if(ai(e.last))return[ci(e.first),!0];let t,n;return[e.first,t]=$o(e.first),[e.last,n]=$o(e.last),[e,t||n]},ci=e=>(e.size=void 0,e),ai=e=>e.first==null&&e.last==null&&(e.tabs==null||e.tabs.length===0),zt=(e,t)=>{if(e.tabs!=null){const l=e.tabs.find(c=>c.tabKey===t);if(l!=null)return[l,e]}if(e.first==null||e.last==null)return[void 0,void 0];const[n,s]=zt(e.first,t);if(n!=null&&s!=null)return[n,s];const[r,i]=zt(e.last,t);return[r,i]},gs=(e,t)=>{if(e.key===t)return e;if(e.first==null||e.last==null)return;const n=gs(e.first,t);return n??gs(e.last,t)},hg=e=>{switch(e){case"top":return["first","last","y"];case"left":return["first","last","x"];case"bottom":return["last","first","y"];case"right":return["last","first","x"];case"center":throw new Error("cannot split a center placed tab")}},lt=e=>ze.x.copy(e),js=(e,t,n=[])=>(n.push(t(e)),e.first!=null&&js(e.first,t,n),e.last!=null&&js(e.last,t,n),n),Ao=(e,t)=>{t(e),e.first!=null&&Ao(e.first,t),e.last!=null&&Ao(e.last,t)},Io=(e,t)=>(e=lt(e),e.key=t,e.first!=null&&(e.first=Io(e.first,t*2)),e.last!=null&&(e.last=Io(e.last,t*2+1)),e);class Mc{constructor(t={}){tt(this,"parent");tt(this,"stub");tt(this,"el");this.el=document.createElement("div"),Object.entries(t).forEach(([n,s])=>this.el.setAttribute(n,s))}mount(t,n){n!==this.stub&&(this.unmount(null),t.replaceChild(this.el,n),this.parent=t,this.stub=n)}unmount(t){t!=null&&t!==this.stub||this.parent==null||this.stub==null||(this.parent.replaceChild(this.stub,this.el),this.parent=void 0,this.stub=void 0)}}const gg=({node:e})=>{const t=g.createRef(),n=g.useRef(e);return g.useEffect(()=>{const s=t.current;if(s==null)return;const r=s.parentNode;if(r!=null)return e.mount(r,s),()=>{t.current!=null&&e.unmount(t.current)}},[]),g.useEffect(()=>{n.current!=null&&e!==n.current&&(n.current.unmount(t.current),n.current=e);const s=t.current;if(s==null)return;const r=s.parentNode;r!=null&&e.mount(r,s)},[e]),o.jsxRuntimeExports.jsx("div",{ref:t})},_c=({node:e,children:t})=>Sl.createPortal(t,e.el),jg=Object.freeze(Object.defineProperty({__proto__:null,In:_c,Node:Mc,Out:gg},Symbol.toStringTag,{value:"Module"})),Es=g.memo(({root:e,onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,activeTab:l,emptyContent:c,onSelect:a,onClose:x,onRename:d,onReorder:p,contextMenu:m,addTooltip:f,...h})=>{const{tabs:j,direction:y,first:S,last:b,key:E,size:C}=e,L={onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,onClose:x,contextMenu:m,onSelect:a,onRename:d,onReorder:p,activeTab:l,addTooltip:f},T=g.useCallback(([D])=>n(E,D),[n]),{props:P}=tr({direction:y,onResize:T,count:2,initialSizes:C!=null?[C]:void 0});let O={};E==1&&(O={...h,className:u.CSS(u.CSS.B("mosaic"))});let I;return j!==void 0?I=o.jsxRuntimeExports.jsx(Pc,{root:e,emptyContent:c,...O,...L}):S!=null&&b!=null?I=o.jsxRuntimeExports.jsxs(nr,{id:`mosaic-${E}`,align:"stretch",...P,...O,children:[o.jsxRuntimeExports.jsx(Es,{...L,root:S,onResize:n},S.key),o.jsxRuntimeExports.jsx(Es,{...L,root:b,onResize:n},b.key)]}):(I=null,console.warn("Mosaic tree is malformed")),I});Es.displayName="Mosaic";const ys="pluto-mosaic-tab-drop",Er="pluto-mosaic-tab-create",Eg=(e,t,n)=>{if(me.filterByType(me.FILE_TYPE,t).length>0&&n)return!0;const r=me.filterByType(ys,t).map(c=>c.key),i=e.filter(c=>!r.includes(c.tabKey)).length>0;return me.filterByType(Er,t).length>0||r.length>0&&(i||e.length===0)},Pc=g.memo(({root:e,onDrop:t,onCreate:n,activeTab:s,children:r,className:i,onReorder:l,onFileDrop:c,addTooltip:a,...x})=>{const{key:d,tabs:p}=e,[m,f]=g.useState(null),h=c!=null,j=g.useCallback(({items:I})=>Eg(p,I,h),[p,h]),y=g.useCallback(({items:I,event:D})=>{if(D==null)return[];const H=Sg(D);f(null);const B=me.filterByType(me.FILE_TYPE,I).length>0,{percents:_}=ui(D),R=p.length===0?"center":xi(_);if(B)return c==null||c(d,R,D),I;const k=me.filterByType(ys,I);if(k.length>0){const M=k.map(({key:A})=>A)[0];t(d,M,R,H)}const v=me.filterByType(Er,I);if(v.length>0){const M=v.map(({key:A})=>A);n==null||n(d,R,M)}return k},[t,p.length]),S=g.useCallback(({event:I})=>{if(I==null)return;const{percents:D,inSelector:H}=ui(I);let B=null;H||(B=p.length===0?"center":xi(D)),f(B)},[p.length]),{startDrag:b,...E}=me.useDragAndDrop({type:"Mosaic",canDrop:j,onDrop:y,onDragOver:S}),C=j(me.useDraggingState()),L=g.useCallback(()=>f(null),[]),T=g.useCallback((I,{tabKey:D})=>{b([{key:D,type:ys,elementID:I.currentTarget.id}])},[b]),P=g.useCallback(()=>n==null?void 0:n(d,"center"),[d]),O=d==1&&p.length==0;return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:o.jsxRuntimeExports.jsxs(Le.Tabs,{id:`tab-${d}`,tabs:p,className:u.CSS(i,O&&m!=null&&u.CSS.M("drag-over")),onDragLeave:L,selected:e.selected,selectedAltColor:s===e.selected,onDragStart:T,onCreate:P,addTooltip:a,...E,...x,children:[e.selected!=null&&r(p.find(I=>I.tabKey===e.selected)),C&&o.jsxRuntimeExports.jsx("div",{style:{zIndex:1e3,position:"absolute",top:0,left:0,width:"100%",height:"100%"}}),m!=null&&o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("mosaic","mask"),style:yg[m]})]})})});Pc.displayName="MosaicTabLeaf";const yg={top:{left:"0%",top:"0%",width:"100%",height:"50%"},bottom:{left:"0%",top:"50%",width:"100%",height:"50%"},left:{left:"0%",top:"0%",width:"50%",height:"100%"},right:{left:"50%",top:"0%",width:"50%",height:"100%"},center:{left:"0%",top:"0%",width:"100%",height:"100%"}},ui=e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;return s<24?{percents:{x:.5,y:.5},inSelector:!0}:{percents:{x:n/t.width,y:s/t.height},inSelector:!1}},Sg=e=>{var n;const t=e.target.closest(".pluto-tabs-selector__btn");if(t!=null)return Array.from(((n=t.parentElement)==null?void 0:n.children)??[]).indexOf(t)},Rg=e=>e,Cg=e=>1-e,xi=({x:e,y:t})=>{if(e>.33&&e<.66&&t>.33&&t<.66)return"center";const[n,s]=[Rg(e),Cg(e)];if(t>n&&t>s)return"bottom";if(t<n&&t<s)return"top";if(t>n&&t<s)return"left";if(t<n&&t>s)return"right";throw new Error("[bug] - invalid insert position")},wg=({root:e,onSelect:t,children:n})=>{const s=g.useRef(new Map),r=new Set,i=js(e,l=>{var c;return(c=l.tabs)==null?void 0:c.map(a=>{let x=s.current.get(a.tabKey);return a==null?null:(x==null&&(x=new Mc({style:"width: 100%; height: 100%; position: relative;"}),x.el.addEventListener("click",()=>t==null?void 0:t(a.tabKey)),s.current.set(a.tabKey,x)),r.add(a.tabKey),o.jsxRuntimeExports.jsx(_c,{node:x,children:n({...a,visible:a.tabKey===l.selected})},a.tabKey))})}).flat().filter(l=>l!=null);return s.current.forEach((l,c)=>!r.has(c)&&s.current.delete(c)),[s,i]},Do=pe.z.interface({key:pe.z.number(),tabs:pe.z.array(Le.tabZ).optional(),selected:pe.z.string().optional(),direction:u.g.direction.optional(),size:pe.z.number().optional(),get first(){return Do.optional()},get last(){return Do.optional()}}),bg=({allowRename:e=!1,initialTree:t})=>{const[n,s]=g.useState(t);return g.useEffect(()=>s(fs(t)[0]),[t]),{root:n,onDrop:(x,d,p)=>s(m=>bc(m,d,p,x)[0]),onClose:x=>s(d=>jr(d,x)[0]),onSelect:x=>s(d=>wc(d,x)),onResize:(x,d)=>s(p=>vc(p,x,d)),onRename:e?(x,d)=>s(p=>kc(p,x,d)):void 0}},vg=Object.freeze(Object.defineProperty({__proto__:null,HAUL_CREATE_TYPE:Er,HAUL_DROP_TYPE:ys,Mosaic:Es,autoSelectTabs:fs,canSplit:pg,findSelected:hs,findTabNode:kn,forEachNode:Ao,insertTab:ms,isEmpty:mg,mapNodes:js,moveTab:bc,nodeZ:Do,removeTab:jr,renameTab:kc,resizeNode:vc,selectTab:wc,split:dg,updateTab:xg,use:bg,usePortal:wg},Symbol.toStringTag,{value:"Module"})),kg=({variant:e,className:t,...n})=>o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(t,u.CSS.B("note"),u.CSS.M(e)),align:"stretch",empty:!0,...n}),Mg=Object.freeze(Object.defineProperty({__proto__:null,Note:kg},Symbol.toStringTag,{value:"Module"})),fo={Close:o.jsxRuntimeExports.jsxs("svg",{width:"124",height:"124",viewBox:"0 0 124 124",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsxRuntimeExports.jsx("rect",{x:"26.8701",y:"88.3883",width:"87",height:"11",transform:"rotate(-45 26.8701 88.3883)",fill:"#7E0508"}),o.jsxRuntimeExports.jsx("rect",{x:"26.8701",y:"34.6482",width:"11",height:"87",transform:"rotate(-45 26.8701 34.6482)",fill:"#7E0508"})]}),Minimize:o.jsxRuntimeExports.jsx("svg",{width:"87",height:"11",viewBox:"0 0 87 11",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsxRuntimeExports.jsx("rect",{x:"15",width:"60",height:"11",fill:"#985712"})}),Maximize:o.jsxRuntimeExports.jsxs("svg",{width:"143",height:"143",viewBox:"0 0 143 143",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsxRuntimeExports.jsx("path",{d:"M108.242 32.8833C108.797 32.8817 109.247 33.3317 109.245 33.8862L109.092 87.5891C109.09 88.4786 108.014 88.9223 107.385 88.2933L53.8351 34.7432C53.2061 34.1142 53.6499 33.0387 54.5394 33.0361L108.242 32.8833Z",fill:"#0B650D"}),o.jsxRuntimeExports.jsx("path",{d:"M33.8862 109.245C33.3317 109.247 32.8818 108.797 32.8833 108.242L33.0361 54.5394C33.0387 53.6499 34.1142 53.2061 34.7432 53.8351L88.2934 107.385C88.9223 108.014 88.4786 109.09 87.5891 109.092L33.8862 109.245Z",fill:"#0B650D"})]})},_g=({disabled:e=[],className:t,focused:n=!0,onMinimize:s,onMaximize:r,onFullscreen:i,onClose:l,...c})=>o.jsxRuntimeExports.jsxs(ne.Space,{size:1.5,x:!0,className:u.CSS(u.CSS.B("macos-controls"),!n&&u.CSS.BM("macos-controls","blurred"),t),...c,children:[o.jsxRuntimeExports.jsx(ho,{onClick:l,className:u.CSS.BM("macos-control","close"),disabled:e.includes("close"),children:fo.Close}),o.jsxRuntimeExports.jsx(ho,{onClick:s,className:u.CSS.BM("macos-control","minimize"),disabled:e.includes("minimize"),children:fo.Minimize}),o.jsxRuntimeExports.jsx(ho,{onClick:i,className:u.CSS.BM("macos-control","maximize"),disabled:e.includes("maximize"),children:fo.Maximize})]}),ho=({className:e,disabled:t,color:n,...s})=>o.jsxRuntimeExports.jsx("button",{className:u.CSS(u.CSS.B("macos-control"),u.CSS.disabled(t),e),tabIndex:-1,disabled:t,size:"",...s}),Pg=({disabled:e=[],onMinimize:t,onMaximize:n,onClose:s,onFullscreen:r,focused:i,shade:l=2,...c})=>o.jsxRuntimeExports.jsxs(Ts.Pack,{...c,children:[o.jsxRuntimeExports.jsx(go,{className:u.CSS.BM("windows-control","minimize"),onClick:t,disabled:e.includes("minimize"),shade:l,children:o.jsxRuntimeExports.jsx(Z.y4.Subtract,{})}),o.jsxRuntimeExports.jsx(go,{className:u.CSS.BM("windows-control","maximize"),onClick:n,disabled:e.includes("maximize"),shade:l,children:o.jsxRuntimeExports.jsx(Z.y4.Box,{})}),o.jsxRuntimeExports.jsx(go,{onClick:s,className:u.CSS.BM("windows-control","close"),disabled:e.includes("close"),shade:l,children:o.jsxRuntimeExports.jsx(Z.y4.Close,{})})]}),go=({disabled:e=!1,className:t,...n})=>e?null:o.jsxRuntimeExports.jsx(he.Icon,{className:u.CSS(u.CSS.B("windows-control"),t),tabIndex:-1,...n}),Lc=u.S.getOS,Lg="Windows",Ng=({forceOS:e,visibleIfOS:t,...n})=>{const s=Lc({force:e,default:Lg});if(t!=null&&t!==s)return null;const r=s==="macOS"?_g:Pg;return o.jsxRuntimeExports.jsx(r,{...n})},Tg=Object.freeze(Object.defineProperty({__proto__:null,Controls:Ng,use:Lc},Symbol.toStringTag,{value:"Module"})),$g=(e,t)=>{const n=s=>o.jsxRuntimeExports.jsx(e,{...t,...s});return n.displayName=e.displayName,n},Ag=Object.freeze(Object.defineProperty({__proto__:null,createComponent:$g},Symbol.toStringTag,{value:"Module"}));g.createContext({instrumentation:nt.C.NOOP});const Ig=({children:e,...t})=>{const{path:n}=Q.useUnidirectional({type:xs.Provider.TYPE,schema:xs.providerStateZ,state:t});return o.jsxRuntimeExports.jsx(Q.Composite,{path:n,children:e})},Dg="data:video/mp2t;base64,Ly8gQ29weXJpZ2h0IDIwMjUgU3lubmF4IExhYnMsIEluYy4KLy8KLy8gVXNlIG9mIHRoaXMgc29mdHdhcmUgaXMgZ292ZXJuZWQgYnkgdGhlIEJ1c2luZXNzIFNvdXJjZSBMaWNlbnNlIGluY2x1ZGVkIGluIHRoZSBmaWxlCi8vIGxpY2Vuc2VzL0JTTC50eHQuCi8vCi8vIEFzIG9mIHRoZSBDaGFuZ2UgRGF0ZSBzcGVjaWZpZWQgaW4gdGhhdCBmaWxlLCBpbiBhY2NvcmRhbmNlIHdpdGggdGhlIEJ1c2luZXNzIFNvdXJjZQovLyBMaWNlbnNlLCB1c2Ugb2YgdGhpcyBzb2Z0d2FyZSB3aWxsIGJlIGdvdmVybmVkIGJ5IHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAsCi8vIGluY2x1ZGVkIGluIHRoZSBmaWxlIGxpY2Vuc2VzL0FQTC50eHQuCgppbXBvcnQgeyBwbHV0byB9IGZyb20gIkAvcGx1dG8vYWV0aGVyIjsKCnBsdXRvLnJlbmRlcigpOwo=",Nc=({children:e})=>{const{path:t}=Q.useUnidirectional({type:z.BaseProvider.TYPE,schema:z.providerStateZ$1,state:{}});return o.jsxRuntimeExports.jsx(Q.Composite,{path:t,children:e})},zg=Object.freeze(Object.defineProperty({__proto__:null,Provider:Nc},Symbol.toStringTag,{value:"Module"})),Bg=Object.freeze(Object.defineProperty({__proto__:null,AcquireChannelControl:z.AcquireChannelControl,AuthoritySource:z.AuthoritySource,Chip:z.Chip,Controller:z.Controller,Indicator:z.Indicator,Legend:z.Legend,REGISTRY:z.REGISTRY$16,STATUSES:z.STATUSES,SetChannelValue:z.SetChannelValue,StateProvider:z.StateProvider,acquireChannelControl:z.acquireChannelControl,acquireChannelControlPropsZ:z.acquireChannelControlPropsZ,authoritySource:z.authoritySource,authoritySourceProps:z.authoritySourceProps,chipStateZ:z.chipStateZ,controllerStateZ:z.controllerStateZ,indicatorStateZ:z.indicatorStateZ,legendStateZ:z.legendStateZ,setChannelValue:z.setChannelValue,setChannelValuePropsZ:z.setChannelValuePropsZ,stateProviderStateZ:z.stateProviderStateZ,statusZ:z.statusZ,sugaredStateZ:z.sugaredStateZ},Symbol.toStringTag,{value:"Module"})),Og=e=>{var t,n;switch(e.variant){case"disabled":return((t=e.data)==null?void 0:t.valid)===!0?{message:"Uncontrolled. Click to take control.",chipColor:"var(--pluto-gray-l12)"}:{message:"No channel connected. This element cannot be controlled.",chipColor:"var(--pluto-gray-l7)",disabled:!0};case"error":return{message:"Not controlled by you. Click to take absolute control.",chipColor:"var(--pluto-error-z)"};case"success":return((n=e.data)==null?void 0:n.authority)===nt.Gv.ABSOLUTE_AUTHORITY?{message:"You have absolute control. Click to release.",chipColor:"var(--pluto-secondary-z)",buttonStyle:{background:"var(--pluto-secondary-z-30)"}}:{message:"You're in control. Release P&ID to release control.",chipColor:"var(--pluto-primary-z)"};default:return{message:"Unexpected status.",chipColor:"var(--pluto-error-z)"}}},Tc=({source:e,sink:t,className:n,...s})=>{const r=Ne.useMemoDeepEqualProps({source:e,sink:t}),[,{status:i},l]=Q.use$1({type:z.Chip.TYPE,schema:z.chipStateZ,initialState:{triggered:!1,...r,status:{key:"no_chip",variant:"disabled",message:"No chip connected.",time:u.m.now()}}});g.useEffect(()=>{l(m=>({...m,...r}))},[r,l]);const c=g.useCallback(()=>l(m=>({...m,triggered:!m.triggered})),[l]),{message:a,chipColor:x,buttonStyle:d,disabled:p}=Og(i);return o.jsxRuntimeExports.jsx(he.Icon,{variant:"text",className:u.CSS(u.CSS.B("control-chip"),n),disabled:p,onClick:c,tooltip:o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:a}),style:d,...s,children:o.jsxRuntimeExports.jsx(Z.y4.Circle,{color:x})})},$c=g.createContext({needsControlOf:[]}),Ac=()=>g.use($c),Vg=({children:e,onStatusChange:t,...n})=>{const s=Ne.useMemoDeepEqualProps(n),[{path:r},{status:i,needsControlOf:l},c]=Q.use$1({type:z.Controller.TYPE,schema:z.controllerStateZ,initialState:s});return g.useEffect(()=>{i!=null&&(t==null||t(i))},[i,t]),g.useEffect(()=>{c(a=>({...a,...s}))},[s,c]),g.useEffect(()=>()=>t==null?void 0:t("released"),[]),o.jsxRuntimeExports.jsxs($c,{value:{needsControlOf:l},children:[o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:e}),";"]})},Ic=({colorSource:e,statusSource:t})=>{var c;const n=Ne.useMemoDeepEqualProps({colorSource:e,statusSource:t}),[,{color:s,status:r},i]=Q.use$1({type:z.Indicator.TYPE,initialState:{...n,status:{key:"no_chip",variant:"warning",message:"No chip connected.",time:u.m.now()}},schema:z.indicatorStateZ});g.useEffect(()=>{i(a=>({...a,...n}))},[n,i]);let l;return((c=r.data)==null?void 0:c.color)!=null?l=u.Dt.colorZ.parse(r.data.color):s!=null&&!u.Dt.isZero(s)?l=s:l="var(--pluto-gray-l10)",o.jsxRuntimeExports.jsxs(he.Dialog,{location:{x:"center",y:"bottom"},children:[o.jsxRuntimeExports.jsx(Z.Text,{level:"p",children:r.message}),o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("indicator"),style:{backgroundColor:u.Dt.cssString(l),flexGrow:1}})]})},Fg=e=>{const{needsControlOf:t}=Ac(),[,{states:n},s]=Q.use$1({type:z.Legend.TYPE,schema:z.legendStateZ,initialState:{states:[],needsControlOf:t}});g.useEffect(()=>{s(l=>({...l,needsControlOf:t}))},[t]);const i=u.c$1.unique(n.map(l=>l.subject.key)).map(l=>{const c=n.find(a=>a.subject.key===l);if(c==null)throw new nt.Qt("Legend subject not found");return{key:c.subject.key,label:c.subject.name,color:c.subjectColor}});return o.jsxRuntimeExports.jsx(lr,{data:i,...e})},Dc=({children:e})=>{const[{path:t}]=Q.use$1({type:z.StateProvider.TYPE,schema:z.stateProviderStateZ,initialState:{}});return o.jsxRuntimeExports.jsx(Q.Composite,{path:t,children:e})},Hg=Object.freeze(Object.defineProperty({__proto__:null,Chip:Tc,Controller:Vg,Indicator:Ic,Legend:Fg,StateProvider:Dc,useContext:Ac},Symbol.toStringTag,{value:"Module"})),zc=e=>{const t=({disabled:n=!1,...s})=>n?s.children:o.jsxRuntimeExports.jsx(e,{...s});return t.displayName=e.displayName,t},Zg=zc(Nc),Wg=zc(Q.Provider$2),Yg=({children:e,connParams:t,workerEnabled:n=!0,workerURL:s,theming:r,tooltip:i,triggers:l,alamos:c,haul:a,channelAlias:x,telem:d,color:p})=>o.jsxRuntimeExports.jsx(Ie.Provider,{...l,children:o.jsxRuntimeExports.jsx(he.Config,{...i,children:o.jsxRuntimeExports.jsx(me.Provider,{...a,children:o.jsxRuntimeExports.jsx(Q.Provider$1,{url:s??Dg,enabled:n,children:o.jsxRuntimeExports.jsx(Wg,{workerKey:"vis",children:o.jsxRuntimeExports.jsx(Ig,{...c,children:o.jsxRuntimeExports.jsx(Re.Aggregator,{children:o.jsxRuntimeExports.jsx(Ll,{connParams:t,children:o.jsxRuntimeExports.jsx($l,{...x,children:o.jsxRuntimeExports.jsx(Ke.Provider,{...p,children:o.jsxRuntimeExports.jsx(Q.Provider,{...r,children:o.jsxRuntimeExports.jsx(Zg,{...d,children:o.jsxRuntimeExports.jsx(Dc,{children:e})})})})})})})})})})})})}),Gg=Object.freeze(Object.defineProperty({__proto__:null,Provider:Yg},Symbol.toStringTag,{value:"Module"})),Kg=({value:e})=>o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("progress"),children:o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("progress-bar"),style:{width:`${e}%`}})}),qg=Object.freeze(Object.defineProperty({__proto__:null,Progress:Kg},Symbol.toStringTag,{value:"Module"})),Mn="range",yr=[{key:"name",name:"Name"}],Ss=({items:e},t)=>{const n=me.filterByType(Mn,e);return n.length>0&&!n.every(s=>t.includes(s.key))},Xg=({onChange:e,className:t,value:n,...s})=>{const r=qe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=me.useDragAndDrop({type:"Ranger.SelectMultiple",canDrop:g.useCallback(m=>Ss(m,Me.A(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=me.filterByType(Mn,m);if(f.length===0)return[];const h=u.c$1.unique([...Me.A(n),...f.map(j=>j.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),x=me.useDraggingState(),d=g.useCallback(({dropped:m})=>{e(Me.A(n).filter(f=>!m.some(h=>h.key===f)),{clickedIndex:null,clicked:null,entries:[]})},[e,n]),p=g.useCallback((m,f)=>l([{key:f,type:Mn}],d),[l,d]);return o.jsxRuntimeExports.jsx(cn,{className:u.CSS(t,u.CSS.dropRegion(Ss(x,Me.A(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.ranges,onChange:e,columns:yr,emptyContent:i,entryRenderKey:"name",...a,...s})},Bc=({value:e,onChange:t})=>{const n=qe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),r=g.useId(),i=g.useMemo(()=>({key:r,type:"Ranger.SelectMultiple"}),[r]),{startDrag:l,...c}=me.useDragAndDrop({type:"Ranger.SelectSingle",canDrop:g.useCallback(d=>Ss(d,Me.o(e)),[e]),onDrop:g.useCallback(({items:d})=>{const p=me.filterByType(Mn,d);return p.length===0?[]:(t(p[0].key,{clickedIndex:null,clicked:null,entries:[]}),p)},[i,t])}),a=me.useDraggingState(),x=g.useCallback(()=>e!=null&&l([{type:Mn,key:e}]),[l,e]);return{emptyContent:s,dragging:a,...c,onDragStart:x,searcher:n==null?void 0:n.ranges}},Ug=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=Bc({value:t,onChange:e});return o.jsxRuntimeExports.jsx(ft,{data:s,className:u.CSS(n,u.CSS.dropRegion(Ss(i,Me.o(t)))),value:t,onChange:e,columns:yr,entryRenderKey:"name",...l,...r})},Jg=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=Bc({value:t,onChange:n});return o.jsxRuntimeExports.jsx(ft,{data:e,value:t,onChange:n,columns:yr,entryRenderKey:"name",...i,...s})},Qg=[{key:"color",name:"Color",width:50,render:e=>o.jsxRuntimeExports.jsx(Z.y4.Circle,{style:{fontSize:10,marginLeft:10,marginRight:30},color:e.entry.color})},{key:"name",name:"Name"}],e0=e=>{const t=qe();return o.jsxRuntimeExports.jsx(cn,{...e,searcher:t==null?void 0:t.labels,columns:Qg,renderTag:n=>n.entry==null?o.jsxRuntimeExports.jsx(vn,{color:"gray",children:n.entryKey}):o.jsxRuntimeExports.jsx(vn,{color:n.entry.color,children:n.entry.name})})},t0=({timeRange:e,level:t="p",shade:n=9,showSpan:s=!1,labeled:r=!1,...i})=>{const l=new u.m(e.start),c=l.isToday?"time":"dateTime",a=new u.m(e.end),x=a.equals(u.m.MAX),d=a.span(l)<u.O.DAY?"time":"dateTime",p=l.span(a);let m=o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",size:"small",children:[l.isToday&&o.jsxRuntimeExports.jsx(Z.Text,{level:t,shade:n,weight:450,children:"Today"}),o.jsxRuntimeExports.jsx(_o.DateTime,{level:t,displayTZ:"local",format:c,shade:n,weight:450,children:l})]}),f=o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[x?o.jsxRuntimeExports.jsx(Z.Text,{level:t,children:"Now"}):o.jsxRuntimeExports.jsx(_o.DateTime,{level:t,displayTZ:"local",format:d,shade:n,weight:450,children:a}),!p.isZero&&s&&o.jsxRuntimeExports.jsxs(Z.Text,{level:t,shade:n,weight:450,children:["(",l.span(a).truncate(u.O.MILLISECOND).toString(),")"]})]});r&&(m=o.jsxRuntimeExports.jsx(ge.Item,{label:"Start",showHelpText:!1,children:m}),f=o.jsxRuntimeExports.jsx(ge.Item,{label:"End",showHelpText:!1,children:f}));const h=u.CSS.levelSizeVar(t);return o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,size:"small",className:u.CSS(u.CSS.B("time-range-chip")),align:"center",...i,children:[m,o.jsxRuntimeExports.jsx(Z.y4.Arrow.Right,{color:"var(--pluto-gray-l9)",style:{width:h,height:h}}),f]})},n0=Object.freeze(Object.defineProperty({__proto__:null,SelectButton:Jg,SelectLabels:e0,SelectMultiple:Xg,SelectSingle:Ug,TimeRangeChip:t0},Symbol.toStringTag,{value:"Module"})),s0=({steps:e,value:t,onChange:n,...s})=>{const r=e.findIndex(i=>i.key===t);return o.jsxRuntimeExports.jsx(ne.Space,{x:!0,align:"center",className:u.CSS.B("steps"),...s,children:e.map((i,l)=>o.jsxRuntimeExports.jsxs(g.Fragment,{children:[o.jsxRuntimeExports.jsxs(he.Button,{onClick:()=>n(i.key),variant:"outlined",disabled:l>r,children:[l+1,". ",i.title]},i.key),l!==e.length-1&&o.jsxRuntimeExports.jsx(Z.y4.Arrow.Right,{style:{fontSize:"15px",color:"var(--pluto-gray-l10)"}})]},i.key))})},o0=Object.freeze(Object.defineProperty({__proto__:null,Steps:s0},Symbol.toStringTag,{value:"Module"})),r0=({children:e,className:t,visible:n,...s})=>{const[{path:r},,i]=Q.use$1({type:z.Table.TYPE,schema:z.Table.stateZ,initialState:{region:u.$t.ZERO,visible:n}});g.useEffect(()=>{i(c=>({...c,visible:n}))},[n]);const l=Dn(c=>i(a=>({...a,region:c})));return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx("div",{ref:l,style:{right:0,bottom:0,position:"absolute",top:6,left:6}}),o.jsxRuntimeExports.jsx("table",{className:u.CSS(u.CSS.B("table"),t),...s,children:o.jsxRuntimeExports.jsx("tbody",{children:o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:e})})})]})},i0=({children:e,className:t,size:n,index:s,onResize:r,onSelect:i,position:l,...c})=>o.jsxRuntimeExports.jsxs("tr",{className:u.CSS(u.CSS.BE("table","row"),t),...c,children:[r!=null&&o.jsxRuntimeExports.jsx(Vc,{onSelect:i,index:s,value:n,onChange:r,position:l,direction:"y"}),e]}),Sr=({ref:e,children:t,className:n,selected:s=!1,...r})=>o.jsxRuntimeExports.jsx("td",{ref:e,...r,className:u.CSS(u.CSS.BE("table","cell"),u.CSS.selected(s),n),children:t}),Oc="ABCDEFGHIJKLMNOPQRSTUVWXYZ",l0=e=>Oc[e],Vc=({value:e,selected:t=!1,index:n,onChange:s,position:r,direction:i="x",onSelect:l})=>{const c=Z.useSyncedRef(e),a=g.useRef(e),x=Ke.useCursorDrag({onStart:g.useCallback(()=>{a.current=c.current},[]),onMove:g.useCallback(d=>s(a.current+u.$t.dim(d,i,!0),n),[s,n])});return o.jsxRuntimeExports.jsxs("td",{id:`resizer-${i}-${n}`,className:u.CSS(u.CSS.BE("table","resizer"),u.CSS.dir(i),u.CSS.selected(t),kt.CONTEXT_TARGET,t&&kt.CONTEXT_SELECTED),style:{[u.g.dimension(i)]:e},onClick:()=>l(n),onContextMenu:()=>l(n),children:[o.jsxRuntimeExports.jsx(Z.Text,{level:"p",shade:11,style:{width:"100%",textAlign:"center"},children:i==="x"?Oc[n]:n+1}),o.jsxRuntimeExports.jsx("button",{onClick:d=>d.stopPropagation(),style:{[u.g.location(i)]:r+e},onDragStart:x,draggable:!0})]})},c0=({selected:e,onSelect:t,columns:n,onResize:s})=>{let r=15;return o.jsxRuntimeExports.jsxs("tr",{className:u.CSS(u.CSS.BE("table","row"),u.CSS.BE("table","col-resizer")),children:[o.jsxRuntimeExports.jsx("td",{}),n.map((i,l)=>{const c=r;return r+=i,o.jsxRuntimeExports.jsx(Vc,{onSelect:t,position:c,selected:e.includes(l),index:l,value:i,onChange:a=>s(a,l),direction:"x"},l)})]})},a0=Object.freeze(Object.defineProperty({__proto__:null,Cell:Sr,ColumnIndicators:c0,Row:i0,Table:r0,getCellColumn:l0},Symbol.toStringTag,{value:"Module"})),u0=[{key:"standard",name:"Standard"},{key:"scientific",name:"Scientific"},{key:"engineering",name:"Engineering"}],x0=e=>o.jsxRuntimeExports.jsx(it,{...e,entryRenderKey:"name",data:u0}),Fc=[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],Rr=({path:e})=>{var f;const{value:t,onChange:n}=_t({path:e}),s=z.sourcePipelinePropsZ.parse((f=t.telem)==null?void 0:f.props),r=z.streamChannelValuePropsZ.parse(s.segments.valueStream.props),i=z.stringifyNumberProps.parse(s.segments.stringifier.props),l=z.rollingAverageProps.parse(s.segments.rollingAverage.props),c=h=>{const j=z.sourcePipeline("string",{connections:Fc,segments:{valueStream:z.streamChannelValue({channel:r.channel}),stringifier:z.stringifyNumber({precision:i.precision??2,notation:i.notation}),rollingAverage:z.rollingAverage({windowSize:l.windowSize??1}),...h},outlet:"stringifier"});n({...t,telem:j})},a=h=>c({valueStream:z.streamChannelValue({channel:h??0})}),x=h=>c({stringifier:z.stringifyNumber({...i,notation:h})}),d=h=>c({stringifier:z.stringifyNumber({...i,precision:h})}),p=h=>c({rollingAverage:z.rollingAverage({windowSize:h})}),m=As(r.channel);return g.useEffect(()=>n({...t,tooltip:[m]}),[m]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(ge.Item,{label:"Input Channel",grow:!0,children:o.jsxRuntimeExports.jsx(Dt,{value:r.channel,onChange:a})}),o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,children:[o.jsxRuntimeExports.jsx(ge.Item,{label:"Notation",children:o.jsxRuntimeExports.jsx(x0,{value:i.notation,onChange:x})}),o.jsxRuntimeExports.jsx(ge.Item,{label:"Precision",align:"start",children:o.jsxRuntimeExports.jsx(ge.Numeric,{value:i.precision??2,bounds:{lower:0,upper:10},onChange:d})}),o.jsxRuntimeExports.jsx(ge.Item,{label:"Averaging Window",align:"start",children:o.jsxRuntimeExports.jsx(ge.Numeric,{value:l.windowSize??1,bounds:{lower:1,upper:100},onChange:p})})]})]})},d0=z.Value.z.partial({color:!0}).extend({level:st.levelZ.optional()}),Cr=({aetherKey:e,box:t,telem:n,color:s,precision:r,minWidth:i,level:l="small",backgroundTelem:c,notation:a,location:x})=>{const d=Ne.useMemoDeepEqualProps({box:t,telem:n,color:s,precision:r,level:l,minWidth:i,notation:a,backgroundTelem:c,location:x}),[,p,m]=Q.use$1({aetherKey:e,type:z.Value.TYPE,schema:z.Value.z,initialState:d});return g.useEffect(()=>m(f=>({...f,...d})),[d]),{width:p.width??p.minWidth}},p0=Object.freeze(Object.defineProperty({__proto__:null,TelemForm:Rr,VALUE_CONNECTIONS:Fc,corePropsZ:d0,use:Cr},Symbol.toStringTag,{value:"Module"})),m0=pe.z.object({value:pe.z.string(),level:st.levelZ,weight:st.weightZ,align:u.K.x.or(u.K.center),backgroundColor:u.Dt.crudeZ}),f0=({cellKey:e,onChange:t,value:n,selected:s,onSelect:r,align:i,level:l,weight:c,backgroundColor:a})=>{const x=p=>r(e,p),d=p=>t({level:l,value:p,weight:c,align:i,backgroundColor:a});return o.jsxRuntimeExports.jsx(Sr,{id:e,className:u.CSS(kt.CONTEXT_TARGET,s&&kt.CONTEXT_SELECTED,u.CSS.BEM("table","cell","text")),selected:s,onClick:x,onContextMenu:x,style:{backgroundColor:u.Dt.cssString(a)},children:o.jsxRuntimeExports.jsx(Z.Editable,{level:l,value:n,weight:c,onChange:d,style:{justifyContent:i},allowEmpty:!0,outline:!1})})},h0=pe.z.object({telem:z.stringSourceSpecZ,redline:pe.z.object({bounds:u.G.bounds,gradient:u.Dt.gradientZ}),level:st.levelZ,color:pe.z.string(),units:pe.z.string()}),g0=({cellKey:e,telem:t,level:n,color:s,redline:{gradient:r,bounds:i},selected:l,box:c,onSelect:a})=>{const{width:x}=Cr({aetherKey:e,box:c,telem:t,level:n,color:s,backgroundTelem:z.sourcePipeline("color",{connections:[{from:"source",to:"scale"},{from:"scale",to:"gradient"}],segments:{source:t,scale:z.scaleNumber({scale:u.b.Scale.scale(i).scale(0,1).transform}),gradient:z.colorGradient({gradient:r})},outlet:"gradient"}),location:{x:"center",y:"center"}}),d=p=>a(e,p);return o.jsxRuntimeExports.jsx(Sr,{id:e,selected:l,onClick:d,onContextMenu:d,style:{height:"5rem",width:x},className:u.CSS(kt.CONTEXT_TARGET,l&&kt.CONTEXT_SELECTED,u.CSS.BEM("table","cell","value"))})},j0=({onVariantChange:e})=>{const t=g.useCallback(({tabKey:s})=>{switch(s){case"telem":return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(Rr,{path:""})});case"redline":return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(E0,{})});default:return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,grow:!0,empty:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,children:[o.jsxRuntimeExports.jsx(ge.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Hc,{onChange:e,value:"value"})}),o.jsxRuntimeExports.jsx(Ce,{hideIfNull:!0,label:"Color",align:"start",padHelpText:!1,path:"color",children:({value:r,onChange:i,variant:l,...c})=>o.jsxRuntimeExports.jsx(Ke.Swatch,{value:r??u.Dt.setAlpha(u.Dt.ZERO,1),onChange:i,...c,bordered:!0})}),o.jsxRuntimeExports.jsx(Ce,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:r=>o.jsxRuntimeExports.jsx(an,{...r})})]})})}},[]),n=Le.useStatic({tabs:[{tabKey:"style",name:"Style"},{tabKey:"telem",name:"Telemetry"},{tabKey:"redline",name:"Redline"}],content:t});return o.jsxRuntimeExports.jsx(Le.Tabs,{...n})},E0=()=>{const{set:e,get:t}=ht(),n=hc("redline.bounds"),s=u.b.Scale.scale(0,1).scale(n);return o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,grow:!0,children:[o.jsxRuntimeExports.jsx(Ze,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Lower",path:"redline.bounds.lower"}),o.jsxRuntimeExports.jsx(Ce,{path:"redline.gradient",label:"Gradient",align:"start",padHelpText:!1,children:({value:r,onChange:i})=>o.jsxRuntimeExports.jsx(Ke.GradientPicker,{value:ze.x.copy(r),scale:s,onChange:l=>{const a={...t("redline.bounds").value},x=l.map(j=>j.position),d=s.pos(Math.max(...x)),p=s.pos(Math.min(...x)),m=d>a.upper,f=p<a.lower;m&&(l[l.length-1].position=1,a.upper=d),f&&(l[0].position=0,a.lower=p);const h=l.map(j=>({...j,color:u.Dt.hex(j.color)}));m||f?e("redline",{bounds:a,gradient:h}):i(l.map(j=>({...j,color:u.Dt.hex(j.color)})))}})}),o.jsxRuntimeExports.jsx(Ze,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Upper",path:"redline.bounds.upper"})]})},y0=({onVariantChange:e})=>o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,grow:!0,style:{padding:"2rem"},children:[o.jsxRuntimeExports.jsx(ge.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Hc,{onChange:e,value:"text"})}),o.jsxRuntimeExports.jsx(fr,{path:"value",label:"Text"}),o.jsxRuntimeExports.jsx(Ce,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(an,{...t})}),o.jsxRuntimeExports.jsx(Ce,{path:"weight",label:"Weight",padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(nc,{...t})}),o.jsxRuntimeExports.jsx(Ce,{path:"align",label:"Alignment",hideIfNull:!0,children:t=>o.jsxRuntimeExports.jsx(zs,{...t})}),o.jsxRuntimeExports.jsx(Ce,{path:"backgroundColor",label:"Background",align:"start",padHelpText:!1,children:({value:t,onChange:n})=>o.jsxRuntimeExports.jsx(Ke.Swatch,{value:t,onChange:n})})]}),S0=[{key:"text",name:"Text"},{key:"value",name:"Value"}],Hc=e=>o.jsxRuntimeExports.jsx(it,{...e,data:S0,allowMultiple:!1,entryRenderKey:"name"}),R0=["text","value"],C0=pe.z.enum(R0),w0={key:"value",name:"Value",Form:j0,Cell:g0,defaultProps:e=>({telem:z.sourcePipeline("string",{connections:[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],segments:{valueStream:z.streamChannelValue({channel:0}),rollingAverage:z.rollingAverage({windowSize:1}),stringifier:z.stringifyNumber({precision:2,notation:"standard"})},outlet:"stringifier"}),redline:{bounds:{lower:0,upper:1},gradient:[]},color:u.Dt.hex(e.colors.gray.l10),level:"h5",units:""}),schema:h0},b0={key:"text",name:"Text",Form:y0,Cell:f0,defaultProps:()=>({value:"",level:"h5",units:"",weight:400,align:"center",backgroundColor:"#00000000"}),schema:m0},v0={text:b0,value:w0},k0=Object.freeze(Object.defineProperty({__proto__:null,CELLS:v0,variantZ:C0},Symbol.toStringTag,{value:"Module"})),di=({sourcePos:e,targetPos:t,next:n,prev:s})=>{const r=Tt(e,...n);return u.J.distance(r,t)<1?!0:(console.warn("Connector is out of sync with target"),console.log("Theoretical target",r),console.log("Actual target",t),console.log("Segments",n),console.log("Prev segments",s),!1)},pi=({sourceStumpTip:e,sourceOrientation:t,sourceBox:n,targetStumpTip:s,targetOrientation:r,targetBox:i})=>{if(!M0({sourcePos:e,sourceOrientation:t,targetPos:s}))return;const l=u.g.construct(t),c=u.g.swap(l);let a=At(c,s[c]-e[c]);const x=u.$t.loc(n,a);if(u.K.swap(t)===r){const d=u.$t.loc(i,u.K.swap(a));Math.abs(x-d)<Fe&&(a=u.K.swap(a))}return{direction:c,length:x-e[c]+Bt(a,Fe)}},zo=pe.z.object({direction:u.g.direction,length:pe.z.number()}),Tt=(e,...t)=>{let n=e;for(const s of t)n=u.J.translate(n,s.direction,s.length);return n},Zc=(e,t,n,s)=>{try{let r=e;const i=[e,...t.map(f=>(r=u.J.translate(r,f.direction,f.length),r))];if(!s)return i;const l=t[0],c=At(l.direction,l.length),a=mi(c),x=4*(2-n**.5);i[0]=u.J.translate(i[0],{[l.direction]:-1*a*x,[u.g.swap(l.direction)]:0});const d=t[t.length-1],p=At(d.direction,d.length),m=mi(p);return i[i.length-1]=u.J.translate(i[i.length-1],{[d.direction]:m*x,[u.g.swap(d.direction)]:0}),i}catch{return[]}},Fe=10,mi=e=>e==="top"||e==="left"?-1:1,Bt=(e,t)=>e==="top"||e==="left"?-t:t,At=(e,t)=>e==="x"?t>0?"right":"left":t>0?"bottom":"top",Ct=e=>At(e.direction,e.length),M0=({sourcePos:e,targetPos:t,sourceOrientation:n})=>{const s=u.g.construct(n),r=t[s]-e[s];return Bt(n,r)<0},Kn=e=>({direction:u.g.construct(e),length:Bt(e,Fe)}),fi={top:Kn("top"),bottom:Kn("bottom"),left:Kn("left"),right:Kn("right")},_0=4,P0=.25,Fs=e=>Bo(L0(Bo(e))),L0=e=>{const t=[...e],n=e.findIndex((s,r)=>{const i=Math.abs(s.length);if(i<_0){if(r===0||r===e.length-1)return!1;if(i<P0)return!0;if(e.length<=3)return!1;if(r+2<e.length){const l=t[r+2];if(l.direction!==s.direction)return!1;t[r+2]={...l,length:l.length+s.length}}else{const l=t[r-2];if(l.direction!==s.direction)return!1;t[r-2]={...l,length:l.length+s.length}}return!0}return!1});return n!==-1&&t.splice(n,1),t},Bo=e=>{const t=[...e];return e.findIndex((s,r)=>{const i=t[r-1];if(r===0||s.direction!==i.direction)return!1;if(r===1){const l=r-1,c=r,a=Ct(i),x=Ct(s);if(a===x)return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0;if(Math.abs(i.length)===Fe)return!1;const d=Bt(a,Fe),p=t[l].length-d,m=t[c].length+p;return Math.abs(m)<Fe?!1:(t[l]={...t[l],length:d},t[c]={...t[c],length:m},!0)}if(r===e.length-1){const l=r,c=r-1,a=Ct(s),x=Ct(i);if(a===x)return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0;if(Math.abs(s.length)===Fe)return!1;const d=Bt(a,Fe),p=t[l].length-d,m=t[c].length+p;return Math.abs(m)<Fe?!1:(t[l]={...t[l],length:d},t[c]={...t[c],length:m},!0)}return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0})!==-1?Bo(t):t},qt=e=>Fs(N0(e)),N0=({sourceBox:e,targetBox:t,sourcePos:n,targetPos:s,targetOrientation:r,sourceOrientation:i})=>{let l=i,c=r,a={...fi[i]},x=Tt(n,a);const d={...fi[r]};let p=Tt(s,d);const m=Math.abs(x.x-p.x),f=Math.abs(x.y-p.y);m<2*Fe&&f<10&&(a.length-=m/2,d.length+=m/2,x=Tt(n,a),p=Tt(s,d));const h=[a],j=pi({sourceStumpTip:x,sourceOrientation:i,sourceBox:e,targetStumpTip:p,targetOrientation:r,targetBox:t});j!=null&&(h.push(j),x=Tt(x,j),l=Ct(j),a=j);const y=pi({sourceStumpTip:p,sourceOrientation:c,sourceBox:t,targetStumpTip:x,targetOrientation:l,targetBox:e});y!=null&&(p=Tt(p,y),c=At(y.direction,y.length));const S=()=>{y!=null&&(y.length*=-1,h.push(y)),d.length*=-1,h.push(d)};if(u.K.swap(l)===r){const P=u.g.construct(l),O=(p[P]-x[P])/2;h.push({direction:P,length:O});const I=u.g.swap(P);return h.push({direction:I,length:p[I]-x[I]}),h.push({direction:P,length:O}),S(),h}const b=p[a.direction]-x[a.direction];let E=u.g.swap(a.direction);const C=x[E]-p[E];let L;At(a.direction,b)===l&&At(E,C)===c?L={direction:a.direction,length:b}:(L={direction:E,length:p[E]-x[E]},E=u.g.swap(E)),h.push(L);const T={direction:E,length:p[E]-x[E]};return h.push(T),S(),h},T0=e=>Fs($0(e)),$0=({segments:e,index:t,magnitude:n})=>{const s=[...e],r=s[t],i=u.g.swap(r.direction),l=Ct(r);if(t===0){s.unshift({direction:i,length:n});const c=Bt(l,Fe);s.unshift({direction:r.direction,length:c}),t+=2,s[t]={...s[t],length:s[t].length-c}}else s[t-1]={direction:s[t-1].direction,length:s[t-1].length+n};if(t===s.length-1){s.push({direction:i,length:-n});const c=Bt(l,Fe);s.push({direction:r.direction,length:c}),s[t]={...s[t],length:s[t].length-c}}else s[t+1]={direction:s[t+1].direction,length:s[t+1].length-n};return s},A0=(e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n],n))return n;return-1},I0=(e,t,n=!1,...s)=>{const r=(i,l)=>!s.includes(l)&&t(i,l);return n?A0(e,r):e.findIndex(r)},D0=({delta:e,segments:t})=>Fs(Wc(e,t,!1)),z0=({delta:e,segments:t})=>Fs(Wc(e,t,!0)),Wc=(e,t,n)=>{let s=[...t];return e.x!==0&&(s=gi("x",e,s,n)),e.y!==0&&(s=gi("y",e,s,n)),s},hi=(e,t,n)=>{if(t.direction!==e)return!1;const s={...t,length:t.length-n[e]},r=Ct(t),i=Ct(s),l=Math.abs(s.length),c=Math.abs(t.length);return(l>c||l>Fe)&&r===i},gi=(e,t,n,s)=>{const r=u.g.swap(e),i=s?n.length-1:0,l=n[i];if(hi(e,l,t)){const p=n[n.length-1];return p.direction===e&&Math.abs(l.length)<Fe?(n[n.length-1]={...p,length:p.length-t[e]},n):(n[i]={...l,length:l.length-t[e]},n)}const c=s?0:n.length-1,x=I0(n,p=>p.direction===e,s,i);if(x===c){const p=n[c];return hi(e,p,t)?(n[c]={...p,length:p.length-t[e]},n):(l.direction===e&&Math.abs(l.length)>p.length?n[i]={...l,length:l.length-t[e]}:n[c]={...p,length:p.length-t[e]},n)}if(x===-1)return n.length===1?n[0].direction===e?[{direction:e,length:n[0].length-t[e]}]:[{direction:r,length:n[0].length/2},{direction:e,length:-t[e]},{direction:r,length:n[0].length/2}]:l.direction===e?(n[i]={...l,length:l.length-t[e]},n):[{direction:r,length:n[0].length},{direction:e,length:-t[e]},...n.slice(1)];const d=n[x];return n[x]={...d,length:d.length-t[e]},n},B0=pe.z.object({position:u.J.xy,zoom:pe.z.number()}),Yc=pe.z.object({color:u.Dt.crudeZ,variant:pe.z.string().optional(),segments:pe.z.array(zo)}),O0=Yc.extend({key:pe.z.string(),source:pe.z.string(),target:pe.z.string(),segments:pe.z.array(zo),color:u.Dt.crudeZ,id:pe.z.string(),data:pe.z.object({segments:pe.z.array(zo),color:u.Dt.crudeZ,variant:pe.z.string().optional()}).optional(),selected:pe.z.boolean(),sourceHandle:pe.z.string().nullable().optional(),targetHandle:pe.z.string().nullable().optional()}),V0=pe.z.object({key:pe.z.string(),position:u.J.xy,selected:pe.z.boolean().optional(),zIndex:pe.z.number().optional(),type:pe.z.string().optional(),data:u.m$1.optional(),measured:pe.z.object({width:pe.z.number().optional(),height:pe.z.number().optional()}).optional()}),wr=e=>e.map(t=>({id:t.key,type:"custom",zIndex:t.zIndex,measured:{...t.measured},position:{...t.position},selected:t.selected,data:{}})),br=e=>e.map(({segments:t,color:n,variant:s,...r})=>({...r,id:r.key,data:{segments:t,color:n,variant:s}})),Gc=e=>e.map(t=>({key:t.id,...t})),Kc=(e,t)=>e.map(n=>{var s,r,i;return n.data??(n.data={segments:[],color:t,variant:"pipe"}),{key:n.id,segments:((s=n.data)==null?void 0:s.segments)??[],selected:n.selected??!1,color:((r=n.data)==null?void 0:r.color)??t,variant:((i=n.data)==null?void 0:i.variant)??"pipe",...n}}),qc=e=>({...e.position,zoom:e.zoom}),Xc=e=>({position:u.J.construct(e),zoom:e.zoom}),Uc=(e,t)=>Gc(t(wr(e))),is=(e,t,n)=>Kc(t(br(e)),n),F0=(e,t="x")=>{if(e.length===0)return[];const n=u.K.construct(t),s=u.K.swap(n);return e.sort((r,i)=>u.$t.loc(r.box,n)-u.$t.loc(i.box,n)),e.forEach((r,i)=>{if(i===0)return;const c=e[i-1].handles.find(f=>f.orientation===s),a=r.handles.find(f=>f.orientation===n);if(c==null||a==null)return;const x=c.absolutePosition,d=a.absolutePosition,p=u.J.set(u.J.translation(d,x),t,0),m=u.J.translate(u.$t.topLeft(r.box),p);r.box=u.$t.construct(m,u.$t.dims(r.box))}),e};function Ae(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)(s=Ae(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var H0={value:()=>{}};function Hs(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new ls(n)}function ls(e){this._=e}function Z0(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",r=n.indexOf(".");if(r>=0&&(s=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}ls.prototype=Hs.prototype={constructor:ls,on:function(e,t){var n=this._,s=Z0(e+"",n),r,i=-1,l=s.length;if(arguments.length<2){for(;++i<l;)if((r=(e=s[i]).type)&&(r=W0(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<l;)if(r=(e=s[i]).type)n[r]=ji(n[r],e.name,t);else if(t==null)for(r in n)n[r]=ji(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ls(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),s=0,r,i;s<r;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],s=0,r=i.length;s<r;++s)i[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)}};function W0(e,t){for(var n=0,s=e.length,r;n<s;++n)if((r=e[n]).name===t)return r.value}function ji(e,t,n){for(var s=0,r=e.length;s<r;++s)if(e[s].name===t){e[s]=H0,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Oo="http://www.w3.org/1999/xhtml";const Ei={svg:"http://www.w3.org/2000/svg",xhtml:Oo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Zs(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ei.hasOwnProperty(t)?{space:Ei[t],local:e}:e}function Y0(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Oo&&t.documentElement.namespaceURI===Oo?t.createElement(e):t.createElementNS(n,e)}}function G0(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Jc(e){var t=Zs(e);return(t.local?G0:Y0)(t)}function K0(){}function vr(e){return e==null?K0:function(){return this.querySelector(e)}}function q0(e){typeof e!="function"&&(e=vr(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=new Array(l),a,x,d=0;d<l;++d)(a=i[d])&&(x=e.call(a,a.__data__,d,i))&&("__data__"in a&&(x.__data__=a.__data__),c[d]=x);return new Ye(s,this._parents)}function X0(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function U0(){return[]}function Qc(e){return e==null?U0:function(){return this.querySelectorAll(e)}}function J0(e){return function(){return X0(e.apply(this,arguments))}}function Q0(e){typeof e=="function"?e=J0(e):e=Qc(e);for(var t=this._groups,n=t.length,s=[],r=[],i=0;i<n;++i)for(var l=t[i],c=l.length,a,x=0;x<c;++x)(a=l[x])&&(s.push(e.call(a,a.__data__,x,l)),r.push(a));return new Ye(s,r)}function ea(e){return function(){return this.matches(e)}}function ta(e){return function(t){return t.matches(e)}}var e2=Array.prototype.find;function t2(e){return function(){return e2.call(this.children,e)}}function n2(){return this.firstElementChild}function s2(e){return this.select(e==null?n2:t2(typeof e=="function"?e:ta(e)))}var o2=Array.prototype.filter;function r2(){return Array.from(this.children)}function i2(e){return function(){return o2.call(this.children,e)}}function l2(e){return this.selectAll(e==null?r2:i2(typeof e=="function"?e:ta(e)))}function c2(e){typeof e!="function"&&(e=ea(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=[],a,x=0;x<l;++x)(a=i[x])&&e.call(a,a.__data__,x,i)&&c.push(a);return new Ye(s,this._parents)}function na(e){return new Array(e.length)}function a2(){return new Ye(this._enter||this._groups.map(na),this._parents)}function Rs(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Rs.prototype={constructor:Rs,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 u2(e){return function(){return e}}function x2(e,t,n,s,r,i){for(var l=0,c,a=t.length,x=i.length;l<x;++l)(c=t[l])?(c.__data__=i[l],s[l]=c):n[l]=new Rs(e,i[l]);for(;l<a;++l)(c=t[l])&&(r[l]=c)}function d2(e,t,n,s,r,i,l){var c,a,x=new Map,d=t.length,p=i.length,m=new Array(d),f;for(c=0;c<d;++c)(a=t[c])&&(m[c]=f=l.call(a,a.__data__,c,t)+"",x.has(f)?r[c]=a:x.set(f,a));for(c=0;c<p;++c)f=l.call(e,i[c],c,i)+"",(a=x.get(f))?(s[c]=a,a.__data__=i[c],x.delete(f)):n[c]=new Rs(e,i[c]);for(c=0;c<d;++c)(a=t[c])&&x.get(m[c])===a&&(r[c]=a)}function p2(e){return e.__data__}function m2(e,t){if(!arguments.length)return Array.from(this,p2);var n=t?d2:x2,s=this._parents,r=this._groups;typeof e!="function"&&(e=u2(e));for(var i=r.length,l=new Array(i),c=new Array(i),a=new Array(i),x=0;x<i;++x){var d=s[x],p=r[x],m=p.length,f=f2(e.call(d,d&&d.__data__,x,s)),h=f.length,j=c[x]=new Array(h),y=l[x]=new Array(h),S=a[x]=new Array(m);n(d,p,j,y,S,f,t);for(var b=0,E=0,C,L;b<h;++b)if(C=j[b]){for(b>=E&&(E=b+1);!(L=y[E])&&++E<h;);C._next=L||null}}return l=new Ye(l,s),l._enter=c,l._exit=a,l}function f2(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function h2(){return new Ye(this._exit||this._groups.map(na),this._parents)}function g2(e,t,n){var s=this.enter(),r=this,i=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),s&&r?s.merge(r).order():r}function j2(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,r=n.length,i=s.length,l=Math.min(r,i),c=new Array(r),a=0;a<l;++a)for(var x=n[a],d=s[a],p=x.length,m=c[a]=new Array(p),f,h=0;h<p;++h)(f=x[h]||d[h])&&(m[h]=f);for(;a<r;++a)c[a]=n[a];return new Ye(c,this._parents)}function E2(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],r=s.length-1,i=s[r],l;--r>=0;)(l=s[r])&&(i&&l.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(l,i),i=l);return this}function y2(e){e||(e=S2);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var n=this._groups,s=n.length,r=new Array(s),i=0;i<s;++i){for(var l=n[i],c=l.length,a=r[i]=new Array(c),x,d=0;d<c;++d)(x=l[d])&&(a[d]=x);a.sort(t)}return new Ye(r,this._parents).order()}function S2(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function R2(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function C2(){return Array.from(this)}function w2(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,i=s.length;r<i;++r){var l=s[r];if(l)return l}return null}function b2(){let e=0;for(const t of this)++e;return e}function v2(){return!this.node()}function k2(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var r=t[n],i=0,l=r.length,c;i<l;++i)(c=r[i])&&e.call(c,c.__data__,i,r);return this}function M2(e){return function(){this.removeAttribute(e)}}function _2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function P2(e,t){return function(){this.setAttribute(e,t)}}function L2(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function N2(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function T2(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 $2(e,t){var n=Zs(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((t==null?n.local?_2:M2:typeof t=="function"?n.local?T2:N2:n.local?L2:P2)(n,t))}function sa(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function A2(e){return function(){this.style.removeProperty(e)}}function I2(e,t,n){return function(){this.style.setProperty(e,t,n)}}function D2(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function z2(e,t,n){return arguments.length>1?this.each((t==null?A2:typeof t=="function"?D2:I2)(e,t,n??"")):en(this.node(),e)}function en(e,t){return e.style.getPropertyValue(t)||sa(e).getComputedStyle(e,null).getPropertyValue(t)}function B2(e){return function(){delete this[e]}}function O2(e,t){return function(){this[e]=t}}function V2(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function F2(e,t){return arguments.length>1?this.each((t==null?B2:typeof t=="function"?V2:O2)(e,t)):this.node()[e]}function oa(e){return e.trim().split(/^|\s+/)}function kr(e){return e.classList||new ra(e)}function ra(e){this._node=e,this._names=oa(e.getAttribute("class")||"")}ra.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 ia(e,t){for(var n=kr(e),s=-1,r=t.length;++s<r;)n.add(t[s])}function la(e,t){for(var n=kr(e),s=-1,r=t.length;++s<r;)n.remove(t[s])}function H2(e){return function(){ia(this,e)}}function Z2(e){return function(){la(this,e)}}function W2(e,t){return function(){(t.apply(this,arguments)?ia:la)(this,e)}}function Y2(e,t){var n=oa(e+"");if(arguments.length<2){for(var s=kr(this.node()),r=-1,i=n.length;++r<i;)if(!s.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?W2:t?H2:Z2)(n,t))}function G2(){this.textContent=""}function K2(e){return function(){this.textContent=e}}function q2(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function X2(e){return arguments.length?this.each(e==null?G2:(typeof e=="function"?q2:K2)(e)):this.node().textContent}function U2(){this.innerHTML=""}function J2(e){return function(){this.innerHTML=e}}function Q2(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function ej(e){return arguments.length?this.each(e==null?U2:(typeof e=="function"?Q2:J2)(e)):this.node().innerHTML}function tj(){this.nextSibling&&this.parentNode.appendChild(this)}function nj(){return this.each(tj)}function sj(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function oj(){return this.each(sj)}function rj(e){var t=typeof e=="function"?e:Jc(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function ij(){return null}function lj(e,t){var n=typeof e=="function"?e:Jc(e),s=t==null?ij:typeof t=="function"?t:vr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function cj(){var e=this.parentNode;e&&e.removeChild(this)}function aj(){return this.each(cj)}function uj(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function xj(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function dj(e){return this.select(e?xj:uj)}function pj(e){return arguments.length?this.property("__data__",e):this.node().__data__}function mj(e){return function(t){e.call(this,t,this.__data__)}}function fj(e){return e.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");return s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),{type:t,name:n}})}function hj(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++s]=i;++s?t.length=s:delete this.__on}}}function gj(e,t,n){return function(){var s=this.__on,r,i=mj(t);if(s){for(var l=0,c=s.length;l<c;++l)if((r=s[l]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},s?s.push(r):this.__on=[r]}}function jj(e,t,n){var s=fj(e+""),r,i=s.length,l;if(arguments.length<2){var c=this.node().__on;if(c){for(var a=0,x=c.length,d;a<x;++a)for(r=0,d=c[a];r<i;++r)if((l=s[r]).type===d.type&&l.name===d.name)return d.value}return}for(c=t?gj:hj,r=0;r<i;++r)this.each(c(s[r],t,n));return this}function ca(e,t,n){var s=sa(e),r=s.CustomEvent;typeof r=="function"?r=new r(t,n):(r=s.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Ej(e,t){return function(){return ca(this,e,t)}}function yj(e,t){return function(){return ca(this,e,t.apply(this,arguments))}}function Sj(e,t){return this.each((typeof t=="function"?yj:Ej)(e,t))}function*Rj(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,i=s.length,l;r<i;++r)(l=s[r])&&(yield l)}var aa=[null];function Ye(e,t){this._groups=e,this._parents=t}function Bn(){return new Ye([[document.documentElement]],aa)}function Cj(){return this}Ye.prototype=Bn.prototype={constructor:Ye,select:q0,selectAll:Q0,selectChild:s2,selectChildren:l2,filter:c2,data:m2,enter:a2,exit:h2,join:g2,merge:j2,selection:Cj,order:E2,sort:y2,call:R2,nodes:C2,node:w2,size:b2,empty:v2,each:k2,attr:$2,style:z2,property:F2,classed:Y2,text:X2,html:ej,raise:nj,lower:oj,append:rj,insert:lj,remove:aj,clone:dj,datum:pj,on:jj,dispatch:Sj,[Symbol.iterator]:Rj};function We(e){return typeof e=="string"?new Ye([[document.querySelector(e)]],[document.documentElement]):new Ye([[e]],aa)}function wj(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ue(e,t){if(e=wj(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var s=n.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const bj={passive:!1},_n={capture:!0,passive:!1};function jo(e){e.stopImmediatePropagation()}function Jt(e){e.preventDefault(),e.stopImmediatePropagation()}function ua(e){var t=e.document.documentElement,n=We(e).on("dragstart.drag",Jt,_n);"onselectstart"in t?n.on("selectstart.drag",Jt,_n):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function xa(e,t){var n=e.document.documentElement,s=We(e).on("dragstart.drag",null);t&&(s.on("click.drag",Jt,_n),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const qn=e=>()=>e;function Vo(e,{sourceEvent:t,subject:n,target:s,identifier:r,active:i,x:l,y:c,dx:a,dy:x,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:s,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:x,enumerable:!0,configurable:!0},_:{value:d}})}Vo.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function vj(e){return!e.ctrlKey&&!e.button}function kj(){return this.parentNode}function Mj(e,t){return t??{x:e.x,y:e.y}}function _j(){return navigator.maxTouchPoints||"ontouchstart"in this}function da(){var e=vj,t=kj,n=Mj,s=_j,r={},i=Hs("start","drag","end"),l=0,c,a,x,d,p=0;function m(C){C.on("mousedown.drag",f).filter(s).on("touchstart.drag",y).on("touchmove.drag",S,bj).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(C,L){if(!(d||!e.call(this,C,L))){var T=E(this,t.call(this,C,L),C,L,"mouse");T&&(We(C.view).on("mousemove.drag",h,_n).on("mouseup.drag",j,_n),ua(C.view),jo(C),x=!1,c=C.clientX,a=C.clientY,T("start",C))}}function h(C){if(Jt(C),!x){var L=C.clientX-c,T=C.clientY-a;x=L*L+T*T>p}r.mouse("drag",C)}function j(C){We(C.view).on("mousemove.drag mouseup.drag",null),xa(C.view,x),Jt(C),r.mouse("end",C)}function y(C,L){if(e.call(this,C,L)){var T=C.changedTouches,P=t.call(this,C,L),O=T.length,I,D;for(I=0;I<O;++I)(D=E(this,P,C,L,T[I].identifier,T[I]))&&(jo(C),D("start",C,T[I]))}}function S(C){var L=C.changedTouches,T=L.length,P,O;for(P=0;P<T;++P)(O=r[L[P].identifier])&&(Jt(C),O("drag",C,L[P]))}function b(C){var L=C.changedTouches,T=L.length,P,O;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),P=0;P<T;++P)(O=r[L[P].identifier])&&(jo(C),O("end",C,L[P]))}function E(C,L,T,P,O,I){var D=i.copy(),H=Ue(I||T,L),B,_,R;if((R=n.call(C,new Vo("beforestart",{sourceEvent:T,target:m,identifier:O,active:l,x:H[0],y:H[1],dx:0,dy:0,dispatch:D}),P))!=null)return B=R.x-H[0]||0,_=R.y-H[1]||0,function k(v,M,A){var $=H,V;switch(v){case"start":r[O]=k,V=l++;break;case"end":delete r[O],--l;case"drag":H=Ue(A||M,L),V=l;break}D.call(v,C,new Vo(v,{sourceEvent:M,subject:R,target:m,identifier:O,active:V,x:H[0]+B,y:H[1]+_,dx:H[0]-$[0],dy:H[1]-$[1],dispatch:D}),P)}}return m.filter=function(C){return arguments.length?(e=typeof C=="function"?C:qn(!!C),m):e},m.container=function(C){return arguments.length?(t=typeof C=="function"?C:qn(C),m):t},m.subject=function(C){return arguments.length?(n=typeof C=="function"?C:qn(C),m):n},m.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:qn(!!C),m):s},m.on=function(){var C=i.on.apply(i,arguments);return C===i?m:C},m.clickDistance=function(C){return arguments.length?(p=(C=+C)*C,m):Math.sqrt(p)},m}var tn=0,yn=0,hn=0,pa=1e3,Cs,Sn,ws=0,Ot=0,Ws=0,Pn=typeof performance=="object"&&performance.now?performance:Date,ma=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Mr(){return Ot||(ma(Pj),Ot=Pn.now()+Ws)}function Pj(){Ot=0}function bs(){this._call=this._time=this._next=null}bs.prototype=fa.prototype={constructor:bs,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Mr():+n)+(t==null?0:+t),!this._next&&Sn!==this&&(Sn?Sn._next=this:Cs=this,Sn=this),this._call=e,this._time=n,Fo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Fo())}};function fa(e,t,n){var s=new bs;return s.restart(e,t,n),s}function Lj(){Mr(),++tn;for(var e=Cs,t;e;)(t=Ot-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tn}function yi(){Ot=(ws=Pn.now())+Ws,tn=yn=0;try{Lj()}finally{tn=0,Tj(),Ot=0}}function Nj(){var e=Pn.now(),t=e-ws;t>pa&&(Ws-=t,ws=e)}function Tj(){for(var e,t=Cs,n,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Cs=n);Sn=e,Fo(s)}function Fo(e){if(!tn){yn&&(yn=clearTimeout(yn));var t=e-Ot;t>24?(e<1/0&&(yn=setTimeout(yi,e-Pn.now()-Ws)),hn&&(hn=clearInterval(hn))):(hn||(ws=Pn.now(),hn=setInterval(Nj,pa)),tn=1,ma(yi))}}function Si(e,t,n){var s=new bs;return t=t==null?0:+t,s.restart(r=>{s.stop(),e(r+t)},t,n),s}var $j=Hs("start","end","cancel","interrupt"),Aj=[],ha=0,Ri=1,Ho=2,cs=3,Ci=4,Zo=5,as=6;function Ys(e,t,n,s,r,i){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;Ij(e,n,{name:t,index:s,group:r,on:$j,tween:Aj,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ha})}function _r(e,t){var n=et(e,t);if(n.state>ha)throw new Error("too late; already scheduled");return n}function ct(e,t){var n=et(e,t);if(n.state>cs)throw new Error("too late; already running");return n}function et(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Ij(e,t,n){var s=e.__transition,r;s[t]=n,n.timer=fa(i,0,n.time);function i(x){n.state=Ri,n.timer.restart(l,n.delay,n.time),n.delay<=x&&l(x-n.delay)}function l(x){var d,p,m,f;if(n.state!==Ri)return a();for(d in s)if(f=s[d],f.name===n.name){if(f.state===cs)return Si(l);f.state===Ci?(f.state=as,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete s[d]):+d<t&&(f.state=as,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete s[d])}if(Si(function(){n.state===cs&&(n.state=Ci,n.timer.restart(c,n.delay,n.time),c(x))}),n.state=Ho,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Ho){for(n.state=cs,r=new Array(m=n.tween.length),d=0,p=-1;d<m;++d)(f=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(r[++p]=f);r.length=p+1}}function c(x){for(var d=x<n.duration?n.ease.call(null,x/n.duration):(n.timer.restart(a),n.state=Zo,1),p=-1,m=r.length;++p<m;)r[p].call(e,d);n.state===Zo&&(n.on.call("end",e,e.__data__,n.index,n.group),a())}function a(){n.state=as,n.timer.stop(),delete s[t];for(var x in s)return;delete e.__transition}}function us(e,t){var n=e.__transition,s,r,i=!0,l;if(n){t=t==null?null:t+"";for(l in n){if((s=n[l]).name!==t){i=!1;continue}r=s.state>Ho&&s.state<Zo,s.state=as,s.timer.stop(),s.on.call(r?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[l]}i&&delete e.__transition}}function Dj(e){return this.each(function(){us(this,e)})}function zj(e,t){var n,s;return function(){var r=ct(this,e),i=r.tween;if(i!==n){s=n=i;for(var l=0,c=s.length;l<c;++l)if(s[l].name===t){s=s.slice(),s.splice(l,1);break}}r.tween=s}}function Bj(e,t,n){var s,r;if(typeof n!="function")throw new Error;return function(){var i=ct(this,e),l=i.tween;if(l!==s){r=(s=l).slice();for(var c={name:t,value:n},a=0,x=r.length;a<x;++a)if(r[a].name===t){r[a]=c;break}a===x&&r.push(c)}i.tween=r}}function Oj(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=et(this.node(),n).tween,r=0,i=s.length,l;r<i;++r)if((l=s[r]).name===e)return l.value;return null}return this.each((t==null?zj:Bj)(n,e,t))}function Pr(e,t,n){var s=e._id;return e.each(function(){var r=ct(this,s);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return et(r,s).value[t]}}function ga(e,t){var n;return(typeof t=="number"?z.interpolateNumber:t instanceof z.color?z.interpolateRgb:(n=z.color(t))?(t=n,z.interpolateRgb):z.interpolateString)(e,t)}function Vj(e){return function(){this.removeAttribute(e)}}function Fj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Hj(e,t,n){var s,r=n+"",i;return function(){var l=this.getAttribute(e);return l===r?null:l===s?i:i=t(s=l,n)}}function Zj(e,t,n){var s,r=n+"",i;return function(){var l=this.getAttributeNS(e.space,e.local);return l===r?null:l===s?i:i=t(s=l,n)}}function Wj(e,t,n){var s,r,i;return function(){var l,c=n(this),a;return c==null?void this.removeAttribute(e):(l=this.getAttribute(e),a=c+"",l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c)))}}function Yj(e,t,n){var s,r,i;return function(){var l,c=n(this),a;return c==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),a=c+"",l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c)))}}function Gj(e,t){var n=Zs(e),s=n==="transform"?yh:ga;return this.attrTween(e,typeof t=="function"?(n.local?Yj:Wj)(n,s,Pr(this,"attr."+e,t)):t==null?(n.local?Fj:Vj)(n):(n.local?Zj:Hj)(n,s,t))}function Kj(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function qj(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Xj(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&qj(e,i)),n}return r._value=t,r}function Uj(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&Kj(e,i)),n}return r._value=t,r}function Jj(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 s=Zs(e);return this.tween(n,(s.local?Xj:Uj)(s,t))}function Qj(e,t){return function(){_r(this,e).delay=+t.apply(this,arguments)}}function e3(e,t){return t=+t,function(){_r(this,e).delay=t}}function t3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Qj:e3)(t,e)):et(this.node(),t).delay}function n3(e,t){return function(){ct(this,e).duration=+t.apply(this,arguments)}}function s3(e,t){return t=+t,function(){ct(this,e).duration=t}}function o3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?n3:s3)(t,e)):et(this.node(),t).duration}function r3(e,t){if(typeof t!="function")throw new Error;return function(){ct(this,e).ease=t}}function i3(e){var t=this._id;return arguments.length?this.each(r3(t,e)):et(this.node(),t).ease}function l3(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ct(this,e).ease=n}}function c3(e){if(typeof e!="function")throw new Error;return this.each(l3(this._id,e))}function a3(e){typeof e!="function"&&(e=ea(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=[],a,x=0;x<l;++x)(a=i[x])&&e.call(a,a.__data__,x,i)&&c.push(a);return new pt(s,this._parents,this._name,this._id)}function u3(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,r=n.length,i=Math.min(s,r),l=new Array(s),c=0;c<i;++c)for(var a=t[c],x=n[c],d=a.length,p=l[c]=new Array(d),m,f=0;f<d;++f)(m=a[f]||x[f])&&(p[f]=m);for(;c<s;++c)l[c]=t[c];return new pt(l,this._parents,this._name,this._id)}function x3(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 d3(e,t,n){var s,r,i=x3(t)?_r:ct;return function(){var l=i(this,e),c=l.on;c!==s&&(r=(s=c).copy()).on(t,n),l.on=r}}function p3(e,t){var n=this._id;return arguments.length<2?et(this.node(),n).on.on(e):this.each(d3(n,e,t))}function m3(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function f3(){return this.on("end.remove",m3(this._id))}function h3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=vr(e));for(var s=this._groups,r=s.length,i=new Array(r),l=0;l<r;++l)for(var c=s[l],a=c.length,x=i[l]=new Array(a),d,p,m=0;m<a;++m)(d=c[m])&&(p=e.call(d,d.__data__,m,c))&&("__data__"in d&&(p.__data__=d.__data__),x[m]=p,Ys(x[m],t,n,m,x,et(d,n)));return new pt(i,this._parents,t,n)}function g3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Qc(e));for(var s=this._groups,r=s.length,i=[],l=[],c=0;c<r;++c)for(var a=s[c],x=a.length,d,p=0;p<x;++p)if(d=a[p]){for(var m=e.call(d,d.__data__,p,a),f,h=et(d,n),j=0,y=m.length;j<y;++j)(f=m[j])&&Ys(f,t,n,j,m,h);i.push(m),l.push(d)}return new pt(i,l,t,n)}var j3=Bn.prototype.constructor;function E3(){return new j3(this._groups,this._parents)}function y3(e,t){var n,s,r;return function(){var i=en(this,e),l=(this.style.removeProperty(e),en(this,e));return i===l?null:i===n&&l===s?r:r=t(n=i,s=l)}}function ja(e){return function(){this.style.removeProperty(e)}}function S3(e,t,n){var s,r=n+"",i;return function(){var l=en(this,e);return l===r?null:l===s?i:i=t(s=l,n)}}function R3(e,t,n){var s,r,i;return function(){var l=en(this,e),c=n(this),a=c+"";return c==null&&(a=c=(this.style.removeProperty(e),en(this,e))),l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c))}}function C3(e,t){var n,s,r,i="style."+t,l="end."+i,c;return function(){var a=ct(this,e),x=a.on,d=a.value[i]==null?c||(c=ja(t)):void 0;(x!==n||r!==d)&&(s=(n=x).copy()).on(l,r=d),a.on=s}}function w3(e,t,n){var s=(e+="")=="transform"?Eh:ga;return t==null?this.styleTween(e,y3(e,s)).on("end.style."+e,ja(e)):typeof t=="function"?this.styleTween(e,R3(e,s,Pr(this,"style."+e,t))).each(C3(this._id,e)):this.styleTween(e,S3(e,s,t),n).on("end.style."+e,null)}function b3(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function v3(e,t,n){var s,r;function i(){var l=t.apply(this,arguments);return l!==r&&(s=(r=l)&&b3(e,l,n)),s}return i._value=t,i}function k3(e,t,n){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,v3(e,t,n??""))}function M3(e){return function(){this.textContent=e}}function _3(e){return function(){var t=e(this);this.textContent=t??""}}function P3(e){return this.tween("text",typeof e=="function"?_3(Pr(this,"text",e)):M3(e==null?"":e+""))}function L3(e){return function(t){this.textContent=e.call(this,t)}}function N3(e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&L3(r)),t}return s._value=e,s}function T3(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,N3(e))}function $3(){for(var e=this._name,t=this._id,n=Ea(),s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],c=l.length,a,x=0;x<c;++x)if(a=l[x]){var d=et(a,t);Ys(a,e,n,x,l,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new pt(s,this._parents,e,n)}function A3(){var e,t,n=this,s=n._id,r=n.size();return new Promise(function(i,l){var c={value:l},a={value:function(){--r===0&&i()}};n.each(function(){var x=ct(this,s),d=x.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(a)),x.on=t}),r===0&&i()})}var I3=0;function pt(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Ea(){return++I3}var ut=Bn.prototype;pt.prototype={constructor:pt,select:h3,selectAll:g3,selectChild:ut.selectChild,selectChildren:ut.selectChildren,filter:a3,merge:u3,selection:E3,transition:$3,call:ut.call,nodes:ut.nodes,node:ut.node,size:ut.size,empty:ut.empty,each:ut.each,on:p3,attr:Gj,attrTween:Jj,style:w3,styleTween:k3,text:P3,textTween:T3,remove:f3,tween:Oj,delay:t3,duration:o3,ease:i3,easeVarying:c3,end:A3,[Symbol.iterator]:ut[Symbol.iterator]};function D3(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var z3={time:null,delay:0,duration:250,ease:D3};function B3(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 O3(e){var t,n;e instanceof pt?(t=e._id,e=e._name):(t=Ea(),(n=z3).time=Mr(),e=e==null?null:e+"");for(var s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],c=l.length,a,x=0;x<c;++x)(a=l[x])&&Ys(a,e,t,x,l,n||B3(a,t));return new pt(s,this._parents,e,t)}Bn.prototype.interrupt=Dj;Bn.prototype.transition=O3;const Xn=e=>()=>e;function V3(e,{sourceEvent:t,target:n,transform:s,dispatch:r}){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:s,enumerable:!0,configurable:!0},_:{value:r}})}function xt(e,t,n){this.k=e,this.x=t,this.y=n}xt.prototype={constructor:xt,scale:function(e){return e===1?this:new xt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new xt(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 Gs=new xt(1,0,0);ya.prototype=xt.prototype;function ya(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Gs;return e.__zoom}function Eo(e){e.stopImmediatePropagation()}function gn(e){e.preventDefault(),e.stopImmediatePropagation()}function F3(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function H3(){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 wi(){return this.__zoom||Gs}function Z3(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function W3(){return navigator.maxTouchPoints||"ontouchstart"in this}function Y3(e,t,n){var s=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],l=e.invertY(t[1][1])-n[1][1];return e.translate(r>s?(s+r)/2:Math.min(0,s)||Math.max(0,r),l>i?(i+l)/2:Math.min(0,i)||Math.max(0,l))}function Sa(){var e=F3,t=H3,n=Y3,s=Z3,r=W3,i=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,a=wh,x=Hs("start","zoom","end"),d,p,m,f=500,h=150,j=0,y=10;function S(R){R.property("__zoom",wi).on("wheel.zoom",O,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",D).filter(r).on("touchstart.zoom",H).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",_).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(R,k,v,M){var A=R.selection?R.selection():R;A.property("__zoom",wi),R!==A?L(R,k,v,M):A.interrupt().each(function(){T(this,arguments).event(M).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},S.scaleBy=function(R,k,v,M){S.scaleTo(R,function(){var A=this.__zoom.k,$=typeof k=="function"?k.apply(this,arguments):k;return A*$},v,M)},S.scaleTo=function(R,k,v,M){S.transform(R,function(){var A=t.apply(this,arguments),$=this.__zoom,V=v==null?C(A):typeof v=="function"?v.apply(this,arguments):v,F=$.invert(V),W=typeof k=="function"?k.apply(this,arguments):k;return n(E(b($,W),V,F),A,l)},v,M)},S.translateBy=function(R,k,v,M){S.transform(R,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof v=="function"?v.apply(this,arguments):v),t.apply(this,arguments),l)},null,M)},S.translateTo=function(R,k,v,M,A){S.transform(R,function(){var $=t.apply(this,arguments),V=this.__zoom,F=M==null?C($):typeof M=="function"?M.apply(this,arguments):M;return n(Gs.translate(F[0],F[1]).scale(V.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof v=="function"?-v.apply(this,arguments):-v),$,l)},M,A)};function b(R,k){return k=Math.max(i[0],Math.min(i[1],k)),k===R.k?R:new xt(k,R.x,R.y)}function E(R,k,v){var M=k[0]-v[0]*R.k,A=k[1]-v[1]*R.k;return M===R.x&&A===R.y?R:new xt(R.k,M,A)}function C(R){return[(+R[0][0]+ +R[1][0])/2,(+R[0][1]+ +R[1][1])/2]}function L(R,k,v,M){R.on("start.zoom",function(){T(this,arguments).event(M).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(M).end()}).tween("zoom",function(){var A=this,$=arguments,V=T(A,$).event(M),F=t.apply(A,$),W=v==null?C(F):typeof v=="function"?v.apply(A,$):v,ee=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),te=A.__zoom,se=typeof k=="function"?k.apply(A,$):k,oe=a(te.invert(W).concat(ee/te.k),se.invert(W).concat(ee/se.k));return function(J){if(J===1)J=se;else{var le=oe(J),fe=ee/le[2];J=new xt(fe,W[0]-le[0]*fe,W[1]-le[1]*fe)}V.zoom(null,J)}})}function T(R,k,v){return!v&&R.__zooming||new P(R,k)}function P(R,k){this.that=R,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(R,k),this.taps=0}P.prototype={event:function(R){return R&&(this.sourceEvent=R),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(R,k){return this.mouse&&R!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&R!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&R!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(R){var k=We(this.that).datum();x.call(R,this.that,new V3(R,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:x}),k)}};function O(R,...k){if(!e.apply(this,arguments))return;var v=T(this,k).event(R),M=this.__zoom,A=Math.max(i[0],Math.min(i[1],M.k*Math.pow(2,s.apply(this,arguments)))),$=Ue(R);if(v.wheel)(v.mouse[0][0]!==$[0]||v.mouse[0][1]!==$[1])&&(v.mouse[1]=M.invert(v.mouse[0]=$)),clearTimeout(v.wheel);else{if(M.k===A)return;v.mouse=[$,M.invert($)],us(this),v.start()}gn(R),v.wheel=setTimeout(V,h),v.zoom("mouse",n(E(b(M,A),v.mouse[0],v.mouse[1]),v.extent,l));function V(){v.wheel=null,v.end()}}function I(R,...k){if(m||!e.apply(this,arguments))return;var v=R.currentTarget,M=T(this,k,!0).event(R),A=We(R.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",ee,!0),$=Ue(R,v),V=R.clientX,F=R.clientY;ua(R.view),Eo(R),M.mouse=[$,this.__zoom.invert($)],us(this),M.start();function W(te){if(gn(te),!M.moved){var se=te.clientX-V,oe=te.clientY-F;M.moved=se*se+oe*oe>j}M.event(te).zoom("mouse",n(E(M.that.__zoom,M.mouse[0]=Ue(te,v),M.mouse[1]),M.extent,l))}function ee(te){A.on("mousemove.zoom mouseup.zoom",null),xa(te.view,M.moved),gn(te),M.event(te).end()}}function D(R,...k){if(e.apply(this,arguments)){var v=this.__zoom,M=Ue(R.changedTouches?R.changedTouches[0]:R,this),A=v.invert(M),$=v.k*(R.shiftKey?.5:2),V=n(E(b(v,$),M,A),t.apply(this,k),l);gn(R),c>0?We(this).transition().duration(c).call(L,V,M,R):We(this).call(S.transform,V,M,R)}}function H(R,...k){if(e.apply(this,arguments)){var v=R.touches,M=v.length,A=T(this,k,R.changedTouches.length===M).event(R),$,V,F,W;for(Eo(R),V=0;V<M;++V)F=v[V],W=Ue(F,this),W=[W,this.__zoom.invert(W),F.identifier],A.touch0?!A.touch1&&A.touch0[2]!==W[2]&&(A.touch1=W,A.taps=0):(A.touch0=W,$=!0,A.taps=1+!!d);d&&(d=clearTimeout(d)),$&&(A.taps<2&&(p=W[0],d=setTimeout(function(){d=null},f)),us(this),A.start())}}function B(R,...k){if(this.__zooming){var v=T(this,k).event(R),M=R.changedTouches,A=M.length,$,V,F,W;for(gn(R),$=0;$<A;++$)V=M[$],F=Ue(V,this),v.touch0&&v.touch0[2]===V.identifier?v.touch0[0]=F:v.touch1&&v.touch1[2]===V.identifier&&(v.touch1[0]=F);if(V=v.that.__zoom,v.touch1){var ee=v.touch0[0],te=v.touch0[1],se=v.touch1[0],oe=v.touch1[1],J=(J=se[0]-ee[0])*J+(J=se[1]-ee[1])*J,le=(le=oe[0]-te[0])*le+(le=oe[1]-te[1])*le;V=b(V,Math.sqrt(J/le)),F=[(ee[0]+se[0])/2,(ee[1]+se[1])/2],W=[(te[0]+oe[0])/2,(te[1]+oe[1])/2]}else if(v.touch0)F=v.touch0[0],W=v.touch0[1];else return;v.zoom("touch",n(E(V,F,W),v.extent,l))}}function _(R,...k){if(this.__zooming){var v=T(this,k).event(R),M=R.changedTouches,A=M.length,$,V;for(Eo(R),m&&clearTimeout(m),m=setTimeout(function(){m=null},f),$=0;$<A;++$)V=M[$],v.touch0&&v.touch0[2]===V.identifier?delete v.touch0:v.touch1&&v.touch1[2]===V.identifier&&delete v.touch1;if(v.touch1&&!v.touch0&&(v.touch0=v.touch1,delete v.touch1),v.touch0)v.touch0[1]=this.__zoom.invert(v.touch0[0]);else if(v.end(),v.taps===2&&(V=Ue(V,this),Math.hypot(p[0]-V[0],p[1]-V[1])<y)){var F=We(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return S.wheelDelta=function(R){return arguments.length?(s=typeof R=="function"?R:Xn(+R),S):s},S.filter=function(R){return arguments.length?(e=typeof R=="function"?R:Xn(!!R),S):e},S.touchable=function(R){return arguments.length?(r=typeof R=="function"?R:Xn(!!R),S):r},S.extent=function(R){return arguments.length?(t=typeof R=="function"?R:Xn([[+R[0][0],+R[0][1]],[+R[1][0],+R[1][1]]]),S):t},S.scaleExtent=function(R){return arguments.length?(i[0]=+R[0],i[1]=+R[1],S):[i[0],i[1]]},S.translateExtent=function(R){return arguments.length?(l[0][0]=+R[0][0],l[1][0]=+R[1][0],l[0][1]=+R[0][1],l[1][1]=+R[1][1],S):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},S.constrain=function(R){return arguments.length?(n=R,S):n},S.duration=function(R){return arguments.length?(c=+R,S):c},S.interpolate=function(R){return arguments.length?(a=R,S):a},S.on=function(){var R=x.on.apply(x,arguments);return R===x?S:R},S.clickDistance=function(R){return arguments.length?(j=(R=+R)*R,S):Math.sqrt(j)},S.tapDistance=function(R){return arguments.length?(y=+R,S):y},S}const Be={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:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:s}", 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."},Ln=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ra=["Enter"," ","Escape"];var Vt;(function(e){e.Strict="strict",e.Loose="loose"})(Vt||(Vt={}));var It;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(It||(It={}));var nn;(function(e){e.Partial="partial",e.Full="full"})(nn||(nn={}));const Ca={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var Rt;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Rt||(Rt={}));var vs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(vs||(vs={}));var U;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(U||(U={}));const bi={[U.Left]:U.Right,[U.Right]:U.Left,[U.Top]:U.Bottom,[U.Bottom]:U.Top};function wa(e){return e===null?null:e?"valid":"invalid"}const ba=e=>"id"in e&&"source"in e&&"target"in e,G3=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Lr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),On=(e,t=[0,0])=>{const{width:n,height:s}=gt(e),r=e.origin??t,i=n*r[0],l=s*r[1];return{x:e.position.x-i,y:e.position.y-l}},K3=(e,t={nodeOrigin:[0,0]})=>{if(process.env.NODE_ENV==="development"&&!t.nodeLookup&&console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."),e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,r)=>{const i=typeof r=="string";let l=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(l=i?t.nodeLookup.get(r):Lr(r)?r:t.nodeLookup.get(r.id));const c=l?ks(l,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Ks(s,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return qs(n)},Vn=(e,t={})=>{if(e.size===0)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach(s=>{if(t.filter===void 0||t.filter(s)){const r=ks(s);n=Ks(n,r)}}),qs(n)},va=(e,t,[n,s,r]=[0,0,1],i=!1,l=!1)=>{const c={...Fn(t,[n,s,r]),width:t.width/r,height:t.height/r},a=[];for(const x of e.values()){const{measured:d,selectable:p=!0,hidden:m=!1}=x;if(l&&!p||m)continue;const f=d.width??x.width??x.initialWidth??null,h=d.height??x.height??x.initialHeight??null,j=Nn(c,on(x)),y=(f??0)*(h??0),S=i&&j>0;(!x.internals.handleBounds||S||j>=y||x.dragging)&&a.push(x)}return a},q3=(e,t)=>{const n=new Set;return e.forEach(s=>{n.add(s.id)}),t.filter(s=>n.has(s.source)||n.has(s.target))};function X3(e,t){const n=new Map,s=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!s||s.has(r.id))&&n.set(r.id,r)}),n}async function U3({nodes:e,width:t,height:n,panZoom:s,minZoom:r,maxZoom:i},l){if(e.size===0)return Promise.resolve(!0);const c=X3(e,l),a=Vn(c),x=Nr(a,t,n,(l==null?void 0:l.minZoom)??r,(l==null?void 0:l.maxZoom)??i,(l==null?void 0:l.padding)??.1);return await s.setViewport(x,{duration:l==null?void 0:l.duration}),Promise.resolve(!0)}function ka({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:r,onError:i}){const l=n.get(e),c=l.parentId?n.get(l.parentId):void 0,{x:a,y:x}=c?c.internals.positionAbsolute:{x:0,y:0},d=l.origin??s;let p=r;if(l.extent==="parent"&&!l.expandParent)if(!c)i==null||i("005",Be.error005());else{const f=c.measured.width,h=c.measured.height;f&&h&&(p=[[a,x],[a+f,x+h]])}else c&&rn(l.extent)&&(p=[[l.extent[0][0]+a,l.extent[0][1]+x],[l.extent[1][0]+a,l.extent[1][1]+x]]);const m=rn(p)?Ft(t,p,l.measured):t;return(l.measured.width===void 0||l.measured.height===void 0)&&(i==null||i("015",Be.error015())),{position:{x:m.x-a+(l.measured.width??0)*d[0],y:m.y-x+(l.measured.height??0)*d[1]},positionAbsolute:m}}async function J3({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:r}){const i=new Set(e.map(m=>m.id)),l=[];for(const m of n){if(m.deletable===!1)continue;const f=i.has(m.id),h=!f&&m.parentId&&l.find(j=>j.id===m.parentId);(f||h)&&l.push(m)}const c=new Set(t.map(m=>m.id)),a=s.filter(m=>m.deletable!==!1),d=q3(l,a);for(const m of a)c.has(m.id)&&!d.find(h=>h.id===m.id)&&d.push(m);if(!r)return{edges:d,nodes:l};const p=await r({nodes:l,edges:d});return typeof p=="boolean"?p?{edges:d,nodes:l}:{edges:[],nodes:[]}:p}const sn=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ft=(e={x:0,y:0},t,n)=>({x:sn(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:sn(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Ma(e,t,n){const{width:s,height:r}=gt(n),{x:i,y:l}=n.internals.positionAbsolute;return Ft(e,[[i,l],[i+s,l+r]],t)}const vi=(e,t,n)=>e<t?sn(Math.abs(e-t),1,t)/t:e>n?-sn(Math.abs(e-n),1,t)/t:0,_a=(e,t,n=15,s=40)=>{const r=vi(e.x,s,t.width-s)*n,i=vi(e.y,s,t.height-s)*n;return[r,i]},Ks=(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)}),Wo=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),qs=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),on=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=Lr(e)?e.internals.positionAbsolute:On(e,t);return{x:n,y:s,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},ks=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=Lr(e)?e.internals.positionAbsolute:On(e,t);return{x:n,y:s,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:s+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Pa=(e,t)=>qs(Ks(Wo(e),Wo(t))),Nn=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*s)},ki=e=>Je(e.width)&&Je(e.height)&&Je(e.x)&&Je(e.y),Je=e=>!isNaN(e)&&isFinite(e),Ms=(e,t)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)},Xs=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Fn=({x:e,y:t},[n,s,r],i=!1,l=[1,1])=>{const c={x:(e-n)/r,y:(t-s)/r};return i?Xs(c,l):c},_s=({x:e,y:t},[n,s,r])=>({x:e*r+n,y:t*r+s});function Kt(e,t){if(typeof e=="number")return Math.floor(t-t/(1+e));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 Q3(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=Kt(e,n),r=Kt(e,t);return{top:s,right:r,bottom:s,left:r,x:r*2,y:s*2}}if(typeof e=="object"){const s=Kt(e.top??e.y??0,n),r=Kt(e.bottom??e.y??0,n),i=Kt(e.left??e.x??0,t),l=Kt(e.right??e.x??0,t);return{top:s,right:l,bottom:r,left:i,x:i+l,y:s+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function e5(e,t,n,s,r,i){const{x:l,y:c}=_s(e,[t,n,s]),{x:a,y:x}=_s({x:e.x+e.width,y:e.y+e.height},[t,n,s]),d=r-a,p=i-x;return{left:Math.floor(l),top:Math.floor(c),right:Math.floor(d),bottom:Math.floor(p)}}const Nr=(e,t,n,s,r,i)=>{const l=Q3(i,t,n),c=(t-l.x)/e.width,a=(n-l.y)/e.height,x=Math.min(c,a),d=sn(x,s,r),p=e.x+e.width/2,m=e.y+e.height/2,f=t/2-p*d,h=n/2-m*d,j=e5(e,f,h,d,t,n),y={left:Math.min(j.left-l.left,0),top:Math.min(j.top-l.top,0),right:Math.min(j.right-l.right,0),bottom:Math.min(j.bottom-l.bottom,0)};return{x:f-y.left+y.right,y:h-y.top+y.bottom,zoom:d}},Ps=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function rn(e){return e!==void 0&&e!=="parent"}function gt(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function La(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Na(e,t={width:0,height:0},n,s,r){const i={...e},l=s.get(n);if(l){const c=l.origin||r;i.x+=l.internals.positionAbsolute.x-(t.width??0)*c[0],i.y+=l.internals.positionAbsolute.y-(t.height??0)*c[1]}return i}function Mi(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Cn(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:r}){const{x:i,y:l}=dt(e),c=Fn({x:i-((r==null?void 0:r.left)??0),y:l-((r==null?void 0:r.top)??0)},s),{x:a,y:x}=n?Xs(c,t):c;return{xSnapped:a,ySnapped:x,...c}}const Tr=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ta=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},t5=["INPUT","SELECT","TEXTAREA"];function $a(e){var s,r;const t=((r=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:t5.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Aa=e=>"clientX"in e,dt=(e,t)=>{var i,l;const n=Aa(e),s=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,r=n?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},_i=(e,t,n,s,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(l=>{const c=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:r,position:l.getAttribute("data-handlepos"),x:(c.left-n.left)/s,y:(c.top-n.top)/s,...Tr(l)}})};function Ia({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:r,sourceControlY:i,targetControlX:l,targetControlY:c}){const a=e*.125+r*.375+l*.375+n*.125,x=t*.125+i*.375+c*.375+s*.125,d=Math.abs(a-e),p=Math.abs(x-t);return[a,x,d,p]}function Un(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Pi({pos:e,x1:t,y1:n,x2:s,y2:r,c:i}){switch(e){case U.Left:return[t-Un(t-s,i),n];case U.Right:return[t+Un(s-t,i),n];case U.Top:return[t,n-Un(n-r,i)];case U.Bottom:return[t,n+Un(r-n,i)]}}function Da({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:s,targetY:r,targetPosition:i=U.Top,curvature:l=.25}){const[c,a]=Pi({pos:n,x1:e,y1:t,x2:s,y2:r,c:l}),[x,d]=Pi({pos:i,x1:s,y1:r,x2:e,y2:t,c:l}),[p,m,f,h]=Ia({sourceX:e,sourceY:t,targetX:s,targetY:r,sourceControlX:c,sourceControlY:a,targetControlX:x,targetControlY:d});return[`M${e},${t} C${c},${a} ${x},${d} ${s},${r}`,p,m,f,h]}function za({sourceX:e,sourceY:t,targetX:n,targetY:s}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,l=Math.abs(s-t)/2,c=s<t?s+l:s-l;return[i,c,r,l]}function n5({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s=0,elevateOnSelect:r=!1}){if(!r)return s;const i=n||t.selected||e.selected,l=Math.max(e.internals.z||0,t.internals.z||0,1e3);return s+(i?l:0)}function s5({sourceNode:e,targetNode:t,width:n,height:s,transform:r}){const i=Ks(ks(e),ks(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const l={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:s/r[2]};return Nn(l,qs(i))>0}const Ba=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,o5=(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)),Oa=(e,t)=>{if(!e.source||!e.target)return Ms("006",Be.error006()),t;let n;return ba(e)?n={...e}:n={...e,id:Ba(e)},o5(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))},r5=(e,t,n,s={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return Ms("006",Be.error006()),n;if(!n.find(a=>a.id===e.id))return Ms("007",Be.error007(r)),n;const c={...i,id:s.shouldReplaceId?Ba(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(a=>a.id!==r).concat(c)};function Va({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[r,i,l,c]=za({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,r,i,l,c]}const Li={[U.Left]:{x:-1,y:0},[U.Right]:{x:1,y:0},[U.Top]:{x:0,y:-1},[U.Bottom]:{x:0,y:1}},i5=({source:e,sourcePosition:t=U.Bottom,target:n})=>t===U.Left||t===U.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},Ni=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function l5({source:e,sourcePosition:t=U.Bottom,target:n,targetPosition:s=U.Top,center:r,offset:i}){const l=Li[t],c=Li[s],a={x:e.x+l.x*i,y:e.y+l.y*i},x={x:n.x+c.x*i,y:n.y+c.y*i},d=i5({source:a,sourcePosition:t,target:x}),p=d.x!==0?"x":"y",m=d[p];let f=[],h,j;const y={x:0,y:0},S={x:0,y:0},[b,E,C,L]=za({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){h=r.x??b,j=r.y??E;const P=[{x:h,y:a.y},{x:h,y:x.y}],O=[{x:a.x,y:j},{x:x.x,y:j}];l[p]===m?f=p==="x"?P:O:f=p==="x"?O:P}else{const P=[{x:a.x,y:x.y}],O=[{x:x.x,y:a.y}];if(p==="x"?f=l.x===m?O:P:f=l.y===m?P:O,t===s){const _=Math.abs(e[p]-n[p]);if(_<=i){const R=Math.min(i-1,i-_);l[p]===m?y[p]=(a[p]>e[p]?-1:1)*R:S[p]=(x[p]>n[p]?-1:1)*R}}if(t!==s){const _=p==="x"?"y":"x",R=l[p]===c[_],k=a[_]>x[_],v=a[_]<x[_];(l[p]===1&&(!R&&k||R&&v)||l[p]!==1&&(!R&&v||R&&k))&&(f=p==="x"?P:O)}const I={x:a.x+y.x,y:a.y+y.y},D={x:x.x+S.x,y:x.y+S.y},H=Math.max(Math.abs(I.x-f[0].x),Math.abs(D.x-f[0].x)),B=Math.max(Math.abs(I.y-f[0].y),Math.abs(D.y-f[0].y));H>=B?(h=(I.x+D.x)/2,j=f[0].y):(h=f[0].x,j=(I.y+D.y)/2)}return[[e,{x:a.x+y.x,y:a.y+y.y},...f,{x:x.x+S.x,y:x.y+S.y},n],h,j,C,L]}function c5(e,t,n,s){const r=Math.min(Ni(e,t)/2,Ni(t,n)/2,s),{x:i,y:l}=t;if(e.x===i&&i===n.x||e.y===l&&l===n.y)return`L${i} ${l}`;if(e.y===l){const x=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${i+r*x},${l}Q ${i},${l} ${i},${l+r*d}`}const c=e.x<n.x?1:-1,a=e.y<n.y?-1:1;return`L ${i},${l+r*a}Q ${i},${l} ${i+r*c},${l}`}function Yo({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:s,targetY:r,targetPosition:i=U.Top,borderRadius:l=5,centerX:c,centerY:a,offset:x=20}){const[d,p,m,f,h]=l5({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:r},targetPosition:i,center:{x:c,y:a},offset:x});return[d.reduce((y,S,b)=>{let E="";return b>0&&b<d.length-1?E=c5(d[b-1],S,d[b+1],l):E=`${b===0?"M":"L"}${S.x} ${S.y}`,y+=E,y},""),p,m,f,h]}function Ti(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function a5(e){var p;const{sourceNode:t,targetNode:n}=e;if(!Ti(t)||!Ti(n))return null;const s=t.internals.handleBounds||$i(t.handles),r=n.internals.handleBounds||$i(n.handles),i=Ai((s==null?void 0:s.source)??[],e.sourceHandle),l=Ai(e.connectionMode===Vt.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!i||!l)return(p=e.onError)==null||p.call(e,"008",Be.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(i==null?void 0:i.position)||U.Bottom,a=(l==null?void 0:l.position)||U.Top,x=Tn(t,i,c),d=Tn(n,l,a);return{sourceX:x.x,sourceY:x.y,targetX:d.x,targetY:d.y,sourcePosition:c,targetPosition:a}}function $i(e){if(!e)return null;const t=[],n=[];for(const s of e)s.width=s.width??1,s.height=s.height??1,s.type==="source"?t.push(s):s.type==="target"&&n.push(s);return{source:t,target:n}}function Tn(e,t,n=U.Left,s=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:l,height:c}=t??gt(e);if(s)return{x:r+l/2,y:i+c/2};switch((t==null?void 0:t.position)??n){case U.Top:return{x:r+l/2,y:i};case U.Right:return{x:r+l,y:i+c/2};case U.Bottom:return{x:r+l/2,y:i+c};case U.Left:return{x:r,y:i+c/2}}}function Ai(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Go(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function u5(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:r}){const i=new Set;return e.reduce((l,c)=>([c.markerStart||s,c.markerEnd||r].forEach(a=>{if(a&&typeof a=="object"){const x=Go(a,t);i.has(x)||(l.push({id:x,color:a.color||n,...a}),i.add(x))}}),l),[]).sort((l,c)=>l.id.localeCompare(c.id))}const $r={nodeOrigin:[0,0],nodeExtent:Ln,elevateNodesOnSelect:!0,defaults:{}},x5={...$r,checkEquality:!0};function Ar(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function d5(e,t,n){const s=Ar($r,n);for(const r of e.values())if(r.parentId)Ir(r,e,t,s);else{const i=On(r,s.nodeOrigin),l=rn(r.extent)?r.extent:s.nodeExtent,c=Ft(i,l,gt(r));r.internals.positionAbsolute=c}}function Ko(e,t,n,s){var a,x;const r=Ar(x5,s);let i=!0;const l=new Map(t),c=r!=null&&r.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const d of e){let p=l.get(d.id);if(r.checkEquality&&d===(p==null?void 0:p.internals.userNode))t.set(d.id,p);else{const m=On(d,r.nodeOrigin),f=rn(d.extent)?d.extent:r.nodeExtent,h=Ft(m,f,gt(d));p={...r.defaults,...d,measured:{width:(a=d.measured)==null?void 0:a.width,height:(x=d.measured)==null?void 0:x.height},internals:{positionAbsolute:h,handleBounds:d.measured?p==null?void 0:p.internals.handleBounds:void 0,z:Fa(d,c),userNode:d}},t.set(d.id,p)}(!p.measured||!p.measured.width||!p.measured.height)&&!p.hidden&&(i=!1),d.parentId&&Ir(p,t,n,s)}return i}function p5(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 Ir(e,t,n,s){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:l}=Ar($r,s),c=e.parentId,a=t.get(c);if(!a){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}p5(e,n);const x=r?1e3:0,{x:d,y:p,z:m}=m5(e,a,i,l,x),{positionAbsolute:f}=e.internals,h=d!==f.x||p!==f.y;(h||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:p}:f,z:m}})}function Fa(e,t){return(Je(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function m5(e,t,n,s,r){const{x:i,y:l}=t.internals.positionAbsolute,c=gt(e),a=On(e,n),x=rn(e.extent)?Ft(a,e.extent,c):a;let d=Ft({x:i+x.x,y:l+x.y},s,c);e.extent==="parent"&&(d=Ma(d,c,t));const p=Fa(e,r),m=t.internals.z??0;return{x:d.x,y:d.y,z:m>p?m:p}}function Dr(e,t,n,s=[0,0]){var l;const r=[],i=new Map;for(const c of e){const a=t.get(c.parentId);if(!a)continue;const x=((l=i.get(c.parentId))==null?void 0:l.expandedRect)??on(a),d=Pa(x,c.rect);i.set(c.parentId,{expandedRect:d,parent:a})}return i.size>0&&i.forEach(({expandedRect:c,parent:a},x)=>{var E;const d=a.internals.positionAbsolute,p=gt(a),m=a.origin??s,f=c.x<d.x?Math.round(Math.abs(d.x-c.x)):0,h=c.y<d.y?Math.round(Math.abs(d.y-c.y)):0,j=Math.max(p.width,Math.round(c.width)),y=Math.max(p.height,Math.round(c.height)),S=(j-p.width)*m[0],b=(y-p.height)*m[1];(f>0||h>0||S||b)&&(r.push({id:x,type:"position",position:{x:a.position.x-f+S,y:a.position.y-h+b}}),(E=n.get(x))==null||E.forEach(C=>{e.some(L=>L.id===C.id)||r.push({id:C.id,type:"position",position:{x:C.position.x+f,y:C.position.y+h}})})),(p.width<c.width||p.height<c.height||f||h)&&r.push({id:x,type:"dimensions",setAttributes:!0,dimensions:{width:j+(f?m[0]*f-S:0),height:y+(h?m[1]*h-b:0)}})}),r}function f5(e,t,n,s,r,i){const l=s==null?void 0:s.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const a=[],x=window.getComputedStyle(l),{m22:d}=new window.DOMMatrixReadOnly(x.transform),p=[];for(const m of e.values()){const f=t.get(m.id);if(!f)continue;if(f.hidden){t.set(f.id,{...f,internals:{...f.internals,handleBounds:void 0}}),c=!0;continue}const h=Tr(m.nodeElement),j=f.measured.width!==h.width||f.measured.height!==h.height;if(!!(h.width&&h.height&&(j||!f.internals.handleBounds||m.force))){const S=m.nodeElement.getBoundingClientRect(),b=rn(f.extent)?f.extent:i;let{positionAbsolute:E}=f.internals;f.parentId&&f.extent==="parent"?E=Ma(E,h,t.get(f.parentId)):b&&(E=Ft(E,b,h));const C={...f,measured:h,internals:{...f.internals,positionAbsolute:E,handleBounds:{source:_i("source",m.nodeElement,S,d,f.id),target:_i("target",m.nodeElement,S,d,f.id)}}};t.set(f.id,C),f.parentId&&Ir(C,t,n,{nodeOrigin:r}),c=!0,j&&(a.push({id:f.id,type:"dimensions",dimensions:h}),f.expandParent&&f.parentId&&p.push({id:f.id,parentId:f.parentId,rect:on(C,r)}))}}if(p.length>0){const m=Dr(p,t,n,r);a.push(...m)}return{changes:a,updatedInternals:c}}async function h5({delta:e,panZoom:t,transform:n,translateExtent:s,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const l=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],s),c=!!l&&(l.x!==n[0]||l.y!==n[1]||l.k!==n[2]);return Promise.resolve(c)}function Ii(e,t,n,s,r,i){let l=r;const c=s.get(l)||new Map;s.set(l,c.set(n,t)),l=`${r}-${e}`;const a=s.get(l)||new Map;if(s.set(l,a.set(n,t)),i){l=`${r}-${e}-${i}`;const x=s.get(l)||new Map;s.set(l,x.set(n,t))}}function Ha(e,t,n){e.clear(),t.clear();for(const s of n){const{source:r,target:i,sourceHandle:l=null,targetHandle:c=null}=s,a={edgeId:s.id,source:r,target:i,sourceHandle:l,targetHandle:c},x=`${r}-${l}--${i}-${c}`,d=`${i}-${c}--${r}-${l}`;Ii("source",a,d,e,r,l),Ii("target",a,x,e,i,c),t.set(s.id,s)}}function Za(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Za(n,t):!1}function Di(e,t,n){var r;let s=e;do{if((r=s==null?void 0:s.matches)!=null&&r.call(s,t))return!0;if(s===n)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function g5(e,t,n,s){const r=new Map;for(const[i,l]of e)if((l.selected||l.id===s)&&(!l.parentId||!Za(l,e))&&(l.draggable||t&&typeof l.draggable>"u")){const c=e.get(i);c&&r.set(i,{id:i,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return r}function yo({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){var l,c,a;const r=[];for(const[x,d]of t){const p=(l=n.get(x))==null?void 0:l.internals.userNode;p&&r.push({...p,position:d.position,dragging:s})}if(!e)return[r[0],r];const i=(c=n.get(e))==null?void 0:c.internals.userNode;return[i?{...i,position:((a=t.get(e))==null?void 0:a.position)||i.position,dragging:s}:r[0],r]}function j5({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:r}){let i={x:null,y:null},l=0,c=new Map,a=!1,x={x:0,y:0},d=null,p=!1,m=null,f=!1;function h({noDragClassName:y,handleSelector:S,domNode:b,isSelectable:E,nodeId:C,nodeClickDistance:L=0}){m=We(b);function T({x:D,y:H},B){const{nodeLookup:_,nodeExtent:R,snapGrid:k,snapToGrid:v,nodeOrigin:M,onNodeDrag:A,onSelectionDrag:$,onError:V,updateNodePositions:F}=t();i={x:D,y:H};let W=!1,ee={x:0,y:0,x2:0,y2:0};if(c.size>1&&R){const te=Vn(c);ee=Wo(te)}for(const[te,se]of c){if(!_.has(te))continue;let oe={x:D-se.distance.x,y:H-se.distance.y};v&&(oe=Xs(oe,k));let J=[[R[0][0],R[0][1]],[R[1][0],R[1][1]]];if(c.size>1&&R&&!se.extent){const{positionAbsolute:ke}=se.internals,de=ke.x-ee.x+R[0][0],G=ke.x+se.measured.width-ee.x2+R[1][0],ae=ke.y-ee.y+R[0][1],ue=ke.y+se.measured.height-ee.y2+R[1][1];J=[[de,ae],[G,ue]]}const{position:le,positionAbsolute:fe}=ka({nodeId:te,nextPosition:oe,nodeLookup:_,nodeExtent:J,nodeOrigin:M,onError:V});W=W||se.position.x!==le.x||se.position.y!==le.y,se.position=le,se.internals.positionAbsolute=fe}if(W&&(F(c,!0),B&&(s||A||!C&&$))){const[te,se]=yo({nodeId:C,dragItems:c,nodeLookup:_});s==null||s(B,c,te,se),A==null||A(B,te,se),C||$==null||$(B,se)}}async function P(){if(!d)return;const{transform:D,panBy:H,autoPanSpeed:B,autoPanOnNodeDrag:_}=t();if(!_){a=!1,cancelAnimationFrame(l);return}const[R,k]=_a(x,d,B);(R!==0||k!==0)&&(i.x=(i.x??0)-R/D[2],i.y=(i.y??0)-k/D[2],await H({x:R,y:k})&&T(i,null)),l=requestAnimationFrame(P)}function O(D){var W;const{nodeLookup:H,multiSelectionActive:B,nodesDraggable:_,transform:R,snapGrid:k,snapToGrid:v,selectNodesOnDrag:M,onNodeDragStart:A,onSelectionDragStart:$,unselectNodesAndEdges:V}=t();p=!0,(!M||!E)&&!B&&C&&((W=H.get(C))!=null&&W.selected||V()),E&&M&&C&&(e==null||e(C));const F=Cn(D.sourceEvent,{transform:R,snapGrid:k,snapToGrid:v,containerBounds:d});if(i=F,c=g5(H,_,F,C),c.size>0&&(n||A||!C&&$)){const[ee,te]=yo({nodeId:C,dragItems:c,nodeLookup:H});n==null||n(D.sourceEvent,c,ee,te),A==null||A(D.sourceEvent,ee,te),C||$==null||$(D.sourceEvent,te)}}const I=da().clickDistance(L).on("start",D=>{const{domNode:H,nodeDragThreshold:B,transform:_,snapGrid:R,snapToGrid:k}=t();d=(H==null?void 0:H.getBoundingClientRect())||null,f=!1,B===0&&O(D),i=Cn(D.sourceEvent,{transform:_,snapGrid:R,snapToGrid:k,containerBounds:d}),x=dt(D.sourceEvent,d)}).on("drag",D=>{const{autoPanOnNodeDrag:H,transform:B,snapGrid:_,snapToGrid:R,nodeDragThreshold:k,nodeLookup:v}=t(),M=Cn(D.sourceEvent,{transform:B,snapGrid:_,snapToGrid:R,containerBounds:d});if((D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||C&&!v.has(C))&&(f=!0),!f){if(!a&&H&&p&&(a=!0,P()),!p){const A=M.xSnapped-(i.x??0),$=M.ySnapped-(i.y??0);Math.sqrt(A*A+$*$)>k&&O(D)}(i.x!==M.xSnapped||i.y!==M.ySnapped)&&c&&p&&(x=dt(D.sourceEvent,d),T(M,D.sourceEvent))}}).on("end",D=>{if(!(!p||f)&&(a=!1,p=!1,cancelAnimationFrame(l),c.size>0)){const{nodeLookup:H,updateNodePositions:B,onNodeDragStop:_,onSelectionDragStop:R}=t();if(B(c,!1),r||_||!C&&R){const[k,v]=yo({nodeId:C,dragItems:c,nodeLookup:H,dragging:!1});r==null||r(D.sourceEvent,c,k,v),_==null||_(D.sourceEvent,k,v),C||R==null||R(D.sourceEvent,v)}}}).filter(D=>{const H=D.target;return!D.button&&(!y||!Di(H,`.${y}`,b))&&(!S||Di(H,S,b))});m.call(I)}function j(){m==null||m.on(".drag",null)}return{update:h,destroy:j}}function E5(e,t,n){const s=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Nn(r,on(i))>0&&s.push(i);return s}const y5=250;function S5(e,t,n,s){var c,a;let r=[],i=1/0;const l=E5(e,n,t+y5);for(const x of l){const d=[...((c=x.internals.handleBounds)==null?void 0:c.source)??[],...((a=x.internals.handleBounds)==null?void 0:a.target)??[]];for(const p of d){if(s.nodeId===p.nodeId&&s.type===p.type&&s.id===p.id)continue;const{x:m,y:f}=Tn(x,p,p.position,!0),h=Math.sqrt(Math.pow(m-e.x,2)+Math.pow(f-e.y,2));h>t||(h<i?(r=[{...p,x:m,y:f}],i=h):h===i&&r.push({...p,x:m,y:f}))}}if(!r.length)return null;if(r.length>1){const x=s.type==="source"?"target":"source";return r.find(d=>d.type===x)??r[0]}return r[0]}function Wa(e,t,n,s,r,i=!1){var x,d,p;const l=s.get(e);if(!l)return null;const c=r==="strict"?(x=l.internals.handleBounds)==null?void 0:x[t]:[...((d=l.internals.handleBounds)==null?void 0:d.source)??[],...((p=l.internals.handleBounds)==null?void 0:p.target)??[]],a=(n?c==null?void 0:c.find(m=>m.id===n):c==null?void 0:c[0])??null;return a&&i?{...a,...Tn(l,a,a.position,!0)}:a}function Ya(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function R5(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ga=()=>!0;function C5(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:r,edgeUpdaterType:i,isTarget:l,domNode:c,nodeLookup:a,lib:x,autoPanOnConnect:d,flowId:p,panBy:m,cancelConnection:f,onConnectStart:h,onConnect:j,onConnectEnd:y,isValidConnection:S=Ga,onReconnectEnd:b,updateConnection:E,getTransform:C,getFromHandle:L,autoPanSpeed:T}){const P=Ta(e.target);let O=0,I;const{x:D,y:H}=dt(e),B=P==null?void 0:P.elementFromPoint(D,H),_=Ya(i,B),R=c==null?void 0:c.getBoundingClientRect();if(!R||!_)return;const k=Wa(r,_,s,a,t);if(!k)return;let v=dt(e,R),M=!1,A=null,$=!1,V=null;function F(){if(!d||!R)return;const[fe,ke]=_a(v,R,T);m({x:fe,y:ke}),O=requestAnimationFrame(F)}const W={...k,nodeId:r,type:_,position:k.position},ee=a.get(r),se={inProgress:!0,isValid:null,from:Tn(ee,W,U.Left,!0),fromHandle:W,fromPosition:W.position,fromNode:ee,to:v,toHandle:null,toPosition:bi[W.position],toNode:null};E(se);let oe=se;h==null||h(e,{nodeId:r,handleId:s,handleType:_});function J(fe){if(!L()||!W){le(fe);return}const ke=C();v=dt(fe,R),I=S5(Fn(v,ke,!1,[1,1]),n,a,W),M||(F(),M=!0);const de=Ka(fe,{handle:I,connectionMode:t,fromNodeId:r,fromHandleId:s,fromType:l?"target":"source",isValidConnection:S,doc:P,lib:x,flowId:p,nodeLookup:a});V=de.handleDomNode,A=de.connection,$=R5(!!I,de.isValid);const G={...oe,isValid:$,to:I&&$?_s({x:I.x,y:I.y},ke):v,toHandle:de.toHandle,toPosition:$&&de.toHandle?de.toHandle.position:bi[W.position],toNode:de.toHandle?a.get(de.toHandle.nodeId):null};$&&I&&oe.toHandle&&G.toHandle&&oe.toHandle.type===G.toHandle.type&&oe.toHandle.nodeId===G.toHandle.nodeId&&oe.toHandle.id===G.toHandle.id&&oe.to.x===G.to.x&&oe.to.y===G.to.y||(E(G),oe=G)}function le(fe){(I||V)&&A&&$&&(j==null||j(A));const{inProgress:ke,...de}=oe,G={...de,toPosition:oe.toHandle?oe.toPosition:null};y==null||y(fe,G),i&&(b==null||b(fe,G)),f(),cancelAnimationFrame(O),M=!1,$=!1,A=null,V=null,P.removeEventListener("mousemove",J),P.removeEventListener("mouseup",le),P.removeEventListener("touchmove",J),P.removeEventListener("touchend",le)}P.addEventListener("mousemove",J),P.addEventListener("mouseup",le),P.addEventListener("touchmove",J),P.addEventListener("touchend",le)}function Ka(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:r,fromType:i,doc:l,lib:c,flowId:a,isValidConnection:x=Ga,nodeLookup:d}){const p=i==="target",m=t?l.querySelector(`.${c}-flow__handle[data-id="${a}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:f,y:h}=dt(e),j=l.elementFromPoint(f,h),y=j!=null&&j.classList.contains(`${c}-flow__handle`)?j:m,S={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const b=Ya(void 0,y),E=y.getAttribute("data-nodeid"),C=y.getAttribute("data-handleid"),L=y.classList.contains("connectable"),T=y.classList.contains("connectableend");if(!E||!b)return S;const P={source:p?E:s,sourceHandle:p?C:r,target:p?s:E,targetHandle:p?r:C};S.connection=P;const I=L&&T&&(n===Vt.Strict?p&&b==="source"||!p&&b==="target":E!==s||C!==r);S.isValid=I&&x(P),S.toHandle=Wa(E,b,C,d,n,!1)}return S}const qo={onPointerDown:C5,isValid:Ka};function w5({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const r=We(e);function i({translateExtent:c,width:a,height:x,zoomStep:d=10,pannable:p=!0,zoomable:m=!0,inversePan:f=!1}){const h=E=>{const C=n();if(E.sourceEvent.type!=="wheel"||!t)return;const L=-E.sourceEvent.deltaY*(E.sourceEvent.deltaMode===1?.05:E.sourceEvent.deltaMode?1:.002)*d,T=C[2]*Math.pow(2,L);t.scaleTo(T)};let j=[0,0];const y=E=>{(E.sourceEvent.type==="mousedown"||E.sourceEvent.type==="touchstart")&&(j=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY])},S=E=>{const C=n();if(E.sourceEvent.type!=="mousemove"&&E.sourceEvent.type!=="touchmove"||!t)return;const L=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY],T=[L[0]-j[0],L[1]-j[1]];j=L;const P=s()*Math.max(C[2],Math.log(C[2]))*(f?-1:1),O={x:C[0]-T[0]*P,y:C[1]-T[1]*P},I=[[0,0],[a,x]];t.setViewportConstrained({x:O.x,y:O.y,zoom:C[2]},I,c)},b=Sa().on("start",y).on("zoom",p?S:null).on("zoom.wheel",m?h:null);r.call(b,{})}function l(){r.on("zoom",null)}return{update:i,destroy:l,pointer:Ue}}const b5=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Us=e=>({x:e.x,y:e.y,zoom:e.k}),So=({x:e,y:t,zoom:n})=>Gs.translate(e,t).scale(n),Xt=(e,t)=>e.target.closest(`.${t}`),qa=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ro=(e,t=0,n=()=>{})=>{const s=typeof t=="number"&&t>0;return s||n(),s?e.transition().duration(t).on("end",n):e},Xa=e=>{const t=e.ctrlKey&&Ps()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function v5({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:l,onPanZoomStart:c,onPanZoom:a,onPanZoomEnd:x}){return d=>{if(Xt(d,t))return!1;d.preventDefault(),d.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(d.ctrlKey&&l){const y=Ue(d),S=Xa(d),b=p*Math.pow(2,S);s.scaleTo(n,b,y,d);return}const m=d.deltaMode===1?20:1;let f=r===It.Vertical?0:d.deltaX*m,h=r===It.Horizontal?0:d.deltaY*m;!Ps()&&d.shiftKey&&r!==It.Vertical&&(f=d.deltaY*m,h=0),s.translateBy(n,-(f/p)*i,-(h/p)*i,{internal:!0});const j=Us(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,c==null||c(d,j)),e.isPanScrolling&&(a==null||a(d,j),e.panScrollTimeout=setTimeout(()=>{x==null||x(d,j),e.isPanScrolling=!1},150))}}function k5({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,r){const i=s.type==="wheel",l=!t&&i&&!s.ctrlKey,c=Xt(s,e);if(s.ctrlKey&&i&&c&&s.preventDefault(),l||c)return null;s.preventDefault(),n.call(this,s,r)}}function M5({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{var i,l,c;if((i=s.sourceEvent)!=null&&i.internal)return;const r=Us(s.transform);e.mouseButton=((l=s.sourceEvent)==null?void 0:l.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((c=s.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(s.sourceEvent,r))}}function _5({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:r}){return i=>{var l,c;e.usedRightMouseButton=!!(n&&qa(t,e.mouseButton??0)),(l=i.sourceEvent)!=null&&l.sync||s([i.transform.x,i.transform.y,i.transform.k]),r&&!((c=i.sourceEvent)!=null&&c.internal)&&(r==null||r(i.sourceEvent,Us(i.transform)))}}function P5({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:r,onPaneContextMenu:i}){return l=>{var c;if(!((c=l.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,i&&qa(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&i(l.sourceEvent),e.usedRightMouseButton=!1,s(!1),r&&b5(e.prevViewport,l.transform))){const a=Us(l.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(l.sourceEvent,a)},n?150:0)}}}function L5({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:s,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:l,noWheelClassName:c,noPanClassName:a,lib:x}){return d=>{var h;const p=e||t,m=n&&d.ctrlKey;if(d.button===1&&d.type==="mousedown"&&(Xt(d,`${x}-flow__node`)||Xt(d,`${x}-flow__edge`)))return!0;if(!s&&!p&&!r&&!i&&!n||l||Xt(d,c)&&d.type==="wheel"||Xt(d,a)&&(d.type!=="wheel"||r&&d.type==="wheel"&&!e)||!n&&d.ctrlKey&&d.type==="wheel")return!1;if(!n&&d.type==="touchstart"&&((h=d.touches)==null?void 0:h.length)>1)return d.preventDefault(),!1;if(!p&&!r&&!m&&d.type==="wheel"||!s&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(s)&&!s.includes(d.button)&&d.type==="mousedown")return!1;const f=Array.isArray(s)&&s.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||d.type==="wheel")&&f}}function N5({domNode:e,minZoom:t,maxZoom:n,paneClickDistance:s,translateExtent:r,viewport:i,onPanZoom:l,onPanZoomStart:c,onPanZoomEnd:a,onDraggingChange:x}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),m=Sa().clickDistance(!Je(s)||s<0?0:s).scaleExtent([t,n]).translateExtent(r),f=We(e).call(m);E({x:i.x,y:i.y,zoom:sn(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const h=f.on("wheel.zoom"),j=f.on("dblclick.zoom");m.wheelDelta(Xa);function y(B,_){return f?new Promise(R=>{m==null||m.transform(Ro(f,_==null?void 0:_.duration,()=>R(!0)),B)}):Promise.resolve(!1)}function S({noWheelClassName:B,noPanClassName:_,onPaneContextMenu:R,userSelectionActive:k,panOnScroll:v,panOnDrag:M,panOnScrollMode:A,panOnScrollSpeed:$,preventScrolling:V,zoomOnPinch:F,zoomOnScroll:W,zoomOnDoubleClick:ee,zoomActivationKeyPressed:te,lib:se,onTransformChange:oe}){k&&!d.isZoomingOrPanning&&b();const le=v&&!te&&!k?v5({zoomPanValues:d,noWheelClassName:B,d3Selection:f,d3Zoom:m,panOnScrollMode:A,panOnScrollSpeed:$,zoomOnPinch:F,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:a}):k5({noWheelClassName:B,preventScrolling:V,d3ZoomHandler:h});if(f.on("wheel.zoom",le,{passive:!1}),!k){const ke=M5({zoomPanValues:d,onDraggingChange:x,onPanZoomStart:c});m.on("start",ke);const de=_5({zoomPanValues:d,panOnDrag:M,onPaneContextMenu:!!R,onPanZoom:l,onTransformChange:oe});m.on("zoom",de);const G=P5({zoomPanValues:d,panOnDrag:M,panOnScroll:v,onPaneContextMenu:R,onPanZoomEnd:a,onDraggingChange:x});m.on("end",G)}const fe=L5({zoomActivationKeyPressed:te,panOnDrag:M,zoomOnScroll:W,panOnScroll:v,zoomOnDoubleClick:ee,zoomOnPinch:F,userSelectionActive:k,noPanClassName:_,noWheelClassName:B,lib:se});m.filter(fe),ee?f.on("dblclick.zoom",j):f.on("dblclick.zoom",null)}function b(){m.on("zoom",null)}async function E(B,_,R){const k=So(B),v=m==null?void 0:m.constrain()(k,_,R);return v&&await y(v),new Promise(M=>M(v))}async function C(B,_){const R=So(B);return await y(R,_),new Promise(k=>k(R))}function L(B){if(f){const _=So(B),R=f.property("__zoom");(R.k!==B.zoom||R.x!==B.x||R.y!==B.y)&&(m==null||m.transform(f,_,null,{sync:!0}))}}function T(){const B=f?ya(f.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function P(B,_){return f?new Promise(R=>{m==null||m.scaleTo(Ro(f,_==null?void 0:_.duration,()=>R(!0)),B)}):Promise.resolve(!1)}function O(B,_){return f?new Promise(R=>{m==null||m.scaleBy(Ro(f,_==null?void 0:_.duration,()=>R(!0)),B)}):Promise.resolve(!1)}function I(B){m==null||m.scaleExtent(B)}function D(B){m==null||m.translateExtent(B)}function H(B){const _=!Je(B)||B<0?0:B;m==null||m.clickDistance(_)}return{update:S,destroy:b,setViewport:C,setViewportConstrained:E,getViewport:T,scaleTo:P,scaleBy:O,setScaleExtent:I,setTranslateExtent:D,syncViewport:L,setClickDistance:H}}var wn;(function(e){e.Line="line",e.Handle="handle"})(wn||(wn={}));function T5({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:r,affectsY:i}){const l=e-t,c=n-s,a=[l>0?1:l<0?-1:0,c>0?1:c<0?-1:0];return l&&r&&(a[0]=a[0]*-1),c&&i&&(a[1]=a[1]*-1),a}function $5(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),s=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:s,affectsY:r}}function Et(e,t){return Math.max(0,t-e)}function yt(e,t){return Math.max(0,e-t)}function Jn(e,t,n){return Math.max(0,t-e,e-n)}function zi(e,t){return e?!t:t}function A5(e,t,n,s,r,i,l,c){let{affectsX:a,affectsY:x}=t;const{isHorizontal:d,isVertical:p}=t,m=d&&p,{xSnapped:f,ySnapped:h}=n,{minWidth:j,maxWidth:y,minHeight:S,maxHeight:b}=s,{x:E,y:C,width:L,height:T,aspectRatio:P}=e;let O=Math.floor(d?f-e.pointerX:0),I=Math.floor(p?h-e.pointerY:0);const D=L+(a?-O:O),H=T+(x?-I:I),B=-i[0]*L,_=-i[1]*T;let R=Jn(D,j,y),k=Jn(H,S,b);if(l){let A=0,$=0;a&&O<0?A=Et(E+O+B,l[0][0]):!a&&O>0&&(A=yt(E+D+B,l[1][0])),x&&I<0?$=Et(C+I+_,l[0][1]):!x&&I>0&&($=yt(C+H+_,l[1][1])),R=Math.max(R,A),k=Math.max(k,$)}if(c){let A=0,$=0;a&&O>0?A=yt(E+O,c[0][0]):!a&&O<0&&(A=Et(E+D,c[1][0])),x&&I>0?$=yt(C+I,c[0][1]):!x&&I<0&&($=Et(C+H,c[1][1])),R=Math.max(R,A),k=Math.max(k,$)}if(r){if(d){const A=Jn(D/P,S,b)*P;if(R=Math.max(R,A),l){let $=0;!a&&!x||a&&!x&&m?$=yt(C+_+D/P,l[1][1])*P:$=Et(C+_+(a?O:-O)/P,l[0][1])*P,R=Math.max(R,$)}if(c){let $=0;!a&&!x||a&&!x&&m?$=Et(C+D/P,c[1][1])*P:$=yt(C+(a?O:-O)/P,c[0][1])*P,R=Math.max(R,$)}}if(p){const A=Jn(H*P,j,y)/P;if(k=Math.max(k,A),l){let $=0;!a&&!x||x&&!a&&m?$=yt(E+H*P+B,l[1][0])/P:$=Et(E+(x?I:-I)*P+B,l[0][0])/P,k=Math.max(k,$)}if(c){let $=0;!a&&!x||x&&!a&&m?$=Et(E+H*P,c[1][0])/P:$=yt(E+(x?I:-I)*P,c[0][0])/P,k=Math.max(k,$)}}}I=I+(I<0?k:-k),O=O+(O<0?R:-R),r&&(m?D>H*P?I=(zi(a,x)?-O:O)/P:O=(zi(a,x)?-I:I)*P:d?(I=O/P,x=a):(O=I*P,a=x));const v=a?E+O:E,M=x?C+I:C;return{width:L+(a?-O:O),height:T+(x?-I:I),x:i[0]*O*(a?-1:1)+v,y:i[1]*I*(x?-1:1)+M}}const Ua={width:0,height:0,x:0,y:0},I5={...Ua,pointerX:0,pointerY:0,aspectRatio:1};function D5(e){return[[0,0],[e.measured.width,e.measured.height]]}function z5(e,t,n){const s=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,l=e.measured.height??0,c=n[0]*i,a=n[1]*l;return[[s-c,r-a],[s+i-c,r+l-a]]}function B5({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:r}){const i=We(e);function l({controlPosition:a,boundaries:x,keepAspectRatio:d,onResizeStart:p,onResize:m,onResizeEnd:f,shouldResize:h}){let j={...Ua},y={...I5};const S=$5(a);let b,E=null,C=[],L,T,P;const O=da().on("start",I=>{const{nodeLookup:D,transform:H,snapGrid:B,snapToGrid:_,nodeOrigin:R,paneDomNode:k}=n();if(b=D.get(t),!b)return;E=(k==null?void 0:k.getBoundingClientRect())??null;const{xSnapped:v,ySnapped:M}=Cn(I.sourceEvent,{transform:H,snapGrid:B,snapToGrid:_,containerBounds:E});j={width:b.measured.width??0,height:b.measured.height??0,x:b.position.x??0,y:b.position.y??0},y={...j,pointerX:v,pointerY:M,aspectRatio:j.width/j.height},L=void 0,b.parentId&&(b.extent==="parent"||b.expandParent)&&(L=D.get(b.parentId),T=L&&b.extent==="parent"?D5(L):void 0),C=[],P=void 0;for(const[A,$]of D)if($.parentId===t&&(C.push({id:A,position:{...$.position},extent:$.extent}),$.extent==="parent"||$.expandParent)){const V=z5($,b,$.origin??R);P?P=[[Math.min(V[0][0],P[0][0]),Math.min(V[0][1],P[0][1])],[Math.max(V[1][0],P[1][0]),Math.max(V[1][1],P[1][1])]]:P=V}p==null||p(I,{...j})}).on("drag",I=>{const{transform:D,snapGrid:H,snapToGrid:B,nodeOrigin:_}=n(),R=Cn(I.sourceEvent,{transform:D,snapGrid:H,snapToGrid:B,containerBounds:E}),k=[];if(!b)return;const{x:v,y:M,width:A,height:$}=j,V={},F=b.origin??_,{width:W,height:ee,x:te,y:se}=A5(y,S,R,x,d,F,T,P),oe=W!==A,J=ee!==$,le=te!==v&&oe,fe=se!==M&&J;if(!le&&!fe&&!oe&&!J)return;if((le||fe||F[0]===1||F[1]===1)&&(V.x=le?te:j.x,V.y=fe?se:j.y,j.x=V.x,j.y=V.y,C.length>0)){const ae=te-v,ue=se-M;for(const _e of C)_e.position={x:_e.position.x-ae+F[0]*(W-A),y:_e.position.y-ue+F[1]*(ee-$)},k.push(_e)}if((oe||J)&&(V.width=oe?W:j.width,V.height=J?ee:j.height,j.width=V.width,j.height=V.height),L&&b.expandParent){const ae=F[0]*(V.width??0);V.x&&V.x<ae&&(j.x=ae,y.x=y.x-(V.x-ae));const ue=F[1]*(V.height??0);V.y&&V.y<ue&&(j.y=ue,y.y=y.y-(V.y-ue))}const ke=T5({width:j.width,prevWidth:A,height:j.height,prevHeight:$,affectsX:S.affectsX,affectsY:S.affectsY}),de={...j,direction:ke};(h==null?void 0:h(I,de))!==!1&&(m==null||m(I,de),s(V,k))}).on("end",I=>{f==null||f(I,{...j}),r==null||r({...j})});i.call(O)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var Qn={exports:{}},Co={},es={exports:{}},wo={};/**
1
+ "use strict";var kf=Object.defineProperty;var Mf=(e,t,n)=>t in e?kf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var tt=(e,t,n)=>Mf(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./jsx-runtime-CITbqOLs.cjs"),g=require("react"),Z=require("./Divider-Dut8qPee.cjs"),u=require("./css-9iEiTRNL.cjs"),ss=require("./external-CzTBFiv_.cjs"),st=require("./state-_FFrG5nH.cjs"),_f=require("./Stack-BbwDtaE6.cjs"),ge=require("./external-DQwznOyH.cjs"),ne=require("./Space-DvalhzRj.cjs"),Ie=require("./hooks-B5aLaWzS.cjs"),Pf=require("./useVirtualCursorDragWebKit-DDmXE4RW.cjs"),Q=require("./Provider-Cw0mSr2D.cjs"),Lf=require("./external-BGBgNbe2.cjs"),Le=require("./external-DGJ8YAe-.cjs"),El=require("./external-Dq8-cbf3.cjs"),Ns=require("./WithIcon-BgS5shNZ.cjs"),Me=require("./toArray-BvVYuN_b.cjs"),Nf=require("./external-DmryCcwg.cjs"),In=require("./external-CTc1n-JC.cjs"),he=require("./Toggle-C0lZDyeo.cjs"),mt=require("./Text-C8GBHl-F.cjs"),nt=require("./provider-aWtsGnV8.cjs"),Re=require("./Text-CMTkSEWx.cjs"),z=require("./value-CkzEjG7v.cjs"),me=require("./Haul-C6i2oI7z.cjs"),Ne=require("./useMemoCompare-C2X7Mzx8.cjs"),Ur=require("./dimensions-By-vgVks.cjs"),Jo=require("./font-XlUAG1-r.cjs"),Ge=require("./Dropdown-BSSe1E1e.cjs"),ze=require("./deep-BNa3STCp.cjs"),pe=require("zod"),Ke=require("./external-zbKPQ9ls.cjs"),Ts=require("./Pack-DeZUUdJM.cjs"),kt=require("./ContextMenu-HpMLd1Ht.cjs"),Tf=require("./Text-DkA06TeT.cjs"),yl=require("./external-DiLZ1dEk.cjs");require("./Item-DSBs9VLu.cjs");const Sl=require("react-dom"),Mt=require("./external-B8uaUKhb.cjs"),Rl=require("./units-CX_coN92.cjs"),$f=require("./useClickOutside-CSff8yb-.cjs"),Qo=require("./useDebouncedCallback-DnwYZzjR.cjs"),Af=require("./external-CUgPP-JD.cjs"),xs=require("./eraser-BkqFgBRY.cjs"),_o=require("./DateTime-BsjSfOY-.cjs"),If=require("./external-BwUa_5Vs.cjs"),Df=require("./Video-DgjuFLiE.cjs"),zf=(e,t,n=150)=>{const[s,r]=g.useState(e);return g.useEffect(()=>{const i=setTimeout(()=>r(t),n);return()=>clearTimeout(i)},[t,n]),s},Bf=Object.freeze(Object.defineProperty({__proto__:null,Config:he.Config,Dialog:he.Dialog,chooseLocation:he.chooseLocation,formatTip:he.formatTip,useConfig:he.useConfig,wrap:he.wrap},Symbol.toStringTag,{value:"Module"})),er=({ref:e,location:t,style:n,size:s,className:r,children:i,onDragStart:l,sizeUnits:c="px",showHandle:a=!0,...x})=>{const d=u.K.construct(t),p=u.K.direction(d),m=u.g.dimension(p);return o.jsxRuntimeExports.jsxs(ne.Core,{className:u.CSS(u.CSS.B("resize"),u.CSS.loc(d),u.CSS.dir(p),r),style:{[m]:`${s}${c}`,...n},ref:e,...x,children:[i,a&&o.jsxRuntimeExports.jsx("div",{draggable:!0,className:u.CSS(u.CSS.BE("resize","handle"),u.CSS.bordered(u.K.swap(d))),onDragStart:l,onDrag:ge.preventDefault,onDragEnd:ge.preventDefault})]})},tr=({onResize:e,count:t,initialSizes:n=[],minSize:s=100,direction:r="x"})=>{const i=g.useRef(null),[l,c]=g.useState({sizeDistribution:Of(n,t),root:null}),a=g.useCallback((p,m,f)=>{if(i.current==null)return;const h=u.$t.dim(u.$t.construct(i.current),r);c(j=>po(j,h,p,s,m,f))},[s,c,r]);g.useEffect(()=>e==null?void 0:e(l.sizeDistribution),[l.sizeDistribution,e]);const x=g.useCallback((p,m)=>{p.preventDefault();const f=r==="x"?"clientX":"clientY",h=y=>a(m,y[f]),j=()=>{c(y=>({...y,root:null})),document.removeEventListener("mousemove",h)};c(y=>({...y,root:p[f]})),document.addEventListener("mousemove",h),document.addEventListener("mouseup",j,{once:!0})},[c,r,po]);return{setSize:g.useCallback((p,m)=>a(p,void 0,m),[po]),props:{direction:r,sizeDistribution:l.sizeDistribution,onDragHandle:x,ref:i}}},nr=({ref:e,direction:t="x",children:n,sizeDistribution:s,onDragHandle:r,className:i,...l})=>{const c=u.g.construct(t),a=g.Children.toArray(n);return s=Vf(s),o.jsxRuntimeExports.jsx(ne.Space,{...l,ref:e,direction:c,className:u.CSS(u.CSS.B("resize-multiple"),i),empty:!0,grow:!0,children:a.map((x,d)=>o.jsxRuntimeExports.jsx(er,{onDragStart:p=>r(p,d),location:u.g.location(c),size:s[d]*100,sizeUnits:"%",showHandle:d!==a.length-1,children:x},d))})},Of=(e,t)=>{const n=e.reduce((r,i)=>r+i,0),s=t-e.length;if(s<=0)return e.slice(0,t).map(r=>r/n);if(e.every(r=>r<=1)){const r=1-n;return[...e,...Array(s).fill(r/s)]}return e.map(()=>1/t)},xo=.001,Vf=e=>e.every(t=>u.Wt.closeTo(t,1/e.length),xo)?e.map((t,n)=>n%2===0?t+xo:n===e.length-1?t:t-xo):e,po=(e,t,n,s,r,i)=>{const l=Cl(e,t,n,r,i),[c,a]=Ff(e.sizeDistribution,n,l,s/t),x=a?r??null:e.root;return{...e,sizeDistribution:c,root:x}},Cl=(e,t,n,s,r)=>{let i;if(r!=null)r>1&&(r/=t),i=r-e.sizeDistribution[n];else if(s!=null){if(e.root===null)throw new Error("resize root is null during handle drag");i=(s-e.root)/t}else throw new Error("must provide either a MouseEvent or a targetSize");return i},Ff=(e,t,n,s)=>{let r=t;for(;r>0&&e[r]+n<=s;)r--;const i=e[r]+n,l=Hf(r,e,s,n),c=e[l]-n;return i<s||c<s?[e,!1]:[e.map((a,x)=>x===r?i:x===l?c:a),!0]},Hf=(e,t,n,s)=>(e===t.length-1?Wf:Zf)(e,t,n,s),Zf=(e,t,n,s)=>{let r=e+1;for(;r<t.length-1&&t[r]-s<=n;)r++;return r},Wf=(e,t,n,s)=>{let r=e-1;for(;r>0&&t[r]-s<=n;)r--;return r},mo=2,Yf=100,wl=({onCollapse:e,onResize:t,location:n="left",minSize:s,maxSize:r,initialSize:i=200,collapseThreshold:l=1/0,className:c,...a})=>{const[x,d]=g.useState(u.Y(i,s,r)),p=g.useRef(null),m=u.K.construct(n),f=g.useCallback(E=>{if(p.current===null)return 0;const C=u.$t.dim(E,u.K.direction(m),!0)*(1-2*Number(["bottom","right"].includes(m))),L=p.current+C,T=u.Y(L,s,r);return(T-L)/(s??Yf)>l?mo:T},[m,s,r,l]),h=g.useRef(null),j=g.useCallback(E=>{const C=f(E);d(C),h.current!=null&&(t==null||t(C,u.$t.construct(h.current)))},[t,f]),y=g.useCallback(()=>d(E=>(p.current=E,E)),[d]),S=g.useCallback(E=>f(E)===mo&&(e==null?void 0:e()),[e,f]);g.useEffect(()=>{s==null||r==null||d(E=>{const C=u.Y(E,s,r);return p.current=C,C})},[s,r]);const b=Ke.useCursorDrag({onMove:j,onStart:y,onEnd:S});return o.jsxRuntimeExports.jsx(er,{ref:h,location:m,size:x,onDragStart:b,className:u.clsx(c,u.CSS.expanded(x!==mo)),...a})},Gf=Object.freeze(Object.defineProperty({__proto__:null,Core:er,Multiple:nr,Single:wl,calculateDiffPercentage:Cl,useMultiple:tr},Symbol.toStringTag,{value:"Module"})),os="y",Jr=28,Kf=32,qf=40,Xf=.5,Uf=({data:e,...t})=>{const{setSize:n,props:{sizeDistribution:s,ref:r,...i}}=tr({direction:os,count:e.length,minSize:Jr}),l=c=>{if(r.current==null)return;const a=u.$t.dim(u.$t.construct(r.current),os);s[c]<qf/a?n(c,e[c].initialSize??Xf):n(c,Jr+1)};return o.jsxRuntimeExports.jsx(nr,{empty:!0,className:u.CSS.B("accordion"),sizeDistribution:s,ref:r,...t,...i,children:e.map((c,a)=>g.createElement(eh,{...c,key:c.key,index:a,direction:os,onExpand:l,parent:r,size:s[a]}))})},Jf=o.jsxRuntimeExports.jsx(Z.y4.Caret.Down,{"aria-label":"contract"}),Qf=o.jsxRuntimeExports.jsx(Z.y4.Caret.Right,{"aria-label":"expand"}),eh=({index:e,name:t,content:n,actions:s,size:r,parent:i,onExpand:l})=>{let c=!0;if(i.current!=null){const x=u.$t.dim(u.$t.construct(i.current),os);c=r*x>Kf}const a=c?Jf:Qf;return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsxs(ss.Header,{level:"p",className:u.CSS.expanded(c),empty:!0,children:[o.jsxRuntimeExports.jsx(ss.ButtonTitle,{startIcon:a,onClick:()=>l(e),children:t}),s!=null&&o.jsxRuntimeExports.jsx(ss.Actions,{children:s})]}),n]})},th=Object.freeze(Object.defineProperty({__proto__:null,Accordion:Uf},Symbol.toStringTag,{value:"Module"})),nh=(e,t)=>Me.A(e).map(s=>typeof s=="string"?s.split(t).map(r=>({label:r})):s).flat(),bl=({segments:e,shade:t,level:n,weight:s,separator:r,transform:i})=>{let c=nh(e,r);return i!=null&&(c=c.map(i)),c.map(({label:a,icon:x,href:d,...p},m)=>{const f=[o.jsxRuntimeExports.jsx(Z.y4.Caret.Right,{style:{transform:"scale(0.8) translateY(0.5px)",color:u.CSS.shade(t)}},`${a}-${m}`)];if(x!=null){const j=Le.resolve(x);j!=null&&f.push(j)}const h={weight:s,shade:t,level:n,style:{marginLeft:x!=null?"0.5rem":"0"},children:a,...p};return d!=null?f.push(o.jsxRuntimeExports.jsx(El.Link,{...h,href:d},a)):f.push(o.jsxRuntimeExports.jsx(Z.Text,{...h},a)),f}).flat()},vl=({children:e,icon:t,shade:n=9,weight:s,size:r=.5,url:i,level:l="p",separator:c=".",className:a,hideFirst:x=!0,...d})=>{i!=null&&(e=i);const p=bl({segments:e,separator:c,shade:n,level:l,weight:s});return x&&p.shift(),o.jsxRuntimeExports.jsxs(Ns.WithIcon,{className:u.CSS(a,u.CSS.B("breadcrumb"),x&&u.CSS.M("hide-first")),level:l,shade:n,weight:s,size:r,x:!0,...d,children:[Le.resolve(t),...p]})},sh=({url:e,className:t,level:n="p",separator:s="/",weight:r,shade:i=9})=>{const l=bl({segments:e,separator:s,shade:i,level:n,weight:r,transform:(c,a)=>({...c,label:c.label.split("-").map(x=>u.d.capitalize(x)).join(" "),href:`/${e.split(s).slice(0,a+1).join("/")}`})});return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(t,u.CSS.B("breadcrumb"),u.CSS.BM("breadcrumb","url")),x:!0,size:"small",align:"center",children:l})},oh=Object.freeze(Object.defineProperty({__proto__:null,Breadcrumb:vl,URL:sh},Symbol.toStringTag,{value:"Module"})),kl=({variant:e="info",...t})=>e==="loading"?o.jsxRuntimeExports.jsx(Z.y4.Loading,{...t}):o.jsxRuntimeExports.jsx(Z.y4.Circle,{color:Re.VARIANT_COLORS[e],...t}),rh=({action:e})=>g.isValidElement(e)?e:g.createElement(he.Button,{...e,key:e.key}),ih=({status:{key:e,time:t,count:n,message:s,description:r,variant:i},silence:l,actions:c,className:a,children:x,...d})=>{const p=g.useRef(null);return o.jsxRuntimeExports.jsxs(ne.Space,{className:u.CSS(u.CSS.B("notification"),a),y:!0,empty:!0,ref:p,...d,children:[o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,justify:"spaceBetween",grow:!0,style:{width:"100%"},children:[o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(kl,{style:{height:"2.25rem",width:"2.5rem"},variant:i}),o.jsxRuntimeExports.jsx(Z.Text,{level:"small",shade:11,children:`x${n}`}),o.jsxRuntimeExports.jsx(_o.DateTime,{className:u.CSS(u.CSS.BE("notification","time")),level:"small",format:"time",children:t})]}),o.jsxRuntimeExports.jsx(he.Icon,{className:u.CSS(u.CSS.BE("notification","silence")),variant:"outlined",size:"small",onClick:()=>l(e),children:o.jsxRuntimeExports.jsx(Z.y4.Close,{})})]}),o.jsxRuntimeExports.jsxs(ne.Space,{y:!0,align:"start",className:u.CSS(u.CSS.BE("notification","content")),size:"small",children:[x??o.jsxRuntimeExports.jsx(Z.Text,{className:u.CSS(u.CSS.BE("notification","message")),level:"p",style:{flexGrow:1},children:s}),r!=null&&o.jsxRuntimeExports.jsx(Z.Text,{className:u.CSS(u.CSS.BE("notification","description")),level:"small",style:{flexGrow:1},children:r})]}),c!=null&&o.jsxRuntimeExports.jsx(ne.Space,{x:!0,align:"center",justify:"end",className:u.CSS(u.CSS.BE("notification","actions")),children:Me.A(c).map(m=>o.jsxRuntimeExports.jsx(rh,{action:m},m.key))})]},t.toString())},lh=Object.freeze(Object.defineProperty({__proto__:null,Aggregator:Re.Aggregator,Circle:kl,Notification:ih,Text:Re.Text,VARIANTS:nt.VARIANTS,VARIANT_COLORS:Re.VARIANT_COLORS,specZ:nt.specZ,useAdder:Re.useAdder,useErrorHandler:Re.useErrorHandler,useNotifications:Re.useNotifications,variantZ:nt.variantZ},Symbol.toStringTag,{value:"Module"})),sr=({aetherKey:e,enabled:t=!0})=>{const{setState:n}=Q.useLifecycle({aetherKey:e,type:xs.Eraser.TYPE,schema:xs.eraserStateZ,initialState:{region:u.$t.ZERO,enabled:t}}),s=Z.useSyncedRef(t);return{erase:g.useCallback(i=>{n({enabled:s.current,region:i})},[n,s])}},ch=({aetherKey:e,children:t})=>{const{erase:n}=sr({aetherKey:e}),s=Ge.useResize(n);return o.jsxRuntimeExports.jsx("div",{ref:s,className:u.CSS(u.CSS.inheritDims()),children:t})},ah=Object.freeze(Object.defineProperty({__proto__:null,Eraser:ch,use:sr},Symbol.toStringTag,{value:"Module"})),uh=({items:e,initialKey:t})=>{const[n,s]=g.useState(t),r=l=>s(l===n?void 0:l),i=e.find(l=>l.key===n);return{onSelect:r,activeItem:i}},xh=({activeItem:e,children:t,onSelect:n,location:s="left",collapseThreshold:r=.65,className:i,onResize:l,onCollapse:c,eraseEnabled:a,...x})=>{const d=u.K.direction(s);a??(a=e!=null);const p=g.useCallback(()=>{c?c():e!=null&&(n==null||n(e.key))},[n,e==null?void 0:e.key,c]),{erase:m}=sr({enabled:a}),f=g.useCallback((b,E)=>{l==null||l(b,E),m(E)},[l,m]),{content:h,minSize:j,maxSize:y,initialSize:S=0}=e??{};return o.jsxRuntimeExports.jsx(wl,{className:u.CSS(u.CSS.B("nav-drawer"),u.CSS.dir(d),u.CSS.visible(e!=null),i),collapseThreshold:r,onCollapse:p,location:s,onResize:f,minSize:j,maxSize:y,initialSize:S,...x,children:h})},dh=Object.freeze(Object.defineProperty({__proto__:null,Bar:ge.Bar,Drawer:xh,useDrawer:uh},Symbol.toStringTag,{value:"Module"})),rs={...z.ZERO_CONTEXT_VALUE,state:nt.tv.connectivity.DEFAULT},Ml=g.createContext(rs),_l=()=>g.use(Ml),qe=()=>_l().client,ph=()=>_l().state,Qr={connected:"success",connecting:"info",disconnected:"info",failed:"error"},Pl="serverVersionMismatch",mh=(e,t,n)=>`Cluster version ${n!=null?`${n} `:""}is ${e?"older":"newer"} than client version ${t}. Compatibility issues may arise.`,Ll=({children:e,connParams:t})=>{const[n,s,r]=Z.useCombinedStateAndRef(rs),{path:i}=Q.useUnidirectional({type:z.Provider.TYPE,schema:z.Provider.stateZ,state:{props:t??null,state:null}}),l=Re.useAdder(),c=g.useCallback(a=>{r.current.state.status!==a.status&&l({variant:Qr[a.status],message:a.message??u.d.capitalize(a.status)}),s(x=>({...x,state:a}))},[l]);return Q.useAsyncEffect(async()=>{if(n.client!=null&&n.client.close(),t==null)return s(rs);const a=new nt.tv({...t,connectivityPollFrequency:nt.S.seconds(2)});s({client:a,state:{clusterKey:"",status:"connecting",message:"Connecting...",clientServerCompatible:!1,clientVersion:a.clientVersion}});const x=await a.connectivity.check();if(s({client:a,state:x}),l({variant:Qr[x.status],message:x.message??x.status.toUpperCase()}),x.status==="connected"&&!x.clientServerCompatible){const d=x.nodeVersion==null||u.Jt.semVerOlder(x.nodeVersion,x.clientVersion),p=mh(d,x.clientVersion,x.nodeVersion);l({variant:"warning",message:"Incompatible cluster version",description:p,data:{type:Pl,oldServer:d,nodeVersion:x.nodeVersion,clientVersion:x.clientVersion}})}return a.connectivity.onChange(c),()=>{a.close(),s(rs)}},[t,c]),o.jsxRuntimeExports.jsx(Ml,{value:n,children:o.jsxRuntimeExports.jsx(Q.Composite,{path:i,children:e})})},fh=Object.freeze(Object.defineProperty({__proto__:null,Provider:Ll,SERVER_VERSION_MISMATCH:Pl,use:qe,useConnectionState:ph},Symbol.toStringTag,{value:"Module"})),Nl=g.createContext({aliases:{},getName:async()=>await Promise.resolve(void 0),setAlias:null}),ln=()=>g.use(Nl),Tl=e=>ln().aliases[e]??null,$s=()=>ln().aliases,As=(e,t="")=>{const{getName:n}=ln(),[s,r]=g.useState(t);return Q.useAsyncEffect(async()=>{const i=await n(e);r(i)},[e,n]),s??t},or=()=>ln().activeRange??void 0,$l=({activeRange:e,children:t})=>{const n=qe(),[s,r]=g.useState({}),i=g.useCallback(a=>{r(x=>{const d={...x};return a.forEach(({variant:p,key:m,value:f})=>{const h=Number(m.split("---")[1]);p==="delete"?delete d[h]:d[f.channel]=f.alias}),d})},[r]),l=g.useCallback(async(a,x)=>{if(n==null||e==null)return;await(await n.ranges.retrieve(e)).setAlias(a,x)},[n,e]),c=g.useCallback(async a=>{if(n==null||a===0)return;const x=s[a];return x??(await n.channels.retrieve(a)).name},[s,n]);return Q.useAsyncEffect(async()=>{if(n==null||e==null){r({});return}const a=await n.ranges.retrieve(e),x=await a.listAliases();r(x);const d=await a.openAliasTracker(),p=d.onChange(i);return()=>{p(),d.close()}},[n,e]),o.jsxRuntimeExports.jsx(Nl,{value:{aliases:s,activeRange:e,setAlias:e!=null?l:null,getName:c},children:t})},hh=({channelKey:e,value:t,shadow:n,className:s,...r})=>{const[i,l]=g.useState(!1),{setAlias:c}=ln(),a=Tl(e),x=As(e);let d=o.jsxRuntimeExports.jsx(Z.y4.Rename,{});i?d=o.jsxRuntimeExports.jsx(Z.y4.Loading,{}):a===t&&(d=o.jsxRuntimeExports.jsx(Z.y4.Check,{}));const p=c!=null&&!i&&a!==t&&e!==0,m=Re.useErrorHandler(),f=()=>{p&&m(async()=>{l(!0),await c(e,t),l(!1)},"Failed to set channel alias")},h=()=>{var y;a!=null&&((y=r.onChange)==null||y.call(r,a))},j=()=>e===0?o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:"Select a channel to enable alias syncing with this label"}):c==null?o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:"Select a range to enable alias syncing with this label"}):t.length===0?o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:"Enter a value to enable alias syncing with this label"}):a===t?o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:"Alias synced with this label"}):o.jsxRuntimeExports.jsxs(Z.Text,{level:"small",children:["Sync alias for ",x," with this label"]});return o.jsxRuntimeExports.jsxs(mt.Text,{value:t,...r,children:[p&&o.jsxRuntimeExports.jsx(he.Icon,{onClick:h,tooltip:o.jsxRuntimeExports.jsxs(Z.Text,{level:"small",children:["Set ",x," as label"]}),tooltipLocation:{y:"top"},variant:"outlined",children:o.jsxRuntimeExports.jsx(Z.y4.Sync,{})}),o.jsxRuntimeExports.jsx(he.Icon,{onClick:f,disabled:!p,tooltip:o.jsxRuntimeExports.jsx(j,{}),tooltipLocation:{y:"top"},variant:"outlined",children:d})]})},ot="channel";var ei=180/Math.PI,Po={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Al(e,t,n,s,r,i){var l,c,a;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(a=e*n+t*s)&&(n-=e*a,s-=t*a),(c=Math.sqrt(n*n+s*s))&&(n/=c,s/=c,a/=c),e*s<t*n&&(e=-e,t=-t,a=-a,l=-l),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ei,skewX:Math.atan(a)*ei,scaleX:l,scaleY:c}}var Gn;function gh(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Po:Al(t.a,t.b,t.c,t.d,t.e,t.f)}function jh(e){return e==null||(Gn||(Gn=document.createElementNS("http://www.w3.org/2000/svg","g")),Gn.setAttribute("transform",e),!(e=Gn.transform.baseVal.consolidate()))?Po:(e=e.matrix,Al(e.a,e.b,e.c,e.d,e.e,e.f))}function Il(e,t,n,s){function r(x){return x.length?x.pop()+" ":""}function i(x,d,p,m,f,h){if(x!==p||d!==m){var j=f.push("translate(",null,t,null,n);h.push({i:j-4,x:z.interpolateNumber(x,p)},{i:j-2,x:z.interpolateNumber(d,m)})}else(p||m)&&f.push("translate("+p+t+m+n)}function l(x,d,p,m){x!==d?(x-d>180?d+=360:d-x>180&&(x+=360),m.push({i:p.push(r(p)+"rotate(",null,s)-2,x:z.interpolateNumber(x,d)})):d&&p.push(r(p)+"rotate("+d+s)}function c(x,d,p,m){x!==d?m.push({i:p.push(r(p)+"skewX(",null,s)-2,x:z.interpolateNumber(x,d)}):d&&p.push(r(p)+"skewX("+d+s)}function a(x,d,p,m,f,h){if(x!==p||d!==m){var j=f.push(r(f)+"scale(",null,",",null,")");h.push({i:j-4,x:z.interpolateNumber(x,p)},{i:j-2,x:z.interpolateNumber(d,m)})}else(p!==1||m!==1)&&f.push(r(f)+"scale("+p+","+m+")")}return function(x,d){var p=[],m=[];return x=e(x),d=e(d),i(x.translateX,x.translateY,d.translateX,d.translateY,p,m),l(x.rotate,d.rotate,p,m),c(x.skewX,d.skewX,p,m),a(x.scaleX,x.scaleY,d.scaleX,d.scaleY,p,m),x=d=null,function(f){for(var h=-1,j=m.length,y;++h<j;)p[(y=m[h]).i]=y.x(f);return p.join("")}}}var Eh=Il(gh,"px, ","px)","deg)"),yh=Il(jh,", ",")",")"),Sh=1e-12;function ti(e){return((e=Math.exp(e))+1/e)/2}function Rh(e){return((e=Math.exp(e))-1/e)/2}function Ch(e){return((e=Math.exp(2*e))-1)/(e+1)}const wh=function e(t,n,s){function r(i,l){var c=i[0],a=i[1],x=i[2],d=l[0],p=l[1],m=l[2],f=d-c,h=p-a,j=f*f+h*h,y,S;if(j<Sh)S=Math.log(m/x)/t,y=function(P){return[c+P*f,a+P*h,x*Math.exp(t*P*S)]};else{var b=Math.sqrt(j),E=(m*m-x*x+s*j)/(2*x*n*b),C=(m*m-x*x-s*j)/(2*m*n*b),L=Math.log(Math.sqrt(E*E+1)-E),T=Math.log(Math.sqrt(C*C+1)-C);S=(T-L)/t,y=function(P){var O=P*S,I=ti(L),D=x/(n*b)*(I*Ch(t*O+L)-Rh(L));return[c+D*f,a+D*h,x*I/ti(t*O+L)]}}return y.duration=S*1e3*t/Math.SQRT2,y}return r.rho=function(i){var l=Math.max(.001,+i),c=l*l,a=c*c;return e(l,c,a)},r}(Math.SQRT2,2,4),bh=Object.freeze(Object.defineProperty({__proto__:null,Base:z.Base,Bottom:z.Bottom,Right:z.Right,Top:z.Top,axisStateZ:z.axisStateZ,newCanvas:z.newCanvas,newTickFactory:z.newTickFactory,tickFactoryProps:z.tickFactoryProps,tickType:z.tickType},Symbol.toStringTag,{value:"Module"})),vh={region:u.$t.ZERO,dpr:1,os:u.S.getOS()},kh={gl:null,lower2d:null,upper2d:null,bootstrapped:!1},Mh=({children:e,resizeDebounce:t=100,className:n,...s})=>{const[{path:r},{bootstrapped:i,dpr:l},c]=Q.use$1({type:z.Canvas.TYPE,schema:z.canvasStateZ,initialState:vh}),a=g.useRef({...kh}),x=g.useRef(!1),d=g.useCallback(j=>{a.current.bootstrapped&&(c(()=>({bootstrapped:!0,region:j,dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})})),x.current=!0)},[c]),p=g.useRef(null),m=Ge.useResize(d,{debounce:t}),f=Z.useCombinedRefs(p,m);g.useEffect(()=>{const j=()=>{window.devicePixelRatio===l||!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.$t.construct(p.current),dpr:window.devicePixelRatio}))};window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`).addEventListener("change",j,{once:!0})},[l]),g.useEffect(()=>{const j=()=>{!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.$t.construct(p.current),glCanvas:void 0,upper2dCanvas:void 0,lower2dCanvas:void 0}))};window.addEventListener("focus",j),window.addEventListener("blur",j)},[c]);const h=g.useCallback(j=>{if(j==null)return;j.className.includes("gl")?a.current.gl=j:j.className.includes("upper2d")?a.current.upper2d=j:a.current.lower2d=j;const{gl:y,lower2d:S,upper2d:b,bootstrapped:E}=a.current;if(y==null||S==null||b==null||E)return;a.current.bootstrapped=!0;const C=y.transferControlToOffscreen(),L=b.transferControlToOffscreen(),T=S.transferControlToOffscreen();c({glCanvas:C,upper2dCanvas:L,lower2dCanvas:T,bootstrap:!0,bootstrapped:!1,region:u.$t.construct(y),dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})},[C,L,T])},[c]);return o.jsxRuntimeExports.jsxs("div",{ref:f,className:u.CSS(u.CSS.B("canvas-container"),n),...s,children:[o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","lower2d"))}),o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","gl"))}),o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","upper2d"))}),o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:i&&e})]})},Dn=(e,t)=>Ge.useResize(g.useCallback((n,s)=>{const r=document.querySelector(".pluto-canvas--lower2d");r!=null&&e(u.b.XY.translate(u.J.scale(u.$t.topLeft(r),-1)).box(n),s)},[e]),t),_h=Object.freeze(Object.defineProperty({__proto__:null,Canvas:Mh,useRegion:Dn},Symbol.toStringTag,{value:"Module"})),Dl=g.createContext(null),rt=e=>{const t=g.use(Dl);if(t==null)throw new Error(`Cannot to use ${e} as a non-child of LinePlot.`);return t},zl=e=>{const t=rt("Viewport"),{addViewportHandler:n}=t;g.useEffect(()=>n(e),[n,e])},zn=(e,t)=>{const{setGridEntry:n,removeGridEntry:s}=rt(t),{key:r}=e;return Q.useEffectCompare(()=>{u.K.outer.parse(e.loc),n(e)},([c],[a])=>ze.x.equal(c,a),[e]),g.useEffect(()=>()=>s(r),[]),{gridArea:u.g.swap(u.K.direction(e.loc))==="x"?`axis-start-${r} / plot-start / axis-end-${r} / plot-end`:`plot-start / axis-start-${r} / plot-end / axis-end-${r}`}},Bl=({aetherKey:e,style:t,resizeDebounce:n=0,clearOverScan:s=u.J.ZERO,children:r,hold:i=!1,onHold:l,visible:c,...a})=>{const[x,d]=g.useState([]),p=Ne.useMemoDeepEqualProps({clearOverScan:s,hold:i,visible:c}),[{path:m},{grid:f},h]=Q.use$1({aetherKey:e,type:z.LinePlot.TYPE,schema:z.linePlotStateZ,initialState:{container:u.$t.ZERO,viewport:u.$t.DECIMAL,grid:{},...p}}),j=g.useCallback(B=>{c&&h(_=>({..._,container:B}))},[h,c]),y=Dn(j,{debounce:n});g.useEffect(()=>h(B=>({...B,...p})),[p]);const S=g.useRef(new Map),b=g.useCallback(B=>(S.current.set(B,null),()=>S.current.delete(B)),[S]),E=g.useCallback(B=>{const{mode:_,box:R,stage:k}=B;(_==="pan"&&k!=="start"||_==="zoom"||_==="zoomReset"&&k==="start")&&h(v=>({...v,viewport:R})),S.current.forEach((v,M)=>M(B))},[h]),C=g.useCallback(B=>{h(_=>({..._,grid:{..._.grid,[B.key]:B}}))},[h]),L=g.useCallback(B=>h(_=>{const{[B]:R,...k}=_.grid;return{..._,grid:k}}),[h]),T=g.useCallback(B=>{d(_=>[..._.filter(({key:R})=>R!==B.key),B])},[d]),P=g.useCallback(B=>d(_=>_.filter(({key:R})=>R!==B)),[T]),O=g.useMemo(()=>Ph(f),[f]),I=g.useCallback(B=>{h(_=>({..._,hold:B})),l==null||l(B)},[h,l]),D=`line-plot-${e}`,H=g.useMemo(()=>({lines:x,setGridEntry:C,removeGridEntry:L,setLine:T,removeLine:P,setViewport:E,addViewportHandler:b,setHold:I,id:D}),[D,x,C,L,T,P,E,b,I]);return o.jsxRuntimeExports.jsx("div",{id:D,className:u.CSS.B("line-plot"),style:{...t,...O},ref:y,...a,children:o.jsxRuntimeExports.jsx(Dl,{value:H,children:o.jsxRuntimeExports.jsx(Q.Composite,{path:m,children:r})})})},Ph=e=>{const t=u.CSS.newGridBuilder();return z.regions("top",e).forEach(({key:n,size:s})=>t.row(`axis-start-${n}`,`axis-end-${n}`,s)),t.row("plot-start","plot-end","minmax(0, 1fr)"),z.regions("bottom",e).reverse().forEach(({key:n,size:s})=>t.row(`axis-start-${n}`,`axis-end-${n}`,s)),z.regions("left",e).forEach(({key:n,size:s})=>t.col(`axis-start-${n}`,`axis-end-${n}`,s)),t.col("plot-start","plot-end","minmax(0, 1fr)"),z.regions("right",e).forEach(({key:n,size:s})=>t.col(`axis-start-${n}`,`axis-end-${n}`,s)),t.build()},rr=e=>{const t=e==="x"?"bottom":"left",n=e==="x"?z.XAxis.TYPE:z.YAxis.TYPE,s=`${e}-axis`,r=({aetherKey:i,children:l,location:c=t,label:a="",labelLevel:x="small",labelDirection:d=e,onLabelChange:p,color:m,labelSize:f,showGrid:h,type:j,bounds:y,className:S,tickSpacing:b,autoBounds:E,axisKey:C,autoBoundUpdateInterval:L,onAutoBoundsChange:T,style:P,...O})=>{const I=((a==null?void 0:a.length)??0)>0,D=Q.useUniqueKey(i),H=Ne.useMemoDeepEqualProps({location:c,showGrid:h,type:j,bounds:y,axisKey:C,label:a,labelDirection:d,tickSpacing:b,autoBounds:E,autoBoundUpdateInterval:L}),[{path:B},{size:_,labelSize:R,...k},v]=Q.use$1({aetherKey:D,type:n,schema:z.coreAxisStateZ,initialState:H});g.useEffect(()=>v(V=>({...V,...H})),[H]),g.useEffect(()=>{const{lower:V,upper:F}=z.parseAutoBounds(k.autoBounds);k.bounds!=null&&(V&&(y==null?void 0:y.lower)!==k.bounds.lower||F&&(y==null?void 0:y.upper)!==k.bounds.upper)&&(T==null||T(k.bounds))},[k.autoBounds,k.bounds]);const M=zn({loc:c,key:`${n}-${D}`,size:_+R,order:1},`${e.toUpperCase()}Axis`),A=Jo.useTypography(x).toString(),$=g.useRef(0);return g.useEffect(()=>{if(e==="y"){if(a==null)return;let F=Ur.dimensions(a,A)[u.g.dimension(u.g.construct(d))];F>0&&(F+=9),v(W=>({...W,labelSize:F}))}else{let F=Ur.dimensions(a,A).height*1.3;F>0&&(F+=12);const W=$.current;z.withinSizeThreshold(W,F)||($.current=F,v(ee=>({...ee,labelSize:F})))}},[a,d,A]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(S,u.CSS.B("axis"),u.CSS.B(s),u.CSS.loc(c)),style:{...P,...M},align:"center",justify:c!=="left"?"end":"start",direction:u.g.swap(e),...O,children:I&&o.jsxRuntimeExports.jsx(Z.MaybeEditable,{className:u.CSS(u.CSS.BE("axis","label"),u.CSS.dir(d)),value:a,onChange:p,level:x})}),o.jsxRuntimeExports.jsx(Q.Composite,{path:B,children:l})]})};return r.displayName=`${e.toUpperCase()}Axis`,r},Ol=rr("x"),Vl=rr("y"),Fl=u.J.xy.extend({root:u.K.corner,units:pe.z.object({x:pe.z.enum(["px","decimal"]),y:pe.z.enum(["px","decimal"])})}),Lh=Fl.partial({root:!0,units:!0}),Nh=e=>{var n,s,r,i;const t={};return t[((n=e.root)==null?void 0:n.x)??"left"]=((s=e==null?void 0:e.units)==null?void 0:s.x)==="px"?`${e.x}px`:`${e.x*100}%`,t[((r=e.root)==null?void 0:r.y)??"top"]=((i=e==null?void 0:e.units)==null?void 0:i.y)==="px"?`${e.y}px`:`${e.y*100}%`,t},Th=(e,t)=>{var i,l,c,a,x,d;const n={x:e.x,y:e.y};if(t.current==null)return n;const s=u.$t.construct(t.current),r=u.$t.construct(t.current.parentElement);return((i=e.units)==null?void 0:i.x)==="decimal"?((l=e.root)==null?void 0:l.x)==="right"&&(n.x=1-e.x):((c=e.root)==null?void 0:c.x)==="right"?n.x=1-(e.x+u.$t.width(s))/u.$t.width(r):n.x/=u.$t.width(r),((a=e.units)==null?void 0:a.y)==="decimal"?((x=e.root)==null?void 0:x.y)==="bottom"&&(n.y=1-e.y):((d=e.root)==null?void 0:d.y)==="bottom"?n.y=1-(e.y+u.$t.height(s))/u.$t.height(r):n.y/=u.$t.height(r),n},Hl=(e,t)=>{if(t.current==null)return null;const n=u.$t.construct(t.current.parentElement),s=u.$t.construct(t.current),r={x:e.x,y:e.y,root:{...u.K.TOP_LEFT},units:{x:"px",y:"px"}};return e.x>.8?(r.x=(1-e.x)*u.$t.width(n)-u.$t.width(s),r.root.x="right"):e.x<.2?r.x=e.x*u.$t.width(n):r.units.x="decimal",e.y>.8?(r.y=(1-e.y)*u.$t.height(n)-u.$t.height(s),r.root.y="bottom"):e.y<.2?r.y=e.y*u.$t.height(n):r.units.y="decimal",r.x=Math.round(r.x*100)/100,{...r,...u.J.truncate(r,3)}},ni=u.$t.reRoot(u.$t.DECIMAL,u.K.TOP_LEFT),$h={x:.1,y:.1,root:u.K.TOP_LEFT,units:{x:"decimal",y:"decimal"}},ir=g.memo(({className:e,value:t,onChange:n,style:s,draggable:r=!0,initial:i=$h,...l})=>{const[c,a]=st.usePurePassthrough({value:t,onChange:n,initial:i}),x=g.useRef(c),d=Z.useSyncedRef(r===!1),p=g.useRef(null);c!==null&&(s={...s,...Nh(c)});const m=g.useCallback(h=>{var L;if(((L=p.current)==null?void 0:L.parentElement)==null)return x.current;const j=u.$t.construct(p.current.parentElement),y=u.b.XY.scale(j).scale(ni),S=y.box(u.$t.construct(p.current)),b=u.b.XY.clamp(u.$t.construct(u.$t.topLeft(ni),{width:1-u.$t.width(S),height:1-u.$t.height(S)})),E=u.J.translate(u.J.construct(x.current),u.$t.signedDims(y.box(h))),C=b.pos(E);return Hl(C,p)},[]),f=Ke.useCursorDrag({onStart:g.useCallback(()=>{x.current=Th(x.current,p)},[]),onMove:g.useCallback(h=>{if(d.current)return;const j=m(h);j!==null&&a(j)},[]),onEnd:g.useCallback(h=>{if(d.current)return;const j=m(h);j!==null&&(x.current=j)},[])});return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(e,u.CSS.B("legend")),bordered:!0,rounded:!0,style:s,onDragStart:f,draggable:r,borderShade:5,ref:p,onDrag:ge.preventDefault,onDragEnd:ge.preventDefault,background:1,...l})});ir.displayName="Legend.Container";const Is=g.memo(({data:e,onEntryChange:t,onVisibleChange:n,allowVisibleChange:s=!0,shade:r=1})=>o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:e.sort((i,l)=>i.label.localeCompare(l.label)).map(({key:i,color:l,label:c,visible:a=!0})=>o.jsxRuntimeExports.jsxs(ne.Space,{style:{cursor:"pointer"},x:!0,align:"center",size:"small",justify:"spaceBetween",grow:!0,children:[o.jsxRuntimeExports.jsxs(ne.Space,{direction:"x",align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(Ke.Swatch,{value:l,onChange:x=>t==null?void 0:t({key:i,color:x,label:c,visible:a}),onVisibleChange:n,allowChange:t!=null,draggable:!1,size:"tiny"}),o.jsxRuntimeExports.jsx(Z.MaybeEditable,{level:"small",value:c,onChange:x=>t==null?void 0:t({key:i,color:l,label:x,visible:a}),noWrap:!0,shade:a?10:7,onDoubleClick:x=>x.stopPropagation()})]}),s&&o.jsxRuntimeExports.jsx(he.Icon,{className:u.CSS.B("visible-toggle"),onClick:x=>{x.stopPropagation(),t==null||t({key:i,color:l,label:c,visible:!a})},onDoubleClick:x=>x.stopPropagation(),size:"tiny",shade:r,children:a?o.jsxRuntimeExports.jsx(Z.y4.Visible,{}):o.jsxRuntimeExports.jsx(Z.y4.Hidden,{})})]},i))}));Is.displayName="LegendSwatches";const lr=({data:e=[],onEntryChange:t,position:n,onPositionChange:s,allowVisibleChange:r=!0,...i})=>{const[l,c]=g.useState(!1);return e.length===0?null:o.jsxRuntimeExports.jsx(ir,{...i,className:r?u.CSS.M("with-visible-toggle"):void 0,draggable:!l,value:n,onChange:s,size:r?0:"tiny",children:o.jsxRuntimeExports.jsx(Is,{data:e,onEntryChange:t,onVisibleChange:c,allowVisibleChange:r})})},Ah=Object.freeze(Object.defineProperty({__proto__:null,Container:ir,LegendSwatches:Is,Simple:lr,calcStickyPos:Hl,completeStickyXYz:Fl,stickyXYz:Lh},Symbol.toStringTag,{value:"Module"})),cr=g.memo(({className:e,style:t,onLineChange:n,...s})=>{const{lines:r}=rt("Legend");return rt("Legend"),o.jsxRuntimeExports.jsx(lr,{data:r,onEntryChange:n,...s})});cr.displayName="FloatingLegend";const Ih=({onLineChange:e})=>{const{lines:t}=rt("Legend"),n=Q.useUniqueKey(),s=zn({key:n,size:t.length>0?36:0,loc:"bottom",order:5},"Legend");return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS.BE("legend","container"),align:"center",x:!0,style:{...s,padding:"0 1rem",height:"var(--pluto-height-medium)",margin:"1rem 0 ",width:"fit-content"},children:o.jsxRuntimeExports.jsx(Is,{data:t,onEntryChange:e,shade:0})})},Zl=({variant:e="floating",...t})=>e==="floating"?o.jsxRuntimeExports.jsx(cr,{...t}):o.jsxRuntimeExports.jsx(Ih,{...t}),ar=g.memo(({aetherKey:e,...t})=>(Q.useUnidirectional({aetherKey:e,type:z.Line.TYPE,schema:z.stateZ,state:t}),null));ar.displayName="Line";const Dh=Object.freeze(Object.defineProperty({__proto__:null,Line:ar},Symbol.toStringTag,{value:"Module"})),ur=({aetherKey:e,color:t,label:n="",visible:s=!0,...r})=>{const i=Q.useUniqueKey(e),{setLine:l,removeLine:c}=rt("Line");return g.useEffect(()=>(l({key:i,color:t,label:n,visible:s}),()=>c(i)),[n,t,s]),o.jsxRuntimeExports.jsx(ar,{aetherKey:i,color:t,label:n,visible:s,...r})},Wl=({level:e="h2",...t})=>{const n=Q.useUniqueKey(),s=Jo.useTypography(e),r=zn({key:n,size:(s.lineHeight+2)*s.baseSize,loc:"top",order:10},"Title");return o.jsxRuntimeExports.jsx(ne.Space,{justify:"center",align:"center",style:r,children:o.jsxRuntimeExports.jsx(Z.MaybeEditable,{...t,level:e})})},Yl=({aetherKey:e,...t})=>{const n=Q.useUniqueKey(e),[,,s]=Q.use$1({aetherKey:n,type:z.Tooltip.TYPE,schema:z.tooltipStateZ,initialState:{position:null,...t}}),r=g.useRef(null),i=g.useCallback(c=>{const a=document.querySelector(".pluto-canvas-container");if(a==null)return;const x=u.$t.topLeft(a);s({position:u.J.translation(x,u.J.construct(c))})},[s]),l=g.useCallback(()=>s({position:null}),[s]);return g.useEffect(()=>{if(r.current===null)return;const c=r.current.parentElement;if(c!=null)return c.addEventListener("mousemove",i),c.addEventListener("mouseleave",l),()=>{c.removeEventListener("mousemove",i),c.removeEventListener("mouseleave",l)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:r})},zh=Object.freeze(Object.defineProperty({__proto__:null,Tooltip:Yl},Symbol.toStringTag,{value:"Module"})),Gl=()=>{const e=g.useRef(new Map),t=g.useCallback(s=>{const{request:r,response:i}=s,l=e.current.get(r);l!=null&&(l(i.bounds),e.current.delete(r))},[]),[,,n]=Q.use$1({type:z.BoundQuerier.TYPE,schema:z.boundQuerierStateZ,onAetherChange:t,initialState:{request:"",response:{request:"",bounds:{}}}});return g.useCallback(async()=>await new Promise(s=>{const r=u.Lt.create();e.current.set(r,s),n(i=>({...i,request:r}))}),[])},Bh=({ref:e})=>(e.current=Gl(),null),Oh={select:"pointer",zoom:"crosshair",pan:"grab",zoomReset:"crosshair",click:"pointer",cancel:"default"},Kl=({className:e,mode:t,maskBox:n,children:s,style:r,...i})=>o.jsxRuntimeExports.jsxs("div",{className:u.CSS(u.CSS.noSelect,u.CSS.BE("viewport-mask","container"),e),style:{cursor:Oh[t],...r},...i,children:[o.jsxRuntimeExports.jsx("div",{style:{...u.$t.css(n),display:u.$t.areaIsZero(n)?"none":"block"},className:u.CSS.BE("viewport-mask","selection")}),s]}),Vh=[],xr=({data:e,emptyContent:t,value:n,onChange:s,allowMultiple:r,allowNone:i,hideColumnHeader:l=!1,columns:c=Vh,visible:a,itemHeight:x=Re.Column.itemHeight,listItem:d=he.componentRenderProp(Re.Column.Item),replaceOnSingle:p,omit:m,autoSelectOnNone:f,trigger:h,extraDialogContent:j,variant:y="connected",...S})=>{let b=o.jsxRuntimeExports.jsxs(Re.Hover,{disabled:!a,children:[j,o.jsxRuntimeExports.jsx(Re.Column.Header,{hide:l||d!=null,columns:c,children:o.jsxRuntimeExports.jsx(Re.Core.Virtual,{itemHeight:x,children:d})})]});return y!=="connected"&&(b=o.jsxRuntimeExports.jsx(Ts.Pack,{y:!0,className:u.CSS.B("select-dialog-content"),children:b})),o.jsxRuntimeExports.jsx(Re.List,{data:e,emptyContent:t,omit:m,children:o.jsxRuntimeExports.jsx(Re.Selector,{value:n,onChange:s,allowMultiple:r,allowNone:i,replaceOnSingle:p,autoSelectOnNone:f,children:o.jsxRuntimeExports.jsxs(Ge.Dialog,{visible:a,className:u.CSS.B("select"),keepMounted:!1,variant:y,...S,children:[h,b]})})})},it=({children:e=Fh,value:t,onChange:n,entryRenderKey:s="key",allowNone:r=!1,allowMultiple:i=!1,data:l,replaceOnSingle:c,className:a,size:x="medium",actions:d,pack:p=!0,variant:m,...f})=>{const{onSelect:h}=Re.useSelect({allowMultiple:i,allowNone:r,replaceOnSingle:c,data:l,value:t,onChange:n}),j=S=>{m!=="preview"&&h(S)},y=l==null?void 0:l.map(S=>e({key:S.key,onClick:()=>j(S.key),size:x,selected:S.key===t,entry:S,title:S[s]}));return p?o.jsxRuntimeExports.jsxs(Ts.Pack,{borderShade:5,className:u.CSS(u.CSS.B("select-button"),a),size:x,...f,children:[y,d]}):o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:y})},Fh=({key:e,onClick:t,selected:n,title:s,size:r})=>o.jsxRuntimeExports.jsx(he.Button,{onClick:t,variant:n?"filled":"outlined",size:r,children:s},e),ql=({selected:e,renderKey:t,toggle:n,visible:s,children:r,...i})=>o.jsxRuntimeExports.jsx(he.Button,{className:u.CSS.B("select-dropdown-button"),onClick:n,variant:"outlined",endIcon:o.jsxRuntimeExports.jsx(In.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:s}),...i,children:r??(e==null?void 0:e[t])}),Xl=he.componentRenderProp(ql),Ds=({data:e,value:t,columns:n=[],children:s=Xl,entryRenderKey:r="key",allowNone:i=!1,onChange:l,disabled:c,hideColumnHeader:a=!0,variant:x,dropdownVariant:d,...p})=>{const{close:m,visible:f,toggle:h}=Ge.use(),[j,y]=g.useState((e==null?void 0:e.find(E=>E.key===t))??null);g.useEffect(()=>{y((e==null?void 0:e.find(E=>E.key===t))??null)},[e,t]);const S=g.useCallback((E,C)=>{if(!(Array.isArray(E)||E===null)){if(m(),E==null)return y(null),l(t);y(C.entries[0]),l(E)}},[l,t,m,y]),b={selected:j,renderKey:r,toggle:h,visible:f,disabled:c};return x!=null&&(b.variant=x),o.jsxRuntimeExports.jsx(xr,{close:m,data:e,visible:f,value:t,onChange:S,allowMultiple:!1,allowNone:i,columns:n,hideColumnHeader:a,variant:d,trigger:o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:s(b)}),...p})},Hh=[{key:"start",icon:o.jsxRuntimeExports.jsx(Z.y4.TextAlign.Left,{})},{key:"center",icon:o.jsxRuntimeExports.jsx(Z.y4.TextAlign.Center,{})},{key:"end",icon:o.jsxRuntimeExports.jsx(Z.y4.TextAlign.Right,{})}],Zh=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(he.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),zs=({children:e=Zh,...t})=>o.jsxRuntimeExports.jsx(it,{...t,allowMultiple:!1,data:Hh,children:e}),Wh=[{key:"large",label:"L"},{key:"medium",label:"M"},{key:"small",label:"S"}],Ul=e=>o.jsxRuntimeExports.jsx(it,{...e,data:Wh,entryRenderKey:"label"}),Yh=new Set([u.g$2.UUID,u.g$2.JSON]),Jl=u.g$2.ALL.filter(e=>e!==u.g$2.UNKNOWN).map(e=>({key:e.toString(),name:Yh.has(e)?e.toString().toUpperCase():u.d.capitalize(e.toString())})),Gh=Jl.filter(e=>!new u.g$2(e.key).isVariable),Kh=[{key:"name",name:"Name"}],qh=({hideVariableDensity:e=!1,...t})=>o.jsxRuntimeExports.jsx(Ds,{...t,data:e?Gh:Jl,columns:Kh,entryRenderKey:"name"}),Xh=[{key:"x",icon:o.jsxRuntimeExports.jsx(Z.y4.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(Z.y4.Arrow.Up,{})}],Uh=[{key:"x",icon:o.jsxRuntimeExports.jsx(Z.y4.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(Z.y4.Arrow.Down,{})}],Jh=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(he.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),Ql=({children:e=Jh,yDirection:t="up",...n})=>o.jsxRuntimeExports.jsx(it,{...n,allowMultiple:!1,data:t==="up"?Xh:Uh,children:e}),ec=e=>o.jsxRuntimeExports.jsx(he.Icon,{className:u.CSS.BE("select","clear"),variant:"outlined",...e,children:o.jsxRuntimeExports.jsx(Z.y4.Close,{"aria-label":"clear"})}),ft=({onChange:e,value:t,entryRenderKey:n="key",data:s,inputProps:r,allowNone:i=!0,searcher:l,className:c,variant:a="button",hideColumnHeader:x=!1,disabled:d,children:p,dropdownVariant:m="connected",placeholder:f=Bs,inputPlaceholder:h=f,triggerTooltip:j,dropdownZIndex:y,filter:S,actions:b,...E})=>{const{visible:C,open:L,close:T,toggle:P}=Ge.use(),[O,I]=g.useState(null),D=l!=null;Q.useAsyncEffect(async()=>{if(Re.selectValueIsZero(t))return I(null);if((O==null?void 0:O.key)===t)return;let k=null;if(D)try{[k]=await l.retrieve([t])}finally{k??(k=null)}else s!=null&&(k=s.find(v=>v.key===t)??null);I(k)},[l,t,s]);const H=g.useCallback((k,v)=>{Array.isArray(k)||(I(k==null?null:v.entries[0]),T(),e(k,v))},[e,i]),B=g.useMemo(()=>D?Mt.Search:Mt.Filter,[D]),_=o.jsxRuntimeExports.jsx(B,{searcher:l,filter:S,children:({onChange:k})=>o.jsxRuntimeExports.jsx(Qh,{...r,autoFocus:m==="modal",variant:a,onChange:k,onFocus:L,selected:O,entryRenderKey:n,visible:C,allowNone:i,className:c,dropdownVariant:m,disabled:d,placeholder:h,children:b})}),R=o.jsxRuntimeExports.jsx(he.Button,{tooltip:j,variant:"outlined",onClick:P,disabled:d,children:O!=null?tc(n,O):f});return o.jsxRuntimeExports.jsx(xr,{close:T,zIndex:y,data:s,allowMultiple:!1,visible:C,value:t,hideColumnHeader:x,onChange:H,allowNone:i,listItem:p,variant:m,trigger:m!=="modal"?_:R,extraDialogContent:m==="modal"?_:void 0,keepMounted:!1,...E})},Bs="Select",tc=(e,t)=>t==null?"":typeof e=="function"?e(t):t[e].toString(),Qh=({entryRenderKey:e,selected:t,visible:n,onChange:s,onFocus:r,allowNone:i=!0,placeholder:l=Bs,className:c,disabled:a,dropdownVariant:x,children:d,...p})=>{const{clear:m}=Re.useSelectionUtils(),[f,h]=g.useState("");g.useEffect(()=>{if(!n){if(u.w$2(t==null?void 0:t.key))return h("");t!=null&&h(tc(e,t))}},[t,n,e]);const j=C=>{s(C),h(C)},y=()=>{f===""&&s(""),h(""),r==null||r()},S=C=>{n||(C.preventDefault(),r==null||r())},b=()=>{h(""),m==null||m()};let E;return x!=="modal"&&(E=o.jsxRuntimeExports.jsx(In.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:n})),o.jsxRuntimeExports.jsxs(mt.Text,{className:u.CSS(u.CSS.BE("select","input"),c),value:f,onChange:j,onFocus:y,onKeyDown:Ie.matchCallback([["Enter"]],C=>{C.preventDefault(),!n&&(r==null||r())}),endContent:E,style:{flexGrow:1},onClick:S,placeholder:l,disabled:a,...p,children:[d,i&&o.jsxRuntimeExports.jsx(ec,{onClick:b,disabled:a})]})},vn=({children:e="",size:t="medium",color:n,icon:s,onClose:r,className:i,onDragStart:l,...c})=>{const a=u.Dt.cssString(n);s==null&&n!=null&&(s=o.jsxRuntimeExports.jsx(Z.y4.Circle,{fill:a}));const x=r==null?void 0:o.jsxRuntimeExports.jsx(he.Icon,{"aria-label":"close",size:"small",className:u.CSS.BE("tag","close"),shade:1,sharp:!0,onClick:d=>{d.stopPropagation(),r()},children:o.jsxRuntimeExports.jsx(Z.y4.Close,{})});return o.jsxRuntimeExports.jsx(Ns.WithIcon,{startIcon:s,endIcon:x,className:u.CSS(i,u.CSS.B("tag"),u.CSS.size(t),r!=null&&u.CSS.BM("tag","closeable")),level:st.ComponentSizeLevels[t],noWrap:!0,align:"center",size:"small",onDragStart:l,...c,children:e})},e1=Object.freeze(Object.defineProperty({__proto__:null,Tag:vn},Symbol.toStringTag,{value:"Module"})),dr=({entryKey:e,entryRenderKey:t,entry:n,loading:s,...r})=>{let i=e;return n!=null&&(i=typeof t=="function"?t(n):n[t]),g.createElement(vn,{size:"small",variant:"outlined",className:u.CSS(n==null&&!s&&u.CSS.BEM("select-multiple","tag","invalid")),draggable:!0,...r,key:e.toString()},u.Gt(i))},t1=he.componentRenderProp(dr),cn=({onChange:e,value:t,className:n,data:s,columns:r=[],entryRenderKey:i="key",emptyContent:l,searcher:c,renderTag:a=t1,placeholder:x,onTagDragStart:d,allowMultiple:p,allowNone:m,replaceOnSingle:f,onTagDragEnd:h,style:j,addPlaceholder:y="Add",children:S,dropdownVariant:b="connected",actions:E,...C})=>{const{visible:L,open:T,close:P}=Ge.use(),[O,I]=g.useState([]),[D,H]=g.useState(!1),B=c!=null;Q.useAsyncEffect(async()=>{H(!0),Re.selectValueIsZero(t)&&I([]);const M=O.map(V=>V.key),A=Me.A(t);if(u.F.unorderedPrimitiveArrays(M,A)===u.F.EQUAL)return;let $=[];if(B)try{$=await c.retrieve(A)}finally{H(!1)}else s!=null&&($=s.filter(V=>A.includes(V.key)));I($)},[c,B,t,s]);const _=g.useCallback((M,A)=>{M!=null&&(I(A.entries),e(Me.A(M),A))},[e]),R=g.useMemo(()=>B?Mt.Search:Mt.Filter,[B]);let k,v;if(b==="connected")v=o.jsxRuntimeExports.jsx(R,{searcher:c,children:({onChange:M,value:A})=>o.jsxRuntimeExports.jsx(n1,{dropdownVariant:b,value:A,selectedKeys:t,className:n,onChange:M,loading:D,selected:O,onFocus:T,entryRenderKey:i,visible:L,renderTag:a,placeholder:x,onTagDragStart:d,onTagDragEnd:h,style:j,children:E})});else{const M=Me.A(t);v=o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",grow:!0,style:j,size:"small",children:[M.map(A=>{const $=O.find(V=>V.key===A);return a({key:A,entryKey:A,entryRenderKey:i,loading:D,entry:$,onClose:()=>{const V=M.filter(F=>F!==A);e(V,{clicked:null,clickedIndex:-1,entries:[]})},onDragStart:V=>d==null?void 0:d(V,A),onDragEnd:V=>h==null?void 0:h(V,A)})}),M.length>0?o.jsxRuntimeExports.jsx(he.Icon,{onClick:T,children:o.jsxRuntimeExports.jsx(Z.y4.Add,{style:{color:"var(--pluto-gray-l9)"}})}):o.jsxRuntimeExports.jsx(he.Button,{onClick:T,shade:0,textShade:9,startIcon:o.jsxRuntimeExports.jsx(Z.y4.Add,{}),variant:"text",children:y})]}),k=o.jsxRuntimeExports.jsx(R,{searcher:c,children:A=>o.jsxRuntimeExports.jsx(mt.Text,{autoFocus:!0,placeholder:"Search",...A,children:E})})}return o.jsxRuntimeExports.jsx(xr,{close:P,data:s,emptyContent:l,visible:L,value:t,onChange:_,allowNone:m,replaceOnSingle:f,columns:r,allowMultiple:!0,listItem:S,trigger:v,extraDialogContent:k,variant:b,...C})},n1=({selectedKeys:e,loading:t,selected:n,onChange:s,onFocus:r,visible:i,entryRenderKey:l,renderTag:c,placeholder:a=Bs,onTagDragStart:x,onTagDragEnd:d,value:p,className:m,children:f,dropdownVariant:h,...j})=>{const{onSelect:y,clear:S}=Re.useSelectionUtils(),b=g.useRef(null);g.useLayoutEffect(()=>{var P;i&&((P=b.current)==null||P.focus())},[i,n]);const E=()=>{i||s(""),r==null||r()},C=()=>{i||r==null||r()},L=()=>{i||s("")};let T;return h!=="modal"&&(T=o.jsxRuntimeExports.jsx(In.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:i})),o.jsxRuntimeExports.jsxs(mt.Text,{ref:b,className:u.CSS(u.CSS.BE("select-multiple","input"),u.CSS.visible(i),m),onBlur:L,placeholder:a,value:p,onChange:s,onFocus:E,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",onClick:C,endContent:T,variant:"button",...j,children:[o.jsxRuntimeExports.jsx(ne.Space,{x:!0,className:u.CSS.BE("select-multiple","tags"),align:"center",grow:!0,size:"small",children:Me.A(e).map(P=>{const O=n.find(I=>I.key===P);return c({key:P,entryKey:P,entryRenderKey:l,loading:t,entry:O,onClose:()=>y==null?void 0:y(P),onDragStart:I=>x==null?void 0:x(I,P),onDragEnd:I=>d==null?void 0:d(I,P)})})}),f,o.jsxRuntimeExports.jsx(ec,{onClick:S})]})},s1=[{key:"h2",label:"XL"},{key:"h3",label:"L"},{key:"h4",label:"M"},{key:"h5",label:"S"},{key:"small",label:"XS"}],an=e=>o.jsxRuntimeExports.jsx(it,{...e,data:s1,entryRenderKey:"label"}),o1=[{key:600,label:"Bold"},{key:500,label:"Medium"},{key:400,label:"Normal"},{key:250,label:"Light"}],nc=e=>o.jsxRuntimeExports.jsx(it,{...e,data:o1,entryRenderKey:"label"}),r1=Object.freeze(Object.defineProperty({__proto__:null,Level:an,Weight:nc},Symbol.toStringTag,{value:"Module"})),i1=Object.freeze(Object.defineProperty({__proto__:null,BaseButton:ql,Button:it,ComponentSize:Ul,DEFAULT_PLACEHOLDER:Bs,DataType:qh,Direction:Ql,DropdownButton:Ds,Multiple:cn,MultipleTag:dr,Single:ft,Text:r1,TextAlignment:zs,defaultButton:Xl},Symbol.toStringTag,{value:"Module"})),l1=11,c1=6,a1=2,si=5,u1=e=>u.$t.width(e)<si&&u.$t.height(e)<si,jn=e=>{const t=u.$t.width(e),n=u.$t.height(e);return Math.min(t,n)<.001?l1:c1},x1=["zoom","pan","select","zoomReset","cancel"],Rn=[...x1,"click"],d1=pe.z.enum(Rn),sc=["zoom","select"],En={defaultMode:"zoom",zoom:[["MouseLeft"]],zoomReset:[["MouseLeft","Control"]],pan:[["MouseLeft","Shift"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},oc={defaultMode:"pan",pan:[["MouseLeft"]],zoom:[["MouseLeft","Shift"]],zoomReset:[["MouseLeft","Control"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},rc={defaultMode:"select",select:[["MouseLeft"]],pan:[["MouseLeft","Shift"]],zoom:[["MouseLeft","Alt"]],zoomReset:[["MouseLeft","Control"]],cancel:[["Escape"]]},pr={zoom:En,pan:oc,select:rc,zoomReset:En,click:En,cancel:En},p1=e=>{const t=Object.entries(e);return Object.fromEntries(t.map(([n,s])=>n==="defaultMode"?[n,s]:[n,s.map(r=>r.filter(i=>i!=="MouseLeft")).filter(r=>r.length>0)]))},m1=u.$t.construct(0,0,1,1,u.K.TOP_LEFT),f1={width:30,height:50},ic=({onChange:e,triggers:t,initial:n=m1,threshold:s=f1,ref:r})=>{const i=(t==null?void 0:t.defaultMode)??"zoom",[l,c]=g.useState(u.$t.ZERO),[a,x]=g.useState(i),[d,p]=Z.useStateRef(n),m=g.useRef(u.J.ZERO),f=g.useRef(null),h=u._.construct(s);g.useEffect(()=>p(()=>u.$t.truncate(n,jn(n))),[n]),g.useEffect(()=>x(i),[i]);const[j,y,S,b]=Ne.useMemoCompare(()=>{const O={...pr[i],...t},I=Ie.flattenConfig(O),D=p1(O);return[O,I,D,Ie.flattenConfig(D)]},Ie.compareModeConfigs,[t]),E=g.useCallback(({box:O,triggers:I,stage:D,cursor:H})=>{if(f.current==null)return;const B=Ie.determineMode(j,I),_=u.$t.construct(f.current);if(B==null)return;if(B==="cancel"){c(u.$t.ZERO),e==null||e({box:d.current,mode:B,stage:D,cursor:H});return}if(B==="zoomReset")return c(u.$t.ZERO),e==null||e({box:u.$t.DECIMAL,mode:B,stage:D,cursor:H}),p(u.$t.DECIMAL);const R=u1(O);if(D==="end"){if(R){B==="zoom"&&c(u.$t.ZERO),e==null||e({box:d.current,mode:"click",stage:D,cursor:H});return}return p(v=>{if(B==="pan"){const A=oi(O,v,_);return A===null||u.$t.equals(A,v)?v:(e==null||e({box:A,mode:B,stage:D,cursor:H}),A)}const M=C(O,v,_);return M===null?v:(e==null||e({box:M,mode:B,stage:D,cursor:H}),B==="zoom"?(c(u.$t.ZERO),M):u.$t.truncate(v,jn(v)))})}if(sc.includes(B))return R?void 0:c(u.b.XY.scale(_).clamp(_).translate({x:-u.$t.left(_),y:-u.$t.top(_)}).box(ri(h,O,_)));if(c(v=>u.$t.areaIsZero(v)?v:u.$t.ZERO),u.J.distance(H,m.current)<a1)return;m.current=H;const k=oi(O,d.current,_);e==null||e({box:k,mode:B,stage:D,cursor:H})},[c,x,e,j,s.height,s.width,p,f,jn]);g.useImperativeHandle(r,()=>({reset:()=>{c(u.$t.ZERO),p(u.$t.DECIMAL),e==null||e({box:u.$t.DECIMAL,mode:"zoomReset",stage:"start",cursor:u.J.ZERO})}}),[e]);const C=g.useCallback((O,I,D)=>{const H=Lo(I,D).box(ri(h,O,D));return u.$t.truncate(H,jn(H))},[s]),L=Ie.useHeldRef({triggers:[["Control"]]}),T=Ie.useHeldRef({triggers:[["Alt"]]});g.useEffect(()=>{const O=I=>{if(f.current==null)return;let D=1;I.deltaY<0?D-=.035:D+=.035;const H=u.$t.construct(f.current),B=u.J.construct(I);if(Array.from(f.current.children).push(f.current),!u.$t.contains(H,B)||f.current!==I.target&&Ge.findParent(I.target,A=>A===f.current)==null)return;const k=Lo(d.current,u.$t.construct(f.current)).pos(u.J.construct(I));let M=u.b.XY.magnify({x:L.current.held?1:D,y:T.current.held?1:D}).box(d.current);M=u.$t.translate(M,{x:L.current.held?0:k.x*(1-D),y:T.current.held?0:k.y*(1-D)}),p(M),e==null||e({stage:"end",box:M,cursor:u.J.construct(I),mode:"zoom"})};return window.addEventListener("wheel",O),()=>window.removeEventListener("wheel",O)},[p,e]),yl.useDrag({bound:f,onDrag:E,triggers:y,loose:!0});const P=g.useCallback(({triggers:O,stage:I})=>{if(I==="end")return x(i);const D=Ie.determineMode(S,O);D!=null&&x(D)},[S,i,e]);return Ie.use({triggers:b,callback:P,region:f}),{maskBox:l,ref:f,mode:a}},Lo=(e,t)=>u.b.XY.scale(t).clamp(t).scale(e),oi=(e,t,n)=>{let s=u.$t.signedDims(Lo(t,n).box(e));s={signedWidth:-s.signedWidth,signedHeight:-s.signedHeight};const r=u.b.XY.translate(u.J.construct(s)).box(t);return u.$t.truncate(r,jn(r))},ri=(e,t,n)=>u.$t.height(t)<=e.height?u.$t.construct(u.$t.left(t),u.$t.top(n),u.$t.width(t),u.$t.height(n)):u.$t.width(t)<=e.width?u.$t.construct(u.$t.left(n),u.$t.top(t),u.$t.width(n),u.$t.height(t)):t,h1=({mode:e,triggers:t})=>o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",children:[o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:u.d.capitalize(e)}),o.jsxRuntimeExports.jsx(ne.Space,{empty:!0,x:!0,align:"center",children:o.jsxRuntimeExports.jsx(Tf.Text,{trigger:t[0],level:"small"})})]}),g1={zoom:o.jsxRuntimeExports.jsx(Z.y4.Zoom,{}),pan:o.jsxRuntimeExports.jsx(Z.y4.Pan,{}),select:o.jsxRuntimeExports.jsx(Z.y4.Selection,{}),zoomReset:o.jsxRuntimeExports.jsx(Z.y4.Expand,{}),click:o.jsxRuntimeExports.jsx(Z.y4.Bolt,{})},j1=({triggers:e,disable:t=["zoomReset","click"],...n})=>{const s=[...t,"cancel"],r=Object.entries(e).filter(([i])=>!s.includes(i)&&Rn.includes(i)).map(([i,l])=>({key:i,icon:g1[i],tooltip:o.jsxRuntimeExports.jsx(h1,{mode:i,triggers:l})})).sort((i,l)=>Rn.indexOf(i.key)-Rn.indexOf(l.key));return o.jsxRuntimeExports.jsx(it,{...n,data:r,entryRenderKey:"icon",children:({title:i,entry:l,...c})=>g.createElement(he.Icon,{...c,key:l.key,variant:c.selected?"filled":"outlined",size:"small",tooltip:l.tooltip,tooltipLocation:u.K.BOTTOM_LEFT},l.icon)})},E1=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_TRIGGERS:pr,MASK_MODES:sc,MODES:Rn,Mask:Kl,PAN_DEFAULT_TRIGGERS:oc,SELECT_DEFAULT_TRIGGERS:rc,SelectMode:j1,ZOOM_DEFAULT_TRIGGERS:En,modeZ:d1,use:ic},Symbol.toStringTag,{value:"Module"})),y1=e=>e==null?null:e.closest(".pluto-line-plot__viewport")??null,lc=({ref:e,children:t,initial:n=u.$t.DECIMAL,onChange:s,...r})=>{const{setViewport:i}=rt("Viewport");g.useLayoutEffect(()=>{i({box:n,mode:"zoom",cursor:u.J.ZERO,stage:"start"})},[i,n]);const l=g.useCallback(a=>{i(a),s==null||s(a)},[s,i]),c=ic({onChange:l,initial:n,ref:e,...r});return o.jsxRuntimeExports.jsx(Kl,{className:u.CSS.BE("line-plot","viewport"),...c,children:t})},S1=Object.freeze(Object.defineProperty({__proto__:null,BoundsQuerier:Bh,Floating:cr,Legend:Zl,Line:ur,LinePlot:Bl,Title:Wl,Tooltip:zh,Viewport:lc,XAxis:Ol,YAxis:Vl,axisFactory:rr,selectViewportEl:y1,useBoundQuerier:Gl,useContext:rt,useGridEntry:zn,useViewport:zl},Symbol.toStringTag,{value:"Module"})),R1=({aetherKey:e,...t})=>(Q.use$1({aetherKey:e,type:z.Annotation.TYPE,schema:z.annotationStateZ,initialState:t}),null),cc=({aetherKey:e,menu:t,...n})=>{const s=Q.useUniqueKey(e),{setViewport:r,setHold:i}=rt("Range.Provider"),[,{hovered:l,count:c},a]=Q.use$1({aetherKey:s,type:z.Provider$1.TYPE,schema:z.providerStateZ,initialState:{...n,cursor:null,hovered:null,count:0}}),x=zn({key:s,loc:"top",size:c>0?32:0,order:3},"Annotation.Provider"),d=kt.useContextMenu(),p=Z.useSyncedRef(d.visible),m=g.useCallback(f=>{const h=y=>{a(S=>({...S,cursor:{x:y.clientX,y:y.clientY}}))},j=f.currentTarget;j.addEventListener("mousemove",h),j.addEventListener("mouseleave",()=>{j.removeEventListener("mousemove",h),p.current||a(y=>({...y,cursor:null}))},{once:!0})},[a]);return o.jsxRuntimeExports.jsx(kt.ContextMenu,{...d,menu:()=>t==null||l==null?null:t(l),children:o.jsxRuntimeExports.jsx(ne.Space,{style:{...x,cursor:l!=null?"pointer":"default",width:"100%",height:"100%"},onContextMenu:d.open,className:d.className,onClick:()=>{l!=null&&(r({box:u.$t.construct({x:l.viewport.lower,y:0},{x:l.viewport.upper,y:1}),mode:"zoom",cursor:u.J.ZERO,stage:"start"}),i(!0))},onMouseEnter:m})})},C1=Object.freeze(Object.defineProperty({__proto__:null,Annotation:R1,Provider:cc},Symbol.toStringTag,{value:"Module"})),ac={defaultMode:"empty",one:[["1"]],two:[["2"]],clear:[["Shift"]],empty:[[]]},w1=Ie.flattenConfig(ac),uc=({aetherKey:e})=>{const t=Q.useUniqueKey(e),[,,n]=Q.use$1({aetherKey:t,type:z.Measure.TYPE,schema:z.measureStateZ,initialState:{hover:null,one:null,two:null}}),s=g.useRef(null),r=Ie.useHeldRef({triggers:w1,loose:!0}),i=g.useCallback(({mode:a,cursor:x})=>{if(a==="click"){const d=Ie.determineMode(ac,r.current.triggers,{loose:!0});if(["one","two"].includes(d))return n(p=>({...p,[d]:x}));n(d==="clear"?p=>({...p,one:null,two:null}):p=>({...p,one:p.one??x,two:p.one!==null?x:p.two}))}},[n,r]);zl(i);const l=g.useCallback(a=>n(x=>({...x,hover:u.J.construct(a)})),[n]),c=g.useCallback(()=>{n(a=>({...a,hover:null}))},[n]);return g.useEffect(()=>{if(s.current===null)return;const a=s.current.parentElement;if(a!=null)return a.addEventListener("mousemove",l),a.addEventListener("mouseleave",c),()=>{a.removeEventListener("mousemove",l),a.removeEventListener("mouseleave",c)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:s})},b1=Object.freeze(Object.defineProperty({__proto__:null,Measure:uc},Symbol.toStringTag,{value:"Module"})),mr=({aetherKey:e,label:t,position:n,onLabelChange:s,onPositionChange:r,onUnitsChange:i,units:l="",color:c,lineWidth:a,lineDash:x,className:d,onSelect:p,style:m,...f})=>{const[h,j]=st.usePurePassthrough({value:t,onChange:s,initial:""}),y=Z.useSyncedRef(r),[,{pixelPosition:S},b]=Q.use$1({aetherKey:e,type:z.Rule.TYPE,schema:z.ruleStateZ,initialState:{color:c,dragging:!1,position:n,lineWidth:a,lineDash:x},onAetherChange:g.useCallback(({position:B})=>{var _;B!=null&&((_=y.current)==null||_.call(y,B))},[y])}),E=g.useRef(S);S!==E.current&&(E.current=S);const{id:C}=rt("Rule"),L=document.getElementById(C),T=L==null?void 0:L.querySelector(".pluto-line-plot__viewport"),P=g.useRef(S);g.useEffect(()=>{b(B=>({...B,position:n,color:c,lineWidth:a,lineDash:x}))},[n,c,a,x]);const O=Ke.useCursorDrag({onStart:g.useCallback(()=>{p==null||p(),b(B=>({...B,dragging:!0})),P.current=E.current},[]),onMove:B=>{b(_=>({..._,pixelPosition:(P.current??0)+u.$t.signedHeight(B)}))},onEnd:g.useCallback(()=>{b(B=>({...B,dragging:!1})),P.current=S},[])}),I=g.useRef(null);if(n==null||S==null)return null;const D=u.Dt.pickByContrast(c,u.Dt.BLACK,u.Dt.WHITE),H=o.jsxRuntimeExports.jsxs("div",{ref:I,className:u.CSS.B("rule"),style:{top:`calc(${S}px - 0.5rem)`},children:[o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("rule","drag-handle"),onDragStart:O,draggable:!0}),o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",className:u.CSS(d,u.CSS.BE("rule","tag")),bordered:!0,onClick:p,size:1,rounded:!0,style:{borderColor:u.Dt.cssString(c),backgroundColor:u.Dt.hex(u.Dt.setAlpha(c,.7)),...m},...f,children:[o.jsxRuntimeExports.jsx(Z.Editable,{className:u.CSS.B("label"),level:"small",value:h,onChange:j,color:D}),o.jsxRuntimeExports.jsx(Ns.Divider,{y:!0,style:{borderColor:u.Dt.cssString(c)}}),o.jsxRuntimeExports.jsxs(ne.Space,{size:"small",x:!0,align:"center",children:[o.jsxRuntimeExports.jsx(Z.Editable,{value:n.toFixed(2),onChange:B=>{const _=Number(B);isFinite(_)&&(r==null||r(_))},level:"small",color:D}),o.jsxRuntimeExports.jsx(Z.MaybeEditable,{level:"small",color:D,value:l,onChange:i})]})]})]});return T==null?H:Sl.createPortal(H,T)},v1=Object.freeze(Object.defineProperty({__proto__:null,Rule:mr},Symbol.toStringTag,{value:"Module"})),xc=me.canDropOfType(ot),k1=({lines:e,axes:t,showTitle:n=!0,title:s="",onTitleChange:r,showLegend:i=!0,legendPosition:l,onLegendPositionChange:c,titleLevel:a="h4",onLineChange:x,onRuleChange:d,onAxisChannelDrop:p,onAxisChange:m,rules:f,enableTooltip:h=!0,enableMeasure:j=!1,initialViewport:y=u.$t.DECIMAL,legendVariant:S,onViewportChange:b,viewportTriggers:E,annotationProvider:C,onSelectRule:L,children:T,...P})=>{var B;const O=t.filter(({location:_})=>u.K.isY(_)),I=g.useRef(null),D=Z.usePrevious(e.length),H=Z.usePrevious(P.hold);return(D===0&&e.length!==0||H===!0&&P.hold===!1)&&((B=I.current)==null||B.reset()),o.jsxRuntimeExports.jsxs(Bl,{...P,children:[O.map((_,R)=>{const k=e.filter(A=>A.axes.x===_.key),v=t.filter(({location:A})=>u.K.isX(A)),M=f==null?void 0:f.filter(A=>[...v.map(({key:$})=>$),_.key].includes(A.axis));return o.jsxRuntimeExports.jsx(M1,{axis:_,index:R,lines:k,yAxes:v,rules:M,onAxisChannelDrop:p,onAxisChange:m,annotationProvider:C,onRuleChange:d,onSelectRule:L},_.key)}),i&&o.jsxRuntimeExports.jsx(Zl,{onLineChange:x,position:l,onPositionChange:c,variant:S}),n&&o.jsxRuntimeExports.jsx(Wl,{value:s,onChange:r,level:a}),o.jsxRuntimeExports.jsxs(lc,{initial:y,onChange:b,triggers:E,ref:I,children:[h&&o.jsxRuntimeExports.jsx(Yl,{}),j&&o.jsxRuntimeExports.jsx(uc,{}),T]})]})},M1=({yAxes:e,lines:t,index:n,rules:s,onRuleChange:r,onSelectRule:i,onAxisChannelDrop:l,onAxisChange:c,axis:{location:a,key:x,showGrid:d,...p},annotationProvider:m})=>{const f=me.useDrop({type:"Channel.LinePlot.XAxis",canDrop:xc,onDrop:g.useCallback(({items:y})=>{const S=me.filterByType(ot,y);return l==null||l(x,S.map(({key:b})=>b)),S},[x,l])}),h=s==null?void 0:s.filter(y=>y.axis===x),j=me.useDraggingState();return o.jsxRuntimeExports.jsxs(Ol,{...p,...f,location:a,axisKey:x,showGrid:d??n===0,className:u.CSS(u.CSS.dropRegion(me.canDropOfType(ot)(j))),onAutoBoundsChange:y=>c==null?void 0:c({key:x,bounds:y}),children:[e.map((y,S)=>{const b=t.filter(C=>C.axes.y===y.key),E=s==null?void 0:s.filter(C=>C.axis===y.key);return o.jsxRuntimeExports.jsx(P1,{axis:{...y,showGrid:d??(n===0&&S===0)},lines:b,rules:E,onRuleChange:r,onAxisChannelDrop:l,onAxisChange:c,onSelectRule:i},y.key)}),h==null?void 0:h.map(y=>g.createElement(mr,{aetherKey:y.key,...y,key:y.key,onLabelChange:S=>r==null?void 0:r({key:y.key,label:S}),onPositionChange:S=>r==null?void 0:r({key:y.key,position:S}),onUnitsChange:S=>r==null?void 0:r({key:y.key,units:S}),onSelect:()=>i==null?void 0:i(y.key)})),o.jsxRuntimeExports.jsx(cc,{...m})]})},_1=({channels:{x:e,y:t}})=>`${e??0}-${t}`,P1=({lines:e,rules:t,onRuleChange:n,onAxisChannelDrop:s,onAxisChange:r,axis:{key:i,location:l,...c},onSelectRule:a})=>{const x=me.useDrop({type:"Channel.LinePlot.YAxis",canDrop:xc,onDrop:g.useCallback(({items:p})=>{const m=me.filterByType(ot,p);return s==null||s(i,m.map(({key:f})=>f)),m},[i,s])}),d=me.useDraggingState();return o.jsxRuntimeExports.jsxs(Vl,{...c,...x,location:l,axisKey:i,className:u.CSS(u.CSS.dropRegion(me.canDropOfType(ot)(d))),onAutoBoundsChange:p=>r==null?void 0:r({key:i,bounds:p}),children:[e.map(p=>o.jsxRuntimeExports.jsx(L1,{line:p},_1(p))),t==null?void 0:t.map(p=>g.createElement(mr,{aetherKey:p.key,...p,key:p.key,onLabelChange:m=>n==null?void 0:n({key:p.key,label:m}),onPositionChange:m=>n==null?void 0:n({key:p.key,position:m}),onUnitsChange:m=>n==null?void 0:n({key:p.key,units:m}),onClick:()=>a==null?void 0:a(p.key)}))]})},L1=({line:e})=>e.variant==="static"?o.jsxRuntimeExports.jsx(T1,{line:e}):o.jsxRuntimeExports.jsx(N1,{line:e}),N1=({line:{key:e,timeSpan:t,channels:{x:n,y:s},axes:r,...i}})=>{const{xTelem:l,yTelem:c}=g.useMemo(()=>{const a=Number(t.valueOf())*3,x=z.streamChannelData({timeSpan:t,channel:s,keepFor:a}),d=n!=null&&n!==0;return{xTelem:z.streamChannelData({timeSpan:t,channel:d?n:s,useIndexOfChannel:!d,keepFor:a}),yTelem:x}},[t.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(ur,{aetherKey:e,y:c,x:l,...i})},T1=({line:{timeRange:e,key:t,channels:{x:n,y:s},...r}})=>{const{xTelem:i,yTelem:l}=g.useMemo(()=>{const c=z.channelData({timeRange:e,channel:s}),a=n!=null&&n!==0;return{xTelem:z.channelData({timeRange:e,channel:a?n:s,useIndexOfChannel:!a}),yTelem:c}},[e.start.valueOf(),e.end.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(ur,{aetherKey:t,y:l,x:i,...r})},ii=[{key:"name",name:"Name"},{key:"alias",name:"Alias"},{key:"rate",name:"Rate"},{key:"dataType",name:"Data Type"},{key:"index",name:"Index"},{key:"key",name:"Key"},{key:"isIndex",name:"Is Index"}],ds=({items:e},t)=>{const n=me.filterByType(ot,e);return n.length>0&&!n.every(s=>t.includes(s.key))},dc=["name","alias"],pc=e=>{const t=$s();return g.useMemo(()=>e.length===0?ii:ii.filter(n=>e.includes(n.key)),[e,t])},mc=e=>{if(e==null)return Z.y4.Channel;if(nt.jv.isCalculated(e))return Z.y4.Calculation;if(e.isIndex)return Z.y4.Index;const t=new u.g$2(e.dataType);return t.isInteger?Z.y4.Binary:t.isFloat?Z.y4.Decimal:t.equals(u.g$2.STRING)?Z.y4.String:t.equals(u.g$2.JSON)?Z.y4.JSON:Z.y4.Channel},$1=({key:e,...t})=>{const n=mc(t.entry);return o.jsxRuntimeExports.jsx(dr,{icon:o.jsxRuntimeExports.jsx(n,{}),...t},e)},A1=({columns:e=dc,onChange:t,className:n,value:s,searchOptions:r,...i})=>{const l=qe(),c=$s(),a=pc(e),x=or(),d=Ne.useMemoDeepEqualProps(r),p=g.useMemo(()=>l==null?void 0:l.channels.newSearcherWithOptions({rangeKey:x,internal:!1,...d}),[l,x,d]),m=l!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:f,onDragEnd:h,...j}=me.useDragAndDrop({type:"Channel.SelectMultiple",canDrop:g.useCallback(C=>ds(C,Me.A(s)),[s]),onDrop:g.useCallback(({items:C})=>{const L=me.filterByType(ot,C);if(L.length===0)return[];const T=u.c$1.unique([...Me.A(s),...L.map(P=>P.key)]);return t(T,{clickedIndex:null,clicked:null,entries:[]}),L},[t,s])}),y=me.useDraggingState(),S=g.useCallback(({dropped:C})=>{t(Me.A(s).filter(L=>!C.some(T=>T.key===L)),{clickedIndex:null,clicked:null,entries:[]})},[t,s]),b=g.useCallback((C,L)=>f([{key:L,type:ot}],S),[f,S]),E=g.useCallback(C=>c[C.key]??C.name,[c]);return o.jsxRuntimeExports.jsx(cn,{className:u.CSS(n,u.CSS.dropRegion(ds(y,Me.A(s)))),value:s,onTagDragStart:b,onTagDragEnd:h,searcher:p,onChange:t,columns:a,emptyContent:m,entryRenderKey:E,renderTag:$1,...j,...i})},Dt=({columns:e=dc,onChange:t,value:n,className:s,data:r,searchOptions:i,...l})=>{const c=qe(),a=$s(),x=pc(e),d=or(),p=Ne.useMemoDeepEqualProps(i),m=g.useMemo(()=>{if(!(r!=null&&r.length>0))return c==null?void 0:c.channels.newSearcherWithOptions({rangeKey:d,internal:!1,...p})},[c,d,r==null?void 0:r.length,p]),f=c!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),h=g.useId(),j=g.useMemo(()=>({key:h,type:"Channel.SelectMultiple"}),[h]),{startDrag:y,onDragEnd:S,...b}=me.useDragAndDrop({type:"Channel.SelectSingle",canDrop:g.useCallback(T=>ds(T,Me.o(n)),[n]),onDrop:g.useCallback(({items:T})=>{const P=me.filterByType(ot,T);return P.length===0?[]:(t(P[0].key,{clickedIndex:null,clicked:null,entries:[]}),P)},[j,t])}),E=me.useDraggingState(),C=g.useCallback(()=>n!=null&&y([{type:ot,key:n}]),[y,n]),L=g.useCallback(T=>a[T.key]??T.name,[a]);return o.jsxRuntimeExports.jsx(ft,{data:r,className:u.CSS(s,u.CSS.dropRegion(ds(E,Me.o(n)))),value:n,onDragStart:C,onDragEnd:S,onChange:t,searcher:m,columns:x,emptyContent:f,entryRenderKey:L,...b,...l})},I1=Object.freeze(Object.defineProperty({__proto__:null,AliasInput:hh,AliasProvider:$l,LinePlot:k1,SelectMultiple:A1,SelectSingle:Dt,resolveIcon:mc,useActiveRange:or,useAlias:Tl,useAliases:$s,useContext:ln,useName:As},Symbol.toStringTag,{value:"Module"})),_t=({path:e,optional:t=!1,onChange:n})=>{const s=ht(),{get:r,bind:i,set:l,setStatus:c}=s,[a,x]=g.useState(r(e,{optional:t}));g.useEffect(()=>(x(r(e,{optional:t})),i({path:e,onChange:x,listenToChildren:!1})),[e,n,i,r]);const d=g.useCallback(f=>{n==null||n(f,{...s,path:e}),l(e,f)},[e,l,n]),p=g.useCallback(f=>c(e,f),[e,c]);if(a==null){if(!t)throw new Error(`Field state is null: ${e}`);return null}let m;return s.mode==="preview"&&(m="preview"),{onChange:d,setStatus:p,variant:m,...a}},fc=(e,t=!1,n)=>{const{get:s,bind:r}=ht(n),[,i]=g.useState(0);return g.useEffect(()=>(i(l=>l+1),r({path:e,onChange:()=>i(l=>l+1)})),[e,r]),s(e,{optional:t})??null},hc=(e,t=!1,n)=>{var l;const{get:s,bind:r}=ht(n),[,i]=g.useState(0);return g.useEffect(()=>(i(c=>c+1),r({path:e,onChange:()=>i(c=>c+1)})),[e,r]),((l=s(e,{optional:t}))==null?void 0:l.value)??null},D1=e=>{var t,n;return((n=(t=fc(e,!0))==null?void 0:t.status)==null?void 0:n.variant)==="success"},z1=({path:e,ctx:t,onChange:n})=>{const s=ht(t);g.useEffect(()=>s.bind({path:e,onChange:r=>n(r,s),listenToChildren:!1}),[e,s])},B1=({path:e,optional:t=!1})=>{const{bind:n,get:s}=ht(),[r,i]=g.useState(s(e,{optional:t}));if(g.useEffect(()=>(i(s(e,{optional:t})),n({path:e,onChange:l=>i({...l,value:u.Qt(l.value)}),listenToChildren:!0})),[e,n,s]),r==null&&!t)throw new Error("Field state is null");return(r==null?void 0:r.value)??null},gc=(e,t)=>({add:(n,s)=>{const r=u.Qt(e.get(t).value);r.splice(s,0,...Me.A(n)),e.set(t,r,{validateChildren:!1})},push:(n,s)=>{const r=u.Qt(e.get(t).value);r.push(...Me.A(n)),s!=null&&r.sort(s),e.set(t,r,{validateChildren:!1})},remove:n=>{const s=e.get(t).value,r=new Set(Me.A(n));e.set(t,s.filter((i,l)=>!r.has(l)))},keepOnly:n=>{const s=e.get(t).value,r=new Set(Me.A(n));e.set(t,s.filter((i,l)=>r.has(l)))},set:n=>e.set(t,st.executeSetter(n,e.get(t).value)),sort:n=>{const s=u.Qt(e.get(t).value);s.sort(n),e.set(t,s)}}),O1=({path:e,updateOnChildren:t=!1,ctx:n})=>{const s=ht(n),{bind:r,get:i}=s,[l,c]=g.useState(i(e).value);return g.useEffect(()=>(c(i(e).value),r({path:e,onChange:a=>{c(u.Qt(a.value))},listenToChildren:t})),[e,r,i,c]),g.useMemo(()=>({value:l,...gc(s,e)}),[l,s,e])},jc=g.createContext({mode:"normal",bind:()=>()=>{},set:()=>{},reset:()=>{},remove:()=>{},get:()=>({value:void 0,status:{key:"",variant:"success",message:""},touched:!1,required:!1}),validate:()=>!1,validateAsync:()=>Promise.resolve(!1),value:()=>({}),has:()=>!1,setStatus:()=>{},clearStatuses:()=>{},setCurrentStateAsInitialValues:()=>{}}),ht=e=>{const t=g.use(jc);return e??t},li=e=>({key:e,variant:"success",message:""}),V1=e=>e.code===pe.z.ZodIssueCode.custom&&e.params!=null&&"variant"in e.params?e.params.variant:"error",Ec=({values:e,sync:t=!1,schema:n,mode:s="normal",onChange:r,onHasTouched:i})=>{const l=Z.useInitializerRef(()=>({state:ze.x.copy(e),statuses:new Map,touched:new Set,listeners:new Map,parentListeners:new Map})),c=Z.useSyncedRef(n),a=Z.useSyncedRef(r),x=Z.useSyncedRef(e),d=Z.useSyncedRef(i),p=Re.useErrorHandler(),m=g.useCallback(()=>{x.current=ze.x.copy(l.current.state),S()},[]),f=g.useCallback(({path:_,onChange:R,listenToChildren:k=!1})=>{var $;const{parentListeners:v,listeners:M}=l.current,A=k?v:M;return A.has(_)||A.set(_,new Set),($=A.get(_))==null||$.add(R),()=>{var V;return(V=A.get(_))==null?void 0:V.delete(R)}},[]),h=g.useCallback((_,{optional:R}={optional:!1})=>{const{state:k,statuses:v,touched:M}=l.current,A=ze.x.get(k,_,{optional:R});if(A==null)return null;const $={value:A,status:v.get(_)??li(_),touched:M.has(_),required:!1};if(c.current==null)return $;const V=c.current,F=u.L.getFieldSchema(V,_,{optional:!0});return F==null||"isOptional"in F&&typeof F.isOptional=="function"&&($.required=!F.isOptional()),$},[]),j=g.useCallback(_=>{var M;const{touched:R}=l.current,k=R.size===0;R.add(_);const v=R.size===0;k!==v&&((M=d.current)==null||M.call(d,!v))},[]),y=g.useCallback(_=>{var M;const{touched:R}=l.current,k=R.size===0;R.delete(_);const v=R.size===0;k!==v&&((M=d.current)==null||M.call(d,!v))},[]),S=g.useCallback(()=>{var v;const{touched:_}=l.current,R=_.size===0;_.clear();const k=_.size===0;R!==k&&((v=d.current)==null||v.call(d,!k))},[]),b=g.useCallback(_=>{const{state:R,statuses:k,listeners:v,parentListeners:M}=l.current;ze.x.remove(R,_),k.delete(_),y(_),v.delete(_),M.delete(_)},[]),E=g.useCallback(_=>{const{statuses:R}=l.current;l.current.state=_??ze.x.copy(x.current),L(""),R.clear(),S()},[]),C=g.useCallback(_=>{var v;const{listeners:R}=l.current,k=h(_,{optional:!0});k!=null&&((v=R.get(_))==null||v.forEach(M=>M(k)))},[]),L=g.useCallback(_=>{const{listeners:R,parentListeners:k}=l.current,v=R.get(_);if(_==""&&([...R.keys()].forEach($=>{var F;const V=h($,{optional:!0});V!=null&&((F=R.get($))==null||F.forEach(W=>{W(V)}))}),[...k.keys()].forEach($=>{var F;const V=h($,{optional:!0});V!=null&&((F=k.get($))==null||F.forEach(W=>{W(V)}))})),v!=null){const M=h(_,{optional:!0});M!=null&&v.forEach(A=>{A(M)})}k.forEach((M,A)=>{if(ze.x.pathsMatch(_,A)){const V=h(A,{optional:!0});V!=null&&M.forEach(F=>{F(V)})}})},[]),T=g.useCallback((_,R="",k=!0)=>{const{statuses:v,listeners:M}=l.current;if(_.success){const F=[...v.keys()];return v.clear(),F.forEach(W=>C(W)),!0}let A=!0;const $=new Set(_.error.issues.map(F=>F.path.join(".")));let V=(F,W)=>F===W;return k&&(V=(F,W)=>ze.x.pathsMatch(F,W)),_.error.issues.forEach(F=>{var oe;const{message:W}=F,ee=F.path.join(".");if(!V(ee,R))return;const te=V1(F);te!=="warning"&&(A=!1),v.set(ee,{key:ee,variant:te,message:W}),j(ee);let se=h(ee,{optional:!0});se??(se={value:void 0,status:v.get(ee)??li(ee),touched:!1,required:!1}),(oe=M.get(ee))==null||oe.forEach(J=>J(se))}),v.forEach((F,W)=>{$.has(W)||(v.delete(W),C(W))}),A},[]),P=g.useCallback((_,R)=>{if(c.current==null)return!0;const{state:k}=l.current,v=c.current.safeParse(k);return T(v,_,R)},[T]),O=g.useCallback(async(_,R)=>{if(c.current==null)return!0;const{state:k}=l.current,v=await c.current.safeParseAsync(k);return T(v,_,R)},[T]),I=g.useCallback((_,R,k={})=>{const v=ze.x.get(l.current.state,_,{optional:!0}),{validateChildren:M=!0}=k,{state:A}=l.current,$=ze.x.get(x.current,_,{optional:!0});ze.x.equal($,R)?y(_):j(_),_.length===0?l.current.state=R:ze.x.set(A,_,R),L(_),p(async()=>{var W;let F;try{F=P(_,M)}catch{F=await O(_,M)}(W=a.current)==null||W.call(a,{values:l.current.state,path:_,prev:v,valid:F})},"Failed to validate form")},[]),D=g.useCallback(_=>ze.x.has(l.current.state,_),[]),H=g.useCallback((_,R)=>{l.current.statuses.set(_,R),j(_),C(_)},[]),B=g.useCallback(()=>{const{statuses:_}=l.current;_.clear(),_.forEach((R,k)=>C(k))},[]);return g.useEffect(()=>{if(!t)return;const{listeners:_}=l.current;l.current.state=e,_.forEach((R,k)=>{const v=h(k,{optional:!0});v!=null&&R.forEach(M=>M(v))})},[t,e]),g.useMemo(()=>({bind:f,set:I,get:h,mode:s,validate:P,validateAsync:O,value:()=>l.current.state,has:D,remove:b,setStatus:H,clearStatuses:B,reset:E,setCurrentStateAsInitialValues:m}),[f,I,h,P,O,D,b,H,B,E,s,m])},F1=({children:e,...t})=>o.jsxRuntimeExports.jsx(jc,{value:t,children:e}),H1=he.componentRenderProp(mt.Text),Ce=({path:e,children:t=H1,label:n,padHelpText:s=!0,visible:r=!0,hideIfNull:i=!1,optional:l,onChange:c,className:a,...x})=>{const d=_t({path:e,optional:l??i,onChange:c}),p=ht();if(d==null)return null;if(e==null)throw new Error("No path provided to Form Field");if(n??(n=u.d.capitalize(ze.x.element(e,-1))),r=typeof r=="function"?r(d,p):r,!r)return null;const m=d.status.message,{onChange:f,value:h}=d,j={onChange:f,value:h};return d.variant!=null&&(j.variant=d.variant),o.jsxRuntimeExports.jsx(ge.Item,{padHelpText:s,helpText:m,helpTextVariant:d.status.variant,label:n,required:d.required,className:u.CSS(a,u.CSS.BE("field",e.split(".").join("-")),u.CSS.M(d.status.variant)),...x,children:t(j)})},Pt=e=>({fieldKey:t,fieldProps:n,inputProps:s})=>{const r=({inputProps:i,path:l,fieldKey:c=t,...a})=>o.jsxRuntimeExports.jsx(Ce,{...n,...a,path:c?`${l}.${c}`:l,children:x=>o.jsxRuntimeExports.jsx(e,{...x,...s,...i})});return r.displayName=e.displayName,r},yc=Pt(ge.Numeric),Ze=yc({}),Sc=Pt(mt.Text),fr=Sc({}),Rc=Pt(Q.Switch$1),Os=Rc({}),Z1=Pt(ft),W1=Pt(cn),Y1=Pt(Ds),G1=Pt(it),hr=({key:e,open:t,onChange:n})=>{const s=Ne.useMemoPrimitiveArray(e);Q.useAsyncEffect(async()=>{if(t==null)return;const r=await t();if(r==null)return;const i=r.onChange(n);return async()=>{i(),await r.close()}},[t==null,s])},K1=({fetchInitialValue:e,...t})=>{const[n,s]=g.useState(void 0);return Q.useAsyncEffect(async()=>{s(await e())},[e]),hr({...t,onChange:s}),n},q1=Object.freeze(Object.defineProperty({__proto__:null,useListener:hr,useState:K1},Symbol.toStringTag,{value:"Module"})),X1=({key:e,name:t,queryFn:n,values:s,openObservable:r,applyChanges:i,applyObservable:l,...c})=>{const a=qe(),x=Re.useErrorHandler(),d=Ne.useMemoPrimitiveArray(e),p=Ec({values:s,...c,sync:!1,onChange:h=>{a!=null&&x(async()=>{await(i==null?void 0:i({...h,client:a}))},`Failed to apply changes for ${t}`)}});Q.useAsyncEffect(async()=>{if(a!=null)try{const h=await n({client:a});p.set("",h)}catch(h){x(h,`Failed to retrieve ${t}`)}},[d,a==null?void 0:a.key]);const m=g.useCallback(async()=>{if(a!=null)return await(r==null?void 0:r(a))},[d,a==null?void 0:a.key]),f=g.useCallback(h=>l==null?void 0:l({changes:h,ctx:p}),[d,l]);return hr({key:d,open:m,onChange:f}),p},U1=Object.freeze(Object.defineProperty({__proto__:null,Field:Ce,Form:F1,NumericField:Ze,SwitchField:Os,TextField:fr,buildButtonSelectField:G1,buildDropdownButtonSelectField:Y1,buildNumericField:yc,buildSelectMultiField:W1,buildSelectSingleField:Z1,buildSwitchField:Rc,buildTextField:Sc,fieldArrayUtils:gc,fieldBuilder:Pt,use:Ec,useChildFieldValues:B1,useContext:ht,useField:_t,useFieldArray:O1,useFieldListener:z1,useFieldState:fc,useFieldValid:D1,useFieldValue:hc,useSynced:X1},Symbol.toStringTag,{value:"Module"})),J1=[{key:"name",name:"Name"},{key:"location",name:"Location",render:({entry:{location:e,rackName:t}})=>o.jsxRuntimeExports.jsx(vl,{level:"small",shade:9,weight:450,style:{marginTop:"0.25rem"},size:"tiny",children:t?`${t}.${e}`:e})}],Q1=({searchOptions:e,filter:t,...n})=>{const s=qe();let r=s==null?void 0:s.hardware.devices;e!=null&&s!=null&&(r=s.hardware.devices.newSearcherWithOptions(e));const[i,l]=g.useState(new Map),c=g.useCallback(a=>((t==null?void 0:t(a))??a).map(d=>({...d,rackName:i.get(d.rack)})),[t,i]);return Q.useAsyncEffect(async()=>{if(s==null){l(new Map);return}const a=await s.hardware.racks.retrieve([]);l(new Map(a.map(({key:x,name:d})=>[x,d])))},[s==null?void 0:s.key]),o.jsxRuntimeExports.jsx(ft,{columns:J1,searcher:r,entryRenderKey:"name",filter:c,...n})},eg=Object.freeze(Object.defineProperty({__proto__:null,SelectSingle:Q1},Symbol.toStringTag,{value:"Module"})),tg=[{key:"name",name:"Name"},{key:"location",name:"Location"}],ng=e=>{const t=qe();return o.jsxRuntimeExports.jsx(ft,{columns:tg,searcher:t==null?void 0:t.hardware.racks,entryRenderKey:"name",...e})},sg=Object.freeze(Object.defineProperty({__proto__:null,SelectSingle:ng},Symbol.toStringTag,{value:"Module"})),Qt="label",gr=[{key:"color",name:"Color",render:({entry:e})=>o.jsxRuntimeExports.jsx(Z.y4.Circle,{name:"circle",color:e.color,style:{height:"2.5rem",width:"2.5rem"}})},{key:"name",name:"Name"}],ps=({items:e},t)=>{const n=me.filterByType(Qt,e);return n.length>0&&!n.every(s=>t.includes(s.key))},og=({entry:e,loading:t,entryKey:n,entryRenderKey:s,...r})=>o.jsxRuntimeExports.jsx(vn,{color:e==null?void 0:e.color,...r,children:e==null?void 0:e.name}),rg=he.componentRenderProp(og),ig=({onChange:e,className:t,value:n,...s})=>{const r=qe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=me.useDragAndDrop({type:"Label.SelectMultiple",canDrop:g.useCallback(m=>ps(m,Me.A(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=me.filterByType(Qt,m);if(f.length===0)return[];const h=u.c$1.unique([...Me.A(n),...f.map(j=>j.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),x=me.useDraggingState(),d=g.useCallback(({dropped:m})=>{e(Me.A(n).filter(f=>!m.some(h=>h.key===f)),{clickedIndex:null,clicked:null,entries:[]})},[e,n]),p=g.useCallback((m,f)=>l([{key:f,type:Qt}],d),[l,d]);return o.jsxRuntimeExports.jsx(cn,{className:u.CSS(t,u.CSS.dropRegion(ps(x,Me.A(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.labels,onChange:e,columns:gr,emptyContent:i,renderTag:rg,addPlaceholder:"Label",...a,...s})},Cc=({value:e,onChange:t})=>{const n=qe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),r=g.useId(),i=g.useMemo(()=>({key:r,type:"Label.SelectMultiple"}),[r]),l=me.useDragAndDrop({type:"Label.SelectSingle",canDrop:g.useCallback(x=>ps(x,Me.o(e)),[e]),onDrop:g.useCallback(({items:x})=>{const d=me.filterByType(Qt,x);return d.length===0?[]:(t(d[0].key,{clickedIndex:null,clicked:null,entries:[]}),d)},[i,t])}),c=me.useDraggingState(),a=g.useCallback(()=>e!=null&&l.startDrag([{type:Qt,key:e}]),[l.startDrag,e]);return{emptyContent:s,dragging:c,...l,onDragStart:a,searcher:n==null?void 0:n.labels}},lg=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=Cc({value:t,onChange:e});return o.jsxRuntimeExports.jsx(ft,{data:s,className:u.CSS(n,u.CSS.dropRegion(ps(i,Me.o(t)))),value:t,onChange:e,columns:gr,entryRenderKey:"name",...l,...r})},cg=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=Cc({value:t,onChange:n});return o.jsxRuntimeExports.jsx(ft,{data:e,value:t,onChange:n,columns:gr,entryRenderKey:"name",...i,...s})},ag=Object.freeze(Object.defineProperty({__proto__:null,HAUL_TYPE:Qt,SelectButton:cg,SelectMultiple:ig,SelectSingle:lg},Symbol.toStringTag,{value:"Module"})),Vs=new Error("Tab not found"),ug=new Error("Invalid Mosaic"),ms=(e,t,n="center",s,r)=>{if(e=lt(e),s===void 0)return No(e,t);const i=To(e,s);if(n==="center")return i.tabs||(i.tabs=[]),r!==void 0&&r>=0&&r<=i.tabs.length?i.tabs.splice(r,0,t):i.tabs.push(t),i.selected=t.tabKey,e;const l=i.key*2,c=i.key*2+1,a=n==="top"||n==="left"?l:c;if(To(e,a).key!==i.key)return ms(e,t,"center",a);if(i.tabs==null||i.tabs.length===0)return ms(e,t,"center",s);const[x,d,p]=hg(n);if(i.direction=p,i[x]={key:0,tabs:[t],selected:t.tabKey},i[d]={key:0,tabs:i.tabs,selected:i.selected},i.first==null||i.last==null)throw ug;return i.first.key=l,i.last.key=c,i.tabs=void 0,i.size=void 0,i.selected=void 0,e},xg=(e,t,n)=>{var i;e=lt(e);const[s,r]=zt(e,t);if(s==null||r==null)throw Vs;return r.tabs=(i=r.tabs)==null?void 0:i.map(l=>l.tabKey===t?n(l):l),e},No=(e,t)=>(e=lt(e),e.tabs!=null?(e.tabs.push(t),e.selected=t.tabKey,e):(e.first!=null?e.first=No(e.first,t):e.last!=null&&(e.last=No(e.last,t)),e)),fs=e=>{e=lt(e);const t=[];if(e.tabs!=null&&(e.selected=Le.resetSelection(e.selected,e.tabs),e.selected!=null&&t.push(e.selected)),e.first!=null){const[n,s]=fs(e.first);e.first=n,t.push(...s)}if(e.last!=null){const[n,s]=fs(e.last);e.last=n,t.push(...s)}return[e,t]},jr=(e,t)=>{var r;e=lt(e);const[,n]=zt(e,t);if(n==null)return[e,null];n.tabs=(r=n.tabs)==null?void 0:r.filter(i=>i.tabKey!==t),n.selected=Le.resetSelection(n.selected,n.tabs),e=fg(e);const s=n.selected??hs(e);return[e,s]},hs=e=>e.selected!=null?e.selected:e.first!=null?hs(e.first):e.last!=null?hs(e.last):null,wc=(e,t)=>{e=lt(e);const[n,s]=zt(e,t);if(n==null||s==null)throw Vs;return s.selected=t,e},bc=(e,t,n,s,r)=>{e=lt(e);const[i,l]=zt(e,t);if(i==null||l==null)throw Vs;const[c,a]=jr(e,t);return[ms(c,i,n,s,r),a]},kn=(e,t)=>{if(e.tabs!=null)return e.tabs.some(n=>n.tabKey===t)?e:void 0;if(e.first!=null){const n=kn(e.first,t);if(n!=null)return n}if(e.last!=null){const n=kn(e.last,t);if(n!=null)return n}},vc=(e,t,n)=>{const s=gs(e,t);if(s==null)throw new Error("Node not found");return s.size=n,e},dg=(e,t,n)=>{e=lt(e);const s=kn(e,t);if(s==null)throw new Error("Tab not found");if(s.tabs==null||s.tabs.length===0)throw new Error("Node has no tabs");const r=s.tabs.findIndex(d=>d.tabKey===t);if(r===-1)throw new Error("Tab not found in node");const i=s.tabs[r];s.tabs=s.tabs.filter(d=>d.tabKey!==t);const l=s.key*2,a={key:s.key*2+1,tabs:[i],selected:i.tabKey},x={key:l,tabs:s.tabs,selected:s.selected};return x.selected=Le.resetSelection(x.selected,x.tabs),s.direction=n,s.first=x,s.last=a,s.tabs=void 0,s.selected=void 0,e},pg=(e,t)=>{const n=kn(e,t);return n==null?!1:n.tabs!=null&&n.tabs.length>1},kc=(e,t,n)=>{e=lt(e);const[,s]=zt(e,t);if((s==null?void 0:s.tabs)==null)throw Vs;return s.tabs=Le.rename(t,n,(s==null?void 0:s.tabs)??[]),e},mg=e=>e.tabs!=null?e.tabs.length===0:e.first==null&&e.last==null,To=(e,t)=>{const n=gs(e,t);if(n!=null)return n;const s=Math.floor(t/2);return s===0?e:To(e,s)},fg=e=>{let t=!0;for(;t;)[e,t]=$o(e);return e=Io(e,1),e},$o=e=>{if(e.first==null||e.last==null)return[e,!1];if(ai(e.first))return[ci(e.last),!0];if(ai(e.last))return[ci(e.first),!0];let t,n;return[e.first,t]=$o(e.first),[e.last,n]=$o(e.last),[e,t||n]},ci=e=>(e.size=void 0,e),ai=e=>e.first==null&&e.last==null&&(e.tabs==null||e.tabs.length===0),zt=(e,t)=>{if(e.tabs!=null){const l=e.tabs.find(c=>c.tabKey===t);if(l!=null)return[l,e]}if(e.first==null||e.last==null)return[void 0,void 0];const[n,s]=zt(e.first,t);if(n!=null&&s!=null)return[n,s];const[r,i]=zt(e.last,t);return[r,i]},gs=(e,t)=>{if(e.key===t)return e;if(e.first==null||e.last==null)return;const n=gs(e.first,t);return n??gs(e.last,t)},hg=e=>{switch(e){case"top":return["first","last","y"];case"left":return["first","last","x"];case"bottom":return["last","first","y"];case"right":return["last","first","x"];case"center":throw new Error("cannot split a center placed tab")}},lt=e=>ze.x.copy(e),js=(e,t,n=[])=>(n.push(t(e)),e.first!=null&&js(e.first,t,n),e.last!=null&&js(e.last,t,n),n),Ao=(e,t)=>{t(e),e.first!=null&&Ao(e.first,t),e.last!=null&&Ao(e.last,t)},Io=(e,t)=>(e=lt(e),e.key=t,e.first!=null&&(e.first=Io(e.first,t*2)),e.last!=null&&(e.last=Io(e.last,t*2+1)),e);class Mc{constructor(t={}){tt(this,"parent");tt(this,"stub");tt(this,"el");this.el=document.createElement("div"),Object.entries(t).forEach(([n,s])=>this.el.setAttribute(n,s))}mount(t,n){n!==this.stub&&(this.unmount(null),t.replaceChild(this.el,n),this.parent=t,this.stub=n)}unmount(t){t!=null&&t!==this.stub||this.parent==null||this.stub==null||(this.parent.replaceChild(this.stub,this.el),this.parent=void 0,this.stub=void 0)}}const gg=({node:e})=>{const t=g.createRef(),n=g.useRef(e);return g.useEffect(()=>{const s=t.current;if(s==null)return;const r=s.parentNode;if(r!=null)return e.mount(r,s),()=>{t.current!=null&&e.unmount(t.current)}},[]),g.useEffect(()=>{n.current!=null&&e!==n.current&&(n.current.unmount(t.current),n.current=e);const s=t.current;if(s==null)return;const r=s.parentNode;r!=null&&e.mount(r,s)},[e]),o.jsxRuntimeExports.jsx("div",{ref:t})},_c=({node:e,children:t})=>Sl.createPortal(t,e.el),jg=Object.freeze(Object.defineProperty({__proto__:null,In:_c,Node:Mc,Out:gg},Symbol.toStringTag,{value:"Module"})),Es=g.memo(({root:e,onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,activeTab:l,emptyContent:c,onSelect:a,onClose:x,onRename:d,onReorder:p,contextMenu:m,addTooltip:f,...h})=>{const{tabs:j,direction:y,first:S,last:b,key:E,size:C}=e,L={onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,onClose:x,contextMenu:m,onSelect:a,onRename:d,onReorder:p,activeTab:l,addTooltip:f},T=g.useCallback(([D])=>n(E,D),[n]),{props:P}=tr({direction:y,onResize:T,count:2,initialSizes:C!=null?[C]:void 0});let O={};E==1&&(O={...h,className:u.CSS(u.CSS.B("mosaic"))});let I;return j!==void 0?I=o.jsxRuntimeExports.jsx(Pc,{root:e,emptyContent:c,...O,...L}):S!=null&&b!=null?I=o.jsxRuntimeExports.jsxs(nr,{id:`mosaic-${E}`,align:"stretch",...P,...O,children:[o.jsxRuntimeExports.jsx(Es,{...L,root:S,onResize:n},S.key),o.jsxRuntimeExports.jsx(Es,{...L,root:b,onResize:n},b.key)]}):(I=null,console.warn("Mosaic tree is malformed")),I});Es.displayName="Mosaic";const ys="pluto-mosaic-tab-drop",Er="pluto-mosaic-tab-create",Eg=(e,t,n)=>{if(me.filterByType(me.FILE_TYPE,t).length>0&&n)return!0;const r=me.filterByType(ys,t).map(c=>c.key),i=e.filter(c=>!r.includes(c.tabKey)).length>0;return me.filterByType(Er,t).length>0||r.length>0&&(i||e.length===0)},Pc=g.memo(({root:e,onDrop:t,onCreate:n,activeTab:s,children:r,className:i,onReorder:l,onFileDrop:c,addTooltip:a,...x})=>{const{key:d,tabs:p}=e,[m,f]=g.useState(null),h=c!=null,j=g.useCallback(({items:I})=>Eg(p,I,h),[p,h]),y=g.useCallback(({items:I,event:D})=>{if(D==null)return[];const H=Sg(D);f(null);const B=me.filterByType(me.FILE_TYPE,I).length>0,{percents:_}=ui(D),R=p.length===0?"center":xi(_);if(B)return c==null||c(d,R,D),I;const k=me.filterByType(ys,I);if(k.length>0){const M=k.map(({key:A})=>A)[0];t(d,M,R,H)}const v=me.filterByType(Er,I);if(v.length>0){const M=v.map(({key:A})=>A);n==null||n(d,R,M)}return k},[t,p.length]),S=g.useCallback(({event:I})=>{if(I==null)return;const{percents:D,inSelector:H}=ui(I);let B=null;H||(B=p.length===0?"center":xi(D)),f(B)},[p.length]),{startDrag:b,...E}=me.useDragAndDrop({type:"Mosaic",canDrop:j,onDrop:y,onDragOver:S}),C=j(me.useDraggingState()),L=g.useCallback(()=>f(null),[]),T=g.useCallback((I,{tabKey:D})=>{b([{key:D,type:ys,elementID:I.currentTarget.id}])},[b]),P=g.useCallback(()=>n==null?void 0:n(d,"center"),[d]),O=d==1&&p.length==0;return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:o.jsxRuntimeExports.jsxs(Le.Tabs,{id:`tab-${d}`,tabs:p,className:u.CSS(i,O&&m!=null&&u.CSS.M("drag-over")),onDragLeave:L,selected:e.selected,selectedAltColor:s===e.selected,onDragStart:T,onCreate:P,addTooltip:a,...E,...x,children:[e.selected!=null&&r(p.find(I=>I.tabKey===e.selected)),C&&o.jsxRuntimeExports.jsx("div",{style:{zIndex:1e3,position:"absolute",top:0,left:0,width:"100%",height:"100%"}}),m!=null&&o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("mosaic","mask"),style:yg[m]})]})})});Pc.displayName="MosaicTabLeaf";const yg={top:{left:"0%",top:"0%",width:"100%",height:"50%"},bottom:{left:"0%",top:"50%",width:"100%",height:"50%"},left:{left:"0%",top:"0%",width:"50%",height:"100%"},right:{left:"50%",top:"0%",width:"50%",height:"100%"},center:{left:"0%",top:"0%",width:"100%",height:"100%"}},ui=e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;return s<24?{percents:{x:.5,y:.5},inSelector:!0}:{percents:{x:n/t.width,y:s/t.height},inSelector:!1}},Sg=e=>{var n;const t=e.target.closest(".pluto-tabs-selector__btn");if(t!=null)return Array.from(((n=t.parentElement)==null?void 0:n.children)??[]).indexOf(t)},Rg=e=>e,Cg=e=>1-e,xi=({x:e,y:t})=>{if(e>.33&&e<.66&&t>.33&&t<.66)return"center";const[n,s]=[Rg(e),Cg(e)];if(t>n&&t>s)return"bottom";if(t<n&&t<s)return"top";if(t>n&&t<s)return"left";if(t<n&&t>s)return"right";throw new Error("[bug] - invalid insert position")},wg=({root:e,onSelect:t,children:n})=>{const s=g.useRef(new Map),r=new Set,i=js(e,l=>{var c;return(c=l.tabs)==null?void 0:c.map(a=>{let x=s.current.get(a.tabKey);return a==null?null:(x==null&&(x=new Mc({style:"width: 100%; height: 100%; position: relative;"}),x.el.addEventListener("click",()=>t==null?void 0:t(a.tabKey)),s.current.set(a.tabKey,x)),r.add(a.tabKey),o.jsxRuntimeExports.jsx(_c,{node:x,children:n({...a,visible:a.tabKey===l.selected})},a.tabKey))})}).flat().filter(l=>l!=null);return s.current.forEach((l,c)=>!r.has(c)&&s.current.delete(c)),[s,i]},Do=pe.z.interface({key:pe.z.number(),tabs:pe.z.array(Le.tabZ).optional(),selected:pe.z.string().optional(),direction:u.g.direction.optional(),size:pe.z.number().optional(),get first(){return Do.optional()},get last(){return Do.optional()}}),bg=({allowRename:e=!1,initialTree:t})=>{const[n,s]=g.useState(t);return g.useEffect(()=>s(fs(t)[0]),[t]),{root:n,onDrop:(x,d,p)=>s(m=>bc(m,d,p,x)[0]),onClose:x=>s(d=>jr(d,x)[0]),onSelect:x=>s(d=>wc(d,x)),onResize:(x,d)=>s(p=>vc(p,x,d)),onRename:e?(x,d)=>s(p=>kc(p,x,d)):void 0}},vg=Object.freeze(Object.defineProperty({__proto__:null,HAUL_CREATE_TYPE:Er,HAUL_DROP_TYPE:ys,Mosaic:Es,autoSelectTabs:fs,canSplit:pg,findSelected:hs,findTabNode:kn,forEachNode:Ao,insertTab:ms,isEmpty:mg,mapNodes:js,moveTab:bc,nodeZ:Do,removeTab:jr,renameTab:kc,resizeNode:vc,selectTab:wc,split:dg,updateTab:xg,use:bg,usePortal:wg},Symbol.toStringTag,{value:"Module"})),kg=({variant:e,className:t,...n})=>o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(t,u.CSS.B("note"),u.CSS.M(e)),align:"stretch",empty:!0,...n}),Mg=Object.freeze(Object.defineProperty({__proto__:null,Note:kg},Symbol.toStringTag,{value:"Module"})),fo={Close:o.jsxRuntimeExports.jsxs("svg",{width:"124",height:"124",viewBox:"0 0 124 124",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsxRuntimeExports.jsx("rect",{x:"26.8701",y:"88.3883",width:"87",height:"11",transform:"rotate(-45 26.8701 88.3883)",fill:"#7E0508"}),o.jsxRuntimeExports.jsx("rect",{x:"26.8701",y:"34.6482",width:"11",height:"87",transform:"rotate(-45 26.8701 34.6482)",fill:"#7E0508"})]}),Minimize:o.jsxRuntimeExports.jsx("svg",{width:"87",height:"11",viewBox:"0 0 87 11",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsxRuntimeExports.jsx("rect",{x:"15",width:"60",height:"11",fill:"#985712"})}),Maximize:o.jsxRuntimeExports.jsxs("svg",{width:"143",height:"143",viewBox:"0 0 143 143",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsxRuntimeExports.jsx("path",{d:"M108.242 32.8833C108.797 32.8817 109.247 33.3317 109.245 33.8862L109.092 87.5891C109.09 88.4786 108.014 88.9223 107.385 88.2933L53.8351 34.7432C53.2061 34.1142 53.6499 33.0387 54.5394 33.0361L108.242 32.8833Z",fill:"#0B650D"}),o.jsxRuntimeExports.jsx("path",{d:"M33.8862 109.245C33.3317 109.247 32.8818 108.797 32.8833 108.242L33.0361 54.5394C33.0387 53.6499 34.1142 53.2061 34.7432 53.8351L88.2934 107.385C88.9223 108.014 88.4786 109.09 87.5891 109.092L33.8862 109.245Z",fill:"#0B650D"})]})},_g=({disabled:e=[],className:t,focused:n=!0,onMinimize:s,onMaximize:r,onFullscreen:i,onClose:l,...c})=>o.jsxRuntimeExports.jsxs(ne.Space,{size:1.5,x:!0,className:u.CSS(u.CSS.B("macos-controls"),!n&&u.CSS.BM("macos-controls","blurred"),t),...c,children:[o.jsxRuntimeExports.jsx(ho,{onClick:l,className:u.CSS.BM("macos-control","close"),disabled:e.includes("close"),children:fo.Close}),o.jsxRuntimeExports.jsx(ho,{onClick:s,className:u.CSS.BM("macos-control","minimize"),disabled:e.includes("minimize"),children:fo.Minimize}),o.jsxRuntimeExports.jsx(ho,{onClick:i,className:u.CSS.BM("macos-control","maximize"),disabled:e.includes("maximize"),children:fo.Maximize})]}),ho=({className:e,disabled:t,color:n,...s})=>o.jsxRuntimeExports.jsx("button",{className:u.CSS(u.CSS.B("macos-control"),u.CSS.disabled(t),e),tabIndex:-1,disabled:t,size:"",...s}),Pg=({disabled:e=[],onMinimize:t,onMaximize:n,onClose:s,onFullscreen:r,focused:i,shade:l=2,...c})=>o.jsxRuntimeExports.jsxs(Ts.Pack,{...c,children:[o.jsxRuntimeExports.jsx(go,{className:u.CSS.BM("windows-control","minimize"),onClick:t,disabled:e.includes("minimize"),shade:l,children:o.jsxRuntimeExports.jsx(Z.y4.Subtract,{})}),o.jsxRuntimeExports.jsx(go,{className:u.CSS.BM("windows-control","maximize"),onClick:n,disabled:e.includes("maximize"),shade:l,children:o.jsxRuntimeExports.jsx(Z.y4.Box,{})}),o.jsxRuntimeExports.jsx(go,{onClick:s,className:u.CSS.BM("windows-control","close"),disabled:e.includes("close"),shade:l,children:o.jsxRuntimeExports.jsx(Z.y4.Close,{})})]}),go=({disabled:e=!1,className:t,...n})=>e?null:o.jsxRuntimeExports.jsx(he.Icon,{className:u.CSS(u.CSS.B("windows-control"),t),tabIndex:-1,...n}),Lc=u.S.getOS,Lg="Windows",Ng=({forceOS:e,visibleIfOS:t,...n})=>{const s=Lc({force:e,default:Lg});if(t!=null&&t!==s)return null;const r=s==="macOS"?_g:Pg;return o.jsxRuntimeExports.jsx(r,{...n})},Tg=Object.freeze(Object.defineProperty({__proto__:null,Controls:Ng,use:Lc},Symbol.toStringTag,{value:"Module"})),$g=(e,t)=>{const n=s=>o.jsxRuntimeExports.jsx(e,{...t,...s});return n.displayName=e.displayName,n},Ag=Object.freeze(Object.defineProperty({__proto__:null,createComponent:$g},Symbol.toStringTag,{value:"Module"}));g.createContext({instrumentation:nt.C.NOOP});const Ig=({children:e,...t})=>{const{path:n}=Q.useUnidirectional({type:xs.Provider.TYPE,schema:xs.providerStateZ,state:t});return o.jsxRuntimeExports.jsx(Q.Composite,{path:n,children:e})},Dg="data:video/mp2t;base64,Ly8gQ29weXJpZ2h0IDIwMjUgU3lubmF4IExhYnMsIEluYy4KLy8KLy8gVXNlIG9mIHRoaXMgc29mdHdhcmUgaXMgZ292ZXJuZWQgYnkgdGhlIEJ1c2luZXNzIFNvdXJjZSBMaWNlbnNlIGluY2x1ZGVkIGluIHRoZSBmaWxlCi8vIGxpY2Vuc2VzL0JTTC50eHQuCi8vCi8vIEFzIG9mIHRoZSBDaGFuZ2UgRGF0ZSBzcGVjaWZpZWQgaW4gdGhhdCBmaWxlLCBpbiBhY2NvcmRhbmNlIHdpdGggdGhlIEJ1c2luZXNzIFNvdXJjZQovLyBMaWNlbnNlLCB1c2Ugb2YgdGhpcyBzb2Z0d2FyZSB3aWxsIGJlIGdvdmVybmVkIGJ5IHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAsCi8vIGluY2x1ZGVkIGluIHRoZSBmaWxlIGxpY2Vuc2VzL0FQTC50eHQuCgppbXBvcnQgeyBwbHV0byB9IGZyb20gIkAvcGx1dG8vYWV0aGVyIjsKCnBsdXRvLnJlbmRlcigpOwo=",Nc=({children:e})=>{const{path:t}=Q.useUnidirectional({type:z.BaseProvider.TYPE,schema:z.providerStateZ$1,state:{}});return o.jsxRuntimeExports.jsx(Q.Composite,{path:t,children:e})},zg=Object.freeze(Object.defineProperty({__proto__:null,Provider:Nc},Symbol.toStringTag,{value:"Module"})),Bg=Object.freeze(Object.defineProperty({__proto__:null,AcquireChannelControl:z.AcquireChannelControl,AuthoritySource:z.AuthoritySource,Chip:z.Chip,Controller:z.Controller,Indicator:z.Indicator,Legend:z.Legend,REGISTRY:z.REGISTRY$16,STATUSES:z.STATUSES,SetChannelValue:z.SetChannelValue,StateProvider:z.StateProvider,acquireChannelControl:z.acquireChannelControl,acquireChannelControlPropsZ:z.acquireChannelControlPropsZ,authoritySource:z.authoritySource,authoritySourceProps:z.authoritySourceProps,chipStateZ:z.chipStateZ,controllerStateZ:z.controllerStateZ,indicatorStateZ:z.indicatorStateZ,legendStateZ:z.legendStateZ,setChannelValue:z.setChannelValue,setChannelValuePropsZ:z.setChannelValuePropsZ,stateProviderStateZ:z.stateProviderStateZ,statusZ:z.statusZ,sugaredStateZ:z.sugaredStateZ},Symbol.toStringTag,{value:"Module"})),Og=e=>{var t,n;switch(e.variant){case"disabled":return((t=e.data)==null?void 0:t.valid)===!0?{message:"Uncontrolled. Click to take control.",chipColor:"var(--pluto-gray-l12)"}:{message:"No channel connected. This element cannot be controlled.",chipColor:"var(--pluto-gray-l7)",disabled:!0};case"error":return{message:"Not controlled by you. Click to take absolute control.",chipColor:"var(--pluto-error-z)"};case"success":return((n=e.data)==null?void 0:n.authority)===nt.Gv.ABSOLUTE_AUTHORITY?{message:"You have absolute control. Click to release.",chipColor:"var(--pluto-secondary-z)",buttonStyle:{background:"var(--pluto-secondary-z-30)"}}:{message:"You're in control. Release P&ID to release control.",chipColor:"var(--pluto-primary-z)"};default:return{message:"Unexpected status.",chipColor:"var(--pluto-error-z)"}}},Tc=({source:e,sink:t,className:n,...s})=>{const r=Ne.useMemoDeepEqualProps({source:e,sink:t}),[,{status:i},l]=Q.use$1({type:z.Chip.TYPE,schema:z.chipStateZ,initialState:{triggered:!1,...r,status:{key:"no_chip",variant:"disabled",message:"No chip connected.",time:u.m.now()}}});g.useEffect(()=>{l(m=>({...m,...r}))},[r,l]);const c=g.useCallback(()=>l(m=>({...m,triggered:!m.triggered})),[l]),{message:a,chipColor:x,buttonStyle:d,disabled:p}=Og(i);return o.jsxRuntimeExports.jsx(he.Icon,{variant:"text",className:u.CSS(u.CSS.B("control-chip"),n),disabled:p,onClick:c,tooltip:o.jsxRuntimeExports.jsx(Z.Text,{level:"small",children:a}),style:d,...s,children:o.jsxRuntimeExports.jsx(Z.y4.Circle,{color:x})})},$c=g.createContext({needsControlOf:[]}),Ac=()=>g.use($c),Vg=({children:e,onStatusChange:t,...n})=>{const s=Ne.useMemoDeepEqualProps(n),[{path:r},{status:i,needsControlOf:l},c]=Q.use$1({type:z.Controller.TYPE,schema:z.controllerStateZ,initialState:s});return g.useEffect(()=>{i!=null&&(t==null||t(i))},[i,t]),g.useEffect(()=>{c(a=>({...a,...s}))},[s,c]),g.useEffect(()=>()=>t==null?void 0:t("released"),[]),o.jsxRuntimeExports.jsxs($c,{value:{needsControlOf:l},children:[o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:e}),";"]})},Ic=({colorSource:e,statusSource:t})=>{var c;const n=Ne.useMemoDeepEqualProps({colorSource:e,statusSource:t}),[,{color:s,status:r},i]=Q.use$1({type:z.Indicator.TYPE,initialState:{...n,status:{key:"no_chip",variant:"warning",message:"No chip connected.",time:u.m.now()}},schema:z.indicatorStateZ});g.useEffect(()=>{i(a=>({...a,...n}))},[n,i]);let l;return((c=r.data)==null?void 0:c.color)!=null?l=u.Dt.colorZ.parse(r.data.color):s!=null&&!u.Dt.isZero(s)?l=s:l="var(--pluto-gray-l10)",o.jsxRuntimeExports.jsxs(he.Dialog,{location:{x:"center",y:"bottom"},children:[o.jsxRuntimeExports.jsx(Z.Text,{level:"p",children:r.message}),o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("indicator"),style:{backgroundColor:u.Dt.cssString(l),flexGrow:1}})]})},Fg=e=>{const{needsControlOf:t}=Ac(),[,{states:n},s]=Q.use$1({type:z.Legend.TYPE,schema:z.legendStateZ,initialState:{states:[],needsControlOf:t}});g.useEffect(()=>{s(l=>({...l,needsControlOf:t}))},[t]);const i=u.c$1.unique(n.map(l=>l.subject.key)).map(l=>{const c=n.find(a=>a.subject.key===l);if(c==null)throw new nt.Qt("Legend subject not found");return{key:c.subject.key,label:c.subject.name,color:c.subjectColor}});return o.jsxRuntimeExports.jsx(lr,{data:i,...e})},Dc=({children:e})=>{const[{path:t}]=Q.use$1({type:z.StateProvider.TYPE,schema:z.stateProviderStateZ,initialState:{}});return o.jsxRuntimeExports.jsx(Q.Composite,{path:t,children:e})},Hg=Object.freeze(Object.defineProperty({__proto__:null,Chip:Tc,Controller:Vg,Indicator:Ic,Legend:Fg,StateProvider:Dc,useContext:Ac},Symbol.toStringTag,{value:"Module"})),zc=e=>{const t=({disabled:n=!1,...s})=>n?s.children:o.jsxRuntimeExports.jsx(e,{...s});return t.displayName=e.displayName,t},Zg=zc(Nc),Wg=zc(Q.Provider$2),Yg=({children:e,connParams:t,workerEnabled:n=!0,workerURL:s,theming:r,tooltip:i,triggers:l,alamos:c,haul:a,channelAlias:x,telem:d,color:p})=>o.jsxRuntimeExports.jsx(Ie.Provider,{...l,children:o.jsxRuntimeExports.jsx(he.Config,{...i,children:o.jsxRuntimeExports.jsx(me.Provider,{...a,children:o.jsxRuntimeExports.jsx(Q.Provider$1,{url:s??Dg,enabled:n,children:o.jsxRuntimeExports.jsx(Wg,{workerKey:"vis",children:o.jsxRuntimeExports.jsx(Ig,{...c,children:o.jsxRuntimeExports.jsx(Re.Aggregator,{children:o.jsxRuntimeExports.jsx(Ll,{connParams:t,children:o.jsxRuntimeExports.jsx($l,{...x,children:o.jsxRuntimeExports.jsx(Ke.Provider,{...p,children:o.jsxRuntimeExports.jsx(Q.Provider,{...r,children:o.jsxRuntimeExports.jsx(Zg,{...d,children:o.jsxRuntimeExports.jsx(Dc,{children:e})})})})})})})})})})})})}),Gg=Object.freeze(Object.defineProperty({__proto__:null,Provider:Yg},Symbol.toStringTag,{value:"Module"})),Kg=({value:e})=>o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("progress"),children:o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("progress-bar"),style:{width:`${e}%`}})}),qg=Object.freeze(Object.defineProperty({__proto__:null,Progress:Kg},Symbol.toStringTag,{value:"Module"})),Mn="range",yr=[{key:"name",name:"Name"}],Ss=({items:e},t)=>{const n=me.filterByType(Mn,e);return n.length>0&&!n.every(s=>t.includes(s.key))},Xg=({onChange:e,className:t,value:n,...s})=>{const r=qe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=me.useDragAndDrop({type:"Ranger.SelectMultiple",canDrop:g.useCallback(m=>Ss(m,Me.A(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=me.filterByType(Mn,m);if(f.length===0)return[];const h=u.c$1.unique([...Me.A(n),...f.map(j=>j.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),x=me.useDraggingState(),d=g.useCallback(({dropped:m})=>{e(Me.A(n).filter(f=>!m.some(h=>h.key===f)),{clickedIndex:null,clicked:null,entries:[]})},[e,n]),p=g.useCallback((m,f)=>l([{key:f,type:Mn}],d),[l,d]);return o.jsxRuntimeExports.jsx(cn,{className:u.CSS(t,u.CSS.dropRegion(Ss(x,Me.A(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.ranges,onChange:e,columns:yr,emptyContent:i,entryRenderKey:"name",...a,...s})},Bc=({value:e,onChange:t})=>{const n=qe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(Re.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),r=g.useId(),i=g.useMemo(()=>({key:r,type:"Ranger.SelectMultiple"}),[r]),{startDrag:l,...c}=me.useDragAndDrop({type:"Ranger.SelectSingle",canDrop:g.useCallback(d=>Ss(d,Me.o(e)),[e]),onDrop:g.useCallback(({items:d})=>{const p=me.filterByType(Mn,d);return p.length===0?[]:(t(p[0].key,{clickedIndex:null,clicked:null,entries:[]}),p)},[i,t])}),a=me.useDraggingState(),x=g.useCallback(()=>e!=null&&l([{type:Mn,key:e}]),[l,e]);return{emptyContent:s,dragging:a,...c,onDragStart:x,searcher:n==null?void 0:n.ranges}},Ug=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=Bc({value:t,onChange:e});return o.jsxRuntimeExports.jsx(ft,{data:s,className:u.CSS(n,u.CSS.dropRegion(Ss(i,Me.o(t)))),value:t,onChange:e,columns:yr,entryRenderKey:"name",...l,...r})},Jg=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=Bc({value:t,onChange:n});return o.jsxRuntimeExports.jsx(ft,{data:e,value:t,onChange:n,columns:yr,entryRenderKey:"name",...i,...s})},Qg=[{key:"color",name:"Color",width:50,render:e=>o.jsxRuntimeExports.jsx(Z.y4.Circle,{style:{fontSize:10,marginLeft:10,marginRight:30},color:e.entry.color})},{key:"name",name:"Name"}],e0=e=>{const t=qe();return o.jsxRuntimeExports.jsx(cn,{...e,searcher:t==null?void 0:t.labels,columns:Qg,renderTag:n=>n.entry==null?o.jsxRuntimeExports.jsx(vn,{color:"gray",children:n.entryKey}):o.jsxRuntimeExports.jsx(vn,{color:n.entry.color,children:n.entry.name})})},t0=({timeRange:e,level:t="p",shade:n=9,showSpan:s=!1,labeled:r=!1,...i})=>{const l=new u.m(e.start),c=l.isToday?"time":"dateTime",a=new u.m(e.end),x=a.equals(u.m.MAX),d=a.span(l)<u.O.DAY?"time":"dateTime",p=l.span(a);let m=o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",size:"small",children:[l.isToday&&o.jsxRuntimeExports.jsx(Z.Text,{level:t,shade:n,weight:450,children:"Today"}),o.jsxRuntimeExports.jsx(_o.DateTime,{level:t,displayTZ:"local",format:c,shade:n,weight:450,children:l})]}),f=o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[x?o.jsxRuntimeExports.jsx(Z.Text,{level:t,children:"Now"}):o.jsxRuntimeExports.jsx(_o.DateTime,{level:t,displayTZ:"local",format:d,shade:n,weight:450,children:a}),!p.isZero&&s&&o.jsxRuntimeExports.jsxs(Z.Text,{level:t,shade:n,weight:450,children:["(",l.span(a).truncate(u.O.MILLISECOND).toString(),")"]})]});r&&(m=o.jsxRuntimeExports.jsx(ge.Item,{label:"Start",showHelpText:!1,children:m}),f=o.jsxRuntimeExports.jsx(ge.Item,{label:"End",showHelpText:!1,children:f}));const h=u.CSS.levelSizeVar(t);return o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,size:"small",className:u.CSS(u.CSS.B("time-range-chip")),align:"center",...i,children:[m,o.jsxRuntimeExports.jsx(Z.y4.Arrow.Right,{color:"var(--pluto-gray-l9)",style:{width:h,height:h}}),f]})},n0=Object.freeze(Object.defineProperty({__proto__:null,SelectButton:Jg,SelectLabels:e0,SelectMultiple:Xg,SelectSingle:Ug,TimeRangeChip:t0},Symbol.toStringTag,{value:"Module"})),s0=({steps:e,value:t,onChange:n,...s})=>{const r=e.findIndex(i=>i.key===t);return o.jsxRuntimeExports.jsx(ne.Space,{x:!0,align:"center",className:u.CSS.B("steps"),...s,children:e.map((i,l)=>o.jsxRuntimeExports.jsxs(g.Fragment,{children:[o.jsxRuntimeExports.jsxs(he.Button,{onClick:()=>n(i.key),variant:"outlined",disabled:l>r,children:[l+1,". ",i.title]},i.key),l!==e.length-1&&o.jsxRuntimeExports.jsx(Z.y4.Arrow.Right,{style:{fontSize:"15px",color:"var(--pluto-gray-l10)"}})]},i.key))})},o0=Object.freeze(Object.defineProperty({__proto__:null,Steps:s0},Symbol.toStringTag,{value:"Module"})),r0=({children:e,className:t,visible:n,...s})=>{const[{path:r},,i]=Q.use$1({type:z.Table.TYPE,schema:z.Table.stateZ,initialState:{region:u.$t.ZERO,visible:n}});g.useEffect(()=>{i(c=>({...c,visible:n}))},[n]);const l=Dn(c=>i(a=>({...a,region:c})));return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx("div",{ref:l,style:{right:0,bottom:0,position:"absolute",top:6,left:6}}),o.jsxRuntimeExports.jsx("table",{className:u.CSS(u.CSS.B("table"),t),...s,children:o.jsxRuntimeExports.jsx("tbody",{children:o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:e})})})]})},i0=({children:e,className:t,size:n,index:s,onResize:r,onSelect:i,position:l,...c})=>o.jsxRuntimeExports.jsxs("tr",{className:u.CSS(u.CSS.BE("table","row"),t),...c,children:[r!=null&&o.jsxRuntimeExports.jsx(Vc,{onSelect:i,index:s,value:n,onChange:r,position:l,direction:"y"}),e]}),Sr=({ref:e,children:t,className:n,selected:s=!1,...r})=>o.jsxRuntimeExports.jsx("td",{ref:e,...r,className:u.CSS(u.CSS.BE("table","cell"),u.CSS.selected(s),n),children:t}),Oc="ABCDEFGHIJKLMNOPQRSTUVWXYZ",l0=e=>Oc[e],Vc=({value:e,selected:t=!1,index:n,onChange:s,position:r,direction:i="x",onSelect:l})=>{const c=Z.useSyncedRef(e),a=g.useRef(e),x=Ke.useCursorDrag({onStart:g.useCallback(()=>{a.current=c.current},[]),onMove:g.useCallback(d=>s(a.current+u.$t.dim(d,i,!0),n),[s,n])});return o.jsxRuntimeExports.jsxs("td",{id:`resizer-${i}-${n}`,className:u.CSS(u.CSS.BE("table","resizer"),u.CSS.dir(i),u.CSS.selected(t),kt.CONTEXT_TARGET,t&&kt.CONTEXT_SELECTED),style:{[u.g.dimension(i)]:e},onClick:()=>l(n),onContextMenu:()=>l(n),children:[o.jsxRuntimeExports.jsx(Z.Text,{level:"p",shade:11,style:{width:"100%",textAlign:"center"},children:i==="x"?Oc[n]:n+1}),o.jsxRuntimeExports.jsx("button",{onClick:d=>d.stopPropagation(),style:{[u.g.location(i)]:r+e},onDragStart:x,draggable:!0})]})},c0=({selected:e,onSelect:t,columns:n,onResize:s})=>{let r=15;return o.jsxRuntimeExports.jsxs("tr",{className:u.CSS(u.CSS.BE("table","row"),u.CSS.BE("table","col-resizer")),children:[o.jsxRuntimeExports.jsx("td",{}),n.map((i,l)=>{const c=r;return r+=i,o.jsxRuntimeExports.jsx(Vc,{onSelect:t,position:c,selected:e.includes(l),index:l,value:i,onChange:a=>s(a,l),direction:"x"},l)})]})},a0=Object.freeze(Object.defineProperty({__proto__:null,Cell:Sr,ColumnIndicators:c0,Row:i0,Table:r0,getCellColumn:l0},Symbol.toStringTag,{value:"Module"})),u0=[{key:"standard",name:"Standard"},{key:"scientific",name:"Scientific"},{key:"engineering",name:"Engineering"}],x0=e=>o.jsxRuntimeExports.jsx(it,{...e,entryRenderKey:"name",data:u0}),Fc=[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],Rr=({path:e})=>{var f;const{value:t,onChange:n}=_t({path:e}),s=z.sourcePipelinePropsZ.parse((f=t.telem)==null?void 0:f.props),r=z.streamChannelValuePropsZ.parse(s.segments.valueStream.props),i=z.stringifyNumberProps.parse(s.segments.stringifier.props),l=z.rollingAverageProps.parse(s.segments.rollingAverage.props),c=h=>{const j=z.sourcePipeline("string",{connections:Fc,segments:{valueStream:z.streamChannelValue({channel:r.channel}),stringifier:z.stringifyNumber({precision:i.precision??2,notation:i.notation}),rollingAverage:z.rollingAverage({windowSize:l.windowSize??1}),...h},outlet:"stringifier"});n({...t,telem:j})},a=h=>c({valueStream:z.streamChannelValue({channel:h??0})}),x=h=>c({stringifier:z.stringifyNumber({...i,notation:h})}),d=h=>c({stringifier:z.stringifyNumber({...i,precision:h})}),p=h=>c({rollingAverage:z.rollingAverage({windowSize:h})}),m=As(r.channel);return g.useEffect(()=>n({...t,tooltip:[m]}),[m]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(ge.Item,{label:"Input Channel",grow:!0,children:o.jsxRuntimeExports.jsx(Dt,{value:r.channel,onChange:a})}),o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,children:[o.jsxRuntimeExports.jsx(ge.Item,{label:"Notation",children:o.jsxRuntimeExports.jsx(x0,{value:i.notation,onChange:x})}),o.jsxRuntimeExports.jsx(ge.Item,{label:"Precision",align:"start",children:o.jsxRuntimeExports.jsx(ge.Numeric,{value:i.precision??2,bounds:{lower:0,upper:10},onChange:d})}),o.jsxRuntimeExports.jsx(ge.Item,{label:"Averaging Window",align:"start",children:o.jsxRuntimeExports.jsx(ge.Numeric,{value:l.windowSize??1,bounds:{lower:1,upper:100},onChange:p})})]})]})},d0=z.Value.z.partial({color:!0}).extend({level:st.levelZ.optional()}),Cr=({aetherKey:e,box:t,telem:n,color:s,precision:r,minWidth:i,level:l="small",backgroundTelem:c,notation:a,location:x})=>{const d=Ne.useMemoDeepEqualProps({box:t,telem:n,color:s,precision:r,level:l,minWidth:i,notation:a,backgroundTelem:c,location:x}),[,p,m]=Q.use$1({aetherKey:e,type:z.Value.TYPE,schema:z.Value.z,initialState:d});return g.useEffect(()=>m(f=>({...f,...d})),[d]),{width:p.width??p.minWidth}},p0=Object.freeze(Object.defineProperty({__proto__:null,TelemForm:Rr,VALUE_CONNECTIONS:Fc,corePropsZ:d0,use:Cr},Symbol.toStringTag,{value:"Module"})),m0=pe.z.object({value:pe.z.string(),level:st.levelZ,weight:st.weightZ,align:u.K.x.or(u.K.center),backgroundColor:u.Dt.crudeZ}),f0=({cellKey:e,onChange:t,value:n,selected:s,onSelect:r,align:i,level:l,weight:c,backgroundColor:a})=>{const x=p=>r(e,p),d=p=>t({level:l,value:p,weight:c,align:i,backgroundColor:a});return o.jsxRuntimeExports.jsx(Sr,{id:e,className:u.CSS(kt.CONTEXT_TARGET,s&&kt.CONTEXT_SELECTED,u.CSS.BEM("table","cell","text")),selected:s,onClick:x,onContextMenu:x,style:{backgroundColor:u.Dt.cssString(a)},children:o.jsxRuntimeExports.jsx(Z.Editable,{level:l,value:n,weight:c,onChange:d,style:{justifyContent:i},allowEmpty:!0,outline:!1})})},h0=pe.z.object({telem:z.stringSourceSpecZ,redline:pe.z.object({bounds:u.G.bounds,gradient:u.Dt.gradientZ}),level:st.levelZ,color:pe.z.string(),units:pe.z.string()}),g0=({cellKey:e,telem:t,level:n,color:s,redline:{gradient:r,bounds:i},selected:l,box:c,onSelect:a})=>{const{width:x}=Cr({aetherKey:e,box:c,telem:t,level:n,color:s,backgroundTelem:z.sourcePipeline("color",{connections:[{from:"source",to:"scale"},{from:"scale",to:"gradient"}],segments:{source:t,scale:z.scaleNumber({scale:u.b.Scale.scale(i).scale(0,1).transform}),gradient:z.colorGradient({gradient:r})},outlet:"gradient"}),location:{x:"center",y:"center"}}),d=p=>a(e,p);return o.jsxRuntimeExports.jsx(Sr,{id:e,selected:l,onClick:d,onContextMenu:d,style:{height:"5rem",width:x},className:u.CSS(kt.CONTEXT_TARGET,l&&kt.CONTEXT_SELECTED,u.CSS.BEM("table","cell","value"))})},j0=({onVariantChange:e})=>{const t=g.useCallback(({tabKey:s})=>{switch(s){case"telem":return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(Rr,{path:""})});case"redline":return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(E0,{})});default:return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,grow:!0,empty:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,children:[o.jsxRuntimeExports.jsx(ge.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Hc,{onChange:e,value:"value"})}),o.jsxRuntimeExports.jsx(Ce,{hideIfNull:!0,label:"Color",align:"start",padHelpText:!1,path:"color",children:({value:r,onChange:i,variant:l,...c})=>o.jsxRuntimeExports.jsx(Ke.Swatch,{value:r??u.Dt.setAlpha(u.Dt.ZERO,1),onChange:i,...c,bordered:!0})}),o.jsxRuntimeExports.jsx(Ce,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:r=>o.jsxRuntimeExports.jsx(an,{...r})})]})})}},[]),n=Le.useStatic({tabs:[{tabKey:"style",name:"Style"},{tabKey:"telem",name:"Telemetry"},{tabKey:"redline",name:"Redline"}],content:t});return o.jsxRuntimeExports.jsx(Le.Tabs,{...n})},E0=()=>{const{set:e,get:t}=ht(),n=hc("redline.bounds"),s=u.b.Scale.scale(0,1).scale(n);return o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,grow:!0,children:[o.jsxRuntimeExports.jsx(Ze,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Lower",path:"redline.bounds.lower"}),o.jsxRuntimeExports.jsx(Ce,{path:"redline.gradient",label:"Gradient",align:"start",padHelpText:!1,children:({value:r,onChange:i})=>o.jsxRuntimeExports.jsx(Ke.GradientPicker,{value:ze.x.copy(r),scale:s,onChange:l=>{const a={...t("redline.bounds").value},x=l.map(j=>j.position),d=s.pos(Math.max(...x)),p=s.pos(Math.min(...x)),m=d>a.upper,f=p<a.lower;m&&(l[l.length-1].position=1,a.upper=d),f&&(l[0].position=0,a.lower=p);const h=l.map(j=>({...j,color:u.Dt.hex(j.color)}));m||f?e("redline",{bounds:a,gradient:h}):i(l.map(j=>({...j,color:u.Dt.hex(j.color)})))}})}),o.jsxRuntimeExports.jsx(Ze,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Upper",path:"redline.bounds.upper"})]})},y0=({onVariantChange:e})=>o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,grow:!0,style:{padding:"2rem"},children:[o.jsxRuntimeExports.jsx(ge.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Hc,{onChange:e,value:"text"})}),o.jsxRuntimeExports.jsx(fr,{path:"value",label:"Text"}),o.jsxRuntimeExports.jsx(Ce,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(an,{...t})}),o.jsxRuntimeExports.jsx(Ce,{path:"weight",label:"Weight",padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(nc,{...t})}),o.jsxRuntimeExports.jsx(Ce,{path:"align",label:"Alignment",hideIfNull:!0,children:t=>o.jsxRuntimeExports.jsx(zs,{...t})}),o.jsxRuntimeExports.jsx(Ce,{path:"backgroundColor",label:"Background",align:"start",padHelpText:!1,children:({value:t,onChange:n})=>o.jsxRuntimeExports.jsx(Ke.Swatch,{value:t,onChange:n})})]}),S0=[{key:"text",name:"Text"},{key:"value",name:"Value"}],Hc=e=>o.jsxRuntimeExports.jsx(it,{...e,data:S0,allowMultiple:!1,entryRenderKey:"name"}),R0=["text","value"],C0=pe.z.enum(R0),w0={key:"value",name:"Value",Form:j0,Cell:g0,defaultProps:e=>({telem:z.sourcePipeline("string",{connections:[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],segments:{valueStream:z.streamChannelValue({channel:0}),rollingAverage:z.rollingAverage({windowSize:1}),stringifier:z.stringifyNumber({precision:2,notation:"standard"})},outlet:"stringifier"}),redline:{bounds:{lower:0,upper:1},gradient:[]},color:u.Dt.hex(e.colors.gray.l10),level:"h5",units:""}),schema:h0},b0={key:"text",name:"Text",Form:y0,Cell:f0,defaultProps:()=>({value:"",level:"h5",units:"",weight:400,align:"center",backgroundColor:"#00000000"}),schema:m0},v0={text:b0,value:w0},k0=Object.freeze(Object.defineProperty({__proto__:null,CELLS:v0,variantZ:C0},Symbol.toStringTag,{value:"Module"})),di=({sourcePos:e,targetPos:t,next:n,prev:s})=>{const r=Tt(e,...n);return u.J.distance(r,t)<1?!0:(console.warn("Connector is out of sync with target"),console.log("Theoretical target",r),console.log("Actual target",t),console.log("Segments",n),console.log("Prev segments",s),!1)},pi=({sourceStumpTip:e,sourceOrientation:t,sourceBox:n,targetStumpTip:s,targetOrientation:r,targetBox:i})=>{if(!M0({sourcePos:e,sourceOrientation:t,targetPos:s}))return;const l=u.g.construct(t),c=u.g.swap(l);let a=At(c,s[c]-e[c]);const x=u.$t.loc(n,a);if(u.K.swap(t)===r){const d=u.$t.loc(i,u.K.swap(a));Math.abs(x-d)<Fe&&(a=u.K.swap(a))}return{direction:c,length:x-e[c]+Bt(a,Fe)}},zo=pe.z.object({direction:u.g.direction,length:pe.z.number()}),Tt=(e,...t)=>{let n=e;for(const s of t)n=u.J.translate(n,s.direction,s.length);return n},Zc=(e,t,n,s)=>{try{let r=e;const i=[e,...t.map(f=>(r=u.J.translate(r,f.direction,f.length),r))];if(!s)return i;const l=t[0],c=At(l.direction,l.length),a=mi(c),x=4*(2-n**.5);i[0]=u.J.translate(i[0],{[l.direction]:-1*a*x,[u.g.swap(l.direction)]:0});const d=t[t.length-1],p=At(d.direction,d.length),m=mi(p);return i[i.length-1]=u.J.translate(i[i.length-1],{[d.direction]:m*x,[u.g.swap(d.direction)]:0}),i}catch{return[]}},Fe=10,mi=e=>e==="top"||e==="left"?-1:1,Bt=(e,t)=>e==="top"||e==="left"?-t:t,At=(e,t)=>e==="x"?t>0?"right":"left":t>0?"bottom":"top",Ct=e=>At(e.direction,e.length),M0=({sourcePos:e,targetPos:t,sourceOrientation:n})=>{const s=u.g.construct(n),r=t[s]-e[s];return Bt(n,r)<0},Kn=e=>({direction:u.g.construct(e),length:Bt(e,Fe)}),fi={top:Kn("top"),bottom:Kn("bottom"),left:Kn("left"),right:Kn("right")},_0=4,P0=.25,Fs=e=>Bo(L0(Bo(e))),L0=e=>{const t=[...e],n=e.findIndex((s,r)=>{const i=Math.abs(s.length);if(i<_0){if(r===0||r===e.length-1)return!1;if(i<P0)return!0;if(e.length<=3)return!1;if(r+2<e.length){const l=t[r+2];if(l.direction!==s.direction)return!1;t[r+2]={...l,length:l.length+s.length}}else{const l=t[r-2];if(l.direction!==s.direction)return!1;t[r-2]={...l,length:l.length+s.length}}return!0}return!1});return n!==-1&&t.splice(n,1),t},Bo=e=>{const t=[...e];return e.findIndex((s,r)=>{const i=t[r-1];if(r===0||s.direction!==i.direction)return!1;if(r===1){const l=r-1,c=r,a=Ct(i),x=Ct(s);if(a===x)return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0;if(Math.abs(i.length)===Fe)return!1;const d=Bt(a,Fe),p=t[l].length-d,m=t[c].length+p;return Math.abs(m)<Fe?!1:(t[l]={...t[l],length:d},t[c]={...t[c],length:m},!0)}if(r===e.length-1){const l=r,c=r-1,a=Ct(s),x=Ct(i);if(a===x)return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0;if(Math.abs(s.length)===Fe)return!1;const d=Bt(a,Fe),p=t[l].length-d,m=t[c].length+p;return Math.abs(m)<Fe?!1:(t[l]={...t[l],length:d},t[c]={...t[c],length:m},!0)}return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0})!==-1?Bo(t):t},qt=e=>Fs(N0(e)),N0=({sourceBox:e,targetBox:t,sourcePos:n,targetPos:s,targetOrientation:r,sourceOrientation:i})=>{let l=i,c=r,a={...fi[i]},x=Tt(n,a);const d={...fi[r]};let p=Tt(s,d);const m=Math.abs(x.x-p.x),f=Math.abs(x.y-p.y);m<2*Fe&&f<10&&(a.length-=m/2,d.length+=m/2,x=Tt(n,a),p=Tt(s,d));const h=[a],j=pi({sourceStumpTip:x,sourceOrientation:i,sourceBox:e,targetStumpTip:p,targetOrientation:r,targetBox:t});j!=null&&(h.push(j),x=Tt(x,j),l=Ct(j),a=j);const y=pi({sourceStumpTip:p,sourceOrientation:c,sourceBox:t,targetStumpTip:x,targetOrientation:l,targetBox:e});y!=null&&(p=Tt(p,y),c=At(y.direction,y.length));const S=()=>{y!=null&&(y.length*=-1,h.push(y)),d.length*=-1,h.push(d)};if(u.K.swap(l)===r){const P=u.g.construct(l),O=(p[P]-x[P])/2;h.push({direction:P,length:O});const I=u.g.swap(P);return h.push({direction:I,length:p[I]-x[I]}),h.push({direction:P,length:O}),S(),h}const b=p[a.direction]-x[a.direction];let E=u.g.swap(a.direction);const C=x[E]-p[E];let L;At(a.direction,b)===l&&At(E,C)===c?L={direction:a.direction,length:b}:(L={direction:E,length:p[E]-x[E]},E=u.g.swap(E)),h.push(L);const T={direction:E,length:p[E]-x[E]};return h.push(T),S(),h},T0=e=>Fs($0(e)),$0=({segments:e,index:t,magnitude:n})=>{const s=[...e],r=s[t],i=u.g.swap(r.direction),l=Ct(r);if(t===0){s.unshift({direction:i,length:n});const c=Bt(l,Fe);s.unshift({direction:r.direction,length:c}),t+=2,s[t]={...s[t],length:s[t].length-c}}else s[t-1]={direction:s[t-1].direction,length:s[t-1].length+n};if(t===s.length-1){s.push({direction:i,length:-n});const c=Bt(l,Fe);s.push({direction:r.direction,length:c}),s[t]={...s[t],length:s[t].length-c}}else s[t+1]={direction:s[t+1].direction,length:s[t+1].length-n};return s},A0=(e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n],n))return n;return-1},I0=(e,t,n=!1,...s)=>{const r=(i,l)=>!s.includes(l)&&t(i,l);return n?A0(e,r):e.findIndex(r)},D0=({delta:e,segments:t})=>Fs(Wc(e,t,!1)),z0=({delta:e,segments:t})=>Fs(Wc(e,t,!0)),Wc=(e,t,n)=>{let s=[...t];return e.x!==0&&(s=gi("x",e,s,n)),e.y!==0&&(s=gi("y",e,s,n)),s},hi=(e,t,n)=>{if(t.direction!==e)return!1;const s={...t,length:t.length-n[e]},r=Ct(t),i=Ct(s),l=Math.abs(s.length),c=Math.abs(t.length);return(l>c||l>Fe)&&r===i},gi=(e,t,n,s)=>{const r=u.g.swap(e),i=s?n.length-1:0,l=n[i];if(hi(e,l,t)){const p=n[n.length-1];return p.direction===e&&Math.abs(l.length)<Fe?(n[n.length-1]={...p,length:p.length-t[e]},n):(n[i]={...l,length:l.length-t[e]},n)}const c=s?0:n.length-1,x=I0(n,p=>p.direction===e,s,i);if(x===c){const p=n[c];return hi(e,p,t)?(n[c]={...p,length:p.length-t[e]},n):(l.direction===e&&Math.abs(l.length)>p.length?n[i]={...l,length:l.length-t[e]}:n[c]={...p,length:p.length-t[e]},n)}if(x===-1)return n.length===1?n[0].direction===e?[{direction:e,length:n[0].length-t[e]}]:[{direction:r,length:n[0].length/2},{direction:e,length:-t[e]},{direction:r,length:n[0].length/2}]:l.direction===e?(n[i]={...l,length:l.length-t[e]},n):[{direction:r,length:n[0].length},{direction:e,length:-t[e]},...n.slice(1)];const d=n[x];return n[x]={...d,length:d.length-t[e]},n},B0=pe.z.object({position:u.J.xy,zoom:pe.z.number()}),Yc=pe.z.object({color:u.Dt.crudeZ,variant:pe.z.string().optional(),segments:pe.z.array(zo)}),O0=Yc.extend({key:pe.z.string(),source:pe.z.string(),target:pe.z.string(),segments:pe.z.array(zo),color:u.Dt.crudeZ,id:pe.z.string(),data:pe.z.object({segments:pe.z.array(zo),color:u.Dt.crudeZ,variant:pe.z.string().optional()}).optional(),selected:pe.z.boolean(),sourceHandle:pe.z.string().nullable().optional(),targetHandle:pe.z.string().nullable().optional()}),V0=pe.z.object({key:pe.z.string(),position:u.J.xy,selected:pe.z.boolean().optional(),zIndex:pe.z.number().optional(),type:pe.z.string().optional(),data:u.m$1.optional(),measured:pe.z.object({width:pe.z.number().optional(),height:pe.z.number().optional()}).optional()}),wr=e=>e.map(t=>({id:t.key,type:"custom",zIndex:t.zIndex,measured:{...t.measured},position:{...t.position},selected:t.selected,data:{}})),br=e=>e.map(({segments:t,color:n,variant:s,...r})=>({...r,id:r.key,data:{segments:t,color:n,variant:s}})),Gc=e=>e.map(t=>({key:t.id,...t})),Kc=(e,t)=>e.map(n=>{var s,r,i;return n.data??(n.data={segments:[],color:t,variant:"pipe"}),{key:n.id,segments:((s=n.data)==null?void 0:s.segments)??[],selected:n.selected??!1,color:((r=n.data)==null?void 0:r.color)??t,variant:((i=n.data)==null?void 0:i.variant)??"pipe",...n}}),qc=e=>({...e.position,zoom:e.zoom}),Xc=e=>({position:u.J.construct(e),zoom:e.zoom}),Uc=(e,t)=>Gc(t(wr(e))),is=(e,t,n)=>Kc(t(br(e)),n),F0=(e,t="x")=>{if(e.length===0)return[];const n=u.K.construct(t),s=u.K.swap(n);return e.sort((r,i)=>u.$t.loc(r.box,n)-u.$t.loc(i.box,n)),e.forEach((r,i)=>{if(i===0)return;const c=e[i-1].handles.find(f=>f.orientation===s),a=r.handles.find(f=>f.orientation===n);if(c==null||a==null)return;const x=c.absolutePosition,d=a.absolutePosition,p=u.J.set(u.J.translation(d,x),t,0),m=u.J.translate(u.$t.topLeft(r.box),p);r.box=u.$t.construct(m,u.$t.dims(r.box))}),e};function Ae(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)(s=Ae(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var H0={value:()=>{}};function Hs(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new ls(n)}function ls(e){this._=e}function Z0(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",r=n.indexOf(".");if(r>=0&&(s=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}ls.prototype=Hs.prototype={constructor:ls,on:function(e,t){var n=this._,s=Z0(e+"",n),r,i=-1,l=s.length;if(arguments.length<2){for(;++i<l;)if((r=(e=s[i]).type)&&(r=W0(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<l;)if(r=(e=s[i]).type)n[r]=ji(n[r],e.name,t);else if(t==null)for(r in n)n[r]=ji(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ls(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),s=0,r,i;s<r;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],s=0,r=i.length;s<r;++s)i[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)}};function W0(e,t){for(var n=0,s=e.length,r;n<s;++n)if((r=e[n]).name===t)return r.value}function ji(e,t,n){for(var s=0,r=e.length;s<r;++s)if(e[s].name===t){e[s]=H0,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Oo="http://www.w3.org/1999/xhtml";const Ei={svg:"http://www.w3.org/2000/svg",xhtml:Oo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Zs(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ei.hasOwnProperty(t)?{space:Ei[t],local:e}:e}function Y0(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Oo&&t.documentElement.namespaceURI===Oo?t.createElement(e):t.createElementNS(n,e)}}function G0(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Jc(e){var t=Zs(e);return(t.local?G0:Y0)(t)}function K0(){}function vr(e){return e==null?K0:function(){return this.querySelector(e)}}function q0(e){typeof e!="function"&&(e=vr(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=new Array(l),a,x,d=0;d<l;++d)(a=i[d])&&(x=e.call(a,a.__data__,d,i))&&("__data__"in a&&(x.__data__=a.__data__),c[d]=x);return new Ye(s,this._parents)}function X0(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function U0(){return[]}function Qc(e){return e==null?U0:function(){return this.querySelectorAll(e)}}function J0(e){return function(){return X0(e.apply(this,arguments))}}function Q0(e){typeof e=="function"?e=J0(e):e=Qc(e);for(var t=this._groups,n=t.length,s=[],r=[],i=0;i<n;++i)for(var l=t[i],c=l.length,a,x=0;x<c;++x)(a=l[x])&&(s.push(e.call(a,a.__data__,x,l)),r.push(a));return new Ye(s,r)}function ea(e){return function(){return this.matches(e)}}function ta(e){return function(t){return t.matches(e)}}var e2=Array.prototype.find;function t2(e){return function(){return e2.call(this.children,e)}}function n2(){return this.firstElementChild}function s2(e){return this.select(e==null?n2:t2(typeof e=="function"?e:ta(e)))}var o2=Array.prototype.filter;function r2(){return Array.from(this.children)}function i2(e){return function(){return o2.call(this.children,e)}}function l2(e){return this.selectAll(e==null?r2:i2(typeof e=="function"?e:ta(e)))}function c2(e){typeof e!="function"&&(e=ea(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=[],a,x=0;x<l;++x)(a=i[x])&&e.call(a,a.__data__,x,i)&&c.push(a);return new Ye(s,this._parents)}function na(e){return new Array(e.length)}function a2(){return new Ye(this._enter||this._groups.map(na),this._parents)}function Rs(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Rs.prototype={constructor:Rs,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 u2(e){return function(){return e}}function x2(e,t,n,s,r,i){for(var l=0,c,a=t.length,x=i.length;l<x;++l)(c=t[l])?(c.__data__=i[l],s[l]=c):n[l]=new Rs(e,i[l]);for(;l<a;++l)(c=t[l])&&(r[l]=c)}function d2(e,t,n,s,r,i,l){var c,a,x=new Map,d=t.length,p=i.length,m=new Array(d),f;for(c=0;c<d;++c)(a=t[c])&&(m[c]=f=l.call(a,a.__data__,c,t)+"",x.has(f)?r[c]=a:x.set(f,a));for(c=0;c<p;++c)f=l.call(e,i[c],c,i)+"",(a=x.get(f))?(s[c]=a,a.__data__=i[c],x.delete(f)):n[c]=new Rs(e,i[c]);for(c=0;c<d;++c)(a=t[c])&&x.get(m[c])===a&&(r[c]=a)}function p2(e){return e.__data__}function m2(e,t){if(!arguments.length)return Array.from(this,p2);var n=t?d2:x2,s=this._parents,r=this._groups;typeof e!="function"&&(e=u2(e));for(var i=r.length,l=new Array(i),c=new Array(i),a=new Array(i),x=0;x<i;++x){var d=s[x],p=r[x],m=p.length,f=f2(e.call(d,d&&d.__data__,x,s)),h=f.length,j=c[x]=new Array(h),y=l[x]=new Array(h),S=a[x]=new Array(m);n(d,p,j,y,S,f,t);for(var b=0,E=0,C,L;b<h;++b)if(C=j[b]){for(b>=E&&(E=b+1);!(L=y[E])&&++E<h;);C._next=L||null}}return l=new Ye(l,s),l._enter=c,l._exit=a,l}function f2(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function h2(){return new Ye(this._exit||this._groups.map(na),this._parents)}function g2(e,t,n){var s=this.enter(),r=this,i=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),s&&r?s.merge(r).order():r}function j2(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,r=n.length,i=s.length,l=Math.min(r,i),c=new Array(r),a=0;a<l;++a)for(var x=n[a],d=s[a],p=x.length,m=c[a]=new Array(p),f,h=0;h<p;++h)(f=x[h]||d[h])&&(m[h]=f);for(;a<r;++a)c[a]=n[a];return new Ye(c,this._parents)}function E2(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],r=s.length-1,i=s[r],l;--r>=0;)(l=s[r])&&(i&&l.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(l,i),i=l);return this}function y2(e){e||(e=S2);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var n=this._groups,s=n.length,r=new Array(s),i=0;i<s;++i){for(var l=n[i],c=l.length,a=r[i]=new Array(c),x,d=0;d<c;++d)(x=l[d])&&(a[d]=x);a.sort(t)}return new Ye(r,this._parents).order()}function S2(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function R2(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function C2(){return Array.from(this)}function w2(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,i=s.length;r<i;++r){var l=s[r];if(l)return l}return null}function b2(){let e=0;for(const t of this)++e;return e}function v2(){return!this.node()}function k2(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var r=t[n],i=0,l=r.length,c;i<l;++i)(c=r[i])&&e.call(c,c.__data__,i,r);return this}function M2(e){return function(){this.removeAttribute(e)}}function _2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function P2(e,t){return function(){this.setAttribute(e,t)}}function L2(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function N2(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function T2(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 $2(e,t){var n=Zs(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((t==null?n.local?_2:M2:typeof t=="function"?n.local?T2:N2:n.local?L2:P2)(n,t))}function sa(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function A2(e){return function(){this.style.removeProperty(e)}}function I2(e,t,n){return function(){this.style.setProperty(e,t,n)}}function D2(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function z2(e,t,n){return arguments.length>1?this.each((t==null?A2:typeof t=="function"?D2:I2)(e,t,n??"")):en(this.node(),e)}function en(e,t){return e.style.getPropertyValue(t)||sa(e).getComputedStyle(e,null).getPropertyValue(t)}function B2(e){return function(){delete this[e]}}function O2(e,t){return function(){this[e]=t}}function V2(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function F2(e,t){return arguments.length>1?this.each((t==null?B2:typeof t=="function"?V2:O2)(e,t)):this.node()[e]}function oa(e){return e.trim().split(/^|\s+/)}function kr(e){return e.classList||new ra(e)}function ra(e){this._node=e,this._names=oa(e.getAttribute("class")||"")}ra.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 ia(e,t){for(var n=kr(e),s=-1,r=t.length;++s<r;)n.add(t[s])}function la(e,t){for(var n=kr(e),s=-1,r=t.length;++s<r;)n.remove(t[s])}function H2(e){return function(){ia(this,e)}}function Z2(e){return function(){la(this,e)}}function W2(e,t){return function(){(t.apply(this,arguments)?ia:la)(this,e)}}function Y2(e,t){var n=oa(e+"");if(arguments.length<2){for(var s=kr(this.node()),r=-1,i=n.length;++r<i;)if(!s.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?W2:t?H2:Z2)(n,t))}function G2(){this.textContent=""}function K2(e){return function(){this.textContent=e}}function q2(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function X2(e){return arguments.length?this.each(e==null?G2:(typeof e=="function"?q2:K2)(e)):this.node().textContent}function U2(){this.innerHTML=""}function J2(e){return function(){this.innerHTML=e}}function Q2(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function ej(e){return arguments.length?this.each(e==null?U2:(typeof e=="function"?Q2:J2)(e)):this.node().innerHTML}function tj(){this.nextSibling&&this.parentNode.appendChild(this)}function nj(){return this.each(tj)}function sj(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function oj(){return this.each(sj)}function rj(e){var t=typeof e=="function"?e:Jc(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function ij(){return null}function lj(e,t){var n=typeof e=="function"?e:Jc(e),s=t==null?ij:typeof t=="function"?t:vr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function cj(){var e=this.parentNode;e&&e.removeChild(this)}function aj(){return this.each(cj)}function uj(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function xj(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function dj(e){return this.select(e?xj:uj)}function pj(e){return arguments.length?this.property("__data__",e):this.node().__data__}function mj(e){return function(t){e.call(this,t,this.__data__)}}function fj(e){return e.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");return s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),{type:t,name:n}})}function hj(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++s]=i;++s?t.length=s:delete this.__on}}}function gj(e,t,n){return function(){var s=this.__on,r,i=mj(t);if(s){for(var l=0,c=s.length;l<c;++l)if((r=s[l]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},s?s.push(r):this.__on=[r]}}function jj(e,t,n){var s=fj(e+""),r,i=s.length,l;if(arguments.length<2){var c=this.node().__on;if(c){for(var a=0,x=c.length,d;a<x;++a)for(r=0,d=c[a];r<i;++r)if((l=s[r]).type===d.type&&l.name===d.name)return d.value}return}for(c=t?gj:hj,r=0;r<i;++r)this.each(c(s[r],t,n));return this}function ca(e,t,n){var s=sa(e),r=s.CustomEvent;typeof r=="function"?r=new r(t,n):(r=s.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Ej(e,t){return function(){return ca(this,e,t)}}function yj(e,t){return function(){return ca(this,e,t.apply(this,arguments))}}function Sj(e,t){return this.each((typeof t=="function"?yj:Ej)(e,t))}function*Rj(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,i=s.length,l;r<i;++r)(l=s[r])&&(yield l)}var aa=[null];function Ye(e,t){this._groups=e,this._parents=t}function Bn(){return new Ye([[document.documentElement]],aa)}function Cj(){return this}Ye.prototype=Bn.prototype={constructor:Ye,select:q0,selectAll:Q0,selectChild:s2,selectChildren:l2,filter:c2,data:m2,enter:a2,exit:h2,join:g2,merge:j2,selection:Cj,order:E2,sort:y2,call:R2,nodes:C2,node:w2,size:b2,empty:v2,each:k2,attr:$2,style:z2,property:F2,classed:Y2,text:X2,html:ej,raise:nj,lower:oj,append:rj,insert:lj,remove:aj,clone:dj,datum:pj,on:jj,dispatch:Sj,[Symbol.iterator]:Rj};function We(e){return typeof e=="string"?new Ye([[document.querySelector(e)]],[document.documentElement]):new Ye([[e]],aa)}function wj(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ue(e,t){if(e=wj(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var s=n.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const bj={passive:!1},_n={capture:!0,passive:!1};function jo(e){e.stopImmediatePropagation()}function Jt(e){e.preventDefault(),e.stopImmediatePropagation()}function ua(e){var t=e.document.documentElement,n=We(e).on("dragstart.drag",Jt,_n);"onselectstart"in t?n.on("selectstart.drag",Jt,_n):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function xa(e,t){var n=e.document.documentElement,s=We(e).on("dragstart.drag",null);t&&(s.on("click.drag",Jt,_n),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const qn=e=>()=>e;function Vo(e,{sourceEvent:t,subject:n,target:s,identifier:r,active:i,x:l,y:c,dx:a,dy:x,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:s,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:x,enumerable:!0,configurable:!0},_:{value:d}})}Vo.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function vj(e){return!e.ctrlKey&&!e.button}function kj(){return this.parentNode}function Mj(e,t){return t??{x:e.x,y:e.y}}function _j(){return navigator.maxTouchPoints||"ontouchstart"in this}function da(){var e=vj,t=kj,n=Mj,s=_j,r={},i=Hs("start","drag","end"),l=0,c,a,x,d,p=0;function m(C){C.on("mousedown.drag",f).filter(s).on("touchstart.drag",y).on("touchmove.drag",S,bj).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(C,L){if(!(d||!e.call(this,C,L))){var T=E(this,t.call(this,C,L),C,L,"mouse");T&&(We(C.view).on("mousemove.drag",h,_n).on("mouseup.drag",j,_n),ua(C.view),jo(C),x=!1,c=C.clientX,a=C.clientY,T("start",C))}}function h(C){if(Jt(C),!x){var L=C.clientX-c,T=C.clientY-a;x=L*L+T*T>p}r.mouse("drag",C)}function j(C){We(C.view).on("mousemove.drag mouseup.drag",null),xa(C.view,x),Jt(C),r.mouse("end",C)}function y(C,L){if(e.call(this,C,L)){var T=C.changedTouches,P=t.call(this,C,L),O=T.length,I,D;for(I=0;I<O;++I)(D=E(this,P,C,L,T[I].identifier,T[I]))&&(jo(C),D("start",C,T[I]))}}function S(C){var L=C.changedTouches,T=L.length,P,O;for(P=0;P<T;++P)(O=r[L[P].identifier])&&(Jt(C),O("drag",C,L[P]))}function b(C){var L=C.changedTouches,T=L.length,P,O;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),P=0;P<T;++P)(O=r[L[P].identifier])&&(jo(C),O("end",C,L[P]))}function E(C,L,T,P,O,I){var D=i.copy(),H=Ue(I||T,L),B,_,R;if((R=n.call(C,new Vo("beforestart",{sourceEvent:T,target:m,identifier:O,active:l,x:H[0],y:H[1],dx:0,dy:0,dispatch:D}),P))!=null)return B=R.x-H[0]||0,_=R.y-H[1]||0,function k(v,M,A){var $=H,V;switch(v){case"start":r[O]=k,V=l++;break;case"end":delete r[O],--l;case"drag":H=Ue(A||M,L),V=l;break}D.call(v,C,new Vo(v,{sourceEvent:M,subject:R,target:m,identifier:O,active:V,x:H[0]+B,y:H[1]+_,dx:H[0]-$[0],dy:H[1]-$[1],dispatch:D}),P)}}return m.filter=function(C){return arguments.length?(e=typeof C=="function"?C:qn(!!C),m):e},m.container=function(C){return arguments.length?(t=typeof C=="function"?C:qn(C),m):t},m.subject=function(C){return arguments.length?(n=typeof C=="function"?C:qn(C),m):n},m.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:qn(!!C),m):s},m.on=function(){var C=i.on.apply(i,arguments);return C===i?m:C},m.clickDistance=function(C){return arguments.length?(p=(C=+C)*C,m):Math.sqrt(p)},m}var tn=0,yn=0,hn=0,pa=1e3,Cs,Sn,ws=0,Ot=0,Ws=0,Pn=typeof performance=="object"&&performance.now?performance:Date,ma=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Mr(){return Ot||(ma(Pj),Ot=Pn.now()+Ws)}function Pj(){Ot=0}function bs(){this._call=this._time=this._next=null}bs.prototype=fa.prototype={constructor:bs,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Mr():+n)+(t==null?0:+t),!this._next&&Sn!==this&&(Sn?Sn._next=this:Cs=this,Sn=this),this._call=e,this._time=n,Fo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Fo())}};function fa(e,t,n){var s=new bs;return s.restart(e,t,n),s}function Lj(){Mr(),++tn;for(var e=Cs,t;e;)(t=Ot-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tn}function yi(){Ot=(ws=Pn.now())+Ws,tn=yn=0;try{Lj()}finally{tn=0,Tj(),Ot=0}}function Nj(){var e=Pn.now(),t=e-ws;t>pa&&(Ws-=t,ws=e)}function Tj(){for(var e,t=Cs,n,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Cs=n);Sn=e,Fo(s)}function Fo(e){if(!tn){yn&&(yn=clearTimeout(yn));var t=e-Ot;t>24?(e<1/0&&(yn=setTimeout(yi,e-Pn.now()-Ws)),hn&&(hn=clearInterval(hn))):(hn||(ws=Pn.now(),hn=setInterval(Nj,pa)),tn=1,ma(yi))}}function Si(e,t,n){var s=new bs;return t=t==null?0:+t,s.restart(r=>{s.stop(),e(r+t)},t,n),s}var $j=Hs("start","end","cancel","interrupt"),Aj=[],ha=0,Ri=1,Ho=2,cs=3,Ci=4,Zo=5,as=6;function Ys(e,t,n,s,r,i){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;Ij(e,n,{name:t,index:s,group:r,on:$j,tween:Aj,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ha})}function _r(e,t){var n=et(e,t);if(n.state>ha)throw new Error("too late; already scheduled");return n}function ct(e,t){var n=et(e,t);if(n.state>cs)throw new Error("too late; already running");return n}function et(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Ij(e,t,n){var s=e.__transition,r;s[t]=n,n.timer=fa(i,0,n.time);function i(x){n.state=Ri,n.timer.restart(l,n.delay,n.time),n.delay<=x&&l(x-n.delay)}function l(x){var d,p,m,f;if(n.state!==Ri)return a();for(d in s)if(f=s[d],f.name===n.name){if(f.state===cs)return Si(l);f.state===Ci?(f.state=as,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete s[d]):+d<t&&(f.state=as,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete s[d])}if(Si(function(){n.state===cs&&(n.state=Ci,n.timer.restart(c,n.delay,n.time),c(x))}),n.state=Ho,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Ho){for(n.state=cs,r=new Array(m=n.tween.length),d=0,p=-1;d<m;++d)(f=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(r[++p]=f);r.length=p+1}}function c(x){for(var d=x<n.duration?n.ease.call(null,x/n.duration):(n.timer.restart(a),n.state=Zo,1),p=-1,m=r.length;++p<m;)r[p].call(e,d);n.state===Zo&&(n.on.call("end",e,e.__data__,n.index,n.group),a())}function a(){n.state=as,n.timer.stop(),delete s[t];for(var x in s)return;delete e.__transition}}function us(e,t){var n=e.__transition,s,r,i=!0,l;if(n){t=t==null?null:t+"";for(l in n){if((s=n[l]).name!==t){i=!1;continue}r=s.state>Ho&&s.state<Zo,s.state=as,s.timer.stop(),s.on.call(r?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[l]}i&&delete e.__transition}}function Dj(e){return this.each(function(){us(this,e)})}function zj(e,t){var n,s;return function(){var r=ct(this,e),i=r.tween;if(i!==n){s=n=i;for(var l=0,c=s.length;l<c;++l)if(s[l].name===t){s=s.slice(),s.splice(l,1);break}}r.tween=s}}function Bj(e,t,n){var s,r;if(typeof n!="function")throw new Error;return function(){var i=ct(this,e),l=i.tween;if(l!==s){r=(s=l).slice();for(var c={name:t,value:n},a=0,x=r.length;a<x;++a)if(r[a].name===t){r[a]=c;break}a===x&&r.push(c)}i.tween=r}}function Oj(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=et(this.node(),n).tween,r=0,i=s.length,l;r<i;++r)if((l=s[r]).name===e)return l.value;return null}return this.each((t==null?zj:Bj)(n,e,t))}function Pr(e,t,n){var s=e._id;return e.each(function(){var r=ct(this,s);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return et(r,s).value[t]}}function ga(e,t){var n;return(typeof t=="number"?z.interpolateNumber:t instanceof z.color?z.interpolateRgb:(n=z.color(t))?(t=n,z.interpolateRgb):z.interpolateString)(e,t)}function Vj(e){return function(){this.removeAttribute(e)}}function Fj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Hj(e,t,n){var s,r=n+"",i;return function(){var l=this.getAttribute(e);return l===r?null:l===s?i:i=t(s=l,n)}}function Zj(e,t,n){var s,r=n+"",i;return function(){var l=this.getAttributeNS(e.space,e.local);return l===r?null:l===s?i:i=t(s=l,n)}}function Wj(e,t,n){var s,r,i;return function(){var l,c=n(this),a;return c==null?void this.removeAttribute(e):(l=this.getAttribute(e),a=c+"",l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c)))}}function Yj(e,t,n){var s,r,i;return function(){var l,c=n(this),a;return c==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),a=c+"",l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c)))}}function Gj(e,t){var n=Zs(e),s=n==="transform"?yh:ga;return this.attrTween(e,typeof t=="function"?(n.local?Yj:Wj)(n,s,Pr(this,"attr."+e,t)):t==null?(n.local?Fj:Vj)(n):(n.local?Zj:Hj)(n,s,t))}function Kj(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function qj(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Xj(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&qj(e,i)),n}return r._value=t,r}function Uj(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&Kj(e,i)),n}return r._value=t,r}function Jj(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 s=Zs(e);return this.tween(n,(s.local?Xj:Uj)(s,t))}function Qj(e,t){return function(){_r(this,e).delay=+t.apply(this,arguments)}}function e3(e,t){return t=+t,function(){_r(this,e).delay=t}}function t3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Qj:e3)(t,e)):et(this.node(),t).delay}function n3(e,t){return function(){ct(this,e).duration=+t.apply(this,arguments)}}function s3(e,t){return t=+t,function(){ct(this,e).duration=t}}function o3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?n3:s3)(t,e)):et(this.node(),t).duration}function r3(e,t){if(typeof t!="function")throw new Error;return function(){ct(this,e).ease=t}}function i3(e){var t=this._id;return arguments.length?this.each(r3(t,e)):et(this.node(),t).ease}function l3(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ct(this,e).ease=n}}function c3(e){if(typeof e!="function")throw new Error;return this.each(l3(this._id,e))}function a3(e){typeof e!="function"&&(e=ea(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=[],a,x=0;x<l;++x)(a=i[x])&&e.call(a,a.__data__,x,i)&&c.push(a);return new pt(s,this._parents,this._name,this._id)}function u3(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,r=n.length,i=Math.min(s,r),l=new Array(s),c=0;c<i;++c)for(var a=t[c],x=n[c],d=a.length,p=l[c]=new Array(d),m,f=0;f<d;++f)(m=a[f]||x[f])&&(p[f]=m);for(;c<s;++c)l[c]=t[c];return new pt(l,this._parents,this._name,this._id)}function x3(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 d3(e,t,n){var s,r,i=x3(t)?_r:ct;return function(){var l=i(this,e),c=l.on;c!==s&&(r=(s=c).copy()).on(t,n),l.on=r}}function p3(e,t){var n=this._id;return arguments.length<2?et(this.node(),n).on.on(e):this.each(d3(n,e,t))}function m3(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function f3(){return this.on("end.remove",m3(this._id))}function h3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=vr(e));for(var s=this._groups,r=s.length,i=new Array(r),l=0;l<r;++l)for(var c=s[l],a=c.length,x=i[l]=new Array(a),d,p,m=0;m<a;++m)(d=c[m])&&(p=e.call(d,d.__data__,m,c))&&("__data__"in d&&(p.__data__=d.__data__),x[m]=p,Ys(x[m],t,n,m,x,et(d,n)));return new pt(i,this._parents,t,n)}function g3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Qc(e));for(var s=this._groups,r=s.length,i=[],l=[],c=0;c<r;++c)for(var a=s[c],x=a.length,d,p=0;p<x;++p)if(d=a[p]){for(var m=e.call(d,d.__data__,p,a),f,h=et(d,n),j=0,y=m.length;j<y;++j)(f=m[j])&&Ys(f,t,n,j,m,h);i.push(m),l.push(d)}return new pt(i,l,t,n)}var j3=Bn.prototype.constructor;function E3(){return new j3(this._groups,this._parents)}function y3(e,t){var n,s,r;return function(){var i=en(this,e),l=(this.style.removeProperty(e),en(this,e));return i===l?null:i===n&&l===s?r:r=t(n=i,s=l)}}function ja(e){return function(){this.style.removeProperty(e)}}function S3(e,t,n){var s,r=n+"",i;return function(){var l=en(this,e);return l===r?null:l===s?i:i=t(s=l,n)}}function R3(e,t,n){var s,r,i;return function(){var l=en(this,e),c=n(this),a=c+"";return c==null&&(a=c=(this.style.removeProperty(e),en(this,e))),l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c))}}function C3(e,t){var n,s,r,i="style."+t,l="end."+i,c;return function(){var a=ct(this,e),x=a.on,d=a.value[i]==null?c||(c=ja(t)):void 0;(x!==n||r!==d)&&(s=(n=x).copy()).on(l,r=d),a.on=s}}function w3(e,t,n){var s=(e+="")=="transform"?Eh:ga;return t==null?this.styleTween(e,y3(e,s)).on("end.style."+e,ja(e)):typeof t=="function"?this.styleTween(e,R3(e,s,Pr(this,"style."+e,t))).each(C3(this._id,e)):this.styleTween(e,S3(e,s,t),n).on("end.style."+e,null)}function b3(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function v3(e,t,n){var s,r;function i(){var l=t.apply(this,arguments);return l!==r&&(s=(r=l)&&b3(e,l,n)),s}return i._value=t,i}function k3(e,t,n){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,v3(e,t,n??""))}function M3(e){return function(){this.textContent=e}}function _3(e){return function(){var t=e(this);this.textContent=t??""}}function P3(e){return this.tween("text",typeof e=="function"?_3(Pr(this,"text",e)):M3(e==null?"":e+""))}function L3(e){return function(t){this.textContent=e.call(this,t)}}function N3(e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&L3(r)),t}return s._value=e,s}function T3(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,N3(e))}function $3(){for(var e=this._name,t=this._id,n=Ea(),s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],c=l.length,a,x=0;x<c;++x)if(a=l[x]){var d=et(a,t);Ys(a,e,n,x,l,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new pt(s,this._parents,e,n)}function A3(){var e,t,n=this,s=n._id,r=n.size();return new Promise(function(i,l){var c={value:l},a={value:function(){--r===0&&i()}};n.each(function(){var x=ct(this,s),d=x.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(a)),x.on=t}),r===0&&i()})}var I3=0;function pt(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Ea(){return++I3}var ut=Bn.prototype;pt.prototype={constructor:pt,select:h3,selectAll:g3,selectChild:ut.selectChild,selectChildren:ut.selectChildren,filter:a3,merge:u3,selection:E3,transition:$3,call:ut.call,nodes:ut.nodes,node:ut.node,size:ut.size,empty:ut.empty,each:ut.each,on:p3,attr:Gj,attrTween:Jj,style:w3,styleTween:k3,text:P3,textTween:T3,remove:f3,tween:Oj,delay:t3,duration:o3,ease:i3,easeVarying:c3,end:A3,[Symbol.iterator]:ut[Symbol.iterator]};function D3(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var z3={time:null,delay:0,duration:250,ease:D3};function B3(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 O3(e){var t,n;e instanceof pt?(t=e._id,e=e._name):(t=Ea(),(n=z3).time=Mr(),e=e==null?null:e+"");for(var s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],c=l.length,a,x=0;x<c;++x)(a=l[x])&&Ys(a,e,t,x,l,n||B3(a,t));return new pt(s,this._parents,e,t)}Bn.prototype.interrupt=Dj;Bn.prototype.transition=O3;const Xn=e=>()=>e;function V3(e,{sourceEvent:t,target:n,transform:s,dispatch:r}){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:s,enumerable:!0,configurable:!0},_:{value:r}})}function xt(e,t,n){this.k=e,this.x=t,this.y=n}xt.prototype={constructor:xt,scale:function(e){return e===1?this:new xt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new xt(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 Gs=new xt(1,0,0);ya.prototype=xt.prototype;function ya(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Gs;return e.__zoom}function Eo(e){e.stopImmediatePropagation()}function gn(e){e.preventDefault(),e.stopImmediatePropagation()}function F3(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function H3(){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 wi(){return this.__zoom||Gs}function Z3(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function W3(){return navigator.maxTouchPoints||"ontouchstart"in this}function Y3(e,t,n){var s=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],l=e.invertY(t[1][1])-n[1][1];return e.translate(r>s?(s+r)/2:Math.min(0,s)||Math.max(0,r),l>i?(i+l)/2:Math.min(0,i)||Math.max(0,l))}function Sa(){var e=F3,t=H3,n=Y3,s=Z3,r=W3,i=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,a=wh,x=Hs("start","zoom","end"),d,p,m,f=500,h=150,j=0,y=10;function S(R){R.property("__zoom",wi).on("wheel.zoom",O,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",D).filter(r).on("touchstart.zoom",H).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",_).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(R,k,v,M){var A=R.selection?R.selection():R;A.property("__zoom",wi),R!==A?L(R,k,v,M):A.interrupt().each(function(){T(this,arguments).event(M).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},S.scaleBy=function(R,k,v,M){S.scaleTo(R,function(){var A=this.__zoom.k,$=typeof k=="function"?k.apply(this,arguments):k;return A*$},v,M)},S.scaleTo=function(R,k,v,M){S.transform(R,function(){var A=t.apply(this,arguments),$=this.__zoom,V=v==null?C(A):typeof v=="function"?v.apply(this,arguments):v,F=$.invert(V),W=typeof k=="function"?k.apply(this,arguments):k;return n(E(b($,W),V,F),A,l)},v,M)},S.translateBy=function(R,k,v,M){S.transform(R,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof v=="function"?v.apply(this,arguments):v),t.apply(this,arguments),l)},null,M)},S.translateTo=function(R,k,v,M,A){S.transform(R,function(){var $=t.apply(this,arguments),V=this.__zoom,F=M==null?C($):typeof M=="function"?M.apply(this,arguments):M;return n(Gs.translate(F[0],F[1]).scale(V.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof v=="function"?-v.apply(this,arguments):-v),$,l)},M,A)};function b(R,k){return k=Math.max(i[0],Math.min(i[1],k)),k===R.k?R:new xt(k,R.x,R.y)}function E(R,k,v){var M=k[0]-v[0]*R.k,A=k[1]-v[1]*R.k;return M===R.x&&A===R.y?R:new xt(R.k,M,A)}function C(R){return[(+R[0][0]+ +R[1][0])/2,(+R[0][1]+ +R[1][1])/2]}function L(R,k,v,M){R.on("start.zoom",function(){T(this,arguments).event(M).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(M).end()}).tween("zoom",function(){var A=this,$=arguments,V=T(A,$).event(M),F=t.apply(A,$),W=v==null?C(F):typeof v=="function"?v.apply(A,$):v,ee=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),te=A.__zoom,se=typeof k=="function"?k.apply(A,$):k,oe=a(te.invert(W).concat(ee/te.k),se.invert(W).concat(ee/se.k));return function(J){if(J===1)J=se;else{var le=oe(J),fe=ee/le[2];J=new xt(fe,W[0]-le[0]*fe,W[1]-le[1]*fe)}V.zoom(null,J)}})}function T(R,k,v){return!v&&R.__zooming||new P(R,k)}function P(R,k){this.that=R,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(R,k),this.taps=0}P.prototype={event:function(R){return R&&(this.sourceEvent=R),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(R,k){return this.mouse&&R!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&R!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&R!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(R){var k=We(this.that).datum();x.call(R,this.that,new V3(R,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:x}),k)}};function O(R,...k){if(!e.apply(this,arguments))return;var v=T(this,k).event(R),M=this.__zoom,A=Math.max(i[0],Math.min(i[1],M.k*Math.pow(2,s.apply(this,arguments)))),$=Ue(R);if(v.wheel)(v.mouse[0][0]!==$[0]||v.mouse[0][1]!==$[1])&&(v.mouse[1]=M.invert(v.mouse[0]=$)),clearTimeout(v.wheel);else{if(M.k===A)return;v.mouse=[$,M.invert($)],us(this),v.start()}gn(R),v.wheel=setTimeout(V,h),v.zoom("mouse",n(E(b(M,A),v.mouse[0],v.mouse[1]),v.extent,l));function V(){v.wheel=null,v.end()}}function I(R,...k){if(m||!e.apply(this,arguments))return;var v=R.currentTarget,M=T(this,k,!0).event(R),A=We(R.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",ee,!0),$=Ue(R,v),V=R.clientX,F=R.clientY;ua(R.view),Eo(R),M.mouse=[$,this.__zoom.invert($)],us(this),M.start();function W(te){if(gn(te),!M.moved){var se=te.clientX-V,oe=te.clientY-F;M.moved=se*se+oe*oe>j}M.event(te).zoom("mouse",n(E(M.that.__zoom,M.mouse[0]=Ue(te,v),M.mouse[1]),M.extent,l))}function ee(te){A.on("mousemove.zoom mouseup.zoom",null),xa(te.view,M.moved),gn(te),M.event(te).end()}}function D(R,...k){if(e.apply(this,arguments)){var v=this.__zoom,M=Ue(R.changedTouches?R.changedTouches[0]:R,this),A=v.invert(M),$=v.k*(R.shiftKey?.5:2),V=n(E(b(v,$),M,A),t.apply(this,k),l);gn(R),c>0?We(this).transition().duration(c).call(L,V,M,R):We(this).call(S.transform,V,M,R)}}function H(R,...k){if(e.apply(this,arguments)){var v=R.touches,M=v.length,A=T(this,k,R.changedTouches.length===M).event(R),$,V,F,W;for(Eo(R),V=0;V<M;++V)F=v[V],W=Ue(F,this),W=[W,this.__zoom.invert(W),F.identifier],A.touch0?!A.touch1&&A.touch0[2]!==W[2]&&(A.touch1=W,A.taps=0):(A.touch0=W,$=!0,A.taps=1+!!d);d&&(d=clearTimeout(d)),$&&(A.taps<2&&(p=W[0],d=setTimeout(function(){d=null},f)),us(this),A.start())}}function B(R,...k){if(this.__zooming){var v=T(this,k).event(R),M=R.changedTouches,A=M.length,$,V,F,W;for(gn(R),$=0;$<A;++$)V=M[$],F=Ue(V,this),v.touch0&&v.touch0[2]===V.identifier?v.touch0[0]=F:v.touch1&&v.touch1[2]===V.identifier&&(v.touch1[0]=F);if(V=v.that.__zoom,v.touch1){var ee=v.touch0[0],te=v.touch0[1],se=v.touch1[0],oe=v.touch1[1],J=(J=se[0]-ee[0])*J+(J=se[1]-ee[1])*J,le=(le=oe[0]-te[0])*le+(le=oe[1]-te[1])*le;V=b(V,Math.sqrt(J/le)),F=[(ee[0]+se[0])/2,(ee[1]+se[1])/2],W=[(te[0]+oe[0])/2,(te[1]+oe[1])/2]}else if(v.touch0)F=v.touch0[0],W=v.touch0[1];else return;v.zoom("touch",n(E(V,F,W),v.extent,l))}}function _(R,...k){if(this.__zooming){var v=T(this,k).event(R),M=R.changedTouches,A=M.length,$,V;for(Eo(R),m&&clearTimeout(m),m=setTimeout(function(){m=null},f),$=0;$<A;++$)V=M[$],v.touch0&&v.touch0[2]===V.identifier?delete v.touch0:v.touch1&&v.touch1[2]===V.identifier&&delete v.touch1;if(v.touch1&&!v.touch0&&(v.touch0=v.touch1,delete v.touch1),v.touch0)v.touch0[1]=this.__zoom.invert(v.touch0[0]);else if(v.end(),v.taps===2&&(V=Ue(V,this),Math.hypot(p[0]-V[0],p[1]-V[1])<y)){var F=We(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return S.wheelDelta=function(R){return arguments.length?(s=typeof R=="function"?R:Xn(+R),S):s},S.filter=function(R){return arguments.length?(e=typeof R=="function"?R:Xn(!!R),S):e},S.touchable=function(R){return arguments.length?(r=typeof R=="function"?R:Xn(!!R),S):r},S.extent=function(R){return arguments.length?(t=typeof R=="function"?R:Xn([[+R[0][0],+R[0][1]],[+R[1][0],+R[1][1]]]),S):t},S.scaleExtent=function(R){return arguments.length?(i[0]=+R[0],i[1]=+R[1],S):[i[0],i[1]]},S.translateExtent=function(R){return arguments.length?(l[0][0]=+R[0][0],l[1][0]=+R[1][0],l[0][1]=+R[0][1],l[1][1]=+R[1][1],S):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},S.constrain=function(R){return arguments.length?(n=R,S):n},S.duration=function(R){return arguments.length?(c=+R,S):c},S.interpolate=function(R){return arguments.length?(a=R,S):a},S.on=function(){var R=x.on.apply(x,arguments);return R===x?S:R},S.clickDistance=function(R){return arguments.length?(j=(R=+R)*R,S):Math.sqrt(j)},S.tapDistance=function(R){return arguments.length?(y=+R,S):y},S}const Be={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:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:s}", 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."},Ln=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ra=["Enter"," ","Escape"];var Vt;(function(e){e.Strict="strict",e.Loose="loose"})(Vt||(Vt={}));var It;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(It||(It={}));var nn;(function(e){e.Partial="partial",e.Full="full"})(nn||(nn={}));const Ca={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var Rt;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Rt||(Rt={}));var vs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(vs||(vs={}));var U;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(U||(U={}));const bi={[U.Left]:U.Right,[U.Right]:U.Left,[U.Top]:U.Bottom,[U.Bottom]:U.Top};function wa(e){return e===null?null:e?"valid":"invalid"}const ba=e=>"id"in e&&"source"in e&&"target"in e,G3=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Lr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),On=(e,t=[0,0])=>{const{width:n,height:s}=gt(e),r=e.origin??t,i=n*r[0],l=s*r[1];return{x:e.position.x-i,y:e.position.y-l}},K3=(e,t={nodeOrigin:[0,0]})=>{if(process.env.NODE_ENV==="development"&&!t.nodeLookup&&console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."),e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,r)=>{const i=typeof r=="string";let l=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(l=i?t.nodeLookup.get(r):Lr(r)?r:t.nodeLookup.get(r.id));const c=l?ks(l,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Ks(s,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return qs(n)},Vn=(e,t={})=>{if(e.size===0)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach(s=>{if(t.filter===void 0||t.filter(s)){const r=ks(s);n=Ks(n,r)}}),qs(n)},va=(e,t,[n,s,r]=[0,0,1],i=!1,l=!1)=>{const c={...Fn(t,[n,s,r]),width:t.width/r,height:t.height/r},a=[];for(const x of e.values()){const{measured:d,selectable:p=!0,hidden:m=!1}=x;if(l&&!p||m)continue;const f=d.width??x.width??x.initialWidth??null,h=d.height??x.height??x.initialHeight??null,j=Nn(c,on(x)),y=(f??0)*(h??0),S=i&&j>0;(!x.internals.handleBounds||S||j>=y||x.dragging)&&a.push(x)}return a},q3=(e,t)=>{const n=new Set;return e.forEach(s=>{n.add(s.id)}),t.filter(s=>n.has(s.source)||n.has(s.target))};function X3(e,t){const n=new Map,s=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!s||s.has(r.id))&&n.set(r.id,r)}),n}async function U3({nodes:e,width:t,height:n,panZoom:s,minZoom:r,maxZoom:i},l){if(e.size===0)return Promise.resolve(!0);const c=X3(e,l),a=Vn(c),x=Nr(a,t,n,(l==null?void 0:l.minZoom)??r,(l==null?void 0:l.maxZoom)??i,(l==null?void 0:l.padding)??.1);return await s.setViewport(x,{duration:l==null?void 0:l.duration}),Promise.resolve(!0)}function ka({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:r,onError:i}){const l=n.get(e),c=l.parentId?n.get(l.parentId):void 0,{x:a,y:x}=c?c.internals.positionAbsolute:{x:0,y:0},d=l.origin??s;let p=r;if(l.extent==="parent"&&!l.expandParent)if(!c)i==null||i("005",Be.error005());else{const f=c.measured.width,h=c.measured.height;f&&h&&(p=[[a,x],[a+f,x+h]])}else c&&rn(l.extent)&&(p=[[l.extent[0][0]+a,l.extent[0][1]+x],[l.extent[1][0]+a,l.extent[1][1]+x]]);const m=rn(p)?Ft(t,p,l.measured):t;return(l.measured.width===void 0||l.measured.height===void 0)&&(i==null||i("015",Be.error015())),{position:{x:m.x-a+(l.measured.width??0)*d[0],y:m.y-x+(l.measured.height??0)*d[1]},positionAbsolute:m}}async function J3({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:r}){const i=new Set(e.map(m=>m.id)),l=[];for(const m of n){if(m.deletable===!1)continue;const f=i.has(m.id),h=!f&&m.parentId&&l.find(j=>j.id===m.parentId);(f||h)&&l.push(m)}const c=new Set(t.map(m=>m.id)),a=s.filter(m=>m.deletable!==!1),d=q3(l,a);for(const m of a)c.has(m.id)&&!d.find(h=>h.id===m.id)&&d.push(m);if(!r)return{edges:d,nodes:l};const p=await r({nodes:l,edges:d});return typeof p=="boolean"?p?{edges:d,nodes:l}:{edges:[],nodes:[]}:p}const sn=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ft=(e={x:0,y:0},t,n)=>({x:sn(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:sn(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Ma(e,t,n){const{width:s,height:r}=gt(n),{x:i,y:l}=n.internals.positionAbsolute;return Ft(e,[[i,l],[i+s,l+r]],t)}const vi=(e,t,n)=>e<t?sn(Math.abs(e-t),1,t)/t:e>n?-sn(Math.abs(e-n),1,t)/t:0,_a=(e,t,n=15,s=40)=>{const r=vi(e.x,s,t.width-s)*n,i=vi(e.y,s,t.height-s)*n;return[r,i]},Ks=(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)}),Wo=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),qs=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),on=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=Lr(e)?e.internals.positionAbsolute:On(e,t);return{x:n,y:s,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},ks=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=Lr(e)?e.internals.positionAbsolute:On(e,t);return{x:n,y:s,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:s+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Pa=(e,t)=>qs(Ks(Wo(e),Wo(t))),Nn=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*s)},ki=e=>Je(e.width)&&Je(e.height)&&Je(e.x)&&Je(e.y),Je=e=>!isNaN(e)&&isFinite(e),Ms=(e,t)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)},Xs=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Fn=({x:e,y:t},[n,s,r],i=!1,l=[1,1])=>{const c={x:(e-n)/r,y:(t-s)/r};return i?Xs(c,l):c},_s=({x:e,y:t},[n,s,r])=>({x:e*r+n,y:t*r+s});function Kt(e,t){if(typeof e=="number")return Math.floor(t-t/(1+e));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 Q3(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=Kt(e,n),r=Kt(e,t);return{top:s,right:r,bottom:s,left:r,x:r*2,y:s*2}}if(typeof e=="object"){const s=Kt(e.top??e.y??0,n),r=Kt(e.bottom??e.y??0,n),i=Kt(e.left??e.x??0,t),l=Kt(e.right??e.x??0,t);return{top:s,right:l,bottom:r,left:i,x:i+l,y:s+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function e5(e,t,n,s,r,i){const{x:l,y:c}=_s(e,[t,n,s]),{x:a,y:x}=_s({x:e.x+e.width,y:e.y+e.height},[t,n,s]),d=r-a,p=i-x;return{left:Math.floor(l),top:Math.floor(c),right:Math.floor(d),bottom:Math.floor(p)}}const Nr=(e,t,n,s,r,i)=>{const l=Q3(i,t,n),c=(t-l.x)/e.width,a=(n-l.y)/e.height,x=Math.min(c,a),d=sn(x,s,r),p=e.x+e.width/2,m=e.y+e.height/2,f=t/2-p*d,h=n/2-m*d,j=e5(e,f,h,d,t,n),y={left:Math.min(j.left-l.left,0),top:Math.min(j.top-l.top,0),right:Math.min(j.right-l.right,0),bottom:Math.min(j.bottom-l.bottom,0)};return{x:f-y.left+y.right,y:h-y.top+y.bottom,zoom:d}},Ps=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function rn(e){return e!==void 0&&e!=="parent"}function gt(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function La(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Na(e,t={width:0,height:0},n,s,r){const i={...e},l=s.get(n);if(l){const c=l.origin||r;i.x+=l.internals.positionAbsolute.x-(t.width??0)*c[0],i.y+=l.internals.positionAbsolute.y-(t.height??0)*c[1]}return i}function Mi(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Cn(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:r}){const{x:i,y:l}=dt(e),c=Fn({x:i-((r==null?void 0:r.left)??0),y:l-((r==null?void 0:r.top)??0)},s),{x:a,y:x}=n?Xs(c,t):c;return{xSnapped:a,ySnapped:x,...c}}const Tr=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ta=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},t5=["INPUT","SELECT","TEXTAREA"];function $a(e){var s,r;const t=((r=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:t5.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Aa=e=>"clientX"in e,dt=(e,t)=>{var i,l;const n=Aa(e),s=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,r=n?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},_i=(e,t,n,s,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(l=>{const c=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:r,position:l.getAttribute("data-handlepos"),x:(c.left-n.left)/s,y:(c.top-n.top)/s,...Tr(l)}})};function Ia({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:r,sourceControlY:i,targetControlX:l,targetControlY:c}){const a=e*.125+r*.375+l*.375+n*.125,x=t*.125+i*.375+c*.375+s*.125,d=Math.abs(a-e),p=Math.abs(x-t);return[a,x,d,p]}function Un(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Pi({pos:e,x1:t,y1:n,x2:s,y2:r,c:i}){switch(e){case U.Left:return[t-Un(t-s,i),n];case U.Right:return[t+Un(s-t,i),n];case U.Top:return[t,n-Un(n-r,i)];case U.Bottom:return[t,n+Un(r-n,i)]}}function Da({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:s,targetY:r,targetPosition:i=U.Top,curvature:l=.25}){const[c,a]=Pi({pos:n,x1:e,y1:t,x2:s,y2:r,c:l}),[x,d]=Pi({pos:i,x1:s,y1:r,x2:e,y2:t,c:l}),[p,m,f,h]=Ia({sourceX:e,sourceY:t,targetX:s,targetY:r,sourceControlX:c,sourceControlY:a,targetControlX:x,targetControlY:d});return[`M${e},${t} C${c},${a} ${x},${d} ${s},${r}`,p,m,f,h]}function za({sourceX:e,sourceY:t,targetX:n,targetY:s}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,l=Math.abs(s-t)/2,c=s<t?s+l:s-l;return[i,c,r,l]}function n5({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s=0,elevateOnSelect:r=!1}){if(!r)return s;const i=n||t.selected||e.selected,l=Math.max(e.internals.z||0,t.internals.z||0,1e3);return s+(i?l:0)}function s5({sourceNode:e,targetNode:t,width:n,height:s,transform:r}){const i=Ks(ks(e),ks(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const l={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:s/r[2]};return Nn(l,qs(i))>0}const Ba=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,o5=(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)),Oa=(e,t)=>{if(!e.source||!e.target)return Ms("006",Be.error006()),t;let n;return ba(e)?n={...e}:n={...e,id:Ba(e)},o5(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))},r5=(e,t,n,s={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return Ms("006",Be.error006()),n;if(!n.find(a=>a.id===e.id))return Ms("007",Be.error007(r)),n;const c={...i,id:s.shouldReplaceId?Ba(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(a=>a.id!==r).concat(c)};function Va({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[r,i,l,c]=za({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,r,i,l,c]}const Li={[U.Left]:{x:-1,y:0},[U.Right]:{x:1,y:0},[U.Top]:{x:0,y:-1},[U.Bottom]:{x:0,y:1}},i5=({source:e,sourcePosition:t=U.Bottom,target:n})=>t===U.Left||t===U.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},Ni=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function l5({source:e,sourcePosition:t=U.Bottom,target:n,targetPosition:s=U.Top,center:r,offset:i}){const l=Li[t],c=Li[s],a={x:e.x+l.x*i,y:e.y+l.y*i},x={x:n.x+c.x*i,y:n.y+c.y*i},d=i5({source:a,sourcePosition:t,target:x}),p=d.x!==0?"x":"y",m=d[p];let f=[],h,j;const y={x:0,y:0},S={x:0,y:0},[b,E,C,L]=za({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){h=r.x??b,j=r.y??E;const P=[{x:h,y:a.y},{x:h,y:x.y}],O=[{x:a.x,y:j},{x:x.x,y:j}];l[p]===m?f=p==="x"?P:O:f=p==="x"?O:P}else{const P=[{x:a.x,y:x.y}],O=[{x:x.x,y:a.y}];if(p==="x"?f=l.x===m?O:P:f=l.y===m?P:O,t===s){const _=Math.abs(e[p]-n[p]);if(_<=i){const R=Math.min(i-1,i-_);l[p]===m?y[p]=(a[p]>e[p]?-1:1)*R:S[p]=(x[p]>n[p]?-1:1)*R}}if(t!==s){const _=p==="x"?"y":"x",R=l[p]===c[_],k=a[_]>x[_],v=a[_]<x[_];(l[p]===1&&(!R&&k||R&&v)||l[p]!==1&&(!R&&v||R&&k))&&(f=p==="x"?P:O)}const I={x:a.x+y.x,y:a.y+y.y},D={x:x.x+S.x,y:x.y+S.y},H=Math.max(Math.abs(I.x-f[0].x),Math.abs(D.x-f[0].x)),B=Math.max(Math.abs(I.y-f[0].y),Math.abs(D.y-f[0].y));H>=B?(h=(I.x+D.x)/2,j=f[0].y):(h=f[0].x,j=(I.y+D.y)/2)}return[[e,{x:a.x+y.x,y:a.y+y.y},...f,{x:x.x+S.x,y:x.y+S.y},n],h,j,C,L]}function c5(e,t,n,s){const r=Math.min(Ni(e,t)/2,Ni(t,n)/2,s),{x:i,y:l}=t;if(e.x===i&&i===n.x||e.y===l&&l===n.y)return`L${i} ${l}`;if(e.y===l){const x=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${i+r*x},${l}Q ${i},${l} ${i},${l+r*d}`}const c=e.x<n.x?1:-1,a=e.y<n.y?-1:1;return`L ${i},${l+r*a}Q ${i},${l} ${i+r*c},${l}`}function Yo({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:s,targetY:r,targetPosition:i=U.Top,borderRadius:l=5,centerX:c,centerY:a,offset:x=20}){const[d,p,m,f,h]=l5({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:r},targetPosition:i,center:{x:c,y:a},offset:x});return[d.reduce((y,S,b)=>{let E="";return b>0&&b<d.length-1?E=c5(d[b-1],S,d[b+1],l):E=`${b===0?"M":"L"}${S.x} ${S.y}`,y+=E,y},""),p,m,f,h]}function Ti(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function a5(e){var p;const{sourceNode:t,targetNode:n}=e;if(!Ti(t)||!Ti(n))return null;const s=t.internals.handleBounds||$i(t.handles),r=n.internals.handleBounds||$i(n.handles),i=Ai((s==null?void 0:s.source)??[],e.sourceHandle),l=Ai(e.connectionMode===Vt.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!i||!l)return(p=e.onError)==null||p.call(e,"008",Be.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(i==null?void 0:i.position)||U.Bottom,a=(l==null?void 0:l.position)||U.Top,x=Tn(t,i,c),d=Tn(n,l,a);return{sourceX:x.x,sourceY:x.y,targetX:d.x,targetY:d.y,sourcePosition:c,targetPosition:a}}function $i(e){if(!e)return null;const t=[],n=[];for(const s of e)s.width=s.width??1,s.height=s.height??1,s.type==="source"?t.push(s):s.type==="target"&&n.push(s);return{source:t,target:n}}function Tn(e,t,n=U.Left,s=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:l,height:c}=t??gt(e);if(s)return{x:r+l/2,y:i+c/2};switch((t==null?void 0:t.position)??n){case U.Top:return{x:r+l/2,y:i};case U.Right:return{x:r+l,y:i+c/2};case U.Bottom:return{x:r+l/2,y:i+c};case U.Left:return{x:r,y:i+c/2}}}function Ai(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Go(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function u5(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:r}){const i=new Set;return e.reduce((l,c)=>([c.markerStart||s,c.markerEnd||r].forEach(a=>{if(a&&typeof a=="object"){const x=Go(a,t);i.has(x)||(l.push({id:x,color:a.color||n,...a}),i.add(x))}}),l),[]).sort((l,c)=>l.id.localeCompare(c.id))}const $r={nodeOrigin:[0,0],nodeExtent:Ln,elevateNodesOnSelect:!0,defaults:{}},x5={...$r,checkEquality:!0};function Ar(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function d5(e,t,n){const s=Ar($r,n);for(const r of e.values())if(r.parentId)Ir(r,e,t,s);else{const i=On(r,s.nodeOrigin),l=rn(r.extent)?r.extent:s.nodeExtent,c=Ft(i,l,gt(r));r.internals.positionAbsolute=c}}function Ko(e,t,n,s){var a,x;const r=Ar(x5,s);let i=!0;const l=new Map(t),c=r!=null&&r.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const d of e){let p=l.get(d.id);if(r.checkEquality&&d===(p==null?void 0:p.internals.userNode))t.set(d.id,p);else{const m=On(d,r.nodeOrigin),f=rn(d.extent)?d.extent:r.nodeExtent,h=Ft(m,f,gt(d));p={...r.defaults,...d,measured:{width:(a=d.measured)==null?void 0:a.width,height:(x=d.measured)==null?void 0:x.height},internals:{positionAbsolute:h,handleBounds:d.measured?p==null?void 0:p.internals.handleBounds:void 0,z:Fa(d,c),userNode:d}},t.set(d.id,p)}(!p.measured||!p.measured.width||!p.measured.height)&&!p.hidden&&(i=!1),d.parentId&&Ir(p,t,n,s)}return i}function p5(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 Ir(e,t,n,s){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:l}=Ar($r,s),c=e.parentId,a=t.get(c);if(!a){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}p5(e,n);const x=r?1e3:0,{x:d,y:p,z:m}=m5(e,a,i,l,x),{positionAbsolute:f}=e.internals,h=d!==f.x||p!==f.y;(h||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:p}:f,z:m}})}function Fa(e,t){return(Je(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function m5(e,t,n,s,r){const{x:i,y:l}=t.internals.positionAbsolute,c=gt(e),a=On(e,n),x=rn(e.extent)?Ft(a,e.extent,c):a;let d=Ft({x:i+x.x,y:l+x.y},s,c);e.extent==="parent"&&(d=Ma(d,c,t));const p=Fa(e,r),m=t.internals.z??0;return{x:d.x,y:d.y,z:m>p?m:p}}function Dr(e,t,n,s=[0,0]){var l;const r=[],i=new Map;for(const c of e){const a=t.get(c.parentId);if(!a)continue;const x=((l=i.get(c.parentId))==null?void 0:l.expandedRect)??on(a),d=Pa(x,c.rect);i.set(c.parentId,{expandedRect:d,parent:a})}return i.size>0&&i.forEach(({expandedRect:c,parent:a},x)=>{var E;const d=a.internals.positionAbsolute,p=gt(a),m=a.origin??s,f=c.x<d.x?Math.round(Math.abs(d.x-c.x)):0,h=c.y<d.y?Math.round(Math.abs(d.y-c.y)):0,j=Math.max(p.width,Math.round(c.width)),y=Math.max(p.height,Math.round(c.height)),S=(j-p.width)*m[0],b=(y-p.height)*m[1];(f>0||h>0||S||b)&&(r.push({id:x,type:"position",position:{x:a.position.x-f+S,y:a.position.y-h+b}}),(E=n.get(x))==null||E.forEach(C=>{e.some(L=>L.id===C.id)||r.push({id:C.id,type:"position",position:{x:C.position.x+f,y:C.position.y+h}})})),(p.width<c.width||p.height<c.height||f||h)&&r.push({id:x,type:"dimensions",setAttributes:!0,dimensions:{width:j+(f?m[0]*f-S:0),height:y+(h?m[1]*h-b:0)}})}),r}function f5(e,t,n,s,r,i){const l=s==null?void 0:s.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const a=[],x=window.getComputedStyle(l),{m22:d}=new window.DOMMatrixReadOnly(x.transform),p=[];for(const m of e.values()){const f=t.get(m.id);if(!f)continue;if(f.hidden){t.set(f.id,{...f,internals:{...f.internals,handleBounds:void 0}}),c=!0;continue}const h=Tr(m.nodeElement),j=f.measured.width!==h.width||f.measured.height!==h.height;if(!!(h.width&&h.height&&(j||!f.internals.handleBounds||m.force))){const S=m.nodeElement.getBoundingClientRect(),b=rn(f.extent)?f.extent:i;let{positionAbsolute:E}=f.internals;f.parentId&&f.extent==="parent"?E=Ma(E,h,t.get(f.parentId)):b&&(E=Ft(E,b,h));const C={...f,measured:h,internals:{...f.internals,positionAbsolute:E,handleBounds:{source:_i("source",m.nodeElement,S,d,f.id),target:_i("target",m.nodeElement,S,d,f.id)}}};t.set(f.id,C),f.parentId&&Ir(C,t,n,{nodeOrigin:r}),c=!0,j&&(a.push({id:f.id,type:"dimensions",dimensions:h}),f.expandParent&&f.parentId&&p.push({id:f.id,parentId:f.parentId,rect:on(C,r)}))}}if(p.length>0){const m=Dr(p,t,n,r);a.push(...m)}return{changes:a,updatedInternals:c}}async function h5({delta:e,panZoom:t,transform:n,translateExtent:s,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const l=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],s),c=!!l&&(l.x!==n[0]||l.y!==n[1]||l.k!==n[2]);return Promise.resolve(c)}function Ii(e,t,n,s,r,i){let l=r;const c=s.get(l)||new Map;s.set(l,c.set(n,t)),l=`${r}-${e}`;const a=s.get(l)||new Map;if(s.set(l,a.set(n,t)),i){l=`${r}-${e}-${i}`;const x=s.get(l)||new Map;s.set(l,x.set(n,t))}}function Ha(e,t,n){e.clear(),t.clear();for(const s of n){const{source:r,target:i,sourceHandle:l=null,targetHandle:c=null}=s,a={edgeId:s.id,source:r,target:i,sourceHandle:l,targetHandle:c},x=`${r}-${l}--${i}-${c}`,d=`${i}-${c}--${r}-${l}`;Ii("source",a,d,e,r,l),Ii("target",a,x,e,i,c),t.set(s.id,s)}}function Za(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Za(n,t):!1}function Di(e,t,n){var r;let s=e;do{if((r=s==null?void 0:s.matches)!=null&&r.call(s,t))return!0;if(s===n)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function g5(e,t,n,s){const r=new Map;for(const[i,l]of e)if((l.selected||l.id===s)&&(!l.parentId||!Za(l,e))&&(l.draggable||t&&typeof l.draggable>"u")){const c=e.get(i);c&&r.set(i,{id:i,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return r}function yo({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){var l,c,a;const r=[];for(const[x,d]of t){const p=(l=n.get(x))==null?void 0:l.internals.userNode;p&&r.push({...p,position:d.position,dragging:s})}if(!e)return[r[0],r];const i=(c=n.get(e))==null?void 0:c.internals.userNode;return[i?{...i,position:((a=t.get(e))==null?void 0:a.position)||i.position,dragging:s}:r[0],r]}function j5({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:r}){let i={x:null,y:null},l=0,c=new Map,a=!1,x={x:0,y:0},d=null,p=!1,m=null,f=!1;function h({noDragClassName:y,handleSelector:S,domNode:b,isSelectable:E,nodeId:C,nodeClickDistance:L=0}){m=We(b);function T({x:D,y:H},B){const{nodeLookup:_,nodeExtent:R,snapGrid:k,snapToGrid:v,nodeOrigin:M,onNodeDrag:A,onSelectionDrag:$,onError:V,updateNodePositions:F}=t();i={x:D,y:H};let W=!1,ee={x:0,y:0,x2:0,y2:0};if(c.size>1&&R){const te=Vn(c);ee=Wo(te)}for(const[te,se]of c){if(!_.has(te))continue;let oe={x:D-se.distance.x,y:H-se.distance.y};v&&(oe=Xs(oe,k));let J=[[R[0][0],R[0][1]],[R[1][0],R[1][1]]];if(c.size>1&&R&&!se.extent){const{positionAbsolute:ke}=se.internals,de=ke.x-ee.x+R[0][0],G=ke.x+se.measured.width-ee.x2+R[1][0],ae=ke.y-ee.y+R[0][1],ue=ke.y+se.measured.height-ee.y2+R[1][1];J=[[de,ae],[G,ue]]}const{position:le,positionAbsolute:fe}=ka({nodeId:te,nextPosition:oe,nodeLookup:_,nodeExtent:J,nodeOrigin:M,onError:V});W=W||se.position.x!==le.x||se.position.y!==le.y,se.position=le,se.internals.positionAbsolute=fe}if(W&&(F(c,!0),B&&(s||A||!C&&$))){const[te,se]=yo({nodeId:C,dragItems:c,nodeLookup:_});s==null||s(B,c,te,se),A==null||A(B,te,se),C||$==null||$(B,se)}}async function P(){if(!d)return;const{transform:D,panBy:H,autoPanSpeed:B,autoPanOnNodeDrag:_}=t();if(!_){a=!1,cancelAnimationFrame(l);return}const[R,k]=_a(x,d,B);(R!==0||k!==0)&&(i.x=(i.x??0)-R/D[2],i.y=(i.y??0)-k/D[2],await H({x:R,y:k})&&T(i,null)),l=requestAnimationFrame(P)}function O(D){var W;const{nodeLookup:H,multiSelectionActive:B,nodesDraggable:_,transform:R,snapGrid:k,snapToGrid:v,selectNodesOnDrag:M,onNodeDragStart:A,onSelectionDragStart:$,unselectNodesAndEdges:V}=t();p=!0,(!M||!E)&&!B&&C&&((W=H.get(C))!=null&&W.selected||V()),E&&M&&C&&(e==null||e(C));const F=Cn(D.sourceEvent,{transform:R,snapGrid:k,snapToGrid:v,containerBounds:d});if(i=F,c=g5(H,_,F,C),c.size>0&&(n||A||!C&&$)){const[ee,te]=yo({nodeId:C,dragItems:c,nodeLookup:H});n==null||n(D.sourceEvent,c,ee,te),A==null||A(D.sourceEvent,ee,te),C||$==null||$(D.sourceEvent,te)}}const I=da().clickDistance(L).on("start",D=>{const{domNode:H,nodeDragThreshold:B,transform:_,snapGrid:R,snapToGrid:k}=t();d=(H==null?void 0:H.getBoundingClientRect())||null,f=!1,B===0&&O(D),i=Cn(D.sourceEvent,{transform:_,snapGrid:R,snapToGrid:k,containerBounds:d}),x=dt(D.sourceEvent,d)}).on("drag",D=>{const{autoPanOnNodeDrag:H,transform:B,snapGrid:_,snapToGrid:R,nodeDragThreshold:k,nodeLookup:v}=t(),M=Cn(D.sourceEvent,{transform:B,snapGrid:_,snapToGrid:R,containerBounds:d});if((D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||C&&!v.has(C))&&(f=!0),!f){if(!a&&H&&p&&(a=!0,P()),!p){const A=M.xSnapped-(i.x??0),$=M.ySnapped-(i.y??0);Math.sqrt(A*A+$*$)>k&&O(D)}(i.x!==M.xSnapped||i.y!==M.ySnapped)&&c&&p&&(x=dt(D.sourceEvent,d),T(M,D.sourceEvent))}}).on("end",D=>{if(!(!p||f)&&(a=!1,p=!1,cancelAnimationFrame(l),c.size>0)){const{nodeLookup:H,updateNodePositions:B,onNodeDragStop:_,onSelectionDragStop:R}=t();if(B(c,!1),r||_||!C&&R){const[k,v]=yo({nodeId:C,dragItems:c,nodeLookup:H,dragging:!1});r==null||r(D.sourceEvent,c,k,v),_==null||_(D.sourceEvent,k,v),C||R==null||R(D.sourceEvent,v)}}}).filter(D=>{const H=D.target;return!D.button&&(!y||!Di(H,`.${y}`,b))&&(!S||Di(H,S,b))});m.call(I)}function j(){m==null||m.on(".drag",null)}return{update:h,destroy:j}}function E5(e,t,n){const s=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Nn(r,on(i))>0&&s.push(i);return s}const y5=250;function S5(e,t,n,s){var c,a;let r=[],i=1/0;const l=E5(e,n,t+y5);for(const x of l){const d=[...((c=x.internals.handleBounds)==null?void 0:c.source)??[],...((a=x.internals.handleBounds)==null?void 0:a.target)??[]];for(const p of d){if(s.nodeId===p.nodeId&&s.type===p.type&&s.id===p.id)continue;const{x:m,y:f}=Tn(x,p,p.position,!0),h=Math.sqrt(Math.pow(m-e.x,2)+Math.pow(f-e.y,2));h>t||(h<i?(r=[{...p,x:m,y:f}],i=h):h===i&&r.push({...p,x:m,y:f}))}}if(!r.length)return null;if(r.length>1){const x=s.type==="source"?"target":"source";return r.find(d=>d.type===x)??r[0]}return r[0]}function Wa(e,t,n,s,r,i=!1){var x,d,p;const l=s.get(e);if(!l)return null;const c=r==="strict"?(x=l.internals.handleBounds)==null?void 0:x[t]:[...((d=l.internals.handleBounds)==null?void 0:d.source)??[],...((p=l.internals.handleBounds)==null?void 0:p.target)??[]],a=(n?c==null?void 0:c.find(m=>m.id===n):c==null?void 0:c[0])??null;return a&&i?{...a,...Tn(l,a,a.position,!0)}:a}function Ya(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function R5(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ga=()=>!0;function C5(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:r,edgeUpdaterType:i,isTarget:l,domNode:c,nodeLookup:a,lib:x,autoPanOnConnect:d,flowId:p,panBy:m,cancelConnection:f,onConnectStart:h,onConnect:j,onConnectEnd:y,isValidConnection:S=Ga,onReconnectEnd:b,updateConnection:E,getTransform:C,getFromHandle:L,autoPanSpeed:T}){const P=Ta(e.target);let O=0,I;const{x:D,y:H}=dt(e),B=P==null?void 0:P.elementFromPoint(D,H),_=Ya(i,B),R=c==null?void 0:c.getBoundingClientRect();if(!R||!_)return;const k=Wa(r,_,s,a,t);if(!k)return;let v=dt(e,R),M=!1,A=null,$=!1,V=null;function F(){if(!d||!R)return;const[fe,ke]=_a(v,R,T);m({x:fe,y:ke}),O=requestAnimationFrame(F)}const W={...k,nodeId:r,type:_,position:k.position},ee=a.get(r),se={inProgress:!0,isValid:null,from:Tn(ee,W,U.Left,!0),fromHandle:W,fromPosition:W.position,fromNode:ee,to:v,toHandle:null,toPosition:bi[W.position],toNode:null};E(se);let oe=se;h==null||h(e,{nodeId:r,handleId:s,handleType:_});function J(fe){if(!L()||!W){le(fe);return}const ke=C();v=dt(fe,R),I=S5(Fn(v,ke,!1,[1,1]),n,a,W),M||(F(),M=!0);const de=Ka(fe,{handle:I,connectionMode:t,fromNodeId:r,fromHandleId:s,fromType:l?"target":"source",isValidConnection:S,doc:P,lib:x,flowId:p,nodeLookup:a});V=de.handleDomNode,A=de.connection,$=R5(!!I,de.isValid);const G={...oe,isValid:$,to:I&&$?_s({x:I.x,y:I.y},ke):v,toHandle:de.toHandle,toPosition:$&&de.toHandle?de.toHandle.position:bi[W.position],toNode:de.toHandle?a.get(de.toHandle.nodeId):null};$&&I&&oe.toHandle&&G.toHandle&&oe.toHandle.type===G.toHandle.type&&oe.toHandle.nodeId===G.toHandle.nodeId&&oe.toHandle.id===G.toHandle.id&&oe.to.x===G.to.x&&oe.to.y===G.to.y||(E(G),oe=G)}function le(fe){(I||V)&&A&&$&&(j==null||j(A));const{inProgress:ke,...de}=oe,G={...de,toPosition:oe.toHandle?oe.toPosition:null};y==null||y(fe,G),i&&(b==null||b(fe,G)),f(),cancelAnimationFrame(O),M=!1,$=!1,A=null,V=null,P.removeEventListener("mousemove",J),P.removeEventListener("mouseup",le),P.removeEventListener("touchmove",J),P.removeEventListener("touchend",le)}P.addEventListener("mousemove",J),P.addEventListener("mouseup",le),P.addEventListener("touchmove",J),P.addEventListener("touchend",le)}function Ka(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:r,fromType:i,doc:l,lib:c,flowId:a,isValidConnection:x=Ga,nodeLookup:d}){const p=i==="target",m=t?l.querySelector(`.${c}-flow__handle[data-id="${a}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:f,y:h}=dt(e),j=l.elementFromPoint(f,h),y=j!=null&&j.classList.contains(`${c}-flow__handle`)?j:m,S={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const b=Ya(void 0,y),E=y.getAttribute("data-nodeid"),C=y.getAttribute("data-handleid"),L=y.classList.contains("connectable"),T=y.classList.contains("connectableend");if(!E||!b)return S;const P={source:p?E:s,sourceHandle:p?C:r,target:p?s:E,targetHandle:p?r:C};S.connection=P;const I=L&&T&&(n===Vt.Strict?p&&b==="source"||!p&&b==="target":E!==s||C!==r);S.isValid=I&&x(P),S.toHandle=Wa(E,b,C,d,n,!1)}return S}const qo={onPointerDown:C5,isValid:Ka};function w5({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const r=We(e);function i({translateExtent:c,width:a,height:x,zoomStep:d=10,pannable:p=!0,zoomable:m=!0,inversePan:f=!1}){const h=E=>{const C=n();if(E.sourceEvent.type!=="wheel"||!t)return;const L=-E.sourceEvent.deltaY*(E.sourceEvent.deltaMode===1?.05:E.sourceEvent.deltaMode?1:.002)*d,T=C[2]*Math.pow(2,L);t.scaleTo(T)};let j=[0,0];const y=E=>{(E.sourceEvent.type==="mousedown"||E.sourceEvent.type==="touchstart")&&(j=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY])},S=E=>{const C=n();if(E.sourceEvent.type!=="mousemove"&&E.sourceEvent.type!=="touchmove"||!t)return;const L=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY],T=[L[0]-j[0],L[1]-j[1]];j=L;const P=s()*Math.max(C[2],Math.log(C[2]))*(f?-1:1),O={x:C[0]-T[0]*P,y:C[1]-T[1]*P},I=[[0,0],[a,x]];t.setViewportConstrained({x:O.x,y:O.y,zoom:C[2]},I,c)},b=Sa().on("start",y).on("zoom",p?S:null).on("zoom.wheel",m?h:null);r.call(b,{})}function l(){r.on("zoom",null)}return{update:i,destroy:l,pointer:Ue}}const b5=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Us=e=>({x:e.x,y:e.y,zoom:e.k}),So=({x:e,y:t,zoom:n})=>Gs.translate(e,t).scale(n),Xt=(e,t)=>e.target.closest(`.${t}`),qa=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ro=(e,t=0,n=()=>{})=>{const s=typeof t=="number"&&t>0;return s||n(),s?e.transition().duration(t).on("end",n):e},Xa=e=>{const t=e.ctrlKey&&Ps()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function v5({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:l,onPanZoomStart:c,onPanZoom:a,onPanZoomEnd:x}){return d=>{if(Xt(d,t))return!1;d.preventDefault(),d.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(d.ctrlKey&&l){const y=Ue(d),S=Xa(d),b=p*Math.pow(2,S);s.scaleTo(n,b,y,d);return}const m=d.deltaMode===1?20:1;let f=r===It.Vertical?0:d.deltaX*m,h=r===It.Horizontal?0:d.deltaY*m;!Ps()&&d.shiftKey&&r!==It.Vertical&&(f=d.deltaY*m,h=0),s.translateBy(n,-(f/p)*i,-(h/p)*i,{internal:!0});const j=Us(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,c==null||c(d,j)),e.isPanScrolling&&(a==null||a(d,j),e.panScrollTimeout=setTimeout(()=>{x==null||x(d,j),e.isPanScrolling=!1},150))}}function k5({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,r){const i=s.type==="wheel",l=!t&&i&&!s.ctrlKey,c=Xt(s,e);if(s.ctrlKey&&i&&c&&s.preventDefault(),l||c)return null;s.preventDefault(),n.call(this,s,r)}}function M5({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{var i,l,c;if((i=s.sourceEvent)!=null&&i.internal)return;const r=Us(s.transform);e.mouseButton=((l=s.sourceEvent)==null?void 0:l.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((c=s.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(s.sourceEvent,r))}}function _5({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:r}){return i=>{var l,c;e.usedRightMouseButton=!!(n&&qa(t,e.mouseButton??0)),(l=i.sourceEvent)!=null&&l.sync||s([i.transform.x,i.transform.y,i.transform.k]),r&&!((c=i.sourceEvent)!=null&&c.internal)&&(r==null||r(i.sourceEvent,Us(i.transform)))}}function P5({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:r,onPaneContextMenu:i}){return l=>{var c;if(!((c=l.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,i&&qa(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&i(l.sourceEvent),e.usedRightMouseButton=!1,s(!1),r&&b5(e.prevViewport,l.transform))){const a=Us(l.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(l.sourceEvent,a)},n?150:0)}}}function L5({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:s,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:l,noWheelClassName:c,noPanClassName:a,lib:x}){return d=>{var h;const p=e||t,m=n&&d.ctrlKey;if(d.button===1&&d.type==="mousedown"&&(Xt(d,`${x}-flow__node`)||Xt(d,`${x}-flow__edge`)))return!0;if(!s&&!p&&!r&&!i&&!n||l||Xt(d,c)&&d.type==="wheel"||Xt(d,a)&&(d.type!=="wheel"||r&&d.type==="wheel"&&!e)||!n&&d.ctrlKey&&d.type==="wheel")return!1;if(!n&&d.type==="touchstart"&&((h=d.touches)==null?void 0:h.length)>1)return d.preventDefault(),!1;if(!p&&!r&&!m&&d.type==="wheel"||!s&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(s)&&!s.includes(d.button)&&d.type==="mousedown")return!1;const f=Array.isArray(s)&&s.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||d.type==="wheel")&&f}}function N5({domNode:e,minZoom:t,maxZoom:n,paneClickDistance:s,translateExtent:r,viewport:i,onPanZoom:l,onPanZoomStart:c,onPanZoomEnd:a,onDraggingChange:x}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),m=Sa().clickDistance(!Je(s)||s<0?0:s).scaleExtent([t,n]).translateExtent(r),f=We(e).call(m);E({x:i.x,y:i.y,zoom:sn(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const h=f.on("wheel.zoom"),j=f.on("dblclick.zoom");m.wheelDelta(Xa);function y(B,_){return f?new Promise(R=>{m==null||m.transform(Ro(f,_==null?void 0:_.duration,()=>R(!0)),B)}):Promise.resolve(!1)}function S({noWheelClassName:B,noPanClassName:_,onPaneContextMenu:R,userSelectionActive:k,panOnScroll:v,panOnDrag:M,panOnScrollMode:A,panOnScrollSpeed:$,preventScrolling:V,zoomOnPinch:F,zoomOnScroll:W,zoomOnDoubleClick:ee,zoomActivationKeyPressed:te,lib:se,onTransformChange:oe}){k&&!d.isZoomingOrPanning&&b();const le=v&&!te&&!k?v5({zoomPanValues:d,noWheelClassName:B,d3Selection:f,d3Zoom:m,panOnScrollMode:A,panOnScrollSpeed:$,zoomOnPinch:F,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:a}):k5({noWheelClassName:B,preventScrolling:V,d3ZoomHandler:h});if(f.on("wheel.zoom",le,{passive:!1}),!k){const ke=M5({zoomPanValues:d,onDraggingChange:x,onPanZoomStart:c});m.on("start",ke);const de=_5({zoomPanValues:d,panOnDrag:M,onPaneContextMenu:!!R,onPanZoom:l,onTransformChange:oe});m.on("zoom",de);const G=P5({zoomPanValues:d,panOnDrag:M,panOnScroll:v,onPaneContextMenu:R,onPanZoomEnd:a,onDraggingChange:x});m.on("end",G)}const fe=L5({zoomActivationKeyPressed:te,panOnDrag:M,zoomOnScroll:W,panOnScroll:v,zoomOnDoubleClick:ee,zoomOnPinch:F,userSelectionActive:k,noPanClassName:_,noWheelClassName:B,lib:se});m.filter(fe),ee?f.on("dblclick.zoom",j):f.on("dblclick.zoom",null)}function b(){m.on("zoom",null)}async function E(B,_,R){const k=So(B),v=m==null?void 0:m.constrain()(k,_,R);return v&&await y(v),new Promise(M=>M(v))}async function C(B,_){const R=So(B);return await y(R,_),new Promise(k=>k(R))}function L(B){if(f){const _=So(B),R=f.property("__zoom");(R.k!==B.zoom||R.x!==B.x||R.y!==B.y)&&(m==null||m.transform(f,_,null,{sync:!0}))}}function T(){const B=f?ya(f.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function P(B,_){return f?new Promise(R=>{m==null||m.scaleTo(Ro(f,_==null?void 0:_.duration,()=>R(!0)),B)}):Promise.resolve(!1)}function O(B,_){return f?new Promise(R=>{m==null||m.scaleBy(Ro(f,_==null?void 0:_.duration,()=>R(!0)),B)}):Promise.resolve(!1)}function I(B){m==null||m.scaleExtent(B)}function D(B){m==null||m.translateExtent(B)}function H(B){const _=!Je(B)||B<0?0:B;m==null||m.clickDistance(_)}return{update:S,destroy:b,setViewport:C,setViewportConstrained:E,getViewport:T,scaleTo:P,scaleBy:O,setScaleExtent:I,setTranslateExtent:D,syncViewport:L,setClickDistance:H}}var wn;(function(e){e.Line="line",e.Handle="handle"})(wn||(wn={}));function T5({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:r,affectsY:i}){const l=e-t,c=n-s,a=[l>0?1:l<0?-1:0,c>0?1:c<0?-1:0];return l&&r&&(a[0]=a[0]*-1),c&&i&&(a[1]=a[1]*-1),a}function $5(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),s=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:s,affectsY:r}}function Et(e,t){return Math.max(0,t-e)}function yt(e,t){return Math.max(0,e-t)}function Jn(e,t,n){return Math.max(0,t-e,e-n)}function zi(e,t){return e?!t:t}function A5(e,t,n,s,r,i,l,c){let{affectsX:a,affectsY:x}=t;const{isHorizontal:d,isVertical:p}=t,m=d&&p,{xSnapped:f,ySnapped:h}=n,{minWidth:j,maxWidth:y,minHeight:S,maxHeight:b}=s,{x:E,y:C,width:L,height:T,aspectRatio:P}=e;let O=Math.floor(d?f-e.pointerX:0),I=Math.floor(p?h-e.pointerY:0);const D=L+(a?-O:O),H=T+(x?-I:I),B=-i[0]*L,_=-i[1]*T;let R=Jn(D,j,y),k=Jn(H,S,b);if(l){let A=0,$=0;a&&O<0?A=Et(E+O+B,l[0][0]):!a&&O>0&&(A=yt(E+D+B,l[1][0])),x&&I<0?$=Et(C+I+_,l[0][1]):!x&&I>0&&($=yt(C+H+_,l[1][1])),R=Math.max(R,A),k=Math.max(k,$)}if(c){let A=0,$=0;a&&O>0?A=yt(E+O,c[0][0]):!a&&O<0&&(A=Et(E+D,c[1][0])),x&&I>0?$=yt(C+I,c[0][1]):!x&&I<0&&($=Et(C+H,c[1][1])),R=Math.max(R,A),k=Math.max(k,$)}if(r){if(d){const A=Jn(D/P,S,b)*P;if(R=Math.max(R,A),l){let $=0;!a&&!x||a&&!x&&m?$=yt(C+_+D/P,l[1][1])*P:$=Et(C+_+(a?O:-O)/P,l[0][1])*P,R=Math.max(R,$)}if(c){let $=0;!a&&!x||a&&!x&&m?$=Et(C+D/P,c[1][1])*P:$=yt(C+(a?O:-O)/P,c[0][1])*P,R=Math.max(R,$)}}if(p){const A=Jn(H*P,j,y)/P;if(k=Math.max(k,A),l){let $=0;!a&&!x||x&&!a&&m?$=yt(E+H*P+B,l[1][0])/P:$=Et(E+(x?I:-I)*P+B,l[0][0])/P,k=Math.max(k,$)}if(c){let $=0;!a&&!x||x&&!a&&m?$=Et(E+H*P,c[1][0])/P:$=yt(E+(x?I:-I)*P,c[0][0])/P,k=Math.max(k,$)}}}I=I+(I<0?k:-k),O=O+(O<0?R:-R),r&&(m?D>H*P?I=(zi(a,x)?-O:O)/P:O=(zi(a,x)?-I:I)*P:d?(I=O/P,x=a):(O=I*P,a=x));const v=a?E+O:E,M=x?C+I:C;return{width:L+(a?-O:O),height:T+(x?-I:I),x:i[0]*O*(a?-1:1)+v,y:i[1]*I*(x?-1:1)+M}}const Ua={width:0,height:0,x:0,y:0},I5={...Ua,pointerX:0,pointerY:0,aspectRatio:1};function D5(e){return[[0,0],[e.measured.width,e.measured.height]]}function z5(e,t,n){const s=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,l=e.measured.height??0,c=n[0]*i,a=n[1]*l;return[[s-c,r-a],[s+i-c,r+l-a]]}function B5({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:r}){const i=We(e);function l({controlPosition:a,boundaries:x,keepAspectRatio:d,onResizeStart:p,onResize:m,onResizeEnd:f,shouldResize:h}){let j={...Ua},y={...I5};const S=$5(a);let b,E=null,C=[],L,T,P;const O=da().on("start",I=>{const{nodeLookup:D,transform:H,snapGrid:B,snapToGrid:_,nodeOrigin:R,paneDomNode:k}=n();if(b=D.get(t),!b)return;E=(k==null?void 0:k.getBoundingClientRect())??null;const{xSnapped:v,ySnapped:M}=Cn(I.sourceEvent,{transform:H,snapGrid:B,snapToGrid:_,containerBounds:E});j={width:b.measured.width??0,height:b.measured.height??0,x:b.position.x??0,y:b.position.y??0},y={...j,pointerX:v,pointerY:M,aspectRatio:j.width/j.height},L=void 0,b.parentId&&(b.extent==="parent"||b.expandParent)&&(L=D.get(b.parentId),T=L&&b.extent==="parent"?D5(L):void 0),C=[],P=void 0;for(const[A,$]of D)if($.parentId===t&&(C.push({id:A,position:{...$.position},extent:$.extent}),$.extent==="parent"||$.expandParent)){const V=z5($,b,$.origin??R);P?P=[[Math.min(V[0][0],P[0][0]),Math.min(V[0][1],P[0][1])],[Math.max(V[1][0],P[1][0]),Math.max(V[1][1],P[1][1])]]:P=V}p==null||p(I,{...j})}).on("drag",I=>{const{transform:D,snapGrid:H,snapToGrid:B,nodeOrigin:_}=n(),R=Cn(I.sourceEvent,{transform:D,snapGrid:H,snapToGrid:B,containerBounds:E}),k=[];if(!b)return;const{x:v,y:M,width:A,height:$}=j,V={},F=b.origin??_,{width:W,height:ee,x:te,y:se}=A5(y,S,R,x,d,F,T,P),oe=W!==A,J=ee!==$,le=te!==v&&oe,fe=se!==M&&J;if(!le&&!fe&&!oe&&!J)return;if((le||fe||F[0]===1||F[1]===1)&&(V.x=le?te:j.x,V.y=fe?se:j.y,j.x=V.x,j.y=V.y,C.length>0)){const ae=te-v,ue=se-M;for(const _e of C)_e.position={x:_e.position.x-ae+F[0]*(W-A),y:_e.position.y-ue+F[1]*(ee-$)},k.push(_e)}if((oe||J)&&(V.width=oe?W:j.width,V.height=J?ee:j.height,j.width=V.width,j.height=V.height),L&&b.expandParent){const ae=F[0]*(V.width??0);V.x&&V.x<ae&&(j.x=ae,y.x=y.x-(V.x-ae));const ue=F[1]*(V.height??0);V.y&&V.y<ue&&(j.y=ue,y.y=y.y-(V.y-ue))}const ke=T5({width:j.width,prevWidth:A,height:j.height,prevHeight:$,affectsX:S.affectsX,affectsY:S.affectsY}),de={...j,direction:ke};(h==null?void 0:h(I,de))!==!1&&(m==null||m(I,de),s(V,k))}).on("end",I=>{f==null||f(I,{...j}),r==null||r({...j})});i.call(O)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var Qn={exports:{}},Co={},es={exports:{}},wo={};/**
2
2
  * @license React
3
3
  * use-sync-external-store-shim.production.js
4
4
  *