react-semaphor 0.0.537 → 0.0.539
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{dashboard-plus-DVDMguwO.js → dashboard-plus-BKpXOKRS.js} +2623 -2622
- package/dist/chunks/{dashboard-plus-DYytGv__.js → dashboard-plus-NfeI9KXl.js} +10 -10
- package/dist/chunks/{index-Cp70TiL_.js → index-C4HtFfvy.js} +2 -2
- package/dist/chunks/{index-C7jXeSfd.js → index-uzOCVajs.js} +2 -2
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +1 -1
- package/package.json +1 -1
|
@@ -487,7 +487,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
487
487
|
To pick up a draggable item, press the space bar.
|
|
488
488
|
While dragging, use the arrow keys to move the item.
|
|
489
489
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
490
|
-
`},nne={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 rne(e){let{announcements:t=nne,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=tne}=e;const{announce:i,announcement:s}=Zte(),a=Sp("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(Xte,{id:r,value:o.draggable}),R.createElement(Qte,{id:a,announcement:s}));return n?an.createPortal(u,n):u}var An;(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"})(An||(An={}));function _b(){}function bh(e,t){return R.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function F_(){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 Zo=Object.freeze({x:0,y:0});function w4(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function one(e,t){const n=Eb(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 C4(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function ine(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function JM(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 eD(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 $_=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=eD(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=w4(eD(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(C4)},sne=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=JM(t),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=JM(l),u=o.reduce((h,p,g)=>h+w4(c[g],p),0),d=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:d}})}}return i.sort(C4)};function ane(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 lne=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=ane(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(ine)};function cne(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function E4(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Zo}function une(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 dne=une(1);function _4(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 fne(e,t,n){const r=_4(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 hne={ignoreTransform:!1};function wd(e,t){t===void 0&&(t=hne);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=_r(e).getComputedStyle(e);c&&(n=fne(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 tD(e){return wd(e,{ignoreTransform:!0})}function pne(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function mne(e,t){return t===void 0&&(t=_r(e).getComputedStyle(e)),t.position==="fixed"}function gne(e,t){t===void 0&&(t=_r(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 py(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(O_(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!wp(o)||y4(o)||n.includes(o))return n;const i=_r(e).getComputedStyle(o);return o!==e&&gne(o,i)&&n.push(o),mne(o,i)?n:r(o.parentNode)}return e?r(e):n}function R4(e){const[t]=py(e,1);return t??null}function Rx(e){return!dy||!e?null:vd(e)?e:j_(e)?O_(e)||e===xd(e).scrollingElement?window:wp(e)?e:null:null}function k4(e){return vd(e)?e.scrollX:e.scrollLeft}function N4(e){return vd(e)?e.scrollY:e.scrollTop}function bC(e){return{x:k4(e),y:N4(e)}}var $n;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})($n||($n={}));function M4(e){return!dy||!e?!1:e===document.scrollingElement}function D4(e){const t={x:0,y:0},n=M4(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 bne={x:.2,y:.2};function yne(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=bne);const{isTop:c,isBottom:u,isLeft:d,isRight:h}=D4(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=$n.Backward,g.y=r*Math.abs((t.top+m.height-i)/m.height)):!u&&l>=t.bottom-m.height&&(p.y=$n.Forward,g.y=r*Math.abs((t.bottom-m.height-l)/m.height)),!h&&a>=t.right-m.width?(p.x=$n.Forward,g.x=r*Math.abs((t.right-m.width-a)/m.width)):!d&&s<=t.left+m.width&&(p.x=$n.Backward,g.x=r*Math.abs((t.left+m.width-s)/m.width)),{direction:p,speed:g}}function vne(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)=>bu(t,bC(n)),Zo)}function xne(e){return e.reduce((t,n)=>t+k4(n),0)}function wne(e){return e.reduce((t,n)=>t+N4(n),0)}function A4(e,t){if(t===void 0&&(t=wd),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);R4(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Cne=[["x",["left","right"],xne],["y",["top","bottom"],wne]];class L_{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=py(n),o=P4(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of Cne)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 Pf{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 Sne(e){const{EventTarget:t}=_r(e);return e instanceof t?e:xd(e)}function kx(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 So;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(So||(So={}));function nD(e){e.preventDefault()}function Ene(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 I4={start:[ht.Space,ht.Enter],cancel:[ht.Esc],end:[ht.Space,ht.Enter,ht.Tab]},_ne=(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 Ep{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 Pf(xd(n)),this.windowListeners=new Pf(_r(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(So.Resize,this.handleCancel),this.windowListeners.add(So.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(So.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&A4(r),n(Zo)}handleKeyDown(t){if(hy(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=I4,coordinateGetter:s=_ne,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}:Zo;this.referenceCoordinates||(this.referenceCoordinates=u);const d=s(t,{active:n,context:r.current,currentCoordinates:u});if(d){const h=gh(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:C,maxScroll:_,minScroll:S}=D4(m),E=vne(m),k={x:Math.min(b===ht.Right?E.right-E.width/2:E.right,Math.max(b===ht.Right?E.left:E.left+E.width/2,d.x)),y:Math.min(b===ht.Down?E.bottom-E.height/2:E.bottom,Math.max(b===ht.Down?E.top:E.top+E.height/2,d.y))},N=b===ht.Right&&!v||b===ht.Left&&!x,M=b===ht.Down&&!C||b===ht.Up&&!y;if(N&&k.x!==d.x){const I=m.scrollLeft+h.x,P=b===ht.Right&&I<=_.x||b===ht.Left&&I>=S.x;if(P&&!h.y){m.scrollTo({left:I,behavior:a});return}P?p.x=m.scrollLeft-I:p.x=b===ht.Right?m.scrollLeft-_.x:m.scrollLeft-S.x,p.x&&m.scrollBy({left:-p.x,behavior:a});break}else if(M&&k.y!==d.y){const I=m.scrollTop+h.y,P=b===ht.Down&&I<=_.y||b===ht.Up&&I>=S.y;if(P&&!h.x){m.scrollTo({top:I,behavior:a});return}P?p.y=m.scrollTop-I:p.y=b===ht.Down?m.scrollTop-_.y:m.scrollTop-S.y,p.y&&m.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(t,bu(gh(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()}}Ep.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=I4,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 rD(e){return!!(e&&"distance"in e)}function oD(e){return!!(e&&"delay"in e)}class z_{constructor(t,n,r){var o;r===void 0&&(r=Sne(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=xd(s),this.documentListeners=new Pf(this.document),this.listeners=new Pf(r),this.windowListeners=new Pf(_r(s)),this.initialCoordinates=(o=Eb(i))!=null?o:Zo,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(So.Resize,this.handleCancel),this.windowListeners.add(So.DragStart,nD),this.windowListeners.add(So.VisibilityChange,this.handleCancel),this.windowListeners.add(So.ContextMenu,nD),this.documentListeners.add(So.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(oD(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(rD(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(So.Click,Ene,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(So.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=Eb(t))!=null?n:Zo,c=gh(o,l);if(!r&&a){if(rD(a)){if(a.tolerance!=null&&kx(c,a.tolerance))return this.handleCancel();if(kx(c,a.distance))return this.handleStart()}if(oD(a)&&kx(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 Rne={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class _p extends z_{constructor(t){const{event:n}=t,r=xd(n.target);super(t,Rne,r)}}_p.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 kne={move:{name:"mousemove"},end:{name:"mouseup"}};var yC;(function(e){e[e.RightClick=2]="RightClick"})(yC||(yC={}));class T4 extends z_{constructor(t){super(t,kne,xd(t.event.target))}}T4.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===yC.RightClick?!1:(r==null||r({event:n}),!0)}}];const Nx={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Nne extends z_{constructor(t){super(t,Nx)}static setup(){return window.addEventListener(Nx.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Nx.move.name,t)};function t(){}}}Nne.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 Af;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Af||(Af={}));var Rb;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Rb||(Rb={}));function Mne(e){let{acceleration:t,activator:n=Af.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=Rb.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:h}=e;const p=Pne({delta:d,disabled:!i}),[g,m]=Ute(),b=R.useRef({x:0,y:0}),y=R.useRef({x:0,y:0}),v=R.useMemo(()=>{switch(n){case Af.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Af.DraggableRect:return o}},[n,o,l]),x=R.useRef(null),C=R.useCallback(()=>{const S=x.current;if(!S)return;const E=b.current.x*y.current.x,k=b.current.y*y.current.y;S.scrollBy(E,k)},[]),_=R.useMemo(()=>a===Rb.TreeOrder?[...c].reverse():c,[a,c]);R.useEffect(()=>{if(!i||!c.length||!v){m();return}for(const S of _){if((r==null?void 0:r(S))===!1)continue;const E=c.indexOf(S),k=u[E];if(!k)continue;const{direction:N,speed:M}=yne(S,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=S,g(C,s),b.current=M,y.current=N;return}}b.current={x:0,y:0},y.current={x:0,y:0},m()},[t,C,r,m,i,s,JSON.stringify(v),JSON.stringify(p),g,c,_,u,JSON.stringify(h)])}const Dne={x:{[$n.Backward]:!1,[$n.Forward]:!1},y:{[$n.Backward]:!1,[$n.Forward]:!1}};function Pne(e){let{delta:t,disabled:n}=e;const r=Sb(t);return Cp(o=>{if(n||!r||!o)return Dne;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[$n.Backward]:o.x[$n.Backward]||i.x===-1,[$n.Forward]:o.x[$n.Forward]||i.x===1},y:{[$n.Backward]:o.y[$n.Backward]||i.y===-1,[$n.Forward]:o.y[$n.Forward]||i.y===1}}},[n,t,r])}function Ane(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Cp(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function Ine(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 yh;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(yh||(yh={}));var vC;(function(e){e.Optimized="optimized"})(vC||(vC={}));const iD=new Map;function Tne(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=mh(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=Cp(y=>{if(d&&!n)return iD;if(!y||y===iD||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 C=x.node.current,_=C?new L_(l(C),C):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 yh.Always:return!1;case yh.BeforeDragging:return n;default:return!n}}}function B_(e,t){return Cp(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function jne(e,t){return B_(e,t)}function One(e){let{callback:t,disabled:n}=e;const r=fy(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 my(e){let{callback:t,disabled:n}=e;const r=fy(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 Fne(e){return new L_(wd(e),e)}function sD(e,t,n){t===void 0&&(t=Fne);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=One({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=my({callback:i});return Qo(()=>{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 $ne(e){const t=B_(e);return E4(e,t)}const aD=[];function Lne(e){const t=R.useRef(e),n=Cp(r=>e?r&&r!==aD&&e&&t.current&&e.parentNode===t.current.parentNode?r:py(e):aD,[e]);return R.useEffect(()=>{t.current=e},[e]),n}function zne(e){const[t,n]=R.useState(null),r=R.useRef(e),o=R.useCallback(i=>{const s=Rx(i.target);s&&n(a=>a?(a.set(s,bC(s)),new Map(a)):null)},[]);return R.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const c=Rx(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,bC(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=Rx(l);c==null||c.removeEventListener("scroll",o)})}},[o,e]),R.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>bu(i,s),Zo):P4(e):Zo,[e,t])}function lD(e,t){t===void 0&&(t=[]);const n=R.useRef(null);return R.useEffect(()=>{n.current=null},t),R.useEffect(()=>{const r=e!==Zo;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?gh(e,n.current):Zo}function Bne(e){R.useEffect(()=>{if(!dy)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 Vne(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 j4(e){return R.useMemo(()=>e?pne(e):null,[e])}const cD=[];function Hne(e,t){t===void 0&&(t=wd);const[n]=e,r=j4(n?_r(n):null),[o,i]=R.useState(cD);function s(){i(()=>e.length?e.map(l=>M4(l)?r:new L_(t(l),l)):cD)}const a=my({callback:s});return Qo(()=>{a==null||a.disconnect(),s(),e.forEach(l=>a==null?void 0:a.observe(l))},[e]),o}function O4(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return wp(t)?t:e}function Wne(e){let{measure:t}=e;const[n,r]=R.useState(null),o=R.useCallback(c=>{for(const{target:u}of c)if(wp(u)){r(d=>{const h=t(u);return d?{...d,width:h.width,height:h.height}:h});break}},[t]),i=my({callback:o}),s=R.useCallback(c=>{const u=O4(c);i==null||i.disconnect(),u&&(i==null||i.observe(u)),r(u?t(u):null)},[t,i]),[a,l]=Cb(s);return R.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const Une=[{sensor:_p,options:{}},{sensor:Ep,options:{}}],qne={current:{}},Bg={draggable:{measure:tD},droppable:{measure:tD,strategy:yh.WhileDragging,frequency:vC.Optimized},dragOverlay:{measure:wd}};class If 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 Gne={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new If,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:_b},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Bg,measureDroppableContainers:_b,windowRect:null,measuringScheduled:!1},F4={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:_b,draggableNodes:new Map,over:null,measureDroppableContainers:_b},Rp=R.createContext(F4),$4=R.createContext(Gne);function Yne(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new If}}}function Kne(e,t){switch(t.type){case An.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case An.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 An.DragEnd:case An.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case An.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new If(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case An.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 If(e.droppable.containers);return s.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case An.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new If(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Xne(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=R.useContext(Rp),i=Sb(r),s=Sb(n==null?void 0:n.id);return R.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!hy(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=Yte(u);if(d){d.focus();break}}})}},[r,t,o,s,i]),null}function L4(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function Qne(e){return R.useMemo(()=>({draggable:{...Bg.draggable,...e==null?void 0:e.draggable},droppable:{...Bg.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Bg.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 Zne(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;Qo(()=>{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=E4(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=R4(c);h&&h.scrollBy({top:d.y,left:d.x})}},[t,s,a,r,n])}const gy=R.createContext({...Zo,scaleX:1,scaleY:1});var Xs;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Xs||(Xs={}));const V_=R.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=Une,collisionDetection:d=lne,measuring:h,modifiers:p,...g}=t;const m=R.useReducer(Kne,void 0,Yne),[b,y]=m,[v,x]=ene(),[C,_]=R.useState(Xs.Uninitialized),S=C===Xs.Initialized,{draggable:{active:E,nodes:k,translate:N},droppable:{containers:M}}=b,I=E!=null?k.get(E):null,P=R.useRef({initial:null,translated:null}),j=R.useMemo(()=>{var cn;return E!=null?{id:E,data:(cn=I==null?void 0:I.data)!=null?cn:qne,rect:P}:null},[E,I]),F=R.useRef(null),[T,O]=R.useState(null),[L,B]=R.useState(null),z=mh(g,Object.values(g)),A=Sp("DndDescribedBy",s),W=R.useMemo(()=>M.getEnabled(),[M]),$=Qne(h),{droppableRects:D,measureDroppableContainers:H,measuringScheduled:V}=Tne(W,{dragging:S,dependencies:[N.x,N.y],config:$.droppable}),G=Ane(k,E),q=R.useMemo(()=>L?Eb(L):null,[L]),K=Ki(),Y=jne(G,$.draggable.measure);Zne({activeNode:E!=null?k.get(E):null,config:K.layoutShiftCompensation,initialRect:Y,measure:$.draggable.measure});const Q=sD(G,$.draggable.measure,Y),ne=sD(G?G.parentElement:null),Z=R.useRef({activatorEvent:null,active:null,activeNode:G,collisionRect:null,collisions:null,droppableRects:D,draggableNodes:k,draggingNode:null,draggingNodeRect:null,droppableContainers:M,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ie=M.getNodeFor((n=Z.current.over)==null?void 0:n.id),te=Wne({measure:$.dragOverlay.measure}),ce=(r=te.nodeRef.current)!=null?r:G,de=S?(o=te.rect)!=null?o:Q:null,ke=!!(te.nodeRef.current&&te.rect),we=$ne(ke?null:Q),Ce=j4(ce?_r(ce):null),Pe=Lne(S?ie??G:null),Ye=Hne(Pe),_t=L4(p,{transform:{x:N.x-we.x,y:N.y-we.y,scaleX:1,scaleY:1},activatorEvent:L,active:j,activeNodeRect:Q,containerNodeRect:ne,draggingNodeRect:de,over:Z.current.over,overlayNodeRect:te.rect,scrollableAncestors:Pe,scrollableAncestorRects:Ye,windowRect:Ce}),ge=q?bu(q,N):null,je=zne(Pe),Ae=lD(je),ee=lD(je,[Q]),le=bu(_t,Ae),Re=de?dne(de,_t):null,De=j&&Re?d({active:j,collisionRect:Re,droppableRects:D,droppableContainers:W,pointerCoordinates:ge}):null,Ue=S4(De,"id"),[jt,Pn]=R.useState(null),vn=ke?_t:bu(_t,ee),ye=cne(vn,(i=jt==null?void 0:jt.rect)!=null?i:null,Q),xn=R.useRef(null),Ot=R.useCallback((cn,Rt)=>{let{sensor:Vn,options:Ie}=Rt;if(F.current==null)return;const qe=k.get(F.current);if(!qe)return;const rt=cn.nativeEvent,nn=new Vn({active:F.current,activeNode:qe,event:rt,options:Ie,context:Z,onAbort($t){if(!k.get($t))return;const{onDragAbort:rn}=z.current,wn={id:$t};rn==null||rn(wn),v({type:"onDragAbort",event:wn})},onPending($t,Fn,rn,wn){if(!k.get($t))return;const{onDragPending:bo}=z.current,li={id:$t,constraint:Fn,initialCoordinates:rn,offset:wn};bo==null||bo(li),v({type:"onDragPending",event:li})},onStart($t){const Fn=F.current;if(Fn==null)return;const rn=k.get(Fn);if(!rn)return;const{onDragStart:wn}=z.current,Xa={activatorEvent:rt,active:{id:Fn,data:rn.data,rect:P}};an.unstable_batchedUpdates(()=>{wn==null||wn(Xa),_(Xs.Initializing),y({type:An.DragStart,initialCoordinates:$t,active:Fn}),v({type:"onDragStart",event:Xa}),O(xn.current),B(rt)})},onMove($t){y({type:An.DragMove,coordinates:$t})},onEnd:Ft(An.DragEnd),onCancel:Ft(An.DragCancel)});xn.current=nn;function Ft($t){return async function(){const{active:rn,collisions:wn,over:Xa,scrollAdjustedTranslate:bo}=Z.current;let li=null;if(rn&&bo){const{cancelDrop:Qa}=z.current;li={activatorEvent:rt,active:rn,collisions:wn,delta:bo,over:Xa},$t===An.DragEnd&&typeof Qa=="function"&&await Promise.resolve(Qa(li))&&($t=An.DragCancel)}F.current=null,an.unstable_batchedUpdates(()=>{y({type:$t}),_(Xs.Uninitialized),Pn(null),O(null),B(null),xn.current=null;const Qa=$t===An.DragEnd?"onDragEnd":"onDragCancel";if(li){const Vd=z.current[Qa];Vd==null||Vd(li),v({type:Qa,event:li})}})}}},[k]),go=R.useCallback((cn,Rt)=>(Vn,Ie)=>{const qe=Vn.nativeEvent,rt=k.get(Ie);if(F.current!==null||!rt||qe.dndKit||qe.defaultPrevented)return;const nn={active:rt};cn(Vn,Rt.options,nn)===!0&&(qe.dndKit={capturedBy:Rt.sensor},F.current=Ie,Ot(Vn,Rt))},[k,Ot]),Bn=Ine(u,go);Bne(u),Qo(()=>{Q&&C===Xs.Initializing&&_(Xs.Initialized)},[Q,C]),R.useEffect(()=>{const{onDragMove:cn}=z.current,{active:Rt,activatorEvent:Vn,collisions:Ie,over:qe}=Z.current;if(!Rt||!Vn)return;const rt={active:Rt,activatorEvent:Vn,collisions:Ie,delta:{x:le.x,y:le.y},over:qe};an.unstable_batchedUpdates(()=>{cn==null||cn(rt),v({type:"onDragMove",event:rt})})},[le.x,le.y]),R.useEffect(()=>{const{active:cn,activatorEvent:Rt,collisions:Vn,droppableContainers:Ie,scrollAdjustedTranslate:qe}=Z.current;if(!cn||F.current==null||!Rt||!qe)return;const{onDragOver:rt}=z.current,nn=Ie.get(Ue),Ft=nn&&nn.rect.current?{id:nn.id,rect:nn.rect.current,data:nn.data,disabled:nn.disabled}:null,$t={active:cn,activatorEvent:Rt,collisions:Vn,delta:{x:qe.x,y:qe.y},over:Ft};an.unstable_batchedUpdates(()=>{Pn(Ft),rt==null||rt($t),v({type:"onDragOver",event:$t})})},[Ue]),Qo(()=>{Z.current={activatorEvent:L,active:j,activeNode:G,collisionRect:Re,collisions:De,droppableRects:D,draggableNodes:k,draggingNode:ce,draggingNodeRect:de,droppableContainers:M,over:jt,scrollableAncestors:Pe,scrollAdjustedTranslate:le},P.current={initial:de,translated:Re}},[j,G,De,Re,k,ce,de,D,M,jt,Pe,le]),Mne({...K,delta:N,draggingRect:Re,pointerCoordinates:ge,scrollableAncestors:Pe,scrollableAncestorRects:Ye});const Tc=R.useMemo(()=>({active:j,activeNode:G,activeNodeRect:Q,activatorEvent:L,collisions:De,containerNodeRect:ne,dragOverlay:te,draggableNodes:k,droppableContainers:M,droppableRects:D,over:jt,measureDroppableContainers:H,scrollableAncestors:Pe,scrollableAncestorRects:Ye,measuringConfiguration:$,measuringScheduled:V,windowRect:Ce}),[j,G,Q,L,De,ne,te,k,M,D,jt,H,Pe,Ye,$,V,Ce]),Ka=R.useMemo(()=>({activatorEvent:L,activators:Bn,active:j,activeNodeRect:Q,ariaDescribedById:{draggable:A},dispatch:y,draggableNodes:k,over:jt,measureDroppableContainers:H}),[L,Bn,j,Q,y,A,k,jt,H]);return R.createElement(x4.Provider,{value:x},R.createElement(Rp.Provider,{value:Ka},R.createElement($4.Provider,{value:Tc},R.createElement(gy.Provider,{value:ye},c)),R.createElement(Xne,{disabled:(a==null?void 0:a.restoreFocus)===!1})),R.createElement(rne,{...a,hiddenTextDescribedById:A}));function Ki(){const cn=(T==null?void 0:T.autoScrollEnabled)===!1,Rt=typeof l=="object"?l.enabled===!1:l===!1,Vn=S&&!cn&&!Rt;return typeof l=="object"?{...l,enabled:Vn}:{enabled:Vn}}}),Jne=R.createContext(null),uD="button",ere="Draggable";function z4(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=Sp(ere),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:h}=R.useContext(Rp),{role:p=uD,roleDescription:g="draggable",tabIndex:m=0}=o??{},b=(l==null?void 0:l.id)===t,y=R.useContext(b?gy:Jne),[v,x]=Cb(),[C,_]=Cb(),S=Vne(s,t),E=mh(n);Qo(()=>(d.set(t,{id:t,key:i,node:v,activatorNode:C,data:E}),()=>{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===uD?!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:S,node:v,over:h,setNodeRef:x,setActivatorNodeRef:_,transform:y}}function B4(){return R.useContext($4)}const tre="Droppable",nre={timeout:25};function V4(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=Sp(tre),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=R.useContext(Rp),u=R.useRef({disabled:n}),d=R.useRef(!1),h=R.useRef(null),p=R.useRef(null),{disabled:g,updateMeasurementsFor:m,timeout:b}={...nre,...o},y=mh(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=my({callback:v,disabled:g||!s}),C=R.useCallback((k,N)=>{x&&(N&&(x.unobserve(N),d.current=!1),k&&x.observe(k))},[x]),[_,S]=Cb(C),E=mh(t);return R.useEffect(()=>{!x||!_.current||(x.disconnect(),d.current=!1,x.observe(_.current))},[_,x]),R.useEffect(()=>(a({type:An.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:h,data:E}}),()=>a({type:An.UnregisterDroppable,key:i,id:r})),[r]),R.useEffect(()=>{n!==u.current.disabled&&(a({type:An.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:S}}function rre(e){let{animation:t,children:n}=e;const[r,o]=R.useState(null),[i,s]=R.useState(null),a=Sb(n);return!n&&!r&&a&&o(a),Qo(()=>{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 ore={x:0,y:0,scaleX:1,scaleY:1};function ire(e){let{children:t}=e;return R.createElement(Rp.Provider,{value:F4},R.createElement(gy.Provider,{value:ore},t))}const sre={position:"fixed",touchAction:"none"},are=e=>hy(e)?"transform 250ms ease":void 0,lre=R.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=are}=e;if(!a)return null;const d=o?c:{...c,scaleX:1,scaleY:1},h={...sre,width:a.width,height:a.height,top:a.top,left:a.left,transform:Ai.Transform.toString(d),transformOrigin:o&&r?one(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return R.createElement(n,{className:s,style:h,ref:t},i)}),cre=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)}},ure=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Ai.Transform.toString(t)},{transform:Ai.Transform.toString(n)}]},dre={duration:250,easing:"ease",keyframes:ure,sideEffects:cre({styles:{active:{opacity:"0"}}})};function fre(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return fy((i,s)=>{if(t===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=O4(s);if(!c)return;const{transform:u}=_r(s).getComputedStyle(s),d=_4(u);if(!d)return;const h=typeof t=="function"?t:hre(t);return A4(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 hre(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...dre,...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 dD=0;function pre(e){return R.useMemo(()=>{if(e!=null)return dD++,dD},[e])}const H4=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:C,windowRect:_}=B4(),S=R.useContext(gy),E=pre(d==null?void 0:d.id),k=L4(s,{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:b.rect,over:y,overlayNodeRect:b.rect,scrollableAncestors:x,scrollableAncestorRects:C,transform:S,windowRect:_}),N=B_(h),M=fre({config:r,draggableNodes:g,droppableContainers:m,measuringConfiguration:v}),I=N?b.setRef:void 0;return R.createElement(ire,null,R.createElement(rre,{animation:M},d&&E?R.createElement(lre,{key:E,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 kp(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function mre(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Am(e){return e!==null&&e>=0}function gre(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 bre(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Im={scaleX:1,scaleY:1},yre=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=vre(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,...Im}:null}return s>o&&s<=i?{x:-a.width-l,y:0,...Im}:s<o&&s>=i?{x:a.width+l,y:0,...Im}:{x:0,y:0,...Im}};function vre(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 W4=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=kp(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}},Tm={scaleX:1,scaleY:1},U4=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,...Tm}:null}const l=xre(i,o,n);return o>n&&o<=s?{x:0,y:-a.height-l,...Tm}:o<n&&o>=s?{x:0,y:a.height+l,...Tm}:{x:0,y:0,...Tm}};function xre(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 q4="Sortable",G4=R.createContext({activeIndex:-1,containerId:q4,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:W4,disabled:{draggable:!1,droppable:!1}});function H_(e){let{children:t,id:n,items:r,strategy:o=W4,disabled:i=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=B4(),d=Sp(q4,n),h=a.rect!==null,p=R.useMemo(()=>r.map(S=>typeof S=="object"&&"id"in S?S.id:S),[r]),g=s!=null,m=s?p.indexOf(s.id):-1,b=c?p.indexOf(c.id):-1,y=R.useRef(p),v=!gre(p,y.current),x=b!==-1&&m===-1||v,C=bre(i);Qo(()=>{v&&g&&u(p)},[v,p,g,u]),R.useEffect(()=>{y.current=p},[p]);const _=R.useMemo(()=>({activeIndex:m,containerId:d,disabled:C,disableTransforms:x,items:p,overIndex:b,useDragOverlay:h,sortedRects:mre(p,l),strategy:o}),[m,d,C.draggable,C.droppable,x,p,b,l,h,o]);return R.createElement(G4.Provider,{value:_},t)}const wre=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return kp(n,r,o).indexOf(t)},Cre=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},Sre={duration:200,easing:"ease"},Y4="transform",Ere=Ai.Transition.toString({property:Y4,duration:0,easing:"linear"}),_re={roleDescription:"sortable"};function Rre(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=R.useState(null),a=R.useRef(n);return Qo(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=wd(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 W_(e){let{animateLayoutChanges:t=Cre,attributes:n,disabled:r,data:o,getNewIndex:i=wre,id:s,strategy:a,resizeObserverConfig:l,transition:c=Sre}=e;const{items:u,containerId:d,activeIndex:h,disabled:p,disableTransforms:g,sortedRects:m,overIndex:b,useDragOverlay:y,strategy:v}=R.useContext(G4),x=kre(r,p),C=u.indexOf(s),_=R.useMemo(()=>({sortable:{containerId:d,index:C,items:u},...o}),[d,o,C,u]),S=R.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:E,node:k,isOver:N,setNodeRef:M}=V4({id:s,data:_,disabled:x.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...l}}),{active:I,activatorEvent:P,activeNodeRect:j,attributes:F,setNodeRef:T,listeners:O,isDragging:L,over:B,setActivatorNodeRef:z,transform:A}=z4({id:s,data:_,attributes:{..._re,...n},disabled:x.draggable}),W=Wte(M,T),$=!!I,D=$&&!g&&Am(h)&&Am(b),H=!y&&L,V=H&&D?A:null,q=D?V??(a??v)({rects:m,activeNodeRect:j,activeIndex:h,overIndex:b,index:C}):null,K=Am(h)&&Am(b)?i({id:s,items:u,activeIndex:h,overIndex:b}):C,Y=I==null?void 0:I.id,Q=R.useRef({activeId:Y,items:u,newIndex:K,containerId:d}),ne=u!==Q.current.items,Z=t({active:I,containerId:d,isDragging:L,isSorting:$,id:s,index:C,items:u,newIndex:Q.current.newIndex,previousItems:Q.current.items,previousContainerId:Q.current.containerId,transition:c,wasDragging:Q.current.activeId!=null}),ie=Rre({disabled:!Z,index:C,node:k,rect:E});return R.useEffect(()=>{$&&Q.current.newIndex!==K&&(Q.current.newIndex=K),d!==Q.current.containerId&&(Q.current.containerId=d),u!==Q.current.items&&(Q.current.items=u)},[$,K,d,u]),R.useEffect(()=>{if(Y===Q.current.activeId)return;if(Y!=null&&Q.current.activeId==null){Q.current.activeId=Y;return}const ce=setTimeout(()=>{Q.current.activeId=Y},50);return()=>clearTimeout(ce)},[Y]),{active:I,activeIndex:h,attributes:F,data:_,rect:E,index:C,newIndex:K,items:u,isOver:N,isSorting:$,isDragging:L,listeners:O,node:k,overIndex:b,over:B,setNodeRef:W,setActivatorNodeRef:z,setDroppableNodeRef:M,setDraggableNodeRef:T,transform:ie??q,transition:te()};function te(){if(ie||ne&&Q.current.newIndex===C)return Ere;if(!(H&&!hy(P)||!c)&&($||Z))return Ai.Transition.toString({...c,property:Y4})}}function kre(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 kb(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 Nre=[ht.Down,ht.Right,ht.Up,ht.Left],U_=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:s,scrollableAncestors:a}}=t;if(Nre.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=sne({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=py(g).some((S,E)=>a[E]!==S),y=K4(d,h),v=Mre(d,h),x=b||!y?{x:0,y:0}:{x:v?r.width-p.width:0,y:v?r.height-p.height:0},C={x:p.left,y:p.top};return x.x&&x.y?C:gh(C,x)}}}};function K4(e,t){return!kb(e)||!kb(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Mre(e,t){return!kb(e)||!kb(t)||!K4(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Dre(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,C)=>C===m?{...x,...b}:x);c(g,{steps:v})}},setDefaultHierarchy:g=>{t(e.map(m=>({...m,default:m.id===g})))}}}function Pre({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 Are(e,t=globalThis==null?void 0:globalThis.document){const n=In(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 Ire="DismissableLayer",xC="dismissableLayer.update",Tre="dismissableLayer.pointerDownOutside",jre="dismissableLayer.focusOutside",fD,X4=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_c=w.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...l}=e,c=w.useContext(X4),[u,d]=w.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=w.useState({}),g=He(t,E=>d(E)),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,C=v>=y,_=$re(E=>{const k=E.target,N=[...c.branches].some(M=>M.contains(k));!C||N||(o==null||o(E),s==null||s(E),E.defaultPrevented||a==null||a())},h),S=Lre(E=>{const k=E.target;[...c.branches].some(M=>M.contains(k))||(i==null||i(E),s==null||s(E),E.defaultPrevented||a==null||a())},h);return Are(E=>{v===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),w.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(fD=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),hD(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=fD)}},[u,h,n,c]),w.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),hD())},[u,c]),w.useEffect(()=>{const E=()=>p({});return document.addEventListener(xC,E),()=>document.removeEventListener(xC,E)},[]),f.jsx(_e.div,{...l,ref:g,style:{pointerEvents:x?C?"auto":"none":void 0,...e.style},onFocusCapture:he(e.onFocusCapture,S.onFocusCapture),onBlurCapture:he(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:he(e.onPointerDownCapture,_.onPointerDownCapture)})});_c.displayName=Ire;var Ore="DismissableLayerBranch",Fre=w.forwardRef((e,t)=>{const n=w.useContext(X4),r=w.useRef(null),o=He(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})});Fre.displayName=Ore;function $re(e,t=globalThis==null?void 0:globalThis.document){const n=In(e),r=w.useRef(!1),o=w.useRef(()=>{});return w.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let l=function(){Q4(Tre,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 Lre(e,t=globalThis==null?void 0:globalThis.document){const n=In(e),r=w.useRef(!1);return w.useEffect(()=>{const o=i=>{i.target&&!r.current&&Q4(jre,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 hD(){const e=new CustomEvent(xC);document.dispatchEvent(e)}function Q4(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?ZO(o,i):o.dispatchEvent(i)}var Mx=0;function by(){w.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??pD()),document.body.insertAdjacentElement("beforeend",e[1]??pD()),Mx++,()=>{Mx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Mx--}},[])}function pD(){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 Dx="focusScope.autoFocusOnMount",Px="focusScope.autoFocusOnUnmount",mD={bubbles:!1,cancelable:!0},zre="FocusScope",Np=w.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,l]=w.useState(null),c=In(o),u=In(i),d=w.useRef(null),h=He(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 C=x.target;a.contains(C)?d.current=C:Ys(d.current,{select:!0})},b=function(x){if(p.paused||!a)return;const C=x.relatedTarget;C!==null&&(a.contains(C)||Ys(d.current,{select:!0}))},y=function(x){if(document.activeElement===document.body)for(const _ of x)_.removedNodes.length>0&&Ys(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){bD.add(p);const m=document.activeElement;if(!a.contains(m)){const y=new CustomEvent(Dx,mD);a.addEventListener(Dx,c),a.dispatchEvent(y),y.defaultPrevented||(Bre(qre(Z4(a)),{select:!0}),document.activeElement===m&&Ys(a))}return()=>{a.removeEventListener(Dx,c),setTimeout(()=>{const y=new CustomEvent(Px,mD);a.addEventListener(Px,u),a.dispatchEvent(y),y.defaultPrevented||Ys(m??document.body,{select:!0}),a.removeEventListener(Px,u),bD.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,C]=Vre(v);x&&C?!m.shiftKey&&y===C?(m.preventDefault(),n&&Ys(x,{select:!0})):m.shiftKey&&y===x&&(m.preventDefault(),n&&Ys(C,{select:!0})):y===v&&m.preventDefault()}},[n,r,p.paused]);return f.jsx(_e.div,{tabIndex:-1,...s,ref:h,onKeyDown:g})});Np.displayName=zre;function Bre(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ys(r,{select:t}),document.activeElement!==n)return}function Vre(e){const t=Z4(e),n=gD(t,e),r=gD(t.reverse(),e);return[n,r]}function Z4(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 gD(e,t){for(const n of e)if(!Hre(n,{upTo:t}))return n}function Hre(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 Wre(e){return e instanceof HTMLInputElement&&"select"in e}function Ys(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Wre(e)&&t&&e.select()}}var bD=Ure();function Ure(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=yD(e,t),e.unshift(t)},remove(t){var n;e=yD(e,t),(n=e[0])==null||n.resume()}}}function yD(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function qre(e){return e.filter(t=>t.tagName!=="A")}const Gre=["top","right","bottom","left"],Ns=Math.min,rr=Math.max,vh=Math.round,jm=Math.floor,Ci=e=>({x:e,y:e}),Yre={left:"right",right:"left",bottom:"top",top:"bottom"},Kre={start:"end",end:"start"};function wC(e,t,n){return rr(e,Ns(t,n))}function Ii(e,t){return typeof e=="function"?e(t):e}function Ms(e){return e.split("-")[0]}function Cd(e){return e.split("-")[1]}function q_(e){return e==="x"?"y":"x"}function G_(e){return e==="y"?"height":"width"}function Ca(e){return["top","bottom"].includes(Ms(e))?"y":"x"}function Y_(e){return q_(Ca(e))}function Xre(e,t,n){n===void 0&&(n=!1);const r=Cd(e),o=Y_(e),i=G_(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Nb(s)),[s,Nb(s)]}function Qre(e){const t=Nb(e);return[CC(e),t,CC(t)]}function CC(e){return e.replace(/start|end/g,t=>Kre[t])}function Zre(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=Cd(e);let i=Zre(Ms(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(CC)))),i}function Nb(e){return e.replace(/left|right|bottom|top/g,t=>Yre[t])}function eoe(e){return{top:0,right:0,bottom:0,left:0,...e}}function J4(e){return typeof e!="number"?eoe(e):{top:e,right:e,bottom:e,left:e}}function Mb(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 vD(e,t,n){let{reference:r,floating:o}=e;const i=Ca(t),s=Y_(t),a=G_(s),l=Ms(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(Cd(t)){case"start":p[s]-=h*(n&&c?-1:1);break;case"end":p[s]+=h*(n&&c?-1:1);break}return p}const toe=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}=vD(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:C,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],...C}},_&&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}=vD(c,h,l)),m=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:p}};async function Xu(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}=Ii(t,e),g=J4(p),b=a[h?d==="floating"?"reference":"floating":d],y=Mb(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)),C=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},_=Mb(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:l}):v);return{top:(y.top-_.top+g.top)/C.y,bottom:(_.bottom-y.bottom+g.bottom)/C.y,left:(y.left-_.left+g.left)/C.x,right:(_.right-y.right+g.right)/C.x}}const noe=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}=Ii(e,t)||{};if(c==null)return{};const d=J4(u),h={x:n,y:r},p=Y_(o),g=G_(p),m=await s.getDimensions(c),b=p==="y",y=b?"top":"left",v=b?"bottom":"right",x=b?"clientHeight":"clientWidth",C=i.reference[g]+i.reference[p]-h[p]-i.floating[g],_=h[p]-i.reference[p],S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let E=S?S[x]:0;(!E||!await(s.isElement==null?void 0:s.isElement(S)))&&(E=a.floating[x]||i.floating[g]);const k=C/2-_/2,N=E/2-m[g]/2-1,M=Ns(d[y],N),I=Ns(d[v],N),P=M,j=E-m[g]-I,F=E/2-m[g]/2+k,T=wC(P,F,j),O=!l.arrow&&Cd(o)!=null&&F!==T&&i.reference[g]/2-(F<P?M:I)-m[g]/2<0,L=O?F<P?F-P:F-j:0;return{[p]:h[p]+L,data:{[p]:T,centerOffset:F-T-L,...O&&{alignmentOffset:L}},reset:O}}}),roe=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}=Ii(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=Ms(o),v=Ca(a),x=Ms(a)===a,C=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=h||(x||!m?[Nb(a)]:Qre(a)),S=g!=="none";!h&&S&&_.push(...Jre(a,m,g,C));const E=[a,..._],k=await Xu(t,b),N=[];let M=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&N.push(k[y]),d){const F=Xre(o,s,C);N.push(k[F[0]],k[F[1]])}if(M=[...M,{placement:o,overflows:N}],!N.every(F=>F<=0)){var I,P;const F=(((I=i.flip)==null?void 0:I.index)||0)+1,T=E[F];if(T)return{data:{index:F,overflows:M},reset:{placement:T}};let O=(P=M.filter(L=>L.overflows[0]<=0).sort((L,B)=>L.overflows[1]-B.overflows[1])[0])==null?void 0:P.placement;if(!O)switch(p){case"bestFit":{var j;const L=(j=M.filter(B=>{if(S){const z=Ca(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];L&&(O=L);break}case"initialPlacement":O=a;break}if(o!==O)return{reset:{placement:O}}}return{}}}};function xD(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wD(e){return Gre.some(t=>e[t]>=0)}const ooe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Ii(e,t);switch(r){case"referenceHidden":{const i=await Xu(t,{...o,elementContext:"reference"}),s=xD(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:wD(s)}}}case"escaped":{const i=await Xu(t,{...o,altBoundary:!0}),s=xD(i,n.floating);return{data:{escapedOffsets:s,escaped:wD(s)}}}default:return{}}}}};async function ioe(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Ms(n),a=Cd(n),l=Ca(n)==="y",c=["left","top"].includes(s)?-1:1,u=i&&l?-1:1,d=Ii(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 soe=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 ioe(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}}}}},aoe=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}=Ii(e,t),c={x:n,y:r},u=await Xu(t,l),d=Ca(Ms(o)),h=q_(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=wC(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=wC(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}}}}}},loe=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}=Ii(e,t),u={x:n,y:r},d=Ca(o),h=q_(d);let p=u[h],g=u[d];const m=Ii(a,t),b=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const x=h==="y"?"height":"width",C=i.reference[h]-i.floating[x]+b.mainAxis,_=i.reference[h]+i.reference[x]-b.mainAxis;p<C?p=C:p>_&&(p=_)}if(c){var y,v;const x=h==="y"?"width":"height",C=["top","left"].includes(Ms(o)),_=i.reference[d]-i.floating[x]+(C&&((y=s.offset)==null?void 0:y[d])||0)+(C?0:b.crossAxis),S=i.reference[d]+i.reference[x]+(C?0:((v=s.offset)==null?void 0:v[d])||0)-(C?b.crossAxis:0);g<_?g=_:g>S&&(g=S)}return{[h]:p,[d]:g}}}},coe=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}=Ii(e,t),u=await Xu(t,c),d=Ms(o),h=Cd(o),p=Ca(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,C=Ns(m-u[b],v),_=Ns(g-u[y],x),S=!t.middlewareData.shift;let E=C,k=_;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=v),S&&!h){const M=rr(u.left,0),I=rr(u.right,0),P=rr(u.top,0),j=rr(u.bottom,0);p?k=g-2*(M!==0||I!==0?M+I:rr(u.left,u.right)):E=m-2*(P!==0||j!==0?P+j:rr(u.top,u.bottom))}await l({...t,availableWidth:k,availableHeight:E});const N=await s.getDimensions(a.floating);return g!==N.width||m!==N.height?{reset:{rects:!0}}:{}}}};function yy(){return typeof window<"u"}function Sd(e){return e3(e)?(e.nodeName||"").toLowerCase():"#document"}function co(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Wi(e){var t;return(t=(e3(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function e3(e){return yy()?e instanceof Node||e instanceof co(e).Node:!1}function ir(e){return yy()?e instanceof Element||e instanceof co(e).Element:!1}function Ti(e){return yy()?e instanceof HTMLElement||e instanceof co(e).HTMLElement:!1}function CD(e){return!yy()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof co(e).ShadowRoot}function Mp(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Jo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function uoe(e){return["table","td","th"].includes(Sd(e))}function vy(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function K_(e){const t=X_(),n=ir(e)?Jo(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 doe(e){let t=Sa(e);for(;Ti(t)&&!Qu(t);){if(K_(t))return t;if(vy(t))return null;t=Sa(t)}return null}function X_(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Qu(e){return["html","body","#document"].includes(Sd(e))}function Jo(e){return co(e).getComputedStyle(e)}function xy(e){return ir(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Sa(e){if(Sd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||CD(e)&&e.host||Wi(e);return CD(t)?t.host:t}function t3(e){const t=Sa(e);return Qu(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ti(t)&&Mp(t)?t:t3(t)}function xh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=t3(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=co(o);if(i){const a=SC(s);return t.concat(s,s.visualViewport||[],Mp(o)?o:[],a&&n?xh(a):[])}return t.concat(o,xh(o,[],n))}function SC(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function n3(e){const t=Jo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ti(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=vh(n)!==i||vh(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function Q_(e){return ir(e)?e:e.contextElement}function yu(e){const t=Q_(e);if(!Ti(t))return Ci(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=n3(t);let s=(i?vh(n.width):n.width)/r,a=(i?vh(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const foe=Ci(0);function r3(e){const t=co(e);return!X_()||!t.visualViewport?foe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function hoe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==co(e)?!1:t}function ec(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Q_(e);let s=Ci(1);t&&(r?ir(r)&&(s=yu(r)):s=yu(e));const a=hoe(i,n,r)?r3(i):Ci(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=co(i),p=r&&ir(r)?co(r):r;let g=h,m=SC(g);for(;m&&r&&p!==g;){const b=yu(m),y=m.getBoundingClientRect(),v=Jo(m),x=y.left+(m.clientLeft+parseFloat(v.paddingLeft))*b.x,C=y.top+(m.clientTop+parseFloat(v.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=x,c+=C,g=co(m),m=SC(g)}}return Mb({width:u,height:d,x:l,y:c})}function Z_(e,t){const n=xy(e).scrollLeft;return t?t.left+n:ec(Wi(e)).left+n}function o3(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:Z_(e,r)),i=r.top+t.scrollTop;return{x:o,y:i}}function poe(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=Wi(r),a=t?vy(t.floating):!1;if(r===s||a&&i)return n;let l={scrollLeft:0,scrollTop:0},c=Ci(1);const u=Ci(0),d=Ti(r);if((d||!d&&!i)&&((Sd(r)!=="body"||Mp(s))&&(l=xy(r)),Ti(r))){const p=ec(r);c=yu(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=s&&!d&&!i?o3(s,l,!0):Ci(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 moe(e){return Array.from(e.getClientRects())}function goe(e){const t=Wi(e),n=xy(e),r=e.ownerDocument.body,o=rr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=rr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Z_(e);const a=-n.scrollTop;return Jo(r).direction==="rtl"&&(s+=rr(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function boe(e,t){const n=co(e),r=Wi(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=X_();(!c||c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:i,height:s,x:a,y:l}}function yoe(e,t){const n=ec(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Ti(e)?yu(e):Ci(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 SD(e,t,n){let r;if(t==="viewport")r=boe(e,n);else if(t==="document")r=goe(Wi(e));else if(ir(t))r=yoe(t,n);else{const o=r3(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Mb(r)}function i3(e,t){const n=Sa(e);return n===t||!ir(n)||Qu(n)?!1:Jo(n).position==="fixed"||i3(n,t)}function voe(e,t){const n=t.get(e);if(n)return n;let r=xh(e,[],!1).filter(a=>ir(a)&&Sd(a)!=="body"),o=null;const i=Jo(e).position==="fixed";let s=i?Sa(e):e;for(;ir(s)&&!Qu(s);){const a=Jo(s),l=K_(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Mp(s)&&!l&&i3(e,s))?r=r.filter(u=>u!==s):o=a,s=Sa(s)}return t.set(e,r),r}function xoe(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?vy(t)?[]:voe(t,this._c):[].concat(n),r],a=s[0],l=s.reduce((c,u)=>{const d=SD(t,u,o);return c.top=rr(d.top,c.top),c.right=Ns(d.right,c.right),c.bottom=Ns(d.bottom,c.bottom),c.left=rr(d.left,c.left),c},SD(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function woe(e){const{width:t,height:n}=n3(e);return{width:t,height:n}}function Coe(e,t,n){const r=Ti(t),o=Wi(t),i=n==="fixed",s=ec(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=Ci(0);if(r||!r&&!i)if((Sd(t)!=="body"||Mp(o))&&(a=xy(t)),r){const h=ec(t,!0,i,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&(l.x=Z_(o));const c=o&&!r&&!i?o3(o,a):Ci(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 Ax(e){return Jo(e).position==="static"}function ED(e,t){if(!Ti(e)||Jo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Wi(e)===n&&(n=n.ownerDocument.body),n}function s3(e,t){const n=co(e);if(vy(e))return n;if(!Ti(e)){let o=Sa(e);for(;o&&!Qu(o);){if(ir(o)&&!Ax(o))return o;o=Sa(o)}return n}let r=ED(e,t);for(;r&&uoe(r)&&Ax(r);)r=ED(r,t);return r&&Qu(r)&&Ax(r)&&!K_(r)?n:r||doe(e)||n}const Soe=async function(e){const t=this.getOffsetParent||s3,n=this.getDimensions,r=await n(e.floating);return{reference:Coe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Eoe(e){return Jo(e).direction==="rtl"}const _oe={convertOffsetParentRelativeRectToViewportRelativeRect:poe,getDocumentElement:Wi,getClippingRect:xoe,getOffsetParent:s3,getElementRects:Soe,getClientRects:moe,getDimensions:woe,getScale:yu,isElement:ir,isRTL:Eoe};function a3(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Roe(e,t){let n=null,r;const o=Wi(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=jm(d),m=jm(o.clientWidth-(u+h)),b=jm(o.clientHeight-(d+p)),y=jm(u),x={rootMargin:-g+"px "+-m+"px "+-b+"px "+-y+"px",threshold:rr(0,Ns(1,l))||1};let C=!0;function _(S){const E=S[0].intersectionRatio;if(E!==l){if(!C)return s();E?s(!1,E):r=setTimeout(()=>{s(!1,1e-7)},1e3)}E===1&&!a3(c,e.getBoundingClientRect())&&s(),C=!1}try{n=new IntersectionObserver(_,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,x)}n.observe(e)}return s(!0),i}function J_(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=Q_(e),u=o||i?[...c?xh(c):[],...xh(t)]:[];u.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const d=c&&a?Roe(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?ec(e):null;l&&b();function b(){const y=ec(e);m&&!a3(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 Ix=Xu,koe=soe,Noe=aoe,Moe=roe,Doe=coe,Poe=ooe,_D=noe,Aoe=loe,Ioe=(e,t,n)=>{const r=new Map,o={platform:_oe,...n},i={...o.platform,_c:r};return toe(e,t,{...o,platform:i})};var Vg=typeof document<"u"?R.useLayoutEffect:R.useEffect;function Db(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(!Db(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)&&!Db(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function l3(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function RD(e,t){const n=l3(e);return Math.round(t*n)/n}function Tx(e){const t=w.useRef(e);return Vg(()=>{t.current=e}),t}function e2(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);Db(h,r)||p(r);const[g,m]=w.useState(null),[b,y]=w.useState(null),v=w.useCallback(B=>{B!==S.current&&(S.current=B,m(B))},[]),x=w.useCallback(B=>{B!==E.current&&(E.current=B,y(B))},[]),C=i||g,_=s||b,S=w.useRef(null),E=w.useRef(null),k=w.useRef(u),N=l!=null,M=Tx(l),I=Tx(o),P=Tx(c),j=w.useCallback(()=>{if(!S.current||!E.current)return;const B={placement:t,strategy:n,middleware:h};I.current&&(B.platform=I.current),Ioe(S.current,E.current,B).then(z=>{const A={...z,isPositioned:P.current!==!1};F.current&&!Db(k.current,A)&&(k.current=A,Rs.flushSync(()=>{d(A)}))})},[h,t,n,I,P]);Vg(()=>{c===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,d(B=>({...B,isPositioned:!1})))},[c]);const F=w.useRef(!1);Vg(()=>(F.current=!0,()=>{F.current=!1}),[]),Vg(()=>{if(C&&(S.current=C),_&&(E.current=_),C&&_){if(M.current)return M.current(C,_,j);j()}},[C,_,j,M,N]);const T=w.useMemo(()=>({reference:S,floating:E,setReference:v,setFloating:x}),[v,x]),O=w.useMemo(()=>({reference:C,floating:_}),[C,_]),L=w.useMemo(()=>{const B={position:n,left:0,top:0};if(!O.floating)return B;const z=RD(O.floating,u.x),A=RD(O.floating,u.y);return a?{...B,transform:"translate("+z+"px, "+A+"px)",...l3(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:L}),[u,j,T,O,L])}const Toe=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?_D({element:r.current,padding:o}).fn(n):{}:r?_D({element:r,padding:o}).fn(n):{}}}},wy=(e,t)=>({...koe(e),options:[e,t]}),t2=(e,t)=>({...Noe(e),options:[e,t]}),c3=(e,t)=>({...Aoe(e),options:[e,t]}),n2=(e,t)=>({...Moe(e),options:[e,t]}),r2=(e,t)=>({...Doe(e),options:[e,t]}),u3=(e,t)=>({...Poe(e),options:[e,t]}),d3=(e,t)=>({...Toe(e),options:[e,t]});var joe="Arrow",f3=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"})})});f3.displayName=joe;var Ooe=f3;function Cy(e){const[t,n]=w.useState(void 0);return Yn(()=>{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 o2="Popper",[h3,Ui]=On(o2),[Foe,p3]=h3(o2),m3=e=>{const{__scopePopper:t,children:n}=e,[r,o]=w.useState(null);return f.jsx(Foe,{scope:t,anchor:r,onAnchorChange:o,children:n})};m3.displayName=o2;var g3="PopperAnchor",b3=w.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=p3(g3,n),s=w.useRef(null),a=He(t,s);return w.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:f.jsx(_e.div,{...o,ref:a})});b3.displayName=g3;var i2="PopperContent",[$oe,Loe]=h3(i2),y3=w.forwardRef((e,t)=>{var q,K,Y,Q,ne,Z;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=p3(i2,n),[y,v]=w.useState(null),x=He(t,ie=>v(ie)),[C,_]=w.useState(null),S=Cy(C),E=(S==null?void 0:S.width)??0,k=(S==null?void 0:S.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],P=I.length>0,j={padding:M,boundary:I.filter(Boe),altBoundary:P},{refs:F,floatingStyles:T,placement:O,isPositioned:L,middlewareData:B}=e2({strategy:"fixed",placement:N,whileElementsMounted:(...ie)=>J_(...ie,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[wy({mainAxis:o+k,alignmentAxis:s}),l&&t2({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?c3():void 0,...j}),l&&n2({...j}),r2({...j,apply:({elements:ie,rects:te,availableWidth:ce,availableHeight:de})=>{const{width:ke,height:we}=te.reference,Ce=ie.floating.style;Ce.setProperty("--radix-popper-available-width",`${ce}px`),Ce.setProperty("--radix-popper-available-height",`${de}px`),Ce.setProperty("--radix-popper-anchor-width",`${ke}px`),Ce.setProperty("--radix-popper-anchor-height",`${we}px`)}}),C&&d3({element:C,padding:a}),Voe({arrowWidth:E,arrowHeight:k}),h&&u3({strategy:"referenceHidden",...j})]}),[z,A]=w3(O),W=In(g);Yn(()=>{L&&(W==null||W())},[L,W]);const $=(q=B.arrow)==null?void 0:q.x,D=(K=B.arrow)==null?void 0:K.y,H=((Y=B.arrow)==null?void 0:Y.centerOffset)!==0,[V,G]=w.useState();return Yn(()=>{y&&G(window.getComputedStyle(y).zIndex)},[y]),f.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:L?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[(Q=B.transformOrigin)==null?void 0:Q.x,(ne=B.transformOrigin)==null?void 0:ne.y].join(" "),...((Z=B.hide)==null?void 0:Z.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:f.jsx($oe,{scope:n,placedSide:z,onArrowChange:_,arrowX:$,arrowY:D,shouldHideArrow:H,children:f.jsx(_e.div,{"data-side":z,"data-align":A,...m,ref:x,style:{...m.style,animation:L?void 0:"none"}})})})});y3.displayName=i2;var v3="PopperArrow",zoe={top:"bottom",right:"left",bottom:"top",left:"right"},x3=w.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=Loe(v3,r),s=zoe[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(Ooe,{...o,ref:n,style:{...o.style,display:"block"}})})});x3.displayName=v3;function Boe(e){return e!==null}var Voe=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]=w3(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 w3(e){const[t,n="center"]=e.split("-");return[t,n]}var Dp=m3,Ed=b3,Pp=y3,Ap=x3,Hoe="Portal",Rc=w.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,i]=w.useState(!1);Yn(()=>i(!0),[]);const s=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return s?an.createPortal(f.jsx(_e.div,{...r,ref:t}),s):null});Rc.displayName=Hoe;var C3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(Uoe);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(EC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(EC,{...r,ref:t,children:n})});C3.displayName="Slot";var EC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=Goe(n),i=qoe(r,n.props);return n.type!==w.Fragment&&(i.ref=t?Sr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});EC.displayName="SlotClone";var Woe=({children:e})=>f.jsx(f.Fragment,{children:e});function Uoe(e){return w.isValidElement(e)&&e.type===Woe}function qoe(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 Goe(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 s2="Popover",[S3,J$e]=On(s2,[Ui]),Ip=Ui(),[Yoe,La]=S3(s2),E3=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=Ip(t),l=w.useRef(null),[c,u]=w.useState(!1),[d=!1,h]=dr({prop:r,defaultProp:o,onChange:i});return f.jsx(Dp,{...a,children:f.jsx(Yoe,{scope:t,contentId:Nn(),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})})};E3.displayName=s2;var _3="PopoverAnchor",Koe=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=La(_3,n),i=Ip(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return w.useEffect(()=>(s(),()=>a()),[s,a]),f.jsx(Ed,{...i,...r,ref:t})});Koe.displayName=_3;var R3="PopoverTrigger",k3=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=La(R3,n),i=Ip(n),s=He(t,o.triggerRef),a=f.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":A3(o.open),...r,ref:s,onClick:he(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:f.jsx(Ed,{asChild:!0,...i,children:a})});k3.displayName=R3;var a2="PopoverPortal",[Xoe,Qoe]=S3(a2,{forceMount:void 0}),N3=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=La(a2,t);return f.jsx(Xoe,{scope:t,forceMount:n,children:f.jsx(gn,{present:n||i.open,children:f.jsx(Rc,{asChild:!0,container:o,children:r})})})};N3.displayName=a2;var Zu="PopoverContent",M3=w.forwardRef((e,t)=>{const n=Qoe(Zu,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=La(Zu,e.__scopePopover);return f.jsx(gn,{present:r||i.open,children:i.modal?f.jsx(Zoe,{...o,ref:t}):f.jsx(Joe,{...o,ref:t})})});M3.displayName=Zu;var Zoe=w.forwardRef((e,t)=>{const n=La(Zu,e.__scopePopover),r=w.useRef(null),o=He(t,r),i=w.useRef(!1);return w.useEffect(()=>{const s=r.current;if(s)return yd(s)},[]),f.jsx(Ec,{as:C3,allowPinchZoom:!0,children:f.jsx(D3,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:he(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:he(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:he(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),Joe=w.forwardRef((e,t)=>{const n=La(Zu,e.__scopePopover),r=w.useRef(!1),o=w.useRef(!1);return f.jsx(D3,{...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()}})}),D3=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=La(Zu,n),p=Ip(n);return by(),f.jsx(Np,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:f.jsx(_c,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:f.jsx(Pp,{"data-state":A3(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",eie=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=La(P3,n);return f.jsx(_e.button,{type:"button",...r,ref:t,onClick:he(e.onClick,()=>o.onOpenChange(!1))})});eie.displayName=P3;var tie="PopoverArrow",nie=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ip(n);return f.jsx(Ap,{...o,...r,ref:t})});nie.displayName=tie;function A3(e){return e?"open":"closed"}var rie=E3,oie=k3,iie=N3,Sy=M3;const za=rie,Ba=oie,Ts=w.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>f.jsx(iie,{children:f.jsx(ri,{children:f.jsx(Sy,{ref:o,align:t,sideOffset:n,className:oe("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})})}));Ts.displayName=Sy.displayName;function _C(e,[t,n]){return Math.min(n,Math.max(t,e))}var I3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(aie);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(RC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(RC,{...r,ref:t,children:n})});I3.displayName="Slot";var RC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=cie(n),i=lie(r,n.props);return n.type!==w.Fragment&&(i.ref=t?Sr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});RC.displayName="SlotClone";var sie=({children:e})=>f.jsx(f.Fragment,{children:e});function aie(e){return w.isValidElement(e)&&e.type===sie}function lie(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 cie(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 Ey(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 uie="VisuallyHidden",l2=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}}));l2.displayName=uie;var die=l2,fie=[" ","Enter","ArrowUp","ArrowDown"],hie=[" ","Enter"],Tp="Select",[_y,Ry,pie]=B0(Tp),[_d,eLe]=On(Tp,[pie,Ui]),ky=Ui(),[mie,Va]=_d(Tp),[gie,bie]=_d(Tp),T3=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=ky(t),[b,y]=w.useState(null),[v,x]=w.useState(null),[C,_]=w.useState(!1),S=yc(c),[E=!1,k]=dr({prop:r,defaultProp:o,onChange:i}),[N,M]=dr({prop:s,defaultProp:a,onChange:l}),I=w.useRef(null),P=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(Dp,{...m,children:f.jsxs(mie,{required:p,scope:t,trigger:b,onTriggerChange:y,valueNode:v,onValueNodeChange:x,valueNodeHasChildren:C,onValueNodeHasChildrenChange:_,contentId:Nn(),value:N,onValueChange:M,open:E,onOpenChange:k,dir:S,triggerPointerDownPosRef:I,disabled:h,children:[f.jsx(_y.Provider,{scope:t,children:f.jsx(gie,{scope:e.__scopeSelect,onNativeOptionAdd:w.useCallback(O=>{F(L=>new Set(L).add(O))},[]),onNativeOptionRemove:w.useCallback(O=>{F(L=>{const B=new Set(L);return B.delete(O),B})},[]),children:n})}),P?f.jsxs(s$,{"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]})})};T3.displayName=Tp;var j3="SelectTrigger",O3=w.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=ky(n),s=Va(j3,n),a=s.disabled||r,l=He(t,s.onTriggerChange),c=Ry(n),u=w.useRef("touch"),[d,h,p]=a$(m=>{const b=c().filter(x=>!x.disabled),y=b.find(x=>x.value===s.value),v=l$(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(Ed,{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":i$(s.value)?"":void 0,...o,ref:l,onClick:he(o.onClick,m=>{m.currentTarget.focus(),u.current!=="mouse"&&g(m)}),onPointerDown:he(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:he(o.onKeyDown,m=>{const b=d.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&h(m.key),!(b&&m.key===" ")&&fie.includes(m.key)&&(g(),m.preventDefault())})})})});O3.displayName=j3;var F3="SelectValue",$3=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:s="",...a}=e,l=Va(F3,n),{onValueNodeHasChildrenChange:c}=l,u=i!==void 0,d=He(t,l.onValueNodeChange);return Yn(()=>{c(u)},[c,u]),f.jsx(_e.span,{...a,ref:d,style:{pointerEvents:"none"},children:i$(l.value)?f.jsx(f.Fragment,{children:s}):i})});$3.displayName=F3;var yie="SelectIcon",L3=w.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return f.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});L3.displayName=yie;var vie="SelectPortal",z3=e=>f.jsx(Rc,{asChild:!0,...e});z3.displayName=vie;var tc="SelectContent",B3=w.forwardRef((e,t)=>{const n=Va(tc,e.__scopeSelect),[r,o]=w.useState();if(Yn(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?Rs.createPortal(f.jsx(V3,{scope:e.__scopeSelect,children:f.jsx(_y.Slot,{scope:e.__scopeSelect,children:f.jsx("div",{children:e.children})})}),i):null}return f.jsx(H3,{...e,ref:t})});B3.displayName=tc;var zo=10,[V3,Ha]=_d(tc),xie="SelectContentImpl",H3=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=Va(tc,n),[x,C]=w.useState(null),[_,S]=w.useState(null),E=He(t,q=>C(q)),[k,N]=w.useState(null),[M,I]=w.useState(null),P=Ry(n),[j,F]=w.useState(!1),T=w.useRef(!1);w.useEffect(()=>{if(x)return yd(x)},[x]),by();const O=w.useCallback(q=>{const[K,...Y]=P().map(Z=>Z.ref.current),[Q]=Y.slice(-1),ne=document.activeElement;for(const Z of q)if(Z===ne||(Z==null||Z.scrollIntoView({block:"nearest"}),Z===K&&_&&(_.scrollTop=0),Z===Q&&_&&(_.scrollTop=_.scrollHeight),Z==null||Z.focus(),document.activeElement!==ne))return},[P,_]),L=w.useCallback(()=>O([k,x]),[O,k,x]);w.useEffect(()=>{j&&L()},[j,L]);const{onOpenChange:B,triggerPointerDownPosRef:z}=v;w.useEffect(()=>{if(x){let q={x:0,y:0};const K=Q=>{var ne,Z;q={x:Math.abs(Math.round(Q.pageX)-(((ne=z.current)==null?void 0:ne.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((Z=z.current)==null?void 0:Z.y)??0))}},Y=Q=>{q.x<=10&&q.y<=10?Q.preventDefault():x.contains(Q.target)||B(!1),document.removeEventListener("pointermove",K),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",K),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",Y,{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]=a$(q=>{const K=P().filter(ne=>!ne.disabled),Y=K.find(ne=>ne.ref.current===document.activeElement),Q=l$(K,q,Y);Q&&setTimeout(()=>Q.ref.current.focus())}),$=w.useCallback((q,K,Y)=>{const Q=!T.current&&!Y;(v.value!==void 0&&v.value===K||Q)&&(N(q),Q&&(T.current=!0))},[v.value]),D=w.useCallback(()=>x==null?void 0:x.focus(),[x]),H=w.useCallback((q,K,Y)=>{const Q=!T.current&&!Y;(v.value!==void 0&&v.value===K||Q)&&I(q)},[v.value]),V=r==="popper"?kC:W3,G=V===kC?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:g,hideWhenDetached:m,avoidCollisions:b}:{};return f.jsx(V3,{scope:n,content:x,viewport:_,onViewportChange:S,itemRefCallback:$,selectedItem:k,onItemLeave:D,itemTextRefCallback:H,focusSelectedItem:L,selectedItemText:M,position:r,isPositioned:j,searchRef:A,children:f.jsx(Ec,{as:I3,allowPinchZoom:!0,children:f.jsx(Np,{asChild:!0,trapped:v.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:he(o,q=>{var K;(K=v.trigger)==null||K.focus({preventScroll:!0}),q.preventDefault()}),children:f.jsx(_c,{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:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:he(y.onKeyDown,q=>{const K=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!K&&q.key.length===1&&W(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let Q=P().filter(ne=>!ne.disabled).map(ne=>ne.ref.current);if(["ArrowUp","End"].includes(q.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const ne=q.target,Z=Q.indexOf(ne);Q=Q.slice(Z+1)}setTimeout(()=>O(Q)),q.preventDefault()}})})})})})})});H3.displayName=xie;var wie="SelectItemAlignedPosition",W3=w.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=Va(tc,n),s=Ha(tc,n),[a,l]=w.useState(null),[c,u]=w.useState(null),d=He(t,E=>u(E)),h=Ry(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 E=i.trigger.getBoundingClientRect(),k=c.getBoundingClientRect(),N=i.valueNode.getBoundingClientRect(),M=y.getBoundingClientRect();if(i.dir!=="rtl"){const ne=M.left-k.left,Z=N.left-ne,ie=E.left-Z,te=E.width+ie,ce=Math.max(te,k.width),de=window.innerWidth-zo,ke=_C(Z,[zo,Math.max(zo,de-ce)]);a.style.minWidth=te+"px",a.style.left=ke+"px"}else{const ne=k.right-M.right,Z=window.innerWidth-N.right-ne,ie=window.innerWidth-E.right-Z,te=E.width+ie,ce=Math.max(te,k.width),de=window.innerWidth-zo,ke=_C(Z,[zo,Math.max(zo,de-ce)]);a.style.minWidth=te+"px",a.style.right=ke+"px"}const I=h(),P=window.innerHeight-zo*2,j=m.scrollHeight,F=window.getComputedStyle(c),T=parseInt(F.borderTopWidth,10),O=parseInt(F.paddingTop,10),L=parseInt(F.borderBottomWidth,10),B=parseInt(F.paddingBottom,10),z=T+O+j+B+L,A=Math.min(b.offsetHeight*5,z),W=window.getComputedStyle(m),$=parseInt(W.paddingTop,10),D=parseInt(W.paddingBottom,10),H=E.top+E.height/2-zo,V=P-H,G=b.offsetHeight/2,q=b.offsetTop+G,K=T+O+q,Y=z-K;if(K<=H){const ne=I.length>0&&b===I[I.length-1].ref.current;a.style.bottom="0px";const Z=c.clientHeight-m.offsetTop-m.offsetHeight,ie=Math.max(V,G+(ne?D:0)+Z+L),te=K+ie;a.style.height=te+"px"}else{const ne=I.length>0&&b===I[0].ref.current;a.style.top="0px";const ie=Math.max(H,T+m.offsetTop+(ne?$:0)+G)+Y;a.style.height=ie+"px",m.scrollTop=K-H+m.offsetTop}a.style.margin=`${zo}px 0`,a.style.minHeight=A+"px",a.style.maxHeight=P+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,i.trigger,i.valueNode,a,c,m,b,y,i.dir,r]);Yn(()=>x(),[x]);const[C,_]=w.useState();Yn(()=>{c&&_(window.getComputedStyle(c).zIndex)},[c]);const S=w.useCallback(E=>{E&&g.current===!0&&(x(),v==null||v(),g.current=!1)},[x,v]);return f.jsx(Sie,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:f.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:C},children:f.jsx(_e.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});W3.displayName=wie;var Cie="SelectPopperPosition",kC=w.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=zo,...i}=e,s=ky(n);return f.jsx(Pp,{...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)"}})});kC.displayName=Cie;var[Sie,c2]=_d(tc,{}),NC="SelectViewport",U3=w.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=Ha(NC,n),s=c2(NC,n),a=He(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(_y.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:he(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-zo*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),C=v-x;d.style.height=x+"px",d.style.bottom==="0px"&&(u.scrollTop=C>0?C:0,d.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});U3.displayName=NC;var q3="SelectGroup",[Eie,_ie]=_d(q3),G3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nn();return f.jsx(Eie,{scope:n,id:o,children:f.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});G3.displayName=q3;var Y3="SelectLabel",K3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_ie(Y3,n);return f.jsx(_e.div,{id:o.id,...r,ref:t})});K3.displayName=Y3;var Pb="SelectItem",[Rie,X3]=_d(Pb),Q3=w.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...s}=e,a=Va(Pb,n),l=Ha(Pb,n),c=a.value===r,[u,d]=w.useState(i??""),[h,p]=w.useState(!1),g=He(t,v=>{var x;return(x=l.itemRefCallback)==null?void 0:x.call(l,v,r,o)}),m=Nn(),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(Rie,{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(_y.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:he(s.onFocus,()=>p(!0)),onBlur:he(s.onBlur,()=>p(!1)),onClick:he(s.onClick,()=>{b.current!=="mouse"&&y()}),onPointerUp:he(s.onPointerUp,()=>{b.current==="mouse"&&y()}),onPointerDown:he(s.onPointerDown,v=>{b.current=v.pointerType}),onPointerMove:he(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:he(s.onPointerLeave,v=>{var x;v.currentTarget===document.activeElement&&((x=l.onItemLeave)==null||x.call(l))}),onKeyDown:he(s.onKeyDown,v=>{var C;((C=l.searchRef)==null?void 0:C.current)!==""&&v.key===" "||(hie.includes(v.key)&&y(),v.key===" "&&v.preventDefault())})})})})});Q3.displayName=Pb;var pf="SelectItemText",Z3=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,s=Va(pf,n),a=Ha(pf,n),l=X3(pf,n),c=bie(pf,n),[u,d]=w.useState(null),h=He(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 Yn(()=>(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?Rs.createPortal(i.children,s.valueNode):null]})});Z3.displayName=pf;var J3="SelectItemIndicator",e$=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return X3(J3,n).isSelected?f.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});e$.displayName=J3;var MC="SelectScrollUpButton",t$=w.forwardRef((e,t)=>{const n=Ha(MC,e.__scopeSelect),r=c2(MC,e.__scopeSelect),[o,i]=w.useState(!1),s=He(t,r.onScrollButtonChange);return Yn(()=>{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(r$,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});t$.displayName=MC;var DC="SelectScrollDownButton",n$=w.forwardRef((e,t)=>{const n=Ha(DC,e.__scopeSelect),r=c2(DC,e.__scopeSelect),[o,i]=w.useState(!1),s=He(t,r.onScrollButtonChange);return Yn(()=>{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(r$,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});n$.displayName=DC;var r$=w.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=Ha("SelectScrollButton",n),s=w.useRef(null),a=Ry(n),l=w.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return w.useEffect(()=>()=>l(),[l]),Yn(()=>{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:he(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:he(o.onPointerMove,()=>{var c;(c=i.onItemLeave)==null||c.call(i),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:he(o.onPointerLeave,()=>{l()})})}),kie="SelectSeparator",o$=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return f.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});o$.displayName=kie;var PC="SelectArrow",Nie=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ky(n),i=Va(PC,n),s=Ha(PC,n);return i.open&&s.position==="popper"?f.jsx(Ap,{...o,...r,ref:t}):null});Nie.displayName=PC;function i$(e){return e===""||e===void 0}var s$=w.forwardRef((e,t)=>{const{value:n,...r}=e,o=w.useRef(null),i=He(t,o),s=Ey(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(l2,{asChild:!0,children:f.jsx("select",{...r,ref:i,defaultValue:n})})});s$.displayName="BubbleSelect";function a$(e){const t=In(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 l$(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=Mie(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 Mie(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Die=T3,c$=O3,Pie=$3,Aie=L3,Iie=z3,u$=B3,Tie=U3,jie=G3,d$=K3,f$=Q3,Oie=Z3,Fie=e$,h$=t$,p$=n$,m$=o$;const Dt=Die,Qs=jie,Pt=Pie,Ct=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(c$,{ref:r,className:oe("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(Aie,{asChild:!0,children:f.jsx(ma,{className:"h-4 w-4 opacity-50"})})]}));Ct.displayName=c$.displayName;const g$=w.forwardRef(({className:e,...t},n)=>f.jsx(h$,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(Mf,{className:"h-4 w-4"})}));g$.displayName=h$.displayName;const b$=w.forwardRef(({className:e,...t},n)=>f.jsx(p$,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(ma,{className:"h-4 w-4"})}));b$.displayName=p$.displayName;const St=w.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>f.jsx(Iie,{children:f.jsx(ri,{children:f.jsxs(u$,{ref:o,className:oe("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(g$,{}),f.jsx(Tie,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),f.jsx(b$,{})]})})}));St.displayName=u$.displayName;const cs=w.forwardRef(({className:e,...t},n)=>f.jsx(d$,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));cs.displayName=d$.displayName;const xe=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(f$,{ref:r,className:oe("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(Fie,{children:f.jsx(Ur,{className:"h-4 w-4"})})}),f.jsx(Oie,{children:t})]}));xe.displayName=f$.displayName;const Tf=w.forwardRef(({className:e,...t},n)=>f.jsx(m$,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));Tf.displayName=m$.displayName;const Cr=w.forwardRef(({className:e,type:t,...n},r)=>f.jsx("input",{type:t,className:oe("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}));Cr.displayName="Input";var $ie="Label",u2=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())}}));u2.displayName=$ie;var y$=u2;const Lie=sy("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fe=w.forwardRef(({className:e,...t},n)=>f.jsx(y$,{ref:n,className:oe(Lie(),e),...t}));fe.displayName=y$.displayName;function zie({step:e,hierarchyId:t,stepIndex:n,onUpdateStep:r,open:o,onOpenChange:i,trigger:s}){return f.jsxs(za,{open:o,onOpenChange:i,children:[f.jsx(Ba,{asChild:!0,children:s}),f.jsx(Ts,{className:"z-50 w-80",align:"start",children:f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx(fe,{className:"mb-1 block text-xs font-medium",children:"Chart Type"}),f.jsxs(Dt,{value:e.preferredChartType||"bar",onValueChange:a=>{r(t,n,{preferredChartType:a})},children:[f.jsx(Ct,{className:"h-8",children:f.jsx(Pt,{})}),f.jsxs(St,{children:[f.jsx(xe,{value:"bar",children:"Bar Chart"}),f.jsx(xe,{value:"pie",children:"Pie Chart"}),f.jsx(xe,{value:"line",children:"Line Chart"}),f.jsx(xe,{value:"donut",children:"Donut Chart"}),f.jsx(xe,{value:"table",children:"Table"}),f.jsx(xe,{value:"metric",children:"Metric"})]})]})]}),f.jsxs("div",{children:[f.jsx(fe,{className:"mb-1 block text-xs font-medium",children:"Step Label"}),f.jsx(Cr,{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(fe,{className:"mb-1 block text-xs font-medium",children:"Breadcrumb Label Template"}),f.jsx(Cr,{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(Se,{size:"sm",variant:"outline",onClick:()=>i(!1),children:"Done"})})]})})]})}function Bie({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}=W_({id:`${r}-${e.id}-${n}`,disabled:!1}),m={transform:Ai.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(zie,{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 Vie(e){return{sensors:F_(bh(_p,{activationConstraint:{distance:5}}),bh(Ep,{coordinateGetter:U_})),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=kp(o.steps,c,u);e(o.id,{steps:d})}}}}function Hie({hierarchy:e,onUpdateStep:t,onRemoveStep:n,onUpdateHierarchy:r}){const{sensors:o}=Vie(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(V_,{sensors:o,collisionDetection:$_,onDragStart:u,onDragEnd:d,children:[f.jsx(H_,{items:c,strategy:yre,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(Pi,{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(Bie,{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"&&an.createPortal(f.jsx(H4,{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 kD=1,Wie=.9,Uie=.8,qie=.17,jx=.1,Ox=.999,Gie=.9999,Yie=.99,Kie=/[\\\/_+.#"@\[\(\{&]/,Xie=/[\\\/_+.#"@\[\(\{&]/g,Qie=/[\s-]/,v$=/[\s-]/g;function AC(e,t,n,r,o,i,s){if(i===t.length)return o===e.length?kD:Yie;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=AC(e,t,n,r,c+1,i+1,s),d>u&&(c===o?d*=kD:Kie.test(e.charAt(c-1))?(d*=Uie,p=e.slice(o,c-1).match(Xie),p&&o>0&&(d*=Math.pow(Ox,p.length))):Qie.test(e.charAt(c-1))?(d*=Wie,g=e.slice(o,c-1).match(v$),g&&o>0&&(d*=Math.pow(Ox,g.length))):(d*=qie,o>0&&(d*=Math.pow(Ox,c-o))),e.charAt(c)!==t.charAt(i)&&(d*=Gie)),(d<jx&&n.charAt(c-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(c-1)!==r.charAt(i))&&(h=AC(e,t,n,r,c+1,i+2,s),h*jx>d&&(d=h*jx)),d>u&&(u=d),c=n.indexOf(l,c+1);return s[a]=u,u}function ND(e){return e.toLowerCase().replace(v$," ")}function Zie(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,AC(e,t,ND(e),ND(t),0,0,{})}var Kd='[cmdk-group=""]',Fx='[cmdk-group-items=""]',Jie='[cmdk-group-heading=""]',x$='[cmdk-item=""]',MD=`${x$}:not([aria-disabled="true"])`,IC="cmdk-item-select",eu="data-value",ese=(e,t,n)=>Zie(e,t,n),w$=w.createContext(void 0),jp=()=>w.useContext(w$),C$=w.createContext(void 0),d2=()=>w.useContext(C$),S$=w.createContext(void 0),E$=w.forwardRef((e,t)=>{let n=tu(()=>{var $,D;return{search:"",value:(D=($=e.value)!=null?$:e.defaultValue)!=null?D:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=tu(()=>new Set),o=tu(()=>new Map),i=tu(()=>new Map),s=tu(()=>new Set),a=_$(e),{label:l,children:c,value:u,onValueChange:d,filter:h,shouldFilter:p,loop:g,disablePointerSelection:m=!1,vimBindings:b=!0,...y}=e,v=Nn(),x=Nn(),C=Nn(),_=w.useRef(null),S=dse();nc(()=>{if(u!==void 0){let $=u.trim();n.current.value=$,E.emit()}},[u]),nc(()=>{S(6,j)},[]);let E=w.useMemo(()=>({subscribe:$=>(s.current.add($),()=>s.current.delete($)),snapshot:()=>n.current,setState:($,D,H)=>{var V,G,q,K;if(!Object.is(n.current[$],D)){if(n.current[$]=D,$==="search")P(),M(),S(1,I);else if($==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Y=document.getElementById(C);Y?Y.focus():(V=document.getElementById(v))==null||V.focus()}if(S(7,()=>{var Y;n.current.selectedItemId=(Y=F())==null?void 0:Y.id,E.emit()}),H||S(5,j),((G=a.current)==null?void 0:G.value)!==void 0){let Y=D??"";(K=(q=a.current).onValueChange)==null||K.call(q,Y);return}}E.emit()}},emit:()=>{s.current.forEach($=>$())}}),[]),k=w.useMemo(()=>({value:($,D,H)=>{var V;D!==((V=i.current.get($))==null?void 0:V.value)&&(i.current.set($,{value:D,keywords:H}),n.current.filtered.items.set($,N(D,H)),S(2,()=>{M(),E.emit()}))},item:($,D)=>(r.current.add($),D&&(o.current.has(D)?o.current.get(D).add($):o.current.set(D,new Set([$]))),S(3,()=>{P(),M(),n.current.value||I(),E.emit()}),()=>{i.current.delete($),r.current.delete($),n.current.filtered.items.delete($);let H=F();S(4,()=>{P(),(H==null?void 0:H.getAttribute("id"))===$&&I(),E.emit()})}),group:$=>(o.current.has($)||o.current.set($,new Set),()=>{i.current.delete($),o.current.delete($)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:v,inputId:C,labelId:x,listInnerRef:_}),[]);function N($,D){var H,V;let G=(V=(H=a.current)==null?void 0:H.filter)!=null?V:ese;return $?G($,n.current.search,D):0}function M(){if(!n.current.search||a.current.shouldFilter===!1)return;let $=n.current.filtered.items,D=[];n.current.filtered.groups.forEach(V=>{let G=o.current.get(V),q=0;G.forEach(K=>{let Y=$.get(K);q=Math.max(Y,q)}),D.push([V,q])});let H=_.current;T().sort((V,G)=>{var q,K;let Y=V.getAttribute("id"),Q=G.getAttribute("id");return((q=$.get(Q))!=null?q:0)-((K=$.get(Y))!=null?K:0)}).forEach(V=>{let G=V.closest(Fx);G?G.appendChild(V.parentElement===G?V:V.closest(`${Fx} > *`)):H.appendChild(V.parentElement===H?V:V.closest(`${Fx} > *`))}),D.sort((V,G)=>G[1]-V[1]).forEach(V=>{var G;let q=(G=_.current)==null?void 0:G.querySelector(`${Kd}[${eu}="${encodeURIComponent(V[0])}"]`);q==null||q.parentElement.appendChild(q)})}function I(){let $=T().find(H=>H.getAttribute("aria-disabled")!=="true"),D=$==null?void 0:$.getAttribute(eu);E.setState("value",D||void 0)}function P(){var $,D,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 K=(D=($=i.current.get(q))==null?void 0:$.value)!=null?D:"",Y=(V=(H=i.current.get(q))==null?void 0:H.keywords)!=null?V:[],Q=N(K,Y);n.current.filtered.items.set(q,Q),Q>0&&G++}for(let[q,K]of o.current)for(let Y of K)if(n.current.filtered.items.get(Y)>0){n.current.filtered.groups.add(q);break}n.current.filtered.count=G}function j(){var $,D,H;let V=F();V&&((($=V.parentElement)==null?void 0:$.firstChild)===V&&((H=(D=V.closest(Kd))==null?void 0:D.querySelector(Jie))==null||H.scrollIntoView({block:"nearest"})),V.scrollIntoView({block:"nearest"}))}function F(){var $;return($=_.current)==null?void 0:$.querySelector(`${x$}[aria-selected="true"]`)}function T(){var $;return Array.from((($=_.current)==null?void 0:$.querySelectorAll(MD))||[])}function O($){let D=T()[$];D&&E.setState("value",D.getAttribute(eu))}function L($){var D;let H=F(),V=T(),G=V.findIndex(K=>K===H),q=V[G+$];(D=a.current)!=null&&D.loop&&(q=G+$<0?V[V.length-1]:G+$===V.length?V[0]:V[G+$]),q&&E.setState("value",q.getAttribute(eu))}function B($){let D=F(),H=D==null?void 0:D.closest(Kd),V;for(;H&&!V;)H=$>0?cse(H,Kd):use(H,Kd),V=H==null?void 0:H.querySelector(MD);V?E.setState("value",V.getAttribute(eu)):L($)}let z=()=>O(T().length-1),A=$=>{$.preventDefault(),$.metaKey?z():$.altKey?B(1):L(1)},W=$=>{$.preventDefault(),$.metaKey?O(0):$.altKey?B(-1):L(-1)};return w.createElement(_e.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:$=>{var D;(D=y.onKeyDown)==null||D.call(y,$);let H=$.nativeEvent.isComposing||$.keyCode===229;if(!($.defaultPrevented||H))switch($.key){case"n":case"j":{b&&$.ctrlKey&&A($);break}case"ArrowDown":{A($);break}case"p":case"k":{b&&$.ctrlKey&&W($);break}case"ArrowUp":{W($);break}case"Home":{$.preventDefault(),O(0);break}case"End":{$.preventDefault(),z();break}case"Enter":{$.preventDefault();let V=F();if(V){let G=new Event(IC);V.dispatchEvent(G)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:hse},l),Ny(e,$=>w.createElement(C$.Provider,{value:E},w.createElement(w$.Provider,{value:k},$))))}),tse=w.forwardRef((e,t)=>{var n,r;let o=Nn(),i=w.useRef(null),s=w.useContext(S$),a=jp(),l=_$(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:s==null?void 0:s.forceMount;nc(()=>{if(!c)return a.item(o,s==null?void 0:s.id)},[c]);let u=R$(o,i,[e.value,e.children,i],e.keywords),d=d2(),h=Ea(S=>S.value&&S.value===u.current),p=Ea(S=>c||a.filter()===!1?!0:S.search?S.filtered.items.get(o)>0:!0);w.useEffect(()=>{let S=i.current;if(!(!S||e.disabled))return S.addEventListener(IC,g),()=>S.removeEventListener(IC,g)},[p,e.onSelect,e.disabled]);function g(){var S,E;m(),(E=(S=l.current).onSelect)==null||E.call(S,u.current)}function m(){d.setState("value",u.current,!0)}if(!p)return null;let{disabled:b,value:y,onSelect:v,forceMount:x,keywords:C,..._}=e;return w.createElement(_e.div,{ref:Sr(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)}),nse=w.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...i}=e,s=Nn(),a=w.useRef(null),l=w.useRef(null),c=Nn(),u=jp(),d=Ea(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(s):!0);nc(()=>u.group(s),[]),R$(s,a,[e.value,e.heading,l]);let h=w.useMemo(()=>({id:s,forceMount:o}),[o]);return w.createElement(_e.div,{ref:Sr(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),Ny(e,p=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},w.createElement(S$.Provider,{value:h},p))))}),rse=w.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=w.useRef(null),i=Ea(s=>!s.search);return!n&&!i?null:w.createElement(_e.div,{ref:Sr(o,t),...r,"cmdk-separator":"",role:"separator"})}),ose=w.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,i=d2(),s=Ea(c=>c.search),a=Ea(c=>c.selectedItemId),l=jp();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)}})}),ise=w.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,i=w.useRef(null),s=w.useRef(null),a=Ea(c=>c.selectedItemId),l=jp();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:Sr(i,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Ny(e,c=>w.createElement("div",{ref:Sr(s,l.listInnerRef),"cmdk-list-sizer":""},c)))}),sse=w.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:i,container:s,...a}=e;return w.createElement(h4,{open:n,onOpenChange:r},w.createElement(p4,{container:s},w.createElement(I_,{"cmdk-overlay":"",className:o}),w.createElement(T_,{"aria-label":e.label,"cmdk-dialog":"",className:i},w.createElement(E$,{ref:t,...a}))))}),ase=w.forwardRef((e,t)=>Ea(n=>n.filtered.count===0)?w.createElement(_e.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),lse=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},Ny(e,s=>w.createElement("div",{"aria-hidden":!0},s)))}),Kr=Object.assign(E$,{List:ise,Item:tse,Input:ose,Group:nse,Separator:rse,Dialog:sse,Empty:ase,Loading:lse});function cse(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function use(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function _$(e){let t=w.useRef(e);return nc(()=>{t.current=e}),t}var nc=typeof window>"u"?w.useEffect:w.useLayoutEffect;function tu(e){let t=w.useRef();return t.current===void 0&&(t.current=e()),t}function Ea(e){let t=d2(),n=()=>e(t.snapshot());return w.useSyncExternalStore(t.subscribe,n,n)}function R$(e,t,n,r=[]){let o=w.useRef(),i=jp();return nc(()=>{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(eu,a),o.current=a}),o}var dse=()=>{let[e,t]=w.useState(),n=tu(()=>new Map);return nc(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function fse(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Ny({asChild:e,children:t},n){return e&&w.isValidElement(t)?w.cloneElement(fse(t),{ref:t.ref},n(t.props.children)):n(t)}var hse={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const My=w.forwardRef(({className:e,...t},n)=>f.jsx(Kr,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));My.displayName=Kr.displayName;const Dy=w.forwardRef(({className:e,...t},n)=>f.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[f.jsx(E_,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),f.jsx(Kr.Input,{ref:n,className:oe("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})]}));Dy.displayName=Kr.Input.displayName;const Py=w.forwardRef(({className:e,...t},n)=>f.jsx(Kr.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Py.displayName=Kr.List.displayName;const Ay=w.forwardRef((e,t)=>f.jsx(Kr.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Ay.displayName=Kr.Empty.displayName;const Iy=w.forwardRef(({className:e,...t},n)=>f.jsx(Kr.Group,{ref:n,className:oe("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}));Iy.displayName=Kr.Group.displayName;const pse=w.forwardRef(({className:e,...t},n)=>f.jsx(Kr.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));pse.displayName=Kr.Separator.displayName;const Ty=w.forwardRef(({className:e,...t},n)=>f.jsx(Kr.Item,{ref:n,className:oe("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}));Ty.displayName=Kr.Item.displayName;function mse({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(za,{open:a,onOpenChange:l,children:[f.jsx(Ba,{asChild:!0,children:f.jsxs(Se,{variant:"outline",role:"combobox","aria-expanded":a,className:oe("justify-between",o),disabled:i,children:[u?u.label:r,f.jsx(fF,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),f.jsx(Ts,{className:"z-50 w-[200px] p-0",children:f.jsxs(My,{children:[f.jsx(Dy,{placeholder:"Search fields..."}),f.jsxs(Py,{children:[f.jsx(Ay,{children:"No field found."}),f.jsx(Iy,{children:c.map(d=>f.jsxs(Ty,{value:d.label,onSelect:()=>{n(d.id),l(!1)},children:[f.jsx(Ur,{className:oe("mr-2 h-4 w-4",t===d.id?"opacity-100":"opacity-0")}),d.label]},d.id))})]})]})})]})}function gse({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}=W_({id:e.id,disabled:u}),b={transform:Ai.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(Pre,{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(Se,{size:"sm",variant:"ghost",onClick:v=>{v.stopPropagation(),i(e.id)},onPointerDown:v=>v.stopPropagation(),children:f.jsx(pp,{className:"h-3 w-3"})})})]}),f.jsx(Hie,{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(mse,{fields:n,excludeFieldIds:y,onValueChange:v=>c(e.id,v),placeholder:"Add drill step...",className:"w-48"})})})]})}function bse({configuringIntent:e,setConfiguringIntent:t,drillHierarchies:n,onUpdateHierarchies:r,availableFields:o}){const i=F_(bh(_p),bh(Ep,{coordinateGetter:U_})),{editingHierarchy:s,setEditingHierarchy:a,createNewHierarchy:l,deleteHierarchy:c,updateHierarchy:u,addStepToHierarchy:d,removeStepFromHierarchy:h,updateStep:p,setDefaultHierarchy:g}=Dre(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),C=n.findIndex(_=>_.id===(v==null?void 0:v.id));r(kp(n,x,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-blue-100",children:f.jsx(cF,{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(Se,{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(Se,{size:"sm",onClick:l,children:[f.jsx(Cc,{className:"mr-1 h-4 w-4"}),"Add Hierarchy"]})})]}),f.jsx(V_,{sensors:i,collisionDetection:$_,onDragEnd:m,children:f.jsx(H_,{items:n.map(b=>b.id),strategy:U4,children:f.jsx("div",{className:"mb-6 space-y-4",children:n.map(b=>f.jsx(gse,{hierarchy:b,editingHierarchy:s,sampleFieldReferences:o,onSetEditingHierarchy:a,onUpdateHierarchy:u,onDeleteHierarchy:c,onSetDefaultHierarchy:g,onUpdateStep:p,onRemoveStep:h,onAddStep:d},b.id))})})})]})]})]})})}var f2="Checkbox",[yse,tLe]=On(f2),[vse,xse]=yse(f2),k$=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=He(t,C=>p(C)),m=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=dr({prop:o,defaultProp:i,onChange:c}),x=w.useRef(y);return w.useEffect(()=>{const C=h==null?void 0:h.form;if(C){const _=()=>v(x.current);return C.addEventListener("reset",_),()=>C.removeEventListener("reset",_)}},[h,v]),f.jsxs(vse,{scope:n,state:y,disabled:a,children:[f.jsx(_e.button,{type:"button",role:"checkbox","aria-checked":ya(y)?"mixed":y,"aria-required":s,"data-state":D$(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:g,onKeyDown:he(e.onKeyDown,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:he(e.onClick,C=>{v(_=>ya(_)?!0:!_),b&&(m.current=C.isPropagationStopped(),m.current||C.stopPropagation())})}),b&&f.jsx(wse,{control:h,bubbles:!m.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:ya(i)?!1:i})]})});k$.displayName=f2;var N$="CheckboxIndicator",M$=w.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=xse(N$,n);return f.jsx(gn,{present:r||ya(i.state)||i.state===!0,children:f.jsx(_e.span,{"data-state":D$(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});M$.displayName=N$;var wse=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=w.useRef(null),a=Ey(n),l=Cy(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=ya(n),p.call(u,ya(n)?!1:n),u.dispatchEvent(g)}},[a,n,r]);const c=w.useRef(ya(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 ya(e){return e==="indeterminate"}function D$(e){return ya(e)?"indeterminate":e?"checked":"unchecked"}var P$=k$,Cse=M$;const qr=w.forwardRef(({className:e,...t},n)=>f.jsx(P$,{ref:n,className:oe("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(Cse,{className:oe("flex items-center justify-center text-current"),children:f.jsx(Ur,{className:"h-4 w-4"})})}));qr.displayName=P$.displayName;function Sse({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(Cr,{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(Se,{size:"sm",variant:"outline",onClick:l,children:"Select All"}),f.jsx(Se,{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(qr,{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 Ese=e=>["string","boolean"].includes(wO(e.dataType));function _se({configuringIntent:e,setConfiguringIntent:t,selectedDrillTargets:n,setSelectedDrillTargets:r,availableFields:o}){const i=o.filter(Ese),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(wF,{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(Se,{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(Sse,{fields:i,selectedFieldIds:s,onSelectionChange:a,searchPlaceholder:"Search fields..."})})]})]})]})]})})}var h2="Switch",[Rse,nLe]=On(h2),[kse,Nse]=Rse(h2),A$=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=He(t,x=>p(x)),m=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=dr({prop:o,defaultProp:i,onChange:c});return f.jsxs(kse,{scope:n,checked:y,disabled:a,children:[f.jsx(_e.button,{type:"button",role:"switch","aria-checked":y,"aria-required":s,"data-state":j$(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:g,onClick:he(e.onClick,x=>{v(C=>!C),b&&(m.current=x.isPropagationStopped(),m.current||x.stopPropagation())})}),b&&f.jsx(Mse,{control:h,bubbles:!m.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});A$.displayName=h2;var I$="SwitchThumb",T$=w.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Nse(I$,n);return f.jsx(_e.span,{"data-state":j$(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});T$.displayName=I$;var Mse=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=Ey(n),a=Cy(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 j$(e){return e?"checked":"unchecked"}var jy=A$,O$=T$;const p2=w.forwardRef(({className:e,...t},n)=>f.jsx(jy,{className:oe("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(O$,{className:oe("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")})}));p2.displayName=jy.displayName;var m2="Radio",[Dse,F$]=On(m2),[Pse,Ase]=Dse(m2),$$=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=He(t,b=>h(b)),g=w.useRef(!1),m=d?c||!!d.closest("form"):!0;return f.jsxs(Pse,{scope:n,checked:o,disabled:s,children:[f.jsx(_e.button,{type:"button",role:"radio","aria-checked":o,"data-state":B$(o),"data-disabled":s?"":void 0,disabled:s,value:a,...u,ref:p,onClick:he(e.onClick,b=>{o||l==null||l(),m&&(g.current=b.isPropagationStopped(),g.current||b.stopPropagation())})}),m&&f.jsx(Ise,{control:d,bubbles:!g.current,name:r,value:a,checked:o,required:i,disabled:s,form:c,style:{transform:"translateX(-100%)"}})]})});$$.displayName=m2;var L$="RadioIndicator",z$=w.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...o}=e,i=Ase(L$,n);return f.jsx(gn,{present:r||i.checked,children:f.jsx(_e.span,{"data-state":B$(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})});z$.displayName=L$;var Ise=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=Ey(n),a=Cy(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 B$(e){return e?"checked":"unchecked"}var Tse=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],g2="RadioGroup",[jse,rLe]=On(g2,[gd,F$]),V$=gd(),H$=F$(),[Ose,Fse]=jse(g2),W$=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=V$(n),g=yc(c),[m,b]=dr({prop:i,defaultProp:o,onChange:d});return f.jsx(Ose,{scope:n,name:r,required:s,disabled:a,value:m,onValueChange:b,children:f.jsx(BE,{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})})})});W$.displayName=g2;var U$="RadioGroupItem",q$=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...o}=e,i=Fse(U$,n),s=i.disabled||r,a=V$(n),l=H$(n),c=w.useRef(null),u=He(t,c),d=i.value===o.value,h=w.useRef(!1);return w.useEffect(()=>{const p=m=>{Tse.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(VE,{asChild:!0,...a,focusable:!s,active:d,children:f.jsx($$,{disabled:s,required:i.required,checked:d,...l,...o,name:i.name,ref:u,onCheck:()=>i.onValueChange(o.value),onKeyDown:he(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:he(o.onFocus,()=>{var p;h.current&&((p=c.current)==null||p.click())})})})});q$.displayName=U$;var $se="RadioGroupIndicator",G$=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,o=H$(n);return f.jsx(z$,{...o,...r,ref:t})});G$.displayName=$se;var Y$=W$,K$=q$,Lse=G$;const _a=w.forwardRef(({className:e,...t},n)=>f.jsx(Y$,{className:oe("grid gap-2",e),...t,ref:n}));_a.displayName=Y$.displayName;const Vr=w.forwardRef(({className:e,...t},n)=>f.jsx(K$,{ref:n,className:oe("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(Lse,{className:"flex items-center justify-center",children:f.jsx(m_,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Vr.displayName=K$.displayName;function zse({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=mO(),h=e==="clickFilter",p=()=>{const S=!i;if(s(S),S){const E={filterFields:n,highlightSelf:!0,mode:"clickFilter"};l(E),r([E])}else r([])},g=()=>{t("clickFilter")},m=()=>{t(null)},b=S=>{const E={...a,...S};l(E),r([E])},y=()=>a.applyToCardIds!==void 0?"specific-cards":a.excludeCardIds!==void 0?"all-except-specific":"all-cards",v=S=>{const E={};switch(S){case"all-cards":E.applyToCardIds=void 0,E.excludeCardIds=void 0;break;case"specific-cards":E.applyToCardIds=[],E.excludeCardIds=void 0;break;case"all-except-specific":E.applyToCardIds=void 0,E.excludeCardIds=[];break}b(E)},x=(S,E)=>{if(E==="specific-cards"){const k=a.applyToCardIds||[],N=k.includes(S)?k.filter(M=>M!==S):[...k,S];b({applyToCardIds:N})}else if(E==="all-except-specific"){const k=a.excludeCardIds||[],N=k.includes(S)?k.filter(M=>M!==S):[...k,S];b({excludeCardIds:N})}},C=R.useMemo(()=>{if(!c.trim())return d;const S=c.toLowerCase();return d==null?void 0:d.filter(E=>{var k;return(k=E==null?void 0:E.title)==null?void 0:k.toLowerCase().includes(S)})},[c,d]),_=()=>{var E,k;if(!i)return"0 settings configured";const S=y();if(S==="all-cards")return"filtering all cards";if(S==="specific-cards"){const N=((E=a.applyToCardIds)==null?void 0:E.length)||0;return N===0?"no cards selected":`filtering ${N} card${N!==1?"s":""}`}else if(S==="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(p2,{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(Se,{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(fe,{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(_a,{value:y(),onValueChange:S=>v(S),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(Vr,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(fe,{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(Vr,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(fe,{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(fe,{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(Cr,{placeholder:"Search cards...",value:c,onChange:S=>u(S.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:C.length>0?C.map(S=>{const E=(a.applyToCardIds||[]).includes(S.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(qr,{id:`card-${S.id}`,checked:E,onCheckedChange:()=>x(S.id,"specific-cards")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(fe,{htmlFor:`card-${S.id}`,className:"cursor-pointer text-sm font-medium",children:S.title}),S.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:S.description})]})]},S.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(Vr,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(fe,{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(fe,{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(Cr,{placeholder:"Search cards...",value:c,onChange:S=>u(S.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:C.length>0?C.map(S=>{const E=(a.excludeCardIds||[]).includes(S.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(qr,{id:`card-exclude-${S.id}`,checked:E,onCheckedChange:()=>x(S.id,"all-except-specific")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(fe,{htmlFor:`card-exclude-${S.id}`,className:"cursor-pointer text-sm font-medium",children:S.title}),S.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:S.description})]})]},S.id)}):f.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]})]})]})})]})]})]})})}function Bse(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||Di(n.name),description:n.description,entityId:t.entityId,entityName:t.entityName,entityType:t.entityType})))}function X$(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 Q$(e){var m;const t=re(b=>b.authToken)||e,{hasSchemaSupport:n}=iee(e),r=ue(b=>{var y;return(y=b.card.dataSource)==null?void 0:y.connectionId}),o=ue(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=ue(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=ue(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:!!r&&!!b.name&&!!b.database:!1}const l=[...o,...i,...s],c=gK({queries:l.map(b=>{let y={};return b.type==="model"?y={connection_id:r,datamodel_id:b.id,database_name:"",schema_name:"",table_name:"",domain_id:b.domainId,dataset_name:b.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:()=>Tn("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 C;const v=l[y],x=X$(v);return{entityId:v.id||v.name,entityType:v.type,entityName:v.name,label:v.label,description:v.description,qualifiedEntityName:x,columns:(C=b.data)==null?void 0:C.columns.map(_=>({id:`${v.name}-${_.column_name}`,name:_.column_name,dataType:_.data_type,label:_.label||xO(_.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=Bse(p);return{columnGroups:p,columns:g,isLoading:u,hasError:d,error:h,refetch:()=>{c.forEach(b=>b.refetch())}}}function Vse({isOpen:e,onClose:t}){var T,O,L,B;const n=XJ(),r=QJ(),{updateCurrentDashboardCard:o}=Gt(),{columns:i}=Q$(),{groupByFields:s,pivotByFields:a}=gO(),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)||[]},[(L=n.interactionConfig)==null?void 0:L.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),[C,_]=R.useState(()=>p.filter(z=>z.mode==="drillToURL")),[S,E]=R.useState(()=>p.filter(z=>z.mode==="drillThrough")),[k,N]=R.useState(()=>p.filter(z=>z.mode==="drillToDetail")),[M,I]=R.useState(h),P=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 $=((W=n.interactionConfig)==null?void 0:W.drillInteractions)||[];_($.filter(D=>D.mode==="drillToURL")),E($.filter(D=>D.mode==="drillThrough")),N($.filter(D=>D.mode==="drillToDetail")),I(h)}},[e,n.interactionConfig,h]);const j=()=>{var W;const z=[...C,...S,...k];r.updateDrillHierarchies(g),r.updateDrillInteractions(z),(W=P.current)!=null&&W.saveToGlobal&&P.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(uy,{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(gp,{className:"flex max-h-[90vh] max-w-4xl flex-col overflow-hidden",children:[f.jsxs(bp,{children:[f.jsx(vp,{children:"Configure Interactions"}),f.jsx(xp,{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(zse,{configuringIntent:v,setConfiguringIntent:x,incomingFilterFields:l,onUpdateClickFilterInteractions:I,currentClickFilterInteractions:M}),f.jsx(bse,{configuringIntent:v,setConfiguringIntent:x,drillHierarchies:g,onUpdateHierarchies:m,availableFields:c}),f.jsx(_se,{configuringIntent:v,setConfiguringIntent:x,selectedDrillTargets:b,setSelectedDrillTargets:y,availableFields:c})]})})})}),f.jsxs(yp,{className:"border-t-0",children:[f.jsx(Se,{variant:"outline",onClick:F,children:"Cancel"}),f.jsx(Se,{onClick:j,children:"Save Changes"})]})]})]}):null}function Z$({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}=see(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(ga,{className:"size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}),f.jsx(Vse,{isOpen:o,onClose:()=>i(!1)}),t&&(n?f.jsx("button",{onClick:()=>{l(!n)},children:f.jsx(UZ,{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(GZ,{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(iF,{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(SJ,{data:(d==null?void 0:d.records)||[],filename:u.title})]})})}const Hse=R.createContext(null),$x={didCatch:!1,error:null};class Oy extends R.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=$x}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($x)}}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&&Wse(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($x)}}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(Hse.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function Wse(){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 b2({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 Use({error:e,frame:t}){return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[f.jsx(Z$,{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 qse({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 ur({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 Fy(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function $y(e){try{const n=new Function("getDatalabelColor",e)(M1);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 Gse(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 Yse(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return J$(t)}function J$(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 Kse(e,t){return e.map(r=>Object.fromEntries(Object.entries(r).filter(([o])=>!t.some(i=>i.label===o))))}function Xse(e){return e.length===1?[e[0]]:e.slice(1).filter(n=>!uO.includes(n))}function Vc({data:e,cfg:t,customCfg:n,preferences:r,cardType:o,card:i}){var x;const s=o==="radar"?.2:1,{keys:a}=pn(e),l=Xse(a);let c="none";o=="bar"?c="bar":o=="line"&&(c="line");const u=jF(l,e,r,s,c),d=Il(u,n),h=a[0],p=mp(e,h),{options:g,plugins:m}=Ab({cardType:o,cfg:t,preferences:r,customCfg:n}),b=(x=i.interactionConfig)==null?void 0:x.clickFilterInteractions,y=function(C,_){var E;const S=((E=C.native)==null?void 0:E.target)||C.target;_.length?S.style.cursor="pointer":S.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 eL(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 Qse(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 tL(e,t){var i,s,a,l,c,u,d,h,p,g,m,b;const n=eL(t,e),r=Qse(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,C,_;return ur({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:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.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,C,_;return ur({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:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.locale)||"",currency:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.currency)||""})}}}}}function Ab({cardType:e,cfg:t,preferences:n,customCfg:r}){var g,m,b,y,v,x,C,_,S,E,k,N,M,I,P,j,F,T,O,L,B,z,A,W,$,D,H,V,G;const o=re.getState().themeStyle,i=tL(t,n),s=qn((t==null?void 0:t.options)||{},n==null?void 0:n.chartOptions),a=qn(i,s),l=qn(a,(r==null?void 0:r.options)||{}),c=Zse(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:(_=(C=(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:C.grid)==null?void 0:_.color}},y:{...(S=l==null?void 0:l.scales)==null?void 0:S.y,grid:{...(k=(E=l==null?void 0:l.scales)==null?void 0:E.y)==null?void 0:k.grid,color:(j=(P=(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:P.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=(L=(O=(T=o==null?void 0:o.chart)==null?void 0:T.options)==null?void 0:O.plugins)==null?void 0:L.tooltip)==null?void 0:B.backgroundColor,bodyColor:($=(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:$.bodyColor,titleColor:(G=(V=(H=(D=o==null?void 0:o.chart)==null?void 0:D.options)==null?void 0:H.plugins)==null?void 0:V.tooltip)==null?void 0:G.titleColor}}},{plugins:d,options:h}=$y((n==null?void 0:n.customVisualCode)||"");return{options:qn(u,h),plugins:d}}function Zse(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=ur({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=ur({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)||{}}}/*!
|
|
490
|
+
`},nne={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 rne(e){let{announcements:t=nne,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=tne}=e;const{announce:i,announcement:s}=Zte(),a=Sp("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(Xte,{id:r,value:o.draggable}),R.createElement(Qte,{id:a,announcement:s}));return n?an.createPortal(u,n):u}var An;(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"})(An||(An={}));function _b(){}function bh(e,t){return R.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function F_(){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 Zo=Object.freeze({x:0,y:0});function w4(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function one(e,t){const n=Eb(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 C4(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function ine(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function JM(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 eD(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 $_=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=eD(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=w4(eD(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(C4)},sne=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=JM(t),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=JM(l),u=o.reduce((h,p,g)=>h+w4(c[g],p),0),d=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:d}})}}return i.sort(C4)};function ane(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 lne=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=ane(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(ine)};function cne(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function E4(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Zo}function une(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 dne=une(1);function _4(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 fne(e,t,n){const r=_4(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 hne={ignoreTransform:!1};function wd(e,t){t===void 0&&(t=hne);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=_r(e).getComputedStyle(e);c&&(n=fne(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 tD(e){return wd(e,{ignoreTransform:!0})}function pne(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function mne(e,t){return t===void 0&&(t=_r(e).getComputedStyle(e)),t.position==="fixed"}function gne(e,t){t===void 0&&(t=_r(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 py(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(O_(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!wp(o)||y4(o)||n.includes(o))return n;const i=_r(e).getComputedStyle(o);return o!==e&&gne(o,i)&&n.push(o),mne(o,i)?n:r(o.parentNode)}return e?r(e):n}function R4(e){const[t]=py(e,1);return t??null}function Rx(e){return!dy||!e?null:vd(e)?e:j_(e)?O_(e)||e===xd(e).scrollingElement?window:wp(e)?e:null:null}function k4(e){return vd(e)?e.scrollX:e.scrollLeft}function N4(e){return vd(e)?e.scrollY:e.scrollTop}function bC(e){return{x:k4(e),y:N4(e)}}var $n;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})($n||($n={}));function M4(e){return!dy||!e?!1:e===document.scrollingElement}function D4(e){const t={x:0,y:0},n=M4(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 bne={x:.2,y:.2};function yne(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=bne);const{isTop:c,isBottom:u,isLeft:d,isRight:h}=D4(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=$n.Backward,g.y=r*Math.abs((t.top+m.height-i)/m.height)):!u&&l>=t.bottom-m.height&&(p.y=$n.Forward,g.y=r*Math.abs((t.bottom-m.height-l)/m.height)),!h&&a>=t.right-m.width?(p.x=$n.Forward,g.x=r*Math.abs((t.right-m.width-a)/m.width)):!d&&s<=t.left+m.width&&(p.x=$n.Backward,g.x=r*Math.abs((t.left+m.width-s)/m.width)),{direction:p,speed:g}}function vne(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)=>bu(t,bC(n)),Zo)}function xne(e){return e.reduce((t,n)=>t+k4(n),0)}function wne(e){return e.reduce((t,n)=>t+N4(n),0)}function A4(e,t){if(t===void 0&&(t=wd),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);R4(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Cne=[["x",["left","right"],xne],["y",["top","bottom"],wne]];class L_{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=py(n),o=P4(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of Cne)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 Pf{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 Sne(e){const{EventTarget:t}=_r(e);return e instanceof t?e:xd(e)}function kx(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 So;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(So||(So={}));function nD(e){e.preventDefault()}function Ene(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 I4={start:[ht.Space,ht.Enter],cancel:[ht.Esc],end:[ht.Space,ht.Enter,ht.Tab]},_ne=(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 Ep{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 Pf(xd(n)),this.windowListeners=new Pf(_r(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(So.Resize,this.handleCancel),this.windowListeners.add(So.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(So.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&A4(r),n(Zo)}handleKeyDown(t){if(hy(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=I4,coordinateGetter:s=_ne,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}:Zo;this.referenceCoordinates||(this.referenceCoordinates=u);const d=s(t,{active:n,context:r.current,currentCoordinates:u});if(d){const h=gh(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:C,maxScroll:_,minScroll:S}=D4(m),E=vne(m),k={x:Math.min(b===ht.Right?E.right-E.width/2:E.right,Math.max(b===ht.Right?E.left:E.left+E.width/2,d.x)),y:Math.min(b===ht.Down?E.bottom-E.height/2:E.bottom,Math.max(b===ht.Down?E.top:E.top+E.height/2,d.y))},N=b===ht.Right&&!v||b===ht.Left&&!x,M=b===ht.Down&&!C||b===ht.Up&&!y;if(N&&k.x!==d.x){const I=m.scrollLeft+h.x,P=b===ht.Right&&I<=_.x||b===ht.Left&&I>=S.x;if(P&&!h.y){m.scrollTo({left:I,behavior:a});return}P?p.x=m.scrollLeft-I:p.x=b===ht.Right?m.scrollLeft-_.x:m.scrollLeft-S.x,p.x&&m.scrollBy({left:-p.x,behavior:a});break}else if(M&&k.y!==d.y){const I=m.scrollTop+h.y,P=b===ht.Down&&I<=_.y||b===ht.Up&&I>=S.y;if(P&&!h.x){m.scrollTo({top:I,behavior:a});return}P?p.y=m.scrollTop-I:p.y=b===ht.Down?m.scrollTop-_.y:m.scrollTop-S.y,p.y&&m.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(t,bu(gh(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()}}Ep.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=I4,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 rD(e){return!!(e&&"distance"in e)}function oD(e){return!!(e&&"delay"in e)}class z_{constructor(t,n,r){var o;r===void 0&&(r=Sne(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=xd(s),this.documentListeners=new Pf(this.document),this.listeners=new Pf(r),this.windowListeners=new Pf(_r(s)),this.initialCoordinates=(o=Eb(i))!=null?o:Zo,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(So.Resize,this.handleCancel),this.windowListeners.add(So.DragStart,nD),this.windowListeners.add(So.VisibilityChange,this.handleCancel),this.windowListeners.add(So.ContextMenu,nD),this.documentListeners.add(So.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(oD(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(rD(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(So.Click,Ene,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(So.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=Eb(t))!=null?n:Zo,c=gh(o,l);if(!r&&a){if(rD(a)){if(a.tolerance!=null&&kx(c,a.tolerance))return this.handleCancel();if(kx(c,a.distance))return this.handleStart()}if(oD(a)&&kx(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 Rne={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class _p extends z_{constructor(t){const{event:n}=t,r=xd(n.target);super(t,Rne,r)}}_p.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 kne={move:{name:"mousemove"},end:{name:"mouseup"}};var yC;(function(e){e[e.RightClick=2]="RightClick"})(yC||(yC={}));class T4 extends z_{constructor(t){super(t,kne,xd(t.event.target))}}T4.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===yC.RightClick?!1:(r==null||r({event:n}),!0)}}];const Nx={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Nne extends z_{constructor(t){super(t,Nx)}static setup(){return window.addEventListener(Nx.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Nx.move.name,t)};function t(){}}}Nne.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 Af;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Af||(Af={}));var Rb;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Rb||(Rb={}));function Mne(e){let{acceleration:t,activator:n=Af.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=Rb.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:h}=e;const p=Pne({delta:d,disabled:!i}),[g,m]=Ute(),b=R.useRef({x:0,y:0}),y=R.useRef({x:0,y:0}),v=R.useMemo(()=>{switch(n){case Af.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Af.DraggableRect:return o}},[n,o,l]),x=R.useRef(null),C=R.useCallback(()=>{const S=x.current;if(!S)return;const E=b.current.x*y.current.x,k=b.current.y*y.current.y;S.scrollBy(E,k)},[]),_=R.useMemo(()=>a===Rb.TreeOrder?[...c].reverse():c,[a,c]);R.useEffect(()=>{if(!i||!c.length||!v){m();return}for(const S of _){if((r==null?void 0:r(S))===!1)continue;const E=c.indexOf(S),k=u[E];if(!k)continue;const{direction:N,speed:M}=yne(S,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=S,g(C,s),b.current=M,y.current=N;return}}b.current={x:0,y:0},y.current={x:0,y:0},m()},[t,C,r,m,i,s,JSON.stringify(v),JSON.stringify(p),g,c,_,u,JSON.stringify(h)])}const Dne={x:{[$n.Backward]:!1,[$n.Forward]:!1},y:{[$n.Backward]:!1,[$n.Forward]:!1}};function Pne(e){let{delta:t,disabled:n}=e;const r=Sb(t);return Cp(o=>{if(n||!r||!o)return Dne;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[$n.Backward]:o.x[$n.Backward]||i.x===-1,[$n.Forward]:o.x[$n.Forward]||i.x===1},y:{[$n.Backward]:o.y[$n.Backward]||i.y===-1,[$n.Forward]:o.y[$n.Forward]||i.y===1}}},[n,t,r])}function Ane(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Cp(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function Ine(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 yh;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(yh||(yh={}));var vC;(function(e){e.Optimized="optimized"})(vC||(vC={}));const iD=new Map;function Tne(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=mh(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=Cp(y=>{if(d&&!n)return iD;if(!y||y===iD||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 C=x.node.current,_=C?new L_(l(C),C):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 yh.Always:return!1;case yh.BeforeDragging:return n;default:return!n}}}function B_(e,t){return Cp(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function jne(e,t){return B_(e,t)}function One(e){let{callback:t,disabled:n}=e;const r=fy(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 my(e){let{callback:t,disabled:n}=e;const r=fy(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 Fne(e){return new L_(wd(e),e)}function sD(e,t,n){t===void 0&&(t=Fne);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=One({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=my({callback:i});return Qo(()=>{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 $ne(e){const t=B_(e);return E4(e,t)}const aD=[];function Lne(e){const t=R.useRef(e),n=Cp(r=>e?r&&r!==aD&&e&&t.current&&e.parentNode===t.current.parentNode?r:py(e):aD,[e]);return R.useEffect(()=>{t.current=e},[e]),n}function zne(e){const[t,n]=R.useState(null),r=R.useRef(e),o=R.useCallback(i=>{const s=Rx(i.target);s&&n(a=>a?(a.set(s,bC(s)),new Map(a)):null)},[]);return R.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const c=Rx(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,bC(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=Rx(l);c==null||c.removeEventListener("scroll",o)})}},[o,e]),R.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>bu(i,s),Zo):P4(e):Zo,[e,t])}function lD(e,t){t===void 0&&(t=[]);const n=R.useRef(null);return R.useEffect(()=>{n.current=null},t),R.useEffect(()=>{const r=e!==Zo;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?gh(e,n.current):Zo}function Bne(e){R.useEffect(()=>{if(!dy)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 Vne(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 j4(e){return R.useMemo(()=>e?pne(e):null,[e])}const cD=[];function Hne(e,t){t===void 0&&(t=wd);const[n]=e,r=j4(n?_r(n):null),[o,i]=R.useState(cD);function s(){i(()=>e.length?e.map(l=>M4(l)?r:new L_(t(l),l)):cD)}const a=my({callback:s});return Qo(()=>{a==null||a.disconnect(),s(),e.forEach(l=>a==null?void 0:a.observe(l))},[e]),o}function O4(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return wp(t)?t:e}function Wne(e){let{measure:t}=e;const[n,r]=R.useState(null),o=R.useCallback(c=>{for(const{target:u}of c)if(wp(u)){r(d=>{const h=t(u);return d?{...d,width:h.width,height:h.height}:h});break}},[t]),i=my({callback:o}),s=R.useCallback(c=>{const u=O4(c);i==null||i.disconnect(),u&&(i==null||i.observe(u)),r(u?t(u):null)},[t,i]),[a,l]=Cb(s);return R.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const Une=[{sensor:_p,options:{}},{sensor:Ep,options:{}}],qne={current:{}},Bg={draggable:{measure:tD},droppable:{measure:tD,strategy:yh.WhileDragging,frequency:vC.Optimized},dragOverlay:{measure:wd}};class If 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 Gne={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new If,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:_b},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Bg,measureDroppableContainers:_b,windowRect:null,measuringScheduled:!1},F4={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:_b,draggableNodes:new Map,over:null,measureDroppableContainers:_b},Rp=R.createContext(F4),$4=R.createContext(Gne);function Yne(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new If}}}function Kne(e,t){switch(t.type){case An.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case An.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 An.DragEnd:case An.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case An.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new If(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case An.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 If(e.droppable.containers);return s.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case An.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new If(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Xne(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=R.useContext(Rp),i=Sb(r),s=Sb(n==null?void 0:n.id);return R.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!hy(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=Yte(u);if(d){d.focus();break}}})}},[r,t,o,s,i]),null}function L4(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function Qne(e){return R.useMemo(()=>({draggable:{...Bg.draggable,...e==null?void 0:e.draggable},droppable:{...Bg.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Bg.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 Zne(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;Qo(()=>{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=E4(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=R4(c);h&&h.scrollBy({top:d.y,left:d.x})}},[t,s,a,r,n])}const gy=R.createContext({...Zo,scaleX:1,scaleY:1});var Xs;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Xs||(Xs={}));const V_=R.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=Une,collisionDetection:d=lne,measuring:h,modifiers:p,...g}=t;const m=R.useReducer(Kne,void 0,Yne),[b,y]=m,[v,x]=ene(),[C,_]=R.useState(Xs.Uninitialized),S=C===Xs.Initialized,{draggable:{active:E,nodes:k,translate:N},droppable:{containers:M}}=b,I=E!=null?k.get(E):null,P=R.useRef({initial:null,translated:null}),j=R.useMemo(()=>{var cn;return E!=null?{id:E,data:(cn=I==null?void 0:I.data)!=null?cn:qne,rect:P}:null},[E,I]),F=R.useRef(null),[T,O]=R.useState(null),[L,B]=R.useState(null),z=mh(g,Object.values(g)),A=Sp("DndDescribedBy",s),W=R.useMemo(()=>M.getEnabled(),[M]),$=Qne(h),{droppableRects:D,measureDroppableContainers:H,measuringScheduled:V}=Tne(W,{dragging:S,dependencies:[N.x,N.y],config:$.droppable}),G=Ane(k,E),q=R.useMemo(()=>L?Eb(L):null,[L]),K=Ki(),Y=jne(G,$.draggable.measure);Zne({activeNode:E!=null?k.get(E):null,config:K.layoutShiftCompensation,initialRect:Y,measure:$.draggable.measure});const Q=sD(G,$.draggable.measure,Y),ne=sD(G?G.parentElement:null),Z=R.useRef({activatorEvent:null,active:null,activeNode:G,collisionRect:null,collisions:null,droppableRects:D,draggableNodes:k,draggingNode:null,draggingNodeRect:null,droppableContainers:M,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ie=M.getNodeFor((n=Z.current.over)==null?void 0:n.id),te=Wne({measure:$.dragOverlay.measure}),ce=(r=te.nodeRef.current)!=null?r:G,de=S?(o=te.rect)!=null?o:Q:null,ke=!!(te.nodeRef.current&&te.rect),we=$ne(ke?null:Q),Ce=j4(ce?_r(ce):null),Pe=Lne(S?ie??G:null),Ye=Hne(Pe),_t=L4(p,{transform:{x:N.x-we.x,y:N.y-we.y,scaleX:1,scaleY:1},activatorEvent:L,active:j,activeNodeRect:Q,containerNodeRect:ne,draggingNodeRect:de,over:Z.current.over,overlayNodeRect:te.rect,scrollableAncestors:Pe,scrollableAncestorRects:Ye,windowRect:Ce}),ge=q?bu(q,N):null,je=zne(Pe),Ae=lD(je),ee=lD(je,[Q]),le=bu(_t,Ae),Re=de?dne(de,_t):null,De=j&&Re?d({active:j,collisionRect:Re,droppableRects:D,droppableContainers:W,pointerCoordinates:ge}):null,Ue=S4(De,"id"),[jt,Pn]=R.useState(null),vn=ke?_t:bu(_t,ee),ye=cne(vn,(i=jt==null?void 0:jt.rect)!=null?i:null,Q),xn=R.useRef(null),Ot=R.useCallback((cn,Rt)=>{let{sensor:Vn,options:Ie}=Rt;if(F.current==null)return;const qe=k.get(F.current);if(!qe)return;const rt=cn.nativeEvent,nn=new Vn({active:F.current,activeNode:qe,event:rt,options:Ie,context:Z,onAbort($t){if(!k.get($t))return;const{onDragAbort:rn}=z.current,wn={id:$t};rn==null||rn(wn),v({type:"onDragAbort",event:wn})},onPending($t,Fn,rn,wn){if(!k.get($t))return;const{onDragPending:bo}=z.current,li={id:$t,constraint:Fn,initialCoordinates:rn,offset:wn};bo==null||bo(li),v({type:"onDragPending",event:li})},onStart($t){const Fn=F.current;if(Fn==null)return;const rn=k.get(Fn);if(!rn)return;const{onDragStart:wn}=z.current,Xa={activatorEvent:rt,active:{id:Fn,data:rn.data,rect:P}};an.unstable_batchedUpdates(()=>{wn==null||wn(Xa),_(Xs.Initializing),y({type:An.DragStart,initialCoordinates:$t,active:Fn}),v({type:"onDragStart",event:Xa}),O(xn.current),B(rt)})},onMove($t){y({type:An.DragMove,coordinates:$t})},onEnd:Ft(An.DragEnd),onCancel:Ft(An.DragCancel)});xn.current=nn;function Ft($t){return async function(){const{active:rn,collisions:wn,over:Xa,scrollAdjustedTranslate:bo}=Z.current;let li=null;if(rn&&bo){const{cancelDrop:Qa}=z.current;li={activatorEvent:rt,active:rn,collisions:wn,delta:bo,over:Xa},$t===An.DragEnd&&typeof Qa=="function"&&await Promise.resolve(Qa(li))&&($t=An.DragCancel)}F.current=null,an.unstable_batchedUpdates(()=>{y({type:$t}),_(Xs.Uninitialized),Pn(null),O(null),B(null),xn.current=null;const Qa=$t===An.DragEnd?"onDragEnd":"onDragCancel";if(li){const Vd=z.current[Qa];Vd==null||Vd(li),v({type:Qa,event:li})}})}}},[k]),go=R.useCallback((cn,Rt)=>(Vn,Ie)=>{const qe=Vn.nativeEvent,rt=k.get(Ie);if(F.current!==null||!rt||qe.dndKit||qe.defaultPrevented)return;const nn={active:rt};cn(Vn,Rt.options,nn)===!0&&(qe.dndKit={capturedBy:Rt.sensor},F.current=Ie,Ot(Vn,Rt))},[k,Ot]),Bn=Ine(u,go);Bne(u),Qo(()=>{Q&&C===Xs.Initializing&&_(Xs.Initialized)},[Q,C]),R.useEffect(()=>{const{onDragMove:cn}=z.current,{active:Rt,activatorEvent:Vn,collisions:Ie,over:qe}=Z.current;if(!Rt||!Vn)return;const rt={active:Rt,activatorEvent:Vn,collisions:Ie,delta:{x:le.x,y:le.y},over:qe};an.unstable_batchedUpdates(()=>{cn==null||cn(rt),v({type:"onDragMove",event:rt})})},[le.x,le.y]),R.useEffect(()=>{const{active:cn,activatorEvent:Rt,collisions:Vn,droppableContainers:Ie,scrollAdjustedTranslate:qe}=Z.current;if(!cn||F.current==null||!Rt||!qe)return;const{onDragOver:rt}=z.current,nn=Ie.get(Ue),Ft=nn&&nn.rect.current?{id:nn.id,rect:nn.rect.current,data:nn.data,disabled:nn.disabled}:null,$t={active:cn,activatorEvent:Rt,collisions:Vn,delta:{x:qe.x,y:qe.y},over:Ft};an.unstable_batchedUpdates(()=>{Pn(Ft),rt==null||rt($t),v({type:"onDragOver",event:$t})})},[Ue]),Qo(()=>{Z.current={activatorEvent:L,active:j,activeNode:G,collisionRect:Re,collisions:De,droppableRects:D,draggableNodes:k,draggingNode:ce,draggingNodeRect:de,droppableContainers:M,over:jt,scrollableAncestors:Pe,scrollAdjustedTranslate:le},P.current={initial:de,translated:Re}},[j,G,De,Re,k,ce,de,D,M,jt,Pe,le]),Mne({...K,delta:N,draggingRect:Re,pointerCoordinates:ge,scrollableAncestors:Pe,scrollableAncestorRects:Ye});const Tc=R.useMemo(()=>({active:j,activeNode:G,activeNodeRect:Q,activatorEvent:L,collisions:De,containerNodeRect:ne,dragOverlay:te,draggableNodes:k,droppableContainers:M,droppableRects:D,over:jt,measureDroppableContainers:H,scrollableAncestors:Pe,scrollableAncestorRects:Ye,measuringConfiguration:$,measuringScheduled:V,windowRect:Ce}),[j,G,Q,L,De,ne,te,k,M,D,jt,H,Pe,Ye,$,V,Ce]),Ka=R.useMemo(()=>({activatorEvent:L,activators:Bn,active:j,activeNodeRect:Q,ariaDescribedById:{draggable:A},dispatch:y,draggableNodes:k,over:jt,measureDroppableContainers:H}),[L,Bn,j,Q,y,A,k,jt,H]);return R.createElement(x4.Provider,{value:x},R.createElement(Rp.Provider,{value:Ka},R.createElement($4.Provider,{value:Tc},R.createElement(gy.Provider,{value:ye},c)),R.createElement(Xne,{disabled:(a==null?void 0:a.restoreFocus)===!1})),R.createElement(rne,{...a,hiddenTextDescribedById:A}));function Ki(){const cn=(T==null?void 0:T.autoScrollEnabled)===!1,Rt=typeof l=="object"?l.enabled===!1:l===!1,Vn=S&&!cn&&!Rt;return typeof l=="object"?{...l,enabled:Vn}:{enabled:Vn}}}),Jne=R.createContext(null),uD="button",ere="Draggable";function z4(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=Sp(ere),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:h}=R.useContext(Rp),{role:p=uD,roleDescription:g="draggable",tabIndex:m=0}=o??{},b=(l==null?void 0:l.id)===t,y=R.useContext(b?gy:Jne),[v,x]=Cb(),[C,_]=Cb(),S=Vne(s,t),E=mh(n);Qo(()=>(d.set(t,{id:t,key:i,node:v,activatorNode:C,data:E}),()=>{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===uD?!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:S,node:v,over:h,setNodeRef:x,setActivatorNodeRef:_,transform:y}}function B4(){return R.useContext($4)}const tre="Droppable",nre={timeout:25};function V4(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=Sp(tre),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=R.useContext(Rp),u=R.useRef({disabled:n}),d=R.useRef(!1),h=R.useRef(null),p=R.useRef(null),{disabled:g,updateMeasurementsFor:m,timeout:b}={...nre,...o},y=mh(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=my({callback:v,disabled:g||!s}),C=R.useCallback((k,N)=>{x&&(N&&(x.unobserve(N),d.current=!1),k&&x.observe(k))},[x]),[_,S]=Cb(C),E=mh(t);return R.useEffect(()=>{!x||!_.current||(x.disconnect(),d.current=!1,x.observe(_.current))},[_,x]),R.useEffect(()=>(a({type:An.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:h,data:E}}),()=>a({type:An.UnregisterDroppable,key:i,id:r})),[r]),R.useEffect(()=>{n!==u.current.disabled&&(a({type:An.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:S}}function rre(e){let{animation:t,children:n}=e;const[r,o]=R.useState(null),[i,s]=R.useState(null),a=Sb(n);return!n&&!r&&a&&o(a),Qo(()=>{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 ore={x:0,y:0,scaleX:1,scaleY:1};function ire(e){let{children:t}=e;return R.createElement(Rp.Provider,{value:F4},R.createElement(gy.Provider,{value:ore},t))}const sre={position:"fixed",touchAction:"none"},are=e=>hy(e)?"transform 250ms ease":void 0,lre=R.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=are}=e;if(!a)return null;const d=o?c:{...c,scaleX:1,scaleY:1},h={...sre,width:a.width,height:a.height,top:a.top,left:a.left,transform:Ai.Transform.toString(d),transformOrigin:o&&r?one(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return R.createElement(n,{className:s,style:h,ref:t},i)}),cre=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)}},ure=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Ai.Transform.toString(t)},{transform:Ai.Transform.toString(n)}]},dre={duration:250,easing:"ease",keyframes:ure,sideEffects:cre({styles:{active:{opacity:"0"}}})};function fre(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return fy((i,s)=>{if(t===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=O4(s);if(!c)return;const{transform:u}=_r(s).getComputedStyle(s),d=_4(u);if(!d)return;const h=typeof t=="function"?t:hre(t);return A4(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 hre(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...dre,...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 dD=0;function pre(e){return R.useMemo(()=>{if(e!=null)return dD++,dD},[e])}const H4=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:C,windowRect:_}=B4(),S=R.useContext(gy),E=pre(d==null?void 0:d.id),k=L4(s,{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:b.rect,over:y,overlayNodeRect:b.rect,scrollableAncestors:x,scrollableAncestorRects:C,transform:S,windowRect:_}),N=B_(h),M=fre({config:r,draggableNodes:g,droppableContainers:m,measuringConfiguration:v}),I=N?b.setRef:void 0;return R.createElement(ire,null,R.createElement(rre,{animation:M},d&&E?R.createElement(lre,{key:E,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 kp(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function mre(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Am(e){return e!==null&&e>=0}function gre(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 bre(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Im={scaleX:1,scaleY:1},yre=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=vre(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,...Im}:null}return s>o&&s<=i?{x:-a.width-l,y:0,...Im}:s<o&&s>=i?{x:a.width+l,y:0,...Im}:{x:0,y:0,...Im}};function vre(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 W4=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=kp(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}},Tm={scaleX:1,scaleY:1},U4=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,...Tm}:null}const l=xre(i,o,n);return o>n&&o<=s?{x:0,y:-a.height-l,...Tm}:o<n&&o>=s?{x:0,y:a.height+l,...Tm}:{x:0,y:0,...Tm}};function xre(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 q4="Sortable",G4=R.createContext({activeIndex:-1,containerId:q4,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:W4,disabled:{draggable:!1,droppable:!1}});function H_(e){let{children:t,id:n,items:r,strategy:o=W4,disabled:i=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=B4(),d=Sp(q4,n),h=a.rect!==null,p=R.useMemo(()=>r.map(S=>typeof S=="object"&&"id"in S?S.id:S),[r]),g=s!=null,m=s?p.indexOf(s.id):-1,b=c?p.indexOf(c.id):-1,y=R.useRef(p),v=!gre(p,y.current),x=b!==-1&&m===-1||v,C=bre(i);Qo(()=>{v&&g&&u(p)},[v,p,g,u]),R.useEffect(()=>{y.current=p},[p]);const _=R.useMemo(()=>({activeIndex:m,containerId:d,disabled:C,disableTransforms:x,items:p,overIndex:b,useDragOverlay:h,sortedRects:mre(p,l),strategy:o}),[m,d,C.draggable,C.droppable,x,p,b,l,h,o]);return R.createElement(G4.Provider,{value:_},t)}const wre=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return kp(n,r,o).indexOf(t)},Cre=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},Sre={duration:200,easing:"ease"},Y4="transform",Ere=Ai.Transition.toString({property:Y4,duration:0,easing:"linear"}),_re={roleDescription:"sortable"};function Rre(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=R.useState(null),a=R.useRef(n);return Qo(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=wd(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 W_(e){let{animateLayoutChanges:t=Cre,attributes:n,disabled:r,data:o,getNewIndex:i=wre,id:s,strategy:a,resizeObserverConfig:l,transition:c=Sre}=e;const{items:u,containerId:d,activeIndex:h,disabled:p,disableTransforms:g,sortedRects:m,overIndex:b,useDragOverlay:y,strategy:v}=R.useContext(G4),x=kre(r,p),C=u.indexOf(s),_=R.useMemo(()=>({sortable:{containerId:d,index:C,items:u},...o}),[d,o,C,u]),S=R.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:E,node:k,isOver:N,setNodeRef:M}=V4({id:s,data:_,disabled:x.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...l}}),{active:I,activatorEvent:P,activeNodeRect:j,attributes:F,setNodeRef:T,listeners:O,isDragging:L,over:B,setActivatorNodeRef:z,transform:A}=z4({id:s,data:_,attributes:{..._re,...n},disabled:x.draggable}),W=Wte(M,T),$=!!I,D=$&&!g&&Am(h)&&Am(b),H=!y&&L,V=H&&D?A:null,q=D?V??(a??v)({rects:m,activeNodeRect:j,activeIndex:h,overIndex:b,index:C}):null,K=Am(h)&&Am(b)?i({id:s,items:u,activeIndex:h,overIndex:b}):C,Y=I==null?void 0:I.id,Q=R.useRef({activeId:Y,items:u,newIndex:K,containerId:d}),ne=u!==Q.current.items,Z=t({active:I,containerId:d,isDragging:L,isSorting:$,id:s,index:C,items:u,newIndex:Q.current.newIndex,previousItems:Q.current.items,previousContainerId:Q.current.containerId,transition:c,wasDragging:Q.current.activeId!=null}),ie=Rre({disabled:!Z,index:C,node:k,rect:E});return R.useEffect(()=>{$&&Q.current.newIndex!==K&&(Q.current.newIndex=K),d!==Q.current.containerId&&(Q.current.containerId=d),u!==Q.current.items&&(Q.current.items=u)},[$,K,d,u]),R.useEffect(()=>{if(Y===Q.current.activeId)return;if(Y!=null&&Q.current.activeId==null){Q.current.activeId=Y;return}const ce=setTimeout(()=>{Q.current.activeId=Y},50);return()=>clearTimeout(ce)},[Y]),{active:I,activeIndex:h,attributes:F,data:_,rect:E,index:C,newIndex:K,items:u,isOver:N,isSorting:$,isDragging:L,listeners:O,node:k,overIndex:b,over:B,setNodeRef:W,setActivatorNodeRef:z,setDroppableNodeRef:M,setDraggableNodeRef:T,transform:ie??q,transition:te()};function te(){if(ie||ne&&Q.current.newIndex===C)return Ere;if(!(H&&!hy(P)||!c)&&($||Z))return Ai.Transition.toString({...c,property:Y4})}}function kre(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 kb(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 Nre=[ht.Down,ht.Right,ht.Up,ht.Left],U_=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:s,scrollableAncestors:a}}=t;if(Nre.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=sne({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=py(g).some((S,E)=>a[E]!==S),y=K4(d,h),v=Mre(d,h),x=b||!y?{x:0,y:0}:{x:v?r.width-p.width:0,y:v?r.height-p.height:0},C={x:p.left,y:p.top};return x.x&&x.y?C:gh(C,x)}}}};function K4(e,t){return!kb(e)||!kb(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Mre(e,t){return!kb(e)||!kb(t)||!K4(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Dre(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,C)=>C===m?{...x,...b}:x);c(g,{steps:v})}},setDefaultHierarchy:g=>{t(e.map(m=>({...m,default:m.id===g})))}}}function Pre({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 Are(e,t=globalThis==null?void 0:globalThis.document){const n=In(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 Ire="DismissableLayer",xC="dismissableLayer.update",Tre="dismissableLayer.pointerDownOutside",jre="dismissableLayer.focusOutside",fD,X4=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_c=w.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...l}=e,c=w.useContext(X4),[u,d]=w.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=w.useState({}),g=He(t,E=>d(E)),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,C=v>=y,_=$re(E=>{const k=E.target,N=[...c.branches].some(M=>M.contains(k));!C||N||(o==null||o(E),s==null||s(E),E.defaultPrevented||a==null||a())},h),S=Lre(E=>{const k=E.target;[...c.branches].some(M=>M.contains(k))||(i==null||i(E),s==null||s(E),E.defaultPrevented||a==null||a())},h);return Are(E=>{v===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),w.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(fD=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),hD(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=fD)}},[u,h,n,c]),w.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),hD())},[u,c]),w.useEffect(()=>{const E=()=>p({});return document.addEventListener(xC,E),()=>document.removeEventListener(xC,E)},[]),f.jsx(_e.div,{...l,ref:g,style:{pointerEvents:x?C?"auto":"none":void 0,...e.style},onFocusCapture:he(e.onFocusCapture,S.onFocusCapture),onBlurCapture:he(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:he(e.onPointerDownCapture,_.onPointerDownCapture)})});_c.displayName=Ire;var Ore="DismissableLayerBranch",Fre=w.forwardRef((e,t)=>{const n=w.useContext(X4),r=w.useRef(null),o=He(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})});Fre.displayName=Ore;function $re(e,t=globalThis==null?void 0:globalThis.document){const n=In(e),r=w.useRef(!1),o=w.useRef(()=>{});return w.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let l=function(){Q4(Tre,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 Lre(e,t=globalThis==null?void 0:globalThis.document){const n=In(e),r=w.useRef(!1);return w.useEffect(()=>{const o=i=>{i.target&&!r.current&&Q4(jre,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 hD(){const e=new CustomEvent(xC);document.dispatchEvent(e)}function Q4(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?ZO(o,i):o.dispatchEvent(i)}var Mx=0;function by(){w.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??pD()),document.body.insertAdjacentElement("beforeend",e[1]??pD()),Mx++,()=>{Mx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Mx--}},[])}function pD(){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 Dx="focusScope.autoFocusOnMount",Px="focusScope.autoFocusOnUnmount",mD={bubbles:!1,cancelable:!0},zre="FocusScope",Np=w.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,l]=w.useState(null),c=In(o),u=In(i),d=w.useRef(null),h=He(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 C=x.target;a.contains(C)?d.current=C:Ys(d.current,{select:!0})},b=function(x){if(p.paused||!a)return;const C=x.relatedTarget;C!==null&&(a.contains(C)||Ys(d.current,{select:!0}))},y=function(x){if(document.activeElement===document.body)for(const _ of x)_.removedNodes.length>0&&Ys(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){bD.add(p);const m=document.activeElement;if(!a.contains(m)){const y=new CustomEvent(Dx,mD);a.addEventListener(Dx,c),a.dispatchEvent(y),y.defaultPrevented||(Bre(qre(Z4(a)),{select:!0}),document.activeElement===m&&Ys(a))}return()=>{a.removeEventListener(Dx,c),setTimeout(()=>{const y=new CustomEvent(Px,mD);a.addEventListener(Px,u),a.dispatchEvent(y),y.defaultPrevented||Ys(m??document.body,{select:!0}),a.removeEventListener(Px,u),bD.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,C]=Vre(v);x&&C?!m.shiftKey&&y===C?(m.preventDefault(),n&&Ys(x,{select:!0})):m.shiftKey&&y===x&&(m.preventDefault(),n&&Ys(C,{select:!0})):y===v&&m.preventDefault()}},[n,r,p.paused]);return f.jsx(_e.div,{tabIndex:-1,...s,ref:h,onKeyDown:g})});Np.displayName=zre;function Bre(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ys(r,{select:t}),document.activeElement!==n)return}function Vre(e){const t=Z4(e),n=gD(t,e),r=gD(t.reverse(),e);return[n,r]}function Z4(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 gD(e,t){for(const n of e)if(!Hre(n,{upTo:t}))return n}function Hre(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 Wre(e){return e instanceof HTMLInputElement&&"select"in e}function Ys(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Wre(e)&&t&&e.select()}}var bD=Ure();function Ure(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=yD(e,t),e.unshift(t)},remove(t){var n;e=yD(e,t),(n=e[0])==null||n.resume()}}}function yD(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function qre(e){return e.filter(t=>t.tagName!=="A")}const Gre=["top","right","bottom","left"],Ns=Math.min,rr=Math.max,vh=Math.round,jm=Math.floor,Ci=e=>({x:e,y:e}),Yre={left:"right",right:"left",bottom:"top",top:"bottom"},Kre={start:"end",end:"start"};function wC(e,t,n){return rr(e,Ns(t,n))}function Ii(e,t){return typeof e=="function"?e(t):e}function Ms(e){return e.split("-")[0]}function Cd(e){return e.split("-")[1]}function q_(e){return e==="x"?"y":"x"}function G_(e){return e==="y"?"height":"width"}function Ca(e){return["top","bottom"].includes(Ms(e))?"y":"x"}function Y_(e){return q_(Ca(e))}function Xre(e,t,n){n===void 0&&(n=!1);const r=Cd(e),o=Y_(e),i=G_(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Nb(s)),[s,Nb(s)]}function Qre(e){const t=Nb(e);return[CC(e),t,CC(t)]}function CC(e){return e.replace(/start|end/g,t=>Kre[t])}function Zre(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=Cd(e);let i=Zre(Ms(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(CC)))),i}function Nb(e){return e.replace(/left|right|bottom|top/g,t=>Yre[t])}function eoe(e){return{top:0,right:0,bottom:0,left:0,...e}}function J4(e){return typeof e!="number"?eoe(e):{top:e,right:e,bottom:e,left:e}}function Mb(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 vD(e,t,n){let{reference:r,floating:o}=e;const i=Ca(t),s=Y_(t),a=G_(s),l=Ms(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(Cd(t)){case"start":p[s]-=h*(n&&c?-1:1);break;case"end":p[s]+=h*(n&&c?-1:1);break}return p}const toe=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}=vD(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:C,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],...C}},_&&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}=vD(c,h,l)),m=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:p}};async function Xu(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}=Ii(t,e),g=J4(p),b=a[h?d==="floating"?"reference":"floating":d],y=Mb(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)),C=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},_=Mb(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:l}):v);return{top:(y.top-_.top+g.top)/C.y,bottom:(_.bottom-y.bottom+g.bottom)/C.y,left:(y.left-_.left+g.left)/C.x,right:(_.right-y.right+g.right)/C.x}}const noe=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}=Ii(e,t)||{};if(c==null)return{};const d=J4(u),h={x:n,y:r},p=Y_(o),g=G_(p),m=await s.getDimensions(c),b=p==="y",y=b?"top":"left",v=b?"bottom":"right",x=b?"clientHeight":"clientWidth",C=i.reference[g]+i.reference[p]-h[p]-i.floating[g],_=h[p]-i.reference[p],S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let E=S?S[x]:0;(!E||!await(s.isElement==null?void 0:s.isElement(S)))&&(E=a.floating[x]||i.floating[g]);const k=C/2-_/2,N=E/2-m[g]/2-1,M=Ns(d[y],N),I=Ns(d[v],N),P=M,j=E-m[g]-I,F=E/2-m[g]/2+k,T=wC(P,F,j),O=!l.arrow&&Cd(o)!=null&&F!==T&&i.reference[g]/2-(F<P?M:I)-m[g]/2<0,L=O?F<P?F-P:F-j:0;return{[p]:h[p]+L,data:{[p]:T,centerOffset:F-T-L,...O&&{alignmentOffset:L}},reset:O}}}),roe=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}=Ii(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=Ms(o),v=Ca(a),x=Ms(a)===a,C=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=h||(x||!m?[Nb(a)]:Qre(a)),S=g!=="none";!h&&S&&_.push(...Jre(a,m,g,C));const E=[a,..._],k=await Xu(t,b),N=[];let M=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&N.push(k[y]),d){const F=Xre(o,s,C);N.push(k[F[0]],k[F[1]])}if(M=[...M,{placement:o,overflows:N}],!N.every(F=>F<=0)){var I,P;const F=(((I=i.flip)==null?void 0:I.index)||0)+1,T=E[F];if(T)return{data:{index:F,overflows:M},reset:{placement:T}};let O=(P=M.filter(L=>L.overflows[0]<=0).sort((L,B)=>L.overflows[1]-B.overflows[1])[0])==null?void 0:P.placement;if(!O)switch(p){case"bestFit":{var j;const L=(j=M.filter(B=>{if(S){const z=Ca(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];L&&(O=L);break}case"initialPlacement":O=a;break}if(o!==O)return{reset:{placement:O}}}return{}}}};function xD(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wD(e){return Gre.some(t=>e[t]>=0)}const ooe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Ii(e,t);switch(r){case"referenceHidden":{const i=await Xu(t,{...o,elementContext:"reference"}),s=xD(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:wD(s)}}}case"escaped":{const i=await Xu(t,{...o,altBoundary:!0}),s=xD(i,n.floating);return{data:{escapedOffsets:s,escaped:wD(s)}}}default:return{}}}}};async function ioe(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Ms(n),a=Cd(n),l=Ca(n)==="y",c=["left","top"].includes(s)?-1:1,u=i&&l?-1:1,d=Ii(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 soe=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 ioe(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}}}}},aoe=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}=Ii(e,t),c={x:n,y:r},u=await Xu(t,l),d=Ca(Ms(o)),h=q_(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=wC(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=wC(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}}}}}},loe=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}=Ii(e,t),u={x:n,y:r},d=Ca(o),h=q_(d);let p=u[h],g=u[d];const m=Ii(a,t),b=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const x=h==="y"?"height":"width",C=i.reference[h]-i.floating[x]+b.mainAxis,_=i.reference[h]+i.reference[x]-b.mainAxis;p<C?p=C:p>_&&(p=_)}if(c){var y,v;const x=h==="y"?"width":"height",C=["top","left"].includes(Ms(o)),_=i.reference[d]-i.floating[x]+(C&&((y=s.offset)==null?void 0:y[d])||0)+(C?0:b.crossAxis),S=i.reference[d]+i.reference[x]+(C?0:((v=s.offset)==null?void 0:v[d])||0)-(C?b.crossAxis:0);g<_?g=_:g>S&&(g=S)}return{[h]:p,[d]:g}}}},coe=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}=Ii(e,t),u=await Xu(t,c),d=Ms(o),h=Cd(o),p=Ca(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,C=Ns(m-u[b],v),_=Ns(g-u[y],x),S=!t.middlewareData.shift;let E=C,k=_;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=v),S&&!h){const M=rr(u.left,0),I=rr(u.right,0),P=rr(u.top,0),j=rr(u.bottom,0);p?k=g-2*(M!==0||I!==0?M+I:rr(u.left,u.right)):E=m-2*(P!==0||j!==0?P+j:rr(u.top,u.bottom))}await l({...t,availableWidth:k,availableHeight:E});const N=await s.getDimensions(a.floating);return g!==N.width||m!==N.height?{reset:{rects:!0}}:{}}}};function yy(){return typeof window<"u"}function Sd(e){return e3(e)?(e.nodeName||"").toLowerCase():"#document"}function co(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Wi(e){var t;return(t=(e3(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function e3(e){return yy()?e instanceof Node||e instanceof co(e).Node:!1}function ir(e){return yy()?e instanceof Element||e instanceof co(e).Element:!1}function Ti(e){return yy()?e instanceof HTMLElement||e instanceof co(e).HTMLElement:!1}function CD(e){return!yy()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof co(e).ShadowRoot}function Mp(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Jo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function uoe(e){return["table","td","th"].includes(Sd(e))}function vy(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function K_(e){const t=X_(),n=ir(e)?Jo(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 doe(e){let t=Sa(e);for(;Ti(t)&&!Qu(t);){if(K_(t))return t;if(vy(t))return null;t=Sa(t)}return null}function X_(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Qu(e){return["html","body","#document"].includes(Sd(e))}function Jo(e){return co(e).getComputedStyle(e)}function xy(e){return ir(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Sa(e){if(Sd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||CD(e)&&e.host||Wi(e);return CD(t)?t.host:t}function t3(e){const t=Sa(e);return Qu(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ti(t)&&Mp(t)?t:t3(t)}function xh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=t3(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=co(o);if(i){const a=SC(s);return t.concat(s,s.visualViewport||[],Mp(o)?o:[],a&&n?xh(a):[])}return t.concat(o,xh(o,[],n))}function SC(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function n3(e){const t=Jo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ti(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=vh(n)!==i||vh(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function Q_(e){return ir(e)?e:e.contextElement}function yu(e){const t=Q_(e);if(!Ti(t))return Ci(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=n3(t);let s=(i?vh(n.width):n.width)/r,a=(i?vh(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const foe=Ci(0);function r3(e){const t=co(e);return!X_()||!t.visualViewport?foe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function hoe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==co(e)?!1:t}function ec(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Q_(e);let s=Ci(1);t&&(r?ir(r)&&(s=yu(r)):s=yu(e));const a=hoe(i,n,r)?r3(i):Ci(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=co(i),p=r&&ir(r)?co(r):r;let g=h,m=SC(g);for(;m&&r&&p!==g;){const b=yu(m),y=m.getBoundingClientRect(),v=Jo(m),x=y.left+(m.clientLeft+parseFloat(v.paddingLeft))*b.x,C=y.top+(m.clientTop+parseFloat(v.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=x,c+=C,g=co(m),m=SC(g)}}return Mb({width:u,height:d,x:l,y:c})}function Z_(e,t){const n=xy(e).scrollLeft;return t?t.left+n:ec(Wi(e)).left+n}function o3(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:Z_(e,r)),i=r.top+t.scrollTop;return{x:o,y:i}}function poe(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=Wi(r),a=t?vy(t.floating):!1;if(r===s||a&&i)return n;let l={scrollLeft:0,scrollTop:0},c=Ci(1);const u=Ci(0),d=Ti(r);if((d||!d&&!i)&&((Sd(r)!=="body"||Mp(s))&&(l=xy(r)),Ti(r))){const p=ec(r);c=yu(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=s&&!d&&!i?o3(s,l,!0):Ci(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 moe(e){return Array.from(e.getClientRects())}function goe(e){const t=Wi(e),n=xy(e),r=e.ownerDocument.body,o=rr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=rr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Z_(e);const a=-n.scrollTop;return Jo(r).direction==="rtl"&&(s+=rr(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function boe(e,t){const n=co(e),r=Wi(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=X_();(!c||c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:i,height:s,x:a,y:l}}function yoe(e,t){const n=ec(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Ti(e)?yu(e):Ci(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 SD(e,t,n){let r;if(t==="viewport")r=boe(e,n);else if(t==="document")r=goe(Wi(e));else if(ir(t))r=yoe(t,n);else{const o=r3(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Mb(r)}function i3(e,t){const n=Sa(e);return n===t||!ir(n)||Qu(n)?!1:Jo(n).position==="fixed"||i3(n,t)}function voe(e,t){const n=t.get(e);if(n)return n;let r=xh(e,[],!1).filter(a=>ir(a)&&Sd(a)!=="body"),o=null;const i=Jo(e).position==="fixed";let s=i?Sa(e):e;for(;ir(s)&&!Qu(s);){const a=Jo(s),l=K_(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Mp(s)&&!l&&i3(e,s))?r=r.filter(u=>u!==s):o=a,s=Sa(s)}return t.set(e,r),r}function xoe(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?vy(t)?[]:voe(t,this._c):[].concat(n),r],a=s[0],l=s.reduce((c,u)=>{const d=SD(t,u,o);return c.top=rr(d.top,c.top),c.right=Ns(d.right,c.right),c.bottom=Ns(d.bottom,c.bottom),c.left=rr(d.left,c.left),c},SD(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function woe(e){const{width:t,height:n}=n3(e);return{width:t,height:n}}function Coe(e,t,n){const r=Ti(t),o=Wi(t),i=n==="fixed",s=ec(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=Ci(0);if(r||!r&&!i)if((Sd(t)!=="body"||Mp(o))&&(a=xy(t)),r){const h=ec(t,!0,i,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&(l.x=Z_(o));const c=o&&!r&&!i?o3(o,a):Ci(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 Ax(e){return Jo(e).position==="static"}function ED(e,t){if(!Ti(e)||Jo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Wi(e)===n&&(n=n.ownerDocument.body),n}function s3(e,t){const n=co(e);if(vy(e))return n;if(!Ti(e)){let o=Sa(e);for(;o&&!Qu(o);){if(ir(o)&&!Ax(o))return o;o=Sa(o)}return n}let r=ED(e,t);for(;r&&uoe(r)&&Ax(r);)r=ED(r,t);return r&&Qu(r)&&Ax(r)&&!K_(r)?n:r||doe(e)||n}const Soe=async function(e){const t=this.getOffsetParent||s3,n=this.getDimensions,r=await n(e.floating);return{reference:Coe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Eoe(e){return Jo(e).direction==="rtl"}const _oe={convertOffsetParentRelativeRectToViewportRelativeRect:poe,getDocumentElement:Wi,getClippingRect:xoe,getOffsetParent:s3,getElementRects:Soe,getClientRects:moe,getDimensions:woe,getScale:yu,isElement:ir,isRTL:Eoe};function a3(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Roe(e,t){let n=null,r;const o=Wi(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=jm(d),m=jm(o.clientWidth-(u+h)),b=jm(o.clientHeight-(d+p)),y=jm(u),x={rootMargin:-g+"px "+-m+"px "+-b+"px "+-y+"px",threshold:rr(0,Ns(1,l))||1};let C=!0;function _(S){const E=S[0].intersectionRatio;if(E!==l){if(!C)return s();E?s(!1,E):r=setTimeout(()=>{s(!1,1e-7)},1e3)}E===1&&!a3(c,e.getBoundingClientRect())&&s(),C=!1}try{n=new IntersectionObserver(_,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,x)}n.observe(e)}return s(!0),i}function J_(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=Q_(e),u=o||i?[...c?xh(c):[],...xh(t)]:[];u.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const d=c&&a?Roe(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?ec(e):null;l&&b();function b(){const y=ec(e);m&&!a3(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 Ix=Xu,koe=soe,Noe=aoe,Moe=roe,Doe=coe,Poe=ooe,_D=noe,Aoe=loe,Ioe=(e,t,n)=>{const r=new Map,o={platform:_oe,...n},i={...o.platform,_c:r};return toe(e,t,{...o,platform:i})};var Vg=typeof document<"u"?R.useLayoutEffect:R.useEffect;function Db(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(!Db(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)&&!Db(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function l3(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function RD(e,t){const n=l3(e);return Math.round(t*n)/n}function Tx(e){const t=w.useRef(e);return Vg(()=>{t.current=e}),t}function e2(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);Db(h,r)||p(r);const[g,m]=w.useState(null),[b,y]=w.useState(null),v=w.useCallback(B=>{B!==S.current&&(S.current=B,m(B))},[]),x=w.useCallback(B=>{B!==E.current&&(E.current=B,y(B))},[]),C=i||g,_=s||b,S=w.useRef(null),E=w.useRef(null),k=w.useRef(u),N=l!=null,M=Tx(l),I=Tx(o),P=Tx(c),j=w.useCallback(()=>{if(!S.current||!E.current)return;const B={placement:t,strategy:n,middleware:h};I.current&&(B.platform=I.current),Ioe(S.current,E.current,B).then(z=>{const A={...z,isPositioned:P.current!==!1};F.current&&!Db(k.current,A)&&(k.current=A,Rs.flushSync(()=>{d(A)}))})},[h,t,n,I,P]);Vg(()=>{c===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,d(B=>({...B,isPositioned:!1})))},[c]);const F=w.useRef(!1);Vg(()=>(F.current=!0,()=>{F.current=!1}),[]),Vg(()=>{if(C&&(S.current=C),_&&(E.current=_),C&&_){if(M.current)return M.current(C,_,j);j()}},[C,_,j,M,N]);const T=w.useMemo(()=>({reference:S,floating:E,setReference:v,setFloating:x}),[v,x]),O=w.useMemo(()=>({reference:C,floating:_}),[C,_]),L=w.useMemo(()=>{const B={position:n,left:0,top:0};if(!O.floating)return B;const z=RD(O.floating,u.x),A=RD(O.floating,u.y);return a?{...B,transform:"translate("+z+"px, "+A+"px)",...l3(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:L}),[u,j,T,O,L])}const Toe=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?_D({element:r.current,padding:o}).fn(n):{}:r?_D({element:r,padding:o}).fn(n):{}}}},wy=(e,t)=>({...koe(e),options:[e,t]}),t2=(e,t)=>({...Noe(e),options:[e,t]}),c3=(e,t)=>({...Aoe(e),options:[e,t]}),n2=(e,t)=>({...Moe(e),options:[e,t]}),r2=(e,t)=>({...Doe(e),options:[e,t]}),u3=(e,t)=>({...Poe(e),options:[e,t]}),d3=(e,t)=>({...Toe(e),options:[e,t]});var joe="Arrow",f3=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"})})});f3.displayName=joe;var Ooe=f3;function Cy(e){const[t,n]=w.useState(void 0);return Yn(()=>{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 o2="Popper",[h3,Ui]=On(o2),[Foe,p3]=h3(o2),m3=e=>{const{__scopePopper:t,children:n}=e,[r,o]=w.useState(null);return f.jsx(Foe,{scope:t,anchor:r,onAnchorChange:o,children:n})};m3.displayName=o2;var g3="PopperAnchor",b3=w.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=p3(g3,n),s=w.useRef(null),a=He(t,s);return w.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:f.jsx(_e.div,{...o,ref:a})});b3.displayName=g3;var i2="PopperContent",[$oe,Loe]=h3(i2),y3=w.forwardRef((e,t)=>{var q,K,Y,Q,ne,Z;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=p3(i2,n),[y,v]=w.useState(null),x=He(t,ie=>v(ie)),[C,_]=w.useState(null),S=Cy(C),E=(S==null?void 0:S.width)??0,k=(S==null?void 0:S.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],P=I.length>0,j={padding:M,boundary:I.filter(Boe),altBoundary:P},{refs:F,floatingStyles:T,placement:O,isPositioned:L,middlewareData:B}=e2({strategy:"fixed",placement:N,whileElementsMounted:(...ie)=>J_(...ie,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[wy({mainAxis:o+k,alignmentAxis:s}),l&&t2({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?c3():void 0,...j}),l&&n2({...j}),r2({...j,apply:({elements:ie,rects:te,availableWidth:ce,availableHeight:de})=>{const{width:ke,height:we}=te.reference,Ce=ie.floating.style;Ce.setProperty("--radix-popper-available-width",`${ce}px`),Ce.setProperty("--radix-popper-available-height",`${de}px`),Ce.setProperty("--radix-popper-anchor-width",`${ke}px`),Ce.setProperty("--radix-popper-anchor-height",`${we}px`)}}),C&&d3({element:C,padding:a}),Voe({arrowWidth:E,arrowHeight:k}),h&&u3({strategy:"referenceHidden",...j})]}),[z,A]=w3(O),W=In(g);Yn(()=>{L&&(W==null||W())},[L,W]);const $=(q=B.arrow)==null?void 0:q.x,D=(K=B.arrow)==null?void 0:K.y,H=((Y=B.arrow)==null?void 0:Y.centerOffset)!==0,[V,G]=w.useState();return Yn(()=>{y&&G(window.getComputedStyle(y).zIndex)},[y]),f.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:L?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[(Q=B.transformOrigin)==null?void 0:Q.x,(ne=B.transformOrigin)==null?void 0:ne.y].join(" "),...((Z=B.hide)==null?void 0:Z.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:f.jsx($oe,{scope:n,placedSide:z,onArrowChange:_,arrowX:$,arrowY:D,shouldHideArrow:H,children:f.jsx(_e.div,{"data-side":z,"data-align":A,...m,ref:x,style:{...m.style,animation:L?void 0:"none"}})})})});y3.displayName=i2;var v3="PopperArrow",zoe={top:"bottom",right:"left",bottom:"top",left:"right"},x3=w.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=Loe(v3,r),s=zoe[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(Ooe,{...o,ref:n,style:{...o.style,display:"block"}})})});x3.displayName=v3;function Boe(e){return e!==null}var Voe=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]=w3(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 w3(e){const[t,n="center"]=e.split("-");return[t,n]}var Dp=m3,Ed=b3,Pp=y3,Ap=x3,Hoe="Portal",Rc=w.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,i]=w.useState(!1);Yn(()=>i(!0),[]);const s=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return s?an.createPortal(f.jsx(_e.div,{...r,ref:t}),s):null});Rc.displayName=Hoe;var C3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(Uoe);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(EC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(EC,{...r,ref:t,children:n})});C3.displayName="Slot";var EC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=Goe(n),i=qoe(r,n.props);return n.type!==w.Fragment&&(i.ref=t?Sr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});EC.displayName="SlotClone";var Woe=({children:e})=>f.jsx(f.Fragment,{children:e});function Uoe(e){return w.isValidElement(e)&&e.type===Woe}function qoe(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 Goe(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 s2="Popover",[S3,J$e]=On(s2,[Ui]),Ip=Ui(),[Yoe,La]=S3(s2),E3=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=Ip(t),l=w.useRef(null),[c,u]=w.useState(!1),[d=!1,h]=dr({prop:r,defaultProp:o,onChange:i});return f.jsx(Dp,{...a,children:f.jsx(Yoe,{scope:t,contentId:Nn(),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})})};E3.displayName=s2;var _3="PopoverAnchor",Koe=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=La(_3,n),i=Ip(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return w.useEffect(()=>(s(),()=>a()),[s,a]),f.jsx(Ed,{...i,...r,ref:t})});Koe.displayName=_3;var R3="PopoverTrigger",k3=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=La(R3,n),i=Ip(n),s=He(t,o.triggerRef),a=f.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":A3(o.open),...r,ref:s,onClick:he(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:f.jsx(Ed,{asChild:!0,...i,children:a})});k3.displayName=R3;var a2="PopoverPortal",[Xoe,Qoe]=S3(a2,{forceMount:void 0}),N3=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=La(a2,t);return f.jsx(Xoe,{scope:t,forceMount:n,children:f.jsx(gn,{present:n||i.open,children:f.jsx(Rc,{asChild:!0,container:o,children:r})})})};N3.displayName=a2;var Zu="PopoverContent",M3=w.forwardRef((e,t)=>{const n=Qoe(Zu,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=La(Zu,e.__scopePopover);return f.jsx(gn,{present:r||i.open,children:i.modal?f.jsx(Zoe,{...o,ref:t}):f.jsx(Joe,{...o,ref:t})})});M3.displayName=Zu;var Zoe=w.forwardRef((e,t)=>{const n=La(Zu,e.__scopePopover),r=w.useRef(null),o=He(t,r),i=w.useRef(!1);return w.useEffect(()=>{const s=r.current;if(s)return yd(s)},[]),f.jsx(Ec,{as:C3,allowPinchZoom:!0,children:f.jsx(D3,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:he(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:he(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:he(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),Joe=w.forwardRef((e,t)=>{const n=La(Zu,e.__scopePopover),r=w.useRef(!1),o=w.useRef(!1);return f.jsx(D3,{...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()}})}),D3=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=La(Zu,n),p=Ip(n);return by(),f.jsx(Np,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:f.jsx(_c,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:f.jsx(Pp,{"data-state":A3(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",eie=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=La(P3,n);return f.jsx(_e.button,{type:"button",...r,ref:t,onClick:he(e.onClick,()=>o.onOpenChange(!1))})});eie.displayName=P3;var tie="PopoverArrow",nie=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ip(n);return f.jsx(Ap,{...o,...r,ref:t})});nie.displayName=tie;function A3(e){return e?"open":"closed"}var rie=E3,oie=k3,iie=N3,Sy=M3;const za=rie,Ba=oie,Ts=w.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>f.jsx(iie,{children:f.jsx(ri,{children:f.jsx(Sy,{ref:o,align:t,sideOffset:n,className:oe("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})})}));Ts.displayName=Sy.displayName;function _C(e,[t,n]){return Math.min(n,Math.max(t,e))}var I3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(aie);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(RC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(RC,{...r,ref:t,children:n})});I3.displayName="Slot";var RC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=cie(n),i=lie(r,n.props);return n.type!==w.Fragment&&(i.ref=t?Sr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});RC.displayName="SlotClone";var sie=({children:e})=>f.jsx(f.Fragment,{children:e});function aie(e){return w.isValidElement(e)&&e.type===sie}function lie(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 cie(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 Ey(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 uie="VisuallyHidden",l2=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}}));l2.displayName=uie;var die=l2,fie=[" ","Enter","ArrowUp","ArrowDown"],hie=[" ","Enter"],Tp="Select",[_y,Ry,pie]=B0(Tp),[_d,eLe]=On(Tp,[pie,Ui]),ky=Ui(),[mie,Va]=_d(Tp),[gie,bie]=_d(Tp),T3=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=ky(t),[b,y]=w.useState(null),[v,x]=w.useState(null),[C,_]=w.useState(!1),S=yc(c),[E=!1,k]=dr({prop:r,defaultProp:o,onChange:i}),[N,M]=dr({prop:s,defaultProp:a,onChange:l}),I=w.useRef(null),P=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(Dp,{...m,children:f.jsxs(mie,{required:p,scope:t,trigger:b,onTriggerChange:y,valueNode:v,onValueNodeChange:x,valueNodeHasChildren:C,onValueNodeHasChildrenChange:_,contentId:Nn(),value:N,onValueChange:M,open:E,onOpenChange:k,dir:S,triggerPointerDownPosRef:I,disabled:h,children:[f.jsx(_y.Provider,{scope:t,children:f.jsx(gie,{scope:e.__scopeSelect,onNativeOptionAdd:w.useCallback(O=>{F(L=>new Set(L).add(O))},[]),onNativeOptionRemove:w.useCallback(O=>{F(L=>{const B=new Set(L);return B.delete(O),B})},[]),children:n})}),P?f.jsxs(s$,{"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]})})};T3.displayName=Tp;var j3="SelectTrigger",O3=w.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=ky(n),s=Va(j3,n),a=s.disabled||r,l=He(t,s.onTriggerChange),c=Ry(n),u=w.useRef("touch"),[d,h,p]=a$(m=>{const b=c().filter(x=>!x.disabled),y=b.find(x=>x.value===s.value),v=l$(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(Ed,{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":i$(s.value)?"":void 0,...o,ref:l,onClick:he(o.onClick,m=>{m.currentTarget.focus(),u.current!=="mouse"&&g(m)}),onPointerDown:he(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:he(o.onKeyDown,m=>{const b=d.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&h(m.key),!(b&&m.key===" ")&&fie.includes(m.key)&&(g(),m.preventDefault())})})})});O3.displayName=j3;var F3="SelectValue",$3=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:s="",...a}=e,l=Va(F3,n),{onValueNodeHasChildrenChange:c}=l,u=i!==void 0,d=He(t,l.onValueNodeChange);return Yn(()=>{c(u)},[c,u]),f.jsx(_e.span,{...a,ref:d,style:{pointerEvents:"none"},children:i$(l.value)?f.jsx(f.Fragment,{children:s}):i})});$3.displayName=F3;var yie="SelectIcon",L3=w.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return f.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});L3.displayName=yie;var vie="SelectPortal",z3=e=>f.jsx(Rc,{asChild:!0,...e});z3.displayName=vie;var tc="SelectContent",B3=w.forwardRef((e,t)=>{const n=Va(tc,e.__scopeSelect),[r,o]=w.useState();if(Yn(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?Rs.createPortal(f.jsx(V3,{scope:e.__scopeSelect,children:f.jsx(_y.Slot,{scope:e.__scopeSelect,children:f.jsx("div",{children:e.children})})}),i):null}return f.jsx(H3,{...e,ref:t})});B3.displayName=tc;var zo=10,[V3,Ha]=_d(tc),xie="SelectContentImpl",H3=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=Va(tc,n),[x,C]=w.useState(null),[_,S]=w.useState(null),E=He(t,q=>C(q)),[k,N]=w.useState(null),[M,I]=w.useState(null),P=Ry(n),[j,F]=w.useState(!1),T=w.useRef(!1);w.useEffect(()=>{if(x)return yd(x)},[x]),by();const O=w.useCallback(q=>{const[K,...Y]=P().map(Z=>Z.ref.current),[Q]=Y.slice(-1),ne=document.activeElement;for(const Z of q)if(Z===ne||(Z==null||Z.scrollIntoView({block:"nearest"}),Z===K&&_&&(_.scrollTop=0),Z===Q&&_&&(_.scrollTop=_.scrollHeight),Z==null||Z.focus(),document.activeElement!==ne))return},[P,_]),L=w.useCallback(()=>O([k,x]),[O,k,x]);w.useEffect(()=>{j&&L()},[j,L]);const{onOpenChange:B,triggerPointerDownPosRef:z}=v;w.useEffect(()=>{if(x){let q={x:0,y:0};const K=Q=>{var ne,Z;q={x:Math.abs(Math.round(Q.pageX)-(((ne=z.current)==null?void 0:ne.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((Z=z.current)==null?void 0:Z.y)??0))}},Y=Q=>{q.x<=10&&q.y<=10?Q.preventDefault():x.contains(Q.target)||B(!1),document.removeEventListener("pointermove",K),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",K),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",Y,{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]=a$(q=>{const K=P().filter(ne=>!ne.disabled),Y=K.find(ne=>ne.ref.current===document.activeElement),Q=l$(K,q,Y);Q&&setTimeout(()=>Q.ref.current.focus())}),$=w.useCallback((q,K,Y)=>{const Q=!T.current&&!Y;(v.value!==void 0&&v.value===K||Q)&&(N(q),Q&&(T.current=!0))},[v.value]),D=w.useCallback(()=>x==null?void 0:x.focus(),[x]),H=w.useCallback((q,K,Y)=>{const Q=!T.current&&!Y;(v.value!==void 0&&v.value===K||Q)&&I(q)},[v.value]),V=r==="popper"?kC:W3,G=V===kC?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:g,hideWhenDetached:m,avoidCollisions:b}:{};return f.jsx(V3,{scope:n,content:x,viewport:_,onViewportChange:S,itemRefCallback:$,selectedItem:k,onItemLeave:D,itemTextRefCallback:H,focusSelectedItem:L,selectedItemText:M,position:r,isPositioned:j,searchRef:A,children:f.jsx(Ec,{as:I3,allowPinchZoom:!0,children:f.jsx(Np,{asChild:!0,trapped:v.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:he(o,q=>{var K;(K=v.trigger)==null||K.focus({preventScroll:!0}),q.preventDefault()}),children:f.jsx(_c,{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:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:he(y.onKeyDown,q=>{const K=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!K&&q.key.length===1&&W(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let Q=P().filter(ne=>!ne.disabled).map(ne=>ne.ref.current);if(["ArrowUp","End"].includes(q.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const ne=q.target,Z=Q.indexOf(ne);Q=Q.slice(Z+1)}setTimeout(()=>O(Q)),q.preventDefault()}})})})})})})});H3.displayName=xie;var wie="SelectItemAlignedPosition",W3=w.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=Va(tc,n),s=Ha(tc,n),[a,l]=w.useState(null),[c,u]=w.useState(null),d=He(t,E=>u(E)),h=Ry(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 E=i.trigger.getBoundingClientRect(),k=c.getBoundingClientRect(),N=i.valueNode.getBoundingClientRect(),M=y.getBoundingClientRect();if(i.dir!=="rtl"){const ne=M.left-k.left,Z=N.left-ne,ie=E.left-Z,te=E.width+ie,ce=Math.max(te,k.width),de=window.innerWidth-zo,ke=_C(Z,[zo,Math.max(zo,de-ce)]);a.style.minWidth=te+"px",a.style.left=ke+"px"}else{const ne=k.right-M.right,Z=window.innerWidth-N.right-ne,ie=window.innerWidth-E.right-Z,te=E.width+ie,ce=Math.max(te,k.width),de=window.innerWidth-zo,ke=_C(Z,[zo,Math.max(zo,de-ce)]);a.style.minWidth=te+"px",a.style.right=ke+"px"}const I=h(),P=window.innerHeight-zo*2,j=m.scrollHeight,F=window.getComputedStyle(c),T=parseInt(F.borderTopWidth,10),O=parseInt(F.paddingTop,10),L=parseInt(F.borderBottomWidth,10),B=parseInt(F.paddingBottom,10),z=T+O+j+B+L,A=Math.min(b.offsetHeight*5,z),W=window.getComputedStyle(m),$=parseInt(W.paddingTop,10),D=parseInt(W.paddingBottom,10),H=E.top+E.height/2-zo,V=P-H,G=b.offsetHeight/2,q=b.offsetTop+G,K=T+O+q,Y=z-K;if(K<=H){const ne=I.length>0&&b===I[I.length-1].ref.current;a.style.bottom="0px";const Z=c.clientHeight-m.offsetTop-m.offsetHeight,ie=Math.max(V,G+(ne?D:0)+Z+L),te=K+ie;a.style.height=te+"px"}else{const ne=I.length>0&&b===I[0].ref.current;a.style.top="0px";const ie=Math.max(H,T+m.offsetTop+(ne?$:0)+G)+Y;a.style.height=ie+"px",m.scrollTop=K-H+m.offsetTop}a.style.margin=`${zo}px 0`,a.style.minHeight=A+"px",a.style.maxHeight=P+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,i.trigger,i.valueNode,a,c,m,b,y,i.dir,r]);Yn(()=>x(),[x]);const[C,_]=w.useState();Yn(()=>{c&&_(window.getComputedStyle(c).zIndex)},[c]);const S=w.useCallback(E=>{E&&g.current===!0&&(x(),v==null||v(),g.current=!1)},[x,v]);return f.jsx(Sie,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:f.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:C},children:f.jsx(_e.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});W3.displayName=wie;var Cie="SelectPopperPosition",kC=w.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=zo,...i}=e,s=ky(n);return f.jsx(Pp,{...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)"}})});kC.displayName=Cie;var[Sie,c2]=_d(tc,{}),NC="SelectViewport",U3=w.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=Ha(NC,n),s=c2(NC,n),a=He(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(_y.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:he(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-zo*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),C=v-x;d.style.height=x+"px",d.style.bottom==="0px"&&(u.scrollTop=C>0?C:0,d.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});U3.displayName=NC;var q3="SelectGroup",[Eie,_ie]=_d(q3),G3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nn();return f.jsx(Eie,{scope:n,id:o,children:f.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});G3.displayName=q3;var Y3="SelectLabel",K3=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_ie(Y3,n);return f.jsx(_e.div,{id:o.id,...r,ref:t})});K3.displayName=Y3;var Pb="SelectItem",[Rie,X3]=_d(Pb),Q3=w.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...s}=e,a=Va(Pb,n),l=Ha(Pb,n),c=a.value===r,[u,d]=w.useState(i??""),[h,p]=w.useState(!1),g=He(t,v=>{var x;return(x=l.itemRefCallback)==null?void 0:x.call(l,v,r,o)}),m=Nn(),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(Rie,{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(_y.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:he(s.onFocus,()=>p(!0)),onBlur:he(s.onBlur,()=>p(!1)),onClick:he(s.onClick,()=>{b.current!=="mouse"&&y()}),onPointerUp:he(s.onPointerUp,()=>{b.current==="mouse"&&y()}),onPointerDown:he(s.onPointerDown,v=>{b.current=v.pointerType}),onPointerMove:he(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:he(s.onPointerLeave,v=>{var x;v.currentTarget===document.activeElement&&((x=l.onItemLeave)==null||x.call(l))}),onKeyDown:he(s.onKeyDown,v=>{var C;((C=l.searchRef)==null?void 0:C.current)!==""&&v.key===" "||(hie.includes(v.key)&&y(),v.key===" "&&v.preventDefault())})})})})});Q3.displayName=Pb;var pf="SelectItemText",Z3=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,s=Va(pf,n),a=Ha(pf,n),l=X3(pf,n),c=bie(pf,n),[u,d]=w.useState(null),h=He(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 Yn(()=>(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?Rs.createPortal(i.children,s.valueNode):null]})});Z3.displayName=pf;var J3="SelectItemIndicator",e$=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return X3(J3,n).isSelected?f.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});e$.displayName=J3;var MC="SelectScrollUpButton",t$=w.forwardRef((e,t)=>{const n=Ha(MC,e.__scopeSelect),r=c2(MC,e.__scopeSelect),[o,i]=w.useState(!1),s=He(t,r.onScrollButtonChange);return Yn(()=>{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(r$,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});t$.displayName=MC;var DC="SelectScrollDownButton",n$=w.forwardRef((e,t)=>{const n=Ha(DC,e.__scopeSelect),r=c2(DC,e.__scopeSelect),[o,i]=w.useState(!1),s=He(t,r.onScrollButtonChange);return Yn(()=>{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(r$,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});n$.displayName=DC;var r$=w.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=Ha("SelectScrollButton",n),s=w.useRef(null),a=Ry(n),l=w.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return w.useEffect(()=>()=>l(),[l]),Yn(()=>{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:he(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:he(o.onPointerMove,()=>{var c;(c=i.onItemLeave)==null||c.call(i),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:he(o.onPointerLeave,()=>{l()})})}),kie="SelectSeparator",o$=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return f.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});o$.displayName=kie;var PC="SelectArrow",Nie=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ky(n),i=Va(PC,n),s=Ha(PC,n);return i.open&&s.position==="popper"?f.jsx(Ap,{...o,...r,ref:t}):null});Nie.displayName=PC;function i$(e){return e===""||e===void 0}var s$=w.forwardRef((e,t)=>{const{value:n,...r}=e,o=w.useRef(null),i=He(t,o),s=Ey(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(l2,{asChild:!0,children:f.jsx("select",{...r,ref:i,defaultValue:n})})});s$.displayName="BubbleSelect";function a$(e){const t=In(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 l$(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=Mie(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 Mie(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Die=T3,c$=O3,Pie=$3,Aie=L3,Iie=z3,u$=B3,Tie=U3,jie=G3,d$=K3,f$=Q3,Oie=Z3,Fie=e$,h$=t$,p$=n$,m$=o$;const Dt=Die,Qs=jie,Pt=Pie,Ct=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(c$,{ref:r,className:oe("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(Aie,{asChild:!0,children:f.jsx(ma,{className:"h-4 w-4 opacity-50"})})]}));Ct.displayName=c$.displayName;const g$=w.forwardRef(({className:e,...t},n)=>f.jsx(h$,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(Mf,{className:"h-4 w-4"})}));g$.displayName=h$.displayName;const b$=w.forwardRef(({className:e,...t},n)=>f.jsx(p$,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(ma,{className:"h-4 w-4"})}));b$.displayName=p$.displayName;const St=w.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>f.jsx(Iie,{children:f.jsx(ri,{children:f.jsxs(u$,{ref:o,className:oe("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(g$,{}),f.jsx(Tie,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),f.jsx(b$,{})]})})}));St.displayName=u$.displayName;const cs=w.forwardRef(({className:e,...t},n)=>f.jsx(d$,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));cs.displayName=d$.displayName;const xe=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(f$,{ref:r,className:oe("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(Fie,{children:f.jsx(Ur,{className:"h-4 w-4"})})}),f.jsx(Oie,{children:t})]}));xe.displayName=f$.displayName;const Tf=w.forwardRef(({className:e,...t},n)=>f.jsx(m$,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));Tf.displayName=m$.displayName;const Cr=w.forwardRef(({className:e,type:t,...n},r)=>f.jsx("input",{type:t,className:oe("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}));Cr.displayName="Input";var $ie="Label",u2=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())}}));u2.displayName=$ie;var y$=u2;const Lie=sy("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fe=w.forwardRef(({className:e,...t},n)=>f.jsx(y$,{ref:n,className:oe(Lie(),e),...t}));fe.displayName=y$.displayName;function zie({step:e,hierarchyId:t,stepIndex:n,onUpdateStep:r,open:o,onOpenChange:i,trigger:s}){return f.jsxs(za,{open:o,onOpenChange:i,children:[f.jsx(Ba,{asChild:!0,children:s}),f.jsx(Ts,{className:"z-50 w-80",align:"start",children:f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx(fe,{className:"mb-1 block text-xs font-medium",children:"Chart Type"}),f.jsxs(Dt,{value:e.preferredChartType||"bar",onValueChange:a=>{r(t,n,{preferredChartType:a})},children:[f.jsx(Ct,{className:"h-8",children:f.jsx(Pt,{})}),f.jsxs(St,{children:[f.jsx(xe,{value:"bar",children:"Bar Chart"}),f.jsx(xe,{value:"pie",children:"Pie Chart"}),f.jsx(xe,{value:"line",children:"Line Chart"}),f.jsx(xe,{value:"donut",children:"Donut Chart"}),f.jsx(xe,{value:"table",children:"Table"}),f.jsx(xe,{value:"metric",children:"Metric"})]})]})]}),f.jsxs("div",{children:[f.jsx(fe,{className:"mb-1 block text-xs font-medium",children:"Step Label"}),f.jsx(Cr,{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(fe,{className:"mb-1 block text-xs font-medium",children:"Breadcrumb Label Template"}),f.jsx(Cr,{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(Se,{size:"sm",variant:"outline",onClick:()=>i(!1),children:"Done"})})]})})]})}function Bie({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}=W_({id:`${r}-${e.id}-${n}`,disabled:!1}),m={transform:Ai.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(zie,{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 Vie(e){return{sensors:F_(bh(_p,{activationConstraint:{distance:5}}),bh(Ep,{coordinateGetter:U_})),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=kp(o.steps,c,u);e(o.id,{steps:d})}}}}function Hie({hierarchy:e,onUpdateStep:t,onRemoveStep:n,onUpdateHierarchy:r}){const{sensors:o}=Vie(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(V_,{sensors:o,collisionDetection:$_,onDragStart:u,onDragEnd:d,children:[f.jsx(H_,{items:c,strategy:yre,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(Pi,{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(Bie,{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"&&an.createPortal(f.jsx(H4,{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 kD=1,Wie=.9,Uie=.8,qie=.17,jx=.1,Ox=.999,Gie=.9999,Yie=.99,Kie=/[\\\/_+.#"@\[\(\{&]/,Xie=/[\\\/_+.#"@\[\(\{&]/g,Qie=/[\s-]/,v$=/[\s-]/g;function AC(e,t,n,r,o,i,s){if(i===t.length)return o===e.length?kD:Yie;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=AC(e,t,n,r,c+1,i+1,s),d>u&&(c===o?d*=kD:Kie.test(e.charAt(c-1))?(d*=Uie,p=e.slice(o,c-1).match(Xie),p&&o>0&&(d*=Math.pow(Ox,p.length))):Qie.test(e.charAt(c-1))?(d*=Wie,g=e.slice(o,c-1).match(v$),g&&o>0&&(d*=Math.pow(Ox,g.length))):(d*=qie,o>0&&(d*=Math.pow(Ox,c-o))),e.charAt(c)!==t.charAt(i)&&(d*=Gie)),(d<jx&&n.charAt(c-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(c-1)!==r.charAt(i))&&(h=AC(e,t,n,r,c+1,i+2,s),h*jx>d&&(d=h*jx)),d>u&&(u=d),c=n.indexOf(l,c+1);return s[a]=u,u}function ND(e){return e.toLowerCase().replace(v$," ")}function Zie(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,AC(e,t,ND(e),ND(t),0,0,{})}var Kd='[cmdk-group=""]',Fx='[cmdk-group-items=""]',Jie='[cmdk-group-heading=""]',x$='[cmdk-item=""]',MD=`${x$}:not([aria-disabled="true"])`,IC="cmdk-item-select",eu="data-value",ese=(e,t,n)=>Zie(e,t,n),w$=w.createContext(void 0),jp=()=>w.useContext(w$),C$=w.createContext(void 0),d2=()=>w.useContext(C$),S$=w.createContext(void 0),E$=w.forwardRef((e,t)=>{let n=tu(()=>{var $,D;return{search:"",value:(D=($=e.value)!=null?$:e.defaultValue)!=null?D:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=tu(()=>new Set),o=tu(()=>new Map),i=tu(()=>new Map),s=tu(()=>new Set),a=_$(e),{label:l,children:c,value:u,onValueChange:d,filter:h,shouldFilter:p,loop:g,disablePointerSelection:m=!1,vimBindings:b=!0,...y}=e,v=Nn(),x=Nn(),C=Nn(),_=w.useRef(null),S=dse();nc(()=>{if(u!==void 0){let $=u.trim();n.current.value=$,E.emit()}},[u]),nc(()=>{S(6,j)},[]);let E=w.useMemo(()=>({subscribe:$=>(s.current.add($),()=>s.current.delete($)),snapshot:()=>n.current,setState:($,D,H)=>{var V,G,q,K;if(!Object.is(n.current[$],D)){if(n.current[$]=D,$==="search")P(),M(),S(1,I);else if($==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Y=document.getElementById(C);Y?Y.focus():(V=document.getElementById(v))==null||V.focus()}if(S(7,()=>{var Y;n.current.selectedItemId=(Y=F())==null?void 0:Y.id,E.emit()}),H||S(5,j),((G=a.current)==null?void 0:G.value)!==void 0){let Y=D??"";(K=(q=a.current).onValueChange)==null||K.call(q,Y);return}}E.emit()}},emit:()=>{s.current.forEach($=>$())}}),[]),k=w.useMemo(()=>({value:($,D,H)=>{var V;D!==((V=i.current.get($))==null?void 0:V.value)&&(i.current.set($,{value:D,keywords:H}),n.current.filtered.items.set($,N(D,H)),S(2,()=>{M(),E.emit()}))},item:($,D)=>(r.current.add($),D&&(o.current.has(D)?o.current.get(D).add($):o.current.set(D,new Set([$]))),S(3,()=>{P(),M(),n.current.value||I(),E.emit()}),()=>{i.current.delete($),r.current.delete($),n.current.filtered.items.delete($);let H=F();S(4,()=>{P(),(H==null?void 0:H.getAttribute("id"))===$&&I(),E.emit()})}),group:$=>(o.current.has($)||o.current.set($,new Set),()=>{i.current.delete($),o.current.delete($)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:v,inputId:C,labelId:x,listInnerRef:_}),[]);function N($,D){var H,V;let G=(V=(H=a.current)==null?void 0:H.filter)!=null?V:ese;return $?G($,n.current.search,D):0}function M(){if(!n.current.search||a.current.shouldFilter===!1)return;let $=n.current.filtered.items,D=[];n.current.filtered.groups.forEach(V=>{let G=o.current.get(V),q=0;G.forEach(K=>{let Y=$.get(K);q=Math.max(Y,q)}),D.push([V,q])});let H=_.current;T().sort((V,G)=>{var q,K;let Y=V.getAttribute("id"),Q=G.getAttribute("id");return((q=$.get(Q))!=null?q:0)-((K=$.get(Y))!=null?K:0)}).forEach(V=>{let G=V.closest(Fx);G?G.appendChild(V.parentElement===G?V:V.closest(`${Fx} > *`)):H.appendChild(V.parentElement===H?V:V.closest(`${Fx} > *`))}),D.sort((V,G)=>G[1]-V[1]).forEach(V=>{var G;let q=(G=_.current)==null?void 0:G.querySelector(`${Kd}[${eu}="${encodeURIComponent(V[0])}"]`);q==null||q.parentElement.appendChild(q)})}function I(){let $=T().find(H=>H.getAttribute("aria-disabled")!=="true"),D=$==null?void 0:$.getAttribute(eu);E.setState("value",D||void 0)}function P(){var $,D,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 K=(D=($=i.current.get(q))==null?void 0:$.value)!=null?D:"",Y=(V=(H=i.current.get(q))==null?void 0:H.keywords)!=null?V:[],Q=N(K,Y);n.current.filtered.items.set(q,Q),Q>0&&G++}for(let[q,K]of o.current)for(let Y of K)if(n.current.filtered.items.get(Y)>0){n.current.filtered.groups.add(q);break}n.current.filtered.count=G}function j(){var $,D,H;let V=F();V&&((($=V.parentElement)==null?void 0:$.firstChild)===V&&((H=(D=V.closest(Kd))==null?void 0:D.querySelector(Jie))==null||H.scrollIntoView({block:"nearest"})),V.scrollIntoView({block:"nearest"}))}function F(){var $;return($=_.current)==null?void 0:$.querySelector(`${x$}[aria-selected="true"]`)}function T(){var $;return Array.from((($=_.current)==null?void 0:$.querySelectorAll(MD))||[])}function O($){let D=T()[$];D&&E.setState("value",D.getAttribute(eu))}function L($){var D;let H=F(),V=T(),G=V.findIndex(K=>K===H),q=V[G+$];(D=a.current)!=null&&D.loop&&(q=G+$<0?V[V.length-1]:G+$===V.length?V[0]:V[G+$]),q&&E.setState("value",q.getAttribute(eu))}function B($){let D=F(),H=D==null?void 0:D.closest(Kd),V;for(;H&&!V;)H=$>0?cse(H,Kd):use(H,Kd),V=H==null?void 0:H.querySelector(MD);V?E.setState("value",V.getAttribute(eu)):L($)}let z=()=>O(T().length-1),A=$=>{$.preventDefault(),$.metaKey?z():$.altKey?B(1):L(1)},W=$=>{$.preventDefault(),$.metaKey?O(0):$.altKey?B(-1):L(-1)};return w.createElement(_e.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:$=>{var D;(D=y.onKeyDown)==null||D.call(y,$);let H=$.nativeEvent.isComposing||$.keyCode===229;if(!($.defaultPrevented||H))switch($.key){case"n":case"j":{b&&$.ctrlKey&&A($);break}case"ArrowDown":{A($);break}case"p":case"k":{b&&$.ctrlKey&&W($);break}case"ArrowUp":{W($);break}case"Home":{$.preventDefault(),O(0);break}case"End":{$.preventDefault(),z();break}case"Enter":{$.preventDefault();let V=F();if(V){let G=new Event(IC);V.dispatchEvent(G)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:hse},l),Ny(e,$=>w.createElement(C$.Provider,{value:E},w.createElement(w$.Provider,{value:k},$))))}),tse=w.forwardRef((e,t)=>{var n,r;let o=Nn(),i=w.useRef(null),s=w.useContext(S$),a=jp(),l=_$(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:s==null?void 0:s.forceMount;nc(()=>{if(!c)return a.item(o,s==null?void 0:s.id)},[c]);let u=R$(o,i,[e.value,e.children,i],e.keywords),d=d2(),h=Ea(S=>S.value&&S.value===u.current),p=Ea(S=>c||a.filter()===!1?!0:S.search?S.filtered.items.get(o)>0:!0);w.useEffect(()=>{let S=i.current;if(!(!S||e.disabled))return S.addEventListener(IC,g),()=>S.removeEventListener(IC,g)},[p,e.onSelect,e.disabled]);function g(){var S,E;m(),(E=(S=l.current).onSelect)==null||E.call(S,u.current)}function m(){d.setState("value",u.current,!0)}if(!p)return null;let{disabled:b,value:y,onSelect:v,forceMount:x,keywords:C,..._}=e;return w.createElement(_e.div,{ref:Sr(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)}),nse=w.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...i}=e,s=Nn(),a=w.useRef(null),l=w.useRef(null),c=Nn(),u=jp(),d=Ea(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(s):!0);nc(()=>u.group(s),[]),R$(s,a,[e.value,e.heading,l]);let h=w.useMemo(()=>({id:s,forceMount:o}),[o]);return w.createElement(_e.div,{ref:Sr(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),Ny(e,p=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},w.createElement(S$.Provider,{value:h},p))))}),rse=w.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=w.useRef(null),i=Ea(s=>!s.search);return!n&&!i?null:w.createElement(_e.div,{ref:Sr(o,t),...r,"cmdk-separator":"",role:"separator"})}),ose=w.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,i=d2(),s=Ea(c=>c.search),a=Ea(c=>c.selectedItemId),l=jp();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)}})}),ise=w.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,i=w.useRef(null),s=w.useRef(null),a=Ea(c=>c.selectedItemId),l=jp();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:Sr(i,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Ny(e,c=>w.createElement("div",{ref:Sr(s,l.listInnerRef),"cmdk-list-sizer":""},c)))}),sse=w.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:i,container:s,...a}=e;return w.createElement(h4,{open:n,onOpenChange:r},w.createElement(p4,{container:s},w.createElement(I_,{"cmdk-overlay":"",className:o}),w.createElement(T_,{"aria-label":e.label,"cmdk-dialog":"",className:i},w.createElement(E$,{ref:t,...a}))))}),ase=w.forwardRef((e,t)=>Ea(n=>n.filtered.count===0)?w.createElement(_e.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),lse=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},Ny(e,s=>w.createElement("div",{"aria-hidden":!0},s)))}),Kr=Object.assign(E$,{List:ise,Item:tse,Input:ose,Group:nse,Separator:rse,Dialog:sse,Empty:ase,Loading:lse});function cse(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function use(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function _$(e){let t=w.useRef(e);return nc(()=>{t.current=e}),t}var nc=typeof window>"u"?w.useEffect:w.useLayoutEffect;function tu(e){let t=w.useRef();return t.current===void 0&&(t.current=e()),t}function Ea(e){let t=d2(),n=()=>e(t.snapshot());return w.useSyncExternalStore(t.subscribe,n,n)}function R$(e,t,n,r=[]){let o=w.useRef(),i=jp();return nc(()=>{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(eu,a),o.current=a}),o}var dse=()=>{let[e,t]=w.useState(),n=tu(()=>new Map);return nc(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function fse(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Ny({asChild:e,children:t},n){return e&&w.isValidElement(t)?w.cloneElement(fse(t),{ref:t.ref},n(t.props.children)):n(t)}var hse={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const My=w.forwardRef(({className:e,...t},n)=>f.jsx(Kr,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));My.displayName=Kr.displayName;const Dy=w.forwardRef(({className:e,...t},n)=>f.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[f.jsx(E_,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),f.jsx(Kr.Input,{ref:n,className:oe("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})]}));Dy.displayName=Kr.Input.displayName;const Py=w.forwardRef(({className:e,...t},n)=>f.jsx(Kr.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Py.displayName=Kr.List.displayName;const Ay=w.forwardRef((e,t)=>f.jsx(Kr.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Ay.displayName=Kr.Empty.displayName;const Iy=w.forwardRef(({className:e,...t},n)=>f.jsx(Kr.Group,{ref:n,className:oe("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}));Iy.displayName=Kr.Group.displayName;const pse=w.forwardRef(({className:e,...t},n)=>f.jsx(Kr.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));pse.displayName=Kr.Separator.displayName;const Ty=w.forwardRef(({className:e,...t},n)=>f.jsx(Kr.Item,{ref:n,className:oe("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}));Ty.displayName=Kr.Item.displayName;function mse({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(za,{open:a,onOpenChange:l,children:[f.jsx(Ba,{asChild:!0,children:f.jsxs(Se,{variant:"outline",role:"combobox","aria-expanded":a,className:oe("justify-between",o),disabled:i,children:[u?u.label:r,f.jsx(fF,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),f.jsx(Ts,{className:"z-50 w-[200px] p-0",children:f.jsxs(My,{children:[f.jsx(Dy,{placeholder:"Search fields..."}),f.jsxs(Py,{children:[f.jsx(Ay,{children:"No field found."}),f.jsx(Iy,{children:c.map(d=>f.jsxs(Ty,{value:d.label,onSelect:()=>{n(d.id),l(!1)},children:[f.jsx(Ur,{className:oe("mr-2 h-4 w-4",t===d.id?"opacity-100":"opacity-0")}),d.label]},d.id))})]})]})})]})}function gse({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}=W_({id:e.id,disabled:u}),b={transform:Ai.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(Pre,{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(Se,{size:"sm",variant:"ghost",onClick:v=>{v.stopPropagation(),i(e.id)},onPointerDown:v=>v.stopPropagation(),children:f.jsx(pp,{className:"h-3 w-3"})})})]}),f.jsx(Hie,{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(mse,{fields:n,excludeFieldIds:y,onValueChange:v=>c(e.id,v),placeholder:"Add drill step...",className:"w-48"})})})]})}function bse({configuringIntent:e,setConfiguringIntent:t,drillHierarchies:n,onUpdateHierarchies:r,availableFields:o}){const i=F_(bh(_p),bh(Ep,{coordinateGetter:U_})),{editingHierarchy:s,setEditingHierarchy:a,createNewHierarchy:l,deleteHierarchy:c,updateHierarchy:u,addStepToHierarchy:d,removeStepFromHierarchy:h,updateStep:p,setDefaultHierarchy:g}=Dre(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),C=n.findIndex(_=>_.id===(v==null?void 0:v.id));r(kp(n,x,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-blue-100",children:f.jsx(cF,{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(Se,{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(Se,{size:"sm",onClick:l,children:[f.jsx(Cc,{className:"mr-1 h-4 w-4"}),"Add Hierarchy"]})})]}),f.jsx(V_,{sensors:i,collisionDetection:$_,onDragEnd:m,children:f.jsx(H_,{items:n.map(b=>b.id),strategy:U4,children:f.jsx("div",{className:"mb-6 space-y-4",children:n.map(b=>f.jsx(gse,{hierarchy:b,editingHierarchy:s,sampleFieldReferences:o,onSetEditingHierarchy:a,onUpdateHierarchy:u,onDeleteHierarchy:c,onSetDefaultHierarchy:g,onUpdateStep:p,onRemoveStep:h,onAddStep:d},b.id))})})})]})]})]})})}var f2="Checkbox",[yse,tLe]=On(f2),[vse,xse]=yse(f2),k$=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=He(t,C=>p(C)),m=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=dr({prop:o,defaultProp:i,onChange:c}),x=w.useRef(y);return w.useEffect(()=>{const C=h==null?void 0:h.form;if(C){const _=()=>v(x.current);return C.addEventListener("reset",_),()=>C.removeEventListener("reset",_)}},[h,v]),f.jsxs(vse,{scope:n,state:y,disabled:a,children:[f.jsx(_e.button,{type:"button",role:"checkbox","aria-checked":ya(y)?"mixed":y,"aria-required":s,"data-state":D$(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:g,onKeyDown:he(e.onKeyDown,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:he(e.onClick,C=>{v(_=>ya(_)?!0:!_),b&&(m.current=C.isPropagationStopped(),m.current||C.stopPropagation())})}),b&&f.jsx(wse,{control:h,bubbles:!m.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:ya(i)?!1:i})]})});k$.displayName=f2;var N$="CheckboxIndicator",M$=w.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=xse(N$,n);return f.jsx(gn,{present:r||ya(i.state)||i.state===!0,children:f.jsx(_e.span,{"data-state":D$(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});M$.displayName=N$;var wse=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=w.useRef(null),a=Ey(n),l=Cy(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=ya(n),p.call(u,ya(n)?!1:n),u.dispatchEvent(g)}},[a,n,r]);const c=w.useRef(ya(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 ya(e){return e==="indeterminate"}function D$(e){return ya(e)?"indeterminate":e?"checked":"unchecked"}var P$=k$,Cse=M$;const qr=w.forwardRef(({className:e,...t},n)=>f.jsx(P$,{ref:n,className:oe("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(Cse,{className:oe("flex items-center justify-center text-current"),children:f.jsx(Ur,{className:"h-4 w-4"})})}));qr.displayName=P$.displayName;function Sse({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(Cr,{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(Se,{size:"sm",variant:"outline",onClick:l,children:"Select All"}),f.jsx(Se,{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(qr,{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 Ese=e=>["string","boolean"].includes(wO(e.dataType));function _se({configuringIntent:e,setConfiguringIntent:t,selectedDrillTargets:n,setSelectedDrillTargets:r,availableFields:o}){const i=o.filter(Ese),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(wF,{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(Se,{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(Sse,{fields:i,selectedFieldIds:s,onSelectionChange:a,searchPlaceholder:"Search fields..."})})]})]})]})]})})}var h2="Switch",[Rse,nLe]=On(h2),[kse,Nse]=Rse(h2),A$=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=He(t,x=>p(x)),m=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=dr({prop:o,defaultProp:i,onChange:c});return f.jsxs(kse,{scope:n,checked:y,disabled:a,children:[f.jsx(_e.button,{type:"button",role:"switch","aria-checked":y,"aria-required":s,"data-state":j$(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:g,onClick:he(e.onClick,x=>{v(C=>!C),b&&(m.current=x.isPropagationStopped(),m.current||x.stopPropagation())})}),b&&f.jsx(Mse,{control:h,bubbles:!m.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});A$.displayName=h2;var I$="SwitchThumb",T$=w.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Nse(I$,n);return f.jsx(_e.span,{"data-state":j$(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});T$.displayName=I$;var Mse=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=Ey(n),a=Cy(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 j$(e){return e?"checked":"unchecked"}var jy=A$,O$=T$;const p2=w.forwardRef(({className:e,...t},n)=>f.jsx(jy,{className:oe("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(O$,{className:oe("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")})}));p2.displayName=jy.displayName;var m2="Radio",[Dse,F$]=On(m2),[Pse,Ase]=Dse(m2),$$=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=He(t,b=>h(b)),g=w.useRef(!1),m=d?c||!!d.closest("form"):!0;return f.jsxs(Pse,{scope:n,checked:o,disabled:s,children:[f.jsx(_e.button,{type:"button",role:"radio","aria-checked":o,"data-state":B$(o),"data-disabled":s?"":void 0,disabled:s,value:a,...u,ref:p,onClick:he(e.onClick,b=>{o||l==null||l(),m&&(g.current=b.isPropagationStopped(),g.current||b.stopPropagation())})}),m&&f.jsx(Ise,{control:d,bubbles:!g.current,name:r,value:a,checked:o,required:i,disabled:s,form:c,style:{transform:"translateX(-100%)"}})]})});$$.displayName=m2;var L$="RadioIndicator",z$=w.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...o}=e,i=Ase(L$,n);return f.jsx(gn,{present:r||i.checked,children:f.jsx(_e.span,{"data-state":B$(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})});z$.displayName=L$;var Ise=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=Ey(n),a=Cy(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 B$(e){return e?"checked":"unchecked"}var Tse=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],g2="RadioGroup",[jse,rLe]=On(g2,[gd,F$]),V$=gd(),H$=F$(),[Ose,Fse]=jse(g2),W$=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=V$(n),g=yc(c),[m,b]=dr({prop:i,defaultProp:o,onChange:d});return f.jsx(Ose,{scope:n,name:r,required:s,disabled:a,value:m,onValueChange:b,children:f.jsx(BE,{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})})})});W$.displayName=g2;var U$="RadioGroupItem",q$=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...o}=e,i=Fse(U$,n),s=i.disabled||r,a=V$(n),l=H$(n),c=w.useRef(null),u=He(t,c),d=i.value===o.value,h=w.useRef(!1);return w.useEffect(()=>{const p=m=>{Tse.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(VE,{asChild:!0,...a,focusable:!s,active:d,children:f.jsx($$,{disabled:s,required:i.required,checked:d,...l,...o,name:i.name,ref:u,onCheck:()=>i.onValueChange(o.value),onKeyDown:he(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:he(o.onFocus,()=>{var p;h.current&&((p=c.current)==null||p.click())})})})});q$.displayName=U$;var $se="RadioGroupIndicator",G$=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,o=H$(n);return f.jsx(z$,{...o,...r,ref:t})});G$.displayName=$se;var Y$=W$,K$=q$,Lse=G$;const _a=w.forwardRef(({className:e,...t},n)=>f.jsx(Y$,{className:oe("grid gap-2",e),...t,ref:n}));_a.displayName=Y$.displayName;const Vr=w.forwardRef(({className:e,...t},n)=>f.jsx(K$,{ref:n,className:oe("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(Lse,{className:"flex items-center justify-center",children:f.jsx(m_,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Vr.displayName=K$.displayName;function zse({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=mO(),h=e==="clickFilter",p=()=>{const S=!i;if(s(S),S){const E={filterFields:n,highlightSelf:!0,mode:"clickFilter"};l(E),r([E])}else r([])},g=()=>{t("clickFilter")},m=()=>{t(null)},b=S=>{const E={...a,...S};l(E),r([E])},y=()=>a.applyToCardIds!==void 0?"specific-cards":a.excludeCardIds!==void 0?"all-except-specific":"all-cards",v=S=>{const E={};switch(S){case"all-cards":E.applyToCardIds=void 0,E.excludeCardIds=void 0;break;case"specific-cards":E.applyToCardIds=[],E.excludeCardIds=void 0;break;case"all-except-specific":E.applyToCardIds=void 0,E.excludeCardIds=[];break}b(E)},x=(S,E)=>{if(E==="specific-cards"){const k=a.applyToCardIds||[],N=k.includes(S)?k.filter(M=>M!==S):[...k,S];b({applyToCardIds:N})}else if(E==="all-except-specific"){const k=a.excludeCardIds||[],N=k.includes(S)?k.filter(M=>M!==S):[...k,S];b({excludeCardIds:N})}},C=R.useMemo(()=>{if(!c.trim())return d;const S=c.toLowerCase();return d==null?void 0:d.filter(E=>{var k;return(k=E==null?void 0:E.title)==null?void 0:k.toLowerCase().includes(S)})},[c,d]),_=()=>{var E,k;if(!i)return"0 settings configured";const S=y();if(S==="all-cards")return"filtering all cards";if(S==="specific-cards"){const N=((E=a.applyToCardIds)==null?void 0:E.length)||0;return N===0?"no cards selected":`filtering ${N} card${N!==1?"s":""}`}else if(S==="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(p2,{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(Se,{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(fe,{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(_a,{value:y(),onValueChange:S=>v(S),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(Vr,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(fe,{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(Vr,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(fe,{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(fe,{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(Cr,{placeholder:"Search cards...",value:c,onChange:S=>u(S.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:C.length>0?C.map(S=>{const E=(a.applyToCardIds||[]).includes(S.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(qr,{id:`card-${S.id}`,checked:E,onCheckedChange:()=>x(S.id,"specific-cards")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(fe,{htmlFor:`card-${S.id}`,className:"cursor-pointer text-sm font-medium",children:S.title}),S.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:S.description})]})]},S.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(Vr,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(fe,{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(fe,{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(Cr,{placeholder:"Search cards...",value:c,onChange:S=>u(S.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:C.length>0?C.map(S=>{const E=(a.excludeCardIds||[]).includes(S.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(qr,{id:`card-exclude-${S.id}`,checked:E,onCheckedChange:()=>x(S.id,"all-except-specific")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(fe,{htmlFor:`card-exclude-${S.id}`,className:"cursor-pointer text-sm font-medium",children:S.title}),S.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:S.description})]})]},S.id)}):f.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]})]})]})})]})]})]})})}function Bse(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||Di(n.name),description:n.description,entityId:t.entityId,entityName:t.entityName,entityType:t.entityType})))}function X$(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 Q$(e){var m;const t=re(b=>b.authToken)||e,{hasSchemaSupport:n}=iee(e),r=ue(b=>{var y;return(y=b.card.dataSource)==null?void 0:y.connectionId}),o=ue(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=ue(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=ue(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=gK({queries:l.map(b=>{let y={};return b.type==="model"?y={connection_id:r,datamodel_id:b.id,database_name:"",schema_name:"",table_name:"",domain_id:b.domainId,dataset_name:b.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:()=>Tn("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 C;const v=l[y],x=X$(v);return{entityId:v.id||v.name,entityType:v.type,entityName:v.name,label:v.label,description:v.description,qualifiedEntityName:x,columns:(C=b.data)==null?void 0:C.columns.map(_=>({id:`${v.name}-${_.column_name}`,name:_.column_name,dataType:_.data_type,label:_.label||xO(_.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=Bse(p);return{columnGroups:p,columns:g,isLoading:u,hasError:d,error:h,refetch:()=>{c.forEach(b=>b.refetch())}}}function Vse({isOpen:e,onClose:t}){var T,O,L,B;const n=XJ(),r=QJ(),{updateCurrentDashboardCard:o}=Gt(),{columns:i}=Q$(),{groupByFields:s,pivotByFields:a}=gO(),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)||[]},[(L=n.interactionConfig)==null?void 0:L.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),[C,_]=R.useState(()=>p.filter(z=>z.mode==="drillToURL")),[S,E]=R.useState(()=>p.filter(z=>z.mode==="drillThrough")),[k,N]=R.useState(()=>p.filter(z=>z.mode==="drillToDetail")),[M,I]=R.useState(h),P=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 $=((W=n.interactionConfig)==null?void 0:W.drillInteractions)||[];_($.filter(D=>D.mode==="drillToURL")),E($.filter(D=>D.mode==="drillThrough")),N($.filter(D=>D.mode==="drillToDetail")),I(h)}},[e,n.interactionConfig,h]);const j=()=>{var W;const z=[...C,...S,...k];r.updateDrillHierarchies(g),r.updateDrillInteractions(z),(W=P.current)!=null&&W.saveToGlobal&&P.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(uy,{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(gp,{className:"flex max-h-[90vh] max-w-4xl flex-col overflow-hidden",children:[f.jsxs(bp,{children:[f.jsx(vp,{children:"Configure Interactions"}),f.jsx(xp,{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(zse,{configuringIntent:v,setConfiguringIntent:x,incomingFilterFields:l,onUpdateClickFilterInteractions:I,currentClickFilterInteractions:M}),f.jsx(bse,{configuringIntent:v,setConfiguringIntent:x,drillHierarchies:g,onUpdateHierarchies:m,availableFields:c}),f.jsx(_se,{configuringIntent:v,setConfiguringIntent:x,selectedDrillTargets:b,setSelectedDrillTargets:y,availableFields:c})]})})})}),f.jsxs(yp,{className:"border-t-0",children:[f.jsx(Se,{variant:"outline",onClick:F,children:"Cancel"}),f.jsx(Se,{onClick:j,children:"Save Changes"})]})]})]}):null}function Z$({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}=see(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(ga,{className:"size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}),f.jsx(Vse,{isOpen:o,onClose:()=>i(!1)}),t&&(n?f.jsx("button",{onClick:()=>{l(!n)},children:f.jsx(UZ,{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(GZ,{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(iF,{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(SJ,{data:(d==null?void 0:d.records)||[],filename:u.title})]})})}const Hse=R.createContext(null),$x={didCatch:!1,error:null};class Oy extends R.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=$x}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($x)}}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&&Wse(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($x)}}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(Hse.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function Wse(){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 b2({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 Use({error:e,frame:t}){return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[f.jsx(Z$,{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 qse({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 ur({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 Fy(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function $y(e){try{const n=new Function("getDatalabelColor",e)(M1);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 Gse(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 Yse(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return J$(t)}function J$(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 Kse(e,t){return e.map(r=>Object.fromEntries(Object.entries(r).filter(([o])=>!t.some(i=>i.label===o))))}function Xse(e){return e.length===1?[e[0]]:e.slice(1).filter(n=>!uO.includes(n))}function Vc({data:e,cfg:t,customCfg:n,preferences:r,cardType:o,card:i}){var x;const s=o==="radar"?.2:1,{keys:a}=pn(e),l=Xse(a);let c="none";o=="bar"?c="bar":o=="line"&&(c="line");const u=jF(l,e,r,s,c),d=Il(u,n),h=a[0],p=mp(e,h),{options:g,plugins:m}=Ab({cardType:o,cfg:t,preferences:r,customCfg:n}),b=(x=i.interactionConfig)==null?void 0:x.clickFilterInteractions,y=function(C,_){var E;const S=((E=C.native)==null?void 0:E.target)||C.target;_.length?S.style.cursor="pointer":S.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 eL(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 Qse(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 tL(e,t){var i,s,a,l,c,u,d,h,p,g,m,b;const n=eL(t,e),r=Qse(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,C,_;return ur({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:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.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,C,_;return ur({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:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.locale)||"",currency:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.currency)||""})}}}}}function Ab({cardType:e,cfg:t,preferences:n,customCfg:r}){var g,m,b,y,v,x,C,_,S,E,k,N,M,I,P,j,F,T,O,L,B,z,A,W,$,D,H,V,G;const o=re.getState().themeStyle,i=tL(t,n),s=qn((t==null?void 0:t.options)||{},n==null?void 0:n.chartOptions),a=qn(i,s),l=qn(a,(r==null?void 0:r.options)||{}),c=Zse(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:(_=(C=(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:C.grid)==null?void 0:_.color}},y:{...(S=l==null?void 0:l.scales)==null?void 0:S.y,grid:{...(k=(E=l==null?void 0:l.scales)==null?void 0:E.y)==null?void 0:k.grid,color:(j=(P=(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:P.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=(L=(O=(T=o==null?void 0:o.chart)==null?void 0:T.options)==null?void 0:O.plugins)==null?void 0:L.tooltip)==null?void 0:B.backgroundColor,bodyColor:($=(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:$.bodyColor,titleColor:(G=(V=(H=(D=o==null?void 0:o.chart)==null?void 0:D.options)==null?void 0:H.plugins)==null?void 0:V.tooltip)==null?void 0:G.titleColor}}},{plugins:d,options:h}=$y((n==null?void 0:n.customVisualCode)||"");return{options:qn(u,h),plugins:d}}function Zse(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=ur({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=ur({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)||{}}}/*!
|
|
491
491
|
* @kurkle/color v0.3.4
|
|
492
492
|
* https://github.com/kurkle/color#readme
|
|
493
493
|
* (c) 2024 Jukka Kurkela
|
|
@@ -629,7 +629,7 @@ Error message: ${XW(n)}`,cause:n}),this[iU]=!0,this.value=t}static isInstance(t)
|
|
|
629
629
|
padding: 0 4px;
|
|
630
630
|
margin: 0 1px;
|
|
631
631
|
}
|
|
632
|
-
`})]})});EU.displayName="HighlightedInput";function NFe({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=P=>"label"in P?P.label:P.name,d=P=>t.selectedEntities.some(j=>"id"in P&&"id"in j?P.id===j.id:P.name===j.name&&P.connectionId===j.connectionId),h=P=>{if(!P)return;P.focus();const j=window.getSelection();if(j){const F=document.createRange();F.selectNodeContents(P),F.collapse(!1),j.removeAllRanges(),j.addRange(F)}},p=P=>{const j=P.target.value,F=P.target.selectionStart||0;o(j),l(F);const T=j.slice(0,F),O=T.lastIndexOf("@");if(O!==-1){const L=T.slice(O+1),B=(O===0||/\s/.test(T[O-1]))&&!L.includes(" ");s(B)}else s(!1)},g=P=>{P.key==="Escape"&&i&&(P.preventDefault(),s(!1),setTimeout(()=>{if(P.currentTarget){P.currentTarget.focus();const j=window.getSelection();if(j){const F=document.createRange();F.selectNodeContents(P.currentTarget),F.collapse(!1),j.removeAllRanges(),j.addRange(F)}}},0))},m=P=>{const j=u(P),T=r.slice(0,a).lastIndexOf("@");if(T!==-1){const O=r.slice(0,T),L=r.slice(a),B=O+"@"+j+" "+L;o(B);const z=T+j.length+2;l(z)}},b=P=>{const F=`@${u(P)}`,T=r.indexOf(F);if(T!==-1){const O=r.slice(0,T),L=r.slice(T+F.length),B=O+(L.startsWith(" ")?L.slice(1):L);o(B),l(T)}},y=P=>{const j=[...t.selectedEntities,P];n({selectedEntities:j})},v=P=>{const j=t.selectedEntities.filter(F=>"id"in P&&"id"in F?P.id!==F.id:!(P.name===F.name&&P.connectionId===F.connectionId));n({selectedEntities:j})},x=P=>{d(P)?(v(P),b(P)):(y(P),m(P))},C=P=>{x(P)},_=P=>{d(P)||y(P),m(P),s(!1),setTimeout(()=>h(c.current),0)},S=P=>{v(P),b(P)},E=P=>{P.forEach(j=>{v(j),b(j)})},k=()=>{n({selectedEntities:[...e]}),e.forEach((P,j)=>{u(P)})},N=()=>{n({selectedEntities:[]});let P=r;t.selectedEntities.forEach(j=>{const T=`@${u(j)}`;P=P.replace(new RegExp(`${T}\\s?`,"g"),"")}),o(P),l(P.length)},M=R.useCallback(()=>{s(!1),setTimeout(()=>h(c.current),0)},[c]);return R.useEffect(()=>{const P=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",P),document.addEventListener("keydown",j)),()=>{document.removeEventListener("mousedown",P),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:C,handleMainTabComplete:_,handleRemoveEntity:S,handleAddAllEntities:k,handleRemoveEntities:E,handleRemoveAllEntities:N,closeDropdownAndFocus:M,handleMainAtButtonClick:()=>{s(!0),setTimeout(()=>h(c.current),0)},focusInputElement:h}}const _U=R.forwardRef(({input:e,setInput:t,handleSubmit:n,isLoading:r,stop:o,onFocus:i},s)=>{const a=pR(),{setCurrentAIContext:l}=mR(),c=re(I=>{var P;return(P=I.dashboard.aiContext)==null?void 0:P.selectedEntities}),{message:u,setMessage:d,showMentionDropdown:h,setShowMentionDropdown:p,mainInputRef:g,handleTextareaChange:m,handleKeyDown:b,handleEntitySelect:y,handleEntityDeselect:v,handleMainTabComplete:x,handleRemoveEntity:C,handleRemoveEntities:_,handleAddAllEntities:S,handleRemoveAllEntities:E,handleMainAtButtonClick:k,focusInputElement:N}=NFe({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(RFe,{entities:a.selectedEntities,availableEntities:c||[],onRemoveEntity:C,onRemoveEntities:_}),f.jsxs("div",{className:"relative",children:[f.jsx(EU,{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(Se,{variant:"outline",size:"sm",className:"absolute bottom-3 left-3 h-7 px-2",onClick:k,title:"Add entity",children:f.jsx(rJ,{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(Se,{size:"sm",onClick:()=>o(),children:f.jsx(hJ,{className:"size-3.5 bg-background"})}),r===!1&&f.jsx(Se,{disabled:r===!1&&!e,size:"sm",onClick:()=>M(),children:f.jsx(vJ,{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(EFe,{isOpen:h,onSelect:y,onDeselect:v,onClose:()=>{p(!1),setTimeout(()=>N(g.current),0)},availableEntities:c||[],selectedEntities:a.selectedEntities,onTabComplete:x,onSelectAll:S,onRemoveAll:E})})]})]})});function RU(e){return e.type==="dataset"&&e.label||e.name}function MFe(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 DFe({selectedEntities:e,onDeselectEntity:t}){return e.length===0?null:f.jsxs("div",{className:"mb-4 space-y-2",children:[f.jsxs(fe,{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(so,{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,"]"]}),RU(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(Gn,{className:"h-2.5 w-2.5 text-red-500"})})]},`${n.type}-${n.name}-${r}`))})]})}function kU(e){const t=re(a=>a.authToken)||e;ue(a=>a.selectedConnectionId),ue(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}=hn({queryKey:["semantic-domains"],queryFn:()=>Tn("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 PFe(e,t){const n=re(l=>l.authToken)||t,{refetch:r,isPending:o,data:i,isLoading:s,isError:a}=hn({queryKey:["datasets",e],queryFn:()=>Tn("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 AFe(e){var g,m;const t=re(b=>b.authToken)||e,{connections:n}=Hi(e),r=ue(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}=hn({queryKey:["databases",r],queryFn:()=>Tn("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 IFe(e){var g;const t=re(m=>m.authToken)||e,{connections:n}=Hi(e),r=ue(m=>{var b,y;return(y=(b=m==null?void 0:m.card)==null?void 0:b.dataSource)==null?void 0:y.connectionId}),o=ue(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}=hn({queryKey:["schemas",r,o],queryFn:()=>Tn("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 NU(e){const t=re(d=>d.authToken)||e,{connections:n}=Hi(e),r=ue(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}=hn({queryKey:["dataModels",r],queryFn:()=>Tn("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 TFe(){var _,S,E;const e=ue(k=>k.card.dataSource);ue(k=>k.actions.updateDirectSource);const t=ue(k=>k.actions.updateDataSource),[n,r]=R.useState(""),{selectedConnection:o,error:i}=Hi(),{databases:s,isPending:a,error:l,label:c}=AFe(),{schemas:u,isPending:d,error:h,label:p}=IFe(),{error:g}=NU(),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)||[]})},C=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(Se,{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(fe,{className:"text-sm font-medium",children:c}),f.jsxs(Dt,{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(dh,{className:"h-4 w-4 animate-spin"}),f.jsx(Pt,{placeholder:l?`Error loading ${y}`:a?`Loading ${y}...`:`Select ${y}...`})]})}),f.jsx(St,{children:s.map(k=>f.jsx(xe,{value:k.id,children:k.name},k.id))})]})]}),((S=e==null?void 0:e.dbSelection)==null?void 0:S.database)&&m&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(fe,{className:"text-sm font-medium",children:p}),f.jsxs(Dt,{value:((E=e==null?void 0:e.dbSelection)==null?void 0:E.schema)||"",onValueChange:C,disabled:d,children:[f.jsx(Ct,{className:"w-full",children:f.jsxs("div",{className:"flex items-center gap-2",children:[d&&f.jsx(dh,{className:"h-4 w-4 animate-spin"}),f.jsx(Pt,{placeholder:h?`Error loading ${v}`:d?`Loading ${v}...`:`Select ${v}...`})]})}),f.jsx(St,{children:u.map(k=>f.jsx(xe,{value:k.id,children:k.name},k.id))})]})]})]})]})}function jFe(){const e=ue(l=>l.card.dataSource),t=ue(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(fe,{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(k_,{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(Se,{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(fe,{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(x_,{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(Se,{variant:"ghost",size:"sm",className:"h-6 w-6 flex-shrink-0 p-0",onClick:()=>i(l.id),children:f.jsx(Gn,{className:"h-3 w-3"})})]},l.id))})]})]})}function OFe(){const e=ue(d=>d.card.dataSource),t=ue(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(fe,{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(fe,{className:"text-xs text-gray-600",children:"Source Name"}),f.jsx(Cr,{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(fe,{className:"text-xs text-gray-600",children:"URL"}),f.jsx(Cr,{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(fe,{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(Se,{onClick:l,disabled:!n.trim()||!o.trim(),size:"sm",className:"w-full",children:[f.jsx(Cc,{className:"mr-1 h-3 w-3"}),"Add Source"]})]})]}),u.length>0&&f.jsxs("div",{className:"space-y-2",children:[f.jsxs(fe,{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(w_,{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(Se,{variant:"ghost",size:"sm",className:"h-6 w-6 flex-shrink-0 p-0",onClick:()=>c(d.id),children:f.jsx(Gn,{className:"h-3 w-3"})})]},d.id))})]})]})}function _j(e,t){var y,v;const n=re(x=>x.authToken)||t,{connections:r}=Hi(t),o=ue(x=>{var C,_;return(_=(C=x==null?void 0:x.card)==null?void 0:C.dataSource)==null?void 0:_.connectionId}),i=ue(x=>{var C,_,S;return(S=(_=(C=x==null?void 0:x.card)==null?void 0:C.dataSource)==null?void 0:_.dbSelection)==null?void 0:S.database}),s=ue(x=>{var C,_,S;return(S=(_=(C=x==null?void 0:x.card)==null?void 0:C.dataSource)==null?void 0:_.dbSelection)==null?void 0:S.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"||!i||l!=null&&l.path.includes("schema")&&!s||e==="view")}const{data:d,isPending:h,isLoading:p,error:g,refetch:m}=hn({queryKey:[e,o,i,s],queryFn:()=>Tn(`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 M0({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(hF,{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 FFe({dataSource:e,onSelectionChange:t,selectedEntities:n}){const{connections:r,isPending:o}=Hi(),[i,s]=R.useState(""),[a,l]=R.useState(""),[c,u]=R.useState(""),{updateDataSource:d,setSelectedConnectionId:h}=jn(),{entities:p,isLoading:g,error:m}=_j("table"),{entities:b}=_j("view"),{dataModels:y,isPending:v,error:x}=NU(),C=N=>{const M=r.find(P=>P.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 P;if(I)P=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};P=[...M,T]}t==null||t(P)},S=N=>{const M=n||[],I=M.some(j=>j.type==="model"&&j.name===N.name);let P;I?P=M.filter(j=>!(j.type==="model"&&j.name===N.name)):P=[...M,N],t==null||t(P)},E=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(fe,{className:"font-medium= text-sm",children:"Connection"}),f.jsxs(Dt,{value:(e==null?void 0:e.connectionId)||"",onValueChange:C,disabled:o,children:[f.jsx(Ct,{className:"w-full",children:f.jsx(Pt,{placeholder:o?"Loading connections...":"Select connection..."})}),f.jsx(St,{children:r.map(N=>f.jsx(xe,{value:N.id,children:f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx(ny,{className:"h-4 w-4 flex-shrink-0"}),f.jsx("span",{className:"truncate",children:N.name}),f.jsx(so,{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(jFe,{}),e.connectionType==="url"&&f.jsx(OFe,{}),e.connectionType!=="upload"&&e.connectionType!=="url"&&f.jsxs(f.Fragment,{children:[f.jsx(TFe,{}),f.jsx("div",{className:"space-y-4",children:f.jsx("div",{className:"space-y-2",children:f.jsxs(bd,{defaultValue:"tables",className:"w-full",children:[f.jsxs(vc,{className:"grid w-full grid-cols-3",children:[f.jsx(io,{value:"tables",children:"Tables"}),f.jsx(io,{value:"datamodels",children:"Data Models"}),f.jsx(io,{value:"views",children:"Views (Coming soon)"})]}),f.jsxs(xi,{value:"tables",className:"space-y-2",children:[f.jsx(Un,{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(M0,{title:"Error loading tables",message:m.message||"Failed to load tables. Please try again.",onRetry:()=>window.location.reload()}):E.length===0?f.jsx("div",{className:"py-4 text-center text-sm",children:"No tables found"}):E.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(qr,{id:`table-${N.name}`,checked:M,onCheckedChange:()=>_(N),disabled:g}),f.jsx(fe,{htmlFor:`table-${N.name}`,children:N.name})]},N.name)})})]}),f.jsxs(xi,{value:"datamodels",className:"space-y-2",children:[f.jsx(Un,{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(M0,{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:"flex items-center space-x-2 rounded p-2 hover:bg-muted",children:[f.jsx(qr,{id:`dataModel-${N.name}`,checked:M,onCheckedChange:()=>S(N),disabled:v}),f.jsx(fe,{htmlFor:`dataModel-${N.name}`,children:N.name})]},N.name)})})]}),f.jsx(xi,{value:"views",className:"space-y-2",children:f.jsx("div",{className:"py-4 text-center text-sm",children:"Views support coming soon"})})]})})})]})]})]})}function $Fe({dataSource:e,onDataSourceUpdate:t,onSelectionChange:n,selectedEntities:r}){var m;const[o,i]=R.useState(""),{semanticDomains:s,isPending:a,error:l}=kU(),{datasets:c,isPending:u,error:d}=PFe(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(C=>C.id===b.id&&C.type==="dataset");let x;if(v)x=y.filter(C=>!(C.id===b.id&&C.type==="dataset"));else{const C={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,C]}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(fe,{className:"text-sm font-medium",children:"Semantic Domain"}),f.jsxs(Dt,{value:(e==null?void 0:e.semanticDomainId)||"",onValueChange:h,disabled:a,children:[f.jsx(Ct,{className:"w-full",children:f.jsx(Pt,{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(xe,{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(M0,{title:"Error loading semantic models",message:l.message})]}),(e==null?void 0:e.semanticDomainId)&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(fe,{className:"text-sm font-medium text-gray-700",children:"Datasets"}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Un,{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(M0,{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(qr,{id:`dataset-${b.id}`,checked:y,onCheckedChange:()=>p(b),disabled:u}),f.jsxs("div",{className:"flex flex-col",children:[f.jsx(fe,{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}=jn(),c=re(x=>x.isVisualEditing),u=re(x=>x.dashboard.aiContext),{setAiContext:d}=Gt(),{semanticDomains:h}=kU();R.useEffect(()=>{e&&a(i||[])},[e,n==null?void 0:n.selectedEntities,o,l,i,n]);const p=x=>{const C=s.filter(_=>!(_.name===x.name&&_.type===x.type));a(C)},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,C;if(o==="aiContext"){const{selectedEntities:_,...S}=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,S=(C=s==null?void 0:s[0])==null?void 0:C.connectionType;l({...n,connectionId:_,connectionType:S,selectedEntities:s})}else l({...n,selectedEntities:s});t(!1)}}return h&&h.length>0,f.jsx(uy,{open:e,onOpenChange:t,children:f.jsx(gp,{className:"flex max-w-2xl flex-col",children:f.jsxs("div",{children:[f.jsxs(bp,{className:"flex-shrink-0",children:[f.jsx(vp,{children:o==="aiContext"?"AI Context":"Select Data Source"}),f.jsx(xp,{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(bd,{defaultValue:(n==null?void 0:n.mode)||"database",value:(n==null?void 0:n.mode)||"database",onValueChange:m,className:"w-full",children:f.jsxs(vc,{className:"grid w-full grid-cols-2",children:[f.jsx(io,{value:"database",children:"Direct Source"}),f.jsx(io,{value:"semanticDomain",children:"Semantic Domain"})]})})}),(n==null?void 0:n.mode)==="semanticDomain"&&f.jsx($Fe,{dataSource:n,onDataSourceUpdate:b,selectedEntities:s,onSelectionChange:y}),(n==null?void 0:n.mode)==="database"&&f.jsx(FFe,{dataSource:n,onDataSourceUpdate:b,selectedEntities:s,onSelectionChange:y})]})}),f.jsx(DFe,{selectedEntities:s,onDeselectEntity:p}),f.jsx(yp,{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(Se,{variant:"outline",onClick:g,disabled:s.length===0,children:"Clear All"}),f.jsx(Se,{variant:"outline",onClick:()=>t(!1),children:"Close"}),f.jsx(Se,{onClick:v,disabled:s.length===0,children:"Save"})]})})})]})})})}const D0={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]},LFe=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function zFe({open:e,setOpen:t}){const[n,r]=R.useState(!1),[o,i]=R.useState(ib),[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}=jn(),g=pR(),{setCurrentAIContext:m,updateSelectedEntities:b}=mR(),y=re(V=>V.dashboard.aiContext),v=ue(V=>V.card.dataSource),{assistantProfile:x}=CU(),C=re(V=>V.handleOpenAssistantProfile),{append:_,handleAddNewFrame:S,isLoading:E,handleSubmit:k,handleInputChange:N,input:M,setInput:I,messages:P,setMessages:j,reload:F,status:T,stop:O,errorMessage:L}=CFe(g);wU({scrollContainerRef:d,inputRef:u,messages:P}),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 $=(M==null?void 0:M.length)===0&&(P==null?void 0:P.filter(V=>V.role==="user").length)===0;function D(){return f.jsx("div",{"data-role":"header",children:f.jsx("div",{className:"text-lg font-semibold",children:"Assistant"})})}function H(){return f.jsxs(tv,{children:[f.jsx(nv,{asChild:!0,children:f.jsx(uu,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:f.jsx(gF,{className:"size-3.5"})})}),f.jsxs(Vp,{align:"end",children:[f.jsx(lR,{children:"Options"}),f.jsx(rv,{}),f.jsx(qf,{checked:n,onCheckedChange:r,children:"Token Usage"}),f.jsx(qf,{checked:o,onCheckedChange:i,children:"Tool Invocations"}),f.jsx(qf,{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:[D(),C&&f.jsx(Se,{variant:"outline",size:"sm",className:"h-7 p-2",onClick:C,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||ib)&&f.jsx(uu,{tooltip:"Add Context",className:"h-7 p-2 text-muted-foreground hover:text-foreground",onClick:A,children:f.jsx(ga,{className:"size-4"})}),f.jsx(uu,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",tooltip:"New Chat",onClick:()=>{j([]),F()},children:f.jsx(__,{className:"size-4"})}),f.jsx(uu,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",onClick:()=>{t(!1)},children:f.jsx(v_,{className:"size-4"})})]})]}),f.jsxs(Wp,{"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(UW,{showTools:o,showSystemMessage:s,messages:P,onAddToDashboard:S}),f.jsx(WW,{messages:P,chatStatus:T,errorMessage:L})]}),f.jsx(Pd,{orientation:"horizontal"})]}),f.jsxs("div",{className:"space-y-3",children:[!x&&$&&f.jsx(qW,{onClick:B,placeholders:LFe}),f.jsx("div",{children:$&&x&&f.jsx(SU,{seedQuestions:x.seedQuestions||[],handleSeedQuestionClick:z})}),f.jsx(_U,{ref:u,setInput:I,stop:O,input:M,handleInputChange:N,handleSubmit:V=>{W(),k(V)},isLoading:E,onFocus:()=>{}})]}),f.jsx(MU,{incomingSelectedEntities:(y==null?void 0:y.selectedEntities)||[],open:l,onOpenChange:c,dataSource:v||D0,fallbackDataSource:D0,dialogMode:"aiContext"})]})}var BFe=e=>{switch(e){case"success":return WFe;case"info":return qFe;case"warning":return UFe;case"error":return GFe;default:return null}},VFe=Array(12).fill(0),HFe=({visible:e,className:t})=>R.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},R.createElement("div",{className:"sonner-spinner"},VFe.map((n,r)=>R.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),WFe=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"})),UFe=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"})),qFe=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"})),GFe=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"})),YFe=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"})),KFe=()=>{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},vE=1,XFe=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:vE++,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(ZFe(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)||vE++;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}},$r=new XFe,QFe=(e,t)=>{let n=(t==null?void 0:t.id)||vE++;return $r.addToast({title:e,...t,id:n}),n},ZFe=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",JFe=QFe,e4e=()=>$r.toasts,t4e=()=>$r.getActiveToasts(),Mn=Object.assign(JFe,{success:$r.success,info:$r.info,warning:$r.warning,error:$r.error,custom:$r.custom,message:$r.message,promise:$r.promise,dismiss:$r.dismiss,loading:$r.loading},{getHistory:e4e,getToasts:t4e});function n4e(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))}n4e(`: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%)}
|
|
632
|
+
`})]})});EU.displayName="HighlightedInput";function NFe({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=P=>"label"in P?P.label:P.name,d=P=>t.selectedEntities.some(j=>"id"in P&&"id"in j?P.id===j.id:P.name===j.name&&P.connectionId===j.connectionId),h=P=>{if(!P)return;P.focus();const j=window.getSelection();if(j){const F=document.createRange();F.selectNodeContents(P),F.collapse(!1),j.removeAllRanges(),j.addRange(F)}},p=P=>{const j=P.target.value,F=P.target.selectionStart||0;o(j),l(F);const T=j.slice(0,F),O=T.lastIndexOf("@");if(O!==-1){const L=T.slice(O+1),B=(O===0||/\s/.test(T[O-1]))&&!L.includes(" ");s(B)}else s(!1)},g=P=>{P.key==="Escape"&&i&&(P.preventDefault(),s(!1),setTimeout(()=>{if(P.currentTarget){P.currentTarget.focus();const j=window.getSelection();if(j){const F=document.createRange();F.selectNodeContents(P.currentTarget),F.collapse(!1),j.removeAllRanges(),j.addRange(F)}}},0))},m=P=>{const j=u(P),T=r.slice(0,a).lastIndexOf("@");if(T!==-1){const O=r.slice(0,T),L=r.slice(a),B=O+"@"+j+" "+L;o(B);const z=T+j.length+2;l(z)}},b=P=>{const F=`@${u(P)}`,T=r.indexOf(F);if(T!==-1){const O=r.slice(0,T),L=r.slice(T+F.length),B=O+(L.startsWith(" ")?L.slice(1):L);o(B),l(T)}},y=P=>{const j=[...t.selectedEntities,P];n({selectedEntities:j})},v=P=>{const j=t.selectedEntities.filter(F=>"id"in P&&"id"in F?P.id!==F.id:!(P.name===F.name&&P.connectionId===F.connectionId));n({selectedEntities:j})},x=P=>{d(P)?(v(P),b(P)):(y(P),m(P))},C=P=>{x(P)},_=P=>{d(P)||y(P),m(P),s(!1),setTimeout(()=>h(c.current),0)},S=P=>{v(P),b(P)},E=P=>{P.forEach(j=>{v(j),b(j)})},k=()=>{n({selectedEntities:[...e]}),e.forEach((P,j)=>{u(P)})},N=()=>{n({selectedEntities:[]});let P=r;t.selectedEntities.forEach(j=>{const T=`@${u(j)}`;P=P.replace(new RegExp(`${T}\\s?`,"g"),"")}),o(P),l(P.length)},M=R.useCallback(()=>{s(!1),setTimeout(()=>h(c.current),0)},[c]);return R.useEffect(()=>{const P=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",P),document.addEventListener("keydown",j)),()=>{document.removeEventListener("mousedown",P),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:C,handleMainTabComplete:_,handleRemoveEntity:S,handleAddAllEntities:k,handleRemoveEntities:E,handleRemoveAllEntities:N,closeDropdownAndFocus:M,handleMainAtButtonClick:()=>{s(!0),setTimeout(()=>h(c.current),0)},focusInputElement:h}}const _U=R.forwardRef(({input:e,setInput:t,handleSubmit:n,isLoading:r,stop:o,onFocus:i},s)=>{const a=pR(),{setCurrentAIContext:l}=mR(),c=re(I=>{var P;return(P=I.dashboard.aiContext)==null?void 0:P.selectedEntities}),{message:u,setMessage:d,showMentionDropdown:h,setShowMentionDropdown:p,mainInputRef:g,handleTextareaChange:m,handleKeyDown:b,handleEntitySelect:y,handleEntityDeselect:v,handleMainTabComplete:x,handleRemoveEntity:C,handleRemoveEntities:_,handleAddAllEntities:S,handleRemoveAllEntities:E,handleMainAtButtonClick:k,focusInputElement:N}=NFe({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(RFe,{entities:a.selectedEntities,availableEntities:c||[],onRemoveEntity:C,onRemoveEntities:_}),f.jsxs("div",{className:"relative",children:[f.jsx(EU,{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(Se,{variant:"outline",size:"sm",className:"absolute bottom-3 left-3 h-7 px-2",onClick:k,title:"Add entity",children:f.jsx(rJ,{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(Se,{size:"sm",onClick:()=>o(),children:f.jsx(hJ,{className:"size-3.5 bg-background"})}),r===!1&&f.jsx(Se,{disabled:r===!1&&!e,size:"sm",onClick:()=>M(),children:f.jsx(vJ,{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(EFe,{isOpen:h,onSelect:y,onDeselect:v,onClose:()=>{p(!1),setTimeout(()=>N(g.current),0)},availableEntities:c||[],selectedEntities:a.selectedEntities,onTabComplete:x,onSelectAll:S,onRemoveAll:E})})]})]})});function RU(e){return e.type==="dataset"&&e.label||e.name}function MFe(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 DFe({selectedEntities:e,onDeselectEntity:t}){return e.length===0?null:f.jsxs("div",{className:"mb-4 space-y-2",children:[f.jsxs(fe,{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(so,{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,"]"]}),RU(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(Gn,{className:"h-2.5 w-2.5 text-red-500"})})]},`${n.type}-${n.name}-${r}`))})]})}function kU(e){const t=re(a=>a.authToken)||e;ue(a=>a.selectedConnectionId),ue(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}=hn({queryKey:["semantic-domains"],queryFn:()=>Tn("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 PFe(e,t){const n=re(l=>l.authToken)||t,{refetch:r,isPending:o,data:i,isLoading:s,isError:a}=hn({queryKey:["datasets",e],queryFn:()=>Tn("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 AFe(e){var g,m;const t=re(b=>b.authToken)||e,{connections:n}=Hi(e),r=ue(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}=hn({queryKey:["databases",r],queryFn:()=>Tn("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 IFe(e){var g;const t=re(m=>m.authToken)||e,{connections:n}=Hi(e),r=ue(m=>{var b,y;return(y=(b=m==null?void 0:m.card)==null?void 0:b.dataSource)==null?void 0:y.connectionId}),o=ue(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}=hn({queryKey:["schemas",r,o],queryFn:()=>Tn("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 NU(e){const t=re(d=>d.authToken)||e,{connections:n}=Hi(e),r=ue(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}=hn({queryKey:["dataModels",r],queryFn:()=>Tn("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 TFe(){var _,S,E;const e=ue(k=>k.card.dataSource);ue(k=>k.actions.updateDirectSource);const t=ue(k=>k.actions.updateDataSource),[n,r]=R.useState(""),{selectedConnection:o,error:i}=Hi(),{databases:s,isPending:a,error:l,label:c}=AFe(),{schemas:u,isPending:d,error:h,label:p}=IFe(),{error:g}=NU(),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)||[]})},C=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(Se,{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(fe,{className:"text-sm font-medium",children:c}),f.jsxs(Dt,{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(dh,{className:"h-4 w-4 animate-spin"}),f.jsx(Pt,{placeholder:l?`Error loading ${y}`:a?`Loading ${y}...`:`Select ${y}...`})]})}),f.jsx(St,{children:s.map(k=>f.jsx(xe,{value:k.id,children:k.name},k.id))})]})]}),((S=e==null?void 0:e.dbSelection)==null?void 0:S.database)&&m&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(fe,{className:"text-sm font-medium",children:p}),f.jsxs(Dt,{value:((E=e==null?void 0:e.dbSelection)==null?void 0:E.schema)||"",onValueChange:C,disabled:d,children:[f.jsx(Ct,{className:"w-full",children:f.jsxs("div",{className:"flex items-center gap-2",children:[d&&f.jsx(dh,{className:"h-4 w-4 animate-spin"}),f.jsx(Pt,{placeholder:h?`Error loading ${v}`:d?`Loading ${v}...`:`Select ${v}...`})]})}),f.jsx(St,{children:u.map(k=>f.jsx(xe,{value:k.id,children:k.name},k.id))})]})]})]})]})}function jFe(){const e=ue(l=>l.card.dataSource),t=ue(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(fe,{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(k_,{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(Se,{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(fe,{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(x_,{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(Se,{variant:"ghost",size:"sm",className:"h-6 w-6 flex-shrink-0 p-0",onClick:()=>i(l.id),children:f.jsx(Gn,{className:"h-3 w-3"})})]},l.id))})]})]})}function OFe(){const e=ue(d=>d.card.dataSource),t=ue(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(fe,{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(fe,{className:"text-xs text-gray-600",children:"Source Name"}),f.jsx(Cr,{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(fe,{className:"text-xs text-gray-600",children:"URL"}),f.jsx(Cr,{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(fe,{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(Se,{onClick:l,disabled:!n.trim()||!o.trim(),size:"sm",className:"w-full",children:[f.jsx(Cc,{className:"mr-1 h-3 w-3"}),"Add Source"]})]})]}),u.length>0&&f.jsxs("div",{className:"space-y-2",children:[f.jsxs(fe,{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(w_,{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(Se,{variant:"ghost",size:"sm",className:"h-6 w-6 flex-shrink-0 p-0",onClick:()=>c(d.id),children:f.jsx(Gn,{className:"h-3 w-3"})})]},d.id))})]})]})}function _j(e,t){var y,v;const n=re(x=>x.authToken)||t,{connections:r}=Hi(t),o=ue(x=>{var C,_;return(_=(C=x==null?void 0:x.card)==null?void 0:C.dataSource)==null?void 0:_.connectionId}),i=ue(x=>{var C,_,S;return(S=(_=(C=x==null?void 0:x.card)==null?void 0:C.dataSource)==null?void 0:_.dbSelection)==null?void 0:S.database}),s=ue(x=>{var C,_,S;return(S=(_=(C=x==null?void 0:x.card)==null?void 0:C.dataSource)==null?void 0:_.dbSelection)==null?void 0:S.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}=hn({queryKey:[e,o,i,s],queryFn:()=>Tn(`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 M0({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(hF,{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 FFe({dataSource:e,onSelectionChange:t,selectedEntities:n}){const{connections:r,isPending:o}=Hi(),[i,s]=R.useState(""),[a,l]=R.useState(""),[c,u]=R.useState(""),{updateDataSource:d,setSelectedConnectionId:h}=jn(),{entities:p,isLoading:g,error:m}=_j("table"),{entities:b}=_j("view"),{dataModels:y,isPending:v,error:x}=NU(),C=N=>{const M=r.find(P=>P.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 P;if(I)P=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};P=[...M,T]}t==null||t(P)},S=N=>{const M=n||[],I=M.some(j=>j.type==="model"&&j.name===N.name);let P;I?P=M.filter(j=>!(j.type==="model"&&j.name===N.name)):P=[...M,N],t==null||t(P)},E=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(fe,{className:"font-medium= text-sm",children:"Connection"}),f.jsxs(Dt,{value:(e==null?void 0:e.connectionId)||"",onValueChange:C,disabled:o,children:[f.jsx(Ct,{className:"w-full",children:f.jsx(Pt,{placeholder:o?"Loading connections...":"Select connection..."})}),f.jsx(St,{children:r.map(N=>f.jsx(xe,{value:N.id,children:f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx(ny,{className:"h-4 w-4 flex-shrink-0"}),f.jsx("span",{className:"truncate",children:N.name}),f.jsx(so,{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(jFe,{}),e.connectionType==="url"&&f.jsx(OFe,{}),e.connectionType!=="upload"&&e.connectionType!=="url"&&f.jsxs(f.Fragment,{children:[f.jsx(TFe,{}),f.jsx("div",{className:"space-y-4",children:f.jsx("div",{className:"space-y-2",children:f.jsxs(bd,{defaultValue:"tables",className:"w-full",children:[f.jsxs(vc,{className:"grid w-full grid-cols-3",children:[f.jsx(io,{value:"tables",children:"Tables"}),f.jsx(io,{value:"datamodels",children:"Data Models"}),f.jsx(io,{value:"views",children:"Views (Coming soon)"})]}),f.jsxs(xi,{value:"tables",className:"space-y-2",children:[f.jsx(Un,{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(M0,{title:"Error loading tables",message:m.message||"Failed to load tables. Please try again.",onRetry:()=>window.location.reload()}):E.length===0?f.jsx("div",{className:"py-4 text-center text-sm",children:"No tables found"}):E.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(qr,{id:`table-${N.name}`,checked:M,onCheckedChange:()=>_(N),disabled:g}),f.jsx(fe,{htmlFor:`table-${N.name}`,children:N.name})]},N.name)})})]}),f.jsxs(xi,{value:"datamodels",className:"space-y-2",children:[f.jsx(Un,{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(M0,{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:"flex items-center space-x-2 rounded p-2 hover:bg-muted",children:[f.jsx(qr,{id:`dataModel-${N.name}`,checked:M,onCheckedChange:()=>S(N),disabled:v}),f.jsx(fe,{htmlFor:`dataModel-${N.name}`,children:N.name})]},N.name)})})]}),f.jsx(xi,{value:"views",className:"space-y-2",children:f.jsx("div",{className:"py-4 text-center text-sm",children:"Views support coming soon"})})]})})})]})]})]})}function $Fe({dataSource:e,onDataSourceUpdate:t,onSelectionChange:n,selectedEntities:r}){var m;const[o,i]=R.useState(""),{semanticDomains:s,isPending:a,error:l}=kU(),{datasets:c,isPending:u,error:d}=PFe(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(C=>C.id===b.id&&C.type==="dataset");let x;if(v)x=y.filter(C=>!(C.id===b.id&&C.type==="dataset"));else{const C={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,C]}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(fe,{className:"text-sm font-medium",children:"Semantic Domain"}),f.jsxs(Dt,{value:(e==null?void 0:e.semanticDomainId)||"",onValueChange:h,disabled:a,children:[f.jsx(Ct,{className:"w-full",children:f.jsx(Pt,{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(xe,{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(M0,{title:"Error loading semantic models",message:l.message})]}),(e==null?void 0:e.semanticDomainId)&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(fe,{className:"text-sm font-medium text-gray-700",children:"Datasets"}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Un,{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(M0,{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(qr,{id:`dataset-${b.id}`,checked:y,onCheckedChange:()=>p(b),disabled:u}),f.jsxs("div",{className:"flex flex-col",children:[f.jsx(fe,{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}=jn(),c=re(x=>x.isVisualEditing),u=re(x=>x.dashboard.aiContext),{setAiContext:d}=Gt(),{semanticDomains:h}=kU();R.useEffect(()=>{e&&a(i||[])},[e,n==null?void 0:n.selectedEntities,o,l,i,n]);const p=x=>{const C=s.filter(_=>!(_.name===x.name&&_.type===x.type));a(C)},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,C;if(o==="aiContext"){const{selectedEntities:_,...S}=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,S=(C=s==null?void 0:s[0])==null?void 0:C.connectionType;l({...n,connectionId:_,connectionType:S,selectedEntities:s})}else l({...n,selectedEntities:s});t(!1)}}return h&&h.length>0,f.jsx(uy,{open:e,onOpenChange:t,children:f.jsx(gp,{className:"flex max-w-2xl flex-col",children:f.jsxs("div",{children:[f.jsxs(bp,{className:"flex-shrink-0",children:[f.jsx(vp,{children:o==="aiContext"?"AI Context":"Select Data Source"}),f.jsx(xp,{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(bd,{defaultValue:(n==null?void 0:n.mode)||"database",value:(n==null?void 0:n.mode)||"database",onValueChange:m,className:"w-full",children:f.jsxs(vc,{className:"grid w-full grid-cols-2",children:[f.jsx(io,{value:"database",children:"Direct Source"}),f.jsx(io,{value:"semanticDomain",children:"Semantic Domain"})]})})}),(n==null?void 0:n.mode)==="semanticDomain"&&f.jsx($Fe,{dataSource:n,onDataSourceUpdate:b,selectedEntities:s,onSelectionChange:y}),(n==null?void 0:n.mode)==="database"&&f.jsx(FFe,{dataSource:n,onDataSourceUpdate:b,selectedEntities:s,onSelectionChange:y})]})}),f.jsx(DFe,{selectedEntities:s,onDeselectEntity:p}),f.jsx(yp,{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(Se,{variant:"outline",onClick:g,disabled:s.length===0,children:"Clear All"}),f.jsx(Se,{variant:"outline",onClick:()=>t(!1),children:"Close"}),f.jsx(Se,{onClick:v,disabled:s.length===0,children:"Save"})]})})})]})})})}const D0={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]},LFe=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function zFe({open:e,setOpen:t}){const[n,r]=R.useState(!1),[o,i]=R.useState(ib),[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}=jn(),g=pR(),{setCurrentAIContext:m,updateSelectedEntities:b}=mR(),y=re(V=>V.dashboard.aiContext),v=ue(V=>V.card.dataSource),{assistantProfile:x}=CU(),C=re(V=>V.handleOpenAssistantProfile),{append:_,handleAddNewFrame:S,isLoading:E,handleSubmit:k,handleInputChange:N,input:M,setInput:I,messages:P,setMessages:j,reload:F,status:T,stop:O,errorMessage:L}=CFe(g);wU({scrollContainerRef:d,inputRef:u,messages:P}),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 $=(M==null?void 0:M.length)===0&&(P==null?void 0:P.filter(V=>V.role==="user").length)===0;function D(){return f.jsx("div",{"data-role":"header",children:f.jsx("div",{className:"text-lg font-semibold",children:"Assistant"})})}function H(){return f.jsxs(tv,{children:[f.jsx(nv,{asChild:!0,children:f.jsx(uu,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:f.jsx(gF,{className:"size-3.5"})})}),f.jsxs(Vp,{align:"end",children:[f.jsx(lR,{children:"Options"}),f.jsx(rv,{}),f.jsx(qf,{checked:n,onCheckedChange:r,children:"Token Usage"}),f.jsx(qf,{checked:o,onCheckedChange:i,children:"Tool Invocations"}),f.jsx(qf,{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:[D(),C&&f.jsx(Se,{variant:"outline",size:"sm",className:"h-7 p-2",onClick:C,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||ib)&&f.jsx(uu,{tooltip:"Add Context",className:"h-7 p-2 text-muted-foreground hover:text-foreground",onClick:A,children:f.jsx(ga,{className:"size-4"})}),f.jsx(uu,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",tooltip:"New Chat",onClick:()=>{j([]),F()},children:f.jsx(__,{className:"size-4"})}),f.jsx(uu,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",onClick:()=>{t(!1)},children:f.jsx(v_,{className:"size-4"})})]})]}),f.jsxs(Wp,{"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(UW,{showTools:o,showSystemMessage:s,messages:P,onAddToDashboard:S}),f.jsx(WW,{messages:P,chatStatus:T,errorMessage:L})]}),f.jsx(Pd,{orientation:"horizontal"})]}),f.jsxs("div",{className:"space-y-3",children:[!x&&$&&f.jsx(qW,{onClick:B,placeholders:LFe}),f.jsx("div",{children:$&&x&&f.jsx(SU,{seedQuestions:x.seedQuestions||[],handleSeedQuestionClick:z})}),f.jsx(_U,{ref:u,setInput:I,stop:O,input:M,handleInputChange:N,handleSubmit:V=>{W(),k(V)},isLoading:E,onFocus:()=>{}})]}),f.jsx(MU,{incomingSelectedEntities:(y==null?void 0:y.selectedEntities)||[],open:l,onOpenChange:c,dataSource:v||D0,fallbackDataSource:D0,dialogMode:"aiContext"})]})}var BFe=e=>{switch(e){case"success":return WFe;case"info":return qFe;case"warning":return UFe;case"error":return GFe;default:return null}},VFe=Array(12).fill(0),HFe=({visible:e,className:t})=>R.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},R.createElement("div",{className:"sonner-spinner"},VFe.map((n,r)=>R.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),WFe=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"})),UFe=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"})),qFe=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"})),GFe=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"})),YFe=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"})),KFe=()=>{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},vE=1,XFe=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:vE++,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(ZFe(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)||vE++;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}},$r=new XFe,QFe=(e,t)=>{let n=(t==null?void 0:t.id)||vE++;return $r.addToast({title:e,...t,id:n}),n},ZFe=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",JFe=QFe,e4e=()=>$r.toasts,t4e=()=>$r.getActiveToasts(),Mn=Object.assign(JFe,{success:$r.success,info:$r.info,warning:$r.warning,error:$r.error,custom:$r.custom,message:$r.message,promise:$r.promise,dismiss:$r.dismiss,loading:$r.loading},{getHistory:e4e,getToasts:t4e});function n4e(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))}n4e(`: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%)}
|
|
633
633
|
`);function Pg(e){return e.label!==void 0}var r4e=3,o4e="32px",i4e="16px",Rj=4e3,s4e=356,a4e=14,l4e=20,c4e=200;function $o(...e){return e.filter(Boolean).join(" ")}function u4e(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var d4e=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:C,expanded:_,removeToast:S,defaultRichColors:E,closeButton:k,style:N,cancelButtonStyle:M,actionButtonStyle:I,className:P="",descriptionClassName:j="",duration:F,position:T,gap:O,loadingIcon:L,expandByDefault:B,classNames:z,icons:A,closeButtonAriaLabel:W="Close toast",pauseWhenPageIsHidden:$}=e,[D,H]=R.useState(null),[V,G]=R.useState(null),[q,K]=R.useState(!1),[Y,Q]=R.useState(!1),[ne,Z]=R.useState(!1),[ie,te]=R.useState(!1),[ce,de]=R.useState(!1),[ke,we]=R.useState(0),[Ce,Pe]=R.useState(0),Ye=R.useRef(p.duration||F||Rj),_t=R.useRef(null),ge=R.useRef(null),je=x===0,Ae=x+1<=y,ee=p.type,le=p.dismissible!==!1,Re=p.className||"",De=p.descriptionClassName||"",Ue=R.useMemo(()=>v.findIndex(Ie=>Ie.toastId===p.id)||0,[v,p.id]),jt=R.useMemo(()=>{var Ie;return(Ie=p.closeButton)!=null?Ie:k},[p.closeButton,k]),Pn=R.useMemo(()=>p.duration||F||Rj,[p.duration,F]),vn=R.useRef(0),ye=R.useRef(0),xn=R.useRef(0),Ot=R.useRef(null),[go,Bn]=T.split("-"),Tc=R.useMemo(()=>v.reduce((Ie,qe,rt)=>rt>=Ue?Ie:Ie+qe.height,0),[v,Ue]),Ka=KFe(),Ki=p.invert||h,cn=ee==="loading";ye.current=R.useMemo(()=>Ue*O+Tc,[Ue,Tc]),R.useEffect(()=>{Ye.current=Pn},[Pn]),R.useEffect(()=>{K(!0)},[]),R.useEffect(()=>{let Ie=ge.current;if(Ie){let qe=Ie.getBoundingClientRect().height;return Pe(qe),b(rt=>[{toastId:p.id,height:qe,position:p.position},...rt]),()=>b(rt=>rt.filter(nn=>nn.toastId!==p.id))}},[b,p.id]),R.useLayoutEffect(()=>{if(!q)return;let Ie=ge.current,qe=Ie.style.height;Ie.style.height="auto";let rt=Ie.getBoundingClientRect().height;Ie.style.height=qe,Pe(rt),b(nn=>nn.find(Ft=>Ft.toastId===p.id)?nn.map(Ft=>Ft.toastId===p.id?{...Ft,height:rt}:Ft):[{toastId:p.id,height:rt,position:p.position},...nn])},[q,p.title,p.description,b,p.id]);let Rt=R.useCallback(()=>{Q(!0),we(ye.current),b(Ie=>Ie.filter(qe=>qe.toastId!==p.id)),setTimeout(()=>{S(p)},c4e)},[p,S,b,ye]);R.useEffect(()=>{if(p.promise&&ee==="loading"||p.duration===1/0||p.type==="loading")return;let Ie;return _||m||$&&Ka?(()=>{if(xn.current<vn.current){let qe=new Date().getTime()-vn.current;Ye.current=Ye.current-qe}xn.current=new Date().getTime()})():Ye.current!==1/0&&(vn.current=new Date().getTime(),Ie=setTimeout(()=>{var qe;(qe=p.onAutoClose)==null||qe.call(p,p),Rt()},Ye.current)),()=>clearTimeout(Ie)},[_,m,p,ee,$,Ka,Rt]),R.useEffect(()=>{p.delete&&Rt()},[Rt,p.delete]);function Vn(){var Ie,qe,rt;return A!=null&&A.loading?R.createElement("div",{className:$o(z==null?void 0:z.loader,(Ie=p==null?void 0:p.classNames)==null?void 0:Ie.loader,"sonner-loader"),"data-visible":ee==="loading"},A.loading):L?R.createElement("div",{className:$o(z==null?void 0:z.loader,(qe=p==null?void 0:p.classNames)==null?void 0:qe.loader,"sonner-loader"),"data-visible":ee==="loading"},L):R.createElement(HFe,{className:$o(z==null?void 0:z.loader,(rt=p==null?void 0:p.classNames)==null?void 0:rt.loader),visible:ee==="loading"})}return R.createElement("li",{tabIndex:0,ref:ge,className:$o(P,Re,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[ee],(n=p==null?void 0:p.classNames)==null?void 0:n[ee]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:E,"data-styled":!(p.jsx||p.unstyled||g),"data-mounted":q,"data-promise":!!p.promise,"data-swiped":ce,"data-removed":Y,"data-visible":Ae,"data-y-position":go,"data-x-position":Bn,"data-index":x,"data-front":je,"data-swiping":ne,"data-dismissible":le,"data-type":ee,"data-invert":Ki,"data-swipe-out":ie,"data-swipe-direction":V,"data-expanded":!!(_||B&&q),style:{"--index":x,"--toasts-before":x,"--z-index":C.length-x,"--offset":`${Y?ke:ye.current}px`,"--initial-height":B?"auto":`${Ce}px`,...N,...p.style},onDragEnd:()=>{Z(!1),H(null),Ot.current=null},onPointerDown:Ie=>{cn||!le||(_t.current=new Date,we(ye.current),Ie.target.setPointerCapture(Ie.pointerId),Ie.target.tagName!=="BUTTON"&&(Z(!0),Ot.current={x:Ie.clientX,y:Ie.clientY}))},onPointerUp:()=>{var Ie,qe,rt,nn;if(ie||!le)return;Ot.current=null;let Ft=Number(((Ie=ge.current)==null?void 0:Ie.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),$t=Number(((qe=ge.current)==null?void 0:qe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Fn=new Date().getTime()-((rt=_t.current)==null?void 0:rt.getTime()),rn=D==="x"?Ft:$t,wn=Math.abs(rn)/Fn;if(Math.abs(rn)>=l4e||wn>.11){we(ye.current),(nn=p.onDismiss)==null||nn.call(p,p),G(D==="x"?Ft>0?"right":"left":$t>0?"down":"up"),Rt(),te(!0),de(!1);return}Z(!1),H(null)},onPointerMove:Ie=>{var qe,rt,nn,Ft;if(!Ot.current||!le||((qe=window.getSelection())==null?void 0:qe.toString().length)>0)return;let $t=Ie.clientY-Ot.current.y,Fn=Ie.clientX-Ot.current.x,rn=(rt=e.swipeDirections)!=null?rt:u4e(T);!D&&(Math.abs(Fn)>1||Math.abs($t)>1)&&H(Math.abs(Fn)>Math.abs($t)?"x":"y");let wn={x:0,y:0};D==="y"?(rn.includes("top")||rn.includes("bottom"))&&(rn.includes("top")&&$t<0||rn.includes("bottom")&&$t>0)&&(wn.y=$t):D==="x"&&(rn.includes("left")||rn.includes("right"))&&(rn.includes("left")&&Fn<0||rn.includes("right")&&Fn>0)&&(wn.x=Fn),(Math.abs(wn.x)>0||Math.abs(wn.y)>0)&&de(!0),(nn=ge.current)==null||nn.style.setProperty("--swipe-amount-x",`${wn.x}px`),(Ft=ge.current)==null||Ft.style.setProperty("--swipe-amount-y",`${wn.y}px`)}},jt&&!p.jsx?R.createElement("button",{"aria-label":W,"data-disabled":cn,"data-close-button":!0,onClick:cn||!le?()=>{}:()=>{var Ie;Rt(),(Ie=p.onDismiss)==null||Ie.call(p,p)},className:$o(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:YFe):null,p.jsx||R.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:R.createElement(R.Fragment,null,ee||p.icon||p.promise?R.createElement("div",{"data-icon":"",className:$o(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||Vn():null,p.type!=="loading"?p.icon||(A==null?void 0:A[ee])||BFe(ee):null):null,R.createElement("div",{"data-content":"",className:$o(z==null?void 0:z.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},R.createElement("div",{"data-title":"",className:$o(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:$o(j,De,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&&Pg(p.cancel)?R.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||M,onClick:Ie=>{var qe,rt;Pg(p.cancel)&&le&&((rt=(qe=p.cancel).onClick)==null||rt.call(qe,Ie),Rt())},className:$o(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&&Pg(p.action)?R.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||I,onClick:Ie=>{var qe,rt;Pg(p.action)&&((rt=(qe=p.action).onClick)==null||rt.call(qe,Ie),!Ie.defaultPrevented&&Rt())},className:$o(z==null?void 0:z.actionButton,(d=p==null?void 0:p.classNames)==null?void 0:d.actionButton)},p.action.label):null))};function kj(){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 f4e(e,t){let n={};return[e,t].forEach((r,o)=>{let i=o===1,s=i?"--mobile-offset":"--offset",a=i?i4e:o4e;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 h4e=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=r4e,toastOptions:m,dir:b=kj(),gap:y=a4e,loadingIcon:v,icons:x,containerAriaLabel:C="Notifications",pauseWhenPageIsHidden:_}=e,[S,E]=R.useState([]),k=R.useMemo(()=>Array.from(new Set([r].concat(S.filter($=>$.position).map($=>$.position)))),[S,r]),[N,M]=R.useState([]),[I,P]=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"),L=R.useRef(null),B=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),z=R.useRef(null),A=R.useRef(!1),W=R.useCallback($=>{E(D=>{var H;return(H=D.find(V=>V.id===$.id))!=null&&H.delete||$r.dismiss($.id),D.filter(({id:V})=>V!==$.id)})},[]);return R.useEffect(()=>$r.subscribe($=>{if($.dismiss){E(D=>D.map(H=>H.id===$.id?{...H,delete:!0}:H));return}setTimeout(()=>{an.flushSync(()=>{E(D=>{let H=D.findIndex(V=>V.id===$.id);return H!==-1?[...D.slice(0,H),{...D[H],...$},...D.slice(H+1)]:[$,...D]})})})}),[]),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 $=window.matchMedia("(prefers-color-scheme: dark)");try{$.addEventListener("change",({matches:D})=>{O(D?"dark":"light")})}catch{$.addListener(({matches:H})=>{try{O(H?"dark":"light")}catch(V){console.error(V)}})}},[u]),R.useEffect(()=>{S.length<=1&&P(!1)},[S]),R.useEffect(()=>{let $=D=>{var H,V;o.every(G=>D[G]||D.code===G)&&(P(!0),(H=L.current)==null||H.focus()),D.code==="Escape"&&(document.activeElement===L.current||(V=L.current)!=null&&V.contains(document.activeElement))&&P(!1)};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[o]),R.useEffect(()=>{if(L.current)return()=>{z.current&&(z.current.focus({preventScroll:!0}),z.current=null,A.current=!1)}},[L.current]),R.createElement("section",{ref:t,"aria-label":`${C} ${B}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},k.map(($,D)=>{var H;let[V,G]=$.split("-");return S.length?R.createElement("ol",{key:$,dir:b==="auto"?kj():b,tabIndex:-1,ref:L,className:a,"data-sonner-toaster":!0,"data-theme":T,"data-y-position":V,"data-lifted":I&&S.length>1&&!i,"data-x-position":G,style:{"--front-toast-height":`${((H=N[0])==null?void 0:H.height)||0}px`,"--width":`${s4e}px`,"--gap":`${y}px`,...p,...f4e(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:()=>P(!0),onMouseMove:()=>P(!0),onMouseLeave:()=>{j||P(!1)},onDragEnd:()=>P(!1),onPointerDown:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||F(!0)},onPointerUp:()=>F(!1)},S.filter(q=>!q.position&&D===0||q.position===$).map((q,K)=>{var Y,Q;return R.createElement(d4e,{key:q.id,icons:x,index:K,toast:q,defaultRichColors:d,duration:(Y=m==null?void 0:m.duration)!=null?Y:h,className:m==null?void 0:m.className,descriptionClassName:m==null?void 0:m.descriptionClassName,invert:n,visibleToasts:g,closeButton:(Q=m==null?void 0:m.closeButton)!=null?Q:s,interacting:j,position:$,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:S.filter(ne=>ne.position==q.position),heights:N.filter(ne=>ne.position==q.position),setHeights:M,expandByDefault:i,gap:y,loadingIcon:v,expanded:I,pauseWhenPageIsHidden:_,swipeDirections:e.swipeDirections})})):null}))});function p4e(e){const t=e.current,{getSelectedFrame:n,addFrame:r,setSelectedFrameId:o}=Gt(),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(),Mn.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=or();const m=g.activeCardId;g.cards.forEach(b=>{const y=b.id;b.id=or(),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 DU(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 PU(){const{showAssistant:e}=Bt(),t=R.useRef(null),n=R.useRef(null),[r,o]=R.useState(!1),[i,s]=DU("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}=Gt();p4e(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:or(),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())},C=N=>{N.preventDefault()},_=(N,M)=>{const I=N.dataTransfer.getData("tabIndex");if(I===M.toString())return;const P=Array.from(l||[]),[j]=P.splice(parseInt(I),1);P.splice(M,0,j),g(P)};function S(){var N,M;if(l&&l.length>1||c)return f.jsxs(vc,{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,P)=>f.jsxs(io,{draggable:!0,onDragStart:j=>x(j,P),onDragOver:C,onDrop:j=>_(j,P),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(Ri,{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(Gn,{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(Cc,{className:"size-3"})})]})}function E(){return f.jsx("div",{ref:n,style:{},className:"grow",children:l==null?void 0:l.map(N=>f.jsx(xi,{style:{backgroundColor:v()},className:oe("mt-0",{}),value:N.id,children:f.jsx(Eke,{sheet:N})},N.id))})}function k(){var N;return f.jsxs(bd,{"data-role":"dashboard-tabs-container",className:oe("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:[S(),f.jsx(Wp,{className:"flex-1 grow basis-0 overflow-y-auto",children:E()}),f.jsx(TNe,{open:r,setOpen:o})]})}return l?f.jsxs(VV,{className:"flex-1 basis-0 overflow-y-auto",direction:"horizontal",children:[f.jsx(WS,{children:k()}),e===!0&&f.jsxs(f.Fragment,{children:[f.jsx(nNe,{open:i,onTabClick:m,withHandle:!0}),f.jsx(WS,{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(zFe,{open:i,setOpen:m})})})]})]}):null}function AU({children:e}){return f.jsx(qY,{defaultTheme:"system",storageKey:"vite-ui-theme",children:f.jsx(Qy,{delayDuration:0,children:e})})}function IU(e){return f.jsx(Oy,{FallbackComponent:b2,children:f.jsx(WO,{dashboardProps:e,children:f.jsx(AU,{children:f.jsx("main",{className:"flex h-full flex-col",children:f.jsx(XO,{...e,children:f.jsx(PU,{})})})})})})}function m4e(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,g4e(o,...t)]}function g4e(...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 b4e(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 xE=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},y4e=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mN=y4e.reduce((e,t)=>{const n=ks(`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 v4e(){return T0.useSyncExternalStore(x4e,()=>!0,()=>!1)}function x4e(){return()=>{}}var gN="Avatar",[w4e,yLe]=m4e(gN),[C4e,TU]=w4e(gN),jU=w.forwardRef((e,t)=>{const{__scopeAvatar:n,...r}=e,[o,i]=w.useState("idle");return f.jsx(C4e,{scope:n,imageLoadingStatus:o,onImageLoadingStatusChange:i,children:f.jsx(mN.span,{...r,ref:t})})});jU.displayName=gN;var OU="AvatarImage",FU=w.forwardRef((e,t)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:o=()=>{},...i}=e,s=TU(OU,n),a=S4e(r,i),l=b4e(c=>{o(c),s.onImageLoadingStatusChange(c)});return xE(()=>{a!=="idle"&&l(a)},[a,l]),a==="loaded"?f.jsx(mN.img,{...i,ref:t,src:r}):null});FU.displayName=OU;var $U="AvatarFallback",LU=w.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:r,...o}=e,i=TU($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(mN.span,{...o,ref:t}):null});LU.displayName=$U;function Nj(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function S4e(e,{referrerPolicy:t,crossOrigin:n}){const r=v4e(),o=w.useRef(null),i=r?(o.current||(o.current=new window.Image),o.current):null,[s,a]=w.useState(()=>Nj(i,e));return xE(()=>{a(Nj(i,e))},[i,e]),xE(()=>{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 zU=jU,BU=FU,VU=LU;const HU=w.forwardRef(({className:e,...t},n)=>f.jsx(zU,{ref:n,className:oe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));HU.displayName=zU.displayName;const WU=w.forwardRef(({className:e,...t},n)=>f.jsx(BU,{ref:n,className:oe("aspect-square h-full w-full",e),...t}));WU.displayName=BU.displayName;const UU=w.forwardRef(({className:e,...t},n)=>f.jsx(VU,{ref:n,className:oe("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));UU.displayName=VU.displayName;var tn=(e=>(e.DASHBOARD="dashboard",e.VISUAL="visual",e))(tn||{});const E4e=async(e,t,n,r,o,i)=>{const s={},a={[tn.DASHBOARD]:"dashboards",[tn.VISUAL]:"visuals"};return Tn(`https://semaphor.cloud/api/management/v1/${a[t]}`,e,s)},_4e=async(e,t,n)=>{const r={[tn.DASHBOARD]:"dashboards",[tn.VISUAL]:"visuals"};return up(`https://semaphor.cloud/api/management/v1/${r[t]}`,e,n)},R4e=async(e,t,n,r)=>{const o={[tn.DASHBOARD]:"dashboards",[tn.VISUAL]:"visuals"},i=await fetch(`https://semaphor.cloud/api/management/v1/${o[t]}/${n}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify(r)});if(!i.ok){const s=await i.json();throw new Error((s==null?void 0:s.error)||`HTTP error! status: ${i.status}`)}return i.json()},k4e=async(e,t,n)=>{const r={[tn.DASHBOARD]:"dashboards",[tn.VISUAL]:"visuals"},o=await fetch(`https://semaphor.cloud/api/management/v1/${r[t]}/${n}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}});if(!o.ok){const i=await o.json();throw new Error((i==null?void 0:i.error)||`HTTP error! status: ${o.status}`)}return o.json()},N4e=async(e,t,n)=>{const r={[tn.DASHBOARD]:"dashboards",[tn.VISUAL]:"visuals"};return up(`https://semaphor.cloud/api/management/v1/${r[t]}/${n}/duplicate`,e,{})},M4e=async(e,t,n,r)=>{const o={[tn.DASHBOARD]:"dashboards",[tn.VISUAL]:"visuals"};return up(`https://semaphor.cloud/api/management/v1/${o[t]}/${n}/share`,e,r)},D4e=async(e,t,n,r)=>{const o={[tn.DASHBOARD]:"dashboards",[tn.VISUAL]:"visuals"},i=await fetch(`https://semaphor.cloud/api/management/v1/${o[t]}/${n}/share`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify(r)});if(!i.ok){const s=await i.json();throw new Error((s==null?void 0:s.error)||`HTTP error! status: ${i.status}`)}return i.json()},P4e=async(e,t,n)=>{const r={[tn.DASHBOARD]:"dashboards",[tn.VISUAL]:"visuals"};return Tn(`https://semaphor.cloud/api/management/v1/${r[t]}/${n}/shares`,e)},A4e=async(e,t,n)=>{const r={[tn.DASHBOARD]:"dashboards",[tn.VISUAL]:"visuals"};return Tn(`https://semaphor.cloud/api/management/v1/${r[t]}/${n}`,e)};function I4e(e){const{authToken:t}=Bt();return hn({queryKey:["tenants"],queryFn:()=>Tn("https://semaphor.cloud/api/management/v1/tenants",(t==null?void 0:t.accessToken)||""),enabled:(e==null?void 0:e.enabled)!==void 0?e.enabled&&!!(t!=null&&t.accessToken):!!(t!=null&&t.accessToken)})}function T4e(e,t,n,r,o){const{authToken:i}=Bt();return hn({queryKey:[e,t,n,r,o],queryFn:()=>E4e((i==null?void 0:i.accessToken)||"",e),enabled:!!(i!=null&&i.accessToken)})}function j4e(e,t){const{authToken:n}=Bt(),r=Qn();return gc({mutationFn:o=>_4e((n==null?void 0:n.accessToken)||"",e,o),onMutate:async()=>{await r.cancelQueries({queryKey:[e]})},onSuccess:async()=>{await r.invalidateQueries({queryKey:[e]}),Mn.success(`${Di(e)} created successfully`),t==null||t()},onError:o=>{Mn.error(`Failed to create ${Di(e)}: ${o.message}`)}})}function O4e(e){const{authToken:t}=Bt(),n=Qn();return gc({mutationFn:({resourceId:r,data:o})=>R4e((t==null?void 0:t.accessToken)||"",e,r,o),onMutate:async()=>{await n.cancelQueries({queryKey:[e]})},onSuccess:async()=>{await n.invalidateQueries({queryKey:[e]}),Mn.success(`${Di(e)} updated successfully`)},onError:r=>{Mn.error(`Failed to update ${Di(e)}: ${r.message}`)}})}function F4e(e,t){const{authToken:n}=Bt(),r=Qn();return gc({mutationFn:o=>k4e((n==null?void 0:n.accessToken)||"",e,o),onMutate:async()=>{await r.cancelQueries({queryKey:[e]})},onSuccess:async()=>{await r.invalidateQueries({queryKey:[e]}),Mn.success(`${Di(e)} deleted successfully`),t==null||t()},onError:o=>{Mn.error(`Failed to delete ${Di(e)}: ${o.message}`)}})}function $4e(e){const{authToken:t}=Bt(),n=Qn();return gc({mutationFn:r=>N4e((t==null?void 0:t.accessToken)||"",e,r),onMutate:async()=>{await n.cancelQueries({queryKey:[e]})},onSuccess:async()=>{await n.invalidateQueries({queryKey:[e]}),Mn.success(`${Di(e)} duplicated successfully`)},onError:r=>{Mn.error(`Failed to duplicate ${Di(e)}: ${r.message}`)}})}function L4e(){const{authToken:e}=Bt(),t=Qn();return gc({mutationFn:({resourceType:n,resourceId:r,data:o})=>M4e((e==null?void 0:e.accessToken)||"",n,r,o),onMutate:async n=>{await t.cancelQueries({queryKey:["resource-shares",n.resourceType,n.resourceId]})},onSuccess:async(n,r)=>{await t.invalidateQueries({queryKey:["resource-shares",r.resourceType,r.resourceId]}),t.invalidateQueries({queryKey:[r.resourceType]})},onError:n=>{Mn.error(`Failed to share resource: ${n.message}`)}})}function z4e(){const{authToken:e}=Bt(),t=Qn();return gc({mutationFn:({resourceType:n,resourceId:r,data:o})=>D4e((e==null?void 0:e.accessToken)||"",n,r,o),onMutate:async n=>{await t.cancelQueries({queryKey:["resource-shares",n.resourceType,n.resourceId]})},onSuccess:async(n,r)=>{await t.invalidateQueries({queryKey:["resource-shares",r.resourceType,r.resourceId]}),t.invalidateQueries({queryKey:[r.resourceType]})},onError:n=>{Mn.error(`Failed to remove resource shares: ${n.message}`)}})}function B4e(e,t){const{authToken:n}=Bt();return hn({queryKey:["resource-shares",e,t],queryFn:()=>P4e((n==null?void 0:n.accessToken)||"",e,t),enabled:!!(n!=null&&n.accessToken)&&!!t})}function V4e(e,t,n){const{authToken:r}=Bt();return hn({queryKey:["resource-by-id",e,t],queryFn:()=>A4e((r==null?void 0:r.accessToken)||"",e,t),enabled:(n==null?void 0:n.enabled)!==void 0?n.enabled&&!!(r!=null&&r.accessToken)&&!!t:!!(r!=null&&r.accessToken)&&!!t})}function H4e(e,t){return V4e(tn.VISUAL,e,t)}function W4e(){const[e,t]=R.useState(new Map),n=R.useCallback((i,s)=>{t(a=>{const l=new Map(a),c=new Set(l.get(i)||[]);return s?c.add(s):(c.add("title"),c.add("description")),l.set(i,c),l})},[]),r=R.useCallback((i,s)=>{t(a=>{const l=new Map(a),c=new Set(l.get(i)||[]);return s?c.delete(s):c.clear(),c.size===0?l.delete(i):l.set(i,c),l})},[]),o=R.useCallback((i,s)=>{const a=e.get(i);return a?s?a.has(s):a.size>0:!1},[e]);return{startUpdating:n,stopUpdating:r,isUpdating:o}}function qU(e,t,n){var d;const r=T4e(e),o=j4e(e,n),i=O4e(e),s=F4e(e,t),a=$4e(e),l=L4e(),c=z4e(),u={[tn.DASHBOARD]:"dashboards",[tn.VISUAL]:"visuals"};return{resources:((d=r.data)==null?void 0:d[u[e]])||[],isLoading:r.isLoading,isError:r.isError,isFetching:r.isFetching,error:r.error,createResource:o.mutate,updateResource:i.mutate,deleteResource:s.mutate,duplicateResource:a.mutate,shareResource:l.mutate,removeResourceShares:c.mutate,isCreating:o.isPending,isUpdating:i.isPending,isDeleting:s.isPending,isDuplicating:a.isPending,isSharing:l.isPending,isRemovingShares:c.isPending,isUpdatingShares:l.isPending,refetch:r.refetch}}function U4e(e,t){return qU(tn.DASHBOARD,e,t)}function q4e(e,t){return qU(tn.VISUAL,e,t)}function G4e(){const{authToken:e}=Bt(),t=Qn();return gc({mutationFn:async({visualId:n,data:r})=>{const o=await fetch(`https://semaphor.cloud/api/management/v1/visuals/${n}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e==null?void 0:e.accessToken}`},body:JSON.stringify(r)});if(!o.ok)throw new Error("Failed to update visual");return o.json()},onSuccess:()=>{Mn.success("Visual updated successfully"),t.invalidateQueries({queryKey:["visuals"]})},onError:()=>{Mn.error("Failed to update visual")}})}const Y4e=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},GU=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 YU(e){var b;const t=re(y=>y.authToken)||e,n=ue(y=>y.selectedConnectionId),r=ue(y=>y.selectedDatabaseName),o=ue(y=>y.selectedDatamodelId),i=ue(y=>y.selectedSchemaName),s=ue(y=>y.selectedTableName),{selectedConnection:a}=Hi(),l=a==null?void 0:a.type,{data:c,isLoading:u,isFetching:d,isError:h,refetch:p}=hn({queryKey:["columns",n,r,o,i,s],queryFn:()=>Tn("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 K4e(e,t){const[n,r]=R.useState(e);return R.useEffect(()=>{const o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}const Mj={searchQuery:"",debouncedSearchQuery:"",selectedUsers:[],usersToRemove:[],usersToUpdate:[],selectedTab:"org",currentContext:"org-tab",currentMode:null,orgWideRole:"VIEWER",allTenantsRole:"VIEWER",tenantWideRole:"VIEWER",selectedTenant:"",message:""},Oo=Ps()(lp(e=>({...Mj,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=>GU(t),resetShareState:()=>{e(t=>{Object.assign(t,Mj)})},resetUserSelections:()=>{e(t=>{t.selectedUsers=[],t.usersToRemove=[],t.usersToUpdate=[]})}}}))),KU=()=>Oo(e=>e.searchQuery),X4e=()=>Oo(e=>e.selectedUsers),Q4e=()=>Oo(e=>e.usersToRemove),Z4e=()=>Oo(e=>e.usersToUpdate),J4e=()=>Oo(e=>e.selectedTenant),e3e=()=>Oo(e=>e.selectedTab),t3e=()=>Oo(e=>e.currentContext),n3e=()=>Oo(e=>e.currentMode),r3e=()=>Oo(e=>e.orgWideRole),o3e=()=>Oo(e=>e.allTenantsRole),i3e=()=>Oo(e=>e.tenantWideRole),XU=()=>Oo(e=>e.actions),s3e=()=>{const e=KU(),t=K4e(e,300),n=XU();return R.useEffect(()=>{n.setDebouncedSearchQuery(t)},[t,n]),{searchQuery:e,debouncedSearchQuery:t,setSearchQuery:n.setSearchQuery}};function QU(e){const t=e.toUpperCase().indexOf("WHERE"),n=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),o=e.toUpperCase().indexOf("ORDER BY");let i=e.length;if(o!==-1&&(i=o),r!==-1&&r<i&&(i=r),t!==-1){const s=e.substring(0,t),a=e.substring(t);return`${s} {{ filters | where }} AND ${a.substring(6)}`}else if(n!==-1){const s=e.substring(0,n),a=e.substring(n);return`${s} {{ filters | where }} ${a}`}else{const s=e.substring(0,i),a=e.substring(i);return console.log("beforeClause",s),console.log("afterClause",a),a?`${s} {{ filters | where }} ${a}`:`${s.replace(/;$/,"")} {{ filters | where }}`}}function bN(e){const[t,n]=R.useState(null),[r,o]=R.useState(null);return R.useEffect(()=>{if(!e||e.trim()===""){n(null),o(null);return}(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const a=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(a,{method:"HEAD"})).ok)throw new Error(`Module not found at ${a}`)}catch{}const l=await import(a);if(typeof l.useChartStore!="function")throw new Error("useChartStore is not a function");n(()=>l.useChartStore),o(null)}catch(s){const a=s instanceof Error?s.message:"Unknown error";console.error("Failed to load remote chart store:",a),o(a),n(null)}})()},[e]),t}function ZU(e,t){if(e.length===0)return"";if(t){const n=e.find(r=>r.id===t);if(n){const r=n.tabTitle;if(r=="All__Header")return e[0].id;if(r&&r.endsWith("__Header")){const i=r.split("__")[0],s=e.find(a=>a.tabTitle===i);return s?s.id:e[0].id}return t}}return e[0].id}async function Dj(e,t,n){if(!e||!t)throw new Error("Missing auth token or visual ID");const r=["resource-by-id","visual",t],o=n.getQueryData(r);if(o)return console.log("Using cached visual data for:",t),{data:o,fromCache:!0};console.log("Fetching visual data from network for:",t);const i=Mn.loading("Loading visual...",{position:"top-center"});try{const s=await fetch(`https://semaphor.cloud/api/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${e}`}});if(!s.ok)throw new Error("Failed to load visual");const a=await s.json();return n.setQueryData(r,a),Mn.dismiss(i),{data:a,fromCache:!1}}catch(s){throw Mn.dismiss(i),s}}function a3e(e,t,n,r,o){const i=e.frameObject;t(i);const s=i.cards.find(a=>a.id===i.activeCardId);s&&n(s),r(!0),o(!0)}function l3e(){var h;const{setCardSql:e}=jn(),t=ue(p=>p.frame),n=ue(p=>p.card),r=bN(((h=n.customCardPreferences)==null?void 0:h.url)||""),o=ue(p=>p.selectedSchemaName),i=ue(p=>p.selectedDatamodelId),s=ue(p=>p.selectedDatabaseName),a=ue(p=>p.selectedTableName),l=ue(p=>p.selectedConnectionId),c=ue(p=>p.isShowingVisual),u=n.sql;return{getUpdatedFrame:R.useCallback(()=>{var y;let p=u;u&&!u.includes("{{")&&(p=QU(u),e(p));const g=(y=r==null?void 0:r.getState())==null?void 0:y.settings,m={...n,dataSource:n.dataSource||{mode:"directSource"},lastSelectedSchema:o,lastSelectedDatamodelId:i,lastSelectedDatabase:s,lastSelectedTable:a,connectionId:l,type:c?n.type:"table",sql:p,customCfg:c?n.customCfg:null,...g&&{customCardPreferences:{...n.customCardPreferences,settings:g}}},b=t.cards.map(v=>v.id===n.id?m:v);return{...t,cards:b,activeCardId:ZU(b,t.activeCardId)}},[n,t,c,o,i,s,a,l,e,r,u])}}function JU(){const{authToken:e}=Bt(),t=Qn(),n=UO(),{selectVisual:r}=qO(),{setFrame:o,setCard:i}=jn(),{setIsDashboardEditing:s,setIsVisualEditing:a,setSelectedFrameId:l,addFrame:c,setIsDashboardPanelOpen:u}=Gt(),d=re(m=>m.selectedSheetId),h=H4e((n==null?void 0:n.id)||"",{enabled:!!(n!=null&&n.id)&&!!(e!=null&&e.accessToken)}),p=R.useCallback(async m=>{try{r(m);const{data:b,fromCache:y}=await Dj((e==null?void 0:e.accessToken)||"",m.id,t);return a3e(b,o,i,s,a),{success:!0,fromCache:y}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,t,r,o,i,s,a]),g=R.useCallback(async m=>{try{if(r(m),!d)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:b,fromCache:y}=await Dj((e==null?void 0:e.accessToken)||"",m.id,t),v=b.frameObject;if(!v)return{success:!1,error:"Visual has no frame data"};const x={...v,id:or()};return c(d,x,"end"),s(!0),l(x.id),u(!1),{success:!0,fromCache:y}}catch(b){return console.error("Error adding visual:",b),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,t,r,d,c,s,l,u]);return{visual:h.data,isLoading:h.isLoading,isError:h.isError,error:h.error,handleEditLibraryVisual:p,handleAddLibraryVisual:g,getUpdatedFrame:l3e().getUpdatedFrame,refetch:h.refetch}}function eq(e,t){var De,Ue,jt,Pn,vn;const n=Qn(),r=Bt().authToken||e,o=ue(ye=>ye.selectedConnectionId),i=ue(ye=>ye.card),{queryKey:s}=TF(i),a=ue(ye=>ye.selectedDatamodelId),l=ue(ye=>ye.isDevMode),c=ue(ye=>ye.selectedDatabaseName),u=ue(ye=>ye.selectedSchemaName),d=ue(ye=>ye.selectedTableName),h=ue(ye=>ye.actions.setSelectedConnectionId),p=ue(ye=>ye.actions.setSelectedDatamodelId),g=ue(ye=>ye.actions.setSelectedDatabaseName),m=ue(ye=>ye.actions.setSelectedSchemaName),b=ue(ye=>ye.actions.setSelectedTableName);ue(ye=>ye.actions.setCardSql);const{setQueryConfig:y}=jn();function v(ye){return o&&c&&u&&c!=="NA"?!0:o&&ye==="API"?!1:!!(o&&ye==="S3")}function x(ye){return o&&ye?!(ye==="API"||ye==="S3"):!1}const{refetchConnections:C,connectionsData:_,isConnectionsLoading:S,isConnectionsError:E,selectedConnection:k}=Hi(e),{refetch:N,data:M,isLoading:I,isError:P}=hn({queryKey:["models",o],queryFn:()=>Tn("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:L,isError:B,refetch:z}=hn({queryKey:["databases",o],queryFn:()=>Tn("https://semaphor.cloud/api/v1/databases",(r==null?void 0:r.accessToken)||"",{connection_id:o}),enabled:x(j)}),{data:A,isLoading:W,isFetching:$,isError:D,refetch:H}=hn({queryKey:["schemas",o,c],queryFn:()=>Tn("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:K,refetch:Y}=hn({queryKey:["tables",o,c,u],queryFn:()=>Tn("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:Q,isColumnsLoading:ne,isColumnsFetching:Z,isColumnsError:ie,refetchColumns:te}=YU(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"?(De=k==null?void 0:k.type)==null?void 0:De.toLowerCase():d||"",de=F?"":u||"";function ke(ye){b(ye),y(void 0),l||(n.setQueryData(s,null),n.removeQueries({queryKey:s,exact:!0}))}function we(ye){m(ye),b("")}function Ce(ye){g(ye==="none"?"":ye),m(""),b(""),ye!=="none"&&ye!==""&&p("")}function Pe(ye){h(ye)}function Ye(ye){p(ye==="none"?"":ye),ye!=="none"&&ye!==""&&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(ye=>({id:ye.id,name:ye.name,type:ye.type})),ge=(Pn=M==null?void 0:M.datamodels)==null?void 0:Pn.map(ye=>({id:ye.id,name:ye.name})),je=T==null?void 0:T.databases.map(ye=>({id:ye.database_name,name:ye.database_name})),Ae=A==null?void 0:A.schemas.map(ye=>({id:ye.schema_name,name:ye.schema_name})),ee=V==null?void 0:V.tables.map(ye=>({id:ye.table_name,name:ye.table_name})),le=(vn=M==null?void 0:M.datamodels.find(ye=>ye.id===a))==null?void 0:vn.name,Re=fO({schemaName:de,tableName:ce,modelName:le,connectionType:j,databaseName:c||""});return{connectionItems:_t,selectedConnectionId:o,selectedConnection:k,isConnectionsLoading:S,isConnectionsError:E,modelItems:ge,selectedDatamodelId:a,selectedDatamodelName:le,isModelsLoading:I,isModelsError:P,selectedDatabaseName:c,databaseItems:je,isDatabasesLoadingOrFetching:O||L,isDatabaseError:B,schemaItems:Ae,selectedSchemaName:u,isSchemaLoadingOrFetching:W||$,isSchemaError:D,tableItems:ee,selectedTableName:d,isTableLoadingOrFetching:G||q,isTableError:K,columns:Q,isColumnsLoadingOrFetching:ne||Z,isColumnsError:ie,isNonDbConnection:F,connectionType:j,tableName:ce,formattedTableName:Re,schemaName:de,refetchConnections:C,refetchModels:N,refetchDatabases:z,refetchSchemas:H,refetchTables:Y,refetchColumns:te,handleConnectionChange:Pe,handleDatamodelChange:Ye,handleDatabaseChange:Ce,handleSchemaChange:we,handleTableChange:ke}}function c3e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pj(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 Aj(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Pj(Object(n),!0).forEach(function(r){c3e(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pj(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function u3e(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 d3e(e,t){if(e==null)return{};var n=u3e(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 f3e(e,t){return h3e(e)||p3e(e,t)||m3e(e,t)||g3e()}function h3e(e){if(Array.isArray(e))return e}function p3e(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 m3e(e,t){if(e){if(typeof e=="string")return Ij(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 Ij(e,t)}}function Ij(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 g3e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
634
634
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b3e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Tj(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 jj(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Tj(Object(n),!0).forEach(function(r){b3e(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tj(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function y3e(){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 Nf(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 P0(e){return{}.toString.call(e).includes("Object")}function v3e(e){return!Object.keys(e).length}function Jh(e){return typeof e=="function"}function x3e(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function w3e(e,t){return P0(t)||xa("changeType"),Object.keys(t).some(function(n){return!x3e(e,n)})&&xa("changeField"),t}function C3e(e){Jh(e)||xa("selectorType")}function S3e(e){Jh(e)||P0(e)||xa("handlerType"),P0(e)&&Object.values(e).some(function(t){return!Jh(t)})&&xa("handlersType")}function E3e(e){e||xa("initialIsRequired"),P0(e)||xa("initialType"),v3e(e)&&xa("initialContent")}function _3e(e,t){throw new Error(e[t]||e.default)}var R3e={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"},xa=Nf(_3e)(R3e),Ag={changes:w3e,selector:C3e,handler:S3e,initial:E3e};function k3e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Ag.initial(e),Ag.handler(t);var n={current:e},r=Nf(D3e)(n,t),o=Nf(M3e)(n),i=Nf(Ag.changes)(e),s=Nf(N3e)(n);function a(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Ag.selector(c),c(n.current)}function l(c){y3e(r,o,i,s)(c)}return[a,l]}function N3e(e,t){return Jh(t)?t(e.current):t}function M3e(e,t){return e.current=jj(jj({},e.current),t),t}function D3e(e,t,n){return Jh(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 P3e={create:k3e},A3e={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs"}};function I3e(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 T3e(e){return{}.toString.call(e).includes("Object")}function j3e(e){return e||Oj("configIsRequired"),T3e(e)||Oj("configType"),e.urls?(O3e(),{paths:{vs:e.urls.monacoBase}}):e}function O3e(){console.warn(tq.deprecation)}function F3e(e,t){throw new Error(e[t]||e.default)}var tq={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!
|
|
635
635
|
You are using deprecated way of configuration.
|