diff --git a/lightrag/api/webui/assets/index-6Cgle0rM.js b/lightrag/api/webui/assets/index-DlScqWrq.js similarity index 96% rename from lightrag/api/webui/assets/index-6Cgle0rM.js rename to lightrag/api/webui/assets/index-DlScqWrq.js index 79036e8b..d4fac364 100644 --- a/lightrag/api/webui/assets/index-6Cgle0rM.js +++ b/lightrag/api/webui/assets/index-DlScqWrq.js @@ -301,7 +301,7 @@ You can add a description to the \`${Rs}\` by passing a \`${DU}\` component as a Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Rs}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. -For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return E.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},WK=RU,YK=CU,zU=_U,BU=NU,UU=MU,jU=FU,GU=IU,HU=LU;const KK=["top","right","bottom","left"],No=Math.min,Jn=Math.max,mf=Math.round,xd=Math.floor,aa=e=>({x:e,y:e}),XK={left:"right",right:"left",bottom:"top",top:"bottom"},ZK={start:"end",end:"start"};function bk(e,t,n){return Jn(e,No(t,n))}function Ga(e,t){return typeof e=="function"?e(t):e}function Ha(e){return e.split("-")[0]}function Vs(e){return e.split("-")[1]}function $0(e){return e==="x"?"y":"x"}function q0(e){return e==="y"?"height":"width"}function Oo(e){return["top","bottom"].includes(Ha(e))?"y":"x"}function V0(e){return $0(Oo(e))}function QK(e,t,n){n===void 0&&(n=!1);const r=Vs(e),a=V0(e),o=q0(a);let s=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=bf(s)),[s,bf(s)]}function JK(e){const t=bf(e);return[yk(e),t,yk(t)]}function yk(e){return e.replace(/start|end/g,t=>ZK[t])}function eX(e,t,n){const r=["left","right"],a=["right","left"],o=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?a:r:t?r:a;case"left":case"right":return t?o:s;default:return[]}}function tX(e,t,n,r){const a=Vs(e);let o=eX(Ha(e),n==="start",r);return a&&(o=o.map(s=>s+"-"+a),t&&(o=o.concat(o.map(yk)))),o}function bf(e){return e.replace(/left|right|bottom|top/g,t=>XK[t])}function nX(e){return{top:0,right:0,bottom:0,left:0,...e}}function $U(e){return typeof e!="number"?nX(e):{top:e,right:e,bottom:e,left:e}}function yf(e){const{x:t,y:n,width:r,height:a}=e;return{width:r,height:a,top:n,left:t,right:t+r,bottom:n+a,x:t,y:n}}function $_(e,t,n){let{reference:r,floating:a}=e;const o=Oo(t),s=V0(t),u=q0(s),c=Ha(t),d=o==="y",p=r.x+r.width/2-a.width/2,g=r.y+r.height/2-a.height/2,m=r[u]/2-a[u]/2;let b;switch(c){case"top":b={x:p,y:r.y-a.height};break;case"bottom":b={x:p,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:g};break;case"left":b={x:r.x-a.width,y:g};break;default:b={x:r.x,y:r.y}}switch(Vs(t)){case"start":b[s]-=m*(n&&d?-1:1);break;case"end":b[s]+=m*(n&&d?-1:1);break}return b}const rX=async(e,t,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:o=[],platform:s}=n,u=o.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(t));let d=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:p,y:g}=$_(d,r,c),m=r,b={},y=0;for(let S=0;S({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:a,rects:o,platform:s,elements:u,middlewareData:c}=t,{element:d,padding:p=0}=Ga(e,t)||{};if(d==null)return{};const g=$U(p),m={x:n,y:r},b=V0(a),y=q0(b),S=await s.getDimensions(d),k=b==="y",R=k?"top":"left",x=k?"bottom":"right",A=k?"clientHeight":"clientWidth",N=o.reference[y]+o.reference[b]-m[b]-o.floating[y],O=m[b]-o.reference[b],C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d));let _=C?C[A]:0;(!_||!await(s.isElement==null?void 0:s.isElement(C)))&&(_=u.floating[A]||o.floating[y]);const P=N/2-O/2,D=_/2-S[y]/2-1,L=No(g[R],D),H=No(g[x],D),$=L,U=_-S[y]-H,W=_/2-S[y]/2+P,Z=bk($,W,U),j=!c.arrow&&Vs(a)!=null&&W!==Z&&o.reference[y]/2-(W<$?L:H)-S[y]/2<0,G=j?W<$?W-$:W-U:0;return{[b]:m[b]+G,data:{[b]:Z,centerOffset:W-Z-G,...j&&{alignmentOffset:G}},reset:j}}}),oX=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:a,middlewareData:o,rects:s,initialPlacement:u,platform:c,elements:d}=t,{mainAxis:p=!0,crossAxis:g=!0,fallbackPlacements:m,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:S=!0,...k}=Ga(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const R=Ha(a),x=Oo(u),A=Ha(u)===u,N=await(c.isRTL==null?void 0:c.isRTL(d.floating)),O=m||(A||!S?[bf(u)]:JK(u)),C=y!=="none";!m&&C&&O.push(...tX(u,S,y,N));const _=[u,...O],P=await ku(t,k),D=[];let L=((r=o.flip)==null?void 0:r.overflows)||[];if(p&&D.push(P[R]),g){const W=QK(a,s,N);D.push(P[W[0]],P[W[1]])}if(L=[...L,{placement:a,overflows:D}],!D.every(W=>W<=0)){var H,$;const W=(((H=o.flip)==null?void 0:H.index)||0)+1,Z=_[W];if(Z)return{data:{index:W,overflows:L},reset:{placement:Z}};let j=($=L.filter(G=>G.overflows[0]<=0).sort((G,z)=>G.overflows[1]-z.overflows[1])[0])==null?void 0:$.placement;if(!j)switch(b){case"bestFit":{var U;const G=(U=L.filter(z=>{if(C){const Y=Oo(z.placement);return Y===x||Y==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(Y=>Y>0).reduce((Y,I)=>Y+I,0)]).sort((z,Y)=>z[1]-Y[1])[0])==null?void 0:U[0];G&&(j=G);break}case"initialPlacement":j=u;break}if(a!==j)return{reset:{placement:j}}}return{}}}};function q_(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function V_(e){return KK.some(t=>e[t]>=0)}const iX=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...a}=Ga(e,t);switch(r){case"referenceHidden":{const o=await ku(t,{...a,elementContext:"reference"}),s=q_(o,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:V_(s)}}}case"escaped":{const o=await ku(t,{...a,altBoundary:!0}),s=q_(o,n.floating);return{data:{escapedOffsets:s,escaped:V_(s)}}}default:return{}}}}};async function sX(e,t){const{placement:n,platform:r,elements:a}=e,o=await(r.isRTL==null?void 0:r.isRTL(a.floating)),s=Ha(n),u=Vs(n),c=Oo(n)==="y",d=["left","top"].includes(s)?-1:1,p=o&&c?-1:1,g=Ga(t,e);let{mainAxis:m,crossAxis:b,alignmentAxis:y}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return u&&typeof y=="number"&&(b=u==="end"?y*-1:y),c?{x:b*p,y:m*d}:{x:m*d,y:b*p}}const lX=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:a,y:o,placement:s,middlewareData:u}=t,c=await sX(t,e);return s===((n=u.offset)==null?void 0:n.placement)&&(r=u.arrow)!=null&&r.alignmentOffset?{}:{x:a+c.x,y:o+c.y,data:{...c,placement:s}}}}},uX=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:u={fn:k=>{let{x:R,y:x}=k;return{x:R,y:x}}},...c}=Ga(e,t),d={x:n,y:r},p=await ku(t,c),g=Oo(Ha(a)),m=$0(g);let b=d[m],y=d[g];if(o){const k=m==="y"?"top":"left",R=m==="y"?"bottom":"right",x=b+p[k],A=b-p[R];b=bk(x,b,A)}if(s){const k=g==="y"?"top":"left",R=g==="y"?"bottom":"right",x=y+p[k],A=y-p[R];y=bk(x,y,A)}const S=u.fn({...t,[m]:b,[g]:y});return{...S,data:{x:S.x-n,y:S.y-r,enabled:{[m]:o,[g]:s}}}}}},cX=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:a,rects:o,middlewareData:s}=t,{offset:u=0,mainAxis:c=!0,crossAxis:d=!0}=Ga(e,t),p={x:n,y:r},g=Oo(a),m=$0(g);let b=p[m],y=p[g];const S=Ga(u,t),k=typeof S=="number"?{mainAxis:S,crossAxis:0}:{mainAxis:0,crossAxis:0,...S};if(c){const A=m==="y"?"height":"width",N=o.reference[m]-o.floating[A]+k.mainAxis,O=o.reference[m]+o.reference[A]-k.mainAxis;bO&&(b=O)}if(d){var R,x;const A=m==="y"?"width":"height",N=["top","left"].includes(Ha(a)),O=o.reference[g]-o.floating[A]+(N&&((R=s.offset)==null?void 0:R[g])||0)+(N?0:k.crossAxis),C=o.reference[g]+o.reference[A]+(N?0:((x=s.offset)==null?void 0:x[g])||0)-(N?k.crossAxis:0);yC&&(y=C)}return{[m]:b,[g]:y}}}},dX=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:a,rects:o,platform:s,elements:u}=t,{apply:c=()=>{},...d}=Ga(e,t),p=await ku(t,d),g=Ha(a),m=Vs(a),b=Oo(a)==="y",{width:y,height:S}=o.floating;let k,R;g==="top"||g==="bottom"?(k=g,R=m===(await(s.isRTL==null?void 0:s.isRTL(u.floating))?"start":"end")?"left":"right"):(R=g,k=m==="end"?"top":"bottom");const x=S-p.top-p.bottom,A=y-p.left-p.right,N=No(S-p[k],x),O=No(y-p[R],A),C=!t.middlewareData.shift;let _=N,P=O;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=A),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(_=x),C&&!m){const L=Jn(p.left,0),H=Jn(p.right,0),$=Jn(p.top,0),U=Jn(p.bottom,0);b?P=y-2*(L!==0||H!==0?L+H:Jn(p.left,p.right)):_=S-2*($!==0||U!==0?$+U:Jn(p.top,p.bottom))}await c({...t,availableWidth:P,availableHeight:_});const D=await s.getDimensions(u.floating);return y!==D.width||S!==D.height?{reset:{rects:!0}}:{}}}};function ap(){return typeof window<"u"}function Ws(e){return qU(e)?(e.nodeName||"").toLowerCase():"#document"}function nr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sa(e){var t;return(t=(qU(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function qU(e){return ap()?e instanceof Node||e instanceof nr(e).Node:!1}function Ur(e){return ap()?e instanceof Element||e instanceof nr(e).Element:!1}function oa(e){return ap()?e instanceof HTMLElement||e instanceof nr(e).HTMLElement:!1}function W_(e){return!ap()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof nr(e).ShadowRoot}function Vu(e){const{overflow:t,overflowX:n,overflowY:r,display:a}=jr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(a)}function fX(e){return["table","td","th"].includes(Ws(e))}function op(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function W0(e){const t=Y0(),n=Ur(e)?jr(e):e;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function pX(e){let t=Io(e);for(;oa(t)&&!Is(t);){if(W0(t))return t;if(op(t))return null;t=Io(t)}return null}function Y0(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Is(e){return["html","body","#document"].includes(Ws(e))}function jr(e){return nr(e).getComputedStyle(e)}function ip(e){return Ur(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Io(e){if(Ws(e)==="html")return e;const t=e.assignedSlot||e.parentNode||W_(e)&&e.host||sa(e);return W_(t)?t.host:t}function VU(e){const t=Io(e);return Is(t)?e.ownerDocument?e.ownerDocument.body:e.body:oa(t)&&Vu(t)?t:VU(t)}function Tu(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=VU(e),o=a===((r=e.ownerDocument)==null?void 0:r.body),s=nr(a);if(o){const u=vk(s);return t.concat(s,s.visualViewport||[],Vu(a)?a:[],u&&n?Tu(u):[])}return t.concat(a,Tu(a,[],n))}function vk(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function WU(e){const t=jr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const a=oa(e),o=a?e.offsetWidth:n,s=a?e.offsetHeight:r,u=mf(n)!==o||mf(r)!==s;return u&&(n=o,r=s),{width:n,height:r,$:u}}function K0(e){return Ur(e)?e:e.contextElement}function Cs(e){const t=K0(e);if(!oa(t))return aa(1);const n=t.getBoundingClientRect(),{width:r,height:a,$:o}=WU(t);let s=(o?mf(n.width):n.width)/r,u=(o?mf(n.height):n.height)/a;return(!s||!Number.isFinite(s))&&(s=1),(!u||!Number.isFinite(u))&&(u=1),{x:s,y:u}}const gX=aa(0);function YU(e){const t=nr(e);return!Y0()||!t.visualViewport?gX:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function hX(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==nr(e)?!1:t}function yi(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),o=K0(e);let s=aa(1);t&&(r?Ur(r)&&(s=Cs(r)):s=Cs(e));const u=hX(o,n,r)?YU(o):aa(0);let c=(a.left+u.x)/s.x,d=(a.top+u.y)/s.y,p=a.width/s.x,g=a.height/s.y;if(o){const m=nr(o),b=r&&Ur(r)?nr(r):r;let y=m,S=vk(y);for(;S&&r&&b!==y;){const k=Cs(S),R=S.getBoundingClientRect(),x=jr(S),A=R.left+(S.clientLeft+parseFloat(x.paddingLeft))*k.x,N=R.top+(S.clientTop+parseFloat(x.paddingTop))*k.y;c*=k.x,d*=k.y,p*=k.x,g*=k.y,c+=A,d+=N,y=nr(S),S=vk(y)}}return yf({width:p,height:g,x:c,y:d})}function X0(e,t){const n=ip(e).scrollLeft;return t?t.left+n:yi(sa(e)).left+n}function KU(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=r.left+t.scrollLeft-(n?0:X0(e,r)),o=r.top+t.scrollTop;return{x:a,y:o}}function mX(e){let{elements:t,rect:n,offsetParent:r,strategy:a}=e;const o=a==="fixed",s=sa(r),u=t?op(t.floating):!1;if(r===s||u&&o)return n;let c={scrollLeft:0,scrollTop:0},d=aa(1);const p=aa(0),g=oa(r);if((g||!g&&!o)&&((Ws(r)!=="body"||Vu(s))&&(c=ip(r)),oa(r))){const b=yi(r);d=Cs(r),p.x=b.x+r.clientLeft,p.y=b.y+r.clientTop}const m=s&&!g&&!o?KU(s,c,!0):aa(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+p.x+m.x,y:n.y*d.y-c.scrollTop*d.y+p.y+m.y}}function bX(e){return Array.from(e.getClientRects())}function yX(e){const t=sa(e),n=ip(e),r=e.ownerDocument.body,a=Jn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Jn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+X0(e);const u=-n.scrollTop;return jr(r).direction==="rtl"&&(s+=Jn(t.clientWidth,r.clientWidth)-a),{width:a,height:o,x:s,y:u}}function vX(e,t){const n=nr(e),r=sa(e),a=n.visualViewport;let o=r.clientWidth,s=r.clientHeight,u=0,c=0;if(a){o=a.width,s=a.height;const d=Y0();(!d||d&&t==="fixed")&&(u=a.offsetLeft,c=a.offsetTop)}return{width:o,height:s,x:u,y:c}}function SX(e,t){const n=yi(e,!0,t==="fixed"),r=n.top+e.clientTop,a=n.left+e.clientLeft,o=oa(e)?Cs(e):aa(1),s=e.clientWidth*o.x,u=e.clientHeight*o.y,c=a*o.x,d=r*o.y;return{width:s,height:u,x:c,y:d}}function Y_(e,t,n){let r;if(t==="viewport")r=vX(e,n);else if(t==="document")r=yX(sa(e));else if(Ur(t))r=SX(t,n);else{const a=YU(e);r={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return yf(r)}function XU(e,t){const n=Io(e);return n===t||!Ur(n)||Is(n)?!1:jr(n).position==="fixed"||XU(n,t)}function EX(e,t){const n=t.get(e);if(n)return n;let r=Tu(e,[],!1).filter(u=>Ur(u)&&Ws(u)!=="body"),a=null;const o=jr(e).position==="fixed";let s=o?Io(e):e;for(;Ur(s)&&!Is(s);){const u=jr(s),c=W0(s);!c&&u.position==="fixed"&&(a=null),(o?!c&&!a:!c&&u.position==="static"&&!!a&&["absolute","fixed"].includes(a.position)||Vu(s)&&!c&&XU(e,s))?r=r.filter(p=>p!==s):a=u,s=Io(s)}return t.set(e,r),r}function wX(e){let{element:t,boundary:n,rootBoundary:r,strategy:a}=e;const s=[...n==="clippingAncestors"?op(t)?[]:EX(t,this._c):[].concat(n),r],u=s[0],c=s.reduce((d,p)=>{const g=Y_(t,p,a);return d.top=Jn(g.top,d.top),d.right=No(g.right,d.right),d.bottom=No(g.bottom,d.bottom),d.left=Jn(g.left,d.left),d},Y_(t,u,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function xX(e){const{width:t,height:n}=WU(e);return{width:t,height:n}}function kX(e,t,n){const r=oa(t),a=sa(t),o=n==="fixed",s=yi(e,!0,o,t);let u={scrollLeft:0,scrollTop:0};const c=aa(0);if(r||!r&&!o)if((Ws(t)!=="body"||Vu(a))&&(u=ip(t)),r){const m=yi(t,!0,o,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else a&&(c.x=X0(a));const d=a&&!r&&!o?KU(a,u):aa(0),p=s.left+u.scrollLeft-c.x-d.x,g=s.top+u.scrollTop-c.y-d.y;return{x:p,y:g,width:s.width,height:s.height}}function im(e){return jr(e).position==="static"}function K_(e,t){if(!oa(e)||jr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return sa(e)===n&&(n=n.ownerDocument.body),n}function ZU(e,t){const n=nr(e);if(op(e))return n;if(!oa(e)){let a=Io(e);for(;a&&!Is(a);){if(Ur(a)&&!im(a))return a;a=Io(a)}return n}let r=K_(e,t);for(;r&&fX(r)&&im(r);)r=K_(r,t);return r&&Is(r)&&im(r)&&!W0(r)?n:r||pX(e)||n}const TX=async function(e){const t=this.getOffsetParent||ZU,n=this.getDimensions,r=await n(e.floating);return{reference:kX(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function AX(e){return jr(e).direction==="rtl"}const RX={convertOffsetParentRelativeRectToViewportRelativeRect:mX,getDocumentElement:sa,getClippingRect:wX,getOffsetParent:ZU,getElementRects:TX,getClientRects:bX,getDimensions:xX,getScale:Cs,isElement:Ur,isRTL:AX};function QU(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function CX(e,t){let n=null,r;const a=sa(e);function o(){var u;clearTimeout(r),(u=n)==null||u.disconnect(),n=null}function s(u,c){u===void 0&&(u=!1),c===void 0&&(c=1),o();const d=e.getBoundingClientRect(),{left:p,top:g,width:m,height:b}=d;if(u||t(),!m||!b)return;const y=xd(g),S=xd(a.clientWidth-(p+m)),k=xd(a.clientHeight-(g+b)),R=xd(p),A={rootMargin:-y+"px "+-S+"px "+-k+"px "+-R+"px",threshold:Jn(0,No(1,c))||1};let N=!0;function O(C){const _=C[0].intersectionRatio;if(_!==c){if(!N)return s();_?s(!1,_):r=setTimeout(()=>{s(!1,1e-7)},1e3)}_===1&&!QU(d,e.getBoundingClientRect())&&s(),N=!1}try{n=new IntersectionObserver(O,{...A,root:a.ownerDocument})}catch{n=new IntersectionObserver(O,A)}n.observe(e)}return s(!0),o}function _X(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=K0(e),p=a||o?[...d?Tu(d):[],...Tu(t)]:[];p.forEach(R=>{a&&R.addEventListener("scroll",n,{passive:!0}),o&&R.addEventListener("resize",n)});const g=d&&u?CX(d,n):null;let m=-1,b=null;s&&(b=new ResizeObserver(R=>{let[x]=R;x&&x.target===d&&b&&(b.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var A;(A=b)==null||A.observe(t)})),n()}),d&&!c&&b.observe(d),b.observe(t));let y,S=c?yi(e):null;c&&k();function k(){const R=yi(e);S&&!QU(S,R)&&n(),S=R,y=requestAnimationFrame(k)}return n(),()=>{var R;p.forEach(x=>{a&&x.removeEventListener("scroll",n),o&&x.removeEventListener("resize",n)}),g==null||g(),(R=b)==null||R.disconnect(),b=null,c&&cancelAnimationFrame(y)}}const NX=lX,OX=uX,IX=oX,DX=dX,LX=iX,X_=aX,MX=cX,PX=(e,t,n)=>{const r=new Map,a={platform:RX,...n},o={...a.platform,_c:r};return rX(e,t,{...a,platform:o})};var Qd=typeof document<"u"?E.useLayoutEffect:E.useEffect;function vf(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!vf(e[r],t[r]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,a[r]))return!1;for(r=n;r--!==0;){const o=a[r];if(!(o==="_owner"&&e.$$typeof)&&!vf(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function JU(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Z_(e,t){const n=JU(e);return Math.round(t*n)/n}function sm(e){const t=E.useRef(e);return Qd(()=>{t.current=e}),t}function FX(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:o,floating:s}={},transform:u=!0,whileElementsMounted:c,open:d}=e,[p,g]=E.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,b]=E.useState(r);vf(m,r)||b(r);const[y,S]=E.useState(null),[k,R]=E.useState(null),x=E.useCallback(z=>{z!==C.current&&(C.current=z,S(z))},[]),A=E.useCallback(z=>{z!==_.current&&(_.current=z,R(z))},[]),N=o||y,O=s||k,C=E.useRef(null),_=E.useRef(null),P=E.useRef(p),D=c!=null,L=sm(c),H=sm(a),$=sm(d),U=E.useCallback(()=>{if(!C.current||!_.current)return;const z={placement:t,strategy:n,middleware:m};H.current&&(z.platform=H.current),PX(C.current,_.current,z).then(Y=>{const I={...Y,isPositioned:$.current!==!1};W.current&&!vf(P.current,I)&&(P.current=I,Gu.flushSync(()=>{g(I)}))})},[m,t,n,H,$]);Qd(()=>{d===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,g(z=>({...z,isPositioned:!1})))},[d]);const W=E.useRef(!1);Qd(()=>(W.current=!0,()=>{W.current=!1}),[]),Qd(()=>{if(N&&(C.current=N),O&&(_.current=O),N&&O){if(L.current)return L.current(N,O,U);U()}},[N,O,U,L,D]);const Z=E.useMemo(()=>({reference:C,floating:_,setReference:x,setFloating:A}),[x,A]),j=E.useMemo(()=>({reference:N,floating:O}),[N,O]),G=E.useMemo(()=>{const z={position:n,left:0,top:0};if(!j.floating)return z;const Y=Z_(j.floating,p.x),I=Z_(j.floating,p.y);return u?{...z,transform:"translate("+Y+"px, "+I+"px)",...JU(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:I}},[n,u,j.floating,p.x,p.y]);return E.useMemo(()=>({...p,update:U,refs:Z,elements:j,floatingStyles:G}),[p,U,Z,j,G])}const zX=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:a}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?X_({element:r.current,padding:a}).fn(n):{}:r?X_({element:r,padding:a}).fn(n):{}}}},BX=(e,t)=>({...NX(e),options:[e,t]}),UX=(e,t)=>({...OX(e),options:[e,t]}),jX=(e,t)=>({...MX(e),options:[e,t]}),GX=(e,t)=>({...IX(e),options:[e,t]}),HX=(e,t)=>({...DX(e),options:[e,t]}),$X=(e,t)=>({...LX(e),options:[e,t]}),qX=(e,t)=>({...zX(e),options:[e,t]});var VX="Arrow",e3=E.forwardRef((e,t)=>{const{children:n,width:r=10,height:a=5,...o}=e;return w.jsx(Ze.svg,{...o,ref:t,width:r,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:w.jsx("polygon",{points:"0,0 30,0 15,10"})})});e3.displayName=VX;var WX=e3;function t3(e){const[t,n]=E.useState(void 0);return Rn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let s,u;if("borderBoxSize"in o){const c=o.borderBoxSize,d=Array.isArray(c)?c[0]:c;s=d.inlineSize,u=d.blockSize}else s=e.offsetWidth,u=e.offsetHeight;n({width:s,height:u})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Z0="Popper",[n3,Ys]=wr(Z0),[YX,r3]=n3(Z0),a3=e=>{const{__scopePopper:t,children:n}=e,[r,a]=E.useState(null);return w.jsx(YX,{scope:t,anchor:r,onAnchorChange:a,children:n})};a3.displayName=Z0;var o3="PopperAnchor",i3=E.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...a}=e,o=r3(o3,n),s=E.useRef(null),u=gt(t,s);return E.useEffect(()=>{o.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:w.jsx(Ze.div,{...a,ref:u})});i3.displayName=o3;var Q0="PopperContent",[KX,XX]=n3(Q0),s3=E.forwardRef((e,t)=>{var J,ae,ye,ie,Ee,Se;const{__scopePopper:n,side:r="bottom",sideOffset:a=0,align:o="center",alignOffset:s=0,arrowPadding:u=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:p=0,sticky:g="partial",hideWhenDetached:m=!1,updatePositionStrategy:b="optimized",onPlaced:y,...S}=e,k=r3(Q0,n),[R,x]=E.useState(null),A=gt(t,De=>x(De)),[N,O]=E.useState(null),C=t3(N),_=(C==null?void 0:C.width)??0,P=(C==null?void 0:C.height)??0,D=r+(o!=="center"?"-"+o:""),L=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},H=Array.isArray(d)?d:[d],$=H.length>0,U={padding:L,boundary:H.filter(QX),altBoundary:$},{refs:W,floatingStyles:Z,placement:j,isPositioned:G,middlewareData:z}=FX({strategy:"fixed",placement:D,whileElementsMounted:(...De)=>_X(...De,{animationFrame:b==="always"}),elements:{reference:k.anchor},middleware:[BX({mainAxis:a+P,alignmentAxis:s}),c&&UX({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?jX():void 0,...U}),c&&GX({...U}),HX({...U,apply:({elements:De,rects:Ce,availableWidth:we,availableHeight:te})=>{const{width:fe,height:Te}=Ce.reference,me=De.floating.style;me.setProperty("--radix-popper-available-width",`${we}px`),me.setProperty("--radix-popper-available-height",`${te}px`),me.setProperty("--radix-popper-anchor-width",`${fe}px`),me.setProperty("--radix-popper-anchor-height",`${Te}px`)}}),N&&qX({element:N,padding:u}),JX({arrowWidth:_,arrowHeight:P}),m&&$X({strategy:"referenceHidden",...U})]}),[Y,I]=c3(j),V=yn(y);Rn(()=>{G&&(V==null||V())},[G,V]);const B=(J=z.arrow)==null?void 0:J.x,M=(ae=z.arrow)==null?void 0:ae.y,K=((ye=z.arrow)==null?void 0:ye.centerOffset)!==0,[ee,Q]=E.useState();return Rn(()=>{R&&Q(window.getComputedStyle(R).zIndex)},[R]),w.jsx("div",{ref:W.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:G?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(ie=z.transformOrigin)==null?void 0:ie.x,(Ee=z.transformOrigin)==null?void 0:Ee.y].join(" "),...((Se=z.hide)==null?void 0:Se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:w.jsx(KX,{scope:n,placedSide:Y,onArrowChange:O,arrowX:B,arrowY:M,shouldHideArrow:K,children:w.jsx(Ze.div,{"data-side":Y,"data-align":I,...S,ref:A,style:{...S.style,animation:G?void 0:"none"}})})})});s3.displayName=Q0;var l3="PopperArrow",ZX={top:"bottom",right:"left",bottom:"top",left:"right"},u3=E.forwardRef(function(t,n){const{__scopePopper:r,...a}=t,o=XX(l3,r),s=ZX[o.placedSide];return w.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:w.jsx(WX,{...a,ref:n,style:{...a.style,display:"block"}})})});u3.displayName=l3;function QX(e){return e!==null}var JX=e=>({name:"transformOrigin",options:e,fn(t){var k,R,x;const{placement:n,rects:r,middlewareData:a}=t,s=((k=a.arrow)==null?void 0:k.centerOffset)!==0,u=s?0:e.arrowWidth,c=s?0:e.arrowHeight,[d,p]=c3(n),g={start:"0%",center:"50%",end:"100%"}[p],m=(((R=a.arrow)==null?void 0:R.x)??0)+u/2,b=(((x=a.arrow)==null?void 0:x.y)??0)+c/2;let y="",S="";return d==="bottom"?(y=s?g:`${m}px`,S=`${-c}px`):d==="top"?(y=s?g:`${m}px`,S=`${r.floating.height+c}px`):d==="right"?(y=`${-c}px`,S=s?g:`${b}px`):d==="left"&&(y=`${r.floating.width+c}px`,S=s?g:`${b}px`),{data:{x:y,y:S}}}});function c3(e){const[t,n="center"]=e.split("-");return[t,n]}var J0=a3,sp=i3,eT=s3,tT=u3,eZ="VisuallyHidden",nT=E.forwardRef((e,t)=>w.jsx(Ze.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));nT.displayName=eZ;var tZ=nT,[lp,Dxe]=wr("Tooltip",[Ys]),up=Ys(),d3="TooltipProvider",nZ=700,Sk="tooltip.open",[rZ,rT]=lp(d3),f3=e=>{const{__scopeTooltip:t,delayDuration:n=nZ,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:o}=e,[s,u]=E.useState(!0),c=E.useRef(!1),d=E.useRef(0);return E.useEffect(()=>{const p=d.current;return()=>window.clearTimeout(p)},[]),w.jsx(rZ,{scope:t,isOpenDelayed:s,delayDuration:n,onOpen:E.useCallback(()=>{window.clearTimeout(d.current),u(!1)},[]),onClose:E.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u(!0),r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:E.useCallback(p=>{c.current=p},[]),disableHoverableContent:a,children:o})};f3.displayName=d3;var cp="Tooltip",[aZ,dp]=lp(cp),p3=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:a=!1,onOpenChange:o,disableHoverableContent:s,delayDuration:u}=e,c=rT(cp,e.__scopeTooltip),d=up(t),[p,g]=E.useState(null),m=An(),b=E.useRef(0),y=s??c.disableHoverableContent,S=u??c.delayDuration,k=E.useRef(!1),[R=!1,x]=ja({prop:r,defaultProp:a,onChange:_=>{_?(c.onOpen(),document.dispatchEvent(new CustomEvent(Sk))):c.onClose(),o==null||o(_)}}),A=E.useMemo(()=>R?k.current?"delayed-open":"instant-open":"closed",[R]),N=E.useCallback(()=>{window.clearTimeout(b.current),b.current=0,k.current=!1,x(!0)},[x]),O=E.useCallback(()=>{window.clearTimeout(b.current),b.current=0,x(!1)},[x]),C=E.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{k.current=!0,x(!0),b.current=0},S)},[S,x]);return E.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),w.jsx(J0,{...d,children:w.jsx(aZ,{scope:t,contentId:m,open:R,stateAttribute:A,trigger:p,onTriggerChange:g,onTriggerEnter:E.useCallback(()=>{c.isOpenDelayed?C():N()},[c.isOpenDelayed,C,N]),onTriggerLeave:E.useCallback(()=>{y?O():(window.clearTimeout(b.current),b.current=0)},[O,y]),onOpen:N,onClose:O,disableHoverableContent:y,children:n})})};p3.displayName=cp;var Ek="TooltipTrigger",g3=E.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=dp(Ek,n),o=rT(Ek,n),s=up(n),u=E.useRef(null),c=gt(t,u,a.onTriggerChange),d=E.useRef(!1),p=E.useRef(!1),g=E.useCallback(()=>d.current=!1,[]);return E.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),w.jsx(sp,{asChild:!0,...s,children:w.jsx(Ze.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:c,onPointerMove:Ke(e.onPointerMove,m=>{m.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Ke(e.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Ke(e.onPointerDown,()=>{d.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:Ke(e.onFocus,()=>{d.current||a.onOpen()}),onBlur:Ke(e.onBlur,a.onClose),onClick:Ke(e.onClick,a.onClose)})})});g3.displayName=Ek;var oZ="TooltipPortal",[Lxe,iZ]=lp(oZ,{forceMount:void 0}),Ds="TooltipContent",h3=E.forwardRef((e,t)=>{const n=iZ(Ds,e.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...o}=e,s=dp(Ds,e.__scopeTooltip);return w.jsx(xr,{present:r||s.open,children:s.disableHoverableContent?w.jsx(m3,{side:a,...o,ref:t}):w.jsx(sZ,{side:a,...o,ref:t})})}),sZ=E.forwardRef((e,t)=>{const n=dp(Ds,e.__scopeTooltip),r=rT(Ds,e.__scopeTooltip),a=E.useRef(null),o=gt(t,a),[s,u]=E.useState(null),{trigger:c,onClose:d}=n,p=a.current,{onPointerInTransitChange:g}=r,m=E.useCallback(()=>{u(null),g(!1)},[g]),b=E.useCallback((y,S)=>{const k=y.currentTarget,R={x:y.clientX,y:y.clientY},x=dZ(R,k.getBoundingClientRect()),A=fZ(R,x),N=pZ(S.getBoundingClientRect()),O=hZ([...A,...N]);u(O),g(!0)},[g]);return E.useEffect(()=>()=>m(),[m]),E.useEffect(()=>{if(c&&p){const y=k=>b(k,p),S=k=>b(k,c);return c.addEventListener("pointerleave",y),p.addEventListener("pointerleave",S),()=>{c.removeEventListener("pointerleave",y),p.removeEventListener("pointerleave",S)}}},[c,p,b,m]),E.useEffect(()=>{if(s){const y=S=>{const k=S.target,R={x:S.clientX,y:S.clientY},x=(c==null?void 0:c.contains(k))||(p==null?void 0:p.contains(k)),A=!gZ(R,s);x?m():A&&(m(),d())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[c,p,s,d,m]),w.jsx(m3,{...e,ref:o})}),[lZ,uZ]=lp(cp,{isInside:!1}),m3=E.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:s,...u}=e,c=dp(Ds,n),d=up(n),{onClose:p}=c;return E.useEffect(()=>(document.addEventListener(Sk,p),()=>document.removeEventListener(Sk,p)),[p]),E.useEffect(()=>{if(c.trigger){const g=m=>{const b=m.target;b!=null&&b.contains(c.trigger)&&p()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[c.trigger,p]),w.jsx(qu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:g=>g.preventDefault(),onDismiss:p,children:w.jsxs(eT,{"data-state":c.stateAttribute,...d,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[w.jsx(O0,{children:r}),w.jsx(lZ,{scope:n,isInside:!0,children:w.jsx(tZ,{id:c.contentId,role:"tooltip",children:a||r})})]})})});h3.displayName=Ds;var b3="TooltipArrow",cZ=E.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=up(n);return uZ(b3,n).isInside?null:w.jsx(tT,{...a,...r,ref:t})});cZ.displayName=b3;function dZ(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,a,o)){case o:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function fZ(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function pZ(e){const{top:t,right:n,bottom:r,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:r},{x:a,y:r}]}function gZ(e,t){const{x:n,y:r}=e;let a=!1;for(let o=0,s=t.length-1;or!=p>r&&n<(d-u)*(r-c)/(p-c)+u&&(a=!a)}return a}function hZ(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),mZ(t)}function mZ(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const o=t[t.length-1],s=t[t.length-2];if((o.x-s.x)*(a.y-s.y)>=(o.y-s.y)*(a.x-s.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const a=e[r];for(;n.length>=2;){const o=n[n.length-1],s=n[n.length-2];if((o.x-s.x)*(a.y-s.y)>=(o.y-s.y)*(a.x-s.x))n.pop();else break}n.push(a)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var bZ=f3,yZ=p3,vZ=g3,y3=h3;const v3=bZ,S3=yZ,E3=vZ,SZ=e=>typeof e!="string"?e:w.jsx("div",{className:"relative top-0 pt-1 whitespace-pre-wrap break-words",children:e}),aT=E.forwardRef(({className:e,side:t="left",align:n="start",children:r,...a},o)=>{const s=E.useRef(null);return E.useEffect(()=>{s.current&&(s.current.scrollTop=0)},[r]),w.jsx(y3,{ref:o,side:t,align:n,className:Pe("bg-popover text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-[60vh] overflow-y-auto whitespace-pre-wrap break-words rounded-md border px-3 py-2 text-sm shadow-md z-60",e),...a,children:typeof r=="string"?SZ(r):r})});aT.displayName=y3.displayName;const Sf=UB("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"size-8"}},defaultVariants:{variant:"default",size:"default"}}),xt=E.forwardRef(({className:e,variant:t,tooltip:n,size:r,side:a="right",asChild:o=!1,...s},u)=>{const c=o?_o:"button";return n?w.jsx(v3,{children:w.jsxs(S3,{children:[w.jsx(E3,{asChild:!0,children:w.jsx(c,{className:Pe(Sf({variant:t,size:r,className:e}),"cursor-pointer"),ref:u,...s})}),w.jsx(aT,{side:a,children:n})]})}):w.jsx(c,{className:Pe(Sf({variant:t,size:r,className:e}),"cursor-pointer"),ref:u,...s})});xt.displayName="Button";const EZ=WK,wZ=YK,w3=E.forwardRef(({className:e,...t},n)=>w.jsx(zU,{className:Pe("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",e),...t,ref:n}));w3.displayName=zU.displayName;const x3=E.forwardRef(({className:e,...t},n)=>w.jsxs(wZ,{children:[w.jsx(w3,{}),w.jsx(BU,{ref:n,className:Pe("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%] fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg",e),...t})]}));x3.displayName=BU.displayName;const k3=({className:e,...t})=>w.jsx("div",{className:Pe("flex flex-col space-y-2 text-center sm:text-left",e),...t});k3.displayName="AlertDialogHeader";const T3=E.forwardRef(({className:e,...t},n)=>w.jsx(GU,{ref:n,className:Pe("text-lg font-semibold",e),...t}));T3.displayName=GU.displayName;const A3=E.forwardRef(({className:e,...t},n)=>w.jsx(HU,{ref:n,className:Pe("text-muted-foreground text-sm",e),...t}));A3.displayName=HU.displayName;const xZ=E.forwardRef(({className:e,...t},n)=>w.jsx(UU,{ref:n,className:Pe(Sf(),e),...t}));xZ.displayName=UU.displayName;const kZ=E.forwardRef(({className:e,...t},n)=>w.jsx(jU,{ref:n,className:Pe(Sf({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));kZ.displayName=jU.displayName;const $a=E.forwardRef(({className:e,type:t,...n},r)=>w.jsx("input",{type:t,className:Pe("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm [&::-webkit-inner-spin-button]:opacity-100 [&::-webkit-outer-spin-button]:opacity-100",e),ref:r,...n}));$a.displayName="Input";const TZ=()=>{const[e,t]=E.useState(!0),n=Le.use.apiKey(),[r,a]=E.useState(""),o=tr.use.message();E.useEffect(()=>{a(n||"")},[n,e]),E.useEffect(()=>{o&&(o.includes(DB)||o.includes(LB))&&t(!0)},[o,t]);const s=E.useCallback(async()=>{if(Le.setState({apiKey:r||null}),await tr.getState().check()){t(!1);return}Ft.error("API Key is invalid")},[r]),u=E.useCallback(c=>{a(c.target.value)},[a]);return w.jsx(EZ,{open:e,onOpenChange:t,children:w.jsxs(x3,{children:[w.jsxs(k3,{children:[w.jsx(T3,{children:"API Key is required"}),w.jsx(A3,{children:"Please enter your API key"})]}),w.jsxs("form",{className:"flex gap-2",onSubmit:c=>c.preventDefault(),children:[w.jsx($a,{type:"password",value:r,onChange:u,placeholder:"Enter your API key",className:"max-h-full w-full min-w-0",autoComplete:"off"}),w.jsx(xt,{onClick:s,variant:"outline",size:"sm",children:"Save"})]})]})})};var oT="Popover",[R3,Mxe]=wr(oT,[Ys]),Wu=Ys(),[AZ,Ti]=R3(oT),C3=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:a,onOpenChange:o,modal:s=!1}=e,u=Wu(t),c=E.useRef(null),[d,p]=E.useState(!1),[g=!1,m]=ja({prop:r,defaultProp:a,onChange:o});return w.jsx(J0,{...u,children:w.jsx(AZ,{scope:t,contentId:An(),triggerRef:c,open:g,onOpenChange:m,onOpenToggle:E.useCallback(()=>m(b=>!b),[m]),hasCustomAnchor:d,onCustomAnchorAdd:E.useCallback(()=>p(!0),[]),onCustomAnchorRemove:E.useCallback(()=>p(!1),[]),modal:s,children:n})})};C3.displayName=oT;var _3="PopoverAnchor",RZ=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Ti(_3,n),o=Wu(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:u}=a;return E.useEffect(()=>(s(),()=>u()),[s,u]),w.jsx(sp,{...o,...r,ref:t})});RZ.displayName=_3;var N3="PopoverTrigger",O3=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Ti(N3,n),o=Wu(n),s=gt(t,a.triggerRef),u=w.jsx(Ze.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":M3(a.open),...r,ref:s,onClick:Ke(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:w.jsx(sp,{asChild:!0,...o,children:u})});O3.displayName=N3;var CZ="PopoverPortal",[Pxe,_Z]=R3(CZ,{forceMount:void 0}),Ls="PopoverContent",I3=E.forwardRef((e,t)=>{const n=_Z(Ls,e.__scopePopover),{forceMount:r=n.forceMount,...a}=e,o=Ti(Ls,e.__scopePopover);return w.jsx(xr,{present:r||o.open,children:o.modal?w.jsx(NZ,{...a,ref:t}):w.jsx(OZ,{...a,ref:t})})});I3.displayName=Ls;var NZ=E.forwardRef((e,t)=>{const n=Ti(Ls,e.__scopePopover),r=E.useRef(null),a=gt(t,r),o=E.useRef(!1);return E.useEffect(()=>{const s=r.current;if(s)return L0(s)},[]),w.jsx(tp,{as:_o,allowPinchZoom:!0,children:w.jsx(D3,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ke(e.onCloseAutoFocus,s=>{var u;s.preventDefault(),o.current||(u=n.triggerRef.current)==null||u.focus()}),onPointerDownOutside:Ke(e.onPointerDownOutside,s=>{const u=s.detail.originalEvent,c=u.button===0&&u.ctrlKey===!0,d=u.button===2||c;o.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:Ke(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),OZ=E.forwardRef((e,t)=>{const n=Ti(Ls,e.__scopePopover),r=E.useRef(!1),a=E.useRef(!1);return w.jsx(D3,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var s,u;(s=e.onCloseAutoFocus)==null||s.call(e,o),o.defaultPrevented||(r.current||(u=n.triggerRef.current)==null||u.focus(),o.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:o=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const s=o.target;((d=n.triggerRef.current)==null?void 0:d.contains(s))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),D3=E.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:p,...g}=e,m=Ti(Ls,n),b=Wu(n);return D0(),w.jsx(Jf,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:o,children:w.jsx(qu,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:p,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>m.onOpenChange(!1),children:w.jsx(eT,{"data-state":M3(m.open),role:"dialog",id:m.contentId,...b,...g,ref:t,style:{...g.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),L3="PopoverClose",IZ=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Ti(L3,n);return w.jsx(Ze.button,{type:"button",...r,ref:t,onClick:Ke(e.onClick,()=>a.onOpenChange(!1))})});IZ.displayName=L3;var DZ="PopoverArrow",LZ=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Wu(n);return w.jsx(tT,{...a,...r,ref:t})});LZ.displayName=DZ;function M3(e){return e?"open":"closed"}var MZ=C3,PZ=O3,P3=I3;const Yu=MZ,Ku=PZ,Ks=E.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>w.jsx(P3,{ref:a,align:t,sideOffset:n,className:Pe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 rounded-md border p-4 shadow-md outline-none",e),...r}));Ks.displayName=P3.displayName;const FZ=(e,t,n,r)=>{var o,s,u,c;const a=[n,{code:t,...r||{}}];if((s=(o=e==null?void 0:e.services)==null?void 0:o.logger)!=null&&s.forward)return e.services.logger.forward(a,"warn","react-i18next::",!0);gi(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),(c=(u=e==null?void 0:e.services)==null?void 0:u.logger)!=null&&c.warn?e.services.logger.warn(...a):console!=null&&console.warn&&console.warn(...a)},Q_={},wk=(e,t,n,r)=>{gi(n)&&Q_[n]||(gi(n)&&(Q_[n]=new Date),FZ(e,t,n,r))},F3=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},xk=(e,t,n)=>{e.loadNamespaces(t,F3(e,n))},J_=(e,t,n,r)=>{if(gi(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return xk(e,n,r);n.forEach(a=>{e.options.ns.indexOf(a)<0&&e.options.ns.push(a)}),e.loadLanguages(t,F3(e,r))},zZ=(e,t,n={})=>!t.languages||!t.languages.length?(wk(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(r,a)=>{var o;if(((o=n.bindI18n)==null?void 0:o.indexOf("languageChanging"))>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!a(r.isLanguageChangingTo,e))return!1}}),gi=e=>typeof e=="string",BZ=e=>typeof e=="object"&&e!==null,UZ=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,jZ={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},GZ=e=>jZ[e],HZ=e=>e.replace(UZ,GZ);let kk={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:HZ};const $Z=(e={})=>{kk={...kk,...e}},qZ=()=>kk;let z3;const VZ=e=>{z3=e},WZ=()=>z3,YZ={type:"3rdParty",init(e){$Z(e.options.react),VZ(e)}},KZ=E.createContext();class XZ{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const ZZ=(e,t)=>{const n=E.useRef();return E.useEffect(()=>{n.current=e},[e,t]),n.current},B3=(e,t,n,r)=>e.getFixedT(t,n,r),QZ=(e,t,n,r)=>E.useCallback(B3(e,t,n,r),[e,t,n,r]),Pt=(e,t={})=>{var N,O,C,_;const{i18n:n}=t,{i18n:r,defaultNS:a}=E.useContext(KZ)||{},o=n||r||WZ();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new XZ),!o){wk(o,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const P=(L,H)=>gi(H)?H:BZ(H)&&gi(H.defaultValue)?H.defaultValue:Array.isArray(L)?L[L.length-1]:L,D=[P,{},!1];return D.t=P,D.i18n={},D.ready=!1,D}(N=o.options.react)!=null&&N.wait&&wk(o,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const s={...qZ(),...o.options.react,...t},{useSuspense:u,keyPrefix:c}=s;let d=a||((O=o.options)==null?void 0:O.defaultNS);d=gi(d)?[d]:d||["translation"],(_=(C=o.reportNamespaces).addUsedNamespaces)==null||_.call(C,d);const p=(o.isInitialized||o.initializedStoreOnce)&&d.every(P=>zZ(P,o,s)),g=QZ(o,t.lng||null,s.nsMode==="fallback"?d:d[0],c),m=()=>g,b=()=>B3(o,t.lng||null,s.nsMode==="fallback"?d:d[0],c),[y,S]=E.useState(m);let k=d.join();t.lng&&(k=`${t.lng}${k}`);const R=ZZ(k),x=E.useRef(!0);E.useEffect(()=>{const{bindI18n:P,bindI18nStore:D}=s;x.current=!0,!p&&!u&&(t.lng?J_(o,t.lng,d,()=>{x.current&&S(b)}):xk(o,d,()=>{x.current&&S(b)})),p&&R&&R!==k&&x.current&&S(b);const L=()=>{x.current&&S(b)};return P&&(o==null||o.on(P,L)),D&&(o==null||o.store.on(D,L)),()=>{x.current=!1,o&&(P==null||P.split(" ").forEach(H=>o.off(H,L))),D&&o&&D.split(" ").forEach(H=>o.store.off(H,L))}},[o,k]),E.useEffect(()=>{x.current&&p&&S(m)},[o,c,p]);const A=[y,o,p];if(A.t=y,A.i18n=o,A.ready=p,p||!p&&!u)return A;throw new Promise(P=>{t.lng?J_(o,t.lng,d,()=>P()):xk(o,d,()=>P())})},JZ=({status:e})=>{const{t}=Pt();return e?w.jsxs("div",{className:"min-w-[300px] space-y-3 text-sm",children:[w.jsxs("div",{className:"space-y-1",children:[w.jsx("h4",{className:"font-medium",children:t("graphPanel.statusCard.storageInfo")}),w.jsxs("div",{className:"text-muted-foreground grid grid-cols-2 gap-1",children:[w.jsxs("span",{children:[t("graphPanel.statusCard.workingDirectory"),":"]}),w.jsx("span",{className:"truncate",children:e.working_directory}),w.jsxs("span",{children:[t("graphPanel.statusCard.inputDirectory"),":"]}),w.jsx("span",{className:"truncate",children:e.input_directory})]})]}),w.jsxs("div",{className:"space-y-1",children:[w.jsx("h4",{className:"font-medium",children:t("graphPanel.statusCard.llmConfig")}),w.jsxs("div",{className:"text-muted-foreground grid grid-cols-2 gap-1",children:[w.jsxs("span",{children:[t("graphPanel.statusCard.llmBinding"),":"]}),w.jsx("span",{children:e.configuration.llm_binding}),w.jsxs("span",{children:[t("graphPanel.statusCard.llmBindingHost"),":"]}),w.jsx("span",{children:e.configuration.llm_binding_host}),w.jsxs("span",{children:[t("graphPanel.statusCard.llmModel"),":"]}),w.jsx("span",{children:e.configuration.llm_model}),w.jsxs("span",{children:[t("graphPanel.statusCard.maxTokens"),":"]}),w.jsx("span",{children:e.configuration.max_tokens})]})]}),w.jsxs("div",{className:"space-y-1",children:[w.jsx("h4",{className:"font-medium",children:t("graphPanel.statusCard.embeddingConfig")}),w.jsxs("div",{className:"text-muted-foreground grid grid-cols-2 gap-1",children:[w.jsxs("span",{children:[t("graphPanel.statusCard.embeddingBinding"),":"]}),w.jsx("span",{children:e.configuration.embedding_binding}),w.jsxs("span",{children:[t("graphPanel.statusCard.embeddingBindingHost"),":"]}),w.jsx("span",{children:e.configuration.embedding_binding_host}),w.jsxs("span",{children:[t("graphPanel.statusCard.embeddingModel"),":"]}),w.jsx("span",{children:e.configuration.embedding_model})]})]}),w.jsxs("div",{className:"space-y-1",children:[w.jsx("h4",{className:"font-medium",children:t("graphPanel.statusCard.storageConfig")}),w.jsxs("div",{className:"text-muted-foreground grid grid-cols-2 gap-1",children:[w.jsxs("span",{children:[t("graphPanel.statusCard.kvStorage"),":"]}),w.jsx("span",{children:e.configuration.kv_storage}),w.jsxs("span",{children:[t("graphPanel.statusCard.docStatusStorage"),":"]}),w.jsx("span",{children:e.configuration.doc_status_storage}),w.jsxs("span",{children:[t("graphPanel.statusCard.graphStorage"),":"]}),w.jsx("span",{children:e.configuration.graph_storage}),w.jsxs("span",{children:[t("graphPanel.statusCard.vectorStorage"),":"]}),w.jsx("span",{children:e.configuration.vector_storage})]})]})]}):w.jsx("div",{className:"text-muted-foreground text-sm",children:t("graphPanel.statusCard.unavailable")})},eQ=()=>{const{t:e}=Pt(),t=tr.use.health(),n=tr.use.lastCheckTime(),r=tr.use.status(),[a,o]=E.useState(!1);return E.useEffect(()=>{o(!0);const s=setTimeout(()=>o(!1),300);return()=>clearTimeout(s)},[n]),w.jsx("div",{className:"fixed right-4 bottom-4 flex items-center gap-2 opacity-80 select-none",children:w.jsxs(Yu,{children:[w.jsx(Ku,{asChild:!0,children:w.jsxs("div",{className:"flex cursor-help items-center gap-2",children:[w.jsx("div",{className:Pe("h-3 w-3 rounded-full transition-all duration-300","shadow-[0_0_8px_rgba(0,0,0,0.2)]",t?"bg-green-500":"bg-red-500",a&&"scale-125",a&&t&&"shadow-[0_0_12px_rgba(34,197,94,0.4)]",a&&!t&&"shadow-[0_0_12px_rgba(239,68,68,0.4)]")}),w.jsx("span",{className:"text-muted-foreground text-xs",children:e(t?"graphPanel.statusIndicator.connected":"graphPanel.statusIndicator.disconnected")})]})}),w.jsx(Ks,{className:"w-auto",side:"top",align:"end",children:w.jsx(JZ,{status:r})})]})})};function Tk(e,[t,n]){return Math.min(n,Math.max(t,e))}function U3(e){const t=e+"CollectionProvider",[n,r]=wr(t),[a,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=b=>{const{scope:y,children:S}=b,k=ve.useRef(null),R=ve.useRef(new Map).current;return w.jsx(a,{scope:y,itemMap:R,collectionRef:k,children:S})};s.displayName=t;const u=e+"CollectionSlot",c=ve.forwardRef((b,y)=>{const{scope:S,children:k}=b,R=o(u,S),x=gt(y,R.collectionRef);return w.jsx(_o,{ref:x,children:k})});c.displayName=u;const d=e+"CollectionItemSlot",p="data-radix-collection-item",g=ve.forwardRef((b,y)=>{const{scope:S,children:k,...R}=b,x=ve.useRef(null),A=gt(y,x),N=o(d,S);return ve.useEffect(()=>(N.itemMap.set(x,{ref:x,...R}),()=>void N.itemMap.delete(x))),w.jsx(_o,{[p]:"",ref:A,children:k})});g.displayName=d;function m(b){const y=o(e+"CollectionConsumer",b);return ve.useCallback(()=>{const k=y.collectionRef.current;if(!k)return[];const R=Array.from(k.querySelectorAll(`[${p}]`));return Array.from(y.itemMap.values()).sort((N,O)=>R.indexOf(N.ref.current)-R.indexOf(O.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:s,Slot:c,ItemSlot:g},m,r]}var tQ=E.createContext(void 0);function fp(e){const t=E.useContext(tQ);return e||t||"ltr"}function j3(e){const t=E.useRef({value:e,previous:e});return E.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var nQ=[" ","Enter","ArrowUp","ArrowDown"],rQ=[" ","Enter"],Xu="Select",[pp,gp,aQ]=U3(Xu),[Xs,Fxe]=wr(Xu,[aQ,Ys]),hp=Ys(),[oQ,Lo]=Xs(Xu),[iQ,sQ]=Xs(Xu),G3=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:a,onOpenChange:o,value:s,defaultValue:u,onValueChange:c,dir:d,name:p,autoComplete:g,disabled:m,required:b,form:y}=e,S=hp(t),[k,R]=E.useState(null),[x,A]=E.useState(null),[N,O]=E.useState(!1),C=fp(d),[_=!1,P]=ja({prop:r,defaultProp:a,onChange:o}),[D,L]=ja({prop:s,defaultProp:u,onChange:c}),H=E.useRef(null),$=k?y||!!k.closest("form"):!0,[U,W]=E.useState(new Set),Z=Array.from(U).map(j=>j.props.value).join(";");return w.jsx(J0,{...S,children:w.jsxs(oQ,{required:b,scope:t,trigger:k,onTriggerChange:R,valueNode:x,onValueNodeChange:A,valueNodeHasChildren:N,onValueNodeHasChildrenChange:O,contentId:An(),value:D,onValueChange:L,open:_,onOpenChange:P,dir:C,triggerPointerDownPosRef:H,disabled:m,children:[w.jsx(pp.Provider,{scope:t,children:w.jsx(iQ,{scope:e.__scopeSelect,onNativeOptionAdd:E.useCallback(j=>{W(G=>new Set(G).add(j))},[]),onNativeOptionRemove:E.useCallback(j=>{W(G=>{const z=new Set(G);return z.delete(j),z})},[]),children:n})}),$?w.jsxs(gj,{"aria-hidden":!0,required:b,tabIndex:-1,name:p,autoComplete:g,value:D,onChange:j=>L(j.target.value),disabled:m,form:y,children:[D===void 0?w.jsx("option",{value:""}):null,Array.from(U)]},Z):null]})})};G3.displayName=Xu;var H3="SelectTrigger",$3=E.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...a}=e,o=hp(n),s=Lo(H3,n),u=s.disabled||r,c=gt(t,s.onTriggerChange),d=gp(n),p=E.useRef("touch"),[g,m,b]=hj(S=>{const k=d().filter(A=>!A.disabled),R=k.find(A=>A.value===s.value),x=mj(k,S,R);x!==void 0&&s.onValueChange(x.value)}),y=S=>{u||(s.onOpenChange(!0),b()),S&&(s.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return w.jsx(sp,{asChild:!0,...o,children:w.jsx(Ze.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:u,"data-disabled":u?"":void 0,"data-placeholder":pj(s.value)?"":void 0,...a,ref:c,onClick:Ke(a.onClick,S=>{S.currentTarget.focus(),p.current!=="mouse"&&y(S)}),onPointerDown:Ke(a.onPointerDown,S=>{p.current=S.pointerType;const k=S.target;k.hasPointerCapture(S.pointerId)&&k.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(y(S),S.preventDefault())}),onKeyDown:Ke(a.onKeyDown,S=>{const k=g.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&m(S.key),!(k&&S.key===" ")&&nQ.includes(S.key)&&(y(),S.preventDefault())})})})});$3.displayName=H3;var q3="SelectValue",V3=E.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:a,children:o,placeholder:s="",...u}=e,c=Lo(q3,n),{onValueNodeHasChildrenChange:d}=c,p=o!==void 0,g=gt(t,c.onValueNodeChange);return Rn(()=>{d(p)},[d,p]),w.jsx(Ze.span,{...u,ref:g,style:{pointerEvents:"none"},children:pj(c.value)?w.jsx(w.Fragment,{children:s}):o})});V3.displayName=q3;var lQ="SelectIcon",W3=E.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...a}=e;return w.jsx(Ze.span,{"aria-hidden":!0,...a,ref:t,children:r||"▼"})});W3.displayName=lQ;var uQ="SelectPortal",Y3=e=>w.jsx(I0,{asChild:!0,...e});Y3.displayName=uQ;var vi="SelectContent",K3=E.forwardRef((e,t)=>{const n=Lo(vi,e.__scopeSelect),[r,a]=E.useState();if(Rn(()=>{a(new DocumentFragment)},[]),!n.open){const o=r;return o?Gu.createPortal(w.jsx(X3,{scope:e.__scopeSelect,children:w.jsx(pp.Slot,{scope:e.__scopeSelect,children:w.jsx("div",{children:e.children})})}),o):null}return w.jsx(Z3,{...e,ref:t})});K3.displayName=vi;var Lr=10,[X3,Mo]=Xs(vi),cQ="SelectContentImpl",Z3=E.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:s,side:u,sideOffset:c,align:d,alignOffset:p,arrowPadding:g,collisionBoundary:m,collisionPadding:b,sticky:y,hideWhenDetached:S,avoidCollisions:k,...R}=e,x=Lo(vi,n),[A,N]=E.useState(null),[O,C]=E.useState(null),_=gt(t,J=>N(J)),[P,D]=E.useState(null),[L,H]=E.useState(null),$=gp(n),[U,W]=E.useState(!1),Z=E.useRef(!1);E.useEffect(()=>{if(A)return L0(A)},[A]),D0();const j=E.useCallback(J=>{const[ae,...ye]=$().map(Se=>Se.ref.current),[ie]=ye.slice(-1),Ee=document.activeElement;for(const Se of J)if(Se===Ee||(Se==null||Se.scrollIntoView({block:"nearest"}),Se===ae&&O&&(O.scrollTop=0),Se===ie&&O&&(O.scrollTop=O.scrollHeight),Se==null||Se.focus(),document.activeElement!==Ee))return},[$,O]),G=E.useCallback(()=>j([P,A]),[j,P,A]);E.useEffect(()=>{U&&G()},[U,G]);const{onOpenChange:z,triggerPointerDownPosRef:Y}=x;E.useEffect(()=>{if(A){let J={x:0,y:0};const ae=ie=>{var Ee,Se;J={x:Math.abs(Math.round(ie.pageX)-(((Ee=Y.current)==null?void 0:Ee.x)??0)),y:Math.abs(Math.round(ie.pageY)-(((Se=Y.current)==null?void 0:Se.y)??0))}},ye=ie=>{J.x<=10&&J.y<=10?ie.preventDefault():A.contains(ie.target)||z(!1),document.removeEventListener("pointermove",ae),Y.current=null};return Y.current!==null&&(document.addEventListener("pointermove",ae),document.addEventListener("pointerup",ye,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ae),document.removeEventListener("pointerup",ye,{capture:!0})}}},[A,z,Y]),E.useEffect(()=>{const J=()=>z(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[z]);const[I,V]=hj(J=>{const ae=$().filter(Ee=>!Ee.disabled),ye=ae.find(Ee=>Ee.ref.current===document.activeElement),ie=mj(ae,J,ye);ie&&setTimeout(()=>ie.ref.current.focus())}),B=E.useCallback((J,ae,ye)=>{const ie=!Z.current&&!ye;(x.value!==void 0&&x.value===ae||ie)&&(D(J),ie&&(Z.current=!0))},[x.value]),M=E.useCallback(()=>A==null?void 0:A.focus(),[A]),K=E.useCallback((J,ae,ye)=>{const ie=!Z.current&&!ye;(x.value!==void 0&&x.value===ae||ie)&&H(J)},[x.value]),ee=r==="popper"?Ak:Q3,Q=ee===Ak?{side:u,sideOffset:c,align:d,alignOffset:p,arrowPadding:g,collisionBoundary:m,collisionPadding:b,sticky:y,hideWhenDetached:S,avoidCollisions:k}:{};return w.jsx(X3,{scope:n,content:A,viewport:O,onViewportChange:C,itemRefCallback:B,selectedItem:P,onItemLeave:M,itemTextRefCallback:K,focusSelectedItem:G,selectedItemText:L,position:r,isPositioned:U,searchRef:I,children:w.jsx(tp,{as:_o,allowPinchZoom:!0,children:w.jsx(Jf,{asChild:!0,trapped:x.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:Ke(a,J=>{var ae;(ae=x.trigger)==null||ae.focus({preventScroll:!0}),J.preventDefault()}),children:w.jsx(qu,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:w.jsx(ee,{role:"listbox",id:x.contentId,"data-state":x.open?"open":"closed",dir:x.dir,onContextMenu:J=>J.preventDefault(),...R,...Q,onPlaced:()=>W(!0),ref:_,style:{display:"flex",flexDirection:"column",outline:"none",...R.style},onKeyDown:Ke(R.onKeyDown,J=>{const ae=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!ae&&J.key.length===1&&V(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let ie=$().filter(Ee=>!Ee.disabled).map(Ee=>Ee.ref.current);if(["ArrowUp","End"].includes(J.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const Ee=J.target,Se=ie.indexOf(Ee);ie=ie.slice(Se+1)}setTimeout(()=>j(ie)),J.preventDefault()}})})})})})})});Z3.displayName=cQ;var dQ="SelectItemAlignedPosition",Q3=E.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...a}=e,o=Lo(vi,n),s=Mo(vi,n),[u,c]=E.useState(null),[d,p]=E.useState(null),g=gt(t,_=>p(_)),m=gp(n),b=E.useRef(!1),y=E.useRef(!0),{viewport:S,selectedItem:k,selectedItemText:R,focusSelectedItem:x}=s,A=E.useCallback(()=>{if(o.trigger&&o.valueNode&&u&&d&&S&&k&&R){const _=o.trigger.getBoundingClientRect(),P=d.getBoundingClientRect(),D=o.valueNode.getBoundingClientRect(),L=R.getBoundingClientRect();if(o.dir!=="rtl"){const Ee=L.left-P.left,Se=D.left-Ee,De=_.left-Se,Ce=_.width+De,we=Math.max(Ce,P.width),te=window.innerWidth-Lr,fe=Tk(Se,[Lr,Math.max(Lr,te-we)]);u.style.minWidth=Ce+"px",u.style.left=fe+"px"}else{const Ee=P.right-L.right,Se=window.innerWidth-D.right-Ee,De=window.innerWidth-_.right-Se,Ce=_.width+De,we=Math.max(Ce,P.width),te=window.innerWidth-Lr,fe=Tk(Se,[Lr,Math.max(Lr,te-we)]);u.style.minWidth=Ce+"px",u.style.right=fe+"px"}const H=m(),$=window.innerHeight-Lr*2,U=S.scrollHeight,W=window.getComputedStyle(d),Z=parseInt(W.borderTopWidth,10),j=parseInt(W.paddingTop,10),G=parseInt(W.borderBottomWidth,10),z=parseInt(W.paddingBottom,10),Y=Z+j+U+z+G,I=Math.min(k.offsetHeight*5,Y),V=window.getComputedStyle(S),B=parseInt(V.paddingTop,10),M=parseInt(V.paddingBottom,10),K=_.top+_.height/2-Lr,ee=$-K,Q=k.offsetHeight/2,J=k.offsetTop+Q,ae=Z+j+J,ye=Y-ae;if(ae<=K){const Ee=H.length>0&&k===H[H.length-1].ref.current;u.style.bottom="0px";const Se=d.clientHeight-S.offsetTop-S.offsetHeight,De=Math.max(ee,Q+(Ee?M:0)+Se+G),Ce=ae+De;u.style.height=Ce+"px"}else{const Ee=H.length>0&&k===H[0].ref.current;u.style.top="0px";const De=Math.max(K,Z+S.offsetTop+(Ee?B:0)+Q)+ye;u.style.height=De+"px",S.scrollTop=ae-K+S.offsetTop}u.style.margin=`${Lr}px 0`,u.style.minHeight=I+"px",u.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>b.current=!0)}},[m,o.trigger,o.valueNode,u,d,S,k,R,o.dir,r]);Rn(()=>A(),[A]);const[N,O]=E.useState();Rn(()=>{d&&O(window.getComputedStyle(d).zIndex)},[d]);const C=E.useCallback(_=>{_&&y.current===!0&&(A(),x==null||x(),y.current=!1)},[A,x]);return w.jsx(pQ,{scope:n,contentWrapper:u,shouldExpandOnScrollRef:b,onScrollButtonChange:C,children:w.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:w.jsx(Ze.div,{...a,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});Q3.displayName=dQ;var fQ="SelectPopperPosition",Ak=E.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=Lr,...o}=e,s=hp(n);return w.jsx(eT,{...s,...o,ref:t,align:r,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ak.displayName=fQ;var[pQ,iT]=Xs(vi,{}),Rk="SelectViewport",J3=E.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...a}=e,o=Mo(Rk,n),s=iT(Rk,n),u=gt(t,o.onViewportChange),c=E.useRef(0);return w.jsxs(w.Fragment,{children:[w.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),w.jsx(pp.Slot,{scope:n,children:w.jsx(Ze.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:u,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Ke(a.onScroll,d=>{const p=d.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:m}=s;if(m!=null&&m.current&&g){const b=Math.abs(c.current-p.scrollTop);if(b>0){const y=window.innerHeight-Lr*2,S=parseFloat(g.style.minHeight),k=parseFloat(g.style.height),R=Math.max(S,k);if(R0?N:0,g.style.justifyContent="flex-end")}}}c.current=p.scrollTop})})})]})});J3.displayName=Rk;var ej="SelectGroup",[gQ,hQ]=Xs(ej),tj=E.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=An();return w.jsx(gQ,{scope:n,id:a,children:w.jsx(Ze.div,{role:"group","aria-labelledby":a,...r,ref:t})})});tj.displayName=ej;var nj="SelectLabel",rj=E.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=hQ(nj,n);return w.jsx(Ze.div,{id:a.id,...r,ref:t})});rj.displayName=nj;var Ef="SelectItem",[mQ,aj]=Xs(Ef),oj=E.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:o,...s}=e,u=Lo(Ef,n),c=Mo(Ef,n),d=u.value===r,[p,g]=E.useState(o??""),[m,b]=E.useState(!1),y=gt(t,x=>{var A;return(A=c.itemRefCallback)==null?void 0:A.call(c,x,r,a)}),S=An(),k=E.useRef("touch"),R=()=>{a||(u.onValueChange(r),u.onOpenChange(!1))};if(r==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return w.jsx(mQ,{scope:n,value:r,disabled:a,textId:S,isSelected:d,onItemTextChange:E.useCallback(x=>{g(A=>A||((x==null?void 0:x.textContent)??"").trim())},[]),children:w.jsx(pp.ItemSlot,{scope:n,value:r,disabled:a,textValue:p,children:w.jsx(Ze.div,{role:"option","aria-labelledby":S,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...s,ref:y,onFocus:Ke(s.onFocus,()=>b(!0)),onBlur:Ke(s.onBlur,()=>b(!1)),onClick:Ke(s.onClick,()=>{k.current!=="mouse"&&R()}),onPointerUp:Ke(s.onPointerUp,()=>{k.current==="mouse"&&R()}),onPointerDown:Ke(s.onPointerDown,x=>{k.current=x.pointerType}),onPointerMove:Ke(s.onPointerMove,x=>{var A;k.current=x.pointerType,a?(A=c.onItemLeave)==null||A.call(c):k.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ke(s.onPointerLeave,x=>{var A;x.currentTarget===document.activeElement&&((A=c.onItemLeave)==null||A.call(c))}),onKeyDown:Ke(s.onKeyDown,x=>{var N;((N=c.searchRef)==null?void 0:N.current)!==""&&x.key===" "||(rQ.includes(x.key)&&R(),x.key===" "&&x.preventDefault())})})})})});oj.displayName=Ef;var gu="SelectItemText",ij=E.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:a,...o}=e,s=Lo(gu,n),u=Mo(gu,n),c=aj(gu,n),d=sQ(gu,n),[p,g]=E.useState(null),m=gt(t,R=>g(R),c.onItemTextChange,R=>{var x;return(x=u.itemTextRefCallback)==null?void 0:x.call(u,R,c.value,c.disabled)}),b=p==null?void 0:p.textContent,y=E.useMemo(()=>w.jsx("option",{value:c.value,disabled:c.disabled,children:b},c.value),[c.disabled,c.value,b]),{onNativeOptionAdd:S,onNativeOptionRemove:k}=d;return Rn(()=>(S(y),()=>k(y)),[S,k,y]),w.jsxs(w.Fragment,{children:[w.jsx(Ze.span,{id:c.textId,...o,ref:m}),c.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Gu.createPortal(o.children,s.valueNode):null]})});ij.displayName=gu;var sj="SelectItemIndicator",lj=E.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return aj(sj,n).isSelected?w.jsx(Ze.span,{"aria-hidden":!0,...r,ref:t}):null});lj.displayName=sj;var Ck="SelectScrollUpButton",uj=E.forwardRef((e,t)=>{const n=Mo(Ck,e.__scopeSelect),r=iT(Ck,e.__scopeSelect),[a,o]=E.useState(!1),s=gt(t,r.onScrollButtonChange);return Rn(()=>{if(n.viewport&&n.isPositioned){let u=function(){const d=c.scrollTop>0;o(d)};const c=n.viewport;return u(),c.addEventListener("scroll",u),()=>c.removeEventListener("scroll",u)}},[n.viewport,n.isPositioned]),a?w.jsx(dj,{...e,ref:s,onAutoScroll:()=>{const{viewport:u,selectedItem:c}=n;u&&c&&(u.scrollTop=u.scrollTop-c.offsetHeight)}}):null});uj.displayName=Ck;var _k="SelectScrollDownButton",cj=E.forwardRef((e,t)=>{const n=Mo(_k,e.__scopeSelect),r=iT(_k,e.__scopeSelect),[a,o]=E.useState(!1),s=gt(t,r.onScrollButtonChange);return Rn(()=>{if(n.viewport&&n.isPositioned){let u=function(){const d=c.scrollHeight-c.clientHeight,p=Math.ceil(c.scrollTop)c.removeEventListener("scroll",u)}},[n.viewport,n.isPositioned]),a?w.jsx(dj,{...e,ref:s,onAutoScroll:()=>{const{viewport:u,selectedItem:c}=n;u&&c&&(u.scrollTop=u.scrollTop+c.offsetHeight)}}):null});cj.displayName=_k;var dj=E.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=e,o=Mo("SelectScrollButton",n),s=E.useRef(null),u=gp(n),c=E.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return E.useEffect(()=>()=>c(),[c]),Rn(()=>{var p;const d=u().find(g=>g.ref.current===document.activeElement);(p=d==null?void 0:d.ref.current)==null||p.scrollIntoView({block:"nearest"})},[u]),w.jsx(Ze.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:Ke(a.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:Ke(a.onPointerMove,()=>{var d;(d=o.onItemLeave)==null||d.call(o),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:Ke(a.onPointerLeave,()=>{c()})})}),bQ="SelectSeparator",fj=E.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return w.jsx(Ze.div,{"aria-hidden":!0,...r,ref:t})});fj.displayName=bQ;var Nk="SelectArrow",yQ=E.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=hp(n),o=Lo(Nk,n),s=Mo(Nk,n);return o.open&&s.position==="popper"?w.jsx(tT,{...a,...r,ref:t}):null});yQ.displayName=Nk;function pj(e){return e===""||e===void 0}var gj=E.forwardRef((e,t)=>{const{value:n,...r}=e,a=E.useRef(null),o=gt(t,a),s=j3(n);return E.useEffect(()=>{const u=a.current,c=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(c,"value").set;if(s!==n&&p){const g=new Event("change",{bubbles:!0});p.call(u,n),u.dispatchEvent(g)}},[s,n]),w.jsx(nT,{asChild:!0,children:w.jsx("select",{...r,ref:o,defaultValue:n})})});gj.displayName="BubbleSelect";function hj(e){const t=yn(e),n=E.useRef(""),r=E.useRef(0),a=E.useCallback(s=>{const u=n.current+s;t(u),function c(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(u)},[t]),o=E.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return E.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,o]}function mj(e,t,n){const a=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let s=vQ(e,Math.max(o,0));a.length===1&&(s=s.filter(d=>d!==n));const c=s.find(d=>d.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==n?c:void 0}function vQ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var SQ=G3,bj=$3,EQ=V3,wQ=W3,xQ=Y3,yj=K3,kQ=J3,TQ=tj,vj=rj,Sj=oj,AQ=ij,RQ=lj,Ej=uj,wj=cj,xj=fj;const wf=SQ,eN=TQ,xf=EQ,Au=E.forwardRef(({className:e,children:t,...n},r)=>w.jsxs(bj,{ref:r,className:Pe("border-input bg-background ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-10 w-full items-center justify-between rounded-md border px-3 py-2 text-sm focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,w.jsx(wQ,{asChild:!0,children:w.jsx(N0,{className:"h-4 w-4 opacity-50"})})]}));Au.displayName=bj.displayName;const kj=E.forwardRef(({className:e,...t},n)=>w.jsx(Ej,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:w.jsx(qB,{className:"h-4 w-4"})}));kj.displayName=Ej.displayName;const Tj=E.forwardRef(({className:e,...t},n)=>w.jsx(wj,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:w.jsx(N0,{className:"h-4 w-4"})}));Tj.displayName=wj.displayName;const Ru=E.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>w.jsx(xQ,{children:w.jsxs(yj,{ref:a,className:Pe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[w.jsx(kj,{}),w.jsx(kQ,{className:Pe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),w.jsx(Tj,{})]})}));Ru.displayName=yj.displayName;const CQ=E.forwardRef(({className:e,...t},n)=>w.jsx(vj,{ref:n,className:Pe("py-1.5 pr-2 pl-8 text-sm font-semibold",e),...t}));CQ.displayName=vj.displayName;const xn=E.forwardRef(({className:e,children:t,...n},r)=>w.jsxs(Sj,{ref:r,className:Pe("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-default items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[w.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:w.jsx(RQ,{children:w.jsx(_0,{className:"h-4 w-4"})})}),w.jsx(AQ,{children:t})]}));xn.displayName=Sj.displayName;const _Q=E.forwardRef(({className:e,...t},n)=>w.jsx(xj,{ref:n,className:Pe("bg-muted -mx-1 my-1 h-px",e),...t}));_Q.displayName=xj.displayName;function Aj({className:e}){const[t,n]=E.useState(!1),{t:r}=Pt(),a=Le.use.language(),o=Le.use.setLanguage(),s=Le.use.theme(),u=Le.use.setTheme(),c=E.useCallback(p=>{o(p)},[o]),d=E.useCallback(p=>{u(p)},[u]);return w.jsxs(Yu,{open:t,onOpenChange:n,children:[w.jsx(Ku,{asChild:!0,children:w.jsx(xt,{variant:"ghost",size:"icon",className:Pe("h-9 w-9",e),children:w.jsx(HW,{className:"h-5 w-5"})})}),w.jsx(Ks,{side:"bottom",align:"end",className:"w-56",children:w.jsxs("div",{className:"flex flex-col gap-4",children:[w.jsxs("div",{className:"flex flex-col gap-2",children:[w.jsx("label",{className:"text-sm font-medium",children:r("settings.language")}),w.jsxs(wf,{value:a,onValueChange:c,children:[w.jsx(Au,{children:w.jsx(xf,{})}),w.jsxs(Ru,{children:[w.jsx(xn,{value:"en",children:"English"}),w.jsx(xn,{value:"zh",children:"中文"}),w.jsx(xn,{value:"fr",children:"Français"}),w.jsx(xn,{value:"ar",children:"العربية"})]})]})]}),w.jsxs("div",{className:"flex flex-col gap-2",children:[w.jsx("label",{className:"text-sm font-medium",children:r("settings.theme")}),w.jsxs(wf,{value:s,onValueChange:d,children:[w.jsx(Au,{children:w.jsx(xf,{})}),w.jsxs(Ru,{children:[w.jsx(xn,{value:"light",children:r("settings.light")}),w.jsx(xn,{value:"dark",children:r("settings.dark")}),w.jsx(xn,{value:"system",children:r("settings.system")})]})]})]})]})})]})}var lm="rovingFocusGroup.onEntryFocus",NQ={bubbles:!1,cancelable:!0},mp="RovingFocusGroup",[Ok,Rj,OQ]=U3(mp),[IQ,Cj]=wr(mp,[OQ]),[DQ,LQ]=IQ(mp),_j=E.forwardRef((e,t)=>w.jsx(Ok.Provider,{scope:e.__scopeRovingFocusGroup,children:w.jsx(Ok.Slot,{scope:e.__scopeRovingFocusGroup,children:w.jsx(MQ,{...e,ref:t})})}));_j.displayName=mp;var MQ=E.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:p=!1,...g}=e,m=E.useRef(null),b=gt(t,m),y=fp(o),[S=null,k]=ja({prop:s,defaultProp:u,onChange:c}),[R,x]=E.useState(!1),A=yn(d),N=Rj(n),O=E.useRef(!1),[C,_]=E.useState(0);return E.useEffect(()=>{const P=m.current;if(P)return P.addEventListener(lm,A),()=>P.removeEventListener(lm,A)},[A]),w.jsx(DQ,{scope:n,orientation:r,dir:y,loop:a,currentTabStopId:S,onItemFocus:E.useCallback(P=>k(P),[k]),onItemShiftTab:E.useCallback(()=>x(!0),[]),onFocusableItemAdd:E.useCallback(()=>_(P=>P+1),[]),onFocusableItemRemove:E.useCallback(()=>_(P=>P-1),[]),children:w.jsx(Ze.div,{tabIndex:R||C===0?-1:0,"data-orientation":r,...g,ref:b,style:{outline:"none",...e.style},onMouseDown:Ke(e.onMouseDown,()=>{O.current=!0}),onFocus:Ke(e.onFocus,P=>{const D=!O.current;if(P.target===P.currentTarget&&D&&!R){const L=new CustomEvent(lm,NQ);if(P.currentTarget.dispatchEvent(L),!L.defaultPrevented){const H=N().filter(j=>j.focusable),$=H.find(j=>j.active),U=H.find(j=>j.id===S),Z=[$,U,...H].filter(Boolean).map(j=>j.ref.current);Ij(Z,p)}}O.current=!1}),onBlur:Ke(e.onBlur,()=>x(!1))})})}),Nj="RovingFocusGroupItem",Oj=E.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:o,...s}=e,u=An(),c=o||u,d=LQ(Nj,n),p=d.currentTabStopId===c,g=Rj(n),{onFocusableItemAdd:m,onFocusableItemRemove:b}=d;return E.useEffect(()=>{if(r)return m(),()=>b()},[r,m,b]),w.jsx(Ok.ItemSlot,{scope:n,id:c,focusable:r,active:a,children:w.jsx(Ze.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...s,ref:t,onMouseDown:Ke(e.onMouseDown,y=>{r?d.onItemFocus(c):y.preventDefault()}),onFocus:Ke(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:Ke(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){d.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const S=zQ(y,d.orientation,d.dir);if(S!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let R=g().filter(x=>x.focusable).map(x=>x.ref.current);if(S==="last")R.reverse();else if(S==="prev"||S==="next"){S==="prev"&&R.reverse();const x=R.indexOf(y.currentTarget);R=d.loop?BQ(R,x+1):R.slice(x+1)}setTimeout(()=>Ij(R))}})})})});Oj.displayName=Nj;var PQ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function FQ(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function zQ(e,t,n){const r=FQ(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return PQ[r]}function Ij(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function BQ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var UQ=_j,jQ=Oj,sT="Tabs",[GQ,zxe]=wr(sT,[Cj]),Dj=Cj(),[HQ,lT]=GQ(sT),Lj=E.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:o,orientation:s="horizontal",dir:u,activationMode:c="automatic",...d}=e,p=fp(u),[g,m]=ja({prop:r,onChange:a,defaultProp:o});return w.jsx(HQ,{scope:n,baseId:An(),value:g,onValueChange:m,orientation:s,dir:p,activationMode:c,children:w.jsx(Ze.div,{dir:p,"data-orientation":s,...d,ref:t})})});Lj.displayName=sT;var Mj="TabsList",Pj=E.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...a}=e,o=lT(Mj,n),s=Dj(n);return w.jsx(UQ,{asChild:!0,...s,orientation:o.orientation,dir:o.dir,loop:r,children:w.jsx(Ze.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:t})})});Pj.displayName=Mj;var Fj="TabsTrigger",zj=E.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...o}=e,s=lT(Fj,n),u=Dj(n),c=jj(s.baseId,r),d=Gj(s.baseId,r),p=r===s.value;return w.jsx(jQ,{asChild:!0,...u,focusable:!a,active:p,children:w.jsx(Ze.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":d,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:c,...o,ref:t,onMouseDown:Ke(e.onMouseDown,g=>{!a&&g.button===0&&g.ctrlKey===!1?s.onValueChange(r):g.preventDefault()}),onKeyDown:Ke(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&s.onValueChange(r)}),onFocus:Ke(e.onFocus,()=>{const g=s.activationMode!=="manual";!p&&!a&&g&&s.onValueChange(r)})})})});zj.displayName=Fj;var Bj="TabsContent",Uj=E.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:a,children:o,...s}=e,u=lT(Bj,n),c=jj(u.baseId,r),d=Gj(u.baseId,r),p=r===u.value,g=E.useRef(p);return E.useEffect(()=>{const m=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(m)},[]),w.jsx(xr,{present:a||p,children:({present:m})=>w.jsx(Ze.div,{"data-state":p?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:d,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:m&&o})})});Uj.displayName=Bj;function jj(e,t){return`${e}-trigger-${t}`}function Gj(e,t){return`${e}-content-${t}`}var $Q=Lj,Hj=Pj,$j=zj,qj=Uj;const qQ=$Q,Vj=E.forwardRef(({className:e,...t},n)=>w.jsx(Hj,{ref:n,className:Pe("bg-muted text-muted-foreground inline-flex h-10 items-center justify-center rounded-md p-1",e),...t}));Vj.displayName=Hj.displayName;const Wj=E.forwardRef(({className:e,...t},n)=>w.jsx($j,{ref:n,className:Pe("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center rounded-sm px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm",e),...t}));Wj.displayName=$j.displayName;const hu=E.forwardRef(({className:e,...t},n)=>w.jsx(qj,{ref:n,className:Pe("ring-offset-background focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none","data-[state=inactive]:invisible data-[state=active]:visible","h-full w-full",e),forceMount:!0,...t}));hu.displayName=qj.displayName;function kd({value:e,currentTab:t,children:n}){return w.jsx(Wj,{value:e,className:Pe("cursor-pointer px-2 py-1 transition-all",t===e?"!bg-emerald-400 !text-zinc-50":"hover:bg-background/60"),children:n})}function VQ(){const e=Le.use.currentTab(),{t}=Pt();return w.jsx("div",{className:"flex h-8 self-center",children:w.jsxs(Vj,{className:"h-full gap-2",children:[w.jsx(kd,{value:"documents",currentTab:e,children:t("header.documents")}),w.jsx(kd,{value:"knowledge-graph",currentTab:e,children:t("header.knowledgeGraph")}),w.jsx(kd,{value:"retrieval",currentTab:e,children:t("header.retrieval")}),w.jsx(kd,{value:"api",currentTab:e,children:t("header.api")})]})})}function WQ(){const{t:e}=Pt(),{isGuestMode:t,coreVersion:n,apiVersion:r}=ra(),a=n&&r?`${n}/${r}`:null,o=()=>{C0.navigateToLogin()};return w.jsxs("header",{className:"border-border/40 bg-background/95 supports-[backdrop-filter]:bg-background/60 sticky top-0 z-50 flex h-10 w-full border-b px-4 backdrop-blur",children:[w.jsxs("a",{href:tV,className:"mr-6 flex items-center gap-2",children:[w.jsx(XB,{className:"size-4 text-emerald-400","aria-hidden":"true"}),w.jsx("span",{className:"font-bold md:inline-block",children:T_.name}),a&&w.jsxs("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400",children:["v",a]})]}),w.jsxs("div",{className:"flex h-10 flex-1 justify-center",children:[w.jsx(VQ,{}),t&&w.jsx("div",{className:"ml-2 self-center px-2 py-1 text-xs bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200 rounded-md",children:e("login.guestMode","Guest Mode")})]}),w.jsx("nav",{className:"flex items-center",children:w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx(xt,{variant:"ghost",size:"icon",side:"bottom",tooltip:e("header.projectRepository"),children:w.jsx("a",{href:T_.github,target:"_blank",rel:"noopener noreferrer",children:w.jsx(NW,{className:"size-4","aria-hidden":"true"})})}),w.jsx(Aj,{}),w.jsx(xt,{variant:"ghost",size:"icon",side:"bottom",tooltip:e("header.logout"),onClick:o,children:w.jsx(FW,{className:"size-4","aria-hidden":"true"})})]})})]})}var Td={exports:{}},tN;function YQ(){if(tN)return Td.exports;tN=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(O,C,_){return Function.prototype.apply.call(O,C,_)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(O){return Object.getOwnPropertyNames(O).concat(Object.getOwnPropertySymbols(O))}:n=function(O){return Object.getOwnPropertyNames(O)};function r(N){console&&console.warn&&console.warn(N)}var a=Number.isNaN||function(O){return O!==O};function o(){o.init.call(this)}Td.exports=o,Td.exports.once=R,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function u(N){if(typeof N!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof N)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(N){if(typeof N!="number"||N<0||a(N))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+N+".");s=N}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(O){if(typeof O!="number"||O<0||a(O))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+O+".");return this._maxListeners=O,this};function c(N){return N._maxListeners===void 0?o.defaultMaxListeners:N._maxListeners}o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(O){for(var C=[],_=1;_0&&(L=C[0]),L instanceof Error)throw L;var H=new Error("Unhandled error."+(L?" ("+L.message+")":""));throw H.context=L,H}var $=D[O];if($===void 0)return!1;if(typeof $=="function")t($,this,C);else for(var U=$.length,W=y($,U),_=0;_0&&L.length>P&&!L.warned){L.warned=!0;var H=new Error("Possible EventEmitter memory leak detected. "+L.length+" "+String(O)+" listeners added. Use emitter.setMaxListeners() to increase limit");H.name="MaxListenersExceededWarning",H.emitter=N,H.type=O,H.count=L.length,r(H)}return N}o.prototype.addListener=function(O,C){return d(this,O,C,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(O,C){return d(this,O,C,!0)};function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function g(N,O,C){var _={fired:!1,wrapFn:void 0,target:N,type:O,listener:C},P=p.bind(_);return P.listener=C,_.wrapFn=P,P}o.prototype.once=function(O,C){return u(C),this.on(O,g(this,O,C)),this},o.prototype.prependOnceListener=function(O,C){return u(C),this.prependListener(O,g(this,O,C)),this},o.prototype.removeListener=function(O,C){var _,P,D,L,H;if(u(C),P=this._events,P===void 0)return this;if(_=P[O],_===void 0)return this;if(_===C||_.listener===C)--this._eventsCount===0?this._events=Object.create(null):(delete P[O],P.removeListener&&this.emit("removeListener",O,_.listener||C));else if(typeof _!="function"){for(D=-1,L=_.length-1;L>=0;L--)if(_[L]===C||_[L].listener===C){H=_[L].listener,D=L;break}if(D<0)return this;D===0?_.shift():S(_,D),_.length===1&&(P[O]=_[0]),P.removeListener!==void 0&&this.emit("removeListener",O,H||C)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(O){var C,_,P;if(_=this._events,_===void 0)return this;if(_.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):_[O]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete _[O]),this;if(arguments.length===0){var D=Object.keys(_),L;for(P=0;P=0;P--)this.removeListener(O,C[P]);return this};function m(N,O,C){var _=N._events;if(_===void 0)return[];var P=_[O];return P===void 0?[]:typeof P=="function"?C?[P.listener||P]:[P]:C?k(P):y(P,P.length)}o.prototype.listeners=function(O){return m(this,O,!0)},o.prototype.rawListeners=function(O){return m(this,O,!1)},o.listenerCount=function(N,O){return typeof N.listenerCount=="function"?N.listenerCount(O):b.call(N,O)},o.prototype.listenerCount=b;function b(N){var O=this._events;if(O!==void 0){var C=O[N];if(typeof C=="function")return 1;if(C!==void 0)return C.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function y(N,O){for(var C=new Array(O),_=0;_e++}function Ba(){const e=arguments;let t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done){t=null;continue}break}while(!0);return r}}}function Zs(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class uT extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class Me extends uT{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Me.prototype.constructor)}}class Ie extends uT{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Ie.prototype.constructor)}}class Qe extends uT{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Qe.prototype.constructor)}}function Xj(e,t){this.key=e,this.attributes=t,this.clear()}Xj.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Zj(e,t){this.key=e,this.attributes=t,this.clear()}Zj.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Qj(e,t){this.key=e,this.attributes=t,this.clear()}Qj.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Qs(e,t,n,r,a){this.key=t,this.attributes=a,this.undirected=e,this.source=n,this.target=r}Qs.prototype.attach=function(){let e="out",t="in";this.undirected&&(e=t="undirected");const n=this.source.key,r=this.target.key;this.source[e][r]=this,!(this.undirected&&n===r)&&(this.target[t][n]=this)};Qs.prototype.attachMulti=function(){let e="out",t="in";const n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");const a=this.source[e],o=a[r];if(typeof o>"u"){a[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}o.previous=this,this.next=o,a[r]=this,this.target[t][n]=this};Qs.prototype.detach=function(){const e=this.source.key,t=this.target.key;let n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][t],delete this.target[r][e]};Qs.prototype.detachMulti=function(){const e=this.source.key,t=this.target.key;let n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Jj=0,e4=1,ZQ=2,t4=3;function Wa(e,t,n,r,a,o,s){let u,c,d,p;if(r=""+r,n===Jj){if(u=e._nodes.get(r),!u)throw new Ie(`Graph.${t}: could not find the "${r}" node in the graph.`);d=a,p=o}else if(n===t4){if(a=""+a,c=e._edges.get(a),!c)throw new Ie(`Graph.${t}: could not find the "${a}" edge in the graph.`);const g=c.source.key,m=c.target.key;if(r===g)u=c.target;else if(r===m)u=c.source;else throw new Ie(`Graph.${t}: the "${r}" node is not attached to the "${a}" edge (${g}, ${m}).`);d=o,p=s}else{if(c=e._edges.get(r),!c)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===e4?u=c.source:u=c.target,d=a,p=o}return[u,d,p]}function QQ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);return s.attributes[u]}}function JQ(e,t,n){e.prototype[t]=function(r,a){const[o]=Wa(this,t,n,r,a);return o.attributes}}function eJ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);return s.attributes.hasOwnProperty(u)}}function tJ(e,t,n){e.prototype[t]=function(r,a,o,s){const[u,c,d]=Wa(this,t,n,r,a,o,s);return u.attributes[c]=d,this.emit("nodeAttributesUpdated",{key:u.key,type:"set",attributes:u.attributes,name:c}),this}}function nJ(e,t,n){e.prototype[t]=function(r,a,o,s){const[u,c,d]=Wa(this,t,n,r,a,o,s);if(typeof d!="function")throw new Me(`Graph.${t}: updater should be a function.`);const p=u.attributes,g=d(p[c]);return p[c]=g,this.emit("nodeAttributesUpdated",{key:u.key,type:"set",attributes:u.attributes,name:c}),this}}function rJ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);return delete s.attributes[u],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:u}),this}}function aJ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);if(!vn(u))throw new Me(`Graph.${t}: provided attributes are not a plain object.`);return s.attributes=u,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function oJ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);if(!vn(u))throw new Me(`Graph.${t}: provided attributes are not a plain object.`);return nn(s.attributes,u),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:u}),this}}function iJ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);if(typeof u!="function")throw new Me(`Graph.${t}: provided updater is not a function.`);return s.attributes=u(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const sJ=[{name:e=>`get${e}Attribute`,attacher:QQ},{name:e=>`get${e}Attributes`,attacher:JQ},{name:e=>`has${e}Attribute`,attacher:eJ},{name:e=>`set${e}Attribute`,attacher:tJ},{name:e=>`update${e}Attribute`,attacher:nJ},{name:e=>`remove${e}Attribute`,attacher:rJ},{name:e=>`replace${e}Attributes`,attacher:aJ},{name:e=>`merge${e}Attributes`,attacher:oJ},{name:e=>`update${e}Attributes`,attacher:iJ}];function lJ(e){sJ.forEach(function({name:t,attacher:n}){n(e,t("Node"),Jj),n(e,t("Source"),e4),n(e,t("Target"),ZQ),n(e,t("Opposite"),t4)})}function uJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[a]}}function cJ(e,t,n){e.prototype[t]=function(r){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+r,s=""+arguments[1];if(a=Er(this,o,s,n),!a)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return a.attributes}}function dJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(a)}}function fJ(e,t,n){e.prototype[t]=function(r,a,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+r,c=""+a;if(a=arguments[2],o=arguments[3],s=Er(this,u,c,n),!s)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${u}" - "${c}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,s=this._edges.get(r),!s)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return s.attributes[a]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:a}),this}}function pJ(e,t,n){e.prototype[t]=function(r,a,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+r,c=""+a;if(a=arguments[2],o=arguments[3],s=Er(this,u,c,n),!s)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${u}" - "${c}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,s=this._edges.get(r),!s)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new Me(`Graph.${t}: updater should be a function.`);return s.attributes[a]=o(s.attributes[a]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:a}),this}}function gJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[a],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:a}),this}}function hJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!vn(a))throw new Me(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=a,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function mJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!vn(a))throw new Me(`Graph.${t}: provided attributes are not a plain object.`);return nn(o.attributes,a),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:a}),this}}function bJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof a!="function")throw new Me(`Graph.${t}: provided updater is not a function.`);return o.attributes=a(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const yJ=[{name:e=>`get${e}Attribute`,attacher:uJ},{name:e=>`get${e}Attributes`,attacher:cJ},{name:e=>`has${e}Attribute`,attacher:dJ},{name:e=>`set${e}Attribute`,attacher:fJ},{name:e=>`update${e}Attribute`,attacher:pJ},{name:e=>`remove${e}Attribute`,attacher:gJ},{name:e=>`replace${e}Attributes`,attacher:hJ},{name:e=>`merge${e}Attributes`,attacher:mJ},{name:e=>`update${e}Attributes`,attacher:bJ}];function vJ(e){yJ.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const SJ=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function EJ(e,t,n,r){let a=!1;for(const o in t){if(o===r)continue;const s=t[o];if(a=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),e&&a)return s.key}}function wJ(e,t,n,r){let a,o,s,u=!1;for(const c in t)if(c!==r){a=t[c];do{if(o=a.source,s=a.target,u=n(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected),e&&u)return a.key;a=a.next}while(a!==void 0)}}function um(e,t){const n=Object.keys(e),r=n.length;let a,o=0;return{[Symbol.iterator](){return this},next(){do if(a)a=a.next;else{if(o>=r)return{done:!0};const s=n[o++];if(s===t){a=void 0;continue}a=e[s]}while(!a);return{done:!1,value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected}}}}}function xJ(e,t,n,r){const a=t[n];if(!a)return;const o=a.source,s=a.target;if(r(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected)&&e)return a.key}function kJ(e,t,n,r){let a=t[n];if(!a)return;let o=!1;do{if(o=r(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),e&&o)return a.key;a=a.next}while(a!==void 0)}function cm(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};const a={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:a}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function TJ(e,t){if(e.size===0)return[];if(t==="mixed"||t===e.type)return Array.from(e._edges.keys());const n=t==="undirected"?e.undirectedSize:e.directedSize,r=new Array(n),a=t==="undirected",o=e._edges.values();let s=0,u,c;for(;u=o.next(),u.done!==!0;)c=u.value,c.undirected===a&&(r[s++]=c.key);return r}function n4(e,t,n,r){if(t.size===0)return;const a=n!=="mixed"&&n!==t.type,o=n==="undirected";let s,u,c=!1;const d=t._edges.values();for(;s=d.next(),s.done!==!0;){if(u=s.value,a&&u.undirected!==o)continue;const{key:p,attributes:g,source:m,target:b}=u;if(c=r(p,g,m.key,b.key,m.attributes,b.attributes,u.undirected),e&&c)return p}}function AJ(e,t){if(e.size===0)return Zs();const n=t!=="mixed"&&t!==e.type,r=t==="undirected",a=e._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=a.next(),o.done)return o;if(s=o.value,!(n&&s.undirected!==r))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function cT(e,t,n,r,a,o){const s=t?wJ:EJ;let u;if(n!=="undirected"&&(r!=="out"&&(u=s(e,a.in,o),e&&u)||r!=="in"&&(u=s(e,a.out,o,r?void 0:a.key),e&&u))||n!=="directed"&&(u=s(e,a.undirected,o),e&&u))return u}function RJ(e,t,n,r){const a=[];return cT(!1,e,t,n,r,function(o){a.push(o)}),a}function CJ(e,t,n){let r=Zs();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=Ba(r,um(n.in))),t!=="in"&&typeof n.out<"u"&&(r=Ba(r,um(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=Ba(r,um(n.undirected))),r}function dT(e,t,n,r,a,o,s){const u=n?kJ:xJ;let c;if(t!=="undirected"&&(typeof a.in<"u"&&r!=="out"&&(c=u(e,a.in,o,s),e&&c)||typeof a.out<"u"&&r!=="in"&&(r||a.key!==o)&&(c=u(e,a.out,o,s),e&&c))||t!=="directed"&&typeof a.undirected<"u"&&(c=u(e,a.undirected,o,s),e&&c))return c}function _J(e,t,n,r,a){const o=[];return dT(!1,e,t,n,r,a,function(s){o.push(s)}),o}function NJ(e,t,n,r){let a=Zs();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(a=Ba(a,cm(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(a=Ba(a,cm(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(a=Ba(a,cm(n.undirected,r))),a}function OJ(e,t){const{name:n,type:r,direction:a}=t;e.prototype[n]=function(o,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return TJ(this,r);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(typeof u>"u")throw new Ie(`Graph.${n}: could not find the "${o}" node in the graph.`);return RJ(this.multi,r==="mixed"?this.type:r,a,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new Ie(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new Ie(`Graph.${n}: could not find the "${s}" target node in the graph.`);return _J(r,this.multi,a,u,s)}throw new Me(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function IJ(e,t){const{name:n,type:r,direction:a}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(d,p,g){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return g=d,n4(!1,this,r,g);if(arguments.length===2){d=""+d,g=p;const m=this._nodes.get(d);if(typeof m>"u")throw new Ie(`Graph.${o}: could not find the "${d}" node in the graph.`);return cT(!1,this.multi,r==="mixed"?this.type:r,a,m,g)}if(arguments.length===3){d=""+d,p=""+p;const m=this._nodes.get(d);if(!m)throw new Ie(`Graph.${o}: could not find the "${d}" source node in the graph.`);if(!this._nodes.has(p))throw new Ie(`Graph.${o}: could not find the "${p}" target node in the graph.`);return dT(!1,r,this.multi,a,m,p,g)}throw new Me(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){const d=Array.prototype.slice.call(arguments),p=d.pop();let g;if(d.length===0){let m=0;r!=="directed"&&(m+=this.undirectedSize),r!=="undirected"&&(m+=this.directedSize),g=new Array(m);let b=0;d.push((y,S,k,R,x,A,N)=>{g[b++]=p(y,S,k,R,x,A,N)})}else g=[],d.push((m,b,y,S,k,R,x)=>{g.push(p(m,b,y,S,k,R,x))});return this[o].apply(this,d),g};const u="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[u]=function(){const d=Array.prototype.slice.call(arguments),p=d.pop(),g=[];return d.push((m,b,y,S,k,R,x)=>{p(m,b,y,S,k,R,x)&&g.push(m)}),this[o].apply(this,d),g};const c="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(){let d=Array.prototype.slice.call(arguments);if(d.length<2||d.length>4)throw new Me(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${d.length}).`);if(typeof d[d.length-1]=="function"&&typeof d[d.length-2]!="function")throw new Me(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let p,g;d.length===2?(p=d[0],g=d[1],d=[]):d.length===3?(p=d[1],g=d[2],d=[d[0]]):d.length===4&&(p=d[2],g=d[3],d=[d[0],d[1]]);let m=g;return d.push((b,y,S,k,R,x,A)=>{m=p(m,b,y,S,k,R,x,A)}),this[o].apply(this,d),m}}function DJ(e,t){const{name:n,type:r,direction:a}=t,o="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,d,p){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return p=c,n4(!0,this,r,p);if(arguments.length===2){c=""+c,p=d;const g=this._nodes.get(c);if(typeof g>"u")throw new Ie(`Graph.${o}: could not find the "${c}" node in the graph.`);return cT(!0,this.multi,r==="mixed"?this.type:r,a,g,p)}if(arguments.length===3){c=""+c,d=""+d;const g=this._nodes.get(c);if(!g)throw new Ie(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(d))throw new Ie(`Graph.${o}: could not find the "${d}" target node in the graph.`);return dT(!0,r,this.multi,a,g,d,p)}throw new Me(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){const c=Array.prototype.slice.call(arguments),d=c.pop();return c.push((g,m,b,y,S,k,R)=>d(g,m,b,y,S,k,R)),!!this[o].apply(this,c)};const u="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[u]=function(){const c=Array.prototype.slice.call(arguments),d=c.pop();return c.push((g,m,b,y,S,k,R)=>!d(g,m,b,y,S,k,R)),!this[o].apply(this,c)}}function LJ(e,t){const{name:n,type:r,direction:a}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Zs();if(!arguments.length)return AJ(this,r);if(arguments.length===1){s=""+s;const c=this._nodes.get(s);if(!c)throw new Ie(`Graph.${o}: could not find the "${s}" node in the graph.`);return CJ(r,a,c)}if(arguments.length===2){s=""+s,u=""+u;const c=this._nodes.get(s);if(!c)throw new Ie(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(u))throw new Ie(`Graph.${o}: could not find the "${u}" target node in the graph.`);return NJ(r,a,c,u)}throw new Me(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function MJ(e){SJ.forEach(t=>{OJ(e,t),IJ(e,t),DJ(e,t),LJ(e,t)})}const PJ=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function bp(){this.A=null,this.B=null}bp.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};bp.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function ru(e,t,n,r,a){for(const o in r){const s=r[o],u=s.source,c=s.target,d=u===n?c:u;if(t&&t.has(d.key))continue;const p=a(d.key,d.attributes);if(e&&p)return d.key}}function fT(e,t,n,r,a){if(t!=="mixed"){if(t==="undirected")return ru(e,null,r,r.undirected,a);if(typeof n=="string")return ru(e,null,r,r[n],a)}const o=new bp;let s;if(t!=="undirected"){if(n!=="out"){if(s=ru(e,null,r,r.in,a),e&&s)return s;o.wrap(r.in)}if(n!=="in"){if(s=ru(e,o,r,r.out,a),e&&s)return s;o.wrap(r.out)}}if(t!=="directed"&&(s=ru(e,o,r,r.undirected,a),e&&s))return s}function FJ(e,t,n){if(e!=="mixed"){if(e==="undirected")return Object.keys(n.undirected);if(typeof t=="string")return Object.keys(n[t])}const r=[];return fT(!1,e,t,n,function(a){r.push(a)}),r}function au(e,t,n){const r=Object.keys(n),a=r.length;let o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=a)return e&&e.wrap(n),{done:!0};const u=n[r[o++]],c=u.source,d=u.target;if(s=c===t?d:c,e&&e.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function zJ(e,t,n){if(e!=="mixed"){if(e==="undirected")return au(null,n,n.undirected);if(typeof t=="string")return au(null,n,n[t])}let r=Zs();const a=new bp;return e!=="undirected"&&(t!=="out"&&(r=Ba(r,au(a,n,n.in))),t!=="in"&&(r=Ba(r,au(a,n,n.out)))),e!=="directed"&&(r=Ba(r,au(a,n,n.undirected))),r}function BJ(e,t){const{name:n,type:r,direction:a}=t;e.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new Ie(`Graph.${n}: could not find the "${o}" node in the graph.`);return FJ(r==="mixed"?this.type:r,a,s)}}function UJ(e,t){const{name:n,type:r,direction:a}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(d,p){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;d=""+d;const g=this._nodes.get(d);if(typeof g>"u")throw new Ie(`Graph.${o}: could not find the "${d}" node in the graph.`);fT(!1,r==="mixed"?this.type:r,a,g,p)};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(d,p){const g=[];return this[o](d,(m,b)=>{g.push(p(m,b))}),g};const u="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[u]=function(d,p){const g=[];return this[o](d,(m,b)=>{p(m,b)&&g.push(m)}),g};const c="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(d,p,g){if(arguments.length<3)throw new Me(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let m=g;return this[o](d,(b,y)=>{m=p(m,b,y)}),m}}function jJ(e,t){const{name:n,type:r,direction:a}=t,o=n[0].toUpperCase()+n.slice(1,-1),s="find"+o;e.prototype[s]=function(d,p){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;d=""+d;const g=this._nodes.get(d);if(typeof g>"u")throw new Ie(`Graph.${s}: could not find the "${d}" node in the graph.`);return fT(!0,r==="mixed"?this.type:r,a,g,p)};const u="some"+o;e.prototype[u]=function(d,p){return!!this[s](d,p)};const c="every"+o;e.prototype[c]=function(d,p){return!this[s](d,(m,b)=>!p(m,b))}}function GJ(e,t){const{name:n,type:r,direction:a}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Zs();s=""+s;const u=this._nodes.get(s);if(typeof u>"u")throw new Ie(`Graph.${o}: could not find the "${s}" node in the graph.`);return zJ(r==="mixed"?this.type:r,a,u)}}function HJ(e){PJ.forEach(t=>{BJ(e,t),UJ(e,t),jJ(e,t),GJ(e,t)})}function Ad(e,t,n,r,a){const o=r._nodes.values(),s=r.type;let u,c,d,p,g,m;for(;u=o.next(),u.done!==!0;){let b=!1;if(c=u.value,s!=="undirected"){p=c.out;for(d in p){g=p[d];do m=g.target,b=!0,a(c.key,m.key,c.attributes,m.attributes,g.key,g.attributes,g.undirected),g=g.next;while(g)}}if(s!=="directed"){p=c.undirected;for(d in p)if(!(t&&c.key>d)){g=p[d];do m=g.target,m.key!==d&&(m=g.source),b=!0,a(c.key,m.key,c.attributes,m.attributes,g.key,g.attributes,g.undirected),g=g.next;while(g)}}n&&!b&&a(c.key,null,c.attributes,null,null,null,null)}}function $J(e,t){const n={key:e};return Kj(t.attributes)||(n.attributes=nn({},t.attributes)),n}function qJ(e,t,n){const r={key:t,source:n.source.key,target:n.target.key};return Kj(n.attributes)||(r.attributes=nn({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function VJ(e){if(!vn(e))throw new Me('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new Me("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!vn(e.attributes)||e.attributes===null))throw new Me("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function WJ(e){if(!vn(e))throw new Me('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new Me("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new Me("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!vn(e.attributes)||e.attributes===null))throw new Me("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new Me("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const YJ=XQ(),KJ=new Set(["directed","undirected","mixed"]),rN=new Set(["domain","_events","_eventsCount","_maxListeners"]),XJ=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:"directed"},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:"directed"},{name:e=>`${e}UndirectedEdgeWithKey`,type:"undirected"}],ZJ={allowSelfLoops:!0,multi:!1,type:"mixed"};function QJ(e,t,n){if(n&&!vn(n))throw new Me(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new Qe(`Graph.addNode: the "${t}" node already exist in the graph.`);const r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function aN(e,t,n){const r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function r4(e,t,n,r,a,o,s,u){if(!r&&e.type==="undirected")throw new Qe(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new Qe(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(u&&!vn(u))throw new Me(`Graph.${t}: invalid attributes. Expecting an object but got "${u}"`);if(o=""+o,s=""+s,u=u||{},!e.allowSelfLoops&&o===s)throw new Qe(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const c=e._nodes.get(o),d=e._nodes.get(s);if(!c)throw new Ie(`Graph.${t}: source node "${o}" not found.`);if(!d)throw new Ie(`Graph.${t}: target node "${s}" not found.`);const p={key:null,undirected:r,source:o,target:s,attributes:u};if(n)a=e._edgeKeyGenerator();else if(a=""+a,e._edges.has(a))throw new Qe(`Graph.${t}: the "${a}" edge already exists in the graph.`);if(!e.multi&&(r?typeof c.undirected[s]<"u":typeof c.out[s]<"u"))throw new Qe(`Graph.${t}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const g=new Qs(r,a,c,d,u);e._edges.set(a,g);const m=o===s;return r?(c.undirectedDegree++,d.undirectedDegree++,m&&(c.undirectedLoops++,e._undirectedSelfLoopCount++)):(c.outDegree++,d.inDegree++,m&&(c.directedLoops++,e._directedSelfLoopCount++)),e.multi?g.attachMulti():g.attach(),r?e._undirectedSize++:e._directedSize++,p.key=a,e.emit("edgeAdded",p),a}function JJ(e,t,n,r,a,o,s,u,c){if(!r&&e.type==="undirected")throw new Qe(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new Qe(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(u){if(c){if(typeof u!="function")throw new Me(`Graph.${t}: invalid updater function. Expecting a function but got "${u}"`)}else if(!vn(u))throw new Me(`Graph.${t}: invalid attributes. Expecting an object but got "${u}"`)}o=""+o,s=""+s;let d;if(c&&(d=u,u=void 0),!e.allowSelfLoops&&o===s)throw new Qe(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let p=e._nodes.get(o),g=e._nodes.get(s),m,b;if(!n&&(m=e._edges.get(a),m)){if((m.source.key!==o||m.target.key!==s)&&(!r||m.source.key!==s||m.target.key!==o))throw new Qe(`Graph.${t}: inconsistency detected when attempting to merge the "${a}" edge with "${o}" source & "${s}" target vs. ("${m.source.key}", "${m.target.key}").`);b=m}if(!b&&!e.multi&&p&&(b=r?p.undirected[s]:p.out[s]),b){const x=[b.key,!1,!1,!1];if(c?!d:!u)return x;if(c){const A=b.attributes;b.attributes=d(A),e.emit("edgeAttributesUpdated",{type:"replace",key:b.key,attributes:b.attributes})}else nn(b.attributes,u),e.emit("edgeAttributesUpdated",{type:"merge",key:b.key,attributes:b.attributes,data:u});return x}u=u||{},c&&d&&(u=d(u));const y={key:null,undirected:r,source:o,target:s,attributes:u};if(n)a=e._edgeKeyGenerator();else if(a=""+a,e._edges.has(a))throw new Qe(`Graph.${t}: the "${a}" edge already exists in the graph.`);let S=!1,k=!1;p||(p=aN(e,o,{}),S=!0,o===s&&(g=p,k=!0)),g||(g=aN(e,s,{}),k=!0),m=new Qs(r,a,p,g,u),e._edges.set(a,m);const R=o===s;return r?(p.undirectedDegree++,g.undirectedDegree++,R&&(p.undirectedLoops++,e._undirectedSelfLoopCount++)):(p.outDegree++,g.inDegree++,R&&(p.directedLoops++,e._directedSelfLoopCount++)),e.multi?m.attachMulti():m.attach(),r?e._undirectedSize++:e._directedSize++,y.key=a,e.emit("edgeAdded",y),[a,!0,S,k]}function ps(e,t){e._edges.delete(t.key);const{source:n,target:r,attributes:a}=t,o=t.undirected,s=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,s&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,s&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),o?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:a,source:n.key,target:r.key,undirected:o})}class Ct extends Yj.EventEmitter{constructor(t){if(super(),t=nn({},ZJ,t),typeof t.multi!="boolean")throw new Me(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!KJ.has(t.type))throw new Me(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new Me(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?Xj:t.type==="directed"?Zj:Qj;yr(this,"NodeDataClass",n);const r="geid_"+YJ()+"_";let a=0;const o=()=>{let s;do s=r+a++;while(this._edges.has(s));return s};yr(this,"_attributes",{}),yr(this,"_nodes",new Map),yr(this,"_edges",new Map),yr(this,"_directedSize",0),yr(this,"_undirectedSize",0),yr(this,"_directedSelfLoopCount",0),yr(this,"_undirectedSelfLoopCount",0),yr(this,"_edgeKeyGenerator",o),yr(this,"_options",t),rN.forEach(s=>yr(this,s,this[s])),Dr(this,"order",()=>this._nodes.size),Dr(this,"size",()=>this._edges.size),Dr(this,"directedSize",()=>this._directedSize),Dr(this,"undirectedSize",()=>this._undirectedSize),Dr(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Dr(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Dr(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Dr(this,"multi",this._options.multi),Dr(this,"type",this._options.type),Dr(this,"allowSelfLoops",this._options.allowSelfLoops),Dr(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(t){return this._nodes.has(""+t)}hasDirectedEdge(t,n){if(this.type==="undirected")return!1;if(arguments.length===1){const r=""+t,a=this._edges.get(r);return!!a&&!a.undirected}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?r.out.hasOwnProperty(n):!1}throw new Me(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(t,n){if(this.type==="directed")return!1;if(arguments.length===1){const r=""+t,a=this._edges.get(r);return!!a&&a.undirected}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?r.undirected.hasOwnProperty(n):!1}throw new Me(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(t,n){if(arguments.length===1){const r=""+t;return this._edges.has(r)}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new Me(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(t,n){if(this.type==="undirected")return;if(t=""+t,n=""+n,this.multi)throw new Qe("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Ie(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);const a=r.out&&r.out[n]||void 0;if(a)return a.key}undirectedEdge(t,n){if(this.type==="directed")return;if(t=""+t,n=""+n,this.multi)throw new Qe("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Ie(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);const a=r.undirected&&r.undirected[n]||void 0;if(a)return a.key}edge(t,n){if(this.multi)throw new Qe("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Ie(`Graph.edge: could not find the "${n}" target node in the graph.`);const a=r.out&&r.out[n]||r.undirected&&r.undirected[n]||void 0;if(a)return a.key}areDirectedNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areDirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areOutNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areInNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areUndirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areInboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areOutboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.inDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.outDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.directedDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.undirectedDegree: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.inboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.outboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.degree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.inDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.outDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.directedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,a=0;return this.type!=="directed"&&(r+=n.undirectedDegree,a+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree,a+=n.directedLoops),r-a}outboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,a=0;return this.type!=="directed"&&(r+=n.undirectedDegree,a+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.outDegree,a+=n.directedLoops),r-a}degreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.degreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,a=0;return this.type!=="directed"&&(r+=n.undirectedDegree,a+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree,a+=n.directedLoops*2),r-a}source(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.source: could not find the "${t}" edge in the graph.`);return n.source.key}target(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.target: could not find the "${t}" edge in the graph.`);return n.target.key}extremities(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.extremities: could not find the "${t}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(t,n){t=""+t,n=""+n;const r=this._edges.get(n);if(!r)throw new Ie(`Graph.opposite: could not find the "${n}" edge in the graph.`);const a=r.source.key,o=r.target.key;if(t===a)return o;if(t===o)return a;throw new Ie(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${a}, ${o}).`)}hasExtremity(t,n){t=""+t,n=""+n;const r=this._edges.get(t);if(!r)throw new Ie(`Graph.hasExtremity: could not find the "${t}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.isUndirected: could not find the "${t}" edge in the graph.`);return n.undirected}isDirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.isDirected: could not find the "${t}" edge in the graph.`);return!n.undirected}isSelfLoop(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return QJ(this,t,n).key}mergeNode(t,n){if(n&&!vn(n))throw new Me(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(nn(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:r.attributes,data:n})),[t,!1]):(r=new this.NodeDataClass(t,n),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:n}),[t,!0])}updateNode(t,n){if(n&&typeof n!="function")throw new Me(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let r=this._nodes.get(t);if(r){if(n){const o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:r.attributes})}return[t,!1]}const a=n?n({}):{};return r=new this.NodeDataClass(t,a),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:a}),[t,!0]}dropNode(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.dropNode: could not find the "${t}" node in the graph.`);let r;if(this.type!=="undirected"){for(const a in n.out){r=n.out[a];do ps(this,r),r=r.next;while(r)}for(const a in n.in){r=n.in[a];do ps(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(const a in n.undirected){r=n.undirected[a];do ps(this,r),r=r.next;while(r)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})}dropEdge(t){let n;if(arguments.length>1){const r=""+arguments[0],a=""+arguments[1];if(n=Er(this,r,a,this.type),!n)throw new Ie(`Graph.dropEdge: could not find the "${r}" -> "${a}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new Ie(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return ps(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new Qe("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new Qe("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");t=""+t,n=""+n;const r=Er(this,t,n,"directed");if(!r)throw new Ie(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return ps(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new Qe("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new Qe("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const r=Er(this,t,n,"undirected");if(!r)throw new Ie(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return ps(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const t=this._nodes.values();let n;for(;n=t.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(t){return this._attributes[t]}getAttributes(){return this._attributes}hasAttribute(t){return this._attributes.hasOwnProperty(t)}setAttribute(t,n){return this._attributes[t]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}updateAttribute(t,n){if(typeof n!="function")throw new Me("Graph.updateAttribute: updater should be a function.");const r=this._attributes[t];return this._attributes[t]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}removeAttribute(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this}replaceAttributes(t){if(!vn(t))throw new Me("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(t){if(!vn(t))throw new Me("Graph.mergeAttributes: provided attributes are not a plain object.");return nn(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new Me("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(t,n){if(typeof t!="function")throw new Me("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!nN(n))throw new Me("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const r=this._nodes.values();let a,o;for(;a=r.next(),a.done!==!0;)o=a.value,o.attributes=t(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new Me("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!nN(n))throw new Me("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const r=this._edges.values();let a,o,s,u;for(;a=r.next(),a.done!==!0;)o=a.value,s=o.source,u=o.target,o.attributes=t(o.key,o.attributes,s.key,u.key,s.attributes,u.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new Me("Graph.forEachAdjacencyEntry: expecting a callback.");Ad(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new Me("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Ad(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new Me("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Ad(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new Me("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Ad(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new Me("Graph.forEachNode: expecting a callback.");const n=this._nodes.values();let r,a;for(;r=n.next(),r.done!==!0;)a=r.value,t(a.key,a.attributes)}findNode(t){if(typeof t!="function")throw new Me("Graph.findNode: expecting a callback.");const n=this._nodes.values();let r,a;for(;r=n.next(),r.done!==!0;)if(a=r.value,t(a.key,a.attributes))return a.key}mapNodes(t){if(typeof t!="function")throw new Me("Graph.mapNode: expecting a callback.");const n=this._nodes.values();let r,a;const o=new Array(this.order);let s=0;for(;r=n.next(),r.done!==!0;)a=r.value,o[s++]=t(a.key,a.attributes);return o}someNode(t){if(typeof t!="function")throw new Me("Graph.someNode: expecting a callback.");const n=this._nodes.values();let r,a;for(;r=n.next(),r.done!==!0;)if(a=r.value,t(a.key,a.attributes))return!0;return!1}everyNode(t){if(typeof t!="function")throw new Me("Graph.everyNode: expecting a callback.");const n=this._nodes.values();let r,a;for(;r=n.next(),r.done!==!0;)if(a=r.value,!t(a.key,a.attributes))return!1;return!0}filterNodes(t){if(typeof t!="function")throw new Me("Graph.filterNodes: expecting a callback.");const n=this._nodes.values();let r,a;const o=[];for(;r=n.next(),r.done!==!0;)a=r.value,t(a.key,a.attributes)&&o.push(a.key);return o}reduceNodes(t,n){if(typeof t!="function")throw new Me("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new Me("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let r=n;const a=this._nodes.values();let o,s;for(;o=a.next(),o.done!==!0;)s=o.value,r=t(r,s.key,s.attributes);return r}nodeEntries(){const t=this._nodes.values();return{[Symbol.iterator](){return this},next(){const n=t.next();if(n.done)return n;const r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){const t=new Array(this._nodes.size);let n=0;this._nodes.forEach((a,o)=>{t[n++]=$J(o,a)});const r=new Array(this._edges.size);return n=0,this._edges.forEach((a,o)=>{r[n++]=qJ(this.type,o,a)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:r}}import(t,n=!1){if(t instanceof Ct)return t.forEachNode((c,d)=>{n?this.mergeNode(c,d):this.addNode(c,d)}),t.forEachEdge((c,d,p,g,m,b,y)=>{n?y?this.mergeUndirectedEdgeWithKey(c,p,g,d):this.mergeDirectedEdgeWithKey(c,p,g,d):y?this.addUndirectedEdgeWithKey(c,p,g,d):this.addDirectedEdgeWithKey(c,p,g,d)}),this;if(!vn(t))throw new Me("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!vn(t.attributes))throw new Me("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,a,o,s,u;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new Me("Graph.import: invalid nodes. Expecting an array.");for(r=0,a=o.length;r{const o=nn({},r.attributes);r=new n.NodeDataClass(a,o),n._nodes.set(a,r)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new Qe(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${t.type}" because this would mean losing information about the current graph.`);if(typeof t.multi=="boolean"&&t.multi!==this.multi&&t.multi!==!0)throw new Qe("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof t.allowSelfLoops=="boolean"&&t.allowSelfLoops!==this.allowSelfLoops&&t.allowSelfLoops!==!0)throw new Qe("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const n=this.emptyCopy(t),r=this._edges.values();let a,o;for(;a=r.next(),a.done!==!0;)o=a.value,r4(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,nn({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const t={};this._nodes.forEach((o,s)=>{t[s]=o.attributes});const n={},r={};this._edges.forEach((o,s)=>{const u=o.undirected?"--":"->";let c="",d=o.source.key,p=o.target.key,g;o.undirected&&d>p&&(g=d,d=p,p=g);const m=`(${d})${u}(${p})`;s.startsWith("geid_")?this.multi&&(typeof r[m]>"u"?r[m]=0:r[m]++,c+=`${r[m]}. `):c+=`[${s}]: `,c+=m,n[c]=o.attributes});const a={};for(const o in this)this.hasOwnProperty(o)&&!rN.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(a[o]=this[o]);return a.attributes=this._attributes,a.nodes=t,a.edges=n,yr(a,"constructor",this.constructor),a}}typeof Symbol<"u"&&(Ct.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ct.prototype.inspect);XJ.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),r=t==="add"?r4:JJ;e.generateKey?Ct.prototype[n]=function(a,o,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,a,o,s,t==="update")}:Ct.prototype[n]=function(a,o,s,u){return r(this,n,!1,(e.type||this.type)==="undirected",a,o,s,u,t==="update")}})});lJ(Ct);vJ(Ct);MJ(Ct);HJ(Ct);class Cu extends Ct{constructor(t){const n=nn({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new Me("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new Me('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class a4 extends Ct{constructor(t){const n=nn({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new Me("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new Me('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class o4 extends Ct{constructor(t){const n=nn({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Me("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class i4 extends Ct{constructor(t){const n=nn({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Me("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new Me('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class s4 extends Ct{constructor(t){const n=nn({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Me("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new Me('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function Js(e){e.from=function(t,n){const r=nn({},t.options,n),a=new e(r);return a.import(t),a}}Js(Ct);Js(Cu);Js(a4);Js(o4);Js(i4);Js(s4);Ct.Graph=Ct;Ct.DirectedGraph=Cu;Ct.UndirectedGraph=a4;Ct.MultiGraph=o4;Ct.MultiDirectedGraph=i4;Ct.MultiUndirectedGraph=s4;Ct.InvalidArgumentsGraphError=Me;Ct.NotFoundGraphError=Ie;Ct.UsageGraphError=Qe;function eee(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function mu(e){var t=eee(e,"string");return typeof t=="symbol"?t:t+""}function dn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function oN(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},WK=RU,YK=CU,zU=_U,BU=NU,UU=MU,jU=FU,GU=IU,HU=LU;const KK=["top","right","bottom","left"],No=Math.min,Jn=Math.max,mf=Math.round,xd=Math.floor,aa=e=>({x:e,y:e}),XK={left:"right",right:"left",bottom:"top",top:"bottom"},ZK={start:"end",end:"start"};function bk(e,t,n){return Jn(e,No(t,n))}function Ga(e,t){return typeof e=="function"?e(t):e}function Ha(e){return e.split("-")[0]}function Vs(e){return e.split("-")[1]}function $0(e){return e==="x"?"y":"x"}function q0(e){return e==="y"?"height":"width"}function Oo(e){return["top","bottom"].includes(Ha(e))?"y":"x"}function V0(e){return $0(Oo(e))}function QK(e,t,n){n===void 0&&(n=!1);const r=Vs(e),a=V0(e),o=q0(a);let s=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=bf(s)),[s,bf(s)]}function JK(e){const t=bf(e);return[yk(e),t,yk(t)]}function yk(e){return e.replace(/start|end/g,t=>ZK[t])}function eX(e,t,n){const r=["left","right"],a=["right","left"],o=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?a:r:t?r:a;case"left":case"right":return t?o:s;default:return[]}}function tX(e,t,n,r){const a=Vs(e);let o=eX(Ha(e),n==="start",r);return a&&(o=o.map(s=>s+"-"+a),t&&(o=o.concat(o.map(yk)))),o}function bf(e){return e.replace(/left|right|bottom|top/g,t=>XK[t])}function nX(e){return{top:0,right:0,bottom:0,left:0,...e}}function $U(e){return typeof e!="number"?nX(e):{top:e,right:e,bottom:e,left:e}}function yf(e){const{x:t,y:n,width:r,height:a}=e;return{width:r,height:a,top:n,left:t,right:t+r,bottom:n+a,x:t,y:n}}function $_(e,t,n){let{reference:r,floating:a}=e;const o=Oo(t),s=V0(t),u=q0(s),c=Ha(t),d=o==="y",p=r.x+r.width/2-a.width/2,g=r.y+r.height/2-a.height/2,m=r[u]/2-a[u]/2;let b;switch(c){case"top":b={x:p,y:r.y-a.height};break;case"bottom":b={x:p,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:g};break;case"left":b={x:r.x-a.width,y:g};break;default:b={x:r.x,y:r.y}}switch(Vs(t)){case"start":b[s]-=m*(n&&d?-1:1);break;case"end":b[s]+=m*(n&&d?-1:1);break}return b}const rX=async(e,t,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:o=[],platform:s}=n,u=o.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(t));let d=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:p,y:g}=$_(d,r,c),m=r,b={},y=0;for(let S=0;S({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:a,rects:o,platform:s,elements:u,middlewareData:c}=t,{element:d,padding:p=0}=Ga(e,t)||{};if(d==null)return{};const g=$U(p),m={x:n,y:r},b=V0(a),y=q0(b),S=await s.getDimensions(d),k=b==="y",R=k?"top":"left",x=k?"bottom":"right",A=k?"clientHeight":"clientWidth",N=o.reference[y]+o.reference[b]-m[b]-o.floating[y],O=m[b]-o.reference[b],C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d));let _=C?C[A]:0;(!_||!await(s.isElement==null?void 0:s.isElement(C)))&&(_=u.floating[A]||o.floating[y]);const P=N/2-O/2,D=_/2-S[y]/2-1,L=No(g[R],D),H=No(g[x],D),$=L,U=_-S[y]-H,W=_/2-S[y]/2+P,Z=bk($,W,U),j=!c.arrow&&Vs(a)!=null&&W!==Z&&o.reference[y]/2-(W<$?L:H)-S[y]/2<0,G=j?W<$?W-$:W-U:0;return{[b]:m[b]+G,data:{[b]:Z,centerOffset:W-Z-G,...j&&{alignmentOffset:G}},reset:j}}}),oX=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:a,middlewareData:o,rects:s,initialPlacement:u,platform:c,elements:d}=t,{mainAxis:p=!0,crossAxis:g=!0,fallbackPlacements:m,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:S=!0,...k}=Ga(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const R=Ha(a),x=Oo(u),A=Ha(u)===u,N=await(c.isRTL==null?void 0:c.isRTL(d.floating)),O=m||(A||!S?[bf(u)]:JK(u)),C=y!=="none";!m&&C&&O.push(...tX(u,S,y,N));const _=[u,...O],P=await ku(t,k),D=[];let L=((r=o.flip)==null?void 0:r.overflows)||[];if(p&&D.push(P[R]),g){const W=QK(a,s,N);D.push(P[W[0]],P[W[1]])}if(L=[...L,{placement:a,overflows:D}],!D.every(W=>W<=0)){var H,$;const W=(((H=o.flip)==null?void 0:H.index)||0)+1,Z=_[W];if(Z)return{data:{index:W,overflows:L},reset:{placement:Z}};let j=($=L.filter(G=>G.overflows[0]<=0).sort((G,z)=>G.overflows[1]-z.overflows[1])[0])==null?void 0:$.placement;if(!j)switch(b){case"bestFit":{var U;const G=(U=L.filter(z=>{if(C){const Y=Oo(z.placement);return Y===x||Y==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(Y=>Y>0).reduce((Y,I)=>Y+I,0)]).sort((z,Y)=>z[1]-Y[1])[0])==null?void 0:U[0];G&&(j=G);break}case"initialPlacement":j=u;break}if(a!==j)return{reset:{placement:j}}}return{}}}};function q_(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function V_(e){return KK.some(t=>e[t]>=0)}const iX=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...a}=Ga(e,t);switch(r){case"referenceHidden":{const o=await ku(t,{...a,elementContext:"reference"}),s=q_(o,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:V_(s)}}}case"escaped":{const o=await ku(t,{...a,altBoundary:!0}),s=q_(o,n.floating);return{data:{escapedOffsets:s,escaped:V_(s)}}}default:return{}}}}};async function sX(e,t){const{placement:n,platform:r,elements:a}=e,o=await(r.isRTL==null?void 0:r.isRTL(a.floating)),s=Ha(n),u=Vs(n),c=Oo(n)==="y",d=["left","top"].includes(s)?-1:1,p=o&&c?-1:1,g=Ga(t,e);let{mainAxis:m,crossAxis:b,alignmentAxis:y}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return u&&typeof y=="number"&&(b=u==="end"?y*-1:y),c?{x:b*p,y:m*d}:{x:m*d,y:b*p}}const lX=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:a,y:o,placement:s,middlewareData:u}=t,c=await sX(t,e);return s===((n=u.offset)==null?void 0:n.placement)&&(r=u.arrow)!=null&&r.alignmentOffset?{}:{x:a+c.x,y:o+c.y,data:{...c,placement:s}}}}},uX=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:u={fn:k=>{let{x:R,y:x}=k;return{x:R,y:x}}},...c}=Ga(e,t),d={x:n,y:r},p=await ku(t,c),g=Oo(Ha(a)),m=$0(g);let b=d[m],y=d[g];if(o){const k=m==="y"?"top":"left",R=m==="y"?"bottom":"right",x=b+p[k],A=b-p[R];b=bk(x,b,A)}if(s){const k=g==="y"?"top":"left",R=g==="y"?"bottom":"right",x=y+p[k],A=y-p[R];y=bk(x,y,A)}const S=u.fn({...t,[m]:b,[g]:y});return{...S,data:{x:S.x-n,y:S.y-r,enabled:{[m]:o,[g]:s}}}}}},cX=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:a,rects:o,middlewareData:s}=t,{offset:u=0,mainAxis:c=!0,crossAxis:d=!0}=Ga(e,t),p={x:n,y:r},g=Oo(a),m=$0(g);let b=p[m],y=p[g];const S=Ga(u,t),k=typeof S=="number"?{mainAxis:S,crossAxis:0}:{mainAxis:0,crossAxis:0,...S};if(c){const A=m==="y"?"height":"width",N=o.reference[m]-o.floating[A]+k.mainAxis,O=o.reference[m]+o.reference[A]-k.mainAxis;bO&&(b=O)}if(d){var R,x;const A=m==="y"?"width":"height",N=["top","left"].includes(Ha(a)),O=o.reference[g]-o.floating[A]+(N&&((R=s.offset)==null?void 0:R[g])||0)+(N?0:k.crossAxis),C=o.reference[g]+o.reference[A]+(N?0:((x=s.offset)==null?void 0:x[g])||0)-(N?k.crossAxis:0);yC&&(y=C)}return{[m]:b,[g]:y}}}},dX=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:a,rects:o,platform:s,elements:u}=t,{apply:c=()=>{},...d}=Ga(e,t),p=await ku(t,d),g=Ha(a),m=Vs(a),b=Oo(a)==="y",{width:y,height:S}=o.floating;let k,R;g==="top"||g==="bottom"?(k=g,R=m===(await(s.isRTL==null?void 0:s.isRTL(u.floating))?"start":"end")?"left":"right"):(R=g,k=m==="end"?"top":"bottom");const x=S-p.top-p.bottom,A=y-p.left-p.right,N=No(S-p[k],x),O=No(y-p[R],A),C=!t.middlewareData.shift;let _=N,P=O;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=A),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(_=x),C&&!m){const L=Jn(p.left,0),H=Jn(p.right,0),$=Jn(p.top,0),U=Jn(p.bottom,0);b?P=y-2*(L!==0||H!==0?L+H:Jn(p.left,p.right)):_=S-2*($!==0||U!==0?$+U:Jn(p.top,p.bottom))}await c({...t,availableWidth:P,availableHeight:_});const D=await s.getDimensions(u.floating);return y!==D.width||S!==D.height?{reset:{rects:!0}}:{}}}};function ap(){return typeof window<"u"}function Ws(e){return qU(e)?(e.nodeName||"").toLowerCase():"#document"}function nr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sa(e){var t;return(t=(qU(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function qU(e){return ap()?e instanceof Node||e instanceof nr(e).Node:!1}function Ur(e){return ap()?e instanceof Element||e instanceof nr(e).Element:!1}function oa(e){return ap()?e instanceof HTMLElement||e instanceof nr(e).HTMLElement:!1}function W_(e){return!ap()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof nr(e).ShadowRoot}function Vu(e){const{overflow:t,overflowX:n,overflowY:r,display:a}=jr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(a)}function fX(e){return["table","td","th"].includes(Ws(e))}function op(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function W0(e){const t=Y0(),n=Ur(e)?jr(e):e;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function pX(e){let t=Io(e);for(;oa(t)&&!Is(t);){if(W0(t))return t;if(op(t))return null;t=Io(t)}return null}function Y0(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Is(e){return["html","body","#document"].includes(Ws(e))}function jr(e){return nr(e).getComputedStyle(e)}function ip(e){return Ur(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Io(e){if(Ws(e)==="html")return e;const t=e.assignedSlot||e.parentNode||W_(e)&&e.host||sa(e);return W_(t)?t.host:t}function VU(e){const t=Io(e);return Is(t)?e.ownerDocument?e.ownerDocument.body:e.body:oa(t)&&Vu(t)?t:VU(t)}function Tu(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=VU(e),o=a===((r=e.ownerDocument)==null?void 0:r.body),s=nr(a);if(o){const u=vk(s);return t.concat(s,s.visualViewport||[],Vu(a)?a:[],u&&n?Tu(u):[])}return t.concat(a,Tu(a,[],n))}function vk(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function WU(e){const t=jr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const a=oa(e),o=a?e.offsetWidth:n,s=a?e.offsetHeight:r,u=mf(n)!==o||mf(r)!==s;return u&&(n=o,r=s),{width:n,height:r,$:u}}function K0(e){return Ur(e)?e:e.contextElement}function Cs(e){const t=K0(e);if(!oa(t))return aa(1);const n=t.getBoundingClientRect(),{width:r,height:a,$:o}=WU(t);let s=(o?mf(n.width):n.width)/r,u=(o?mf(n.height):n.height)/a;return(!s||!Number.isFinite(s))&&(s=1),(!u||!Number.isFinite(u))&&(u=1),{x:s,y:u}}const gX=aa(0);function YU(e){const t=nr(e);return!Y0()||!t.visualViewport?gX:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function hX(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==nr(e)?!1:t}function yi(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),o=K0(e);let s=aa(1);t&&(r?Ur(r)&&(s=Cs(r)):s=Cs(e));const u=hX(o,n,r)?YU(o):aa(0);let c=(a.left+u.x)/s.x,d=(a.top+u.y)/s.y,p=a.width/s.x,g=a.height/s.y;if(o){const m=nr(o),b=r&&Ur(r)?nr(r):r;let y=m,S=vk(y);for(;S&&r&&b!==y;){const k=Cs(S),R=S.getBoundingClientRect(),x=jr(S),A=R.left+(S.clientLeft+parseFloat(x.paddingLeft))*k.x,N=R.top+(S.clientTop+parseFloat(x.paddingTop))*k.y;c*=k.x,d*=k.y,p*=k.x,g*=k.y,c+=A,d+=N,y=nr(S),S=vk(y)}}return yf({width:p,height:g,x:c,y:d})}function X0(e,t){const n=ip(e).scrollLeft;return t?t.left+n:yi(sa(e)).left+n}function KU(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=r.left+t.scrollLeft-(n?0:X0(e,r)),o=r.top+t.scrollTop;return{x:a,y:o}}function mX(e){let{elements:t,rect:n,offsetParent:r,strategy:a}=e;const o=a==="fixed",s=sa(r),u=t?op(t.floating):!1;if(r===s||u&&o)return n;let c={scrollLeft:0,scrollTop:0},d=aa(1);const p=aa(0),g=oa(r);if((g||!g&&!o)&&((Ws(r)!=="body"||Vu(s))&&(c=ip(r)),oa(r))){const b=yi(r);d=Cs(r),p.x=b.x+r.clientLeft,p.y=b.y+r.clientTop}const m=s&&!g&&!o?KU(s,c,!0):aa(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+p.x+m.x,y:n.y*d.y-c.scrollTop*d.y+p.y+m.y}}function bX(e){return Array.from(e.getClientRects())}function yX(e){const t=sa(e),n=ip(e),r=e.ownerDocument.body,a=Jn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Jn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+X0(e);const u=-n.scrollTop;return jr(r).direction==="rtl"&&(s+=Jn(t.clientWidth,r.clientWidth)-a),{width:a,height:o,x:s,y:u}}function vX(e,t){const n=nr(e),r=sa(e),a=n.visualViewport;let o=r.clientWidth,s=r.clientHeight,u=0,c=0;if(a){o=a.width,s=a.height;const d=Y0();(!d||d&&t==="fixed")&&(u=a.offsetLeft,c=a.offsetTop)}return{width:o,height:s,x:u,y:c}}function SX(e,t){const n=yi(e,!0,t==="fixed"),r=n.top+e.clientTop,a=n.left+e.clientLeft,o=oa(e)?Cs(e):aa(1),s=e.clientWidth*o.x,u=e.clientHeight*o.y,c=a*o.x,d=r*o.y;return{width:s,height:u,x:c,y:d}}function Y_(e,t,n){let r;if(t==="viewport")r=vX(e,n);else if(t==="document")r=yX(sa(e));else if(Ur(t))r=SX(t,n);else{const a=YU(e);r={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return yf(r)}function XU(e,t){const n=Io(e);return n===t||!Ur(n)||Is(n)?!1:jr(n).position==="fixed"||XU(n,t)}function EX(e,t){const n=t.get(e);if(n)return n;let r=Tu(e,[],!1).filter(u=>Ur(u)&&Ws(u)!=="body"),a=null;const o=jr(e).position==="fixed";let s=o?Io(e):e;for(;Ur(s)&&!Is(s);){const u=jr(s),c=W0(s);!c&&u.position==="fixed"&&(a=null),(o?!c&&!a:!c&&u.position==="static"&&!!a&&["absolute","fixed"].includes(a.position)||Vu(s)&&!c&&XU(e,s))?r=r.filter(p=>p!==s):a=u,s=Io(s)}return t.set(e,r),r}function wX(e){let{element:t,boundary:n,rootBoundary:r,strategy:a}=e;const s=[...n==="clippingAncestors"?op(t)?[]:EX(t,this._c):[].concat(n),r],u=s[0],c=s.reduce((d,p)=>{const g=Y_(t,p,a);return d.top=Jn(g.top,d.top),d.right=No(g.right,d.right),d.bottom=No(g.bottom,d.bottom),d.left=Jn(g.left,d.left),d},Y_(t,u,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function xX(e){const{width:t,height:n}=WU(e);return{width:t,height:n}}function kX(e,t,n){const r=oa(t),a=sa(t),o=n==="fixed",s=yi(e,!0,o,t);let u={scrollLeft:0,scrollTop:0};const c=aa(0);if(r||!r&&!o)if((Ws(t)!=="body"||Vu(a))&&(u=ip(t)),r){const m=yi(t,!0,o,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else a&&(c.x=X0(a));const d=a&&!r&&!o?KU(a,u):aa(0),p=s.left+u.scrollLeft-c.x-d.x,g=s.top+u.scrollTop-c.y-d.y;return{x:p,y:g,width:s.width,height:s.height}}function im(e){return jr(e).position==="static"}function K_(e,t){if(!oa(e)||jr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return sa(e)===n&&(n=n.ownerDocument.body),n}function ZU(e,t){const n=nr(e);if(op(e))return n;if(!oa(e)){let a=Io(e);for(;a&&!Is(a);){if(Ur(a)&&!im(a))return a;a=Io(a)}return n}let r=K_(e,t);for(;r&&fX(r)&&im(r);)r=K_(r,t);return r&&Is(r)&&im(r)&&!W0(r)?n:r||pX(e)||n}const TX=async function(e){const t=this.getOffsetParent||ZU,n=this.getDimensions,r=await n(e.floating);return{reference:kX(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function AX(e){return jr(e).direction==="rtl"}const RX={convertOffsetParentRelativeRectToViewportRelativeRect:mX,getDocumentElement:sa,getClippingRect:wX,getOffsetParent:ZU,getElementRects:TX,getClientRects:bX,getDimensions:xX,getScale:Cs,isElement:Ur,isRTL:AX};function QU(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function CX(e,t){let n=null,r;const a=sa(e);function o(){var u;clearTimeout(r),(u=n)==null||u.disconnect(),n=null}function s(u,c){u===void 0&&(u=!1),c===void 0&&(c=1),o();const d=e.getBoundingClientRect(),{left:p,top:g,width:m,height:b}=d;if(u||t(),!m||!b)return;const y=xd(g),S=xd(a.clientWidth-(p+m)),k=xd(a.clientHeight-(g+b)),R=xd(p),A={rootMargin:-y+"px "+-S+"px "+-k+"px "+-R+"px",threshold:Jn(0,No(1,c))||1};let N=!0;function O(C){const _=C[0].intersectionRatio;if(_!==c){if(!N)return s();_?s(!1,_):r=setTimeout(()=>{s(!1,1e-7)},1e3)}_===1&&!QU(d,e.getBoundingClientRect())&&s(),N=!1}try{n=new IntersectionObserver(O,{...A,root:a.ownerDocument})}catch{n=new IntersectionObserver(O,A)}n.observe(e)}return s(!0),o}function _X(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=K0(e),p=a||o?[...d?Tu(d):[],...Tu(t)]:[];p.forEach(R=>{a&&R.addEventListener("scroll",n,{passive:!0}),o&&R.addEventListener("resize",n)});const g=d&&u?CX(d,n):null;let m=-1,b=null;s&&(b=new ResizeObserver(R=>{let[x]=R;x&&x.target===d&&b&&(b.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var A;(A=b)==null||A.observe(t)})),n()}),d&&!c&&b.observe(d),b.observe(t));let y,S=c?yi(e):null;c&&k();function k(){const R=yi(e);S&&!QU(S,R)&&n(),S=R,y=requestAnimationFrame(k)}return n(),()=>{var R;p.forEach(x=>{a&&x.removeEventListener("scroll",n),o&&x.removeEventListener("resize",n)}),g==null||g(),(R=b)==null||R.disconnect(),b=null,c&&cancelAnimationFrame(y)}}const NX=lX,OX=uX,IX=oX,DX=dX,LX=iX,X_=aX,MX=cX,PX=(e,t,n)=>{const r=new Map,a={platform:RX,...n},o={...a.platform,_c:r};return rX(e,t,{...a,platform:o})};var Qd=typeof document<"u"?E.useLayoutEffect:E.useEffect;function vf(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!vf(e[r],t[r]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,a[r]))return!1;for(r=n;r--!==0;){const o=a[r];if(!(o==="_owner"&&e.$$typeof)&&!vf(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function JU(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Z_(e,t){const n=JU(e);return Math.round(t*n)/n}function sm(e){const t=E.useRef(e);return Qd(()=>{t.current=e}),t}function FX(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:o,floating:s}={},transform:u=!0,whileElementsMounted:c,open:d}=e,[p,g]=E.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,b]=E.useState(r);vf(m,r)||b(r);const[y,S]=E.useState(null),[k,R]=E.useState(null),x=E.useCallback(z=>{z!==C.current&&(C.current=z,S(z))},[]),A=E.useCallback(z=>{z!==_.current&&(_.current=z,R(z))},[]),N=o||y,O=s||k,C=E.useRef(null),_=E.useRef(null),P=E.useRef(p),D=c!=null,L=sm(c),H=sm(a),$=sm(d),U=E.useCallback(()=>{if(!C.current||!_.current)return;const z={placement:t,strategy:n,middleware:m};H.current&&(z.platform=H.current),PX(C.current,_.current,z).then(Y=>{const I={...Y,isPositioned:$.current!==!1};W.current&&!vf(P.current,I)&&(P.current=I,Gu.flushSync(()=>{g(I)}))})},[m,t,n,H,$]);Qd(()=>{d===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,g(z=>({...z,isPositioned:!1})))},[d]);const W=E.useRef(!1);Qd(()=>(W.current=!0,()=>{W.current=!1}),[]),Qd(()=>{if(N&&(C.current=N),O&&(_.current=O),N&&O){if(L.current)return L.current(N,O,U);U()}},[N,O,U,L,D]);const Z=E.useMemo(()=>({reference:C,floating:_,setReference:x,setFloating:A}),[x,A]),j=E.useMemo(()=>({reference:N,floating:O}),[N,O]),G=E.useMemo(()=>{const z={position:n,left:0,top:0};if(!j.floating)return z;const Y=Z_(j.floating,p.x),I=Z_(j.floating,p.y);return u?{...z,transform:"translate("+Y+"px, "+I+"px)",...JU(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:I}},[n,u,j.floating,p.x,p.y]);return E.useMemo(()=>({...p,update:U,refs:Z,elements:j,floatingStyles:G}),[p,U,Z,j,G])}const zX=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:a}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?X_({element:r.current,padding:a}).fn(n):{}:r?X_({element:r,padding:a}).fn(n):{}}}},BX=(e,t)=>({...NX(e),options:[e,t]}),UX=(e,t)=>({...OX(e),options:[e,t]}),jX=(e,t)=>({...MX(e),options:[e,t]}),GX=(e,t)=>({...IX(e),options:[e,t]}),HX=(e,t)=>({...DX(e),options:[e,t]}),$X=(e,t)=>({...LX(e),options:[e,t]}),qX=(e,t)=>({...zX(e),options:[e,t]});var VX="Arrow",e3=E.forwardRef((e,t)=>{const{children:n,width:r=10,height:a=5,...o}=e;return w.jsx(Ze.svg,{...o,ref:t,width:r,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:w.jsx("polygon",{points:"0,0 30,0 15,10"})})});e3.displayName=VX;var WX=e3;function t3(e){const[t,n]=E.useState(void 0);return Rn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let s,u;if("borderBoxSize"in o){const c=o.borderBoxSize,d=Array.isArray(c)?c[0]:c;s=d.inlineSize,u=d.blockSize}else s=e.offsetWidth,u=e.offsetHeight;n({width:s,height:u})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Z0="Popper",[n3,Ys]=wr(Z0),[YX,r3]=n3(Z0),a3=e=>{const{__scopePopper:t,children:n}=e,[r,a]=E.useState(null);return w.jsx(YX,{scope:t,anchor:r,onAnchorChange:a,children:n})};a3.displayName=Z0;var o3="PopperAnchor",i3=E.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...a}=e,o=r3(o3,n),s=E.useRef(null),u=gt(t,s);return E.useEffect(()=>{o.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:w.jsx(Ze.div,{...a,ref:u})});i3.displayName=o3;var Q0="PopperContent",[KX,XX]=n3(Q0),s3=E.forwardRef((e,t)=>{var J,ae,ye,ie,Ee,Se;const{__scopePopper:n,side:r="bottom",sideOffset:a=0,align:o="center",alignOffset:s=0,arrowPadding:u=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:p=0,sticky:g="partial",hideWhenDetached:m=!1,updatePositionStrategy:b="optimized",onPlaced:y,...S}=e,k=r3(Q0,n),[R,x]=E.useState(null),A=gt(t,De=>x(De)),[N,O]=E.useState(null),C=t3(N),_=(C==null?void 0:C.width)??0,P=(C==null?void 0:C.height)??0,D=r+(o!=="center"?"-"+o:""),L=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},H=Array.isArray(d)?d:[d],$=H.length>0,U={padding:L,boundary:H.filter(QX),altBoundary:$},{refs:W,floatingStyles:Z,placement:j,isPositioned:G,middlewareData:z}=FX({strategy:"fixed",placement:D,whileElementsMounted:(...De)=>_X(...De,{animationFrame:b==="always"}),elements:{reference:k.anchor},middleware:[BX({mainAxis:a+P,alignmentAxis:s}),c&&UX({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?jX():void 0,...U}),c&&GX({...U}),HX({...U,apply:({elements:De,rects:Ce,availableWidth:we,availableHeight:te})=>{const{width:fe,height:Te}=Ce.reference,me=De.floating.style;me.setProperty("--radix-popper-available-width",`${we}px`),me.setProperty("--radix-popper-available-height",`${te}px`),me.setProperty("--radix-popper-anchor-width",`${fe}px`),me.setProperty("--radix-popper-anchor-height",`${Te}px`)}}),N&&qX({element:N,padding:u}),JX({arrowWidth:_,arrowHeight:P}),m&&$X({strategy:"referenceHidden",...U})]}),[Y,I]=c3(j),V=yn(y);Rn(()=>{G&&(V==null||V())},[G,V]);const B=(J=z.arrow)==null?void 0:J.x,M=(ae=z.arrow)==null?void 0:ae.y,K=((ye=z.arrow)==null?void 0:ye.centerOffset)!==0,[ee,Q]=E.useState();return Rn(()=>{R&&Q(window.getComputedStyle(R).zIndex)},[R]),w.jsx("div",{ref:W.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:G?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(ie=z.transformOrigin)==null?void 0:ie.x,(Ee=z.transformOrigin)==null?void 0:Ee.y].join(" "),...((Se=z.hide)==null?void 0:Se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:w.jsx(KX,{scope:n,placedSide:Y,onArrowChange:O,arrowX:B,arrowY:M,shouldHideArrow:K,children:w.jsx(Ze.div,{"data-side":Y,"data-align":I,...S,ref:A,style:{...S.style,animation:G?void 0:"none"}})})})});s3.displayName=Q0;var l3="PopperArrow",ZX={top:"bottom",right:"left",bottom:"top",left:"right"},u3=E.forwardRef(function(t,n){const{__scopePopper:r,...a}=t,o=XX(l3,r),s=ZX[o.placedSide];return w.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:w.jsx(WX,{...a,ref:n,style:{...a.style,display:"block"}})})});u3.displayName=l3;function QX(e){return e!==null}var JX=e=>({name:"transformOrigin",options:e,fn(t){var k,R,x;const{placement:n,rects:r,middlewareData:a}=t,s=((k=a.arrow)==null?void 0:k.centerOffset)!==0,u=s?0:e.arrowWidth,c=s?0:e.arrowHeight,[d,p]=c3(n),g={start:"0%",center:"50%",end:"100%"}[p],m=(((R=a.arrow)==null?void 0:R.x)??0)+u/2,b=(((x=a.arrow)==null?void 0:x.y)??0)+c/2;let y="",S="";return d==="bottom"?(y=s?g:`${m}px`,S=`${-c}px`):d==="top"?(y=s?g:`${m}px`,S=`${r.floating.height+c}px`):d==="right"?(y=`${-c}px`,S=s?g:`${b}px`):d==="left"&&(y=`${r.floating.width+c}px`,S=s?g:`${b}px`),{data:{x:y,y:S}}}});function c3(e){const[t,n="center"]=e.split("-");return[t,n]}var J0=a3,sp=i3,eT=s3,tT=u3,eZ="VisuallyHidden",nT=E.forwardRef((e,t)=>w.jsx(Ze.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));nT.displayName=eZ;var tZ=nT,[lp,Dxe]=wr("Tooltip",[Ys]),up=Ys(),d3="TooltipProvider",nZ=700,Sk="tooltip.open",[rZ,rT]=lp(d3),f3=e=>{const{__scopeTooltip:t,delayDuration:n=nZ,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:o}=e,[s,u]=E.useState(!0),c=E.useRef(!1),d=E.useRef(0);return E.useEffect(()=>{const p=d.current;return()=>window.clearTimeout(p)},[]),w.jsx(rZ,{scope:t,isOpenDelayed:s,delayDuration:n,onOpen:E.useCallback(()=>{window.clearTimeout(d.current),u(!1)},[]),onClose:E.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u(!0),r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:E.useCallback(p=>{c.current=p},[]),disableHoverableContent:a,children:o})};f3.displayName=d3;var cp="Tooltip",[aZ,dp]=lp(cp),p3=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:a=!1,onOpenChange:o,disableHoverableContent:s,delayDuration:u}=e,c=rT(cp,e.__scopeTooltip),d=up(t),[p,g]=E.useState(null),m=An(),b=E.useRef(0),y=s??c.disableHoverableContent,S=u??c.delayDuration,k=E.useRef(!1),[R=!1,x]=ja({prop:r,defaultProp:a,onChange:_=>{_?(c.onOpen(),document.dispatchEvent(new CustomEvent(Sk))):c.onClose(),o==null||o(_)}}),A=E.useMemo(()=>R?k.current?"delayed-open":"instant-open":"closed",[R]),N=E.useCallback(()=>{window.clearTimeout(b.current),b.current=0,k.current=!1,x(!0)},[x]),O=E.useCallback(()=>{window.clearTimeout(b.current),b.current=0,x(!1)},[x]),C=E.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{k.current=!0,x(!0),b.current=0},S)},[S,x]);return E.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),w.jsx(J0,{...d,children:w.jsx(aZ,{scope:t,contentId:m,open:R,stateAttribute:A,trigger:p,onTriggerChange:g,onTriggerEnter:E.useCallback(()=>{c.isOpenDelayed?C():N()},[c.isOpenDelayed,C,N]),onTriggerLeave:E.useCallback(()=>{y?O():(window.clearTimeout(b.current),b.current=0)},[O,y]),onOpen:N,onClose:O,disableHoverableContent:y,children:n})})};p3.displayName=cp;var Ek="TooltipTrigger",g3=E.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=dp(Ek,n),o=rT(Ek,n),s=up(n),u=E.useRef(null),c=gt(t,u,a.onTriggerChange),d=E.useRef(!1),p=E.useRef(!1),g=E.useCallback(()=>d.current=!1,[]);return E.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),w.jsx(sp,{asChild:!0,...s,children:w.jsx(Ze.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:c,onPointerMove:Ke(e.onPointerMove,m=>{m.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Ke(e.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Ke(e.onPointerDown,()=>{d.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:Ke(e.onFocus,()=>{d.current||a.onOpen()}),onBlur:Ke(e.onBlur,a.onClose),onClick:Ke(e.onClick,a.onClose)})})});g3.displayName=Ek;var oZ="TooltipPortal",[Lxe,iZ]=lp(oZ,{forceMount:void 0}),Ds="TooltipContent",h3=E.forwardRef((e,t)=>{const n=iZ(Ds,e.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...o}=e,s=dp(Ds,e.__scopeTooltip);return w.jsx(xr,{present:r||s.open,children:s.disableHoverableContent?w.jsx(m3,{side:a,...o,ref:t}):w.jsx(sZ,{side:a,...o,ref:t})})}),sZ=E.forwardRef((e,t)=>{const n=dp(Ds,e.__scopeTooltip),r=rT(Ds,e.__scopeTooltip),a=E.useRef(null),o=gt(t,a),[s,u]=E.useState(null),{trigger:c,onClose:d}=n,p=a.current,{onPointerInTransitChange:g}=r,m=E.useCallback(()=>{u(null),g(!1)},[g]),b=E.useCallback((y,S)=>{const k=y.currentTarget,R={x:y.clientX,y:y.clientY},x=dZ(R,k.getBoundingClientRect()),A=fZ(R,x),N=pZ(S.getBoundingClientRect()),O=hZ([...A,...N]);u(O),g(!0)},[g]);return E.useEffect(()=>()=>m(),[m]),E.useEffect(()=>{if(c&&p){const y=k=>b(k,p),S=k=>b(k,c);return c.addEventListener("pointerleave",y),p.addEventListener("pointerleave",S),()=>{c.removeEventListener("pointerleave",y),p.removeEventListener("pointerleave",S)}}},[c,p,b,m]),E.useEffect(()=>{if(s){const y=S=>{const k=S.target,R={x:S.clientX,y:S.clientY},x=(c==null?void 0:c.contains(k))||(p==null?void 0:p.contains(k)),A=!gZ(R,s);x?m():A&&(m(),d())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[c,p,s,d,m]),w.jsx(m3,{...e,ref:o})}),[lZ,uZ]=lp(cp,{isInside:!1}),m3=E.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:s,...u}=e,c=dp(Ds,n),d=up(n),{onClose:p}=c;return E.useEffect(()=>(document.addEventListener(Sk,p),()=>document.removeEventListener(Sk,p)),[p]),E.useEffect(()=>{if(c.trigger){const g=m=>{const b=m.target;b!=null&&b.contains(c.trigger)&&p()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[c.trigger,p]),w.jsx(qu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:g=>g.preventDefault(),onDismiss:p,children:w.jsxs(eT,{"data-state":c.stateAttribute,...d,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[w.jsx(O0,{children:r}),w.jsx(lZ,{scope:n,isInside:!0,children:w.jsx(tZ,{id:c.contentId,role:"tooltip",children:a||r})})]})})});h3.displayName=Ds;var b3="TooltipArrow",cZ=E.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=up(n);return uZ(b3,n).isInside?null:w.jsx(tT,{...a,...r,ref:t})});cZ.displayName=b3;function dZ(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,a,o)){case o:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function fZ(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function pZ(e){const{top:t,right:n,bottom:r,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:r},{x:a,y:r}]}function gZ(e,t){const{x:n,y:r}=e;let a=!1;for(let o=0,s=t.length-1;or!=p>r&&n<(d-u)*(r-c)/(p-c)+u&&(a=!a)}return a}function hZ(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),mZ(t)}function mZ(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const o=t[t.length-1],s=t[t.length-2];if((o.x-s.x)*(a.y-s.y)>=(o.y-s.y)*(a.x-s.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const a=e[r];for(;n.length>=2;){const o=n[n.length-1],s=n[n.length-2];if((o.x-s.x)*(a.y-s.y)>=(o.y-s.y)*(a.x-s.x))n.pop();else break}n.push(a)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var bZ=f3,yZ=p3,vZ=g3,y3=h3;const v3=bZ,S3=yZ,E3=vZ,SZ=e=>typeof e!="string"?e:w.jsx("div",{className:"relative top-0 pt-1 whitespace-pre-wrap break-words",children:e}),aT=E.forwardRef(({className:e,side:t="left",align:n="start",children:r,...a},o)=>{const s=E.useRef(null);return E.useEffect(()=>{s.current&&(s.current.scrollTop=0)},[r]),w.jsx(y3,{ref:o,side:t,align:n,className:Pe("bg-popover text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-[60vh] overflow-y-auto whitespace-pre-wrap break-words rounded-md border px-3 py-2 text-sm shadow-md z-60",e),...a,children:typeof r=="string"?SZ(r):r})});aT.displayName=y3.displayName;const Sf=UB("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"size-8"}},defaultVariants:{variant:"default",size:"default"}}),xt=E.forwardRef(({className:e,variant:t,tooltip:n,size:r,side:a="right",asChild:o=!1,...s},u)=>{const c=o?_o:"button";return n?w.jsx(v3,{children:w.jsxs(S3,{children:[w.jsx(E3,{asChild:!0,children:w.jsx(c,{className:Pe(Sf({variant:t,size:r,className:e}),"cursor-pointer"),ref:u,...s})}),w.jsx(aT,{side:a,children:n})]})}):w.jsx(c,{className:Pe(Sf({variant:t,size:r,className:e}),"cursor-pointer"),ref:u,...s})});xt.displayName="Button";const EZ=WK,wZ=YK,w3=E.forwardRef(({className:e,...t},n)=>w.jsx(zU,{className:Pe("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",e),...t,ref:n}));w3.displayName=zU.displayName;const x3=E.forwardRef(({className:e,...t},n)=>w.jsxs(wZ,{children:[w.jsx(w3,{}),w.jsx(BU,{ref:n,className:Pe("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%] fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg",e),...t})]}));x3.displayName=BU.displayName;const k3=({className:e,...t})=>w.jsx("div",{className:Pe("flex flex-col space-y-2 text-center sm:text-left",e),...t});k3.displayName="AlertDialogHeader";const T3=E.forwardRef(({className:e,...t},n)=>w.jsx(GU,{ref:n,className:Pe("text-lg font-semibold",e),...t}));T3.displayName=GU.displayName;const A3=E.forwardRef(({className:e,...t},n)=>w.jsx(HU,{ref:n,className:Pe("text-muted-foreground text-sm",e),...t}));A3.displayName=HU.displayName;const xZ=E.forwardRef(({className:e,...t},n)=>w.jsx(UU,{ref:n,className:Pe(Sf(),e),...t}));xZ.displayName=UU.displayName;const kZ=E.forwardRef(({className:e,...t},n)=>w.jsx(jU,{ref:n,className:Pe(Sf({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));kZ.displayName=jU.displayName;const $a=E.forwardRef(({className:e,type:t,...n},r)=>w.jsx("input",{type:t,className:Pe("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm [&::-webkit-inner-spin-button]:opacity-100 [&::-webkit-outer-spin-button]:opacity-100",e),ref:r,...n}));$a.displayName="Input";const TZ=()=>{const[e,t]=E.useState(!0),n=Le.use.apiKey(),[r,a]=E.useState(""),o=tr.use.message();E.useEffect(()=>{a(n||"")},[n,e]),E.useEffect(()=>{o&&(o.includes(DB)||o.includes(LB))&&t(!0)},[o,t]);const s=E.useCallback(async()=>{if(Le.setState({apiKey:r||null}),await tr.getState().check()){t(!1);return}Ft.error("API Key is invalid")},[r]),u=E.useCallback(c=>{a(c.target.value)},[a]);return w.jsx(EZ,{open:e,onOpenChange:t,children:w.jsxs(x3,{children:[w.jsxs(k3,{children:[w.jsx(T3,{children:"API Key is required"}),w.jsx(A3,{children:"Please enter your API key"})]}),w.jsxs("form",{className:"flex gap-2",onSubmit:c=>c.preventDefault(),children:[w.jsx($a,{type:"password",value:r,onChange:u,placeholder:"Enter your API key",className:"max-h-full w-full min-w-0",autoComplete:"off"}),w.jsx(xt,{onClick:s,variant:"outline",size:"sm",children:"Save"})]})]})})};var oT="Popover",[R3,Mxe]=wr(oT,[Ys]),Wu=Ys(),[AZ,Ti]=R3(oT),C3=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:a,onOpenChange:o,modal:s=!1}=e,u=Wu(t),c=E.useRef(null),[d,p]=E.useState(!1),[g=!1,m]=ja({prop:r,defaultProp:a,onChange:o});return w.jsx(J0,{...u,children:w.jsx(AZ,{scope:t,contentId:An(),triggerRef:c,open:g,onOpenChange:m,onOpenToggle:E.useCallback(()=>m(b=>!b),[m]),hasCustomAnchor:d,onCustomAnchorAdd:E.useCallback(()=>p(!0),[]),onCustomAnchorRemove:E.useCallback(()=>p(!1),[]),modal:s,children:n})})};C3.displayName=oT;var _3="PopoverAnchor",RZ=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Ti(_3,n),o=Wu(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:u}=a;return E.useEffect(()=>(s(),()=>u()),[s,u]),w.jsx(sp,{...o,...r,ref:t})});RZ.displayName=_3;var N3="PopoverTrigger",O3=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Ti(N3,n),o=Wu(n),s=gt(t,a.triggerRef),u=w.jsx(Ze.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":M3(a.open),...r,ref:s,onClick:Ke(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:w.jsx(sp,{asChild:!0,...o,children:u})});O3.displayName=N3;var CZ="PopoverPortal",[Pxe,_Z]=R3(CZ,{forceMount:void 0}),Ls="PopoverContent",I3=E.forwardRef((e,t)=>{const n=_Z(Ls,e.__scopePopover),{forceMount:r=n.forceMount,...a}=e,o=Ti(Ls,e.__scopePopover);return w.jsx(xr,{present:r||o.open,children:o.modal?w.jsx(NZ,{...a,ref:t}):w.jsx(OZ,{...a,ref:t})})});I3.displayName=Ls;var NZ=E.forwardRef((e,t)=>{const n=Ti(Ls,e.__scopePopover),r=E.useRef(null),a=gt(t,r),o=E.useRef(!1);return E.useEffect(()=>{const s=r.current;if(s)return L0(s)},[]),w.jsx(tp,{as:_o,allowPinchZoom:!0,children:w.jsx(D3,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ke(e.onCloseAutoFocus,s=>{var u;s.preventDefault(),o.current||(u=n.triggerRef.current)==null||u.focus()}),onPointerDownOutside:Ke(e.onPointerDownOutside,s=>{const u=s.detail.originalEvent,c=u.button===0&&u.ctrlKey===!0,d=u.button===2||c;o.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:Ke(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),OZ=E.forwardRef((e,t)=>{const n=Ti(Ls,e.__scopePopover),r=E.useRef(!1),a=E.useRef(!1);return w.jsx(D3,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var s,u;(s=e.onCloseAutoFocus)==null||s.call(e,o),o.defaultPrevented||(r.current||(u=n.triggerRef.current)==null||u.focus(),o.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:o=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const s=o.target;((d=n.triggerRef.current)==null?void 0:d.contains(s))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),D3=E.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:p,...g}=e,m=Ti(Ls,n),b=Wu(n);return D0(),w.jsx(Jf,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:o,children:w.jsx(qu,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:p,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>m.onOpenChange(!1),children:w.jsx(eT,{"data-state":M3(m.open),role:"dialog",id:m.contentId,...b,...g,ref:t,style:{...g.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),L3="PopoverClose",IZ=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Ti(L3,n);return w.jsx(Ze.button,{type:"button",...r,ref:t,onClick:Ke(e.onClick,()=>a.onOpenChange(!1))})});IZ.displayName=L3;var DZ="PopoverArrow",LZ=E.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Wu(n);return w.jsx(tT,{...a,...r,ref:t})});LZ.displayName=DZ;function M3(e){return e?"open":"closed"}var MZ=C3,PZ=O3,P3=I3;const Yu=MZ,Ku=PZ,Ks=E.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>w.jsx(P3,{ref:a,align:t,sideOffset:n,className:Pe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 rounded-md border p-4 shadow-md outline-none",e),...r}));Ks.displayName=P3.displayName;const FZ=(e,t,n,r)=>{var o,s,u,c;const a=[n,{code:t,...r||{}}];if((s=(o=e==null?void 0:e.services)==null?void 0:o.logger)!=null&&s.forward)return e.services.logger.forward(a,"warn","react-i18next::",!0);gi(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),(c=(u=e==null?void 0:e.services)==null?void 0:u.logger)!=null&&c.warn?e.services.logger.warn(...a):console!=null&&console.warn&&console.warn(...a)},Q_={},wk=(e,t,n,r)=>{gi(n)&&Q_[n]||(gi(n)&&(Q_[n]=new Date),FZ(e,t,n,r))},F3=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},xk=(e,t,n)=>{e.loadNamespaces(t,F3(e,n))},J_=(e,t,n,r)=>{if(gi(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return xk(e,n,r);n.forEach(a=>{e.options.ns.indexOf(a)<0&&e.options.ns.push(a)}),e.loadLanguages(t,F3(e,r))},zZ=(e,t,n={})=>!t.languages||!t.languages.length?(wk(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(r,a)=>{var o;if(((o=n.bindI18n)==null?void 0:o.indexOf("languageChanging"))>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!a(r.isLanguageChangingTo,e))return!1}}),gi=e=>typeof e=="string",BZ=e=>typeof e=="object"&&e!==null,UZ=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,jZ={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},GZ=e=>jZ[e],HZ=e=>e.replace(UZ,GZ);let kk={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:HZ};const $Z=(e={})=>{kk={...kk,...e}},qZ=()=>kk;let z3;const VZ=e=>{z3=e},WZ=()=>z3,YZ={type:"3rdParty",init(e){$Z(e.options.react),VZ(e)}},KZ=E.createContext();class XZ{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const ZZ=(e,t)=>{const n=E.useRef();return E.useEffect(()=>{n.current=e},[e,t]),n.current},B3=(e,t,n,r)=>e.getFixedT(t,n,r),QZ=(e,t,n,r)=>E.useCallback(B3(e,t,n,r),[e,t,n,r]),Pt=(e,t={})=>{var N,O,C,_;const{i18n:n}=t,{i18n:r,defaultNS:a}=E.useContext(KZ)||{},o=n||r||WZ();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new XZ),!o){wk(o,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const P=(L,H)=>gi(H)?H:BZ(H)&&gi(H.defaultValue)?H.defaultValue:Array.isArray(L)?L[L.length-1]:L,D=[P,{},!1];return D.t=P,D.i18n={},D.ready=!1,D}(N=o.options.react)!=null&&N.wait&&wk(o,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const s={...qZ(),...o.options.react,...t},{useSuspense:u,keyPrefix:c}=s;let d=a||((O=o.options)==null?void 0:O.defaultNS);d=gi(d)?[d]:d||["translation"],(_=(C=o.reportNamespaces).addUsedNamespaces)==null||_.call(C,d);const p=(o.isInitialized||o.initializedStoreOnce)&&d.every(P=>zZ(P,o,s)),g=QZ(o,t.lng||null,s.nsMode==="fallback"?d:d[0],c),m=()=>g,b=()=>B3(o,t.lng||null,s.nsMode==="fallback"?d:d[0],c),[y,S]=E.useState(m);let k=d.join();t.lng&&(k=`${t.lng}${k}`);const R=ZZ(k),x=E.useRef(!0);E.useEffect(()=>{const{bindI18n:P,bindI18nStore:D}=s;x.current=!0,!p&&!u&&(t.lng?J_(o,t.lng,d,()=>{x.current&&S(b)}):xk(o,d,()=>{x.current&&S(b)})),p&&R&&R!==k&&x.current&&S(b);const L=()=>{x.current&&S(b)};return P&&(o==null||o.on(P,L)),D&&(o==null||o.store.on(D,L)),()=>{x.current=!1,o&&(P==null||P.split(" ").forEach(H=>o.off(H,L))),D&&o&&D.split(" ").forEach(H=>o.store.off(H,L))}},[o,k]),E.useEffect(()=>{x.current&&p&&S(m)},[o,c,p]);const A=[y,o,p];if(A.t=y,A.i18n=o,A.ready=p,p||!p&&!u)return A;throw new Promise(P=>{t.lng?J_(o,t.lng,d,()=>P()):xk(o,d,()=>P())})},JZ=({status:e})=>{const{t}=Pt();return e?w.jsxs("div",{className:"min-w-[300px] space-y-3 text-sm",children:[w.jsxs("div",{className:"space-y-1",children:[w.jsx("h4",{className:"font-medium",children:t("graphPanel.statusCard.storageInfo")}),w.jsxs("div",{className:"text-muted-foreground grid grid-cols-2 gap-1",children:[w.jsxs("span",{children:[t("graphPanel.statusCard.workingDirectory"),":"]}),w.jsx("span",{className:"truncate",children:e.working_directory}),w.jsxs("span",{children:[t("graphPanel.statusCard.inputDirectory"),":"]}),w.jsx("span",{className:"truncate",children:e.input_directory})]})]}),w.jsxs("div",{className:"space-y-1",children:[w.jsx("h4",{className:"font-medium",children:t("graphPanel.statusCard.llmConfig")}),w.jsxs("div",{className:"text-muted-foreground grid grid-cols-2 gap-1",children:[w.jsxs("span",{children:[t("graphPanel.statusCard.llmBinding"),":"]}),w.jsx("span",{children:e.configuration.llm_binding}),w.jsxs("span",{children:[t("graphPanel.statusCard.llmBindingHost"),":"]}),w.jsx("span",{children:e.configuration.llm_binding_host}),w.jsxs("span",{children:[t("graphPanel.statusCard.llmModel"),":"]}),w.jsx("span",{children:e.configuration.llm_model}),w.jsxs("span",{children:[t("graphPanel.statusCard.maxTokens"),":"]}),w.jsx("span",{children:e.configuration.max_tokens})]})]}),w.jsxs("div",{className:"space-y-1",children:[w.jsx("h4",{className:"font-medium",children:t("graphPanel.statusCard.embeddingConfig")}),w.jsxs("div",{className:"text-muted-foreground grid grid-cols-2 gap-1",children:[w.jsxs("span",{children:[t("graphPanel.statusCard.embeddingBinding"),":"]}),w.jsx("span",{children:e.configuration.embedding_binding}),w.jsxs("span",{children:[t("graphPanel.statusCard.embeddingBindingHost"),":"]}),w.jsx("span",{children:e.configuration.embedding_binding_host}),w.jsxs("span",{children:[t("graphPanel.statusCard.embeddingModel"),":"]}),w.jsx("span",{children:e.configuration.embedding_model})]})]}),w.jsxs("div",{className:"space-y-1",children:[w.jsx("h4",{className:"font-medium",children:t("graphPanel.statusCard.storageConfig")}),w.jsxs("div",{className:"text-muted-foreground grid grid-cols-2 gap-1",children:[w.jsxs("span",{children:[t("graphPanel.statusCard.kvStorage"),":"]}),w.jsx("span",{children:e.configuration.kv_storage}),w.jsxs("span",{children:[t("graphPanel.statusCard.docStatusStorage"),":"]}),w.jsx("span",{children:e.configuration.doc_status_storage}),w.jsxs("span",{children:[t("graphPanel.statusCard.graphStorage"),":"]}),w.jsx("span",{children:e.configuration.graph_storage}),w.jsxs("span",{children:[t("graphPanel.statusCard.vectorStorage"),":"]}),w.jsx("span",{children:e.configuration.vector_storage})]})]})]}):w.jsx("div",{className:"text-muted-foreground text-sm",children:t("graphPanel.statusCard.unavailable")})},eQ=()=>{const{t:e}=Pt(),t=tr.use.health(),n=tr.use.lastCheckTime(),r=tr.use.status(),[a,o]=E.useState(!1);return E.useEffect(()=>{o(!0);const s=setTimeout(()=>o(!1),300);return()=>clearTimeout(s)},[n]),w.jsx("div",{className:"fixed right-4 bottom-4 flex items-center gap-2 opacity-80 select-none",children:w.jsxs(Yu,{children:[w.jsx(Ku,{asChild:!0,children:w.jsxs("div",{className:"flex cursor-help items-center gap-2",children:[w.jsx("div",{className:Pe("h-3 w-3 rounded-full transition-all duration-300","shadow-[0_0_8px_rgba(0,0,0,0.2)]",t?"bg-green-500":"bg-red-500",a&&"scale-125",a&&t&&"shadow-[0_0_12px_rgba(34,197,94,0.4)]",a&&!t&&"shadow-[0_0_12px_rgba(239,68,68,0.4)]")}),w.jsx("span",{className:"text-muted-foreground text-xs",children:e(t?"graphPanel.statusIndicator.connected":"graphPanel.statusIndicator.disconnected")})]})}),w.jsx(Ks,{className:"w-auto",side:"top",align:"end",children:w.jsx(JZ,{status:r})})]})})};function Tk(e,[t,n]){return Math.min(n,Math.max(t,e))}function U3(e){const t=e+"CollectionProvider",[n,r]=wr(t),[a,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=b=>{const{scope:y,children:S}=b,k=ve.useRef(null),R=ve.useRef(new Map).current;return w.jsx(a,{scope:y,itemMap:R,collectionRef:k,children:S})};s.displayName=t;const u=e+"CollectionSlot",c=ve.forwardRef((b,y)=>{const{scope:S,children:k}=b,R=o(u,S),x=gt(y,R.collectionRef);return w.jsx(_o,{ref:x,children:k})});c.displayName=u;const d=e+"CollectionItemSlot",p="data-radix-collection-item",g=ve.forwardRef((b,y)=>{const{scope:S,children:k,...R}=b,x=ve.useRef(null),A=gt(y,x),N=o(d,S);return ve.useEffect(()=>(N.itemMap.set(x,{ref:x,...R}),()=>void N.itemMap.delete(x))),w.jsx(_o,{[p]:"",ref:A,children:k})});g.displayName=d;function m(b){const y=o(e+"CollectionConsumer",b);return ve.useCallback(()=>{const k=y.collectionRef.current;if(!k)return[];const R=Array.from(k.querySelectorAll(`[${p}]`));return Array.from(y.itemMap.values()).sort((N,O)=>R.indexOf(N.ref.current)-R.indexOf(O.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:s,Slot:c,ItemSlot:g},m,r]}var tQ=E.createContext(void 0);function fp(e){const t=E.useContext(tQ);return e||t||"ltr"}function j3(e){const t=E.useRef({value:e,previous:e});return E.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var nQ=[" ","Enter","ArrowUp","ArrowDown"],rQ=[" ","Enter"],Xu="Select",[pp,gp,aQ]=U3(Xu),[Xs,Fxe]=wr(Xu,[aQ,Ys]),hp=Ys(),[oQ,Lo]=Xs(Xu),[iQ,sQ]=Xs(Xu),G3=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:a,onOpenChange:o,value:s,defaultValue:u,onValueChange:c,dir:d,name:p,autoComplete:g,disabled:m,required:b,form:y}=e,S=hp(t),[k,R]=E.useState(null),[x,A]=E.useState(null),[N,O]=E.useState(!1),C=fp(d),[_=!1,P]=ja({prop:r,defaultProp:a,onChange:o}),[D,L]=ja({prop:s,defaultProp:u,onChange:c}),H=E.useRef(null),$=k?y||!!k.closest("form"):!0,[U,W]=E.useState(new Set),Z=Array.from(U).map(j=>j.props.value).join(";");return w.jsx(J0,{...S,children:w.jsxs(oQ,{required:b,scope:t,trigger:k,onTriggerChange:R,valueNode:x,onValueNodeChange:A,valueNodeHasChildren:N,onValueNodeHasChildrenChange:O,contentId:An(),value:D,onValueChange:L,open:_,onOpenChange:P,dir:C,triggerPointerDownPosRef:H,disabled:m,children:[w.jsx(pp.Provider,{scope:t,children:w.jsx(iQ,{scope:e.__scopeSelect,onNativeOptionAdd:E.useCallback(j=>{W(G=>new Set(G).add(j))},[]),onNativeOptionRemove:E.useCallback(j=>{W(G=>{const z=new Set(G);return z.delete(j),z})},[]),children:n})}),$?w.jsxs(gj,{"aria-hidden":!0,required:b,tabIndex:-1,name:p,autoComplete:g,value:D,onChange:j=>L(j.target.value),disabled:m,form:y,children:[D===void 0?w.jsx("option",{value:""}):null,Array.from(U)]},Z):null]})})};G3.displayName=Xu;var H3="SelectTrigger",$3=E.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...a}=e,o=hp(n),s=Lo(H3,n),u=s.disabled||r,c=gt(t,s.onTriggerChange),d=gp(n),p=E.useRef("touch"),[g,m,b]=hj(S=>{const k=d().filter(A=>!A.disabled),R=k.find(A=>A.value===s.value),x=mj(k,S,R);x!==void 0&&s.onValueChange(x.value)}),y=S=>{u||(s.onOpenChange(!0),b()),S&&(s.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return w.jsx(sp,{asChild:!0,...o,children:w.jsx(Ze.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:u,"data-disabled":u?"":void 0,"data-placeholder":pj(s.value)?"":void 0,...a,ref:c,onClick:Ke(a.onClick,S=>{S.currentTarget.focus(),p.current!=="mouse"&&y(S)}),onPointerDown:Ke(a.onPointerDown,S=>{p.current=S.pointerType;const k=S.target;k.hasPointerCapture(S.pointerId)&&k.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(y(S),S.preventDefault())}),onKeyDown:Ke(a.onKeyDown,S=>{const k=g.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&m(S.key),!(k&&S.key===" ")&&nQ.includes(S.key)&&(y(),S.preventDefault())})})})});$3.displayName=H3;var q3="SelectValue",V3=E.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:a,children:o,placeholder:s="",...u}=e,c=Lo(q3,n),{onValueNodeHasChildrenChange:d}=c,p=o!==void 0,g=gt(t,c.onValueNodeChange);return Rn(()=>{d(p)},[d,p]),w.jsx(Ze.span,{...u,ref:g,style:{pointerEvents:"none"},children:pj(c.value)?w.jsx(w.Fragment,{children:s}):o})});V3.displayName=q3;var lQ="SelectIcon",W3=E.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...a}=e;return w.jsx(Ze.span,{"aria-hidden":!0,...a,ref:t,children:r||"▼"})});W3.displayName=lQ;var uQ="SelectPortal",Y3=e=>w.jsx(I0,{asChild:!0,...e});Y3.displayName=uQ;var vi="SelectContent",K3=E.forwardRef((e,t)=>{const n=Lo(vi,e.__scopeSelect),[r,a]=E.useState();if(Rn(()=>{a(new DocumentFragment)},[]),!n.open){const o=r;return o?Gu.createPortal(w.jsx(X3,{scope:e.__scopeSelect,children:w.jsx(pp.Slot,{scope:e.__scopeSelect,children:w.jsx("div",{children:e.children})})}),o):null}return w.jsx(Z3,{...e,ref:t})});K3.displayName=vi;var Lr=10,[X3,Mo]=Xs(vi),cQ="SelectContentImpl",Z3=E.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:s,side:u,sideOffset:c,align:d,alignOffset:p,arrowPadding:g,collisionBoundary:m,collisionPadding:b,sticky:y,hideWhenDetached:S,avoidCollisions:k,...R}=e,x=Lo(vi,n),[A,N]=E.useState(null),[O,C]=E.useState(null),_=gt(t,J=>N(J)),[P,D]=E.useState(null),[L,H]=E.useState(null),$=gp(n),[U,W]=E.useState(!1),Z=E.useRef(!1);E.useEffect(()=>{if(A)return L0(A)},[A]),D0();const j=E.useCallback(J=>{const[ae,...ye]=$().map(Se=>Se.ref.current),[ie]=ye.slice(-1),Ee=document.activeElement;for(const Se of J)if(Se===Ee||(Se==null||Se.scrollIntoView({block:"nearest"}),Se===ae&&O&&(O.scrollTop=0),Se===ie&&O&&(O.scrollTop=O.scrollHeight),Se==null||Se.focus(),document.activeElement!==Ee))return},[$,O]),G=E.useCallback(()=>j([P,A]),[j,P,A]);E.useEffect(()=>{U&&G()},[U,G]);const{onOpenChange:z,triggerPointerDownPosRef:Y}=x;E.useEffect(()=>{if(A){let J={x:0,y:0};const ae=ie=>{var Ee,Se;J={x:Math.abs(Math.round(ie.pageX)-(((Ee=Y.current)==null?void 0:Ee.x)??0)),y:Math.abs(Math.round(ie.pageY)-(((Se=Y.current)==null?void 0:Se.y)??0))}},ye=ie=>{J.x<=10&&J.y<=10?ie.preventDefault():A.contains(ie.target)||z(!1),document.removeEventListener("pointermove",ae),Y.current=null};return Y.current!==null&&(document.addEventListener("pointermove",ae),document.addEventListener("pointerup",ye,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ae),document.removeEventListener("pointerup",ye,{capture:!0})}}},[A,z,Y]),E.useEffect(()=>{const J=()=>z(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[z]);const[I,V]=hj(J=>{const ae=$().filter(Ee=>!Ee.disabled),ye=ae.find(Ee=>Ee.ref.current===document.activeElement),ie=mj(ae,J,ye);ie&&setTimeout(()=>ie.ref.current.focus())}),B=E.useCallback((J,ae,ye)=>{const ie=!Z.current&&!ye;(x.value!==void 0&&x.value===ae||ie)&&(D(J),ie&&(Z.current=!0))},[x.value]),M=E.useCallback(()=>A==null?void 0:A.focus(),[A]),K=E.useCallback((J,ae,ye)=>{const ie=!Z.current&&!ye;(x.value!==void 0&&x.value===ae||ie)&&H(J)},[x.value]),ee=r==="popper"?Ak:Q3,Q=ee===Ak?{side:u,sideOffset:c,align:d,alignOffset:p,arrowPadding:g,collisionBoundary:m,collisionPadding:b,sticky:y,hideWhenDetached:S,avoidCollisions:k}:{};return w.jsx(X3,{scope:n,content:A,viewport:O,onViewportChange:C,itemRefCallback:B,selectedItem:P,onItemLeave:M,itemTextRefCallback:K,focusSelectedItem:G,selectedItemText:L,position:r,isPositioned:U,searchRef:I,children:w.jsx(tp,{as:_o,allowPinchZoom:!0,children:w.jsx(Jf,{asChild:!0,trapped:x.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:Ke(a,J=>{var ae;(ae=x.trigger)==null||ae.focus({preventScroll:!0}),J.preventDefault()}),children:w.jsx(qu,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:w.jsx(ee,{role:"listbox",id:x.contentId,"data-state":x.open?"open":"closed",dir:x.dir,onContextMenu:J=>J.preventDefault(),...R,...Q,onPlaced:()=>W(!0),ref:_,style:{display:"flex",flexDirection:"column",outline:"none",...R.style},onKeyDown:Ke(R.onKeyDown,J=>{const ae=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!ae&&J.key.length===1&&V(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let ie=$().filter(Ee=>!Ee.disabled).map(Ee=>Ee.ref.current);if(["ArrowUp","End"].includes(J.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const Ee=J.target,Se=ie.indexOf(Ee);ie=ie.slice(Se+1)}setTimeout(()=>j(ie)),J.preventDefault()}})})})})})})});Z3.displayName=cQ;var dQ="SelectItemAlignedPosition",Q3=E.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...a}=e,o=Lo(vi,n),s=Mo(vi,n),[u,c]=E.useState(null),[d,p]=E.useState(null),g=gt(t,_=>p(_)),m=gp(n),b=E.useRef(!1),y=E.useRef(!0),{viewport:S,selectedItem:k,selectedItemText:R,focusSelectedItem:x}=s,A=E.useCallback(()=>{if(o.trigger&&o.valueNode&&u&&d&&S&&k&&R){const _=o.trigger.getBoundingClientRect(),P=d.getBoundingClientRect(),D=o.valueNode.getBoundingClientRect(),L=R.getBoundingClientRect();if(o.dir!=="rtl"){const Ee=L.left-P.left,Se=D.left-Ee,De=_.left-Se,Ce=_.width+De,we=Math.max(Ce,P.width),te=window.innerWidth-Lr,fe=Tk(Se,[Lr,Math.max(Lr,te-we)]);u.style.minWidth=Ce+"px",u.style.left=fe+"px"}else{const Ee=P.right-L.right,Se=window.innerWidth-D.right-Ee,De=window.innerWidth-_.right-Se,Ce=_.width+De,we=Math.max(Ce,P.width),te=window.innerWidth-Lr,fe=Tk(Se,[Lr,Math.max(Lr,te-we)]);u.style.minWidth=Ce+"px",u.style.right=fe+"px"}const H=m(),$=window.innerHeight-Lr*2,U=S.scrollHeight,W=window.getComputedStyle(d),Z=parseInt(W.borderTopWidth,10),j=parseInt(W.paddingTop,10),G=parseInt(W.borderBottomWidth,10),z=parseInt(W.paddingBottom,10),Y=Z+j+U+z+G,I=Math.min(k.offsetHeight*5,Y),V=window.getComputedStyle(S),B=parseInt(V.paddingTop,10),M=parseInt(V.paddingBottom,10),K=_.top+_.height/2-Lr,ee=$-K,Q=k.offsetHeight/2,J=k.offsetTop+Q,ae=Z+j+J,ye=Y-ae;if(ae<=K){const Ee=H.length>0&&k===H[H.length-1].ref.current;u.style.bottom="0px";const Se=d.clientHeight-S.offsetTop-S.offsetHeight,De=Math.max(ee,Q+(Ee?M:0)+Se+G),Ce=ae+De;u.style.height=Ce+"px"}else{const Ee=H.length>0&&k===H[0].ref.current;u.style.top="0px";const De=Math.max(K,Z+S.offsetTop+(Ee?B:0)+Q)+ye;u.style.height=De+"px",S.scrollTop=ae-K+S.offsetTop}u.style.margin=`${Lr}px 0`,u.style.minHeight=I+"px",u.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>b.current=!0)}},[m,o.trigger,o.valueNode,u,d,S,k,R,o.dir,r]);Rn(()=>A(),[A]);const[N,O]=E.useState();Rn(()=>{d&&O(window.getComputedStyle(d).zIndex)},[d]);const C=E.useCallback(_=>{_&&y.current===!0&&(A(),x==null||x(),y.current=!1)},[A,x]);return w.jsx(pQ,{scope:n,contentWrapper:u,shouldExpandOnScrollRef:b,onScrollButtonChange:C,children:w.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:w.jsx(Ze.div,{...a,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});Q3.displayName=dQ;var fQ="SelectPopperPosition",Ak=E.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=Lr,...o}=e,s=hp(n);return w.jsx(eT,{...s,...o,ref:t,align:r,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ak.displayName=fQ;var[pQ,iT]=Xs(vi,{}),Rk="SelectViewport",J3=E.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...a}=e,o=Mo(Rk,n),s=iT(Rk,n),u=gt(t,o.onViewportChange),c=E.useRef(0);return w.jsxs(w.Fragment,{children:[w.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),w.jsx(pp.Slot,{scope:n,children:w.jsx(Ze.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:u,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Ke(a.onScroll,d=>{const p=d.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:m}=s;if(m!=null&&m.current&&g){const b=Math.abs(c.current-p.scrollTop);if(b>0){const y=window.innerHeight-Lr*2,S=parseFloat(g.style.minHeight),k=parseFloat(g.style.height),R=Math.max(S,k);if(R0?N:0,g.style.justifyContent="flex-end")}}}c.current=p.scrollTop})})})]})});J3.displayName=Rk;var ej="SelectGroup",[gQ,hQ]=Xs(ej),tj=E.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=An();return w.jsx(gQ,{scope:n,id:a,children:w.jsx(Ze.div,{role:"group","aria-labelledby":a,...r,ref:t})})});tj.displayName=ej;var nj="SelectLabel",rj=E.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=hQ(nj,n);return w.jsx(Ze.div,{id:a.id,...r,ref:t})});rj.displayName=nj;var Ef="SelectItem",[mQ,aj]=Xs(Ef),oj=E.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:o,...s}=e,u=Lo(Ef,n),c=Mo(Ef,n),d=u.value===r,[p,g]=E.useState(o??""),[m,b]=E.useState(!1),y=gt(t,x=>{var A;return(A=c.itemRefCallback)==null?void 0:A.call(c,x,r,a)}),S=An(),k=E.useRef("touch"),R=()=>{a||(u.onValueChange(r),u.onOpenChange(!1))};if(r==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return w.jsx(mQ,{scope:n,value:r,disabled:a,textId:S,isSelected:d,onItemTextChange:E.useCallback(x=>{g(A=>A||((x==null?void 0:x.textContent)??"").trim())},[]),children:w.jsx(pp.ItemSlot,{scope:n,value:r,disabled:a,textValue:p,children:w.jsx(Ze.div,{role:"option","aria-labelledby":S,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...s,ref:y,onFocus:Ke(s.onFocus,()=>b(!0)),onBlur:Ke(s.onBlur,()=>b(!1)),onClick:Ke(s.onClick,()=>{k.current!=="mouse"&&R()}),onPointerUp:Ke(s.onPointerUp,()=>{k.current==="mouse"&&R()}),onPointerDown:Ke(s.onPointerDown,x=>{k.current=x.pointerType}),onPointerMove:Ke(s.onPointerMove,x=>{var A;k.current=x.pointerType,a?(A=c.onItemLeave)==null||A.call(c):k.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ke(s.onPointerLeave,x=>{var A;x.currentTarget===document.activeElement&&((A=c.onItemLeave)==null||A.call(c))}),onKeyDown:Ke(s.onKeyDown,x=>{var N;((N=c.searchRef)==null?void 0:N.current)!==""&&x.key===" "||(rQ.includes(x.key)&&R(),x.key===" "&&x.preventDefault())})})})})});oj.displayName=Ef;var gu="SelectItemText",ij=E.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:a,...o}=e,s=Lo(gu,n),u=Mo(gu,n),c=aj(gu,n),d=sQ(gu,n),[p,g]=E.useState(null),m=gt(t,R=>g(R),c.onItemTextChange,R=>{var x;return(x=u.itemTextRefCallback)==null?void 0:x.call(u,R,c.value,c.disabled)}),b=p==null?void 0:p.textContent,y=E.useMemo(()=>w.jsx("option",{value:c.value,disabled:c.disabled,children:b},c.value),[c.disabled,c.value,b]),{onNativeOptionAdd:S,onNativeOptionRemove:k}=d;return Rn(()=>(S(y),()=>k(y)),[S,k,y]),w.jsxs(w.Fragment,{children:[w.jsx(Ze.span,{id:c.textId,...o,ref:m}),c.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Gu.createPortal(o.children,s.valueNode):null]})});ij.displayName=gu;var sj="SelectItemIndicator",lj=E.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return aj(sj,n).isSelected?w.jsx(Ze.span,{"aria-hidden":!0,...r,ref:t}):null});lj.displayName=sj;var Ck="SelectScrollUpButton",uj=E.forwardRef((e,t)=>{const n=Mo(Ck,e.__scopeSelect),r=iT(Ck,e.__scopeSelect),[a,o]=E.useState(!1),s=gt(t,r.onScrollButtonChange);return Rn(()=>{if(n.viewport&&n.isPositioned){let u=function(){const d=c.scrollTop>0;o(d)};const c=n.viewport;return u(),c.addEventListener("scroll",u),()=>c.removeEventListener("scroll",u)}},[n.viewport,n.isPositioned]),a?w.jsx(dj,{...e,ref:s,onAutoScroll:()=>{const{viewport:u,selectedItem:c}=n;u&&c&&(u.scrollTop=u.scrollTop-c.offsetHeight)}}):null});uj.displayName=Ck;var _k="SelectScrollDownButton",cj=E.forwardRef((e,t)=>{const n=Mo(_k,e.__scopeSelect),r=iT(_k,e.__scopeSelect),[a,o]=E.useState(!1),s=gt(t,r.onScrollButtonChange);return Rn(()=>{if(n.viewport&&n.isPositioned){let u=function(){const d=c.scrollHeight-c.clientHeight,p=Math.ceil(c.scrollTop)c.removeEventListener("scroll",u)}},[n.viewport,n.isPositioned]),a?w.jsx(dj,{...e,ref:s,onAutoScroll:()=>{const{viewport:u,selectedItem:c}=n;u&&c&&(u.scrollTop=u.scrollTop+c.offsetHeight)}}):null});cj.displayName=_k;var dj=E.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=e,o=Mo("SelectScrollButton",n),s=E.useRef(null),u=gp(n),c=E.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return E.useEffect(()=>()=>c(),[c]),Rn(()=>{var p;const d=u().find(g=>g.ref.current===document.activeElement);(p=d==null?void 0:d.ref.current)==null||p.scrollIntoView({block:"nearest"})},[u]),w.jsx(Ze.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:Ke(a.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:Ke(a.onPointerMove,()=>{var d;(d=o.onItemLeave)==null||d.call(o),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:Ke(a.onPointerLeave,()=>{c()})})}),bQ="SelectSeparator",fj=E.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return w.jsx(Ze.div,{"aria-hidden":!0,...r,ref:t})});fj.displayName=bQ;var Nk="SelectArrow",yQ=E.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=hp(n),o=Lo(Nk,n),s=Mo(Nk,n);return o.open&&s.position==="popper"?w.jsx(tT,{...a,...r,ref:t}):null});yQ.displayName=Nk;function pj(e){return e===""||e===void 0}var gj=E.forwardRef((e,t)=>{const{value:n,...r}=e,a=E.useRef(null),o=gt(t,a),s=j3(n);return E.useEffect(()=>{const u=a.current,c=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(c,"value").set;if(s!==n&&p){const g=new Event("change",{bubbles:!0});p.call(u,n),u.dispatchEvent(g)}},[s,n]),w.jsx(nT,{asChild:!0,children:w.jsx("select",{...r,ref:o,defaultValue:n})})});gj.displayName="BubbleSelect";function hj(e){const t=yn(e),n=E.useRef(""),r=E.useRef(0),a=E.useCallback(s=>{const u=n.current+s;t(u),function c(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(u)},[t]),o=E.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return E.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,o]}function mj(e,t,n){const a=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let s=vQ(e,Math.max(o,0));a.length===1&&(s=s.filter(d=>d!==n));const c=s.find(d=>d.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==n?c:void 0}function vQ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var SQ=G3,bj=$3,EQ=V3,wQ=W3,xQ=Y3,yj=K3,kQ=J3,TQ=tj,vj=rj,Sj=oj,AQ=ij,RQ=lj,Ej=uj,wj=cj,xj=fj;const wf=SQ,eN=TQ,xf=EQ,Au=E.forwardRef(({className:e,children:t,...n},r)=>w.jsxs(bj,{ref:r,className:Pe("border-input bg-background ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-10 w-full items-center justify-between rounded-md border px-3 py-2 text-sm focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,w.jsx(wQ,{asChild:!0,children:w.jsx(N0,{className:"h-4 w-4 opacity-50"})})]}));Au.displayName=bj.displayName;const kj=E.forwardRef(({className:e,...t},n)=>w.jsx(Ej,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:w.jsx(qB,{className:"h-4 w-4"})}));kj.displayName=Ej.displayName;const Tj=E.forwardRef(({className:e,...t},n)=>w.jsx(wj,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:w.jsx(N0,{className:"h-4 w-4"})}));Tj.displayName=wj.displayName;const Ru=E.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>w.jsx(xQ,{children:w.jsxs(yj,{ref:a,className:Pe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[w.jsx(kj,{}),w.jsx(kQ,{className:Pe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),w.jsx(Tj,{})]})}));Ru.displayName=yj.displayName;const CQ=E.forwardRef(({className:e,...t},n)=>w.jsx(vj,{ref:n,className:Pe("py-1.5 pr-2 pl-8 text-sm font-semibold",e),...t}));CQ.displayName=vj.displayName;const xn=E.forwardRef(({className:e,children:t,...n},r)=>w.jsxs(Sj,{ref:r,className:Pe("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-default items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[w.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:w.jsx(RQ,{children:w.jsx(_0,{className:"h-4 w-4"})})}),w.jsx(AQ,{children:t})]}));xn.displayName=Sj.displayName;const _Q=E.forwardRef(({className:e,...t},n)=>w.jsx(xj,{ref:n,className:Pe("bg-muted -mx-1 my-1 h-px",e),...t}));_Q.displayName=xj.displayName;function Aj({className:e}){const[t,n]=E.useState(!1),{t:r}=Pt(),a=Le.use.language(),o=Le.use.setLanguage(),s=Le.use.theme(),u=Le.use.setTheme(),c=E.useCallback(p=>{o(p)},[o]),d=E.useCallback(p=>{u(p)},[u]);return w.jsxs(Yu,{open:t,onOpenChange:n,children:[w.jsx(Ku,{asChild:!0,children:w.jsx(xt,{variant:"ghost",size:"icon",className:Pe("h-9 w-9",e),children:w.jsx(HW,{className:"h-5 w-5"})})}),w.jsx(Ks,{side:"bottom",align:"end",className:"w-56",children:w.jsxs("div",{className:"flex flex-col gap-4",children:[w.jsxs("div",{className:"flex flex-col gap-2",children:[w.jsx("label",{className:"text-sm font-medium",children:r("settings.language")}),w.jsxs(wf,{value:a,onValueChange:c,children:[w.jsx(Au,{children:w.jsx(xf,{})}),w.jsxs(Ru,{children:[w.jsx(xn,{value:"en",children:"English"}),w.jsx(xn,{value:"zh",children:"中文"}),w.jsx(xn,{value:"fr",children:"Français"}),w.jsx(xn,{value:"ar",children:"العربية"})]})]})]}),w.jsxs("div",{className:"flex flex-col gap-2",children:[w.jsx("label",{className:"text-sm font-medium",children:r("settings.theme")}),w.jsxs(wf,{value:s,onValueChange:d,children:[w.jsx(Au,{children:w.jsx(xf,{})}),w.jsxs(Ru,{children:[w.jsx(xn,{value:"light",children:r("settings.light")}),w.jsx(xn,{value:"dark",children:r("settings.dark")}),w.jsx(xn,{value:"system",children:r("settings.system")})]})]})]})]})})]})}var lm="rovingFocusGroup.onEntryFocus",NQ={bubbles:!1,cancelable:!0},mp="RovingFocusGroup",[Ok,Rj,OQ]=U3(mp),[IQ,Cj]=wr(mp,[OQ]),[DQ,LQ]=IQ(mp),_j=E.forwardRef((e,t)=>w.jsx(Ok.Provider,{scope:e.__scopeRovingFocusGroup,children:w.jsx(Ok.Slot,{scope:e.__scopeRovingFocusGroup,children:w.jsx(MQ,{...e,ref:t})})}));_j.displayName=mp;var MQ=E.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:p=!1,...g}=e,m=E.useRef(null),b=gt(t,m),y=fp(o),[S=null,k]=ja({prop:s,defaultProp:u,onChange:c}),[R,x]=E.useState(!1),A=yn(d),N=Rj(n),O=E.useRef(!1),[C,_]=E.useState(0);return E.useEffect(()=>{const P=m.current;if(P)return P.addEventListener(lm,A),()=>P.removeEventListener(lm,A)},[A]),w.jsx(DQ,{scope:n,orientation:r,dir:y,loop:a,currentTabStopId:S,onItemFocus:E.useCallback(P=>k(P),[k]),onItemShiftTab:E.useCallback(()=>x(!0),[]),onFocusableItemAdd:E.useCallback(()=>_(P=>P+1),[]),onFocusableItemRemove:E.useCallback(()=>_(P=>P-1),[]),children:w.jsx(Ze.div,{tabIndex:R||C===0?-1:0,"data-orientation":r,...g,ref:b,style:{outline:"none",...e.style},onMouseDown:Ke(e.onMouseDown,()=>{O.current=!0}),onFocus:Ke(e.onFocus,P=>{const D=!O.current;if(P.target===P.currentTarget&&D&&!R){const L=new CustomEvent(lm,NQ);if(P.currentTarget.dispatchEvent(L),!L.defaultPrevented){const H=N().filter(j=>j.focusable),$=H.find(j=>j.active),U=H.find(j=>j.id===S),Z=[$,U,...H].filter(Boolean).map(j=>j.ref.current);Ij(Z,p)}}O.current=!1}),onBlur:Ke(e.onBlur,()=>x(!1))})})}),Nj="RovingFocusGroupItem",Oj=E.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:o,...s}=e,u=An(),c=o||u,d=LQ(Nj,n),p=d.currentTabStopId===c,g=Rj(n),{onFocusableItemAdd:m,onFocusableItemRemove:b}=d;return E.useEffect(()=>{if(r)return m(),()=>b()},[r,m,b]),w.jsx(Ok.ItemSlot,{scope:n,id:c,focusable:r,active:a,children:w.jsx(Ze.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...s,ref:t,onMouseDown:Ke(e.onMouseDown,y=>{r?d.onItemFocus(c):y.preventDefault()}),onFocus:Ke(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:Ke(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){d.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const S=zQ(y,d.orientation,d.dir);if(S!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let R=g().filter(x=>x.focusable).map(x=>x.ref.current);if(S==="last")R.reverse();else if(S==="prev"||S==="next"){S==="prev"&&R.reverse();const x=R.indexOf(y.currentTarget);R=d.loop?BQ(R,x+1):R.slice(x+1)}setTimeout(()=>Ij(R))}})})})});Oj.displayName=Nj;var PQ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function FQ(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function zQ(e,t,n){const r=FQ(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return PQ[r]}function Ij(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function BQ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var UQ=_j,jQ=Oj,sT="Tabs",[GQ,zxe]=wr(sT,[Cj]),Dj=Cj(),[HQ,lT]=GQ(sT),Lj=E.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:o,orientation:s="horizontal",dir:u,activationMode:c="automatic",...d}=e,p=fp(u),[g,m]=ja({prop:r,onChange:a,defaultProp:o});return w.jsx(HQ,{scope:n,baseId:An(),value:g,onValueChange:m,orientation:s,dir:p,activationMode:c,children:w.jsx(Ze.div,{dir:p,"data-orientation":s,...d,ref:t})})});Lj.displayName=sT;var Mj="TabsList",Pj=E.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...a}=e,o=lT(Mj,n),s=Dj(n);return w.jsx(UQ,{asChild:!0,...s,orientation:o.orientation,dir:o.dir,loop:r,children:w.jsx(Ze.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:t})})});Pj.displayName=Mj;var Fj="TabsTrigger",zj=E.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...o}=e,s=lT(Fj,n),u=Dj(n),c=jj(s.baseId,r),d=Gj(s.baseId,r),p=r===s.value;return w.jsx(jQ,{asChild:!0,...u,focusable:!a,active:p,children:w.jsx(Ze.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":d,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:c,...o,ref:t,onMouseDown:Ke(e.onMouseDown,g=>{!a&&g.button===0&&g.ctrlKey===!1?s.onValueChange(r):g.preventDefault()}),onKeyDown:Ke(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&s.onValueChange(r)}),onFocus:Ke(e.onFocus,()=>{const g=s.activationMode!=="manual";!p&&!a&&g&&s.onValueChange(r)})})})});zj.displayName=Fj;var Bj="TabsContent",Uj=E.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:a,children:o,...s}=e,u=lT(Bj,n),c=jj(u.baseId,r),d=Gj(u.baseId,r),p=r===u.value,g=E.useRef(p);return E.useEffect(()=>{const m=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(m)},[]),w.jsx(xr,{present:a||p,children:({present:m})=>w.jsx(Ze.div,{"data-state":p?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:d,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:m&&o})})});Uj.displayName=Bj;function jj(e,t){return`${e}-trigger-${t}`}function Gj(e,t){return`${e}-content-${t}`}var $Q=Lj,Hj=Pj,$j=zj,qj=Uj;const qQ=$Q,Vj=E.forwardRef(({className:e,...t},n)=>w.jsx(Hj,{ref:n,className:Pe("bg-muted text-muted-foreground inline-flex h-10 items-center justify-center rounded-md p-1",e),...t}));Vj.displayName=Hj.displayName;const Wj=E.forwardRef(({className:e,...t},n)=>w.jsx($j,{ref:n,className:Pe("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center rounded-sm px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm",e),...t}));Wj.displayName=$j.displayName;const hu=E.forwardRef(({className:e,...t},n)=>w.jsx(qj,{ref:n,className:Pe("ring-offset-background focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none","data-[state=inactive]:invisible data-[state=active]:visible","h-full w-full",e),forceMount:!0,...t}));hu.displayName=qj.displayName;function kd({value:e,currentTab:t,children:n}){return w.jsx(Wj,{value:e,className:Pe("cursor-pointer px-2 py-1 transition-all",t===e?"!bg-emerald-400 !text-zinc-50":"hover:bg-background/60"),children:n})}function VQ(){const e=Le.use.currentTab(),{t}=Pt();return w.jsx("div",{className:"flex h-8 self-center",children:w.jsxs(Vj,{className:"h-full gap-2",children:[w.jsx(kd,{value:"documents",currentTab:e,children:t("header.documents")}),w.jsx(kd,{value:"knowledge-graph",currentTab:e,children:t("header.knowledgeGraph")}),w.jsx(kd,{value:"retrieval",currentTab:e,children:t("header.retrieval")}),w.jsx(kd,{value:"api",currentTab:e,children:t("header.api")})]})})}function WQ(){const{t:e}=Pt(),{isGuestMode:t,coreVersion:n,apiVersion:r}=ra(),a=n&&r?`${n}/${r}`:null,o=()=>{C0.navigateToLogin()};return w.jsxs("header",{className:"border-border/40 bg-background/95 supports-[backdrop-filter]:bg-background/60 sticky top-0 z-50 flex h-10 w-full border-b px-4 backdrop-blur",children:[w.jsxs("a",{href:tV,className:"mr-6 flex items-center gap-2",children:[w.jsx(XB,{className:"size-4 text-emerald-400","aria-hidden":"true"}),w.jsx("span",{className:"font-bold md:inline-block",children:T_.name}),a&&w.jsxs("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400",children:["v",a]})]}),w.jsxs("div",{className:"flex h-10 flex-1 justify-center",children:[w.jsx(VQ,{}),t&&w.jsx("div",{className:"ml-2 self-center px-2 py-1 text-xs bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200 rounded-md",children:e("login.guestMode","Guest Mode")})]}),w.jsx("nav",{className:"flex items-center",children:w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx(xt,{variant:"ghost",size:"icon",side:"bottom",tooltip:e("header.projectRepository"),children:w.jsx("a",{href:T_.github,target:"_blank",rel:"noopener noreferrer",children:w.jsx(NW,{className:"size-4","aria-hidden":"true"})})}),w.jsx(Aj,{}),!t&&w.jsx(xt,{variant:"ghost",size:"icon",side:"bottom",tooltip:e("header.logout"),onClick:o,children:w.jsx(FW,{className:"size-4","aria-hidden":"true"})})]})})]})}var Td={exports:{}},tN;function YQ(){if(tN)return Td.exports;tN=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(O,C,_){return Function.prototype.apply.call(O,C,_)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(O){return Object.getOwnPropertyNames(O).concat(Object.getOwnPropertySymbols(O))}:n=function(O){return Object.getOwnPropertyNames(O)};function r(N){console&&console.warn&&console.warn(N)}var a=Number.isNaN||function(O){return O!==O};function o(){o.init.call(this)}Td.exports=o,Td.exports.once=R,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function u(N){if(typeof N!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof N)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(N){if(typeof N!="number"||N<0||a(N))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+N+".");s=N}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(O){if(typeof O!="number"||O<0||a(O))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+O+".");return this._maxListeners=O,this};function c(N){return N._maxListeners===void 0?o.defaultMaxListeners:N._maxListeners}o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(O){for(var C=[],_=1;_0&&(L=C[0]),L instanceof Error)throw L;var H=new Error("Unhandled error."+(L?" ("+L.message+")":""));throw H.context=L,H}var $=D[O];if($===void 0)return!1;if(typeof $=="function")t($,this,C);else for(var U=$.length,W=y($,U),_=0;_0&&L.length>P&&!L.warned){L.warned=!0;var H=new Error("Possible EventEmitter memory leak detected. "+L.length+" "+String(O)+" listeners added. Use emitter.setMaxListeners() to increase limit");H.name="MaxListenersExceededWarning",H.emitter=N,H.type=O,H.count=L.length,r(H)}return N}o.prototype.addListener=function(O,C){return d(this,O,C,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(O,C){return d(this,O,C,!0)};function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function g(N,O,C){var _={fired:!1,wrapFn:void 0,target:N,type:O,listener:C},P=p.bind(_);return P.listener=C,_.wrapFn=P,P}o.prototype.once=function(O,C){return u(C),this.on(O,g(this,O,C)),this},o.prototype.prependOnceListener=function(O,C){return u(C),this.prependListener(O,g(this,O,C)),this},o.prototype.removeListener=function(O,C){var _,P,D,L,H;if(u(C),P=this._events,P===void 0)return this;if(_=P[O],_===void 0)return this;if(_===C||_.listener===C)--this._eventsCount===0?this._events=Object.create(null):(delete P[O],P.removeListener&&this.emit("removeListener",O,_.listener||C));else if(typeof _!="function"){for(D=-1,L=_.length-1;L>=0;L--)if(_[L]===C||_[L].listener===C){H=_[L].listener,D=L;break}if(D<0)return this;D===0?_.shift():S(_,D),_.length===1&&(P[O]=_[0]),P.removeListener!==void 0&&this.emit("removeListener",O,H||C)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(O){var C,_,P;if(_=this._events,_===void 0)return this;if(_.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):_[O]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete _[O]),this;if(arguments.length===0){var D=Object.keys(_),L;for(P=0;P=0;P--)this.removeListener(O,C[P]);return this};function m(N,O,C){var _=N._events;if(_===void 0)return[];var P=_[O];return P===void 0?[]:typeof P=="function"?C?[P.listener||P]:[P]:C?k(P):y(P,P.length)}o.prototype.listeners=function(O){return m(this,O,!0)},o.prototype.rawListeners=function(O){return m(this,O,!1)},o.listenerCount=function(N,O){return typeof N.listenerCount=="function"?N.listenerCount(O):b.call(N,O)},o.prototype.listenerCount=b;function b(N){var O=this._events;if(O!==void 0){var C=O[N];if(typeof C=="function")return 1;if(C!==void 0)return C.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function y(N,O){for(var C=new Array(O),_=0;_e++}function Ba(){const e=arguments;let t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done){t=null;continue}break}while(!0);return r}}}function Zs(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class uT extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class Me extends uT{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Me.prototype.constructor)}}class Ie extends uT{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Ie.prototype.constructor)}}class Qe extends uT{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Qe.prototype.constructor)}}function Xj(e,t){this.key=e,this.attributes=t,this.clear()}Xj.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Zj(e,t){this.key=e,this.attributes=t,this.clear()}Zj.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Qj(e,t){this.key=e,this.attributes=t,this.clear()}Qj.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Qs(e,t,n,r,a){this.key=t,this.attributes=a,this.undirected=e,this.source=n,this.target=r}Qs.prototype.attach=function(){let e="out",t="in";this.undirected&&(e=t="undirected");const n=this.source.key,r=this.target.key;this.source[e][r]=this,!(this.undirected&&n===r)&&(this.target[t][n]=this)};Qs.prototype.attachMulti=function(){let e="out",t="in";const n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");const a=this.source[e],o=a[r];if(typeof o>"u"){a[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}o.previous=this,this.next=o,a[r]=this,this.target[t][n]=this};Qs.prototype.detach=function(){const e=this.source.key,t=this.target.key;let n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][t],delete this.target[r][e]};Qs.prototype.detachMulti=function(){const e=this.source.key,t=this.target.key;let n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Jj=0,e4=1,ZQ=2,t4=3;function Wa(e,t,n,r,a,o,s){let u,c,d,p;if(r=""+r,n===Jj){if(u=e._nodes.get(r),!u)throw new Ie(`Graph.${t}: could not find the "${r}" node in the graph.`);d=a,p=o}else if(n===t4){if(a=""+a,c=e._edges.get(a),!c)throw new Ie(`Graph.${t}: could not find the "${a}" edge in the graph.`);const g=c.source.key,m=c.target.key;if(r===g)u=c.target;else if(r===m)u=c.source;else throw new Ie(`Graph.${t}: the "${r}" node is not attached to the "${a}" edge (${g}, ${m}).`);d=o,p=s}else{if(c=e._edges.get(r),!c)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===e4?u=c.source:u=c.target,d=a,p=o}return[u,d,p]}function QQ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);return s.attributes[u]}}function JQ(e,t,n){e.prototype[t]=function(r,a){const[o]=Wa(this,t,n,r,a);return o.attributes}}function eJ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);return s.attributes.hasOwnProperty(u)}}function tJ(e,t,n){e.prototype[t]=function(r,a,o,s){const[u,c,d]=Wa(this,t,n,r,a,o,s);return u.attributes[c]=d,this.emit("nodeAttributesUpdated",{key:u.key,type:"set",attributes:u.attributes,name:c}),this}}function nJ(e,t,n){e.prototype[t]=function(r,a,o,s){const[u,c,d]=Wa(this,t,n,r,a,o,s);if(typeof d!="function")throw new Me(`Graph.${t}: updater should be a function.`);const p=u.attributes,g=d(p[c]);return p[c]=g,this.emit("nodeAttributesUpdated",{key:u.key,type:"set",attributes:u.attributes,name:c}),this}}function rJ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);return delete s.attributes[u],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:u}),this}}function aJ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);if(!vn(u))throw new Me(`Graph.${t}: provided attributes are not a plain object.`);return s.attributes=u,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function oJ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);if(!vn(u))throw new Me(`Graph.${t}: provided attributes are not a plain object.`);return nn(s.attributes,u),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:u}),this}}function iJ(e,t,n){e.prototype[t]=function(r,a,o){const[s,u]=Wa(this,t,n,r,a,o);if(typeof u!="function")throw new Me(`Graph.${t}: provided updater is not a function.`);return s.attributes=u(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const sJ=[{name:e=>`get${e}Attribute`,attacher:QQ},{name:e=>`get${e}Attributes`,attacher:JQ},{name:e=>`has${e}Attribute`,attacher:eJ},{name:e=>`set${e}Attribute`,attacher:tJ},{name:e=>`update${e}Attribute`,attacher:nJ},{name:e=>`remove${e}Attribute`,attacher:rJ},{name:e=>`replace${e}Attributes`,attacher:aJ},{name:e=>`merge${e}Attributes`,attacher:oJ},{name:e=>`update${e}Attributes`,attacher:iJ}];function lJ(e){sJ.forEach(function({name:t,attacher:n}){n(e,t("Node"),Jj),n(e,t("Source"),e4),n(e,t("Target"),ZQ),n(e,t("Opposite"),t4)})}function uJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[a]}}function cJ(e,t,n){e.prototype[t]=function(r){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+r,s=""+arguments[1];if(a=Er(this,o,s,n),!a)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return a.attributes}}function dJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(a)}}function fJ(e,t,n){e.prototype[t]=function(r,a,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+r,c=""+a;if(a=arguments[2],o=arguments[3],s=Er(this,u,c,n),!s)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${u}" - "${c}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,s=this._edges.get(r),!s)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return s.attributes[a]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:a}),this}}function pJ(e,t,n){e.prototype[t]=function(r,a,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+r,c=""+a;if(a=arguments[2],o=arguments[3],s=Er(this,u,c,n),!s)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${u}" - "${c}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,s=this._edges.get(r),!s)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new Me(`Graph.${t}: updater should be a function.`);return s.attributes[a]=o(s.attributes[a]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:a}),this}}function gJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[a],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:a}),this}}function hJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!vn(a))throw new Me(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=a,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function mJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!vn(a))throw new Me(`Graph.${t}: provided attributes are not a plain object.`);return nn(o.attributes,a),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:a}),this}}function bJ(e,t,n){e.prototype[t]=function(r,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new Qe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Qe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,u=""+a;if(a=arguments[2],o=Er(this,s,u,n),!o)throw new Ie(`Graph.${t}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(n!=="mixed")throw new Qe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Ie(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof a!="function")throw new Me(`Graph.${t}: provided updater is not a function.`);return o.attributes=a(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const yJ=[{name:e=>`get${e}Attribute`,attacher:uJ},{name:e=>`get${e}Attributes`,attacher:cJ},{name:e=>`has${e}Attribute`,attacher:dJ},{name:e=>`set${e}Attribute`,attacher:fJ},{name:e=>`update${e}Attribute`,attacher:pJ},{name:e=>`remove${e}Attribute`,attacher:gJ},{name:e=>`replace${e}Attributes`,attacher:hJ},{name:e=>`merge${e}Attributes`,attacher:mJ},{name:e=>`update${e}Attributes`,attacher:bJ}];function vJ(e){yJ.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const SJ=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function EJ(e,t,n,r){let a=!1;for(const o in t){if(o===r)continue;const s=t[o];if(a=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),e&&a)return s.key}}function wJ(e,t,n,r){let a,o,s,u=!1;for(const c in t)if(c!==r){a=t[c];do{if(o=a.source,s=a.target,u=n(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected),e&&u)return a.key;a=a.next}while(a!==void 0)}}function um(e,t){const n=Object.keys(e),r=n.length;let a,o=0;return{[Symbol.iterator](){return this},next(){do if(a)a=a.next;else{if(o>=r)return{done:!0};const s=n[o++];if(s===t){a=void 0;continue}a=e[s]}while(!a);return{done:!1,value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected}}}}}function xJ(e,t,n,r){const a=t[n];if(!a)return;const o=a.source,s=a.target;if(r(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected)&&e)return a.key}function kJ(e,t,n,r){let a=t[n];if(!a)return;let o=!1;do{if(o=r(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),e&&o)return a.key;a=a.next}while(a!==void 0)}function cm(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};const a={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:a}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function TJ(e,t){if(e.size===0)return[];if(t==="mixed"||t===e.type)return Array.from(e._edges.keys());const n=t==="undirected"?e.undirectedSize:e.directedSize,r=new Array(n),a=t==="undirected",o=e._edges.values();let s=0,u,c;for(;u=o.next(),u.done!==!0;)c=u.value,c.undirected===a&&(r[s++]=c.key);return r}function n4(e,t,n,r){if(t.size===0)return;const a=n!=="mixed"&&n!==t.type,o=n==="undirected";let s,u,c=!1;const d=t._edges.values();for(;s=d.next(),s.done!==!0;){if(u=s.value,a&&u.undirected!==o)continue;const{key:p,attributes:g,source:m,target:b}=u;if(c=r(p,g,m.key,b.key,m.attributes,b.attributes,u.undirected),e&&c)return p}}function AJ(e,t){if(e.size===0)return Zs();const n=t!=="mixed"&&t!==e.type,r=t==="undirected",a=e._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=a.next(),o.done)return o;if(s=o.value,!(n&&s.undirected!==r))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function cT(e,t,n,r,a,o){const s=t?wJ:EJ;let u;if(n!=="undirected"&&(r!=="out"&&(u=s(e,a.in,o),e&&u)||r!=="in"&&(u=s(e,a.out,o,r?void 0:a.key),e&&u))||n!=="directed"&&(u=s(e,a.undirected,o),e&&u))return u}function RJ(e,t,n,r){const a=[];return cT(!1,e,t,n,r,function(o){a.push(o)}),a}function CJ(e,t,n){let r=Zs();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=Ba(r,um(n.in))),t!=="in"&&typeof n.out<"u"&&(r=Ba(r,um(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=Ba(r,um(n.undirected))),r}function dT(e,t,n,r,a,o,s){const u=n?kJ:xJ;let c;if(t!=="undirected"&&(typeof a.in<"u"&&r!=="out"&&(c=u(e,a.in,o,s),e&&c)||typeof a.out<"u"&&r!=="in"&&(r||a.key!==o)&&(c=u(e,a.out,o,s),e&&c))||t!=="directed"&&typeof a.undirected<"u"&&(c=u(e,a.undirected,o,s),e&&c))return c}function _J(e,t,n,r,a){const o=[];return dT(!1,e,t,n,r,a,function(s){o.push(s)}),o}function NJ(e,t,n,r){let a=Zs();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(a=Ba(a,cm(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(a=Ba(a,cm(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(a=Ba(a,cm(n.undirected,r))),a}function OJ(e,t){const{name:n,type:r,direction:a}=t;e.prototype[n]=function(o,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return TJ(this,r);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(typeof u>"u")throw new Ie(`Graph.${n}: could not find the "${o}" node in the graph.`);return RJ(this.multi,r==="mixed"?this.type:r,a,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new Ie(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new Ie(`Graph.${n}: could not find the "${s}" target node in the graph.`);return _J(r,this.multi,a,u,s)}throw new Me(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function IJ(e,t){const{name:n,type:r,direction:a}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(d,p,g){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return g=d,n4(!1,this,r,g);if(arguments.length===2){d=""+d,g=p;const m=this._nodes.get(d);if(typeof m>"u")throw new Ie(`Graph.${o}: could not find the "${d}" node in the graph.`);return cT(!1,this.multi,r==="mixed"?this.type:r,a,m,g)}if(arguments.length===3){d=""+d,p=""+p;const m=this._nodes.get(d);if(!m)throw new Ie(`Graph.${o}: could not find the "${d}" source node in the graph.`);if(!this._nodes.has(p))throw new Ie(`Graph.${o}: could not find the "${p}" target node in the graph.`);return dT(!1,r,this.multi,a,m,p,g)}throw new Me(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){const d=Array.prototype.slice.call(arguments),p=d.pop();let g;if(d.length===0){let m=0;r!=="directed"&&(m+=this.undirectedSize),r!=="undirected"&&(m+=this.directedSize),g=new Array(m);let b=0;d.push((y,S,k,R,x,A,N)=>{g[b++]=p(y,S,k,R,x,A,N)})}else g=[],d.push((m,b,y,S,k,R,x)=>{g.push(p(m,b,y,S,k,R,x))});return this[o].apply(this,d),g};const u="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[u]=function(){const d=Array.prototype.slice.call(arguments),p=d.pop(),g=[];return d.push((m,b,y,S,k,R,x)=>{p(m,b,y,S,k,R,x)&&g.push(m)}),this[o].apply(this,d),g};const c="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(){let d=Array.prototype.slice.call(arguments);if(d.length<2||d.length>4)throw new Me(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${d.length}).`);if(typeof d[d.length-1]=="function"&&typeof d[d.length-2]!="function")throw new Me(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let p,g;d.length===2?(p=d[0],g=d[1],d=[]):d.length===3?(p=d[1],g=d[2],d=[d[0]]):d.length===4&&(p=d[2],g=d[3],d=[d[0],d[1]]);let m=g;return d.push((b,y,S,k,R,x,A)=>{m=p(m,b,y,S,k,R,x,A)}),this[o].apply(this,d),m}}function DJ(e,t){const{name:n,type:r,direction:a}=t,o="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,d,p){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return p=c,n4(!0,this,r,p);if(arguments.length===2){c=""+c,p=d;const g=this._nodes.get(c);if(typeof g>"u")throw new Ie(`Graph.${o}: could not find the "${c}" node in the graph.`);return cT(!0,this.multi,r==="mixed"?this.type:r,a,g,p)}if(arguments.length===3){c=""+c,d=""+d;const g=this._nodes.get(c);if(!g)throw new Ie(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(d))throw new Ie(`Graph.${o}: could not find the "${d}" target node in the graph.`);return dT(!0,r,this.multi,a,g,d,p)}throw new Me(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){const c=Array.prototype.slice.call(arguments),d=c.pop();return c.push((g,m,b,y,S,k,R)=>d(g,m,b,y,S,k,R)),!!this[o].apply(this,c)};const u="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[u]=function(){const c=Array.prototype.slice.call(arguments),d=c.pop();return c.push((g,m,b,y,S,k,R)=>!d(g,m,b,y,S,k,R)),!this[o].apply(this,c)}}function LJ(e,t){const{name:n,type:r,direction:a}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Zs();if(!arguments.length)return AJ(this,r);if(arguments.length===1){s=""+s;const c=this._nodes.get(s);if(!c)throw new Ie(`Graph.${o}: could not find the "${s}" node in the graph.`);return CJ(r,a,c)}if(arguments.length===2){s=""+s,u=""+u;const c=this._nodes.get(s);if(!c)throw new Ie(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(u))throw new Ie(`Graph.${o}: could not find the "${u}" target node in the graph.`);return NJ(r,a,c,u)}throw new Me(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function MJ(e){SJ.forEach(t=>{OJ(e,t),IJ(e,t),DJ(e,t),LJ(e,t)})}const PJ=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function bp(){this.A=null,this.B=null}bp.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};bp.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function ru(e,t,n,r,a){for(const o in r){const s=r[o],u=s.source,c=s.target,d=u===n?c:u;if(t&&t.has(d.key))continue;const p=a(d.key,d.attributes);if(e&&p)return d.key}}function fT(e,t,n,r,a){if(t!=="mixed"){if(t==="undirected")return ru(e,null,r,r.undirected,a);if(typeof n=="string")return ru(e,null,r,r[n],a)}const o=new bp;let s;if(t!=="undirected"){if(n!=="out"){if(s=ru(e,null,r,r.in,a),e&&s)return s;o.wrap(r.in)}if(n!=="in"){if(s=ru(e,o,r,r.out,a),e&&s)return s;o.wrap(r.out)}}if(t!=="directed"&&(s=ru(e,o,r,r.undirected,a),e&&s))return s}function FJ(e,t,n){if(e!=="mixed"){if(e==="undirected")return Object.keys(n.undirected);if(typeof t=="string")return Object.keys(n[t])}const r=[];return fT(!1,e,t,n,function(a){r.push(a)}),r}function au(e,t,n){const r=Object.keys(n),a=r.length;let o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=a)return e&&e.wrap(n),{done:!0};const u=n[r[o++]],c=u.source,d=u.target;if(s=c===t?d:c,e&&e.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function zJ(e,t,n){if(e!=="mixed"){if(e==="undirected")return au(null,n,n.undirected);if(typeof t=="string")return au(null,n,n[t])}let r=Zs();const a=new bp;return e!=="undirected"&&(t!=="out"&&(r=Ba(r,au(a,n,n.in))),t!=="in"&&(r=Ba(r,au(a,n,n.out)))),e!=="directed"&&(r=Ba(r,au(a,n,n.undirected))),r}function BJ(e,t){const{name:n,type:r,direction:a}=t;e.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new Ie(`Graph.${n}: could not find the "${o}" node in the graph.`);return FJ(r==="mixed"?this.type:r,a,s)}}function UJ(e,t){const{name:n,type:r,direction:a}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(d,p){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;d=""+d;const g=this._nodes.get(d);if(typeof g>"u")throw new Ie(`Graph.${o}: could not find the "${d}" node in the graph.`);fT(!1,r==="mixed"?this.type:r,a,g,p)};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(d,p){const g=[];return this[o](d,(m,b)=>{g.push(p(m,b))}),g};const u="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[u]=function(d,p){const g=[];return this[o](d,(m,b)=>{p(m,b)&&g.push(m)}),g};const c="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(d,p,g){if(arguments.length<3)throw new Me(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let m=g;return this[o](d,(b,y)=>{m=p(m,b,y)}),m}}function jJ(e,t){const{name:n,type:r,direction:a}=t,o=n[0].toUpperCase()+n.slice(1,-1),s="find"+o;e.prototype[s]=function(d,p){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;d=""+d;const g=this._nodes.get(d);if(typeof g>"u")throw new Ie(`Graph.${s}: could not find the "${d}" node in the graph.`);return fT(!0,r==="mixed"?this.type:r,a,g,p)};const u="some"+o;e.prototype[u]=function(d,p){return!!this[s](d,p)};const c="every"+o;e.prototype[c]=function(d,p){return!this[s](d,(m,b)=>!p(m,b))}}function GJ(e,t){const{name:n,type:r,direction:a}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Zs();s=""+s;const u=this._nodes.get(s);if(typeof u>"u")throw new Ie(`Graph.${o}: could not find the "${s}" node in the graph.`);return zJ(r==="mixed"?this.type:r,a,u)}}function HJ(e){PJ.forEach(t=>{BJ(e,t),UJ(e,t),jJ(e,t),GJ(e,t)})}function Ad(e,t,n,r,a){const o=r._nodes.values(),s=r.type;let u,c,d,p,g,m;for(;u=o.next(),u.done!==!0;){let b=!1;if(c=u.value,s!=="undirected"){p=c.out;for(d in p){g=p[d];do m=g.target,b=!0,a(c.key,m.key,c.attributes,m.attributes,g.key,g.attributes,g.undirected),g=g.next;while(g)}}if(s!=="directed"){p=c.undirected;for(d in p)if(!(t&&c.key>d)){g=p[d];do m=g.target,m.key!==d&&(m=g.source),b=!0,a(c.key,m.key,c.attributes,m.attributes,g.key,g.attributes,g.undirected),g=g.next;while(g)}}n&&!b&&a(c.key,null,c.attributes,null,null,null,null)}}function $J(e,t){const n={key:e};return Kj(t.attributes)||(n.attributes=nn({},t.attributes)),n}function qJ(e,t,n){const r={key:t,source:n.source.key,target:n.target.key};return Kj(n.attributes)||(r.attributes=nn({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function VJ(e){if(!vn(e))throw new Me('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new Me("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!vn(e.attributes)||e.attributes===null))throw new Me("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function WJ(e){if(!vn(e))throw new Me('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new Me("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new Me("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!vn(e.attributes)||e.attributes===null))throw new Me("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new Me("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const YJ=XQ(),KJ=new Set(["directed","undirected","mixed"]),rN=new Set(["domain","_events","_eventsCount","_maxListeners"]),XJ=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:"directed"},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:"directed"},{name:e=>`${e}UndirectedEdgeWithKey`,type:"undirected"}],ZJ={allowSelfLoops:!0,multi:!1,type:"mixed"};function QJ(e,t,n){if(n&&!vn(n))throw new Me(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new Qe(`Graph.addNode: the "${t}" node already exist in the graph.`);const r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function aN(e,t,n){const r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function r4(e,t,n,r,a,o,s,u){if(!r&&e.type==="undirected")throw new Qe(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new Qe(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(u&&!vn(u))throw new Me(`Graph.${t}: invalid attributes. Expecting an object but got "${u}"`);if(o=""+o,s=""+s,u=u||{},!e.allowSelfLoops&&o===s)throw new Qe(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const c=e._nodes.get(o),d=e._nodes.get(s);if(!c)throw new Ie(`Graph.${t}: source node "${o}" not found.`);if(!d)throw new Ie(`Graph.${t}: target node "${s}" not found.`);const p={key:null,undirected:r,source:o,target:s,attributes:u};if(n)a=e._edgeKeyGenerator();else if(a=""+a,e._edges.has(a))throw new Qe(`Graph.${t}: the "${a}" edge already exists in the graph.`);if(!e.multi&&(r?typeof c.undirected[s]<"u":typeof c.out[s]<"u"))throw new Qe(`Graph.${t}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const g=new Qs(r,a,c,d,u);e._edges.set(a,g);const m=o===s;return r?(c.undirectedDegree++,d.undirectedDegree++,m&&(c.undirectedLoops++,e._undirectedSelfLoopCount++)):(c.outDegree++,d.inDegree++,m&&(c.directedLoops++,e._directedSelfLoopCount++)),e.multi?g.attachMulti():g.attach(),r?e._undirectedSize++:e._directedSize++,p.key=a,e.emit("edgeAdded",p),a}function JJ(e,t,n,r,a,o,s,u,c){if(!r&&e.type==="undirected")throw new Qe(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new Qe(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(u){if(c){if(typeof u!="function")throw new Me(`Graph.${t}: invalid updater function. Expecting a function but got "${u}"`)}else if(!vn(u))throw new Me(`Graph.${t}: invalid attributes. Expecting an object but got "${u}"`)}o=""+o,s=""+s;let d;if(c&&(d=u,u=void 0),!e.allowSelfLoops&&o===s)throw new Qe(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let p=e._nodes.get(o),g=e._nodes.get(s),m,b;if(!n&&(m=e._edges.get(a),m)){if((m.source.key!==o||m.target.key!==s)&&(!r||m.source.key!==s||m.target.key!==o))throw new Qe(`Graph.${t}: inconsistency detected when attempting to merge the "${a}" edge with "${o}" source & "${s}" target vs. ("${m.source.key}", "${m.target.key}").`);b=m}if(!b&&!e.multi&&p&&(b=r?p.undirected[s]:p.out[s]),b){const x=[b.key,!1,!1,!1];if(c?!d:!u)return x;if(c){const A=b.attributes;b.attributes=d(A),e.emit("edgeAttributesUpdated",{type:"replace",key:b.key,attributes:b.attributes})}else nn(b.attributes,u),e.emit("edgeAttributesUpdated",{type:"merge",key:b.key,attributes:b.attributes,data:u});return x}u=u||{},c&&d&&(u=d(u));const y={key:null,undirected:r,source:o,target:s,attributes:u};if(n)a=e._edgeKeyGenerator();else if(a=""+a,e._edges.has(a))throw new Qe(`Graph.${t}: the "${a}" edge already exists in the graph.`);let S=!1,k=!1;p||(p=aN(e,o,{}),S=!0,o===s&&(g=p,k=!0)),g||(g=aN(e,s,{}),k=!0),m=new Qs(r,a,p,g,u),e._edges.set(a,m);const R=o===s;return r?(p.undirectedDegree++,g.undirectedDegree++,R&&(p.undirectedLoops++,e._undirectedSelfLoopCount++)):(p.outDegree++,g.inDegree++,R&&(p.directedLoops++,e._directedSelfLoopCount++)),e.multi?m.attachMulti():m.attach(),r?e._undirectedSize++:e._directedSize++,y.key=a,e.emit("edgeAdded",y),[a,!0,S,k]}function ps(e,t){e._edges.delete(t.key);const{source:n,target:r,attributes:a}=t,o=t.undirected,s=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,s&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,s&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),o?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:a,source:n.key,target:r.key,undirected:o})}class Ct extends Yj.EventEmitter{constructor(t){if(super(),t=nn({},ZJ,t),typeof t.multi!="boolean")throw new Me(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!KJ.has(t.type))throw new Me(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new Me(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?Xj:t.type==="directed"?Zj:Qj;yr(this,"NodeDataClass",n);const r="geid_"+YJ()+"_";let a=0;const o=()=>{let s;do s=r+a++;while(this._edges.has(s));return s};yr(this,"_attributes",{}),yr(this,"_nodes",new Map),yr(this,"_edges",new Map),yr(this,"_directedSize",0),yr(this,"_undirectedSize",0),yr(this,"_directedSelfLoopCount",0),yr(this,"_undirectedSelfLoopCount",0),yr(this,"_edgeKeyGenerator",o),yr(this,"_options",t),rN.forEach(s=>yr(this,s,this[s])),Dr(this,"order",()=>this._nodes.size),Dr(this,"size",()=>this._edges.size),Dr(this,"directedSize",()=>this._directedSize),Dr(this,"undirectedSize",()=>this._undirectedSize),Dr(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Dr(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Dr(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Dr(this,"multi",this._options.multi),Dr(this,"type",this._options.type),Dr(this,"allowSelfLoops",this._options.allowSelfLoops),Dr(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(t){return this._nodes.has(""+t)}hasDirectedEdge(t,n){if(this.type==="undirected")return!1;if(arguments.length===1){const r=""+t,a=this._edges.get(r);return!!a&&!a.undirected}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?r.out.hasOwnProperty(n):!1}throw new Me(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(t,n){if(this.type==="directed")return!1;if(arguments.length===1){const r=""+t,a=this._edges.get(r);return!!a&&a.undirected}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?r.undirected.hasOwnProperty(n):!1}throw new Me(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(t,n){if(arguments.length===1){const r=""+t;return this._edges.has(r)}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new Me(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(t,n){if(this.type==="undirected")return;if(t=""+t,n=""+n,this.multi)throw new Qe("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Ie(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);const a=r.out&&r.out[n]||void 0;if(a)return a.key}undirectedEdge(t,n){if(this.type==="directed")return;if(t=""+t,n=""+n,this.multi)throw new Qe("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Ie(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);const a=r.undirected&&r.undirected[n]||void 0;if(a)return a.key}edge(t,n){if(this.multi)throw new Qe("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Ie(`Graph.edge: could not find the "${n}" target node in the graph.`);const a=r.out&&r.out[n]||r.undirected&&r.undirected[n]||void 0;if(a)return a.key}areDirectedNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areDirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areOutNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areInNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areUndirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areInboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Ie(`Graph.areOutboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.inDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.outDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.directedDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.undirectedDegree: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.inboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.outboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.degree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.inDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.outDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.directedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,a=0;return this.type!=="directed"&&(r+=n.undirectedDegree,a+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree,a+=n.directedLoops),r-a}outboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,a=0;return this.type!=="directed"&&(r+=n.undirectedDegree,a+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.outDegree,a+=n.directedLoops),r-a}degreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.degreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,a=0;return this.type!=="directed"&&(r+=n.undirectedDegree,a+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree,a+=n.directedLoops*2),r-a}source(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.source: could not find the "${t}" edge in the graph.`);return n.source.key}target(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.target: could not find the "${t}" edge in the graph.`);return n.target.key}extremities(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.extremities: could not find the "${t}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(t,n){t=""+t,n=""+n;const r=this._edges.get(n);if(!r)throw new Ie(`Graph.opposite: could not find the "${n}" edge in the graph.`);const a=r.source.key,o=r.target.key;if(t===a)return o;if(t===o)return a;throw new Ie(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${a}, ${o}).`)}hasExtremity(t,n){t=""+t,n=""+n;const r=this._edges.get(t);if(!r)throw new Ie(`Graph.hasExtremity: could not find the "${t}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.isUndirected: could not find the "${t}" edge in the graph.`);return n.undirected}isDirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.isDirected: could not find the "${t}" edge in the graph.`);return!n.undirected}isSelfLoop(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return QJ(this,t,n).key}mergeNode(t,n){if(n&&!vn(n))throw new Me(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(nn(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:r.attributes,data:n})),[t,!1]):(r=new this.NodeDataClass(t,n),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:n}),[t,!0])}updateNode(t,n){if(n&&typeof n!="function")throw new Me(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let r=this._nodes.get(t);if(r){if(n){const o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:r.attributes})}return[t,!1]}const a=n?n({}):{};return r=new this.NodeDataClass(t,a),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:a}),[t,!0]}dropNode(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Ie(`Graph.dropNode: could not find the "${t}" node in the graph.`);let r;if(this.type!=="undirected"){for(const a in n.out){r=n.out[a];do ps(this,r),r=r.next;while(r)}for(const a in n.in){r=n.in[a];do ps(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(const a in n.undirected){r=n.undirected[a];do ps(this,r),r=r.next;while(r)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})}dropEdge(t){let n;if(arguments.length>1){const r=""+arguments[0],a=""+arguments[1];if(n=Er(this,r,a,this.type),!n)throw new Ie(`Graph.dropEdge: could not find the "${r}" -> "${a}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new Ie(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return ps(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new Qe("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new Qe("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");t=""+t,n=""+n;const r=Er(this,t,n,"directed");if(!r)throw new Ie(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return ps(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new Qe("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new Qe("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const r=Er(this,t,n,"undirected");if(!r)throw new Ie(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return ps(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const t=this._nodes.values();let n;for(;n=t.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(t){return this._attributes[t]}getAttributes(){return this._attributes}hasAttribute(t){return this._attributes.hasOwnProperty(t)}setAttribute(t,n){return this._attributes[t]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}updateAttribute(t,n){if(typeof n!="function")throw new Me("Graph.updateAttribute: updater should be a function.");const r=this._attributes[t];return this._attributes[t]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}removeAttribute(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this}replaceAttributes(t){if(!vn(t))throw new Me("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(t){if(!vn(t))throw new Me("Graph.mergeAttributes: provided attributes are not a plain object.");return nn(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new Me("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(t,n){if(typeof t!="function")throw new Me("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!nN(n))throw new Me("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const r=this._nodes.values();let a,o;for(;a=r.next(),a.done!==!0;)o=a.value,o.attributes=t(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new Me("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!nN(n))throw new Me("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const r=this._edges.values();let a,o,s,u;for(;a=r.next(),a.done!==!0;)o=a.value,s=o.source,u=o.target,o.attributes=t(o.key,o.attributes,s.key,u.key,s.attributes,u.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new Me("Graph.forEachAdjacencyEntry: expecting a callback.");Ad(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new Me("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Ad(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new Me("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Ad(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new Me("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Ad(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new Me("Graph.forEachNode: expecting a callback.");const n=this._nodes.values();let r,a;for(;r=n.next(),r.done!==!0;)a=r.value,t(a.key,a.attributes)}findNode(t){if(typeof t!="function")throw new Me("Graph.findNode: expecting a callback.");const n=this._nodes.values();let r,a;for(;r=n.next(),r.done!==!0;)if(a=r.value,t(a.key,a.attributes))return a.key}mapNodes(t){if(typeof t!="function")throw new Me("Graph.mapNode: expecting a callback.");const n=this._nodes.values();let r,a;const o=new Array(this.order);let s=0;for(;r=n.next(),r.done!==!0;)a=r.value,o[s++]=t(a.key,a.attributes);return o}someNode(t){if(typeof t!="function")throw new Me("Graph.someNode: expecting a callback.");const n=this._nodes.values();let r,a;for(;r=n.next(),r.done!==!0;)if(a=r.value,t(a.key,a.attributes))return!0;return!1}everyNode(t){if(typeof t!="function")throw new Me("Graph.everyNode: expecting a callback.");const n=this._nodes.values();let r,a;for(;r=n.next(),r.done!==!0;)if(a=r.value,!t(a.key,a.attributes))return!1;return!0}filterNodes(t){if(typeof t!="function")throw new Me("Graph.filterNodes: expecting a callback.");const n=this._nodes.values();let r,a;const o=[];for(;r=n.next(),r.done!==!0;)a=r.value,t(a.key,a.attributes)&&o.push(a.key);return o}reduceNodes(t,n){if(typeof t!="function")throw new Me("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new Me("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let r=n;const a=this._nodes.values();let o,s;for(;o=a.next(),o.done!==!0;)s=o.value,r=t(r,s.key,s.attributes);return r}nodeEntries(){const t=this._nodes.values();return{[Symbol.iterator](){return this},next(){const n=t.next();if(n.done)return n;const r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){const t=new Array(this._nodes.size);let n=0;this._nodes.forEach((a,o)=>{t[n++]=$J(o,a)});const r=new Array(this._edges.size);return n=0,this._edges.forEach((a,o)=>{r[n++]=qJ(this.type,o,a)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:r}}import(t,n=!1){if(t instanceof Ct)return t.forEachNode((c,d)=>{n?this.mergeNode(c,d):this.addNode(c,d)}),t.forEachEdge((c,d,p,g,m,b,y)=>{n?y?this.mergeUndirectedEdgeWithKey(c,p,g,d):this.mergeDirectedEdgeWithKey(c,p,g,d):y?this.addUndirectedEdgeWithKey(c,p,g,d):this.addDirectedEdgeWithKey(c,p,g,d)}),this;if(!vn(t))throw new Me("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!vn(t.attributes))throw new Me("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,a,o,s,u;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new Me("Graph.import: invalid nodes. Expecting an array.");for(r=0,a=o.length;r{const o=nn({},r.attributes);r=new n.NodeDataClass(a,o),n._nodes.set(a,r)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new Qe(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${t.type}" because this would mean losing information about the current graph.`);if(typeof t.multi=="boolean"&&t.multi!==this.multi&&t.multi!==!0)throw new Qe("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof t.allowSelfLoops=="boolean"&&t.allowSelfLoops!==this.allowSelfLoops&&t.allowSelfLoops!==!0)throw new Qe("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const n=this.emptyCopy(t),r=this._edges.values();let a,o;for(;a=r.next(),a.done!==!0;)o=a.value,r4(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,nn({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const t={};this._nodes.forEach((o,s)=>{t[s]=o.attributes});const n={},r={};this._edges.forEach((o,s)=>{const u=o.undirected?"--":"->";let c="",d=o.source.key,p=o.target.key,g;o.undirected&&d>p&&(g=d,d=p,p=g);const m=`(${d})${u}(${p})`;s.startsWith("geid_")?this.multi&&(typeof r[m]>"u"?r[m]=0:r[m]++,c+=`${r[m]}. `):c+=`[${s}]: `,c+=m,n[c]=o.attributes});const a={};for(const o in this)this.hasOwnProperty(o)&&!rN.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(a[o]=this[o]);return a.attributes=this._attributes,a.nodes=t,a.edges=n,yr(a,"constructor",this.constructor),a}}typeof Symbol<"u"&&(Ct.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ct.prototype.inspect);XJ.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),r=t==="add"?r4:JJ;e.generateKey?Ct.prototype[n]=function(a,o,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,a,o,s,t==="update")}:Ct.prototype[n]=function(a,o,s,u){return r(this,n,!1,(e.type||this.type)==="undirected",a,o,s,u,t==="update")}})});lJ(Ct);vJ(Ct);MJ(Ct);HJ(Ct);class Cu extends Ct{constructor(t){const n=nn({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new Me("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new Me('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class a4 extends Ct{constructor(t){const n=nn({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new Me("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new Me('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class o4 extends Ct{constructor(t){const n=nn({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Me("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class i4 extends Ct{constructor(t){const n=nn({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Me("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new Me('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class s4 extends Ct{constructor(t){const n=nn({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new Me("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new Me('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function Js(e){e.from=function(t,n){const r=nn({},t.options,n),a=new e(r);return a.import(t),a}}Js(Ct);Js(Cu);Js(a4);Js(o4);Js(i4);Js(s4);Ct.Graph=Ct;Ct.DirectedGraph=Cu;Ct.UndirectedGraph=a4;Ct.MultiGraph=o4;Ct.MultiDirectedGraph=i4;Ct.MultiUndirectedGraph=s4;Ct.InvalidArgumentsGraphError=Me;Ct.NotFoundGraphError=Ie;Ct.UsageGraphError=Qe;function eee(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function mu(e){var t=eee(e,"string");return typeof t=="symbol"?t:t+""}function dn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function oN(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n>8&255,o=n>>16&255,s=n>>24&255;return[r,a,o,s]}var fm={};function p4(e){if(typeof fm[e]<"u")return fm[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,a=255,o=f4(t,n,r,a);return fm[e]=o,o}function iN(e,t,n,r){return n+(t<<8)+(e<<16)}function sN(e,t,n,r,a,o){var s=Math.floor(n/o*a),u=Math.floor(e.drawingBufferHeight/o-r/o*a),c=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(s,u,1,1,e.RGBA,e.UNSIGNED_BYTE,c);var d=Ps(c,4),p=d[0],g=d[1],m=d[2],b=d[3];return[p,g,m,b]}function Re(e,t,n){return(t=mu(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function Ue(e){for(var t=1;t