react-semaphor 0.1.44 → 0.1.45

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.
@@ -1,5 +1,5 @@
1
1
  import { jsxs as a, jsx as e, Fragment as K } from "react/jsx-runtime";
2
- import { c as ue, a2 as Bs, u as Q, a3 as St, a4 as kt, B as V, a5 as Tt, a6 as Ye, a7 as qs, _ as pt, a8 as Ze, a9 as nt, aa as Al, ab as We, ac as lt, ad as rt, ae as it, af as gt, ag as j, ah as Ie, ai as Dt, I as ge, aj as Ks, ak as Xt, al as ui, am as Hn, an as Ws, f as B, ao as Js, ap as mi, aq as Il, ar as hi, as as pi, at as ma, au as ne, w as Qn, av as fi, aw as gi, ax as Zt, ay as qe, az as le, aA as Ae, aB as Ct, aC as $e, aD as ya, aE as sa, aF as ba, aG as vi, aH as na, aI as vt, aJ as Je, aK as He, aL as Ca, aM as Xe, aN as Ee, aO as tt, aP as Hs, aQ as Ya, aR as ha, aS as $t, aT as jt, aU as Qs, aV as Ys, aW as xi, aX as Ra, aY as Xs, aZ as Zs, a_ as en, a$ as tn, R as Rt, b0 as Ol, b1 as Ni, b2 as an, b3 as Ma, b4 as sn, b5 as nn, b6 as wa, b7 as Sa, b8 as ka, b9 as ln, ba as rs, bb as rn, bc as Rl, bd as Ml, be as on, bf as me, bg as he, bh as pe, bi as fe, bj as Z, bk as Fl, bl as Pl, bm as yi, bn as bi, bo as Mt, bp as Ci, bq as wi, br as Ft, bs as Pt, bt as Ve, bu as dt, bv as bt, a0 as M, bw as Et, bx as is, by as os, bz as cn, bA as Si, bB as mt, bC as Os, bD as Gt, bE as Rs, bF as Ll, bG as zl, bH as ki, bI as dn, bJ as un, bK as mn, bL as hn, bM as pn, bN as fn, bO as gn, bP as vn, bQ as Ti, bR as cs, bS as Fa, a1 as oe, bT as Di, bU as wt, bV as Ei, o as la, bW as Vl, bX as je, bY as Ai, bZ as ds, b_ as Xa, b$ as xn, c0 as Ka, c1 as Pa, c2 as Nn, c3 as Ii, c4 as Oi, c5 as Ri, c6 as Mi, c7 as Fi, v as Pi, c8 as Za, c9 as _l, ca as Li, cb as us, cc as zi, cd as ct, ce as Vi, cf as _i, cg as Wa, ch as Ui, ci as Ja, cj as Ha, ck as ms, W as La, A as Yn, Q as Xn, K as Ul, J as $l, y as Vt, z as $i, G as ji, T as Gi, cl as Zn, cm as el, cn as hs, co as ps, cp as Bi, cq as za, cr as qi, cs as es, ct as Ut, cu as jl, cv as fs, cw as Ki, cx as Gl, cy as ht, cz as Se, cA as ke, cB as Te, cC as Bl, cD as Ea, cE as ql, cF as Kl, cG as Va, g as Bt, cH as tl, cI as Wl, cJ as Wi, cK as Ms, cL as Jl, cM as yn, cN as Hl, cO as Aa, cP as al, cQ as Ji, cR as Hi, cS as Qi, cT as Ql, cU as Yi, cV as Xi, cW as Yl, cX as Zi, cY as gs, cZ as eo, c_ as to, c$ as Fs, d0 as ea, d1 as st, d2 as ta, d3 as ao, d4 as so, d5 as vs, d6 as no, d7 as bn, d8 as lo, d9 as Cn, da as ro, db as Xl, dc as Qa, dd as Zl, de as io, df as oo, dg as co, dh as wn, di as uo, dj as mo, dk as sl, dl as ho, E as _a, b as Sn, dm as po, dn as fo, dp as go, dq as vo, dr as xo, ds as No, dt as er, du as Ps, dv as kn, dw as tr, dx as ar, dy as sr, dz as nr, dA as lr, dB as Tn, dC as Dn, dD as rr, dE as ir, dF as or, dG as En, dH as xs, dI as Ns, dJ as yo, P as qt, e as Kt, dK as bo, dL as Ht, dM as Co, dN as wo, dO as So, dP as ko, dQ as To, dR as Do, dS as cr, dT as ut, dU as Ia, dV as ts, dW as _t, h as ra, dX as Eo, dY as Ao, dZ as Io, d_ as Oo, d$ as Ro, e0 as dr, e1 as Mo, i as ys, j as bs, k as Cs, l as ws, m as ua, n as Ua, e2 as Fo, e3 as ft, e4 as ja, e5 as nl, e6 as Po, e7 as ll, e8 as Lo, e9 as zo, ea as Vo, eb as _o, ec as rl, ed as Uo, ee as $o, ef as jo, eg as Go, eh as Bo, ei as qo, O as il, ej as ol, ek as Ko, el as Wo, em as ur, en as Jo, eo as mr, ep as Ho, eq as Qo, er as Yo, es as Xo, et as Zo, eu as ec, ev as tc, ew as ac, ex as sc, ey as nc, ez as lc, eA as rc, eB as ic, eC as oc, eD as cc, eE as dc, eF as hr, eG as Ts, eH as An, eI as pr, eJ as In, eK as uc, eL as mc, eM as hc, eN as cl, eO as pc, eP as fc, eQ as pa, eR as fa, eS as gc, eT as fr, eU as vc, eV as Ls, eW as xc, eX as Nc, eY as as, eZ as Qt, e_ as zs, e$ as Vs, f0 as ss, f1 as gr, f2 as ga, f3 as va, f4 as On, f5 as yc, f6 as bc, f7 as Cc, f8 as wc, f9 as Sc, fa as kc, fb as Tc, fc as Dc, fd as Ds, fe as Ec, ff as Ac, fg as Ic, F as vr, fh as Oc, fi as Rc, fj as Mc, fk as xr, fl as Nr, fm as Fc, fn as yr, fo as Pc, fp as Lc, fq as zc, fr as Vc, fs as _c, S as Uc, ft as $c, U as jc, fu as Gc, C as Bc } from "./index-AVHej3yO.js";
2
+ import { c as ue, a2 as Bs, u as Q, a3 as St, a4 as kt, B as V, a5 as Tt, a6 as Ye, a7 as qs, _ as pt, a8 as Ze, a9 as nt, aa as Al, ab as We, ac as lt, ad as rt, ae as it, af as gt, ag as j, ah as Ie, ai as Dt, I as ge, aj as Ks, ak as Xt, al as ui, am as Hn, an as Ws, f as B, ao as Js, ap as mi, aq as Il, ar as hi, as as pi, at as ma, au as ne, w as Qn, av as fi, aw as gi, ax as Zt, ay as qe, az as le, aA as Ae, aB as Ct, aC as $e, aD as ya, aE as sa, aF as ba, aG as vi, aH as na, aI as vt, aJ as Je, aK as He, aL as Ca, aM as Xe, aN as Ee, aO as tt, aP as Hs, aQ as Ya, aR as ha, aS as $t, aT as jt, aU as Qs, aV as Ys, aW as xi, aX as Ra, aY as Xs, aZ as Zs, a_ as en, a$ as tn, R as Rt, b0 as Ol, b1 as Ni, b2 as an, b3 as Ma, b4 as sn, b5 as nn, b6 as wa, b7 as Sa, b8 as ka, b9 as ln, ba as rs, bb as rn, bc as Rl, bd as Ml, be as on, bf as me, bg as he, bh as pe, bi as fe, bj as Z, bk as Fl, bl as Pl, bm as yi, bn as bi, bo as Mt, bp as Ci, bq as wi, br as Ft, bs as Pt, bt as Ve, bu as dt, bv as bt, a0 as M, bw as Et, bx as is, by as os, bz as cn, bA as Si, bB as mt, bC as Os, bD as Gt, bE as Rs, bF as Ll, bG as zl, bH as ki, bI as dn, bJ as un, bK as mn, bL as hn, bM as pn, bN as fn, bO as gn, bP as vn, bQ as Ti, bR as cs, bS as Fa, a1 as oe, bT as Di, bU as wt, bV as Ei, o as la, bW as Vl, bX as je, bY as Ai, bZ as ds, b_ as Xa, b$ as xn, c0 as Ka, c1 as Pa, c2 as Nn, c3 as Ii, c4 as Oi, c5 as Ri, c6 as Mi, c7 as Fi, v as Pi, c8 as Za, c9 as _l, ca as Li, cb as us, cc as zi, cd as ct, ce as Vi, cf as _i, cg as Wa, ch as Ui, ci as Ja, cj as Ha, ck as ms, W as La, A as Yn, Q as Xn, K as Ul, J as $l, y as Vt, z as $i, G as ji, T as Gi, cl as Zn, cm as el, cn as hs, co as ps, cp as Bi, cq as za, cr as qi, cs as es, ct as Ut, cu as jl, cv as fs, cw as Ki, cx as Gl, cy as ht, cz as Se, cA as ke, cB as Te, cC as Bl, cD as Ea, cE as ql, cF as Kl, cG as Va, g as Bt, cH as tl, cI as Wl, cJ as Wi, cK as Ms, cL as Jl, cM as yn, cN as Hl, cO as Aa, cP as al, cQ as Ji, cR as Hi, cS as Qi, cT as Ql, cU as Yi, cV as Xi, cW as Yl, cX as Zi, cY as gs, cZ as eo, c_ as to, c$ as Fs, d0 as ea, d1 as st, d2 as ta, d3 as ao, d4 as so, d5 as vs, d6 as no, d7 as bn, d8 as lo, d9 as Cn, da as ro, db as Xl, dc as Qa, dd as Zl, de as io, df as oo, dg as co, dh as wn, di as uo, dj as mo, dk as sl, dl as ho, E as _a, b as Sn, dm as po, dn as fo, dp as go, dq as vo, dr as xo, ds as No, dt as er, du as Ps, dv as kn, dw as tr, dx as ar, dy as sr, dz as nr, dA as lr, dB as Tn, dC as Dn, dD as rr, dE as ir, dF as or, dG as En, dH as xs, dI as Ns, dJ as yo, P as qt, e as Kt, dK as bo, dL as Ht, dM as Co, dN as wo, dO as So, dP as ko, dQ as To, dR as Do, dS as cr, dT as ut, dU as Ia, dV as ts, dW as _t, h as ra, dX as Eo, dY as Ao, dZ as Io, d_ as Oo, d$ as Ro, e0 as dr, e1 as Mo, i as ys, j as bs, k as Cs, l as ws, m as ua, n as Ua, e2 as Fo, e3 as ft, e4 as ja, e5 as nl, e6 as Po, e7 as ll, e8 as Lo, e9 as zo, ea as Vo, eb as _o, ec as rl, ed as Uo, ee as $o, ef as jo, eg as Go, eh as Bo, ei as qo, O as il, ej as ol, ek as Ko, el as Wo, em as ur, en as Jo, eo as mr, ep as Ho, eq as Qo, er as Yo, es as Xo, et as Zo, eu as ec, ev as tc, ew as ac, ex as sc, ey as nc, ez as lc, eA as rc, eB as ic, eC as oc, eD as cc, eE as dc, eF as hr, eG as Ts, eH as An, eI as pr, eJ as In, eK as uc, eL as mc, eM as hc, eN as cl, eO as pc, eP as fc, eQ as pa, eR as fa, eS as gc, eT as fr, eU as vc, eV as Ls, eW as xc, eX as Nc, eY as as, eZ as Qt, e_ as zs, e$ as Vs, f0 as ss, f1 as gr, f2 as ga, f3 as va, f4 as On, f5 as yc, f6 as bc, f7 as Cc, f8 as wc, f9 as Sc, fa as kc, fb as Tc, fc as Dc, fd as Ds, fe as Ec, ff as Ac, fg as Ic, F as vr, fh as Oc, fi as Rc, fj as Mc, fk as xr, fl as Nr, fm as Fc, fn as yr, fo as Pc, fp as Lc, fq as zc, fr as Vc, fs as _c, S as Uc, ft as $c, U as jc, fu as Gc, C as Bc } from "./index-CYNeBPQZ.js";
3
3
  import * as _s from "react";
4
4
  import Ke, { useState as _, useRef as Nt, useEffect as Ne, useMemo as et, useCallback as Ce, useContext as Rn, Suspense as br } from "react";
5
5
  import { createPortal as qc } from "react-dom";
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("react/jsx-runtime"),s=require("./index-C5uHl9Yr.js"),E=require("react"),Lt=require("react-dom");function Mt(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const es=Mt(E);/**
1
+ "use strict";const e=require("react/jsx-runtime"),s=require("./index-CYXXeUAg.js"),E=require("react"),Lt=require("react-dom");function Mt(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const es=Mt(E);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -68308,10 +68308,7 @@ function wRe({
68308
68308
  }) {
68309
68309
  const [u, d] = ne(""), f = re((v) => v.themeStyle), p = ve(() => {
68310
68310
  const v = o || e;
68311
- return u === "" ? v : v == null ? void 0 : v.filter((x) => {
68312
- var w;
68313
- return x != null && x.value ? (w = x.value) == null ? void 0 : w.toLowerCase().includes(u == null ? void 0 : u.toLowerCase()) : !1;
68314
- });
68311
+ return u === "" ? v : v == null ? void 0 : v.filter((x) => x != null && x.value ? String(x.value).toLowerCase().includes(u == null ? void 0 : u.toLowerCase()) : !1);
68315
68312
  }, [e, o, u]);
68316
68313
  function m(v) {
68317
68314
  return v != null && v.length ? v == null ? void 0 : v.map((x) => x.value).join(", ") : "";
@@ -907,7 +907,7 @@ Defaulting to \`null\`.`}const DW=EW,XDe=YDe,XD=E.forwardRef(({className:e,value
907
907
  font-size: .6rem;
908
908
  font-weight: bold;
909
909
  color: hsl(${Math.max(0,Math.min(120-120*g,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(l=n==null?void 0:n.onChange)==null||l.call(n,s),s}}function $C(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const yTe=(e,t)=>Math.abs(e-t)<1,xTe=(e,t,n)=>{let r;return function(...s){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,s),n)}},vTe=e=>e,wTe=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let s=t;s<=n;s++)r.push(s);return r},STe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const s=i=>{const{width:a,height:l}=i;t({width:Math.round(a),height:Math.round(l)})};if(s(n.getBoundingClientRect()),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(i=>{const a=()=>{const l=i[0];if(l!=null&&l.borderBoxSize){const c=l.borderBoxSize[0];if(c){s({width:c.inlineSize,height:c.blockSize});return}}s(n.getBoundingClientRect())};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},sF={passive:!0},oF=typeof window>"u"?!0:"onscrollend"in window,CTe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let s=0;const o=e.options.useScrollendEvent&&oF?()=>{}:xTe(r,()=>{t(s,!1)},e.options.isScrollingResetDelay),i=d=>()=>{const{horizontal:f,isRtl:h}=e.options;s=f?n.scrollLeft*(h&&-1||1):n.scrollTop,o(),t(s,d)},a=i(!0),l=i(!1);l(),n.addEventListener("scroll",a,sF);const c=e.options.useScrollendEvent&&oF;return c&&n.addEventListener("scrollend",l,sF),()=>{n.removeEventListener("scroll",a),c&&n.removeEventListener("scrollend",l)}},NTe=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return Math.round(e.getBoundingClientRect()[n.options.horizontal?"width":"height"])},kTe=(e,{adjustments:t=0,behavior:n},r)=>{var s,o;const i=e+t;(o=(s=r.scrollElement)==null?void 0:s.scrollTo)==null||o.call(s,{[r.options.horizontal?"left":"top"]:i,behavior:n})};class ETe{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(s=>{s.forEach(o=>{const i=()=>{this._measureElement(o.target,o)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var s;(s=r())==null||s.disconnect(),n=null},observe:s=>{var o;return(o=r())==null?void 0:o.observe(s,{box:"border-box"})},unobserve:s=>{var o;return(o=r())==null?void 0:o.unobserve(s)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,s])=>{typeof s>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:vTe,rangeExtractor:wTe,onChange:()=>{},measureElement:NTe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!0,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,s;(s=(r=this.options).onChange)==null||s.call(r,this,n)},this.maybeNotify=kd(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=o,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const s=new Map,o=new Map;for(let i=r-1;i>=0;i--){const a=n[i];if(s.has(a.lane))continue;const l=o.get(a.lane);if(l==null||a.end>l.end?o.set(a.lane,a):a.end<l.end&&s.set(a.lane,!0),s.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((i,a)=>i.end===a.end?i.index-a.index:i.end-a.end)[0]:void 0},this.getMeasurementOptions=kd(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(n,r,s,o,i)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:s,getItemKey:o,enabled:i}),{key:!1}),this.getMeasurements=kd(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:s,getItemKey:o,enabled:i},a)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(d=>{this.itemSizeCache.set(d.key,d.size)}));const l=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const c=this.measurementsCache.slice(0,l);for(let d=l;d<n;d++){const f=o(d),h=this.options.lanes===1?c[d-1]:this.getFurthestMeasurement(c,d),p=h?h.end+this.options.gap:r+s,m=a.get(f),g=typeof m=="number"?m:this.options.estimateSize(d),b=p+g,y=h?h.lane:d%this.options.lanes;c[d]={index:d,start:p,size:g,end:b,key:f,lane:y}}return this.measurementsCache=c,c},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=kd(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,s,o)=>this.range=n.length>0&&r>0?jTe({measurements:n,outerSize:r,scrollOffset:s,lanes:o}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=kd(()=>{let n=null,r=null;const s=this.calculateRange();return s&&(n=s.startIndex,r=s.endIndex),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,s,o,i)=>o===null||i===null?[]:n({startIndex:o,endIndex:i,overscan:r,count:s}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,s=n.getAttribute(r);return s?parseInt(s,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const s=this.indexFromElement(n),o=this.measurementsCache[s];if(!o)return;const i=o.key,a=this.elementsCache.get(i);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(i,n)),n.isConnected&&this.resizeItem(s,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const s=this.measurementsCache[n];if(!s)return;const o=this.itemSizeCache.get(s.key)??s.size,i=r-o;i!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(s,i,this):s.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",i),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=i,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(s.index),this.itemSizeCache=new Map(this.itemSizeCache.set(s.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,s)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(s))});return}this._measureElement(n,void 0)},this.getVirtualItems=kd(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const s=[];for(let o=0,i=n.length;o<i;o++){const a=n[o],l=r[a];s.push(l)}return s},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return $C(r[uq(0,r.length-1,s=>$C(r[s]).start,n)])},this.getOffsetForAlignment=(n,r,s=0)=>{const o=this.getSize(),i=this.getScrollOffset();r==="auto"&&(r=n>=i+o?"end":"start"),r==="center"?n+=(s-o)/2:r==="end"&&(n-=o);const a=this.options.horizontal?"scrollWidth":"scrollHeight",c=(this.scrollElement?"document"in this.scrollElement?this.scrollElement.document.documentElement[a]:this.scrollElement[a]:0)-o;return Math.max(Math.min(c,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const s=this.measurementsCache[n];if(!s)return;const o=this.getSize(),i=this.getScrollOffset();if(r==="auto")if(s.end>=i+o-this.options.scrollPaddingEnd)r="end";else if(s.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];const a=r==="end"?s.end+this.options.scrollPaddingEnd:s.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,s.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(n,{align:r="start",behavior:s}={})=>{this.cancelScrollToIndex(),s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:s})},this.scrollToIndex=(n,{align:r="auto",behavior:s}={})=>{n=Math.max(0,Math.min(n,this.options.count-1)),this.cancelScrollToIndex(),s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const o=this.getOffsetForIndex(n,r);if(!o)return;const[i,a]=o;this._scrollToOffset(i,{adjustments:void 0,behavior:s}),s!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(n))){const[c]=$C(this.getOffsetForIndex(n,a));yTe(c,this.getScrollOffset())||this.scrollToIndex(n,{align:a,behavior:s})}else this.scrollToIndex(n,{align:a,behavior:s})}))},this.scrollBy=(n,{behavior:r}={})=>{this.cancelScrollToIndex(),r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let s;return r.length===0?s=this.options.paddingStart:s=this.options.lanes===1?((n=r[r.length-1])==null?void 0:n.end)??0:Math.max(...r.slice(-this.options.lanes).map(o=>o.end)),Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:s})=>{this.options.scrollToFn(n,{behavior:s,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(t)}}const uq=(e,t,n,r)=>{for(;e<=t;){const s=(e+t)/2|0,o=n(s);if(o<r)e=s+1;else if(o>r)t=s-1;else return s}return e>0?e-1:0};function jTe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const s=e.length-1;let i=uq(0,s,l=>e[l].start,n),a=i;for(;a<s&&e[a].end<n+t;)a++;return r>1&&(i=Math.max(0,i-i%r),a=Math.min(s,a+(r-1-a%r))),{startIndex:i,endIndex:a}}const iF=typeof document<"u"?E.useLayoutEffect:E.useEffect;function _Te(e){const t=E.useReducer(()=>({}),{})[1],n={...e,onChange:(s,o)=>{var i;o?_n.flushSync(t):t(),(i=e.onChange)==null||i.call(e,s,o)}},[r]=E.useState(()=>new ETe(n));return r.setOptions(n),iF(()=>r._didMount(),[]),iF(()=>r._willUpdate()),r}function DTe(e){return _Te({observeElementRect:STe,observeElementOffset:CTe,scrollToFn:kTe,...e})}function MTe(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function TTe(e=MTe){return C.useCallback((t,n)=>{if(typeof e=="string"){let r=e;return(t==null?void 0:t[r])===(n==null?void 0:n[r])}return e(t,n)},[e])}function RTe(e){if(e===null)return{width:0,height:0};let{width:t,height:n}=e.getBoundingClientRect();return{width:t,height:n}}function aF(e,t=!1){let[n,r]=C.useReducer(()=>({}),{}),s=C.useMemo(()=>RTe(e),[e,n]);return Bn(()=>{if(!e)return;let o=new ResizeObserver(r);return o.observe(e),()=>{o.disconnect()}},[e]),t?{width:`${s.width}px`,height:`${s.height}px`}:s}let ITe=class extends Map{constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t),this.set(t,n)),n}};function dq(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(s){return r.add(s),()=>r.delete(s)},dispatch(s,...o){let i=t[s].call(n,...o);i&&(n=i,r.forEach(a=>a()))}}}function fq(e){return C.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}let ATe=new ITe(()=>dq(()=>[],{ADD(e){return this.includes(e)?this:[...this,e]},REMOVE(e){let t=this.indexOf(e);if(t===-1)return this;let n=this.slice();return n.splice(t,1),n}}));function lM(e,t){let n=ATe.get(t),r=C.useId(),s=fq(n);if(Bn(()=>{if(e)return n.dispatch("ADD",r),()=>n.dispatch("REMOVE",r)},[n,e]),!e)return!1;let o=s.indexOf(r),i=s.length;return o===-1&&(o=i,i+=1),o===i-1}let qk=new Map,rm=new Map;function lF(e){var t;let n=(t=rm.get(e))!=null?t:0;return rm.set(e,n+1),n!==0?()=>cF(e):(qk.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>cF(e))}function cF(e){var t;let n=(t=rm.get(e))!=null?t:1;if(n===1?rm.delete(e):rm.set(e,n-1),n!==1)return;let r=qk.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,qk.delete(e))}function PTe(e,{allowed:t,disallowed:n}={}){let r=lM(e,"inert-others");Bn(()=>{var s,o;if(!r)return;let i=qi();for(let l of(s=n==null?void 0:n())!=null?s:[])l&&i.add(lF(l));let a=(o=t==null?void 0:t())!=null?o:[];for(let l of a){if(!l)continue;let c=lb(l);if(!c)continue;let d=l.parentElement;for(;d&&d!==c.body;){for(let f of d.children)a.some(h=>f.contains(h))||i.add(lF(f));d=d.parentElement}}return i.dispose},[r,t,n])}function OTe(e,t,n){let r=id(s=>{let o=s.getBoundingClientRect();o.x===0&&o.y===0&&o.width===0&&o.height===0&&n()});C.useEffect(()=>{if(!e)return;let s=t===null?null:t instanceof HTMLElement?t:t.current;if(!s)return;let o=qi();if(typeof ResizeObserver<"u"){let i=new ResizeObserver(()=>r.current(s));i.observe(s),o.add(()=>i.disconnect())}if(typeof IntersectionObserver<"u"){let i=new IntersectionObserver(()=>r.current(s));i.observe(s),o.add(()=>i.disconnect())}return()=>o.dispose()},[t,r,e])}let Yk=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var FTe=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e[e.AutoFocus=64]="AutoFocus",e))(FTe||{}),$Te=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))($Te||{}),LTe=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(LTe||{}),hq=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(hq||{});function zTe(e,t=0){var n;return e===((n=lb(e))==null?void 0:n.body)?!1:Oa(t,{0(){return e.matches(Yk)},1(){let r=e;for(;r!==null;){if(r.matches(Yk))return!0;r=r.parentElement}return!1}})}var BTe=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(BTe||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function VTe(e,t=n=>n){return e.slice().sort((n,r)=>{let s=t(n),o=t(r);if(s===null||o===null)return 0;let i=s.compareDocumentPosition(o);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function pq(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function HTe(){return/Android/gi.test(window.navigator.userAgent)}function mq(){return pq()||HTe()}function rp(e,t,n,r){let s=id(n);C.useEffect(()=>{if(!e)return;function o(i){s.current(i)}return document.addEventListener(t,o,r),()=>document.removeEventListener(t,o,r)},[e,t,r])}function UTe(e,t,n,r){let s=id(n);C.useEffect(()=>{if(!e)return;function o(i){s.current(i)}return window.addEventListener(t,o,r),()=>window.removeEventListener(t,o,r)},[e,t,r])}const uF=30;function WTe(e,t,n){let r=lM(e,"outside-click"),s=id(n),o=C.useCallback(function(l,c){if(l.defaultPrevented)return;let d=c(l);if(d===null||!d.getRootNode().contains(d)||!d.isConnected)return;let f=function h(p){return typeof p=="function"?h(p()):Array.isArray(p)||p instanceof Set?p:[p]}(t);for(let h of f)if(h!==null&&(h.contains(d)||l.composed&&l.composedPath().includes(h)))return;return!zTe(d,hq.Loose)&&d.tabIndex!==-1&&l.preventDefault(),s.current(l,d)},[s,t]),i=C.useRef(null);rp(r,"pointerdown",l=>{var c,d;i.current=((d=(c=l.composedPath)==null?void 0:c.call(l))==null?void 0:d[0])||l.target},!0),rp(r,"mousedown",l=>{var c,d;i.current=((d=(c=l.composedPath)==null?void 0:c.call(l))==null?void 0:d[0])||l.target},!0),rp(r,"click",l=>{mq()||i.current&&(o(l,()=>i.current),i.current=null)},!0);let a=C.useRef({x:0,y:0});rp(r,"touchstart",l=>{a.current.x=l.touches[0].clientX,a.current.y=l.touches[0].clientY},!0),rp(r,"touchend",l=>{let c={x:l.changedTouches[0].clientX,y:l.changedTouches[0].clientY};if(!(Math.abs(c.x-a.current.x)>=uF||Math.abs(c.y-a.current.y)>=uF))return o(l,()=>l.target instanceof HTMLElement?l.target:null)},!0),UTe(r,"blur",l=>o(l,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}function r1(...e){return C.useMemo(()=>lb(...e),[...e])}function qTe(e,t,n,r){let s=id(n);C.useEffect(()=>{e=e??window;function o(i){s.current(i)}return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)},[e,t,r])}function gq(e){let t=C.useRef({value:"",selectionStart:null,selectionEnd:null});return qTe(e,"blur",n=>{let r=n.target;r instanceof HTMLInputElement&&(t.current={value:r.value,selectionStart:r.selectionStart,selectionEnd:r.selectionEnd})}),yt(()=>{if(document.activeElement!==e&&e instanceof HTMLInputElement&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==t.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:n,selectionEnd:r}=t.current;n!==null&&r!==null&&e.setSelectionRange(n,r)}t.current={value:"",selectionStart:null,selectionEnd:null}}})}function YTe(e,t){return C.useMemo(()=>{var n;if(e.type)return e.type;let r=(n=e.as)!=null?n:"button";if(typeof r=="string"&&r.toLowerCase()==="button"||(t==null?void 0:t.tagName)==="BUTTON"&&!t.hasAttribute("type"))return"button"},[e.type,e.as,t])}function GTe(){let e;return{before({doc:t}){var n;let r=t.documentElement,s=(n=t.defaultView)!=null?n:window;e=Math.max(0,s.innerWidth-r.clientWidth)},after({doc:t,d:n}){let r=t.documentElement,s=Math.max(0,r.clientWidth-r.offsetWidth),o=Math.max(0,e-s);n.style(r,"paddingRight",`${o}px`)}}}function ZTe(){return pq()?{before({doc:e,d:t,meta:n}){function r(s){return n.containers.flatMap(o=>o()).some(o=>o.contains(s))}t.microTask(()=>{var s;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let a=qi();a.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>a.dispose()))}let o=(s=window.scrollY)!=null?s:window.pageYOffset,i=null;t.addEventListener(e,"click",a=>{if(a.target instanceof HTMLElement)try{let l=a.target.closest("a");if(!l)return;let{hash:c}=new URL(l.href),d=e.querySelector(c);d&&!r(d)&&(i=d)}catch{}},!0),t.addEventListener(e,"touchstart",a=>{if(a.target instanceof HTMLElement)if(r(a.target)){let l=a.target;for(;l.parentElement&&r(l.parentElement);)l=l.parentElement;t.style(l,"overscrollBehavior","contain")}else t.style(a.target,"touchAction","none")}),t.addEventListener(e,"touchmove",a=>{if(a.target instanceof HTMLElement){if(a.target.tagName==="INPUT")return;if(r(a.target)){let l=a.target;for(;l.parentElement&&l.dataset.headlessuiPortal!==""&&!(l.scrollHeight>l.clientHeight||l.scrollWidth>l.clientWidth);)l=l.parentElement;l.dataset.headlessuiPortal===""&&a.preventDefault()}else a.preventDefault()}},{passive:!1}),t.add(()=>{var a;let l=(a=window.scrollY)!=null?a:window.pageYOffset;o!==l&&window.scrollTo(0,o),i&&i.isConnected&&(i.scrollIntoView({block:"nearest"}),i=null)})})}}:{}}function KTe(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function XTe(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let Wc=dq(()=>new Map,{PUSH(e,t){var n;let r=(n=this.get(e))!=null?n:{doc:e,count:0,d:qi(),meta:new Set};return r.count++,r.meta.add(t),this.set(e,r),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:n}){let r={doc:e,d:t,meta:XTe(n)},s=[ZTe(),GTe(),KTe()];s.forEach(({before:o})=>o==null?void 0:o(r)),s.forEach(({after:o})=>o==null?void 0:o(r))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});Wc.subscribe(()=>{let e=Wc.getSnapshot(),t=new Map;for(let[n]of e)t.set(n,n.documentElement.style.overflow);for(let n of e.values()){let r=t.get(n.doc)==="hidden",s=n.count!==0;(s&&!r||!s&&r)&&Wc.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),n.count===0&&Wc.dispatch("TEARDOWN",n)}});function QTe(e,t,n=()=>({containers:[]})){let r=fq(Wc),s=t?r.get(t):void 0,o=s?s.count>0:!1;return Bn(()=>{if(!(!t||!e))return Wc.dispatch("PUSH",t,n),()=>Wc.dispatch("POP",t,n)},[e,t]),o}function JTe(e,t,n=()=>[document.body]){let r=lM(e,"scroll-lock");QTe(r,t,s=>{var o;return{containers:[...(o=s.containers)!=null?o:[],n]}})}function dF(e){return[e.screenX,e.screenY]}function eRe(){let e=C.useRef([-1,-1]);return{wasMoved(t){let n=dF(t);return e.current[0]===n[0]&&e.current[1]===n[1]?!1:(e.current=n,!0)},update(t){e.current=dF(t)}}}function tRe(e=0){let[t,n]=C.useState(e),r=C.useCallback(l=>n(l),[t]),s=C.useCallback(l=>n(c=>c|l),[t]),o=C.useCallback(l=>(t&l)===l,[t]),i=C.useCallback(l=>n(c=>c&~l),[n]),a=C.useCallback(l=>n(c=>c^l),[n]);return{flags:t,setFlag:r,addFlag:s,hasFlag:o,removeFlag:i,toggleFlag:a}}var fF,hF;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((fF=process==null?void 0:process.env)==null?void 0:fF.NODE_ENV)==="test"&&typeof((hF=Element==null?void 0:Element.prototype)==null?void 0:hF.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
910
- `)),[]});var nRe=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(nRe||{});function rRe(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function sRe(e,t,n,r){let[s,o]=C.useState(n),{hasFlag:i,addFlag:a,removeFlag:l}=tRe(e&&s?3:0),c=C.useRef(!1),d=C.useRef(!1),f=cb();return Bn(()=>{var h;if(e){if(n&&o(!0),!t){n&&a(3);return}return(h=void 0)==null||h.call(r,n),oRe(t,{inFlight:c,prepare(){d.current?d.current=!1:d.current=c.current,c.current=!0,!d.current&&(n?(a(3),l(4)):(a(4),l(2)))},run(){d.current?n?(l(3),a(4)):(l(4),a(3)):n?l(1):a(1)},done(){var p;d.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(c.current=!1,l(7),n||o(!1),(p=void 0)==null||p.call(r,n))}})}},[e,n,t,f]),e?[s,{closed:i(1),enter:i(2),leave:i(4),transition:i(2)||i(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function oRe(e,{prepare:t,run:n,done:r,inFlight:s}){let o=qi();return aRe(e,{prepare:t,inFlight:s}),o.nextFrame(()=>{n(),o.requestAnimationFrame(()=>{o.add(iRe(e,r))})}),o.dispose}function iRe(e,t){var n,r;let s=qi();if(!e)return s.dispose;let o=!1;s.add(()=>{o=!0});let i=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(a=>a instanceof CSSTransition))!=null?r:[];return i.length===0?(t(),s.dispose):(Promise.allSettled(i.map(a=>a.finished)).then(()=>{o||t()}),s.dispose)}function aRe(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function lRe(e,{container:t,accept:n,walk:r}){let s=C.useRef(n),o=C.useRef(r);C.useEffect(()=>{s.current=n,o.current=r},[n,r]),Bn(()=>{if(!t||!e)return;let i=lb(t);if(!i)return;let a=s.current,l=o.current,c=Object.assign(f=>a(f),{acceptNode:a}),d=i.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,c,!1);for(;d.nextNode();)l(d.currentNode)},[t,e,s,o])}function pF(e,t){let n=C.useRef([]),r=yt(e);C.useEffect(()=>{let s=[...n.current];for(let[o,i]of t.entries())if(n.current[o]!==i){let a=r(t,s);return n.current=t,a}},[r,...t])}function cRe(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}const bq={...E},uRe=bq.useInsertionEffect,dRe=uRe||(e=>e());function yq(e){const t=E.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return dRe(()=>{t.current=e}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}var Gk=typeof document<"u"?C.useLayoutEffect:C.useEffect;let mF=!1,fRe=0;const gF=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+fRe++;function hRe(){const[e,t]=E.useState(()=>mF?gF():void 0);return Gk(()=>{e==null&&t(gF())},[]),E.useEffect(()=>{mF=!0},[]),e}const pRe=bq.useId,mRe=pRe||hRe;let Km;process.env.NODE_ENV!=="production"&&(Km=new Set);function gRe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Km)!=null&&e.has(s))){var o;(o=Km)==null||o.add(s),console.warn(s)}}function bRe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Km)!=null&&e.has(s))){var o;(o=Km)==null||o.add(s),console.error(s)}}function yRe(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(s=>s(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(s=>s!==n))||[])}}}const xRe=E.createContext(null),vRe=E.createContext(null),wRe=()=>{var e;return((e=E.useContext(xRe))==null?void 0:e.id)||null},SRe=()=>E.useContext(vRe),CRe="data-floating-ui-focusable";function NRe(e){const{open:t=!1,onOpenChange:n,elements:r}=e,s=mRe(),o=E.useRef({}),[i]=E.useState(()=>yRe()),a=wRe()!=null;if(process.env.NODE_ENV!=="production"){const p=r.reference;p&&!Br(p)&&bRe("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[l,c]=E.useState(r.reference),d=yq((p,m,g)=>{o.current.openEvent=p?m:void 0,i.emit("openchange",{open:p,event:m,reason:g,nested:a}),n==null||n(p,m,g)}),f=E.useMemo(()=>({setPositionReference:c}),[]),h=E.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return E.useMemo(()=>({dataRef:o,open:t,onOpenChange:d,elements:h,events:i,floatingId:s,refs:f}),[t,d,h,i,s,f])}function kRe(e){e===void 0&&(e={});const{nodeId:t}=e,n=NRe({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,s=r.elements,[o,i]=E.useState(null),[a,l]=E.useState(null),d=(s==null?void 0:s.domReference)||o,f=E.useRef(null),h=SRe();Gk(()=>{d&&(f.current=d)},[d]);const p=Ez({...e,elements:{...s,...a&&{reference:a}}}),m=E.useCallback(v=>{const w=Br(v)?{getBoundingClientRect:()=>v.getBoundingClientRect(),contextElement:v}:v;l(w),p.refs.setReference(w)},[p.refs]),g=E.useCallback(v=>{(Br(v)||v===null)&&(f.current=v,i(v)),(Br(p.refs.reference.current)||p.refs.reference.current===null||v!==null&&!Br(v))&&p.refs.setReference(v)},[p.refs]),b=E.useMemo(()=>({...p.refs,setReference:g,setPositionReference:m,domReference:f}),[p.refs,g,m]),y=E.useMemo(()=>({...p.elements,domReference:d}),[p.elements,d]),x=E.useMemo(()=>({...p,...r,refs:b,elements:y,nodeId:t}),[p,b,y,t,r]);return Gk(()=>{r.dataRef.current.floatingContext=x;const v=h==null?void 0:h.nodesRef.current.find(w=>w.id===t);v&&(v.context=x)}),E.useMemo(()=>({...p,context:x,refs:b,elements:y}),[p,b,y,x])}const bF="active",yF="selected";function LC(e,t,n){const r=new Map,s=n==="item";let o=e;if(s&&e){const{[bF]:i,[yF]:a,...l}=e;o=l}return{...n==="floating"&&{tabIndex:-1,[CRe]:""},...o,...t.map(i=>{const a=i?i[n]:null;return typeof a=="function"?e?a(e):null:a}).concat(e).reduce((i,a)=>(a&&Object.entries(a).forEach(l=>{let[c,d]=l;if(!(s&&[bF,yF].includes(c)))if(c.indexOf("on")===0){if(r.has(c)||r.set(c,[]),typeof d=="function"){var f;(f=r.get(c))==null||f.push(d),i[c]=function(){for(var h,p=arguments.length,m=new Array(p),g=0;g<p;g++)m[g]=arguments[g];return(h=r.get(c))==null?void 0:h.map(b=>b(...m)).find(b=>b!==void 0)}}}else i[c]=d}),i),{})}}function ERe(e){e===void 0&&(e=[]);const t=e.map(a=>a==null?void 0:a.reference),n=e.map(a=>a==null?void 0:a.floating),r=e.map(a=>a==null?void 0:a.item),s=E.useCallback(a=>LC(a,e,"reference"),t),o=E.useCallback(a=>LC(a,e,"floating"),n),i=E.useCallback(a=>LC(a,e,"item"),r);return E.useMemo(()=>({getReferenceProps:s,getFloatingProps:o,getItemProps:i}),[s,o,i])}function xF(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const jRe=e=>({name:"inner",options:e,async fn(t){const{listRef:n,overflowRef:r,onFallbackChange:s,offset:o=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:l=0,scrollRef:c,...d}=Vi(e,t),{rects:f,elements:{floating:h}}=t,p=n.current[i],m=(c==null?void 0:c.current)||h,g=h.clientTop||m.clientTop,b=h.clientTop!==0,y=m.clientTop!==0,x=h===m;if(process.env.NODE_ENV!=="production"&&(t.placement.startsWith("bottom")||gRe('`placement` side must be "bottom" when using the `inner`',"middleware.")),!p)return{};const v={...t,...await l_(-p.offsetTop-h.clientTop-f.reference.height/2-p.offsetHeight/2-o).fn(t)},w=await MS(xF(v,m.scrollHeight+g+h.clientTop),d),S=await MS(v,{...d,elementContext:"reference"}),N=zr(0,w.top),k=v.y+N,D=(m.scrollHeight>m.clientHeight?M=>M:Nm)(zr(0,m.scrollHeight+(b&&x||y?g*2:0)-N-zr(0,w.bottom)));if(m.style.maxHeight=D+"px",m.scrollTop=N,s){const M=m.offsetHeight<p.offsetHeight*Va(a,n.current.length)-1||S.top>=-l||S.bottom>=-l;Fl.flushSync(()=>s(M))}return r&&(r.current=await MS(xF({...v,y:k},m.offsetHeight+g+h.clientTop),d)),{y:k}}});function _Re(e,t){const{open:n,elements:r}=e,{enabled:s=!0,overflowRef:o,scrollRef:i,onChange:a}=t,l=yq(a),c=E.useRef(!1),d=E.useRef(null),f=E.useRef(null);E.useEffect(()=>{if(!s)return;function p(g){if(g.ctrlKey||!m||o.current==null)return;const b=g.deltaY,y=o.current.top>=-.5,x=o.current.bottom>=-.5,v=m.scrollHeight-m.clientHeight,w=b<0?-1:1,S=b<0?"max":"min";m.scrollHeight<=m.clientHeight||(!y&&b>0||!x&&b<0?(g.preventDefault(),Fl.flushSync(()=>{l(N=>N+Math[S](b,v*w))})):/firefox/i.test(cRe())&&(m.scrollTop+=b))}const m=(i==null?void 0:i.current)||r.floating;if(n&&m)return m.addEventListener("wheel",p),requestAnimationFrame(()=>{d.current=m.scrollTop,o.current!=null&&(f.current={...o.current})}),()=>{d.current=null,f.current=null,m.removeEventListener("wheel",p)}},[s,n,r.floating,o,i,l]);const h=E.useMemo(()=>({onKeyDown(){c.current=!0},onWheel(){c.current=!1},onPointerMove(){c.current=!1},onScroll(){const p=(i==null?void 0:i.current)||r.floating;if(!(!o.current||!p||!c.current)){if(d.current!==null){const m=p.scrollTop-d.current;(o.current.bottom<-.5&&m<-1||o.current.top<-.5&&m>1)&&Fl.flushSync(()=>l(g=>g+m))}requestAnimationFrame(()=>{d.current=p.scrollTop})}}}),[r.floating,l,o,i]);return E.useMemo(()=>s?{floating:h}:{},[s,h])}let ub=C.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});ub.displayName="FloatingContext";let cM=C.createContext(null);cM.displayName="PlacementContext";function DRe(e){return C.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function MRe(){return C.useContext(ub).setReference}function TRe(){let{getFloatingProps:e,slot:t}=C.useContext(ub);return C.useCallback((...n)=>Object.assign({},e(...n),{"data-anchor":t.anchor}),[e,t])}function RRe(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=C.useContext(cM),n=C.useMemo(()=>e,[JSON.stringify(e,(s,o)=>{var i;return(i=o==null?void 0:o.outerHTML)!=null?i:o})]);Bn(()=>{t==null||t(n??null)},[t,n]);let r=C.useContext(ub);return C.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let vF=4;function IRe({children:e,enabled:t=!0}){let[n,r]=C.useState(null),[s,o]=C.useState(0),i=C.useRef(null),[a,l]=C.useState(null);ARe(a);let c=t&&n!==null&&a!==null,{to:d="bottom",gap:f=0,offset:h=0,padding:p=0,inner:m}=PRe(n,a),[g,b="center"]=d.split(" ");Bn(()=>{c&&o(0)},[c]);let{refs:y,floatingStyles:x,context:v}=kRe({open:c,placement:g==="selection"?b==="center"?"bottom":`bottom-${b}`:b==="center"?`${g}`:`${g}-${b}`,strategy:"absolute",transform:!1,middleware:[l_({mainAxis:g==="selection"?0:f,crossAxis:h}),jz({padding:p}),g!=="selection"&&_z({padding:p}),g==="selection"&&m?jRe({...m,padding:p,overflowRef:i,offset:s,minItemsVisible:vF,referenceOverflowThreshold:p,onFallbackChange(M){var T,O;if(!M)return;let A=v.elements.floating;if(!A)return;let P=parseFloat(getComputedStyle(A).scrollPaddingBottom)||0,F=Math.min(vF,A.childElementCount),V=0,U=0;for(let z of(O=(T=v.elements.floating)==null?void 0:T.childNodes)!=null?O:[])if(z instanceof HTMLElement){let I=z.offsetTop,B=I+z.clientHeight+P,L=A.scrollTop,R=L+A.clientHeight;if(I>=L&&B<=R)F--;else{U=Math.max(0,Math.min(B,R)-Math.max(I,L)),V=z.clientHeight;break}}F>=1&&o(z=>{let I=V*F-U+P;return z>=I?z:I})}}):null,Dz({padding:p,apply({availableWidth:M,availableHeight:T,elements:O}){Object.assign(O.floating.style,{overflow:"auto",maxWidth:`${M}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${T}px)`})}})].filter(Boolean),whileElementsMounted:Nz}),[w=g,S=b]=v.placement.split("-");g==="selection"&&(w="selection");let N=C.useMemo(()=>({anchor:[w,S].filter(Boolean).join(" ")}),[w,S]),k=_Re(v,{overflowRef:i,onChange:o}),{getReferenceProps:j,getFloatingProps:_}=ERe([k]),D=yt(M=>{l(M),y.setFloating(M)});return E.createElement(cM.Provider,{value:r},E.createElement(ub.Provider,{value:{setFloating:D,setReference:y.setReference,styles:x,getReferenceProps:j,getFloatingProps:_,slot:N}},e))}function ARe(e){Bn(()=>{if(!e)return;let t=new MutationObserver(()=>{let n=window.getComputedStyle(e).maxHeight,r=parseFloat(n);if(isNaN(r))return;let s=parseInt(n);isNaN(s)||r!==s&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function PRe(e,t){var n,r,s;let o=zC((n=e==null?void 0:e.gap)!=null?n:"var(--anchor-gap, 0)",t),i=zC((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),a=zC((s=e==null?void 0:e.padding)!=null?s:"var(--anchor-padding, 0)",t);return{...e,gap:o,offset:i,padding:a}}function zC(e,t,n=void 0){let r=cb(),s=yt((l,c)=>{if(l==null)return[n,null];if(typeof l=="number")return[l,null];if(typeof l=="string"){if(!c)return[n,null];let d=wF(l,c);return[d,f=>{let h=xq(l);{let p=h.map(m=>window.getComputedStyle(c).getPropertyValue(m));r.requestAnimationFrame(function m(){r.nextFrame(m);let g=!1;for(let[y,x]of h.entries()){let v=window.getComputedStyle(c).getPropertyValue(x);if(p[y]!==v){p[y]=v,g=!0;break}}if(!g)return;let b=wF(l,c);d!==b&&(f(b),d=b)})}return r.dispose}]}return[n,null]}),o=C.useMemo(()=>s(e,t)[0],[e,t]),[i=o,a]=C.useState();return Bn(()=>{let[l,c]=s(e,t);if(a(l),!!c)return c(a)},[e,t]),i}function xq(e){let t=/var\((.*)\)/.exec(e);if(t){let n=t[1].indexOf(",");if(n===-1)return[t[1]];let r=t[1].slice(0,n).trim(),s=t[1].slice(n+1).trim();return s?[r,...xq(s)]:[r]}return[]}function wF(e,t){let n=document.createElement("div");t.appendChild(n),n.style.setProperty("margin-top","0px","important"),n.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(n).marginTop)||0;return t.removeChild(n),r}function ORe({children:e,freeze:t}){let n=Zk(t,e);return C.createElement(C.Fragment,null,n)}function Zk(e,t){let[n,r]=C.useState(t);return!e&&n!==t&&r(t),e?n:t}let uM=C.createContext(null);uM.displayName="OpenClosedContext";var Xm=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Xm||{});function FRe(){return C.useContext(uM)}function $Re({value:e,children:t}){return C.createElement(uM.Provider,{value:e},t)}function LRe(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Fc=[];LRe(()=>{function e(t){if(!(t.target instanceof HTMLElement)||t.target===document.body||Fc[0]===t.target)return;let n=t.target;n=n.closest(Yk),Fc.unshift(n??t.target),Fc=Fc.filter(r=>r!=null&&r.isConnected),Fc.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function zRe(e){throw new Error("Unexpected object: "+e)}var ir=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(ir||{});function SF(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),s=r??-1;switch(e.focus){case 0:{for(let o=0;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 1:{s===-1&&(s=n.length);for(let o=s-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 2:{for(let o=s+1;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 3:{for(let o=n.length-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 4:{for(let o=0;o<n.length;++o)if(t.resolveId(n[o],o,n)===e.id)return o;return r}case 5:return null;default:zRe(e)}}var dM=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(dM||{});function BRe(e){let t=yt(e),n=C.useRef(!1);C.useEffect(()=>(n.current=!1,()=>{n.current=!0,eq(()=>{n.current&&t()})}),[t])}function VRe(){let e=typeof document>"u";return"useSyncExternalStore"in E?(t=>t.useSyncExternalStore)(E)(()=>()=>{},()=>!1,()=>!e):!1}function HRe(){let e=VRe(),[t,n]=E.useState(xu.isHandoffComplete);return t&&xu.isHandoffComplete===!1&&n(!1),E.useEffect(()=>{t!==!0&&n(!0)},[t]),E.useEffect(()=>xu.handoff(),[]),e?!1:t}let URe=C.createContext(!1);function WRe(){return C.useContext(URe)}function qRe(e){let t=WRe(),n=C.useContext(wq),r=r1(e),[s,o]=C.useState(()=>{var i;if(!t&&n!==null)return(i=n.current)!=null?i:null;if(xu.isServer)return null;let a=r==null?void 0:r.getElementById("headlessui-portal-root");if(a)return a;if(r===null)return null;let l=r.createElement("div");return l.setAttribute("id","headlessui-portal-root"),r.body.appendChild(l)});return C.useEffect(()=>{s!==null&&(r!=null&&r.body.contains(s)||r==null||r.body.appendChild(s))},[s,r]),C.useEffect(()=>{t||n!==null&&o(n.current)},[n,o,t]),s}let vq=C.Fragment,YRe=hi(function(e,t){let n=e,r=C.useRef(null),s=Qa(lTe(f=>{r.current=f}),t),o=r1(r),i=qRe(r),[a]=C.useState(()=>{var f;return xu.isServer?null:(f=o==null?void 0:o.createElement("div"))!=null?f:null}),l=C.useContext(XRe),c=HRe();Bn(()=>{!i||!a||i.contains(a)||(a.setAttribute("data-headlessui-portal",""),i.appendChild(a))},[i,a]),Bn(()=>{if(a&&l)return l.register(a)},[l,a]),BRe(()=>{var f;!i||!a||(a instanceof Node&&i.contains(a)&&i.removeChild(a),i.childNodes.length<=0&&((f=i.parentElement)==null||f.removeChild(i)))});let d=fi();return c?!i||!a?null:_n.createPortal(d({ourProps:{ref:s},theirProps:n,slot:{},defaultTag:vq,name:"Portal"}),a):null});function GRe(e,t){let n=Qa(t),{enabled:r=!0,...s}=e,o=fi();return r?C.createElement(YRe,{...s,ref:n}):o({ourProps:{ref:n},theirProps:s,slot:{},defaultTag:vq,name:"Portal"})}let ZRe=C.Fragment,wq=C.createContext(null);function KRe(e,t){let{target:n,...r}=e,s={ref:Qa(t)},o=fi();return C.createElement(wq.Provider,{value:n},o({ourProps:s,theirProps:r,defaultTag:ZRe,name:"Popover.Group"}))}let XRe=C.createContext(null),QRe=hi(GRe),JRe=hi(KRe),eIe=Object.assign(QRe,{Group:JRe});var tIe=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(tIe||{}),nIe=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(nIe||{}),rIe=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(rIe||{}),sIe=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.SetActivationTrigger=6]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=7]="UpdateVirtualConfiguration",e[e.SetInputElement=8]="SetInputElement",e[e.SetButtonElement=9]="SetButtonElement",e[e.SetOptionsElement=10]="SetOptionsElement",e))(sIe||{});function BC(e,t=n=>n){let n=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=t(e.options.slice()),s=r.length>0&&r[0].dataRef.current.order!==null?r.sort((i,a)=>i.dataRef.current.order-a.dataRef.current.order):VTe(r,i=>i.dataRef.current.domRef.current),o=n?s.indexOf(n):null;return o===-1&&(o=null),{options:s,activeOptionIndex:o}}let oIe={1(e){var t;return(t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1?e:{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let r=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(r!==-1)return{...e,activeOptionIndex:r,comboboxState:0,__demoMode:!1}}return{...e,comboboxState:0,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r,s,o;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:c,disabled:d}=e.virtual,f=t.focus===ir.Specific?t.idx:SF(t,{resolveItems:()=>c,resolveActiveIndex:()=>{var p,m;return(m=(p=e.activeOptionIndex)!=null?p:c.findIndex(g=>!d(g)))!=null?m:null},resolveDisabled:d,resolveId(){throw new Error("Function not implemented.")}}),h=(s=t.trigger)!=null?s:2;return e.activeOptionIndex===f&&e.activationTrigger===h?e:{...e,activeOptionIndex:f,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=BC(e);if(i.activeOptionIndex===null){let c=i.options.findIndex(d=>!d.dataRef.current.disabled);c!==-1&&(i.activeOptionIndex=c)}let a=t.focus===ir.Specific?t.idx:SF(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:c=>c.id,resolveDisabled:c=>c.dataRef.current.disabled}),l=(o=t.trigger)!=null?o:2;return e.activeOptionIndex===a&&e.activationTrigger===l?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:l,__demoMode:!1}},4:(e,t)=>{var n,r,s;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let o=t.payload,i=BC(e,l=>(l.push(o),l));e.activeOptionIndex===null&&(r=e.dataRef.current)!=null&&r.isSelected(t.payload.dataRef.current.value)&&(i.activeOptionIndex=i.options.indexOf(o));let a={...e,...i,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(a.activeOptionIndex=0),a},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(s=>s.id!==t.id)};let r=BC(e,s=>{let o=s.findIndex(i=>i.id===t.id);return o!==-1&&s.splice(o,1),s});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},7:(e,t)=>{var n,r;if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:(n=t.disabled)!=null?n:()=>!1}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let s=e.activeOptionIndex;if(e.activeOptionIndex!==null){let o=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);o!==-1?s=o:s=null}return{...e,activeOptionIndex:s,virtual:{options:t.options,disabled:(r=t.disabled)!=null?r:()=>!1}}},8:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},9:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},10:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element}},fM=C.createContext(null);fM.displayName="ComboboxActionsContext";function db(e){let t=C.useContext(fM);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,db),n}return t}let Sq=C.createContext(null);function iIe(e){let t=Th("VirtualProvider"),{options:n}=t.virtual,[r,s]=C.useMemo(()=>{let c=t.optionsElement;if(!c)return[0,0];let d=window.getComputedStyle(c);return[parseFloat(d.paddingBlockStart||d.paddingTop),parseFloat(d.paddingBlockEnd||d.paddingBottom)]},[t.optionsElement]),o=DTe({enabled:n.length!==0,scrollPaddingStart:r,scrollPaddingEnd:s,count:n.length,estimateSize(){return 40},getScrollElement(){return t.optionsElement},overscan:12}),[i,a]=C.useState(0);Bn(()=>{a(c=>c+1)},[n]);let l=o.getVirtualItems();return l.length===0?null:C.createElement(Sq.Provider,{value:o},C.createElement("div",{style:{position:"relative",width:"100%",height:`${o.getTotalSize()}px`},ref:c=>{c&&t.activationTrigger!==0&&t.activeOptionIndex!==null&&n.length>t.activeOptionIndex&&o.scrollToIndex(t.activeOptionIndex)}},l.map(c=>{var d;return C.createElement(C.Fragment,{key:c.key},C.cloneElement((d=e.children)==null?void 0:d.call(e,{...e.slot,option:n[c.index]}),{key:`${i}-${c.key}`,"data-index":c.index,"aria-setsize":n.length,"aria-posinset":c.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${c.start}px)`,overflowAnchor:"none"}}))})))}let Qm=C.createContext(null);Qm.displayName="ComboboxDataContext";function Th(e){let t=C.useContext(Qm);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Th),n}return t}function aIe(e,t){return Oa(t.type,oIe,e,t)}let lIe=C.Fragment;function cIe(e,t){var n,r;let s=sM(),{value:o,defaultValue:i,onChange:a,form:l,name:c,by:d,disabled:f=s||!1,onClose:h,__demoMode:p=!1,multiple:m=!1,immediate:g=!1,virtual:b=null,nullable:y,...x}=e,v=QMe(i),[w=m?[]:void 0,S]=XMe(o,a,v),[N,k]=C.useReducer(aIe,{dataRef:C.createRef(),comboboxState:p?0:1,isTyping:!1,options:[],virtual:b?{options:b.options,disabled:(n=b.disabled)!=null?n:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:p}),j=C.useRef(!1),_=C.useRef({static:!1,hold:!1}),D=TTe(d),M=yt(oe=>b?d===null?b.options.indexOf(oe):b.options.findIndex(de=>D(de,oe)):N.options.findIndex(de=>D(de.dataRef.current.value,oe))),T=C.useCallback(oe=>Oa(A.mode,{1:()=>w.some(de=>D(de,oe)),0:()=>D(w,oe)}),[w]),O=yt(oe=>N.activeOptionIndex===M(oe)),A=C.useMemo(()=>({...N,immediate:g,optionsPropsRef:_,value:w,defaultValue:v,disabled:f,mode:m?1:0,virtual:b?N.virtual:null,get activeOptionIndex(){if(j.current&&N.activeOptionIndex===null&&(b?b.options.length>0:N.options.length>0)){if(b){let de=b.options.findIndex(le=>{var ke,ye;return!((ye=(ke=b.disabled)==null?void 0:ke.call(b,le))!=null&&ye)});if(de!==-1)return de}let oe=N.options.findIndex(de=>!de.dataRef.current.disabled);if(oe!==-1)return oe}return N.activeOptionIndex},calculateIndex:M,compare:D,isSelected:T,isActive:O}),[w,v,f,m,p,N,b]);Bn(()=>{var oe;b&&k({type:7,options:b.options,disabled:(oe=b.disabled)!=null?oe:null})},[b,b==null?void 0:b.options,b==null?void 0:b.disabled]),Bn(()=>{N.dataRef.current=A},[A]);let P=A.comboboxState===0;WTe(P,[A.buttonElement,A.inputElement,A.optionsElement],()=>$.closeCombobox());let F=C.useMemo(()=>{var oe,de,le;return{open:A.comboboxState===0,disabled:f,activeIndex:A.activeOptionIndex,activeOption:A.activeOptionIndex===null?null:A.virtual?A.virtual.options[(oe=A.activeOptionIndex)!=null?oe:0]:(le=(de=A.options[A.activeOptionIndex])==null?void 0:de.dataRef.current.value)!=null?le:null,value:w}},[A,f,w]),V=yt(()=>{if(A.activeOptionIndex!==null){if($.setIsTyping(!1),A.virtual)R(A.virtual.options[A.activeOptionIndex]);else{let{dataRef:oe}=A.options[A.activeOptionIndex];R(oe.current.value)}$.goToOption(ir.Specific,A.activeOptionIndex)}}),U=yt(()=>{k({type:0}),j.current=!0}),z=yt(()=>{k({type:1}),j.current=!1,h==null||h()}),I=yt(oe=>{k({type:3,isTyping:oe})}),B=yt((oe,de,le)=>(j.current=!1,oe===ir.Specific?k({type:2,focus:ir.Specific,idx:de,trigger:le}):k({type:2,focus:oe,trigger:le}))),L=yt((oe,de)=>(k({type:4,payload:{id:oe,dataRef:de}}),()=>{A.isActive(de.current.value)&&(j.current=!0),k({type:5,id:oe})})),R=yt(oe=>Oa(A.mode,{0(){return S==null?void 0:S(oe)},1(){let de=A.value.slice(),le=de.findIndex(ke=>D(ke,oe));return le===-1?de.push(oe):de.splice(le,1),S==null?void 0:S(de)}})),W=yt(oe=>{k({type:6,trigger:oe})}),Y=yt(oe=>{k({type:8,element:oe})}),Z=yt(oe=>{k({type:9,element:oe})}),H=yt(oe=>{k({type:10,element:oe})}),$=C.useMemo(()=>({onChange:R,registerOption:L,goToOption:B,setIsTyping:I,closeCombobox:z,openCombobox:U,setActivationTrigger:W,selectActiveOption:V,setInputElement:Y,setButtonElement:Z,setOptionsElement:H}),[]),[q,G]=hTe(),ee=t===null?{}:{ref:t},Q=C.useCallback(()=>{if(v!==void 0)return S==null?void 0:S(v)},[S,v]),ne=fi();return C.createElement(G,{value:q,props:{htmlFor:(r=A.inputElement)==null?void 0:r.id},slot:{open:A.comboboxState===0,disabled:f}},C.createElement(IRe,null,C.createElement(fM.Provider,{value:$},C.createElement(Qm.Provider,{value:A},C.createElement($Re,{value:Oa(A.comboboxState,{0:Xm.Open,1:Xm.Closed})},c!=null&&C.createElement(rTe,{disabled:f,data:w!=null?{[c]:w}:{},form:l,onReset:Q}),ne({ourProps:ee,theirProps:x,slot:F,defaultTag:lIe,name:"Combobox"}))))))}let uIe="input";function dIe(e,t){var n,r,s,o,i;let a=Th("Combobox.Input"),l=db("Combobox.Input"),c=C.useId(),d=iq(),{id:f=d||`headlessui-combobox-input-${c}`,onChange:h,displayValue:p,disabled:m=a.disabled||!1,autoFocus:g=!1,type:b="text",...y}=e,x=C.useRef(null),v=Qa(x,t,MRe(),l.setInputElement),w=r1(a.inputElement),S=cb(),N=yt(()=>{l.onChange(null),a.optionsElement&&(a.optionsElement.scrollTop=0),l.goToOption(ir.Nothing)}),k=C.useMemo(()=>{var R;return typeof p=="function"&&a.value!==void 0?(R=p(a.value))!=null?R:"":typeof a.value=="string"?a.value:""},[a.value,p]);pF(([R,W],[Y,Z])=>{if(a.isTyping)return;let H=x.current;H&&((Z===0&&W===1||R!==Y)&&(H.value=R),requestAnimationFrame(()=>{if(a.isTyping||!H||(w==null?void 0:w.activeElement)!==H)return;let{selectionStart:$,selectionEnd:q}=H;Math.abs((q??0)-($??0))===0&&$===0&&H.setSelectionRange(H.value.length,H.value.length)}))},[k,a.comboboxState,w,a.isTyping]),pF(([R],[W])=>{if(R===0&&W===1){if(a.isTyping)return;let Y=x.current;if(!Y)return;let Z=Y.value,{selectionStart:H,selectionEnd:$,selectionDirection:q}=Y;Y.value="",Y.value=Z,q!==null?Y.setSelectionRange(H,$,q):Y.setSelectionRange(H,$)}},[a.comboboxState]);let j=C.useRef(!1),_=yt(()=>{j.current=!0}),D=yt(()=>{S.nextFrame(()=>{j.current=!1})}),M=yt(R=>{switch(l.setIsTyping(!0),R.key){case os.Enter:if(a.comboboxState!==0||j.current)return;if(R.preventDefault(),R.stopPropagation(),a.activeOptionIndex===null){l.closeCombobox();return}l.selectActiveOption(),a.mode===0&&l.closeCombobox();break;case os.ArrowDown:return R.preventDefault(),R.stopPropagation(),Oa(a.comboboxState,{0:()=>l.goToOption(ir.Next),1:()=>l.openCombobox()});case os.ArrowUp:return R.preventDefault(),R.stopPropagation(),Oa(a.comboboxState,{0:()=>l.goToOption(ir.Previous),1:()=>{_n.flushSync(()=>l.openCombobox()),a.value||l.goToOption(ir.Last)}});case os.Home:if(R.shiftKey)break;return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.First);case os.PageUp:return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.First);case os.End:if(R.shiftKey)break;return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.Last);case os.PageDown:return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.Last);case os.Escape:return a.comboboxState!==0?void 0:(R.preventDefault(),a.optionsElement&&!a.optionsPropsRef.current.static&&R.stopPropagation(),a.mode===0&&a.value===null&&N(),l.closeCombobox());case os.Tab:if(a.comboboxState!==0)return;a.mode===0&&a.activationTrigger!==1&&l.selectActiveOption(),l.closeCombobox();break}}),T=yt(R=>{h==null||h(R),a.mode===0&&R.target.value===""&&N(),l.openCombobox()}),O=yt(R=>{var W,Y,Z;let H=(W=R.relatedTarget)!=null?W:Fc.find($=>$!==R.currentTarget);if(!((Y=a.optionsElement)!=null&&Y.contains(H))&&!((Z=a.buttonElement)!=null&&Z.contains(H))&&a.comboboxState===0)return R.preventDefault(),a.mode===0&&a.value===null&&N(),l.closeCombobox()}),A=yt(R=>{var W,Y,Z;let H=(W=R.relatedTarget)!=null?W:Fc.find($=>$!==R.currentTarget);(Y=a.buttonElement)!=null&&Y.contains(H)||(Z=a.optionsElement)!=null&&Z.contains(H)||a.disabled||a.immediate&&a.comboboxState!==0&&S.microTask(()=>{_n.flushSync(()=>l.openCombobox()),l.setActivationTrigger(1)})}),P=n1(),F=cTe(),{isFocused:V,focusProps:U}=JW({autoFocus:g}),{isHovered:z,hoverProps:I}=QW({isDisabled:m}),B=C.useMemo(()=>({open:a.comboboxState===0,disabled:m,hover:z,focus:V,autofocus:g}),[a,z,V,g,m]),L=oM({ref:v,id:f,role:"combobox",type:b,"aria-controls":(n=a.optionsElement)==null?void 0:n.id,"aria-expanded":a.comboboxState===0,"aria-activedescendant":a.activeOptionIndex===null?void 0:a.virtual?(r=a.options.find(R=>!R.dataRef.current.disabled&&a.compare(R.dataRef.current.value,a.virtual.options[a.activeOptionIndex])))==null?void 0:r.id:(s=a.options[a.activeOptionIndex])==null?void 0:s.id,"aria-labelledby":P,"aria-describedby":F,"aria-autocomplete":"list",defaultValue:(i=(o=e.defaultValue)!=null?o:a.defaultValue!==void 0?p==null?void 0:p(a.defaultValue):null)!=null?i:a.defaultValue,disabled:m||void 0,autoFocus:g,onCompositionStart:_,onCompositionEnd:D,onKeyDown:M,onChange:T,onFocus:A,onBlur:O},U,I);return fi()({ourProps:L,theirProps:y,slot:B,defaultTag:uIe,name:"Combobox.Input"})}let fIe="button";function hIe(e,t){var n;let r=Th("Combobox.Button"),s=db("Combobox.Button"),o=Qa(t,s.setButtonElement),i=C.useId(),{id:a=`headlessui-combobox-button-${i}`,disabled:l=r.disabled||!1,autoFocus:c=!1,...d}=e,f=gq(r.inputElement),h=yt(k=>{switch(k.key){case os.Space:case os.Enter:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&_n.flushSync(()=>s.openCombobox()),f();return;case os.ArrowDown:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ir.First)),f();return;case os.ArrowUp:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ir.Last)),f();return;case os.Escape:if(r.comboboxState!==0)return;k.preventDefault(),r.optionsElement&&!r.optionsPropsRef.current.static&&k.stopPropagation(),_n.flushSync(()=>s.closeCombobox()),f();return;default:return}}),p=yt(k=>{k.preventDefault(),!iTe(k.currentTarget)&&(k.button===dM.Left&&(r.comboboxState===0?s.closeCombobox():s.openCombobox()),f())}),m=n1([a]),{isFocusVisible:g,focusProps:b}=JW({autoFocus:c}),{isHovered:y,hoverProps:x}=QW({isDisabled:l}),{pressed:v,pressProps:w}=UMe({disabled:l}),S=C.useMemo(()=>({open:r.comboboxState===0,active:v||r.comboboxState===0,disabled:l,value:r.value,hover:y,focus:g}),[r,y,g,v,l]),N=oM({ref:o,id:a,type:YTe(e,r.buttonElement),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":(n=r.optionsElement)==null?void 0:n.id,"aria-expanded":r.comboboxState===0,"aria-labelledby":m,disabled:l||void 0,autoFocus:c,onMouseDown:p,onKeyDown:h},b,x,w);return fi()({ourProps:N,theirProps:d,slot:S,defaultTag:fIe,name:"Combobox.Button"})}let pIe="div",mIe=Wk.RenderStrategy|Wk.Static;function gIe(e,t){var n,r,s;let o=C.useId(),{id:i=`headlessui-combobox-options-${o}`,hold:a=!1,anchor:l,portal:c=!1,modal:d=!0,transition:f=!1,...h}=e,p=Th("Combobox.Options"),m=db("Combobox.Options"),g=DRe(l);g&&(c=!0);let[b,y]=RRe(g),[x,v]=C.useState(null),w=TRe(),S=Qa(t,g?b:null,m.setOptionsElement,v),N=r1(p.optionsElement),k=FRe(),[j,_]=sRe(f,x,k!==null?(k&Xm.Open)===Xm.Open:p.comboboxState===0);OTe(j,p.inputElement,m.closeCombobox);let D=p.__demoMode?!1:d&&p.comboboxState===0;JTe(D,N);let M=p.__demoMode?!1:d&&p.comboboxState===0;PTe(M,{allowed:C.useCallback(()=>[p.inputElement,p.buttonElement,p.optionsElement],[p.inputElement,p.buttonElement,p.optionsElement])}),Bn(()=>{var L;p.optionsPropsRef.current.static=(L=e.static)!=null?L:!1},[p.optionsPropsRef,e.static]),Bn(()=>{p.optionsPropsRef.current.hold=a},[p.optionsPropsRef,a]),lRe(p.comboboxState===0,{container:p.optionsElement,accept(L){return L.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:L.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(L){L.setAttribute("role","none")}});let T=n1([(n=p.buttonElement)==null?void 0:n.id]),O=C.useMemo(()=>({open:p.comboboxState===0,option:void 0}),[p.comboboxState]),A=yt(()=>{m.setActivationTrigger(0)}),P=yt(L=>{L.preventDefault(),m.setActivationTrigger(0)}),F=oM(g?w():{},{"aria-labelledby":T,role:"listbox","aria-multiselectable":p.mode===1?!0:void 0,id:i,ref:S,style:{...h.style,...y,"--input-width":aF(p.inputElement,!0).width,"--button-width":aF(p.buttonElement,!0).width},onWheel:p.activationTrigger===0?void 0:A,onMouseDown:P,...rRe(_)}),V=j&&p.comboboxState===1,U=Zk(V,(r=p.virtual)==null?void 0:r.options),z=Zk(V,p.value),I=yt(L=>p.compare(z,L));if(p.virtual){if(U===void 0)throw new Error("Missing `options` in virtual mode");Object.assign(h,{children:C.createElement(Qm.Provider,{value:U!==p.virtual.options?{...p,virtual:{...p.virtual,options:U}}:p},C.createElement(iIe,{slot:O},h.children))})}let B=fi();return C.createElement(eIe,{enabled:c?e.static||j:!1},C.createElement(Qm.Provider,{value:p.mode===1?p:{...p,isSelected:I}},B({ourProps:F,theirProps:{...h,children:C.createElement(ORe,{freeze:V},typeof h.children=="function"?(s=h.children)==null?void 0:s.call(h,O):h.children)},slot:O,defaultTag:pIe,features:mIe,visible:j,name:"Combobox.Options"})))}let bIe="div";function yIe(e,t){var n,r,s,o;let i=Th("Combobox.Option"),a=db("Combobox.Option"),l=C.useId(),{id:c=`headlessui-combobox-option-${l}`,value:d,disabled:f=(s=(r=(n=i.virtual)==null?void 0:n.disabled)==null?void 0:r.call(n,d))!=null?s:!1,order:h=null,...p}=e,m=gq(i.inputElement),g=i.virtual?i.activeOptionIndex===i.calculateIndex(d):i.activeOptionIndex===null?!1:((o=i.options[i.activeOptionIndex])==null?void 0:o.id)===c,b=i.isSelected(d),y=C.useRef(null),x=id({disabled:f,value:d,domRef:y,order:h}),v=C.useContext(Sq),w=Qa(t,y,v?v.measureElement:null),S=yt(()=>{a.setIsTyping(!1),a.onChange(d)});Bn(()=>a.registerOption(c,x),[x,c]);let N=C.useRef(!(i.virtual||i.__demoMode));Bn(()=>{if(!i.virtual&&!i.__demoMode)return qi().requestAnimationFrame(()=>{N.current=!0})},[i.virtual,i.__demoMode]),Bn(()=>{if(N.current&&i.comboboxState===0&&g&&i.activationTrigger!==0)return qi().requestAnimationFrame(()=>{var P,F;(F=(P=y.current)==null?void 0:P.scrollIntoView)==null||F.call(P,{block:"nearest"})})},[y,g,i.comboboxState,i.activationTrigger,i.activeOptionIndex]);let k=yt(P=>{P.preventDefault(),P.button===dM.Left&&(f||(S(),mq()||requestAnimationFrame(()=>m()),i.mode===0&&a.closeCombobox()))}),j=yt(()=>{if(f)return a.goToOption(ir.Nothing);let P=i.calculateIndex(d);a.goToOption(ir.Specific,P)}),_=eRe(),D=yt(P=>_.update(P)),M=yt(P=>{if(!_.wasMoved(P)||f||g)return;let F=i.calculateIndex(d);a.goToOption(ir.Specific,F,0)}),T=yt(P=>{_.wasMoved(P)&&(f||g&&(i.optionsPropsRef.current.hold||a.goToOption(ir.Nothing)))}),O=C.useMemo(()=>({active:g,focus:g,selected:b,disabled:f}),[g,b,f]),A={id:c,ref:w,role:"option",tabIndex:f===!0?void 0:-1,"aria-disabled":f===!0?!0:void 0,"aria-selected":b,disabled:void 0,onMouseDown:k,onFocus:j,onPointerEnter:D,onMouseEnter:D,onPointerMove:M,onMouseMove:M,onPointerLeave:T,onMouseLeave:T};return fi()({ourProps:A,theirProps:p,slot:O,defaultTag:bIe,name:"Combobox.Option"})}let xIe=hi(cIe),Cq=hi(hIe),Nq=hi(dIe),vIe=bTe,kq=hi(gIe),Eq=hi(yIe),wIe=Object.assign(xIe,{Input:Nq,Button:Cq,Label:vIe,Options:kq,Option:Eq});function SIe({elementId:e}){const t=C.useRef(!1);return C.useEffect(()=>{if(t.current)return;const n=document.getElementById(e);return n&&(n.classList.add("semaphor-scope"),t.current=!0),()=>{n&&(n.classList.remove("semaphor-scope"),t.current=!1)}},[e]),null}const CIe=C.memo(({option:e,currentStyle:t})=>u.jsxs(Eq,{style:{borderRadius:t==null?void 0:t.controlInputRadius},value:e,className:"group flex cursor-default select-none items-start gap-2 rounded-sm px-3 py-1.5 data-[focus]:bg-muted",children:[u.jsx(_r,{className:"invisible size-4 shrink-0 group-data-[selected]:visible"}),e.value]},e.id),(e,t)=>e.option.id===t.option.id&&e.option.value===t.option.value);function NIe({options:e,onChange:t,selectedOptions:n,multiple:r=!0,externalFilteredOptions:s,selectAllChecked:o,onSelectAllCheckedChange:i,inputClassName:a,renderFilterModeButton:l,showNegativeIndicator:c}){const[d,f]=C.useState(""),h=te(x=>x.themeStyle),p=C.useMemo(()=>{const x=s||e;return d===""?x:x==null?void 0:x.filter(v=>{var w;return v!=null&&v.value?(w=v.value)==null?void 0:w.toLowerCase().includes(d==null?void 0:d.toLowerCase()):!1})},[e,s,d]);function m(x){return x!=null&&x.length?x==null?void 0:x.map(v=>v.value).join(", "):""}function g(x){Array.isArray(x)||(x=[x]),t(x)}function b(){return p&&p.length>0?null:u.jsx("div",{className:"relative cursor-default select-none px-4 py-2",children:"No records found."})}function y(){return!r||!(p!=null&&p.length)?null:u.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-b-muted px-4 py-2",children:[l==null?void 0:l(),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{children:"All"}),u.jsx(gn,{className:"border-muted-foreground/50",checked:o,onCheckedChange:i})]})]})}return u.jsx(wIe,{multiple:r,value:n,onChange:g,onClose:()=>f(""),children:({open:x})=>u.jsxs("div",{children:[u.jsxs("div",{className:"relative flex items-center gap-0.5",children:[c&&u.jsx("div",{className:"h-8 w-0.5 bg-red-400"}),u.jsx(Nq,{className:K("h-8 w-full rounded-sm border border-border bg-background py-1.5 pl-3 pr-8 text-sm","data-[focus]:outline-border-none focus:outline-none data-[focus]:outline-none data-[focus]:-outline-offset-2",a),style:{borderRadius:h==null?void 0:h.controlInputRadius},displayValue:m,onChange:v=>f(v.target.value)}),u.jsx(Cq,{className:"group absolute inset-y-0 right-0 px-2.5",children:u.jsx(js,{className:"size-4 text-muted-foreground hover:text-foreground"})})]}),u.jsxs(kq,{anchor:"bottom",transition:!0,style:{borderRadius:h==null?void 0:h.controlInputRadius},className:Su("mt-1 !max-h-60 w-[var(--input-width)] overflow-y-auto rounded-sm border border-border bg-background p-1 text-sm [--anchor-gap:var(--spacing-1)] empty:invisible","transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"),children:[x&&u.jsx(SIe,{elementId:"headlessui-portal-root"}),b(),y(),p==null?void 0:p.map(v=>u.jsx(CIe,{option:v,currentStyle:h},v.id))]})]})})}function kIe({filter:e}){const t=te(f=>f.themeStyle),{filteredRecords:n,isSingleSelect:r,allSelected:s,handleChange:o,handleSelectAll:i,isLoading:a,isFetching:l,isError:c,selectedRecords:d}=nM(e);return a||l?u.jsx(Ia,{style:{borderRadius:t==null?void 0:t.controlInputRadius},className:"h-8 w-full bg-foreground/10"}):c?u.jsx("div",{className:"flex h-8 w-full items-center bg-muted px-2 text-sm",children:"Error"}):u.jsx(NIe,{showNegativeIndicator:e.operation==="not in",renderFilterModeButton:()=>u.jsx(EIe,{filter:e}),inputClassName:"h-8",options:n,selectedOptions:d,onChange:o,multiple:!r,selectAllChecked:s,onSelectAllCheckedChange:i})}function EIe({filter:e}){const t=e.operation==="in"?"include":"exclude",{setFilterMode:n}=Qt();function r(){t==="include"?n(e.id,"exclude"):n(e.id,"include")}return u.jsx(ie,{onClick:r,variant:"secondary",size:"sm",className:K("h-6 text-xs hover:underline",{}),children:kv(t)})}function jIe({filter:e}){var o;const{filteredRecords:t,handleChange:n,selectedRecords:r}=nM(e);function s(i){n([{value:i,id:i}])}return u.jsx(ni,{onValueChange:s,value:((o=r==null?void 0:r[0])==null?void 0:o.value)||"",className:"mt-2 flex gap-3 overflow-x-auto",children:t==null?void 0:t.map(i=>u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Wn,{value:i.value,id:"r1"}),u.jsx(ae,{className:"text-muted-foreground",htmlFor:"r1",children:i.value})]},i.value))})}function hM({filter:e}){return Yu(e.dataType)?u.jsx(xMe,{filter:e}):e.uiType==="radio"&&e.type==="single"?u.jsx(jIe,{filter:e}):u.jsx(kIe,{filter:e})}function _Ie({frame:e}){const[t,n]=C.useState(!1),r=e==null?void 0:e.cards[0],{data:s,isPending:o,isError:i}=Ba(r),a=e==null?void 0:e.cards[1],{data:l,isLoading:c,isFetching:d}=Ba(a);return(a==null?void 0:a.type)!=="text"?u.jsx(Zm,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}):u.jsxs(Rs,{className:K("group relative overflow-y-auto",t?"m-4":"mx-0"),children:[t?u.jsx("div",{className:"overflow-y-auto break-words p-1",children:u.jsx(Zf,{card:a,data:(l==null?void 0:l.records)||[],isLoading:!1})}):u.jsx(Zm,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}),u.jsx("div",{className:K("fixed z-10",{"invisible bottom-4 right-4 group-hover:visible":t,"right-6 top-6":!t}),children:u.jsx(ob,{disabled:c||d,className:K("h-7 p-1"),pressed:t,onPressedChange:n,"aria-label":"Toggle bold",children:t?u.jsx(cte,{className:"size-4 text-muted-foreground/70"}):u.jsx(ute,{className:"size-4 text-muted-foreground/70"})})})]})}function q0(e){return{clickFilter:Ca,drillToDetail:Dg,drillThrough:ej,drillToURL:_g,drillDown:hte,drillUp:pte,dynamicDrill:ec,inlineDrill:Mv}[e]||Ca}function ad(e){return{clickFilter:"Filter Dashboard",drillToDetail:"Show Details",drillThrough:"Navigate to Dashboard",drillToURL:"Open External Link",drillDown:"Drill Down",drillUp:"Drill Up",dynamicDrill:"Explore Field",inlineDrill:"Drill"}[e]||"Interaction"}function DIe(e,t,n,r,s){const o=q0(e.mode),i=e.label||ad(e.mode),a=MIe(e,t,n,r,s);return{label:i,icon:o,targetInfo:a,interaction:e}}function MIe(e,t,n=0,r,s){var o,i,a,l,c,d;switch(e.mode){case"clickFilter":{if((o=e.applyToCardIds)!=null&&o.length){const f=e.applyToCardIds.length;return`Apply to ${f} ${f===1?"card":"cards"}`}return(i=e.excludeCardIds)!=null&&i.length?"Apply to all cards":"Apply to other cards"}case"drillToDetail":{if(e.targetInsightId)return"Drill into Insight";const f=((a=e.detailFields)==null?void 0:a.length)||0;return f>0?`Show ${f} detail ${f===1?"field":"fields"}`:"Show detail table"}case"drillThrough":return e.targetDashboardId,"Navigate to dashboard";case"drillToURL":{if(e.urlTemplate)try{return`Open ${new URL(e.urlTemplate).hostname}`}catch{return"Open external link"}return"Open external link"}case"drillDown":{if(e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){let h;if((f.type==="date"||f.baseField)&&r&&f.baseField){const p=OE(f,r,s),m=PE(f,p);h=m==null?void 0:m.field}else h=(l=f.steps[n])==null?void 0:l.field;return h?h.label:n>=f.steps.length?"End of path":f.label||"Drill by hierarchy"}}return"Drill to next level"}case"drillUp":{if(n>0&&e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){const h=(c=f.steps[n-2])==null?void 0:c.field;return h?`Back to ${h.label}`:`Back to All: ${f.label||"Data"}`}}return"Go back one level"}case"dynamicDrill":{if(e.drillField)return`Drill into ${e.drillField.label} data`;if((d=e.availableFields)!=null&&d.length){const f=e.availableFields.length;return`Choose from ${f} ${f===1?"dimension":"dimensions"}`}return"Explore dimension"}case"inlineDrill":{const f=e.inlineLimit||100,h=e.displayMode||"table";return`Show ${f} records as ${h}`}default:return""}}function TIe(e,t,n,r,s){return e.map(o=>DIe(o,t,n,r,s))}function RIe({open:e,onOpenChange:t,position:n,interactions:r,selectedConditions:s,onSelectInteraction:o,drillHierarchies:i,cardId:a,card:l}){const{currentDepth:c,breadcrumbs:d}=Kt(w=>{var S,N,k;return{currentDepth:a?((N=(S=w.interactionStates[a])==null?void 0:S.breadcrumbs)==null?void 0:N.length)??0:0,breadcrumbs:a?((k=w.interactionStates[a])==null?void 0:k.breadcrumbs)??[]:[]}}),f=E.useMemo(()=>TIe(r,i,c,l,d),[r,i,c,l,d]),h=E.useMemo(()=>{if(s.length===0)return"";const w=s[0];if(w.label){const S=w.label.split(/[=><]/);if(S.length>1)return S[1].trim()}return String(w.value)},[s]);if(E.useEffect(()=>{if(!e)return;const w=S=>{S.key==="Escape"&&t(!1)};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[e,t]),!e||!n)return null;const p=280,m=80+f.length*60,g=window.innerWidth,b=window.innerHeight;let y=n.x,x=n.y+8;y+p>g&&(y=Math.max(8,g-p-8)),x+m>b&&(x=Math.max(8,n.y-m-8));const v=u.jsxs("div",{className:"semaphor-scope",style:{position:"fixed",inset:0,pointerEvents:"none",background:"transparent"},children:[u.jsx("div",{className:"fixed inset-0",style:{zIndex:50,pointerEvents:"auto",background:"transparent"},onClick:()=>t(!1),"aria-hidden":"true"}),u.jsxs("div",{className:K("fixed rounded-lg border bg-popover shadow-lg","animate-in fade-in-0 zoom-in-95"),style:{left:`${y}px`,top:`${x}px`,zIndex:51,width:`${p}px`,maxHeight:"400px",pointerEvents:"auto"},role:"menu","aria-label":"Select interaction",children:[h&&u.jsxs("div",{className:"border-b px-4 py-3",children:[u.jsx("p",{className:"text-xs text-muted-foreground",children:"Selected"}),u.jsx("p",{className:"text-sm font-medium",children:h})]}),u.jsx("div",{className:"max-h-80 overflow-y-auto py-1",children:f.map((w,S)=>{var j;const N=w.icon,k=w.interaction.mode==="dynamicDrill"&&(S===0||((j=f[S-1])==null?void 0:j.interaction.mode)!=="dynamicDrill");return u.jsxs(E.Fragment,{children:[k&&u.jsx("div",{className:"border-t px-4 py-2",children:u.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"⚡ Explore Other Fields"})}),u.jsxs("button",{className:K("flex w-full items-start gap-3 px-4 py-3","hover:bg-accent hover:text-accent-foreground","cursor-pointer transition-colors","border-b text-left last:border-b-0"),onClick:()=>{o(w.interaction),t(!1)},role:"menuitem",children:[u.jsx("div",{className:"mt-0.5 flex-shrink-0",children:u.jsx(N,{className:"h-4 w-4 text-muted-foreground"})}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"mb-1 text-sm font-medium leading-none",children:w.label}),w.targetInfo&&u.jsx("p",{className:"text-xs text-muted-foreground",children:w.targetInfo})]})]})]},S)})})]})]});return _n.createPortal(v,document.body)}function IIe(e){const t=C.useRef([]),n=C.useRef(null),r=C.useRef(null),o=_i(e.interactionConfig).some(h=>h.mode==="clickFilter"&&h.trigger!==void 0),i=Rp(h=>h.registerClearBlurCallback),a=Rp(h=>h.unregisterCard);C.useEffect(()=>{const h=()=>{r.current&&f(r.current)};return i(e.id,h),()=>{a(e.id)}},[e.id,i,a]);function l({chart:h,selectedSegments:p,storedOriginalColorsRef:m}){if(!h||!h.canvas||!h.canvas.ownerDocument){console.warn("Chart or canvas is null when trying to toggle blur segments");return}const g=h.data.datasets;m.current||(m.current=g.map((y,x)=>h.getDatasetMeta(x).data.map(w=>w.options.backgroundColor)));const b=m.current;g.forEach((y,x)=>{const v=b[x];if(p.length===0){y.backgroundColor=[...v];return}y.backgroundColor=v.map((w,S)=>p.some(k=>k.datasetIndex===x&&k.dataIndex===S)?w:c(w,.2))});try{h.update()}catch(y){console.warn("Failed to update chart during blur toggle:",y)}}function c(h,p=.2){if(h.startsWith("rgba"))return h.replace(/[\d.]+\)$/g,`${p})`);if(h.startsWith("#")){const m=parseInt(h.slice(1,3),16),g=parseInt(h.slice(3,5),16),b=parseInt(h.slice(5,7),16);return`rgba(${m}, ${g}, ${b}, ${p})`}return h}function d(h,p){var v;if(!o||!p)return;r.current=p;const m=p.getElementsAtEventForMode(h,"nearest",{intersect:!0},!0);if(!m.length)return;const{datasetIndex:g,index:b}=m[0],y={datasetIndex:g,dataIndex:b};if(((v=h.native)==null?void 0:v.shiftKey)||h.shiftKey){const w=t.current.findIndex(S=>S.datasetIndex===g&&S.dataIndex===b);w>=0?t.current.splice(w,1):t.current.push(y)}else{const w=t.current.length===1&&t.current[0].datasetIndex===g&&t.current[0].dataIndex===b;t.current=w?[]:[y]}l({chart:p,selectedSegments:t.current,storedOriginalColorsRef:n})}function f(h){h&&(t.current=[],n.current&&l({chart:h,selectedSegments:[],storedOriginalColorsRef:n}))}return{handleChartClick:d,clearBlur:f}}function AIe({resolvedCardConfig:e,card:t,records:n,chart:r,clickEvent:s}){var c,d,f,h,p,m,g,b,y,x;const o=r==null?void 0:r.getElementsAtEventForMode(s,"nearest",{intersect:!0},!0);if(!o.length)return;const i=o[0].datasetIndex,a=o[0].index,l=(d=(c=o[0].element)==null?void 0:c.$context)==null?void 0:d.raw;console.log("datasetIndex",i),console.log("clickIndex",a),console.log("value",l);try{if(!(n!=null&&n.length))return;const{keys:v}=Qn(n),{groupByColumns:w=[],pivotByColumns:S=[],metricColumns:N=[]}=e||t.config,k=j=>w.find(_=>_.label===j)||S.find(_=>_.label===j)||N.find(_=>_.label===j);if(t.type==="map"){const j=v[0],_=((h=(f=l==null?void 0:l.feature)==null?void 0:f.properties)==null?void 0:h.name)||((m=(p=l==null?void 0:l.feature)==null?void 0:p.properties)==null?void 0:m.NAME),D=k(j);return!D||_==null?void 0:{conditions:[{field:D,operator:"=",value:_}]}}if(["pie","funnel","doughnut"].includes(t.type)){const j=v[0],_=v==null?void 0:v[1+i],D=k(j),M=k(_),T=(g=n==null?void 0:n[a])==null?void 0:g[j];if(!D||T==null){console.log("no dim field or value",j,T);return}return{conditions:[{field:D,operator:"=",value:T}],metrics:M?[{field:M,value:l}]:void 0}}if(["stackedBar","bar","line"].includes(t.type)){const j=v[0],_=k(j),D=(b=n==null?void 0:n[a])==null?void 0:b[j];if(!_||D==null){console.log("no dim field or value for stacked bar",j,D);return}const M=N[i]||N[0];if(!M){console.log("no metric field found");return}const T=S[0],A=Object.keys(n[0]).filter(U=>U!==j)[i],F=(A?(y=n==null?void 0:n[a])==null?void 0:y[A]:(x=n==null?void 0:n[a])==null?void 0:x[M.label])??l,V=[{field:_,operator:"=",value:D}];return T&&A&&V.push({field:T,operator:"=",value:A}),{conditions:V,metrics:[{field:M,value:F}]}}}catch(v){console.error("getClickContextFromChart error",v)}}function PIe(e){return e&&typeof e=="object"&&"field"in e&&"operator"in e}function OIe(e){return e&&typeof e=="object"&&"filterId"in e&&"operation"in e&&"values"in e}function jq({filters:e,filterDefinitions:t,contextMode:n,className:r,showLabel:s=!0,labelText:o="Applied Filters:",icon:i}){if(!e||e.length===0)return n==="none"?u.jsx("div",{className:"px-6 pb-4",children:u.jsx("span",{className:"text-xs text-muted-foreground",children:"No filters applied"})}):null;const l=e.map(c=>{var d,f;if(PIe(c))return{fieldName:((d=c.field)==null?void 0:d.label)||((f=c.field)==null?void 0:f.name)||"Unknown",operator:c.operator,value:$Ie(c)};if(OIe(c)){const h=t==null?void 0:t.find(p=>p.id===c.filterId);return{fieldName:(h==null?void 0:h.title)||c.name,operator:c.operation,value:FIe(c)}}else return{fieldName:"Unknown",operator:"=",value:String(c)}}).reduce((c,d)=>(c[d.fieldName]||(c[d.fieldName]=[]),c[d.fieldName].push(d),c),{});return u.jsxs("div",{className:r||"px-6 pb-4 border-b",children:[u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s&&i&&u.jsxs("div",{className:"flex items-center gap-2 text-foreground/80",children:[i,u.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:o})]}),s&&!i&&u.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:o}),u.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(l).map(([c,d])=>u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsxs("span",{className:"text-sm font-medium",children:[c,":"]}),d.map((f,h)=>u.jsx(jt,{variant:"secondary",className:"border border-primary/20 bg-primary/10 text-primary",children:f.value},`${c}-${h}`))]},c))})]}),n&&u.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[n==="interactionFilters"&&u.jsx("span",{children:"Showing data filtered by interaction only"}),n==="full"&&u.jsx("span",{children:"Showing data with all dashboard filters + interaction filters"}),n==="none"&&u.jsx("span",{children:"Showing all data (no filters applied)"})]})]})}function FIe(e){const{values:t,operation:n}=e;return!t||t.length===0?"":n==="="||n==="!="||n===">"||n==="<"||n===">="||n==="<="?String(t[0]):n==="in"||n==="not in"?t.map(r=>String(r)).join(", "):(n==="between"||n==="not between")&&t.length===2?`${t[0]} - ${t[1]}`:String(t[0])}function $Ie(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`between ${n[0]} and ${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not between ${n[0]} and ${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function LIe({cardId:e,className:t}){const n=Kt(d=>d.interactionStates[e]),r=Kt(d=>d.popInteractionStep),s=Kt(d=>d.resetInteractionState),o=(n==null?void 0:n.breadcrumbs)??[];if(n==null||n.hierarchyId,o.length===0)return null;const i=d=>{const f=o.length-d-1;for(let h=0;h<f;h++)r(e)},a=()=>{s(e)},l=d=>(d.sourceFilterGroups[0],d.toField?d.toField.label||d.toField.name:"Drill Step"),c=d=>{const f=d.sourceFilterGroups.flatMap(h=>h.filters);return u.jsxs("div",{className:"max-w-xs space-y-2 text-sm",children:[f.length>0&&u.jsx(jq,{filters:f,className:"pb-2",labelText:"Drill Down Filters:",icon:u.jsx(gte,{className:"h-4 w-4 text-foreground/80"})}),d.granularity&&u.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[u.jsx(to,{className:"h-4 w-4 text-foreground/80"}),u.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Granularity: ",d.granularity]})]}),d.metric&&u.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[u.jsx(nte,{className:"h-4 w-4 text-foreground/80"}),u.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Value:"," ",d.metric.formattedValue||d.metric.value]})]})]})};return u.jsx(si,{children:u.jsxs("div",{className:K("flex items-center gap-1 text-sm",t),children:[u.jsx(qr,{children:u.jsx(Yr,{asChild:!0,children:u.jsx("button",{className:"flex items-center p-0 text-muted-foreground hover:text-foreground",onClick:a,"aria-label":"Reset drill path",children:u.jsx(D$,{className:"h-3.5 w-3.5"})})})}),u.jsx(La,{className:"ml-0.5 h-3 w-3 text-muted-foreground"}),u.jsx("div",{className:"flex items-center",children:o.map((d,f)=>u.jsxs("div",{className:"flex items-center",children:[f>0&&u.jsx(La,{className:"mx-1 h-3 w-3 text-muted-foreground"}),u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(ie,{variant:"link",size:"sm",className:"h-6 px-1 text-muted-foreground no-underline hover:text-foreground hover:no-underline",onClick:()=>i(f),"aria-label":`Go back to: ${l(d)}`,children:l(d)})}),u.jsx(KD,{className:"ml-4",side:"bottom",children:c(d)})]})]},f))})]})})}function zIe(e){switch(e){case"content-only":return{showHeader:!1,showTitle:!1,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"print":return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showTableToolbar:!1,showColumnSettings:!1};case"embed":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!0,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"table-print":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showPagination:!1,showTableToolbar:!1,showColumnSettings:!1};case"full":default:return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!0,showFooter:!0,showFilters:!0,showBreadcrumbs:!0,showRefreshIndicator:!0,showFilterInfo:!0}}}function pM({children:e,displayPreferences:t={mode:"full"},currentUser:n}){const r=C.useMemo(()=>{const s=t.mode||"full",o=zIe(s),i=ez(n||null),a={mode:s,overrides:{...o,...i,...t.overrides}};return{displayPreferences:a,shouldShowElement:c=>{var d;return((d=a.overrides)==null?void 0:d[c])??!0}}},[t,n]);return u.jsx(Z6.Provider,{value:r,children:e})}function CF({card:e,frame:t}){var ne,oe,de,le,ke,ye,Pe,Ve,lt;const{customCards:n,placeholders:r,tokenProps:s}=Ye(),{shouldShowElement:o}=nc(),i=Kt(ue=>ue.interactionStates[e.id]),a=((ne=i==null?void 0:i.breadcrumbs)==null?void 0:ne.length)>0,l=te(ue=>ue.themeStyle),c=te(ue=>ue.selectedSheetId),d=te(ue=>ue.isDashboardEditing);te(ue=>ue.selectedLensId);const f=te(ue=>ue.dashboard.filters),h=f==null?void 0:f.find(ue=>ue.id===t.filterId&&!ue.hide),{setCardTitle:p,setCardDescription:m,setSelectedFrameId:g,updateFilter:b}=Qt(),{updateFrame:y}=Qt(),{handleChartClick:x}=IIe(e),v=o("showHeader")&&(((oe=e.customCardPreferences)==null?void 0:oe.showCardHeader)??!0),{isError:w,isLoading:S,isFetching:N,cfg:k,isPending:j,data:_,handleDatapointClick:D,pagination:M}=Wg(e),[T,O]=C.useState({open:!1,position:null,interactions:[],context:null}),{breadcrumbs:A,hierarchyId:P}=Kt(ue=>{var Ne,Je;return{breadcrumbs:((Ne=ue.interactionStates[e.id])==null?void 0:Ne.breadcrumbs)??[],hierarchyId:(Je=ue.interactionStates[e.id])==null?void 0:Je.hierarchyId}}),F=(ue,Ne,Je)=>{var Oe;const We=A.length>0?[{mode:"drillUp",trigger:(Oe=ue[0])==null?void 0:Oe.trigger,label:"Drill Up",hierarchyId:P}]:[],re=[];for(const Me of ue)if(Me.mode==="dynamicDrill"&&Me.availableFields){const nt=Me.availableFields.filter(Dt=>!A.some(ct=>{var Ot;return((Ot=ct.toField)==null?void 0:Ot.id)===Dt.id}));for(const Dt of nt)re.push({mode:"dynamicDrill",trigger:Me.trigger,drillField:Dt,label:Dt.label,availableFields:Me.availableFields})}const fe=ue.filter(Me=>Me.mode!=="dynamicDrill"),De=[...We,...fe,...re];O({open:!0,position:Je||{x:0,y:0},interactions:De,context:Ne})},{handlePointerInteraction:V,applySelectedInteraction:U}=UJ(e,F),z=b3(e),I=C.useMemo(()=>{var ue;return e.type!=="pivotTable"||!((ue=_==null?void 0:_.records)!=null&&ue.length)?null:{records:_.records,columnSubtotalMeta:_.columnSubtotalMeta,subtotalColumns:_.subtotalColumns||[],pivotSchema:_.pivotSchema||[],groupByColumns:_.groupByColumns}},[e.type,_==null?void 0:_.records,_==null?void 0:_.columnSubtotalMeta,_==null?void 0:_.subtotalColumns,_==null?void 0:_.pivotSchema,_==null?void 0:_.groupByColumns]),B=Ch(e,I),L=(ue,Ne)=>{const Je={...e,paginationConfig:{page:ue+1,pageSize:Ne}},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)};function R(ue,Ne){ue.stopPropagation();const Je=AIe({resolvedCardConfig:z,card:e,records:(_==null?void 0:_.records)||[],chart:Ne,clickEvent:ue.nativeEvent});if(!Je)return;const We=_i(e.interactionConfig),re=FE(We,Je),fe=re.length===1&&re[0].mode==="clickFilter",De=re.some(nt=>nt.mode==="dynamicDrill"),Oe=re.length>1||De;ue.button===0&&fe&&!Oe&&x(ue.nativeEvent,Ne);const Me={shift:ue.shiftKey,ctrl:ue.ctrlKey,meta:ue.metaKey};ue.button===0?V({context:Je,gesture:"leftClick",modifierKeys:Me,position:{x:ue.clientX,y:ue.clientY}}):ue.button===2&&V({context:Je,gesture:"rightClick",modifierKeys:Me,position:{x:ue.clientX,y:ue.clientY}})}function W(){var ue,Ne,Je;if(n&&n.length>0){const We=n.find(re=>re.cardId===e.id);if(We&&We.replaceDefault){const re=We.content;if(re)return u.jsx(re,{card:e})}}if(e.type==="kpi"){if(((ue=t==null?void 0:t.cards)==null?void 0:ue.length)===1)return u.jsx(Zm,{card:e,data:w?[]:(_==null?void 0:_.records)||[],isPending:j,isError:w});if(((Ne=t==null?void 0:t.cards)==null?void 0:Ne.length)>1)return u.jsx(_Ie,{frame:t})}return e.type==="text"&&((Je=t==null?void 0:t.cards)==null?void 0:Je.length)===1?u.jsx(Rs,{className:"my-4 overflow-y-auto break-words px-4",children:u.jsx(Zf,{isLoading:S||N,card:e,data:(_==null?void 0:_.records)||[]})}):ee}function Y(){if(w)return u.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[u.jsx(Rv,{className:"size-8 text-destructive"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Error fetching data. Check your card settings."})]});if((S||N)&&e.type!=="table")return u.jsx("div",{className:"flex h-full w-full items-center justify-center",children:u.jsx(Ou,{size:"md",color:"muted","aria-label":"Loading data"})});if(_!=null&&_.records&&(_==null?void 0:_.records.length)===0)return r!=null&&r.NoRecords?u.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:r.NoRecords}):u.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[u.jsx(aj,{className:"size-8 text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"No results to display"})]});if(e.type==="table")return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Qg,{card:e,data:(_==null?void 0:_.records)||[],paginationMetadata:M,onPaginationChange:L,isLoading:S||N})});if(e.type==="pivotTable"&&B)return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(eb,{card:e,data:B.data,options:B.options,onAggregationChange:ue=>{const Ne=zk(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)},onAggregationLabelChange:ue=>{const Ne=zW(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)}})});if(e.type==="aggregateTable")return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Ow,{card:e,data:(_==null?void 0:_.records)||[],groupByColumns:_==null?void 0:_.groupByColumns,pivotSchema:_==null?void 0:_.pivotSchema,paginationMetadata:M,onPaginationChange:L,onAggregationChange:ue=>{const Ne=zk(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)},isLoading:S||N})});if(e.type==="text")return u.jsx(Rs,{className:"overflow-y-auto break-words pr-2",children:u.jsx(Zf,{isLoading:S||N,card:e,data:(_==null?void 0:_.records)||[]})});if(e.type==="custom")return u.jsx(uc,{FallbackComponent:Lw,children:u.jsx(PD,{frame:t,card:e})});if(n&&n.length>0){const ue=n.find(Ne=>Ne.cardId===e.id);if(ue&&ue.content){const Ne=ue.content;return u.jsx(Ne,{card:e})}}if(k)return u.jsx(Jg,{cfg:k,onChartClick:R,onDatapointClick:D})}function Z(){if(n&&n.length>0){const ue=n.find(Ne=>Ne.cardId===e.id);if(ue&&ue.footer){const Ne=ue.footer;if(Ne)return u.jsx(Ne,{card:e})}}return null}function H(){var Je;const ue=t.cards.filter(We=>{var re;return!((re=We.tabTitle)!=null&&re.endsWith("__Header"))&&(We.displayTab===!0||We.displayTab===void 0)}),Ne=l==null?void 0:l.controlInputRadius;return u.jsx(lo,{value:t.activeCardId,className:"flex items-center justify-end gap-3",onValueChange:We=>{const re={...t,activeCardId:We};y(c,re)},children:u.jsx(Os,{style:{borderRadius:l==null?void 0:l.controlInputRadius},className:"flex-end flex h-9 flex-wrap items-center border border-border bg-background p-0",children:(Je=t.cards.filter(We=>{var re;return!((re=We.tabTitle)!=null&&re.endsWith("__Header"))&&(We.displayTab===!0||We.displayTab===void 0)}))==null?void 0:Je.map((We,re)=>u.jsx(mn,{className:K("h-full items-center rounded-none data-[state=active]:bg-muted data-[state=active]:shadow-none",{"border-r":re!==ue.length-1}),style:{borderTopLeftRadius:re===0?Ne:0,borderTopRightRadius:re===ue.length-1?Ne:0,borderBottomLeftRadius:re===0?Ne:0,borderBottomRightRadius:re===ue.length-1?Ne:0},value:We.id,children:We.tabTitle||We.title},We.id))})})}function $(){var Ne,Je,We,re;let ue=t.cards.find(fe=>fe.type==="kpi"&&fe.tabTitle===`${e.tabTitle}__Header`);return ue||(ue=t.cards.find(fe=>fe.type==="kpi"&&fe.tabTitle==="All__Header")),ue?u.jsx("div",{className:"flex items-end gap-2",children:u.jsx(fMe,{renderFilterInfo:()=>{var fe,De,Oe,Me;return o("showFilterInfo")&&((De=(fe=e.preferences)==null?void 0:fe.displayOptions)==null?void 0:De.showFilterInfo)!==!1?u.jsx(Lk,{cardId:e.id,cardFilters:(Oe=e.config)==null?void 0:Oe.filters,cardFilterCount:H0(((Me=e.config)==null?void 0:Me.filters)||null)}):null},card:ue})}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{role:"card-title-container",className:"flex h-7 items-center gap-2",children:[o("showTitle")&&u.jsx(zi,{className:K("text-base",{}),children:u.jsx(Do,{value:e.title,onSave:fe=>p(c,e.id,fe),isEditable:d,placeholder:"Add title",displayClassName:"text-base font-semibold",inputClassName:"text-base font-semibold"})}),o("showTitle")&&(d||e.info)&&u.jsx(LW,{card:e}),o("showRefreshIndicator")&&e.refreshInterval&&u.jsxs(qr,{children:[u.jsx(Yr,{className:"pr-1",children:u.jsx("div",{className:K("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":S||N})})}),u.jsx(fs,{side:"right",align:"center",children:u.jsx("p",{className:"text-xs",children:`Realtime (${e==null?void 0:e.refreshInterval})`})})]}),o("showFilterInfo")&&((Je=(Ne=e.preferences)==null?void 0:Ne.displayOptions)==null?void 0:Je.showFilterInfo)!==!1&&u.jsx(Lk,{cardId:e.id,cardFilters:(We=e.config)==null?void 0:We.filters,cardFilterCount:H0(((re=e.config)==null?void 0:re.filters)||null)})]}),u.jsxs("div",{"data-content":"card-description-and-breadcrumb",className:"flex h-6 items-center overflow-y-auto",children:[!a&&o("showDescription")&&u.jsx("div",{className:K("text-sm text-muted-foreground",{}),children:u.jsx(Do,{value:(e==null?void 0:e.description)||"",onSave:fe=>m(c,e.id,fe),isEditable:d,placeholder:"Add description",displayClassName:"text-sm text-muted-foreground",inputClassName:"text-sm"})}),a&&o("showBreadcrumbs")&&u.jsx(LIe,{cardId:e.id})]})]})}if(!e.id)return null;const q=((le=(de=e.preferences)==null?void 0:de.displayOptions)==null?void 0:le.showChrome)??!0,G=((ye=(ke=e.preferences)==null?void 0:ke.displayOptions)==null?void 0:ye.allowScroll)??!0,ee=q?u.jsxs(u.Fragment,{children:[v?u.jsx(Li,{children:u.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[u.jsx("div",{className:"flex-1 basis-0 scroll-pb-2 overflow-x-auto",role:"header-container",children:$()}),u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx("div",{children:h&&o("showFilters")&&u.jsxs("div",{style:{borderRadius:(Ve=(Pe=l==null?void 0:l.chart)==null?void 0:Pe.options)==null?void 0:Ve.borderRadius},"data-content":"frame-filter-container",className:"flex shrink-0 items-center",children:[!Yu(h.dataType)&&u.jsx(ae,{className:"my-1 shrink-0 px-3",children:u.jsx(Do,{value:h.title||h.column,onSave:ue=>b({...h,title:ue}),isEditable:d,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),u.jsx(hM,{filter:h})]})}),t.cards.length>1&&o("showTabs")&&H()]})]})}):u.jsx("div",{className:"h-8"}),u.jsx($a,{"data-role":"card-content",className:"relative flex min-h-0 grow flex-col",children:Y()}),o("showFooter")&&u.jsx(r$,{children:Z()})]}):Y(),Q=()=>q&&G?"flex h-full flex-col":q&&!G?"flex h-full flex-col overflow-hidden":!q&&!G?"h-full":"h-full overflow-auto";return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:K(Q(),{"animate-pulse":S||N}),children:W()}),T.context&&u.jsx(RIe,{open:T.open,onOpenChange:ue=>{O(Ne=>({...Ne,open:ue}))},position:T.position,interactions:T.interactions,selectedConditions:T.context.conditions,drillHierarchies:(lt=e.interactionConfig)==null?void 0:lt.drillHierarchies,cardId:e.id,card:e,onSelectInteraction:ue=>{T.context&&U(ue,T.context),O({open:!1,position:null,interactions:[],context:null})}})]})}function _q({card:e,frame:t}){return e.displayPreferences?u.jsx(pM,{displayPreferences:e.displayPreferences,children:u.jsx(CF,{card:e,frame:t})}):u.jsx(CF,{card:e,frame:t})}function BIe({card:e,frame:t,showTitle:n=!0}){const{isError:r,isLoading:s,isFetching:o,cfg:i,data:a,pagination:l}=Wg(e),c=C.useMemo(()=>{var h;return e.type!=="pivotTable"||!((h=a==null?void 0:a.records)!=null&&h.length)?null:{records:a.records,columnSubtotalMeta:a.columnSubtotalMeta,subtotalColumns:a.subtotalColumns||[],pivotSchema:a.pivotSchema||[],groupByColumns:a.groupByColumns}},[e.type,a==null?void 0:a.records,a==null?void 0:a.columnSubtotalMeta,a==null?void 0:a.subtotalColumns,a==null?void 0:a.pivotSchema,a==null?void 0:a.groupByColumns]),d=Ch(e,c);if(s||o)return u.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[u.jsx(cs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]});if(r)return u.jsx("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:u.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load visual"})});function f(){return e.type==="kpi"?u.jsx(Zm,{card:e,data:(a==null?void 0:a.records)||[],isPending:s||o}):e.type==="table"?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Qg,{card:e,data:(a==null?void 0:a.records)||[],isLoading:s||o,paginationMetadata:l})}):e.type==="pivotTable"&&d?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(eb,{card:e,data:(a==null?void 0:a.records)||[],onAggregationChange:()=>{},onAggregationLabelChange:()=>{}})}):e.type==="aggregateTable"?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Ow,{card:e,data:(a==null?void 0:a.records)||[],groupByColumns:a==null?void 0:a.groupByColumns,pivotSchema:a==null?void 0:a.pivotSchema,paginationMetadata:l,onAggregationChange:()=>{},isLoading:s||o})}):e.type==="text"?u.jsx(Rs,{className:"overflow-y-auto break-words pr-2",children:u.jsx(Zf,{isLoading:s||o,card:e,data:(a==null?void 0:a.records)||[]})}):e.type==="custom"?u.jsx(uc,{FallbackComponent:Lw,children:u.jsx(PD,{frame:t,card:e})}):i?u.jsx(Jg,{cfg:i,onChartClick:()=>{},onDatapointClick:()=>{}}):null}return u.jsxs("div",{className:"flex h-full w-full flex-col",children:[n&&e.title&&u.jsxs("div",{className:"border-b px-4 py-2",children:[u.jsx("h3",{className:"text-lg font-medium",children:e.title}),e.description&&u.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),u.jsx("div",{className:"min-h-0 flex-1 p-4",children:f()})]})}function Dq({insightId:e,filters:t,contextMode:n}){const{data:r,isLoading:s,isError:o,error:i}=dj(e,{enabled:!!e}),a=Kt(f=>f.setInteractionState),l=Kt(f=>f.resetInteractionState),c=C.useMemo(()=>{var h;if(!r)return null;const f=(r==null?void 0:r.frameObject)??((h=r==null?void 0:r.visual)==null?void 0:h.frameObject);if(!f)return null;if(typeof f=="string")try{return JSON.parse(f)}catch{return null}return f},[r]),d=C.useMemo(()=>{var f;return(f=c==null?void 0:c.cards)!=null&&f.length?c.activeCardId&&c.cards.find(h=>h.id===c.activeCardId)||c.cards[0]:null},[c]);return C.useEffect(()=>{if(!d)return;if(n==="none"||!(t!=null&&t.length)){const m={...Wo(),contextMode:n};a(d.id,m);return}const h={sourceCardId:"drill-to-insight",interactionMode:"clickFilter",filterGroups:[{filters:t}],applyToCardIds:[d.id]},p={...Wo(),appliedClickFilters:[h],contextMode:n};return a(d.id,p),()=>{l(d.id)}},[d,t,n,a,l]),s?u.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[u.jsx(cs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]}):o?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:[u.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load insight"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:i instanceof Error?i.message:"Unknown error"})]}):!c||!d?u.jsx("div",{className:"flex items-center justify-center p-12",children:u.jsx("p",{className:"text-sm text-muted-foreground",children:"This insight has no visual data to display"})}):u.jsx("div",{className:"h-full w-full",children:u.jsx(BIe,{card:d,frame:c,showTitle:!1})})}function VIe({filters:e,contextMode:t}){if(!e||e.length===0)return t==="none"?u.jsxs(jt,{variant:"outline",className:"gap-1 whitespace-nowrap",children:[u.jsx(Ca,{className:"h-3 w-3"}),"No filters"]}):null;const n=e.reduce((s,o)=>{var a,l;const i=((a=o.field)==null?void 0:a.label)||((l=o.field)==null?void 0:l.name)||"Unknown";return s[i]||(s[i]=[]),s[i].push(o),s},{});e.length;const r=Object.keys(n).length;return u.jsx(si,{children:u.jsxs(qr,{delayDuration:200,children:[u.jsx(Yr,{asChild:!0,children:u.jsxs(jt,{variant:"secondary",className:"cursor-help gap-1 whitespace-nowrap border border-blue-500/20 bg-blue-500/10 text-blue-700 dark:text-blue-300",children:[u.jsx(Ca,{className:"h-3 w-3"}),r," ",r===1?"filter":"filters"]})}),u.jsx(fs,{side:"bottom",align:"start",className:"max-w-md",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"text-sm font-medium",children:"Applied Filters"}),u.jsx("div",{className:"space-y-1.5",children:Object.entries(n).map(([s,o])=>u.jsxs("div",{className:"text-xs",children:[u.jsxs("span",{className:"font-medium",children:[s,":"]})," ",o.map((i,a)=>u.jsxs("span",{children:[HIe(i),a<o.length-1?", ":""]},a))]},s))}),t&&u.jsx("div",{className:"border-t pt-2 text-xs text-muted-foreground",children:UIe(t)})]})})]})})}function HIe(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`${n[0]}-${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not ${n[0]}-${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function UIe(e){switch(e){case"filters":case"interactionFilters":return"Showing data filtered by interaction only";case"full":return"Showing data with all dashboard filters + interaction filters";case"none":return"Showing all data (no filters applied)"}}function Mq(e,t={}){const{enabled:n=!0}=t,{data:r}=dj(e,{enabled:n&&!!e});return C.useMemo(()=>{var l,c;if(!r)return{title:"",description:void 0};const o=(r==null?void 0:r.frameObject)??((l=r==null?void 0:r.visual)==null?void 0:l.frameObject);if(!o)return{title:"",description:void 0};let i=null;if(typeof o=="string")try{i=JSON.parse(o)}catch{return{title:"",description:void 0}}else i=o;if(!((c=i==null?void 0:i.cards)!=null&&c.length))return{title:"",description:void 0};const a=i.activeCardId&&i.cards.find(d=>d.id===i.activeCardId)||i.cards[0];return{title:a.title,description:a.description}},[r])}function WIe({cardId:e,children:t}){const n=Kt(o=>o.replacedCards[e]),r=Kt(o=>o.restoreCard),s=Mq((n==null?void 0:n.insightId)||"",{enabled:!!(n!=null&&n.insightId)});return n?u.jsxs("div",{className:"flex h-full w-full flex-col",children:[u.jsxs("div",{className:"border-b bg-muted/30",children:[u.jsx("div",{className:"flex items-baseline gap-2 px-5 pb-2 pt-4",children:s.title&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"truncate text-sm font-semibold",children:s.title}),s.description&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-muted-foreground",children:"-"}),u.jsx("span",{className:"truncate text-xs text-muted-foreground",children:s.description})]})]})}),u.jsxs("div",{className:"flex items-center gap-3 px-4 pb-2",children:[u.jsxs(ie,{variant:"ghost",size:"sm",onClick:()=>r(e),className:"flex-shrink-0 gap-1",children:[u.jsx(o$,{className:"h-4 w-4"}),"Back"]}),u.jsx(VIe,{filters:n.filters,contextMode:n.contextMode})]})]}),u.jsx("div",{className:"min-h-0 flex-1",children:u.jsx(Dq,{insightId:n.insightId,filters:n.filters,contextMode:n.contextMode})})]}):u.jsx(u.Fragment,{children:t})}function qIe({frame:e,footer:t,className:n,...r}){var w,S;const s=C.useRef(null),[o,i]=C.useState(!1),a=te(N=>N.themeStyle),l=te(N=>N.isVisualEditing),c=te(N=>N.selectedFrameId),d=te(N=>N.isDashboardEditing),{setSelectedFrameId:f}=Qt(),{clearSelectedVisual:h}=Eg(),{setSelectedConnectionId:p,setSelectedDatabaseName:m,setSelectedSchemaName:g,setSelectedTableName:b,setCard:y}=Gr();C.useEffect(()=>{if(c===e.id&&d&&!l){const N=s==null?void 0:s.current;N==null||N.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[c,e.id,d,l,s]);const x=e.cards.find(N=>N.id===e.activeCardId);function v(N){N.stopPropagation(),f(e.id),h(),x&&y(x),x!=null&&x.connectionId&&p(x==null?void 0:x.connectionId),x!=null&&x.lastSelectedDatabase&&m(x==null?void 0:x.lastSelectedDatabase),x!=null&&x.lastSelectedSchema&&g(x==null?void 0:x.lastSelectedSchema),x!=null&&x.lastSelectedTable&&b(x==null?void 0:x.lastSelectedTable)}return u.jsx(uc,{FallbackComponent:OD,children:u.jsxs("div",{tabIndex:-1,ref:s,role:"card-frame","data-frame-id":e.id,"data-active-card-id":x==null?void 0:x.id,onClick:v,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{borderRadius:a==null?void 0:a.cardBorderRadius},className:K("relative flex h-full flex-col rounded-sm border bg-background shadow-sm",{"border-dashed border-foreground/50":c===e.id&&d},a==null?void 0:a.dashboardCard,n,"semaphor-card-frame"),...r,children:[(d||((S=(w=x==null?void 0:x.preferences)==null?void 0:w.displayOptions)==null?void 0:S.showCardToolbar)!==!1)&&u.jsx(vW,{frame:e,isHovered:o}),x&&u.jsx(WIe,{cardId:x.id,children:u.jsx(_q,{card:x,frame:e},x.id)})]})})}function YIe({label:e,onCheckedChange:t,checked:n}){return u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(gn,{onCheckedChange:t,id:"terms",checked:n}),u.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:e})]})}function mM(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,o;for(o=0;o<r.length;o++)s=r[o],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var GIe=["color"],ZIe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,GIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),KIe=["color"],Tq=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,KIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),XIe=["color"],QIe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,XIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))});function eh({text:e,className:t}){const[n,r]=C.useState(!1);return u.jsx(ie,{className:K("h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",t),variant:"ghost",size:"icon",onClick:()=>{navigator.clipboard.writeText(e),r(!0),setTimeout(()=>{r(!1)},1e3)},children:n?u.jsx(Tq,{className:"size-3.5"}):u.jsx(JE,{className:"size-3.5"})})}function JIe({filter:e,onUpdate:t}){const[n,r]=C.useState(""),s=te(y=>y.dashboard.sheets)||[],o=C.useMemo(()=>{const y=[];return s==null||s.forEach(x=>{var v;(v=x.frames)==null||v.forEach(w=>{var S;(S=w.cards)==null||S.forEach(N=>{y.push({...N,sheetId:x.id,sheetTitle:x.title||x.id})})})}),y},[s]),i=()=>e.applyToSheetIds!==void 0?"specific-sheets":e.excludeSheetIds!==void 0?"all-except-specific":"all-sheets",a=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",l=y=>{const x={};switch(y){case"all-sheets":x.applyToSheetIds=void 0,x.excludeSheetIds=void 0;break;case"specific-sheets":x.applyToSheetIds=[],x.excludeSheetIds=void 0;break;case"all-except-specific":x.applyToSheetIds=void 0,x.excludeSheetIds=[];break}t(x)},c=y=>{const x={};switch(y){case"all-cards":x.applyToCardIds=void 0,x.excludeCardIds=void 0;break;case"specific-cards":x.applyToCardIds=[],x.excludeCardIds=void 0;break;case"all-except-specific":x.applyToCardIds=void 0,x.excludeCardIds=[];break}t(x)},d=(y,x)=>{if(x==="specific-sheets"){const v=e.applyToSheetIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({applyToSheetIds:w})}else if(x==="all-except-specific"){const v=e.excludeSheetIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({excludeSheetIds:w})}},f=(y,x)=>{if(x==="specific-cards"){const v=e.applyToCardIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({applyToCardIds:w})}else if(x==="all-except-specific"){const v=e.excludeCardIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({excludeCardIds:w})}},h=()=>{const y=i();return y==="specific-sheets"?e.applyToSheetIds||[]:y==="all-except-specific"?(s==null?void 0:s.filter(x=>{var v;return!((v=e.excludeSheetIds)!=null&&v.includes(x.id))}).map(x=>x.id))||[]:(s==null?void 0:s.map(x=>x.id))||[]},p=C.useMemo(()=>{const y=h();return o.filter(x=>y.includes(x.sheetId))},[o,e.applyToSheetIds,e.excludeSheetIds]),m=C.useMemo(()=>{if(!n.trim())return p;const y=n.toLowerCase();return p.filter(x=>{var v;return(v=x==null?void 0:x.title)==null?void 0:v.toLowerCase().includes(y)})},[n,p]),g=i(),b=a();return u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Sheet Scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Which sheets should display this filter?"})]}),u.jsxs(ni,{value:g,onValueChange:y=>l(y),className:"space-y-3",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-sheets",id:"all-sheets",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-sheets",className:"cursor-pointer text-sm font-medium",children:"All sheets"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Display filter on all sheets (",(s==null?void 0:s.length)||0," sheets)"]})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-sheets",id:"specific-sheets",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-sheets",className:"cursor-pointer text-sm font-medium",children:"Only specific sheets"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on selected sheets only"})]})]}),g==="specific-sheets"&&u.jsx("div",{className:"ml-7 space-y-2",children:u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:s==null?void 0:s.map(y=>{const x=(e.applyToSheetIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`sheet-${y.id}`,checked:x,onCheckedChange:()=>d(y.id,"specific-sheets")}),u.jsx(ae,{htmlFor:`sheet-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title||y.id})]},y.id)})})}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-sheets-except",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-sheets-except",className:"cursor-pointer text-sm font-medium",children:"All sheets except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on all sheets except selected ones"})]})]}),g==="all-except-specific"&&u.jsx("div",{className:"ml-7 space-y-2",children:u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:s==null?void 0:s.map(y=>{const x=(e.excludeSheetIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`sheet-exclude-${y.id}`,checked:x,onCheckedChange:()=>d(y.id,"all-except-specific")}),u.jsx(ae,{htmlFor:`sheet-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title||y.id})]},y.id)})})})]})]}),u.jsxs("div",{className:"space-y-3 border-t pt-4",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Card Scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Which cards should receive this filter?"})]}),u.jsxs(ni,{value:b,onValueChange:y=>c(y),className:"space-y-3",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Apply filter to all cards in applicable sheets (",p.length," cards)"]})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),b==="specific-cards"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:m.length>0?m.map(y=>{const x=(e.applyToCardIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-${y.id}`,checked:x,onCheckedChange:()=>f(y.id,"specific-cards")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),u.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):u.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-cards-except",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards-except",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards except selected ones"})]})]}),b==="all-except-specific"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:m.length>0?m.map(y=>{const x=(e.excludeCardIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-exclude-${y.id}`,checked:x,onCheckedChange:()=>f(y.id,"all-except-specific")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),u.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):u.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]})]})]}),u.jsx("div",{className:"rounded-md bg-blue-50 p-3 text-xs text-blue-900 dark:bg-blue-950 dark:text-blue-100",children:"ℹ️ Cards are filtered based on sheet scope selection. Only cards from applicable sheets are shown in card scope."})]})}function eAe({filter:e}){const[t,n]=C.useState(e.sql),[r,s]=C.useState(!1),[o,i]=C.useState({}),[a,l]=C.useState(e.title||""),[c,d]=C.useState(e.column),f=te(y=>y.selectedSheetId),{updateFilter:h}=Qt();function p(){const y=a.trim(),x=c.trim(),v={sql:t,...o},w=x||e.column;x&&x!==e.column&&(v.column=w),v.title=y||w;const S={...e,...v};h(S),i({}),s(!1)}C.useEffect(()=>{r&&(i({}),n(e.sql),l(e.title===e.column?"":e.title||""),d(e.column))},[r,e.sql,e.title,e.column]);function m(y){const x={...e,type:y};h(x)}function g(y){const x={...e,uiType:y};h(x)}function b(y){if(!f)return;const x={...e,sheetId:y?f:void 0};h(x)}return u.jsxs(Ds,{open:r,onOpenChange:s,children:[u.jsx(Ms,{children:u.jsx(ou,{className:"invisible h-3 w-3 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),u.jsx(Ts,{onMouseDown:y=>y.stopPropagation(),onDoubleClick:y=>y.stopPropagation(),className:"z-50 m-2 h-[600px] w-[500px] overflow-hidden",children:u.jsxs("div",{className:"flex h-full flex-col",children:[u.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[u.jsx("h4",{className:"font-medium leading-none",title:e.column,children:e.column.split(".").pop()}),u.jsx(jt,{variant:"secondary",className:"flex-shrink-0 text-xs font-normal",children:e.dataType})]}),u.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Customize filter settings and scope"}),u.jsxs(lo,{defaultValue:"scope",className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[u.jsxs(Os,{className:"grid w-full flex-shrink-0 grid-cols-2",children:[u.jsx(mn,{value:"scope",children:"Scope"}),u.jsx(mn,{value:"advanced",children:"Configuration"})]}),u.jsx(lr,{value:"scope",className:"mt-4 flex-1 overflow-y-auto",children:u.jsx(JIe,{filter:{...e,...o},onUpdate:y=>{i(x=>({...x,...y}))}})}),u.jsxs(lr,{value:"advanced",className:"mt-4 flex-1 space-y-5 overflow-y-auto",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Custom Title (optional)"}),u.jsx(si,{children:u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),u.jsx(fs,{side:"right",className:"max-w-xs",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{className:"text-xs",children:"Leave empty to use the column name. Provide a custom title to override it."}),u.jsxs("div",{className:"space-y-1 border-t pt-2",children:[u.jsx("p",{className:"text-xs font-medium",children:"Filter ID"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.id}),u.jsx(eh,{text:e.id})]})]})]})})]})})]}),u.jsx(pr,{value:a,onChange:y=>l(y.target.value),placeholder:e.column,className:"h-8 text-sm"})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Column Name"}),u.jsx(pr,{value:c,onChange:y=>d(y.target.value),placeholder:"Enter column name",className:"h-8 font-mono text-xs"})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Selection Type"}),u.jsxs(ni,{onValueChange:m,value:e.type||"multiple",className:"flex gap-4",children:[u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"multiple",id:"r1"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"r1",children:"Multiple"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"single",id:"r2"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"r2",children:"Single"})]})]})]}),e.type==="single"&&u.jsxs("div",{className:"space-y-3",children:[u.jsx(ae,{className:"text-sm font-medium",children:"UI Component"}),u.jsxs(ni,{onValueChange:g,value:e.uiType||"dropdown",className:"flex gap-4",children:[u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"dropdown",id:"dropdown"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"dropdown",children:"Dropdown"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"radio",id:"radio"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"radio",children:"Radio"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"SQL"}),u.jsx(si,{children:u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),u.jsx(fs,{side:"right",className:"max-w-xs",children:u.jsx("p",{className:"text-xs",children:"This SQL will be used to fetch the filter values"})})]})})]}),u.jsx(ch,{onKeyDown:y=>{y.stopPropagation()},value:t,onChange:y=>n(y.target.value),className:`h-32 w-full resize-none break-all font-mono text-xs ${Kd}`,placeholder:"SELECT column FROM table..."})]}),u.jsx("div",{className:"border-t pt-2",children:u.jsx(YIe,{label:"Local to sheet",onCheckedChange:b,checked:!!e.sheetId})})]})]}),u.jsx("div",{className:"mt-3 flex justify-end gap-2 border-t pt-3",children:u.jsxs(ie,{onClick:p,size:"sm",variant:"outline",children:[u.jsx(_r,{className:"mr-2 size-4"}),"Accept"]})})]})})]})}const Rq=C.createContext(void 0);function fb(){const e=C.useContext(Rq);return e||{preferences:{},isLocalDev:!1,isConsoleMode:!1}}function Iq({filter:e}){var c;const t=te(d=>d.isDashboardEditing),{preferences:n}=fb(),r=((c=n==null?void 0:n.cardDisplay)==null?void 0:c.mode)==="print",s=te(d=>d.filterValues),o=s==null?void 0:s.some(d=>d.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:l}=Qt();return u.jsxs("div",{className:"group mb-1 flex h-5 items-center justify-between",children:[u.jsxs("div",{className:"flex grow items-center gap-2",children:[u.jsx(ae,{className:"my-1 inline-block text-sm",children:u.jsx(Do,{value:e.title||e.column,onSave:d=>l({...e,title:d}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),o&&!r&&u.jsx("button",{onClick:()=>i(e.id),className:"text-muted-foreground",children:u.jsx(lte,{className:"size-3.5"})}),t&&u.jsx("button",{className:"invisible group-hover:visible",onClick:()=>{l({...e,hide:!e.hide})},children:e.hide?u.jsx(oh,{className:"size-3.5 text-muted-foreground hover:text-foreground"}):u.jsx(Dv,{className:"size-3.5 text-muted-foreground hover:text-foreground"})}),t&&u.jsx(eAe,{filter:e})]}),u.jsx("div",{className:"flex items-center gap-2",children:t&&u.jsx(Xt,{onClick:()=>{i(e.id),a(e.id)},className:"size-3 cursor-pointer text-muted-foreground hover:cursor-pointer hover:text-foreground"})})]})}function Aq(){var g;const e=te(b=>b.isDashboardEditing),t=te(b=>b.selectedSheetId),n=te(b=>b.dashboard),r=n==null?void 0:n.sheets,s=r==null?void 0:r.find(b=>b.id===t),o=Ae(b=>b.card),i=Ae(b=>b.selectedConnectionId),{addFrame:a,setSelectedFrameId:l,setIsVisualEditing:c}=Qt(),{setFrame:d,setCard:f,setActiveTabCardId:h}=Gr();function p(){var v,w;const b=o==null?void 0:o.dataSource;if(b)return b;const y=(w=(v=n==null?void 0:n.aiContext)==null?void 0:v.selectedEntities)==null?void 0:w[0],x=y==null?void 0:y.type;if(y)return{connectionId:y.connectionId,connectionType:y.connectionType,type:x,selectedEntities:[y]}}function m(b){const y=(b==null?void 0:b.sheetId)||t,x=r==null?void 0:r.find(k=>k.id===y);if(!x){console.warn("Cannot add frame: No sheet found");return}if(!(!x.frames||x.frames.length===0)&&!e){console.warn("Cannot add frame: Dashboard not in editing mode");return}const w=p(),S={id:wr(),title:"Title",type:"bar",connectionId:i||"",dataSource:w,preferences:{onClickFilter:[{columnIndex:0,expression:""}]},sql:"",data:[]},N={id:wr(),cards:[S],activeCardId:S.id};return y&&(a(y,N),l(N.id)),b!=null&&b.openVisualEditor&&(d(N),f(S),h(S.id),c(!0)),N}return{handleAddNewFrame:m,canAddFrame:e||!((g=s==null?void 0:s.frames)!=null&&g.length)}}function tAe({sheetId:e}){const{handleAddNewFrame:t}=Aq(),n=te(s=>s.themeStyle),r=()=>{t({openVisualEditor:!0,sheetId:e})};return u.jsx("div",{className:"flex h-full min-h-[400px] items-start justify-start p-4",children:u.jsxs("button",{onClick:r,style:{borderRadius:n==null?void 0:n.cardBorderRadius},className:"group flex h-96 w-[600px] flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed border-muted-foreground/25 bg-background transition-all hover:border-muted-foreground/50 hover:bg-muted/50",children:[u.jsx("div",{className:"rounded-full bg-primary/10 p-3 transition-colors group-hover:bg-primary/20",children:u.jsx(gr,{className:"h-6 w-6 text-primary"})}),u.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Add new Visual"})]})})}function Y0(e){const t=(e||"").toLowerCase(),n=Jl(t);return n==="string"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-blue-100 text-xs text-blue-700 dark:bg-blue-950 dark:text-blue-300",children:u.jsx(B$,{className:"h-3 w-3"})}):n==="number"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-green-100 text-xs text-green-700 dark:bg-green-950 dark:text-green-300",children:u.jsx(_$,{className:"h-3 w-3"})}):n==="date"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-purple-100 text-xs text-purple-700 dark:bg-purple-950 dark:text-purple-300",children:u.jsx(to,{className:"h-3 w-3"})}):n==="boolean"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-orange-100 text-xs text-orange-700 dark:bg-orange-950 dark:text-orange-300",children:u.jsx(L$,{className:"h-3 w-3"})}):n==="json"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-gray-100 text-xs text-gray-700 dark:bg-gray-950 dark:text-gray-300",children:u.jsx(w$,{className:"h-3 w-3"})}):n==="geo"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-orange-100 text-xs text-orange-700 dark:bg-orange-950 dark:text-orange-300",children:u.jsx(dte,{className:"h-3 w-3"})}):n==="calculated"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-gray-100 text-xs text-gray-700 dark:bg-gray-950 dark:text-gray-300",children:u.jsx(l$,{className:"h-3 w-3"})}):null}function nAe({value:e,onChange:t,metrics:n,attributes:r}){const s=(o,i)=>(e==null?void 0:e.field.id)===o.id&&(e==null?void 0:e.type)===i;return u.jsx(si,{children:u.jsxs("div",{className:"space-y-4",children:[n.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Metric"}),u.jsxs(qr,{children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 text-muted-foreground"})}),u.jsxs(fs,{className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures intersection of all dimensions"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: Clicking a bar segment in "Sales by Country, stacked by State" captures both Country='USA' AND State='California'`})]})]})]}),u.jsx("div",{className:"space-y-1",children:n.map(o=>{const i=s(o,"metric");return u.jsxs(ie,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"metric",field:o}),children:[i&&u.jsx(_r,{className:"mr-2 h-4 w-4"}),Y0(o.dataType),u.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),r.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Attribute"}),u.jsxs(qr,{children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 text-muted-foreground"})}),u.jsxs(fs,{className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures only this dimension"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: If configured on "State", clicking a bar in "Sales by Country, stacked by State" captures only State='California' (Country is not included)`})]})]})]}),u.jsx("div",{className:"space-y-1",children:r.map(o=>{const i=s(o,"attribute");return u.jsxs(ie,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"attribute",field:o}),children:[i&&u.jsx(_r,{className:"mr-2 h-4 w-4"}),Y0(o.dataType),u.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),n.length===0&&r.length===0&&u.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No metrics or attributes available in this chart"})]})})}const NF=[{value:"clickFilter",label:"Cross filter",description:"Filter other cards on the dashboard"},{value:"drillDown",label:"Drill down",description:"Navigate through a hierarchy of dimensions"},{value:"dynamicDrill",label:"Explore dimensions",description:"Let users explore any dimension dynamically"},{value:"drillThrough",label:"Drill into dashboard",description:"Navigate to another dashboard"},{value:"drillToDetail",label:"Drill into insight",description:"Navigate to a saved insight"},{value:"drillToURL",label:"Drill into URL",description:"Navigate to a custom URL"}];function rAe({value:e,onChange:t}){const n=NF.find(r=>r.value===e);return u.jsx("div",{className:"space-y-2",children:u.jsxs(pt,{value:e,onValueChange:t,children:[u.jsx(dt,{className:"w-full",children:u.jsx(bt,{placeholder:"Choose action...",children:n&&u.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const r=q0(n.value);return u.jsx(r,{className:"h-4 w-4"})})(),u.jsx("span",{children:n.label})]})})}),u.jsx(ft,{children:NF.map(r=>{const s=q0(r.value);return u.jsx(be,{value:r.value,children:u.jsxs("div",{className:"flex items-start gap-2 py-1",children:[u.jsx(s,{className:"mt-0.5 h-4 w-4 shrink-0"}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:r.label}),u.jsx("span",{className:"text-xs text-muted-foreground",children:r.description})]})]})},r.value)})})]})})}function sAe({interaction:e,onUpdate:t}){const[n,r]=C.useState(""),s=E3(),o=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",i=d=>{const f={};switch(d){case"all-cards":f.applyToCardIds=void 0,f.excludeCardIds=void 0;break;case"specific-cards":f.applyToCardIds=[],f.excludeCardIds=void 0;break;case"all-except-specific":f.applyToCardIds=void 0,f.excludeCardIds=[];break}t({...e,...f})},a=(d,f)=>{if(f==="specific-cards"){const h=e.applyToCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,applyToCardIds:p})}else if(f==="all-except-specific"){const h=e.excludeCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,excludeCardIds:p})}},l=C.useMemo(()=>{if(!n.trim())return s;const d=n.toLowerCase();return s==null?void 0:s.filter(f=>{var h;return(h=f==null?void 0:f.title)==null?void 0:h.toLowerCase().includes(d)})},[n,s]),c=o();return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Filter scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),u.jsxs(ni,{value:c,onValueChange:d=>i(d),className:"space-y-2",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),c==="specific-cards"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Cards to filter"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.applyToCardIds||[]).includes(d.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"specific-cards")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&u.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):u.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),c==="all-except-specific"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Cards to exclude"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.excludeCardIds||[]).includes(d.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-exclude-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"all-except-specific")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-exclude-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&u.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):u.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:d=>t({...e,label:d.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}var gM="Collapsible",[oAe,Pq]=yr(gM),[iAe,bM]=oAe(gM),Oq=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...a}=e,[l=!1,c]=Mr({prop:r,defaultProp:s,onChange:i});return u.jsx(iAe,{scope:n,disabled:o,contentId:Gn(),open:l,onOpenToggle:E.useCallback(()=>c(d=>!d),[c]),children:u.jsx(Re.div,{"data-state":wM(l),"data-disabled":o?"":void 0,...a,ref:t})})});Oq.displayName=gM;var Fq="CollapsibleTrigger",yM=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,s=bM(Fq,n);return u.jsx(Re.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":wM(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:t,onClick:we(e.onClick,s.onOpenToggle)})});yM.displayName=Fq;var xM="CollapsibleContent",vM=E.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=bM(xM,e.__scopeCollapsible);return u.jsx(Zn,{present:n||s.open,children:({present:o})=>u.jsx(aAe,{...r,ref:t,present:o})})});vM.displayName=xM;var aAe=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:s,...o}=e,i=bM(xM,n),[a,l]=E.useState(r),c=E.useRef(null),d=at(t,c),f=E.useRef(0),h=f.current,p=E.useRef(0),m=p.current,g=i.open||a,b=E.useRef(g),y=E.useRef(void 0);return E.useEffect(()=>{const x=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(x)},[]),Dr(()=>{const x=c.current;if(x){y.current=y.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const v=x.getBoundingClientRect();f.current=v.height,p.current=v.width,b.current||(x.style.transitionDuration=y.current.transitionDuration,x.style.animationName=y.current.animationName),l(r)}},[i.open,r]),u.jsx(Re.div,{"data-state":wM(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&s})});function wM(e){return e?"open":"closed"}var $q=Oq,lAe=yM,cAe=vM;const zu=$q,Bu=yM,Vu=vM;function uAe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return C.useMemo(()=>r=>{t.forEach(s=>s(r))},t)}const s1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Rh(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function SM(e){return"nodeType"in e}function hs(e){var t,n;return e?Rh(e)?e:SM(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function CM(e){const{Document:t}=hs(e);return e instanceof t}function hb(e){return Rh(e)?!1:e instanceof hs(e).HTMLElement}function Lq(e){return e instanceof hs(e).SVGElement}function Ih(e){return e?Rh(e)?e.document:SM(e)?CM(e)?e:hb(e)||Lq(e)?e.ownerDocument:document:document:document}const ii=s1?C.useLayoutEffect:C.useEffect;function o1(e){const t=C.useRef(e);return ii(()=>{t.current=e}),C.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}function dAe(){const e=C.useRef(null),t=C.useCallback((r,s)=>{e.current=setInterval(r,s)},[]),n=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Jm(e,t){t===void 0&&(t=[e]);const n=C.useRef(e);return ii(()=>{n.current!==e&&(n.current=e)},t),n}function pb(e,t){const n=C.useRef();return C.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function G0(e){const t=o1(e),n=C.useRef(null),r=C.useCallback(s=>{s!==n.current&&(t==null||t(s,n.current)),n.current=s},[]);return[n,r]}function Z0(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let VC={};function mb(e,t){return C.useMemo(()=>{if(t)return t;const n=VC[e]==null?0:VC[e]+1;return VC[e]=n,e+"-"+n},[e,t])}function zq(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((o,i)=>{const a=Object.entries(i);for(const[l,c]of a){const d=o[l];d!=null&&(o[l]=d+e*c)}return o},{...t})}}const uf=zq(1),eg=zq(-1);function fAe(e){return"clientX"in e&&"clientY"in e}function i1(e){if(!e)return!1;const{KeyboardEvent:t}=hs(e.target);return t&&e instanceof t}function hAe(e){if(!e)return!1;const{TouchEvent:t}=hs(e.target);return t&&e instanceof t}function K0(e){if(hAe(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return fAe(e)?{x:e.clientX,y:e.clientY}:null}const Yi=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Yi.Translate.toString(e),Yi.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),kF="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function pAe(e){return e.matches(kF)?e:e.querySelector(kF)}const mAe={display:"none"};function gAe(e){let{id:t,value:n}=e;return C.createElement("div",{id:t,style:mAe},n)}function bAe(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return C.createElement("div",{id:t,style:s,role:"status","aria-live":r,"aria-atomic":!0},n)}function yAe(){const[e,t]=C.useState("");return{announce:C.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Bq=C.createContext(null);function xAe(e){const t=C.useContext(Bq);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function vAe(){const[e]=C.useState(()=>new Set),t=C.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[C.useCallback(r=>{let{type:s,event:o}=r;e.forEach(i=>{var a;return(a=i[s])==null?void 0:a.call(i,o)})},[e]),t]}const wAe={draggable:`
910
+ `)),[]});var nRe=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(nRe||{});function rRe(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function sRe(e,t,n,r){let[s,o]=C.useState(n),{hasFlag:i,addFlag:a,removeFlag:l}=tRe(e&&s?3:0),c=C.useRef(!1),d=C.useRef(!1),f=cb();return Bn(()=>{var h;if(e){if(n&&o(!0),!t){n&&a(3);return}return(h=void 0)==null||h.call(r,n),oRe(t,{inFlight:c,prepare(){d.current?d.current=!1:d.current=c.current,c.current=!0,!d.current&&(n?(a(3),l(4)):(a(4),l(2)))},run(){d.current?n?(l(3),a(4)):(l(4),a(3)):n?l(1):a(1)},done(){var p;d.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(c.current=!1,l(7),n||o(!1),(p=void 0)==null||p.call(r,n))}})}},[e,n,t,f]),e?[s,{closed:i(1),enter:i(2),leave:i(4),transition:i(2)||i(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function oRe(e,{prepare:t,run:n,done:r,inFlight:s}){let o=qi();return aRe(e,{prepare:t,inFlight:s}),o.nextFrame(()=>{n(),o.requestAnimationFrame(()=>{o.add(iRe(e,r))})}),o.dispose}function iRe(e,t){var n,r;let s=qi();if(!e)return s.dispose;let o=!1;s.add(()=>{o=!0});let i=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(a=>a instanceof CSSTransition))!=null?r:[];return i.length===0?(t(),s.dispose):(Promise.allSettled(i.map(a=>a.finished)).then(()=>{o||t()}),s.dispose)}function aRe(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function lRe(e,{container:t,accept:n,walk:r}){let s=C.useRef(n),o=C.useRef(r);C.useEffect(()=>{s.current=n,o.current=r},[n,r]),Bn(()=>{if(!t||!e)return;let i=lb(t);if(!i)return;let a=s.current,l=o.current,c=Object.assign(f=>a(f),{acceptNode:a}),d=i.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,c,!1);for(;d.nextNode();)l(d.currentNode)},[t,e,s,o])}function pF(e,t){let n=C.useRef([]),r=yt(e);C.useEffect(()=>{let s=[...n.current];for(let[o,i]of t.entries())if(n.current[o]!==i){let a=r(t,s);return n.current=t,a}},[r,...t])}function cRe(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}const bq={...E},uRe=bq.useInsertionEffect,dRe=uRe||(e=>e());function yq(e){const t=E.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return dRe(()=>{t.current=e}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}var Gk=typeof document<"u"?C.useLayoutEffect:C.useEffect;let mF=!1,fRe=0;const gF=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+fRe++;function hRe(){const[e,t]=E.useState(()=>mF?gF():void 0);return Gk(()=>{e==null&&t(gF())},[]),E.useEffect(()=>{mF=!0},[]),e}const pRe=bq.useId,mRe=pRe||hRe;let Km;process.env.NODE_ENV!=="production"&&(Km=new Set);function gRe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Km)!=null&&e.has(s))){var o;(o=Km)==null||o.add(s),console.warn(s)}}function bRe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Km)!=null&&e.has(s))){var o;(o=Km)==null||o.add(s),console.error(s)}}function yRe(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(s=>s(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(s=>s!==n))||[])}}}const xRe=E.createContext(null),vRe=E.createContext(null),wRe=()=>{var e;return((e=E.useContext(xRe))==null?void 0:e.id)||null},SRe=()=>E.useContext(vRe),CRe="data-floating-ui-focusable";function NRe(e){const{open:t=!1,onOpenChange:n,elements:r}=e,s=mRe(),o=E.useRef({}),[i]=E.useState(()=>yRe()),a=wRe()!=null;if(process.env.NODE_ENV!=="production"){const p=r.reference;p&&!Br(p)&&bRe("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[l,c]=E.useState(r.reference),d=yq((p,m,g)=>{o.current.openEvent=p?m:void 0,i.emit("openchange",{open:p,event:m,reason:g,nested:a}),n==null||n(p,m,g)}),f=E.useMemo(()=>({setPositionReference:c}),[]),h=E.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return E.useMemo(()=>({dataRef:o,open:t,onOpenChange:d,elements:h,events:i,floatingId:s,refs:f}),[t,d,h,i,s,f])}function kRe(e){e===void 0&&(e={});const{nodeId:t}=e,n=NRe({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,s=r.elements,[o,i]=E.useState(null),[a,l]=E.useState(null),d=(s==null?void 0:s.domReference)||o,f=E.useRef(null),h=SRe();Gk(()=>{d&&(f.current=d)},[d]);const p=Ez({...e,elements:{...s,...a&&{reference:a}}}),m=E.useCallback(v=>{const w=Br(v)?{getBoundingClientRect:()=>v.getBoundingClientRect(),contextElement:v}:v;l(w),p.refs.setReference(w)},[p.refs]),g=E.useCallback(v=>{(Br(v)||v===null)&&(f.current=v,i(v)),(Br(p.refs.reference.current)||p.refs.reference.current===null||v!==null&&!Br(v))&&p.refs.setReference(v)},[p.refs]),b=E.useMemo(()=>({...p.refs,setReference:g,setPositionReference:m,domReference:f}),[p.refs,g,m]),y=E.useMemo(()=>({...p.elements,domReference:d}),[p.elements,d]),x=E.useMemo(()=>({...p,...r,refs:b,elements:y,nodeId:t}),[p,b,y,t,r]);return Gk(()=>{r.dataRef.current.floatingContext=x;const v=h==null?void 0:h.nodesRef.current.find(w=>w.id===t);v&&(v.context=x)}),E.useMemo(()=>({...p,context:x,refs:b,elements:y}),[p,b,y,x])}const bF="active",yF="selected";function LC(e,t,n){const r=new Map,s=n==="item";let o=e;if(s&&e){const{[bF]:i,[yF]:a,...l}=e;o=l}return{...n==="floating"&&{tabIndex:-1,[CRe]:""},...o,...t.map(i=>{const a=i?i[n]:null;return typeof a=="function"?e?a(e):null:a}).concat(e).reduce((i,a)=>(a&&Object.entries(a).forEach(l=>{let[c,d]=l;if(!(s&&[bF,yF].includes(c)))if(c.indexOf("on")===0){if(r.has(c)||r.set(c,[]),typeof d=="function"){var f;(f=r.get(c))==null||f.push(d),i[c]=function(){for(var h,p=arguments.length,m=new Array(p),g=0;g<p;g++)m[g]=arguments[g];return(h=r.get(c))==null?void 0:h.map(b=>b(...m)).find(b=>b!==void 0)}}}else i[c]=d}),i),{})}}function ERe(e){e===void 0&&(e=[]);const t=e.map(a=>a==null?void 0:a.reference),n=e.map(a=>a==null?void 0:a.floating),r=e.map(a=>a==null?void 0:a.item),s=E.useCallback(a=>LC(a,e,"reference"),t),o=E.useCallback(a=>LC(a,e,"floating"),n),i=E.useCallback(a=>LC(a,e,"item"),r);return E.useMemo(()=>({getReferenceProps:s,getFloatingProps:o,getItemProps:i}),[s,o,i])}function xF(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const jRe=e=>({name:"inner",options:e,async fn(t){const{listRef:n,overflowRef:r,onFallbackChange:s,offset:o=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:l=0,scrollRef:c,...d}=Vi(e,t),{rects:f,elements:{floating:h}}=t,p=n.current[i],m=(c==null?void 0:c.current)||h,g=h.clientTop||m.clientTop,b=h.clientTop!==0,y=m.clientTop!==0,x=h===m;if(process.env.NODE_ENV!=="production"&&(t.placement.startsWith("bottom")||gRe('`placement` side must be "bottom" when using the `inner`',"middleware.")),!p)return{};const v={...t,...await l_(-p.offsetTop-h.clientTop-f.reference.height/2-p.offsetHeight/2-o).fn(t)},w=await MS(xF(v,m.scrollHeight+g+h.clientTop),d),S=await MS(v,{...d,elementContext:"reference"}),N=zr(0,w.top),k=v.y+N,D=(m.scrollHeight>m.clientHeight?M=>M:Nm)(zr(0,m.scrollHeight+(b&&x||y?g*2:0)-N-zr(0,w.bottom)));if(m.style.maxHeight=D+"px",m.scrollTop=N,s){const M=m.offsetHeight<p.offsetHeight*Va(a,n.current.length)-1||S.top>=-l||S.bottom>=-l;Fl.flushSync(()=>s(M))}return r&&(r.current=await MS(xF({...v,y:k},m.offsetHeight+g+h.clientTop),d)),{y:k}}});function _Re(e,t){const{open:n,elements:r}=e,{enabled:s=!0,overflowRef:o,scrollRef:i,onChange:a}=t,l=yq(a),c=E.useRef(!1),d=E.useRef(null),f=E.useRef(null);E.useEffect(()=>{if(!s)return;function p(g){if(g.ctrlKey||!m||o.current==null)return;const b=g.deltaY,y=o.current.top>=-.5,x=o.current.bottom>=-.5,v=m.scrollHeight-m.clientHeight,w=b<0?-1:1,S=b<0?"max":"min";m.scrollHeight<=m.clientHeight||(!y&&b>0||!x&&b<0?(g.preventDefault(),Fl.flushSync(()=>{l(N=>N+Math[S](b,v*w))})):/firefox/i.test(cRe())&&(m.scrollTop+=b))}const m=(i==null?void 0:i.current)||r.floating;if(n&&m)return m.addEventListener("wheel",p),requestAnimationFrame(()=>{d.current=m.scrollTop,o.current!=null&&(f.current={...o.current})}),()=>{d.current=null,f.current=null,m.removeEventListener("wheel",p)}},[s,n,r.floating,o,i,l]);const h=E.useMemo(()=>({onKeyDown(){c.current=!0},onWheel(){c.current=!1},onPointerMove(){c.current=!1},onScroll(){const p=(i==null?void 0:i.current)||r.floating;if(!(!o.current||!p||!c.current)){if(d.current!==null){const m=p.scrollTop-d.current;(o.current.bottom<-.5&&m<-1||o.current.top<-.5&&m>1)&&Fl.flushSync(()=>l(g=>g+m))}requestAnimationFrame(()=>{d.current=p.scrollTop})}}}),[r.floating,l,o,i]);return E.useMemo(()=>s?{floating:h}:{},[s,h])}let ub=C.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});ub.displayName="FloatingContext";let cM=C.createContext(null);cM.displayName="PlacementContext";function DRe(e){return C.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function MRe(){return C.useContext(ub).setReference}function TRe(){let{getFloatingProps:e,slot:t}=C.useContext(ub);return C.useCallback((...n)=>Object.assign({},e(...n),{"data-anchor":t.anchor}),[e,t])}function RRe(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=C.useContext(cM),n=C.useMemo(()=>e,[JSON.stringify(e,(s,o)=>{var i;return(i=o==null?void 0:o.outerHTML)!=null?i:o})]);Bn(()=>{t==null||t(n??null)},[t,n]);let r=C.useContext(ub);return C.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let vF=4;function IRe({children:e,enabled:t=!0}){let[n,r]=C.useState(null),[s,o]=C.useState(0),i=C.useRef(null),[a,l]=C.useState(null);ARe(a);let c=t&&n!==null&&a!==null,{to:d="bottom",gap:f=0,offset:h=0,padding:p=0,inner:m}=PRe(n,a),[g,b="center"]=d.split(" ");Bn(()=>{c&&o(0)},[c]);let{refs:y,floatingStyles:x,context:v}=kRe({open:c,placement:g==="selection"?b==="center"?"bottom":`bottom-${b}`:b==="center"?`${g}`:`${g}-${b}`,strategy:"absolute",transform:!1,middleware:[l_({mainAxis:g==="selection"?0:f,crossAxis:h}),jz({padding:p}),g!=="selection"&&_z({padding:p}),g==="selection"&&m?jRe({...m,padding:p,overflowRef:i,offset:s,minItemsVisible:vF,referenceOverflowThreshold:p,onFallbackChange(M){var T,O;if(!M)return;let A=v.elements.floating;if(!A)return;let P=parseFloat(getComputedStyle(A).scrollPaddingBottom)||0,F=Math.min(vF,A.childElementCount),V=0,U=0;for(let z of(O=(T=v.elements.floating)==null?void 0:T.childNodes)!=null?O:[])if(z instanceof HTMLElement){let I=z.offsetTop,B=I+z.clientHeight+P,L=A.scrollTop,R=L+A.clientHeight;if(I>=L&&B<=R)F--;else{U=Math.max(0,Math.min(B,R)-Math.max(I,L)),V=z.clientHeight;break}}F>=1&&o(z=>{let I=V*F-U+P;return z>=I?z:I})}}):null,Dz({padding:p,apply({availableWidth:M,availableHeight:T,elements:O}){Object.assign(O.floating.style,{overflow:"auto",maxWidth:`${M}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${T}px)`})}})].filter(Boolean),whileElementsMounted:Nz}),[w=g,S=b]=v.placement.split("-");g==="selection"&&(w="selection");let N=C.useMemo(()=>({anchor:[w,S].filter(Boolean).join(" ")}),[w,S]),k=_Re(v,{overflowRef:i,onChange:o}),{getReferenceProps:j,getFloatingProps:_}=ERe([k]),D=yt(M=>{l(M),y.setFloating(M)});return E.createElement(cM.Provider,{value:r},E.createElement(ub.Provider,{value:{setFloating:D,setReference:y.setReference,styles:x,getReferenceProps:j,getFloatingProps:_,slot:N}},e))}function ARe(e){Bn(()=>{if(!e)return;let t=new MutationObserver(()=>{let n=window.getComputedStyle(e).maxHeight,r=parseFloat(n);if(isNaN(r))return;let s=parseInt(n);isNaN(s)||r!==s&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function PRe(e,t){var n,r,s;let o=zC((n=e==null?void 0:e.gap)!=null?n:"var(--anchor-gap, 0)",t),i=zC((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),a=zC((s=e==null?void 0:e.padding)!=null?s:"var(--anchor-padding, 0)",t);return{...e,gap:o,offset:i,padding:a}}function zC(e,t,n=void 0){let r=cb(),s=yt((l,c)=>{if(l==null)return[n,null];if(typeof l=="number")return[l,null];if(typeof l=="string"){if(!c)return[n,null];let d=wF(l,c);return[d,f=>{let h=xq(l);{let p=h.map(m=>window.getComputedStyle(c).getPropertyValue(m));r.requestAnimationFrame(function m(){r.nextFrame(m);let g=!1;for(let[y,x]of h.entries()){let v=window.getComputedStyle(c).getPropertyValue(x);if(p[y]!==v){p[y]=v,g=!0;break}}if(!g)return;let b=wF(l,c);d!==b&&(f(b),d=b)})}return r.dispose}]}return[n,null]}),o=C.useMemo(()=>s(e,t)[0],[e,t]),[i=o,a]=C.useState();return Bn(()=>{let[l,c]=s(e,t);if(a(l),!!c)return c(a)},[e,t]),i}function xq(e){let t=/var\((.*)\)/.exec(e);if(t){let n=t[1].indexOf(",");if(n===-1)return[t[1]];let r=t[1].slice(0,n).trim(),s=t[1].slice(n+1).trim();return s?[r,...xq(s)]:[r]}return[]}function wF(e,t){let n=document.createElement("div");t.appendChild(n),n.style.setProperty("margin-top","0px","important"),n.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(n).marginTop)||0;return t.removeChild(n),r}function ORe({children:e,freeze:t}){let n=Zk(t,e);return C.createElement(C.Fragment,null,n)}function Zk(e,t){let[n,r]=C.useState(t);return!e&&n!==t&&r(t),e?n:t}let uM=C.createContext(null);uM.displayName="OpenClosedContext";var Xm=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Xm||{});function FRe(){return C.useContext(uM)}function $Re({value:e,children:t}){return C.createElement(uM.Provider,{value:e},t)}function LRe(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Fc=[];LRe(()=>{function e(t){if(!(t.target instanceof HTMLElement)||t.target===document.body||Fc[0]===t.target)return;let n=t.target;n=n.closest(Yk),Fc.unshift(n??t.target),Fc=Fc.filter(r=>r!=null&&r.isConnected),Fc.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function zRe(e){throw new Error("Unexpected object: "+e)}var ir=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(ir||{});function SF(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),s=r??-1;switch(e.focus){case 0:{for(let o=0;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 1:{s===-1&&(s=n.length);for(let o=s-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 2:{for(let o=s+1;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 3:{for(let o=n.length-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 4:{for(let o=0;o<n.length;++o)if(t.resolveId(n[o],o,n)===e.id)return o;return r}case 5:return null;default:zRe(e)}}var dM=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(dM||{});function BRe(e){let t=yt(e),n=C.useRef(!1);C.useEffect(()=>(n.current=!1,()=>{n.current=!0,eq(()=>{n.current&&t()})}),[t])}function VRe(){let e=typeof document>"u";return"useSyncExternalStore"in E?(t=>t.useSyncExternalStore)(E)(()=>()=>{},()=>!1,()=>!e):!1}function HRe(){let e=VRe(),[t,n]=E.useState(xu.isHandoffComplete);return t&&xu.isHandoffComplete===!1&&n(!1),E.useEffect(()=>{t!==!0&&n(!0)},[t]),E.useEffect(()=>xu.handoff(),[]),e?!1:t}let URe=C.createContext(!1);function WRe(){return C.useContext(URe)}function qRe(e){let t=WRe(),n=C.useContext(wq),r=r1(e),[s,o]=C.useState(()=>{var i;if(!t&&n!==null)return(i=n.current)!=null?i:null;if(xu.isServer)return null;let a=r==null?void 0:r.getElementById("headlessui-portal-root");if(a)return a;if(r===null)return null;let l=r.createElement("div");return l.setAttribute("id","headlessui-portal-root"),r.body.appendChild(l)});return C.useEffect(()=>{s!==null&&(r!=null&&r.body.contains(s)||r==null||r.body.appendChild(s))},[s,r]),C.useEffect(()=>{t||n!==null&&o(n.current)},[n,o,t]),s}let vq=C.Fragment,YRe=hi(function(e,t){let n=e,r=C.useRef(null),s=Qa(lTe(f=>{r.current=f}),t),o=r1(r),i=qRe(r),[a]=C.useState(()=>{var f;return xu.isServer?null:(f=o==null?void 0:o.createElement("div"))!=null?f:null}),l=C.useContext(XRe),c=HRe();Bn(()=>{!i||!a||i.contains(a)||(a.setAttribute("data-headlessui-portal",""),i.appendChild(a))},[i,a]),Bn(()=>{if(a&&l)return l.register(a)},[l,a]),BRe(()=>{var f;!i||!a||(a instanceof Node&&i.contains(a)&&i.removeChild(a),i.childNodes.length<=0&&((f=i.parentElement)==null||f.removeChild(i)))});let d=fi();return c?!i||!a?null:_n.createPortal(d({ourProps:{ref:s},theirProps:n,slot:{},defaultTag:vq,name:"Portal"}),a):null});function GRe(e,t){let n=Qa(t),{enabled:r=!0,...s}=e,o=fi();return r?C.createElement(YRe,{...s,ref:n}):o({ourProps:{ref:n},theirProps:s,slot:{},defaultTag:vq,name:"Portal"})}let ZRe=C.Fragment,wq=C.createContext(null);function KRe(e,t){let{target:n,...r}=e,s={ref:Qa(t)},o=fi();return C.createElement(wq.Provider,{value:n},o({ourProps:s,theirProps:r,defaultTag:ZRe,name:"Popover.Group"}))}let XRe=C.createContext(null),QRe=hi(GRe),JRe=hi(KRe),eIe=Object.assign(QRe,{Group:JRe});var tIe=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(tIe||{}),nIe=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(nIe||{}),rIe=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(rIe||{}),sIe=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.SetActivationTrigger=6]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=7]="UpdateVirtualConfiguration",e[e.SetInputElement=8]="SetInputElement",e[e.SetButtonElement=9]="SetButtonElement",e[e.SetOptionsElement=10]="SetOptionsElement",e))(sIe||{});function BC(e,t=n=>n){let n=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=t(e.options.slice()),s=r.length>0&&r[0].dataRef.current.order!==null?r.sort((i,a)=>i.dataRef.current.order-a.dataRef.current.order):VTe(r,i=>i.dataRef.current.domRef.current),o=n?s.indexOf(n):null;return o===-1&&(o=null),{options:s,activeOptionIndex:o}}let oIe={1(e){var t;return(t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1?e:{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let r=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(r!==-1)return{...e,activeOptionIndex:r,comboboxState:0,__demoMode:!1}}return{...e,comboboxState:0,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r,s,o;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:c,disabled:d}=e.virtual,f=t.focus===ir.Specific?t.idx:SF(t,{resolveItems:()=>c,resolveActiveIndex:()=>{var p,m;return(m=(p=e.activeOptionIndex)!=null?p:c.findIndex(g=>!d(g)))!=null?m:null},resolveDisabled:d,resolveId(){throw new Error("Function not implemented.")}}),h=(s=t.trigger)!=null?s:2;return e.activeOptionIndex===f&&e.activationTrigger===h?e:{...e,activeOptionIndex:f,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=BC(e);if(i.activeOptionIndex===null){let c=i.options.findIndex(d=>!d.dataRef.current.disabled);c!==-1&&(i.activeOptionIndex=c)}let a=t.focus===ir.Specific?t.idx:SF(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:c=>c.id,resolveDisabled:c=>c.dataRef.current.disabled}),l=(o=t.trigger)!=null?o:2;return e.activeOptionIndex===a&&e.activationTrigger===l?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:l,__demoMode:!1}},4:(e,t)=>{var n,r,s;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let o=t.payload,i=BC(e,l=>(l.push(o),l));e.activeOptionIndex===null&&(r=e.dataRef.current)!=null&&r.isSelected(t.payload.dataRef.current.value)&&(i.activeOptionIndex=i.options.indexOf(o));let a={...e,...i,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(a.activeOptionIndex=0),a},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(s=>s.id!==t.id)};let r=BC(e,s=>{let o=s.findIndex(i=>i.id===t.id);return o!==-1&&s.splice(o,1),s});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},7:(e,t)=>{var n,r;if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:(n=t.disabled)!=null?n:()=>!1}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let s=e.activeOptionIndex;if(e.activeOptionIndex!==null){let o=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);o!==-1?s=o:s=null}return{...e,activeOptionIndex:s,virtual:{options:t.options,disabled:(r=t.disabled)!=null?r:()=>!1}}},8:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},9:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},10:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element}},fM=C.createContext(null);fM.displayName="ComboboxActionsContext";function db(e){let t=C.useContext(fM);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,db),n}return t}let Sq=C.createContext(null);function iIe(e){let t=Th("VirtualProvider"),{options:n}=t.virtual,[r,s]=C.useMemo(()=>{let c=t.optionsElement;if(!c)return[0,0];let d=window.getComputedStyle(c);return[parseFloat(d.paddingBlockStart||d.paddingTop),parseFloat(d.paddingBlockEnd||d.paddingBottom)]},[t.optionsElement]),o=DTe({enabled:n.length!==0,scrollPaddingStart:r,scrollPaddingEnd:s,count:n.length,estimateSize(){return 40},getScrollElement(){return t.optionsElement},overscan:12}),[i,a]=C.useState(0);Bn(()=>{a(c=>c+1)},[n]);let l=o.getVirtualItems();return l.length===0?null:C.createElement(Sq.Provider,{value:o},C.createElement("div",{style:{position:"relative",width:"100%",height:`${o.getTotalSize()}px`},ref:c=>{c&&t.activationTrigger!==0&&t.activeOptionIndex!==null&&n.length>t.activeOptionIndex&&o.scrollToIndex(t.activeOptionIndex)}},l.map(c=>{var d;return C.createElement(C.Fragment,{key:c.key},C.cloneElement((d=e.children)==null?void 0:d.call(e,{...e.slot,option:n[c.index]}),{key:`${i}-${c.key}`,"data-index":c.index,"aria-setsize":n.length,"aria-posinset":c.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${c.start}px)`,overflowAnchor:"none"}}))})))}let Qm=C.createContext(null);Qm.displayName="ComboboxDataContext";function Th(e){let t=C.useContext(Qm);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Th),n}return t}function aIe(e,t){return Oa(t.type,oIe,e,t)}let lIe=C.Fragment;function cIe(e,t){var n,r;let s=sM(),{value:o,defaultValue:i,onChange:a,form:l,name:c,by:d,disabled:f=s||!1,onClose:h,__demoMode:p=!1,multiple:m=!1,immediate:g=!1,virtual:b=null,nullable:y,...x}=e,v=QMe(i),[w=m?[]:void 0,S]=XMe(o,a,v),[N,k]=C.useReducer(aIe,{dataRef:C.createRef(),comboboxState:p?0:1,isTyping:!1,options:[],virtual:b?{options:b.options,disabled:(n=b.disabled)!=null?n:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:p}),j=C.useRef(!1),_=C.useRef({static:!1,hold:!1}),D=TTe(d),M=yt(oe=>b?d===null?b.options.indexOf(oe):b.options.findIndex(de=>D(de,oe)):N.options.findIndex(de=>D(de.dataRef.current.value,oe))),T=C.useCallback(oe=>Oa(A.mode,{1:()=>w.some(de=>D(de,oe)),0:()=>D(w,oe)}),[w]),O=yt(oe=>N.activeOptionIndex===M(oe)),A=C.useMemo(()=>({...N,immediate:g,optionsPropsRef:_,value:w,defaultValue:v,disabled:f,mode:m?1:0,virtual:b?N.virtual:null,get activeOptionIndex(){if(j.current&&N.activeOptionIndex===null&&(b?b.options.length>0:N.options.length>0)){if(b){let de=b.options.findIndex(le=>{var ke,ye;return!((ye=(ke=b.disabled)==null?void 0:ke.call(b,le))!=null&&ye)});if(de!==-1)return de}let oe=N.options.findIndex(de=>!de.dataRef.current.disabled);if(oe!==-1)return oe}return N.activeOptionIndex},calculateIndex:M,compare:D,isSelected:T,isActive:O}),[w,v,f,m,p,N,b]);Bn(()=>{var oe;b&&k({type:7,options:b.options,disabled:(oe=b.disabled)!=null?oe:null})},[b,b==null?void 0:b.options,b==null?void 0:b.disabled]),Bn(()=>{N.dataRef.current=A},[A]);let P=A.comboboxState===0;WTe(P,[A.buttonElement,A.inputElement,A.optionsElement],()=>$.closeCombobox());let F=C.useMemo(()=>{var oe,de,le;return{open:A.comboboxState===0,disabled:f,activeIndex:A.activeOptionIndex,activeOption:A.activeOptionIndex===null?null:A.virtual?A.virtual.options[(oe=A.activeOptionIndex)!=null?oe:0]:(le=(de=A.options[A.activeOptionIndex])==null?void 0:de.dataRef.current.value)!=null?le:null,value:w}},[A,f,w]),V=yt(()=>{if(A.activeOptionIndex!==null){if($.setIsTyping(!1),A.virtual)R(A.virtual.options[A.activeOptionIndex]);else{let{dataRef:oe}=A.options[A.activeOptionIndex];R(oe.current.value)}$.goToOption(ir.Specific,A.activeOptionIndex)}}),U=yt(()=>{k({type:0}),j.current=!0}),z=yt(()=>{k({type:1}),j.current=!1,h==null||h()}),I=yt(oe=>{k({type:3,isTyping:oe})}),B=yt((oe,de,le)=>(j.current=!1,oe===ir.Specific?k({type:2,focus:ir.Specific,idx:de,trigger:le}):k({type:2,focus:oe,trigger:le}))),L=yt((oe,de)=>(k({type:4,payload:{id:oe,dataRef:de}}),()=>{A.isActive(de.current.value)&&(j.current=!0),k({type:5,id:oe})})),R=yt(oe=>Oa(A.mode,{0(){return S==null?void 0:S(oe)},1(){let de=A.value.slice(),le=de.findIndex(ke=>D(ke,oe));return le===-1?de.push(oe):de.splice(le,1),S==null?void 0:S(de)}})),W=yt(oe=>{k({type:6,trigger:oe})}),Y=yt(oe=>{k({type:8,element:oe})}),Z=yt(oe=>{k({type:9,element:oe})}),H=yt(oe=>{k({type:10,element:oe})}),$=C.useMemo(()=>({onChange:R,registerOption:L,goToOption:B,setIsTyping:I,closeCombobox:z,openCombobox:U,setActivationTrigger:W,selectActiveOption:V,setInputElement:Y,setButtonElement:Z,setOptionsElement:H}),[]),[q,G]=hTe(),ee=t===null?{}:{ref:t},Q=C.useCallback(()=>{if(v!==void 0)return S==null?void 0:S(v)},[S,v]),ne=fi();return C.createElement(G,{value:q,props:{htmlFor:(r=A.inputElement)==null?void 0:r.id},slot:{open:A.comboboxState===0,disabled:f}},C.createElement(IRe,null,C.createElement(fM.Provider,{value:$},C.createElement(Qm.Provider,{value:A},C.createElement($Re,{value:Oa(A.comboboxState,{0:Xm.Open,1:Xm.Closed})},c!=null&&C.createElement(rTe,{disabled:f,data:w!=null?{[c]:w}:{},form:l,onReset:Q}),ne({ourProps:ee,theirProps:x,slot:F,defaultTag:lIe,name:"Combobox"}))))))}let uIe="input";function dIe(e,t){var n,r,s,o,i;let a=Th("Combobox.Input"),l=db("Combobox.Input"),c=C.useId(),d=iq(),{id:f=d||`headlessui-combobox-input-${c}`,onChange:h,displayValue:p,disabled:m=a.disabled||!1,autoFocus:g=!1,type:b="text",...y}=e,x=C.useRef(null),v=Qa(x,t,MRe(),l.setInputElement),w=r1(a.inputElement),S=cb(),N=yt(()=>{l.onChange(null),a.optionsElement&&(a.optionsElement.scrollTop=0),l.goToOption(ir.Nothing)}),k=C.useMemo(()=>{var R;return typeof p=="function"&&a.value!==void 0?(R=p(a.value))!=null?R:"":typeof a.value=="string"?a.value:""},[a.value,p]);pF(([R,W],[Y,Z])=>{if(a.isTyping)return;let H=x.current;H&&((Z===0&&W===1||R!==Y)&&(H.value=R),requestAnimationFrame(()=>{if(a.isTyping||!H||(w==null?void 0:w.activeElement)!==H)return;let{selectionStart:$,selectionEnd:q}=H;Math.abs((q??0)-($??0))===0&&$===0&&H.setSelectionRange(H.value.length,H.value.length)}))},[k,a.comboboxState,w,a.isTyping]),pF(([R],[W])=>{if(R===0&&W===1){if(a.isTyping)return;let Y=x.current;if(!Y)return;let Z=Y.value,{selectionStart:H,selectionEnd:$,selectionDirection:q}=Y;Y.value="",Y.value=Z,q!==null?Y.setSelectionRange(H,$,q):Y.setSelectionRange(H,$)}},[a.comboboxState]);let j=C.useRef(!1),_=yt(()=>{j.current=!0}),D=yt(()=>{S.nextFrame(()=>{j.current=!1})}),M=yt(R=>{switch(l.setIsTyping(!0),R.key){case os.Enter:if(a.comboboxState!==0||j.current)return;if(R.preventDefault(),R.stopPropagation(),a.activeOptionIndex===null){l.closeCombobox();return}l.selectActiveOption(),a.mode===0&&l.closeCombobox();break;case os.ArrowDown:return R.preventDefault(),R.stopPropagation(),Oa(a.comboboxState,{0:()=>l.goToOption(ir.Next),1:()=>l.openCombobox()});case os.ArrowUp:return R.preventDefault(),R.stopPropagation(),Oa(a.comboboxState,{0:()=>l.goToOption(ir.Previous),1:()=>{_n.flushSync(()=>l.openCombobox()),a.value||l.goToOption(ir.Last)}});case os.Home:if(R.shiftKey)break;return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.First);case os.PageUp:return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.First);case os.End:if(R.shiftKey)break;return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.Last);case os.PageDown:return R.preventDefault(),R.stopPropagation(),l.goToOption(ir.Last);case os.Escape:return a.comboboxState!==0?void 0:(R.preventDefault(),a.optionsElement&&!a.optionsPropsRef.current.static&&R.stopPropagation(),a.mode===0&&a.value===null&&N(),l.closeCombobox());case os.Tab:if(a.comboboxState!==0)return;a.mode===0&&a.activationTrigger!==1&&l.selectActiveOption(),l.closeCombobox();break}}),T=yt(R=>{h==null||h(R),a.mode===0&&R.target.value===""&&N(),l.openCombobox()}),O=yt(R=>{var W,Y,Z;let H=(W=R.relatedTarget)!=null?W:Fc.find($=>$!==R.currentTarget);if(!((Y=a.optionsElement)!=null&&Y.contains(H))&&!((Z=a.buttonElement)!=null&&Z.contains(H))&&a.comboboxState===0)return R.preventDefault(),a.mode===0&&a.value===null&&N(),l.closeCombobox()}),A=yt(R=>{var W,Y,Z;let H=(W=R.relatedTarget)!=null?W:Fc.find($=>$!==R.currentTarget);(Y=a.buttonElement)!=null&&Y.contains(H)||(Z=a.optionsElement)!=null&&Z.contains(H)||a.disabled||a.immediate&&a.comboboxState!==0&&S.microTask(()=>{_n.flushSync(()=>l.openCombobox()),l.setActivationTrigger(1)})}),P=n1(),F=cTe(),{isFocused:V,focusProps:U}=JW({autoFocus:g}),{isHovered:z,hoverProps:I}=QW({isDisabled:m}),B=C.useMemo(()=>({open:a.comboboxState===0,disabled:m,hover:z,focus:V,autofocus:g}),[a,z,V,g,m]),L=oM({ref:v,id:f,role:"combobox",type:b,"aria-controls":(n=a.optionsElement)==null?void 0:n.id,"aria-expanded":a.comboboxState===0,"aria-activedescendant":a.activeOptionIndex===null?void 0:a.virtual?(r=a.options.find(R=>!R.dataRef.current.disabled&&a.compare(R.dataRef.current.value,a.virtual.options[a.activeOptionIndex])))==null?void 0:r.id:(s=a.options[a.activeOptionIndex])==null?void 0:s.id,"aria-labelledby":P,"aria-describedby":F,"aria-autocomplete":"list",defaultValue:(i=(o=e.defaultValue)!=null?o:a.defaultValue!==void 0?p==null?void 0:p(a.defaultValue):null)!=null?i:a.defaultValue,disabled:m||void 0,autoFocus:g,onCompositionStart:_,onCompositionEnd:D,onKeyDown:M,onChange:T,onFocus:A,onBlur:O},U,I);return fi()({ourProps:L,theirProps:y,slot:B,defaultTag:uIe,name:"Combobox.Input"})}let fIe="button";function hIe(e,t){var n;let r=Th("Combobox.Button"),s=db("Combobox.Button"),o=Qa(t,s.setButtonElement),i=C.useId(),{id:a=`headlessui-combobox-button-${i}`,disabled:l=r.disabled||!1,autoFocus:c=!1,...d}=e,f=gq(r.inputElement),h=yt(k=>{switch(k.key){case os.Space:case os.Enter:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&_n.flushSync(()=>s.openCombobox()),f();return;case os.ArrowDown:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ir.First)),f();return;case os.ArrowUp:k.preventDefault(),k.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ir.Last)),f();return;case os.Escape:if(r.comboboxState!==0)return;k.preventDefault(),r.optionsElement&&!r.optionsPropsRef.current.static&&k.stopPropagation(),_n.flushSync(()=>s.closeCombobox()),f();return;default:return}}),p=yt(k=>{k.preventDefault(),!iTe(k.currentTarget)&&(k.button===dM.Left&&(r.comboboxState===0?s.closeCombobox():s.openCombobox()),f())}),m=n1([a]),{isFocusVisible:g,focusProps:b}=JW({autoFocus:c}),{isHovered:y,hoverProps:x}=QW({isDisabled:l}),{pressed:v,pressProps:w}=UMe({disabled:l}),S=C.useMemo(()=>({open:r.comboboxState===0,active:v||r.comboboxState===0,disabled:l,value:r.value,hover:y,focus:g}),[r,y,g,v,l]),N=oM({ref:o,id:a,type:YTe(e,r.buttonElement),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":(n=r.optionsElement)==null?void 0:n.id,"aria-expanded":r.comboboxState===0,"aria-labelledby":m,disabled:l||void 0,autoFocus:c,onMouseDown:p,onKeyDown:h},b,x,w);return fi()({ourProps:N,theirProps:d,slot:S,defaultTag:fIe,name:"Combobox.Button"})}let pIe="div",mIe=Wk.RenderStrategy|Wk.Static;function gIe(e,t){var n,r,s;let o=C.useId(),{id:i=`headlessui-combobox-options-${o}`,hold:a=!1,anchor:l,portal:c=!1,modal:d=!0,transition:f=!1,...h}=e,p=Th("Combobox.Options"),m=db("Combobox.Options"),g=DRe(l);g&&(c=!0);let[b,y]=RRe(g),[x,v]=C.useState(null),w=TRe(),S=Qa(t,g?b:null,m.setOptionsElement,v),N=r1(p.optionsElement),k=FRe(),[j,_]=sRe(f,x,k!==null?(k&Xm.Open)===Xm.Open:p.comboboxState===0);OTe(j,p.inputElement,m.closeCombobox);let D=p.__demoMode?!1:d&&p.comboboxState===0;JTe(D,N);let M=p.__demoMode?!1:d&&p.comboboxState===0;PTe(M,{allowed:C.useCallback(()=>[p.inputElement,p.buttonElement,p.optionsElement],[p.inputElement,p.buttonElement,p.optionsElement])}),Bn(()=>{var L;p.optionsPropsRef.current.static=(L=e.static)!=null?L:!1},[p.optionsPropsRef,e.static]),Bn(()=>{p.optionsPropsRef.current.hold=a},[p.optionsPropsRef,a]),lRe(p.comboboxState===0,{container:p.optionsElement,accept(L){return L.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:L.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(L){L.setAttribute("role","none")}});let T=n1([(n=p.buttonElement)==null?void 0:n.id]),O=C.useMemo(()=>({open:p.comboboxState===0,option:void 0}),[p.comboboxState]),A=yt(()=>{m.setActivationTrigger(0)}),P=yt(L=>{L.preventDefault(),m.setActivationTrigger(0)}),F=oM(g?w():{},{"aria-labelledby":T,role:"listbox","aria-multiselectable":p.mode===1?!0:void 0,id:i,ref:S,style:{...h.style,...y,"--input-width":aF(p.inputElement,!0).width,"--button-width":aF(p.buttonElement,!0).width},onWheel:p.activationTrigger===0?void 0:A,onMouseDown:P,...rRe(_)}),V=j&&p.comboboxState===1,U=Zk(V,(r=p.virtual)==null?void 0:r.options),z=Zk(V,p.value),I=yt(L=>p.compare(z,L));if(p.virtual){if(U===void 0)throw new Error("Missing `options` in virtual mode");Object.assign(h,{children:C.createElement(Qm.Provider,{value:U!==p.virtual.options?{...p,virtual:{...p.virtual,options:U}}:p},C.createElement(iIe,{slot:O},h.children))})}let B=fi();return C.createElement(eIe,{enabled:c?e.static||j:!1},C.createElement(Qm.Provider,{value:p.mode===1?p:{...p,isSelected:I}},B({ourProps:F,theirProps:{...h,children:C.createElement(ORe,{freeze:V},typeof h.children=="function"?(s=h.children)==null?void 0:s.call(h,O):h.children)},slot:O,defaultTag:pIe,features:mIe,visible:j,name:"Combobox.Options"})))}let bIe="div";function yIe(e,t){var n,r,s,o;let i=Th("Combobox.Option"),a=db("Combobox.Option"),l=C.useId(),{id:c=`headlessui-combobox-option-${l}`,value:d,disabled:f=(s=(r=(n=i.virtual)==null?void 0:n.disabled)==null?void 0:r.call(n,d))!=null?s:!1,order:h=null,...p}=e,m=gq(i.inputElement),g=i.virtual?i.activeOptionIndex===i.calculateIndex(d):i.activeOptionIndex===null?!1:((o=i.options[i.activeOptionIndex])==null?void 0:o.id)===c,b=i.isSelected(d),y=C.useRef(null),x=id({disabled:f,value:d,domRef:y,order:h}),v=C.useContext(Sq),w=Qa(t,y,v?v.measureElement:null),S=yt(()=>{a.setIsTyping(!1),a.onChange(d)});Bn(()=>a.registerOption(c,x),[x,c]);let N=C.useRef(!(i.virtual||i.__demoMode));Bn(()=>{if(!i.virtual&&!i.__demoMode)return qi().requestAnimationFrame(()=>{N.current=!0})},[i.virtual,i.__demoMode]),Bn(()=>{if(N.current&&i.comboboxState===0&&g&&i.activationTrigger!==0)return qi().requestAnimationFrame(()=>{var P,F;(F=(P=y.current)==null?void 0:P.scrollIntoView)==null||F.call(P,{block:"nearest"})})},[y,g,i.comboboxState,i.activationTrigger,i.activeOptionIndex]);let k=yt(P=>{P.preventDefault(),P.button===dM.Left&&(f||(S(),mq()||requestAnimationFrame(()=>m()),i.mode===0&&a.closeCombobox()))}),j=yt(()=>{if(f)return a.goToOption(ir.Nothing);let P=i.calculateIndex(d);a.goToOption(ir.Specific,P)}),_=eRe(),D=yt(P=>_.update(P)),M=yt(P=>{if(!_.wasMoved(P)||f||g)return;let F=i.calculateIndex(d);a.goToOption(ir.Specific,F,0)}),T=yt(P=>{_.wasMoved(P)&&(f||g&&(i.optionsPropsRef.current.hold||a.goToOption(ir.Nothing)))}),O=C.useMemo(()=>({active:g,focus:g,selected:b,disabled:f}),[g,b,f]),A={id:c,ref:w,role:"option",tabIndex:f===!0?void 0:-1,"aria-disabled":f===!0?!0:void 0,"aria-selected":b,disabled:void 0,onMouseDown:k,onFocus:j,onPointerEnter:D,onMouseEnter:D,onPointerMove:M,onMouseMove:M,onPointerLeave:T,onMouseLeave:T};return fi()({ourProps:A,theirProps:p,slot:O,defaultTag:bIe,name:"Combobox.Option"})}let xIe=hi(cIe),Cq=hi(hIe),Nq=hi(dIe),vIe=bTe,kq=hi(gIe),Eq=hi(yIe),wIe=Object.assign(xIe,{Input:Nq,Button:Cq,Label:vIe,Options:kq,Option:Eq});function SIe({elementId:e}){const t=C.useRef(!1);return C.useEffect(()=>{if(t.current)return;const n=document.getElementById(e);return n&&(n.classList.add("semaphor-scope"),t.current=!0),()=>{n&&(n.classList.remove("semaphor-scope"),t.current=!1)}},[e]),null}const CIe=C.memo(({option:e,currentStyle:t})=>u.jsxs(Eq,{style:{borderRadius:t==null?void 0:t.controlInputRadius},value:e,className:"group flex cursor-default select-none items-start gap-2 rounded-sm px-3 py-1.5 data-[focus]:bg-muted",children:[u.jsx(_r,{className:"invisible size-4 shrink-0 group-data-[selected]:visible"}),e.value]},e.id),(e,t)=>e.option.id===t.option.id&&e.option.value===t.option.value);function NIe({options:e,onChange:t,selectedOptions:n,multiple:r=!0,externalFilteredOptions:s,selectAllChecked:o,onSelectAllCheckedChange:i,inputClassName:a,renderFilterModeButton:l,showNegativeIndicator:c}){const[d,f]=C.useState(""),h=te(x=>x.themeStyle),p=C.useMemo(()=>{const x=s||e;return d===""?x:x==null?void 0:x.filter(v=>v!=null&&v.value?String(v.value).toLowerCase().includes(d==null?void 0:d.toLowerCase()):!1)},[e,s,d]);function m(x){return x!=null&&x.length?x==null?void 0:x.map(v=>v.value).join(", "):""}function g(x){Array.isArray(x)||(x=[x]),t(x)}function b(){return p&&p.length>0?null:u.jsx("div",{className:"relative cursor-default select-none px-4 py-2",children:"No records found."})}function y(){return!r||!(p!=null&&p.length)?null:u.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-b-muted px-4 py-2",children:[l==null?void 0:l(),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{children:"All"}),u.jsx(gn,{className:"border-muted-foreground/50",checked:o,onCheckedChange:i})]})]})}return u.jsx(wIe,{multiple:r,value:n,onChange:g,onClose:()=>f(""),children:({open:x})=>u.jsxs("div",{children:[u.jsxs("div",{className:"relative flex items-center gap-0.5",children:[c&&u.jsx("div",{className:"h-8 w-0.5 bg-red-400"}),u.jsx(Nq,{className:K("h-8 w-full rounded-sm border border-border bg-background py-1.5 pl-3 pr-8 text-sm","data-[focus]:outline-border-none focus:outline-none data-[focus]:outline-none data-[focus]:-outline-offset-2",a),style:{borderRadius:h==null?void 0:h.controlInputRadius},displayValue:m,onChange:v=>f(v.target.value)}),u.jsx(Cq,{className:"group absolute inset-y-0 right-0 px-2.5",children:u.jsx(js,{className:"size-4 text-muted-foreground hover:text-foreground"})})]}),u.jsxs(kq,{anchor:"bottom",transition:!0,style:{borderRadius:h==null?void 0:h.controlInputRadius},className:Su("mt-1 !max-h-60 w-[var(--input-width)] overflow-y-auto rounded-sm border border-border bg-background p-1 text-sm [--anchor-gap:var(--spacing-1)] empty:invisible","transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"),children:[x&&u.jsx(SIe,{elementId:"headlessui-portal-root"}),b(),y(),p==null?void 0:p.map(v=>u.jsx(CIe,{option:v,currentStyle:h},v.id))]})]})})}function kIe({filter:e}){const t=te(f=>f.themeStyle),{filteredRecords:n,isSingleSelect:r,allSelected:s,handleChange:o,handleSelectAll:i,isLoading:a,isFetching:l,isError:c,selectedRecords:d}=nM(e);return a||l?u.jsx(Ia,{style:{borderRadius:t==null?void 0:t.controlInputRadius},className:"h-8 w-full bg-foreground/10"}):c?u.jsx("div",{className:"flex h-8 w-full items-center bg-muted px-2 text-sm",children:"Error"}):u.jsx(NIe,{showNegativeIndicator:e.operation==="not in",renderFilterModeButton:()=>u.jsx(EIe,{filter:e}),inputClassName:"h-8",options:n,selectedOptions:d,onChange:o,multiple:!r,selectAllChecked:s,onSelectAllCheckedChange:i})}function EIe({filter:e}){const t=e.operation==="in"?"include":"exclude",{setFilterMode:n}=Qt();function r(){t==="include"?n(e.id,"exclude"):n(e.id,"include")}return u.jsx(ie,{onClick:r,variant:"secondary",size:"sm",className:K("h-6 text-xs hover:underline",{}),children:kv(t)})}function jIe({filter:e}){var o;const{filteredRecords:t,handleChange:n,selectedRecords:r}=nM(e);function s(i){n([{value:i,id:i}])}return u.jsx(ni,{onValueChange:s,value:((o=r==null?void 0:r[0])==null?void 0:o.value)||"",className:"mt-2 flex gap-3 overflow-x-auto",children:t==null?void 0:t.map(i=>u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Wn,{value:i.value,id:"r1"}),u.jsx(ae,{className:"text-muted-foreground",htmlFor:"r1",children:i.value})]},i.value))})}function hM({filter:e}){return Yu(e.dataType)?u.jsx(xMe,{filter:e}):e.uiType==="radio"&&e.type==="single"?u.jsx(jIe,{filter:e}):u.jsx(kIe,{filter:e})}function _Ie({frame:e}){const[t,n]=C.useState(!1),r=e==null?void 0:e.cards[0],{data:s,isPending:o,isError:i}=Ba(r),a=e==null?void 0:e.cards[1],{data:l,isLoading:c,isFetching:d}=Ba(a);return(a==null?void 0:a.type)!=="text"?u.jsx(Zm,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}):u.jsxs(Rs,{className:K("group relative overflow-y-auto",t?"m-4":"mx-0"),children:[t?u.jsx("div",{className:"overflow-y-auto break-words p-1",children:u.jsx(Zf,{card:a,data:(l==null?void 0:l.records)||[],isLoading:!1})}):u.jsx(Zm,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}),u.jsx("div",{className:K("fixed z-10",{"invisible bottom-4 right-4 group-hover:visible":t,"right-6 top-6":!t}),children:u.jsx(ob,{disabled:c||d,className:K("h-7 p-1"),pressed:t,onPressedChange:n,"aria-label":"Toggle bold",children:t?u.jsx(cte,{className:"size-4 text-muted-foreground/70"}):u.jsx(ute,{className:"size-4 text-muted-foreground/70"})})})]})}function q0(e){return{clickFilter:Ca,drillToDetail:Dg,drillThrough:ej,drillToURL:_g,drillDown:hte,drillUp:pte,dynamicDrill:ec,inlineDrill:Mv}[e]||Ca}function ad(e){return{clickFilter:"Filter Dashboard",drillToDetail:"Show Details",drillThrough:"Navigate to Dashboard",drillToURL:"Open External Link",drillDown:"Drill Down",drillUp:"Drill Up",dynamicDrill:"Explore Field",inlineDrill:"Drill"}[e]||"Interaction"}function DIe(e,t,n,r,s){const o=q0(e.mode),i=e.label||ad(e.mode),a=MIe(e,t,n,r,s);return{label:i,icon:o,targetInfo:a,interaction:e}}function MIe(e,t,n=0,r,s){var o,i,a,l,c,d;switch(e.mode){case"clickFilter":{if((o=e.applyToCardIds)!=null&&o.length){const f=e.applyToCardIds.length;return`Apply to ${f} ${f===1?"card":"cards"}`}return(i=e.excludeCardIds)!=null&&i.length?"Apply to all cards":"Apply to other cards"}case"drillToDetail":{if(e.targetInsightId)return"Drill into Insight";const f=((a=e.detailFields)==null?void 0:a.length)||0;return f>0?`Show ${f} detail ${f===1?"field":"fields"}`:"Show detail table"}case"drillThrough":return e.targetDashboardId,"Navigate to dashboard";case"drillToURL":{if(e.urlTemplate)try{return`Open ${new URL(e.urlTemplate).hostname}`}catch{return"Open external link"}return"Open external link"}case"drillDown":{if(e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){let h;if((f.type==="date"||f.baseField)&&r&&f.baseField){const p=OE(f,r,s),m=PE(f,p);h=m==null?void 0:m.field}else h=(l=f.steps[n])==null?void 0:l.field;return h?h.label:n>=f.steps.length?"End of path":f.label||"Drill by hierarchy"}}return"Drill to next level"}case"drillUp":{if(n>0&&e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){const h=(c=f.steps[n-2])==null?void 0:c.field;return h?`Back to ${h.label}`:`Back to All: ${f.label||"Data"}`}}return"Go back one level"}case"dynamicDrill":{if(e.drillField)return`Drill into ${e.drillField.label} data`;if((d=e.availableFields)!=null&&d.length){const f=e.availableFields.length;return`Choose from ${f} ${f===1?"dimension":"dimensions"}`}return"Explore dimension"}case"inlineDrill":{const f=e.inlineLimit||100,h=e.displayMode||"table";return`Show ${f} records as ${h}`}default:return""}}function TIe(e,t,n,r,s){return e.map(o=>DIe(o,t,n,r,s))}function RIe({open:e,onOpenChange:t,position:n,interactions:r,selectedConditions:s,onSelectInteraction:o,drillHierarchies:i,cardId:a,card:l}){const{currentDepth:c,breadcrumbs:d}=Kt(w=>{var S,N,k;return{currentDepth:a?((N=(S=w.interactionStates[a])==null?void 0:S.breadcrumbs)==null?void 0:N.length)??0:0,breadcrumbs:a?((k=w.interactionStates[a])==null?void 0:k.breadcrumbs)??[]:[]}}),f=E.useMemo(()=>TIe(r,i,c,l,d),[r,i,c,l,d]),h=E.useMemo(()=>{if(s.length===0)return"";const w=s[0];if(w.label){const S=w.label.split(/[=><]/);if(S.length>1)return S[1].trim()}return String(w.value)},[s]);if(E.useEffect(()=>{if(!e)return;const w=S=>{S.key==="Escape"&&t(!1)};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[e,t]),!e||!n)return null;const p=280,m=80+f.length*60,g=window.innerWidth,b=window.innerHeight;let y=n.x,x=n.y+8;y+p>g&&(y=Math.max(8,g-p-8)),x+m>b&&(x=Math.max(8,n.y-m-8));const v=u.jsxs("div",{className:"semaphor-scope",style:{position:"fixed",inset:0,pointerEvents:"none",background:"transparent"},children:[u.jsx("div",{className:"fixed inset-0",style:{zIndex:50,pointerEvents:"auto",background:"transparent"},onClick:()=>t(!1),"aria-hidden":"true"}),u.jsxs("div",{className:K("fixed rounded-lg border bg-popover shadow-lg","animate-in fade-in-0 zoom-in-95"),style:{left:`${y}px`,top:`${x}px`,zIndex:51,width:`${p}px`,maxHeight:"400px",pointerEvents:"auto"},role:"menu","aria-label":"Select interaction",children:[h&&u.jsxs("div",{className:"border-b px-4 py-3",children:[u.jsx("p",{className:"text-xs text-muted-foreground",children:"Selected"}),u.jsx("p",{className:"text-sm font-medium",children:h})]}),u.jsx("div",{className:"max-h-80 overflow-y-auto py-1",children:f.map((w,S)=>{var j;const N=w.icon,k=w.interaction.mode==="dynamicDrill"&&(S===0||((j=f[S-1])==null?void 0:j.interaction.mode)!=="dynamicDrill");return u.jsxs(E.Fragment,{children:[k&&u.jsx("div",{className:"border-t px-4 py-2",children:u.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"⚡ Explore Other Fields"})}),u.jsxs("button",{className:K("flex w-full items-start gap-3 px-4 py-3","hover:bg-accent hover:text-accent-foreground","cursor-pointer transition-colors","border-b text-left last:border-b-0"),onClick:()=>{o(w.interaction),t(!1)},role:"menuitem",children:[u.jsx("div",{className:"mt-0.5 flex-shrink-0",children:u.jsx(N,{className:"h-4 w-4 text-muted-foreground"})}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"mb-1 text-sm font-medium leading-none",children:w.label}),w.targetInfo&&u.jsx("p",{className:"text-xs text-muted-foreground",children:w.targetInfo})]})]})]},S)})})]})]});return _n.createPortal(v,document.body)}function IIe(e){const t=C.useRef([]),n=C.useRef(null),r=C.useRef(null),o=_i(e.interactionConfig).some(h=>h.mode==="clickFilter"&&h.trigger!==void 0),i=Rp(h=>h.registerClearBlurCallback),a=Rp(h=>h.unregisterCard);C.useEffect(()=>{const h=()=>{r.current&&f(r.current)};return i(e.id,h),()=>{a(e.id)}},[e.id,i,a]);function l({chart:h,selectedSegments:p,storedOriginalColorsRef:m}){if(!h||!h.canvas||!h.canvas.ownerDocument){console.warn("Chart or canvas is null when trying to toggle blur segments");return}const g=h.data.datasets;m.current||(m.current=g.map((y,x)=>h.getDatasetMeta(x).data.map(w=>w.options.backgroundColor)));const b=m.current;g.forEach((y,x)=>{const v=b[x];if(p.length===0){y.backgroundColor=[...v];return}y.backgroundColor=v.map((w,S)=>p.some(k=>k.datasetIndex===x&&k.dataIndex===S)?w:c(w,.2))});try{h.update()}catch(y){console.warn("Failed to update chart during blur toggle:",y)}}function c(h,p=.2){if(h.startsWith("rgba"))return h.replace(/[\d.]+\)$/g,`${p})`);if(h.startsWith("#")){const m=parseInt(h.slice(1,3),16),g=parseInt(h.slice(3,5),16),b=parseInt(h.slice(5,7),16);return`rgba(${m}, ${g}, ${b}, ${p})`}return h}function d(h,p){var v;if(!o||!p)return;r.current=p;const m=p.getElementsAtEventForMode(h,"nearest",{intersect:!0},!0);if(!m.length)return;const{datasetIndex:g,index:b}=m[0],y={datasetIndex:g,dataIndex:b};if(((v=h.native)==null?void 0:v.shiftKey)||h.shiftKey){const w=t.current.findIndex(S=>S.datasetIndex===g&&S.dataIndex===b);w>=0?t.current.splice(w,1):t.current.push(y)}else{const w=t.current.length===1&&t.current[0].datasetIndex===g&&t.current[0].dataIndex===b;t.current=w?[]:[y]}l({chart:p,selectedSegments:t.current,storedOriginalColorsRef:n})}function f(h){h&&(t.current=[],n.current&&l({chart:h,selectedSegments:[],storedOriginalColorsRef:n}))}return{handleChartClick:d,clearBlur:f}}function AIe({resolvedCardConfig:e,card:t,records:n,chart:r,clickEvent:s}){var c,d,f,h,p,m,g,b,y,x;const o=r==null?void 0:r.getElementsAtEventForMode(s,"nearest",{intersect:!0},!0);if(!o.length)return;const i=o[0].datasetIndex,a=o[0].index,l=(d=(c=o[0].element)==null?void 0:c.$context)==null?void 0:d.raw;console.log("datasetIndex",i),console.log("clickIndex",a),console.log("value",l);try{if(!(n!=null&&n.length))return;const{keys:v}=Qn(n),{groupByColumns:w=[],pivotByColumns:S=[],metricColumns:N=[]}=e||t.config,k=j=>w.find(_=>_.label===j)||S.find(_=>_.label===j)||N.find(_=>_.label===j);if(t.type==="map"){const j=v[0],_=((h=(f=l==null?void 0:l.feature)==null?void 0:f.properties)==null?void 0:h.name)||((m=(p=l==null?void 0:l.feature)==null?void 0:p.properties)==null?void 0:m.NAME),D=k(j);return!D||_==null?void 0:{conditions:[{field:D,operator:"=",value:_}]}}if(["pie","funnel","doughnut"].includes(t.type)){const j=v[0],_=v==null?void 0:v[1+i],D=k(j),M=k(_),T=(g=n==null?void 0:n[a])==null?void 0:g[j];if(!D||T==null){console.log("no dim field or value",j,T);return}return{conditions:[{field:D,operator:"=",value:T}],metrics:M?[{field:M,value:l}]:void 0}}if(["stackedBar","bar","line"].includes(t.type)){const j=v[0],_=k(j),D=(b=n==null?void 0:n[a])==null?void 0:b[j];if(!_||D==null){console.log("no dim field or value for stacked bar",j,D);return}const M=N[i]||N[0];if(!M){console.log("no metric field found");return}const T=S[0],A=Object.keys(n[0]).filter(U=>U!==j)[i],F=(A?(y=n==null?void 0:n[a])==null?void 0:y[A]:(x=n==null?void 0:n[a])==null?void 0:x[M.label])??l,V=[{field:_,operator:"=",value:D}];return T&&A&&V.push({field:T,operator:"=",value:A}),{conditions:V,metrics:[{field:M,value:F}]}}}catch(v){console.error("getClickContextFromChart error",v)}}function PIe(e){return e&&typeof e=="object"&&"field"in e&&"operator"in e}function OIe(e){return e&&typeof e=="object"&&"filterId"in e&&"operation"in e&&"values"in e}function jq({filters:e,filterDefinitions:t,contextMode:n,className:r,showLabel:s=!0,labelText:o="Applied Filters:",icon:i}){if(!e||e.length===0)return n==="none"?u.jsx("div",{className:"px-6 pb-4",children:u.jsx("span",{className:"text-xs text-muted-foreground",children:"No filters applied"})}):null;const l=e.map(c=>{var d,f;if(PIe(c))return{fieldName:((d=c.field)==null?void 0:d.label)||((f=c.field)==null?void 0:f.name)||"Unknown",operator:c.operator,value:$Ie(c)};if(OIe(c)){const h=t==null?void 0:t.find(p=>p.id===c.filterId);return{fieldName:(h==null?void 0:h.title)||c.name,operator:c.operation,value:FIe(c)}}else return{fieldName:"Unknown",operator:"=",value:String(c)}}).reduce((c,d)=>(c[d.fieldName]||(c[d.fieldName]=[]),c[d.fieldName].push(d),c),{});return u.jsxs("div",{className:r||"px-6 pb-4 border-b",children:[u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s&&i&&u.jsxs("div",{className:"flex items-center gap-2 text-foreground/80",children:[i,u.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:o})]}),s&&!i&&u.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:o}),u.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(l).map(([c,d])=>u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsxs("span",{className:"text-sm font-medium",children:[c,":"]}),d.map((f,h)=>u.jsx(jt,{variant:"secondary",className:"border border-primary/20 bg-primary/10 text-primary",children:f.value},`${c}-${h}`))]},c))})]}),n&&u.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[n==="interactionFilters"&&u.jsx("span",{children:"Showing data filtered by interaction only"}),n==="full"&&u.jsx("span",{children:"Showing data with all dashboard filters + interaction filters"}),n==="none"&&u.jsx("span",{children:"Showing all data (no filters applied)"})]})]})}function FIe(e){const{values:t,operation:n}=e;return!t||t.length===0?"":n==="="||n==="!="||n===">"||n==="<"||n===">="||n==="<="?String(t[0]):n==="in"||n==="not in"?t.map(r=>String(r)).join(", "):(n==="between"||n==="not between")&&t.length===2?`${t[0]} - ${t[1]}`:String(t[0])}function $Ie(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`between ${n[0]} and ${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not between ${n[0]} and ${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function LIe({cardId:e,className:t}){const n=Kt(d=>d.interactionStates[e]),r=Kt(d=>d.popInteractionStep),s=Kt(d=>d.resetInteractionState),o=(n==null?void 0:n.breadcrumbs)??[];if(n==null||n.hierarchyId,o.length===0)return null;const i=d=>{const f=o.length-d-1;for(let h=0;h<f;h++)r(e)},a=()=>{s(e)},l=d=>(d.sourceFilterGroups[0],d.toField?d.toField.label||d.toField.name:"Drill Step"),c=d=>{const f=d.sourceFilterGroups.flatMap(h=>h.filters);return u.jsxs("div",{className:"max-w-xs space-y-2 text-sm",children:[f.length>0&&u.jsx(jq,{filters:f,className:"pb-2",labelText:"Drill Down Filters:",icon:u.jsx(gte,{className:"h-4 w-4 text-foreground/80"})}),d.granularity&&u.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[u.jsx(to,{className:"h-4 w-4 text-foreground/80"}),u.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Granularity: ",d.granularity]})]}),d.metric&&u.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[u.jsx(nte,{className:"h-4 w-4 text-foreground/80"}),u.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Value:"," ",d.metric.formattedValue||d.metric.value]})]})]})};return u.jsx(si,{children:u.jsxs("div",{className:K("flex items-center gap-1 text-sm",t),children:[u.jsx(qr,{children:u.jsx(Yr,{asChild:!0,children:u.jsx("button",{className:"flex items-center p-0 text-muted-foreground hover:text-foreground",onClick:a,"aria-label":"Reset drill path",children:u.jsx(D$,{className:"h-3.5 w-3.5"})})})}),u.jsx(La,{className:"ml-0.5 h-3 w-3 text-muted-foreground"}),u.jsx("div",{className:"flex items-center",children:o.map((d,f)=>u.jsxs("div",{className:"flex items-center",children:[f>0&&u.jsx(La,{className:"mx-1 h-3 w-3 text-muted-foreground"}),u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(ie,{variant:"link",size:"sm",className:"h-6 px-1 text-muted-foreground no-underline hover:text-foreground hover:no-underline",onClick:()=>i(f),"aria-label":`Go back to: ${l(d)}`,children:l(d)})}),u.jsx(KD,{className:"ml-4",side:"bottom",children:c(d)})]})]},f))})]})})}function zIe(e){switch(e){case"content-only":return{showHeader:!1,showTitle:!1,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"print":return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showTableToolbar:!1,showColumnSettings:!1};case"embed":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!0,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"table-print":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showPagination:!1,showTableToolbar:!1,showColumnSettings:!1};case"full":default:return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!0,showFooter:!0,showFilters:!0,showBreadcrumbs:!0,showRefreshIndicator:!0,showFilterInfo:!0}}}function pM({children:e,displayPreferences:t={mode:"full"},currentUser:n}){const r=C.useMemo(()=>{const s=t.mode||"full",o=zIe(s),i=ez(n||null),a={mode:s,overrides:{...o,...i,...t.overrides}};return{displayPreferences:a,shouldShowElement:c=>{var d;return((d=a.overrides)==null?void 0:d[c])??!0}}},[t,n]);return u.jsx(Z6.Provider,{value:r,children:e})}function CF({card:e,frame:t}){var ne,oe,de,le,ke,ye,Pe,Ve,lt;const{customCards:n,placeholders:r,tokenProps:s}=Ye(),{shouldShowElement:o}=nc(),i=Kt(ue=>ue.interactionStates[e.id]),a=((ne=i==null?void 0:i.breadcrumbs)==null?void 0:ne.length)>0,l=te(ue=>ue.themeStyle),c=te(ue=>ue.selectedSheetId),d=te(ue=>ue.isDashboardEditing);te(ue=>ue.selectedLensId);const f=te(ue=>ue.dashboard.filters),h=f==null?void 0:f.find(ue=>ue.id===t.filterId&&!ue.hide),{setCardTitle:p,setCardDescription:m,setSelectedFrameId:g,updateFilter:b}=Qt(),{updateFrame:y}=Qt(),{handleChartClick:x}=IIe(e),v=o("showHeader")&&(((oe=e.customCardPreferences)==null?void 0:oe.showCardHeader)??!0),{isError:w,isLoading:S,isFetching:N,cfg:k,isPending:j,data:_,handleDatapointClick:D,pagination:M}=Wg(e),[T,O]=C.useState({open:!1,position:null,interactions:[],context:null}),{breadcrumbs:A,hierarchyId:P}=Kt(ue=>{var Ne,Je;return{breadcrumbs:((Ne=ue.interactionStates[e.id])==null?void 0:Ne.breadcrumbs)??[],hierarchyId:(Je=ue.interactionStates[e.id])==null?void 0:Je.hierarchyId}}),F=(ue,Ne,Je)=>{var Oe;const We=A.length>0?[{mode:"drillUp",trigger:(Oe=ue[0])==null?void 0:Oe.trigger,label:"Drill Up",hierarchyId:P}]:[],re=[];for(const Me of ue)if(Me.mode==="dynamicDrill"&&Me.availableFields){const nt=Me.availableFields.filter(Dt=>!A.some(ct=>{var Ot;return((Ot=ct.toField)==null?void 0:Ot.id)===Dt.id}));for(const Dt of nt)re.push({mode:"dynamicDrill",trigger:Me.trigger,drillField:Dt,label:Dt.label,availableFields:Me.availableFields})}const fe=ue.filter(Me=>Me.mode!=="dynamicDrill"),De=[...We,...fe,...re];O({open:!0,position:Je||{x:0,y:0},interactions:De,context:Ne})},{handlePointerInteraction:V,applySelectedInteraction:U}=UJ(e,F),z=b3(e),I=C.useMemo(()=>{var ue;return e.type!=="pivotTable"||!((ue=_==null?void 0:_.records)!=null&&ue.length)?null:{records:_.records,columnSubtotalMeta:_.columnSubtotalMeta,subtotalColumns:_.subtotalColumns||[],pivotSchema:_.pivotSchema||[],groupByColumns:_.groupByColumns}},[e.type,_==null?void 0:_.records,_==null?void 0:_.columnSubtotalMeta,_==null?void 0:_.subtotalColumns,_==null?void 0:_.pivotSchema,_==null?void 0:_.groupByColumns]),B=Ch(e,I),L=(ue,Ne)=>{const Je={...e,paginationConfig:{page:ue+1,pageSize:Ne}},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)};function R(ue,Ne){ue.stopPropagation();const Je=AIe({resolvedCardConfig:z,card:e,records:(_==null?void 0:_.records)||[],chart:Ne,clickEvent:ue.nativeEvent});if(!Je)return;const We=_i(e.interactionConfig),re=FE(We,Je),fe=re.length===1&&re[0].mode==="clickFilter",De=re.some(nt=>nt.mode==="dynamicDrill"),Oe=re.length>1||De;ue.button===0&&fe&&!Oe&&x(ue.nativeEvent,Ne);const Me={shift:ue.shiftKey,ctrl:ue.ctrlKey,meta:ue.metaKey};ue.button===0?V({context:Je,gesture:"leftClick",modifierKeys:Me,position:{x:ue.clientX,y:ue.clientY}}):ue.button===2&&V({context:Je,gesture:"rightClick",modifierKeys:Me,position:{x:ue.clientX,y:ue.clientY}})}function W(){var ue,Ne,Je;if(n&&n.length>0){const We=n.find(re=>re.cardId===e.id);if(We&&We.replaceDefault){const re=We.content;if(re)return u.jsx(re,{card:e})}}if(e.type==="kpi"){if(((ue=t==null?void 0:t.cards)==null?void 0:ue.length)===1)return u.jsx(Zm,{card:e,data:w?[]:(_==null?void 0:_.records)||[],isPending:j,isError:w});if(((Ne=t==null?void 0:t.cards)==null?void 0:Ne.length)>1)return u.jsx(_Ie,{frame:t})}return e.type==="text"&&((Je=t==null?void 0:t.cards)==null?void 0:Je.length)===1?u.jsx(Rs,{className:"my-4 overflow-y-auto break-words px-4",children:u.jsx(Zf,{isLoading:S||N,card:e,data:(_==null?void 0:_.records)||[]})}):ee}function Y(){if(w)return u.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[u.jsx(Rv,{className:"size-8 text-destructive"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Error fetching data. Check your card settings."})]});if((S||N)&&e.type!=="table")return u.jsx("div",{className:"flex h-full w-full items-center justify-center",children:u.jsx(Ou,{size:"md",color:"muted","aria-label":"Loading data"})});if(_!=null&&_.records&&(_==null?void 0:_.records.length)===0)return r!=null&&r.NoRecords?u.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:r.NoRecords}):u.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[u.jsx(aj,{className:"size-8 text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"No results to display"})]});if(e.type==="table")return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Qg,{card:e,data:(_==null?void 0:_.records)||[],paginationMetadata:M,onPaginationChange:L,isLoading:S||N})});if(e.type==="pivotTable"&&B)return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(eb,{card:e,data:B.data,options:B.options,onAggregationChange:ue=>{const Ne=zk(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)},onAggregationLabelChange:ue=>{const Ne=zW(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)}})});if(e.type==="aggregateTable")return u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Ow,{card:e,data:(_==null?void 0:_.records)||[],groupByColumns:_==null?void 0:_.groupByColumns,pivotSchema:_==null?void 0:_.pivotSchema,paginationMetadata:M,onPaginationChange:L,onAggregationChange:ue=>{const Ne=zk(ue,e.config),Je={...e,config:Ne},We={...t,cards:t.cards.map(re=>re.id===e.id?Je:re)};c&&y(c,We)},isLoading:S||N})});if(e.type==="text")return u.jsx(Rs,{className:"overflow-y-auto break-words pr-2",children:u.jsx(Zf,{isLoading:S||N,card:e,data:(_==null?void 0:_.records)||[]})});if(e.type==="custom")return u.jsx(uc,{FallbackComponent:Lw,children:u.jsx(PD,{frame:t,card:e})});if(n&&n.length>0){const ue=n.find(Ne=>Ne.cardId===e.id);if(ue&&ue.content){const Ne=ue.content;return u.jsx(Ne,{card:e})}}if(k)return u.jsx(Jg,{cfg:k,onChartClick:R,onDatapointClick:D})}function Z(){if(n&&n.length>0){const ue=n.find(Ne=>Ne.cardId===e.id);if(ue&&ue.footer){const Ne=ue.footer;if(Ne)return u.jsx(Ne,{card:e})}}return null}function H(){var Je;const ue=t.cards.filter(We=>{var re;return!((re=We.tabTitle)!=null&&re.endsWith("__Header"))&&(We.displayTab===!0||We.displayTab===void 0)}),Ne=l==null?void 0:l.controlInputRadius;return u.jsx(lo,{value:t.activeCardId,className:"flex items-center justify-end gap-3",onValueChange:We=>{const re={...t,activeCardId:We};y(c,re)},children:u.jsx(Os,{style:{borderRadius:l==null?void 0:l.controlInputRadius},className:"flex-end flex h-9 flex-wrap items-center border border-border bg-background p-0",children:(Je=t.cards.filter(We=>{var re;return!((re=We.tabTitle)!=null&&re.endsWith("__Header"))&&(We.displayTab===!0||We.displayTab===void 0)}))==null?void 0:Je.map((We,re)=>u.jsx(mn,{className:K("h-full items-center rounded-none data-[state=active]:bg-muted data-[state=active]:shadow-none",{"border-r":re!==ue.length-1}),style:{borderTopLeftRadius:re===0?Ne:0,borderTopRightRadius:re===ue.length-1?Ne:0,borderBottomLeftRadius:re===0?Ne:0,borderBottomRightRadius:re===ue.length-1?Ne:0},value:We.id,children:We.tabTitle||We.title},We.id))})})}function $(){var Ne,Je,We,re;let ue=t.cards.find(fe=>fe.type==="kpi"&&fe.tabTitle===`${e.tabTitle}__Header`);return ue||(ue=t.cards.find(fe=>fe.type==="kpi"&&fe.tabTitle==="All__Header")),ue?u.jsx("div",{className:"flex items-end gap-2",children:u.jsx(fMe,{renderFilterInfo:()=>{var fe,De,Oe,Me;return o("showFilterInfo")&&((De=(fe=e.preferences)==null?void 0:fe.displayOptions)==null?void 0:De.showFilterInfo)!==!1?u.jsx(Lk,{cardId:e.id,cardFilters:(Oe=e.config)==null?void 0:Oe.filters,cardFilterCount:H0(((Me=e.config)==null?void 0:Me.filters)||null)}):null},card:ue})}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{role:"card-title-container",className:"flex h-7 items-center gap-2",children:[o("showTitle")&&u.jsx(zi,{className:K("text-base",{}),children:u.jsx(Do,{value:e.title,onSave:fe=>p(c,e.id,fe),isEditable:d,placeholder:"Add title",displayClassName:"text-base font-semibold",inputClassName:"text-base font-semibold"})}),o("showTitle")&&(d||e.info)&&u.jsx(LW,{card:e}),o("showRefreshIndicator")&&e.refreshInterval&&u.jsxs(qr,{children:[u.jsx(Yr,{className:"pr-1",children:u.jsx("div",{className:K("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":S||N})})}),u.jsx(fs,{side:"right",align:"center",children:u.jsx("p",{className:"text-xs",children:`Realtime (${e==null?void 0:e.refreshInterval})`})})]}),o("showFilterInfo")&&((Je=(Ne=e.preferences)==null?void 0:Ne.displayOptions)==null?void 0:Je.showFilterInfo)!==!1&&u.jsx(Lk,{cardId:e.id,cardFilters:(We=e.config)==null?void 0:We.filters,cardFilterCount:H0(((re=e.config)==null?void 0:re.filters)||null)})]}),u.jsxs("div",{"data-content":"card-description-and-breadcrumb",className:"flex h-6 items-center overflow-y-auto",children:[!a&&o("showDescription")&&u.jsx("div",{className:K("text-sm text-muted-foreground",{}),children:u.jsx(Do,{value:(e==null?void 0:e.description)||"",onSave:fe=>m(c,e.id,fe),isEditable:d,placeholder:"Add description",displayClassName:"text-sm text-muted-foreground",inputClassName:"text-sm"})}),a&&o("showBreadcrumbs")&&u.jsx(LIe,{cardId:e.id})]})]})}if(!e.id)return null;const q=((le=(de=e.preferences)==null?void 0:de.displayOptions)==null?void 0:le.showChrome)??!0,G=((ye=(ke=e.preferences)==null?void 0:ke.displayOptions)==null?void 0:ye.allowScroll)??!0,ee=q?u.jsxs(u.Fragment,{children:[v?u.jsx(Li,{children:u.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[u.jsx("div",{className:"flex-1 basis-0 scroll-pb-2 overflow-x-auto",role:"header-container",children:$()}),u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsx("div",{children:h&&o("showFilters")&&u.jsxs("div",{style:{borderRadius:(Ve=(Pe=l==null?void 0:l.chart)==null?void 0:Pe.options)==null?void 0:Ve.borderRadius},"data-content":"frame-filter-container",className:"flex shrink-0 items-center",children:[!Yu(h.dataType)&&u.jsx(ae,{className:"my-1 shrink-0 px-3",children:u.jsx(Do,{value:h.title||h.column,onSave:ue=>b({...h,title:ue}),isEditable:d,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),u.jsx(hM,{filter:h})]})}),t.cards.length>1&&o("showTabs")&&H()]})]})}):u.jsx("div",{className:"h-8"}),u.jsx($a,{"data-role":"card-content",className:"relative flex min-h-0 grow flex-col",children:Y()}),o("showFooter")&&u.jsx(r$,{children:Z()})]}):Y(),Q=()=>q&&G?"flex h-full flex-col":q&&!G?"flex h-full flex-col overflow-hidden":!q&&!G?"h-full":"h-full overflow-auto";return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:K(Q(),{"animate-pulse":S||N}),children:W()}),T.context&&u.jsx(RIe,{open:T.open,onOpenChange:ue=>{O(Ne=>({...Ne,open:ue}))},position:T.position,interactions:T.interactions,selectedConditions:T.context.conditions,drillHierarchies:(lt=e.interactionConfig)==null?void 0:lt.drillHierarchies,cardId:e.id,card:e,onSelectInteraction:ue=>{T.context&&U(ue,T.context),O({open:!1,position:null,interactions:[],context:null})}})]})}function _q({card:e,frame:t}){return e.displayPreferences?u.jsx(pM,{displayPreferences:e.displayPreferences,children:u.jsx(CF,{card:e,frame:t})}):u.jsx(CF,{card:e,frame:t})}function BIe({card:e,frame:t,showTitle:n=!0}){const{isError:r,isLoading:s,isFetching:o,cfg:i,data:a,pagination:l}=Wg(e),c=C.useMemo(()=>{var h;return e.type!=="pivotTable"||!((h=a==null?void 0:a.records)!=null&&h.length)?null:{records:a.records,columnSubtotalMeta:a.columnSubtotalMeta,subtotalColumns:a.subtotalColumns||[],pivotSchema:a.pivotSchema||[],groupByColumns:a.groupByColumns}},[e.type,a==null?void 0:a.records,a==null?void 0:a.columnSubtotalMeta,a==null?void 0:a.subtotalColumns,a==null?void 0:a.pivotSchema,a==null?void 0:a.groupByColumns]),d=Ch(e,c);if(s||o)return u.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[u.jsx(cs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]});if(r)return u.jsx("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:u.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load visual"})});function f(){return e.type==="kpi"?u.jsx(Zm,{card:e,data:(a==null?void 0:a.records)||[],isPending:s||o}):e.type==="table"?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Qg,{card:e,data:(a==null?void 0:a.records)||[],isLoading:s||o,paginationMetadata:l})}):e.type==="pivotTable"&&d?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(eb,{card:e,data:(a==null?void 0:a.records)||[],onAggregationChange:()=>{},onAggregationLabelChange:()=>{}})}):e.type==="aggregateTable"?u.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:u.jsx(Ow,{card:e,data:(a==null?void 0:a.records)||[],groupByColumns:a==null?void 0:a.groupByColumns,pivotSchema:a==null?void 0:a.pivotSchema,paginationMetadata:l,onAggregationChange:()=>{},isLoading:s||o})}):e.type==="text"?u.jsx(Rs,{className:"overflow-y-auto break-words pr-2",children:u.jsx(Zf,{isLoading:s||o,card:e,data:(a==null?void 0:a.records)||[]})}):e.type==="custom"?u.jsx(uc,{FallbackComponent:Lw,children:u.jsx(PD,{frame:t,card:e})}):i?u.jsx(Jg,{cfg:i,onChartClick:()=>{},onDatapointClick:()=>{}}):null}return u.jsxs("div",{className:"flex h-full w-full flex-col",children:[n&&e.title&&u.jsxs("div",{className:"border-b px-4 py-2",children:[u.jsx("h3",{className:"text-lg font-medium",children:e.title}),e.description&&u.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),u.jsx("div",{className:"min-h-0 flex-1 p-4",children:f()})]})}function Dq({insightId:e,filters:t,contextMode:n}){const{data:r,isLoading:s,isError:o,error:i}=dj(e,{enabled:!!e}),a=Kt(f=>f.setInteractionState),l=Kt(f=>f.resetInteractionState),c=C.useMemo(()=>{var h;if(!r)return null;const f=(r==null?void 0:r.frameObject)??((h=r==null?void 0:r.visual)==null?void 0:h.frameObject);if(!f)return null;if(typeof f=="string")try{return JSON.parse(f)}catch{return null}return f},[r]),d=C.useMemo(()=>{var f;return(f=c==null?void 0:c.cards)!=null&&f.length?c.activeCardId&&c.cards.find(h=>h.id===c.activeCardId)||c.cards[0]:null},[c]);return C.useEffect(()=>{if(!d)return;if(n==="none"||!(t!=null&&t.length)){const m={...Wo(),contextMode:n};a(d.id,m);return}const h={sourceCardId:"drill-to-insight",interactionMode:"clickFilter",filterGroups:[{filters:t}],applyToCardIds:[d.id]},p={...Wo(),appliedClickFilters:[h],contextMode:n};return a(d.id,p),()=>{l(d.id)}},[d,t,n,a,l]),s?u.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[u.jsx(cs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]}):o?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:[u.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load insight"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:i instanceof Error?i.message:"Unknown error"})]}):!c||!d?u.jsx("div",{className:"flex items-center justify-center p-12",children:u.jsx("p",{className:"text-sm text-muted-foreground",children:"This insight has no visual data to display"})}):u.jsx("div",{className:"h-full w-full",children:u.jsx(BIe,{card:d,frame:c,showTitle:!1})})}function VIe({filters:e,contextMode:t}){if(!e||e.length===0)return t==="none"?u.jsxs(jt,{variant:"outline",className:"gap-1 whitespace-nowrap",children:[u.jsx(Ca,{className:"h-3 w-3"}),"No filters"]}):null;const n=e.reduce((s,o)=>{var a,l;const i=((a=o.field)==null?void 0:a.label)||((l=o.field)==null?void 0:l.name)||"Unknown";return s[i]||(s[i]=[]),s[i].push(o),s},{});e.length;const r=Object.keys(n).length;return u.jsx(si,{children:u.jsxs(qr,{delayDuration:200,children:[u.jsx(Yr,{asChild:!0,children:u.jsxs(jt,{variant:"secondary",className:"cursor-help gap-1 whitespace-nowrap border border-blue-500/20 bg-blue-500/10 text-blue-700 dark:text-blue-300",children:[u.jsx(Ca,{className:"h-3 w-3"}),r," ",r===1?"filter":"filters"]})}),u.jsx(fs,{side:"bottom",align:"start",className:"max-w-md",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"text-sm font-medium",children:"Applied Filters"}),u.jsx("div",{className:"space-y-1.5",children:Object.entries(n).map(([s,o])=>u.jsxs("div",{className:"text-xs",children:[u.jsxs("span",{className:"font-medium",children:[s,":"]})," ",o.map((i,a)=>u.jsxs("span",{children:[HIe(i),a<o.length-1?", ":""]},a))]},s))}),t&&u.jsx("div",{className:"border-t pt-2 text-xs text-muted-foreground",children:UIe(t)})]})})]})})}function HIe(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`${n[0]}-${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not ${n[0]}-${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function UIe(e){switch(e){case"filters":case"interactionFilters":return"Showing data filtered by interaction only";case"full":return"Showing data with all dashboard filters + interaction filters";case"none":return"Showing all data (no filters applied)"}}function Mq(e,t={}){const{enabled:n=!0}=t,{data:r}=dj(e,{enabled:n&&!!e});return C.useMemo(()=>{var l,c;if(!r)return{title:"",description:void 0};const o=(r==null?void 0:r.frameObject)??((l=r==null?void 0:r.visual)==null?void 0:l.frameObject);if(!o)return{title:"",description:void 0};let i=null;if(typeof o=="string")try{i=JSON.parse(o)}catch{return{title:"",description:void 0}}else i=o;if(!((c=i==null?void 0:i.cards)!=null&&c.length))return{title:"",description:void 0};const a=i.activeCardId&&i.cards.find(d=>d.id===i.activeCardId)||i.cards[0];return{title:a.title,description:a.description}},[r])}function WIe({cardId:e,children:t}){const n=Kt(o=>o.replacedCards[e]),r=Kt(o=>o.restoreCard),s=Mq((n==null?void 0:n.insightId)||"",{enabled:!!(n!=null&&n.insightId)});return n?u.jsxs("div",{className:"flex h-full w-full flex-col",children:[u.jsxs("div",{className:"border-b bg-muted/30",children:[u.jsx("div",{className:"flex items-baseline gap-2 px-5 pb-2 pt-4",children:s.title&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"truncate text-sm font-semibold",children:s.title}),s.description&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-muted-foreground",children:"-"}),u.jsx("span",{className:"truncate text-xs text-muted-foreground",children:s.description})]})]})}),u.jsxs("div",{className:"flex items-center gap-3 px-4 pb-2",children:[u.jsxs(ie,{variant:"ghost",size:"sm",onClick:()=>r(e),className:"flex-shrink-0 gap-1",children:[u.jsx(o$,{className:"h-4 w-4"}),"Back"]}),u.jsx(VIe,{filters:n.filters,contextMode:n.contextMode})]})]}),u.jsx("div",{className:"min-h-0 flex-1",children:u.jsx(Dq,{insightId:n.insightId,filters:n.filters,contextMode:n.contextMode})})]}):u.jsx(u.Fragment,{children:t})}function qIe({frame:e,footer:t,className:n,...r}){var w,S;const s=C.useRef(null),[o,i]=C.useState(!1),a=te(N=>N.themeStyle),l=te(N=>N.isVisualEditing),c=te(N=>N.selectedFrameId),d=te(N=>N.isDashboardEditing),{setSelectedFrameId:f}=Qt(),{clearSelectedVisual:h}=Eg(),{setSelectedConnectionId:p,setSelectedDatabaseName:m,setSelectedSchemaName:g,setSelectedTableName:b,setCard:y}=Gr();C.useEffect(()=>{if(c===e.id&&d&&!l){const N=s==null?void 0:s.current;N==null||N.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[c,e.id,d,l,s]);const x=e.cards.find(N=>N.id===e.activeCardId);function v(N){N.stopPropagation(),f(e.id),h(),x&&y(x),x!=null&&x.connectionId&&p(x==null?void 0:x.connectionId),x!=null&&x.lastSelectedDatabase&&m(x==null?void 0:x.lastSelectedDatabase),x!=null&&x.lastSelectedSchema&&g(x==null?void 0:x.lastSelectedSchema),x!=null&&x.lastSelectedTable&&b(x==null?void 0:x.lastSelectedTable)}return u.jsx(uc,{FallbackComponent:OD,children:u.jsxs("div",{tabIndex:-1,ref:s,role:"card-frame","data-frame-id":e.id,"data-active-card-id":x==null?void 0:x.id,onClick:v,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{borderRadius:a==null?void 0:a.cardBorderRadius},className:K("relative flex h-full flex-col rounded-sm border bg-background shadow-sm",{"border-dashed border-foreground/50":c===e.id&&d},a==null?void 0:a.dashboardCard,n,"semaphor-card-frame"),...r,children:[(d||((S=(w=x==null?void 0:x.preferences)==null?void 0:w.displayOptions)==null?void 0:S.showCardToolbar)!==!1)&&u.jsx(vW,{frame:e,isHovered:o}),x&&u.jsx(WIe,{cardId:x.id,children:u.jsx(_q,{card:x,frame:e},x.id)})]})})}function YIe({label:e,onCheckedChange:t,checked:n}){return u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(gn,{onCheckedChange:t,id:"terms",checked:n}),u.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:e})]})}function mM(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,o;for(o=0;o<r.length;o++)s=r[o],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var GIe=["color"],ZIe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,GIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),KIe=["color"],Tq=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,KIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),XIe=["color"],QIe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=mM(e,XIe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))});function eh({text:e,className:t}){const[n,r]=C.useState(!1);return u.jsx(ie,{className:K("h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",t),variant:"ghost",size:"icon",onClick:()=>{navigator.clipboard.writeText(e),r(!0),setTimeout(()=>{r(!1)},1e3)},children:n?u.jsx(Tq,{className:"size-3.5"}):u.jsx(JE,{className:"size-3.5"})})}function JIe({filter:e,onUpdate:t}){const[n,r]=C.useState(""),s=te(y=>y.dashboard.sheets)||[],o=C.useMemo(()=>{const y=[];return s==null||s.forEach(x=>{var v;(v=x.frames)==null||v.forEach(w=>{var S;(S=w.cards)==null||S.forEach(N=>{y.push({...N,sheetId:x.id,sheetTitle:x.title||x.id})})})}),y},[s]),i=()=>e.applyToSheetIds!==void 0?"specific-sheets":e.excludeSheetIds!==void 0?"all-except-specific":"all-sheets",a=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",l=y=>{const x={};switch(y){case"all-sheets":x.applyToSheetIds=void 0,x.excludeSheetIds=void 0;break;case"specific-sheets":x.applyToSheetIds=[],x.excludeSheetIds=void 0;break;case"all-except-specific":x.applyToSheetIds=void 0,x.excludeSheetIds=[];break}t(x)},c=y=>{const x={};switch(y){case"all-cards":x.applyToCardIds=void 0,x.excludeCardIds=void 0;break;case"specific-cards":x.applyToCardIds=[],x.excludeCardIds=void 0;break;case"all-except-specific":x.applyToCardIds=void 0,x.excludeCardIds=[];break}t(x)},d=(y,x)=>{if(x==="specific-sheets"){const v=e.applyToSheetIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({applyToSheetIds:w})}else if(x==="all-except-specific"){const v=e.excludeSheetIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({excludeSheetIds:w})}},f=(y,x)=>{if(x==="specific-cards"){const v=e.applyToCardIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({applyToCardIds:w})}else if(x==="all-except-specific"){const v=e.excludeCardIds||[],w=v.includes(y)?v.filter(S=>S!==y):[...v,y];t({excludeCardIds:w})}},h=()=>{const y=i();return y==="specific-sheets"?e.applyToSheetIds||[]:y==="all-except-specific"?(s==null?void 0:s.filter(x=>{var v;return!((v=e.excludeSheetIds)!=null&&v.includes(x.id))}).map(x=>x.id))||[]:(s==null?void 0:s.map(x=>x.id))||[]},p=C.useMemo(()=>{const y=h();return o.filter(x=>y.includes(x.sheetId))},[o,e.applyToSheetIds,e.excludeSheetIds]),m=C.useMemo(()=>{if(!n.trim())return p;const y=n.toLowerCase();return p.filter(x=>{var v;return(v=x==null?void 0:x.title)==null?void 0:v.toLowerCase().includes(y)})},[n,p]),g=i(),b=a();return u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Sheet Scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Which sheets should display this filter?"})]}),u.jsxs(ni,{value:g,onValueChange:y=>l(y),className:"space-y-3",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-sheets",id:"all-sheets",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-sheets",className:"cursor-pointer text-sm font-medium",children:"All sheets"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Display filter on all sheets (",(s==null?void 0:s.length)||0," sheets)"]})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-sheets",id:"specific-sheets",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-sheets",className:"cursor-pointer text-sm font-medium",children:"Only specific sheets"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on selected sheets only"})]})]}),g==="specific-sheets"&&u.jsx("div",{className:"ml-7 space-y-2",children:u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:s==null?void 0:s.map(y=>{const x=(e.applyToSheetIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`sheet-${y.id}`,checked:x,onCheckedChange:()=>d(y.id,"specific-sheets")}),u.jsx(ae,{htmlFor:`sheet-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title||y.id})]},y.id)})})}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-sheets-except",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-sheets-except",className:"cursor-pointer text-sm font-medium",children:"All sheets except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on all sheets except selected ones"})]})]}),g==="all-except-specific"&&u.jsx("div",{className:"ml-7 space-y-2",children:u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:s==null?void 0:s.map(y=>{const x=(e.excludeSheetIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`sheet-exclude-${y.id}`,checked:x,onCheckedChange:()=>d(y.id,"all-except-specific")}),u.jsx(ae,{htmlFor:`sheet-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title||y.id})]},y.id)})})})]})]}),u.jsxs("div",{className:"space-y-3 border-t pt-4",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Card Scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Which cards should receive this filter?"})]}),u.jsxs(ni,{value:b,onValueChange:y=>c(y),className:"space-y-3",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Apply filter to all cards in applicable sheets (",p.length," cards)"]})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),b==="specific-cards"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:m.length>0?m.map(y=>{const x=(e.applyToCardIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-${y.id}`,checked:x,onCheckedChange:()=>f(y.id,"specific-cards")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),u.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):u.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-cards-except",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards-except",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards except selected ones"})]})]}),b==="all-except-specific"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:m.length>0?m.map(y=>{const x=(e.excludeCardIds||[]).includes(y.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-exclude-${y.id}`,checked:x,onCheckedChange:()=>f(y.id,"all-except-specific")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),u.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):u.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]})]})]}),u.jsx("div",{className:"rounded-md bg-blue-50 p-3 text-xs text-blue-900 dark:bg-blue-950 dark:text-blue-100",children:"ℹ️ Cards are filtered based on sheet scope selection. Only cards from applicable sheets are shown in card scope."})]})}function eAe({filter:e}){const[t,n]=C.useState(e.sql),[r,s]=C.useState(!1),[o,i]=C.useState({}),[a,l]=C.useState(e.title||""),[c,d]=C.useState(e.column),f=te(y=>y.selectedSheetId),{updateFilter:h}=Qt();function p(){const y=a.trim(),x=c.trim(),v={sql:t,...o},w=x||e.column;x&&x!==e.column&&(v.column=w),v.title=y||w;const S={...e,...v};h(S),i({}),s(!1)}C.useEffect(()=>{r&&(i({}),n(e.sql),l(e.title===e.column?"":e.title||""),d(e.column))},[r,e.sql,e.title,e.column]);function m(y){const x={...e,type:y};h(x)}function g(y){const x={...e,uiType:y};h(x)}function b(y){if(!f)return;const x={...e,sheetId:y?f:void 0};h(x)}return u.jsxs(Ds,{open:r,onOpenChange:s,children:[u.jsx(Ms,{children:u.jsx(ou,{className:"invisible h-3 w-3 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),u.jsx(Ts,{onMouseDown:y=>y.stopPropagation(),onDoubleClick:y=>y.stopPropagation(),className:"z-50 m-2 h-[600px] w-[500px] overflow-hidden",children:u.jsxs("div",{className:"flex h-full flex-col",children:[u.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[u.jsx("h4",{className:"font-medium leading-none",title:e.column,children:e.column.split(".").pop()}),u.jsx(jt,{variant:"secondary",className:"flex-shrink-0 text-xs font-normal",children:e.dataType})]}),u.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Customize filter settings and scope"}),u.jsxs(lo,{defaultValue:"scope",className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[u.jsxs(Os,{className:"grid w-full flex-shrink-0 grid-cols-2",children:[u.jsx(mn,{value:"scope",children:"Scope"}),u.jsx(mn,{value:"advanced",children:"Configuration"})]}),u.jsx(lr,{value:"scope",className:"mt-4 flex-1 overflow-y-auto",children:u.jsx(JIe,{filter:{...e,...o},onUpdate:y=>{i(x=>({...x,...y}))}})}),u.jsxs(lr,{value:"advanced",className:"mt-4 flex-1 space-y-5 overflow-y-auto",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Custom Title (optional)"}),u.jsx(si,{children:u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),u.jsx(fs,{side:"right",className:"max-w-xs",children:u.jsxs("div",{className:"space-y-2",children:[u.jsx("p",{className:"text-xs",children:"Leave empty to use the column name. Provide a custom title to override it."}),u.jsxs("div",{className:"space-y-1 border-t pt-2",children:[u.jsx("p",{className:"text-xs font-medium",children:"Filter ID"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.id}),u.jsx(eh,{text:e.id})]})]})]})})]})})]}),u.jsx(pr,{value:a,onChange:y=>l(y.target.value),placeholder:e.column,className:"h-8 text-sm"})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Column Name"}),u.jsx(pr,{value:c,onChange:y=>d(y.target.value),placeholder:"Enter column name",className:"h-8 font-mono text-xs"})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Selection Type"}),u.jsxs(ni,{onValueChange:m,value:e.type||"multiple",className:"flex gap-4",children:[u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"multiple",id:"r1"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"r1",children:"Multiple"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"single",id:"r2"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"r2",children:"Single"})]})]})]}),e.type==="single"&&u.jsxs("div",{className:"space-y-3",children:[u.jsx(ae,{className:"text-sm font-medium",children:"UI Component"}),u.jsxs(ni,{onValueChange:g,value:e.uiType||"dropdown",className:"flex gap-4",children:[u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"dropdown",id:"dropdown"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"dropdown",children:"Dropdown"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Wn,{value:"radio",id:"radio"}),u.jsx("label",{className:"cursor-pointer text-sm",htmlFor:"radio",children:"Radio"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"SQL"}),u.jsx(si,{children:u.jsxs(qr,{delayDuration:0,children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),u.jsx(fs,{side:"right",className:"max-w-xs",children:u.jsx("p",{className:"text-xs",children:"This SQL will be used to fetch the filter values"})})]})})]}),u.jsx(ch,{onKeyDown:y=>{y.stopPropagation()},value:t,onChange:y=>n(y.target.value),className:`h-32 w-full resize-none break-all font-mono text-xs ${Kd}`,placeholder:"SELECT column FROM table..."})]}),u.jsx("div",{className:"border-t pt-2",children:u.jsx(YIe,{label:"Local to sheet",onCheckedChange:b,checked:!!e.sheetId})})]})]}),u.jsx("div",{className:"mt-3 flex justify-end gap-2 border-t pt-3",children:u.jsxs(ie,{onClick:p,size:"sm",variant:"outline",children:[u.jsx(_r,{className:"mr-2 size-4"}),"Accept"]})})]})})]})}const Rq=C.createContext(void 0);function fb(){const e=C.useContext(Rq);return e||{preferences:{},isLocalDev:!1,isConsoleMode:!1}}function Iq({filter:e}){var c;const t=te(d=>d.isDashboardEditing),{preferences:n}=fb(),r=((c=n==null?void 0:n.cardDisplay)==null?void 0:c.mode)==="print",s=te(d=>d.filterValues),o=s==null?void 0:s.some(d=>d.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:l}=Qt();return u.jsxs("div",{className:"group mb-1 flex h-5 items-center justify-between",children:[u.jsxs("div",{className:"flex grow items-center gap-2",children:[u.jsx(ae,{className:"my-1 inline-block text-sm",children:u.jsx(Do,{value:e.title||e.column,onSave:d=>l({...e,title:d}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),o&&!r&&u.jsx("button",{onClick:()=>i(e.id),className:"text-muted-foreground",children:u.jsx(lte,{className:"size-3.5"})}),t&&u.jsx("button",{className:"invisible group-hover:visible",onClick:()=>{l({...e,hide:!e.hide})},children:e.hide?u.jsx(oh,{className:"size-3.5 text-muted-foreground hover:text-foreground"}):u.jsx(Dv,{className:"size-3.5 text-muted-foreground hover:text-foreground"})}),t&&u.jsx(eAe,{filter:e})]}),u.jsx("div",{className:"flex items-center gap-2",children:t&&u.jsx(Xt,{onClick:()=>{i(e.id),a(e.id)},className:"size-3 cursor-pointer text-muted-foreground hover:cursor-pointer hover:text-foreground"})})]})}function Aq(){var g;const e=te(b=>b.isDashboardEditing),t=te(b=>b.selectedSheetId),n=te(b=>b.dashboard),r=n==null?void 0:n.sheets,s=r==null?void 0:r.find(b=>b.id===t),o=Ae(b=>b.card),i=Ae(b=>b.selectedConnectionId),{addFrame:a,setSelectedFrameId:l,setIsVisualEditing:c}=Qt(),{setFrame:d,setCard:f,setActiveTabCardId:h}=Gr();function p(){var v,w;const b=o==null?void 0:o.dataSource;if(b)return b;const y=(w=(v=n==null?void 0:n.aiContext)==null?void 0:v.selectedEntities)==null?void 0:w[0],x=y==null?void 0:y.type;if(y)return{connectionId:y.connectionId,connectionType:y.connectionType,type:x,selectedEntities:[y]}}function m(b){const y=(b==null?void 0:b.sheetId)||t,x=r==null?void 0:r.find(k=>k.id===y);if(!x){console.warn("Cannot add frame: No sheet found");return}if(!(!x.frames||x.frames.length===0)&&!e){console.warn("Cannot add frame: Dashboard not in editing mode");return}const w=p(),S={id:wr(),title:"Title",type:"bar",connectionId:i||"",dataSource:w,preferences:{onClickFilter:[{columnIndex:0,expression:""}]},sql:"",data:[]},N={id:wr(),cards:[S],activeCardId:S.id};return y&&(a(y,N),l(N.id)),b!=null&&b.openVisualEditor&&(d(N),f(S),h(S.id),c(!0)),N}return{handleAddNewFrame:m,canAddFrame:e||!((g=s==null?void 0:s.frames)!=null&&g.length)}}function tAe({sheetId:e}){const{handleAddNewFrame:t}=Aq(),n=te(s=>s.themeStyle),r=()=>{t({openVisualEditor:!0,sheetId:e})};return u.jsx("div",{className:"flex h-full min-h-[400px] items-start justify-start p-4",children:u.jsxs("button",{onClick:r,style:{borderRadius:n==null?void 0:n.cardBorderRadius},className:"group flex h-96 w-[600px] flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed border-muted-foreground/25 bg-background transition-all hover:border-muted-foreground/50 hover:bg-muted/50",children:[u.jsx("div",{className:"rounded-full bg-primary/10 p-3 transition-colors group-hover:bg-primary/20",children:u.jsx(gr,{className:"h-6 w-6 text-primary"})}),u.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Add new Visual"})]})})}function Y0(e){const t=(e||"").toLowerCase(),n=Jl(t);return n==="string"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-blue-100 text-xs text-blue-700 dark:bg-blue-950 dark:text-blue-300",children:u.jsx(B$,{className:"h-3 w-3"})}):n==="number"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-green-100 text-xs text-green-700 dark:bg-green-950 dark:text-green-300",children:u.jsx(_$,{className:"h-3 w-3"})}):n==="date"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-purple-100 text-xs text-purple-700 dark:bg-purple-950 dark:text-purple-300",children:u.jsx(to,{className:"h-3 w-3"})}):n==="boolean"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-orange-100 text-xs text-orange-700 dark:bg-orange-950 dark:text-orange-300",children:u.jsx(L$,{className:"h-3 w-3"})}):n==="json"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-gray-100 text-xs text-gray-700 dark:bg-gray-950 dark:text-gray-300",children:u.jsx(w$,{className:"h-3 w-3"})}):n==="geo"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-orange-100 text-xs text-orange-700 dark:bg-orange-950 dark:text-orange-300",children:u.jsx(dte,{className:"h-3 w-3"})}):n==="calculated"?u.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-gray-100 text-xs text-gray-700 dark:bg-gray-950 dark:text-gray-300",children:u.jsx(l$,{className:"h-3 w-3"})}):null}function nAe({value:e,onChange:t,metrics:n,attributes:r}){const s=(o,i)=>(e==null?void 0:e.field.id)===o.id&&(e==null?void 0:e.type)===i;return u.jsx(si,{children:u.jsxs("div",{className:"space-y-4",children:[n.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Metric"}),u.jsxs(qr,{children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 text-muted-foreground"})}),u.jsxs(fs,{className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures intersection of all dimensions"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: Clicking a bar segment in "Sales by Country, stacked by State" captures both Country='USA' AND State='California'`})]})]})]}),u.jsx("div",{className:"space-y-1",children:n.map(o=>{const i=s(o,"metric");return u.jsxs(ie,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"metric",field:o}),children:[i&&u.jsx(_r,{className:"mr-2 h-4 w-4"}),Y0(o.dataType),u.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),r.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Attribute"}),u.jsxs(qr,{children:[u.jsx(Yr,{asChild:!0,children:u.jsx(Bi,{className:"h-3.5 w-3.5 text-muted-foreground"})}),u.jsxs(fs,{className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures only this dimension"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: If configured on "State", clicking a bar in "Sales by Country, stacked by State" captures only State='California' (Country is not included)`})]})]})]}),u.jsx("div",{className:"space-y-1",children:r.map(o=>{const i=s(o,"attribute");return u.jsxs(ie,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"attribute",field:o}),children:[i&&u.jsx(_r,{className:"mr-2 h-4 w-4"}),Y0(o.dataType),u.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),n.length===0&&r.length===0&&u.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No metrics or attributes available in this chart"})]})})}const NF=[{value:"clickFilter",label:"Cross filter",description:"Filter other cards on the dashboard"},{value:"drillDown",label:"Drill down",description:"Navigate through a hierarchy of dimensions"},{value:"dynamicDrill",label:"Explore dimensions",description:"Let users explore any dimension dynamically"},{value:"drillThrough",label:"Drill into dashboard",description:"Navigate to another dashboard"},{value:"drillToDetail",label:"Drill into insight",description:"Navigate to a saved insight"},{value:"drillToURL",label:"Drill into URL",description:"Navigate to a custom URL"}];function rAe({value:e,onChange:t}){const n=NF.find(r=>r.value===e);return u.jsx("div",{className:"space-y-2",children:u.jsxs(pt,{value:e,onValueChange:t,children:[u.jsx(dt,{className:"w-full",children:u.jsx(bt,{placeholder:"Choose action...",children:n&&u.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const r=q0(n.value);return u.jsx(r,{className:"h-4 w-4"})})(),u.jsx("span",{children:n.label})]})})}),u.jsx(ft,{children:NF.map(r=>{const s=q0(r.value);return u.jsx(be,{value:r.value,children:u.jsxs("div",{className:"flex items-start gap-2 py-1",children:[u.jsx(s,{className:"mt-0.5 h-4 w-4 shrink-0"}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:r.label}),u.jsx("span",{className:"text-xs text-muted-foreground",children:r.description})]})]})},r.value)})})]})})}function sAe({interaction:e,onUpdate:t}){const[n,r]=C.useState(""),s=E3(),o=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",i=d=>{const f={};switch(d){case"all-cards":f.applyToCardIds=void 0,f.excludeCardIds=void 0;break;case"specific-cards":f.applyToCardIds=[],f.excludeCardIds=void 0;break;case"all-except-specific":f.applyToCardIds=void 0,f.excludeCardIds=[];break}t({...e,...f})},a=(d,f)=>{if(f==="specific-cards"){const h=e.applyToCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,applyToCardIds:p})}else if(f==="all-except-specific"){const h=e.excludeCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,excludeCardIds:p})}},l=C.useMemo(()=>{if(!n.trim())return s;const d=n.toLowerCase();return s==null?void 0:s.filter(f=>{var h;return(h=f==null?void 0:f.title)==null?void 0:h.toLowerCase().includes(d)})},[n,s]),c=o();return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Filter scope"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),u.jsxs(ni,{value:c,onValueChange:d=>i(d),className:"space-y-2",children:[u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),c==="specific-cards"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Cards to filter"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.applyToCardIds||[]).includes(d.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"specific-cards")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&u.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):u.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]}),u.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[u.jsx(Wn,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),u.jsxs("div",{className:"flex-1 space-y-1",children:[u.jsx(ae,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),c==="all-except-specific"&&u.jsxs("div",{className:"ml-7 space-y-2",children:[u.jsxs("div",{className:"space-y-0.5",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Cards to exclude"}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),u.jsx(bn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),u.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.excludeCardIds||[]).includes(d.id);return u.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[u.jsx(gn,{id:`card-exclude-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"all-except-specific")}),u.jsxs("div",{className:"flex-1",children:[u.jsx(ae,{htmlFor:`card-exclude-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&u.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):u.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(ae,{className:"text-sm font-medium",children:"Menu label"}),u.jsx(bn,{value:e.label||"",onChange:d=>t({...e,label:d.target.value}),placeholder:ad(e.mode)}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}var gM="Collapsible",[oAe,Pq]=yr(gM),[iAe,bM]=oAe(gM),Oq=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...a}=e,[l=!1,c]=Mr({prop:r,defaultProp:s,onChange:i});return u.jsx(iAe,{scope:n,disabled:o,contentId:Gn(),open:l,onOpenToggle:E.useCallback(()=>c(d=>!d),[c]),children:u.jsx(Re.div,{"data-state":wM(l),"data-disabled":o?"":void 0,...a,ref:t})})});Oq.displayName=gM;var Fq="CollapsibleTrigger",yM=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,s=bM(Fq,n);return u.jsx(Re.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":wM(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:t,onClick:we(e.onClick,s.onOpenToggle)})});yM.displayName=Fq;var xM="CollapsibleContent",vM=E.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=bM(xM,e.__scopeCollapsible);return u.jsx(Zn,{present:n||s.open,children:({present:o})=>u.jsx(aAe,{...r,ref:t,present:o})})});vM.displayName=xM;var aAe=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:s,...o}=e,i=bM(xM,n),[a,l]=E.useState(r),c=E.useRef(null),d=at(t,c),f=E.useRef(0),h=f.current,p=E.useRef(0),m=p.current,g=i.open||a,b=E.useRef(g),y=E.useRef(void 0);return E.useEffect(()=>{const x=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(x)},[]),Dr(()=>{const x=c.current;if(x){y.current=y.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const v=x.getBoundingClientRect();f.current=v.height,p.current=v.width,b.current||(x.style.transitionDuration=y.current.transitionDuration,x.style.animationName=y.current.animationName),l(r)}},[i.open,r]),u.jsx(Re.div,{"data-state":wM(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&s})});function wM(e){return e?"open":"closed"}var $q=Oq,lAe=yM,cAe=vM;const zu=$q,Bu=yM,Vu=vM;function uAe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return C.useMemo(()=>r=>{t.forEach(s=>s(r))},t)}const s1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Rh(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function SM(e){return"nodeType"in e}function hs(e){var t,n;return e?Rh(e)?e:SM(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function CM(e){const{Document:t}=hs(e);return e instanceof t}function hb(e){return Rh(e)?!1:e instanceof hs(e).HTMLElement}function Lq(e){return e instanceof hs(e).SVGElement}function Ih(e){return e?Rh(e)?e.document:SM(e)?CM(e)?e:hb(e)||Lq(e)?e.ownerDocument:document:document:document}const ii=s1?C.useLayoutEffect:C.useEffect;function o1(e){const t=C.useRef(e);return ii(()=>{t.current=e}),C.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}function dAe(){const e=C.useRef(null),t=C.useCallback((r,s)=>{e.current=setInterval(r,s)},[]),n=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Jm(e,t){t===void 0&&(t=[e]);const n=C.useRef(e);return ii(()=>{n.current!==e&&(n.current=e)},t),n}function pb(e,t){const n=C.useRef();return C.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function G0(e){const t=o1(e),n=C.useRef(null),r=C.useCallback(s=>{s!==n.current&&(t==null||t(s,n.current)),n.current=s},[]);return[n,r]}function Z0(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let VC={};function mb(e,t){return C.useMemo(()=>{if(t)return t;const n=VC[e]==null?0:VC[e]+1;return VC[e]=n,e+"-"+n},[e,t])}function zq(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((o,i)=>{const a=Object.entries(i);for(const[l,c]of a){const d=o[l];d!=null&&(o[l]=d+e*c)}return o},{...t})}}const uf=zq(1),eg=zq(-1);function fAe(e){return"clientX"in e&&"clientY"in e}function i1(e){if(!e)return!1;const{KeyboardEvent:t}=hs(e.target);return t&&e instanceof t}function hAe(e){if(!e)return!1;const{TouchEvent:t}=hs(e.target);return t&&e instanceof t}function K0(e){if(hAe(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return fAe(e)?{x:e.clientX,y:e.clientY}:null}const Yi=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Yi.Translate.toString(e),Yi.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),kF="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function pAe(e){return e.matches(kF)?e:e.querySelector(kF)}const mAe={display:"none"};function gAe(e){let{id:t,value:n}=e;return C.createElement("div",{id:t,style:mAe},n)}function bAe(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return C.createElement("div",{id:t,style:s,role:"status","aria-live":r,"aria-atomic":!0},n)}function yAe(){const[e,t]=C.useState("");return{announce:C.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Bq=C.createContext(null);function xAe(e){const t=C.useContext(Bq);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function vAe(){const[e]=C.useState(()=>new Set),t=C.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[C.useCallback(r=>{let{type:s,event:o}=r;e.forEach(i=>{var a;return(a=i[s])==null?void 0:a.call(i,o)})},[e]),t]}const wAe={draggable:`
911
911
  To pick up a draggable item, press the space bar.
912
912
  While dragging, use the arrow keys to move the item.
913
913
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-C5uHl9Yr.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-CYXXeUAg.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as a } from "../chunks/index-AVHej3yO.js";
1
+ import { D as a } from "../chunks/index-CYNeBPQZ.js";
2
2
  import { EMPTY_SELECTION as e } from "../types/index.js";
3
3
  export {
4
4
  a as Dashboard,
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-C5uHl9Yr.js"),v=require("./types/index.cjs"),u=require("./chunks/dashboard-plus-45AVY9lA.js"),a=require("react/jsx-runtime"),x=require("react");require("react-dom");function j(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}return t.default=r,Object.freeze(t)}const p=j(x);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-CYXXeUAg.js"),v=require("./types/index.cjs"),u=require("./chunks/dashboard-plus-RD3AkRH7.js"),a=require("react/jsx-runtime"),x=require("react");require("react-dom");function j(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}return t.default=r,Object.freeze(t)}const p=j(x);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { c as x, E as v, F as N, S as w, U as A, a as L, C as _, u as E, b as g, d as P, P as k, e as W, B as F, f as M, g as R, h as V, i as B, j as O, I as Q, k as I, l as j, m as q, n as U, o as z } from "./chunks/index-AVHej3yO.js";
2
- import { D as ne, t as ie, R as de, r as le, r as ce, $ as Ye, K as ue, w as he, y as pe, M as fe, L as me, Q as Me, T as Ce, J as De, v as ge, H as ve, N as ye, G as be, A as Te, z as Se, V as xe, O as Ne, s as we, X as Ae, Z as Le, Y as _e, _ as Ee, x as Pe, p as ke, a1 as We, W as Fe, a0 as Re, q as Ve } from "./chunks/index-AVHej3yO.js";
1
+ import { c as x, E as v, F as N, S as w, U as A, a as L, C as _, u as E, b as g, d as P, P as k, e as W, B as F, f as M, g as R, h as V, i as B, j as O, I as Q, k as I, l as j, m as q, n as U, o as z } from "./chunks/index-CYNeBPQZ.js";
2
+ import { D as ne, t as ie, R as de, r as le, r as ce, $ as Ye, K as ue, w as he, y as pe, M as fe, L as me, Q as Me, T as Ce, J as De, v as ge, H as ve, N as ye, G as be, A as Te, z as Se, V as xe, O as Ne, s as we, X as Ae, Z as Le, Y as _e, _ as Ee, x as Pe, p as ke, a1 as We, W as Fe, a0 as Re, q as Ve } from "./chunks/index-CYNeBPQZ.js";
3
3
  import { EMPTY_SELECTION as Oe } from "./types/index.js";
4
- import { A as Ie, R as je, b as qe, S as Ue, D as ze, a as Ge, V as He, c as $e, g as Ke } from "./chunks/dashboard-plus-BEXIVqFK.js";
4
+ import { A as Ie, R as je, b as qe, S as Ue, D as ze, a as Ge, V as He, c as $e, g as Ke } from "./chunks/dashboard-plus-B_xxD7g2.js";
5
5
  import { jsx as e, jsxs as d } from "react/jsx-runtime";
6
6
  import * as h from "react";
7
7
  import { useMemo as G } from "react";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/dashboard-plus-45AVY9lA.js"),r=require("../types/index.cjs");exports.Surfboard=e.DashboardPlus;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/dashboard-plus-RD3AkRH7.js"),r=require("../types/index.cjs");exports.Surfboard=e.DashboardPlus;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as f } from "../chunks/dashboard-plus-BEXIVqFK.js";
1
+ import { D as f } from "../chunks/dashboard-plus-B_xxD7g2.js";
2
2
  import { EMPTY_SELECTION as a } from "../types/index.js";
3
3
  export {
4
4
  a as EMPTY_SELECTION,
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.44",
8
+ "version": "0.1.45",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",