react-semaphor 0.0.547 → 0.0.549

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -482,7 +482,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
482
482
  To pick up a draggable item, press the space bar.
483
483
  While dragging, use the arrow keys to move the item.
484
484
  Press space again to drop the item in its new position, or press escape to cancel.
485
- `},Lte={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function $te(e){let{announcements:t=Lte,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Fte}=e;const{announce:i,announcement:s}=Tte(),a=fp("DndLiveRegion"),[l,c]=R.useState(!1);if(R.useEffect(()=>{c(!0)},[]),jte(R.useMemo(()=>({onDragStart(d){let{active:h}=d;i(t.onDragStart({active:h}))},onDragMove(d){let{active:h,over:p}=d;t.onDragMove&&i(t.onDragMove({active:h,over:p}))},onDragOver(d){let{active:h,over:p}=d;i(t.onDragOver({active:h,over:p}))},onDragEnd(d){let{active:h,over:p}=d;i(t.onDragEnd({active:h,over:p}))},onDragCancel(d){let{active:h,over:p}=d;i(t.onDragCancel({active:h,over:p}))}}),[i,t])),!l)return null;const u=R.createElement(R.Fragment,null,R.createElement(Ite,{id:r,value:o.draggable}),R.createElement(Ate,{id:a,announcement:s}));return n?rn.createPortal(u,n):u}var Nn;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Nn||(Nn={}));function mb(){}function sh(e,t){return R.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function R2(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return R.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const qo=Object.freeze({x:0,y:0});function o4(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function zte(e,t){const n=pb(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function i4(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Bte(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function BM(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function s4(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function VM(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const k2=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=VM(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=o4(VM(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(i4)},Vte=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=BM(t),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=BM(l),u=o.reduce((h,p,g)=>h+o4(c[g],p),0),d=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:d}})}}return i.sort(i4)};function Hte(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),s=o-r,a=i-n;if(r<o&&n<i){const l=t.width*t.height,c=e.width*e.height,u=s*a,d=u/(l+c-u);return Number(d.toFixed(4))}return 0}const Wte=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=Hte(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(Bte)};function Ute(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function a4(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:qo}function qte(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+e*a.y,bottom:s.bottom+e*a.y,left:s.left+e*a.x,right:s.right+e*a.x}),{...n})}}const Gte=qte(1);function l4(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Yte(e,t,n){const r=l4(t);if(!r)return e;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=e.left-s-(1-o)*parseFloat(n),c=e.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=o?e.width/o:e.width,d=i?e.height/i:e.height;return{width:u,height:d,top:c,right:l+u,bottom:c+d,left:l}}const Kte={ignoreTransform:!1};function dd(e,t){t===void 0&&(t=Kte);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=wr(e).getComputedStyle(e);c&&(n=Yte(n,c,u))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function HM(e){return dd(e,{ignoreTransform:!0})}function Xte(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Qte(e,t){return t===void 0&&(t=wr(e).getComputedStyle(e)),t.position==="fixed"}function Zte(e,t){t===void 0&&(t=wr(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function oy(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(_2(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!up(o)||t4(o)||n.includes(o))return n;const i=wr(e).getComputedStyle(o);return o!==e&&Zte(o,i)&&n.push(o),Qte(o,i)?n:r(o.parentNode)}return e?r(e):n}function c4(e){const[t]=oy(e,1);return t??null}function px(e){return!ty||!e?null:cd(e)?e:E2(e)?_2(e)||e===ud(e).scrollingElement?window:up(e)?e:null:null}function u4(e){return cd(e)?e.scrollX:e.scrollLeft}function d4(e){return cd(e)?e.scrollY:e.scrollTop}function oC(e){return{x:u4(e),y:d4(e)}}var In;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(In||(In={}));function f4(e){return!ty||!e?!1:e===document.scrollingElement}function h4(e){const t={x:0,y:0},n=f4(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:t}}const Jte={x:.2,y:.2};function ene(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=Jte);const{isTop:c,isBottom:u,isLeft:d,isRight:h}=h4(e),p={x:0,y:0},g={x:0,y:0},m={height:t.height*o.y,width:t.width*o.x};return!c&&i<=t.top+m.height?(p.y=In.Backward,g.y=r*Math.abs((t.top+m.height-i)/m.height)):!u&&l>=t.bottom-m.height&&(p.y=In.Forward,g.y=r*Math.abs((t.bottom-m.height-l)/m.height)),!h&&a>=t.right-m.width?(p.x=In.Forward,g.x=r*Math.abs((t.right-m.width-a)/m.width)):!d&&s<=t.left+m.width&&(p.x=In.Backward,g.x=r*Math.abs((t.left+m.width-s)/m.width)),{direction:p,speed:g}}function tne(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function p4(e){return e.reduce((t,n)=>iu(t,oC(n)),qo)}function nne(e){return e.reduce((t,n)=>t+u4(n),0)}function rne(e){return e.reduce((t,n)=>t+d4(n),0)}function m4(e,t){if(t===void 0&&(t=dd),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);c4(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const one=[["x",["left","right"],nne],["y",["top","bottom"],rne]];class N2{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=oy(n),o=p4(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of one)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[i]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class wf{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function ine(e){const{EventTarget:t}=wr(e);return e instanceof t?e:ud(e)}function mx(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var yo;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(yo||(yo={}));function WM(e){e.preventDefault()}function sne(e){e.stopPropagation()}var ht;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(ht||(ht={}));const g4={start:[ht.Space,ht.Enter],cancel:[ht.Esc],end:[ht.Space,ht.Enter,ht.Tab]},ane=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case ht.Right:return{...n,x:n.x+25};case ht.Left:return{...n,x:n.x-25};case ht.Down:return{...n,y:n.y+25};case ht.Up:return{...n,y:n.y-25}}};class hp{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new wf(ud(n)),this.windowListeners=new wf(wr(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(yo.Resize,this.handleCancel),this.windowListeners.add(yo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(yo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&m4(r),n(qo)}handleKeyDown(t){if(ry(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=g4,coordinateGetter:s=ane,scrollBehavior:a="smooth"}=o,{code:l}=t;if(i.end.includes(l)){this.handleEnd(t);return}if(i.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:qo;this.referenceCoordinates||(this.referenceCoordinates=u);const d=s(t,{active:n,context:r.current,currentCoordinates:u});if(d){const h=ih(d,u),p={x:0,y:0},{scrollableAncestors:g}=r.current;for(const m of g){const b=t.code,{isTop:y,isRight:v,isLeft:x,isBottom:S,maxScroll:_,minScroll:E}=h4(m),C=tne(m),k={x:Math.min(b===ht.Right?C.right-C.width/2:C.right,Math.max(b===ht.Right?C.left:C.left+C.width/2,d.x)),y:Math.min(b===ht.Down?C.bottom-C.height/2:C.bottom,Math.max(b===ht.Down?C.top:C.top+C.height/2,d.y))},N=b===ht.Right&&!v||b===ht.Left&&!x,M=b===ht.Down&&!S||b===ht.Up&&!y;if(N&&k.x!==d.x){const I=m.scrollLeft+h.x,D=b===ht.Right&&I<=_.x||b===ht.Left&&I>=E.x;if(D&&!h.y){m.scrollTo({left:I,behavior:a});return}D?p.x=m.scrollLeft-I:p.x=b===ht.Right?m.scrollLeft-_.x:m.scrollLeft-E.x,p.x&&m.scrollBy({left:-p.x,behavior:a});break}else if(M&&k.y!==d.y){const I=m.scrollTop+h.y,D=b===ht.Down&&I<=_.y||b===ht.Up&&I>=E.y;if(D&&!h.x){m.scrollTo({top:I,behavior:a});return}D?p.y=m.scrollTop-I:p.y=b===ht.Down?m.scrollTop-_.y:m.scrollTop-E.y,p.y&&m.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(t,iu(ih(d,this.referenceCoordinates),p))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}hp.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=g4,onActivation:o}=t,{active:i}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function UM(e){return!!(e&&"distance"in e)}function qM(e){return!!(e&&"delay"in e)}class M2{constructor(t,n,r){var o;r===void 0&&(r=ine(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:s}=i;this.props=t,this.events=n,this.document=ud(s),this.documentListeners=new wf(this.document),this.listeners=new wf(r),this.windowListeners=new wf(wr(s)),this.initialCoordinates=(o=pb(i))!=null?o:qo,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(yo.Resize,this.handleCancel),this.windowListeners.add(yo.DragStart,WM),this.windowListeners.add(yo.VisibilityChange,this.handleCancel),this.windowListeners.add(yo.ContextMenu,WM),this.documentListeners.add(yo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(qM(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(UM(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(yo.Click,sne,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(yo.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=pb(t))!=null?n:qo,c=ih(o,l);if(!r&&a){if(UM(a)){if(a.tolerance!=null&&mx(c,a.tolerance))return this.handleCancel();if(mx(c,a.distance))return this.handleStart()}if(qM(a)&&mx(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}t.cancelable&&t.preventDefault(),s(l)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===ht.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const lne={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class pp extends M2{constructor(t){const{event:n}=t,r=ud(n.target);super(t,lne,r)}}pp.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const cne={move:{name:"mousemove"},end:{name:"mouseup"}};var iC;(function(e){e[e.RightClick=2]="RightClick"})(iC||(iC={}));class b4 extends M2{constructor(t){super(t,cne,ud(t.event.target))}}b4.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===iC.RightClick?!1:(r==null||r({event:n}),!0)}}];const gx={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class une extends M2{constructor(t){super(t,gx)}static setup(){return window.addEventListener(gx.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(gx.move.name,t)};function t(){}}}une.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r==null||r({event:n}),!0)}}];var Cf;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Cf||(Cf={}));var gb;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(gb||(gb={}));function dne(e){let{acceleration:t,activator:n=Cf.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=gb.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:h}=e;const p=hne({delta:d,disabled:!i}),[g,m]=kte(),b=R.useRef({x:0,y:0}),y=R.useRef({x:0,y:0}),v=R.useMemo(()=>{switch(n){case Cf.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Cf.DraggableRect:return o}},[n,o,l]),x=R.useRef(null),S=R.useCallback(()=>{const E=x.current;if(!E)return;const C=b.current.x*y.current.x,k=b.current.y*y.current.y;E.scrollBy(C,k)},[]),_=R.useMemo(()=>a===gb.TreeOrder?[...c].reverse():c,[a,c]);R.useEffect(()=>{if(!i||!c.length||!v){m();return}for(const E of _){if((r==null?void 0:r(E))===!1)continue;const C=c.indexOf(E),k=u[C];if(!k)continue;const{direction:N,speed:M}=ene(E,k,v,t,h);for(const I of["x","y"])p[I][N[I]]||(M[I]=0,N[I]=0);if(M.x>0||M.y>0){m(),x.current=E,g(S,s),b.current=M,y.current=N;return}}b.current={x:0,y:0},y.current={x:0,y:0},m()},[t,S,r,m,i,s,JSON.stringify(v),JSON.stringify(p),g,c,_,u,JSON.stringify(h)])}const fne={x:{[In.Backward]:!1,[In.Forward]:!1},y:{[In.Backward]:!1,[In.Forward]:!1}};function hne(e){let{delta:t,disabled:n}=e;const r=hb(t);return dp(o=>{if(n||!r||!o)return fne;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[In.Backward]:o.x[In.Backward]||i.x===-1,[In.Forward]:o.x[In.Forward]||i.x===1},y:{[In.Backward]:o.y[In.Backward]||i.y===-1,[In.Forward]:o.y[In.Forward]||i.y===1}}},[n,t,r])}function pne(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return dp(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function mne(e,t){return R.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...i]},[]),[e,t])}var ah;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(ah||(ah={}));var sC;(function(e){e.Optimized="optimized"})(sC||(sC={}));const GM=new Map;function gne(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,s]=R.useState(null),{frequency:a,measure:l,strategy:c}=o,u=R.useRef(e),d=b(),h=oh(d),p=R.useCallback(function(y){y===void 0&&(y=[]),!h.current&&s(v=>v===null?y:v.concat(y.filter(x=>!v.includes(x))))},[h]),g=R.useRef(null),m=dp(y=>{if(d&&!n)return GM;if(!y||y===GM||u.current!==e||i!=null){const v=new Map;for(let x of e){if(!x)continue;if(i&&i.length>0&&!i.includes(x.id)&&x.rect.current){v.set(x.id,x.rect.current);continue}const S=x.node.current,_=S?new N2(l(S),S):null;x.rect.current=_,_&&v.set(x.id,_)}return v}return y},[e,i,n,d,l]);return R.useEffect(()=>{u.current=e},[e]),R.useEffect(()=>{d||p()},[n,d]),R.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),R.useEffect(()=>{d||typeof a!="number"||g.current!==null||(g.current=setTimeout(()=>{p(),g.current=null},a))},[a,d,p,...r]),{droppableRects:m,measureDroppableContainers:p,measuringScheduled:i!=null};function b(){switch(c){case ah.Always:return!1;case ah.BeforeDragging:return n;default:return!n}}}function P2(e,t){return dp(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function bne(e,t){return P2(e,t)}function yne(e){let{callback:t,disabled:n}=e;const r=ny(t),o=R.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return R.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function iy(e){let{callback:t,disabled:n}=e;const r=ny(t),o=R.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return R.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function vne(e){return new N2(dd(e),e)}function YM(e,t,n){t===void 0&&(t=vne);const[r,o]=R.useState(null);function i(){o(l=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=t(e);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=yne({callback(l){if(e)for(const c of l){const{type:u,target:d}=c;if(u==="childList"&&d instanceof HTMLElement&&d.contains(e)){i();break}}}}),a=iy({callback:i});return Uo(()=>{i(),e?(a==null||a.observe(e),s==null||s.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),s==null||s.disconnect())},[e]),r}function xne(e){const t=P2(e);return a4(e,t)}const KM=[];function wne(e){const t=R.useRef(e),n=dp(r=>e?r&&r!==KM&&e&&t.current&&e.parentNode===t.current.parentNode?r:oy(e):KM,[e]);return R.useEffect(()=>{t.current=e},[e]),n}function Cne(e){const[t,n]=R.useState(null),r=R.useRef(e),o=R.useCallback(i=>{const s=px(i.target);s&&n(a=>a?(a.set(s,oC(s)),new Map(a)):null)},[]);return R.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const c=px(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,oC(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{s(e),s(i)};function s(a){a.forEach(l=>{const c=px(l);c==null||c.removeEventListener("scroll",o)})}},[o,e]),R.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>iu(i,s),qo):p4(e):qo,[e,t])}function XM(e,t){t===void 0&&(t=[]);const n=R.useRef(null);return R.useEffect(()=>{n.current=null},t),R.useEffect(()=>{const r=e!==qo;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?ih(e,n.current):qo}function Sne(e){R.useEffect(()=>{if(!ty)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function Ene(e,t){return R.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,t)},n},{}),[e,t])}function y4(e){return R.useMemo(()=>e?Xte(e):null,[e])}const QM=[];function _ne(e,t){t===void 0&&(t=dd);const[n]=e,r=y4(n?wr(n):null),[o,i]=R.useState(QM);function s(){i(()=>e.length?e.map(l=>f4(l)?r:new N2(t(l),l)):QM)}const a=iy({callback:s});return Uo(()=>{a==null||a.disconnect(),s(),e.forEach(l=>a==null?void 0:a.observe(l))},[e]),o}function v4(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return up(t)?t:e}function Rne(e){let{measure:t}=e;const[n,r]=R.useState(null),o=R.useCallback(c=>{for(const{target:u}of c)if(up(u)){r(d=>{const h=t(u);return d?{...d,width:h.width,height:h.height}:h});break}},[t]),i=iy({callback:o}),s=R.useCallback(c=>{const u=v4(c);i==null||i.disconnect(),u&&(i==null||i.observe(u)),r(u?t(u):null)},[t,i]),[a,l]=fb(s);return R.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const kne=[{sensor:pp,options:{}},{sensor:hp,options:{}}],Nne={current:{}},Pg={draggable:{measure:HM},droppable:{measure:HM,strategy:ah.WhileDragging,frequency:sC.Optimized},dragOverlay:{measure:dd}};class Sf extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Mne={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Sf,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:mb},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Pg,measureDroppableContainers:mb,windowRect:null,measuringScheduled:!1},x4={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:mb,draggableNodes:new Map,over:null,measureDroppableContainers:mb},mp=R.createContext(x4),w4=R.createContext(Mne);function Pne(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Sf}}}function Dne(e,t){switch(t.type){case Nn.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Nn.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Nn.DragEnd:case Nn.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Nn.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Sf(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case Nn.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const s=new Sf(e.droppable.containers);return s.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case Nn.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Sf(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Ine(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=R.useContext(mp),i=hb(r),s=hb(n==null?void 0:n.id);return R.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!ry(i)||document.activeElement===i.target)return;const a=o.get(s);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const d=Pte(u);if(d){d.focus();break}}})}},[r,t,o,s,i]),null}function C4(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function Ane(e){return R.useMemo(()=>({draggable:{...Pg.draggable,...e==null?void 0:e.draggable},droppable:{...Pg.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Pg.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function Tne(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=R.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Uo(()=>{if(!s&&!a||!t){i.current=!1;return}if(i.current||!r)return;const c=t==null?void 0:t.node.current;if(!c||c.isConnected===!1)return;const u=n(c),d=a4(u,r);if(s||(d.x=0),a||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=c4(c);h&&h.scrollBy({top:d.y,left:d.x})}},[t,s,a,r,n])}const sy=R.createContext({...qo,scaleX:1,scaleY:1});var Hs;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Hs||(Hs={}));const D2=R.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=kne,collisionDetection:d=Wte,measuring:h,modifiers:p,...g}=t;const m=R.useReducer(Dne,void 0,Pne),[b,y]=m,[v,x]=Ote(),[S,_]=R.useState(Hs.Uninitialized),E=S===Hs.Initialized,{draggable:{active:C,nodes:k,translate:N},droppable:{containers:M}}=b,I=C!=null?k.get(C):null,D=R.useRef({initial:null,translated:null}),j=R.useMemo(()=>{var an;return C!=null?{id:C,data:(an=I==null?void 0:I.data)!=null?an:Nne,rect:D}:null},[C,I]),F=R.useRef(null),[T,O]=R.useState(null),[$,B]=R.useState(null),z=oh(g,Object.values(g)),A=fp("DndDescribedBy",s),W=R.useMemo(()=>M.getEnabled(),[M]),L=Ane(h),{droppableRects:P,measureDroppableContainers:H,measuringScheduled:V}=gne(W,{dragging:E,dependencies:[N.x,N.y],config:L.droppable}),G=pne(k,C),q=R.useMemo(()=>$?pb($):null,[$]),Y=Wi(),K=bne(G,L.draggable.measure);Tne({activeNode:C!=null?k.get(C):null,config:Y.layoutShiftCompensation,initialRect:K,measure:L.draggable.measure});const Z=YM(G,L.draggable.measure,K),ee=YM(G?G.parentElement:null),Q=R.useRef({activatorEvent:null,active:null,activeNode:G,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:k,draggingNode:null,draggingNodeRect:null,droppableContainers:M,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=M.getNodeFor((n=Q.current.over)==null?void 0:n.id),te=Rne({measure:L.dragOverlay.measure}),ce=(r=te.nodeRef.current)!=null?r:G,ue=E?(o=te.rect)!=null?o:Z:null,Re=!!(te.nodeRef.current&&te.rect),ve=xne(Re?null:Z),we=y4(ce?wr(ce):null),De=wne(E?oe??G:null),Ye=_ne(De),_t=C4(p,{transform:{x:N.x-ve.x,y:N.y-ve.y,scaleX:1,scaleY:1},activatorEvent:$,active:j,activeNodeRect:Z,containerNodeRect:ee,draggingNodeRect:ue,over:Q.current.over,overlayNodeRect:te.rect,scrollableAncestors:De,scrollableAncestorRects:Ye,windowRect:we}),me=q?iu(q,N):null,je=Cne(De),Ie=XM(je),ne=XM(je,[Z]),le=iu(_t,Ie),ke=ue?Gte(ue,_t):null,Pe=j&&ke?d({active:j,collisionRect:ke,droppableRects:P,droppableContainers:W,pointerCoordinates:me}):null,Ue=s4(Pe,"id"),[jt,kn]=R.useState(null),gn=Re?_t:iu(_t,ne),ge=Ute(gn,(i=jt==null?void 0:jt.rect)!=null?i:null,Z),bn=R.useRef(null),Ot=R.useCallback((an,Rt)=>{let{sensor:Fn,options:Ae}=Rt;if(F.current==null)return;const qe=k.get(F.current);if(!qe)return;const rt=an.nativeEvent,Jt=new Fn({active:F.current,activeNode:qe,event:rt,options:Ae,context:Q,onAbort(Lt){if(!k.get(Lt))return;const{onDragAbort:en}=z.current,yn={id:Lt};en==null||en(yn),v({type:"onDragAbort",event:yn})},onPending(Lt,Dn,en,yn){if(!k.get(Lt))return;const{onDragPending:fo}=z.current,ri={id:Lt,constraint:Dn,initialCoordinates:en,offset:yn};fo==null||fo(ri),v({type:"onDragPending",event:ri})},onStart(Lt){const Dn=F.current;if(Dn==null)return;const en=k.get(Dn);if(!en)return;const{onDragStart:yn}=z.current,Ba={activatorEvent:rt,active:{id:Dn,data:en.data,rect:D}};rn.unstable_batchedUpdates(()=>{yn==null||yn(Ba),_(Hs.Initializing),y({type:Nn.DragStart,initialCoordinates:Lt,active:Dn}),v({type:"onDragStart",event:Ba}),O(bn.current),B(rt)})},onMove(Lt){y({type:Nn.DragMove,coordinates:Lt})},onEnd:Ft(Nn.DragEnd),onCancel:Ft(Nn.DragCancel)});bn.current=Jt;function Ft(Lt){return async function(){const{active:en,collisions:yn,over:Ba,scrollAdjustedTranslate:fo}=Q.current;let ri=null;if(en&&fo){const{cancelDrop:Va}=z.current;ri={activatorEvent:rt,active:en,collisions:yn,delta:fo,over:Ba},Lt===Nn.DragEnd&&typeof Va=="function"&&await Promise.resolve(Va(ri))&&(Lt=Nn.DragCancel)}F.current=null,rn.unstable_batchedUpdates(()=>{y({type:Lt}),_(Hs.Uninitialized),kn(null),O(null),B(null),bn.current=null;const Va=Lt===Nn.DragEnd?"onDragEnd":"onDragCancel";if(ri){const Id=z.current[Va];Id==null||Id(ri),v({type:Va,event:ri})}})}}},[k]),uo=R.useCallback((an,Rt)=>(Fn,Ae)=>{const qe=Fn.nativeEvent,rt=k.get(Ae);if(F.current!==null||!rt||qe.dndKit||qe.defaultPrevented)return;const Jt={active:rt};an(Fn,Rt.options,Jt)===!0&&(qe.dndKit={capturedBy:Rt.sensor},F.current=Ae,Ot(Fn,Rt))},[k,Ot]),On=mne(u,uo);Sne(u),Uo(()=>{Z&&S===Hs.Initializing&&_(Hs.Initialized)},[Z,S]),R.useEffect(()=>{const{onDragMove:an}=z.current,{active:Rt,activatorEvent:Fn,collisions:Ae,over:qe}=Q.current;if(!Rt||!Fn)return;const rt={active:Rt,activatorEvent:Fn,collisions:Ae,delta:{x:le.x,y:le.y},over:qe};rn.unstable_batchedUpdates(()=>{an==null||an(rt),v({type:"onDragMove",event:rt})})},[le.x,le.y]),R.useEffect(()=>{const{active:an,activatorEvent:Rt,collisions:Fn,droppableContainers:Ae,scrollAdjustedTranslate:qe}=Q.current;if(!an||F.current==null||!Rt||!qe)return;const{onDragOver:rt}=z.current,Jt=Ae.get(Ue),Ft=Jt&&Jt.rect.current?{id:Jt.id,rect:Jt.rect.current,data:Jt.data,disabled:Jt.disabled}:null,Lt={active:an,activatorEvent:Rt,collisions:Fn,delta:{x:qe.x,y:qe.y},over:Ft};rn.unstable_batchedUpdates(()=>{kn(Ft),rt==null||rt(Lt),v({type:"onDragOver",event:Lt})})},[Ue]),Uo(()=>{Q.current={activatorEvent:$,active:j,activeNode:G,collisionRect:ke,collisions:Pe,droppableRects:P,draggableNodes:k,draggingNode:ce,draggingNodeRect:ue,droppableContainers:M,over:jt,scrollableAncestors:De,scrollAdjustedTranslate:le},D.current={initial:ue,translated:ke}},[j,G,Pe,ke,k,ce,ue,P,M,jt,De,le]),dne({...Y,delta:N,draggingRect:ke,pointerCoordinates:me,scrollableAncestors:De,scrollableAncestorRects:Ye});const Cc=R.useMemo(()=>({active:j,activeNode:G,activeNodeRect:Z,activatorEvent:$,collisions:Pe,containerNodeRect:ee,dragOverlay:te,draggableNodes:k,droppableContainers:M,droppableRects:P,over:jt,measureDroppableContainers:H,scrollableAncestors:De,scrollableAncestorRects:Ye,measuringConfiguration:L,measuringScheduled:V,windowRect:we}),[j,G,Z,$,Pe,ee,te,k,M,P,jt,H,De,Ye,L,V,we]),za=R.useMemo(()=>({activatorEvent:$,activators:On,active:j,activeNodeRect:Z,ariaDescribedById:{draggable:A},dispatch:y,draggableNodes:k,over:jt,measureDroppableContainers:H}),[$,On,j,Z,y,A,k,jt,H]);return R.createElement(r4.Provider,{value:x},R.createElement(mp.Provider,{value:za},R.createElement(w4.Provider,{value:Cc},R.createElement(sy.Provider,{value:ge},c)),R.createElement(Ine,{disabled:(a==null?void 0:a.restoreFocus)===!1})),R.createElement($te,{...a,hiddenTextDescribedById:A}));function Wi(){const an=(T==null?void 0:T.autoScrollEnabled)===!1,Rt=typeof l=="object"?l.enabled===!1:l===!1,Fn=E&&!an&&!Rt;return typeof l=="object"?{...l,enabled:Fn}:{enabled:Fn}}}),jne=R.createContext(null),ZM="button",One="Draggable";function S4(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=fp(One),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:h}=R.useContext(mp),{role:p=ZM,roleDescription:g="draggable",tabIndex:m=0}=o??{},b=(l==null?void 0:l.id)===t,y=R.useContext(b?sy:jne),[v,x]=fb(),[S,_]=fb(),E=Ene(s,t),C=oh(n);Uo(()=>(d.set(t,{id:t,key:i,node:v,activatorNode:S,data:C}),()=>{const N=d.get(t);N&&N.key===i&&d.delete(t)}),[d,t]);const k=R.useMemo(()=>({role:p,tabIndex:m,"aria-disabled":r,"aria-pressed":b&&p===ZM?!0:void 0,"aria-roledescription":g,"aria-describedby":u.draggable}),[r,p,m,b,g,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:k,isDragging:b,listeners:r?void 0:E,node:v,over:h,setNodeRef:x,setActivatorNodeRef:_,transform:y}}function E4(){return R.useContext(w4)}const Fne="Droppable",Lne={timeout:25};function _4(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=fp(Fne),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=R.useContext(mp),u=R.useRef({disabled:n}),d=R.useRef(!1),h=R.useRef(null),p=R.useRef(null),{disabled:g,updateMeasurementsFor:m,timeout:b}={...Lne,...o},y=oh(m??r),v=R.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),p.current=null},b)},[b]),x=iy({callback:v,disabled:g||!s}),S=R.useCallback((k,N)=>{x&&(N&&(x.unobserve(N),d.current=!1),k&&x.observe(k))},[x]),[_,E]=fb(S),C=oh(t);return R.useEffect(()=>{!x||!_.current||(x.disconnect(),d.current=!1,x.observe(_.current))},[_,x]),R.useEffect(()=>(a({type:Nn.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:h,data:C}}),()=>a({type:Nn.UnregisterDroppable,key:i,id:r})),[r]),R.useEffect(()=>{n!==u.current.disabled&&(a({type:Nn.SetDroppableDisabled,id:r,key:i,disabled:n}),u.current.disabled=n)},[r,i,n,a]),{active:s,rect:h,isOver:(l==null?void 0:l.id)===r,node:_,over:l,setNodeRef:E}}function $ne(e){let{animation:t,children:n}=e;const[r,o]=R.useState(null),[i,s]=R.useState(null),a=hb(n);return!n&&!r&&a&&o(a),Uo(()=>{if(!i)return;const l=r==null?void 0:r.key,c=r==null?void 0:r.props.id;if(l==null||c==null){o(null);return}Promise.resolve(t(c,i)).then(()=>{o(null)})},[t,r,i]),R.createElement(R.Fragment,null,n,r?R.cloneElement(r,{ref:s}):null)}const zne={x:0,y:0,scaleX:1,scaleY:1};function Bne(e){let{children:t}=e;return R.createElement(mp.Provider,{value:x4},R.createElement(sy.Provider,{value:zne},t))}const Vne={position:"fixed",touchAction:"none"},Hne=e=>ry(e)?"transform 250ms ease":void 0,Wne=R.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=Hne}=e;if(!a)return null;const d=o?c:{...c,scaleX:1,scaleY:1},h={...Vne,width:a.width,height:a.height,top:a.top,left:a.left,transform:ki.Transform.toString(d),transformOrigin:o&&r?zte(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return R.createElement(n,{className:s,style:h,ref:t},i)}),Une=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:s}=e;if(i!=null&&i.active)for(const[a,l]of Object.entries(i.active))l!==void 0&&(o[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(i!=null&&i.dragOverlay)for(const[a,l]of Object.entries(i.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return s!=null&&s.active&&n.node.classList.add(s.active),s!=null&&s.dragOverlay&&r.node.classList.add(s.dragOverlay),function(){for(const[l,c]of Object.entries(o))n.node.style.setProperty(l,c);s!=null&&s.active&&n.node.classList.remove(s.active)}},qne=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:ki.Transform.toString(t)},{transform:ki.Transform.toString(n)}]},Gne={duration:250,easing:"ease",keyframes:qne,sideEffects:Une({styles:{active:{opacity:"0"}}})};function Yne(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return ny((i,s)=>{if(t===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=v4(s);if(!c)return;const{transform:u}=wr(s).getComputedStyle(s),d=l4(u);if(!d)return;const h=typeof t=="function"?t:Kne(t);return m4(l,o.draggable.measure),h({active:{id:i,data:a.data,node:l,rect:o.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:s,rect:o.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:o,transform:d})})}function Kne(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...Gne,...e};return i=>{let{active:s,dragOverlay:a,transform:l,...c}=i;if(!t)return;const u={x:a.rect.left-s.rect.left,y:a.rect.top-s.rect.top},d={scaleX:l.scaleX!==1?s.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?s.rect.height*l.scaleY/a.rect.height:1},h={x:l.x-u.x,y:l.y-u.y,...d},p=o({...c,active:s,dragOverlay:a,transform:{initial:l,final:h}}),[g]=p,m=p[p.length-1];if(JSON.stringify(g)===JSON.stringify(m))return;const b=r==null?void 0:r({active:s,dragOverlay:a,...c}),y=a.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(v=>{y.onfinish=()=>{b==null||b(),v()}})}}let JM=0;function Xne(e){return R.useMemo(()=>{if(e!=null)return JM++,JM},[e])}const R4=R.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:s,wrapperElement:a="div",className:l,zIndex:c=999}=e;const{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggableNodes:g,droppableContainers:m,dragOverlay:b,over:y,measuringConfiguration:v,scrollableAncestors:x,scrollableAncestorRects:S,windowRect:_}=E4(),E=R.useContext(sy),C=Xne(d==null?void 0:d.id),k=C4(s,{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:b.rect,over:y,overlayNodeRect:b.rect,scrollableAncestors:x,scrollableAncestorRects:S,transform:E,windowRect:_}),N=P2(h),M=Yne({config:r,draggableNodes:g,droppableContainers:m,measuringConfiguration:v}),I=N?b.setRef:void 0;return R.createElement(Bne,null,R.createElement($ne,{animation:M},d&&C?R.createElement(Wne,{key:C,id:d.id,ref:I,as:a,activatorEvent:u,adjustScale:t,className:l,transition:i,rect:N,style:{zIndex:c,...o},transform:k},n):null))});function gp(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Qne(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Cm(e){return e!==null&&e>=0}function Zne(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Jne(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Sm={scaleX:1,scaleY:1},ere=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:i,index:s}=e;const a=(t=n[o])!=null?t:r;if(!a)return null;const l=tre(n,s,o);if(s===o){const c=n[i];return c?{x:o<i?c.left+c.width-(a.left+a.width):c.left-a.left,y:0,...Sm}:null}return s>o&&s<=i?{x:-a.width-l,y:0,...Sm}:s<o&&s>=i?{x:a.width+l,y:0,...Sm}:{x:0,y:0,...Sm}};function tre(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return!r||!o&&!i?0:n<t?o?r.left-(o.left+o.width):i.left-(r.left+r.width):i?i.left-(r.left+r.width):r.left-(o.left+o.width)}const k4=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=gp(t,r,n),s=t[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},Em={scaleX:1,scaleY:1},N4=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:s}=e;const a=(t=i[n])!=null?t:r;if(!a)return null;if(o===n){const c=i[s];return c?{x:0,y:n<s?c.top+c.height-(a.top+a.height):c.top-a.top,...Em}:null}const l=nre(i,o,n);return o>n&&o<=s?{x:0,y:-a.height-l,...Em}:o<n&&o>=s?{x:0,y:a.height+l,...Em}:{x:0,y:0,...Em}};function nre(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const M4="Sortable",P4=R.createContext({activeIndex:-1,containerId:M4,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:k4,disabled:{draggable:!1,droppable:!1}});function I2(e){let{children:t,id:n,items:r,strategy:o=k4,disabled:i=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=E4(),d=fp(M4,n),h=a.rect!==null,p=R.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),g=s!=null,m=s?p.indexOf(s.id):-1,b=c?p.indexOf(c.id):-1,y=R.useRef(p),v=!Zne(p,y.current),x=b!==-1&&m===-1||v,S=Jne(i);Uo(()=>{v&&g&&u(p)},[v,p,g,u]),R.useEffect(()=>{y.current=p},[p]);const _=R.useMemo(()=>({activeIndex:m,containerId:d,disabled:S,disableTransforms:x,items:p,overIndex:b,useDragOverlay:h,sortedRects:Qne(p,l),strategy:o}),[m,d,S.draggable,S.droppable,x,p,b,l,h,o]);return R.createElement(P4.Provider,{value:_},t)}const rre=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return gp(n,r,o).indexOf(t)},ore=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==i&&o===s?!1:n?!0:s!==o&&t===l},ire={duration:200,easing:"ease"},D4="transform",sre=ki.Transition.toString({property:D4,duration:0,easing:"linear"}),are={roleDescription:"sortable"};function lre(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=R.useState(null),a=R.useRef(n);return Uo(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=dd(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==a.current&&(a.current=n)},[t,n,r,o]),R.useEffect(()=>{i&&s(null)},[i]),i}function A2(e){let{animateLayoutChanges:t=ore,attributes:n,disabled:r,data:o,getNewIndex:i=rre,id:s,strategy:a,resizeObserverConfig:l,transition:c=ire}=e;const{items:u,containerId:d,activeIndex:h,disabled:p,disableTransforms:g,sortedRects:m,overIndex:b,useDragOverlay:y,strategy:v}=R.useContext(P4),x=cre(r,p),S=u.indexOf(s),_=R.useMemo(()=>({sortable:{containerId:d,index:S,items:u},...o}),[d,o,S,u]),E=R.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:C,node:k,isOver:N,setNodeRef:M}=_4({id:s,data:_,disabled:x.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...l}}),{active:I,activatorEvent:D,activeNodeRect:j,attributes:F,setNodeRef:T,listeners:O,isDragging:$,over:B,setActivatorNodeRef:z,transform:A}=S4({id:s,data:_,attributes:{...are,...n},disabled:x.draggable}),W=Rte(M,T),L=!!I,P=L&&!g&&Cm(h)&&Cm(b),H=!y&&$,V=H&&P?A:null,q=P?V??(a??v)({rects:m,activeNodeRect:j,activeIndex:h,overIndex:b,index:S}):null,Y=Cm(h)&&Cm(b)?i({id:s,items:u,activeIndex:h,overIndex:b}):S,K=I==null?void 0:I.id,Z=R.useRef({activeId:K,items:u,newIndex:Y,containerId:d}),ee=u!==Z.current.items,Q=t({active:I,containerId:d,isDragging:$,isSorting:L,id:s,index:S,items:u,newIndex:Z.current.newIndex,previousItems:Z.current.items,previousContainerId:Z.current.containerId,transition:c,wasDragging:Z.current.activeId!=null}),oe=lre({disabled:!Q,index:S,node:k,rect:C});return R.useEffect(()=>{L&&Z.current.newIndex!==Y&&(Z.current.newIndex=Y),d!==Z.current.containerId&&(Z.current.containerId=d),u!==Z.current.items&&(Z.current.items=u)},[L,Y,d,u]),R.useEffect(()=>{if(K===Z.current.activeId)return;if(K!=null&&Z.current.activeId==null){Z.current.activeId=K;return}const ce=setTimeout(()=>{Z.current.activeId=K},50);return()=>clearTimeout(ce)},[K]),{active:I,activeIndex:h,attributes:F,data:_,rect:C,index:S,newIndex:Y,items:u,isOver:N,isSorting:L,isDragging:$,listeners:O,node:k,overIndex:b,over:B,setNodeRef:W,setActivatorNodeRef:z,setDroppableNodeRef:M,setDraggableNodeRef:T,transform:oe??q,transition:te()};function te(){if(oe||ee&&Z.current.newIndex===S)return sre;if(!(H&&!ry(D)||!c)&&(L||Q))return ki.Transition.toString({...c,property:D4})}}function cre(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:t.droppable}}function bb(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const ure=[ht.Down,ht.Right,ht.Up,ht.Left],T2=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:s,scrollableAncestors:a}}=t;if(ure.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const h=o.get(d.id);if(h)switch(e.code){case ht.Down:r.top<h.top&&l.push(d);break;case ht.Up:r.top>h.top&&l.push(d);break;case ht.Left:r.left>h.left&&l.push(d);break;case ht.Right:r.left<h.left&&l.push(d);break}});const c=Vte({collisionRect:r,droppableRects:o,droppableContainers:l});let u=s4(c,"id");if(u===(s==null?void 0:s.id)&&c.length>1&&(u=c[1].id),u!=null){const d=i.get(n.id),h=i.get(u),p=h?o.get(h.id):null,g=h==null?void 0:h.node.current;if(g&&p&&d&&h){const b=oy(g).some((E,C)=>a[C]!==E),y=I4(d,h),v=dre(d,h),x=b||!y?{x:0,y:0}:{x:v?r.width-p.width:0,y:v?r.height-p.height:0},S={x:p.left,y:p.top};return x.x&&x.y?S:ih(S,x)}}}};function I4(e,t){return!bb(e)||!bb(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function dre(e,t){return!bb(e)||!bb(t)||!I4(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function fre(e,t,n){const[r,o]=R.useState(null),[i,s]=R.useState(""),a=()=>{const g={id:`hierarchy_${Date.now()}`,label:i||"New Hierarchy",type:"static",steps:[],default:!1};t([...e,g]),s(""),o(g.id)},l=g=>{t(e.filter(m=>m.id!==g))},c=(g,m)=>{t(e.map(b=>b.id===g?{...b,...m}:b))};return{editingHierarchy:r,setEditingHierarchy:o,newHierarchyName:i,setNewHierarchyName:s,createNewHierarchy:a,deleteHierarchy:l,updateHierarchy:c,addStepToHierarchy:(g,m)=>{const b=n.find(x=>x.id===m);if(!b)return;const y={field:b,mode:"drillDown",label:`Drill to ${b.label}`,retainFilters:!0,preferredChartType:"bar"},v=e.find(x=>x.id===g);v&&c(g,{steps:[...v.steps,y]})},removeStepFromHierarchy:(g,m)=>{const b=e.find(y=>y.id===g);if(b){const y=[...b.steps];y.splice(m,1),c(g,{steps:y})}},updateStep:(g,m,b)=>{const y=e.find(v=>v.id===g);if(y){const v=y.steps.map((x,S)=>S===m?{...x,...b}:x);c(g,{steps:v})}},setDefaultHierarchy:g=>{t(e.map(m=>({...m,default:m.id===g})))}}}function hre({value:e,isEditing:t,onEdit:n,onSave:r,onCancel:o,placeholder:i="Enter text...",inputClassName:s="",displayClassName:a=""}){const[l,c]=R.useState(e);R.useEffect(()=>{c(e)},[e]);const u=g=>{g.key===" "&&g.stopPropagation(),g.key==="Enter"?r(l):g.key==="Escape"&&(c(e),o())},d=()=>{r(l)},h=g=>{g.stopPropagation()},p=g=>{g.stopPropagation()};return t?f.jsx("input",{type:"text",value:l,onChange:g=>c(g.target.value),onKeyDown:u,onBlur:d,onMouseDown:h,onPointerDown:p,className:`min-w-0 border-b border-blue-300 bg-transparent focus:border-blue-500 focus:outline-none dark:border-blue-600 dark:focus:border-blue-400 ${s}`,placeholder:i,autoFocus:!0}):f.jsx("span",{className:`cursor-pointer transition-colors hover:text-blue-600 dark:hover:text-blue-400 ${a}`,onClick:g=>{g.stopPropagation(),n()},onPointerDown:g=>g.stopPropagation(),title:"Click to edit",children:e||i})}function pre(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e);w.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 mre="DismissableLayer",aC="dismissableLayer.update",gre="dismissableLayer.pointerDownOutside",bre="dismissableLayer.focusOutside",eP,A4=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),hc=w.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...l}=e,c=w.useContext(A4),[u,d]=w.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=w.useState({}),g=Ve(t,C=>d(C)),m=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=m.indexOf(b),v=u?m.indexOf(u):-1,x=c.layersWithOutsidePointerEventsDisabled.size>0,S=v>=y,_=xre(C=>{const k=C.target,N=[...c.branches].some(M=>M.contains(k));!S||N||(o==null||o(C),s==null||s(C),C.defaultPrevented||a==null||a())},h),E=wre(C=>{const k=C.target;[...c.branches].some(M=>M.contains(k))||(i==null||i(C),s==null||s(C),C.defaultPrevented||a==null||a())},h);return pre(C=>{v===c.layers.size-1&&(r==null||r(C),!C.defaultPrevented&&a&&(C.preventDefault(),a()))},h),w.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(eP=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),tP(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=eP)}},[u,h,n,c]),w.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),tP())},[u,c]),w.useEffect(()=>{const C=()=>p({});return document.addEventListener(aC,C),()=>document.removeEventListener(aC,C)},[]),f.jsx(_e.div,{...l,ref:g,style:{pointerEvents:x?S?"auto":"none":void 0,...e.style},onFocusCapture:fe(e.onFocusCapture,E.onFocusCapture),onBlurCapture:fe(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:fe(e.onPointerDownCapture,_.onPointerDownCapture)})});hc.displayName=mre;var yre="DismissableLayerBranch",vre=w.forwardRef((e,t)=>{const n=w.useContext(A4),r=w.useRef(null),o=Ve(t,r);return w.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),f.jsx(_e.div,{...e,ref:o})});vre.displayName=yre;function xre(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=w.useRef(!1),o=w.useRef(()=>{});return w.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let l=function(){T4(gre,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function wre(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=w.useRef(!1);return w.useEffect(()=>{const o=i=>{i.target&&!r.current&&T4(bre,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function tP(){const e=new CustomEvent(aC);document.dispatchEvent(e)}function T4(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?jO(o,i):o.dispatchEvent(i)}var bx=0;function ay(){w.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??nP()),document.body.insertAdjacentElement("beforeend",e[1]??nP()),bx++,()=>{bx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),bx--}},[])}function nP(){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 yx="focusScope.autoFocusOnMount",vx="focusScope.autoFocusOnUnmount",rP={bubbles:!1,cancelable:!0},Cre="FocusScope",bp=w.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,l]=w.useState(null),c=Mn(o),u=Mn(i),d=w.useRef(null),h=Ve(t,m=>l(m)),p=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(r){let m=function(x){if(p.paused||!a)return;const S=x.target;a.contains(S)?d.current=S:Bs(d.current,{select:!0})},b=function(x){if(p.paused||!a)return;const S=x.relatedTarget;S!==null&&(a.contains(S)||Bs(d.current,{select:!0}))},y=function(x){if(document.activeElement===document.body)for(const _ of x)_.removedNodes.length>0&&Bs(a)};document.addEventListener("focusin",m),document.addEventListener("focusout",b);const v=new MutationObserver(y);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",b),v.disconnect()}}},[r,a,p.paused]),w.useEffect(()=>{if(a){iP.add(p);const m=document.activeElement;if(!a.contains(m)){const y=new CustomEvent(yx,rP);a.addEventListener(yx,c),a.dispatchEvent(y),y.defaultPrevented||(Sre(Nre(j4(a)),{select:!0}),document.activeElement===m&&Bs(a))}return()=>{a.removeEventListener(yx,c),setTimeout(()=>{const y=new CustomEvent(vx,rP);a.addEventListener(vx,u),a.dispatchEvent(y),y.defaultPrevented||Bs(m??document.body,{select:!0}),a.removeEventListener(vx,u),iP.remove(p)},0)}}},[a,c,u,p]);const g=w.useCallback(m=>{if(!n&&!r||p.paused)return;const b=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,y=document.activeElement;if(b&&y){const v=m.currentTarget,[x,S]=Ere(v);x&&S?!m.shiftKey&&y===S?(m.preventDefault(),n&&Bs(x,{select:!0})):m.shiftKey&&y===x&&(m.preventDefault(),n&&Bs(S,{select:!0})):y===v&&m.preventDefault()}},[n,r,p.paused]);return f.jsx(_e.div,{tabIndex:-1,...s,ref:h,onKeyDown:g})});bp.displayName=Cre;function Sre(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Bs(r,{select:t}),document.activeElement!==n)return}function Ere(e){const t=j4(e),n=oP(t,e),r=oP(t.reverse(),e);return[n,r]}function j4(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 oP(e,t){for(const n of e)if(!_re(n,{upTo:t}))return n}function _re(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 Rre(e){return e instanceof HTMLInputElement&&"select"in e}function Bs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Rre(e)&&t&&e.select()}}var iP=kre();function kre(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=sP(e,t),e.unshift(t)},remove(t){var n;e=sP(e,t),(n=e[0])==null||n.resume()}}}function sP(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Nre(e){return e.filter(t=>t.tagName!=="A")}const Mre=["top","right","bottom","left"],ws=Math.min,Xn=Math.max,lh=Math.round,_m=Math.floor,bi=e=>({x:e,y:e}),Pre={left:"right",right:"left",bottom:"top",top:"bottom"},Dre={start:"end",end:"start"};function lC(e,t,n){return Xn(e,ws(t,n))}function Ni(e,t){return typeof e=="function"?e(t):e}function Cs(e){return e.split("-")[0]}function fd(e){return e.split("-")[1]}function j2(e){return e==="x"?"y":"x"}function O2(e){return e==="y"?"height":"width"}function ha(e){return["top","bottom"].includes(Cs(e))?"y":"x"}function F2(e){return j2(ha(e))}function Ire(e,t,n){n===void 0&&(n=!1);const r=fd(e),o=F2(e),i=O2(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=yb(s)),[s,yb(s)]}function Are(e){const t=yb(e);return[cC(e),t,cC(t)]}function cC(e){return e.replace(/start|end/g,t=>Dre[t])}function Tre(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function jre(e,t,n,r){const o=fd(e);let i=Tre(Cs(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(cC)))),i}function yb(e){return e.replace(/left|right|bottom|top/g,t=>Pre[t])}function Ore(e){return{top:0,right:0,bottom:0,left:0,...e}}function O4(e){return typeof e!="number"?Ore(e):{top:e,right:e,bottom:e,left:e}}function vb(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 aP(e,t,n){let{reference:r,floating:o}=e;const i=ha(t),s=F2(t),a=O2(s),l=Cs(t),c=i==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-o.width,y:d};break;default:p={x:r.x,y:r.y}}switch(fd(t)){case"start":p[s]-=h*(n&&c?-1:1);break;case"end":p[s]+=h*(n&&c?-1:1);break}return p}const Fre=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=aP(c,r,l),h=r,p={},g=0;for(let m=0;m<a.length;m++){const{name:b,fn:y}=a[m],{x:v,y:x,data:S,reset:_}=await y({x:u,y:d,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:s,elements:{reference:e,floating:t}});u=v??u,d=x??d,p={...p,[b]:{...p[b],...S}},_&&g<=50&&(g++,typeof _=="object"&&(_.placement&&(h=_.placement),_.rects&&(c=_.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):_.rects),{x:u,y:d}=aP(c,h,l)),m=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:p}};async function $u(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:p=0}=Ni(t,e),g=O4(p),b=a[h?d==="floating"?"reference":"floating":d],y=vb(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=d==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),S=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},_=vb(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:l}):v);return{top:(y.top-_.top+g.top)/S.y,bottom:(_.bottom-y.bottom+g.bottom)/S.y,left:(y.left-_.left+g.left)/S.x,right:(_.right-y.right+g.right)/S.x}}const Lre=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Ni(e,t)||{};if(c==null)return{};const d=O4(u),h={x:n,y:r},p=F2(o),g=O2(p),m=await s.getDimensions(c),b=p==="y",y=b?"top":"left",v=b?"bottom":"right",x=b?"clientHeight":"clientWidth",S=i.reference[g]+i.reference[p]-h[p]-i.floating[g],_=h[p]-i.reference[p],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let C=E?E[x]:0;(!C||!await(s.isElement==null?void 0:s.isElement(E)))&&(C=a.floating[x]||i.floating[g]);const k=S/2-_/2,N=C/2-m[g]/2-1,M=ws(d[y],N),I=ws(d[v],N),D=M,j=C-m[g]-I,F=C/2-m[g]/2+k,T=lC(D,F,j),O=!l.arrow&&fd(o)!=null&&F!==T&&i.reference[g]/2-(F<D?M:I)-m[g]/2<0,$=O?F<D?F-D:F-j:0;return{[p]:h[p]+$,data:{[p]:T,centerOffset:F-T-$,...O&&{alignmentOffset:$}},reset:O}}}),$re=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...b}=Ni(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=Cs(o),v=ha(a),x=Cs(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=h||(x||!m?[yb(a)]:Are(a)),E=g!=="none";!h&&E&&_.push(...jre(a,m,g,S));const C=[a,..._],k=await $u(t,b),N=[];let M=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&N.push(k[y]),d){const F=Ire(o,s,S);N.push(k[F[0]],k[F[1]])}if(M=[...M,{placement:o,overflows:N}],!N.every(F=>F<=0)){var I,D;const F=(((I=i.flip)==null?void 0:I.index)||0)+1,T=C[F];if(T)return{data:{index:F,overflows:M},reset:{placement:T}};let O=(D=M.filter($=>$.overflows[0]<=0).sort(($,B)=>$.overflows[1]-B.overflows[1])[0])==null?void 0:D.placement;if(!O)switch(p){case"bestFit":{var j;const $=(j=M.filter(B=>{if(E){const z=ha(B.placement);return z===v||z==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(z=>z>0).reduce((z,A)=>z+A,0)]).sort((B,z)=>B[1]-z[1])[0])==null?void 0:j[0];$&&(O=$);break}case"initialPlacement":O=a;break}if(o!==O)return{reset:{placement:O}}}return{}}}};function lP(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function cP(e){return Mre.some(t=>e[t]>=0)}const zre=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Ni(e,t);switch(r){case"referenceHidden":{const i=await $u(t,{...o,elementContext:"reference"}),s=lP(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:cP(s)}}}case"escaped":{const i=await $u(t,{...o,altBoundary:!0}),s=lP(i,n.floating);return{data:{escapedOffsets:s,escaped:cP(s)}}}default:return{}}}}};async function Bre(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Cs(n),a=fd(n),l=ha(n)==="y",c=["left","top"].includes(s)?-1:1,u=i&&l?-1:1,d=Ni(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof g=="number"&&(p=a==="end"?g*-1:g),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}const Vre=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,l=await Bre(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:i+l.y,data:{...l,placement:s}}}}},Hre=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:b=>{let{x:y,y:v}=b;return{x:y,y:v}}},...l}=Ni(e,t),c={x:n,y:r},u=await $u(t,l),d=ha(Cs(o)),h=j2(d);let p=c[h],g=c[d];if(i){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",v=p+u[b],x=p-u[y];p=lC(v,p,x)}if(s){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",v=g+u[b],x=g-u[y];g=lC(v,g,x)}const m=a.fn({...t,[h]:p,[d]:g});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[h]:i,[d]:s}}}}}},Wre=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Ni(e,t),u={x:n,y:r},d=ha(o),h=j2(d);let p=u[h],g=u[d];const m=Ni(a,t),b=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const x=h==="y"?"height":"width",S=i.reference[h]-i.floating[x]+b.mainAxis,_=i.reference[h]+i.reference[x]-b.mainAxis;p<S?p=S:p>_&&(p=_)}if(c){var y,v;const x=h==="y"?"width":"height",S=["top","left"].includes(Cs(o)),_=i.reference[d]-i.floating[x]+(S&&((y=s.offset)==null?void 0:y[d])||0)+(S?0:b.crossAxis),E=i.reference[d]+i.reference[x]+(S?0:((v=s.offset)==null?void 0:v[d])||0)-(S?b.crossAxis:0);g<_?g=_:g>E&&(g=E)}return{[h]:p,[d]:g}}}},Ure=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:s,elements:a}=t,{apply:l=()=>{},...c}=Ni(e,t),u=await $u(t,c),d=Cs(o),h=fd(o),p=ha(o)==="y",{width:g,height:m}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=h===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(y=d,b=h==="end"?"top":"bottom");const v=m-u.top-u.bottom,x=g-u.left-u.right,S=ws(m-u[b],v),_=ws(g-u[y],x),E=!t.middlewareData.shift;let C=S,k=_;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),E&&!h){const M=Xn(u.left,0),I=Xn(u.right,0),D=Xn(u.top,0),j=Xn(u.bottom,0);p?k=g-2*(M!==0||I!==0?M+I:Xn(u.left,u.right)):C=m-2*(D!==0||j!==0?D+j:Xn(u.top,u.bottom))}await l({...t,availableWidth:k,availableHeight:C});const N=await s.getDimensions(a.floating);return g!==N.width||m!==N.height?{reset:{rects:!0}}:{}}}};function ly(){return typeof window<"u"}function hd(e){return F4(e)?(e.nodeName||"").toLowerCase():"#document"}function ro(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function $i(e){var t;return(t=(F4(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function F4(e){return ly()?e instanceof Node||e instanceof ro(e).Node:!1}function Qn(e){return ly()?e instanceof Element||e instanceof ro(e).Element:!1}function Mi(e){return ly()?e instanceof HTMLElement||e instanceof ro(e).HTMLElement:!1}function uP(e){return!ly()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ro(e).ShadowRoot}function yp(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Go(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function qre(e){return["table","td","th"].includes(hd(e))}function cy(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function L2(e){const t=$2(),n=Qn(e)?Go(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 Gre(e){let t=pa(e);for(;Mi(t)&&!zu(t);){if(L2(t))return t;if(cy(t))return null;t=pa(t)}return null}function $2(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function zu(e){return["html","body","#document"].includes(hd(e))}function Go(e){return ro(e).getComputedStyle(e)}function uy(e){return Qn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function pa(e){if(hd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||uP(e)&&e.host||$i(e);return uP(t)?t.host:t}function L4(e){const t=pa(e);return zu(t)?e.ownerDocument?e.ownerDocument.body:e.body:Mi(t)&&yp(t)?t:L4(t)}function ch(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=L4(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=ro(o);if(i){const a=uC(s);return t.concat(s,s.visualViewport||[],yp(o)?o:[],a&&n?ch(a):[])}return t.concat(o,ch(o,[],n))}function uC(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function $4(e){const t=Go(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Mi(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=lh(n)!==i||lh(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function z2(e){return Qn(e)?e:e.contextElement}function su(e){const t=z2(e);if(!Mi(t))return bi(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=$4(t);let s=(i?lh(n.width):n.width)/r,a=(i?lh(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const Yre=bi(0);function z4(e){const t=ro(e);return!$2()||!t.visualViewport?Yre:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Kre(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ro(e)?!1:t}function Wl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=z2(e);let s=bi(1);t&&(r?Qn(r)&&(s=su(r)):s=su(e));const a=Kre(i,n,r)?z4(i):bi(0);let l=(o.left+a.x)/s.x,c=(o.top+a.y)/s.y,u=o.width/s.x,d=o.height/s.y;if(i){const h=ro(i),p=r&&Qn(r)?ro(r):r;let g=h,m=uC(g);for(;m&&r&&p!==g;){const b=su(m),y=m.getBoundingClientRect(),v=Go(m),x=y.left+(m.clientLeft+parseFloat(v.paddingLeft))*b.x,S=y.top+(m.clientTop+parseFloat(v.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=x,c+=S,g=ro(m),m=uC(g)}}return vb({width:u,height:d,x:l,y:c})}function B2(e,t){const n=uy(e).scrollLeft;return t?t.left+n:Wl($i(e)).left+n}function B4(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:B2(e,r)),i=r.top+t.scrollTop;return{x:o,y:i}}function Xre(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=$i(r),a=t?cy(t.floating):!1;if(r===s||a&&i)return n;let l={scrollLeft:0,scrollTop:0},c=bi(1);const u=bi(0),d=Mi(r);if((d||!d&&!i)&&((hd(r)!=="body"||yp(s))&&(l=uy(r)),Mi(r))){const p=Wl(r);c=su(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=s&&!d&&!i?B4(s,l,!0):bi(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function Qre(e){return Array.from(e.getClientRects())}function Zre(e){const t=$i(e),n=uy(e),r=e.ownerDocument.body,o=Xn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Xn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+B2(e);const a=-n.scrollTop;return Go(r).direction==="rtl"&&(s+=Xn(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function Jre(e,t){const n=ro(e),r=$i(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,l=0;if(o){i=o.width,s=o.height;const c=$2();(!c||c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:i,height:s,x:a,y:l}}function eoe(e,t){const n=Wl(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Mi(e)?su(e):bi(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,l=o*i.x,c=r*i.y;return{width:s,height:a,x:l,y:c}}function dP(e,t,n){let r;if(t==="viewport")r=Jre(e,n);else if(t==="document")r=Zre($i(e));else if(Qn(t))r=eoe(t,n);else{const o=z4(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return vb(r)}function V4(e,t){const n=pa(e);return n===t||!Qn(n)||zu(n)?!1:Go(n).position==="fixed"||V4(n,t)}function toe(e,t){const n=t.get(e);if(n)return n;let r=ch(e,[],!1).filter(a=>Qn(a)&&hd(a)!=="body"),o=null;const i=Go(e).position==="fixed";let s=i?pa(e):e;for(;Qn(s)&&!zu(s);){const a=Go(s),l=L2(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||yp(s)&&!l&&V4(e,s))?r=r.filter(u=>u!==s):o=a,s=pa(s)}return t.set(e,r),r}function noe(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?cy(t)?[]:toe(t,this._c):[].concat(n),r],a=s[0],l=s.reduce((c,u)=>{const d=dP(t,u,o);return c.top=Xn(d.top,c.top),c.right=ws(d.right,c.right),c.bottom=ws(d.bottom,c.bottom),c.left=Xn(d.left,c.left),c},dP(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function roe(e){const{width:t,height:n}=$4(e);return{width:t,height:n}}function ooe(e,t,n){const r=Mi(t),o=$i(t),i=n==="fixed",s=Wl(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=bi(0);if(r||!r&&!i)if((hd(t)!=="body"||yp(o))&&(a=uy(t)),r){const h=Wl(t,!0,i,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&(l.x=B2(o));const c=o&&!r&&!i?B4(o,a):bi(0),u=s.left+a.scrollLeft-l.x-c.x,d=s.top+a.scrollTop-l.y-c.y;return{x:u,y:d,width:s.width,height:s.height}}function xx(e){return Go(e).position==="static"}function fP(e,t){if(!Mi(e)||Go(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return $i(e)===n&&(n=n.ownerDocument.body),n}function H4(e,t){const n=ro(e);if(cy(e))return n;if(!Mi(e)){let o=pa(e);for(;o&&!zu(o);){if(Qn(o)&&!xx(o))return o;o=pa(o)}return n}let r=fP(e,t);for(;r&&qre(r)&&xx(r);)r=fP(r,t);return r&&zu(r)&&xx(r)&&!L2(r)?n:r||Gre(e)||n}const ioe=async function(e){const t=this.getOffsetParent||H4,n=this.getDimensions,r=await n(e.floating);return{reference:ooe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function soe(e){return Go(e).direction==="rtl"}const aoe={convertOffsetParentRelativeRectToViewportRelativeRect:Xre,getDocumentElement:$i,getClippingRect:noe,getOffsetParent:H4,getElementRects:ioe,getClientRects:Qre,getDimensions:roe,getScale:su,isElement:Qn,isRTL:soe};function W4(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function loe(e,t){let n=null,r;const o=$i(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const c=e.getBoundingClientRect(),{left:u,top:d,width:h,height:p}=c;if(a||t(),!h||!p)return;const g=_m(d),m=_m(o.clientWidth-(u+h)),b=_m(o.clientHeight-(d+p)),y=_m(u),x={rootMargin:-g+"px "+-m+"px "+-b+"px "+-y+"px",threshold:Xn(0,ws(1,l))||1};let S=!0;function _(E){const C=E[0].intersectionRatio;if(C!==l){if(!S)return s();C?s(!1,C):r=setTimeout(()=>{s(!1,1e-7)},1e3)}C===1&&!W4(c,e.getBoundingClientRect())&&s(),S=!1}try{n=new IntersectionObserver(_,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,x)}n.observe(e)}return s(!0),i}function V2(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=z2(e),u=o||i?[...c?ch(c):[],...ch(t)]:[];u.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const d=c&&a?loe(c,n):null;let h=-1,p=null;s&&(p=new ResizeObserver(y=>{let[v]=y;v&&v.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let g,m=l?Wl(e):null;l&&b();function b(){const y=Wl(e);m&&!W4(m,y)&&n(),m=y,g=requestAnimationFrame(b)}return n(),()=>{var y;u.forEach(v=>{o&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),d==null||d(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const wx=$u,coe=Vre,uoe=Hre,doe=$re,foe=Ure,hoe=zre,hP=Lre,poe=Wre,moe=(e,t,n)=>{const r=new Map,o={platform:aoe,...n},i={...o.platform,_c:r};return Fre(e,t,{...o,platform:i})};var Dg=typeof document<"u"?R.useLayoutEffect:R.useEffect;function xb(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(!xb(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 i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!xb(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function U4(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function pP(e,t){const n=U4(e);return Math.round(t*n)/n}function Cx(e){const t=w.useRef(e);return Dg(()=>{t.current=e}),t}function H2(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=w.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=w.useState(r);xb(h,r)||p(r);const[g,m]=w.useState(null),[b,y]=w.useState(null),v=w.useCallback(B=>{B!==E.current&&(E.current=B,m(B))},[]),x=w.useCallback(B=>{B!==C.current&&(C.current=B,y(B))},[]),S=i||g,_=s||b,E=w.useRef(null),C=w.useRef(null),k=w.useRef(u),N=l!=null,M=Cx(l),I=Cx(o),D=Cx(c),j=w.useCallback(()=>{if(!E.current||!C.current)return;const B={placement:t,strategy:n,middleware:h};I.current&&(B.platform=I.current),moe(E.current,C.current,B).then(z=>{const A={...z,isPositioned:D.current!==!1};F.current&&!xb(k.current,A)&&(k.current=A,vs.flushSync(()=>{d(A)}))})},[h,t,n,I,D]);Dg(()=>{c===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,d(B=>({...B,isPositioned:!1})))},[c]);const F=w.useRef(!1);Dg(()=>(F.current=!0,()=>{F.current=!1}),[]),Dg(()=>{if(S&&(E.current=S),_&&(C.current=_),S&&_){if(M.current)return M.current(S,_,j);j()}},[S,_,j,M,N]);const T=w.useMemo(()=>({reference:E,floating:C,setReference:v,setFloating:x}),[v,x]),O=w.useMemo(()=>({reference:S,floating:_}),[S,_]),$=w.useMemo(()=>{const B={position:n,left:0,top:0};if(!O.floating)return B;const z=pP(O.floating,u.x),A=pP(O.floating,u.y);return a?{...B,transform:"translate("+z+"px, "+A+"px)",...U4(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:A}},[n,a,O.floating,u.x,u.y]);return w.useMemo(()=>({...u,update:j,refs:T,elements:O,floatingStyles:$}),[u,j,T,O,$])}const goe=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?hP({element:r.current,padding:o}).fn(n):{}:r?hP({element:r,padding:o}).fn(n):{}}}},dy=(e,t)=>({...coe(e),options:[e,t]}),W2=(e,t)=>({...uoe(e),options:[e,t]}),q4=(e,t)=>({...poe(e),options:[e,t]}),U2=(e,t)=>({...doe(e),options:[e,t]}),q2=(e,t)=>({...foe(e),options:[e,t]}),G4=(e,t)=>({...hoe(e),options:[e,t]}),Y4=(e,t)=>({...goe(e),options:[e,t]});var boe="Arrow",K4=w.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return f.jsx(_e.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:f.jsx("polygon",{points:"0,0 30,0 15,10"})})});K4.displayName=boe;var yoe=K4;function fy(e){const[t,n]=w.useState(void 0);return Vn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;s=c.inlineSize,a=c.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var G2="Popper",[X4,zi]=Pn(G2),[voe,Q4]=X4(G2),Z4=e=>{const{__scopePopper:t,children:n}=e,[r,o]=w.useState(null);return f.jsx(voe,{scope:t,anchor:r,onAnchorChange:o,children:n})};Z4.displayName=G2;var J4="PopperAnchor",e3=w.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=Q4(J4,n),s=w.useRef(null),a=Ve(t,s);return w.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:f.jsx(_e.div,{...o,ref:a})});e3.displayName=J4;var Y2="PopperContent",[xoe,woe]=X4(Y2),t3=w.forwardRef((e,t)=>{var q,Y,K,Z,ee,Q;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:g,...m}=e,b=Q4(Y2,n),[y,v]=w.useState(null),x=Ve(t,oe=>v(oe)),[S,_]=w.useState(null),E=fy(S),C=(E==null?void 0:E.width)??0,k=(E==null?void 0:E.height)??0,N=r+(i!=="center"?"-"+i:""),M=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},I=Array.isArray(c)?c:[c],D=I.length>0,j={padding:M,boundary:I.filter(Soe),altBoundary:D},{refs:F,floatingStyles:T,placement:O,isPositioned:$,middlewareData:B}=H2({strategy:"fixed",placement:N,whileElementsMounted:(...oe)=>V2(...oe,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[dy({mainAxis:o+k,alignmentAxis:s}),l&&W2({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?q4():void 0,...j}),l&&U2({...j}),q2({...j,apply:({elements:oe,rects:te,availableWidth:ce,availableHeight:ue})=>{const{width:Re,height:ve}=te.reference,we=oe.floating.style;we.setProperty("--radix-popper-available-width",`${ce}px`),we.setProperty("--radix-popper-available-height",`${ue}px`),we.setProperty("--radix-popper-anchor-width",`${Re}px`),we.setProperty("--radix-popper-anchor-height",`${ve}px`)}}),S&&Y4({element:S,padding:a}),Eoe({arrowWidth:C,arrowHeight:k}),h&&G4({strategy:"referenceHidden",...j})]}),[z,A]=o3(O),W=Mn(g);Vn(()=>{$&&(W==null||W())},[$,W]);const L=(q=B.arrow)==null?void 0:q.x,P=(Y=B.arrow)==null?void 0:Y.y,H=((K=B.arrow)==null?void 0:K.centerOffset)!==0,[V,G]=w.useState();return Vn(()=>{y&&G(window.getComputedStyle(y).zIndex)},[y]),f.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:$?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[(Z=B.transformOrigin)==null?void 0:Z.x,(ee=B.transformOrigin)==null?void 0:ee.y].join(" "),...((Q=B.hide)==null?void 0:Q.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:f.jsx(xoe,{scope:n,placedSide:z,onArrowChange:_,arrowX:L,arrowY:P,shouldHideArrow:H,children:f.jsx(_e.div,{"data-side":z,"data-align":A,...m,ref:x,style:{...m.style,animation:$?void 0:"none"}})})})});t3.displayName=Y2;var n3="PopperArrow",Coe={top:"bottom",right:"left",bottom:"top",left:"right"},r3=w.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=woe(n3,r),s=Coe[i.placedSide];return f.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:f.jsx(yoe,{...o,ref:n,style:{...o.style,display:"block"}})})});r3.displayName=n3;function Soe(e){return e!==null}var Eoe=e=>({name:"transformOrigin",options:e,fn(t){var b,y,v;const{placement:n,rects:r,middlewareData:o}=t,s=((b=o.arrow)==null?void 0:b.centerOffset)!==0,a=s?0:e.arrowWidth,l=s?0:e.arrowHeight,[c,u]=o3(n),d={start:"0%",center:"50%",end:"100%"}[u],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((v=o.arrow)==null?void 0:v.y)??0)+l/2;let g="",m="";return c==="bottom"?(g=s?d:`${h}px`,m=`${-l}px`):c==="top"?(g=s?d:`${h}px`,m=`${r.floating.height+l}px`):c==="right"?(g=`${-l}px`,m=s?d:`${p}px`):c==="left"&&(g=`${r.floating.width+l}px`,m=s?d:`${p}px`),{data:{x:g,y:m}}}});function o3(e){const[t,n="center"]=e.split("-");return[t,n]}var vp=Z4,pd=e3,xp=t3,wp=r3,_oe="Portal",pc=w.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,i]=w.useState(!1);Vn(()=>i(!0),[]);const s=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return s?rn.createPortal(f.jsx(_e.div,{...r,ref:t}),s):null});pc.displayName=_oe;var i3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(koe);if(i){const s=i.props.children,a=o.map(l=>l===i?w.Children.count(s)>1?w.Children.only(null):w.isValidElement(s)?s.props.children:null:l);return f.jsx(dC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(dC,{...r,ref:t,children:n})});i3.displayName="Slot";var dC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=Moe(n),i=Noe(r,n.props);return n.type!==w.Fragment&&(i.ref=t?vr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});dC.displayName="SlotClone";var Roe=({children:e})=>f.jsx(f.Fragment,{children:e});function koe(e){return w.isValidElement(e)&&e.type===Roe}function Noe(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Moe(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)}var K2="Popover",[s3,cLe]=Pn(K2,[zi]),Cp=zi(),[Poe,Pa]=s3(K2),a3=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=Cp(t),l=w.useRef(null),[c,u]=w.useState(!1),[d=!1,h]=or({prop:r,defaultProp:o,onChange:i});return f.jsx(vp,{...a,children:f.jsx(Poe,{scope:t,contentId:_n(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:w.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:c,onCustomAnchorAdd:w.useCallback(()=>u(!0),[]),onCustomAnchorRemove:w.useCallback(()=>u(!1),[]),modal:s,children:n})})};a3.displayName=K2;var l3="PopoverAnchor",Doe=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Pa(l3,n),i=Cp(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return w.useEffect(()=>(s(),()=>a()),[s,a]),f.jsx(pd,{...i,...r,ref:t})});Doe.displayName=l3;var c3="PopoverTrigger",u3=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Pa(c3,n),i=Cp(n),s=Ve(t,o.triggerRef),a=f.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":m3(o.open),...r,ref:s,onClick:fe(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:f.jsx(pd,{asChild:!0,...i,children:a})});u3.displayName=c3;var X2="PopoverPortal",[Ioe,Aoe]=s3(X2,{forceMount:void 0}),d3=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Pa(X2,t);return f.jsx(Ioe,{scope:t,forceMount:n,children:f.jsx(fn,{present:n||i.open,children:f.jsx(pc,{asChild:!0,container:o,children:r})})})};d3.displayName=X2;var Bu="PopoverContent",f3=w.forwardRef((e,t)=>{const n=Aoe(Bu,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Pa(Bu,e.__scopePopover);return f.jsx(fn,{present:r||i.open,children:i.modal?f.jsx(Toe,{...o,ref:t}):f.jsx(joe,{...o,ref:t})})});f3.displayName=Bu;var Toe=w.forwardRef((e,t)=>{const n=Pa(Bu,e.__scopePopover),r=w.useRef(null),o=Ve(t,r),i=w.useRef(!1);return w.useEffect(()=>{const s=r.current;if(s)return ld(s)},[]),f.jsx(fc,{as:i3,allowPinchZoom:!0,children:f.jsx(h3,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fe(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:fe(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),joe=w.forwardRef((e,t)=>{const n=Pa(Bu,e.__scopePopover),r=w.useRef(!1),o=w.useRef(!1);return f.jsx(h3,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,a;(s=e.onCloseAutoFocus)==null||s.call(e,i),i.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),h3=w.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,h=Pa(Bu,n),p=Cp(n);return ay(),f.jsx(bp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:f.jsx(hc,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:f.jsx(xp,{"data-state":m3(h.open),role:"dialog",id:h.contentId,...p,...d,ref:t,style:{...d.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)"}})})})}),p3="PopoverClose",Ooe=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Pa(p3,n);return f.jsx(_e.button,{type:"button",...r,ref:t,onClick:fe(e.onClick,()=>o.onOpenChange(!1))})});Ooe.displayName=p3;var Foe="PopoverArrow",Loe=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Cp(n);return f.jsx(wp,{...o,...r,ref:t})});Loe.displayName=Foe;function m3(e){return e?"open":"closed"}var $oe=a3,zoe=u3,Boe=d3,hy=f3;const Da=$oe,Ia=zoe,ks=w.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>f.jsx(Boe,{children:f.jsx(Qo,{children:f.jsx(hy,{ref:o,align:t,sideOffset:n,className:ie("z-49 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",e),...r})})}));ks.displayName=hy.displayName;function fC(e,[t,n]){return Math.min(n,Math.max(t,e))}var g3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(Hoe);if(i){const s=i.props.children,a=o.map(l=>l===i?w.Children.count(s)>1?w.Children.only(null):w.isValidElement(s)?s.props.children:null:l);return f.jsx(hC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(hC,{...r,ref:t,children:n})});g3.displayName="Slot";var hC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=Uoe(n),i=Woe(r,n.props);return n.type!==w.Fragment&&(i.ref=t?vr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});hC.displayName="SlotClone";var Voe=({children:e})=>f.jsx(f.Fragment,{children:e});function Hoe(e){return w.isValidElement(e)&&e.type===Voe}function Woe(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Uoe(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 py(e){const t=w.useRef({value:e,previous:e});return w.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var qoe="VisuallyHidden",Q2=w.forwardRef((e,t)=>f.jsx(_e.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}}));Q2.displayName=qoe;var Goe=Q2,Yoe=[" ","Enter","ArrowUp","ArrowDown"],Koe=[" ","Enter"],Sp="Select",[my,gy,Xoe]=D0(Sp),[md,uLe]=Pn(Sp,[Xoe,zi]),by=zi(),[Qoe,Aa]=md(Sp),[Zoe,Joe]=md(Sp),b3=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:d,disabled:h,required:p,form:g}=e,m=by(t),[b,y]=w.useState(null),[v,x]=w.useState(null),[S,_]=w.useState(!1),E=sc(c),[C=!1,k]=or({prop:r,defaultProp:o,onChange:i}),[N,M]=or({prop:s,defaultProp:a,onChange:l}),I=w.useRef(null),D=b?g||!!b.closest("form"):!0,[j,F]=w.useState(new Set),T=Array.from(j).map(O=>O.props.value).join(";");return f.jsx(vp,{...m,children:f.jsxs(Qoe,{required:p,scope:t,trigger:b,onTriggerChange:y,valueNode:v,onValueNodeChange:x,valueNodeHasChildren:S,onValueNodeHasChildrenChange:_,contentId:_n(),value:N,onValueChange:M,open:C,onOpenChange:k,dir:E,triggerPointerDownPosRef:I,disabled:h,children:[f.jsx(my.Provider,{scope:t,children:f.jsx(Zoe,{scope:e.__scopeSelect,onNativeOptionAdd:w.useCallback(O=>{F($=>new Set($).add(O))},[]),onNativeOptionRemove:w.useCallback(O=>{F($=>{const B=new Set($);return B.delete(O),B})},[]),children:n})}),D?f.jsxs(H3,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:N,onChange:O=>M(O.target.value),disabled:h,form:g,children:[N===void 0?f.jsx("option",{value:""}):null,Array.from(j)]},T):null]})})};b3.displayName=Sp;var y3="SelectTrigger",v3=w.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=by(n),s=Aa(y3,n),a=s.disabled||r,l=Ve(t,s.onTriggerChange),c=gy(n),u=w.useRef("touch"),[d,h,p]=W3(m=>{const b=c().filter(x=>!x.disabled),y=b.find(x=>x.value===s.value),v=U3(b,m,y);v!==void 0&&s.onValueChange(v.value)}),g=m=>{a||(s.onOpenChange(!0),p()),m&&(s.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return f.jsx(pd,{asChild:!0,...i,children:f.jsx(_e.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:a,"data-disabled":a?"":void 0,"data-placeholder":V3(s.value)?"":void 0,...o,ref:l,onClick:fe(o.onClick,m=>{m.currentTarget.focus(),u.current!=="mouse"&&g(m)}),onPointerDown:fe(o.onPointerDown,m=>{u.current=m.pointerType;const b=m.target;b.hasPointerCapture(m.pointerId)&&b.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(g(m),m.preventDefault())}),onKeyDown:fe(o.onKeyDown,m=>{const b=d.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&h(m.key),!(b&&m.key===" ")&&Yoe.includes(m.key)&&(g(),m.preventDefault())})})})});v3.displayName=y3;var x3="SelectValue",w3=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:s="",...a}=e,l=Aa(x3,n),{onValueNodeHasChildrenChange:c}=l,u=i!==void 0,d=Ve(t,l.onValueNodeChange);return Vn(()=>{c(u)},[c,u]),f.jsx(_e.span,{...a,ref:d,style:{pointerEvents:"none"},children:V3(l.value)?f.jsx(f.Fragment,{children:s}):i})});w3.displayName=x3;var eie="SelectIcon",C3=w.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return f.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});C3.displayName=eie;var tie="SelectPortal",S3=e=>f.jsx(pc,{asChild:!0,...e});S3.displayName=tie;var Ul="SelectContent",E3=w.forwardRef((e,t)=>{const n=Aa(Ul,e.__scopeSelect),[r,o]=w.useState();if(Vn(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?vs.createPortal(f.jsx(_3,{scope:e.__scopeSelect,children:f.jsx(my.Slot,{scope:e.__scopeSelect,children:f.jsx("div",{children:e.children})})}),i):null}return f.jsx(R3,{...e,ref:t})});E3.displayName=Ul;var To=10,[_3,Ta]=md(Ul),nie="SelectContentImpl",R3=w.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:g,hideWhenDetached:m,avoidCollisions:b,...y}=e,v=Aa(Ul,n),[x,S]=w.useState(null),[_,E]=w.useState(null),C=Ve(t,q=>S(q)),[k,N]=w.useState(null),[M,I]=w.useState(null),D=gy(n),[j,F]=w.useState(!1),T=w.useRef(!1);w.useEffect(()=>{if(x)return ld(x)},[x]),ay();const O=w.useCallback(q=>{const[Y,...K]=D().map(Q=>Q.ref.current),[Z]=K.slice(-1),ee=document.activeElement;for(const Q of q)if(Q===ee||(Q==null||Q.scrollIntoView({block:"nearest"}),Q===Y&&_&&(_.scrollTop=0),Q===Z&&_&&(_.scrollTop=_.scrollHeight),Q==null||Q.focus(),document.activeElement!==ee))return},[D,_]),$=w.useCallback(()=>O([k,x]),[O,k,x]);w.useEffect(()=>{j&&$()},[j,$]);const{onOpenChange:B,triggerPointerDownPosRef:z}=v;w.useEffect(()=>{if(x){let q={x:0,y:0};const Y=Z=>{var ee,Q;q={x:Math.abs(Math.round(Z.pageX)-(((ee=z.current)==null?void 0:ee.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((Q=z.current)==null?void 0:Q.y)??0))}},K=Z=>{q.x<=10&&q.y<=10?Z.preventDefault():x.contains(Z.target)||B(!1),document.removeEventListener("pointermove",Y),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",Y),document.addEventListener("pointerup",K,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Y),document.removeEventListener("pointerup",K,{capture:!0})}}},[x,B,z]),w.useEffect(()=>{const q=()=>B(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[B]);const[A,W]=W3(q=>{const Y=D().filter(ee=>!ee.disabled),K=Y.find(ee=>ee.ref.current===document.activeElement),Z=U3(Y,q,K);Z&&setTimeout(()=>Z.ref.current.focus())}),L=w.useCallback((q,Y,K)=>{const Z=!T.current&&!K;(v.value!==void 0&&v.value===Y||Z)&&(N(q),Z&&(T.current=!0))},[v.value]),P=w.useCallback(()=>x==null?void 0:x.focus(),[x]),H=w.useCallback((q,Y,K)=>{const Z=!T.current&&!K;(v.value!==void 0&&v.value===Y||Z)&&I(q)},[v.value]),V=r==="popper"?pC:k3,G=V===pC?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:g,hideWhenDetached:m,avoidCollisions:b}:{};return f.jsx(_3,{scope:n,content:x,viewport:_,onViewportChange:E,itemRefCallback:L,selectedItem:k,onItemLeave:P,itemTextRefCallback:H,focusSelectedItem:$,selectedItemText:M,position:r,isPositioned:j,searchRef:A,children:f.jsx(fc,{as:g3,allowPinchZoom:!0,children:f.jsx(bp,{asChild:!0,trapped:v.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:fe(o,q=>{var Y;(Y=v.trigger)==null||Y.focus({preventScroll:!0}),q.preventDefault()}),children:f.jsx(hc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:f.jsx(V,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:q=>q.preventDefault(),...y,...G,onPlaced:()=>F(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:fe(y.onKeyDown,q=>{const Y=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!Y&&q.key.length===1&&W(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let Z=D().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);if(["ArrowUp","End"].includes(q.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const ee=q.target,Q=Z.indexOf(ee);Z=Z.slice(Q+1)}setTimeout(()=>O(Z)),q.preventDefault()}})})})})})})});R3.displayName=nie;var rie="SelectItemAlignedPosition",k3=w.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=Aa(Ul,n),s=Ta(Ul,n),[a,l]=w.useState(null),[c,u]=w.useState(null),d=Ve(t,C=>u(C)),h=gy(n),p=w.useRef(!1),g=w.useRef(!0),{viewport:m,selectedItem:b,selectedItemText:y,focusSelectedItem:v}=s,x=w.useCallback(()=>{if(i.trigger&&i.valueNode&&a&&c&&m&&b&&y){const C=i.trigger.getBoundingClientRect(),k=c.getBoundingClientRect(),N=i.valueNode.getBoundingClientRect(),M=y.getBoundingClientRect();if(i.dir!=="rtl"){const ee=M.left-k.left,Q=N.left-ee,oe=C.left-Q,te=C.width+oe,ce=Math.max(te,k.width),ue=window.innerWidth-To,Re=fC(Q,[To,Math.max(To,ue-ce)]);a.style.minWidth=te+"px",a.style.left=Re+"px"}else{const ee=k.right-M.right,Q=window.innerWidth-N.right-ee,oe=window.innerWidth-C.right-Q,te=C.width+oe,ce=Math.max(te,k.width),ue=window.innerWidth-To,Re=fC(Q,[To,Math.max(To,ue-ce)]);a.style.minWidth=te+"px",a.style.right=Re+"px"}const I=h(),D=window.innerHeight-To*2,j=m.scrollHeight,F=window.getComputedStyle(c),T=parseInt(F.borderTopWidth,10),O=parseInt(F.paddingTop,10),$=parseInt(F.borderBottomWidth,10),B=parseInt(F.paddingBottom,10),z=T+O+j+B+$,A=Math.min(b.offsetHeight*5,z),W=window.getComputedStyle(m),L=parseInt(W.paddingTop,10),P=parseInt(W.paddingBottom,10),H=C.top+C.height/2-To,V=D-H,G=b.offsetHeight/2,q=b.offsetTop+G,Y=T+O+q,K=z-Y;if(Y<=H){const ee=I.length>0&&b===I[I.length-1].ref.current;a.style.bottom="0px";const Q=c.clientHeight-m.offsetTop-m.offsetHeight,oe=Math.max(V,G+(ee?P:0)+Q+$),te=Y+oe;a.style.height=te+"px"}else{const ee=I.length>0&&b===I[0].ref.current;a.style.top="0px";const oe=Math.max(H,T+m.offsetTop+(ee?L:0)+G)+K;a.style.height=oe+"px",m.scrollTop=Y-H+m.offsetTop}a.style.margin=`${To}px 0`,a.style.minHeight=A+"px",a.style.maxHeight=D+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,i.trigger,i.valueNode,a,c,m,b,y,i.dir,r]);Vn(()=>x(),[x]);const[S,_]=w.useState();Vn(()=>{c&&_(window.getComputedStyle(c).zIndex)},[c]);const E=w.useCallback(C=>{C&&g.current===!0&&(x(),v==null||v(),g.current=!1)},[x,v]);return f.jsx(iie,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:E,children:f.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:f.jsx(_e.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});k3.displayName=rie;var oie="SelectPopperPosition",pC=w.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=To,...i}=e,s=by(n);return f.jsx(xp,{...s,...i,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...i.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)"}})});pC.displayName=oie;var[iie,Z2]=md(Ul,{}),mC="SelectViewport",N3=w.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=Ta(mC,n),s=Z2(mC,n),a=Ve(t,i.onViewportChange),l=w.useRef(0);return f.jsxs(f.Fragment,{children:[f.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}),f.jsx(my.Slot,{scope:n,children:f.jsx(_e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,c=>{const u=c.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:h}=s;if(h!=null&&h.current&&d){const p=Math.abs(l.current-u.scrollTop);if(p>0){const g=window.innerHeight-To*2,m=parseFloat(d.style.minHeight),b=parseFloat(d.style.height),y=Math.max(m,b);if(y<g){const v=y+p,x=Math.min(g,v),S=v-x;d.style.height=x+"px",d.style.bottom==="0px"&&(u.scrollTop=S>0?S:0,d.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});N3.displayName=mC;var M3="SelectGroup",[sie,aie]=md(M3),P3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_n();return f.jsx(sie,{scope:n,id:o,children:f.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});P3.displayName=M3;var D3="SelectLabel",I3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=aie(D3,n);return f.jsx(_e.div,{id:o.id,...r,ref:t})});I3.displayName=D3;var wb="SelectItem",[lie,A3]=md(wb),T3=w.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...s}=e,a=Aa(wb,n),l=Ta(wb,n),c=a.value===r,[u,d]=w.useState(i??""),[h,p]=w.useState(!1),g=Ve(t,v=>{var x;return(x=l.itemRefCallback)==null?void 0:x.call(l,v,r,o)}),m=_n(),b=w.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> 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 f.jsx(lie,{scope:n,value:r,disabled:o,textId:m,isSelected:c,onItemTextChange:w.useCallback(v=>{d(x=>x||((v==null?void 0:v.textContent)??"").trim())},[]),children:f.jsx(my.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:f.jsx(_e.div,{role:"option","aria-labelledby":m,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...s,ref:g,onFocus:fe(s.onFocus,()=>p(!0)),onBlur:fe(s.onBlur,()=>p(!1)),onClick:fe(s.onClick,()=>{b.current!=="mouse"&&y()}),onPointerUp:fe(s.onPointerUp,()=>{b.current==="mouse"&&y()}),onPointerDown:fe(s.onPointerDown,v=>{b.current=v.pointerType}),onPointerMove:fe(s.onPointerMove,v=>{var x;b.current=v.pointerType,o?(x=l.onItemLeave)==null||x.call(l):b.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fe(s.onPointerLeave,v=>{var x;v.currentTarget===document.activeElement&&((x=l.onItemLeave)==null||x.call(l))}),onKeyDown:fe(s.onKeyDown,v=>{var S;((S=l.searchRef)==null?void 0:S.current)!==""&&v.key===" "||(Koe.includes(v.key)&&y(),v.key===" "&&v.preventDefault())})})})})});T3.displayName=wb;var rf="SelectItemText",j3=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,s=Aa(rf,n),a=Ta(rf,n),l=A3(rf,n),c=Joe(rf,n),[u,d]=w.useState(null),h=Ve(t,y=>d(y),l.onItemTextChange,y=>{var v;return(v=a.itemTextRefCallback)==null?void 0:v.call(a,y,l.value,l.disabled)}),p=u==null?void 0:u.textContent,g=w.useMemo(()=>f.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:m,onNativeOptionRemove:b}=c;return Vn(()=>(m(g),()=>b(g)),[m,b,g]),f.jsxs(f.Fragment,{children:[f.jsx(_e.span,{id:l.textId,...i,ref:h}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?vs.createPortal(i.children,s.valueNode):null]})});j3.displayName=rf;var O3="SelectItemIndicator",F3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return A3(O3,n).isSelected?f.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});F3.displayName=O3;var gC="SelectScrollUpButton",L3=w.forwardRef((e,t)=>{const n=Ta(gC,e.__scopeSelect),r=Z2(gC,e.__scopeSelect),[o,i]=w.useState(!1),s=Ve(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;i(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?f.jsx(z3,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});L3.displayName=gC;var bC="SelectScrollDownButton",$3=w.forwardRef((e,t)=>{const n=Ta(bC,e.__scopeSelect),r=Z2(bC,e.__scopeSelect),[o,i]=w.useState(!1),s=Ve(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<c;i(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?f.jsx(z3,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});$3.displayName=bC;var z3=w.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=Ta("SelectScrollButton",n),s=w.useRef(null),a=gy(n),l=w.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return w.useEffect(()=>()=>l(),[l]),Vn(()=>{var u;const c=a().find(d=>d.ref.current===document.activeElement);(u=c==null?void 0:c.ref.current)==null||u.scrollIntoView({block:"nearest"})},[a]),f.jsx(_e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:fe(o.onPointerMove,()=>{var c;(c=i.onItemLeave)==null||c.call(i),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{l()})})}),cie="SelectSeparator",B3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return f.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});B3.displayName=cie;var yC="SelectArrow",uie=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=by(n),i=Aa(yC,n),s=Ta(yC,n);return i.open&&s.position==="popper"?f.jsx(wp,{...o,...r,ref:t}):null});uie.displayName=yC;function V3(e){return e===""||e===void 0}var H3=w.forwardRef((e,t)=>{const{value:n,...r}=e,o=w.useRef(null),i=Ve(t,o),s=py(n);return w.useEffect(()=>{const a=o.current,l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==n&&u){const d=new Event("change",{bubbles:!0});u.call(a,n),a.dispatchEvent(d)}},[s,n]),f.jsx(Q2,{asChild:!0,children:f.jsx("select",{...r,ref:i,defaultValue:n})})});H3.displayName="BubbleSelect";function W3(e){const t=Mn(e),n=w.useRef(""),r=w.useRef(0),o=w.useCallback(s=>{const a=n.current+s;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),i=w.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return w.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function U3(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=die(e,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==n));const l=s.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function die(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fie=b3,q3=v3,hie=w3,pie=C3,mie=S3,G3=E3,gie=N3,bie=P3,Y3=I3,K3=T3,yie=j3,vie=F3,X3=L3,Q3=$3,Z3=B3;const Pt=fie,Ws=bie,Dt=hie,Ct=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(q3,{ref:r,className:ie("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-0 focus:ring-ring focus:ring-offset-0 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,f.jsx(pie,{asChild:!0,children:f.jsx(sa,{className:"h-4 w-4 opacity-50"})})]}));Ct.displayName=q3.displayName;const J3=w.forwardRef(({className:e,...t},n)=>f.jsx(X3,{ref:n,className:ie("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(vf,{className:"h-4 w-4"})}));J3.displayName=X3.displayName;const eL=w.forwardRef(({className:e,...t},n)=>f.jsx(Q3,{ref:n,className:ie("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(sa,{className:"h-4 w-4"})}));eL.displayName=Q3.displayName;const St=w.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>f.jsx(mie,{children:f.jsx(Qo,{children:f.jsxs(G3,{ref:o,className:ie("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",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:[f.jsx(J3,{}),f.jsx(gie,{className:ie("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),f.jsx(eL,{})]})})}));St.displayName=G3.displayName;const rs=w.forwardRef(({className:e,...t},n)=>f.jsx(Y3,{ref:n,className:ie("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));rs.displayName=Y3.displayName;const ye=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(K3,{ref:r,className:ie("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(vie,{children:f.jsx(ao,{className:"h-4 w-4"})})}),f.jsx(yie,{children:t})]}));ye.displayName=K3.displayName;const Ef=w.forwardRef(({className:e,...t},n)=>f.jsx(Z3,{ref:n,className:ie("-mx-1 my-1 h-px bg-muted",e),...t}));Ef.displayName=Z3.displayName;const yr=w.forwardRef(({className:e,type:t,...n},r)=>f.jsx("input",{type:t,className:ie("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));yr.displayName="Input";var xie="Label",J2=w.forwardRef((e,t)=>f.jsx(_e.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));J2.displayName=xie;var tL=J2;const wie=X0("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),de=w.forwardRef(({className:e,...t},n)=>f.jsx(tL,{ref:n,className:ie(wie(),e),...t}));de.displayName=tL.displayName;function Cie({step:e,hierarchyId:t,stepIndex:n,onUpdateStep:r,open:o,onOpenChange:i,trigger:s}){return f.jsxs(Da,{open:o,onOpenChange:i,children:[f.jsx(Ia,{asChild:!0,children:s}),f.jsx(ks,{className:"z-50 w-80",align:"start",children:f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Chart Type"}),f.jsxs(Pt,{value:e.preferredChartType||"bar",onValueChange:a=>{r(t,n,{preferredChartType:a})},children:[f.jsx(Ct,{className:"h-8",children:f.jsx(Dt,{})}),f.jsxs(St,{children:[f.jsx(ye,{value:"bar",children:"Bar Chart"}),f.jsx(ye,{value:"pie",children:"Pie Chart"}),f.jsx(ye,{value:"line",children:"Line Chart"}),f.jsx(ye,{value:"donut",children:"Donut Chart"}),f.jsx(ye,{value:"table",children:"Table"}),f.jsx(ye,{value:"metric",children:"Metric"})]})]})]}),f.jsxs("div",{children:[f.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Step Label"}),f.jsx(yr,{value:e.label||"",onChange:a=>r(t,n,{label:a.target.value}),placeholder:"Custom drill label",className:"h-8"})]}),f.jsxs("div",{children:[f.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Breadcrumb Label Template"}),f.jsx(yr,{value:e.breadcrumbLabelTemplate||"",onChange:a=>r(t,n,{breadcrumbLabelTemplate:a.target.value}),placeholder:"e.g., 'Region: {{value}}'",className:"h-8"})]}),f.jsx("div",{className:"flex items-center gap-4",children:f.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[f.jsx("input",{type:"checkbox",checked:e.retainFilters!==!1,onChange:a=>r(t,n,{retainFilters:a.target.checked}),className:"rounded"}),"Retain filters when drilling"]})}),f.jsx("div",{className:"flex justify-end",children:f.jsx(Ee,{size:"sm",variant:"outline",onClick:()=>i(!1),children:"Done"})})]})})]})}function Sie({field:e,step:t,stepIndex:n,hierarchyId:r,onUpdateStep:o,onRemoveStep:i,isFirstField:s=!1}){const[a,l]=R.useState(!1),{attributes:c,listeners:u,setNodeRef:d,transform:h,transition:p,isDragging:g}=A2({id:`${r}-${e.id}-${n}`,disabled:!1}),m={transform:ki.Transform.toString(h),transition:p,opacity:g?.8:1,zIndex:g?1e3:1};return f.jsx("div",{ref:d,style:m,className:`relative ${a?"z-[9998]":""}`,...c,children:f.jsx(Cie,{step:t,hierarchyId:r,stepIndex:n,onUpdateStep:o,open:a,onOpenChange:l,trigger:f.jsxs("div",{className:`flex cursor-pointer items-center gap-2 rounded-lg p-2 transition-colors ${s?"bg-muted hover:bg-muted/50":"bg-blue-100 hover:bg-blue-200 dark:bg-blue-900/50 dark:hover:bg-blue-900/70"} ${g?"shadow-lg ring-2 ring-blue-300 dark:ring-blue-600":""}`,...u,onClick:b=>{b.stopPropagation(),l(y=>!y)},children:[f.jsxs("div",{className:"pointer-events-none flex items-center gap-2",children:[f.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:e.label}),t.preferredChartType&&t.preferredChartType!=="bar"&&f.jsx("span",{className:"whitespace-nowrap rounded bg-purple-100 px-1 py-0.5 text-xs text-purple-700 dark:bg-purple-900/50 dark:text-purple-300",children:t.preferredChartType}),t.linkedInsightId&&f.jsx("span",{className:"whitespace-nowrap rounded bg-green-100 px-1 py-0.5 text-xs text-green-700 dark:bg-green-900/50 dark:text-green-300",children:"📊"})]}),f.jsx("button",{className:`pointer-events-auto ml-1 text-xs hover:text-red-800 dark:hover:text-red-400 ${s?"text-muted-foreground":"text-blue-600 dark:text-blue-400"}`,onClick:b=>{b.stopPropagation(),i(r,n)},children:"×"})]})})})}function Eie(e){return{sensors:R2(sh(pp,{activationConstraint:{distance:5}}),sh(hp,{coordinateGetter:T2})),handleStepDragEnd:(r,o)=>{const{active:i,over:s}=r;if(!s||i.id===s.id)return;const a=i.id.replace(`${o.id}-`,""),l=s.id.replace(`${o.id}-`,""),c=o.steps.findIndex(d=>d.field.id===a),u=o.steps.findIndex(d=>d.field.id===l);if(c!==-1&&u!==-1&&c!==u){const d=gp(o.steps,c,u);e(o.id,{steps:d})}}}}function _ie({hierarchy:e,onUpdateStep:t,onRemoveStep:n,onUpdateHierarchy:r}){const{sensors:o}=Eie(r),[i,s]=R.useState(null),a=e.steps.filter(h=>h&&h.field&&h.field.id),c=a.map(h=>h.field).map((h,p)=>`${e.id}-${h.id}-${p}`),u=h=>{const p=h.active.id,g=Number.parseInt(p.split("-").pop()||"0"),m=a[g],b=m==null?void 0:m.field;s(b||null)},d=h=>{s(null);const{active:p,over:g}=h;if(!g||p.id===g.id)return;const m=Number.parseInt(p.id.split("-").pop()||"0"),b=Number.parseInt(g.id.split("-").pop()||"0");if(m!==b&&m<a.length&&b<a.length){const y=[...e.steps],[v]=y.splice(m,1);y.splice(b,0,v),r(e.id,{steps:y})}};return a.length===0?f.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:f.jsx("div",{className:"rounded-lg border bg-muted/50 p-2 text-sm text-muted-foreground",children:"No drill steps configured. Add steps to create a drill hierarchy."})}):f.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:f.jsxs(D2,{sensors:o,collisionDetection:k2,onDragStart:u,onDragEnd:d,children:[f.jsx(I2,{items:c,strategy:ere,children:f.jsx("div",{className:"flex flex-wrap items-center gap-2",style:{minHeight:"40px"},children:a.map((h,p)=>{if(!h||!h.field||!h.field.id)return null;const g=[];p>0&&g.push(f.jsx(_i,{className:"pointer-events-none h-4 w-4 text-gray-400"},`arrow-${p}`));const m=p===0,b=p===a.length-1;return g.push(f.jsx(Sie,{field:h.field,step:h,stepIndex:p,hierarchyId:e.id,onUpdateStep:t,onRemoveStep:n,isFirstField:m,isLastField:b},`field-${h.field.id}-${p}`)),g})})}),typeof window<"u"&&rn.createPortal(f.jsx(R4,{className:"semaphor-scope",style:{zIndex:9999},children:i?f.jsx("div",{className:"flex items-center gap-2 rounded-lg border-2 border-blue-300 bg-blue-200 p-2 shadow-lg dark:border-blue-600 dark:bg-blue-900/70",children:f.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:i.label})}):null}),document.body)]})})}var mP=1,Rie=.9,kie=.8,Nie=.17,Sx=.1,Ex=.999,Mie=.9999,Pie=.99,Die=/[\\\/_+.#"@\[\(\{&]/,Iie=/[\\\/_+.#"@\[\(\{&]/g,Aie=/[\s-]/,nL=/[\s-]/g;function vC(e,t,n,r,o,i,s){if(i===t.length)return o===e.length?mP:Pie;var a=`${o},${i}`;if(s[a]!==void 0)return s[a];for(var l=r.charAt(i),c=n.indexOf(l,o),u=0,d,h,p,g;c>=0;)d=vC(e,t,n,r,c+1,i+1,s),d>u&&(c===o?d*=mP:Die.test(e.charAt(c-1))?(d*=kie,p=e.slice(o,c-1).match(Iie),p&&o>0&&(d*=Math.pow(Ex,p.length))):Aie.test(e.charAt(c-1))?(d*=Rie,g=e.slice(o,c-1).match(nL),g&&o>0&&(d*=Math.pow(Ex,g.length))):(d*=Nie,o>0&&(d*=Math.pow(Ex,c-o))),e.charAt(c)!==t.charAt(i)&&(d*=Mie)),(d<Sx&&n.charAt(c-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(c-1)!==r.charAt(i))&&(h=vC(e,t,n,r,c+1,i+2,s),h*Sx>d&&(d=h*Sx)),d>u&&(u=d),c=n.indexOf(l,c+1);return s[a]=u,u}function gP(e){return e.toLowerCase().replace(nL," ")}function Tie(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,vC(e,t,gP(e),gP(t),0,0,{})}var $d='[cmdk-group=""]',_x='[cmdk-group-items=""]',jie='[cmdk-group-heading=""]',rL='[cmdk-item=""]',bP=`${rL}:not([aria-disabled="true"])`,xC="cmdk-item-select",Vc="data-value",Oie=(e,t,n)=>Tie(e,t,n),oL=w.createContext(void 0),Ep=()=>w.useContext(oL),iL=w.createContext(void 0),e_=()=>w.useContext(iL),sL=w.createContext(void 0),aL=w.forwardRef((e,t)=>{let n=Hc(()=>{var L,P;return{search:"",value:(P=(L=e.value)!=null?L:e.defaultValue)!=null?P:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Hc(()=>new Set),o=Hc(()=>new Map),i=Hc(()=>new Map),s=Hc(()=>new Set),a=lL(e),{label:l,children:c,value:u,onValueChange:d,filter:h,shouldFilter:p,loop:g,disablePointerSelection:m=!1,vimBindings:b=!0,...y}=e,v=_n(),x=_n(),S=_n(),_=w.useRef(null),E=Gie();ql(()=>{if(u!==void 0){let L=u.trim();n.current.value=L,C.emit()}},[u]),ql(()=>{E(6,j)},[]);let C=w.useMemo(()=>({subscribe:L=>(s.current.add(L),()=>s.current.delete(L)),snapshot:()=>n.current,setState:(L,P,H)=>{var V,G,q,Y;if(!Object.is(n.current[L],P)){if(n.current[L]=P,L==="search")D(),M(),E(1,I);else if(L==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let K=document.getElementById(S);K?K.focus():(V=document.getElementById(v))==null||V.focus()}if(E(7,()=>{var K;n.current.selectedItemId=(K=F())==null?void 0:K.id,C.emit()}),H||E(5,j),((G=a.current)==null?void 0:G.value)!==void 0){let K=P??"";(Y=(q=a.current).onValueChange)==null||Y.call(q,K);return}}C.emit()}},emit:()=>{s.current.forEach(L=>L())}}),[]),k=w.useMemo(()=>({value:(L,P,H)=>{var V;P!==((V=i.current.get(L))==null?void 0:V.value)&&(i.current.set(L,{value:P,keywords:H}),n.current.filtered.items.set(L,N(P,H)),E(2,()=>{M(),C.emit()}))},item:(L,P)=>(r.current.add(L),P&&(o.current.has(P)?o.current.get(P).add(L):o.current.set(P,new Set([L]))),E(3,()=>{D(),M(),n.current.value||I(),C.emit()}),()=>{i.current.delete(L),r.current.delete(L),n.current.filtered.items.delete(L);let H=F();E(4,()=>{D(),(H==null?void 0:H.getAttribute("id"))===L&&I(),C.emit()})}),group:L=>(o.current.has(L)||o.current.set(L,new Set),()=>{i.current.delete(L),o.current.delete(L)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:v,inputId:S,labelId:x,listInnerRef:_}),[]);function N(L,P){var H,V;let G=(V=(H=a.current)==null?void 0:H.filter)!=null?V:Oie;return L?G(L,n.current.search,P):0}function M(){if(!n.current.search||a.current.shouldFilter===!1)return;let L=n.current.filtered.items,P=[];n.current.filtered.groups.forEach(V=>{let G=o.current.get(V),q=0;G.forEach(Y=>{let K=L.get(Y);q=Math.max(K,q)}),P.push([V,q])});let H=_.current;T().sort((V,G)=>{var q,Y;let K=V.getAttribute("id"),Z=G.getAttribute("id");return((q=L.get(Z))!=null?q:0)-((Y=L.get(K))!=null?Y:0)}).forEach(V=>{let G=V.closest(_x);G?G.appendChild(V.parentElement===G?V:V.closest(`${_x} > *`)):H.appendChild(V.parentElement===H?V:V.closest(`${_x} > *`))}),P.sort((V,G)=>G[1]-V[1]).forEach(V=>{var G;let q=(G=_.current)==null?void 0:G.querySelector(`${$d}[${Vc}="${encodeURIComponent(V[0])}"]`);q==null||q.parentElement.appendChild(q)})}function I(){let L=T().find(H=>H.getAttribute("aria-disabled")!=="true"),P=L==null?void 0:L.getAttribute(Vc);C.setState("value",P||void 0)}function D(){var L,P,H,V;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let G=0;for(let q of r.current){let Y=(P=(L=i.current.get(q))==null?void 0:L.value)!=null?P:"",K=(V=(H=i.current.get(q))==null?void 0:H.keywords)!=null?V:[],Z=N(Y,K);n.current.filtered.items.set(q,Z),Z>0&&G++}for(let[q,Y]of o.current)for(let K of Y)if(n.current.filtered.items.get(K)>0){n.current.filtered.groups.add(q);break}n.current.filtered.count=G}function j(){var L,P,H;let V=F();V&&(((L=V.parentElement)==null?void 0:L.firstChild)===V&&((H=(P=V.closest($d))==null?void 0:P.querySelector(jie))==null||H.scrollIntoView({block:"nearest"})),V.scrollIntoView({block:"nearest"}))}function F(){var L;return(L=_.current)==null?void 0:L.querySelector(`${rL}[aria-selected="true"]`)}function T(){var L;return Array.from(((L=_.current)==null?void 0:L.querySelectorAll(bP))||[])}function O(L){let P=T()[L];P&&C.setState("value",P.getAttribute(Vc))}function $(L){var P;let H=F(),V=T(),G=V.findIndex(Y=>Y===H),q=V[G+L];(P=a.current)!=null&&P.loop&&(q=G+L<0?V[V.length-1]:G+L===V.length?V[0]:V[G+L]),q&&C.setState("value",q.getAttribute(Vc))}function B(L){let P=F(),H=P==null?void 0:P.closest($d),V;for(;H&&!V;)H=L>0?Uie(H,$d):qie(H,$d),V=H==null?void 0:H.querySelector(bP);V?C.setState("value",V.getAttribute(Vc)):$(L)}let z=()=>O(T().length-1),A=L=>{L.preventDefault(),L.metaKey?z():L.altKey?B(1):$(1)},W=L=>{L.preventDefault(),L.metaKey?O(0):L.altKey?B(-1):$(-1)};return w.createElement(_e.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:L=>{var P;(P=y.onKeyDown)==null||P.call(y,L);let H=L.nativeEvent.isComposing||L.keyCode===229;if(!(L.defaultPrevented||H))switch(L.key){case"n":case"j":{b&&L.ctrlKey&&A(L);break}case"ArrowDown":{A(L);break}case"p":case"k":{b&&L.ctrlKey&&W(L);break}case"ArrowUp":{W(L);break}case"Home":{L.preventDefault(),O(0);break}case"End":{L.preventDefault(),z();break}case"Enter":{L.preventDefault();let V=F();if(V){let G=new Event(xC);V.dispatchEvent(G)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:Kie},l),yy(e,L=>w.createElement(iL.Provider,{value:C},w.createElement(oL.Provider,{value:k},L))))}),Fie=w.forwardRef((e,t)=>{var n,r;let o=_n(),i=w.useRef(null),s=w.useContext(sL),a=Ep(),l=lL(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:s==null?void 0:s.forceMount;ql(()=>{if(!c)return a.item(o,s==null?void 0:s.id)},[c]);let u=cL(o,i,[e.value,e.children,i],e.keywords),d=e_(),h=ma(E=>E.value&&E.value===u.current),p=ma(E=>c||a.filter()===!1?!0:E.search?E.filtered.items.get(o)>0:!0);w.useEffect(()=>{let E=i.current;if(!(!E||e.disabled))return E.addEventListener(xC,g),()=>E.removeEventListener(xC,g)},[p,e.onSelect,e.disabled]);function g(){var E,C;m(),(C=(E=l.current).onSelect)==null||C.call(E,u.current)}function m(){d.setState("value",u.current,!0)}if(!p)return null;let{disabled:b,value:y,onSelect:v,forceMount:x,keywords:S,..._}=e;return w.createElement(_e.div,{ref:vr(i,t),..._,id:o,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!h,"data-disabled":!!b,"data-selected":!!h,onPointerMove:b||a.getDisablePointerSelection()?void 0:m,onClick:b?void 0:g},e.children)}),Lie=w.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...i}=e,s=_n(),a=w.useRef(null),l=w.useRef(null),c=_n(),u=Ep(),d=ma(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(s):!0);ql(()=>u.group(s),[]),cL(s,a,[e.value,e.heading,l]);let h=w.useMemo(()=>({id:s,forceMount:o}),[o]);return w.createElement(_e.div,{ref:vr(a,t),...i,"cmdk-group":"",role:"presentation",hidden:d?void 0:!0},n&&w.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),yy(e,p=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},w.createElement(sL.Provider,{value:h},p))))}),$ie=w.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=w.useRef(null),i=ma(s=>!s.search);return!n&&!i?null:w.createElement(_e.div,{ref:vr(o,t),...r,"cmdk-separator":"",role:"separator"})}),zie=w.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,i=e_(),s=ma(c=>c.search),a=ma(c=>c.selectedItemId),l=Ep();return w.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),w.createElement(_e.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:s,onChange:c=>{o||i.setState("search",c.target.value),n==null||n(c.target.value)}})}),Bie=w.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,i=w.useRef(null),s=w.useRef(null),a=ma(c=>c.selectedItemId),l=Ep();return w.useEffect(()=>{if(s.current&&i.current){let c=s.current,u=i.current,d,h=new ResizeObserver(()=>{d=requestAnimationFrame(()=>{let p=c.offsetHeight;u.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(d),h.unobserve(c)}}},[]),w.createElement(_e.div,{ref:vr(i,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},yy(e,c=>w.createElement("div",{ref:vr(s,l.listInnerRef),"cmdk-list-sizer":""},c)))}),Vie=w.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:i,container:s,...a}=e;return w.createElement(XF,{open:n,onOpenChange:r},w.createElement(QF,{container:s},w.createElement(C2,{"cmdk-overlay":"",className:o}),w.createElement(S2,{"aria-label":e.label,"cmdk-dialog":"",className:i},w.createElement(aL,{ref:t,...a}))))}),Hie=w.forwardRef((e,t)=>ma(n=>n.filtered.count===0)?w.createElement(_e.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Wie=w.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...i}=e;return w.createElement(_e.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},yy(e,s=>w.createElement("div",{"aria-hidden":!0},s)))}),Hr=Object.assign(aL,{List:Bie,Item:Fie,Input:zie,Group:Lie,Separator:$ie,Dialog:Vie,Empty:Hie,Loading:Wie});function Uie(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function qie(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function lL(e){let t=w.useRef(e);return ql(()=>{t.current=e}),t}var ql=typeof window>"u"?w.useEffect:w.useLayoutEffect;function Hc(e){let t=w.useRef();return t.current===void 0&&(t.current=e()),t}function ma(e){let t=e_(),n=()=>e(t.snapshot());return w.useSyncExternalStore(t.subscribe,n,n)}function cL(e,t,n,r=[]){let o=w.useRef(),i=Ep();return ql(()=>{var s;let a=(()=>{var c;for(let u of n){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(c=u.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());i.value(e,a,l),(s=t.current)==null||s.setAttribute(Vc,a),o.current=a}),o}var Gie=()=>{let[e,t]=w.useState(),n=Hc(()=>new Map);return ql(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Yie(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function yy({asChild:e,children:t},n){return e&&w.isValidElement(t)?w.cloneElement(Yie(t),{ref:t.ref},n(t.props.children)):n(t)}var Kie={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const vy=w.forwardRef(({className:e,...t},n)=>f.jsx(Hr,{ref:n,className:ie("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));vy.displayName=Hr.displayName;const xy=w.forwardRef(({className:e,...t},n)=>f.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[f.jsx(p2,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),f.jsx(Hr.Input,{ref:n,className:ie("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));xy.displayName=Hr.Input.displayName;const wy=w.forwardRef(({className:e,...t},n)=>f.jsx(Hr.List,{ref:n,className:ie("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));wy.displayName=Hr.List.displayName;const Cy=w.forwardRef((e,t)=>f.jsx(Hr.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Cy.displayName=Hr.Empty.displayName;const Sy=w.forwardRef(({className:e,...t},n)=>f.jsx(Hr.Group,{ref:n,className:ie("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Sy.displayName=Hr.Group.displayName;const Xie=w.forwardRef(({className:e,...t},n)=>f.jsx(Hr.Separator,{ref:n,className:ie("-mx-1 h-px bg-border",e),...t}));Xie.displayName=Hr.Separator.displayName;const Ey=w.forwardRef(({className:e,...t},n)=>f.jsx(Hr.Item,{ref:n,className:ie("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",e),...t}));Ey.displayName=Hr.Item.displayName;function Qie({fields:e,value:t,onValueChange:n,placeholder:r="Select field...",className:o,disabled:i=!1,excludeFieldIds:s=[]}){const[a,l]=R.useState(!1),c=e.filter(d=>!s.includes(d.id)),u=c.find(d=>d.id===t);return f.jsxs(Da,{open:a,onOpenChange:l,children:[f.jsx(Ia,{asChild:!0,children:f.jsxs(Ee,{variant:"outline",role:"combobox","aria-expanded":a,className:ie("justify-between",o),disabled:i,children:[u?u.label:r,f.jsx(K5,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),f.jsx(ks,{className:"z-50 w-[200px] p-0",children:f.jsxs(vy,{children:[f.jsx(xy,{placeholder:"Search fields..."}),f.jsxs(wy,{children:[f.jsx(Cy,{children:"No field found."}),f.jsx(Sy,{children:c.map(d=>f.jsxs(Ey,{value:d.label,onSelect:()=>{n(d.id),l(!1)},children:[f.jsx(ao,{className:ie("mr-2 h-4 w-4",t===d.id?"opacity-100":"opacity-0")}),d.label]},d.id))})]})]})})]})}function Zie({hierarchy:e,editingHierarchy:t,sampleFieldReferences:n,onSetEditingHierarchy:r,onUpdateHierarchy:o,onDeleteHierarchy:i,onSetDefaultHierarchy:s,onUpdateStep:a,onRemoveStep:l,onAddStep:c}){const u=t===e.id,{attributes:d,listeners:h,setNodeRef:p,transform:g,transition:m}=A2({id:e.id,disabled:u}),b={transform:ki.Transform.toString(g),transition:m},y=e.steps.filter(v=>v.field).map(v=>v.field.id);return f.jsxs("div",{ref:p,style:b,className:"hierarchy-container relative rounded-lg border bg-background p-3 transition-shadow hover:shadow-md",children:[f.jsxs("div",{className:`mb-3 flex items-center justify-between ${u?"":"cursor-move"}`,...u?{}:d,...u?{}:h,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(hre,{value:e.label||"",isEditing:u,onEdit:()=>{r(e.id)},onSave:v=>{o(e.id,{label:v}),r(null)},onCancel:()=>r(null),placeholder:"Hierarchy Name",displayClassName:"font-medium",inputClassName:"font-medium"}),f.jsxs("span",{className:"rounded bg-muted px-2 py-1 text-xs",children:[e.steps.length," steps"]}),e.default?f.jsx("span",{className:"cursor-pointer rounded bg-blue-100 px-2 py-1 text-xs text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",onClick:v=>{v.stopPropagation(),s("")},onPointerDown:v=>v.stopPropagation(),title:"Click to remove default",children:"Default ✓"}):f.jsx("button",{className:"rounded bg-muted px-2 py-1 text-xs transition-colors hover:bg-blue-100 dark:hover:bg-blue-900/50",onClick:v=>{v.stopPropagation(),s(e.id)},onPointerDown:v=>v.stopPropagation(),title:"Set as default hierarchy",children:"Set Default"})]}),f.jsx("div",{className:"flex items-center gap-1",children:f.jsx(Ee,{size:"sm",variant:"ghost",onClick:v=>{v.stopPropagation(),i(e.id)},onPointerDown:v=>v.stopPropagation(),children:f.jsx(rp,{className:"h-3 w-3"})})})]}),f.jsx(_ie,{hierarchy:e,onUpdateStep:a,onRemoveStep:l,onUpdateHierarchy:o}),f.jsx("div",{className:"mt-3 border-t pt-3","data-hierarchy-editing":!0,children:f.jsx("div",{className:"flex items-center gap-2",children:f.jsx(Qie,{fields:n,excludeFieldIds:y,onValueChange:v=>c(e.id,v),placeholder:"Add drill step...",className:"w-48"})})})]})}function Jie({configuringIntent:e,setConfiguringIntent:t,drillHierarchies:n,onUpdateHierarchies:r,availableFields:o}){const i=R2(sh(pp),sh(hp,{coordinateGetter:T2})),{editingHierarchy:s,setEditingHierarchy:a,createNewHierarchy:l,deleteHierarchy:c,updateHierarchy:u,addStepToHierarchy:d,removeStepFromHierarchy:h,updateStep:p,setDefaultHierarchy:g}=fre(n,r,o),m=b=>{const{active:y,over:v}=b;if(y.id!==(v==null?void 0:v.id)){const x=n.findIndex(_=>_.id===y.id),S=n.findIndex(_=>_.id===(v==null?void 0:v.id));r(gp(n,x,S))}};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100",children:f.jsx(q5,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h4",{className:"mb-1 font-medium",children:"Let users drill deeper into specific paths"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Set up predefined drill paths like regions → cities, categories → products"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ee,{size:"sm",variant:"outline",onClick:()=>t(e==="drillDown"?null:"drillDown"),children:e==="drillDown"?"Done":"Set up drill paths"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.length," hierarchies configured"]})]}),e==="drillDown"&&f.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-blue-100 bg-blue-200/50 p-4 dark:border-blue-900 dark:bg-blue-900/50",children:[f.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("h5",{className:"font-medium",children:"Drill Hierarchies"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Create multiple drill paths for different analysis scenarios"})]}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Ee,{size:"sm",onClick:l,children:[f.jsx(uc,{className:"mr-1 h-4 w-4"}),"Add Hierarchy"]})})]}),f.jsx(D2,{sensors:i,collisionDetection:k2,onDragEnd:m,children:f.jsx(I2,{items:n.map(b=>b.id),strategy:N4,children:f.jsx("div",{className:"mb-6 space-y-4",children:n.map(b=>f.jsx(Zie,{hierarchy:b,editingHierarchy:s,sampleFieldReferences:o,onSetEditingHierarchy:a,onUpdateHierarchy:u,onDeleteHierarchy:c,onSetDefaultHierarchy:g,onUpdateStep:p,onRemoveStep:h,onAddStep:d},b.id))})})})]})]})]})})}var t_="Checkbox",[ese,dLe]=Pn(t_),[tse,nse]=ese(t_),uL=w.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...d}=e,[h,p]=w.useState(null),g=Ve(t,S=>p(S)),m=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=or({prop:o,defaultProp:i,onChange:c}),x=w.useRef(y);return w.useEffect(()=>{const S=h==null?void 0:h.form;if(S){const _=()=>v(x.current);return S.addEventListener("reset",_),()=>S.removeEventListener("reset",_)}},[h,v]),f.jsxs(tse,{scope:n,state:y,disabled:a,children:[f.jsx(_e.button,{type:"button",role:"checkbox","aria-checked":ca(y)?"mixed":y,"aria-required":s,"data-state":hL(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:g,onKeyDown:fe(e.onKeyDown,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:fe(e.onClick,S=>{v(_=>ca(_)?!0:!_),b&&(m.current=S.isPropagationStopped(),m.current||S.stopPropagation())})}),b&&f.jsx(rse,{control:h,bubbles:!m.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:ca(i)?!1:i})]})});uL.displayName=t_;var dL="CheckboxIndicator",fL=w.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=nse(dL,n);return f.jsx(fn,{present:r||ca(i.state)||i.state===!0,children:f.jsx(_e.span,{"data-state":hL(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});fL.displayName=dL;var rse=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=w.useRef(null),a=py(n),l=fy(t);w.useEffect(()=>{const u=s.current,d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"checked").set;if(a!==n&&p){const g=new Event("click",{bubbles:r});u.indeterminate=ca(n),p.call(u,ca(n)?!1:n),u.dispatchEvent(g)}},[a,n,r]);const c=w.useRef(ca(n)?!1:n);return f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??c.current,...i,tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function ca(e){return e==="indeterminate"}function hL(e){return ca(e)?"indeterminate":e?"checked":"unchecked"}var pL=uL,ose=fL;const zr=w.forwardRef(({className:e,...t},n)=>f.jsx(pL,{ref:n,className:ie("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:f.jsx(ose,{className:ie("flex items-center justify-center text-current"),children:f.jsx(ao,{className:"h-4 w-4"})})}));zr.displayName=pL.displayName;function ise({fields:e,selectedFieldIds:t,onSelectionChange:n,searchPlaceholder:r="Search fields...",className:o=""}){const[i,s]=R.useState(""),a=e.filter(u=>u.label.toLowerCase().includes(i.toLowerCase())||u.qualifiedEntityName&&u.qualifiedEntityName.toLowerCase().includes(i.toLowerCase())),l=()=>{const u=[...new Set([...t,...a.map(d=>d.id)])];n(u)},c=()=>{const u=a.map(d=>d.id);n(t.filter(d=>!u.includes(d)))};return f.jsxs("div",{className:`space-y-2 ${o}`,children:[f.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[f.jsx(yr,{placeholder:r,value:i,onChange:u=>s(u.target.value),className:"flex-1"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.length," fields"]})]}),f.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[f.jsx(Ee,{size:"sm",variant:"outline",onClick:l,children:"Select All"}),f.jsx(Ee,{size:"sm",variant:"outline",onClick:c,children:"Deselect All"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.length," selected"]})]}),f.jsx("div",{className:"grid max-h-32 grid-cols-2 gap-2 overflow-y-auto rounded border p-2",children:a.map(u=>f.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border p-2 text-xs hover:bg-muted/50",children:[f.jsx(zr,{checked:t.includes(u.id),onCheckedChange:d=>{n(d?[...t,u.id]:t.filter(h=>h!==u.id))}}),f.jsx("span",{className:"font-medium",children:u.label})]},u.id))}),i&&a.length===0&&f.jsxs("div",{className:"py-4 text-center text-sm text-muted-foreground",children:['No fields found matching "',i,'"']})]})}const sse=e=>["string","boolean"].includes(P0(e.dataType));function ase({configuringIntent:e,setConfiguringIntent:t,selectedDrillTargets:n,setSelectedDrillTargets:r,availableFields:o}){const i=o.filter(sse),s=n.map(l=>l.id),a=l=>{const c=i.filter(u=>l.includes(u.id));r(c)};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:f.jsx(oF,{className:"h-5 w-5 text-green-600 dark:text-green-400"})}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h4",{className:"mb-1 font-medium",children:"Give users freedom to explore any dimension"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Let users dynamically drill into any available field they choose"}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ee,{size:"sm",variant:"outline",onClick:()=>t(e==="dynamicDrill"?null:"dynamicDrill"),children:e==="dynamicDrill"?"Done":"Configure available fields"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:n.length>0?`${n.length} fields selected`:"All fields available"})]}),e==="dynamicDrill"&&f.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-green-100 bg-green-200/50 p-4 dark:border-green-900 dark:bg-green-900/50",children:[f.jsx("h5",{className:"mb-3 font-medium",children:"Configure Dynamic Drilling"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Choose which fields users can explore dynamically:"}),f.jsx("div",{className:"border-l-2 border-green-200 pl-4",children:f.jsx(ise,{fields:i,selectedFieldIds:s,onSelectionChange:a,searchPlaceholder:"Search fields..."})})]})]})]})]})})}var n_="Switch",[lse,fLe]=Pn(n_),[cse,use]=lse(n_),mL=w.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...d}=e,[h,p]=w.useState(null),g=Ve(t,x=>p(x)),m=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=or({prop:o,defaultProp:i,onChange:c});return f.jsxs(cse,{scope:n,checked:y,disabled:a,children:[f.jsx(_e.button,{type:"button",role:"switch","aria-checked":y,"aria-required":s,"data-state":yL(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:g,onClick:fe(e.onClick,x=>{v(S=>!S),b&&(m.current=x.isPropagationStopped(),m.current||x.stopPropagation())})}),b&&f.jsx(dse,{control:h,bubbles:!m.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});mL.displayName=n_;var gL="SwitchThumb",bL=w.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=use(gL,n);return f.jsx(_e.span,{"data-state":yL(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});bL.displayName=gL;var dse=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=py(n),a=fy(t);return w.useEffect(()=>{const l=i.current,c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&d){const h=new Event("click",{bubbles:r});d.call(l,n),l.dispatchEvent(h)}},[s,n,r]),f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:i,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function yL(e){return e?"checked":"unchecked"}var _y=mL,vL=bL;const r_=w.forwardRef(({className:e,...t},n)=>f.jsx(_y,{className:ie("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:f.jsx(vL,{className:ie("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));r_.displayName=_y.displayName;var o_="Radio",[fse,xL]=Pn(o_),[hse,pse]=fse(o_),wL=w.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:o=!1,required:i,disabled:s,value:a="on",onCheck:l,form:c,...u}=e,[d,h]=w.useState(null),p=Ve(t,b=>h(b)),g=w.useRef(!1),m=d?c||!!d.closest("form"):!0;return f.jsxs(hse,{scope:n,checked:o,disabled:s,children:[f.jsx(_e.button,{type:"button",role:"radio","aria-checked":o,"data-state":EL(o),"data-disabled":s?"":void 0,disabled:s,value:a,...u,ref:p,onClick:fe(e.onClick,b=>{o||l==null||l(),m&&(g.current=b.isPropagationStopped(),g.current||b.stopPropagation())})}),m&&f.jsx(mse,{control:d,bubbles:!g.current,name:r,value:a,checked:o,required:i,disabled:s,form:c,style:{transform:"translateX(-100%)"}})]})});wL.displayName=o_;var CL="RadioIndicator",SL=w.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...o}=e,i=pse(CL,n);return f.jsx(fn,{present:r||i.checked,children:f.jsx(_e.span,{"data-state":EL(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})});SL.displayName=CL;var mse=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=py(n),a=fy(t);return w.useEffect(()=>{const l=i.current,c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&d){const h=new Event("click",{bubbles:r});d.call(l,n),l.dispatchEvent(h)}},[s,n,r]),f.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:i,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function EL(e){return e?"checked":"unchecked"}var gse=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],i_="RadioGroup",[bse,hLe]=Pn(i_,[sd,xL]),_L=sd(),RL=xL(),[yse,vse]=bse(i_),kL=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:o,value:i,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:u=!0,onValueChange:d,...h}=e,p=_L(n),g=sc(c),[m,b]=or({prop:i,defaultProp:o,onChange:d});return f.jsx(yse,{scope:n,name:r,required:s,disabled:a,value:m,onValueChange:b,children:f.jsx(DE,{asChild:!0,...p,orientation:l,dir:g,loop:u,children:f.jsx(_e.div,{role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:g,...h,ref:t})})})});kL.displayName=i_;var NL="RadioGroupItem",ML=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...o}=e,i=vse(NL,n),s=i.disabled||r,a=_L(n),l=RL(n),c=w.useRef(null),u=Ve(t,c),d=i.value===o.value,h=w.useRef(!1);return w.useEffect(()=>{const p=m=>{gse.includes(m.key)&&(h.current=!0)},g=()=>h.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",g),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",g)}},[]),f.jsx(IE,{asChild:!0,...a,focusable:!s,active:d,children:f.jsx(wL,{disabled:s,required:i.required,checked:d,...l,...o,name:i.name,ref:u,onCheck:()=>i.onValueChange(o.value),onKeyDown:fe(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:fe(o.onFocus,()=>{var p;h.current&&((p=c.current)==null||p.click())})})})});ML.displayName=NL;var xse="RadioGroupIndicator",PL=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,o=RL(n);return f.jsx(SL,{...o,...r,ref:t})});PL.displayName=xse;var DL=kL,IL=ML,wse=PL;const ga=w.forwardRef(({className:e,...t},n)=>f.jsx(DL,{className:ie("grid gap-2",e),...t,ref:n}));ga.displayName=DL.displayName;const Fr=w.forwardRef(({className:e,...t},n)=>f.jsx(IL,{ref:n,className:ie("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:f.jsx(wse,{className:"flex items-center justify-center",children:f.jsx(i2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Fr.displayName=IL.displayName;function Cse({configuringIntent:e,setConfiguringIntent:t,incomingFilterFields:n,onUpdateClickFilterInteractions:r,currentClickFilterInteractions:o}){const[i,s]=R.useState(o.length>0),[a,l]=R.useState(o[0]||{filterFields:[],highlightSelf:!0}),[c,u]=R.useState(""),d=tO(),h=e==="clickFilter",p=()=>{const E=!i;if(s(E),E){const C={filterFields:n,highlightSelf:!0,mode:"clickFilter"};l(C),r([C])}else r([])},g=()=>{t("clickFilter")},m=()=>{t(null)},b=E=>{const C={...a,...E};l(C),r([C])},y=()=>a.applyToCardIds!==void 0?"specific-cards":a.excludeCardIds!==void 0?"all-except-specific":"all-cards",v=E=>{const C={};switch(E){case"all-cards":C.applyToCardIds=void 0,C.excludeCardIds=void 0;break;case"specific-cards":C.applyToCardIds=[],C.excludeCardIds=void 0;break;case"all-except-specific":C.applyToCardIds=void 0,C.excludeCardIds=[];break}b(C)},x=(E,C)=>{if(C==="specific-cards"){const k=a.applyToCardIds||[],N=k.includes(E)?k.filter(M=>M!==E):[...k,E];b({applyToCardIds:N})}else if(C==="all-except-specific"){const k=a.excludeCardIds||[],N=k.includes(E)?k.filter(M=>M!==E):[...k,E];b({excludeCardIds:N})}},S=R.useMemo(()=>{if(!c.trim())return d;const E=c.toLowerCase();return d==null?void 0:d.filter(C=>{var k;return(k=C==null?void 0:C.title)==null?void 0:k.toLowerCase().includes(E)})},[c,d]),_=()=>{var C,k;if(!i)return"0 settings configured";const E=y();if(E==="all-cards")return"filtering all cards";if(E==="specific-cards"){const N=((C=a.applyToCardIds)==null?void 0:C.length)||0;return N===0?"no cards selected":`filtering ${N} card${N!==1?"s":""}`}else if(E==="all-except-specific"){const N=((k=a.excludeCardIds)==null?void 0:k.length)||0;return N===0?"filtering all cards":`excluding ${N} card${N!==1?"s":""}`}return"0 settings configured"};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:f.jsx("svg",{className:"h-5 w-5 text-green-600 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})})}),f.jsxs("div",{className:"flex-1",children:[f.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[f.jsx("h4",{className:"font-medium",children:"Enable click filters"}),f.jsx(r_,{checked:i,onCheckedChange:p})]}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Apply filters to other cards when users click on chart elements"}),i&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ee,{size:"sm",variant:"outline",onClick:h?m:g,children:h?"Done":"Configure"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:_()})]}),h&&i&&f.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-green-100 bg-green-200/50 p-4 dark:border-green-900 dark:bg-green-900/50",children:[f.jsx("h5",{className:"mb-3 font-medium",children:"Configure Click Filters"}),f.jsx("div",{className:"space-y-6",children:f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(de,{className:"text-sm font-medium",children:"Filter scope"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),f.jsxs(ga,{value:y(),onValueChange:E=>v(E),className:"space-y-3",children:[f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Fr,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(de,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Fr,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(de,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),y()==="specific-cards"&&f.jsxs("div",{className:"ml-7 space-y-2",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(de,{className:"text-sm font-medium",children:"Cards to filter"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),f.jsx(yr,{placeholder:"Search cards...",value:c,onChange:E=>u(E.target.value),className:"mb-2"}),f.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:S.length>0?S.map(E=>{const C=(a.applyToCardIds||[]).includes(E.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(zr,{id:`card-${E.id}`,checked:C,onCheckedChange:()=>x(E.id,"specific-cards")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(de,{htmlFor:`card-${E.id}`,className:"cursor-pointer text-sm font-medium",children:E.title}),E.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:E.description})]})]},E.id)}):f.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]}),f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Fr,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(de,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),y()==="all-except-specific"&&f.jsxs("div",{className:"ml-7 space-y-2",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(de,{className:"text-sm font-medium",children:"Cards to exclude"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),f.jsx(yr,{placeholder:"Search cards...",value:c,onChange:E=>u(E.target.value),className:"mb-2"}),f.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:S.length>0?S.map(E=>{const C=(a.excludeCardIds||[]).includes(E.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(zr,{id:`card-exclude-${E.id}`,checked:C,onCheckedChange:()=>x(E.id,"all-except-specific")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(de,{htmlFor:`card-exclude-${E.id}`,className:"cursor-pointer text-sm font-medium",children:E.title}),E.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:E.description})]})]},E.id)}):f.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]})]})]})})]})]})]})})}function Sse(e){return e.flatMap(t=>t.columns.map(n=>({id:`${t.entityId}-${n.name}`,name:n.name,dataType:n.dataType,qualifiedEntityName:t.qualifiedEntityName,label:n.label||CE(n.name),description:n.description,entityId:t.entityId,entityName:t.entityName,entityType:t.entityType})))}function AL(e){if(e.type==="table"||e.type==="view"){if(e.database&&e.schema)return`${e.database}.${e.schema}.${e.name}`;if(e.database)return`${e.database}.${e.name}`}return e.name}function TL(e){var m;const t=re(b=>b.authToken)||e,{hasSchemaSupport:n}=BJ(e),r=Ce(b=>{var y;return(y=b.card.dataSource)==null?void 0:y.connectionId}),o=Ce(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="model")})||[],i=Ce(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="table"||x.type==="view")})||[],s=Ce(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="dataset")})||[];function a(b){return b.type==="dataset"?!!r&&!!b.domainId&&!!b.name:b.type==="model"?!!r&&!!b.id:b.type==="table"||b.type==="view"?n?!!r&&!!b.name&&!!b.database&&!!b.schema:["S3","API"].includes(b.connectionType)?!!r&&!!b.name:!!r&&!!b.name&&!!b.database:!1}const l=[...o,...i,...s],c=XY({queries:l.map(b=>{let y={};return b.type==="model"?y={connection_id:r,datamodel_id:b.id,database_name:"",schema_name:"",table_name:""}:b.type==="dataset"?y={connection_id:b.connectionId,domain_id:b.domainId,dataset_name:b.name}:y={connection_id:r,datamodel_id:"",database_name:b.database,schema_name:b.schema,table_name:b.name},{queryKey:["columns",r,b],queryFn:()=>br("https://semaphor.cloud/api/v1/columns",(t==null?void 0:t.accessToken)||"",y),enabled:!!r&&a(b)}})}),u=c.some(b=>b.isPending),d=c.some(b=>b.isError),h=(m=c.find(b=>b.isError))==null?void 0:m.error,p=c.map((b,y)=>{var S;const v=l[y],x=AL(v);return{entityId:v.id||v.name,entityType:v.type,entityName:v.name,label:v.label,description:v.description,qualifiedEntityName:x,columns:(S=b.data)==null?void 0:S.columns.map(_=>({id:`${v.name}-${_.column_name}`,name:_.column_name,dataType:_.data_type,label:_.label||SE(_.column_name),description:_.description||"",qualifiedEntityName:x,entityId:v.id||v.id||v.name,entityName:v.name,entityType:v.type}))}}).filter(b=>{var y;return((y=b==null?void 0:b.columns)==null?void 0:y.length)>0})||[],g=Sse(p);return{columnGroups:p,columns:g,isLoading:u,hasError:d,error:h,refetch:()=>{c.forEach(b=>b.refetch())}}}function Ese({isOpen:e,onClose:t}){var T,O,$,B;const n=IJ(),r=AJ(),{updateCurrentDashboardCard:o}=on(),{columns:i}=TL(),{groupByFields:s,pivotByFields:a}=nO(),l=[...s,...a],c=i,u=((T=n.interactionConfig)==null?void 0:T.drillHierarchies)||[],d=((O=n.interactionConfig)==null?void 0:O.allowedDrillTargets)||[],h=R.useMemo(()=>{var z;return((z=n.interactionConfig)==null?void 0:z.clickFilterInteractions)||[]},[($=n.interactionConfig)==null?void 0:$.clickFilterInteractions]),p=R.useMemo(()=>{var z;return((z=n.interactionConfig)==null?void 0:z.drillInteractions)||[]},[(B=n.interactionConfig)==null?void 0:B.drillInteractions]),[g,m]=R.useState(u),[b,y]=R.useState(d||[]),[v,x]=R.useState(null),[S,_]=R.useState(()=>p.filter(z=>z.mode==="drillToURL")),[E,C]=R.useState(()=>p.filter(z=>z.mode==="drillThrough")),[k,N]=R.useState(()=>p.filter(z=>z.mode==="drillToDetail")),[M,I]=R.useState(h),D=R.useRef(null);R.useEffect(()=>{var z,A,W;if(e){m(((z=n.interactionConfig)==null?void 0:z.drillHierarchies)||[]),y(((A=n.interactionConfig)==null?void 0:A.allowedDrillTargets)||[]),x(null);const L=((W=n.interactionConfig)==null?void 0:W.drillInteractions)||[];_(L.filter(P=>P.mode==="drillToURL")),C(L.filter(P=>P.mode==="drillThrough")),N(L.filter(P=>P.mode==="drillToDetail")),I(h)}},[e,n.interactionConfig,h]);const j=()=>{var W;const z=[...S,...E,...k];r.updateDrillHierarchies(g),r.updateDrillInteractions(z),(W=D.current)!=null&&W.saveToGlobal&&D.current.saveToGlobal(),r.updateAllowedDrillTargets(b);const A={...n,interactionConfig:{...n.interactionConfig,drillHierarchies:g,allowedDrillTargets:b,drillInteractions:z,clickFilterInteractions:M}};o(A),t()},F=()=>{x(null),t()};return e?f.jsxs(ey,{modal:!1,open:e,onOpenChange:t,children:[f.jsx("div",{className:"pointer-events-none fixed inset-0 z-40 bg-background/80 backdrop-blur-sm"}),f.jsxs(ip,{className:"flex max-h-[90vh] max-w-4xl flex-col overflow-hidden",children:[f.jsxs(sp,{children:[f.jsx(lp,{children:"Configure Interactions"}),f.jsx(cp,{children:"Set up drill behaviors for this chart"})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx("div",{className:"space-y-6",children:f.jsx("div",{children:f.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[f.jsx(Cse,{configuringIntent:v,setConfiguringIntent:x,incomingFilterFields:l,onUpdateClickFilterInteractions:I,currentClickFilterInteractions:M}),f.jsx(Jie,{configuringIntent:v,setConfiguringIntent:x,drillHierarchies:g,onUpdateHierarchies:m,availableFields:c}),f.jsx(ase,{configuringIntent:v,setConfiguringIntent:x,selectedDrillTargets:b,setSelectedDrillTargets:y,availableFields:c})]})})})}),f.jsxs(ap,{className:"border-t-0",children:[f.jsx(Ee,{variant:"outline",onClick:F,children:"Cancel"}),f.jsx(Ee,{onClick:j,children:"Save Changes"})]})]})]}):null}function jL({frame:e}){var h;const t=re(p=>p.isDashboardEditing),n=re(p=>p.isVisualEditing),r=re(p=>p.selectedSheetId),[o,i]=R.useState(!1),s=e.cards.find(p=>p.id===e.activeCardId),{removeFrame:a}=re(p=>p.actions),l=re(p=>p.actions.setIsVisualEditing),{handleEditVisual:c,card:u,data:d}=VJ(e);return f.jsx("section",{onMouseDown:p=>{p.stopPropagation()},className:"absolute right-2 top-2 z-50",children:f.jsxs("div",{className:"flex items-center gap-2",children:[t&&(s==null?void 0:s.config)&&f.jsx("button",{onClick:()=>i(!0),children:f.jsx(aa,{className:"size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}),f.jsx(Ese,{isOpen:o,onClose:()=>i(!1)}),t&&(n?f.jsx("button",{onClick:()=>{l(!n)},children:f.jsx(kZ,{className:"size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}):f.jsx("button",{role:"edit-visual",onClick:()=>c(),children:f.jsx(MZ,{className:"ml-1 size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})})),t&&f.jsx("button",{onClick:()=>a(r,e.id),children:f.jsx(V5,{className:"size-3.5 text-center text-muted-foreground/70 hover:cursor-pointer hover:text-muted-foreground"})}),((h=u.preferences)==null?void 0:h.allowDownload)===!0&&f.jsx(iJ,{data:(d==null?void 0:d.records)||[],filename:u.title})]})})}const _se=R.createContext(null),Rx={didCatch:!1,error:null};class _p extends R.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Rx}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:i,reason:"imperative-api"}),this.setState(Rx)}}componentDidCatch(t,n){var r,o;(r=(o=this.props).onError)===null||r===void 0||r.call(o,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:o}=this.props;if(r&&n.error!==null&&Rse(t.resetKeys,o)){var i,s;(i=(s=this.props).onReset)===null||i===void 0||i.call(s,{next:o,prev:t.resetKeys,reason:"keys"}),this.setState(Rx)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:o}=this.props,{didCatch:i,error:s}=this.state;let a=t;if(i){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=R.createElement(r,l);else if(o!==void 0)a=o;else throw s}return R.createElement(_se.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function Rse(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function OL({error:e,resetErrorBoundary:t}){return f.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center rounded-lg border border-dashed border-muted-foreground/25 bg-muted/30 p-6 text-center",children:[f.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:f.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),f.jsx("h3",{className:"mb-2 text-sm font-medium text-foreground",children:"Chart Unavailable"}),f.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"We couldn't display this chart right now. Please try refreshing or check your data configuration."}),f.jsxs("button",{onClick:t,className:"inline-flex items-center justify-center rounded-md bg-primary px-3 py-2 text-xs font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[f.jsx("svg",{className:"mr-1.5 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]}),Yg]})}function s_({error:e}){return f.jsx("div",{className:"flex flex-col items-center justify-center",role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},children:f.jsxs("div",{style:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.08)",color:"#b91c1c",fontFamily:"sans-serif",padding:"16px",textAlign:"center",flexDirection:"column",whiteSpace:"pre-wrap",position:"relative"},className:"flex flex-col justify-center space-y-1 rounded-md bg-muted p-10",children:[f.jsx("p",{className:"text-sm",children:"Something went wrong:"}),f.jsx("pre",{className:"text-xs",children:e.message})]})})}function kse({error:e,frame:t}){return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[f.jsx(jL,{frame:t}),f.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),f.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[f.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),f.jsx("p",{className:"text-sm",children:"Something went wrong:"}),f.jsx("pre",{className:"text-xs",children:e.message})]})]})}function Nse({error:e}){return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center",role:"alert",children:[f.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),f.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[f.jsx("p",{className:"text-lg font-semibold",children:"Oops! Something went wrong!"}),f.jsx("p",{className:"text-sm",children:"Something went wrong:"}),f.jsx("pre",{className:"text-xs",children:e.message})]})]})}function rr({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:o="",locale:i="en-US"}){let s=1,a=r,l=i;const c=t;n&&!r&&(e>=1e9?(s=1e9,a="B"):e>=1e7&&i==="en-IN"?(s=1e7,a="Cr"):e>=1e5&&i==="en-IN"?(s=1e5,a="L"):e>=1e6?(s=1e6,a="M"):e>=1e3&&(s=1e3,a="K"));const u=e/s,d={maximumFractionDigits:c,minimumFractionDigits:c};if(o){d.style="currency",d.currency=o;try{new Intl.NumberFormat(i,d).format(0)}catch{}}try{new Intl.NumberFormat(i,d).format(0)}catch{l="en-US"}let p=new Intl.NumberFormat(l,d).format(u);return n&&(p+=a),p}function Ry(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function ky(e){try{const n=new Function("getDatalabelColor",e)(b1);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}catch(t){return console.error("Error processing custom visual code",t),{options:{},plugins:[]}}}function Mse(e){var t,n,r,o,i,s,a,l,c,u,d,h,p,g,m,b,y,v;return!e||((r=(n=(t=e==null?void 0:e.scales)==null?void 0:t.x)==null?void 0:n.grid)==null?void 0:r.display)===!0&&((s=(i=(o=e==null?void 0:e.scales)==null?void 0:o.y)==null?void 0:i.grid)==null?void 0:s.display)===!0?"xy":(c=(l=(a=e.scales)==null?void 0:a.x)==null?void 0:l.grid)!=null&&c.display?"x":(h=(d=(u=e.scales)==null?void 0:u.y)==null?void 0:d.grid)!=null&&h.display?"y":((m=(g=(p=e.scales)==null?void 0:p.x)==null?void 0:g.grid)==null?void 0:m.display)===!1&&((v=(y=(b=e.scales)==null?void 0:b.y)==null?void 0:y.grid)==null?void 0:v.display)===!1?"none":"xy"}function Pse(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return FL(t)}function FL(e){const[t,n,r]=e.split(" "),o=parseFloat(t),i=parseFloat(n),s=parseFloat(r),a=i/100,l=s/100,c=(1-Math.abs(2*l-1))*a,u=c*(1-Math.abs(o/60%2-1)),d=l-c/2;let h=0,p=0,g=0;0<=o&&o<60?(h=c,p=u,g=0):60<=o&&o<120?(h=u,p=c,g=0):120<=o&&o<180?(h=0,p=c,g=u):180<=o&&o<240?(h=0,p=u,g=c):240<=o&&o<300?(h=u,p=0,g=c):300<=o&&o<360&&(h=c,p=0,g=u),h=Math.round((h+d)*255),p=Math.round((p+d)*255),g=Math.round((g+d)*255);const m=b=>{const y=b.toString(16);return y.length==1?"0"+y:y};return`#${m(h)}${m(p)}${m(g)}`}function Dse(e,t){return e.map(r=>Object.fromEntries(Object.entries(r).filter(([o])=>!t.some(i=>i.label===o))))}function Ise(e){return e.length===1?[e[0]]:e.slice(1).filter(n=>!Xj.includes(n))}function Pc({data:e,cfg:t,customCfg:n,preferences:r,cardType:o,card:i}){var x;const s=o==="radar"?.2:1,{keys:a}=un(e),l=Ise(a);let c="none";o=="bar"?c="bar":o=="line"&&(c="line");const u=yF(l,e,r,s,c),d=El(u,n),h=a[0],p=op(e,h),{options:g,plugins:m}=Cb({cardType:o,cfg:t,preferences:r,customCfg:n}),b=(x=i.interactionConfig)==null?void 0:x.clickFilterInteractions,y=function(S,_){var C;const E=((C=S.native)==null?void 0:C.target)||S.target;_.length?E.style.cursor="pointer":E.style.cursor="default"};return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:p,datasets:d},options:{...g,onHover:b?y:void 0},plugins:m}}function LL(e,t){var o,i,s;const n=((o=t==null?void 0:t.options)==null?void 0:o.indexAxis)==="y"?"x":"y";return(i=e==null?void 0:e.chartOptions)!=null&&i.indexAxis?((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)==="x"?"y":"x":n}function Ase(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"x":"y":"x"}function $L(e,t){var i,s,a,l,c,u,d,h,p,g,m,b;const n=LL(t,e),r=Ase(t);return{...e==null?void 0:e.options,scales:{...(i=e==null?void 0:e.options)==null?void 0:i.scales,[n]:{...(a=(s=e==null?void 0:e.options)==null?void 0:s.scales)==null?void 0:a[n],ticks:{...(u=(c=(l=e==null?void 0:e.options)==null?void 0:l.scales)==null?void 0:c[n])==null?void 0:u.ticks,callback:y=>{var v,x,S,_;return rr({number:Number(y),decimalPlaces:((v=t==null?void 0:t.numberAxisFormat)==null?void 0:v.decimalPlaces)||0,useSuffix:!!((x=t==null?void 0:t.numberAxisFormat)!=null&&x.suffix),customSuffix:"",locale:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.locale)||"",currency:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.currency)||""})}}},[r]:{...(p=(h=(d=e==null?void 0:e.options)==null?void 0:d.scales)==null?void 0:h[r])==null?void 0:p.ticks,callback:null}},plugins:{...(g=e==null?void 0:e.options)==null?void 0:g.plugins,datalabels:{...(b=(m=e==null?void 0:e.options)==null?void 0:m.plugins)==null?void 0:b.datalabels,formatter:function(y){var v,x,S,_;return rr({number:Number(y),decimalPlaces:((v=t==null?void 0:t.numberAxisFormat)==null?void 0:v.decimalPlaces)||0,useSuffix:!!((x=t==null?void 0:t.numberAxisFormat)!=null&&x.suffix),customSuffix:"",locale:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.locale)||"",currency:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.currency)||""})}}}}}function Cb({cardType:e,cfg:t,preferences:n,customCfg:r}){var g,m,b,y,v,x,S,_,E,C,k,N,M,I,D,j,F,T,O,$,B,z,A,W,L,P,H,V,G;const o=re.getState().themeStyle,i=$L(t,n),s=Bn((t==null?void 0:t.options)||{},n==null?void 0:n.chartOptions),a=Bn(i,s),l=Bn(a,(r==null?void 0:r.options)||{}),c=Tse(e,n,l),u={...l,scales:{...l==null?void 0:l.scales,x:{...(g=l==null?void 0:l.scales)==null?void 0:g.x,grid:{...(b=(m=l==null?void 0:l.scales)==null?void 0:m.x)==null?void 0:b.grid,color:(_=(S=(x=(v=(y=o==null?void 0:o.chart)==null?void 0:y.options)==null?void 0:v.scales)==null?void 0:x.x)==null?void 0:S.grid)==null?void 0:_.color}},y:{...(E=l==null?void 0:l.scales)==null?void 0:E.y,grid:{...(k=(C=l==null?void 0:l.scales)==null?void 0:C.y)==null?void 0:k.grid,color:(j=(D=(I=(M=(N=o==null?void 0:o.chart)==null?void 0:N.options)==null?void 0:M.scales)==null?void 0:I.y)==null?void 0:D.grid)==null?void 0:j.color}}},plugins:{...l==null?void 0:l.plugins,tooltip:{filter:function(q){return q.raw!==void 0&&q.raw!==0},callbacks:c,...(F=l==null?void 0:l.plugins)==null?void 0:F.tooltip,backgroundColor:(B=($=(O=(T=o==null?void 0:o.chart)==null?void 0:T.options)==null?void 0:O.plugins)==null?void 0:$.tooltip)==null?void 0:B.backgroundColor,bodyColor:(L=(W=(A=(z=o==null?void 0:o.chart)==null?void 0:z.options)==null?void 0:A.plugins)==null?void 0:W.tooltip)==null?void 0:L.bodyColor,titleColor:(G=(V=(H=(P=o==null?void 0:o.chart)==null?void 0:P.options)==null?void 0:H.plugins)==null?void 0:V.tooltip)==null?void 0:G.titleColor}}},{plugins:d,options:h}=ky((n==null?void 0:n.customVisualCode)||"");return{options:Bn(u,h),plugins:d}}function Tse(e,t,n){var r,o;return e==="map"?{}:{title:function(i){var a,l,c,u,d;const s=((a=i==null?void 0:i[0])==null?void 0:a.label)||"";if(i.length>1&&["stackedBar","stackedLine"].includes(e||"")){const h=i.reduce((g,m)=>{const b=m.raw;return b!==void 0&&b!==0?g+b:g},0),p=rr({number:h,decimalPlaces:((l=t==null?void 0:t.numberAxisFormat)==null?void 0:l.decimalPlaces)||0,useSuffix:!!((c=t==null?void 0:t.numberAxisFormat)!=null&&c.suffix),customSuffix:"",locale:((u=t==null?void 0:t.numberAxisFormat)==null?void 0:u.locale)||"",currency:((d=t==null?void 0:t.numberAxisFormat)==null?void 0:d.currency)||""});return`${s} (${p})`}return s},label:function(i){var c,u,d,h,p;const s=((c=i==null?void 0:i.dataset)==null?void 0:c.label)||"",a=i==null?void 0:i.raw;if(a===void 0||a===0)return;const l=rr({number:Number(a),decimalPlaces:((u=t==null?void 0:t.numberAxisFormat)==null?void 0:u.decimalPlaces)||0,useSuffix:!!((d=t==null?void 0:t.numberAxisFormat)!=null&&d.suffix),customSuffix:"",locale:((h=t==null?void 0:t.numberAxisFormat)==null?void 0:h.locale)||"",currency:((p=t==null?void 0:t.numberAxisFormat)==null?void 0:p.currency)||""});return`${s}: ${l}`},...((o=(r=n==null?void 0:n.plugins)==null?void 0:r.tooltip)==null?void 0:o.callbacks)||{}}}/*!
485
+ `},Lte={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function $te(e){let{announcements:t=Lte,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Fte}=e;const{announce:i,announcement:s}=Tte(),a=fp("DndLiveRegion"),[l,c]=R.useState(!1);if(R.useEffect(()=>{c(!0)},[]),jte(R.useMemo(()=>({onDragStart(d){let{active:h}=d;i(t.onDragStart({active:h}))},onDragMove(d){let{active:h,over:p}=d;t.onDragMove&&i(t.onDragMove({active:h,over:p}))},onDragOver(d){let{active:h,over:p}=d;i(t.onDragOver({active:h,over:p}))},onDragEnd(d){let{active:h,over:p}=d;i(t.onDragEnd({active:h,over:p}))},onDragCancel(d){let{active:h,over:p}=d;i(t.onDragCancel({active:h,over:p}))}}),[i,t])),!l)return null;const u=R.createElement(R.Fragment,null,R.createElement(Ite,{id:r,value:o.draggable}),R.createElement(Ate,{id:a,announcement:s}));return n?rn.createPortal(u,n):u}var Nn;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Nn||(Nn={}));function mb(){}function sh(e,t){return R.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function R2(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return R.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const qo=Object.freeze({x:0,y:0});function o4(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function zte(e,t){const n=pb(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function i4(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Bte(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function BM(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function s4(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function VM(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const k2=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=VM(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=o4(VM(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(i4)},Vte=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=BM(t),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=BM(l),u=o.reduce((h,p,g)=>h+o4(c[g],p),0),d=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:d}})}}return i.sort(i4)};function Hte(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),s=o-r,a=i-n;if(r<o&&n<i){const l=t.width*t.height,c=e.width*e.height,u=s*a,d=u/(l+c-u);return Number(d.toFixed(4))}return 0}const Wte=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=Hte(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(Bte)};function Ute(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function a4(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:qo}function qte(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+e*a.y,bottom:s.bottom+e*a.y,left:s.left+e*a.x,right:s.right+e*a.x}),{...n})}}const Gte=qte(1);function l4(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Yte(e,t,n){const r=l4(t);if(!r)return e;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=e.left-s-(1-o)*parseFloat(n),c=e.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=o?e.width/o:e.width,d=i?e.height/i:e.height;return{width:u,height:d,top:c,right:l+u,bottom:c+d,left:l}}const Kte={ignoreTransform:!1};function dd(e,t){t===void 0&&(t=Kte);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=wr(e).getComputedStyle(e);c&&(n=Yte(n,c,u))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function HM(e){return dd(e,{ignoreTransform:!0})}function Xte(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Qte(e,t){return t===void 0&&(t=wr(e).getComputedStyle(e)),t.position==="fixed"}function Zte(e,t){t===void 0&&(t=wr(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function oy(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(_2(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!up(o)||t4(o)||n.includes(o))return n;const i=wr(e).getComputedStyle(o);return o!==e&&Zte(o,i)&&n.push(o),Qte(o,i)?n:r(o.parentNode)}return e?r(e):n}function c4(e){const[t]=oy(e,1);return t??null}function px(e){return!ty||!e?null:cd(e)?e:E2(e)?_2(e)||e===ud(e).scrollingElement?window:up(e)?e:null:null}function u4(e){return cd(e)?e.scrollX:e.scrollLeft}function d4(e){return cd(e)?e.scrollY:e.scrollTop}function oC(e){return{x:u4(e),y:d4(e)}}var In;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(In||(In={}));function f4(e){return!ty||!e?!1:e===document.scrollingElement}function h4(e){const t={x:0,y:0},n=f4(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:t}}const Jte={x:.2,y:.2};function ene(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=Jte);const{isTop:c,isBottom:u,isLeft:d,isRight:h}=h4(e),p={x:0,y:0},g={x:0,y:0},m={height:t.height*o.y,width:t.width*o.x};return!c&&i<=t.top+m.height?(p.y=In.Backward,g.y=r*Math.abs((t.top+m.height-i)/m.height)):!u&&l>=t.bottom-m.height&&(p.y=In.Forward,g.y=r*Math.abs((t.bottom-m.height-l)/m.height)),!h&&a>=t.right-m.width?(p.x=In.Forward,g.x=r*Math.abs((t.right-m.width-a)/m.width)):!d&&s<=t.left+m.width&&(p.x=In.Backward,g.x=r*Math.abs((t.left+m.width-s)/m.width)),{direction:p,speed:g}}function tne(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function p4(e){return e.reduce((t,n)=>iu(t,oC(n)),qo)}function nne(e){return e.reduce((t,n)=>t+u4(n),0)}function rne(e){return e.reduce((t,n)=>t+d4(n),0)}function m4(e,t){if(t===void 0&&(t=dd),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);c4(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const one=[["x",["left","right"],nne],["y",["top","bottom"],rne]];class N2{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=oy(n),o=p4(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of one)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[i]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class wf{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function ine(e){const{EventTarget:t}=wr(e);return e instanceof t?e:ud(e)}function mx(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var yo;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(yo||(yo={}));function WM(e){e.preventDefault()}function sne(e){e.stopPropagation()}var ht;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(ht||(ht={}));const g4={start:[ht.Space,ht.Enter],cancel:[ht.Esc],end:[ht.Space,ht.Enter,ht.Tab]},ane=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case ht.Right:return{...n,x:n.x+25};case ht.Left:return{...n,x:n.x-25};case ht.Down:return{...n,y:n.y+25};case ht.Up:return{...n,y:n.y-25}}};class hp{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new wf(ud(n)),this.windowListeners=new wf(wr(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(yo.Resize,this.handleCancel),this.windowListeners.add(yo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(yo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&m4(r),n(qo)}handleKeyDown(t){if(ry(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=g4,coordinateGetter:s=ane,scrollBehavior:a="smooth"}=o,{code:l}=t;if(i.end.includes(l)){this.handleEnd(t);return}if(i.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:qo;this.referenceCoordinates||(this.referenceCoordinates=u);const d=s(t,{active:n,context:r.current,currentCoordinates:u});if(d){const h=ih(d,u),p={x:0,y:0},{scrollableAncestors:g}=r.current;for(const m of g){const b=t.code,{isTop:y,isRight:v,isLeft:x,isBottom:S,maxScroll:_,minScroll:E}=h4(m),C=tne(m),k={x:Math.min(b===ht.Right?C.right-C.width/2:C.right,Math.max(b===ht.Right?C.left:C.left+C.width/2,d.x)),y:Math.min(b===ht.Down?C.bottom-C.height/2:C.bottom,Math.max(b===ht.Down?C.top:C.top+C.height/2,d.y))},N=b===ht.Right&&!v||b===ht.Left&&!x,M=b===ht.Down&&!S||b===ht.Up&&!y;if(N&&k.x!==d.x){const I=m.scrollLeft+h.x,D=b===ht.Right&&I<=_.x||b===ht.Left&&I>=E.x;if(D&&!h.y){m.scrollTo({left:I,behavior:a});return}D?p.x=m.scrollLeft-I:p.x=b===ht.Right?m.scrollLeft-_.x:m.scrollLeft-E.x,p.x&&m.scrollBy({left:-p.x,behavior:a});break}else if(M&&k.y!==d.y){const I=m.scrollTop+h.y,D=b===ht.Down&&I<=_.y||b===ht.Up&&I>=E.y;if(D&&!h.x){m.scrollTo({top:I,behavior:a});return}D?p.y=m.scrollTop-I:p.y=b===ht.Down?m.scrollTop-_.y:m.scrollTop-E.y,p.y&&m.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(t,iu(ih(d,this.referenceCoordinates),p))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}hp.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=g4,onActivation:o}=t,{active:i}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function UM(e){return!!(e&&"distance"in e)}function qM(e){return!!(e&&"delay"in e)}class M2{constructor(t,n,r){var o;r===void 0&&(r=ine(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:s}=i;this.props=t,this.events=n,this.document=ud(s),this.documentListeners=new wf(this.document),this.listeners=new wf(r),this.windowListeners=new wf(wr(s)),this.initialCoordinates=(o=pb(i))!=null?o:qo,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(yo.Resize,this.handleCancel),this.windowListeners.add(yo.DragStart,WM),this.windowListeners.add(yo.VisibilityChange,this.handleCancel),this.windowListeners.add(yo.ContextMenu,WM),this.documentListeners.add(yo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(qM(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(UM(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(yo.Click,sne,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(yo.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=pb(t))!=null?n:qo,c=ih(o,l);if(!r&&a){if(UM(a)){if(a.tolerance!=null&&mx(c,a.tolerance))return this.handleCancel();if(mx(c,a.distance))return this.handleStart()}if(qM(a)&&mx(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}t.cancelable&&t.preventDefault(),s(l)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===ht.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const lne={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class pp extends M2{constructor(t){const{event:n}=t,r=ud(n.target);super(t,lne,r)}}pp.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const cne={move:{name:"mousemove"},end:{name:"mouseup"}};var iC;(function(e){e[e.RightClick=2]="RightClick"})(iC||(iC={}));class b4 extends M2{constructor(t){super(t,cne,ud(t.event.target))}}b4.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===iC.RightClick?!1:(r==null||r({event:n}),!0)}}];const gx={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class une extends M2{constructor(t){super(t,gx)}static setup(){return window.addEventListener(gx.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(gx.move.name,t)};function t(){}}}une.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r==null||r({event:n}),!0)}}];var Cf;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Cf||(Cf={}));var gb;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(gb||(gb={}));function dne(e){let{acceleration:t,activator:n=Cf.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=gb.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:h}=e;const p=hne({delta:d,disabled:!i}),[g,m]=kte(),b=R.useRef({x:0,y:0}),y=R.useRef({x:0,y:0}),v=R.useMemo(()=>{switch(n){case Cf.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Cf.DraggableRect:return o}},[n,o,l]),x=R.useRef(null),S=R.useCallback(()=>{const E=x.current;if(!E)return;const C=b.current.x*y.current.x,k=b.current.y*y.current.y;E.scrollBy(C,k)},[]),_=R.useMemo(()=>a===gb.TreeOrder?[...c].reverse():c,[a,c]);R.useEffect(()=>{if(!i||!c.length||!v){m();return}for(const E of _){if((r==null?void 0:r(E))===!1)continue;const C=c.indexOf(E),k=u[C];if(!k)continue;const{direction:N,speed:M}=ene(E,k,v,t,h);for(const I of["x","y"])p[I][N[I]]||(M[I]=0,N[I]=0);if(M.x>0||M.y>0){m(),x.current=E,g(S,s),b.current=M,y.current=N;return}}b.current={x:0,y:0},y.current={x:0,y:0},m()},[t,S,r,m,i,s,JSON.stringify(v),JSON.stringify(p),g,c,_,u,JSON.stringify(h)])}const fne={x:{[In.Backward]:!1,[In.Forward]:!1},y:{[In.Backward]:!1,[In.Forward]:!1}};function hne(e){let{delta:t,disabled:n}=e;const r=hb(t);return dp(o=>{if(n||!r||!o)return fne;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[In.Backward]:o.x[In.Backward]||i.x===-1,[In.Forward]:o.x[In.Forward]||i.x===1},y:{[In.Backward]:o.y[In.Backward]||i.y===-1,[In.Forward]:o.y[In.Forward]||i.y===1}}},[n,t,r])}function pne(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return dp(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function mne(e,t){return R.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...i]},[]),[e,t])}var ah;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(ah||(ah={}));var sC;(function(e){e.Optimized="optimized"})(sC||(sC={}));const GM=new Map;function gne(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,s]=R.useState(null),{frequency:a,measure:l,strategy:c}=o,u=R.useRef(e),d=b(),h=oh(d),p=R.useCallback(function(y){y===void 0&&(y=[]),!h.current&&s(v=>v===null?y:v.concat(y.filter(x=>!v.includes(x))))},[h]),g=R.useRef(null),m=dp(y=>{if(d&&!n)return GM;if(!y||y===GM||u.current!==e||i!=null){const v=new Map;for(let x of e){if(!x)continue;if(i&&i.length>0&&!i.includes(x.id)&&x.rect.current){v.set(x.id,x.rect.current);continue}const S=x.node.current,_=S?new N2(l(S),S):null;x.rect.current=_,_&&v.set(x.id,_)}return v}return y},[e,i,n,d,l]);return R.useEffect(()=>{u.current=e},[e]),R.useEffect(()=>{d||p()},[n,d]),R.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),R.useEffect(()=>{d||typeof a!="number"||g.current!==null||(g.current=setTimeout(()=>{p(),g.current=null},a))},[a,d,p,...r]),{droppableRects:m,measureDroppableContainers:p,measuringScheduled:i!=null};function b(){switch(c){case ah.Always:return!1;case ah.BeforeDragging:return n;default:return!n}}}function P2(e,t){return dp(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function bne(e,t){return P2(e,t)}function yne(e){let{callback:t,disabled:n}=e;const r=ny(t),o=R.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return R.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function iy(e){let{callback:t,disabled:n}=e;const r=ny(t),o=R.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return R.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function vne(e){return new N2(dd(e),e)}function YM(e,t,n){t===void 0&&(t=vne);const[r,o]=R.useState(null);function i(){o(l=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=t(e);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=yne({callback(l){if(e)for(const c of l){const{type:u,target:d}=c;if(u==="childList"&&d instanceof HTMLElement&&d.contains(e)){i();break}}}}),a=iy({callback:i});return Uo(()=>{i(),e?(a==null||a.observe(e),s==null||s.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),s==null||s.disconnect())},[e]),r}function xne(e){const t=P2(e);return a4(e,t)}const KM=[];function wne(e){const t=R.useRef(e),n=dp(r=>e?r&&r!==KM&&e&&t.current&&e.parentNode===t.current.parentNode?r:oy(e):KM,[e]);return R.useEffect(()=>{t.current=e},[e]),n}function Cne(e){const[t,n]=R.useState(null),r=R.useRef(e),o=R.useCallback(i=>{const s=px(i.target);s&&n(a=>a?(a.set(s,oC(s)),new Map(a)):null)},[]);return R.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const c=px(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,oC(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{s(e),s(i)};function s(a){a.forEach(l=>{const c=px(l);c==null||c.removeEventListener("scroll",o)})}},[o,e]),R.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>iu(i,s),qo):p4(e):qo,[e,t])}function XM(e,t){t===void 0&&(t=[]);const n=R.useRef(null);return R.useEffect(()=>{n.current=null},t),R.useEffect(()=>{const r=e!==qo;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?ih(e,n.current):qo}function Sne(e){R.useEffect(()=>{if(!ty)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function Ene(e,t){return R.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,t)},n},{}),[e,t])}function y4(e){return R.useMemo(()=>e?Xte(e):null,[e])}const QM=[];function _ne(e,t){t===void 0&&(t=dd);const[n]=e,r=y4(n?wr(n):null),[o,i]=R.useState(QM);function s(){i(()=>e.length?e.map(l=>f4(l)?r:new N2(t(l),l)):QM)}const a=iy({callback:s});return Uo(()=>{a==null||a.disconnect(),s(),e.forEach(l=>a==null?void 0:a.observe(l))},[e]),o}function v4(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return up(t)?t:e}function Rne(e){let{measure:t}=e;const[n,r]=R.useState(null),o=R.useCallback(c=>{for(const{target:u}of c)if(up(u)){r(d=>{const h=t(u);return d?{...d,width:h.width,height:h.height}:h});break}},[t]),i=iy({callback:o}),s=R.useCallback(c=>{const u=v4(c);i==null||i.disconnect(),u&&(i==null||i.observe(u)),r(u?t(u):null)},[t,i]),[a,l]=fb(s);return R.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const kne=[{sensor:pp,options:{}},{sensor:hp,options:{}}],Nne={current:{}},Pg={draggable:{measure:HM},droppable:{measure:HM,strategy:ah.WhileDragging,frequency:sC.Optimized},dragOverlay:{measure:dd}};class Sf extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Mne={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Sf,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:mb},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Pg,measureDroppableContainers:mb,windowRect:null,measuringScheduled:!1},x4={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:mb,draggableNodes:new Map,over:null,measureDroppableContainers:mb},mp=R.createContext(x4),w4=R.createContext(Mne);function Pne(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Sf}}}function Dne(e,t){switch(t.type){case Nn.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Nn.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Nn.DragEnd:case Nn.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Nn.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Sf(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case Nn.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const s=new Sf(e.droppable.containers);return s.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case Nn.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Sf(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Ine(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=R.useContext(mp),i=hb(r),s=hb(n==null?void 0:n.id);return R.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!ry(i)||document.activeElement===i.target)return;const a=o.get(s);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const d=Pte(u);if(d){d.focus();break}}})}},[r,t,o,s,i]),null}function C4(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function Ane(e){return R.useMemo(()=>({draggable:{...Pg.draggable,...e==null?void 0:e.draggable},droppable:{...Pg.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Pg.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function Tne(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=R.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Uo(()=>{if(!s&&!a||!t){i.current=!1;return}if(i.current||!r)return;const c=t==null?void 0:t.node.current;if(!c||c.isConnected===!1)return;const u=n(c),d=a4(u,r);if(s||(d.x=0),a||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=c4(c);h&&h.scrollBy({top:d.y,left:d.x})}},[t,s,a,r,n])}const sy=R.createContext({...qo,scaleX:1,scaleY:1});var Hs;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Hs||(Hs={}));const D2=R.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=kne,collisionDetection:d=Wte,measuring:h,modifiers:p,...g}=t;const m=R.useReducer(Dne,void 0,Pne),[b,y]=m,[v,x]=Ote(),[S,_]=R.useState(Hs.Uninitialized),E=S===Hs.Initialized,{draggable:{active:C,nodes:k,translate:N},droppable:{containers:M}}=b,I=C!=null?k.get(C):null,D=R.useRef({initial:null,translated:null}),j=R.useMemo(()=>{var an;return C!=null?{id:C,data:(an=I==null?void 0:I.data)!=null?an:Nne,rect:D}:null},[C,I]),F=R.useRef(null),[T,O]=R.useState(null),[$,B]=R.useState(null),z=oh(g,Object.values(g)),A=fp("DndDescribedBy",s),W=R.useMemo(()=>M.getEnabled(),[M]),L=Ane(h),{droppableRects:P,measureDroppableContainers:H,measuringScheduled:V}=gne(W,{dragging:E,dependencies:[N.x,N.y],config:L.droppable}),G=pne(k,C),q=R.useMemo(()=>$?pb($):null,[$]),Y=Wi(),K=bne(G,L.draggable.measure);Tne({activeNode:C!=null?k.get(C):null,config:Y.layoutShiftCompensation,initialRect:K,measure:L.draggable.measure});const Z=YM(G,L.draggable.measure,K),ee=YM(G?G.parentElement:null),Q=R.useRef({activatorEvent:null,active:null,activeNode:G,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:k,draggingNode:null,draggingNodeRect:null,droppableContainers:M,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=M.getNodeFor((n=Q.current.over)==null?void 0:n.id),te=Rne({measure:L.dragOverlay.measure}),ce=(r=te.nodeRef.current)!=null?r:G,ue=E?(o=te.rect)!=null?o:Z:null,Re=!!(te.nodeRef.current&&te.rect),ve=xne(Re?null:Z),we=y4(ce?wr(ce):null),De=wne(E?oe??G:null),Ye=_ne(De),_t=C4(p,{transform:{x:N.x-ve.x,y:N.y-ve.y,scaleX:1,scaleY:1},activatorEvent:$,active:j,activeNodeRect:Z,containerNodeRect:ee,draggingNodeRect:ue,over:Q.current.over,overlayNodeRect:te.rect,scrollableAncestors:De,scrollableAncestorRects:Ye,windowRect:we}),me=q?iu(q,N):null,je=Cne(De),Ie=XM(je),ne=XM(je,[Z]),le=iu(_t,Ie),ke=ue?Gte(ue,_t):null,Pe=j&&ke?d({active:j,collisionRect:ke,droppableRects:P,droppableContainers:W,pointerCoordinates:me}):null,Ue=s4(Pe,"id"),[jt,kn]=R.useState(null),gn=Re?_t:iu(_t,ne),ge=Ute(gn,(i=jt==null?void 0:jt.rect)!=null?i:null,Z),bn=R.useRef(null),Ot=R.useCallback((an,Rt)=>{let{sensor:Fn,options:Ae}=Rt;if(F.current==null)return;const qe=k.get(F.current);if(!qe)return;const rt=an.nativeEvent,Jt=new Fn({active:F.current,activeNode:qe,event:rt,options:Ae,context:Q,onAbort(Lt){if(!k.get(Lt))return;const{onDragAbort:en}=z.current,yn={id:Lt};en==null||en(yn),v({type:"onDragAbort",event:yn})},onPending(Lt,Dn,en,yn){if(!k.get(Lt))return;const{onDragPending:fo}=z.current,ri={id:Lt,constraint:Dn,initialCoordinates:en,offset:yn};fo==null||fo(ri),v({type:"onDragPending",event:ri})},onStart(Lt){const Dn=F.current;if(Dn==null)return;const en=k.get(Dn);if(!en)return;const{onDragStart:yn}=z.current,Ba={activatorEvent:rt,active:{id:Dn,data:en.data,rect:D}};rn.unstable_batchedUpdates(()=>{yn==null||yn(Ba),_(Hs.Initializing),y({type:Nn.DragStart,initialCoordinates:Lt,active:Dn}),v({type:"onDragStart",event:Ba}),O(bn.current),B(rt)})},onMove(Lt){y({type:Nn.DragMove,coordinates:Lt})},onEnd:Ft(Nn.DragEnd),onCancel:Ft(Nn.DragCancel)});bn.current=Jt;function Ft(Lt){return async function(){const{active:en,collisions:yn,over:Ba,scrollAdjustedTranslate:fo}=Q.current;let ri=null;if(en&&fo){const{cancelDrop:Va}=z.current;ri={activatorEvent:rt,active:en,collisions:yn,delta:fo,over:Ba},Lt===Nn.DragEnd&&typeof Va=="function"&&await Promise.resolve(Va(ri))&&(Lt=Nn.DragCancel)}F.current=null,rn.unstable_batchedUpdates(()=>{y({type:Lt}),_(Hs.Uninitialized),kn(null),O(null),B(null),bn.current=null;const Va=Lt===Nn.DragEnd?"onDragEnd":"onDragCancel";if(ri){const Id=z.current[Va];Id==null||Id(ri),v({type:Va,event:ri})}})}}},[k]),uo=R.useCallback((an,Rt)=>(Fn,Ae)=>{const qe=Fn.nativeEvent,rt=k.get(Ae);if(F.current!==null||!rt||qe.dndKit||qe.defaultPrevented)return;const Jt={active:rt};an(Fn,Rt.options,Jt)===!0&&(qe.dndKit={capturedBy:Rt.sensor},F.current=Ae,Ot(Fn,Rt))},[k,Ot]),On=mne(u,uo);Sne(u),Uo(()=>{Z&&S===Hs.Initializing&&_(Hs.Initialized)},[Z,S]),R.useEffect(()=>{const{onDragMove:an}=z.current,{active:Rt,activatorEvent:Fn,collisions:Ae,over:qe}=Q.current;if(!Rt||!Fn)return;const rt={active:Rt,activatorEvent:Fn,collisions:Ae,delta:{x:le.x,y:le.y},over:qe};rn.unstable_batchedUpdates(()=>{an==null||an(rt),v({type:"onDragMove",event:rt})})},[le.x,le.y]),R.useEffect(()=>{const{active:an,activatorEvent:Rt,collisions:Fn,droppableContainers:Ae,scrollAdjustedTranslate:qe}=Q.current;if(!an||F.current==null||!Rt||!qe)return;const{onDragOver:rt}=z.current,Jt=Ae.get(Ue),Ft=Jt&&Jt.rect.current?{id:Jt.id,rect:Jt.rect.current,data:Jt.data,disabled:Jt.disabled}:null,Lt={active:an,activatorEvent:Rt,collisions:Fn,delta:{x:qe.x,y:qe.y},over:Ft};rn.unstable_batchedUpdates(()=>{kn(Ft),rt==null||rt(Lt),v({type:"onDragOver",event:Lt})})},[Ue]),Uo(()=>{Q.current={activatorEvent:$,active:j,activeNode:G,collisionRect:ke,collisions:Pe,droppableRects:P,draggableNodes:k,draggingNode:ce,draggingNodeRect:ue,droppableContainers:M,over:jt,scrollableAncestors:De,scrollAdjustedTranslate:le},D.current={initial:ue,translated:ke}},[j,G,Pe,ke,k,ce,ue,P,M,jt,De,le]),dne({...Y,delta:N,draggingRect:ke,pointerCoordinates:me,scrollableAncestors:De,scrollableAncestorRects:Ye});const Cc=R.useMemo(()=>({active:j,activeNode:G,activeNodeRect:Z,activatorEvent:$,collisions:Pe,containerNodeRect:ee,dragOverlay:te,draggableNodes:k,droppableContainers:M,droppableRects:P,over:jt,measureDroppableContainers:H,scrollableAncestors:De,scrollableAncestorRects:Ye,measuringConfiguration:L,measuringScheduled:V,windowRect:we}),[j,G,Z,$,Pe,ee,te,k,M,P,jt,H,De,Ye,L,V,we]),za=R.useMemo(()=>({activatorEvent:$,activators:On,active:j,activeNodeRect:Z,ariaDescribedById:{draggable:A},dispatch:y,draggableNodes:k,over:jt,measureDroppableContainers:H}),[$,On,j,Z,y,A,k,jt,H]);return R.createElement(r4.Provider,{value:x},R.createElement(mp.Provider,{value:za},R.createElement(w4.Provider,{value:Cc},R.createElement(sy.Provider,{value:ge},c)),R.createElement(Ine,{disabled:(a==null?void 0:a.restoreFocus)===!1})),R.createElement($te,{...a,hiddenTextDescribedById:A}));function Wi(){const an=(T==null?void 0:T.autoScrollEnabled)===!1,Rt=typeof l=="object"?l.enabled===!1:l===!1,Fn=E&&!an&&!Rt;return typeof l=="object"?{...l,enabled:Fn}:{enabled:Fn}}}),jne=R.createContext(null),ZM="button",One="Draggable";function S4(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=fp(One),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:h}=R.useContext(mp),{role:p=ZM,roleDescription:g="draggable",tabIndex:m=0}=o??{},b=(l==null?void 0:l.id)===t,y=R.useContext(b?sy:jne),[v,x]=fb(),[S,_]=fb(),E=Ene(s,t),C=oh(n);Uo(()=>(d.set(t,{id:t,key:i,node:v,activatorNode:S,data:C}),()=>{const N=d.get(t);N&&N.key===i&&d.delete(t)}),[d,t]);const k=R.useMemo(()=>({role:p,tabIndex:m,"aria-disabled":r,"aria-pressed":b&&p===ZM?!0:void 0,"aria-roledescription":g,"aria-describedby":u.draggable}),[r,p,m,b,g,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:k,isDragging:b,listeners:r?void 0:E,node:v,over:h,setNodeRef:x,setActivatorNodeRef:_,transform:y}}function E4(){return R.useContext(w4)}const Fne="Droppable",Lne={timeout:25};function _4(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=fp(Fne),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=R.useContext(mp),u=R.useRef({disabled:n}),d=R.useRef(!1),h=R.useRef(null),p=R.useRef(null),{disabled:g,updateMeasurementsFor:m,timeout:b}={...Lne,...o},y=oh(m??r),v=R.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),p.current=null},b)},[b]),x=iy({callback:v,disabled:g||!s}),S=R.useCallback((k,N)=>{x&&(N&&(x.unobserve(N),d.current=!1),k&&x.observe(k))},[x]),[_,E]=fb(S),C=oh(t);return R.useEffect(()=>{!x||!_.current||(x.disconnect(),d.current=!1,x.observe(_.current))},[_,x]),R.useEffect(()=>(a({type:Nn.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:h,data:C}}),()=>a({type:Nn.UnregisterDroppable,key:i,id:r})),[r]),R.useEffect(()=>{n!==u.current.disabled&&(a({type:Nn.SetDroppableDisabled,id:r,key:i,disabled:n}),u.current.disabled=n)},[r,i,n,a]),{active:s,rect:h,isOver:(l==null?void 0:l.id)===r,node:_,over:l,setNodeRef:E}}function $ne(e){let{animation:t,children:n}=e;const[r,o]=R.useState(null),[i,s]=R.useState(null),a=hb(n);return!n&&!r&&a&&o(a),Uo(()=>{if(!i)return;const l=r==null?void 0:r.key,c=r==null?void 0:r.props.id;if(l==null||c==null){o(null);return}Promise.resolve(t(c,i)).then(()=>{o(null)})},[t,r,i]),R.createElement(R.Fragment,null,n,r?R.cloneElement(r,{ref:s}):null)}const zne={x:0,y:0,scaleX:1,scaleY:1};function Bne(e){let{children:t}=e;return R.createElement(mp.Provider,{value:x4},R.createElement(sy.Provider,{value:zne},t))}const Vne={position:"fixed",touchAction:"none"},Hne=e=>ry(e)?"transform 250ms ease":void 0,Wne=R.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=Hne}=e;if(!a)return null;const d=o?c:{...c,scaleX:1,scaleY:1},h={...Vne,width:a.width,height:a.height,top:a.top,left:a.left,transform:ki.Transform.toString(d),transformOrigin:o&&r?zte(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return R.createElement(n,{className:s,style:h,ref:t},i)}),Une=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:s}=e;if(i!=null&&i.active)for(const[a,l]of Object.entries(i.active))l!==void 0&&(o[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(i!=null&&i.dragOverlay)for(const[a,l]of Object.entries(i.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return s!=null&&s.active&&n.node.classList.add(s.active),s!=null&&s.dragOverlay&&r.node.classList.add(s.dragOverlay),function(){for(const[l,c]of Object.entries(o))n.node.style.setProperty(l,c);s!=null&&s.active&&n.node.classList.remove(s.active)}},qne=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:ki.Transform.toString(t)},{transform:ki.Transform.toString(n)}]},Gne={duration:250,easing:"ease",keyframes:qne,sideEffects:Une({styles:{active:{opacity:"0"}}})};function Yne(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return ny((i,s)=>{if(t===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=v4(s);if(!c)return;const{transform:u}=wr(s).getComputedStyle(s),d=l4(u);if(!d)return;const h=typeof t=="function"?t:Kne(t);return m4(l,o.draggable.measure),h({active:{id:i,data:a.data,node:l,rect:o.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:s,rect:o.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:o,transform:d})})}function Kne(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...Gne,...e};return i=>{let{active:s,dragOverlay:a,transform:l,...c}=i;if(!t)return;const u={x:a.rect.left-s.rect.left,y:a.rect.top-s.rect.top},d={scaleX:l.scaleX!==1?s.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?s.rect.height*l.scaleY/a.rect.height:1},h={x:l.x-u.x,y:l.y-u.y,...d},p=o({...c,active:s,dragOverlay:a,transform:{initial:l,final:h}}),[g]=p,m=p[p.length-1];if(JSON.stringify(g)===JSON.stringify(m))return;const b=r==null?void 0:r({active:s,dragOverlay:a,...c}),y=a.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(v=>{y.onfinish=()=>{b==null||b(),v()}})}}let JM=0;function Xne(e){return R.useMemo(()=>{if(e!=null)return JM++,JM},[e])}const R4=R.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:s,wrapperElement:a="div",className:l,zIndex:c=999}=e;const{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggableNodes:g,droppableContainers:m,dragOverlay:b,over:y,measuringConfiguration:v,scrollableAncestors:x,scrollableAncestorRects:S,windowRect:_}=E4(),E=R.useContext(sy),C=Xne(d==null?void 0:d.id),k=C4(s,{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:b.rect,over:y,overlayNodeRect:b.rect,scrollableAncestors:x,scrollableAncestorRects:S,transform:E,windowRect:_}),N=P2(h),M=Yne({config:r,draggableNodes:g,droppableContainers:m,measuringConfiguration:v}),I=N?b.setRef:void 0;return R.createElement(Bne,null,R.createElement($ne,{animation:M},d&&C?R.createElement(Wne,{key:C,id:d.id,ref:I,as:a,activatorEvent:u,adjustScale:t,className:l,transition:i,rect:N,style:{zIndex:c,...o},transform:k},n):null))});function gp(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Qne(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Cm(e){return e!==null&&e>=0}function Zne(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Jne(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Sm={scaleX:1,scaleY:1},ere=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:i,index:s}=e;const a=(t=n[o])!=null?t:r;if(!a)return null;const l=tre(n,s,o);if(s===o){const c=n[i];return c?{x:o<i?c.left+c.width-(a.left+a.width):c.left-a.left,y:0,...Sm}:null}return s>o&&s<=i?{x:-a.width-l,y:0,...Sm}:s<o&&s>=i?{x:a.width+l,y:0,...Sm}:{x:0,y:0,...Sm}};function tre(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return!r||!o&&!i?0:n<t?o?r.left-(o.left+o.width):i.left-(r.left+r.width):i?i.left-(r.left+r.width):r.left-(o.left+o.width)}const k4=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=gp(t,r,n),s=t[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},Em={scaleX:1,scaleY:1},N4=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:s}=e;const a=(t=i[n])!=null?t:r;if(!a)return null;if(o===n){const c=i[s];return c?{x:0,y:n<s?c.top+c.height-(a.top+a.height):c.top-a.top,...Em}:null}const l=nre(i,o,n);return o>n&&o<=s?{x:0,y:-a.height-l,...Em}:o<n&&o>=s?{x:0,y:a.height+l,...Em}:{x:0,y:0,...Em}};function nre(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const M4="Sortable",P4=R.createContext({activeIndex:-1,containerId:M4,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:k4,disabled:{draggable:!1,droppable:!1}});function I2(e){let{children:t,id:n,items:r,strategy:o=k4,disabled:i=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=E4(),d=fp(M4,n),h=a.rect!==null,p=R.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),g=s!=null,m=s?p.indexOf(s.id):-1,b=c?p.indexOf(c.id):-1,y=R.useRef(p),v=!Zne(p,y.current),x=b!==-1&&m===-1||v,S=Jne(i);Uo(()=>{v&&g&&u(p)},[v,p,g,u]),R.useEffect(()=>{y.current=p},[p]);const _=R.useMemo(()=>({activeIndex:m,containerId:d,disabled:S,disableTransforms:x,items:p,overIndex:b,useDragOverlay:h,sortedRects:Qne(p,l),strategy:o}),[m,d,S.draggable,S.droppable,x,p,b,l,h,o]);return R.createElement(P4.Provider,{value:_},t)}const rre=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return gp(n,r,o).indexOf(t)},ore=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==i&&o===s?!1:n?!0:s!==o&&t===l},ire={duration:200,easing:"ease"},D4="transform",sre=ki.Transition.toString({property:D4,duration:0,easing:"linear"}),are={roleDescription:"sortable"};function lre(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=R.useState(null),a=R.useRef(n);return Uo(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=dd(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==a.current&&(a.current=n)},[t,n,r,o]),R.useEffect(()=>{i&&s(null)},[i]),i}function A2(e){let{animateLayoutChanges:t=ore,attributes:n,disabled:r,data:o,getNewIndex:i=rre,id:s,strategy:a,resizeObserverConfig:l,transition:c=ire}=e;const{items:u,containerId:d,activeIndex:h,disabled:p,disableTransforms:g,sortedRects:m,overIndex:b,useDragOverlay:y,strategy:v}=R.useContext(P4),x=cre(r,p),S=u.indexOf(s),_=R.useMemo(()=>({sortable:{containerId:d,index:S,items:u},...o}),[d,o,S,u]),E=R.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:C,node:k,isOver:N,setNodeRef:M}=_4({id:s,data:_,disabled:x.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...l}}),{active:I,activatorEvent:D,activeNodeRect:j,attributes:F,setNodeRef:T,listeners:O,isDragging:$,over:B,setActivatorNodeRef:z,transform:A}=S4({id:s,data:_,attributes:{...are,...n},disabled:x.draggable}),W=Rte(M,T),L=!!I,P=L&&!g&&Cm(h)&&Cm(b),H=!y&&$,V=H&&P?A:null,q=P?V??(a??v)({rects:m,activeNodeRect:j,activeIndex:h,overIndex:b,index:S}):null,Y=Cm(h)&&Cm(b)?i({id:s,items:u,activeIndex:h,overIndex:b}):S,K=I==null?void 0:I.id,Z=R.useRef({activeId:K,items:u,newIndex:Y,containerId:d}),ee=u!==Z.current.items,Q=t({active:I,containerId:d,isDragging:$,isSorting:L,id:s,index:S,items:u,newIndex:Z.current.newIndex,previousItems:Z.current.items,previousContainerId:Z.current.containerId,transition:c,wasDragging:Z.current.activeId!=null}),oe=lre({disabled:!Q,index:S,node:k,rect:C});return R.useEffect(()=>{L&&Z.current.newIndex!==Y&&(Z.current.newIndex=Y),d!==Z.current.containerId&&(Z.current.containerId=d),u!==Z.current.items&&(Z.current.items=u)},[L,Y,d,u]),R.useEffect(()=>{if(K===Z.current.activeId)return;if(K!=null&&Z.current.activeId==null){Z.current.activeId=K;return}const ce=setTimeout(()=>{Z.current.activeId=K},50);return()=>clearTimeout(ce)},[K]),{active:I,activeIndex:h,attributes:F,data:_,rect:C,index:S,newIndex:Y,items:u,isOver:N,isSorting:L,isDragging:$,listeners:O,node:k,overIndex:b,over:B,setNodeRef:W,setActivatorNodeRef:z,setDroppableNodeRef:M,setDraggableNodeRef:T,transform:oe??q,transition:te()};function te(){if(oe||ee&&Z.current.newIndex===S)return sre;if(!(H&&!ry(D)||!c)&&(L||Q))return ki.Transition.toString({...c,property:D4})}}function cre(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:t.droppable}}function bb(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const ure=[ht.Down,ht.Right,ht.Up,ht.Left],T2=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:s,scrollableAncestors:a}}=t;if(ure.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const h=o.get(d.id);if(h)switch(e.code){case ht.Down:r.top<h.top&&l.push(d);break;case ht.Up:r.top>h.top&&l.push(d);break;case ht.Left:r.left>h.left&&l.push(d);break;case ht.Right:r.left<h.left&&l.push(d);break}});const c=Vte({collisionRect:r,droppableRects:o,droppableContainers:l});let u=s4(c,"id");if(u===(s==null?void 0:s.id)&&c.length>1&&(u=c[1].id),u!=null){const d=i.get(n.id),h=i.get(u),p=h?o.get(h.id):null,g=h==null?void 0:h.node.current;if(g&&p&&d&&h){const b=oy(g).some((E,C)=>a[C]!==E),y=I4(d,h),v=dre(d,h),x=b||!y?{x:0,y:0}:{x:v?r.width-p.width:0,y:v?r.height-p.height:0},S={x:p.left,y:p.top};return x.x&&x.y?S:ih(S,x)}}}};function I4(e,t){return!bb(e)||!bb(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function dre(e,t){return!bb(e)||!bb(t)||!I4(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function fre(e,t,n){const[r,o]=R.useState(null),[i,s]=R.useState(""),a=()=>{const g={id:`hierarchy_${Date.now()}`,label:i||"New Hierarchy",type:"static",steps:[],default:!1};t([...e,g]),s(""),o(g.id)},l=g=>{t(e.filter(m=>m.id!==g))},c=(g,m)=>{t(e.map(b=>b.id===g?{...b,...m}:b))};return{editingHierarchy:r,setEditingHierarchy:o,newHierarchyName:i,setNewHierarchyName:s,createNewHierarchy:a,deleteHierarchy:l,updateHierarchy:c,addStepToHierarchy:(g,m)=>{const b=n.find(x=>x.id===m);if(!b)return;const y={field:b,mode:"drillDown",label:`Drill to ${b.label}`,retainFilters:!0,preferredChartType:"bar"},v=e.find(x=>x.id===g);v&&c(g,{steps:[...v.steps,y]})},removeStepFromHierarchy:(g,m)=>{const b=e.find(y=>y.id===g);if(b){const y=[...b.steps];y.splice(m,1),c(g,{steps:y})}},updateStep:(g,m,b)=>{const y=e.find(v=>v.id===g);if(y){const v=y.steps.map((x,S)=>S===m?{...x,...b}:x);c(g,{steps:v})}},setDefaultHierarchy:g=>{t(e.map(m=>({...m,default:m.id===g})))}}}function hre({value:e,isEditing:t,onEdit:n,onSave:r,onCancel:o,placeholder:i="Enter text...",inputClassName:s="",displayClassName:a=""}){const[l,c]=R.useState(e);R.useEffect(()=>{c(e)},[e]);const u=g=>{g.key===" "&&g.stopPropagation(),g.key==="Enter"?r(l):g.key==="Escape"&&(c(e),o())},d=()=>{r(l)},h=g=>{g.stopPropagation()},p=g=>{g.stopPropagation()};return t?f.jsx("input",{type:"text",value:l,onChange:g=>c(g.target.value),onKeyDown:u,onBlur:d,onMouseDown:h,onPointerDown:p,className:`min-w-0 border-b border-blue-300 bg-transparent focus:border-blue-500 focus:outline-none dark:border-blue-600 dark:focus:border-blue-400 ${s}`,placeholder:i,autoFocus:!0}):f.jsx("span",{className:`cursor-pointer transition-colors hover:text-blue-600 dark:hover:text-blue-400 ${a}`,onClick:g=>{g.stopPropagation(),n()},onPointerDown:g=>g.stopPropagation(),title:"Click to edit",children:e||i})}function pre(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e);w.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 mre="DismissableLayer",aC="dismissableLayer.update",gre="dismissableLayer.pointerDownOutside",bre="dismissableLayer.focusOutside",eP,A4=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),hc=w.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...l}=e,c=w.useContext(A4),[u,d]=w.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=w.useState({}),g=Ve(t,C=>d(C)),m=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=m.indexOf(b),v=u?m.indexOf(u):-1,x=c.layersWithOutsidePointerEventsDisabled.size>0,S=v>=y,_=xre(C=>{const k=C.target,N=[...c.branches].some(M=>M.contains(k));!S||N||(o==null||o(C),s==null||s(C),C.defaultPrevented||a==null||a())},h),E=wre(C=>{const k=C.target;[...c.branches].some(M=>M.contains(k))||(i==null||i(C),s==null||s(C),C.defaultPrevented||a==null||a())},h);return pre(C=>{v===c.layers.size-1&&(r==null||r(C),!C.defaultPrevented&&a&&(C.preventDefault(),a()))},h),w.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(eP=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),tP(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=eP)}},[u,h,n,c]),w.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),tP())},[u,c]),w.useEffect(()=>{const C=()=>p({});return document.addEventListener(aC,C),()=>document.removeEventListener(aC,C)},[]),f.jsx(_e.div,{...l,ref:g,style:{pointerEvents:x?S?"auto":"none":void 0,...e.style},onFocusCapture:fe(e.onFocusCapture,E.onFocusCapture),onBlurCapture:fe(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:fe(e.onPointerDownCapture,_.onPointerDownCapture)})});hc.displayName=mre;var yre="DismissableLayerBranch",vre=w.forwardRef((e,t)=>{const n=w.useContext(A4),r=w.useRef(null),o=Ve(t,r);return w.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),f.jsx(_e.div,{...e,ref:o})});vre.displayName=yre;function xre(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=w.useRef(!1),o=w.useRef(()=>{});return w.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let l=function(){T4(gre,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function wre(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=w.useRef(!1);return w.useEffect(()=>{const o=i=>{i.target&&!r.current&&T4(bre,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function tP(){const e=new CustomEvent(aC);document.dispatchEvent(e)}function T4(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?jO(o,i):o.dispatchEvent(i)}var bx=0;function ay(){w.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??nP()),document.body.insertAdjacentElement("beforeend",e[1]??nP()),bx++,()=>{bx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),bx--}},[])}function nP(){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 yx="focusScope.autoFocusOnMount",vx="focusScope.autoFocusOnUnmount",rP={bubbles:!1,cancelable:!0},Cre="FocusScope",bp=w.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,l]=w.useState(null),c=Mn(o),u=Mn(i),d=w.useRef(null),h=Ve(t,m=>l(m)),p=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(r){let m=function(x){if(p.paused||!a)return;const S=x.target;a.contains(S)?d.current=S:Bs(d.current,{select:!0})},b=function(x){if(p.paused||!a)return;const S=x.relatedTarget;S!==null&&(a.contains(S)||Bs(d.current,{select:!0}))},y=function(x){if(document.activeElement===document.body)for(const _ of x)_.removedNodes.length>0&&Bs(a)};document.addEventListener("focusin",m),document.addEventListener("focusout",b);const v=new MutationObserver(y);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",b),v.disconnect()}}},[r,a,p.paused]),w.useEffect(()=>{if(a){iP.add(p);const m=document.activeElement;if(!a.contains(m)){const y=new CustomEvent(yx,rP);a.addEventListener(yx,c),a.dispatchEvent(y),y.defaultPrevented||(Sre(Nre(j4(a)),{select:!0}),document.activeElement===m&&Bs(a))}return()=>{a.removeEventListener(yx,c),setTimeout(()=>{const y=new CustomEvent(vx,rP);a.addEventListener(vx,u),a.dispatchEvent(y),y.defaultPrevented||Bs(m??document.body,{select:!0}),a.removeEventListener(vx,u),iP.remove(p)},0)}}},[a,c,u,p]);const g=w.useCallback(m=>{if(!n&&!r||p.paused)return;const b=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,y=document.activeElement;if(b&&y){const v=m.currentTarget,[x,S]=Ere(v);x&&S?!m.shiftKey&&y===S?(m.preventDefault(),n&&Bs(x,{select:!0})):m.shiftKey&&y===x&&(m.preventDefault(),n&&Bs(S,{select:!0})):y===v&&m.preventDefault()}},[n,r,p.paused]);return f.jsx(_e.div,{tabIndex:-1,...s,ref:h,onKeyDown:g})});bp.displayName=Cre;function Sre(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Bs(r,{select:t}),document.activeElement!==n)return}function Ere(e){const t=j4(e),n=oP(t,e),r=oP(t.reverse(),e);return[n,r]}function j4(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 oP(e,t){for(const n of e)if(!_re(n,{upTo:t}))return n}function _re(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 Rre(e){return e instanceof HTMLInputElement&&"select"in e}function Bs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Rre(e)&&t&&e.select()}}var iP=kre();function kre(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=sP(e,t),e.unshift(t)},remove(t){var n;e=sP(e,t),(n=e[0])==null||n.resume()}}}function sP(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Nre(e){return e.filter(t=>t.tagName!=="A")}const Mre=["top","right","bottom","left"],ws=Math.min,Xn=Math.max,lh=Math.round,_m=Math.floor,bi=e=>({x:e,y:e}),Pre={left:"right",right:"left",bottom:"top",top:"bottom"},Dre={start:"end",end:"start"};function lC(e,t,n){return Xn(e,ws(t,n))}function Ni(e,t){return typeof e=="function"?e(t):e}function Cs(e){return e.split("-")[0]}function fd(e){return e.split("-")[1]}function j2(e){return e==="x"?"y":"x"}function O2(e){return e==="y"?"height":"width"}function ha(e){return["top","bottom"].includes(Cs(e))?"y":"x"}function F2(e){return j2(ha(e))}function Ire(e,t,n){n===void 0&&(n=!1);const r=fd(e),o=F2(e),i=O2(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=yb(s)),[s,yb(s)]}function Are(e){const t=yb(e);return[cC(e),t,cC(t)]}function cC(e){return e.replace(/start|end/g,t=>Dre[t])}function Tre(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function jre(e,t,n,r){const o=fd(e);let i=Tre(Cs(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(cC)))),i}function yb(e){return e.replace(/left|right|bottom|top/g,t=>Pre[t])}function Ore(e){return{top:0,right:0,bottom:0,left:0,...e}}function O4(e){return typeof e!="number"?Ore(e):{top:e,right:e,bottom:e,left:e}}function vb(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 aP(e,t,n){let{reference:r,floating:o}=e;const i=ha(t),s=F2(t),a=O2(s),l=Cs(t),c=i==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-o.width,y:d};break;default:p={x:r.x,y:r.y}}switch(fd(t)){case"start":p[s]-=h*(n&&c?-1:1);break;case"end":p[s]+=h*(n&&c?-1:1);break}return p}const Fre=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=aP(c,r,l),h=r,p={},g=0;for(let m=0;m<a.length;m++){const{name:b,fn:y}=a[m],{x:v,y:x,data:S,reset:_}=await y({x:u,y:d,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:s,elements:{reference:e,floating:t}});u=v??u,d=x??d,p={...p,[b]:{...p[b],...S}},_&&g<=50&&(g++,typeof _=="object"&&(_.placement&&(h=_.placement),_.rects&&(c=_.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):_.rects),{x:u,y:d}=aP(c,h,l)),m=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:p}};async function $u(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:p=0}=Ni(t,e),g=O4(p),b=a[h?d==="floating"?"reference":"floating":d],y=vb(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=d==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),S=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},_=vb(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:l}):v);return{top:(y.top-_.top+g.top)/S.y,bottom:(_.bottom-y.bottom+g.bottom)/S.y,left:(y.left-_.left+g.left)/S.x,right:(_.right-y.right+g.right)/S.x}}const Lre=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Ni(e,t)||{};if(c==null)return{};const d=O4(u),h={x:n,y:r},p=F2(o),g=O2(p),m=await s.getDimensions(c),b=p==="y",y=b?"top":"left",v=b?"bottom":"right",x=b?"clientHeight":"clientWidth",S=i.reference[g]+i.reference[p]-h[p]-i.floating[g],_=h[p]-i.reference[p],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let C=E?E[x]:0;(!C||!await(s.isElement==null?void 0:s.isElement(E)))&&(C=a.floating[x]||i.floating[g]);const k=S/2-_/2,N=C/2-m[g]/2-1,M=ws(d[y],N),I=ws(d[v],N),D=M,j=C-m[g]-I,F=C/2-m[g]/2+k,T=lC(D,F,j),O=!l.arrow&&fd(o)!=null&&F!==T&&i.reference[g]/2-(F<D?M:I)-m[g]/2<0,$=O?F<D?F-D:F-j:0;return{[p]:h[p]+$,data:{[p]:T,centerOffset:F-T-$,...O&&{alignmentOffset:$}},reset:O}}}),$re=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...b}=Ni(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=Cs(o),v=ha(a),x=Cs(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=h||(x||!m?[yb(a)]:Are(a)),E=g!=="none";!h&&E&&_.push(...jre(a,m,g,S));const C=[a,..._],k=await $u(t,b),N=[];let M=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&N.push(k[y]),d){const F=Ire(o,s,S);N.push(k[F[0]],k[F[1]])}if(M=[...M,{placement:o,overflows:N}],!N.every(F=>F<=0)){var I,D;const F=(((I=i.flip)==null?void 0:I.index)||0)+1,T=C[F];if(T)return{data:{index:F,overflows:M},reset:{placement:T}};let O=(D=M.filter($=>$.overflows[0]<=0).sort(($,B)=>$.overflows[1]-B.overflows[1])[0])==null?void 0:D.placement;if(!O)switch(p){case"bestFit":{var j;const $=(j=M.filter(B=>{if(E){const z=ha(B.placement);return z===v||z==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(z=>z>0).reduce((z,A)=>z+A,0)]).sort((B,z)=>B[1]-z[1])[0])==null?void 0:j[0];$&&(O=$);break}case"initialPlacement":O=a;break}if(o!==O)return{reset:{placement:O}}}return{}}}};function lP(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function cP(e){return Mre.some(t=>e[t]>=0)}const zre=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Ni(e,t);switch(r){case"referenceHidden":{const i=await $u(t,{...o,elementContext:"reference"}),s=lP(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:cP(s)}}}case"escaped":{const i=await $u(t,{...o,altBoundary:!0}),s=lP(i,n.floating);return{data:{escapedOffsets:s,escaped:cP(s)}}}default:return{}}}}};async function Bre(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Cs(n),a=fd(n),l=ha(n)==="y",c=["left","top"].includes(s)?-1:1,u=i&&l?-1:1,d=Ni(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof g=="number"&&(p=a==="end"?g*-1:g),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}const Vre=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,l=await Bre(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:i+l.y,data:{...l,placement:s}}}}},Hre=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:b=>{let{x:y,y:v}=b;return{x:y,y:v}}},...l}=Ni(e,t),c={x:n,y:r},u=await $u(t,l),d=ha(Cs(o)),h=j2(d);let p=c[h],g=c[d];if(i){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",v=p+u[b],x=p-u[y];p=lC(v,p,x)}if(s){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",v=g+u[b],x=g-u[y];g=lC(v,g,x)}const m=a.fn({...t,[h]:p,[d]:g});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[h]:i,[d]:s}}}}}},Wre=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Ni(e,t),u={x:n,y:r},d=ha(o),h=j2(d);let p=u[h],g=u[d];const m=Ni(a,t),b=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const x=h==="y"?"height":"width",S=i.reference[h]-i.floating[x]+b.mainAxis,_=i.reference[h]+i.reference[x]-b.mainAxis;p<S?p=S:p>_&&(p=_)}if(c){var y,v;const x=h==="y"?"width":"height",S=["top","left"].includes(Cs(o)),_=i.reference[d]-i.floating[x]+(S&&((y=s.offset)==null?void 0:y[d])||0)+(S?0:b.crossAxis),E=i.reference[d]+i.reference[x]+(S?0:((v=s.offset)==null?void 0:v[d])||0)-(S?b.crossAxis:0);g<_?g=_:g>E&&(g=E)}return{[h]:p,[d]:g}}}},Ure=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:s,elements:a}=t,{apply:l=()=>{},...c}=Ni(e,t),u=await $u(t,c),d=Cs(o),h=fd(o),p=ha(o)==="y",{width:g,height:m}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=h===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(y=d,b=h==="end"?"top":"bottom");const v=m-u.top-u.bottom,x=g-u.left-u.right,S=ws(m-u[b],v),_=ws(g-u[y],x),E=!t.middlewareData.shift;let C=S,k=_;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),E&&!h){const M=Xn(u.left,0),I=Xn(u.right,0),D=Xn(u.top,0),j=Xn(u.bottom,0);p?k=g-2*(M!==0||I!==0?M+I:Xn(u.left,u.right)):C=m-2*(D!==0||j!==0?D+j:Xn(u.top,u.bottom))}await l({...t,availableWidth:k,availableHeight:C});const N=await s.getDimensions(a.floating);return g!==N.width||m!==N.height?{reset:{rects:!0}}:{}}}};function ly(){return typeof window<"u"}function hd(e){return F4(e)?(e.nodeName||"").toLowerCase():"#document"}function ro(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function $i(e){var t;return(t=(F4(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function F4(e){return ly()?e instanceof Node||e instanceof ro(e).Node:!1}function Qn(e){return ly()?e instanceof Element||e instanceof ro(e).Element:!1}function Mi(e){return ly()?e instanceof HTMLElement||e instanceof ro(e).HTMLElement:!1}function uP(e){return!ly()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ro(e).ShadowRoot}function yp(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Go(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function qre(e){return["table","td","th"].includes(hd(e))}function cy(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function L2(e){const t=$2(),n=Qn(e)?Go(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 Gre(e){let t=pa(e);for(;Mi(t)&&!zu(t);){if(L2(t))return t;if(cy(t))return null;t=pa(t)}return null}function $2(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function zu(e){return["html","body","#document"].includes(hd(e))}function Go(e){return ro(e).getComputedStyle(e)}function uy(e){return Qn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function pa(e){if(hd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||uP(e)&&e.host||$i(e);return uP(t)?t.host:t}function L4(e){const t=pa(e);return zu(t)?e.ownerDocument?e.ownerDocument.body:e.body:Mi(t)&&yp(t)?t:L4(t)}function ch(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=L4(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=ro(o);if(i){const a=uC(s);return t.concat(s,s.visualViewport||[],yp(o)?o:[],a&&n?ch(a):[])}return t.concat(o,ch(o,[],n))}function uC(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function $4(e){const t=Go(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Mi(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=lh(n)!==i||lh(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function z2(e){return Qn(e)?e:e.contextElement}function su(e){const t=z2(e);if(!Mi(t))return bi(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=$4(t);let s=(i?lh(n.width):n.width)/r,a=(i?lh(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const Yre=bi(0);function z4(e){const t=ro(e);return!$2()||!t.visualViewport?Yre:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Kre(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ro(e)?!1:t}function Wl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=z2(e);let s=bi(1);t&&(r?Qn(r)&&(s=su(r)):s=su(e));const a=Kre(i,n,r)?z4(i):bi(0);let l=(o.left+a.x)/s.x,c=(o.top+a.y)/s.y,u=o.width/s.x,d=o.height/s.y;if(i){const h=ro(i),p=r&&Qn(r)?ro(r):r;let g=h,m=uC(g);for(;m&&r&&p!==g;){const b=su(m),y=m.getBoundingClientRect(),v=Go(m),x=y.left+(m.clientLeft+parseFloat(v.paddingLeft))*b.x,S=y.top+(m.clientTop+parseFloat(v.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=x,c+=S,g=ro(m),m=uC(g)}}return vb({width:u,height:d,x:l,y:c})}function B2(e,t){const n=uy(e).scrollLeft;return t?t.left+n:Wl($i(e)).left+n}function B4(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:B2(e,r)),i=r.top+t.scrollTop;return{x:o,y:i}}function Xre(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=$i(r),a=t?cy(t.floating):!1;if(r===s||a&&i)return n;let l={scrollLeft:0,scrollTop:0},c=bi(1);const u=bi(0),d=Mi(r);if((d||!d&&!i)&&((hd(r)!=="body"||yp(s))&&(l=uy(r)),Mi(r))){const p=Wl(r);c=su(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=s&&!d&&!i?B4(s,l,!0):bi(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function Qre(e){return Array.from(e.getClientRects())}function Zre(e){const t=$i(e),n=uy(e),r=e.ownerDocument.body,o=Xn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Xn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+B2(e);const a=-n.scrollTop;return Go(r).direction==="rtl"&&(s+=Xn(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function Jre(e,t){const n=ro(e),r=$i(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,l=0;if(o){i=o.width,s=o.height;const c=$2();(!c||c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:i,height:s,x:a,y:l}}function eoe(e,t){const n=Wl(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Mi(e)?su(e):bi(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,l=o*i.x,c=r*i.y;return{width:s,height:a,x:l,y:c}}function dP(e,t,n){let r;if(t==="viewport")r=Jre(e,n);else if(t==="document")r=Zre($i(e));else if(Qn(t))r=eoe(t,n);else{const o=z4(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return vb(r)}function V4(e,t){const n=pa(e);return n===t||!Qn(n)||zu(n)?!1:Go(n).position==="fixed"||V4(n,t)}function toe(e,t){const n=t.get(e);if(n)return n;let r=ch(e,[],!1).filter(a=>Qn(a)&&hd(a)!=="body"),o=null;const i=Go(e).position==="fixed";let s=i?pa(e):e;for(;Qn(s)&&!zu(s);){const a=Go(s),l=L2(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||yp(s)&&!l&&V4(e,s))?r=r.filter(u=>u!==s):o=a,s=pa(s)}return t.set(e,r),r}function noe(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?cy(t)?[]:toe(t,this._c):[].concat(n),r],a=s[0],l=s.reduce((c,u)=>{const d=dP(t,u,o);return c.top=Xn(d.top,c.top),c.right=ws(d.right,c.right),c.bottom=ws(d.bottom,c.bottom),c.left=Xn(d.left,c.left),c},dP(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function roe(e){const{width:t,height:n}=$4(e);return{width:t,height:n}}function ooe(e,t,n){const r=Mi(t),o=$i(t),i=n==="fixed",s=Wl(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=bi(0);if(r||!r&&!i)if((hd(t)!=="body"||yp(o))&&(a=uy(t)),r){const h=Wl(t,!0,i,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&(l.x=B2(o));const c=o&&!r&&!i?B4(o,a):bi(0),u=s.left+a.scrollLeft-l.x-c.x,d=s.top+a.scrollTop-l.y-c.y;return{x:u,y:d,width:s.width,height:s.height}}function xx(e){return Go(e).position==="static"}function fP(e,t){if(!Mi(e)||Go(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return $i(e)===n&&(n=n.ownerDocument.body),n}function H4(e,t){const n=ro(e);if(cy(e))return n;if(!Mi(e)){let o=pa(e);for(;o&&!zu(o);){if(Qn(o)&&!xx(o))return o;o=pa(o)}return n}let r=fP(e,t);for(;r&&qre(r)&&xx(r);)r=fP(r,t);return r&&zu(r)&&xx(r)&&!L2(r)?n:r||Gre(e)||n}const ioe=async function(e){const t=this.getOffsetParent||H4,n=this.getDimensions,r=await n(e.floating);return{reference:ooe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function soe(e){return Go(e).direction==="rtl"}const aoe={convertOffsetParentRelativeRectToViewportRelativeRect:Xre,getDocumentElement:$i,getClippingRect:noe,getOffsetParent:H4,getElementRects:ioe,getClientRects:Qre,getDimensions:roe,getScale:su,isElement:Qn,isRTL:soe};function W4(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function loe(e,t){let n=null,r;const o=$i(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const c=e.getBoundingClientRect(),{left:u,top:d,width:h,height:p}=c;if(a||t(),!h||!p)return;const g=_m(d),m=_m(o.clientWidth-(u+h)),b=_m(o.clientHeight-(d+p)),y=_m(u),x={rootMargin:-g+"px "+-m+"px "+-b+"px "+-y+"px",threshold:Xn(0,ws(1,l))||1};let S=!0;function _(E){const C=E[0].intersectionRatio;if(C!==l){if(!S)return s();C?s(!1,C):r=setTimeout(()=>{s(!1,1e-7)},1e3)}C===1&&!W4(c,e.getBoundingClientRect())&&s(),S=!1}try{n=new IntersectionObserver(_,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,x)}n.observe(e)}return s(!0),i}function V2(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=z2(e),u=o||i?[...c?ch(c):[],...ch(t)]:[];u.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const d=c&&a?loe(c,n):null;let h=-1,p=null;s&&(p=new ResizeObserver(y=>{let[v]=y;v&&v.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let g,m=l?Wl(e):null;l&&b();function b(){const y=Wl(e);m&&!W4(m,y)&&n(),m=y,g=requestAnimationFrame(b)}return n(),()=>{var y;u.forEach(v=>{o&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),d==null||d(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const wx=$u,coe=Vre,uoe=Hre,doe=$re,foe=Ure,hoe=zre,hP=Lre,poe=Wre,moe=(e,t,n)=>{const r=new Map,o={platform:aoe,...n},i={...o.platform,_c:r};return Fre(e,t,{...o,platform:i})};var Dg=typeof document<"u"?R.useLayoutEffect:R.useEffect;function xb(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(!xb(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 i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!xb(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function U4(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function pP(e,t){const n=U4(e);return Math.round(t*n)/n}function Cx(e){const t=w.useRef(e);return Dg(()=>{t.current=e}),t}function H2(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=w.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=w.useState(r);xb(h,r)||p(r);const[g,m]=w.useState(null),[b,y]=w.useState(null),v=w.useCallback(B=>{B!==E.current&&(E.current=B,m(B))},[]),x=w.useCallback(B=>{B!==C.current&&(C.current=B,y(B))},[]),S=i||g,_=s||b,E=w.useRef(null),C=w.useRef(null),k=w.useRef(u),N=l!=null,M=Cx(l),I=Cx(o),D=Cx(c),j=w.useCallback(()=>{if(!E.current||!C.current)return;const B={placement:t,strategy:n,middleware:h};I.current&&(B.platform=I.current),moe(E.current,C.current,B).then(z=>{const A={...z,isPositioned:D.current!==!1};F.current&&!xb(k.current,A)&&(k.current=A,vs.flushSync(()=>{d(A)}))})},[h,t,n,I,D]);Dg(()=>{c===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,d(B=>({...B,isPositioned:!1})))},[c]);const F=w.useRef(!1);Dg(()=>(F.current=!0,()=>{F.current=!1}),[]),Dg(()=>{if(S&&(E.current=S),_&&(C.current=_),S&&_){if(M.current)return M.current(S,_,j);j()}},[S,_,j,M,N]);const T=w.useMemo(()=>({reference:E,floating:C,setReference:v,setFloating:x}),[v,x]),O=w.useMemo(()=>({reference:S,floating:_}),[S,_]),$=w.useMemo(()=>{const B={position:n,left:0,top:0};if(!O.floating)return B;const z=pP(O.floating,u.x),A=pP(O.floating,u.y);return a?{...B,transform:"translate("+z+"px, "+A+"px)",...U4(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:A}},[n,a,O.floating,u.x,u.y]);return w.useMemo(()=>({...u,update:j,refs:T,elements:O,floatingStyles:$}),[u,j,T,O,$])}const goe=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?hP({element:r.current,padding:o}).fn(n):{}:r?hP({element:r,padding:o}).fn(n):{}}}},dy=(e,t)=>({...coe(e),options:[e,t]}),W2=(e,t)=>({...uoe(e),options:[e,t]}),q4=(e,t)=>({...poe(e),options:[e,t]}),U2=(e,t)=>({...doe(e),options:[e,t]}),q2=(e,t)=>({...foe(e),options:[e,t]}),G4=(e,t)=>({...hoe(e),options:[e,t]}),Y4=(e,t)=>({...goe(e),options:[e,t]});var boe="Arrow",K4=w.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return f.jsx(_e.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:f.jsx("polygon",{points:"0,0 30,0 15,10"})})});K4.displayName=boe;var yoe=K4;function fy(e){const[t,n]=w.useState(void 0);return Vn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;s=c.inlineSize,a=c.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var G2="Popper",[X4,zi]=Pn(G2),[voe,Q4]=X4(G2),Z4=e=>{const{__scopePopper:t,children:n}=e,[r,o]=w.useState(null);return f.jsx(voe,{scope:t,anchor:r,onAnchorChange:o,children:n})};Z4.displayName=G2;var J4="PopperAnchor",e3=w.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=Q4(J4,n),s=w.useRef(null),a=Ve(t,s);return w.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:f.jsx(_e.div,{...o,ref:a})});e3.displayName=J4;var Y2="PopperContent",[xoe,woe]=X4(Y2),t3=w.forwardRef((e,t)=>{var q,Y,K,Z,ee,Q;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:g,...m}=e,b=Q4(Y2,n),[y,v]=w.useState(null),x=Ve(t,oe=>v(oe)),[S,_]=w.useState(null),E=fy(S),C=(E==null?void 0:E.width)??0,k=(E==null?void 0:E.height)??0,N=r+(i!=="center"?"-"+i:""),M=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},I=Array.isArray(c)?c:[c],D=I.length>0,j={padding:M,boundary:I.filter(Soe),altBoundary:D},{refs:F,floatingStyles:T,placement:O,isPositioned:$,middlewareData:B}=H2({strategy:"fixed",placement:N,whileElementsMounted:(...oe)=>V2(...oe,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[dy({mainAxis:o+k,alignmentAxis:s}),l&&W2({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?q4():void 0,...j}),l&&U2({...j}),q2({...j,apply:({elements:oe,rects:te,availableWidth:ce,availableHeight:ue})=>{const{width:Re,height:ve}=te.reference,we=oe.floating.style;we.setProperty("--radix-popper-available-width",`${ce}px`),we.setProperty("--radix-popper-available-height",`${ue}px`),we.setProperty("--radix-popper-anchor-width",`${Re}px`),we.setProperty("--radix-popper-anchor-height",`${ve}px`)}}),S&&Y4({element:S,padding:a}),Eoe({arrowWidth:C,arrowHeight:k}),h&&G4({strategy:"referenceHidden",...j})]}),[z,A]=o3(O),W=Mn(g);Vn(()=>{$&&(W==null||W())},[$,W]);const L=(q=B.arrow)==null?void 0:q.x,P=(Y=B.arrow)==null?void 0:Y.y,H=((K=B.arrow)==null?void 0:K.centerOffset)!==0,[V,G]=w.useState();return Vn(()=>{y&&G(window.getComputedStyle(y).zIndex)},[y]),f.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:$?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[(Z=B.transformOrigin)==null?void 0:Z.x,(ee=B.transformOrigin)==null?void 0:ee.y].join(" "),...((Q=B.hide)==null?void 0:Q.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:f.jsx(xoe,{scope:n,placedSide:z,onArrowChange:_,arrowX:L,arrowY:P,shouldHideArrow:H,children:f.jsx(_e.div,{"data-side":z,"data-align":A,...m,ref:x,style:{...m.style,animation:$?void 0:"none"}})})})});t3.displayName=Y2;var n3="PopperArrow",Coe={top:"bottom",right:"left",bottom:"top",left:"right"},r3=w.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=woe(n3,r),s=Coe[i.placedSide];return f.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:f.jsx(yoe,{...o,ref:n,style:{...o.style,display:"block"}})})});r3.displayName=n3;function Soe(e){return e!==null}var Eoe=e=>({name:"transformOrigin",options:e,fn(t){var b,y,v;const{placement:n,rects:r,middlewareData:o}=t,s=((b=o.arrow)==null?void 0:b.centerOffset)!==0,a=s?0:e.arrowWidth,l=s?0:e.arrowHeight,[c,u]=o3(n),d={start:"0%",center:"50%",end:"100%"}[u],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((v=o.arrow)==null?void 0:v.y)??0)+l/2;let g="",m="";return c==="bottom"?(g=s?d:`${h}px`,m=`${-l}px`):c==="top"?(g=s?d:`${h}px`,m=`${r.floating.height+l}px`):c==="right"?(g=`${-l}px`,m=s?d:`${p}px`):c==="left"&&(g=`${r.floating.width+l}px`,m=s?d:`${p}px`),{data:{x:g,y:m}}}});function o3(e){const[t,n="center"]=e.split("-");return[t,n]}var vp=Z4,pd=e3,xp=t3,wp=r3,_oe="Portal",pc=w.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,i]=w.useState(!1);Vn(()=>i(!0),[]);const s=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return s?rn.createPortal(f.jsx(_e.div,{...r,ref:t}),s):null});pc.displayName=_oe;var i3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(koe);if(i){const s=i.props.children,a=o.map(l=>l===i?w.Children.count(s)>1?w.Children.only(null):w.isValidElement(s)?s.props.children:null:l);return f.jsx(dC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(dC,{...r,ref:t,children:n})});i3.displayName="Slot";var dC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=Moe(n),i=Noe(r,n.props);return n.type!==w.Fragment&&(i.ref=t?vr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});dC.displayName="SlotClone";var Roe=({children:e})=>f.jsx(f.Fragment,{children:e});function koe(e){return w.isValidElement(e)&&e.type===Roe}function Noe(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Moe(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)}var K2="Popover",[s3,cLe]=Pn(K2,[zi]),Cp=zi(),[Poe,Pa]=s3(K2),a3=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=Cp(t),l=w.useRef(null),[c,u]=w.useState(!1),[d=!1,h]=or({prop:r,defaultProp:o,onChange:i});return f.jsx(vp,{...a,children:f.jsx(Poe,{scope:t,contentId:_n(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:w.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:c,onCustomAnchorAdd:w.useCallback(()=>u(!0),[]),onCustomAnchorRemove:w.useCallback(()=>u(!1),[]),modal:s,children:n})})};a3.displayName=K2;var l3="PopoverAnchor",Doe=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Pa(l3,n),i=Cp(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return w.useEffect(()=>(s(),()=>a()),[s,a]),f.jsx(pd,{...i,...r,ref:t})});Doe.displayName=l3;var c3="PopoverTrigger",u3=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Pa(c3,n),i=Cp(n),s=Ve(t,o.triggerRef),a=f.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":m3(o.open),...r,ref:s,onClick:fe(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:f.jsx(pd,{asChild:!0,...i,children:a})});u3.displayName=c3;var X2="PopoverPortal",[Ioe,Aoe]=s3(X2,{forceMount:void 0}),d3=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Pa(X2,t);return f.jsx(Ioe,{scope:t,forceMount:n,children:f.jsx(fn,{present:n||i.open,children:f.jsx(pc,{asChild:!0,container:o,children:r})})})};d3.displayName=X2;var Bu="PopoverContent",f3=w.forwardRef((e,t)=>{const n=Aoe(Bu,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Pa(Bu,e.__scopePopover);return f.jsx(fn,{present:r||i.open,children:i.modal?f.jsx(Toe,{...o,ref:t}):f.jsx(joe,{...o,ref:t})})});f3.displayName=Bu;var Toe=w.forwardRef((e,t)=>{const n=Pa(Bu,e.__scopePopover),r=w.useRef(null),o=Ve(t,r),i=w.useRef(!1);return w.useEffect(()=>{const s=r.current;if(s)return ld(s)},[]),f.jsx(fc,{as:i3,allowPinchZoom:!0,children:f.jsx(h3,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fe(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:fe(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),joe=w.forwardRef((e,t)=>{const n=Pa(Bu,e.__scopePopover),r=w.useRef(!1),o=w.useRef(!1);return f.jsx(h3,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,a;(s=e.onCloseAutoFocus)==null||s.call(e,i),i.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),h3=w.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,h=Pa(Bu,n),p=Cp(n);return ay(),f.jsx(bp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:f.jsx(hc,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:f.jsx(xp,{"data-state":m3(h.open),role:"dialog",id:h.contentId,...p,...d,ref:t,style:{...d.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)"}})})})}),p3="PopoverClose",Ooe=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Pa(p3,n);return f.jsx(_e.button,{type:"button",...r,ref:t,onClick:fe(e.onClick,()=>o.onOpenChange(!1))})});Ooe.displayName=p3;var Foe="PopoverArrow",Loe=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Cp(n);return f.jsx(wp,{...o,...r,ref:t})});Loe.displayName=Foe;function m3(e){return e?"open":"closed"}var $oe=a3,zoe=u3,Boe=d3,hy=f3;const Da=$oe,Ia=zoe,ks=w.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>f.jsx(Boe,{children:f.jsx(Qo,{children:f.jsx(hy,{ref:o,align:t,sideOffset:n,className:ie("z-49 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",e),...r})})}));ks.displayName=hy.displayName;function fC(e,[t,n]){return Math.min(n,Math.max(t,e))}var g3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(Hoe);if(i){const s=i.props.children,a=o.map(l=>l===i?w.Children.count(s)>1?w.Children.only(null):w.isValidElement(s)?s.props.children:null:l);return f.jsx(hC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(hC,{...r,ref:t,children:n})});g3.displayName="Slot";var hC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=Uoe(n),i=Woe(r,n.props);return n.type!==w.Fragment&&(i.ref=t?vr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});hC.displayName="SlotClone";var Voe=({children:e})=>f.jsx(f.Fragment,{children:e});function Hoe(e){return w.isValidElement(e)&&e.type===Voe}function Woe(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Uoe(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 py(e){const t=w.useRef({value:e,previous:e});return w.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var qoe="VisuallyHidden",Q2=w.forwardRef((e,t)=>f.jsx(_e.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}}));Q2.displayName=qoe;var Goe=Q2,Yoe=[" ","Enter","ArrowUp","ArrowDown"],Koe=[" ","Enter"],Sp="Select",[my,gy,Xoe]=D0(Sp),[md,uLe]=Pn(Sp,[Xoe,zi]),by=zi(),[Qoe,Aa]=md(Sp),[Zoe,Joe]=md(Sp),b3=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:d,disabled:h,required:p,form:g}=e,m=by(t),[b,y]=w.useState(null),[v,x]=w.useState(null),[S,_]=w.useState(!1),E=sc(c),[C=!1,k]=or({prop:r,defaultProp:o,onChange:i}),[N,M]=or({prop:s,defaultProp:a,onChange:l}),I=w.useRef(null),D=b?g||!!b.closest("form"):!0,[j,F]=w.useState(new Set),T=Array.from(j).map(O=>O.props.value).join(";");return f.jsx(vp,{...m,children:f.jsxs(Qoe,{required:p,scope:t,trigger:b,onTriggerChange:y,valueNode:v,onValueNodeChange:x,valueNodeHasChildren:S,onValueNodeHasChildrenChange:_,contentId:_n(),value:N,onValueChange:M,open:C,onOpenChange:k,dir:E,triggerPointerDownPosRef:I,disabled:h,children:[f.jsx(my.Provider,{scope:t,children:f.jsx(Zoe,{scope:e.__scopeSelect,onNativeOptionAdd:w.useCallback(O=>{F($=>new Set($).add(O))},[]),onNativeOptionRemove:w.useCallback(O=>{F($=>{const B=new Set($);return B.delete(O),B})},[]),children:n})}),D?f.jsxs(H3,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:N,onChange:O=>M(O.target.value),disabled:h,form:g,children:[N===void 0?f.jsx("option",{value:""}):null,Array.from(j)]},T):null]})})};b3.displayName=Sp;var y3="SelectTrigger",v3=w.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=by(n),s=Aa(y3,n),a=s.disabled||r,l=Ve(t,s.onTriggerChange),c=gy(n),u=w.useRef("touch"),[d,h,p]=W3(m=>{const b=c().filter(x=>!x.disabled),y=b.find(x=>x.value===s.value),v=U3(b,m,y);v!==void 0&&s.onValueChange(v.value)}),g=m=>{a||(s.onOpenChange(!0),p()),m&&(s.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return f.jsx(pd,{asChild:!0,...i,children:f.jsx(_e.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:a,"data-disabled":a?"":void 0,"data-placeholder":V3(s.value)?"":void 0,...o,ref:l,onClick:fe(o.onClick,m=>{m.currentTarget.focus(),u.current!=="mouse"&&g(m)}),onPointerDown:fe(o.onPointerDown,m=>{u.current=m.pointerType;const b=m.target;b.hasPointerCapture(m.pointerId)&&b.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(g(m),m.preventDefault())}),onKeyDown:fe(o.onKeyDown,m=>{const b=d.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&h(m.key),!(b&&m.key===" ")&&Yoe.includes(m.key)&&(g(),m.preventDefault())})})})});v3.displayName=y3;var x3="SelectValue",w3=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:s="",...a}=e,l=Aa(x3,n),{onValueNodeHasChildrenChange:c}=l,u=i!==void 0,d=Ve(t,l.onValueNodeChange);return Vn(()=>{c(u)},[c,u]),f.jsx(_e.span,{...a,ref:d,style:{pointerEvents:"none"},children:V3(l.value)?f.jsx(f.Fragment,{children:s}):i})});w3.displayName=x3;var eie="SelectIcon",C3=w.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return f.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});C3.displayName=eie;var tie="SelectPortal",S3=e=>f.jsx(pc,{asChild:!0,...e});S3.displayName=tie;var Ul="SelectContent",E3=w.forwardRef((e,t)=>{const n=Aa(Ul,e.__scopeSelect),[r,o]=w.useState();if(Vn(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?vs.createPortal(f.jsx(_3,{scope:e.__scopeSelect,children:f.jsx(my.Slot,{scope:e.__scopeSelect,children:f.jsx("div",{children:e.children})})}),i):null}return f.jsx(R3,{...e,ref:t})});E3.displayName=Ul;var To=10,[_3,Ta]=md(Ul),nie="SelectContentImpl",R3=w.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:g,hideWhenDetached:m,avoidCollisions:b,...y}=e,v=Aa(Ul,n),[x,S]=w.useState(null),[_,E]=w.useState(null),C=Ve(t,q=>S(q)),[k,N]=w.useState(null),[M,I]=w.useState(null),D=gy(n),[j,F]=w.useState(!1),T=w.useRef(!1);w.useEffect(()=>{if(x)return ld(x)},[x]),ay();const O=w.useCallback(q=>{const[Y,...K]=D().map(Q=>Q.ref.current),[Z]=K.slice(-1),ee=document.activeElement;for(const Q of q)if(Q===ee||(Q==null||Q.scrollIntoView({block:"nearest"}),Q===Y&&_&&(_.scrollTop=0),Q===Z&&_&&(_.scrollTop=_.scrollHeight),Q==null||Q.focus(),document.activeElement!==ee))return},[D,_]),$=w.useCallback(()=>O([k,x]),[O,k,x]);w.useEffect(()=>{j&&$()},[j,$]);const{onOpenChange:B,triggerPointerDownPosRef:z}=v;w.useEffect(()=>{if(x){let q={x:0,y:0};const Y=Z=>{var ee,Q;q={x:Math.abs(Math.round(Z.pageX)-(((ee=z.current)==null?void 0:ee.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((Q=z.current)==null?void 0:Q.y)??0))}},K=Z=>{q.x<=10&&q.y<=10?Z.preventDefault():x.contains(Z.target)||B(!1),document.removeEventListener("pointermove",Y),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",Y),document.addEventListener("pointerup",K,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Y),document.removeEventListener("pointerup",K,{capture:!0})}}},[x,B,z]),w.useEffect(()=>{const q=()=>B(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[B]);const[A,W]=W3(q=>{const Y=D().filter(ee=>!ee.disabled),K=Y.find(ee=>ee.ref.current===document.activeElement),Z=U3(Y,q,K);Z&&setTimeout(()=>Z.ref.current.focus())}),L=w.useCallback((q,Y,K)=>{const Z=!T.current&&!K;(v.value!==void 0&&v.value===Y||Z)&&(N(q),Z&&(T.current=!0))},[v.value]),P=w.useCallback(()=>x==null?void 0:x.focus(),[x]),H=w.useCallback((q,Y,K)=>{const Z=!T.current&&!K;(v.value!==void 0&&v.value===Y||Z)&&I(q)},[v.value]),V=r==="popper"?pC:k3,G=V===pC?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:g,hideWhenDetached:m,avoidCollisions:b}:{};return f.jsx(_3,{scope:n,content:x,viewport:_,onViewportChange:E,itemRefCallback:L,selectedItem:k,onItemLeave:P,itemTextRefCallback:H,focusSelectedItem:$,selectedItemText:M,position:r,isPositioned:j,searchRef:A,children:f.jsx(fc,{as:g3,allowPinchZoom:!0,children:f.jsx(bp,{asChild:!0,trapped:v.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:fe(o,q=>{var Y;(Y=v.trigger)==null||Y.focus({preventScroll:!0}),q.preventDefault()}),children:f.jsx(hc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:f.jsx(V,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:q=>q.preventDefault(),...y,...G,onPlaced:()=>F(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:fe(y.onKeyDown,q=>{const Y=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!Y&&q.key.length===1&&W(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let Z=D().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);if(["ArrowUp","End"].includes(q.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const ee=q.target,Q=Z.indexOf(ee);Z=Z.slice(Q+1)}setTimeout(()=>O(Z)),q.preventDefault()}})})})})})})});R3.displayName=nie;var rie="SelectItemAlignedPosition",k3=w.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=Aa(Ul,n),s=Ta(Ul,n),[a,l]=w.useState(null),[c,u]=w.useState(null),d=Ve(t,C=>u(C)),h=gy(n),p=w.useRef(!1),g=w.useRef(!0),{viewport:m,selectedItem:b,selectedItemText:y,focusSelectedItem:v}=s,x=w.useCallback(()=>{if(i.trigger&&i.valueNode&&a&&c&&m&&b&&y){const C=i.trigger.getBoundingClientRect(),k=c.getBoundingClientRect(),N=i.valueNode.getBoundingClientRect(),M=y.getBoundingClientRect();if(i.dir!=="rtl"){const ee=M.left-k.left,Q=N.left-ee,oe=C.left-Q,te=C.width+oe,ce=Math.max(te,k.width),ue=window.innerWidth-To,Re=fC(Q,[To,Math.max(To,ue-ce)]);a.style.minWidth=te+"px",a.style.left=Re+"px"}else{const ee=k.right-M.right,Q=window.innerWidth-N.right-ee,oe=window.innerWidth-C.right-Q,te=C.width+oe,ce=Math.max(te,k.width),ue=window.innerWidth-To,Re=fC(Q,[To,Math.max(To,ue-ce)]);a.style.minWidth=te+"px",a.style.right=Re+"px"}const I=h(),D=window.innerHeight-To*2,j=m.scrollHeight,F=window.getComputedStyle(c),T=parseInt(F.borderTopWidth,10),O=parseInt(F.paddingTop,10),$=parseInt(F.borderBottomWidth,10),B=parseInt(F.paddingBottom,10),z=T+O+j+B+$,A=Math.min(b.offsetHeight*5,z),W=window.getComputedStyle(m),L=parseInt(W.paddingTop,10),P=parseInt(W.paddingBottom,10),H=C.top+C.height/2-To,V=D-H,G=b.offsetHeight/2,q=b.offsetTop+G,Y=T+O+q,K=z-Y;if(Y<=H){const ee=I.length>0&&b===I[I.length-1].ref.current;a.style.bottom="0px";const Q=c.clientHeight-m.offsetTop-m.offsetHeight,oe=Math.max(V,G+(ee?P:0)+Q+$),te=Y+oe;a.style.height=te+"px"}else{const ee=I.length>0&&b===I[0].ref.current;a.style.top="0px";const oe=Math.max(H,T+m.offsetTop+(ee?L:0)+G)+K;a.style.height=oe+"px",m.scrollTop=Y-H+m.offsetTop}a.style.margin=`${To}px 0`,a.style.minHeight=A+"px",a.style.maxHeight=D+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,i.trigger,i.valueNode,a,c,m,b,y,i.dir,r]);Vn(()=>x(),[x]);const[S,_]=w.useState();Vn(()=>{c&&_(window.getComputedStyle(c).zIndex)},[c]);const E=w.useCallback(C=>{C&&g.current===!0&&(x(),v==null||v(),g.current=!1)},[x,v]);return f.jsx(iie,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:E,children:f.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:f.jsx(_e.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});k3.displayName=rie;var oie="SelectPopperPosition",pC=w.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=To,...i}=e,s=by(n);return f.jsx(xp,{...s,...i,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...i.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)"}})});pC.displayName=oie;var[iie,Z2]=md(Ul,{}),mC="SelectViewport",N3=w.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=Ta(mC,n),s=Z2(mC,n),a=Ve(t,i.onViewportChange),l=w.useRef(0);return f.jsxs(f.Fragment,{children:[f.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}),f.jsx(my.Slot,{scope:n,children:f.jsx(_e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,c=>{const u=c.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:h}=s;if(h!=null&&h.current&&d){const p=Math.abs(l.current-u.scrollTop);if(p>0){const g=window.innerHeight-To*2,m=parseFloat(d.style.minHeight),b=parseFloat(d.style.height),y=Math.max(m,b);if(y<g){const v=y+p,x=Math.min(g,v),S=v-x;d.style.height=x+"px",d.style.bottom==="0px"&&(u.scrollTop=S>0?S:0,d.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});N3.displayName=mC;var M3="SelectGroup",[sie,aie]=md(M3),P3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_n();return f.jsx(sie,{scope:n,id:o,children:f.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});P3.displayName=M3;var D3="SelectLabel",I3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=aie(D3,n);return f.jsx(_e.div,{id:o.id,...r,ref:t})});I3.displayName=D3;var wb="SelectItem",[lie,A3]=md(wb),T3=w.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...s}=e,a=Aa(wb,n),l=Ta(wb,n),c=a.value===r,[u,d]=w.useState(i??""),[h,p]=w.useState(!1),g=Ve(t,v=>{var x;return(x=l.itemRefCallback)==null?void 0:x.call(l,v,r,o)}),m=_n(),b=w.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> 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 f.jsx(lie,{scope:n,value:r,disabled:o,textId:m,isSelected:c,onItemTextChange:w.useCallback(v=>{d(x=>x||((v==null?void 0:v.textContent)??"").trim())},[]),children:f.jsx(my.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:f.jsx(_e.div,{role:"option","aria-labelledby":m,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...s,ref:g,onFocus:fe(s.onFocus,()=>p(!0)),onBlur:fe(s.onBlur,()=>p(!1)),onClick:fe(s.onClick,()=>{b.current!=="mouse"&&y()}),onPointerUp:fe(s.onPointerUp,()=>{b.current==="mouse"&&y()}),onPointerDown:fe(s.onPointerDown,v=>{b.current=v.pointerType}),onPointerMove:fe(s.onPointerMove,v=>{var x;b.current=v.pointerType,o?(x=l.onItemLeave)==null||x.call(l):b.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fe(s.onPointerLeave,v=>{var x;v.currentTarget===document.activeElement&&((x=l.onItemLeave)==null||x.call(l))}),onKeyDown:fe(s.onKeyDown,v=>{var S;((S=l.searchRef)==null?void 0:S.current)!==""&&v.key===" "||(Koe.includes(v.key)&&y(),v.key===" "&&v.preventDefault())})})})})});T3.displayName=wb;var rf="SelectItemText",j3=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,s=Aa(rf,n),a=Ta(rf,n),l=A3(rf,n),c=Joe(rf,n),[u,d]=w.useState(null),h=Ve(t,y=>d(y),l.onItemTextChange,y=>{var v;return(v=a.itemTextRefCallback)==null?void 0:v.call(a,y,l.value,l.disabled)}),p=u==null?void 0:u.textContent,g=w.useMemo(()=>f.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:m,onNativeOptionRemove:b}=c;return Vn(()=>(m(g),()=>b(g)),[m,b,g]),f.jsxs(f.Fragment,{children:[f.jsx(_e.span,{id:l.textId,...i,ref:h}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?vs.createPortal(i.children,s.valueNode):null]})});j3.displayName=rf;var O3="SelectItemIndicator",F3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return A3(O3,n).isSelected?f.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});F3.displayName=O3;var gC="SelectScrollUpButton",L3=w.forwardRef((e,t)=>{const n=Ta(gC,e.__scopeSelect),r=Z2(gC,e.__scopeSelect),[o,i]=w.useState(!1),s=Ve(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;i(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?f.jsx(z3,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});L3.displayName=gC;var bC="SelectScrollDownButton",$3=w.forwardRef((e,t)=>{const n=Ta(bC,e.__scopeSelect),r=Z2(bC,e.__scopeSelect),[o,i]=w.useState(!1),s=Ve(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<c;i(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?f.jsx(z3,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});$3.displayName=bC;var z3=w.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=Ta("SelectScrollButton",n),s=w.useRef(null),a=gy(n),l=w.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return w.useEffect(()=>()=>l(),[l]),Vn(()=>{var u;const c=a().find(d=>d.ref.current===document.activeElement);(u=c==null?void 0:c.ref.current)==null||u.scrollIntoView({block:"nearest"})},[a]),f.jsx(_e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:fe(o.onPointerMove,()=>{var c;(c=i.onItemLeave)==null||c.call(i),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{l()})})}),cie="SelectSeparator",B3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return f.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});B3.displayName=cie;var yC="SelectArrow",uie=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=by(n),i=Aa(yC,n),s=Ta(yC,n);return i.open&&s.position==="popper"?f.jsx(wp,{...o,...r,ref:t}):null});uie.displayName=yC;function V3(e){return e===""||e===void 0}var H3=w.forwardRef((e,t)=>{const{value:n,...r}=e,o=w.useRef(null),i=Ve(t,o),s=py(n);return w.useEffect(()=>{const a=o.current,l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==n&&u){const d=new Event("change",{bubbles:!0});u.call(a,n),a.dispatchEvent(d)}},[s,n]),f.jsx(Q2,{asChild:!0,children:f.jsx("select",{...r,ref:i,defaultValue:n})})});H3.displayName="BubbleSelect";function W3(e){const t=Mn(e),n=w.useRef(""),r=w.useRef(0),o=w.useCallback(s=>{const a=n.current+s;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),i=w.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return w.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function U3(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=die(e,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==n));const l=s.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function die(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fie=b3,q3=v3,hie=w3,pie=C3,mie=S3,G3=E3,gie=N3,bie=P3,Y3=I3,K3=T3,yie=j3,vie=F3,X3=L3,Q3=$3,Z3=B3;const Pt=fie,Ws=bie,Dt=hie,Ct=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(q3,{ref:r,className:ie("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-0 focus:ring-ring focus:ring-offset-0 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,f.jsx(pie,{asChild:!0,children:f.jsx(sa,{className:"h-4 w-4 opacity-50"})})]}));Ct.displayName=q3.displayName;const J3=w.forwardRef(({className:e,...t},n)=>f.jsx(X3,{ref:n,className:ie("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(vf,{className:"h-4 w-4"})}));J3.displayName=X3.displayName;const eL=w.forwardRef(({className:e,...t},n)=>f.jsx(Q3,{ref:n,className:ie("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(sa,{className:"h-4 w-4"})}));eL.displayName=Q3.displayName;const St=w.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>f.jsx(mie,{children:f.jsx(Qo,{children:f.jsxs(G3,{ref:o,className:ie("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",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:[f.jsx(J3,{}),f.jsx(gie,{className:ie("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),f.jsx(eL,{})]})})}));St.displayName=G3.displayName;const rs=w.forwardRef(({className:e,...t},n)=>f.jsx(Y3,{ref:n,className:ie("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));rs.displayName=Y3.displayName;const ye=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(K3,{ref:r,className:ie("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(vie,{children:f.jsx(ao,{className:"h-4 w-4"})})}),f.jsx(yie,{children:t})]}));ye.displayName=K3.displayName;const Ef=w.forwardRef(({className:e,...t},n)=>f.jsx(Z3,{ref:n,className:ie("-mx-1 my-1 h-px bg-muted",e),...t}));Ef.displayName=Z3.displayName;const yr=w.forwardRef(({className:e,type:t,...n},r)=>f.jsx("input",{type:t,className:ie("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));yr.displayName="Input";var xie="Label",J2=w.forwardRef((e,t)=>f.jsx(_e.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));J2.displayName=xie;var tL=J2;const wie=X0("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),de=w.forwardRef(({className:e,...t},n)=>f.jsx(tL,{ref:n,className:ie(wie(),e),...t}));de.displayName=tL.displayName;function Cie({step:e,hierarchyId:t,stepIndex:n,onUpdateStep:r,open:o,onOpenChange:i,trigger:s}){return f.jsxs(Da,{open:o,onOpenChange:i,children:[f.jsx(Ia,{asChild:!0,children:s}),f.jsx(ks,{className:"z-50 w-80",align:"start",children:f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Chart Type"}),f.jsxs(Pt,{value:e.preferredChartType||"bar",onValueChange:a=>{r(t,n,{preferredChartType:a})},children:[f.jsx(Ct,{className:"h-8",children:f.jsx(Dt,{})}),f.jsxs(St,{children:[f.jsx(ye,{value:"bar",children:"Bar Chart"}),f.jsx(ye,{value:"pie",children:"Pie Chart"}),f.jsx(ye,{value:"line",children:"Line Chart"}),f.jsx(ye,{value:"donut",children:"Donut Chart"}),f.jsx(ye,{value:"table",children:"Table"}),f.jsx(ye,{value:"metric",children:"Metric"})]})]})]}),f.jsxs("div",{children:[f.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Step Label"}),f.jsx(yr,{value:e.label||"",onChange:a=>r(t,n,{label:a.target.value}),placeholder:"Custom drill label",className:"h-8"})]}),f.jsxs("div",{children:[f.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Breadcrumb Label Template"}),f.jsx(yr,{value:e.breadcrumbLabelTemplate||"",onChange:a=>r(t,n,{breadcrumbLabelTemplate:a.target.value}),placeholder:"e.g., 'Region: {{value}}'",className:"h-8"})]}),f.jsx("div",{className:"flex items-center gap-4",children:f.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[f.jsx("input",{type:"checkbox",checked:e.retainFilters!==!1,onChange:a=>r(t,n,{retainFilters:a.target.checked}),className:"rounded"}),"Retain filters when drilling"]})}),f.jsx("div",{className:"flex justify-end",children:f.jsx(Ee,{size:"sm",variant:"outline",onClick:()=>i(!1),children:"Done"})})]})})]})}function Sie({field:e,step:t,stepIndex:n,hierarchyId:r,onUpdateStep:o,onRemoveStep:i,isFirstField:s=!1}){const[a,l]=R.useState(!1),{attributes:c,listeners:u,setNodeRef:d,transform:h,transition:p,isDragging:g}=A2({id:`${r}-${e.id}-${n}`,disabled:!1}),m={transform:ki.Transform.toString(h),transition:p,opacity:g?.8:1,zIndex:g?1e3:1};return f.jsx("div",{ref:d,style:m,className:`relative ${a?"z-[9998]":""}`,...c,children:f.jsx(Cie,{step:t,hierarchyId:r,stepIndex:n,onUpdateStep:o,open:a,onOpenChange:l,trigger:f.jsxs("div",{className:`flex cursor-pointer items-center gap-2 rounded-lg p-2 transition-colors ${s?"bg-muted hover:bg-muted/50":"bg-blue-100 hover:bg-blue-200 dark:bg-blue-900/50 dark:hover:bg-blue-900/70"} ${g?"shadow-lg ring-2 ring-blue-300 dark:ring-blue-600":""}`,...u,onClick:b=>{b.stopPropagation(),l(y=>!y)},children:[f.jsxs("div",{className:"pointer-events-none flex items-center gap-2",children:[f.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:e.label}),t.preferredChartType&&t.preferredChartType!=="bar"&&f.jsx("span",{className:"whitespace-nowrap rounded bg-purple-100 px-1 py-0.5 text-xs text-purple-700 dark:bg-purple-900/50 dark:text-purple-300",children:t.preferredChartType}),t.linkedInsightId&&f.jsx("span",{className:"whitespace-nowrap rounded bg-green-100 px-1 py-0.5 text-xs text-green-700 dark:bg-green-900/50 dark:text-green-300",children:"📊"})]}),f.jsx("button",{className:`pointer-events-auto ml-1 text-xs hover:text-red-800 dark:hover:text-red-400 ${s?"text-muted-foreground":"text-blue-600 dark:text-blue-400"}`,onClick:b=>{b.stopPropagation(),i(r,n)},children:"×"})]})})})}function Eie(e){return{sensors:R2(sh(pp,{activationConstraint:{distance:5}}),sh(hp,{coordinateGetter:T2})),handleStepDragEnd:(r,o)=>{const{active:i,over:s}=r;if(!s||i.id===s.id)return;const a=i.id.replace(`${o.id}-`,""),l=s.id.replace(`${o.id}-`,""),c=o.steps.findIndex(d=>d.field.id===a),u=o.steps.findIndex(d=>d.field.id===l);if(c!==-1&&u!==-1&&c!==u){const d=gp(o.steps,c,u);e(o.id,{steps:d})}}}}function _ie({hierarchy:e,onUpdateStep:t,onRemoveStep:n,onUpdateHierarchy:r}){const{sensors:o}=Eie(r),[i,s]=R.useState(null),a=e.steps.filter(h=>h&&h.field&&h.field.id),c=a.map(h=>h.field).map((h,p)=>`${e.id}-${h.id}-${p}`),u=h=>{const p=h.active.id,g=Number.parseInt(p.split("-").pop()||"0"),m=a[g],b=m==null?void 0:m.field;s(b||null)},d=h=>{s(null);const{active:p,over:g}=h;if(!g||p.id===g.id)return;const m=Number.parseInt(p.id.split("-").pop()||"0"),b=Number.parseInt(g.id.split("-").pop()||"0");if(m!==b&&m<a.length&&b<a.length){const y=[...e.steps],[v]=y.splice(m,1);y.splice(b,0,v),r(e.id,{steps:y})}};return a.length===0?f.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:f.jsx("div",{className:"rounded-lg border bg-muted/50 p-2 text-sm text-muted-foreground",children:"No drill steps configured. Add steps to create a drill hierarchy."})}):f.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:f.jsxs(D2,{sensors:o,collisionDetection:k2,onDragStart:u,onDragEnd:d,children:[f.jsx(I2,{items:c,strategy:ere,children:f.jsx("div",{className:"flex flex-wrap items-center gap-2",style:{minHeight:"40px"},children:a.map((h,p)=>{if(!h||!h.field||!h.field.id)return null;const g=[];p>0&&g.push(f.jsx(_i,{className:"pointer-events-none h-4 w-4 text-gray-400"},`arrow-${p}`));const m=p===0,b=p===a.length-1;return g.push(f.jsx(Sie,{field:h.field,step:h,stepIndex:p,hierarchyId:e.id,onUpdateStep:t,onRemoveStep:n,isFirstField:m,isLastField:b},`field-${h.field.id}-${p}`)),g})})}),typeof window<"u"&&rn.createPortal(f.jsx(R4,{className:"semaphor-scope",style:{zIndex:9999},children:i?f.jsx("div",{className:"flex items-center gap-2 rounded-lg border-2 border-blue-300 bg-blue-200 p-2 shadow-lg dark:border-blue-600 dark:bg-blue-900/70",children:f.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:i.label})}):null}),document.body)]})})}var mP=1,Rie=.9,kie=.8,Nie=.17,Sx=.1,Ex=.999,Mie=.9999,Pie=.99,Die=/[\\\/_+.#"@\[\(\{&]/,Iie=/[\\\/_+.#"@\[\(\{&]/g,Aie=/[\s-]/,nL=/[\s-]/g;function vC(e,t,n,r,o,i,s){if(i===t.length)return o===e.length?mP:Pie;var a=`${o},${i}`;if(s[a]!==void 0)return s[a];for(var l=r.charAt(i),c=n.indexOf(l,o),u=0,d,h,p,g;c>=0;)d=vC(e,t,n,r,c+1,i+1,s),d>u&&(c===o?d*=mP:Die.test(e.charAt(c-1))?(d*=kie,p=e.slice(o,c-1).match(Iie),p&&o>0&&(d*=Math.pow(Ex,p.length))):Aie.test(e.charAt(c-1))?(d*=Rie,g=e.slice(o,c-1).match(nL),g&&o>0&&(d*=Math.pow(Ex,g.length))):(d*=Nie,o>0&&(d*=Math.pow(Ex,c-o))),e.charAt(c)!==t.charAt(i)&&(d*=Mie)),(d<Sx&&n.charAt(c-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(c-1)!==r.charAt(i))&&(h=vC(e,t,n,r,c+1,i+2,s),h*Sx>d&&(d=h*Sx)),d>u&&(u=d),c=n.indexOf(l,c+1);return s[a]=u,u}function gP(e){return e.toLowerCase().replace(nL," ")}function Tie(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,vC(e,t,gP(e),gP(t),0,0,{})}var $d='[cmdk-group=""]',_x='[cmdk-group-items=""]',jie='[cmdk-group-heading=""]',rL='[cmdk-item=""]',bP=`${rL}:not([aria-disabled="true"])`,xC="cmdk-item-select",Vc="data-value",Oie=(e,t,n)=>Tie(e,t,n),oL=w.createContext(void 0),Ep=()=>w.useContext(oL),iL=w.createContext(void 0),e_=()=>w.useContext(iL),sL=w.createContext(void 0),aL=w.forwardRef((e,t)=>{let n=Hc(()=>{var L,P;return{search:"",value:(P=(L=e.value)!=null?L:e.defaultValue)!=null?P:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Hc(()=>new Set),o=Hc(()=>new Map),i=Hc(()=>new Map),s=Hc(()=>new Set),a=lL(e),{label:l,children:c,value:u,onValueChange:d,filter:h,shouldFilter:p,loop:g,disablePointerSelection:m=!1,vimBindings:b=!0,...y}=e,v=_n(),x=_n(),S=_n(),_=w.useRef(null),E=Gie();ql(()=>{if(u!==void 0){let L=u.trim();n.current.value=L,C.emit()}},[u]),ql(()=>{E(6,j)},[]);let C=w.useMemo(()=>({subscribe:L=>(s.current.add(L),()=>s.current.delete(L)),snapshot:()=>n.current,setState:(L,P,H)=>{var V,G,q,Y;if(!Object.is(n.current[L],P)){if(n.current[L]=P,L==="search")D(),M(),E(1,I);else if(L==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let K=document.getElementById(S);K?K.focus():(V=document.getElementById(v))==null||V.focus()}if(E(7,()=>{var K;n.current.selectedItemId=(K=F())==null?void 0:K.id,C.emit()}),H||E(5,j),((G=a.current)==null?void 0:G.value)!==void 0){let K=P??"";(Y=(q=a.current).onValueChange)==null||Y.call(q,K);return}}C.emit()}},emit:()=>{s.current.forEach(L=>L())}}),[]),k=w.useMemo(()=>({value:(L,P,H)=>{var V;P!==((V=i.current.get(L))==null?void 0:V.value)&&(i.current.set(L,{value:P,keywords:H}),n.current.filtered.items.set(L,N(P,H)),E(2,()=>{M(),C.emit()}))},item:(L,P)=>(r.current.add(L),P&&(o.current.has(P)?o.current.get(P).add(L):o.current.set(P,new Set([L]))),E(3,()=>{D(),M(),n.current.value||I(),C.emit()}),()=>{i.current.delete(L),r.current.delete(L),n.current.filtered.items.delete(L);let H=F();E(4,()=>{D(),(H==null?void 0:H.getAttribute("id"))===L&&I(),C.emit()})}),group:L=>(o.current.has(L)||o.current.set(L,new Set),()=>{i.current.delete(L),o.current.delete(L)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:v,inputId:S,labelId:x,listInnerRef:_}),[]);function N(L,P){var H,V;let G=(V=(H=a.current)==null?void 0:H.filter)!=null?V:Oie;return L?G(L,n.current.search,P):0}function M(){if(!n.current.search||a.current.shouldFilter===!1)return;let L=n.current.filtered.items,P=[];n.current.filtered.groups.forEach(V=>{let G=o.current.get(V),q=0;G.forEach(Y=>{let K=L.get(Y);q=Math.max(K,q)}),P.push([V,q])});let H=_.current;T().sort((V,G)=>{var q,Y;let K=V.getAttribute("id"),Z=G.getAttribute("id");return((q=L.get(Z))!=null?q:0)-((Y=L.get(K))!=null?Y:0)}).forEach(V=>{let G=V.closest(_x);G?G.appendChild(V.parentElement===G?V:V.closest(`${_x} > *`)):H.appendChild(V.parentElement===H?V:V.closest(`${_x} > *`))}),P.sort((V,G)=>G[1]-V[1]).forEach(V=>{var G;let q=(G=_.current)==null?void 0:G.querySelector(`${$d}[${Vc}="${encodeURIComponent(V[0])}"]`);q==null||q.parentElement.appendChild(q)})}function I(){let L=T().find(H=>H.getAttribute("aria-disabled")!=="true"),P=L==null?void 0:L.getAttribute(Vc);C.setState("value",P||void 0)}function D(){var L,P,H,V;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let G=0;for(let q of r.current){let Y=(P=(L=i.current.get(q))==null?void 0:L.value)!=null?P:"",K=(V=(H=i.current.get(q))==null?void 0:H.keywords)!=null?V:[],Z=N(Y,K);n.current.filtered.items.set(q,Z),Z>0&&G++}for(let[q,Y]of o.current)for(let K of Y)if(n.current.filtered.items.get(K)>0){n.current.filtered.groups.add(q);break}n.current.filtered.count=G}function j(){var L,P,H;let V=F();V&&(((L=V.parentElement)==null?void 0:L.firstChild)===V&&((H=(P=V.closest($d))==null?void 0:P.querySelector(jie))==null||H.scrollIntoView({block:"nearest"})),V.scrollIntoView({block:"nearest"}))}function F(){var L;return(L=_.current)==null?void 0:L.querySelector(`${rL}[aria-selected="true"]`)}function T(){var L;return Array.from(((L=_.current)==null?void 0:L.querySelectorAll(bP))||[])}function O(L){let P=T()[L];P&&C.setState("value",P.getAttribute(Vc))}function $(L){var P;let H=F(),V=T(),G=V.findIndex(Y=>Y===H),q=V[G+L];(P=a.current)!=null&&P.loop&&(q=G+L<0?V[V.length-1]:G+L===V.length?V[0]:V[G+L]),q&&C.setState("value",q.getAttribute(Vc))}function B(L){let P=F(),H=P==null?void 0:P.closest($d),V;for(;H&&!V;)H=L>0?Uie(H,$d):qie(H,$d),V=H==null?void 0:H.querySelector(bP);V?C.setState("value",V.getAttribute(Vc)):$(L)}let z=()=>O(T().length-1),A=L=>{L.preventDefault(),L.metaKey?z():L.altKey?B(1):$(1)},W=L=>{L.preventDefault(),L.metaKey?O(0):L.altKey?B(-1):$(-1)};return w.createElement(_e.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:L=>{var P;(P=y.onKeyDown)==null||P.call(y,L);let H=L.nativeEvent.isComposing||L.keyCode===229;if(!(L.defaultPrevented||H))switch(L.key){case"n":case"j":{b&&L.ctrlKey&&A(L);break}case"ArrowDown":{A(L);break}case"p":case"k":{b&&L.ctrlKey&&W(L);break}case"ArrowUp":{W(L);break}case"Home":{L.preventDefault(),O(0);break}case"End":{L.preventDefault(),z();break}case"Enter":{L.preventDefault();let V=F();if(V){let G=new Event(xC);V.dispatchEvent(G)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:Kie},l),yy(e,L=>w.createElement(iL.Provider,{value:C},w.createElement(oL.Provider,{value:k},L))))}),Fie=w.forwardRef((e,t)=>{var n,r;let o=_n(),i=w.useRef(null),s=w.useContext(sL),a=Ep(),l=lL(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:s==null?void 0:s.forceMount;ql(()=>{if(!c)return a.item(o,s==null?void 0:s.id)},[c]);let u=cL(o,i,[e.value,e.children,i],e.keywords),d=e_(),h=ma(E=>E.value&&E.value===u.current),p=ma(E=>c||a.filter()===!1?!0:E.search?E.filtered.items.get(o)>0:!0);w.useEffect(()=>{let E=i.current;if(!(!E||e.disabled))return E.addEventListener(xC,g),()=>E.removeEventListener(xC,g)},[p,e.onSelect,e.disabled]);function g(){var E,C;m(),(C=(E=l.current).onSelect)==null||C.call(E,u.current)}function m(){d.setState("value",u.current,!0)}if(!p)return null;let{disabled:b,value:y,onSelect:v,forceMount:x,keywords:S,..._}=e;return w.createElement(_e.div,{ref:vr(i,t),..._,id:o,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!h,"data-disabled":!!b,"data-selected":!!h,onPointerMove:b||a.getDisablePointerSelection()?void 0:m,onClick:b?void 0:g},e.children)}),Lie=w.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...i}=e,s=_n(),a=w.useRef(null),l=w.useRef(null),c=_n(),u=Ep(),d=ma(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(s):!0);ql(()=>u.group(s),[]),cL(s,a,[e.value,e.heading,l]);let h=w.useMemo(()=>({id:s,forceMount:o}),[o]);return w.createElement(_e.div,{ref:vr(a,t),...i,"cmdk-group":"",role:"presentation",hidden:d?void 0:!0},n&&w.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),yy(e,p=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},w.createElement(sL.Provider,{value:h},p))))}),$ie=w.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=w.useRef(null),i=ma(s=>!s.search);return!n&&!i?null:w.createElement(_e.div,{ref:vr(o,t),...r,"cmdk-separator":"",role:"separator"})}),zie=w.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,i=e_(),s=ma(c=>c.search),a=ma(c=>c.selectedItemId),l=Ep();return w.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),w.createElement(_e.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:s,onChange:c=>{o||i.setState("search",c.target.value),n==null||n(c.target.value)}})}),Bie=w.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,i=w.useRef(null),s=w.useRef(null),a=ma(c=>c.selectedItemId),l=Ep();return w.useEffect(()=>{if(s.current&&i.current){let c=s.current,u=i.current,d,h=new ResizeObserver(()=>{d=requestAnimationFrame(()=>{let p=c.offsetHeight;u.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(d),h.unobserve(c)}}},[]),w.createElement(_e.div,{ref:vr(i,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},yy(e,c=>w.createElement("div",{ref:vr(s,l.listInnerRef),"cmdk-list-sizer":""},c)))}),Vie=w.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:i,container:s,...a}=e;return w.createElement(XF,{open:n,onOpenChange:r},w.createElement(QF,{container:s},w.createElement(C2,{"cmdk-overlay":"",className:o}),w.createElement(S2,{"aria-label":e.label,"cmdk-dialog":"",className:i},w.createElement(aL,{ref:t,...a}))))}),Hie=w.forwardRef((e,t)=>ma(n=>n.filtered.count===0)?w.createElement(_e.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Wie=w.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...i}=e;return w.createElement(_e.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},yy(e,s=>w.createElement("div",{"aria-hidden":!0},s)))}),Hr=Object.assign(aL,{List:Bie,Item:Fie,Input:zie,Group:Lie,Separator:$ie,Dialog:Vie,Empty:Hie,Loading:Wie});function Uie(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function qie(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function lL(e){let t=w.useRef(e);return ql(()=>{t.current=e}),t}var ql=typeof window>"u"?w.useEffect:w.useLayoutEffect;function Hc(e){let t=w.useRef();return t.current===void 0&&(t.current=e()),t}function ma(e){let t=e_(),n=()=>e(t.snapshot());return w.useSyncExternalStore(t.subscribe,n,n)}function cL(e,t,n,r=[]){let o=w.useRef(),i=Ep();return ql(()=>{var s;let a=(()=>{var c;for(let u of n){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(c=u.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());i.value(e,a,l),(s=t.current)==null||s.setAttribute(Vc,a),o.current=a}),o}var Gie=()=>{let[e,t]=w.useState(),n=Hc(()=>new Map);return ql(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Yie(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function yy({asChild:e,children:t},n){return e&&w.isValidElement(t)?w.cloneElement(Yie(t),{ref:t.ref},n(t.props.children)):n(t)}var Kie={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const vy=w.forwardRef(({className:e,...t},n)=>f.jsx(Hr,{ref:n,className:ie("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));vy.displayName=Hr.displayName;const xy=w.forwardRef(({className:e,...t},n)=>f.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[f.jsx(p2,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),f.jsx(Hr.Input,{ref:n,className:ie("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));xy.displayName=Hr.Input.displayName;const wy=w.forwardRef(({className:e,...t},n)=>f.jsx(Hr.List,{ref:n,className:ie("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));wy.displayName=Hr.List.displayName;const Cy=w.forwardRef((e,t)=>f.jsx(Hr.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Cy.displayName=Hr.Empty.displayName;const Sy=w.forwardRef(({className:e,...t},n)=>f.jsx(Hr.Group,{ref:n,className:ie("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Sy.displayName=Hr.Group.displayName;const Xie=w.forwardRef(({className:e,...t},n)=>f.jsx(Hr.Separator,{ref:n,className:ie("-mx-1 h-px bg-border",e),...t}));Xie.displayName=Hr.Separator.displayName;const Ey=w.forwardRef(({className:e,...t},n)=>f.jsx(Hr.Item,{ref:n,className:ie("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",e),...t}));Ey.displayName=Hr.Item.displayName;function Qie({fields:e,value:t,onValueChange:n,placeholder:r="Select field...",className:o,disabled:i=!1,excludeFieldIds:s=[]}){const[a,l]=R.useState(!1),c=e.filter(d=>!s.includes(d.id)),u=c.find(d=>d.id===t);return f.jsxs(Da,{open:a,onOpenChange:l,children:[f.jsx(Ia,{asChild:!0,children:f.jsxs(Ee,{variant:"outline",role:"combobox","aria-expanded":a,className:ie("justify-between",o),disabled:i,children:[u?u.label:r,f.jsx(K5,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),f.jsx(ks,{className:"z-50 w-[200px] p-0",children:f.jsxs(vy,{children:[f.jsx(xy,{placeholder:"Search fields..."}),f.jsxs(wy,{children:[f.jsx(Cy,{children:"No field found."}),f.jsx(Sy,{children:c.map(d=>f.jsxs(Ey,{value:d.label,onSelect:()=>{n(d.id),l(!1)},children:[f.jsx(ao,{className:ie("mr-2 h-4 w-4",t===d.id?"opacity-100":"opacity-0")}),d.label]},d.id))})]})]})})]})}function Zie({hierarchy:e,editingHierarchy:t,sampleFieldReferences:n,onSetEditingHierarchy:r,onUpdateHierarchy:o,onDeleteHierarchy:i,onSetDefaultHierarchy:s,onUpdateStep:a,onRemoveStep:l,onAddStep:c}){const u=t===e.id,{attributes:d,listeners:h,setNodeRef:p,transform:g,transition:m}=A2({id:e.id,disabled:u}),b={transform:ki.Transform.toString(g),transition:m},y=e.steps.filter(v=>v.field).map(v=>v.field.id);return f.jsxs("div",{ref:p,style:b,className:"hierarchy-container relative rounded-lg border bg-background p-3 transition-shadow hover:shadow-md",children:[f.jsxs("div",{className:`mb-3 flex items-center justify-between ${u?"":"cursor-move"}`,...u?{}:d,...u?{}:h,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(hre,{value:e.label||"",isEditing:u,onEdit:()=>{r(e.id)},onSave:v=>{o(e.id,{label:v}),r(null)},onCancel:()=>r(null),placeholder:"Hierarchy Name",displayClassName:"font-medium",inputClassName:"font-medium"}),f.jsxs("span",{className:"rounded bg-muted px-2 py-1 text-xs",children:[e.steps.length," steps"]}),e.default?f.jsx("span",{className:"cursor-pointer rounded bg-blue-100 px-2 py-1 text-xs text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",onClick:v=>{v.stopPropagation(),s("")},onPointerDown:v=>v.stopPropagation(),title:"Click to remove default",children:"Default ✓"}):f.jsx("button",{className:"rounded bg-muted px-2 py-1 text-xs transition-colors hover:bg-blue-100 dark:hover:bg-blue-900/50",onClick:v=>{v.stopPropagation(),s(e.id)},onPointerDown:v=>v.stopPropagation(),title:"Set as default hierarchy",children:"Set Default"})]}),f.jsx("div",{className:"flex items-center gap-1",children:f.jsx(Ee,{size:"sm",variant:"ghost",onClick:v=>{v.stopPropagation(),i(e.id)},onPointerDown:v=>v.stopPropagation(),children:f.jsx(rp,{className:"h-3 w-3"})})})]}),f.jsx(_ie,{hierarchy:e,onUpdateStep:a,onRemoveStep:l,onUpdateHierarchy:o}),f.jsx("div",{className:"mt-3 border-t pt-3","data-hierarchy-editing":!0,children:f.jsx("div",{className:"flex items-center gap-2",children:f.jsx(Qie,{fields:n,excludeFieldIds:y,onValueChange:v=>c(e.id,v),placeholder:"Add drill step...",className:"w-48"})})})]})}function Jie({configuringIntent:e,setConfiguringIntent:t,drillHierarchies:n,onUpdateHierarchies:r,availableFields:o}){const i=R2(sh(pp),sh(hp,{coordinateGetter:T2})),{editingHierarchy:s,setEditingHierarchy:a,createNewHierarchy:l,deleteHierarchy:c,updateHierarchy:u,addStepToHierarchy:d,removeStepFromHierarchy:h,updateStep:p,setDefaultHierarchy:g}=fre(n,r,o),m=b=>{const{active:y,over:v}=b;if(y.id!==(v==null?void 0:v.id)){const x=n.findIndex(_=>_.id===y.id),S=n.findIndex(_=>_.id===(v==null?void 0:v.id));r(gp(n,x,S))}};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100",children:f.jsx(q5,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h4",{className:"mb-1 font-medium",children:"Let users drill deeper into specific paths"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Set up predefined drill paths like regions → cities, categories → products"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ee,{size:"sm",variant:"outline",onClick:()=>t(e==="drillDown"?null:"drillDown"),children:e==="drillDown"?"Done":"Set up drill paths"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.length," hierarchies configured"]})]}),e==="drillDown"&&f.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-blue-100 bg-blue-200/50 p-4 dark:border-blue-900 dark:bg-blue-900/50",children:[f.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("h5",{className:"font-medium",children:"Drill Hierarchies"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Create multiple drill paths for different analysis scenarios"})]}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Ee,{size:"sm",onClick:l,children:[f.jsx(uc,{className:"mr-1 h-4 w-4"}),"Add Hierarchy"]})})]}),f.jsx(D2,{sensors:i,collisionDetection:k2,onDragEnd:m,children:f.jsx(I2,{items:n.map(b=>b.id),strategy:N4,children:f.jsx("div",{className:"mb-6 space-y-4",children:n.map(b=>f.jsx(Zie,{hierarchy:b,editingHierarchy:s,sampleFieldReferences:o,onSetEditingHierarchy:a,onUpdateHierarchy:u,onDeleteHierarchy:c,onSetDefaultHierarchy:g,onUpdateStep:p,onRemoveStep:h,onAddStep:d},b.id))})})})]})]})]})})}var t_="Checkbox",[ese,dLe]=Pn(t_),[tse,nse]=ese(t_),uL=w.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...d}=e,[h,p]=w.useState(null),g=Ve(t,S=>p(S)),m=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=or({prop:o,defaultProp:i,onChange:c}),x=w.useRef(y);return w.useEffect(()=>{const S=h==null?void 0:h.form;if(S){const _=()=>v(x.current);return S.addEventListener("reset",_),()=>S.removeEventListener("reset",_)}},[h,v]),f.jsxs(tse,{scope:n,state:y,disabled:a,children:[f.jsx(_e.button,{type:"button",role:"checkbox","aria-checked":ca(y)?"mixed":y,"aria-required":s,"data-state":hL(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:g,onKeyDown:fe(e.onKeyDown,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:fe(e.onClick,S=>{v(_=>ca(_)?!0:!_),b&&(m.current=S.isPropagationStopped(),m.current||S.stopPropagation())})}),b&&f.jsx(rse,{control:h,bubbles:!m.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:ca(i)?!1:i})]})});uL.displayName=t_;var dL="CheckboxIndicator",fL=w.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=nse(dL,n);return f.jsx(fn,{present:r||ca(i.state)||i.state===!0,children:f.jsx(_e.span,{"data-state":hL(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});fL.displayName=dL;var rse=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=w.useRef(null),a=py(n),l=fy(t);w.useEffect(()=>{const u=s.current,d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"checked").set;if(a!==n&&p){const g=new Event("click",{bubbles:r});u.indeterminate=ca(n),p.call(u,ca(n)?!1:n),u.dispatchEvent(g)}},[a,n,r]);const c=w.useRef(ca(n)?!1:n);return f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??c.current,...i,tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function ca(e){return e==="indeterminate"}function hL(e){return ca(e)?"indeterminate":e?"checked":"unchecked"}var pL=uL,ose=fL;const zr=w.forwardRef(({className:e,...t},n)=>f.jsx(pL,{ref:n,className:ie("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:f.jsx(ose,{className:ie("flex items-center justify-center text-current"),children:f.jsx(ao,{className:"h-4 w-4"})})}));zr.displayName=pL.displayName;function ise({fields:e,selectedFieldIds:t,onSelectionChange:n,searchPlaceholder:r="Search fields...",className:o=""}){const[i,s]=R.useState(""),a=e.filter(u=>u.label.toLowerCase().includes(i.toLowerCase())||u.qualifiedEntityName&&u.qualifiedEntityName.toLowerCase().includes(i.toLowerCase())),l=()=>{const u=[...new Set([...t,...a.map(d=>d.id)])];n(u)},c=()=>{const u=a.map(d=>d.id);n(t.filter(d=>!u.includes(d)))};return f.jsxs("div",{className:`space-y-2 ${o}`,children:[f.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[f.jsx(yr,{placeholder:r,value:i,onChange:u=>s(u.target.value),className:"flex-1"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.length," fields"]})]}),f.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[f.jsx(Ee,{size:"sm",variant:"outline",onClick:l,children:"Select All"}),f.jsx(Ee,{size:"sm",variant:"outline",onClick:c,children:"Deselect All"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.length," selected"]})]}),f.jsx("div",{className:"grid max-h-32 grid-cols-2 gap-2 overflow-y-auto rounded border p-2",children:a.map(u=>f.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border p-2 text-xs hover:bg-muted/50",children:[f.jsx(zr,{checked:t.includes(u.id),onCheckedChange:d=>{n(d?[...t,u.id]:t.filter(h=>h!==u.id))}}),f.jsx("span",{className:"font-medium",children:u.label})]},u.id))}),i&&a.length===0&&f.jsxs("div",{className:"py-4 text-center text-sm text-muted-foreground",children:['No fields found matching "',i,'"']})]})}const sse=e=>["string","boolean"].includes(P0(e.dataType));function ase({configuringIntent:e,setConfiguringIntent:t,selectedDrillTargets:n,setSelectedDrillTargets:r,availableFields:o}){const i=o.filter(sse),s=n.map(l=>l.id),a=l=>{const c=i.filter(u=>l.includes(u.id));r(c)};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:f.jsx(oF,{className:"h-5 w-5 text-green-600 dark:text-green-400"})}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h4",{className:"mb-1 font-medium",children:"Give users freedom to explore any dimension"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Let users dynamically drill into any available field they choose"}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ee,{size:"sm",variant:"outline",onClick:()=>t(e==="dynamicDrill"?null:"dynamicDrill"),children:e==="dynamicDrill"?"Done":"Configure available fields"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:n.length>0?`${n.length} fields selected`:"All fields available"})]}),e==="dynamicDrill"&&f.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-green-100 bg-green-200/50 p-4 dark:border-green-900 dark:bg-green-900/50",children:[f.jsx("h5",{className:"mb-3 font-medium",children:"Configure Dynamic Drilling"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Choose which fields users can explore dynamically:"}),f.jsx("div",{className:"border-l-2 border-green-200 pl-4",children:f.jsx(ise,{fields:i,selectedFieldIds:s,onSelectionChange:a,searchPlaceholder:"Search fields..."})})]})]})]})]})})}var n_="Switch",[lse,fLe]=Pn(n_),[cse,use]=lse(n_),mL=w.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...d}=e,[h,p]=w.useState(null),g=Ve(t,x=>p(x)),m=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=or({prop:o,defaultProp:i,onChange:c});return f.jsxs(cse,{scope:n,checked:y,disabled:a,children:[f.jsx(_e.button,{type:"button",role:"switch","aria-checked":y,"aria-required":s,"data-state":yL(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:g,onClick:fe(e.onClick,x=>{v(S=>!S),b&&(m.current=x.isPropagationStopped(),m.current||x.stopPropagation())})}),b&&f.jsx(dse,{control:h,bubbles:!m.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});mL.displayName=n_;var gL="SwitchThumb",bL=w.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=use(gL,n);return f.jsx(_e.span,{"data-state":yL(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});bL.displayName=gL;var dse=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=py(n),a=fy(t);return w.useEffect(()=>{const l=i.current,c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&d){const h=new Event("click",{bubbles:r});d.call(l,n),l.dispatchEvent(h)}},[s,n,r]),f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:i,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function yL(e){return e?"checked":"unchecked"}var _y=mL,vL=bL;const r_=w.forwardRef(({className:e,...t},n)=>f.jsx(_y,{className:ie("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:f.jsx(vL,{className:ie("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));r_.displayName=_y.displayName;var o_="Radio",[fse,xL]=Pn(o_),[hse,pse]=fse(o_),wL=w.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:o=!1,required:i,disabled:s,value:a="on",onCheck:l,form:c,...u}=e,[d,h]=w.useState(null),p=Ve(t,b=>h(b)),g=w.useRef(!1),m=d?c||!!d.closest("form"):!0;return f.jsxs(hse,{scope:n,checked:o,disabled:s,children:[f.jsx(_e.button,{type:"button",role:"radio","aria-checked":o,"data-state":EL(o),"data-disabled":s?"":void 0,disabled:s,value:a,...u,ref:p,onClick:fe(e.onClick,b=>{o||l==null||l(),m&&(g.current=b.isPropagationStopped(),g.current||b.stopPropagation())})}),m&&f.jsx(mse,{control:d,bubbles:!g.current,name:r,value:a,checked:o,required:i,disabled:s,form:c,style:{transform:"translateX(-100%)"}})]})});wL.displayName=o_;var CL="RadioIndicator",SL=w.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...o}=e,i=pse(CL,n);return f.jsx(fn,{present:r||i.checked,children:f.jsx(_e.span,{"data-state":EL(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})});SL.displayName=CL;var mse=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=py(n),a=fy(t);return w.useEffect(()=>{const l=i.current,c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&d){const h=new Event("click",{bubbles:r});d.call(l,n),l.dispatchEvent(h)}},[s,n,r]),f.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:i,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function EL(e){return e?"checked":"unchecked"}var gse=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],i_="RadioGroup",[bse,hLe]=Pn(i_,[sd,xL]),_L=sd(),RL=xL(),[yse,vse]=bse(i_),kL=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:o,value:i,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:u=!0,onValueChange:d,...h}=e,p=_L(n),g=sc(c),[m,b]=or({prop:i,defaultProp:o,onChange:d});return f.jsx(yse,{scope:n,name:r,required:s,disabled:a,value:m,onValueChange:b,children:f.jsx(DE,{asChild:!0,...p,orientation:l,dir:g,loop:u,children:f.jsx(_e.div,{role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:g,...h,ref:t})})})});kL.displayName=i_;var NL="RadioGroupItem",ML=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...o}=e,i=vse(NL,n),s=i.disabled||r,a=_L(n),l=RL(n),c=w.useRef(null),u=Ve(t,c),d=i.value===o.value,h=w.useRef(!1);return w.useEffect(()=>{const p=m=>{gse.includes(m.key)&&(h.current=!0)},g=()=>h.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",g),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",g)}},[]),f.jsx(IE,{asChild:!0,...a,focusable:!s,active:d,children:f.jsx(wL,{disabled:s,required:i.required,checked:d,...l,...o,name:i.name,ref:u,onCheck:()=>i.onValueChange(o.value),onKeyDown:fe(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:fe(o.onFocus,()=>{var p;h.current&&((p=c.current)==null||p.click())})})})});ML.displayName=NL;var xse="RadioGroupIndicator",PL=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,o=RL(n);return f.jsx(SL,{...o,...r,ref:t})});PL.displayName=xse;var DL=kL,IL=ML,wse=PL;const ga=w.forwardRef(({className:e,...t},n)=>f.jsx(DL,{className:ie("grid gap-2",e),...t,ref:n}));ga.displayName=DL.displayName;const Fr=w.forwardRef(({className:e,...t},n)=>f.jsx(IL,{ref:n,className:ie("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:f.jsx(wse,{className:"flex items-center justify-center",children:f.jsx(i2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Fr.displayName=IL.displayName;function Cse({configuringIntent:e,setConfiguringIntent:t,incomingFilterFields:n,onUpdateClickFilterInteractions:r,currentClickFilterInteractions:o}){const[i,s]=R.useState(o.length>0),[a,l]=R.useState(o[0]||{filterFields:[],highlightSelf:!0}),[c,u]=R.useState(""),d=tO(),h=e==="clickFilter",p=()=>{const E=!i;if(s(E),E){const C={filterFields:n,highlightSelf:!0,mode:"clickFilter"};l(C),r([C])}else r([])},g=()=>{t("clickFilter")},m=()=>{t(null)},b=E=>{const C={...a,...E};l(C),r([C])},y=()=>a.applyToCardIds!==void 0?"specific-cards":a.excludeCardIds!==void 0?"all-except-specific":"all-cards",v=E=>{const C={};switch(E){case"all-cards":C.applyToCardIds=void 0,C.excludeCardIds=void 0;break;case"specific-cards":C.applyToCardIds=[],C.excludeCardIds=void 0;break;case"all-except-specific":C.applyToCardIds=void 0,C.excludeCardIds=[];break}b(C)},x=(E,C)=>{if(C==="specific-cards"){const k=a.applyToCardIds||[],N=k.includes(E)?k.filter(M=>M!==E):[...k,E];b({applyToCardIds:N})}else if(C==="all-except-specific"){const k=a.excludeCardIds||[],N=k.includes(E)?k.filter(M=>M!==E):[...k,E];b({excludeCardIds:N})}},S=R.useMemo(()=>{if(!c.trim())return d;const E=c.toLowerCase();return d==null?void 0:d.filter(C=>{var k;return(k=C==null?void 0:C.title)==null?void 0:k.toLowerCase().includes(E)})},[c,d]),_=()=>{var C,k;if(!i)return"0 settings configured";const E=y();if(E==="all-cards")return"filtering all cards";if(E==="specific-cards"){const N=((C=a.applyToCardIds)==null?void 0:C.length)||0;return N===0?"no cards selected":`filtering ${N} card${N!==1?"s":""}`}else if(E==="all-except-specific"){const N=((k=a.excludeCardIds)==null?void 0:k.length)||0;return N===0?"filtering all cards":`excluding ${N} card${N!==1?"s":""}`}return"0 settings configured"};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:f.jsx("svg",{className:"h-5 w-5 text-green-600 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})})}),f.jsxs("div",{className:"flex-1",children:[f.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[f.jsx("h4",{className:"font-medium",children:"Enable click filters"}),f.jsx(r_,{checked:i,onCheckedChange:p})]}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Apply filters to other cards when users click on chart elements"}),i&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ee,{size:"sm",variant:"outline",onClick:h?m:g,children:h?"Done":"Configure"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:_()})]}),h&&i&&f.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-green-100 bg-green-200/50 p-4 dark:border-green-900 dark:bg-green-900/50",children:[f.jsx("h5",{className:"mb-3 font-medium",children:"Configure Click Filters"}),f.jsx("div",{className:"space-y-6",children:f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(de,{className:"text-sm font-medium",children:"Filter scope"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),f.jsxs(ga,{value:y(),onValueChange:E=>v(E),className:"space-y-3",children:[f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Fr,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(de,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Fr,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(de,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),y()==="specific-cards"&&f.jsxs("div",{className:"ml-7 space-y-2",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(de,{className:"text-sm font-medium",children:"Cards to filter"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),f.jsx(yr,{placeholder:"Search cards...",value:c,onChange:E=>u(E.target.value),className:"mb-2"}),f.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:S.length>0?S.map(E=>{const C=(a.applyToCardIds||[]).includes(E.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(zr,{id:`card-${E.id}`,checked:C,onCheckedChange:()=>x(E.id,"specific-cards")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(de,{htmlFor:`card-${E.id}`,className:"cursor-pointer text-sm font-medium",children:E.title}),E.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:E.description})]})]},E.id)}):f.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]}),f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Fr,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(de,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),y()==="all-except-specific"&&f.jsxs("div",{className:"ml-7 space-y-2",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(de,{className:"text-sm font-medium",children:"Cards to exclude"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),f.jsx(yr,{placeholder:"Search cards...",value:c,onChange:E=>u(E.target.value),className:"mb-2"}),f.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:S.length>0?S.map(E=>{const C=(a.excludeCardIds||[]).includes(E.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(zr,{id:`card-exclude-${E.id}`,checked:C,onCheckedChange:()=>x(E.id,"all-except-specific")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(de,{htmlFor:`card-exclude-${E.id}`,className:"cursor-pointer text-sm font-medium",children:E.title}),E.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:E.description})]})]},E.id)}):f.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]})]})]})})]})]})]})})}function Sse(e){return e.flatMap(t=>t.columns.map(n=>({id:`${t.entityId}-${n.name}`,name:n.name,dataType:n.dataType,qualifiedEntityName:t.qualifiedEntityName,label:n.label||CE(n.name),description:n.description,entityId:t.entityId,entityName:t.entityName,entityType:t.entityType})))}function AL(e){if(e.type==="table"||e.type==="view"||e.type==="dataset"){if(e.database&&e.schema)return`${e.database}.${e.schema}.${e.name}`;if(e.database)return`${e.database}.${e.name}`}return e.name}function TL(e){var m;const t=re(b=>b.authToken)||e,{hasSchemaSupport:n}=BJ(e),r=Ce(b=>{var y;return(y=b.card.dataSource)==null?void 0:y.connectionId}),o=Ce(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="model")})||[],i=Ce(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="table"||x.type==="view")})||[],s=Ce(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="dataset")})||[];function a(b){return b.type==="dataset"?!!r&&!!b.domainId&&!!b.name:b.type==="model"?!!r&&!!b.id:b.type==="table"||b.type==="view"?n?!!r&&!!b.name&&!!b.database&&!!b.schema:["S3","API"].includes(b.connectionType)?!!r&&!!b.name:!!r&&!!b.name&&!!b.database:!1}const l=[...o,...i,...s],c=XY({queries:l.map(b=>{let y={};return b.type==="model"?y={connection_id:r,datamodel_id:b.id,database_name:"",schema_name:"",table_name:""}:b.type==="dataset"?y={connection_id:b.connectionId,domain_id:b.domainId,dataset_name:b.name}:y={connection_id:r,datamodel_id:"",database_name:b.database,schema_name:b.schema,table_name:b.name},{queryKey:["columns",r,b],queryFn:()=>br("https://semaphor.cloud/api/v1/columns",(t==null?void 0:t.accessToken)||"",y),enabled:!!r&&a(b)}})}),u=c.some(b=>b.isPending),d=c.some(b=>b.isError),h=(m=c.find(b=>b.isError))==null?void 0:m.error,p=c.map((b,y)=>{var S;const v=l[y],x=AL(v);return{entityId:v.id||v.name,entityType:v.type,entityName:v.name,label:v.label,description:v.description,qualifiedEntityName:x,columns:(S=b.data)==null?void 0:S.columns.map(_=>({id:`${v.name}-${_.column_name}`,name:_.column_name,dataType:_.data_type,label:_.label||SE(_.column_name),description:_.description||"",qualifiedEntityName:x,entityId:v.id||v.id||v.name,entityName:v.name,entityType:v.type}))}}).filter(b=>{var y;return((y=b==null?void 0:b.columns)==null?void 0:y.length)>0})||[],g=Sse(p);return{columnGroups:p,columns:g,isLoading:u,hasError:d,error:h,refetch:()=>{c.forEach(b=>b.refetch())}}}function Ese({isOpen:e,onClose:t}){var T,O,$,B;const n=IJ(),r=AJ(),{updateCurrentDashboardCard:o}=on(),{columns:i}=TL(),{groupByFields:s,pivotByFields:a}=nO(),l=[...s,...a],c=i,u=((T=n.interactionConfig)==null?void 0:T.drillHierarchies)||[],d=((O=n.interactionConfig)==null?void 0:O.allowedDrillTargets)||[],h=R.useMemo(()=>{var z;return((z=n.interactionConfig)==null?void 0:z.clickFilterInteractions)||[]},[($=n.interactionConfig)==null?void 0:$.clickFilterInteractions]),p=R.useMemo(()=>{var z;return((z=n.interactionConfig)==null?void 0:z.drillInteractions)||[]},[(B=n.interactionConfig)==null?void 0:B.drillInteractions]),[g,m]=R.useState(u),[b,y]=R.useState(d||[]),[v,x]=R.useState(null),[S,_]=R.useState(()=>p.filter(z=>z.mode==="drillToURL")),[E,C]=R.useState(()=>p.filter(z=>z.mode==="drillThrough")),[k,N]=R.useState(()=>p.filter(z=>z.mode==="drillToDetail")),[M,I]=R.useState(h),D=R.useRef(null);R.useEffect(()=>{var z,A,W;if(e){m(((z=n.interactionConfig)==null?void 0:z.drillHierarchies)||[]),y(((A=n.interactionConfig)==null?void 0:A.allowedDrillTargets)||[]),x(null);const L=((W=n.interactionConfig)==null?void 0:W.drillInteractions)||[];_(L.filter(P=>P.mode==="drillToURL")),C(L.filter(P=>P.mode==="drillThrough")),N(L.filter(P=>P.mode==="drillToDetail")),I(h)}},[e,n.interactionConfig,h]);const j=()=>{var W;const z=[...S,...E,...k];r.updateDrillHierarchies(g),r.updateDrillInteractions(z),(W=D.current)!=null&&W.saveToGlobal&&D.current.saveToGlobal(),r.updateAllowedDrillTargets(b);const A={...n,interactionConfig:{...n.interactionConfig,drillHierarchies:g,allowedDrillTargets:b,drillInteractions:z,clickFilterInteractions:M}};o(A),t()},F=()=>{x(null),t()};return e?f.jsxs(ey,{modal:!1,open:e,onOpenChange:t,children:[f.jsx("div",{className:"pointer-events-none fixed inset-0 z-40 bg-background/80 backdrop-blur-sm"}),f.jsxs(ip,{className:"flex max-h-[90vh] max-w-4xl flex-col overflow-hidden",children:[f.jsxs(sp,{children:[f.jsx(lp,{children:"Configure Interactions"}),f.jsx(cp,{children:"Set up drill behaviors for this chart"})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx("div",{className:"space-y-6",children:f.jsx("div",{children:f.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[f.jsx(Cse,{configuringIntent:v,setConfiguringIntent:x,incomingFilterFields:l,onUpdateClickFilterInteractions:I,currentClickFilterInteractions:M}),f.jsx(Jie,{configuringIntent:v,setConfiguringIntent:x,drillHierarchies:g,onUpdateHierarchies:m,availableFields:c}),f.jsx(ase,{configuringIntent:v,setConfiguringIntent:x,selectedDrillTargets:b,setSelectedDrillTargets:y,availableFields:c})]})})})}),f.jsxs(ap,{className:"border-t-0",children:[f.jsx(Ee,{variant:"outline",onClick:F,children:"Cancel"}),f.jsx(Ee,{onClick:j,children:"Save Changes"})]})]})]}):null}function jL({frame:e}){var h;const t=re(p=>p.isDashboardEditing),n=re(p=>p.isVisualEditing),r=re(p=>p.selectedSheetId),[o,i]=R.useState(!1),s=e.cards.find(p=>p.id===e.activeCardId),{removeFrame:a}=re(p=>p.actions),l=re(p=>p.actions.setIsVisualEditing),{handleEditVisual:c,card:u,data:d}=VJ(e);return f.jsx("section",{onMouseDown:p=>{p.stopPropagation()},className:"absolute right-2 top-2 z-50",children:f.jsxs("div",{className:"flex items-center gap-2",children:[t&&(s==null?void 0:s.config)&&f.jsx("button",{onClick:()=>i(!0),children:f.jsx(aa,{className:"size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}),f.jsx(Ese,{isOpen:o,onClose:()=>i(!1)}),t&&(n?f.jsx("button",{onClick:()=>{l(!n)},children:f.jsx(kZ,{className:"size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}):f.jsx("button",{role:"edit-visual",onClick:()=>c(),children:f.jsx(MZ,{className:"ml-1 size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})})),t&&f.jsx("button",{onClick:()=>a(r,e.id),children:f.jsx(V5,{className:"size-3.5 text-center text-muted-foreground/70 hover:cursor-pointer hover:text-muted-foreground"})}),((h=u.preferences)==null?void 0:h.allowDownload)===!0&&f.jsx(iJ,{data:(d==null?void 0:d.records)||[],filename:u.title})]})})}const _se=R.createContext(null),Rx={didCatch:!1,error:null};class _p extends R.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Rx}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:i,reason:"imperative-api"}),this.setState(Rx)}}componentDidCatch(t,n){var r,o;(r=(o=this.props).onError)===null||r===void 0||r.call(o,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:o}=this.props;if(r&&n.error!==null&&Rse(t.resetKeys,o)){var i,s;(i=(s=this.props).onReset)===null||i===void 0||i.call(s,{next:o,prev:t.resetKeys,reason:"keys"}),this.setState(Rx)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:o}=this.props,{didCatch:i,error:s}=this.state;let a=t;if(i){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=R.createElement(r,l);else if(o!==void 0)a=o;else throw s}return R.createElement(_se.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function Rse(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function OL({error:e,resetErrorBoundary:t}){return f.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center rounded-lg border border-dashed border-muted-foreground/25 bg-muted/30 p-6 text-center",children:[f.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:f.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),f.jsx("h3",{className:"mb-2 text-sm font-medium text-foreground",children:"Chart Unavailable"}),f.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"We couldn't display this chart right now. Please try refreshing or check your data configuration."}),f.jsxs("button",{onClick:t,className:"inline-flex items-center justify-center rounded-md bg-primary px-3 py-2 text-xs font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[f.jsx("svg",{className:"mr-1.5 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]}),Yg]})}function s_({error:e}){return f.jsx("div",{className:"flex flex-col items-center justify-center",role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},children:f.jsxs("div",{style:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.08)",color:"#b91c1c",fontFamily:"sans-serif",padding:"16px",textAlign:"center",flexDirection:"column",whiteSpace:"pre-wrap",position:"relative"},className:"flex flex-col justify-center space-y-1 rounded-md bg-muted p-10",children:[f.jsx("p",{className:"text-sm",children:"Something went wrong:"}),f.jsx("pre",{className:"text-xs",children:e.message})]})})}function kse({error:e,frame:t}){return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[f.jsx(jL,{frame:t}),f.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),f.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[f.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),f.jsx("p",{className:"text-sm",children:"Something went wrong:"}),f.jsx("pre",{className:"text-xs",children:e.message})]})]})}function Nse({error:e}){return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center",role:"alert",children:[f.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),f.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[f.jsx("p",{className:"text-lg font-semibold",children:"Oops! Something went wrong!"}),f.jsx("p",{className:"text-sm",children:"Something went wrong:"}),f.jsx("pre",{className:"text-xs",children:e.message})]})]})}function rr({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:o="",locale:i="en-US"}){let s=1,a=r,l=i;const c=t;n&&!r&&(e>=1e9?(s=1e9,a="B"):e>=1e7&&i==="en-IN"?(s=1e7,a="Cr"):e>=1e5&&i==="en-IN"?(s=1e5,a="L"):e>=1e6?(s=1e6,a="M"):e>=1e3&&(s=1e3,a="K"));const u=e/s,d={maximumFractionDigits:c,minimumFractionDigits:c};if(o){d.style="currency",d.currency=o;try{new Intl.NumberFormat(i,d).format(0)}catch{}}try{new Intl.NumberFormat(i,d).format(0)}catch{l="en-US"}let p=new Intl.NumberFormat(l,d).format(u);return n&&(p+=a),p}function Ry(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function ky(e){try{const n=new Function("getDatalabelColor",e)(b1);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}catch(t){return console.error("Error processing custom visual code",t),{options:{},plugins:[]}}}function Mse(e){var t,n,r,o,i,s,a,l,c,u,d,h,p,g,m,b,y,v;return!e||((r=(n=(t=e==null?void 0:e.scales)==null?void 0:t.x)==null?void 0:n.grid)==null?void 0:r.display)===!0&&((s=(i=(o=e==null?void 0:e.scales)==null?void 0:o.y)==null?void 0:i.grid)==null?void 0:s.display)===!0?"xy":(c=(l=(a=e.scales)==null?void 0:a.x)==null?void 0:l.grid)!=null&&c.display?"x":(h=(d=(u=e.scales)==null?void 0:u.y)==null?void 0:d.grid)!=null&&h.display?"y":((m=(g=(p=e.scales)==null?void 0:p.x)==null?void 0:g.grid)==null?void 0:m.display)===!1&&((v=(y=(b=e.scales)==null?void 0:b.y)==null?void 0:y.grid)==null?void 0:v.display)===!1?"none":"xy"}function Pse(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return FL(t)}function FL(e){const[t,n,r]=e.split(" "),o=parseFloat(t),i=parseFloat(n),s=parseFloat(r),a=i/100,l=s/100,c=(1-Math.abs(2*l-1))*a,u=c*(1-Math.abs(o/60%2-1)),d=l-c/2;let h=0,p=0,g=0;0<=o&&o<60?(h=c,p=u,g=0):60<=o&&o<120?(h=u,p=c,g=0):120<=o&&o<180?(h=0,p=c,g=u):180<=o&&o<240?(h=0,p=u,g=c):240<=o&&o<300?(h=u,p=0,g=c):300<=o&&o<360&&(h=c,p=0,g=u),h=Math.round((h+d)*255),p=Math.round((p+d)*255),g=Math.round((g+d)*255);const m=b=>{const y=b.toString(16);return y.length==1?"0"+y:y};return`#${m(h)}${m(p)}${m(g)}`}function Dse(e,t){return e.map(r=>Object.fromEntries(Object.entries(r).filter(([o])=>!t.some(i=>i.label===o))))}function Ise(e){return e.length===1?[e[0]]:e.slice(1).filter(n=>!Xj.includes(n))}function Pc({data:e,cfg:t,customCfg:n,preferences:r,cardType:o,card:i}){var x;const s=o==="radar"?.2:1,{keys:a}=un(e),l=Ise(a);let c="none";o=="bar"?c="bar":o=="line"&&(c="line");const u=yF(l,e,r,s,c),d=El(u,n),h=a[0],p=op(e,h),{options:g,plugins:m}=Cb({cardType:o,cfg:t,preferences:r,customCfg:n}),b=(x=i.interactionConfig)==null?void 0:x.clickFilterInteractions,y=function(S,_){var C;const E=((C=S.native)==null?void 0:C.target)||S.target;_.length?E.style.cursor="pointer":E.style.cursor="default"};return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:p,datasets:d},options:{...g,onHover:b?y:void 0},plugins:m}}function LL(e,t){var o,i,s;const n=((o=t==null?void 0:t.options)==null?void 0:o.indexAxis)==="y"?"x":"y";return(i=e==null?void 0:e.chartOptions)!=null&&i.indexAxis?((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)==="x"?"y":"x":n}function Ase(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"x":"y":"x"}function $L(e,t){var i,s,a,l,c,u,d,h,p,g,m,b;const n=LL(t,e),r=Ase(t);return{...e==null?void 0:e.options,scales:{...(i=e==null?void 0:e.options)==null?void 0:i.scales,[n]:{...(a=(s=e==null?void 0:e.options)==null?void 0:s.scales)==null?void 0:a[n],ticks:{...(u=(c=(l=e==null?void 0:e.options)==null?void 0:l.scales)==null?void 0:c[n])==null?void 0:u.ticks,callback:y=>{var v,x,S,_;return rr({number:Number(y),decimalPlaces:((v=t==null?void 0:t.numberAxisFormat)==null?void 0:v.decimalPlaces)||0,useSuffix:!!((x=t==null?void 0:t.numberAxisFormat)!=null&&x.suffix),customSuffix:"",locale:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.locale)||"",currency:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.currency)||""})}}},[r]:{...(p=(h=(d=e==null?void 0:e.options)==null?void 0:d.scales)==null?void 0:h[r])==null?void 0:p.ticks,callback:null}},plugins:{...(g=e==null?void 0:e.options)==null?void 0:g.plugins,datalabels:{...(b=(m=e==null?void 0:e.options)==null?void 0:m.plugins)==null?void 0:b.datalabels,formatter:function(y){var v,x,S,_;return rr({number:Number(y),decimalPlaces:((v=t==null?void 0:t.numberAxisFormat)==null?void 0:v.decimalPlaces)||0,useSuffix:!!((x=t==null?void 0:t.numberAxisFormat)!=null&&x.suffix),customSuffix:"",locale:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.locale)||"",currency:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.currency)||""})}}}}}function Cb({cardType:e,cfg:t,preferences:n,customCfg:r}){var g,m,b,y,v,x,S,_,E,C,k,N,M,I,D,j,F,T,O,$,B,z,A,W,L,P,H,V,G;const o=re.getState().themeStyle,i=$L(t,n),s=Bn((t==null?void 0:t.options)||{},n==null?void 0:n.chartOptions),a=Bn(i,s),l=Bn(a,(r==null?void 0:r.options)||{}),c=Tse(e,n,l),u={...l,scales:{...l==null?void 0:l.scales,x:{...(g=l==null?void 0:l.scales)==null?void 0:g.x,grid:{...(b=(m=l==null?void 0:l.scales)==null?void 0:m.x)==null?void 0:b.grid,color:(_=(S=(x=(v=(y=o==null?void 0:o.chart)==null?void 0:y.options)==null?void 0:v.scales)==null?void 0:x.x)==null?void 0:S.grid)==null?void 0:_.color}},y:{...(E=l==null?void 0:l.scales)==null?void 0:E.y,grid:{...(k=(C=l==null?void 0:l.scales)==null?void 0:C.y)==null?void 0:k.grid,color:(j=(D=(I=(M=(N=o==null?void 0:o.chart)==null?void 0:N.options)==null?void 0:M.scales)==null?void 0:I.y)==null?void 0:D.grid)==null?void 0:j.color}}},plugins:{...l==null?void 0:l.plugins,tooltip:{filter:function(q){return q.raw!==void 0&&q.raw!==0},callbacks:c,...(F=l==null?void 0:l.plugins)==null?void 0:F.tooltip,backgroundColor:(B=($=(O=(T=o==null?void 0:o.chart)==null?void 0:T.options)==null?void 0:O.plugins)==null?void 0:$.tooltip)==null?void 0:B.backgroundColor,bodyColor:(L=(W=(A=(z=o==null?void 0:o.chart)==null?void 0:z.options)==null?void 0:A.plugins)==null?void 0:W.tooltip)==null?void 0:L.bodyColor,titleColor:(G=(V=(H=(P=o==null?void 0:o.chart)==null?void 0:P.options)==null?void 0:H.plugins)==null?void 0:V.tooltip)==null?void 0:G.titleColor}}},{plugins:d,options:h}=ky((n==null?void 0:n.customVisualCode)||"");return{options:Bn(u,h),plugins:d}}function Tse(e,t,n){var r,o;return e==="map"?{}:{title:function(i){var a,l,c,u,d;const s=((a=i==null?void 0:i[0])==null?void 0:a.label)||"";if(i.length>1&&["stackedBar","stackedLine"].includes(e||"")){const h=i.reduce((g,m)=>{const b=m.raw;return b!==void 0&&b!==0?g+b:g},0),p=rr({number:h,decimalPlaces:((l=t==null?void 0:t.numberAxisFormat)==null?void 0:l.decimalPlaces)||0,useSuffix:!!((c=t==null?void 0:t.numberAxisFormat)!=null&&c.suffix),customSuffix:"",locale:((u=t==null?void 0:t.numberAxisFormat)==null?void 0:u.locale)||"",currency:((d=t==null?void 0:t.numberAxisFormat)==null?void 0:d.currency)||""});return`${s} (${p})`}return s},label:function(i){var c,u,d,h,p;const s=((c=i==null?void 0:i.dataset)==null?void 0:c.label)||"",a=i==null?void 0:i.raw;if(a===void 0||a===0)return;const l=rr({number:Number(a),decimalPlaces:((u=t==null?void 0:t.numberAxisFormat)==null?void 0:u.decimalPlaces)||0,useSuffix:!!((d=t==null?void 0:t.numberAxisFormat)!=null&&d.suffix),customSuffix:"",locale:((h=t==null?void 0:t.numberAxisFormat)==null?void 0:h.locale)||"",currency:((p=t==null?void 0:t.numberAxisFormat)==null?void 0:p.currency)||""});return`${s}: ${l}`},...((o=(r=n==null?void 0:n.plugins)==null?void 0:r.tooltip)==null?void 0:o.callbacks)||{}}}/*!
486
486
  * @kurkle/color v0.3.4
487
487
  * https://github.com/kurkle/color#readme
488
488
  * (c) 2024 Jukka Kurkela
@@ -624,7 +624,7 @@ Error message: ${OW(n)}`,cause:n}),this[UW]=!0,this.value=t}static isInstance(t)
624
624
  padding: 0 4px;
625
625
  margin: 0 1px;
626
626
  }
627
- `})]})});uU.displayName="HighlightedInput";function hFe({availableEntities:e,localAiContext:t,setLocalAiContext:n}){const[r,o]=R.useState(""),[i,s]=R.useState(!1),[a,l]=R.useState(0),c=R.useRef(null),u=D=>"label"in D?D.label:D.name,d=D=>t.selectedEntities.some(j=>"id"in D&&"id"in j?D.id===j.id:D.name===j.name&&D.connectionId===j.connectionId),h=D=>{if(!D)return;D.focus();const j=window.getSelection();if(j){const F=document.createRange();F.selectNodeContents(D),F.collapse(!1),j.removeAllRanges(),j.addRange(F)}},p=D=>{const j=D.target.value,F=D.target.selectionStart||0;o(j),l(F);const T=j.slice(0,F),O=T.lastIndexOf("@");if(O!==-1){const $=T.slice(O+1),B=(O===0||/\s/.test(T[O-1]))&&!$.includes(" ");s(B)}else s(!1)},g=D=>{D.key==="Escape"&&i&&(D.preventDefault(),s(!1),setTimeout(()=>{if(D.currentTarget){D.currentTarget.focus();const j=window.getSelection();if(j){const F=document.createRange();F.selectNodeContents(D.currentTarget),F.collapse(!1),j.removeAllRanges(),j.addRange(F)}}},0))},m=D=>{const j=u(D),T=r.slice(0,a).lastIndexOf("@");if(T!==-1){const O=r.slice(0,T),$=r.slice(a),B=O+"@"+j+" "+$;o(B);const z=T+j.length+2;l(z)}},b=D=>{const F=`@${u(D)}`,T=r.indexOf(F);if(T!==-1){const O=r.slice(0,T),$=r.slice(T+F.length),B=O+($.startsWith(" ")?$.slice(1):$);o(B),l(T)}},y=D=>{const j=[...t.selectedEntities,D];n({selectedEntities:j})},v=D=>{const j=t.selectedEntities.filter(F=>"id"in D&&"id"in F?D.id!==F.id:!(D.name===F.name&&D.connectionId===F.connectionId));n({selectedEntities:j})},x=D=>{d(D)?(v(D),b(D)):(y(D),m(D))},S=D=>{x(D)},_=D=>{d(D)||y(D),m(D),s(!1),setTimeout(()=>h(c.current),0)},E=D=>{v(D),b(D)},C=D=>{D.forEach(j=>{v(j),b(j)})},k=()=>{n({selectedEntities:[...e]}),e.forEach((D,j)=>{u(D)})},N=()=>{n({selectedEntities:[]});let D=r;t.selectedEntities.forEach(j=>{const T=`@${u(j)}`;D=D.replace(new RegExp(`${T}\\s?`,"g"),"")}),o(D),l(D.length)},M=R.useCallback(()=>{s(!1),setTimeout(()=>h(c.current),0)},[c]);return R.useEffect(()=>{const D=F=>{const T=F.target;!T.closest('[data-dropdown="entity-mention"]')&&!T.closest(".entity-dropdown-container")&&i&&M()},j=F=>{F.key==="Escape"&&i&&M()};return i&&(document.addEventListener("mousedown",D),document.addEventListener("keydown",j)),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",j)}},[i,M]),{message:r,setMessage:o,showMentionDropdown:i,setShowMentionDropdown:s,cursorPosition:a,mainInputRef:c,handleTextareaChange:p,handleKeyDown:g,handleEntitySelect:x,handleEntityDeselect:S,handleMainTabComplete:_,handleRemoveEntity:E,handleAddAllEntities:k,handleRemoveEntities:C,handleRemoveAllEntities:N,closeDropdownAndFocus:M,handleMainAtButtonClick:()=>{s(!0),setTimeout(()=>h(c.current),0)},focusInputElement:h}}const dU=R.forwardRef(({input:e,setInput:t,handleSubmit:n,isLoading:r,stop:o,onFocus:i},s)=>{const a=oR(),{setCurrentAIContext:l}=iR(),c=re(I=>{var D;return(D=I.dashboard.aiContext)==null?void 0:D.selectedEntities}),{message:u,setMessage:d,showMentionDropdown:h,setShowMentionDropdown:p,mainInputRef:g,handleTextareaChange:m,handleKeyDown:b,handleEntitySelect:y,handleEntityDeselect:v,handleMainTabComplete:x,handleRemoveEntity:S,handleRemoveEntities:_,handleAddAllEntities:E,handleRemoveAllEntities:C,handleMainAtButtonClick:k,focusInputElement:N}=hFe({availableEntities:c||[],localAiContext:a,setLocalAiContext:l});R.useEffect(()=>{d(e)},[e,d]),R.useEffect(()=>{t(u)},[u,t]);const M=I=>{u.trim()&&(n({preventDefault:()=>{}}),d(""))};return f.jsxs("div",{className:"space-y-4",children:[f.jsx(dFe,{entities:a.selectedEntities,availableEntities:c||[],onRemoveEntity:S,onRemoveEntities:_}),f.jsxs("div",{className:"relative",children:[f.jsx(uU,{value:u,onChange:m,onKeyDown:I=>{b(I),I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),M())},onFocus:I=>{i==null||i(),u.includes("@")&&p(!0)},placeholder:"What question do you have?",className:"pr-12placeholder-gray-400 min-h-[100px] resize-none border-foreground/20",isTextarea:!0,availableEntities:c||[],"data-input":"main",ref:g}),f.jsx(Ee,{variant:"outline",size:"sm",className:"absolute bottom-3 left-3 h-7 px-2",onClick:k,title:"Add entity",children:f.jsx($Z,{className:"h-4 w-4 text-muted-foreground"})}),f.jsxs("div",{className:"absolute bottom-3 right-3 flex items-center gap-2",children:[r===!0&&f.jsx(Ee,{size:"sm",onClick:()=>o(),children:f.jsx(KZ,{className:"size-3.5 bg-background"})}),r===!1&&f.jsx(Ee,{disabled:r===!1&&!e,size:"sm",onClick:()=>M(),children:f.jsx(tJ,{className:"size-4"})})]}),h&&f.jsx("div",{className:"entity-dropdown-container absolute left-0 z-50","data-dropdown":"entity-mention",style:{bottom:"100%",marginBottom:"0.5rem",width:"20rem",maxWidth:"100%"},ref:I=>{I&&I.getBoundingClientRect().top<10&&(I.style.bottom="auto",I.style.top="100%",I.style.marginBottom="0",I.style.marginTop="0.5rem")},children:f.jsx(cFe,{isOpen:h,onSelect:y,onDeselect:v,onClose:()=>{p(!1),setTimeout(()=>N(g.current),0)},availableEntities:c||[],selectedEntities:a.selectedEntities,onTabComplete:x,onSelectAll:E,onRemoveAll:C})})]})]})});function fU(e){return e.type==="dataset"&&e.label||e.name}function pFe(e){const t=[];return t.push({label:"Type",value:e.type}),t.push({label:"Name",value:e.name}),e.connectionType&&t.push({label:"Connection",value:e.connectionType}),e.database&&t.push({label:"Database",value:e.database}),e.schema&&t.push({label:"Schema",value:e.schema}),e.type==="dataset"&&e.label&&t.push({label:"Label",value:e.label}),e.type==="dataset"&&e.description&&t.push({label:"Description",value:e.description}),e.type==="model"&&e.label&&t.push({label:"Label",value:e.label}),e.type==="model"&&e.description&&t.push({label:"Description",value:e.description}),t}function mFe({selectedEntities:e,onDeselectEntity:t}){return e.length===0?null:f.jsxs("div",{className:"mb-4 space-y-2",children:[f.jsxs(de,{className:"mb-2 text-xs font-medium text-muted-foreground",children:["Selected Entities (",e.length,")"]}),f.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((n,r)=>f.jsxs(eo,{variant:"secondary",className:"group relative cursor-pointer pr-6 text-xs transition-colors hover:border-red-200 hover:bg-red-50 dark:hover:border-red-800 dark:hover:bg-red-950",children:[f.jsxs("span",{className:"mr-1 text-gray-500",children:["[",n.type,"]"]}),fU(n),f.jsx("button",{onClick:o=>{o.stopPropagation(),t(n)},className:"absolute right-1 top-1/2 -translate-y-1/2 rounded-full p-0.5 opacity-0 transition-opacity hover:bg-red-100 group-hover:opacity-100",children:f.jsx(nr,{className:"h-2.5 w-2.5 text-red-500"})})]},`${n.type}-${n.name}-${r}`))})]})}function hU(e){const t=re(a=>a.authToken)||e;Ce(a=>a.selectedConnectionId),Ce(a=>{var l,c;return(c=(l=a==null?void 0:a.card)==null?void 0:l.dataSource)==null?void 0:c.connectionId});const{refetch:n,isPending:r,data:o,isLoading:i,isError:s}=Tn({queryKey:["semantic-domains"],queryFn:()=>br("https://semaphor.cloud/api/v1/domains",(t==null?void 0:t.accessToken)||""),enabled:!!(t!=null&&t.accessToken)});return{isPending:r,error:s,semanticDomainsData:o,semanticDomains:(o==null?void 0:o.domains)||[],isSemanticDomainsLoading:i,isSemanticDomainsError:s,refetchSemanticDomains:n}}function gFe(e,t){const n=re(l=>l.authToken)||t,{refetch:r,isPending:o,data:i,isLoading:s,isError:a}=Tn({queryKey:["datasets",e],queryFn:()=>br("https://semaphor.cloud/api/v1/datasets",(n==null?void 0:n.accessToken)||"",{domainId:e}),enabled:!!(n!=null&&n.accessToken)&&!!e});return{isPending:o,error:a,datasets:(i==null?void 0:i.datasets)||[],isDatasetsLoading:s,isDatasetsError:a,refetchDatasets:r}}function bFe(e){var g,m;const t=re(b=>b.authToken)||e,{connections:n}=Li(e),r=Ce(b=>{var y,v;return(v=(y=b==null?void 0:b.card)==null?void 0:y.dataSource)==null?void 0:v.connectionId}),o=n==null?void 0:n.find(b=>b.id===r),i=o==null?void 0:o.type,s=o==null?void 0:o.capabilities,a=((g=s==null?void 0:s.labels)==null?void 0:g.database)||"Database";function l(b){return r&&b?!(b==="API"||b==="S3"):!1}const{data:c,isPending:u,error:d,refetch:h}=Tn({queryKey:["databases",r],queryFn:()=>br("https://semaphor.cloud/api/v1/databases",(t==null?void 0:t.accessToken)||"",{connection_id:r}),enabled:l(i)}),p=(m=c==null?void 0:c.databases)==null?void 0:m.map(b=>({id:b.database_name,name:b.database_name}));return{isPending:u,error:d,databases:p||[],refetch:h,label:a}}function yFe(e){var g;const t=re(m=>m.authToken)||e,{connections:n}=Li(e),r=Ce(m=>{var b,y;return(y=(b=m==null?void 0:m.card)==null?void 0:b.dataSource)==null?void 0:y.connectionId}),o=Ce(m=>{var b,y,v;return(v=(y=(b=m==null?void 0:m.card)==null?void 0:b.dataSource)==null?void 0:y.dbSelection)==null?void 0:v.database}),i=n==null?void 0:n.find(m=>m.id===r),s=i==null?void 0:i.capabilities,a=((g=s==null?void 0:s.labels)==null?void 0:g.schema)||"Schema";function l(){return!(!r||(i==null?void 0:i.type)==="API"||(i==null?void 0:i.type)==="S3"||!o||!(s!=null&&s.path.includes("schema")))}const{data:c,isPending:u,error:d,refetch:h}=Tn({queryKey:["schemas",r,o],queryFn:()=>br("https://semaphor.cloud/api/v1/schemas",(t==null?void 0:t.accessToken)||"",{connection_id:r,database_name:o}),enabled:l()}),p=c==null?void 0:c.schemas.map(m=>({id:m.schema_name,name:m.schema_name}));return{isPending:u,error:d,schemas:p||[],refetch:h,label:a}}function pU(e){const t=re(d=>d.authToken)||e,{connections:n}=Li(e),r=Ce(d=>{var h,p;return(p=(h=d==null?void 0:d.card)==null?void 0:h.dataSource)==null?void 0:p.connectionId}),o=n.find(d=>d.id===r);function i(){return!(!(t!=null&&t.accessToken)||!r)}const{data:s,isPending:a,error:l,refetch:c}=Tn({queryKey:["dataModels",r],queryFn:()=>br("https://semaphor.cloud/api/v1/datamodels",(t==null?void 0:t.accessToken)||"",{connection_id:r}),enabled:i()}),u=s==null?void 0:s.datamodels.map(d=>({id:d.id,name:d.name,label:d.label,description:d.description,connectionId:r,connectionType:o==null?void 0:o.type,dialect:o==null?void 0:o.dialect,type:"model",database:d.database,schema:d.schema}));return{isPending:a,error:l,dataModels:u||[],refetch:c}}function vFe(){var _,E,C;const e=Ce(k=>k.card.dataSource);Ce(k=>k.actions.updateDirectSource);const t=Ce(k=>k.actions.updateDataSource),[n,r]=R.useState(""),{selectedConnection:o,error:i}=Li(),{databases:s,isPending:a,error:l,label:c}=bFe(),{schemas:u,isPending:d,error:h,label:p}=yFe(),{error:g}=pU(),m=o==null?void 0:o.capabilities.path.includes("schema"),b=o==null?void 0:o.capabilities.path.includes("database"),y=c==null?void 0:c.toLowerCase(),v=p==null?void 0:p.toLowerCase(),x=k=>{e&&t({...e,dbSelection:{database:k,schema:"",entityType:"table"},selectedEntities:(e==null?void 0:e.selectedEntities)||[]})},S=k=>{var M;if(!((M=e==null?void 0:e.dbSelection)!=null&&M.database))return;const N=e.dbSelection||{database:"",schema:"",entityType:"table"};t({...e,dbSelection:{...N,schema:k},selectedEntities:(e==null?void 0:e.selectedEntities)||[]})};return f.jsxs(f.Fragment,{children:[(i||l||h||g)&&f.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 p-3",children:[f.jsx("div",{className:"flex items-center",children:f.jsxs("div",{className:"text-sm text-red-800",children:[f.jsx("strong",{children:"Error loading data:"}),f.jsxs("ul",{className:"mt-1 list-inside list-disc",children:[i&&f.jsxs("li",{children:["Connections: ",i]}),l&&f.jsxs("li",{children:[c,": ",l.message]}),h&&f.jsxs("li",{children:[p,": ",h.message]}),g&&f.jsxs("li",{children:["Data Models: ",g.message]})]})]})}),f.jsx(Ee,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>window.location.reload(),children:"Retry"})]}),f.jsxs("div",{className:"space-y-4",children:[b&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium",children:c}),f.jsxs(Pt,{value:((_=e==null?void 0:e.dbSelection)==null?void 0:_.database)||"",onValueChange:x,disabled:a,children:[f.jsx(Ct,{className:"w-full",children:f.jsxs("div",{className:"flex items-center gap-2",children:[a&&f.jsx(ub,{className:"h-4 w-4 animate-spin"}),f.jsx(Dt,{placeholder:l?`Error loading ${y}`:a?`Loading ${y}...`:`Select ${y}...`})]})}),f.jsx(St,{children:s.map(k=>f.jsx(ye,{className:"hover:bg-muted",value:k.id,children:k.name},k.id))})]})]}),((E=e==null?void 0:e.dbSelection)==null?void 0:E.database)&&m&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium",children:p}),f.jsxs(Pt,{value:((C=e==null?void 0:e.dbSelection)==null?void 0:C.schema)||"",onValueChange:S,disabled:d,children:[f.jsx(Ct,{className:"w-full",children:f.jsxs("div",{className:"flex items-center gap-2",children:[d&&f.jsx(ub,{className:"h-4 w-4 animate-spin"}),f.jsx(Dt,{placeholder:h?`Error loading ${v}`:d?`Loading ${v}...`:`Select ${v}...`})]})}),f.jsx(St,{children:u.map(k=>f.jsx(ye,{className:"hover:bg-muted",value:k.id,children:k.name},k.id))})]})]})]})]})}function xFe(){const e=Ce(l=>l.card.dataSource),t=Ce(l=>l.actions.updateDataSource),[n,r]=R.useState(!1),o=l=>{if(!l||(e==null?void 0:e.mode)!=="upload")return;const c=Array.from(l).map(d=>({id:`file-${Date.now()}-${Math.random()}`,name:d.name,type:"upload",connectionId:"default",connectionType:"none",label:d.name,description:`Uploaded ${new Date().toLocaleString()}`,originalName:d.name,file:d})),u=(e==null?void 0:e.selectedEntities)||[];t({...e,selectedEntities:[...u,...c]})},i=l=>{if(!e)return;const c=(e.selectedEntities||[]).filter(u=>u.id!==l);t({...e,selectedEntities:c})},s=l=>{if(l===0)return"0 Bytes";const c=1024,u=["Bytes","KB","MB","GB"],d=Math.floor(Math.log(l)/Math.log(c));return Number.parseFloat((l/Math.pow(c,d)).toFixed(2))+" "+u[d]},a=(e==null?void 0:e.selectedEntities)||[];return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium",children:"Upload Files"}),f.jsxs("div",{className:`rounded-lg border-2 border-dashed p-6 text-center transition-colors ${n?"border-blue-400 bg-blue-50":"border-gray-300 hover:border-gray-400"}`,onDragOver:l=>{l.preventDefault(),r(!0)},onDragLeave:()=>r(!1),onDrop:l=>{l.preventDefault(),r(!1),o(l.dataTransfer.files)},children:[f.jsx(g2,{className:"mx-auto mb-2 h-8 w-8 text-gray-400"}),f.jsx("p",{className:"mb-2 text-sm text-gray-600",children:"Drag and drop files here, or click to select"}),f.jsx("input",{type:"file",multiple:!0,className:"hidden",id:"file-upload",onChange:l=>o(l.target.files),accept:".csv,.json,.xlsx,.xls"}),f.jsx(Ee,{variant:"outline",size:"sm",onClick:()=>{var l;return(l=document.getElementById("file-upload"))==null?void 0:l.click()},children:"Select Files"}),f.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"Supports CSV, JSON, Excel files"})]})]}),a.length>0&&f.jsxs("div",{className:"space-y-2",children:[f.jsxs(de,{className:"text-xs text-gray-600",children:["Uploaded Files (",a.length,")"]}),f.jsx("div",{className:"max-h-40 space-y-1 overflow-y-auto",children:a.map(l=>f.jsxs("div",{className:"flex items-center justify-between rounded border bg-gray-50 p-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx(u2,{className:"h-4 w-4 flex-shrink-0 text-gray-500"}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"truncate text-sm text-gray-700",children:l.originalName}),f.jsx("p",{className:"text-xs text-gray-500",children:l.file?s(l.file.size):""})]})]}),f.jsx(Ee,{variant:"ghost",size:"sm",className:"h-6 w-6 flex-shrink-0 p-0",onClick:()=>i(l.id),children:f.jsx(nr,{className:"h-3 w-3"})})]},l.id))})]})]})}function wFe(){const e=Ce(d=>d.card.dataSource),t=Ce(d=>d.actions.updateDataSource),[n,r]=R.useState(""),[o,i]=R.useState(""),[s,a]=R.useState("api"),l=()=>{if(!n.trim()||!o.trim()||!e)return;const d={id:`url-${Date.now()}-${Math.random()}`,name:n.trim(),type:"url",connectionId:"default",connectionType:"none",label:n.trim(),description:`URL source of type ${s}`,url:o.trim(),sourceType:s,originalName:n.trim()},h=(e==null?void 0:e.selectedEntities)||[];t({...e,selectedEntities:[...h,d]}),r(""),i(""),a("api")},c=d=>{if(!e)return;const h=(e.selectedEntities||[]).filter(p=>p.id!==d);t({...e,selectedEntities:h})},u=(e==null?void 0:e.selectedEntities)||[];return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium text-gray-700",children:"URL Sources"}),f.jsxs("div",{className:"space-y-3 rounded-lg border bg-gray-50 p-3",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-xs text-gray-600",children:"Source Name"}),f.jsx(yr,{placeholder:"e.g., Sales API, Customer Data",value:n,onChange:d=>r(d.target.value),className:"h-8 text-sm"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-xs text-gray-600",children:"URL"}),f.jsx(yr,{placeholder:"https://api.example.com/data",value:o,onChange:d=>i(d.target.value),className:"h-8 text-sm"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-xs text-gray-600",children:"Type"}),f.jsxs("select",{value:s,onChange:d=>a(d.target.value),className:"h-8 w-full rounded-md border border-gray-300 px-2 text-sm",children:[f.jsx("option",{value:"api",children:"API Endpoint"}),f.jsx("option",{value:"csv",children:"CSV File"}),f.jsx("option",{value:"json",children:"JSON File"})]})]}),f.jsxs(Ee,{onClick:l,disabled:!n.trim()||!o.trim(),size:"sm",className:"w-full",children:[f.jsx(uc,{className:"mr-1 h-3 w-3"}),"Add Source"]})]})]}),u.length>0&&f.jsxs("div",{className:"space-y-2",children:[f.jsxs(de,{className:"text-xs text-gray-600",children:["Added Sources (",u.length,")"]}),f.jsx("div",{className:"max-h-40 space-y-1 overflow-y-auto",children:u.map(d=>f.jsxs("div",{className:"flex items-center justify-between rounded border bg-gray-50 p-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx(d2,{className:"h-4 w-4 flex-shrink-0 text-gray-500"}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"truncate text-sm text-gray-700",children:d.name}),f.jsx("p",{className:"truncate text-xs text-gray-500",children:d.url})]})]}),f.jsx(Ee,{variant:"ghost",size:"sm",className:"h-6 w-6 flex-shrink-0 p-0",onClick:()=>c(d.id),children:f.jsx(nr,{className:"h-3 w-3"})})]},d.id))})]})]})}function hj(e,t){var y,v;const n=re(x=>x.authToken)||t,{connections:r}=Li(t),o=Ce(x=>{var S,_;return(_=(S=x==null?void 0:x.card)==null?void 0:S.dataSource)==null?void 0:_.connectionId}),i=Ce(x=>{var S,_,E;return(E=(_=(S=x==null?void 0:x.card)==null?void 0:S.dataSource)==null?void 0:_.dbSelection)==null?void 0:E.database}),s=Ce(x=>{var S,_,E;return(E=(_=(S=x==null?void 0:x.card)==null?void 0:S.dataSource)==null?void 0:_.dbSelection)==null?void 0:E.schema}),a=r==null?void 0:r.find(x=>x.id===o),l=a==null?void 0:a.capabilities,c=((y=l==null?void 0:l.labels)==null?void 0:y.schema)||"Schema";function u(){return o?(a==null?void 0:a.type)==="API"||(a==null?void 0:a.type)==="S3"?!0:!(!i||l!=null&&l.path.includes("schema")&&!s||e==="view"):!1}const{data:d,isPending:h,isLoading:p,error:g,refetch:m}=Tn({queryKey:[e,o,i,s],queryFn:()=>br(`https://semaphor.cloud/api/v1/${e}s`,(n==null?void 0:n.accessToken)||"",{connection_id:o,database_name:i,schema_name:s}),enabled:u()}),b=(v=d==null?void 0:d[`${e}s`])==null?void 0:v.map(x=>({connectionId:a==null?void 0:a.id,connectionType:a==null?void 0:a.type,dialect:a==null?void 0:a.dialect,type:e,id:x[`${e}_name`],database:i,schema:s,name:x[`${e}_name`]}));return{isPending:h,isLoading:p,error:g,entities:b||[],refetch:m,label:c}}function v0({title:e,message:t}){return f.jsx("div",{className:"rounded-xl border border-destructive/40 bg-destructive/10 p-4 text-destructive shadow-sm",children:f.jsxs("div",{className:"flex items-start gap-4",children:[f.jsx(X5,{className:"h-6 w-6 flex-shrink-0"}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h4",{className:"text-base font-semibold",children:e}),t&&f.jsx("p",{className:"mt-1 text-sm text-destructive/90",children:t})]})]})})}function CFe({dataSource:e,onSelectionChange:t,selectedEntities:n}){const{connections:r,isPending:o}=Li(),[i,s]=R.useState(""),[a,l]=R.useState(""),[c,u]=R.useState(""),{updateDataSource:d,setSelectedConnectionId:h}=Zo(),{entities:p,isLoading:g,error:m}=hj("table"),{entities:b}=hj("view"),{dataModels:y,isPending:v,error:x}=pU(),S=N=>{const M=r.find(D=>D.id===N);if(!M)return;const I=M.type==="upload"?"upload":M.type==="url"?"url":"database";d({...e,connectionId:N,connectionType:M.type,mode:I,dbSelection:{database:"",schema:"",entityType:"table"}}),h(N)},_=N=>{var j,F;const M=n||[],I=M.some(T=>T.name===N.name&&T.type===N.type);let D;if(I)D=M.filter(T=>!(T.name===N.name&&T.type===N.type));else{const T={connectionId:e.connectionId,connectionType:e.connectionType,type:N.type,database:((j=e.dbSelection)==null?void 0:j.database)||"",schema:((F=e.dbSelection)==null?void 0:F.schema)||"",name:N.name,dialect:N.dialect};D=[...M,T]}t==null||t(D)},E=N=>{const M=n||[],I=M.some(j=>j.type==="model"&&j.name===N.name);let D;I?D=M.filter(j=>!(j.type==="model"&&j.name===N.name)):D=[...M,N],t==null||t(D)},C=p.filter(N=>N.name.toLowerCase().includes(i.toLowerCase()));b.filter(N=>N.name.toLowerCase().includes(a.toLowerCase()));const k=y.filter(N=>N.name.toLowerCase().includes(c.toLowerCase()));return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"font-medium= text-sm",children:"Connection"}),f.jsxs(Pt,{value:(e==null?void 0:e.connectionId)||"",onValueChange:S,disabled:o,children:[f.jsx(Ct,{className:"w-full",children:f.jsx(Dt,{placeholder:o?"Loading connections...":"Select connection..."})}),f.jsx(St,{children:r.map(N=>f.jsx(ye,{className:"hover:bg-muted",value:N.id,children:f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx(q0,{className:"h-4 w-4 flex-shrink-0"}),f.jsx("span",{className:"truncate",children:N.name}),f.jsx(eo,{variant:"secondary",className:"flex-shrink-0 text-xs",children:N.type})]})},N.id))})]})]}),(e==null?void 0:e.connectionId)&&f.jsxs(f.Fragment,{children:[e.connectionType==="upload"&&f.jsx(xFe,{}),e.connectionType==="url"&&f.jsx(wFe,{}),e.connectionType!=="upload"&&e.connectionType!=="url"&&f.jsxs(f.Fragment,{children:[f.jsx(vFe,{}),f.jsx("div",{className:"space-y-4",children:f.jsx("div",{className:"space-y-2",children:f.jsxs(ad,{defaultValue:"tables",className:"w-full",children:[f.jsxs(ac,{className:"grid w-full grid-cols-3",children:[f.jsx(Jr,{value:"tables",children:"Tables"}),f.jsx(Jr,{value:"datamodels",children:"Data Models"}),f.jsx(Jr,{value:"views",children:"Views (Coming soon)"})]}),f.jsxs(mi,{value:"tables",className:"space-y-2",children:[f.jsx(zn,{placeholder:"Search tables...",value:i,onChange:N=>s(N.target.value),className:"h-8 text-sm",disabled:g}),f.jsx("div",{className:"max-h-40 space-y-1 overflow-y-auto",children:g?f.jsx("div",{className:"py-4 text-center text-sm",children:"Loading tables..."}):m?f.jsx(v0,{title:"Error loading tables",message:m.message||"Failed to load tables. Please try again.",onRetry:()=>window.location.reload()}):C.length===0?f.jsx("div",{className:"py-4 text-center text-sm",children:"No tables found"}):C.map(N=>{const M=n.some(I=>I.name===N.name&&I.type==="table");return f.jsxs("div",{className:"flex items-center space-x-2 rounded p-2 hover:bg-muted",children:[f.jsx(zr,{id:`table-${N.name}`,checked:M,onCheckedChange:()=>_(N),disabled:g}),f.jsx(de,{htmlFor:`table-${N.name}`,children:N.name})]},N.name)})})]}),f.jsxs(mi,{value:"datamodels",className:"space-y-2",children:[f.jsx(zn,{placeholder:"Search data models...",value:c,onChange:N=>u(N.target.value),className:"h-8 text-sm",disabled:v}),f.jsx("div",{className:"max-h-40 space-y-1 overflow-y-auto",children:v?f.jsx("div",{className:"py-4 text-center text-sm",children:"Loading data models..."}):x?f.jsx(v0,{title:"Error loading data models",message:x.message||"Failed to load data models. Please try again.",onRetry:()=>window.location.reload()}):k.length===0?f.jsx("div",{className:"py-4 text-center text-sm",children:"No data models found"}):k.map(N=>{const M=n.some(I=>I.name===N.name&&I.type==="model");return f.jsxs("div",{className:"ounded flex items-start space-x-2 p-2 hover:bg-muted",children:[f.jsx(zr,{id:`dataModel-${N.name}`,checked:M,onCheckedChange:()=>E(N),disabled:v}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx(de,{htmlFor:`dataModel-${N.name}`,children:N.name}),f.jsx("span",{className:"text-xs text-muted-foreground",children:N.description})]})]},N.name)})})]}),f.jsx(mi,{value:"views",className:"space-y-2",children:f.jsx("div",{className:"py-4 text-center text-sm",children:"Views support coming soon"})})]})})})]})]})]})}function SFe({dataSource:e,onDataSourceUpdate:t,onSelectionChange:n,selectedEntities:r}){var m;const[o,i]=R.useState(""),{semanticDomains:s,isPending:a,error:l}=hU(),{datasets:c,isPending:u,error:d}=gFe(e==null?void 0:e.semanticDomainId),h=b=>{const y={...e,connectionId:e.connectionId||"none",connectionType:e.connectionType||"none",mode:"semanticDomain",semanticDomainId:b};t({...y})},p=b=>{const y=r||[],v=y.some(S=>S.id===b.id&&S.type==="dataset");let x;if(v)x=y.filter(S=>!(S.id===b.id&&S.type==="dataset"));else{const S={id:b.id,name:b.name||b.table,label:b.label,domainId:b.domainId,description:b.description,database:b.database,schema:b.schema,type:"dataset",connectionId:b.connectionId,connectionType:b.connectionType};x=[...y,S]}n==null||n(x)},g=c.filter(b=>b.name.toLowerCase().includes(o.toLowerCase()));return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium",children:"Semantic Domain"}),f.jsxs(Pt,{value:(e==null?void 0:e.semanticDomainId)||"",onValueChange:h,disabled:a,children:[f.jsx(Ct,{className:"w-full",children:f.jsx(Dt,{placeholder:a?"Loading semantic domains...":"Select semantic domain...",children:((m=s.find(b=>b.id===(e==null?void 0:e.semanticDomainId)))==null?void 0:m.label)||"Select semantic domain"})}),f.jsx(St,{children:s.map(b=>f.jsx(ye,{className:"hover:bg-muted",value:b.id,children:f.jsxs("div",{className:"flex flex-col items-start",children:[f.jsx("span",{className:"font-medium",children:b.label}),f.jsx("span",{className:"text-xs",children:b.description})]})},b.id))})]}),l&&f.jsx(v0,{title:"Error loading semantic models",message:l.message})]}),(e==null?void 0:e.semanticDomainId)&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium text-gray-700",children:"Datasets"}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(zn,{placeholder:"Search datasets...",value:o,onChange:b=>i(b.target.value),className:"h-8 text-sm",disabled:u}),f.jsx("div",{className:"max-h-40 space-y-1 overflow-y-auto",children:u?f.jsx("div",{className:"py-4 text-center text-sm text-gray-500",children:"Loading datasets..."}):d?f.jsx(v0,{title:"Error loading datasets",message:d.message||"Failed to load datasets. Please try again.",onRetry:()=>window.location.reload()}):g.length===0?f.jsx("div",{className:"py-4 text-center text-sm text-gray-500",children:o?"No datasets match your search":"No datasets available"}):g.map(b=>{const y=r.some(v=>v.id===b.id&&v.type==="dataset");return f.jsxs("div",{className:"flex items-start space-x-2 rounded p-2 hover:bg-gray-50",children:[f.jsx(zr,{id:`dataset-${b.id}`,checked:y,onCheckedChange:()=>p(b),disabled:u}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx(de,{htmlFor:`dataset-${b.id}`,className:"font-medium",children:b.label||b.name}),f.jsx("span",{className:"text-xs text-gray-500",children:b.description})]})]},b.label||b.name)})})]})]})]})}function mU({open:e,onOpenChange:t,dataSource:n,fallbackDataSource:r,dialogMode:o,incomingSelectedEntities:i}){const[s,a]=R.useState([]),{updateDataSource:l}=Zo(),c=re(x=>x.isVisualEditing),u=re(x=>x.dashboard.aiContext),{setAiContext:d}=on(),{semanticDomains:h}=hU();R.useEffect(()=>{e&&a(i||[])},[e,n==null?void 0:n.selectedEntities,o,l,i,n]);const p=x=>{const S=s.filter(_=>!(_.name===x.name&&_.type===x.type));a(S)},g=()=>{a([]),o==="aiContext"&&(d({...u,selectedEntities:[]}),t(!1)),o==="dataSource"&&(l({...r,...n,selectedEntities:[]}),t(!1))},m=R.useCallback(x=>{l({...n,connectionId:(n==null?void 0:n.connectionId)||"",connectionType:(n==null?void 0:n.connectionType)||"",mode:x,selectedEntities:(n==null?void 0:n.selectedEntities)||[]})},[n,l]),b=R.useCallback(x=>{l({...n,...x})},[n,l]),y=R.useCallback(x=>{a(x)},[]);function v(){var x,S;if(o==="aiContext"){const{selectedEntities:_,...E}=n;c&&l(n),d({...u,selectedEntities:s}),t(!1)}else if(o==="dataSource"){if(n.mode==="semanticDomain"){const _=(x=s==null?void 0:s[0])==null?void 0:x.connectionId,E=(S=s==null?void 0:s[0])==null?void 0:S.connectionType;l({...n,connectionId:_,connectionType:E,selectedEntities:s})}else l({...n,selectedEntities:s});t(!1)}}return h&&h.length>0,f.jsx(ey,{open:e,onOpenChange:t,children:f.jsx(ip,{className:"flex max-w-2xl flex-col",children:f.jsxs("div",{children:[f.jsxs(sp,{className:"flex-shrink-0",children:[f.jsx(lp,{children:o==="aiContext"?"AI Context":"Select Data Source"}),f.jsx(cp,{children:o==="aiContext"?"Set the overall data scope for the Assistant":"Select data sets to analyze"})]}),f.jsx("div",{className:"flex-1 grow overflow-y-auto py-4",children:f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"space-y-2",children:f.jsx(ad,{defaultValue:(n==null?void 0:n.mode)||"database",value:(n==null?void 0:n.mode)||"database",onValueChange:m,className:"w-full",children:f.jsxs(ac,{className:"grid w-full grid-cols-2",children:[f.jsx(Jr,{value:"database",children:"Direct Source"}),f.jsx(Jr,{value:"semanticDomain",children:"Semantic Domain"})]})})}),(n==null?void 0:n.mode)==="semanticDomain"&&f.jsx(SFe,{dataSource:n,onDataSourceUpdate:b,selectedEntities:s,onSelectionChange:y}),(n==null?void 0:n.mode)==="database"&&f.jsx(CFe,{dataSource:n,onDataSourceUpdate:b,selectedEntities:s,onSelectionChange:y})]})}),f.jsx(mFe,{selectedEntities:s,onDeselectEntity:p}),f.jsx(ap,{className:"flex-shrink-0",children:f.jsx("div",{className:"flex w-full justify-between",children:f.jsxs("div",{className:"flex grow justify-end gap-2",children:[f.jsx(Ee,{variant:"outline",onClick:g,disabled:s.length===0,children:"Clear All"}),f.jsx(Ee,{variant:"outline",onClick:()=>t(!1),children:"Close"}),f.jsx(Ee,{onClick:v,disabled:s.length===0,children:"Save"})]})})})]})})})}const sE={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]},EFe=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function _Fe({open:e,setOpen:t}){const[n,r]=R.useState(!1),[o,i]=R.useState(Yg),[s,a]=R.useState(!1),[l,c]=R.useState(!1),u=R.useRef(null),d=R.useRef(null);re(V=>V.dashboard.aiScopeTables);const h=re(V=>V.isDashboardEditing),{setDataSource:p}=Zo(),g=oR(),{setCurrentAIContext:m,updateSelectedEntities:b}=iR(),y=re(V=>V.dashboard.aiContext),v=Ce(V=>V.card.dataSource),{assistantProfile:x}=lU(),S=re(V=>V.handleOpenAssistantProfile),{append:_,handleAddNewFrame:E,isLoading:C,handleSubmit:k,handleInputChange:N,input:M,setInput:I,messages:D,setMessages:j,reload:F,status:T,stop:O,errorMessage:$}=aFe(g);aU({scrollContainerRef:d,inputRef:u,messages:D}),R.useEffect(()=>{var V;e&&((V=u.current)==null||V.focus())},[e]);function B(V){W();const G={role:"user",content:V.title+" "+V.subtitle};_(G)}function z(V){W(),_({role:"user",content:V})}function A(){var q;const V=(q=y==null?void 0:y.selectedEntities)==null?void 0:q[0],G={connectionId:(V==null?void 0:V.connectionId)||"",connectionType:(V==null?void 0:V.connectionType)||"",mode:(V==null?void 0:V.type)==="dataset"?"semanticDomain":"database",dbSelection:{database:(V==null?void 0:V.database)||"",schema:(V==null?void 0:V.schema)||"",entityType:(V==null?void 0:V.type)||"table"},selectedEntities:(y==null?void 0:y.selectedEntities)||[]};p(G),c(!0)}function W(){g.selectedEntities.length===0&&m({selectedEntities:(y==null?void 0:y.selectedEntities)||[]})}const L=(M==null?void 0:M.length)===0&&(D==null?void 0:D.filter(V=>V.role==="user").length)===0;function P(){return f.jsx("div",{"data-role":"header",children:f.jsx("div",{className:"text-lg font-semibold",children:"Assistant"})})}function H(){return f.jsxs(Hy,{children:[f.jsx(Wy,{asChild:!0,children:f.jsx(Zc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:f.jsx(J5,{className:"size-3.5"})})}),f.jsxs(Ip,{align:"end",children:[f.jsx(Z_,{children:"Options"}),f.jsx(Uy,{}),f.jsx(Of,{checked:n,onCheckedChange:r,children:"Token Usage"}),f.jsx(Of,{checked:o,onCheckedChange:i,children:"Tool Invocations"}),f.jsx(Of,{checked:s,onCheckedChange:a,children:"System Message"})]})]})}return f.jsxs("div",{"data-role":"dashboard-assistant",className:"flex h-full grow flex-col justify-between break-words px-6 py-4",children:[f.jsxs("div",{"data-role":"header-section",className:"flex items-start justify-between gap-2",children:[P(),S&&f.jsx(Ee,{variant:"outline",size:"sm",className:"h-7 p-2",onClick:S,children:(x==null?void 0:x.name)||"Default Profile"}),f.jsxs("div",{"data-role":"header-actions",className:"flex items-center gap-2",children:[H(),(h||Yg)&&f.jsx(Zc,{tooltip:"Add Context",className:"h-7 p-2 text-muted-foreground hover:text-foreground",onClick:A,children:f.jsx(aa,{className:"size-4"})}),f.jsx(Zc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",tooltip:"New Chat",onClick:()=>{j([]),F()},children:f.jsx(lF,{className:"size-4"})}),f.jsx(Zc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",onClick:()=>{t(!1)},children:f.jsx(c2,{className:"size-4"})})]})]}),f.jsxs(Tp,{"data-role":"dashboard-assistant-scroll-area",ref:d,className:"mt-4 flex flex-1 basis-0 flex-col flex-wrap justify-end pr-2",children:[f.jsxs("div",{className:"space-y-3 pb-4",children:[f.jsx(DW,{showTools:o,showSystemMessage:s,messages:D,onAddToDashboard:E}),f.jsx(PW,{messages:D,chatStatus:T,errorMessage:$})]}),f.jsx(wd,{orientation:"horizontal"})]}),f.jsxs("div",{className:"space-y-3",children:[!x&&L&&f.jsx(IW,{onClick:B,placeholders:EFe}),f.jsx("div",{children:L&&x&&f.jsx(cU,{seedQuestions:x.seedQuestions||[],handleSeedQuestionClick:z})}),f.jsx(dU,{ref:u,setInput:I,stop:O,input:M,handleInputChange:N,handleSubmit:V=>{W(),k(V)},isLoading:C,onFocus:()=>{}})]}),f.jsx(mU,{incomingSelectedEntities:(y==null?void 0:y.selectedEntities)||[],open:l,onOpenChange:c,dataSource:v||sE,fallbackDataSource:sE,dialogMode:"aiContext"})]})}var RFe=e=>{switch(e){case"success":return MFe;case"info":return DFe;case"warning":return PFe;case"error":return IFe;default:return null}},kFe=Array(12).fill(0),NFe=({visible:e,className:t})=>R.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},R.createElement("div",{className:"sonner-spinner"},kFe.map((n,r)=>R.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),MFe=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),PFe=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),DFe=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),IFe=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),AFe=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},R.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),R.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),TFe=()=>{let[e,t]=R.useState(document.hidden);return R.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},aE=1,jFe=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:aE++,i=this.toasts.find(a=>a.id===o),s=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),i?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:s,title:n}):a):this.addToast({title:n,...r,dismissible:s,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,i,s=r.then(async l=>{if(i=["resolve",l],R.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(FFe(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,u=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:u})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,u=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:u})}}).catch(async l=>{if(i=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,u=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:u})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>s.then(()=>i[0]==="reject"?c(i[1]):l(i[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||aE++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ar=new jFe,OFe=(e,t)=>{let n=(t==null?void 0:t.id)||aE++;return Ar.addToast({title:e,...t,id:n}),n},FFe=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",LFe=OFe,$Fe=()=>Ar.toasts,zFe=()=>Ar.getActiveToasts(),gU=Object.assign(LFe,{success:Ar.success,info:Ar.info,warning:Ar.warning,error:Ar.error,custom:Ar.custom,message:Ar.message,promise:Ar.promise,dismiss:Ar.dismiss,loading:Ar.loading},{getHistory:$Fe,getToasts:zFe});function BFe(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}BFe(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
627
+ `})]})});uU.displayName="HighlightedInput";function hFe({availableEntities:e,localAiContext:t,setLocalAiContext:n}){const[r,o]=R.useState(""),[i,s]=R.useState(!1),[a,l]=R.useState(0),c=R.useRef(null),u=D=>"label"in D?D.label:D.name,d=D=>t.selectedEntities.some(j=>"id"in D&&"id"in j?D.id===j.id:D.name===j.name&&D.connectionId===j.connectionId),h=D=>{if(!D)return;D.focus();const j=window.getSelection();if(j){const F=document.createRange();F.selectNodeContents(D),F.collapse(!1),j.removeAllRanges(),j.addRange(F)}},p=D=>{const j=D.target.value,F=D.target.selectionStart||0;o(j),l(F);const T=j.slice(0,F),O=T.lastIndexOf("@");if(O!==-1){const $=T.slice(O+1),B=(O===0||/\s/.test(T[O-1]))&&!$.includes(" ");s(B)}else s(!1)},g=D=>{D.key==="Escape"&&i&&(D.preventDefault(),s(!1),setTimeout(()=>{if(D.currentTarget){D.currentTarget.focus();const j=window.getSelection();if(j){const F=document.createRange();F.selectNodeContents(D.currentTarget),F.collapse(!1),j.removeAllRanges(),j.addRange(F)}}},0))},m=D=>{const j=u(D),T=r.slice(0,a).lastIndexOf("@");if(T!==-1){const O=r.slice(0,T),$=r.slice(a),B=O+"@"+j+" "+$;o(B);const z=T+j.length+2;l(z)}},b=D=>{const F=`@${u(D)}`,T=r.indexOf(F);if(T!==-1){const O=r.slice(0,T),$=r.slice(T+F.length),B=O+($.startsWith(" ")?$.slice(1):$);o(B),l(T)}},y=D=>{const j=[...t.selectedEntities,D];n({selectedEntities:j})},v=D=>{const j=t.selectedEntities.filter(F=>"id"in D&&"id"in F?D.id!==F.id:!(D.name===F.name&&D.connectionId===F.connectionId));n({selectedEntities:j})},x=D=>{d(D)?(v(D),b(D)):(y(D),m(D))},S=D=>{x(D)},_=D=>{d(D)||y(D),m(D),s(!1),setTimeout(()=>h(c.current),0)},E=D=>{v(D),b(D)},C=D=>{D.forEach(j=>{v(j),b(j)})},k=()=>{n({selectedEntities:[...e]}),e.forEach((D,j)=>{u(D)})},N=()=>{n({selectedEntities:[]});let D=r;t.selectedEntities.forEach(j=>{const T=`@${u(j)}`;D=D.replace(new RegExp(`${T}\\s?`,"g"),"")}),o(D),l(D.length)},M=R.useCallback(()=>{s(!1),setTimeout(()=>h(c.current),0)},[c]);return R.useEffect(()=>{const D=F=>{const T=F.target;!T.closest('[data-dropdown="entity-mention"]')&&!T.closest(".entity-dropdown-container")&&i&&M()},j=F=>{F.key==="Escape"&&i&&M()};return i&&(document.addEventListener("mousedown",D),document.addEventListener("keydown",j)),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",j)}},[i,M]),{message:r,setMessage:o,showMentionDropdown:i,setShowMentionDropdown:s,cursorPosition:a,mainInputRef:c,handleTextareaChange:p,handleKeyDown:g,handleEntitySelect:x,handleEntityDeselect:S,handleMainTabComplete:_,handleRemoveEntity:E,handleAddAllEntities:k,handleRemoveEntities:C,handleRemoveAllEntities:N,closeDropdownAndFocus:M,handleMainAtButtonClick:()=>{s(!0),setTimeout(()=>h(c.current),0)},focusInputElement:h}}const dU=R.forwardRef(({input:e,setInput:t,handleSubmit:n,isLoading:r,stop:o,onFocus:i},s)=>{const a=oR(),{setCurrentAIContext:l}=iR(),c=re(I=>{var D;return(D=I.dashboard.aiContext)==null?void 0:D.selectedEntities}),{message:u,setMessage:d,showMentionDropdown:h,setShowMentionDropdown:p,mainInputRef:g,handleTextareaChange:m,handleKeyDown:b,handleEntitySelect:y,handleEntityDeselect:v,handleMainTabComplete:x,handleRemoveEntity:S,handleRemoveEntities:_,handleAddAllEntities:E,handleRemoveAllEntities:C,handleMainAtButtonClick:k,focusInputElement:N}=hFe({availableEntities:c||[],localAiContext:a,setLocalAiContext:l});R.useEffect(()=>{d(e)},[e,d]),R.useEffect(()=>{t(u)},[u,t]);const M=I=>{u.trim()&&(n({preventDefault:()=>{}}),d(""))};return f.jsxs("div",{className:"space-y-4",children:[f.jsx(dFe,{entities:a.selectedEntities,availableEntities:c||[],onRemoveEntity:S,onRemoveEntities:_}),f.jsxs("div",{className:"relative",children:[f.jsx(uU,{value:u,onChange:m,onKeyDown:I=>{b(I),I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),M())},onFocus:I=>{i==null||i(),u.includes("@")&&p(!0)},placeholder:"What question do you have?",className:"pr-12placeholder-gray-400 min-h-[100px] resize-none border-foreground/20",isTextarea:!0,availableEntities:c||[],"data-input":"main",ref:g}),f.jsx(Ee,{variant:"outline",size:"sm",className:"absolute bottom-3 left-3 h-7 px-2",onClick:k,title:"Add entity",children:f.jsx($Z,{className:"h-4 w-4 text-muted-foreground"})}),f.jsxs("div",{className:"absolute bottom-3 right-3 flex items-center gap-2",children:[r===!0&&f.jsx(Ee,{size:"sm",onClick:()=>o(),children:f.jsx(KZ,{className:"size-3.5 bg-background"})}),r===!1&&f.jsx(Ee,{disabled:r===!1&&!e,size:"sm",onClick:()=>M(),children:f.jsx(tJ,{className:"size-4"})})]}),h&&f.jsx("div",{className:"entity-dropdown-container absolute left-0 z-50","data-dropdown":"entity-mention",style:{bottom:"100%",marginBottom:"0.5rem",width:"20rem",maxWidth:"100%"},ref:I=>{I&&I.getBoundingClientRect().top<10&&(I.style.bottom="auto",I.style.top="100%",I.style.marginBottom="0",I.style.marginTop="0.5rem")},children:f.jsx(cFe,{isOpen:h,onSelect:y,onDeselect:v,onClose:()=>{p(!1),setTimeout(()=>N(g.current),0)},availableEntities:c||[],selectedEntities:a.selectedEntities,onTabComplete:x,onSelectAll:E,onRemoveAll:C})})]})]})});function fU(e){return e.type==="dataset"&&e.label||e.name}function pFe(e){const t=[];return t.push({label:"Type",value:e.type}),t.push({label:"Name",value:e.name}),e.connectionType&&t.push({label:"Connection",value:e.connectionType}),e.database&&t.push({label:"Database",value:e.database}),e.schema&&t.push({label:"Schema",value:e.schema}),e.type==="dataset"&&e.label&&t.push({label:"Label",value:e.label}),e.type==="dataset"&&e.description&&t.push({label:"Description",value:e.description}),e.type==="model"&&e.label&&t.push({label:"Label",value:e.label}),e.type==="model"&&e.description&&t.push({label:"Description",value:e.description}),t}function mFe({selectedEntities:e,onDeselectEntity:t}){return e.length===0?null:f.jsxs("div",{className:"mb-4 space-y-2",children:[f.jsxs(de,{className:"mb-2 text-xs font-medium text-muted-foreground",children:["Selected Entities (",e.length,")"]}),f.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((n,r)=>f.jsxs(eo,{variant:"secondary",className:"group relative cursor-pointer pr-6 text-xs transition-colors hover:border-red-200 hover:bg-red-50 dark:hover:border-red-800 dark:hover:bg-red-950",children:[f.jsxs("span",{className:"mr-1 text-gray-500",children:["[",n.type,"]"]}),fU(n),f.jsx("button",{onClick:o=>{o.stopPropagation(),t(n)},className:"absolute right-1 top-1/2 -translate-y-1/2 rounded-full p-0.5 opacity-0 transition-opacity hover:bg-red-100 group-hover:opacity-100",children:f.jsx(nr,{className:"h-2.5 w-2.5 text-red-500"})})]},`${n.type}-${n.name}-${r}`))})]})}function hU(e){const t=re(a=>a.authToken)||e;Ce(a=>a.selectedConnectionId),Ce(a=>{var l,c;return(c=(l=a==null?void 0:a.card)==null?void 0:l.dataSource)==null?void 0:c.connectionId});const{refetch:n,isPending:r,data:o,isLoading:i,isError:s}=Tn({queryKey:["semantic-domains"],queryFn:()=>br("https://semaphor.cloud/api/v1/domains",(t==null?void 0:t.accessToken)||""),enabled:!!(t!=null&&t.accessToken)});return{isPending:r,error:s,semanticDomainsData:o,semanticDomains:(o==null?void 0:o.domains)||[],isSemanticDomainsLoading:i,isSemanticDomainsError:s,refetchSemanticDomains:n}}function gFe(e,t){const n=re(l=>l.authToken)||t,{refetch:r,isPending:o,data:i,isLoading:s,isError:a}=Tn({queryKey:["datasets",e],queryFn:()=>br("https://semaphor.cloud/api/v1/datasets",(n==null?void 0:n.accessToken)||"",{domainId:e}),enabled:!!(n!=null&&n.accessToken)&&!!e});return{isPending:o,error:a,datasets:(i==null?void 0:i.datasets)||[],isDatasetsLoading:s,isDatasetsError:a,refetchDatasets:r}}function bFe(e){var g,m;const t=re(b=>b.authToken)||e,{connections:n}=Li(e),r=Ce(b=>{var y,v;return(v=(y=b==null?void 0:b.card)==null?void 0:y.dataSource)==null?void 0:v.connectionId}),o=n==null?void 0:n.find(b=>b.id===r),i=o==null?void 0:o.type,s=o==null?void 0:o.capabilities,a=((g=s==null?void 0:s.labels)==null?void 0:g.database)||"Database";function l(b){return r&&b?!(b==="API"||b==="S3"):!1}const{data:c,isPending:u,error:d,refetch:h}=Tn({queryKey:["databases",r],queryFn:()=>br("https://semaphor.cloud/api/v1/databases",(t==null?void 0:t.accessToken)||"",{connection_id:r}),enabled:l(i)}),p=(m=c==null?void 0:c.databases)==null?void 0:m.map(b=>({id:b.database_name,name:b.database_name}));return{isPending:u,error:d,databases:p||[],refetch:h,label:a}}function yFe(e){var g;const t=re(m=>m.authToken)||e,{connections:n}=Li(e),r=Ce(m=>{var b,y;return(y=(b=m==null?void 0:m.card)==null?void 0:b.dataSource)==null?void 0:y.connectionId}),o=Ce(m=>{var b,y,v;return(v=(y=(b=m==null?void 0:m.card)==null?void 0:b.dataSource)==null?void 0:y.dbSelection)==null?void 0:v.database}),i=n==null?void 0:n.find(m=>m.id===r),s=i==null?void 0:i.capabilities,a=((g=s==null?void 0:s.labels)==null?void 0:g.schema)||"Schema";function l(){return!(!r||(i==null?void 0:i.type)==="API"||(i==null?void 0:i.type)==="S3"||!o||!(s!=null&&s.path.includes("schema")))}const{data:c,isPending:u,error:d,refetch:h}=Tn({queryKey:["schemas",r,o],queryFn:()=>br("https://semaphor.cloud/api/v1/schemas",(t==null?void 0:t.accessToken)||"",{connection_id:r,database_name:o}),enabled:l()}),p=c==null?void 0:c.schemas.map(m=>({id:m.schema_name,name:m.schema_name}));return{isPending:u,error:d,schemas:p||[],refetch:h,label:a}}function pU(e){const t=re(d=>d.authToken)||e,{connections:n}=Li(e),r=Ce(d=>{var h,p;return(p=(h=d==null?void 0:d.card)==null?void 0:h.dataSource)==null?void 0:p.connectionId}),o=n.find(d=>d.id===r);function i(){return!(!(t!=null&&t.accessToken)||!r)}const{data:s,isPending:a,error:l,refetch:c}=Tn({queryKey:["dataModels",r],queryFn:()=>br("https://semaphor.cloud/api/v1/datamodels",(t==null?void 0:t.accessToken)||"",{connection_id:r}),enabled:i()}),u=s==null?void 0:s.datamodels.map(d=>({id:d.id,name:d.name,label:d.label,description:d.description,connectionId:r,connectionType:o==null?void 0:o.type,dialect:o==null?void 0:o.dialect,type:"model",database:d.database,schema:d.schema}));return{isPending:a,error:l,dataModels:u||[],refetch:c}}function vFe(){var _,E,C;const e=Ce(k=>k.card.dataSource);Ce(k=>k.actions.updateDirectSource);const t=Ce(k=>k.actions.updateDataSource),[n,r]=R.useState(""),{selectedConnection:o,error:i}=Li(),{databases:s,isPending:a,error:l,label:c}=bFe(),{schemas:u,isPending:d,error:h,label:p}=yFe(),{error:g}=pU(),m=o==null?void 0:o.capabilities.path.includes("schema"),b=o==null?void 0:o.capabilities.path.includes("database"),y=c==null?void 0:c.toLowerCase(),v=p==null?void 0:p.toLowerCase(),x=k=>{e&&t({...e,dbSelection:{database:k,schema:"",entityType:"table"},selectedEntities:(e==null?void 0:e.selectedEntities)||[]})},S=k=>{var M;if(!((M=e==null?void 0:e.dbSelection)!=null&&M.database))return;const N=e.dbSelection||{database:"",schema:"",entityType:"table"};t({...e,dbSelection:{...N,schema:k},selectedEntities:(e==null?void 0:e.selectedEntities)||[]})};return f.jsxs(f.Fragment,{children:[(i||l||h||g)&&f.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 p-3",children:[f.jsx("div",{className:"flex items-center",children:f.jsxs("div",{className:"text-sm text-red-800",children:[f.jsx("strong",{children:"Error loading data:"}),f.jsxs("ul",{className:"mt-1 list-inside list-disc",children:[i&&f.jsxs("li",{children:["Connections: ",i]}),l&&f.jsxs("li",{children:[c,": ",l.message]}),h&&f.jsxs("li",{children:[p,": ",h.message]}),g&&f.jsxs("li",{children:["Data Models: ",g.message]})]})]})}),f.jsx(Ee,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>window.location.reload(),children:"Retry"})]}),f.jsxs("div",{className:"space-y-4",children:[b&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium",children:c}),f.jsxs(Pt,{value:((_=e==null?void 0:e.dbSelection)==null?void 0:_.database)||"",onValueChange:x,disabled:a,children:[f.jsx(Ct,{className:"w-full",children:f.jsxs("div",{className:"flex items-center gap-2",children:[a&&f.jsx(ub,{className:"h-4 w-4 animate-spin"}),f.jsx(Dt,{placeholder:l?`Error loading ${y}`:a?`Loading ${y}...`:`Select ${y}...`})]})}),f.jsx(St,{children:s.map(k=>f.jsx(ye,{className:"hover:bg-muted",value:k.id,children:k.name},k.id))})]})]}),((E=e==null?void 0:e.dbSelection)==null?void 0:E.database)&&m&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium",children:p}),f.jsxs(Pt,{value:((C=e==null?void 0:e.dbSelection)==null?void 0:C.schema)||"",onValueChange:S,disabled:d,children:[f.jsx(Ct,{className:"w-full",children:f.jsxs("div",{className:"flex items-center gap-2",children:[d&&f.jsx(ub,{className:"h-4 w-4 animate-spin"}),f.jsx(Dt,{placeholder:h?`Error loading ${v}`:d?`Loading ${v}...`:`Select ${v}...`})]})}),f.jsx(St,{children:u.map(k=>f.jsx(ye,{className:"hover:bg-muted",value:k.id,children:k.name},k.id))})]})]})]})]})}function xFe(){const e=Ce(l=>l.card.dataSource),t=Ce(l=>l.actions.updateDataSource),[n,r]=R.useState(!1),o=l=>{if(!l||(e==null?void 0:e.mode)!=="upload")return;const c=Array.from(l).map(d=>({id:`file-${Date.now()}-${Math.random()}`,name:d.name,type:"upload",connectionId:"default",connectionType:"none",label:d.name,description:`Uploaded ${new Date().toLocaleString()}`,originalName:d.name,file:d})),u=(e==null?void 0:e.selectedEntities)||[];t({...e,selectedEntities:[...u,...c]})},i=l=>{if(!e)return;const c=(e.selectedEntities||[]).filter(u=>u.id!==l);t({...e,selectedEntities:c})},s=l=>{if(l===0)return"0 Bytes";const c=1024,u=["Bytes","KB","MB","GB"],d=Math.floor(Math.log(l)/Math.log(c));return Number.parseFloat((l/Math.pow(c,d)).toFixed(2))+" "+u[d]},a=(e==null?void 0:e.selectedEntities)||[];return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium",children:"Upload Files"}),f.jsxs("div",{className:`rounded-lg border-2 border-dashed p-6 text-center transition-colors ${n?"border-blue-400 bg-blue-50":"border-gray-300 hover:border-gray-400"}`,onDragOver:l=>{l.preventDefault(),r(!0)},onDragLeave:()=>r(!1),onDrop:l=>{l.preventDefault(),r(!1),o(l.dataTransfer.files)},children:[f.jsx(g2,{className:"mx-auto mb-2 h-8 w-8 text-gray-400"}),f.jsx("p",{className:"mb-2 text-sm text-gray-600",children:"Drag and drop files here, or click to select"}),f.jsx("input",{type:"file",multiple:!0,className:"hidden",id:"file-upload",onChange:l=>o(l.target.files),accept:".csv,.json,.xlsx,.xls"}),f.jsx(Ee,{variant:"outline",size:"sm",onClick:()=>{var l;return(l=document.getElementById("file-upload"))==null?void 0:l.click()},children:"Select Files"}),f.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"Supports CSV, JSON, Excel files"})]})]}),a.length>0&&f.jsxs("div",{className:"space-y-2",children:[f.jsxs(de,{className:"text-xs text-gray-600",children:["Uploaded Files (",a.length,")"]}),f.jsx("div",{className:"max-h-40 space-y-1 overflow-y-auto",children:a.map(l=>f.jsxs("div",{className:"flex items-center justify-between rounded border bg-gray-50 p-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx(u2,{className:"h-4 w-4 flex-shrink-0 text-gray-500"}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"truncate text-sm text-gray-700",children:l.originalName}),f.jsx("p",{className:"text-xs text-gray-500",children:l.file?s(l.file.size):""})]})]}),f.jsx(Ee,{variant:"ghost",size:"sm",className:"h-6 w-6 flex-shrink-0 p-0",onClick:()=>i(l.id),children:f.jsx(nr,{className:"h-3 w-3"})})]},l.id))})]})]})}function wFe(){const e=Ce(d=>d.card.dataSource),t=Ce(d=>d.actions.updateDataSource),[n,r]=R.useState(""),[o,i]=R.useState(""),[s,a]=R.useState("api"),l=()=>{if(!n.trim()||!o.trim()||!e)return;const d={id:`url-${Date.now()}-${Math.random()}`,name:n.trim(),type:"url",connectionId:"default",connectionType:"none",label:n.trim(),description:`URL source of type ${s}`,url:o.trim(),sourceType:s,originalName:n.trim()},h=(e==null?void 0:e.selectedEntities)||[];t({...e,selectedEntities:[...h,d]}),r(""),i(""),a("api")},c=d=>{if(!e)return;const h=(e.selectedEntities||[]).filter(p=>p.id!==d);t({...e,selectedEntities:h})},u=(e==null?void 0:e.selectedEntities)||[];return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium text-gray-700",children:"URL Sources"}),f.jsxs("div",{className:"space-y-3 rounded-lg border bg-gray-50 p-3",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-xs text-gray-600",children:"Source Name"}),f.jsx(yr,{placeholder:"e.g., Sales API, Customer Data",value:n,onChange:d=>r(d.target.value),className:"h-8 text-sm"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-xs text-gray-600",children:"URL"}),f.jsx(yr,{placeholder:"https://api.example.com/data",value:o,onChange:d=>i(d.target.value),className:"h-8 text-sm"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-xs text-gray-600",children:"Type"}),f.jsxs("select",{value:s,onChange:d=>a(d.target.value),className:"h-8 w-full rounded-md border border-gray-300 px-2 text-sm",children:[f.jsx("option",{value:"api",children:"API Endpoint"}),f.jsx("option",{value:"csv",children:"CSV File"}),f.jsx("option",{value:"json",children:"JSON File"})]})]}),f.jsxs(Ee,{onClick:l,disabled:!n.trim()||!o.trim(),size:"sm",className:"w-full",children:[f.jsx(uc,{className:"mr-1 h-3 w-3"}),"Add Source"]})]})]}),u.length>0&&f.jsxs("div",{className:"space-y-2",children:[f.jsxs(de,{className:"text-xs text-gray-600",children:["Added Sources (",u.length,")"]}),f.jsx("div",{className:"max-h-40 space-y-1 overflow-y-auto",children:u.map(d=>f.jsxs("div",{className:"flex items-center justify-between rounded border bg-gray-50 p-2",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx(d2,{className:"h-4 w-4 flex-shrink-0 text-gray-500"}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"truncate text-sm text-gray-700",children:d.name}),f.jsx("p",{className:"truncate text-xs text-gray-500",children:d.url})]})]}),f.jsx(Ee,{variant:"ghost",size:"sm",className:"h-6 w-6 flex-shrink-0 p-0",onClick:()=>c(d.id),children:f.jsx(nr,{className:"h-3 w-3"})})]},d.id))})]})]})}function hj(e,t){var y,v;const n=re(x=>x.authToken)||t,{connections:r}=Li(t),o=Ce(x=>{var S,_;return(_=(S=x==null?void 0:x.card)==null?void 0:S.dataSource)==null?void 0:_.connectionId}),i=Ce(x=>{var S,_,E;return(E=(_=(S=x==null?void 0:x.card)==null?void 0:S.dataSource)==null?void 0:_.dbSelection)==null?void 0:E.database}),s=Ce(x=>{var S,_,E;return(E=(_=(S=x==null?void 0:x.card)==null?void 0:S.dataSource)==null?void 0:_.dbSelection)==null?void 0:E.schema}),a=r==null?void 0:r.find(x=>x.id===o),l=a==null?void 0:a.capabilities,c=((y=l==null?void 0:l.labels)==null?void 0:y.schema)||"Schema";function u(){return o?(a==null?void 0:a.type)==="API"||(a==null?void 0:a.type)==="S3"?!0:!(!i||l!=null&&l.path.includes("schema")&&!s||e==="view"):!1}const{data:d,isPending:h,isLoading:p,error:g,refetch:m}=Tn({queryKey:[e,o,i,s],queryFn:()=>br(`https://semaphor.cloud/api/v1/${e}s`,(n==null?void 0:n.accessToken)||"",{connection_id:o,database_name:i,schema_name:s}),enabled:u()}),b=(v=d==null?void 0:d[`${e}s`])==null?void 0:v.map(x=>({connectionId:a==null?void 0:a.id,connectionType:a==null?void 0:a.type,dialect:a==null?void 0:a.dialect,type:e,id:x[`${e}_name`],database:i,schema:s,name:x[`${e}_name`]}));return{isPending:h,isLoading:p,error:g,entities:b||[],refetch:m,label:c}}function v0({title:e,message:t}){return f.jsx("div",{className:"rounded-xl border border-destructive/40 bg-destructive/10 p-4 text-destructive shadow-sm",children:f.jsxs("div",{className:"flex items-start gap-4",children:[f.jsx(X5,{className:"h-6 w-6 flex-shrink-0"}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h4",{className:"text-base font-semibold",children:e}),t&&f.jsx("p",{className:"mt-1 text-sm text-destructive/90",children:t})]})]})})}function CFe({dataSource:e,onSelectionChange:t,selectedEntities:n}){const{connections:r,isPending:o}=Li(),[i,s]=R.useState(""),[a,l]=R.useState(""),[c,u]=R.useState(""),{updateDataSource:d,setSelectedConnectionId:h}=Zo(),{entities:p,isLoading:g,error:m}=hj("table"),{entities:b}=hj("view"),{dataModels:y,isPending:v,error:x}=pU(),S=N=>{const M=r.find(D=>D.id===N);if(!M)return;const I=M.type==="upload"?"upload":M.type==="url"?"url":"database";d({...e,connectionId:N,connectionType:M.type,mode:I,dbSelection:{database:"",schema:"",entityType:"table"}}),h(N)},_=N=>{var j,F;const M=n||[],I=M.some(T=>T.name===N.name&&T.type===N.type);let D;if(I)D=M.filter(T=>!(T.name===N.name&&T.type===N.type));else{const T={connectionId:e.connectionId,connectionType:e.connectionType,type:N.type,database:((j=e.dbSelection)==null?void 0:j.database)||"",schema:((F=e.dbSelection)==null?void 0:F.schema)||"",name:N.name,dialect:N.dialect};D=[...M,T]}t==null||t(D)},E=N=>{const M=n||[],I=M.some(j=>j.type==="model"&&j.name===N.name);let D;I?D=M.filter(j=>!(j.type==="model"&&j.name===N.name)):D=[...M,N],t==null||t(D)},C=p.filter(N=>N.name.toLowerCase().includes(i.toLowerCase()));b.filter(N=>N.name.toLowerCase().includes(a.toLowerCase()));const k=y.filter(N=>N.name.toLowerCase().includes(c.toLowerCase()));return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"font-medium= text-sm",children:"Connection"}),f.jsxs(Pt,{value:(e==null?void 0:e.connectionId)||"",onValueChange:S,disabled:o,children:[f.jsx(Ct,{className:"w-full",children:f.jsx(Dt,{placeholder:o?"Loading connections...":"Select connection..."})}),f.jsx(St,{children:r.map(N=>f.jsx(ye,{className:"hover:bg-muted",value:N.id,children:f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx(q0,{className:"h-4 w-4 flex-shrink-0"}),f.jsx("span",{className:"truncate",children:N.name}),f.jsx(eo,{variant:"secondary",className:"flex-shrink-0 text-xs",children:N.type})]})},N.id))})]})]}),(e==null?void 0:e.connectionId)&&f.jsxs(f.Fragment,{children:[e.connectionType==="upload"&&f.jsx(xFe,{}),e.connectionType==="url"&&f.jsx(wFe,{}),e.connectionType!=="upload"&&e.connectionType!=="url"&&f.jsxs(f.Fragment,{children:[f.jsx(vFe,{}),f.jsx("div",{className:"space-y-4",children:f.jsx("div",{className:"space-y-2",children:f.jsxs(ad,{defaultValue:"tables",className:"w-full",children:[f.jsxs(ac,{className:"grid w-full grid-cols-3",children:[f.jsx(Jr,{value:"tables",children:"Tables"}),f.jsx(Jr,{value:"datamodels",children:"Data Models"}),f.jsx(Jr,{value:"views",children:"Views (Coming soon)"})]}),f.jsxs(mi,{value:"tables",className:"space-y-2",children:[f.jsx(zn,{placeholder:"Search tables...",value:i,onChange:N=>s(N.target.value),className:"h-8 text-sm",disabled:g}),f.jsx("div",{className:"max-h-40 space-y-1 overflow-y-auto",children:g?f.jsx("div",{className:"py-4 text-center text-sm",children:"Loading tables..."}):m?f.jsx(v0,{title:"Error loading tables",message:m.message||"Failed to load tables. Please try again.",onRetry:()=>window.location.reload()}):C.length===0?f.jsx("div",{className:"py-4 text-center text-sm",children:"No tables found"}):C.map(N=>{const M=n.some(I=>I.name===N.name&&I.type==="table");return f.jsxs("div",{className:"flex items-center space-x-2 rounded p-2 hover:bg-muted",children:[f.jsx(zr,{id:`table-${N.name}`,checked:M,onCheckedChange:()=>_(N),disabled:g}),f.jsx(de,{htmlFor:`table-${N.name}`,children:N.name})]},N.name)})})]}),f.jsxs(mi,{value:"datamodels",className:"space-y-2",children:[f.jsx(zn,{placeholder:"Search data models...",value:c,onChange:N=>u(N.target.value),className:"h-8 text-sm",disabled:v}),f.jsx("div",{className:"max-h-40 space-y-1 overflow-y-auto",children:v?f.jsx("div",{className:"py-4 text-center text-sm",children:"Loading data models..."}):x?f.jsx(v0,{title:"Error loading data models",message:x.message||"Failed to load data models. Please try again.",onRetry:()=>window.location.reload()}):k.length===0?f.jsx("div",{className:"py-4 text-center text-sm",children:"No data models found"}):k.map(N=>{const M=n.some(I=>I.name===N.name&&I.type==="model");return f.jsxs("div",{className:"ounded flex items-start space-x-2 p-2 hover:bg-muted",children:[f.jsx(zr,{id:`dataModel-${N.name}`,checked:M,onCheckedChange:()=>E(N),disabled:v}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx(de,{htmlFor:`dataModel-${N.name}`,children:N.name}),f.jsx("span",{className:"text-xs text-muted-foreground",children:N.description})]})]},N.name)})})]}),f.jsx(mi,{value:"views",className:"space-y-2",children:f.jsx("div",{className:"py-4 text-center text-sm",children:"Views support coming soon"})})]})})})]})]})]})}function SFe({dataSource:e,onDataSourceUpdate:t,onSelectionChange:n,selectedEntities:r}){var m;const[o,i]=R.useState(""),{semanticDomains:s,isPending:a,error:l}=hU(),{datasets:c,isPending:u,error:d}=gFe(e==null?void 0:e.semanticDomainId),h=b=>{const y={...e,connectionId:e.connectionId||"none",connectionType:e.connectionType||"none",mode:"semanticDomain",semanticDomainId:b};t({...y})},p=b=>{const y=r||[],v=y.some(S=>S.id===b.id&&S.type==="dataset");let x;if(v)x=y.filter(S=>!(S.id===b.id&&S.type==="dataset"));else{const S={id:b.id,datasetType:b.type,name:b.name||b.table,label:b.label,domainId:b.domainId,description:b.description,database:b.database,schema:b.schema,type:"dataset",connectionId:b.connectionId,connectionType:b.connectionType,datamodelId:b.datamodelId,sql:b.sql};x=[...y,S]}n==null||n(x)},g=c.filter(b=>b.name.toLowerCase().includes(o.toLowerCase()));return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium",children:"Semantic Domain"}),f.jsxs(Pt,{value:(e==null?void 0:e.semanticDomainId)||"",onValueChange:h,disabled:a,children:[f.jsx(Ct,{className:"w-full",children:f.jsx(Dt,{placeholder:a?"Loading semantic domains...":"Select semantic domain...",children:((m=s.find(b=>b.id===(e==null?void 0:e.semanticDomainId)))==null?void 0:m.label)||"Select semantic domain"})}),f.jsx(St,{children:s.map(b=>f.jsx(ye,{className:"hover:bg-muted",value:b.id,children:f.jsxs("div",{className:"flex flex-col items-start",children:[f.jsx("span",{className:"font-medium",children:b.label}),f.jsx("span",{className:"text-xs",children:b.description})]})},b.id))})]}),l&&f.jsx(v0,{title:"Error loading semantic models",message:l.message})]}),(e==null?void 0:e.semanticDomainId)&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(de,{className:"text-sm font-medium text-gray-700",children:"Datasets"}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(zn,{placeholder:"Search datasets...",value:o,onChange:b=>i(b.target.value),className:"h-8 text-sm",disabled:u}),f.jsx("div",{className:"max-h-40 space-y-1 overflow-y-auto",children:u?f.jsx("div",{className:"py-4 text-center text-sm text-gray-500",children:"Loading datasets..."}):d?f.jsx(v0,{title:"Error loading datasets",message:d.message||"Failed to load datasets. Please try again.",onRetry:()=>window.location.reload()}):g.length===0?f.jsx("div",{className:"py-4 text-center text-sm text-gray-500",children:o?"No datasets match your search":"No datasets available"}):g.map(b=>{const y=r.some(v=>v.id===b.id&&v.type==="dataset");return f.jsxs("div",{className:"flex items-start space-x-2 rounded p-2 hover:bg-gray-50",children:[f.jsx(zr,{id:`dataset-${b.id}`,checked:y,onCheckedChange:()=>p(b),disabled:u}),f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx(de,{htmlFor:`dataset-${b.id}`,className:"font-medium",children:b.label||b.name}),f.jsx("span",{className:"text-xs text-gray-500",children:b.description})]})]},b.label||b.name)})})]})]})]})}function mU({open:e,onOpenChange:t,dataSource:n,fallbackDataSource:r,dialogMode:o,incomingSelectedEntities:i}){const[s,a]=R.useState([]),{updateDataSource:l}=Zo(),c=re(x=>x.isVisualEditing),u=re(x=>x.dashboard.aiContext),{setAiContext:d}=on(),{semanticDomains:h}=hU();R.useEffect(()=>{e&&a(i||[])},[e,n==null?void 0:n.selectedEntities,o,l,i,n]);const p=x=>{const S=s.filter(_=>!(_.name===x.name&&_.type===x.type));a(S)},g=()=>{a([]),o==="aiContext"&&(d({...u,selectedEntities:[]}),t(!1)),o==="dataSource"&&(l({...r,...n,selectedEntities:[]}),t(!1))},m=R.useCallback(x=>{l({...n,connectionId:(n==null?void 0:n.connectionId)||"",connectionType:(n==null?void 0:n.connectionType)||"",mode:x,selectedEntities:(n==null?void 0:n.selectedEntities)||[]})},[n,l]),b=R.useCallback(x=>{l({...n,...x})},[n,l]),y=R.useCallback(x=>{a(x)},[]);function v(){var x,S;if(o==="aiContext"){const{selectedEntities:_,...E}=n;c&&l(n),d({...u,selectedEntities:s}),t(!1)}else if(o==="dataSource"){if(n.mode==="semanticDomain"){const _=(x=s==null?void 0:s[0])==null?void 0:x.connectionId,E=(S=s==null?void 0:s[0])==null?void 0:S.connectionType;l({...n,connectionId:_,connectionType:E,selectedEntities:s})}else l({...n,selectedEntities:s});t(!1)}}return h&&h.length>0,f.jsx(ey,{open:e,onOpenChange:t,children:f.jsx(ip,{className:"flex max-w-2xl flex-col",children:f.jsxs("div",{children:[f.jsxs(sp,{className:"flex-shrink-0",children:[f.jsx(lp,{children:o==="aiContext"?"AI Context":"Select Data Source"}),f.jsx(cp,{children:o==="aiContext"?"Set the overall data scope for the Assistant":"Select data sets to analyze"})]}),f.jsx("div",{className:"flex-1 grow overflow-y-auto py-4",children:f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"space-y-2",children:f.jsx(ad,{defaultValue:(n==null?void 0:n.mode)||"database",value:(n==null?void 0:n.mode)||"database",onValueChange:m,className:"w-full",children:f.jsxs(ac,{className:"grid w-full grid-cols-2",children:[f.jsx(Jr,{value:"database",children:"Direct Source"}),f.jsx(Jr,{value:"semanticDomain",children:"Semantic Domain"})]})})}),(n==null?void 0:n.mode)==="semanticDomain"&&f.jsx(SFe,{dataSource:n,onDataSourceUpdate:b,selectedEntities:s,onSelectionChange:y}),(n==null?void 0:n.mode)==="database"&&f.jsx(CFe,{dataSource:n,onDataSourceUpdate:b,selectedEntities:s,onSelectionChange:y})]})}),f.jsx(mFe,{selectedEntities:s,onDeselectEntity:p}),f.jsx(ap,{className:"flex-shrink-0",children:f.jsx("div",{className:"flex w-full justify-between",children:f.jsxs("div",{className:"flex grow justify-end gap-2",children:[f.jsx(Ee,{variant:"outline",onClick:g,disabled:s.length===0,children:"Clear All"}),f.jsx(Ee,{variant:"outline",onClick:()=>t(!1),children:"Close"}),f.jsx(Ee,{onClick:v,disabled:s.length===0,children:"Save"})]})})})]})})})}const sE={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]},EFe=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function _Fe({open:e,setOpen:t}){const[n,r]=R.useState(!1),[o,i]=R.useState(Yg),[s,a]=R.useState(!1),[l,c]=R.useState(!1),u=R.useRef(null),d=R.useRef(null);re(V=>V.dashboard.aiScopeTables);const h=re(V=>V.isDashboardEditing),{setDataSource:p}=Zo(),g=oR(),{setCurrentAIContext:m,updateSelectedEntities:b}=iR(),y=re(V=>V.dashboard.aiContext),v=Ce(V=>V.card.dataSource),{assistantProfile:x}=lU(),S=re(V=>V.handleOpenAssistantProfile),{append:_,handleAddNewFrame:E,isLoading:C,handleSubmit:k,handleInputChange:N,input:M,setInput:I,messages:D,setMessages:j,reload:F,status:T,stop:O,errorMessage:$}=aFe(g);aU({scrollContainerRef:d,inputRef:u,messages:D}),R.useEffect(()=>{var V;e&&((V=u.current)==null||V.focus())},[e]);function B(V){W();const G={role:"user",content:V.title+" "+V.subtitle};_(G)}function z(V){W(),_({role:"user",content:V})}function A(){var q;const V=(q=y==null?void 0:y.selectedEntities)==null?void 0:q[0],G={connectionId:(V==null?void 0:V.connectionId)||"",connectionType:(V==null?void 0:V.connectionType)||"",mode:(V==null?void 0:V.type)==="dataset"?"semanticDomain":"database",dbSelection:{database:(V==null?void 0:V.database)||"",schema:(V==null?void 0:V.schema)||"",entityType:(V==null?void 0:V.type)||"table"},selectedEntities:(y==null?void 0:y.selectedEntities)||[]};p(G),c(!0)}function W(){g.selectedEntities.length===0&&m({selectedEntities:(y==null?void 0:y.selectedEntities)||[]})}const L=(M==null?void 0:M.length)===0&&(D==null?void 0:D.filter(V=>V.role==="user").length)===0;function P(){return f.jsx("div",{"data-role":"header",children:f.jsx("div",{className:"text-lg font-semibold",children:"Assistant"})})}function H(){return f.jsxs(Hy,{children:[f.jsx(Wy,{asChild:!0,children:f.jsx(Zc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:f.jsx(J5,{className:"size-3.5"})})}),f.jsxs(Ip,{align:"end",children:[f.jsx(Z_,{children:"Options"}),f.jsx(Uy,{}),f.jsx(Of,{checked:n,onCheckedChange:r,children:"Token Usage"}),f.jsx(Of,{checked:o,onCheckedChange:i,children:"Tool Invocations"}),f.jsx(Of,{checked:s,onCheckedChange:a,children:"System Message"})]})]})}return f.jsxs("div",{"data-role":"dashboard-assistant",className:"flex h-full grow flex-col justify-between break-words px-6 py-4",children:[f.jsxs("div",{"data-role":"header-section",className:"flex items-start justify-between gap-2",children:[P(),S&&f.jsx(Ee,{variant:"outline",size:"sm",className:"h-7 p-2",onClick:S,children:(x==null?void 0:x.name)||"Default Profile"}),f.jsxs("div",{"data-role":"header-actions",className:"flex items-center gap-2",children:[H(),(h||Yg)&&f.jsx(Zc,{tooltip:"Add Context",className:"h-7 p-2 text-muted-foreground hover:text-foreground",onClick:A,children:f.jsx(aa,{className:"size-4"})}),f.jsx(Zc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",tooltip:"New Chat",onClick:()=>{j([]),F()},children:f.jsx(lF,{className:"size-4"})}),f.jsx(Zc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",onClick:()=>{t(!1)},children:f.jsx(c2,{className:"size-4"})})]})]}),f.jsxs(Tp,{"data-role":"dashboard-assistant-scroll-area",ref:d,className:"mt-4 flex flex-1 basis-0 flex-col flex-wrap justify-end pr-2",children:[f.jsxs("div",{className:"space-y-3 pb-4",children:[f.jsx(DW,{showTools:o,showSystemMessage:s,messages:D,onAddToDashboard:E}),f.jsx(PW,{messages:D,chatStatus:T,errorMessage:$})]}),f.jsx(wd,{orientation:"horizontal"})]}),f.jsxs("div",{className:"space-y-3",children:[!x&&L&&f.jsx(IW,{onClick:B,placeholders:EFe}),f.jsx("div",{children:L&&x&&f.jsx(cU,{seedQuestions:x.seedQuestions||[],handleSeedQuestionClick:z})}),f.jsx(dU,{ref:u,setInput:I,stop:O,input:M,handleInputChange:N,handleSubmit:V=>{W(),k(V)},isLoading:C,onFocus:()=>{}})]}),f.jsx(mU,{incomingSelectedEntities:(y==null?void 0:y.selectedEntities)||[],open:l,onOpenChange:c,dataSource:v||sE,fallbackDataSource:sE,dialogMode:"aiContext"})]})}var RFe=e=>{switch(e){case"success":return MFe;case"info":return DFe;case"warning":return PFe;case"error":return IFe;default:return null}},kFe=Array(12).fill(0),NFe=({visible:e,className:t})=>R.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},R.createElement("div",{className:"sonner-spinner"},kFe.map((n,r)=>R.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),MFe=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),PFe=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),DFe=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),IFe=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),AFe=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},R.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),R.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),TFe=()=>{let[e,t]=R.useState(document.hidden);return R.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},aE=1,jFe=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:aE++,i=this.toasts.find(a=>a.id===o),s=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),i?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:s,title:n}):a):this.addToast({title:n,...r,dismissible:s,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,i,s=r.then(async l=>{if(i=["resolve",l],R.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(FFe(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,u=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:u})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,u=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:u})}}).catch(async l=>{if(i=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,u=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:u})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>s.then(()=>i[0]==="reject"?c(i[1]):l(i[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||aE++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ar=new jFe,OFe=(e,t)=>{let n=(t==null?void 0:t.id)||aE++;return Ar.addToast({title:e,...t,id:n}),n},FFe=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",LFe=OFe,$Fe=()=>Ar.toasts,zFe=()=>Ar.getActiveToasts(),gU=Object.assign(LFe,{success:Ar.success,info:Ar.info,warning:Ar.warning,error:Ar.error,custom:Ar.custom,message:Ar.message,promise:Ar.promise,dismiss:Ar.dismiss,loading:Ar.loading},{getHistory:$Fe,getToasts:zFe});function BFe(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}BFe(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
628
628
  `);function wg(e){return e.label!==void 0}var VFe=3,HFe="32px",WFe="16px",pj=4e3,UFe=356,qFe=14,GFe=20,YFe=200;function Io(...e){return e.filter(Boolean).join(" ")}function KFe(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var XFe=e=>{var t,n,r,o,i,s,a,l,c,u,d;let{invert:h,toast:p,unstyled:g,interacting:m,setHeights:b,visibleToasts:y,heights:v,index:x,toasts:S,expanded:_,removeToast:E,defaultRichColors:C,closeButton:k,style:N,cancelButtonStyle:M,actionButtonStyle:I,className:D="",descriptionClassName:j="",duration:F,position:T,gap:O,loadingIcon:$,expandByDefault:B,classNames:z,icons:A,closeButtonAriaLabel:W="Close toast",pauseWhenPageIsHidden:L}=e,[P,H]=R.useState(null),[V,G]=R.useState(null),[q,Y]=R.useState(!1),[K,Z]=R.useState(!1),[ee,Q]=R.useState(!1),[oe,te]=R.useState(!1),[ce,ue]=R.useState(!1),[Re,ve]=R.useState(0),[we,De]=R.useState(0),Ye=R.useRef(p.duration||F||pj),_t=R.useRef(null),me=R.useRef(null),je=x===0,Ie=x+1<=y,ne=p.type,le=p.dismissible!==!1,ke=p.className||"",Pe=p.descriptionClassName||"",Ue=R.useMemo(()=>v.findIndex(Ae=>Ae.toastId===p.id)||0,[v,p.id]),jt=R.useMemo(()=>{var Ae;return(Ae=p.closeButton)!=null?Ae:k},[p.closeButton,k]),kn=R.useMemo(()=>p.duration||F||pj,[p.duration,F]),gn=R.useRef(0),ge=R.useRef(0),bn=R.useRef(0),Ot=R.useRef(null),[uo,On]=T.split("-"),Cc=R.useMemo(()=>v.reduce((Ae,qe,rt)=>rt>=Ue?Ae:Ae+qe.height,0),[v,Ue]),za=TFe(),Wi=p.invert||h,an=ne==="loading";ge.current=R.useMemo(()=>Ue*O+Cc,[Ue,Cc]),R.useEffect(()=>{Ye.current=kn},[kn]),R.useEffect(()=>{Y(!0)},[]),R.useEffect(()=>{let Ae=me.current;if(Ae){let qe=Ae.getBoundingClientRect().height;return De(qe),b(rt=>[{toastId:p.id,height:qe,position:p.position},...rt]),()=>b(rt=>rt.filter(Jt=>Jt.toastId!==p.id))}},[b,p.id]),R.useLayoutEffect(()=>{if(!q)return;let Ae=me.current,qe=Ae.style.height;Ae.style.height="auto";let rt=Ae.getBoundingClientRect().height;Ae.style.height=qe,De(rt),b(Jt=>Jt.find(Ft=>Ft.toastId===p.id)?Jt.map(Ft=>Ft.toastId===p.id?{...Ft,height:rt}:Ft):[{toastId:p.id,height:rt,position:p.position},...Jt])},[q,p.title,p.description,b,p.id]);let Rt=R.useCallback(()=>{Z(!0),ve(ge.current),b(Ae=>Ae.filter(qe=>qe.toastId!==p.id)),setTimeout(()=>{E(p)},YFe)},[p,E,b,ge]);R.useEffect(()=>{if(p.promise&&ne==="loading"||p.duration===1/0||p.type==="loading")return;let Ae;return _||m||L&&za?(()=>{if(bn.current<gn.current){let qe=new Date().getTime()-gn.current;Ye.current=Ye.current-qe}bn.current=new Date().getTime()})():Ye.current!==1/0&&(gn.current=new Date().getTime(),Ae=setTimeout(()=>{var qe;(qe=p.onAutoClose)==null||qe.call(p,p),Rt()},Ye.current)),()=>clearTimeout(Ae)},[_,m,p,ne,L,za,Rt]),R.useEffect(()=>{p.delete&&Rt()},[Rt,p.delete]);function Fn(){var Ae,qe,rt;return A!=null&&A.loading?R.createElement("div",{className:Io(z==null?void 0:z.loader,(Ae=p==null?void 0:p.classNames)==null?void 0:Ae.loader,"sonner-loader"),"data-visible":ne==="loading"},A.loading):$?R.createElement("div",{className:Io(z==null?void 0:z.loader,(qe=p==null?void 0:p.classNames)==null?void 0:qe.loader,"sonner-loader"),"data-visible":ne==="loading"},$):R.createElement(NFe,{className:Io(z==null?void 0:z.loader,(rt=p==null?void 0:p.classNames)==null?void 0:rt.loader),visible:ne==="loading"})}return R.createElement("li",{tabIndex:0,ref:me,className:Io(D,ke,z==null?void 0:z.toast,(t=p==null?void 0:p.classNames)==null?void 0:t.toast,z==null?void 0:z.default,z==null?void 0:z[ne],(n=p==null?void 0:p.classNames)==null?void 0:n[ne]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:C,"data-styled":!(p.jsx||p.unstyled||g),"data-mounted":q,"data-promise":!!p.promise,"data-swiped":ce,"data-removed":K,"data-visible":Ie,"data-y-position":uo,"data-x-position":On,"data-index":x,"data-front":je,"data-swiping":ee,"data-dismissible":le,"data-type":ne,"data-invert":Wi,"data-swipe-out":oe,"data-swipe-direction":V,"data-expanded":!!(_||B&&q),style:{"--index":x,"--toasts-before":x,"--z-index":S.length-x,"--offset":`${K?Re:ge.current}px`,"--initial-height":B?"auto":`${we}px`,...N,...p.style},onDragEnd:()=>{Q(!1),H(null),Ot.current=null},onPointerDown:Ae=>{an||!le||(_t.current=new Date,ve(ge.current),Ae.target.setPointerCapture(Ae.pointerId),Ae.target.tagName!=="BUTTON"&&(Q(!0),Ot.current={x:Ae.clientX,y:Ae.clientY}))},onPointerUp:()=>{var Ae,qe,rt,Jt;if(oe||!le)return;Ot.current=null;let Ft=Number(((Ae=me.current)==null?void 0:Ae.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Lt=Number(((qe=me.current)==null?void 0:qe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Dn=new Date().getTime()-((rt=_t.current)==null?void 0:rt.getTime()),en=P==="x"?Ft:Lt,yn=Math.abs(en)/Dn;if(Math.abs(en)>=GFe||yn>.11){ve(ge.current),(Jt=p.onDismiss)==null||Jt.call(p,p),G(P==="x"?Ft>0?"right":"left":Lt>0?"down":"up"),Rt(),te(!0),ue(!1);return}Q(!1),H(null)},onPointerMove:Ae=>{var qe,rt,Jt,Ft;if(!Ot.current||!le||((qe=window.getSelection())==null?void 0:qe.toString().length)>0)return;let Lt=Ae.clientY-Ot.current.y,Dn=Ae.clientX-Ot.current.x,en=(rt=e.swipeDirections)!=null?rt:KFe(T);!P&&(Math.abs(Dn)>1||Math.abs(Lt)>1)&&H(Math.abs(Dn)>Math.abs(Lt)?"x":"y");let yn={x:0,y:0};P==="y"?(en.includes("top")||en.includes("bottom"))&&(en.includes("top")&&Lt<0||en.includes("bottom")&&Lt>0)&&(yn.y=Lt):P==="x"&&(en.includes("left")||en.includes("right"))&&(en.includes("left")&&Dn<0||en.includes("right")&&Dn>0)&&(yn.x=Dn),(Math.abs(yn.x)>0||Math.abs(yn.y)>0)&&ue(!0),(Jt=me.current)==null||Jt.style.setProperty("--swipe-amount-x",`${yn.x}px`),(Ft=me.current)==null||Ft.style.setProperty("--swipe-amount-y",`${yn.y}px`)}},jt&&!p.jsx?R.createElement("button",{"aria-label":W,"data-disabled":an,"data-close-button":!0,onClick:an||!le?()=>{}:()=>{var Ae;Rt(),(Ae=p.onDismiss)==null||Ae.call(p,p)},className:Io(z==null?void 0:z.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(i=A==null?void 0:A.close)!=null?i:AFe):null,p.jsx||R.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:R.createElement(R.Fragment,null,ne||p.icon||p.promise?R.createElement("div",{"data-icon":"",className:Io(z==null?void 0:z.icon,(s=p==null?void 0:p.classNames)==null?void 0:s.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||Fn():null,p.type!=="loading"?p.icon||(A==null?void 0:A[ne])||RFe(ne):null):null,R.createElement("div",{"data-content":"",className:Io(z==null?void 0:z.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},R.createElement("div",{"data-title":"",className:Io(z==null?void 0:z.title,(l=p==null?void 0:p.classNames)==null?void 0:l.title)},typeof p.title=="function"?p.title():p.title),p.description?R.createElement("div",{"data-description":"",className:Io(j,Pe,z==null?void 0:z.description,(c=p==null?void 0:p.classNames)==null?void 0:c.description)},typeof p.description=="function"?p.description():p.description):null),R.isValidElement(p.cancel)?p.cancel:p.cancel&&wg(p.cancel)?R.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||M,onClick:Ae=>{var qe,rt;wg(p.cancel)&&le&&((rt=(qe=p.cancel).onClick)==null||rt.call(qe,Ae),Rt())},className:Io(z==null?void 0:z.cancelButton,(u=p==null?void 0:p.classNames)==null?void 0:u.cancelButton)},p.cancel.label):null,R.isValidElement(p.action)?p.action:p.action&&wg(p.action)?R.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||I,onClick:Ae=>{var qe,rt;wg(p.action)&&((rt=(qe=p.action).onClick)==null||rt.call(qe,Ae),!Ae.defaultPrevented&&Rt())},className:Io(z==null?void 0:z.actionButton,(d=p==null?void 0:p.classNames)==null?void 0:d.actionButton)},p.action.label):null))};function mj(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function QFe(e,t){let n={};return[e,t].forEach((r,o)=>{let i=o===1,s=i?"--mobile-offset":"--offset",a=i?WFe:HFe;function l(c){["top","right","bottom","left"].forEach(u=>{n[`${s}-${u}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${s}-${c}`]=a:n[`${s}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var ZFe=R.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:i,closeButton:s,className:a,offset:l,mobileOffset:c,theme:u="light",richColors:d,duration:h,style:p,visibleToasts:g=VFe,toastOptions:m,dir:b=mj(),gap:y=qFe,loadingIcon:v,icons:x,containerAriaLabel:S="Notifications",pauseWhenPageIsHidden:_}=e,[E,C]=R.useState([]),k=R.useMemo(()=>Array.from(new Set([r].concat(E.filter(L=>L.position).map(L=>L.position)))),[E,r]),[N,M]=R.useState([]),[I,D]=R.useState(!1),[j,F]=R.useState(!1),[T,O]=R.useState(u!=="system"?u:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),$=R.useRef(null),B=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),z=R.useRef(null),A=R.useRef(!1),W=R.useCallback(L=>{C(P=>{var H;return(H=P.find(V=>V.id===L.id))!=null&&H.delete||Ar.dismiss(L.id),P.filter(({id:V})=>V!==L.id)})},[]);return R.useEffect(()=>Ar.subscribe(L=>{if(L.dismiss){C(P=>P.map(H=>H.id===L.id?{...H,delete:!0}:H));return}setTimeout(()=>{rn.flushSync(()=>{C(P=>{let H=P.findIndex(V=>V.id===L.id);return H!==-1?[...P.slice(0,H),{...P[H],...L},...P.slice(H+1)]:[L,...P]})})})}),[]),R.useEffect(()=>{if(u!=="system"){O(u);return}if(u==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?O("dark"):O("light")),typeof window>"u")return;let L=window.matchMedia("(prefers-color-scheme: dark)");try{L.addEventListener("change",({matches:P})=>{O(P?"dark":"light")})}catch{L.addListener(({matches:H})=>{try{O(H?"dark":"light")}catch(V){console.error(V)}})}},[u]),R.useEffect(()=>{E.length<=1&&D(!1)},[E]),R.useEffect(()=>{let L=P=>{var H,V;o.every(G=>P[G]||P.code===G)&&(D(!0),(H=$.current)==null||H.focus()),P.code==="Escape"&&(document.activeElement===$.current||(V=$.current)!=null&&V.contains(document.activeElement))&&D(!1)};return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},[o]),R.useEffect(()=>{if($.current)return()=>{z.current&&(z.current.focus({preventScroll:!0}),z.current=null,A.current=!1)}},[$.current]),R.createElement("section",{ref:t,"aria-label":`${S} ${B}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},k.map((L,P)=>{var H;let[V,G]=L.split("-");return E.length?R.createElement("ol",{key:L,dir:b==="auto"?mj():b,tabIndex:-1,ref:$,className:a,"data-sonner-toaster":!0,"data-theme":T,"data-y-position":V,"data-lifted":I&&E.length>1&&!i,"data-x-position":G,style:{"--front-toast-height":`${((H=N[0])==null?void 0:H.height)||0}px`,"--width":`${UFe}px`,"--gap":`${y}px`,...p,...QFe(l,c)},onBlur:q=>{A.current&&!q.currentTarget.contains(q.relatedTarget)&&(A.current=!1,z.current&&(z.current.focus({preventScroll:!0}),z.current=null))},onFocus:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||A.current||(A.current=!0,z.current=q.relatedTarget)},onMouseEnter:()=>D(!0),onMouseMove:()=>D(!0),onMouseLeave:()=>{j||D(!1)},onDragEnd:()=>D(!1),onPointerDown:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||F(!0)},onPointerUp:()=>F(!1)},E.filter(q=>!q.position&&P===0||q.position===L).map((q,Y)=>{var K,Z;return R.createElement(XFe,{key:q.id,icons:x,index:Y,toast:q,defaultRichColors:d,duration:(K=m==null?void 0:m.duration)!=null?K:h,className:m==null?void 0:m.className,descriptionClassName:m==null?void 0:m.descriptionClassName,invert:n,visibleToasts:g,closeButton:(Z=m==null?void 0:m.closeButton)!=null?Z:s,interacting:j,position:L,style:m==null?void 0:m.style,unstyled:m==null?void 0:m.unstyled,classNames:m==null?void 0:m.classNames,cancelButtonStyle:m==null?void 0:m.cancelButtonStyle,actionButtonStyle:m==null?void 0:m.actionButtonStyle,removeToast:W,toasts:E.filter(ee=>ee.position==q.position),heights:N.filter(ee=>ee.position==q.position),setHeights:M,expandByDefault:i,gap:y,loadingIcon:v,expanded:I,pauseWhenPageIsHidden:_,swipeDirections:e.swipeDirections})})):null}))});function JFe(e){const t=e.current,{getSelectedFrame:n,addFrame:r,setSelectedFrameId:o}=on(),i=re(u=>u.dashboard.sheets),a=re(u=>u.selectedSheetId)??(i==null?void 0:i[0].id),l=re(u=>u.isDashboardEditing),c=re(u=>u.isVisualEditing);R.useEffect(()=>{if(!l||c)return;async function u(p){const g=p.ctrlKey||p.metaKey;g&&p.key==="c"?(await d(),gU.success("Card copied to clipboard"),p.preventDefault()):g&&p.key==="v"&&(await h(),p.preventDefault())}async function d(){try{const p=n();p&&await navigator.clipboard.writeText(JSON.stringify(p))}catch(p){console.error("Failed to copy text:",p)}}async function h(){if(!a)return null;try{const p=await navigator.clipboard.readText();try{const g=JSON.parse(p);if(g&&g.id){g.id=mr();const m=g.activeCardId;g.cards.forEach(b=>{const y=b.id;b.id=mr(),y===m&&(g.activeCardId=b.id,b.title=`${b.title} (Copy)`)}),r(a,g),o(g.id)}}catch(g){console.error("Failed to parse clipboard contents: ",g)}return p}catch(p){return console.error("Failed to paste text:",p),null}}return t==null||t.addEventListener("keydown",u),()=>t==null?void 0:t.removeEventListener("keydown",u)},[r,n,o,a,l,c,t])}function bU(e,t){const[n,r]=R.useState(()=>{const o=localStorage.getItem(e);return o?JSON.parse(o):t});return R.useEffect(()=>{localStorage.setItem(e,JSON.stringify(n))},[n,e]),[n,r]}function yU(){const{showAssistant:e}=ir(),t=R.useRef(null),n=R.useRef(null),[r,o]=R.useState(!1),[i,s]=bU("dashboardAssistantOpen",!1),a=re(N=>N.themeStyle),l=re(N=>{var M;return(M=N.dashboard)==null?void 0:M.sheets}),c=re(N=>N.isDashboardEditing),u=re(N=>N.selectedSheetId),{setSelectedSheetId:d,setSheetTitle:h,addSheet:p,setSheets:g}=on();JFe(n);function m(N){var M,I;N?((M=t.current)==null||M.resize(35),s(!0)):(s(!1),(I=t.current)==null||I.resize(0))}function b(){const N={id:mr(),title:"New Sheet"};p(N)}function y(N){N<1?s(!1):s(!0)}function v(){return(a==null?void 0:a.canvasTheme)==="muted"||!(a!=null&&a.canvasTheme)?"hsl(var(--semaphor-muted))":(a==null?void 0:a.canvasTheme)==="clear"?"":a==null?void 0:a.canvasTheme}const x=(N,M)=>{N.dataTransfer.setData("tabIndex",M.toString())},S=N=>{N.preventDefault()},_=(N,M)=>{const I=N.dataTransfer.getData("tabIndex");if(I===M.toString())return;const D=Array.from(l||[]),[j]=D.splice(parseInt(I),1);D.splice(M,0,j),g(D)};function E(){var N,M;if(l&&l.length>1||c)return f.jsxs(ac,{role:"tab-list",className:"flex h-11 items-center justify-start gap-2 rounded-none border-b border-b-muted bg-transparent px-2.5 py-3",children:[l==null?void 0:l.map((I,D)=>f.jsxs(Jr,{draggable:!0,onDragStart:j=>x(j,D),onDragOver:S,onDrop:j=>_(j,D),style:{borderRadius:a==null?void 0:a.controlInputRadius},onClick:()=>d(I.id),className:"flex items-center gap-1 rounded-none border px-2 py-1",value:I.id,children:[f.jsx(wi,{enabled:c&&I.id===u,text:I.title,onSave:j=>h(I.id,j),children:I.title},I.id),c&&u===I.id&&l.length>1&&f.jsx(nr,{className:"ml-1 size-3",onClick:()=>o(!0)})]},I.id)),c&&f.jsx("div",{style:{borderRadius:(M=(N=a==null?void 0:a.chart)==null?void 0:N.options)==null?void 0:M.borderRadius},className:"flex h-7 items-center justify-center border-none bg-muted p-2 hover:cursor-pointer dark:border-l-background",onClick:b,children:f.jsx(uc,{className:"size-3"})})]})}function C(){return f.jsx("div",{ref:n,style:{},className:"grow",children:l==null?void 0:l.map(N=>f.jsx(mi,{style:{backgroundColor:v()},className:ie("mt-0",{}),value:N.id,children:f.jsx(cke,{sheet:N})},N.id))})}function k(){var N;return f.jsxs(ad,{"data-role":"dashboard-tabs-container",className:ie("relative flex h-full flex-col",a==null?void 0:a.dashboardTabsContainer),onValueChange:M=>{d(M)},value:u||((N=l==null?void 0:l[0])==null?void 0:N.id),children:[E(),f.jsx(Tp,{className:"flex-1 grow basis-0 overflow-y-auto",children:C()}),f.jsx(vNe,{open:r,setOpen:o})]})}return l?f.jsxs(NV,{className:"flex-1 basis-0 overflow-y-auto",direction:"horizontal",children:[f.jsx(DS,{children:k()}),e===!0&&f.jsxs(f.Fragment,{children:[f.jsx(Bke,{open:i,onTabClick:m,withHandle:!0}),f.jsx(DS,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:y,defaultSize:i?35:0,ref:t,children:f.jsx("div",{className:"grow overflow-y-auto",children:f.jsx(_Fe,{open:i,setOpen:m})})})]})]}):null}function vU({children:e}){return f.jsx(kY,{defaultTheme:"system",storageKey:"vite-ui-theme",children:f.jsx(zy,{delayDuration:0,children:e})})}function xU(e){return f.jsx(_p,{FallbackComponent:s_,children:f.jsx(MO,{dashboardProps:e,children:f.jsx(vU,{children:f.jsx("main",{className:"flex h-full flex-col",children:f.jsx(AO,{...e,children:f.jsx(yU,{})})})})})})}function e4e(e,t=[]){let n=[];function r(i,s){const a=w.createContext(s),l=n.length;n=[...n,s];const c=d=>{var y;const{scope:h,children:p,...g}=d,m=((y=h==null?void 0:h[e])==null?void 0:y[l])||a,b=w.useMemo(()=>g,Object.values(g));return f.jsx(m.Provider,{value:b,children:p})};c.displayName=i+"Provider";function u(d,h){var m;const p=((m=h==null?void 0:h[e])==null?void 0:m[l])||a,g=w.useContext(p);if(g)return g;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[c,u]}const o=()=>{const i=n.map(s=>w.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return w.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,t4e(o,...t)]}function t4e(...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(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(i)[`__scope${c}`];return{...a,...d}},{});return w.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function n4e(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e}),w.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}var lE=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},r4e=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],iN=r4e.reduce((e,t)=>{const n=xs(`Primitive.${t}`),r=w.forwardRef((o,i)=>{const{asChild:s,...a}=o,l=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(l,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function o4e(){return S0.useSyncExternalStore(i4e,()=>!0,()=>!1)}function i4e(){return()=>{}}var sN="Avatar",[s4e,NLe]=e4e(sN),[a4e,wU]=s4e(sN),CU=w.forwardRef((e,t)=>{const{__scopeAvatar:n,...r}=e,[o,i]=w.useState("idle");return f.jsx(a4e,{scope:n,imageLoadingStatus:o,onImageLoadingStatusChange:i,children:f.jsx(iN.span,{...r,ref:t})})});CU.displayName=sN;var SU="AvatarImage",EU=w.forwardRef((e,t)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:o=()=>{},...i}=e,s=wU(SU,n),a=l4e(r,i),l=n4e(c=>{o(c),s.onImageLoadingStatusChange(c)});return lE(()=>{a!=="idle"&&l(a)},[a,l]),a==="loaded"?f.jsx(iN.img,{...i,ref:t,src:r}):null});EU.displayName=SU;var _U="AvatarFallback",RU=w.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:r,...o}=e,i=wU(_U,n),[s,a]=w.useState(r===void 0);return w.useEffect(()=>{if(r!==void 0){const l=window.setTimeout(()=>a(!0),r);return()=>window.clearTimeout(l)}},[r]),s&&i.imageLoadingStatus!=="loaded"?f.jsx(iN.span,{...o,ref:t}):null});RU.displayName=_U;function gj(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function l4e(e,{referrerPolicy:t,crossOrigin:n}){const r=o4e(),o=w.useRef(null),i=r?(o.current||(o.current=new window.Image),o.current):null,[s,a]=w.useState(()=>gj(i,e));return lE(()=>{a(gj(i,e))},[i,e]),lE(()=>{const l=d=>()=>{a(d)};if(!i)return;const c=l("loaded"),u=l("error");return i.addEventListener("load",c),i.addEventListener("error",u),t&&(i.referrerPolicy=t),typeof n=="string"&&(i.crossOrigin=n),()=>{i.removeEventListener("load",c),i.removeEventListener("error",u)}},[i,n,t]),s}var kU=CU,NU=EU,MU=RU;const PU=w.forwardRef(({className:e,...t},n)=>f.jsx(kU,{ref:n,className:ie("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));PU.displayName=kU.displayName;const DU=w.forwardRef(({className:e,...t},n)=>f.jsx(NU,{ref:n,className:ie("aspect-square h-full w-full",e),...t}));DU.displayName=NU.displayName;const IU=w.forwardRef(({className:e,...t},n)=>f.jsx(MU,{ref:n,className:ie("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));IU.displayName=MU.displayName;const c4e=e=>{const{currentContext:t,currentMode:n,selectedUsers:r,usersToRemove:o,usersToUpdate:i,selectedTenant:s,orgWideRole:a,allTenantsRole:l,tenantWideRole:c}=e;if(!t||!n)return null;switch(t){case"org-tab":if(n==="allOrgUsers")return{context:"org-tab",mode:"allOrgUsers",orgWideRole:a};if(n==="specificOrgUsers")return{context:"org-tab",mode:"specificOrgUsers",selectedUsers:r,usersToRemove:o,usersToUpdate:i};break;case"tenant-tab":if(n==="allTenants")return{context:"tenant-tab",mode:"allTenants",allTenantsRole:l};if(n==="allTenantUsers")return s?{context:"tenant-tab",mode:"allTenantUsers",tenantId:s,tenantWideRole:c}:null;if(n==="specificTenantUsers")return s?{context:"tenant-tab",mode:"specificTenantUsers",tenantId:s,selectedUsers:r,usersToRemove:o,usersToUpdate:i}:null;break;case"tenant-dialog":if(n==="allTenantUsers")return{context:"tenant-dialog",mode:"allTenantUsers",tenantWideRole:c};if(n==="specificTenantUsers")return{context:"tenant-dialog",mode:"specificTenantUsers",selectedUsers:r,usersToRemove:o,usersToUpdate:i};break}return null},AU=e=>{switch(e.context){case"org-tab":return e.mode==="specificOrgUsers"?e.selectedUsers.length>0||e.usersToRemove.length>0||e.usersToUpdate.length>0:!0;case"tenant-tab":if(e.mode==="allTenantUsers"||e.mode==="specificTenantUsers"){if(!e.tenantId)return!1;if(e.mode==="specificTenantUsers")return e.selectedUsers.length>0||e.usersToRemove.length>0||e.usersToUpdate.length>0}return!0;case"tenant-dialog":return e.mode==="specificTenantUsers"?e.selectedUsers.length>0||e.usersToRemove.length>0||e.usersToUpdate.length>0:!0}return!1};function TU(e){var b;const t=re(y=>y.authToken)||e,n=Ce(y=>y.selectedConnectionId),r=Ce(y=>y.selectedDatabaseName),o=Ce(y=>y.selectedDatamodelId),i=Ce(y=>y.selectedSchemaName),s=Ce(y=>y.selectedTableName),{selectedConnection:a}=Li(),l=a==null?void 0:a.type,{data:c,isLoading:u,isFetching:d,isError:h,refetch:p}=Tn({queryKey:["columns",n,r,o,i,s],queryFn:()=>br("https://semaphor.cloud/api/v1/columns",(t==null?void 0:t.accessToken)||"",{connection_id:n,datamodel_id:o||"",database_name:r,schema_name:i,table_name:s}),enabled:g(l)});function g(y){return t!=null&&t.accessToken?!!(n&&r&&r!=="NA"&&i&&s||n&&(y==="S3"||y==="API")||o&&o):!1}return{columns:(b=c==null?void 0:c.columns)==null?void 0:b.map(y=>({...y,data_type:y.data_type.toLowerCase()})),isColumnsLoading:u,isColumnsFetching:d,isColumnsError:h,refetchColumns:p}}function u4e(e,t){const[n,r]=R.useState(e);return R.useEffect(()=>{const o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}const bj={searchQuery:"",debouncedSearchQuery:"",selectedUsers:[],usersToRemove:[],usersToUpdate:[],selectedTab:"org",currentContext:"org-tab",currentMode:null,orgWideRole:"VIEWER",allTenantsRole:"VIEWER",tenantWideRole:"VIEWER",selectedTenant:"",message:""},Po=Es()(Qh(e=>({...bj,actions:{setSearchQuery:t=>{e(n=>{n.searchQuery=t})},setDebouncedSearchQuery:t=>{e(n=>{n.debouncedSearchQuery=t})},setSelectedUsers:t=>{e(n=>{n.selectedUsers=t})},addSelectedUser:t=>{e(n=>{n.selectedUsers.some(o=>o.id===t.id)||n.selectedUsers.push(t)})},removeSelectedUser:t=>{e(n=>{n.selectedUsers=n.selectedUsers.filter(r=>r.id!==t)})},updateSelectedUserRole:(t,n)=>{e(r=>{const o=r.selectedUsers.find(i=>i.id===t);o&&(o.role=n)})},setUsersToRemove:t=>{e(n=>{n.usersToRemove=t})},addUserToRemove:t=>{e(n=>{n.usersToRemove.includes(t)||n.usersToRemove.push(t)})},removeUserFromRemove:t=>{e(n=>{n.usersToRemove=n.usersToRemove.filter(r=>r!==t)})},setUsersToUpdate:t=>{e(n=>{n.usersToUpdate=t})},addUserToUpdate:t=>{e(n=>{n.usersToUpdate=n.usersToUpdate.filter(r=>r.id!==t.id),n.usersToUpdate.push(t)})},removeUserFromUpdate:t=>{e(n=>{n.usersToUpdate=n.usersToUpdate.filter(r=>r.id!==t)})},setSelectedTenant:t=>{e(n=>{n.selectedTenant=t})},setSelectedTab:t=>{e(n=>{n.selectedTab=t})},setCurrentContext:t=>{e(n=>{n.currentContext=t})},setCurrentMode:t=>{e(n=>{n.currentMode=t})},setOrgWideRole:t=>{e(n=>{n.orgWideRole=t})},setAllTenantsRole:t=>{e(n=>{n.allTenantsRole=t})},setTenantWideRole:t=>{e(n=>{n.tenantWideRole=t})},setMessage:t=>{e(n=>{n.message=t})},validateShareData:t=>AU(t),resetShareState:()=>{e(t=>{Object.assign(t,bj)})},resetUserSelections:()=>{e(t=>{t.selectedUsers=[],t.usersToRemove=[],t.usersToUpdate=[]})}}}))),jU=()=>Po(e=>e.searchQuery),d4e=()=>Po(e=>e.selectedUsers),f4e=()=>Po(e=>e.usersToRemove),h4e=()=>Po(e=>e.usersToUpdate),p4e=()=>Po(e=>e.selectedTenant),m4e=()=>Po(e=>e.selectedTab),g4e=()=>Po(e=>e.currentContext),b4e=()=>Po(e=>e.currentMode),y4e=()=>Po(e=>e.orgWideRole),v4e=()=>Po(e=>e.allTenantsRole),x4e=()=>Po(e=>e.tenantWideRole),OU=()=>Po(e=>e.actions),w4e=()=>{const e=jU(),t=u4e(e,300),n=OU();return R.useEffect(()=>{n.setDebouncedSearchQuery(t)},[t,n]),{searchQuery:e,debouncedSearchQuery:t,setSearchQuery:n.setSearchQuery}};function FU(e,t){var Pe,Ue,jt,kn,gn;const n=Jh(),r=ir().authToken||e,o=Ce(ge=>ge.selectedConnectionId),i=Ce(ge=>ge.card),{queryKey:s}=bF(i),a=Ce(ge=>ge.selectedDatamodelId),l=Ce(ge=>ge.isDevMode),c=Ce(ge=>ge.selectedDatabaseName),u=Ce(ge=>ge.selectedSchemaName),d=Ce(ge=>ge.selectedTableName),h=Ce(ge=>ge.actions.setSelectedConnectionId),p=Ce(ge=>ge.actions.setSelectedDatamodelId),g=Ce(ge=>ge.actions.setSelectedDatabaseName),m=Ce(ge=>ge.actions.setSelectedSchemaName),b=Ce(ge=>ge.actions.setSelectedTableName);Ce(ge=>ge.actions.setCardSql);const{setQueryConfig:y}=Zo();function v(ge){return o&&c&&u&&c!=="NA"?!0:o&&ge==="API"?!1:!!(o&&ge==="S3")}function x(ge){return o&&ge?!(ge==="API"||ge==="S3"):!1}const{refetchConnections:S,connectionsData:_,isConnectionsLoading:E,isConnectionsError:C,selectedConnection:k}=Li(e),{refetch:N,data:M,isLoading:I,isError:D}=Tn({queryKey:["models",o],queryFn:()=>br("https://semaphor.cloud/api/v1/datamodels",(r==null?void 0:r.accessToken)||"",{connection_id:o}),enabled:!!(r!=null&&r.accessToken)&&!!o}),j=k==null?void 0:k.type,F=(k==null?void 0:k.type)==="API"||(k==null?void 0:k.type)==="S3",{data:T,isLoading:O,isFetching:$,isError:B,refetch:z}=Tn({queryKey:["databases",o],queryFn:()=>br("https://semaphor.cloud/api/v1/databases",(r==null?void 0:r.accessToken)||"",{connection_id:o}),enabled:x(j)}),{data:A,isLoading:W,isFetching:L,isError:P,refetch:H}=Tn({queryKey:["schemas",o,c],queryFn:()=>br("https://semaphor.cloud/api/v1/schemas",(r==null?void 0:r.accessToken)||"",{connection_id:o,database_name:c}),enabled:!!o&&!!c&&!F&&c!=="NA"}),{data:V,isLoading:G,isFetching:q,isError:Y,refetch:K}=Tn({queryKey:["tables",o,c,u],queryFn:()=>br("https://semaphor.cloud/api/v1/tables",(r==null?void 0:r.accessToken)||"",{connection_id:o,database_name:c,schema_name:u}),enabled:v(j)}),{columns:Z,isColumnsLoading:ee,isColumnsFetching:Q,isColumnsError:oe,refetchColumns:te}=TU(e);R.useEffect(()=>{(j==="S3"||j==="API")&&(g(""),m(""),p(""),j==="API"&&b("api"))},[j,b,g,m,p]);const ce=(k==null?void 0:k.type)==="API"?(Pe=k==null?void 0:k.type)==null?void 0:Pe.toLowerCase():d||"",ue=F?"":u||"";function Re(ge){b(ge),y(void 0),l||(n.setQueryData(s,null),n.removeQueries({queryKey:s,exact:!0}))}function ve(ge){m(ge),b("")}function we(ge){g(ge==="none"?"":ge),m(""),b(""),ge!=="none"&&ge!==""&&p("")}function De(ge){h(ge)}function Ye(ge){p(ge==="none"?"":ge),ge!=="none"&&ge!==""&&g("")}T&&((Ue=T==null?void 0:T.databases)==null?void 0:Ue.length)>0,A&&((jt=A==null?void 0:A.schemas)==null?void 0:jt.length)>0;const _t=_==null?void 0:_.connections.map(ge=>({id:ge.id,name:ge.name,type:ge.type})),me=(kn=M==null?void 0:M.datamodels)==null?void 0:kn.map(ge=>({id:ge.id,name:ge.name})),je=T==null?void 0:T.databases.map(ge=>({id:ge.database_name,name:ge.database_name})),Ie=A==null?void 0:A.schemas.map(ge=>({id:ge.schema_name,name:ge.schema_name})),ne=V==null?void 0:V.tables.map(ge=>({id:ge.table_name,name:ge.table_name})),le=(gn=M==null?void 0:M.datamodels.find(ge=>ge.id===a))==null?void 0:gn.name,ke=Zj({schemaName:ue,tableName:ce,modelName:le,connectionType:j,databaseName:c||""});return{connectionItems:_t,selectedConnectionId:o,selectedConnection:k,isConnectionsLoading:E,isConnectionsError:C,modelItems:me,selectedDatamodelId:a,selectedDatamodelName:le,isModelsLoading:I,isModelsError:D,selectedDatabaseName:c,databaseItems:je,isDatabasesLoadingOrFetching:O||$,isDatabaseError:B,schemaItems:Ie,selectedSchemaName:u,isSchemaLoadingOrFetching:W||L,isSchemaError:P,tableItems:ne,selectedTableName:d,isTableLoadingOrFetching:G||q,isTableError:Y,columns:Z,isColumnsLoadingOrFetching:ee||Q,isColumnsError:oe,isNonDbConnection:F,connectionType:j,tableName:ce,formattedTableName:ke,schemaName:ue,refetchConnections:S,refetchModels:N,refetchDatabases:z,refetchSchemas:H,refetchTables:K,refetchColumns:te,handleConnectionChange:De,handleDatamodelChange:Ye,handleDatabaseChange:we,handleSchemaChange:ve,handleTableChange:Re}}function C4e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function yj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function vj(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?yj(Object(n),!0).forEach(function(r){C4e(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yj(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function S4e(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function E4e(e,t){if(e==null)return{};var n=S4e(e,t),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function _4e(e,t){return R4e(e)||k4e(e,t)||N4e(e,t)||M4e()}function R4e(e){if(Array.isArray(e))return e}function k4e(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var n=[],r=!0,o=!1,i=void 0;try{for(var s=e[Symbol.iterator](),a;!(r=(a=s.next()).done)&&(n.push(a.value),!(t&&n.length===t));r=!0);}catch(l){o=!0,i=l}finally{try{!r&&s.return!=null&&s.return()}finally{if(o)throw i}}return n}}function N4e(e,t){if(e){if(typeof e=="string")return xj(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return xj(e,t)}}function xj(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function M4e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
629
629
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function P4e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Cj(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?wj(Object(n),!0).forEach(function(r){P4e(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wj(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function D4e(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){return t.reduceRight(function(o,i){return i(o)},r)}}function yf(e){return function t(){for(var n=this,r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];return t.apply(n,[].concat(o,a))}}}function x0(e){return{}.toString.call(e).includes("Object")}function I4e(e){return!Object.keys(e).length}function Vh(e){return typeof e=="function"}function A4e(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function T4e(e,t){return x0(t)||da("changeType"),Object.keys(t).some(function(n){return!A4e(e,n)})&&da("changeField"),t}function j4e(e){Vh(e)||da("selectorType")}function O4e(e){Vh(e)||x0(e)||da("handlerType"),x0(e)&&Object.values(e).some(function(t){return!Vh(t)})&&da("handlersType")}function F4e(e){e||da("initialIsRequired"),x0(e)||da("initialType"),I4e(e)&&da("initialContent")}function L4e(e,t){throw new Error(e[t]||e.default)}var $4e={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},da=yf(L4e)($4e),Cg={changes:T4e,selector:j4e,handler:O4e,initial:F4e};function z4e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Cg.initial(e),Cg.handler(t);var n={current:e},r=yf(H4e)(n,t),o=yf(V4e)(n),i=yf(Cg.changes)(e),s=yf(B4e)(n);function a(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Cg.selector(c),c(n.current)}function l(c){D4e(r,o,i,s)(c)}return[a,l]}function B4e(e,t){return Vh(t)?t(e.current):t}function V4e(e,t){return e.current=Cj(Cj({},e.current),t),t}function H4e(e,t,n){return Vh(t)?t(e.current):Object.keys(n).forEach(function(r){var o;return(o=t[r])===null||o===void 0?void 0:o.call(t,e.current[r])}),n}var W4e={create:z4e},U4e={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs"}};function q4e(e){return function t(){for(var n=this,r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];return t.apply(n,[].concat(o,a))}}}function G4e(e){return{}.toString.call(e).includes("Object")}function Y4e(e){return e||Sj("configIsRequired"),G4e(e)||Sj("configType"),e.urls?(K4e(),{paths:{vs:e.urls.monacoBase}}):e}function K4e(){console.warn(LU.deprecation)}function X4e(e,t){throw new Error(e[t]||e.default)}var LU={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
630
630
  You are using deprecated way of configuration.