UNPKG

sqlflow

Version:

This will let you create sql queries with a drag and drop editor.

9 lines 162 kB
(function(q,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react/jsx-runtime"),require("react"),require("reactflow"),require("react-dnd"),require("react-dom"),require("react-querybuilder"),require("react-querybuilder-shadcn"),require("react-syntax-highlighter")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","reactflow","react-dnd","react-dom","react-querybuilder","react-querybuilder-shadcn","react-syntax-highlighter"],l):(q=typeof globalThis<"u"?globalThis:q||self,l(q.sqlflow={},q["react/jsx-runtime"],q.React,q.Reactflow,q.ReactDnD,q.ReactDOM,q.ReactQueryBuilder,q.ReactQueryBuilderShadcn,q.ReactSyntaxHighlighter))})(this,function(q,l,T,W,at,Xn,en,tn,Cs){"use strict";var wd=Object.defineProperty;var xd=(q,l,T)=>l in q?wd(q,l,{enumerable:!0,configurable:!0,writable:!0,value:T}):q[l]=T;var We=(q,l,T)=>xd(q,typeof l!="symbol"?l+"":l,T);function Zn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const u=Zn(T),wt=Zn(Xn);class Ss{constructor(t,n){We(this,"tables");We(this,"nodes");We(this,"edges");We(this,"listeners");We(this,"query",{select:null,join:new Map,where:null,groupBy:null,having:null,orderBy:null,limit:null,offset:null});this.tables=new Map,this.nodes=t,this.edges=n,this.listeners=new Set}getTables(t){if(!this.isNodeConnected(t))return[];if(t&&this.tables.has(t)){const n=[];for(let[r,o]of this.tables.entries())r!==t&&n.push(o);return n}return Array.from(this.tables.values())}addTable(t,n){this.isNodeConnected(t)&&(this.tables.set(t,n),this.notifyListeners())}removeTable(t){this.tables.has(t)&&(this.tables.delete(t),this.notifyListeners())}getNodes(){return[...this.nodes]}setNodes(t){this.nodes=t}getEdges(){return[...this.edges]}setEdges(t){this.edges=t,this.notifyListeners()}subscribe(t){this.listeners.has(t)||this.listeners.add(t)}unsubscribe(t){this.listeners.has(t)&&this.listeners.delete(t)}isNodeConnected(t){return!!this.edges.find(r=>r.source===t||r.target===t)}notifyListeners(){this.listeners.forEach(t=>t())}processSqlQuery(t,n,r){var o;switch(t){case"select":this.query.select=n;break;case"join":r&&((o=this.query.join)==null||o.set(r,n));break;case"where":this.query.where=n;break;case"groupBy":this.query.groupBy=n;break;case"having":this.query.having=n;break;case"orderBy":this.query.orderBy=n;break;case"limit":this.query.limit=n;break;case"offset":this.query.offset=n;break;default:throw new Error(`Unsupported node type: ${t}`)}}getSqlQuery(){const{select:t,join:n,where:r,groupBy:o,having:s,orderBy:a,limit:i,offset:c}=this.query;let d="";return t&&(d+=`${t} `),n&&n.forEach(f=>{d+=`${f} `}),r&&(d+=`${r} `),o&&(d+=`${o} `),s&&(d+=`${s} `),a&&(d+=`${a} `),i!==null&&(d+=`LIMIT ${i} `),c!==null&&(d+=`OFFSET ${c} `),d.trim()}getFieldData(t){if(t)for(const n of this.tables.values()){let r=n.fields.find(o=>o.name===t);if(r)return r}return null}}const ze=class ze{constructor(){}static destroyInstance(){ze.instance=null}};We(ze,"instance",null),We(ze,"getQueryGraph",(t,n)=>(ze.instance||(ze.instance=new Ss(t,n)),ze.instance));let xt=ze;const Rn=T.createContext(void 0),ve=()=>{const e=T.useContext(Rn);if(!e)throw new Error("useSQLQueryBuilderContext must be used within SQLQueryBuilderProvider");return e},ks=({children:e,tables:t,nodes:n,edges:r})=>{const[o,s]=T.useState([]),[a,i,c]=W.useNodesState([]),[d,f,h]=W.useEdgesState([]),[g]=T.useState(()=>xt.getQueryGraph(a,d)),m=w=>{i(S=>[...S,w])},y=w=>{i(S=>S.filter(C=>C.id!==w))},p=w=>{c(w)},b=w=>{w.forEach(S=>g.removeTable(S.id))},v=w=>{h(w)};T.useEffect(()=>{g.setEdges(d)},[d]),T.useEffect(()=>{g.setNodes(a)},[a]),T.useEffect(()=>{t&&s(t)},[t]),T.useEffect(()=>{n&&i(n)},[n]),T.useEffect(()=>{r&&f(r)},[r]);const x=T.useMemo(()=>({tables:o,nodes:a,edges:d,setEdges:f,handleEdgeChanges:v,addNode:m,removeNode:y,onNodesChange:c,handleNodeChange:p,handleNodeDelete:b,queryGraph:g}),[g,a,d]);return T.useEffect(()=>()=>{s([]),i([]),f([]),xt.destroyInstance()},[]),l.jsx(Rn.Provider,{value:x,children:e})};var D=(e=>(e.SELECT="select",e.WHERE="where",e.JOIN="join",e.GROUP_BY="group_by",e.ORDER_BY="order_by",e.HAVING="having",e.FIELD_ALIAS="field_alias",e.TABLE_ALIAS="table_alias",e.AGGREGATION="aggregation",e.DISTINCT="distinct",e.LIMIT="limit",e.OFFSET="offset",e))(D||{}),nn=(e=>(e.INNER_JOIN="INNER JOIN",e.LEFT_JOIN="LEFT JOIN",e.RIGHT_JOIN="RIGHT JOIN",e.FULL_JOIN="FULL JOIN",e))(nn||{});function er(e,[t,n]){return Math.min(n,Math.max(t,e))}function G(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Es(e,t=[]){let n=[];function r(s,a){const i=u.createContext(a),c=n.length;n=[...n,a];function d(h){const{scope:g,children:m,...y}=h,p=(g==null?void 0:g[e][c])||i,b=u.useMemo(()=>y,Object.values(y));return l.jsx(p.Provider,{value:b,children:m})}function f(h,g){const m=(g==null?void 0:g[e][c])||i,y=u.useContext(m);if(y)return y;if(a!==void 0)return a;throw new Error(`\`${h}\` must be used within \`${s}\``)}return d.displayName=s+"Provider",[d,f]}const o=()=>{const s=n.map(a=>u.createContext(a));return function(i){const c=(i==null?void 0:i[e])||s;return u.useMemo(()=>({[`__scope${e}`]:{...i,[e]:c}}),[i,c])}};return o.scopeName=e,[r,Ns(o,...t)]}function Ns(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const a=r.reduce((i,{useScope:c,scopeName:d})=>{const h=c(s)[`__scope${d}`];return{...i,...h}},{});return u.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function Ts(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function tr(...e){return t=>e.forEach(n=>Ts(n,t))}function R(...e){return u.useCallback(tr(...e),e)}var qe=u.forwardRef((e,t)=>{const{children:n,...r}=e,o=u.Children.toArray(n),s=o.find(As);if(s){const a=s.props.children,i=o.map(c=>c===s?u.Children.count(a)>1?u.Children.only(null):u.isValidElement(a)?a.props.children:null:c);return l.jsx(rn,{...r,ref:t,children:u.isValidElement(a)?u.cloneElement(a,void 0,i):null})}return l.jsx(rn,{...r,ref:t,children:n})});qe.displayName="Slot";var rn=u.forwardRef((e,t)=>{const{children:n,...r}=e;if(u.isValidElement(n)){const o=Os(n);return u.cloneElement(n,{...Ps(r,n.props),ref:t?tr(t,o):o})}return u.Children.count(n)>1?u.Children.only(null):null});rn.displayName="SlotClone";var nr=({children:e})=>l.jsx(l.Fragment,{children:e});function As(e){return u.isValidElement(e)&&e.type===nr}function Ps(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...i)=>{s(...i),o(...i)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Os(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Ms(e){const t=e+"CollectionProvider",[n,r]=Es(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=m=>{const{scope:y,children:p}=m,b=T.useRef(null),v=T.useRef(new Map).current;return l.jsx(o,{scope:y,itemMap:v,collectionRef:b,children:p})};a.displayName=t;const i=e+"CollectionSlot",c=T.forwardRef((m,y)=>{const{scope:p,children:b}=m,v=s(i,p),x=R(y,v.collectionRef);return l.jsx(qe,{ref:x,children:b})});c.displayName=i;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=T.forwardRef((m,y)=>{const{scope:p,children:b,...v}=m,x=T.useRef(null),w=R(y,x),S=s(d,p);return T.useEffect(()=>(S.itemMap.set(x,{ref:x,...v}),()=>void S.itemMap.delete(x))),l.jsx(qe,{[f]:"",ref:w,children:b})});h.displayName=d;function g(m){const y=s(e+"CollectionConsumer",m);return T.useCallback(()=>{const b=y.collectionRef.current;if(!b)return[];const v=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((S,C)=>v.indexOf(S.ref.current)-v.indexOf(C.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:a,Slot:c,ItemSlot:h},g,r]}function on(e,t=[]){let n=[];function r(s,a){const i=u.createContext(a),c=n.length;n=[...n,a];const d=h=>{var v;const{scope:g,children:m,...y}=h,p=((v=g==null?void 0:g[e])==null?void 0:v[c])||i,b=u.useMemo(()=>y,Object.values(y));return l.jsx(p.Provider,{value:b,children:m})};d.displayName=s+"Provider";function f(h,g){var p;const m=((p=g==null?void 0:g[e])==null?void 0:p[c])||i,y=u.useContext(m);if(y)return y;if(a!==void 0)return a;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[d,f]}const o=()=>{const s=n.map(a=>u.createContext(a));return function(i){const c=(i==null?void 0:i[e])||s;return u.useMemo(()=>({[`__scope${e}`]:{...i,[e]:c}}),[i,c])}};return o.scopeName=e,[r,Is(o,...t)]}function Is(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const a=r.reduce((i,{useScope:c,scopeName:d})=>{const h=c(s)[`__scope${d}`];return{...i,...h}},{});return u.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var Ls=u.createContext(void 0);function Ds(e){const t=u.useContext(Ls);return e||t||"ltr"}var _s=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],X=_s.reduce((e,t)=>{const n=u.forwardRef((r,o)=>{const{asChild:s,...a}=r,i=s?qe:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(i,{...a,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function $s(e,t){e&&wt.flushSync(()=>e.dispatchEvent(t))}function Se(e){const t=u.useRef(e);return u.useEffect(()=>{t.current=e}),u.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Fs(e,t=globalThis==null?void 0:globalThis.document){const n=Se(e);u.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Bs="DismissableLayer",sn="dismissableLayer.update",Vs="dismissableLayer.pointerDownOutside",zs="dismissableLayer.focusOutside",rr,or=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),an=u.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:i,...c}=e,d=u.useContext(or),[f,h]=u.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=u.useState({}),y=R(t,A=>h(A)),p=Array.from(d.layers),[b]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),v=p.indexOf(b),x=f?p.indexOf(f):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,S=x>=v,C=Gs(A=>{const L=A.target,V=[...d.branches].some(B=>B.contains(L));!S||V||(o==null||o(A),a==null||a(A),A.defaultPrevented||i==null||i())},g),P=Us(A=>{const L=A.target;[...d.branches].some(B=>B.contains(L))||(s==null||s(A),a==null||a(A),A.defaultPrevented||i==null||i())},g);return Fs(A=>{x===d.layers.size-1&&(r==null||r(A),!A.defaultPrevented&&i&&(A.preventDefault(),i()))},g),u.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(rr=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),sr(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=rr)}},[f,g,n,d]),u.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),sr())},[f,d]),u.useEffect(()=>{const A=()=>m({});return document.addEventListener(sn,A),()=>document.removeEventListener(sn,A)},[]),l.jsx(X.div,{...c,ref:y,style:{pointerEvents:w?S?"auto":"none":void 0,...e.style},onFocusCapture:G(e.onFocusCapture,P.onFocusCapture),onBlurCapture:G(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:G(e.onPointerDownCapture,C.onPointerDownCapture)})});an.displayName=Bs;var Hs="DismissableLayerBranch",Ws=u.forwardRef((e,t)=>{const n=u.useContext(or),r=u.useRef(null),o=R(t,r);return u.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(X.div,{...e,ref:o})});Ws.displayName=Hs;function Gs(e,t=globalThis==null?void 0:globalThis.document){const n=Se(e),r=u.useRef(!1),o=u.useRef(()=>{});return u.useEffect(()=>{const s=i=>{if(i.target&&!r.current){let c=function(){ar(Vs,n,d,{discrete:!0})};const d={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Us(e,t=globalThis==null?void 0:globalThis.document){const n=Se(e),r=u.useRef(!1);return u.useEffect(()=>{const o=s=>{s.target&&!r.current&&ar(zs,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function sr(){const e=new CustomEvent(sn);document.dispatchEvent(e)}function ar(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?$s(o,s):o.dispatchEvent(s)}var ln=0;function js(){u.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ir()),document.body.insertAdjacentElement("beforeend",e[1]??ir()),ln++,()=>{ln===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ln--}},[])}function ir(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var cn="focusScope.autoFocusOnMount",dn="focusScope.autoFocusOnUnmount",lr={bubbles:!1,cancelable:!0},qs="FocusScope",cr=u.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=e,[i,c]=u.useState(null),d=Se(o),f=Se(s),h=u.useRef(null),g=R(t,p=>c(p)),m=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let p=function(w){if(m.paused||!i)return;const S=w.target;i.contains(S)?h.current=S:Te(h.current,{select:!0})},b=function(w){if(m.paused||!i)return;const S=w.relatedTarget;S!==null&&(i.contains(S)||Te(h.current,{select:!0}))},v=function(w){if(document.activeElement===document.body)for(const C of w)C.removedNodes.length>0&&Te(i)};document.addEventListener("focusin",p),document.addEventListener("focusout",b);const x=new MutationObserver(v);return i&&x.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",b),x.disconnect()}}},[r,i,m.paused]),u.useEffect(()=>{if(i){fr.add(m);const p=document.activeElement;if(!i.contains(p)){const v=new CustomEvent(cn,lr);i.addEventListener(cn,d),i.dispatchEvent(v),v.defaultPrevented||(Qs(Zs(dr(i)),{select:!0}),document.activeElement===p&&Te(i))}return()=>{i.removeEventListener(cn,d),setTimeout(()=>{const v=new CustomEvent(dn,lr);i.addEventListener(dn,f),i.dispatchEvent(v),v.defaultPrevented||Te(p??document.body,{select:!0}),i.removeEventListener(dn,f),fr.remove(m)},0)}}},[i,d,f,m]);const y=u.useCallback(p=>{if(!n&&!r||m.paused)return;const b=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,v=document.activeElement;if(b&&v){const x=p.currentTarget,[w,S]=Ys(x);w&&S?!p.shiftKey&&v===S?(p.preventDefault(),n&&Te(w,{select:!0})):p.shiftKey&&v===w&&(p.preventDefault(),n&&Te(S,{select:!0})):v===x&&p.preventDefault()}},[n,r,m.paused]);return l.jsx(X.div,{tabIndex:-1,...a,ref:g,onKeyDown:y})});cr.displayName=qs;function Qs(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Te(r,{select:t}),document.activeElement!==n)return}function Ys(e){const t=dr(e),n=ur(t,e),r=ur(t.reverse(),e);return[n,r]}function dr(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ur(e,t){for(const n of e)if(!Js(n,{upTo:t}))return n}function Js(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Ks(e){return e instanceof HTMLInputElement&&"select"in e}function Te(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ks(e)&&t&&e.select()}}var fr=Xs();function Xs(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=hr(e,t),e.unshift(t)},remove(t){var n;e=hr(e,t),(n=e[0])==null||n.resume()}}}function hr(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Zs(e){return e.filter(t=>t.tagName!=="A")}var ce=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},Rs=u.useId||(()=>{}),ea=0;function Ct(e){const[t,n]=u.useState(Rs());return ce(()=>{n(r=>r??String(ea++))},[e]),t?`radix-${t}`:""}const ta=["top","right","bottom","left"],Ae=Math.min,de=Math.max,St=Math.round,kt=Math.floor,be=e=>({x:e,y:e}),na={left:"right",right:"left",bottom:"top",top:"bottom"},ra={start:"end",end:"start"};function un(e,t,n){return de(e,Ae(t,n))}function ke(e,t){return typeof e=="function"?e(t):e}function Ee(e){return e.split("-")[0]}function Qe(e){return e.split("-")[1]}function fn(e){return e==="x"?"y":"x"}function hn(e){return e==="y"?"height":"width"}function Pe(e){return["top","bottom"].includes(Ee(e))?"y":"x"}function pn(e){return fn(Pe(e))}function oa(e,t,n){n===void 0&&(n=!1);const r=Qe(e),o=pn(e),s=hn(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Et(a)),[a,Et(a)]}function sa(e){const t=Et(e);return[gn(e),t,gn(t)]}function gn(e){return e.replace(/start|end/g,t=>ra[t])}function aa(e,t,n){const r=["left","right"],o=["right","left"],s=["top","bottom"],a=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?s:a;default:return[]}}function ia(e,t,n,r){const o=Qe(e);let s=aa(Ee(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(gn)))),s}function Et(e){return e.replace(/left|right|bottom|top/g,t=>na[t])}function la(e){return{top:0,right:0,bottom:0,left:0,...e}}function pr(e){return typeof e!="number"?la(e):{top:e,right:e,bottom:e,left:e}}function Nt(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function gr(e,t,n){let{reference:r,floating:o}=e;const s=Pe(t),a=pn(t),i=hn(a),c=Ee(t),d=s==="y",f=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,g=r[i]/2-o[i]/2;let m;switch(c){case"top":m={x:f,y:r.y-o.height};break;case"bottom":m={x:f,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:h};break;case"left":m={x:r.x-o.width,y:h};break;default:m={x:r.x,y:r.y}}switch(Qe(t)){case"start":m[a]-=g*(n&&d?-1:1);break;case"end":m[a]+=g*(n&&d?-1:1);break}return m}const ca=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,i=s.filter(Boolean),c=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:h}=gr(d,r,c),g=r,m={},y=0;for(let p=0;p<i.length;p++){const{name:b,fn:v}=i[p],{x,y:w,data:S,reset:C}=await v({x:f,y:h,initialPlacement:r,placement:g,strategy:o,middlewareData:m,rects:d,platform:a,elements:{reference:e,floating:t}});f=x??f,h=w??h,m={...m,[b]:{...m[b],...S}},C&&y<=50&&(y++,typeof C=="object"&&(C.placement&&(g=C.placement),C.rects&&(d=C.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:f,y:h}=gr(d,g,c)),p=-1)}return{x:f,y:h,placement:g,strategy:o,middlewareData:m}};async function it(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:a,elements:i,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:g=!1,padding:m=0}=ke(t,e),y=pr(m),b=i[g?h==="floating"?"reference":"floating":h],v=Nt(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:d,rootBoundary:f,strategy:c})),x=h==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,w=await(s.getOffsetParent==null?void 0:s.getOffsetParent(i.floating)),S=await(s.isElement==null?void 0:s.isElement(w))?await(s.getScale==null?void 0:s.getScale(w))||{x:1,y:1}:{x:1,y:1},C=Nt(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:x,offsetParent:w,strategy:c}):x);return{top:(v.top-C.top+y.top)/S.y,bottom:(C.bottom-v.bottom+y.bottom)/S.y,left:(v.left-C.left+y.left)/S.x,right:(C.right-v.right+y.right)/S.x}}const da=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:a,elements:i,middlewareData:c}=t,{element:d,padding:f=0}=ke(e,t)||{};if(d==null)return{};const h=pr(f),g={x:n,y:r},m=pn(o),y=hn(m),p=await a.getDimensions(d),b=m==="y",v=b?"top":"left",x=b?"bottom":"right",w=b?"clientHeight":"clientWidth",S=s.reference[y]+s.reference[m]-g[m]-s.floating[y],C=g[m]-s.reference[m],P=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let A=P?P[w]:0;(!A||!await(a.isElement==null?void 0:a.isElement(P)))&&(A=i.floating[w]||s.floating[y]);const L=S/2-C/2,V=A/2-p[y]/2-1,B=Ae(h[v],V),H=Ae(h[x],V),M=B,z=A-p[y]-H,k=A/2-p[y]/2+L,E=un(M,k,z),N=!c.arrow&&Qe(o)!=null&&k!==E&&s.reference[y]/2-(k<M?B:H)-p[y]/2<0,I=N?k<M?k-M:k-z:0;return{[m]:g[m]+I,data:{[m]:E,centerOffset:k-E-I,...N&&{alignmentOffset:I}},reset:N}}}),ua=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:a,initialPlacement:i,platform:c,elements:d}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:p=!0,...b}=ke(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=Ee(o),x=Pe(i),w=Ee(i)===i,S=await(c.isRTL==null?void 0:c.isRTL(d.floating)),C=g||(w||!p?[Et(i)]:sa(i)),P=y!=="none";!g&&P&&C.push(...ia(i,p,y,S));const A=[i,...C],L=await it(t,b),V=[];let B=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&V.push(L[v]),h){const k=oa(o,a,S);V.push(L[k[0]],L[k[1]])}if(B=[...B,{placement:o,overflows:V}],!V.every(k=>k<=0)){var H,M;const k=(((H=s.flip)==null?void 0:H.index)||0)+1,E=A[k];if(E)return{data:{index:k,overflows:B},reset:{placement:E}};let N=(M=B.filter(I=>I.overflows[0]<=0).sort((I,O)=>I.overflows[1]-O.overflows[1])[0])==null?void 0:M.placement;if(!N)switch(m){case"bestFit":{var z;const I=(z=B.filter(O=>{if(P){const F=Pe(O.placement);return F===x||F==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(F=>F>0).reduce((F,oe)=>F+oe,0)]).sort((O,F)=>O[1]-F[1])[0])==null?void 0:z[0];I&&(N=I);break}case"initialPlacement":N=i;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function mr(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function vr(e){return ta.some(t=>e[t]>=0)}const fa=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=ke(e,t);switch(r){case"referenceHidden":{const s=await it(t,{...o,elementContext:"reference"}),a=mr(s,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:vr(a)}}}case"escaped":{const s=await it(t,{...o,altBoundary:!0}),a=mr(s,n.floating);return{data:{escapedOffsets:a,escaped:vr(a)}}}default:return{}}}}};async function ha(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Ee(n),i=Qe(n),c=Pe(n)==="y",d=["left","top"].includes(a)?-1:1,f=s&&c?-1:1,h=ke(t,e);let{mainAxis:g,crossAxis:m,alignmentAxis:y}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return i&&typeof y=="number"&&(m=i==="end"?y*-1:y),c?{x:m*f,y:g*d}:{x:g*d,y:m*f}}const pa=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:a,middlewareData:i}=t,c=await ha(t,e);return a===((n=i.offset)==null?void 0:n.placement)&&(r=i.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:a}}}}},ga=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:i={fn:b=>{let{x:v,y:x}=b;return{x:v,y:x}}},...c}=ke(e,t),d={x:n,y:r},f=await it(t,c),h=Pe(Ee(o)),g=fn(h);let m=d[g],y=d[h];if(s){const b=g==="y"?"top":"left",v=g==="y"?"bottom":"right",x=m+f[b],w=m-f[v];m=un(x,m,w)}if(a){const b=h==="y"?"top":"left",v=h==="y"?"bottom":"right",x=y+f[b],w=y-f[v];y=un(x,y,w)}const p=i.fn({...t,[g]:m,[h]:y});return{...p,data:{x:p.x-n,y:p.y-r,enabled:{[g]:s,[h]:a}}}}}},ma=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:a}=t,{offset:i=0,mainAxis:c=!0,crossAxis:d=!0}=ke(e,t),f={x:n,y:r},h=Pe(o),g=fn(h);let m=f[g],y=f[h];const p=ke(i,t),b=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(c){const w=g==="y"?"height":"width",S=s.reference[g]-s.floating[w]+b.mainAxis,C=s.reference[g]+s.reference[w]-b.mainAxis;m<S?m=S:m>C&&(m=C)}if(d){var v,x;const w=g==="y"?"width":"height",S=["top","left"].includes(Ee(o)),C=s.reference[h]-s.floating[w]+(S&&((v=a.offset)==null?void 0:v[h])||0)+(S?0:b.crossAxis),P=s.reference[h]+s.reference[w]+(S?0:((x=a.offset)==null?void 0:x[h])||0)-(S?b.crossAxis:0);y<C?y=C:y>P&&(y=P)}return{[g]:m,[h]:y}}}},va=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:a,elements:i}=t,{apply:c=()=>{},...d}=ke(e,t),f=await it(t,d),h=Ee(o),g=Qe(o),m=Pe(o)==="y",{width:y,height:p}=s.floating;let b,v;h==="top"||h==="bottom"?(b=h,v=g===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(v=h,b=g==="end"?"top":"bottom");const x=p-f.top-f.bottom,w=y-f.left-f.right,S=Ae(p-f[b],x),C=Ae(y-f[v],w),P=!t.middlewareData.shift;let A=S,L=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(L=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(A=x),P&&!g){const B=de(f.left,0),H=de(f.right,0),M=de(f.top,0),z=de(f.bottom,0);m?L=y-2*(B!==0||H!==0?B+H:de(f.left,f.right)):A=p-2*(M!==0||z!==0?M+z:de(f.top,f.bottom))}await c({...t,availableWidth:L,availableHeight:A});const V=await a.getDimensions(i.floating);return y!==V.width||p!==V.height?{reset:{rects:!0}}:{}}}};function Tt(){return typeof window<"u"}function Ye(e){return br(e)?(e.nodeName||"").toLowerCase():"#document"}function ue(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ye(e){var t;return(t=(br(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function br(e){return Tt()?e instanceof Node||e instanceof ue(e).Node:!1}function he(e){return Tt()?e instanceof Element||e instanceof ue(e).Element:!1}function we(e){return Tt()?e instanceof HTMLElement||e instanceof ue(e).HTMLElement:!1}function yr(e){return!Tt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ue(e).ShadowRoot}function lt(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=pe(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function ba(e){return["table","td","th"].includes(Ye(e))}function At(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function mn(e){const t=vn(),n=he(e)?pe(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function ya(e){let t=Oe(e);for(;we(t)&&!Je(t);){if(mn(t))return t;if(At(t))return null;t=Oe(t)}return null}function vn(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Je(e){return["html","body","#document"].includes(Ye(e))}function pe(e){return ue(e).getComputedStyle(e)}function Pt(e){return he(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Oe(e){if(Ye(e)==="html")return e;const t=e.assignedSlot||e.parentNode||yr(e)&&e.host||ye(e);return yr(t)?t.host:t}function wr(e){const t=Oe(e);return Je(t)?e.ownerDocument?e.ownerDocument.body:e.body:we(t)&&lt(t)?t:wr(t)}function ct(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=wr(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),a=ue(o);if(s){const i=bn(a);return t.concat(a,a.visualViewport||[],lt(o)?o:[],i&&n?ct(i):[])}return t.concat(o,ct(o,[],n))}function bn(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function xr(e){const t=pe(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=we(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,i=St(n)!==s||St(r)!==a;return i&&(n=s,r=a),{width:n,height:r,$:i}}function yn(e){return he(e)?e:e.contextElement}function Ke(e){const t=yn(e);if(!we(t))return be(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=xr(t);let a=(s?St(n.width):n.width)/r,i=(s?St(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const wa=be(0);function Cr(e){const t=ue(e);return!vn()||!t.visualViewport?wa:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function xa(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ue(e)?!1:t}function Ge(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=yn(e);let a=be(1);t&&(r?he(r)&&(a=Ke(r)):a=Ke(e));const i=xa(s,n,r)?Cr(s):be(0);let c=(o.left+i.x)/a.x,d=(o.top+i.y)/a.y,f=o.width/a.x,h=o.height/a.y;if(s){const g=ue(s),m=r&&he(r)?ue(r):r;let y=g,p=bn(y);for(;p&&r&&m!==y;){const b=Ke(p),v=p.getBoundingClientRect(),x=pe(p),w=v.left+(p.clientLeft+parseFloat(x.paddingLeft))*b.x,S=v.top+(p.clientTop+parseFloat(x.paddingTop))*b.y;c*=b.x,d*=b.y,f*=b.x,h*=b.y,c+=w,d+=S,y=ue(p),p=bn(y)}}return Nt({width:f,height:h,x:c,y:d})}function wn(e,t){const n=Pt(e).scrollLeft;return t?t.left+n:Ge(ye(e)).left+n}function Sr(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:wn(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Ca(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=ye(r),i=t?At(t.floating):!1;if(r===a||i&&s)return n;let c={scrollLeft:0,scrollTop:0},d=be(1);const f=be(0),h=we(r);if((h||!h&&!s)&&((Ye(r)!=="body"||lt(a))&&(c=Pt(r)),we(r))){const m=Ge(r);d=Ke(r),f.x=m.x+r.clientLeft,f.y=m.y+r.clientTop}const g=a&&!h&&!s?Sr(a,c,!0):be(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+f.x+g.x,y:n.y*d.y-c.scrollTop*d.y+f.y+g.y}}function Sa(e){return Array.from(e.getClientRects())}function ka(e){const t=ye(e),n=Pt(e),r=e.ownerDocument.body,o=de(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=de(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+wn(e);const i=-n.scrollTop;return pe(r).direction==="rtl"&&(a+=de(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:i}}function Ea(e,t){const n=ue(e),r=ye(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,i=0,c=0;if(o){s=o.width,a=o.height;const d=vn();(!d||d&&t==="fixed")&&(i=o.offsetLeft,c=o.offsetTop)}return{width:s,height:a,x:i,y:c}}function Na(e,t){const n=Ge(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=we(e)?Ke(e):be(1),a=e.clientWidth*s.x,i=e.clientHeight*s.y,c=o*s.x,d=r*s.y;return{width:a,height:i,x:c,y:d}}function kr(e,t,n){let r;if(t==="viewport")r=Ea(e,n);else if(t==="document")r=ka(ye(e));else if(he(t))r=Na(t,n);else{const o=Cr(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Nt(r)}function Er(e,t){const n=Oe(e);return n===t||!he(n)||Je(n)?!1:pe(n).position==="fixed"||Er(n,t)}function Ta(e,t){const n=t.get(e);if(n)return n;let r=ct(e,[],!1).filter(i=>he(i)&&Ye(i)!=="body"),o=null;const s=pe(e).position==="fixed";let a=s?Oe(e):e;for(;he(a)&&!Je(a);){const i=pe(a),c=mn(a);!c&&i.position==="fixed"&&(o=null),(s?!c&&!o:!c&&i.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||lt(a)&&!c&&Er(e,a))?r=r.filter(f=>f!==a):o=i,a=Oe(a)}return t.set(e,r),r}function Aa(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?At(t)?[]:Ta(t,this._c):[].concat(n),r],i=a[0],c=a.reduce((d,f)=>{const h=kr(t,f,o);return d.top=de(h.top,d.top),d.right=Ae(h.right,d.right),d.bottom=Ae(h.bottom,d.bottom),d.left=de(h.left,d.left),d},kr(t,i,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Pa(e){const{width:t,height:n}=xr(e);return{width:t,height:n}}function Oa(e,t,n){const r=we(t),o=ye(t),s=n==="fixed",a=Ge(e,!0,s,t);let i={scrollLeft:0,scrollTop:0};const c=be(0);if(r||!r&&!s)if((Ye(t)!=="body"||lt(o))&&(i=Pt(t)),r){const g=Ge(t,!0,s,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else o&&(c.x=wn(o));const d=o&&!r&&!s?Sr(o,i):be(0),f=a.left+i.scrollLeft-c.x-d.x,h=a.top+i.scrollTop-c.y-d.y;return{x:f,y:h,width:a.width,height:a.height}}function xn(e){return pe(e).position==="static"}function Nr(e,t){if(!we(e)||pe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ye(e)===n&&(n=n.ownerDocument.body),n}function Tr(e,t){const n=ue(e);if(At(e))return n;if(!we(e)){let o=Oe(e);for(;o&&!Je(o);){if(he(o)&&!xn(o))return o;o=Oe(o)}return n}let r=Nr(e,t);for(;r&&ba(r)&&xn(r);)r=Nr(r,t);return r&&Je(r)&&xn(r)&&!mn(r)?n:r||ya(e)||n}const Ma=async function(e){const t=this.getOffsetParent||Tr,n=this.getDimensions,r=await n(e.floating);return{reference:Oa(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ia(e){return pe(e).direction==="rtl"}const La={convertOffsetParentRelativeRectToViewportRelativeRect:Ca,getDocumentElement:ye,getClippingRect:Aa,getOffsetParent:Tr,getElementRects:Ma,getClientRects:Sa,getDimensions:Pa,getScale:Ke,isElement:he,isRTL:Ia};function Da(e,t){let n=null,r;const o=ye(e);function s(){var i;clearTimeout(r),(i=n)==null||i.disconnect(),n=null}function a(i,c){i===void 0&&(i=!1),c===void 0&&(c=1),s();const{left:d,top:f,width:h,height:g}=e.getBoundingClientRect();if(i||t(),!h||!g)return;const m=kt(f),y=kt(o.clientWidth-(d+h)),p=kt(o.clientHeight-(f+g)),b=kt(d),x={rootMargin:-m+"px "+-y+"px "+-p+"px "+-b+"px",threshold:de(0,Ae(1,c))||1};let w=!0;function S(C){const P=C[0].intersectionRatio;if(P!==c){if(!w)return a();P?a(!1,P):r=setTimeout(()=>{a(!1,1e-7)},1e3)}w=!1}try{n=new IntersectionObserver(S,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,x)}n.observe(e)}return a(!0),s}function _a(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=yn(e),f=o||s?[...d?ct(d):[],...ct(t)]:[];f.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const h=d&&i?Da(d,n):null;let g=-1,m=null;a&&(m=new ResizeObserver(v=>{let[x]=v;x&&x.target===d&&m&&(m.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var w;(w=m)==null||w.observe(t)})),n()}),d&&!c&&m.observe(d),m.observe(t));let y,p=c?Ge(e):null;c&&b();function b(){const v=Ge(e);p&&(v.x!==p.x||v.y!==p.y||v.width!==p.width||v.height!==p.height)&&n(),p=v,y=requestAnimationFrame(b)}return n(),()=>{var v;f.forEach(x=>{o&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),h==null||h(),(v=m)==null||v.disconnect(),m=null,c&&cancelAnimationFrame(y)}}const $a=pa,Fa=ga,Ba=ua,Va=va,za=fa,Ar=da,Ha=ma,Wa=(e,t,n)=>{const r=new Map,o={platform:La,...n},s={...o.platform,_c:r};return ca(e,t,{...o,platform:s})};var Ot=typeof document<"u"?T.useLayoutEffect:T.useEffect;function Mt(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,o;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(!Mt(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Mt(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Pr(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Or(e,t){const n=Pr(e);return Math.round(t*n)/n}function Cn(e){const t=u.useRef(e);return Ot(()=>{t.current=e}),t}function Ga(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:a}={},transform:i=!0,whileElementsMounted:c,open:d}=e,[f,h]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,m]=u.useState(r);Mt(g,r)||m(r);const[y,p]=u.useState(null),[b,v]=u.useState(null),x=u.useCallback(O=>{O!==P.current&&(P.current=O,p(O))},[]),w=u.useCallback(O=>{O!==A.current&&(A.current=O,v(O))},[]),S=s||y,C=a||b,P=u.useRef(null),A=u.useRef(null),L=u.useRef(f),V=c!=null,B=Cn(c),H=Cn(o),M=Cn(d),z=u.useCallback(()=>{if(!P.current||!A.current)return;const O={placement:t,strategy:n,middleware:g};H.current&&(O.platform=H.current),Wa(P.current,A.current,O).then(F=>{const oe={...F,isPositioned:M.current!==!1};k.current&&!Mt(L.current,oe)&&(L.current=oe,wt.flushSync(()=>{h(oe)}))})},[g,t,n,H,M]);Ot(()=>{d===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,h(O=>({...O,isPositioned:!1})))},[d]);const k=u.useRef(!1);Ot(()=>(k.current=!0,()=>{k.current=!1}),[]),Ot(()=>{if(S&&(P.current=S),C&&(A.current=C),S&&C){if(B.current)return B.current(S,C,z);z()}},[S,C,z,B,V]);const E=u.useMemo(()=>({reference:P,floating:A,setReference:x,setFloating:w}),[x,w]),N=u.useMemo(()=>({reference:S,floating:C}),[S,C]),I=u.useMemo(()=>{const O={position:n,left:0,top:0};if(!N.floating)return O;const F=Or(N.floating,f.x),oe=Or(N.floating,f.y);return i?{...O,transform:"translate("+F+"px, "+oe+"px)",...Pr(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:oe}},[n,i,N.floating,f.x,f.y]);return u.useMemo(()=>({...f,update:z,refs:E,elements:N,floatingStyles:I}),[f,z,E,N,I])}const Ua=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Ar({element:r.current,padding:o}).fn(n):{}:r?Ar({element:r,padding:o}).fn(n):{}}}},ja=(e,t)=>({...$a(e),options:[e,t]}),qa=(e,t)=>({...Fa(e),options:[e,t]}),Qa=(e,t)=>({...Ha(e),options:[e,t]}),Ya=(e,t)=>({...Ba(e),options:[e,t]}),Ja=(e,t)=>({...Va(e),options:[e,t]}),Ka=(e,t)=>({...za(e),options:[e,t]}),Xa=(e,t)=>({...Ua(e),options:[e,t]});var Za="Arrow",Mr=u.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(X.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});Mr.displayName=Za;var Ra=Mr;function ei(e,t=[]){let n=[];function r(s,a){const i=u.createContext(a),c=n.length;n=[...n,a];function d(h){const{scope:g,children:m,...y}=h,p=(g==null?void 0:g[e][c])||i,b=u.useMemo(()=>y,Object.values(y));return l.jsx(p.Provider,{value:b,children:m})}function f(h,g){const m=(g==null?void 0:g[e][c])||i,y=u.useContext(m);if(y)return y;if(a!==void 0)return a;throw new Error(`\`${h}\` must be used within \`${s}\``)}return d.displayName=s+"Provider",[d,f]}const o=()=>{const s=n.map(a=>u.createContext(a));return function(i){const c=(i==null?void 0:i[e])||s;return u.useMemo(()=>({[`__scope${e}`]:{...i,[e]:c}}),[i,c])}};return o.scopeName=e,[r,ti(o,...t)]}function ti(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const a=r.reduce((i,{useScope:c,scopeName:d})=>{const h=c(s)[`__scope${d}`];return{...i,...h}},{});return u.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function Ir(e){const[t,n]=u.useState(void 0);return ce(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let a,i;if("borderBoxSize"in s){const c=s.borderBoxSize,d=Array.isArray(c)?c[0]:c;a=d.inlineSize,i=d.blockSize}else a=e.offsetWidth,i=e.offsetHeight;n({width:a,height:i})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Sn="Popper",[Lr,It]=ei(Sn),[ni,Dr]=Lr(Sn),_r=e=>{const{__scopePopper:t,children:n}=e,[r,o]=u.useState(null);return l.jsx(ni,{scope:t,anchor:r,onAnchorChange:o,children:n})};_r.displayName=Sn;var $r="PopperAnchor",Fr=u.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Dr($r,n),a=u.useRef(null),i=R(t,a);return u.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||a.current)}),r?null:l.jsx(X.div,{...o,ref:i})});Fr.displayName=$r;var kn="PopperContent",[ri,oi]=Lr(kn),Br=u.forwardRef((e,t)=>{var _,K,le,Q,U,j;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:i=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:m="optimized",onPlaced:y,...p}=e,b=Dr(kn,n),[v,x]=u.useState(null),w=R(t,fe=>x(fe)),[S,C]=u.useState(null),P=Ir(S),A=(P==null?void 0:P.width)??0,L=(P==null?void 0:P.height)??0,V=r+(s!=="center"?"-"+s:""),B=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},H=Array.isArray(d)?d:[d],M=H.length>0,z={padding:B,boundary:H.filter(ai),altBoundary:M},{refs:k,floatingStyles:E,placement:N,isPositioned:I,middlewareData:O}=Ga({strategy:"fixed",placement:V,whileElementsMounted:(...fe)=>_a(...fe,{animationFrame:m==="always"}),elements:{reference:b.anchor},middleware:[ja({mainAxis:o+L,alignmentAxis:a}),c&&qa({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Qa():void 0,...z}),c&&Ya({...z}),Ja({...z,apply:({elements:fe,rects:Ce,availableWidth:vt,availableHeight:bt})=>{const{width:yt,height:yd}=Ce.reference,Rt=fe.floating.style;Rt.setProperty("--radix-popper-available-width",`${vt}px`),Rt.setProperty("--radix-popper-available-height",`${bt}px`),Rt.setProperty("--radix-popper-anchor-width",`${yt}px`),Rt.setProperty("--radix-popper-anchor-height",`${yd}px`)}}),S&&Xa({element:S,padding:i}),ii({arrowWidth:A,arrowHeight:L}),g&&Ka({strategy:"referenceHidden",...z})]}),[F,oe]=Hr(N),te=Se(y);ce(()=>{I&&(te==null||te())},[I,te]);const gt=(_=O.arrow)==null?void 0:_.x,mt=(K=O.arrow)==null?void 0:K.y,He=((le=O.arrow)==null?void 0:le.centerOffset)!==0,[st,je]=u.useState();return ce(()=>{v&&je(window.getComputedStyle(v).zIndex)},[v]),l.jsx("div",{ref:k.setFloating,"data-radix-popper-content-wrapper":"",style:{...E,transform:I?E.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:st,"--radix-popper-transform-origin":[(Q=O.transformOrigin)==null?void 0:Q.x,(U=O.transformOrigin)==null?void 0:U.y].join(" "),...((j=O.hide)==null?void 0:j.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(ri,{scope:n,placedSide:F,onArrowChange:C,arrowX:gt,arrowY:mt,shouldHideArrow:He,children:l.jsx(X.div,{"data-side":F,"data-align":oe,...p,ref:w,style:{...p.style,animation:I?void 0:"none"}})})})});Br.displayName=kn;var Vr="PopperArrow",si={top:"bottom",right:"left",bottom:"top",left:"right"},zr=u.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=oi(Vr,r),a=si[s.placedSide];return l.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:l.jsx(Ra,{...o,ref:n,style:{...o.style,display:"block"}})})});zr.displayName=Vr;function ai(e){return e!==null}var ii=e=>({name:"transformOrigin",options:e,fn(t){var b,v,x;const{placement:n,rects:r,middlewareData:o}=t,a=((b=o.arrow)==null?void 0:b.centerOffset)!==0,i=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[d,f]=Hr(n),h={start:"0%",center:"50%",end:"100%"}[f],g=(((v=o.arrow)==null?void 0:v.x)??0)+i/2,m=(((x=o.arrow)==null?void 0:x.y)??0)+c/2;let y="",p="";return d==="bottom"?(y=a?h:`${g}px`,p=`${-c}px`):d==="top"?(y=a?h:`${g}px`,p=`${r.floating.height+c}px`):d==="right"?(y=`${-c}px`,p=a?h:`${m}px`):d==="left"&&(y=`${r.floating.width+c}px`,p=a?h:`${m}px`),{data:{x:y,y:p}}}});function Hr(e){const[t,n="center"]=e.split("-");return[t,n]}var Wr=_r,Gr=Fr,Ur=Br,jr=zr,li="Portal",qr=u.forwardRef((e,t)=>{var i;const{container:n,...r}=e,[o,s]=u.useState(!1);ce(()=>s(!0),[]);const a=n||o&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return a?Xn.createPortal(l.jsx(X.div,{...r,ref:t}),a):null});qr.displayName=li;function Lt({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=ci({defaultProp:t,onChange:n}),s=e!==void 0,a=s?e:r,i=Se(n),c=u.useCallback(d=>{if(s){const h=typeof d=="function"?d(e):d;h!==e&&i(h)}else o(d)},[s,e,o,i]);return[a,c]}function ci({defaultProp:e,onChange:t}){const n=u.useState(e),[r]=n,o=u.useRef(r),s=Se(t);return u.useEffect(()=>{o.current!==r&&(s(r),o.current=r)},[r,o,s]),n}function Qr(e){const t=u.useRef({value:e,previous:e});return u.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var di="VisuallyHidden",En=u.forwardRef((e,t)=>l.jsx(X.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}}));En.displayName=di;var ui=En,fi=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Xe=new WeakMap,Dt=new WeakMap,_t={},Nn=0,Yr=function(e){return e&&(e.host||Yr(e.parentNode))},hi=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Yr(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},pi=function(e,t,n,r){var o=hi(t,Array.isArray(e)?e:[e]);_t[n]||(_t[n]=new WeakMap);var s=_t[n],a=[],i=new Set,c=new Set(o),d=function(h){!h||i.has(h)||(i.add(h),d(h.parentNode))};o.forEach(d);var f=function(h){!h||c.has(h)||Array.prototype.forEach.call(h.children,function(g){if(i.has(g))f(g);else try{var m=g.getAttribute(r),y=m!==null&&m!=="false",p=(Xe.get(g)||0)+1,b=(s.get(g)||0)+1;Xe.set(g,p),s.set(g,b),a.push(g),p===1&&y&&Dt.set(g,!0),b===1&&g.setAttribute(n,"true"),y||g.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",g,v)}})};return f(t),i.clear(),Nn++,function(){a.forEach(function(h){var g=Xe.get(h)-1,m=s.get(h)-1;Xe.set(h,g),s.set(h,m),g||(Dt.has(h)||h.removeAttribute(r),Dt.delete(h)),m||h.removeAttribute(n)}),Nn--,Nn||(Xe=new WeakMap,Xe=new WeakMap,Dt=new WeakMap,_t={})}},gi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=fi(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),pi(r,o,n,"aria-hidden")):function(){return null}},xe=function(){return xe=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},xe.apply(this,arguments)};function Jr(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function mi(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var $t="right-scroll-bar-position",Ft="width-before-scroll-bar",vi="with-scroll-bars-hidden",bi="--removed-body-scroll-bar-size";function Tn(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function yi(e,t){var n=T.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var wi=typeof window<"u"?u.useLayoutEffect:u.useEffect,Kr=new WeakMap;function xi(e,t){var n=yi(null,function(r){return e.forEach(function(o){return Tn(o,r)})});return wi(function(){var r=Kr.get(n);if(r){var o=new Set(r),s=new Set(e),a=n.current;o.forEach(function(i){s.has(i)||Tn(i,null)}),s.forEach(function(i){o.has(i)||Tn(i,a)})}Kr.set(n,e)},[e]),n}function Ci(e){return e}function Si(e,t){t===void 0&&(t=Ci);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var a=t(s,r);return n.push(a),function(){n=n.filter(function(i){return i!==a})}},assignSyncMedium:function(s){for(r=!0;n.length;){var a=n;n=[],a.forEach(s)}n={push:function(i){ret